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


PHP Widget::find方法代码示例

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


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

示例1: destroy

 /**
  * Remove the specified widget from storage.
  * @internal param $id
  * @return Response
  */
 public function destroy($id)
 {
     $widget = $this->widget->find($id);
     // Was the widget deleted?
     if ($widget->delete()) {
         // Redirect to the widget management page
         return Redirect::to('widgets')->with('success', Lang::get('widget/messages.delete.success'));
     }
     // There was a problem deleting the widget
     return Redirect::to('widgets')->with('error', Lang::get('widget/messages.delete.error'));
 }
开发者ID:ehumps,项目名称:rendezview,代码行数:16,代码来源:WidgetController.php

示例2: getList

 public function getList()
 {
     $json = array();
     App::uses('Widget', 'Model');
     $WidgetModel = new Widget();
     $params = array();
     $params['recursive'] = -1;
     $params['fields'] = array('id', 'controller', 'action', 'title');
     $params['order'] = 'title asc';
     if ($widgets = $WidgetModel->find('all', $params)) {
         $json['widgets'] = $widgets;
     } else {
         $json['msg'] = __("You don't have any MushRaider's widget to insert");
     }
     return json_encode($json);
 }
开发者ID:Chaoslan,项目名称:mushraider,代码行数:16,代码来源:AjaxController.php

示例3: generatemenu

 public function generatemenu()
 {
     $menu = new MenuItem();
     $getall = $menu->getall(1);
     $menu = array('items' => array(), 'parents' => array());
     foreach ($getall as $key => $items) {
         $menu['items'][$items['id']] = $items->toArray();
         $menu['parents'][$items['parent']][] = $items->id;
     }
     $items = $this->buildMenu(0, $menu);
     $menufind = Menu::find(Input::get("id"));
     $widget = new Widget();
     $widgetbymenu = $widget->getWidgetByMenu(Input::get("id"));
     if ($widgetbymenu->count()) {
         $widget = Widget::find($widgetbymenu[0]->id);
     }
     $widget->name = $menufind->name;
     $widget->id_component = Input::get("id");
     $widget->description = $this->generarmenu($items);
     $widget->save();
 }
开发者ID:tvad911,项目名称:laravel-wordpress-menu-clone,代码行数:21,代码来源:HomeController.php

示例4: saveWidgetPosition

 /**
  * saveWidgetPosition
  * --------------------------------------------------
  * Saves the widget position.
  * @param  (int)  ($userID) The ID of the user
  * @return Json with status code
  * --------------------------------------------------
  */
 public function saveWidgetPosition($userID)
 {
     /* Escaping invalid data. */
     if (!isset($_POST['positioning'])) {
         throw new BadPosition("Missing positioning data.", 1);
     }
     /* Find user and save positioning if possible */
     if (User::find($userID)) {
         /* Get widgets data */
         $widgets = json_decode($_POST['positioning'], TRUE);
         /* Iterate through all widgets */
         foreach ($widgets as $widgetData) {
             /* Escaping invalid data. */
             if (!isset($widgetData['id'])) {
                 return Response::json(array('error' => 'Invalid JSON input.'));
             }
             /* Find widget */
             $widget = Widget::find($widgetData['id'])->getSpecific();
             /* Skip widget if not found */
             if ($widget === null) {
                 continue;
             }
             /* Set position */
             try {
                 $widget->setPosition($widgetData);
             } catch (BadPosition $e) {
                 return Response::json(array('error' => $e->getMessage()));
             }
         }
         /* No user found with the requested ID */
     } else {
         return Response::json(array('error' => 'No user found with the requested ID'));
     }
     /* Everything OK, return response with 200 status code */
     return Response::make('Widget positions saved.', 200);
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:44,代码来源:GeneralWidgetController.php

示例5: Mysqli

require_once '../paragon.php';
require_once '../drivers/mysqli_master_slave_driver.php';
// setting the connection
// you only need to do this once in the whole script
$mysqli = new Mysqli('localhost', 'username', 'password', 'database');
$driver = new MysqliMasterSlaveDriver(array('master' => $mysqli, 'slave' => $mysqli));
Paragon::set_connection($driver);
// include a model
require_once 'widget.php';
// find by id
$widget = Widget::find(1);
// find one by conditions
$widgets = Widget::find_one(array('conditions' => array('name' => 'foo')));
// find by conditions, with limit, order, and start parameters
$widgets = Widget::find(array('conditions' => array('name' => self::condition('like', 'bar')), 'limit' => 10, 'order' => 'name', 'start' => 0));
// index widgets by id
$widgets_by_id = Widget::find(array('index' => 'id', 'order' => 'name'));
// find widget ids
$widget_ids = Widget::find_primary_keys(array('conditions' => array('name' => 'foo')));
// save a widget
$widget->name = 'bar';
$widget->save();
// create a new widget
$widget = new Widget();
$widget->name = 'foo';
$widget->description = 'i am a widget';
$widget->save();
// using a widget
echo $widget->id;
echo $widget->name;
echo $widget->date_created;
开发者ID:bgoldman,项目名称:Paragon,代码行数:31,代码来源:index.php

示例6: sendStats

 private function sendStats()
 {
     $stats = array();
     // Website
     $stats['Website']['url'] = Router::url('/', true);
     $stats['Website']['version'] = Configure::read('mushraider.version');
     $stats['Website']['php'] = phpversion();
     $stats['Website']['lang'] = Configure::read('Settings.language');
     // Events
     App::uses('Event', 'Model');
     $EventModel = new Event();
     $params = array();
     $params['recursive'] = -1;
     $params['order'] = array('time_start ASC');
     if ($firstEvent = $EventModel->find('first', $params)) {
         $stats['Event']['first'] = $firstEvent['Event']['time_start'];
     } else {
         $stats['Event']['first'] = null;
     }
     $params['conditions']['time_start <='] = date('Y-m-d');
     $params['order'] = array('time_start DESC');
     if ($lastEvent = $EventModel->find('first', $params)) {
         $stats['Event']['last'] = $lastEvent['Event']['time_start'];
     } else {
         $stats['Event']['last'] = null;
     }
     $params = array();
     $params['recursive'] = -1;
     $params['conditions']['time_start <='] = date('Y-m-d');
     $countEvents = $EventModel->find('count', $params);
     $stats['Event']['total'] = $countEvents;
     // Reports
     App::uses('Report', 'Model');
     $ReportModel = new Report();
     $params = array();
     $params['recursive'] = -1;
     $countReports = $ReportModel->find('count', $params);
     $stats['Report']['total'] = $countReports;
     // Users
     App::uses('User', 'Model');
     $UserModel = new User();
     $params = array();
     $params['recursive'] = -1;
     $countUsers = $UserModel->find('count', $params);
     $stats['User']['total'] = $countUsers;
     // Characters
     App::uses('Character', 'Model');
     $CharacterModel = new Character();
     $params = array();
     $params['recursive'] = -1;
     $countCharacters = $CharacterModel->find('count', $params);
     $stats['Character']['total'] = $countCharacters;
     // Games
     App::uses('Game', 'Model');
     $GameModel = new Game();
     $params = array();
     $params['recursive'] = -1;
     if ($games = $GameModel->find('all', $params)) {
         foreach ($games as $game) {
             $stats['Game'][$game['Game']['slug']]['title'] = $game['Game']['title'];
             $stats['Game'][$game['Game']['slug']]['imported'] = $game['Game']['import_modified'] > 0 ? 1 : 0;
             $params = array();
             $params['recursive'] = -1;
             $params['conditions']['game_id'] = $game['Game']['id'];
             $params['group'] = array('user_id');
             $countCharacters = $CharacterModel->find('count', $params);
             $stats['Game'][$game['Game']['slug']]['players'] = $countCharacters;
         }
     }
     // Bridge
     $bridgeSetting = json_decode($this->SettingModel->getOption('bridge'));
     $stats['Bridge']['enabled'] = !empty($bridgeSetting) && $bridgeSetting->enabled ? 1 : 0;
     // Widgets
     App::uses('Widget', 'Model');
     $WidgetModel = new Widget();
     $params = array();
     $params['recursive'] = -1;
     if ($widgets = $WidgetModel->find('all', $params)) {
         foreach ($widgets as $widget) {
             if (!isset($stats['Widget'][$widget['Widget']['controller']])) {
                 $stats['Widget'][$widget['Widget']['controller']]['total'] = 1;
             } else {
                 $stats['Widget'][$widget['Widget']['controller']]['total']++;
             }
         }
     }
     App::uses('HttpSocket', 'Network/Http');
     $this->http = new HttpSocket();
     $this->http->post('http://stats.mushraider.com/acquire', $stats);
 }
开发者ID:Chaoslan,项目名称:mushraider,代码行数:90,代码来源:MushstatsComponent.php


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