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


PHP MenuItem::save方法代码示例

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


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

示例1: actionCreate

 public function actionCreate()
 {
     $model = new MenuItem();
     if (isset($_POST['MenuItem'])) {
         $model->setAttributes($_POST['MenuItem']);
         if (isset($_POST['MenuItem']['menu'])) {
             $model->menu = $_POST['MenuItem']['menu'];
         }
         if (isset($_POST['MenuItem']['parent'])) {
             $model->parent = $_POST['MenuItem']['parent'];
         }
         $model->link = $_POST['MenuItem'][$_POST['MenuItem']['type']];
         if (isset($_POST['MenuItem']['role'])) {
             $model->role = implode(',', $_POST['MenuItem']['role']);
         } else {
             $model->role = '';
         }
         //pushing newly added item to last
         $maxRight = $model->getMaxRight();
         $model->lft = $maxRight + 1;
         $model->rgt = $maxRight + 2;
         try {
             if ($model->save()) {
                 $this->redirect(array('/' . $this->module->id . '/item/index', 'id' => $model->menu_id, 'activeId' => $model->id));
             }
         } catch (Exception $e) {
             $model->addError('', $e->getMessage());
         }
     } elseif (isset($_GET['MenuItem'])) {
         $model->attributes = $_GET['MenuItem'];
     }
     $this->render('create', array('model' => $model, 'menuId' => key($_GET)));
 }
开发者ID:awecode,项目名称:awecms,代码行数:33,代码来源:ItemController.php

示例2: addcustommenu

 public function addcustommenu()
 {
     $menuitem = new MenuItem();
     $menuitem->label = Input::get("labelmenu");
     $menuitem->link = Input::get("linkmenu");
     $menuitem->menu = Input::get("idmenu");
     $menuitem->save();
 }
开发者ID:tvad911,项目名称:wmenu,代码行数:8,代码来源:WmenuContoller.php

示例3: actionCreate

 /**
  * Создает новую модель пунта меню.
  * Если создание прошло успешно - перенаправляет на просмотр.
  *
  * @return void
  */
 public function actionCreate()
 {
     $model = new MenuItem();
     $model->menu_id = Yii::app()->getRequest()->getQuery('mid', null);
     if (($data = Yii::app()->getRequest()->getPost('MenuItem')) !== null) {
         $model->setAttributes($data);
         if ($model->save()) {
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('MenuModule.menu', 'New item was added to menu!'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create']));
         }
     }
     $this->render('create', ['model' => $model]);
 }
开发者ID:RonLab1987,项目名称:43berega,代码行数:19,代码来源:MenuitemBackendController.php

示例4: actionCreate

 /**
  * Creates a new model.
  *
  * @param $menuId
  * @param int $parentId
  *
  * @throws CHttpException
  */
 public function actionCreate($menuId, $parentId = 0)
 {
     $menu = $this->loadMenuModel($menuId);
     $this->breadcrumbs = MenuItem::getBreadcrumbs($parentId, $menuId, 'Добавление');
     $model = new MenuItem();
     $model->menu_id = $menuId;
     $model->parent_id = $parentId;
     if (isset($_POST['MenuItem'])) {
         $model->attributes = $_POST['MenuItem'];
         if ($model->save()) {
             $this->redirect(array('index', 'menuId' => $model->menu_id, 'parentId' => $model->parent_id));
         }
     }
     $this->render('form', array('model' => $model, 'menu' => $menu));
 }
开发者ID:rash012,项目名称:cms,代码行数:23,代码来源:MenuItemController.php

示例5: newMenuItem

 public function newMenuItem()
 {
     $validate = new Validate();
     $validated = $validate->Validate();
     $categories = $this->getCategories();
     $nameToSlug = $this->nameToSlug($validated);
     $current_user = \Auth::user()->user_id;
     if (\Auth::check()) {
         if ($validated->passes() && $nameToSlug === true) {
             $slug = \Input::get('name');
             $slug = preg_replace('#[ -]+#', '-', $slug);
             $slug = strtolower($slug);
             \DB::beginTransaction();
             try {
                 $item = new \MenuItem();
                 $item->menu_item_name = \Input::get('name');
                 $item->menu_item_description = \Input::get('description');
                 $item->menu_item_category_fk = \Input::get('category');
                 $item->menu_item_short = \Input::get('desc');
                 $item->menu_item_price = \Input::get('price');
                 $item->menu_item_slug = $slug;
                 if (\Input::hasFile('Upload')) {
                     $name = \Input::file('Upload')->getClientOriginalName();
                     \Input::file('Upload')->move('uploads', $name);
                     $item->menu_item_picture_uri = '/uploads/' . $name;
                 }
                 //this creates the menu item for user1...they're fucked if it doesnt //exist
                 $item->user_id_fk = $current_user;
                 $item->save();
             } catch (ValidationException $e) {
                 DB::rollback();
                 throw $e;
             }
             \DB::commit();
             return \Redirect::to('admin/edit/' . $slug)->with('message', '<div class="alert alert-dismissible alert-success alert-link"><button type="button" class="close" data-dismiss="alert">×</button>Saved at: ' . link_to('/menu/' . $slug) . '</p></div>');
         }
         if ($nameToSlug === false) {
             return \View::make('menu-items.new')->withErrors($validated)->withInput(array('name', 'description'))->with('message', '<p class="alert alert-dismissible alert-danger alert-link">An item with the same name already exists')->withCategories($categories);
         }
         return \View::make('menu-items.new')->withErrors($validated)->withInput(array('name', 'description', 'category', 'desc', 'price'))->withCategories($categories);
     }
     return \Redirect::to('admin');
 }
开发者ID:adamyWA,项目名称:Menu-CMS,代码行数:43,代码来源:NewMenuItem.php

示例6: safeUp

 public function safeUp()
 {
     if (Yii::app()->hasModule('menu')) {
         Yii::import('application.modules.menu.models.*');
         Yii::import('application.modules.menu.MenuModule');
         $menu = Menu::model()->find(['order' => 'id ASC', 'limit' => 1]);
         if (null !== $menu) {
             $item = MenuItem::model()->find('href = :href', [':href' => '/store/product/index']);
             if (null != $item) {
                 $item = new MenuItem();
                 $item->menu_id = $menu->id;
                 $item->title = 'Магазин';
                 $item->href = '/store/product/index';
                 $item->parent_id = 0;
                 $item->condition_name = null;
                 $item->save();
             }
         }
     }
 }
开发者ID:alextravin,项目名称:yupe,代码行数:20,代码来源:m150210_063409_add_store_menu_item.php

示例7: actionCreate

 /**
  * Создает новую модель пунта меню.
  * Если создание прошло успешно - перенаправляет на просмотр.
  *
  * @return void
  */
 public function actionCreate()
 {
     $model = new MenuItem();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $model->menu_id = Yii::app()->getRequest()->getQuery('mid', null);
     if (($data = Yii::app()->getRequest()->getPost('MenuItem')) !== null) {
         $model->setAttributes($data);
         if ($model->save()) {
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('MenuModule.menu', 'New item was added to menu!'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', array('create')));
         }
     }
     $criteria = new CDbCriteria();
     $criteria->select = new CDbExpression('MAX(sort) as sort');
     $max = $model->find($criteria);
     $model->sort = $max->sort + 1;
     // Set sort in Adding Form as ma x+ 1
     $this->render('create', array('model' => $model));
 }
开发者ID:sepaker,项目名称:yupe,代码行数:26,代码来源:MenuitemBackendController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // define rules
     $rules = array('name' => array('required'), 'position' => array('required'));
     // pass input to validator
     $validator = Validator::make(Input::all(), $rules);
     // test if input fails
     /* @TODO : Faire fonctionner le Validator de l'Update !! (a priori, problème avec méthode Edit également) */
     if ($validator->fails()) {
         return Redirect::route('admin.menu.create')->withErrors($validator)->withInput();
     }
     $name = Input::get('name');
     $route = Input::get('route');
     $position = Input::get('position');
     $menuItem = new MenuItem();
     $menuItem->name = $name;
     $menuItem->route = $route;
     $menuItem->position = $position;
     $menuItem->save();
     return Redirect::route('admin.menu.index')->withMessage("L'onglet de menu a été créé");
 }
开发者ID:jeremy6680,项目名称:easy-peasy-cms,代码行数:26,代码来源:MenuItemController.php

示例9: createMenu

 protected function createMenu($menuArr, $items)
 {
     $menu = new Menu();
     $menu->multilang();
     $attr = array('name' => $menuArr['name']);
     foreach (Yii::app()->params['languages'] as $lang => $langName) {
         $attr['name_' . $lang] = $menuArr['name_' . $lang];
     }
     $menu->setAttributes($attr);
     $menu->id = $menuArr['id'];
     $menu->save();
     $orderNum = 1;
     foreach ($items as $item) {
         $menuItem = new MenuItem();
         $menuItem->multilang();
         $attr = array('menuId' => $menuArr['id'], 'name' => $item['name'], 'link' => $item['link'], 'orderNum' => $orderNum++, 'active' => 1, 'visible' => 1);
         foreach (Yii::app()->params['languages'] as $lang => $langName) {
             $attr['name_' . $lang] = $item['name_' . $lang];
         }
         $menuItem->setAttributes($attr);
         $menuItem->save();
     }
 }
开发者ID:DarkAiR,项目名称:test,代码行数:23,代码来源:ExtendedDbMigration.php

示例10: addItem

 /**
  * Добавляет новый пункт меню в меню
  * @param $title string - Заголовок
  * @param $href string - Ссылка
  * @param $parentId int - Родитель
  * @param bool $regularLink - Обычная ссылка
  * @return bool
  */
 public function addItem($title, $href, $parentId, $regularLink = false)
 {
     $menuItem = new MenuItem();
     $menuItem->parent_id = (int) $parentId;
     $menuItem->menu_id = $this->id;
     $menuItem->title = $title;
     $menuItem->href = $href;
     $menuItem->regular_link = $regularLink;
     if ($menuItem->save()) {
         Yii::app()->getCache()->clear(['menu', $this->code]);
         return true;
     }
     return false;
 }
开发者ID:syrexby,项目名称:domovoishop.by,代码行数:22,代码来源:Menu.php

示例11: actionCrearitemajax

 public function actionCrearitemajax($id)
 {
     if (!$id) {
         throw new CHttpException(404, 'Invalid request');
     }
     $menuItem = new MenuItem();
     $menu = Menu::model()->findByPk($id);
     $menuItem->menu_id = $menu->id;
     if (isset($_POST['MenuItem'])) {
         $menuItem->attributes = $_POST['MenuItem'];
         $menuItem->tipo_link_id = 2;
         $menuItem->url_id = NULL;
         $menuItem->clase = 'fancybox fancybox.ajax';
         if ($menuItem->save()) {
             Yii::app()->user->setFlash('success', 'Item ' . $menuItem->label . ' guardado con éxito');
             $this->redirect(array('view', 'id' => $menuItem->menu_id));
         }
         //if($menuItem->save())
     }
     //if(isset($_POST['MenuItem']))
     $micrositios = Micrositio::model()->with('url')->findAllByAttributes(array('menu_id' => $id));
     $u = $this->createAbsoluteUrl('/' . $micrositios[0]->url->slug);
     $paginas = array($u . '#imagenes' => 'Imágenes', $u . '#videos' => 'Videos');
     $this->render('crearItemajax', array('model' => $menuItem, 'menu' => $menu, 'paginas' => $paginas));
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:25,代码来源:MenuController.php

示例12: updatemenus

 public function updatemenus()
 {
     if (Input::get("id") == 0) {
         $menu = new MenuItem();
         if (Input::has("label")) {
             $menu->label = Input::get("label");
         }
         if (Input::has("class")) {
             $menu->class = Input::get("class");
         }
         if (Input::has("link")) {
             $menu->link = Input::get("link");
         }
         if (Input::has("parent")) {
             if (Input::get("parent") != "") {
                 $menu->parent = Input::get("parent");
             } else {
                 $menu->parent = 0;
             }
         }
         $menu->sort = 0;
         echo $menu->save();
     } else {
         $menu = Menu::find(Input::get("id"));
         if (Input::has("label")) {
             $menu->label = Input::get("label");
         }
         if (Input::has("parent")) {
             $menu->parent = Input::get("parent");
         }
         if (Input::has("class")) {
             $menu->class = Input::get("class");
         }
         if (Input::has("link")) {
             $menu->link = Input::get("link");
         }
         $menu->save();
     }
 }
开发者ID:tvad911,项目名称:laravel-wordpress-menu-clone,代码行数:39,代码来源:HomeController.php

示例13: postItemStore

 public function postItemStore($id)
 {
     if (Session::get('user_level') < Config::get('cms.addMenuItem')) {
         return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning');
     }
     $rules = array('title' => 'Required', 'url' => 'Required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to(_l(URL::action('MenuController@getItemCreate') . "/" . $id))->withErrors($validator)->withInput();
     } else {
         try {
             $menu = Menu::findOrFail($id);
             $item = new MenuItem();
             $item->title = Input::get('title');
             $item->url = Input::get('url');
             $item->item_class = Input::get('class');
             $item->item_id = Input::get('cssid');
             $item->ordering = Input::get('ordering');
             $item->parent_id = Input::get('parent');
             $item->target = Input::get('target');
             $item->menu_id = $menu->id;
             $item->save();
             return Redirect::to(_l(URL::action('MenuController@getItemEdit') . "/" . $item->id))->with('message', Lang::get('admin.menuItemSaved'))->with('notif', 'success');
         } catch (Exception $e) {
             return Redirect::to(_l(URL::action('MenuController@getEdit') . "/" . $id))->with('message', Lang::get('admin.error'))->with('notif', 'danger');
         }
     }
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:28,代码来源:MenuController.php

示例14: addItem

 /**
  * Добавляет новый пункт меню в меню
  * @param $title string - Заголовок
  * @param $href string - Ссылка
  * @param $parentId int - Родитель
  * @param bool $regularLink - Обычная ссылка
  * @return bool
  */
 public function addItem($title, $href, $parentId, $regularLink = false)
 {
     $menuItem = new MenuItem();
     $menuItem->setAttributes(['parent_id' => (int) $parentId, 'menu_id' => $this->id, 'title' => $title, 'href' => $href, 'regular_link' => $regularLink]);
     if (true === $menuItem->save()) {
         Yii::app()->getCache()->clear(['menu', $this->code]);
         return true;
     }
     return false;
 }
开发者ID:yupe,项目名称:yupe,代码行数:18,代码来源:Menu.php

示例15: addItem

 /**
  * Добавляет новый пункт меню в меню
  * @param $title string - Заголовок
  * @param $href string - Ссылка
  * @param $parentId int - Родитель
  * @param bool $regularLink - Обычная ссылка
  * @return bool
  */
 public function addItem($title, $href, $parentId, $regularLink = false)
 {
     $menuItem = new MenuItem();
     $menuItem->parent_id = (int) $parentId;
     $menuItem->menu_id = $this->id;
     $menuItem->title = $title;
     $menuItem->href = $href;
     $menuItem->condition_name = '';
     $menuItem->class = '';
     $menuItem->title_attr = '';
     $menuItem->before_link = '';
     $menuItem->after_link = '';
     $menuItem->target = '';
     $menuItem->rel = '';
     $menuItem->regular_link = $regularLink;
     if ($menuItem->save()) {
         Yii::app()->cache->clear(['menu', $this->code]);
         return true;
     }
     return false;
 }
开发者ID:alextravin,项目名称:yupe,代码行数:29,代码来源:Menu.php


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