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


PHP Assets::select2方法代码示例

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


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

示例1: action_edit

 /**
  * Editing Widgets
  */
 public function action_edit()
 {
     $id = (int) $this->request->param('id', 0);
     $widget = ORM::factory('widget', $id);
     if (!$widget->loaded()) {
         Log::error('Attempt to access non-existent widget.');
         Message::error(__('Widget doesn\'t exists!'));
         $this->request->redirect(Route::get('admin/widget')->uri());
     }
     $widget_regions = array();
     $adminTheme = Theme::getTheme();
     $frontTheme = Theme::getTheme(Config::get('site.theme', $adminTheme->name));
     if (isset($adminTheme->regions) and !empty($adminTheme->regions)) {
         $widget_regions = Arr::merge($widget_regions, $adminTheme->regions);
     }
     if (isset($frontTheme->regions) and !empty($frontTheme->regions)) {
         $widget_regions = Arr::merge($widget_regions, $frontTheme->regions);
     }
     $handler = Widget::factory($widget->name, $widget);
     $fields = $handler->form();
     // Add a last region for disabled blocks.
     $widget_regions = Arr::merge($widget_regions, array(self::$WIDGET_REGION_NONE => self::$WIDGET_REGION_NONE));
     if (isset($widget_regions[self::$WIDGET_REGION_NONE])) {
         $widget_regions[self::$WIDGET_REGION_NONE] = __('Disabled');
     }
     $all_roles = ORM::factory('role')->find_all()->as_array('id', 'name');
     $this->title = __('Edit %widget widget', array('%widget' => $widget->title));
     $view = View::factory('admin/widget/form')->set('widget', $widget)->set('fields', $fields)->set('roles', $all_roles)->set('regions', $widget_regions);
     if ($this->valid_post('widget')) {
         $widget->values($_POST);
         try {
             $widget->save();
             if (isset($_POST['widget'])) {
                 unset($_POST['widget'], $_POST['_token'], $_POST['_action']);
             }
             $handler->save($_POST);
             Message::success(__('Widget %name updated successful!', array('%name' => $widget->title)));
             Cache::instance('widgets')->delete_all();
             // Redirect to listing
             $this->request->redirect(Route::get('admin/widget')->uri());
         } catch (ORM_Validation_Exception $e) {
             $view->errors = $e->errors('models');
         }
     }
     Assets::select2();
     $this->response->body($view);
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:50,代码来源:widget.php

示例2: action_edit

 /**
  * Edit menu item
  *
  * @uses  Message::error
  * @uses  Log::add
  * @uses  Request::redirect
  * @uses  Route::get
  * @uses  Route::uri
  * @uses  ORM::save
  * @uses  Cache::delete_all
  * @uses  Assets::select2
  */
 public function action_edit()
 {
     $id = (int) $this->request->param('id', 0);
     $menu = ORM::factory('menu', $id);
     if (!$menu->loaded()) {
         Log::error('Attempt to access non-existent Menu.');
         Message::error(__("Menu doesn't exists!"));
         $this->request->redirect(Route::get('admin/menu')->uri());
     }
     $this->title = __('Edit Item :name', array(':name' => $menu->title));
     $view = View::factory('admin/menu/item/form')->bind('menu', $menu)->bind('post', $menu)->bind('errors', $this->_errors);
     $post = ORM::factory('menu', $id)->values($_POST);
     if ($this->valid_post('menu-item')) {
         try {
             $post->save();
             Message::success(__('Menu Item %name updated successful!', array('%name' => $post->title)));
             Cache::instance('menus')->delete_all();
             $this->request->redirect(Route::get('admin/menu/item')->uri(array('action' => 'list', 'id' => $menu->scp)), 200);
         } catch (ORM_Validation_Exception $e) {
             $this->_errors = $e->errors('models', TRUE);
         }
     }
     Assets::select2();
     $this->response->body($view);
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:37,代码来源:item.php


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