Example #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);
 }
Example #2
0
 /**
  * Get the feed
  *
  * @param  array               $feedHeaders
  * @param  string              $feedType
  * @param  int                 $feedLimit
  * @param  \Pop\Module\Manager $modules
  * @return Writer
  */
 public function getFeed($feedHeaders, $feedType, $feedLimit, \Pop\Module\Manager $modules)
 {
     $items = [];
     $feed = Table\Feed::findAll();
     foreach ($feed->rows() as $f) {
         if ($f->type == 'content') {
             if ($modules->isRegistered('phire-fields')) {
                 $item = \Phire\Fields\Model\FieldValue::getModelObject('Phire\\Content\\Model\\Content', ['id' => $f->id]);
             } else {
                 $item = new \Phire\Content\Model\Content();
                 $item->getById($f->id);
             }
             if ($item->status == 1 && count($item->roles) == 0) {
                 $items[] = $this->formatItem($item, 'content', $feedType);
             }
         } else {
             if ($f->type == 'media') {
                 if ($modules->isRegistered('phire-fields')) {
                     $item = \Phire\Fields\Model\FieldValue::getModelObject('Phire\\Media\\Model\\Media', ['id' => $f->id]);
                 } else {
                     $item = new \Phire\Media\Model\Media();
                     $item->getById($f->id);
                 }
                 $item->publish = $item->uploaded;
                 $items[] = $this->formatItem($item, 'media', $feedType);
             }
         }
     }
     usort($items, function ($a, $b) {
         $t1 = strtotime($a['publish']);
         $t2 = strtotime($b['publish']);
         return $t2 - $t1;
     });
     if ((int) $feedLimit > 0) {
         if (count($items) > (int) $feedLimit) {
             $items = array_slice($items, 0, (int) $feedLimit);
         }
     }
     $writer = new Writer($feedHeaders, $items);
     if ($feedType == 'atom') {
         $writer->setAtom();
     }
     return $writer;
 }
Example #3
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);
         }
     }
 }
 /**
  * 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);
 }