/** * Sets the canonical page path for a page. */ public function setCanonicalPagePath($cPath, $isAutoGenerated = false) { $em = \ORM::entityManager(); $path = $this->getCollectionPathObject(); if (is_object($path)) { $path->setPagePath($cPath); } else { $path = new \Concrete\Core\Entity\Page\PagePath(); $path->setPagePath($cPath); $path->setPageObject($this); } $path->setPagePathIsAutoGenerated($isAutoGenerated); $path->setPagePathIsCanonical(true); $em->persist($path); $em->flush(); }
public function submit() { $r = new PageEditResponse(); if ($this->validateAction()) { $oc = $this->page; if ($oc->getCollectionParentID() != $_POST['cParentID']) { if ($this->page->getCollectionID() == HOME_CID) { throw new Exception('You cannot move the homepage.'); } $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 (isset($canonical) && $this->page->getCollectionID() == HOME_CID) { throw new Exception('You cannot change the canonical path of the home page.'); } 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()->persist($p); } } \ORM::entityManager()->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(); } }
public function getAutoGeneratedPagePathObject() { $path = new PagePath(); $path->setPagePathIsAutoGenerated(true); //if (!$this->isHomePage()) { $path->setPagePath($this->computeCanonicalPagePath()); //} return $path; }