/** * * @param type $pageId */ public static function getPath($pageId, $path = null) { $page = new Knowledgeroot_Page($pageId); $parent = $page->getParent(); if ($path == null) { $path = array(0 => $page); } if ($parent == 0) { // reverse sort by key krsort($path); return $path; } else { $path[] = new Knowledgeroot_Page($parent); return Knowledgeroot_Page_Path::getPath($parent, $path); } }
/** * get all contents on this page as Knowledgeroot_Content object * * @param object $page Knowledgeroot_Page object * @param string $sorting column to sort by also with ASC|DESC * return $array */ public static function getContents(Knowledgeroot_Page $page, $sorting = 'sorting') { $ret = array(); // get acl $acl = Knowledgeroot_Registry::get('acl'); $content = new Knowledgeroot_Db_Content(); $select = $content->select(); $select->where('parent = ?', $page->getId()); $select->where('deleted = ' . Knowledgeroot_Db::false()); $select->order($sorting); $rows = $content->fetchAll($select); foreach ($rows as $value) { if ($acl->iAmAllowed('content_' . $value->id, 'show')) { $ret[] = new Knowledgeroot_Content($value->id); } } return $ret; }
public function restoreAction() { // acl checks if (!Knowledgeroot_Acl::iAmAllowed('page_' . $this->_getParam('id'), 'edit')) { $this->_redirect(''); } // get page and restore version $page = new Knowledgeroot_Page($this->_getParam('id'), $this->_getParam('version')); $page->restore(); // show success message Knowledgeroot_Message::success("Page restored", "Page was restored to version " . $this->_getParam('version')); // redirect to page $this->_redirect('page/' . $page->getId()); }
public function editAction() { // check acl if (!Knowledgeroot_Acl::iAmAllowed('content_' . $this->_getParam('id'), 'edit')) { $this->_redirect('page/' . $this->_getParam('content_page')); } if ($this->getRequest()->getMethod() == 'POST') { if ($this->_getParam('button') == 'close') { $this->_redirect('page/' . $this->_getParam('content_page')); } $content = new Knowledgeroot_Content($this->_getParam('id')); $content->setName($this->_getParam('content_title')); $content->setContent($this->_getParam('content')); $content->setParent($this->_getParam('content_page')); $content->setAcl(json_decode($this->_getParam('acl'))); $content->save(); // delete existing tags $content->deleteTags(); // save tags if ($this->_getParam('content_tags') != '') { $tags = explode(",", $this->_getParam('content_tags')); foreach ($tags as $tag) { if (trim($tag) != '') { $newTag = new Knowledgeroot_Tag(); $newTag->setName(trim($tag)); $newTag->save(); $content->addTag($newTag); } } } if ($this->_getParam('button') == 'save') { $this->_redirect('content/edit/' . $content->getId()); } else { $this->_redirect('page/' . $this->_getParam('content_page') . '#content' . $content->getId()); } } else { $this->view->action = 'edit'; $this->view->id = $this->_getParam('id'); $content = new Knowledgeroot_Content($this->_getParam('id')); $rte = Knowledgeroot_Registry::get('rte'); $rte->setName('content'); $rte->setContent($content->getContent(true)); $this->view->editor = $rte; $this->view->title = $content->getName(); $this->view->tags = $content->getTags(); $this->view->page = $content->getParent(); $parent = new Knowledgeroot_Page($content->getParent()); $this->view->pagename = $parent->getName(); $this->view->created_by = $content->getCreatedBy()->getLogin(); $this->view->create_date = $content->getCreateDate()->getUserDate(); $this->view->versions = $content->getVersions(); $this->renderScript("content/content.phtml"); } }
/** * restore page version */ public function restore() { if ($this->version === null) { return; } $page = new Knowledgeroot_Page($this->getId()); // restore page $page->setName($this->getName()); $page->setDescription($this->getDescription()); $page->setAlias($this->getAlias()); $page->setIcon($this->getIcon()); $page->setSubtitle($this->getSubtitle()); $page->setTooltip($this->getTooltip()); $page->setShowContentDescription($this->getShowContentDescription()); $page->setShowTableOfContent($this->getShowTableOfContent()); $page->setContentCollapse($this->getContentCollapse()); // save $page->save(); }