当前位置: 首页>>代码示例>>PHP>>正文


PHP MenuItem::model方法代码示例

本文整理汇总了PHP中MenuItem::model方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::model方法的具体用法?PHP MenuItem::model怎么用?PHP MenuItem::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MenuItem的用法示例。


在下文中一共展示了MenuItem::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     if (empty($this->template)) {
         return;
     }
     $url = trim(Yii::app()->request->url, '/');
     $items = MenuItem::model()->onSite()->byParent(0)->byMenuId($this->menuId)->orderDefault()->findAll();
     $itemsArr = array();
     foreach ($items as $item) {
         // Убираем язык из урла
         $domains = explode('/', ltrim($url, '/'));
         if (in_array($domains[0], array_keys(Yii::app()->params['languages']))) {
             array_shift($domains);
             $url = implode('/', $domains);
         }
         $select = strpos($url, trim($item->link, '/')) === 0 ? true : false;
         $blank = 0;
         if (strpos($item->link, 'http://') === 0 || strpos($item->link, 'https://') === 0) {
             $link = $item->link;
             $blank = 1;
         } else {
             $link = isset(Yii::app()->params['routes'][$item->link]) ? array('/' . Yii::app()->params['routes'][$item->link]) : '/' . $item->link;
             // Ссылка без языка, будет вести на дефолтную страницу
             $link = CHtml::normalizeUrl($link);
         }
         $iconUrl = $item->getIconUrl();
         $itemsArr[] = array('name' => $item->name, 'link' => $link, 'select' => $select, 'iconUrl' => $iconUrl, 'blank' => $blank, 'enabled' => $item->active);
     }
     $this->beforeRender($itemsArr);
     $this->render($this->template, array('items' => $itemsArr));
 }
开发者ID:DarkAiR,项目名称:test,代码行数:31,代码来源:MenuWidget.php

示例2: actionView

 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id = null, $path = null)
 {
     //if path is given, find the content_id from the menu item
     if ($path) {
         $Content = Content::model()->findByAttributes(array('path' => $path));
     } else {
         $Content = $this->loadModel($id);
     }
     $Content = $this->loadModel($id);
     $MI = MenuItem::model()->findByAttributes(array('content_id' => $Content->id));
     if (!Yii::app()->user->checkAccess('Update Content')) {
         $today = new DateTime();
         $publish_on = new DateTime($Content->publish_on);
         $unpublish_on = new DateTime($Content->unpublish_on);
         if (!$Content->published || $publish_on > $today || $unpublish_on < $today) {
             throw new CHttpException(403, Yii::t('yii', 'You are not authorized to perform this action.'));
         }
     }
     //$this->layout = '//layouts/column1';
     $view = 'view';
     if ($this->getLayoutFile('//layouts/content_types/' . $Content->type)) {
         $this->layout = '//layouts/content_types/' . $Content->type;
     }
     if ($this->getViewFile($Content->type)) {
         $view = $Content->type;
     }
     $this->meta_keywords = CHtml::value($Content, 'meta_keywords');
     $this->meta_description = CHtml::value($Content, 'meta_description');
     $this->meta_author = CHtml::value($Content, 'UserCreated.full_name');
     //Used by the admin bar
     $this->Content = $Content;
     $this->render($view, array('Content' => $Content, 'MenuItem' => $MI));
 }
开发者ID:snapfrozen,项目名称:snapcms,代码行数:37,代码来源:ContentController.php

示例3: loadModel

 /**
  * Возвращает модель по указанному идентификатору
  * Если модель не будет найдена - возникнет HTTP-исключение.
  *
  * @param integer идентификатор нужной модели
  *
  * @return void
  *
  * @throws CHttpException If MenuItem record not found
  */
 public function loadModel($id)
 {
     if (($model = MenuItem::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('MenuModule.menu', 'Page was not found!'));
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:4seasons,代码行数:17,代码来源:MenuitemBackendController.php

示例4: loadModel

 public function loadModel($id)
 {
     if (($model = MenuItem::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-kamin,代码行数:7,代码来源:MenuitemBackendController.php

示例5: deleteMenu

 protected function deleteMenu($menuId)
 {
     $menuItems = MenuItem::model()->findAllByAttributes(array('menuId' => $menuId));
     foreach ($menuItems as $item) {
         $item->delete();
     }
     Menu::model()->deleteByPk($menuId);
 }
开发者ID:DarkAiR,项目名称:test,代码行数:8,代码来源:ExtendedDbMigration.php

示例6: getMenuItems

 public static function getMenuItems($parent_id, $menu_id)
 {
     $menu_items = MenuItem::model()->findAll(array('condition' => 'parent=:pid AND menu_id=:mid', 'params' => array(':pid' => $parent_id, ':mid' => $menu_id), 'order' => ' t.order ASC '));
     $result = array();
     foreach ($menu_items as $menu_item) {
         $result[] = array('name' => $menu_item->name, 'link' => self::buildLink($menu_item), 'id' => $menu_item->menu_item_id);
     }
     return $result;
 }
开发者ID:nganhtuan63,项目名称:gxc-app,代码行数:9,代码来源:MenuBlock.php

示例7: getSubItems

 protected function getSubItems($item_id)
 {
     $dependencia = new CDbCacheDependency("SELECT GREATEST(MAX(creado), MAX(modificado)) FROM menuItem WHERE estado = 1");
     $c = new CDbCriteria();
     $c->addCondition('t.estado <> 0');
     $c->order = 't.orden ASC';
     $menu_items = MenuItem::model()->cache(21600, $dependencia)->findAllByAttributes(array('item_id' => $this->id), $c);
     return $menu_items ? $menu_items : false;
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:9,代码来源:MenuW.php

示例8: up

 public function up()
 {
     Yii::app()->getModule('menu');
     $Menu = Menu::model()->findByAttributes(['code' => 'top-menu-cabinet']);
     $menuItems = $Menu->menuItems(['condition' => 'href=:href', 'params' => ['href' => '/cabinet/deal']]);
     if (!is_null($menuItems) && count($menuItems)) {
         $menuItem = $menuItems[0];
         MenuItem::model()->deleteByPk($menuItem->id);
     }
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:10,代码来源:m160127_133726_C2G_237.php

示例9: parseUrl

 public function parseUrl($request)
 {
     $path = '/' . Yii::app()->request->pathInfo;
     $MI = MenuItem::model()->findByAttributes(array('path' => $path));
     if ($MI && $MI->content_id) {
         $route = 'content/view/id/' . $MI->content_id;
     } else {
         $route = parent::parseUrl($request);
     }
     return lcfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $route))));
 }
开发者ID:snapfrozen,项目名称:snapcms,代码行数:11,代码来源:SnapUtil.php

示例10: safeDown

 public function safeDown()
 {
     if (Yii::app()->hasModule('menu')) {
         Yii::import('application.modules.menu.models.*');
         Yii::import('application.modules.menu.MenuModule');
         $item = MenuItem::model()->find('href = :href', [':href' => '/store/product/index']);
         if ($item !== null) {
             $item->delete();
         }
     }
 }
开发者ID:alextravin,项目名称:yupe,代码行数:11,代码来源:m150210_063409_add_store_menu_item.php

示例11: safeUp

 public function safeUp()
 {
     if (Yii::app()->hasModule('menu')) {
         Yii::import('application.modules.menu.models.*');
         Yii::import('application.modules.menu.MenuModule');
         $item = MenuItem::model()->find('href = :href', [':href' => '/store/catalog/index']);
         if (null !== $item) {
             $item->href = '/store/product/index';
             $item->save();
         }
     }
 }
开发者ID:alextravin,项目名称:yupe,代码行数:12,代码来源:m150825_184407_change_store_url.php

示例12: getMenuItemFromMenu

 public static function getMenuItemFromMenu($menu_id, $render = true)
 {
     $menus = MenuItem::model()->findAll('menu_id = :id', array(':id' => $menu_id));
     $data = array(0 => t('cms', "None"));
     if ($menus && count($menus) > 0) {
         $data = CMap::mergeArray($data, CHtml::listData($menus, 'menu_item_id', 'name'));
     }
     if ($render) {
         foreach ($data as $value => $name) {
             echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
         }
     } else {
         return $data;
     }
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:15,代码来源:MenuItem.php

示例13: beforeDelete

 protected function beforeDelete()
 {
     try {
         foreach ($this->menuItems as $menuItem) {
             $mi = MenuItem::model()->findByPk($menuItem->id);
             $mi->delete();
         }
         foreach ($this->micrositios as $micrositio) {
             $m = $micrositio->findByPk($micrositio->id);
             $m->menu_id = NULL;
             $m->save();
         }
         return parent::beforeDelete();
     } catch (Exception $e) {
         return false;
     }
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:17,代码来源:Menu.php

示例14: actionView

 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id = null, $path = null)
 {
     if ($path) {
         $MI = MenuItem::model()->findByAttributes(array('path' => $path));
         $id = $MI ? $MI->content_id : null;
     }
     $Content = $this->loadModel($id);
     $this->layout = '//layouts/column1';
     $view = 'view';
     if ($this->getLayoutFile('//layouts/content_types/' . $Content->type)) {
         $this->layout = '//layouts/content_types/' . $Content->type;
     }
     if ($this->getViewFile('content_types/' . $Content->type)) {
         $view = 'content_types/' . $Content->type;
     }
     $this->render($view, array('Content' => $Content));
 }
开发者ID:snapfrozen,项目名称:boxomatic,代码行数:21,代码来源:ContentController.php

示例15: actionSave

 public function actionSave()
 {
     foreach ($_POST['list'] as $item) {
         print_r($_POST);
         if ($item['item_id'] == 'root') {
             continue;
         }
         if ($item['parent_id'] == "root") {
             $item['parent_id'] = "0";
         }
         $menuItem = MenuItem::model()->findByPk($item['item_id']);
         $menuItem->parent = $item['parent_id'];
         $menuItem->depth = $item['depth'];
         $menuItem->lft = $item['left'];
         $menuItem->rgt = $item['right'];
         $menuItem->save();
     }
 }
开发者ID:awecode,项目名称:awecms,代码行数:18,代码来源:AjaxController.php


注:本文中的MenuItem::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。