public static function pagePropertiesForm($pageId) { $page = new \Ip\Page($pageId); $form = new \Ip\Form(); $form->setEnvironment(\Ip\Form::ENVIRONMENT_ADMIN); $field = new \Ip\Form\Field\Hidden(array('name' => 'aa', 'value' => 'Pages.updatePage')); $form->addField($field); $field = new \Ip\Form\Field\Hidden(array('name' => 'pageId', 'value' => $pageId)); $form->addField($field); $field = new \Ip\Form\Field\Text(array('name' => 'title', 'label' => __('Title', 'Ip-admin', false), 'value' => $page->getTitle())); $form->addField($field); $field = new \Ip\Form\Field\Text(array('name' => 'urlPath', 'label' => __('URL path', 'Ip-admin', false), 'value' => $page->getUrlPath())); $form->addField($field); $field = new \Ip\Form\Field\Checkbox(array('name' => 'isVisible', 'label' => __('Visible', 'Ip-admin', false), 'value' => $page->isVisible())); $form->addField($field); $layouts = \Ip\Internal\Design\Service::getLayouts(); $options = array(); foreach ($layouts as $layout) { $options[] = array($layout, $layout); } $field = new \Ip\Form\Field\Select(array('name' => 'layout', 'label' => __('Layout', 'Ip-admin', false), 'values' => $options, 'value' => $page->getLayout())); $form->addField($field); $fieldset = new \Ip\Form\Fieldset(__('Seo', 'Ip-admin', false)); $form->addFieldset($fieldset); $field = new \Ip\Form\Field\Text(array('name' => 'metaTitle', 'label' => __('Meta title', 'Ip-admin', false), 'value' => $page->getMetaTitle())); $form->addField($field); $field = new \Ip\Form\Field\Text(array('name' => 'keywords', 'label' => __('Keywords', 'Ip-admin', false), 'value' => $page->getKeywords())); $form->addField($field); $field = new \Ip\Form\Field\Textarea(array('name' => 'description', 'label' => __('Description', 'Ip-admin', false), 'value' => $page->getDescription())); $form->addField($field); $fieldset = new \Ip\Form\Fieldset(__('Other', 'Ip-admin', false)); $form->addFieldset($fieldset); $field = new \Ip\Form\Field\Url(array('name' => 'redirectUrl', 'label' => __('Redirect', 'Ip-admin', false), 'value' => $page->getRedirectUrl())); $form->addField($field); $field = new \Ip\Form\Field\Checkbox(array('name' => 'isDisabled', 'label' => __('Disabled', 'Ip-admin', false), 'value' => $page->isDisabled(), 'note' => __('Won\'t be clickable in menu if selected.', 'Ip-admin', false))); $form->addField($field); $field = new \Ip\Form\Field\Checkbox(array('name' => 'isSecured', 'label' => __('Secured', 'Ip-admin', false), 'value' => $page->isSecured(), 'note' => __('Won\'t be accessible to view even knowing the URL.', 'Ip-admin', false))); $form->addField($field); $field = new \Ip\Form\Field\Checkbox(array('name' => 'isBlank', 'label' => __('Open in new window', 'Ip-admin', false), 'value' => $page->isBlank())); $form->addField($field); $field = new \Ip\Form\Field\Text(array('name' => 'alias', 'label' => __('Alias (used in code)', 'Ip-admin', false), 'value' => $page->getAlias())); $form->addField($field); $field = new \Ip\Form\Field\Text(array('name' => 'createdAt', 'label' => __('Created on', 'Ip-admin', false), 'value' => date('Y-m-d', strtotime($page->getCreatedAt())))); $form->addField($field); $field = new \Ip\Form\Field\Text(array('name' => 'updatedAt', 'label' => __('Updated on', 'Ip-admin', false), 'value' => date('Y-m-d', strtotime($page->getUpdatedAt())))); $form->addField($field); $form = ipFilter('ipPagePropertiesForm', $form, array('pageId' => $pageId)); return $form; }
/** * Get a breadcrumb * * Gets an array of pages representing a tree path to a current page. * * @param int $pageId * @return \Ip\Page[] */ public function getBreadcrumb($pageId = null) { if ($pageId !== null) { $page = new \Ip\Page($pageId); } else { $page = ipContent()->getCurrentPage(); } if ($page) { $pages[] = $page; $parentPageId = $page->getParentId(); while (!empty($parentPageId)) { $parentPage = new \Ip\Page($parentPageId); $pages[] = $parentPage; $parentPageId = $parentPage->getParentId(); } } $breadcrumb = array(); if (!empty($pages)) { array_pop($pages); $breadcrumb = $pages; } $breadcrumb = array_reverse($breadcrumb); $breadcrumb = ipFilter('ipBreadcrumb', $breadcrumb); return $breadcrumb; }
public function savePage() { if (!isset($_POST['revisionId'])) { return $this->_errorAnswer('Missing revisionId POST variable'); } $revisionId = $_POST['revisionId']; $publish = !empty($_POST['publish']); $revision = \Ip\Internal\Revision::getRevision($revisionId); if (!$revision) { return $this->_errorAnswer('Can\'t find revision. RevisionId \'' . $revisionId . '\''); } if ($publish) { $pageOptions = array(); $pageOptions['updatedAt'] = date("Y-m-d"); $pageOptions['isVisible'] = 1; \Ip\Internal\Pages\Model::updatePageProperties($revision['pageId'], $pageOptions); } \Ip\Internal\Revision::publishRevision($revisionId); $newRevisionId = \Ip\Internal\Revision::duplicateRevision($revisionId); $page = new \Ip\Page($revision['pageId']); $data = array('status' => 'success', 'action' => '_savePageResponse', 'newRevisionId' => $newRevisionId, 'newRevisionUrl' => $page->getLink()); return new \Ip\Response\Json($data); }
public function getPageUrl() { $data = ipRequest()->getQuery(); if (!isset($data['pageId'])) { throw new \Ip\Exception("Page id is not set"); } $pageId = (int) $data['pageId']; $page = new \Ip\Page($pageId); $answer = array('pageUrl' => $page->getLink()); return new \Ip\Response\Json($answer); }
private static function arrayToMenuItem($pages, $depth, $curDepth, $order) { $items = array(); foreach ($pages as $pageRow) { $page = new \Ip\Page($pageRow['id']); $item = new Item(); $subSelected = false; if ($curDepth < $depth) { $children = ipDb()->selectAll('page', '*', array('parentId' => $page->getId(), 'isVisible' => 1, 'isSecured' => 0, 'isDeleted' => 0), "ORDER BY {$order}"); if ($children) { $childrenItems = self::arrayToMenuItem($children, $depth, $curDepth + 1, $order); $item->setChildren($childrenItems); } } if ($page->isCurrent() || $page->getRedirectUrl() && $page->getLink() == \Ip\Internal\UrlHelper::getCurrentUrl()) { $item->markAsCurrent(true); } elseif ($page->isInCurrentBreadcrumb() || $subSelected || $page->getRedirectUrl() && self::existInBreadcrumb($page->getLink())) { $item->markAsInCurrentBreadcrumb(true); } if ($page->isDisabled()) { $item->setUrl(''); } elseif ($page->getRedirectUrl()) { $url = $page->getRedirectUrl(); if (!preg_match('/^((http|https):\\/\\/)/i', $url)) { $url = 'http://' . $url; } $item->setUrl($url); } else { $item->setUrl($page->getLink()); } $metaTitle = $page->getMetaTitle(); $item->setBlank($page->isBlank()); $item->setTitle($page->getTitle()); $item->setDepth($curDepth); $item->setDisabled($page->isDisabled()); $item->setId($page->getId()); $item->setAlias($page->getAlias()); $item->setPageTitle(empty($metaTitle) ? $page->getTitle() : $metaTitle); $items[] = $item; } return $items; }