Exemplo n.º 1
0
 /**
  * Get content for sitemap as a nav object
  *
  * @param  string $node
  * @param  int    $tid
  * @return array
  */
 public function getSitemapObject($node = 'nav', $tid = null)
 {
     $tree = [];
     $content = new \Phire\Content\Model\Content();
     $contentAry = $content->getAll($tid, 'order ASC');
     foreach ($contentAry as $c) {
         $branch = ['id' => $c->id, 'type' => 'content', 'name' => $c->title, 'href' => $c->uri, 'children' => isset($c->status) && $c->status == 1 || !isset($c->status) ? $this->getNavChildren($c, 0, false) : []];
         if (isset($c->roles)) {
             $roles = unserialize($c->roles);
             if (count($roles) > 0) {
                 $branch['acl'] = ['resource' => 'content-' . $c->id];
             }
         }
         if (isset($c->status) && $c->status == 1 || !isset($c->status)) {
             $tree[] = $branch;
         }
     }
     $config = ['top' => ['node' => 'nav', 'id' => 'sitemap', 'class' => 'sitemap'], 'parent' => ['node' => 'nav'], 'child' => ['node' => 'nav']];
     if ($node == 'ul') {
         $config['top']['node'] = 'ul';
         $config['parent']['node'] = 'ul';
         $config['child']['node'] = 'li';
     } else {
         if ($node == 'ol') {
             $config['top']['node'] = 'ol';
             $config['parent']['node'] = 'ol';
             $config['child']['node'] = 'li';
         }
     }
     return new Nav($tree, $config);
 }
Exemplo n.º 2
0
 /**
  * Create nav tree from content type
  *
  * @param  mixed $type
  * @param  int   $navId
  * @return void
  */
 protected function createNavFrom($type, $navId)
 {
     if ($type == 'categories') {
         $category = new \Phire\Categories\Model\Category();
         $contentAry = $category->getAll();
         $cat = true;
     } else {
         $sess = Session::getInstance();
         unset($sess->lastSortField);
         unset($sess->lastSortOrder);
         unset($sess->lastPage);
         $content = new \Phire\Content\Model\Content();
         $contentAry = $content->getAll($type, 'id');
         $cat = false;
     }
     foreach ($contentAry as $c) {
         $item = new Table\NavigationItems(['navigation_id' => $navId, 'item_id' => $c->id, 'type' => $cat ? 'category' : 'content', 'name' => $c->title, 'href' => $cat ? '/category' . $c->uri : $c->uri, 'order' => 0]);
         $item->save();
         if (isset($c->status) && $c->status == 1 || !isset($c->status)) {
             $this->createNavChildren($item->id, $navId, $c, 0, $cat);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Create nav tree from content type
  *
  * @param  int $id
  * @return mixed
  */
 protected function createNavFrom($id)
 {
     $tree = [];
     if ($id == 'categories') {
         $category = new \Phire\Categories\Model\Category();
         $contentAry = $category->getAll();
         $cat = true;
     } else {
         $sess = Session::getInstance();
         unset($sess->lastSortField);
         unset($sess->lastSortOrder);
         unset($sess->lastPage);
         $content = new \Phire\Content\Model\Content();
         $contentAry = $content->getAll($id, 'id');
         $cat = false;
     }
     foreach ($contentAry as $c) {
         $branch = ['id' => $c->id, 'type' => $cat ? 'category' : 'content', 'name' => $c->title, 'href' => $c->uri, 'children' => isset($c->status) && $c->status == 1 || !isset($c->status) ? $this->getNavChildren($c, 0, $cat) : []];
         if (isset($c->roles)) {
             $roles = unserialize($c->roles);
             if (count($roles) > 0) {
                 $branch['acl'] = ['resource' => 'content-' . $c->id];
             }
         }
         if (isset($c->status) && $c->status == 1 || !isset($c->status)) {
             $tree[] = $branch;
         }
     }
     return serialize($tree);
 }