Beispiel #1
0
 /**
  * Make the item active
  *
  * @return Lavary\Menu\Item
  */
 public function active($pattern = null)
 {
     if (!is_null($pattern)) {
         $pattern = ltrim(preg_replace('/\\/\\*/', '(/.*)?', $pattern), '/');
         if (preg_match("@^{$pattern}\\z@", \Request::path())) {
             $this->activate();
         }
         return $this;
     }
     $this->attributes['class'] = Builder::formatGroupClass(array('class' => $this->builder->conf('active_class')), $this->attributes);
     return $this;
 }
Beispiel #2
0
 /**
  * Decide if the item should be active
  *
  */
 public function activate(\Lavary\Menu\Item $item = null)
 {
     $item = is_null($item) ? $this : $item;
     // Check to see which element should have class 'active' set.
     if (\Config::get('laravel-menu::options.active_element') == 'item') {
         $item->active();
     } else {
         $item->link->active();
     }
     if (true === \Config::get('laravel-menu::options.activate_parents')) {
         // Moving up through the parent nodes and activate them too.
         if ($item->parent) {
             $this->activate($this->builder->whereId($item->parent)->first());
         }
     }
 }
Beispiel #3
0
 /**
  * Activat the item
  *
  */
 public function activate(\Lavary\Menu\Item $item = null)
 {
     $item = is_null($item) ? $this : $item;
     // Check to see which element should have class 'active' set.
     if ($this->builder->conf('active_element') == 'item') {
         $item->active();
     } else {
         $item->link->active();
     }
     // If parent activation is enabled:
     if (true === $this->builder->conf('activate_parents')) {
         // Moving up through the parent nodes, activating them as well.
         if ($item->parent) {
             $this->activate($this->builder->whereId($item->parent)->first());
         }
     }
 }