Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->items) {
         if (!$this->menu) {
             throw new InvalidParamException('Menu property must be set.');
         }
         $class = $this->menuModelClass;
         if (is_int($this->menu)) {
             $this->menu = $class::findOne($this->menu);
         } elseif (is_string($this->menu)) {
             $this->menu = $class::findBySlug($this->menu);
         }
         if ($this->menu instanceof $class) {
             //Get items
             $this->items = $this->menu->getItems();
             if ($this->beforeItems) {
                 $this->items = array_merge($this->beforeItems, $this->items);
             }
             if ($this->afterItems) {
                 $this->items = array_merge($this->items, $this->afterItems);
             }
             if (!empty($this->menu->element_id) && !isset($this->options['id'])) {
                 $this->options['id'] = $this->menu->element_id;
             }
             if (!empty($this->menu->css_class)) {
                 Html::addCssClass($this->options, $this->menu->css_class);
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Initializes the widget.
  * If you override this method, make sure you call the parent implementation first.
  */
 public function init()
 {
     parent::init();
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
 }
Exemplo n.º 3
0
 /**
  * Initializes the menu widget.
  * This method mainly normalizes the {@link items} property.
  * If this method is overridden, make sure the parent implementation is invoked.
  */
 public function init()
 {
     parent::init();
     $this->options['role'] = 'menu';
     if (isset($this->options['class'])) {
         $this->options['class'] .= ' page-sidebar-menu';
     } else {
         $this->options['class'] = 'page-sidebar-menu';
     }
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if ($this->route === null && Yii::$app->controller !== null) {
         $this->route = Yii::$app->controller->getRoute();
     }
     if ($this->params === null) {
         $this->params = $_GET;
     }
     Html::addCssClass($this->options, 'nav');
 }
Exemplo n.º 5
0
 public function init()
 {
     parent::init();
     AffixAsset::register($this->getView());
     $this->activateParents = true;
     $this->submenuTemplate = "\n<ul class='nav'>\n{items}\n</ul>\n";
     $this->linkTemplate = '<a href="{url}">{icon}{label}</a>';
     $this->labelTemplate = '{icon}{label}';
     Html::addCssClass($this->options, 'nav kv-nav');
     Html::addCssClass($this->container, 'kv-sidebar hidden-print-affix');
 }
Exemplo n.º 6
0
 /**
  * Initializes this widget.
  */
 public function init()
 {
     parent::init();
     if (empty($this->items)) {
         $this->items = $this->getItems();
     }
     $this->encodeLabels = false;
     $this->activateParents = true;
     $this->submenuTemplate = "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n";
     $this->options = ['class' => 'sidebar-menu'];
 }
Exemplo n.º 7
0
 /**
  *
  */
 public function init()
 {
     parent::init();
     foreach ($this->items as $i => &$item) {
         if (isset($item['url'])) {
             if (isset($item['items'])) {
                 // Menu
                 $item['options'] = isset($item['options']) ? $item['options'] : [];
                 Html::addCssClass($item['options'], 'treeview');
                 if (!isset($item['icon'])) {
                     $item['icon'] = $this->defaultMenuIcon;
                 }
                 // Submenu
                 foreach ($item['items'] as $j => &$subItem) {
                     if (isset($subItem['icon'])) {
                         $subItem['label'] = "{$subItem['icon']} {$subItem['label']}";
                     } else {
                         $subItem['label'] = "{$this->subLinkIcon} {$subItem['label']}";
                     }
                     if (isset($subItem['items'])) {
                         $subItem['options'] = isset($subItem['options']) ? $subItem['options'] : [];
                         Html::addCssClass($subItem['options'], 'treeview');
                         foreach ($subItem['items'] as $k => &$subSubItem) {
                             if (isset($subSubItem['icon'])) {
                                 $subSubItem['label'] = "{$subSubItem['icon']} {$subSubItem['label']}";
                             } else {
                                 $subSubItem['label'] = "{$this->subLinkIcon} {$subSubItem['label']}";
                             }
                         }
                     }
                 }
             } else {
                 // Link
                 if (!isset($item['icon'])) {
                     $item['icon'] = $this->defaultLinkIcon;
                 }
                 if (isset($item['badge'])) {
                     $label = $item['badge']['content'];
                     $type = isset($item['badge']['type']) ? $item['badge']['type'] : $this->defaultBadgeType;
                     $item['badge'] = "<small class=\"label pull-right {$type}\">{$label}</small>";
                 } else {
                     $item['badge'] = '';
                 }
             }
             // Icon
             $item['label'] = "{$item['icon']} <span>{$item['label']}</span>";
         } else {
             // Label
             $item['options'] = isset($item['options']) ? $item['options'] : [];
             Html::addCssClass($item['options'], 'header');
         }
     }
 }
Exemplo n.º 8
0
 public function init()
 {
     if ($this->renderCategories) {
         $categories = Category::findAll(['parent_id' => $this->categoryId, 'show' => true]);
         $this->items = array_merge($this->items, $this->handleCategories($categories));
     }
     if ($this->renderArticles) {
         $articles = Article::find()->where(['category_id' => $this->categoryId, 'show' => true])->orderBy(['position' => SORT_ASC])->all();
         $this->items = array_merge($this->items, $this->handleArticles($articles));
     }
     parent::init();
 }
Exemplo n.º 9
0
 public function init()
 {
     parent::init();
     if ($this->slug == null) {
         throw new InvalidConfigException("slug不能为空");
     }
     $this->currentAbsoluteUrl = \Yii::$app->getRequest()->getAbsoluteUrl();
     $collection = Menu::findBySlug($this->slug);
     $createCallbacks = Hook::trigger(\hass\menu\Module::EVENT_MENU_LINK_CREATE)->parameters;
     $this->items = NestedSetsTree::generateTree($collection, function ($item) use($createCallbacks) {
         list($item['label'], $item["url"]) = call_user_func($createCallbacks[$item['module']], $item['name'], $item['original']);
         $item["options"] = Serializer::unserializeToArray($item["options"]);
         return $item;
     }, 'items');
 }
Exemplo n.º 10
0
 public function init()
 {
     parent::init();
     $this->_initOptions();
     if ($this->cache) {
         /** @var Cache $cache */
         $this->cache = Instance::ensure($this->cache, Cache::className());
         $cacheKey = [__CLASS__, $this->items];
         if (($this->items = $this->cache->get($cacheKey)) === false) {
             $this->items = ModuleEvent::trigger(self::EVENT_FETCH_ITEMS, new MenuItemsEvent(['items' => $this->items]), 'items');
             $this->cache->set($cacheKey, $this->items, $this->cacheDuration, $this->cacheDependency);
         }
     } else {
         $this->items = ModuleEvent::trigger(self::EVENT_FETCH_ITEMS, new MenuItemsEvent(['items' => $this->items]), 'items');
     }
 }
Exemplo n.º 11
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     // add css class 'sidebar-menu'
     if (isset($this->options['class'])) {
         if (is_array($this->options['class']) && !in_array('sidebar-menu', $this->options['class'])) {
             $this->options['class'][] = 'sidebar-menu';
         } elseif (false === strpos($this->options['class'], 'sidebar-menu')) {
             $this->options['class'] .= ' sidebar-menu';
         }
     } else {
         $this->options['class'] = 'sidebar-menu';
     }
     // add first header item
     if (!empty($this->header)) {
         $this->items = ArrayHelper::merge([['label' => $this->header, 'options' => ['class' => 'header']]], $this->items);
     }
 }
Exemplo n.º 12
0
    public function init()
    {
        parent::init();
        Html::addCssClass($this->options, 'iconized');
        Yii::$app->view->registerCss(<<<CSS
.iconized li {
\tbackground: no-repeat 0 50%;
}

.iconized a {
\tpadding-left: 20px;
}
CSS
, [], 'samdark/IconizedMenu');
        if ($this->useSprites) {
            $domains = $this->fetchDomains($this->items);
            $this->spriteUrl = $this->yandexBaseUrl . implode('/', $domains);
        }
    }
Exemplo n.º 13
0
 public function init()
 {
     parent::init();
     SideNavAsset::register($this->getView());
     $this->activateParents = true;
     $this->submenuTemplate = "\n<ul class='nav nav-pills nav-stacked'>\n{items}\n</ul>\n";
     $this->linkTemplate = '<a href="{url}">{icon}{label}</a>';
     $this->labelTemplate = '{icon}{label}';
     $this->markTopItems();
     Html::addCssClass($this->options, 'nav nav-pills nav-stacked kv-sidenav');
 }
Exemplo n.º 14
0
 public function init()
 {
     parent::init();
     MenuAsset::register($this->getView());
     $this->activateParents = true;
 }
Exemplo n.º 15
0
 public function init()
 {
     $this->items = $this->item_list();
     parent::init();
 }
Exemplo n.º 16
0
    public function init()
    {

        $_role = Auction::userRole();

        if ($_role == DatabaseHelper::COMPANY_ADMIN) {

            $this->items = [
                ['label' => '<i class="fa fa-dashboard fa-fw"></i>Dashboard', 'url' => Auction::createUrl('company/info')],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Auctions<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>List Auctions', 'url' => Auction::createUrl('company/auction')],
                        ['label' => '<i class="fa  fa-github-square fa-fw"></i>Add Auction', 'url' => Auction::createUrl('company/auction/create')],
                    ],
                ],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Users<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>List Company Users', 'url' => Auction::createUrl('company/user')],
                        ['label' => '<i class="fa  fa-github-square fa-fw"></i>Dealers', 'url' => Auction::createUrl('company/dealer')],
                    ],
                ],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Auction Lots<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Lots', 'url' => Auction::createUrl('company/lots')],
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Add Products In Lot', 'url' => Auction::createUrl('company/lot-product')],
                    ],
                ],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Products<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>List Products', 'url' => Auction::createUrl('company/product')],
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Upload CSV', 'url' => Auction::createUrl('company/upload-csv')],
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Create Product Cofig', 'url' => Auction::createUrl('company/product-config')],
                    ],
                ],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Setting<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Update Info', 'url' => Auction::createUrl('company/edit')],
                    ],
                ],
            ];
        } elseif ($_role == DatabaseHelper::DEALER) {

            $this->items = [
                ['label' => '<i class="fa fa-dashboard fa-fw"></i>Dashboard', 'url' => Auction::createUrl('dealer/profile')],
                ['label' => '<i class="fa fa-dashboard fa-fw"></i>Auctions', 'url' => Auction::createUrl('dealer/auction')],
                ['label' => '<i class="fa fa-dashboard fa-fw"></i>Companies', 'url' => Auction::createUrl('dealer/company')],
                ['label' => '<i class="fa fa-dashboard fa-fw"></i>Payment', 'url' => Auction::createUrl('dealer/payment')],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Setting<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Update Info', 'url' => Auction::createUrl('dealer/edit-profile')],
                    ],
                ],
            ];
        }

       $this->items[] = ['label' => '<i class="fa fa-sign-out fa-fw"></i>Sign Out', 'url' => Auction::createUrl('site/logout')];

        parent::init();
    }
Exemplo n.º 17
0
 public function init()
 {
     parent::init();
     SideNavAsset::register($this->getView());
     $this->markTopItems();
     Html::addCssClass($this->options, '');
 }
Exemplo n.º 18
0
 public function init()
 {
     parent::init();
     $this->linkTemplate = '<a href="{url}" title="{label}"><i class="fa fa-{icon}"></i><span>{label}</span></a>';
     $this->submenuTemplate = "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n";
 }
Exemplo n.º 19
0
 public function init()
 {
     parent::init();
     $defaults = ['tag' => 'div', 'id' => $this->getId()];
     $this->options = ArrayHelper::merge($defaults, $this->options);
 }
Exemplo n.º 20
0
 public function init()
 {
     parent::init();
     $this->loadMenu();
 }
Exemplo n.º 21
0
 public function init()
 {
     parent::init();
     // next init
 }
Exemplo n.º 22
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     Html::addCssClass($this->options, 'sidebar-menu');
     parent::init();
 }
Exemplo n.º 23
0
 public function init()
 {
     parent::init();
     $this->ensureVisibility($this->items);
 }
Exemplo n.º 24
0
 public function init()
 {
     parent::init();
     $this->_initOptions();
 }