Exemplo n.º 1
0
 /**
  * check if page is accessable
  */
 public static function isAccessable($pageId)
 {
     $path = Knowledgeroot_Page_Path::getPath($pageId);
     foreach ($path as $node) {
         if ($node->isDeleted()) {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 2
0
 public function jsontreeAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     // get config
     $config = Knowledgeroot_Registry::get('config');
     // get all pages
     $pages = Knowledgeroot_Page::getPages();
     // prepare dojo json store
     $out = array('identifier' => 'id', 'label' => 'name', 'items' => array());
     if (count($pages) > 0) {
         foreach ($pages as $key => $page) {
             // check for broken parentId to itself
             if ($page->getId() == $page->getParent()) {
                 continue;
             }
             // check if page is accessable
             if (!Knowledgeroot_Page_Path::isAccessable($page->getId())) {
                 continue;
             }
             $item = array('id' => $page->getId(), 'parent' => $page->getParent() != 0 ? $page->getParent() : '#', 'url' => $config->base->base_url . 'page/' . $page->getId(), 'text' => $page->getName(), 'type' => $page->getParent() == 0 ? 'root' : 'page', 'tooltip' => $page->getTooltip(), 'alias' => $config->alias->enable && $page->getAlias() != "" ? $config->base->base_url . $config->alias->prefix . "/" . $page->getAlias() : "", 'sort' => $page->getSorting(), 'icon' => $page->getIcon());
             $out['items'][] = $item;
         }
     }
     echo json_encode($out);
 }