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


PHP Widget::save方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Validate the inputs
     $rules = array('name' => 'required|alpha_dash|unique:widgets,name', 'description' => 'required');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Get the inputs, with some exceptions
         $inputs = Input::except('csrf_token');
         $this->widget->name = $inputs['name'];
         $this->widget->description = $inputs['description'];
         if ($this->widget->save($rules)) {
             // Redirect to the new widget page
             return Redirect::to('widgets')->with('success', Lang::get('widget/messages.create.success'));
         } else {
             // Redirect to the widget create page
             //var_dump($this->widget);
             return Redirect::to('widgets/create')->with('error', Lang::get('widget/messages.create.error'));
         }
     } else {
         // Form validation failed
         return Redirect::to('widgets/create')->withInput()->withErrors($validator);
     }
 }
开发者ID:ehumps,项目名称:rendezview,代码行数:30,代码来源:WidgetController.php

示例2: save

 /**
  * saves current widget data into the DB config
  * @param string $old_placeholder
  * @return boolean 
  */
 public function save($old_placeholder = NULL)
 {
     if (isset(Kohana::$_POST_ORIG['text_body'])) {
         $this->text_body = Kohana::$_POST_ORIG['text_body'];
     }
     return parent::save($old_placeholder);
 }
开发者ID:JeffPedro,项目名称:project-garage-sale,代码行数:12,代码来源:text.php

示例3: widget_create

 public function widget_create($tipo)
 {
     $widget = new Widget();
     $widget->nombre = 'Nuevo widget';
     $widget->tipo = $tipo;
     $widget->cuenta_id = UsuarioBackendSesion::usuario()->cuenta_id;
     $widget->save();
     redirect($this->input->server('HTTP_REFERER'));
 }
开发者ID:chileindica,项目名称:SIMPLE,代码行数:9,代码来源:gestion.php

示例4: save

 /**
  * save
  * --------------------------------------------------
  * Overrides save to request a new quote.
  * @return None
  * --------------------------------------------------
  */
 public function save(array $options = array())
 {
     /* Calling collectData only if first creation. */
     if (is_null($this->id)) {
         parent::save();
         $this->collectData();
     } else {
         parent::save();
     }
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:17,代码来源:QuoteWidget.php

示例5: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $this->addToolbar();
     $model = new Widget();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Widget'])) {
         $model->attributes = $_POST['Widget'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('form', array('model' => $model));
 }
开发者ID:nctruong,项目名称:inputen,代码行数:18,代码来源:WidgetController.php

示例6: actionAddwidget

 public function actionAddwidget()
 {
     if (isset($_POST['widget'])) {
         $model = new Widget();
         $model->attributes = $_POST['widget'];
         $model->taxonomy = 'widget';
         if ($model->save()) {
             $message = "<strong>Well done!</strong> You successfully Add widget";
             Yii::app()->user->setFlash('info', $message);
         } else {
             Yii::app()->user->setFlash('error', CHtml::errorSummary($model));
         }
         $this->redirect(array('edit', 'id' => $model->groups));
     } else {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:17,代码来源:WidgetmobileController.php

示例7: wizard

 public static function wizard($step = NULL)
 {
     // save the widget
     $widgetData = array();
     $widgetJson = json_encode($widgetData);
     $widget = new Widget();
     $widget->widget_name = 'API widget';
     $widget->widget_type = 'api';
     $widget->widget_provider = 'api';
     $widget->widget_source = $widgetJson;
     $widget->dashboard_id = Auth::user()->dashboards()->first()->id;
     $widget->position = '{"size_x":3,"size_y":3,"col":1,"row":1}';
     $widget->widget_ready = false;
     # widget needs data to load to show properly
     $widget->save();
     $apiKey = base64_encode(json_encode(array('wid' => $widget->id)));
     $url = 'https://dashboard.tryfruit.com/api/0.1/' . $apiKey . '/';
     return View::make('connect.connect-api')->with(array('url' => $url, 'isBackgroundOn' => Auth::user()->isBackgroundOn, 'dailyBackgroundURL' => Auth::user()->dailyBackgroundURL()));
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:19,代码来源:ApiHelper.php

示例8: wizard

 public static function wizard($step = NULL)
 {
     switch ($step) {
         case 'init':
             return View::make('connect.connect-text')->with(array('step' => 'select-source', 'isBackgroundOn' => Auth::user()->isBackgroundOn, 'dailyBackgroundURL' => Auth::user()->dailyBackgroundURL()));
             break;
         case 'source-selected':
             switch (Input::get('source')) {
                 case 'text':
                     return View::make('connect.connect-text')->with(array('step' => 'enter-text', 'isBackgroundOn' => Auth::user()->isBackgroundOn, 'dailyBackgroundURL' => Auth::user()->dailyBackgroundURL()));
                     break;
                 case 'google-spreadsheet-text-cell':
                     return Redirect::to('connect/new/googlespreadsheet/set-type')->with(array('type' => Input::get('source')));
                     break;
                 case 'google-spreadsheet-text-column-random':
                     return Redirect::to('connect/new/googlespreadsheet/set-type')->with(array('type' => Input::get('source')));
                     break;
                 default:
                     return Redirect::route('connect.connect')->with('error', 'Something went wrong.');
                     break;
             }
             break;
             # /source-selected
         # /source-selected
         case 'save-text':
             $widget = new Widget();
             $widget->widget_name = 'text widget';
             $widget->widget_type = 'text';
             $widget->widget_provider = 'text';
             $widget->widget_source = Input::get('text');
             $widget->widget_ready = true;
             $widget->dashboard_id = Auth::user()->dashboards()->first()->id;
             $widget->position = '{"size_x":6,"size_y":2,"col":1,"row":1}';
             $widget->save();
             return Redirect::route('dashboard.dashboard')->with('success', 'Text widget added.');
             break;
         default:
             return Redirect::route('connect.connect')->with('error', 'Something went wrong.');
             break;
     }
     # / switch ($step)
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:42,代码来源:TextHelper.php

示例9: wizard

 public static function wizard($step = NULL)
 {
     // save the widget
     $widgetData = array();
     $widgetJson = json_encode($widgetData);
     $widget = new Widget();
     $widget->widget_name = 'note widget';
     $widget->widget_type = 'note';
     $widget->widget_provider = 'note';
     $widget->widget_source = $widgetJson;
     $widget->dashboard_id = Auth::user()->dashboards()->first()->id;
     $widget->position = '{"size_x":3,"size_y":3,"col":1,"row":1}';
     $widget->save();
     // save an empty data line
     $text = new Data();
     $text->widget_id = $widget->id;
     $text->data_object = '';
     $text->date = Carbon::now()->toDateString();
     $text->save();
     return Redirect::route('dashboard.dashboard')->with('success', 'Note widget added.');
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:21,代码来源:NoteHelper.php

示例10: wizard

 public static function wizard($step = NULL)
 {
     switch ($step) {
         case 'init':
             return View::make('connect.connect-iframe')->with(array('isBackgroundOn' => Auth::user()->isBackgroundOn, 'dailyBackgroundURL' => Auth::user()->dailyBackgroundURL()));
             break;
         case 'set-url':
             $url = Input::get('fullURL');
             # save the widget
             $widget_data = array('iframeURL' => $url);
             $widget_json = json_encode($widget_data);
             $widget = new Widget();
             $widget->widget_name = 'iframe widget';
             $widget->widget_type = 'iframe';
             $widget->widget_provider = 'iframe';
             $widget->widget_source = $widget_json;
             $widget->dashboard_id = Auth::user()->dashboards()->first()->id;
             $widget->position = '{"size_x":6,"size_y":8,"col":1,"row":1}';
             $widget->save();
             return Redirect::route('dashboard.dashboard')->with('success', 'iframe widget added.');
             break;
     }
     # / switch ($step)
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:24,代码来源:IframeHelper.php

示例11: handle_op_create_new_badge

    private function handle_op_create_new_badge($params) {
	$title = $params['new_widget_name'];

	// sanitize name
	$new_name = preg_replace("~[^A-Za-z0-9\-\_]~", "_", $title);

	// make sure we don't already have one with that name
	try {
	    $this->user->load_widget($new_name);
	    // that should throw an exception; if it doesn't, the name is a duplicate
	    return new Badge_Redirect("$this->url?focus=new_widget_name&error=".urlencode("You already have a widget called $new_name. Please select another name."));
	} catch (PAException $e) {
	    switch ($e->getCode()) {
	    case ROW_DOES_NOT_EXIST:
		// Good - this is what we want (no existing widget with this name).
		break;
	    default:
		// A real error occurred; pass it through.
		throw $e;
	    }
	}

	$widget = new Widget($this->user->user_id);
	$widget->badge_tag = $new_name;
	$widget->title = $title;
	$widget->save();

	return new Badge_Redirect("$this->url/$new_name");
    }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:29,代码来源:badge_create.php

示例12: createwidget

 public function createwidget()
 {
     if (Input::has("idwidget")) {
         $widget = Widget::find(Input::get("idwidget"));
     } else {
         $widget = new Widget();
     }
     $widget->name = Input::get("name");
     $widget->description = Input::get("widgeteditor");
     $widget->save();
     return Redirect::route("widgetcreator");
 }
开发者ID:tvad911,项目名称:laravel-wordpress-menu-clone,代码行数:12,代码来源:HomeController.php

示例13: user

Model::factory('ModelWithFilters')->name_is('Bob')->find_many();
$expected = "SELECT * FROM `model_with_filters` WHERE `name` = 'Bob'";
Tester::check_query("Filter with arguments", $expected);
class Widget extends Model
{
}
$widget = Model::factory('Widget');
$widget->name = "Fred";
$widget->age = 10;
$widget->save();
$expected = "INSERT INTO `widget` (`name`, `age`) VALUES ('Fred', '10')";
Tester::check_query("Insert data", $expected);
$widget = new Widget();
$widget->name = "Bob";
$widget->age = 15;
$widget->save();
$expected = "INSERT INTO `widget` (`name`, `age`) VALUES ('Bob', '15')";
Tester::check_query("Insert data (alt)", $expected);
$widget = Model::factory('Widget')->find_one(1);
$widget->name = "Fred";
$widget->age = 10;
$widget->save();
$expected = "UPDATE `widget` SET `name` = 'Fred', `age` = '10' WHERE `id` = '1'";
Tester::check_query("Update data", $expected);
$widget = Model::factory('Widget')->find_one(1);
$widget->delete();
$expected = "DELETE FROM `widget` WHERE `id` = '1'";
Tester::check_query("Delete data", $expected);
class Profile extends Model
{
    public function user()
开发者ID:powerpak,项目名称:dakota,代码行数:31,代码来源:test_queries.php

示例14: dashboard_plugin_actions

function dashboard_plugin_actions()
{
    global $myUser, $_, $conf;
    switch ($_['action']) {
        case 'GET_WIDGETS':
            header('Content-type: application/json');
            require_once dirname(__FILE__) . '/Dashboard.class.php';
            require_once dirname(__FILE__) . '/Widget.class.php';
            $dashManager = new Dashboard();
            $dashManager->change(array('default' => '0'));
            $dashManager->change(array('default' => '1'), array('id' => $_['dashboard']));
            $widgetManager = new Widget();
            $model = array();
            Plugin::callHook("widgets", array(&$model));
            $widgets = $widgetManager->loadAll(array('dashboard' => $_['dashboard']), 'cell');
            $data = array();
            foreach ($widgets as $widget) {
                $data[] = array('data' => $widget->data, 'column' => $widget->column, 'id' => $widget->id, 'cell' => $widget->cell, 'minified' => $widget->minified, 'model' => $widget->model);
            }
            echo json_encode(array('model' => $model, 'data' => $data));
            break;
        case 'ADD_WIDGET':
            header('Content-type: application/json');
            require_once dirname(__FILE__) . '/Widget.class.php';
            $response = array();
            $widget = new Widget();
            $widget->data = json_encode($_POST['data']);
            $widget->column = $_['column'];
            $widget->cell = $_['cell'];
            $widget->model = $_['model'];
            $widget->dashboard = $_['view'];
            $widget->save();
            $response['id'] = $widget->id;
            echo json_encode($response);
            break;
        case 'MINIMIZE_WIDGET':
            header('Content-type: application/json');
            require_once dirname(__FILE__) . '/Widget.class.php';
            $response = array();
            $widgetManager = new Widget();
            $widgetManager = $widgetManager->getById($_['id']);
            $widgetManager->minified = 1;
            $widgetManager->save();
            echo json_encode($response);
            break;
        case 'MAXIMIZE_WIDGET':
            header('Content-type: application/json');
            require_once dirname(__FILE__) . '/Widget.class.php';
            $response = array();
            $widgetManager = new Widget();
            $widgetManager = $widgetManager->getById($_['id']);
            $widgetManager->minified = 0;
            $widgetManager->save();
            echo json_encode($response);
            break;
        case 'MOVE_WIDGET':
            header('Content-type: application/json');
            require_once dirname(__FILE__) . '/Widget.class.php';
            $response = array();
            $widgetManager = new Widget();
            foreach ($_['sort']['cells'] as $id => $sort) {
                $widgetManager->change(array('cell' => $sort['cell'], 'column' => $sort['column']), array('id' => $id));
            }
            echo json_encode($response);
            break;
        case 'DELETE_WIDGET':
            header('Content-type: application/json');
            require_once dirname(__FILE__) . '/Widget.class.php';
            $response = array();
            $widgetManager = new Widget();
            $widgetManager->delete(array('id' => $_['id']));
            echo json_encode($response);
            break;
        case 'DASH_ADD_VIEW':
            global $_, $myUser;
            require_once dirname(__FILE__) . '/Dashboard.class.php';
            $entity = new Dashboard();
            $entity->user = $myUser->getId();
            $entity->label = $_['viewName'];
            $entity->default = 0;
            $entity->save();
            header('location: setting.php?section=preference&block=dashboard');
            break;
        case 'DASH_DELETE_VIEW':
            global $_, $myUser;
            require_once dirname(__FILE__) . '/Dashboard.class.php';
            $entity = new Dashboard();
            $entity->delete(array('id' => $_['id']));
            header('location: setting.php?section=preference&block=dashboard');
            break;
    }
}
开发者ID:parrain27,项目名称:yana-server,代码行数:92,代码来源:dashboard.plugin.php

示例15: wizard

 public static function wizard($step = NULL)
 {
     # user is the authenticated user
     $user = Auth::user();
     # we will need a client for spreadsheet feeds + email + offline (to get a refreshtoken)
     $client = GooglespreadsheetHelper::setGoogleClient();
     switch ($step) {
         case 'init':
             # render wizard step #1
             return View::make('connect.connect-googlespreadsheet')->with(array('step' => 'choose-type', 'isBackgroundOn' => Auth::user()->isBackgroundOn, 'dailyBackgroundURL' => Auth::user()->dailyBackgroundURL()));
             break;
             # /case 'init'
         # /case 'init'
         case 'set-type':
             Log::info("session - " . Session::get('type'));
             # save the widget type in SESSION
             if (Input::get('type')) {
                 Session::put('type', Input::get('type'));
             }
             Log::info("session - " . Session::get('type'));
             if (!$user->isGoogleSpreadsheetConnected()) {
                 # if the user hasn't authorized with google
                 # go to google oauth page
                 $url = $client->createAuthUrl();
                 return Redirect::to($url);
                 break;
             } else {
                 # otherwise render the spreadsheet chooser wizard page
                 # get the spreadsheet list
                 $access_token = GooglespreadsheetHelper::getGoogleAccessToken($client, $user);
                 $serviceRequest = new DefaultServiceRequest($access_token);
                 ServiceRequestFactory::setInstance($serviceRequest);
                 $spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
                 $spreadsheetFeed = $spreadsheetService->getSpreadsheets();
                 # render choose-spreadsheet wizard step
                 return View::make('connect.connect-googlespreadsheet')->with(array('step' => 'choose-spreadsheet', 'spreadsheetFeed' => $spreadsheetFeed, 'isBackgroundOn' => Auth::user()->isBackgroundOn, 'dailyBackgroundURL' => Auth::user()->dailyBackgroundURL(), 'type' => Session::get('type')));
             }
             break;
             # / case 'set-type'
         # / case 'set-type'
         case 'set-spreadsheet':
             Log::info("session - " . Session::get('type'));
             if (Input::get('type')) {
                 Session::put('type', Input::get('type'));
             }
             Log::info("session - " . Session::get('type'));
             # save the spreadsheet ID in SESSION
             Session::put("spreadsheetId", Input::get('spreadsheetId'));
             # init service
             $access_token = GooglespreadsheetHelper::getGoogleAccessToken($client, $user);
             $serviceRequest = new DefaultServiceRequest($access_token);
             ServiceRequestFactory::setInstance($serviceRequest);
             # get the spreadsheet they asked for in the POST
             $spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
             $spreadsheet = $spreadsheetService->getSpreadsheetById(Input::get('spreadsheetId'));
             # save the spreadsheet name in SESSION
             Session::put("spreadsheetName", $spreadsheet->getTitle());
             # get the worksheet list for the selected spreadsheet
             $worksheetFeed = $spreadsheet->getWorksheets();
             # render choose-worksheet wizard step
             return View::make('connect.connect-googlespreadsheet')->with(array('step' => 'choose-worksheet', 'worksheetFeed' => $worksheetFeed, 'isBackgroundOn' => Auth::user()->isBackgroundOn, 'dailyBackgroundURL' => Auth::user()->dailyBackgroundURL(), 'type' => Session::get('type')));
             break;
             # /case 'set-spreadsheet'
         # /case 'set-spreadsheet'
         case 'set-worksheet':
             Log::info("session - " . Session::get('type'));
             if (Input::get('type')) {
                 Session::put('type', Input::get('type'));
             }
             Log::info("session - " . Session::get('type'));
             # save the worksheet name in SESSION
             Session::put("worksheetName", Input::get('worksheetName'));
             # save the widget
             $widget_data = array('googleSpreadsheetId' => Session::get('spreadsheetId'), 'googleWorksheetName' => Session::get('worksheetName'));
             $widget_json = json_encode($widget_data);
             $widget = new Widget();
             $widget->widget_name = Session::get('worksheetName') . ' - ' . Session::get('spreadsheetName');
             $widget->widget_type = Session::get('type');
             $widget->widget_provider = 'googlespreadsheet';
             $widget->widget_source = $widget_json;
             $widget->widget_ready = false;
             $widget->dashboard_id = $user->dashboards()->first()->id;
             $widget->position = '{"size_x":3,"size_y":4,"col":1,"row":1}';
             $widget->save();
             return Redirect::route('dashboard.dashboard')->with('success', 'Google Spreadsheet widget added.');
             break;
             # / case 'set-worksheet'
         # / case 'set-worksheet'
         default:
             // input has no step, this is the google auth return part
             # we got a code in GET from google
             if (Input::has('code')) {
                 # lets get an access token
                 try {
                     $client->authenticate(Input::get('code'));
                 } catch (Exception $e) {
                     GooglespreadsheetHelper::disconnect();
                     return Redirect::route('connect.connect')->with('error', 'Something went wrong, try again please.');
                 }
                 $credentials = $client->getAccessToken();
//.........这里部分代码省略.........
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:101,代码来源:GoogleSpreadsheetHelper.php


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