當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。