Admin_TemplateController::indexAction PHP Метод

indexAction() публичный Метод

public indexAction ( )
    public function indexAction()
    {
        $translator = \Zend_Registry::get('container')->getService('translator');
        $resource = new ResourceId(__CLASS__);
        $themeService = $resource->getService(IThemeService::NAME);
        // item action form
        $form = $this->getActionForm();
        $form->setMethod('post');
        $this->view->form = $form;
        try {
            // get items
            $path = $this->parsePath();
            $folders = $templates = array();
            foreach ($this->service->listItems($path) as $item) {
                $form->file->addMultioption($item->name, $item->name);
                // add possible files
                if (!isset($item->size)) {
                    $folders[] = $item;
                    continue;
                }
                if ($item->name == $themeService->themeConfigFileName) {
                    continue;
                }
                $templates[] = $item;
            }
        } catch (\InvalidArgumentException $e) {
            $this->_helper->flashMessenger(array('error', $e->getMessage()));
            $this->_helper->redirector('index');
        }
        $this->view->folders = $folders;
        $this->view->templates = $templates;
        $request = $this->getRequest();
        if ($request->isPost() && $form->isValid($_POST)) {
            $values = $form->getValues();
            $this->_forward($values['action']);
            return;
        }
        // set current path
        $this->view->path = $this->formatPath($path);
        // get parents
        $parents = explode('/', dirname($path));
        $this->view->parent = implode(self::SEPARATOR, $parents);
        // build breadcrubs for path
        $pages = array($this->buildBreadcrumbs(explode('/', $path)));
        $this->view->moveForm = $this->getMoveForm();
        if ($path == '') {
            $this->view->paths = $this->reqCachePaths;
            // don't move form here
            $this->view->doCache = true;
        }
        $this->view->nav = new Zend_Navigation($pages);
        $this->view->dateFormat = 'Y-m-d H:i';
        $this->view->separator = self::SEPARATOR;
        // redirect parameter in session
        $nextUrl = new Zend_Session_Namespace('upload-next');
        $nextUrl->setExpirationHops(7, 'next', true);
        $nextUrl->next = $this->_request->getParams();
        $this->view->actions = array(array('label' => $translator->trans('Upload', array(), 'themes'), 'module' => 'admin', 'controller' => 'template', 'action' => 'upload', 'class' => 'upload', 'reset_params' => false), array('label' => $translator->trans('Create folder', array(), 'themes'), 'uri' => '#create-folder', 'class' => 'add'), array('label' => $translator->trans('Create file', array(), 'themes'), 'uri' => '#create-file', 'class' => 'add'));
    }