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