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(); $field = new \Ip\Form\Field\Select(array('name' => 'layout', 'label' => __('Layout', 'Ip-admin', false), 'values' => $layouts, '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; }
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; }