Exemple #1
0
 /**
  * Get route to tag view
  *
  * @param int $application_id
  * @param string $tag
  * @param int $force_id
  *
  * @return string the route
  * @since 2.0
  */
 public function tag($application_id, $tag, $force_id = 0)
 {
     $key = $this->_active_menu_item_id . '-tag-' . $application_id . '_' . $tag . '_' . $force_id;
     if ($this->_cache && ($link = $this->_cache->get($key))) {
         return $link;
     }
     if (!$force_id && $this->app->request->getBool('f') && $this->app->request->getString('tag') == $tag) {
         $force_id = $this->app->request->getInt('Itemid');
     }
     // build tag link
     $link = $this->getLinkBase() . '&task=tag&tag=' . $tag . '&app_id=' . $application_id;
     // Priority 1: link to frontpage || Priority 2: current item id
     $item_id = '';
     if ($menu_item = $this->_find('frontpage', $application_id) or $menu_item = $this->app->menu->getActive()) {
         if ($force_id && $force_id != $menu_item->id) {
             $item_id = '&Itemid=' . $force_id;
             $link .= '&f=1&task=tag&tag=' . $tag . '&app_id=' . $application_id;
         } else {
             $item_id = '&Itemid=' . $menu_item->id;
         }
     }
     $link .= $item_id;
     // store link for future lookups
     if ($this->_cache) {
         $this->_cache->set($key, $link)->save();
     }
     return $link;
 }
Exemple #2
0
 /**
  * Class constructor
  *
  * @param string $app App instance.
  */
 public function __construct($app)
 {
     // set application
     $this->app = $app;
     // cache
     if ($this->app->get('cache_routes', false)) {
         // get route cache
         // refreshes after one hour automatically
         $this->_cache = $this->app->cache->create($this->app->path->path('cache:') . '/routes', true, 3600, 'apc');
         if (!$this->_cache || !$this->_cache->check()) {
             $this->_cache = null;
         } else {
             $this->_find(null, null);
             $key = json_encode($this->_menu_items);
             if (!$this->_cache->get($key)) {
                 $this->_cache->clear()->set($key, true)->save();
             }
         }
     }
     // save default menu
     if ($menu_item = $this->app->menu->getActive()) {
         $this->_active_menu_item_id = $menu_item->id;
     }
 }