/**
  * Edit action
  *
  * @return void
  */
 public function editAction()
 {
     $page = new Model_Page();
     $pageId = $this->_request->getParam('id', 0);
     $language = $this->_request->getParam('language', $page->getDefaultLanguage());
     $currentPage = $page->open($pageId, $language);
     // load the template and form
     $template = $page->getTemplate($pageId);
     // @todo: refactor this into some sort of helper function
     $templateParts = explode('_', $template);
     $currentTemplate = $templateParts[0];
     $currentTemplatePage = $templateParts[1];
     $templatePath = BASE_PATH . '/templates/public/' . $currentTemplate;
     $templateConfig = new Zend_Config_Xml($templatePath . '/pages/' . $currentTemplatePage . '.xml');
     $pageTemplate = new Digitalus_Interface_Template();
     $form = $pageTemplate->getForm($templatePath . '/layouts/' . $templateConfig->layout);
     $form->setAction($this->baseUrl . '/admin/page/edit');
     $this->view->contentPanes = $form->modifyEditActionForm();
     $elmPageName = $form->getElement('name');
     $elmPageName->addValidators(array(array('PagenameExistsNot', true, array('exclude' => $currentPage->page->name))));
     if (!is_object($currentPage)) {
         $url = 'admin/page';
         $e = new Digitalus_View_Error();
         $e->add($this->view->getTranslation('Sorry, there was an error opening your page'));
         $this->_redirect($url);
     }
     //process the form if this is a post back
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         unset($values['submit']);
         unset($values['form_instance']);
         $currentPage = $page->edit($values);
     } else {
         if ($currentPage->content) {
             $data = $currentPage->content;
         } else {
             $data = array();
         }
         $data['id'] = $pageId;
         $data['name'] = $currentPage->page->name;
         $data['language'] = $language;
         $form->populate($data);
     }
     $this->view->currentVersion = $language;
     $this->view->pageId = $pageId;
     //main content form
     $this->view->form = $form;
     $this->view->page = $currentPage;
     //meta data form
     $mdlMeta = new Model_MetaData();
     $metaData = $mdlMeta->asArray($pageId);
     $metaData['page_id'] = $pageId;
     $this->view->metaForm = $this->getMetaForm($metaData);
     //properties
     $mdlProperties = new Model_Properties();
     $this->view->properties = $mdlProperties->asArray($pageId);
     //related pages
     //        $this->view->relatedPages = $page->getRelatedPages($pageId);
     $label = $currentPage->page->name;
     if (isset($currentPage->page->label) && !empty($currentPage->page->label)) {
         $label = $currentPage->page->label;
     }
     $this->view->breadcrumbs[$this->view->getTranslation('Open') . ': ' . $label] = $this->baseUrl . '/admin/page/edit/id/' . $pageId;
     $this->view->toolbarLinks = array();
     $this->view->toolbarLinks['Add to my bookmarks'] = $this->baseUrl . '/admin/index/bookmark' . '/url/admin_page_edit_id_' . $pageId . '/label/' . $this->view->getTranslation('Page') . ':' . $currentPage->page->name;
     $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/admin/page/delete/id/' . $pageId;
 }