/** * @param \Difra\Param\AnyInt $id */ public function pageAction(Param\AnyInt $id) { /** @var $pageNode \DOMElement */ $pageNode = $this->root->appendChild($this->xml->createElement('page')); $page = Page::get($id->val()); $page->getXML($pageNode); $this->root->setAttribute('pageTitle', $page->getTitle()); }
/** * Delete page * @param \Difra\Param\AnyInt $id * @param \Difra\Param\AjaxCheckbox $confirm */ public function deleteAjaxAction(\Difra\Param\AnyInt $id, \Difra\Param\AjaxCheckbox $confirm = null) { if ($confirm and $confirm->val()) { \Difra\Plugins\CMS\Page::get($id->val())->delete(); Ajaxer::close(); Ajaxer::redirect('/adm/content/pages'); return; } $page = \Difra\Plugins\CMS\Page::get($id->val()); Ajaxer::display('<span>' . \Difra\Locales::get('cms/adm/delete-page-confirm-1') . $page->getTitle() . \Difra\Locales::get('cms/adm/delete-page-confirm-2') . '</span>' . '<form action="/adm/content/pages/delete/' . $id . '" method="post" class="ajaxer">' . '<input type="hidden" name="confirm" value="1"/>' . '<input type="submit" value="Да"/>' . '<a href="#" onclick="ajaxer.close(this)" class="button">Нет</a>' . '</form>'); }
/** * Get menu element data as XML node * @param \DOMElement $node * @return bool */ public function getXML($node) { if (!$this->load()) { return false; } $node->setAttribute('id', $this->id); $node->setAttribute('id', $this->id); $node->setAttribute('menu', $this->menu); $node->setAttribute('parent', $this->parent); $controllerUri = Action::getControllerUri(); $uri = Envi::getUri(); $href = ''; if ($this->page) { // page if (empty($this->pageData)) { $page = Page::get($this->page); $this->pageData = ['id' => $page->getId(), 'tag' => $page->getUri(), 'hidden' => $page->getHidden(), 'title' => $page->getTitle()]; } $hidden = (!$this->visible or $this->pageData['hidden']) ? '1' : '0'; $node->setAttribute('type', 'page'); $node->setAttribute('label', $this->pageData['title']); $node->setAttribute('link', $href = $this->pageData['tag']); $node->setAttribute('hidden', $hidden); $node->setAttribute('page', $this->pageData['id']); } elseif ($this->link) { // link $node->setAttribute('type', 'link'); $node->setAttribute('label', $this->linkLabel); $node->setAttribute('link', $href = $this->link); $node->setAttribute('hidden', !$this->visible ? '1' : '0'); } else { // empty $node->setAttribute('type', 'empty'); $node->setAttribute('label', $this->linkLabel); $node->setAttribute('hidden', !$this->visible ? '1' : '0'); } if ($href) { if ($href == $uri) { $node->setAttribute('match', 'exact'); } elseif ($href == $controllerUri) { $node->setAttribute('match', 'partial'); } elseif (strpos($uri, $href) !== false) { $node->setAttribute('match', 'partial'); } } return true; }