/** {@inheritdoc} */ public function showFront(Curry_Twig_Template $template = null) { if (is_array($this->languages) && count($this->languages)) { // allowed languages $allowedLanguages = array(); foreach ($this->languages as $lang) { $allowedLanguages[$lang['code']] = $lang; } // find preferred language reset($this->languages); $language = current($this->languages); foreach ($this->getLanguage() as $lang => $quality) { if (array_key_exists($lang, $allowedLanguages)) { $language = $allowedLanguages[$lang]; break; } } $page = PageQuery::create()->findPk($language['page_id']); if ($page) { url($page->getUrl(), $_GET)->redirect(); } else { Curry_Core::log('Redirect page not found', Zend_Log::WARN); } } else { Curry_Core::log('No languages found', Zend_Log::WARN); } return ''; }
/** {@inheritdoc} */ public function showFront(Template $template = null) { if (is_array($this->languages) && count($this->languages)) { // allowed languages $allowedLanguages = array(); foreach ($this->languages as $lang) { $allowedLanguages[$lang['code']] = $lang; } // find preferred language reset($this->languages); $language = current($this->languages); foreach ($this->getLanguage() as $lang => $quality) { if (array_key_exists($lang, $allowedLanguages)) { $language = $allowedLanguages[$lang]; break; } } $page = \PageQuery::create()->findPk($language['page_id']); if ($page) { return RedirectResponse::create(url($page->getUrl(), $_GET)); } else { $this->app->logger->notice('Redirect page not found'); } } else { $this->app->logger->notice('No languages found'); } return ''; }
/** __construct() * @param object Newsletter * @param array recipients mixed string email / object * @param boolean $bRequiresUnsubsribeLink * @param string sender email * @param string sender name * * @return void */ public function __construct($oNewsletter, $aRecipients, $bRequiresUnsubsribeLink, $sSenderEmailAddress, $sSenderName = null) { if ($oNewsletter === null) { throw new Exception('Error in' . __METHOD__ . ': requires a Newsletter object, null given'); } // Prepare sender email and name $this->aRecipients = $aRecipients; $this->oNewsletter = $oNewsletter; $this->sSenderEmailAddress = $sSenderEmailAddress; if ($sSenderName !== null) { $this->sSenderName = $sSenderName; } else { $this->sSenderName = Settings::getSetting('newsletter', 'sender_name', "Rapila Newsletter Plugin"); } if ($bRequiresUnsubsribeLink) { // Unsubscribe page is required, a page that contains a content object NewsletterFrontendModule $this->oUnsubscribePage = PageQuery::create()->findOneByIdentifier(Settings::getSetting('newsletter', 'unsubscribe_page', 'unsubscribe')); if ($this->oUnsubscribePage === null) { // Fallback: try searching the page by name $this->oUnsubscribePage = PageQuery::create()->findOneByName(Settings::getSetting('newsletter', 'unsubscribe_page', 'unsubscribe')); if ($this->oUnsubscribePage === null) { throw new LocalizedException('newsletter.unsubscriber_page_required_error', array('method' => "NewsletterMailer::__construct()")); } } } }
/** {@inheritdoc} */ public function render($content) { $element = $this->getElement(); $view = $element->getView(); if (null === $view) { return $content; } $placement = $this->getPlacement(); $separator = $this->getSeparator(); $attr = array('onchange' => '$(this).prev().val(this.value.split("|")[1]); this.selectedIndex = 0;'); $options = array('' => 'Select page...'); foreach (PageQuery::create()->orderByBranch()->find() as $page) { if (Curry_Backend_Page::isTemplatePage($page)) { continue; } $options[$page->getPageId() . '|' . $page->getUrl()] = str_repeat(Curry_Core::SELECT_TREE_PREFIX, $page->getLevel()) . $page->getName(); } $options = Curry_Html::createSelectOptions($options, ''); $markup = Curry_Html::createTag('select', $attr, $options); switch ($placement) { case 'PREPEND': $content = $markup . $separator . $content; break; case 'APPEND': default: $content = $content . $separator . $markup; } return $content; }
public function setObjectId($iObjectId) { if ($this->oInternalWidget instanceof RichTextWidgetModule) { $oContentObject = ContentObjectQuery::create()->findPk($iObjectId); $oPage = PageQuery::create()->filterByContentObject($oContentObject)->findOne(); $this->oInternalWidget->setTemplate($oPage->getTemplateNameUsed()); } }
public static function getLastUpdatedTimestamp() { $oPage = PageQuery::create()->orderByUdatedAt(Criteria::DESC)->findOne(); if ($oPage) { return $oPage->getUpdatedAtTimestamp(); } return 0; }
public function setPageType($sPageType, $iPageId, $sLanguageId = null) { $this->sPageType = $sPageType; $oPage = PageQuery::create()->findPk($iPageId); if ($oPage === null) { throw new Exception("Invalid Page ID: {$iPageId}"); } $this->oPageType = PageTypeModule::getModuleInstance($sPageType, PageQuery::create()->findPk($iPageId), null, $sLanguageId); }
private function setLinkPage() { $this->oPage = FrontendManager::$CURRENT_PAGE; if ($this->oPage->getIdentifier() !== 'documentation-page') { $this->oPage = PageQuery::create()->filterByIdentifier('documentation-page')->active()->findOne(); if ($this->oPage === null) { throw new Exception('Error in ' . __METHOD__ . ': page with page-identifier «documentation-page» required'); } } }
public function __construct($sSessionKey = null) { parent::__construct($sSessionKey); $oRichtextWidget = WidgetModule::getWidget('rich_text', null, '', 'newsletter'); $oNewsletterPage = PageQuery::create()->findOneByIdentifier('newsletter'); if ($oNewsletterPage) { $oRichtextWidget->setTemplate($oNewsletterPage->getTemplate()); } $this->setSetting('rich_text_session', $oRichtextWidget->getSessionKey()); }
public function getLinkArray($oPage = null) { if ($oPage === null) { $oPage = PageQuery::create()->filterByIdentifier(DocumentationFilterModule::PARENT_PAGE_IDENTIFIER)->active()->findOne(); } if ($oPage === null) { return null; } return $oPage->getFullPathArray(array($this->getKey())); }
public function showPage(Request $request, $view) { $page = \PageQuery::create()->findPk($view['id']); $this->addBreadcrumb('Pages', $view->parent->url()); $this->addBreadcrumb($page->getName(), $view->url()); $this->addMenuContent($this->menu); $this->addMainContent($page->getName()); $form = new \Curry\Form\Form(array('fields' => array('test' => array('type' => 'text')))); $this->addMainContent($form->render()); return $this->render(); }
public function adminSave($aChosenOptions) { ArrayUtil::trimStringsInArray($aChosenOptions); $sValue = $aChosenOptions['external']; if (!$aChosenOptions['external']) { $sValue = $aChosenOptions['internal']; //TODO: remove outdated references (and when changing page types) ReferencePeer::addReference($this->oPage, PageQuery::create()->findPk($sValue)); } $this->oPage->updatePageProperty('redirect-location', $sValue); }
private function addPartLink($oPart) { if (!self::$DOCUMENTATION_PAGE) { self::$DOCUMENTATION_PAGE = PageQuery::create()->filterByIdentifier(DocumentationFilterModule::PARENT_PAGE_IDENTIFIER)->findOne(); } if (!self::$DOCUMENTATION_PAGE) { return; } $sLink = LinkUtil::absoluteLink(LinkUtil::link(array_merge(self::$DOCUMENTATION_PAGE->getFullPathArray(), array($oPart->getDocumentation()->getKey())), 'FrontendManager'), null, 'auto'); return TagWriter::quickTag('a', array('target' => 'documentation', 'href' => $sLink . '#' . $oPart->getKey()), $oPart->getName()); }
/** * Find model from URL. * * @param string $url * @return string|null */ protected static function findPageModel($url) { if (self::$urlToModel === null) { $cacheName = __CLASS__ . '_' . 'UrlToModel'; if ((self::$urlToModel = Curry_Core::$cache->load($cacheName)) === false) { self::$urlToModel = PageQuery::create()->filterByModelRoute(null, Criteria::ISNOTNULL)->find()->toKeyValue('Url', 'ModelRoute'); Curry_Core::$cache->save(self::$urlToModel, $cacheName); } } return isset(self::$urlToModel[$url]) ? self::$urlToModel[$url] : null; }
/** {@inheritdoc} */ public function showMain() { if (!Curry_Core::$config->curry->liveEdit) { $this->addMessage('Live edit is not enabled, go to <a href="' . url('', array('module' => 'Curry_Backend_System')) . '">System Settings</a> to enable it.', Curry_Backend::MSG_WARNING, false); return; } $page = false; if (isset($_GET['page_id'])) { $page = PageQuery::create()->findOneByPageId($_GET['page_id']); } $this->showPage($page ? $page->getUrl() : '/'); }
public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); if ($exception instanceof NotFoundHttpException) { // we don't need to explicitly set 404 status, HttpKernel will do this for us. if ($this->app['errorPage.notFound'] && ($page = \PageQuery::create()->findPk($this->app['errorPage.notFound']))) { $generator = AbstractGenerator::create($this->app, $page->getActivePageRevision()); $event->setResponse($generator->render()); } else { $event->setResponse(new Response('Page not found')); } } }
public function filterByParentAndName($sName, $mParent, $mCurrentToExclude = null) { if (!$mParent instanceof Page) { $mParent = PageQuery::create()->findPk($mParent); } $this->filterByName($sName)->childrenOf($mParent); if ($mCurrentToExclude !== null) { if ($mCurrentToExclude instanceof Page) { $mCurrentToExclude = $mCurrentToExclude->getId(); } $this->filterById($mCurrentToExclude, Criteria::NOT_EQUAL); } return $this; }
public function __invoke($message, $page = null) { if ($page !== null && ($page = \PageQuery::create()->findPk($page))) { // @todo set global maintenance message variable //$vars['curry']['MaintenanceMessage'] = $message; $generator = AbstractGenerator::create($this->app, $page->getActivePageRevision()); $response = $generator->render(); } else { $response = Response::create($message); } $response->setStatusCode(503); $response->headers->set('Retry-After', '3600'); return $response; }
/** * Perform routing. * * @param Curry_Request $request * @return Page|bool */ public function route(Curry_Request $request) { $requestUri = $request->getUrl()->getPath(); // add trailing slash if missing if ($requestUri && substr($requestUri, -1) != '/') { $requestUri .= '/'; } // use domain mapping to restrict page to a certain page-branch $rootPage = null; if (Curry_Core::$config->curry->domainMapping->enabled) { $currentDomain = strtolower($_SERVER['HTTP_HOST']); foreach (Curry_Core::$config->curry->domainMapping->domains as $domain) { if (strtolower($domain->domain) === $currentDomain || $domain->include_www && strtolower('www.' . $domain->domain) === $currentDomain) { $rootPage = $domain->base_page; break; } } if (!$rootPage && Curry_Core::$config->curry->domainMapping->default) { $rootPage = Curry_Core::$config->curry->domainMapping->default; } if ($rootPage) { $rootPage = PageQuery::create()->findPk($rootPage); } } // attempt to find page using url if (Curry_Core::$config->curry->pageCache) { $pages = array(); $allPages = Page::getCachedPages(); foreach ($allPages as $page) { if ($page->getUrl() == $requestUri) { if (!$rootPage || $rootPage->isAncestorOf($page) || $rootPage->getPageId() == $page->getPageId()) { $pages[] = $page; } } } } else { $pages = PageQuery::create()->filterByUrl($requestUri)->_if($rootPage)->branchOf($rootPage)->_endif()->joinWith('Page.ActivePageRevision apr', Criteria::LEFT_JOIN)->find(); } if (count($pages) > 1) { throw new Exception('URL refers to multiple pages: ' . $requestUri); } else { if (count($pages) == 1) { return $pages[0]; } } return false; }
public function postUp($manager) { foreach (PageQuery::create()->filterByPageType('journal')->find() as $oJournalPage) { $sCommentMode = $oJournalPage->getPagePropertyValue('blog_comment_mode', 'on'); $aJournalIds = explode(',', $oJournalPage->getPagePropertyValue('blog_journal_id', '')); $bCaptchaEnabled = !!$oJournalPage->getPagePropertyValue('blog_captcha_enabled', true); foreach (JournalQuery::create()->filterById($aJournalIds)->find() as $oJournal) { $oJournal->setEnableComments($sCommentMode === 'on' || $sCommentMode === 'notified'); $oJournal->setNotifyComments($sCommentMode === 'moderated' || $sCommentMode === 'notified'); $oJournal->setUseCaptcha($bCaptchaEnabled); $oJournal->save(); } $oJournalPage->updatePageProperty('blog_comment_mode', null); $oJournalPage->updatePageProperty('blog_captcha_enabled', null); } // add the post-migration code here }
public function __construct($sSessionKey = null, $oPage = null) { parent::__construct($sSessionKey); $this->oRichTextWidget = WidgetModule::getWidget('rich_text', null, null, 'journal'); if ($oPage === null) { // get any blog page in site $oPage = PageQuery::create()->filterByPageType('journal')->joinPageProperty()->useQuery('PageProperty')->filterByName('journal:journal_id')->endUse()->findOne(); } if ($oPage) { $this->oRichTextWidget->setTemplate($oPage->getTemplateNameUsed()); } $this->setSetting('richtext_session', $this->oRichTextWidget->getSessionKey()); $iJournalEntryImageCategory = Settings::getSetting('journal', 'externally_managed_images_category', null); $this->setSetting('journal_entry_images_category_id', $iJournalEntryImageCategory); $this->setSetting('date_today', date('d.m.Y')); $this->setSetting('date_format', 'dd.mm.yy'); }
public function rightFits($mPage, $sMethodName) { $oPage = $mPage; if ($mPage instanceof Page) { $mPage = $mPage->getId(); } if ($this->getPage() !== null && $mPage === $this->getPage()->getId()) { return call_user_func(array($this, $sMethodName)); } if ($this->getIsInherited() && $mPage !== null) { if (!is_object($oPage)) { $oPage = PageQuery::create()->findPk($mPage); } if ($oPage !== null && $oPage->getParent() !== null) { return $this->rightFits($oPage->getParent(), $sMethodName); } } return false; }
public function renderBackend() { $oTemplate = $this->constructTemplate('config'); // Display options $aDisplayOptions = array(); foreach (self::$DISPLAY_OPTIONS as $sDisplayMode) { $aDisplayOptions[$sDisplayMode] = TranslationPeer::getString('journal.display_mode.' . $sDisplayMode, null, StringUtil::makeReadableName($sDisplayMode)); } $oTemplate->replaceIdentifier('display_options', TagWriter::optionsFromArray($aDisplayOptions, null, null, array())); // Journal pages and journal options $aJournalOptions = array(); foreach (PageQuery::create()->filterByPageType('journal')->orderByName()->find() as $oPage) { $aJournalOptions['page' . self::PAGE_SEPARATOR . $oPage->getId()] = TranslationPeer::getString('wns.journal.journal_page_name', null, null, array('name' => $oPage->getLinkText())); } foreach (JournalQuery::create()->orderByName()->find() as $oJournal) { $aJournalOptions[$oJournal->getId()] = TranslationPeer::getString('wns.journal.journal_name', null, null, array('name' => $oJournal->getName())); } $oTemplate->replaceIdentifier('journal_options', TagWriter::optionsFromArray($aJournalOptions)); return $oTemplate; }
public function __construct($aRequestPath) { parent::__construct($aRequestPath); if (!isset($this->aPath[0])) { // Exceptions thrown in a file module’s constructor yield a UserError but that’s OK. throw new Exception("Error in DisplayDocumentFileModule->__construct: no key given"); } $this->oSession = Session::close(); $this->oDocument = DocumentQuery::create()->findPk(intval($this->aPath[0])); if ($this->oDocument === null || $this->oDocument->getIsProtected() && !$this->isAuthenticated()) { $oErrorPage = PageQuery::create()->findOneByName(Settings::getSetting('error_pages', 'not_found', 'error_404')); if ($oErrorPage) { LinkUtil::redirect(LinkUtil::link($oErrorPage->getLinkArray(), "FrontendManager")); } else { print "Not found"; exit; } } Session::close(); }
/** * Find page in map, if not found attempts to find in database. * * @param string $name * @param array $map * @return Page|null */ protected static function findPageByMap($name, $map) { if ($name) { if (isset($map[$name])) { return $map[$name]; } else { $page = PageQuery::create()->findOneByUrl($name); if (!$page) { throw new Exception('Page with url ' . $name . ' not found.'); } return $page; } } return null; }
/** * Get the associated Page object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return Page The associated Page object. * @throws PropelException */ public function getPage(PropelPDO $con = null, $doQuery = true) { if ($this->aPage === null && $this->page_id !== null && $doQuery) { $this->aPage = PageQuery::create()->findPk($this->page_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aPage->addRights($this); */ } return $this->aPage; }
/** {@inheritdoc} */ public function showMain() { $rootPage = PageQuery::create()->findRoot(); $code = Curry_Backend_PageSyncHelper::getPageCode($rootPage); $localChecksum = sha1(serialize($code)); if (isPost('fetch')) { Curry_Application::returnJson($code); } $form = new Curry_Form(array('csrfCheck' => false, 'action' => (string) url('', $_GET), 'method' => 'post', 'elements' => array('url' => array('text', array('label' => 'URL', 'placeholder' => 'http://example.com/admin.php', 'value' => isset($_COOKIE['curry:remote_url']) ? $_COOKIE['curry:remote_url'] : '')), 'user' => array('text', array('label' => 'User', 'value' => isset($_COOKIE['curry:remote_user']) ? $_COOKIE['curry:remote_user'] : '******')), 'password' => array('password', array('label' => 'Password', 'value' => '')), 'submit' => array('submit', array('class' => 'btn btn-primary', 'label' => 'Fetch'))))); if (isPost('code')) { // we have page-code if ($localChecksum !== $_POST['local_checksum']) { throw new Exception('Local pages were changed during synchronization process, aborting!'); } $remoteCode = json_decode($_POST['code'], true); // Update selected pages if (isset($_POST['page'])) { $updatedPages = Curry_Backend_PageSyncHelper::restorePages($rootPage, $remoteCode, array_keys($_POST['page'])); $this->addMessage(count($updatedPages) . ' pages updated!', self::MSG_SUCCESS); } // Delete selected pages if (isset($_POST['delete'])) { $pagesToDelete = array_keys($_POST['delete']); foreach ($pagesToDelete as $pageId) { $page = PageQuery::create()->findPk($pageId); if (!$page) { throw new Exception('Unable to find page to delete.'); } if (!$page->isLeaf()) { $this->addMessage('Unable to delete page "' . $page->getName() . '" because it has subpages.', self::MSG_ERROR); continue; } $dependantPages = $page->getDependantPages(); if (count($dependantPages)) { $this->addMessage('Unable to delete page "' . $page->getName() . '" because other pages depend on it.', self::MSG_ERROR); continue; } $page->delete(); $this->addMessage('Deleted page "' . $page->getName() . '"', self::MSG_WARNING); } } } else { if (isPost() && $form->isValid($_POST)) { // have user/password try { $context = stream_context_create(array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query(array('login_username' => $form->user->getValue(), 'login_password' => $form->password->getValue(), 'fetch' => '1'))))); $remote = (string) url($form->url->getValue(), array('module' => 'Curry_Backend_PageSync')); $remoteResponse = file_get_contents($remote, null, $context); if ($remoteResponse === false) { throw new Exception('Invalid response'); } $remoteCode = json_decode($remoteResponse, true); if ($remoteCode === null) { throw new Exception('Invalid json: ' . $remoteResponse); } setcookie('curry:remote_url', $form->url->getValue(), time() + 86400 * 365); setcookie('curry:remote_user', $form->user->getValue(), time() + 86400 * 365); $this->addMainContent('<form action="' . url('', $_GET) . '" method="post" class="well">'); $this->addMainContent('<input type="hidden" name="code" value="' . htmlspecialchars($remoteResponse) . '" />'); $this->addMainContent('<input type="hidden" name="local_checksum" value="' . htmlspecialchars($localChecksum) . '" />'); $this->addMainContent('<ul>'); $this->comparePageCode($code, $remoteCode); $this->addMainContent('</ul>'); $this->addMainContent('<button type="submit" class="btn btn-primary">Sync</button>'); $this->addMainContent('</form>'); } catch (Exception $e) { $this->addMainContent($form); $this->addMessage($e->getMessage(), self::MSG_ERROR); } } else { $this->addMainContent(self::INTRO); $this->addMainContent($form); } } }
/** * Deletes all descendants for the given node * Instance pooling is wiped out by this command, * so existing Page instances are probably invalid (except for the current one) * * @param PropelPDO $con Connection to use. * * @return int number of deleted nodes */ public function deleteDescendants(PropelPDO $con = null) { if ($this->isLeaf()) { // save one query return; } if ($con === null) { $con = Propel::getConnection(PagePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $left = $this->getLeftValue(); $right = $this->getRightValue(); $con->beginTransaction(); try { // delete descendant nodes (will empty the instance pool) $ret = PageQuery::create()->descendantsOf($this)->delete($con); // fill up the room that was used by descendants PagePeer::shiftRLValues($left - $right + 1, $right, null, $con); // fix the right value for the current node, which is now a leaf $this->setRightValue($left + 1); $con->commit(); } catch (Exception $e) { $con->rollback(); throw $e; } return $ret; }
/** * Create internal links. * The identifier value signifies the destination. It can be either a path or one of the following special values: “to_self”, “host_only”, “base_href”. * The following additional parameters are allowed: “is_absolute”, “page”, “ignore_request”, “manager” * Implicitly, the value of is_absolute determines the type of absolute link generated. * A value of “false” will not generate absolute links. * Using “auto” will determine server-side whether to use http or https for protocol. * Setting is_absolute to “http” or “https” will set the protocol accordingly. * Any other value (including “true”) will generate a protocol-relative URL (starting with //), meaning the reference is determined on the client-side. * Creating a “base_href” link will always make it absolute and not explicitly setting “is_absolute” will default to “auto” (instead of “true” as is the case with all other link types). */ public function writeLink($oTemplateIdentifier) { $sDestination = $oTemplateIdentifier->getValue(); $aParameters = $oTemplateIdentifier->getParameters(); $bIsAbsolute = false; $bAbsoluteType = $oTemplateIdentifier->getParameter('is_absolute'); if ($bAbsoluteType === 'http' || $bAbsoluteType === 'false') { $bAbsoluteType = false; } else { if ($bAbsoluteType === 'https' || $bAbsoluteType === 'true') { $bAbsoluteType = true; } else { if ($bAbsoluteType === 'auto') { $bAbsoluteType = LinkUtil::isSSL(); } else { if ($oTemplateIdentifier->hasParameter('is_absolute')) { $bAbsoluteType = null; } else { $bAbsoluteType = 'default'; } } } } unset($aParameters['is_absolute']); if ($sDestination === "to_self") { $bIgnoreRequest = $oTemplateIdentifier->getParameter('ignore_request') === 'true'; unset($aParameters['ignore_request']); $sDestination = LinkUtil::linkToSelf(null, $aParameters, $bIgnoreRequest); } else { if ($sDestination === "host_only") { return LinkUtil::absoluteLink(''); } else { if ($sDestination === "base_href") { $sDestination = MAIN_DIR_FE_PHP; $bIsAbsolute = true; if (!$oTemplateIdentifier->hasParameter('is_absolute')) { $bAbsoluteType = LinkUtil::isSSL(); } } elseif ($sPage = $oTemplateIdentifier->getParameter('page')) { $oPage = PageQuery::create()->findOneByIdentifier($sPage); if ($oPage === null) { $oPage = PageQuery::create()->findOneByName($sPage); } $sManager = 'FrontendManager'; if ($oTemplateIdentifier->hasParameter('manager')) { $sManager = $oTemplateIdentifier->getParameter('manager'); } if ($oPage) { $sDestination = LinkUtil::link($oPage->getLink(), $sManager); } } else { $sManager = null; if ($oTemplateIdentifier->hasParameter('manager')) { unset($aParameters['manager']); $sManager = $oTemplateIdentifier->getParameter('manager'); } $sDestination = LinkUtil::link($sDestination, $sManager, $aParameters); } } } return LinkUtil::absoluteLink($sDestination, null, $bAbsoluteType, !$bIsAbsolute); }
public function moveItem($iIdNew, $iIdRef, $sPosition) { $oPage = PageQuery::create()->findPk($iIdNew); $oRefPage = PageQuery::create()->findPk($iIdRef); if ($sPosition === 'first' || $sPosition === 'inside') { $oPage->moveToFirstChildOf($oRefPage); } else { if ($sPosition === 'before') { $oPage->moveToPrevSiblingOf($oRefPage); } else { if ($sPosition === 'after') { $oPage->moveToNextSiblingOf($oRefPage); } else { if ($sPosition === 'last') { $oPage->moveToLastChildOf($oRefPage); } else { return false; } } } } return true; }