/**
  * {@inheritDoc}
  */
 public function setPagePath($path)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPagePath', array($path));
     return parent::setPagePath($path);
 }
Beispiel #2
0
 public function getAutoGeneratedPagePathObject()
 {
     $path = new PagePath();
     $path->setPagePath($this->computeCanonicalPagePath());
     $path->setPagePathIsAutoGenerated(true);
     return $path;
 }
 public function submit()
 {
     $r = new PageEditResponse();
     if ($this->validateAction()) {
         $oc = $this->page;
         if ($oc->getCollectionParentID() != $_POST['cParentID']) {
             $dc = Page::getByID($_POST['cParentID'], 'RECENT');
             if (!is_object($dc) || $dc->isError()) {
                 throw new Exception('Invalid parent page.');
             }
             $dcp = new Permissions($dc);
             $ct = PageType::getByID($this->page->getPageTypeID());
             if (!$dcp->canAddSubpage($ct)) {
                 throw new Exception('You do not have permission to add this subpage here.');
             }
             if (!$oc->canMoveCopyTo($dc)) {
                 throw new Exception('You cannot add a page beneath itself.');
             }
             if ($oc->isPageDraft()) {
                 $oc->setPageDraftTargetParentPageID($dc->getCollectionID());
             } else {
                 $u = new User();
                 $pkr = new MovePagePageWorkflowRequest();
                 $pkr->setRequestedPage($oc);
                 $pkr->setRequestedTargetPage($dc);
                 $pkr->setSaveOldPagePath(false);
                 $pkr->setRequesterUserID($u->getUserID());
                 $u->unloadCollectionEdit($oc);
                 $response = $pkr->trigger();
                 if ($response instanceof WorkflowProgressResponse && !$this->request->request->get('sitemap')) {
                     $nc = Page::getByID($oc->getCollectionID());
                     $r->setRedirectURL(Loader::helper('navigation')->getLinkToCollection($nc));
                 }
             }
         }
         // now we do additional page URLs
         $req = Request::getInstance();
         $oc->clearPagePaths();
         $canonical = $req->request->get('canonical');
         $pathArray = $req->request->get('path');
         if (is_array($pathArray)) {
             foreach ($pathArray as $i => $path) {
                 $p = new PagePath();
                 $p->setPagePath($path);
                 $p->setPageObject($this->page);
                 if ($canonical == $i) {
                     $p->setPagePathIsCanonical(true);
                 }
                 \ORM::entityManager('core')->persist($p);
             }
         }
         \ORM::entityManager('core')->flush();
         $r->setTitle(t('Page Updated'));
         $r->setMessage(t('Page location information saved successfully.'));
         $r->setPage($this->page);
         $nc = Page::getByID($this->page->getCollectionID(), 'ACTIVE');
         $r->outputJSON();
     }
 }