當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Draft::save方法代碼示例

本文整理匯總了PHP中Draft::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Draft::save方法的具體用法?PHP Draft::save怎麽用?PHP Draft::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Draft的用法示例。


在下文中一共展示了Draft::save方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: move_to_drafts

 public function move_to_drafts($dummy)
 {
     $rules = array('subject' => 'required|max:128', 'emailbody' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json(array('validation' => $validator->messages()->toArray()));
     } else {
         $draft = new Draft();
         $draft->subject = Input::get('subject');
         $draft->message = Input::get('emailbody');
         $draft->save();
         return Response::json(array('success' => 'Email successfully moved to drafts. You can access it by navigating to the drafts tab.'));
     }
 }
開發者ID:shinichi81,項目名稱:Laravel4-Newsletter-Application,代碼行數:14,代碼來源:EmailController.php

示例2: store

 public static function store()
 {
     self::check_logged_in();
     $user_logged_in = self::get_user_logged_in();
     $params = $_POST;
     $attributes = array('name' => $params['name'], 'laatija_id' => $user_logged_in->id, 'hero1' => $params['hero1'], 'hero2' => $params['hero2'], 'hero3' => $params['hero3'], 'hero4' => $params['hero4'], 'hero5' => $params['hero5'], 'vaikeus' => $params['vaikeus'], 'suunnitelma' => $params['suunnitelma']);
     $draft = new Draft($attributes);
     $errors = $draft->errors();
     if (count($errors) == 0) {
         $draft->save();
         Redirect::to('/drafts' . $draft->id, array('message' => 'Drafti on lisätty arkistoon!'));
     } else {
         $heroes = Hero::all();
         View::make('drafts/new.html', array('errors' => $errors, 'attributes' => $attributes, 'heroes' => $heroes));
     }
 }
開發者ID:sasumaki,項目名稱:Tsoha-Bootstrap,代碼行數:16,代碼來源:DraftController.php

示例3: index

 function index()
 {
     list($params, $id) = $this->parse_params(func_get_args());
     $theme = new Theme();
     $themes = $theme->read(true);
     if ($this->method == 'post' && isset($_POST['theme'])) {
         $t = $_POST['theme'];
         if (isset($themes[$t])) {
             $d = new Draft();
             $d->where('draft', 1)->update('draft', 0);
             $d->where('path', $t)->get();
             $d->path = $t;
             $d->draft = 1;
             if (isset($_POST['refresh'])) {
                 $d->init_draft_nav($_POST['refresh']);
             }
             $d->save();
             $this->redirect('/drafts');
         } else {
             // error
         }
     } else {
         if ($this->method == 'delete' && isset($_POST['theme'])) {
             $d = new Draft();
             $d->where('path', $_POST['theme'])->get();
             if ($d->exists()) {
                 $d->delete();
             }
             exit;
         }
     }
     $final = array();
     $d = new Draft();
     $drafts = $d->get_iterated();
     foreach ($drafts as $d) {
         if (isset($themes[$d->path])) {
             $final[] = array('id' => $d->id, 'theme' => $themes[$d->path], 'published' => (bool) $d->current, 'active' => (bool) $d->draft, 'created_on' => (int) $d->created_on, 'modified_on' => (int) $d->modified_on);
         }
     }
     $this->set_response_data($final);
 }
開發者ID:Atomox,項目名稱:benhelmerphotography,代碼行數:41,代碼來源:drafts.php

示例4: publish

 function publish($draft_id = false)
 {
     if (!$draft_id) {
         $this->error('400', 'Draft ID parameter not present.');
         return;
     }
     if ($this->method === 'post') {
         $draft = new Draft();
         $draft->where('id', $draft_id)->get();
         if ($draft->exists()) {
             $draft->where('current', 1)->update('current', 0);
             $draft->live_data = $draft->data;
             $draft->current = 1;
             $draft->save();
             $guid = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $draft->path . DIRECTORY_SEPARATOR . 'koken.guid';
             if (file_exists($guid)) {
                 $s = new Setting();
                 $s->where('name', 'uuid')->get();
                 $curl = curl_init();
                 curl_setopt($curl, CURLOPT_URL, KOKEN_STORE_URL . '/register?uuid=' . $s->value . '&theme=' . trim(file_get_contents($guid)));
                 curl_setopt($curl, CURLOPT_HEADER, 0);
                 curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
                 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                 $r = curl_exec($curl);
                 curl_close($curl);
             }
             exit;
         } else {
             $this->error('404', "Draft not found.");
             return;
         }
     } else {
         $this->error('400', 'This endpoint only accepts tokenized POST requests.');
         return;
     }
 }
開發者ID:Caldis,項目名稱:htdocs,代碼行數:38,代碼來源:sites.php

示例5: sendMessage

 public function sendMessage()
 {
     $recipient = Input::get('recipient');
     $subject = Input::get('subject');
     $message = Input::get('message');
     $submit_type = Input::get('submit_type');
     $now = new DateTime();
     $validation = Validator::make(['recipient' => Input::get('recipient'), 'subject' => Input::get('subject'), 'message' => Input::get('message')], ['recipient' => 'required', 'subject' => 'required|max:40|min:4', 'message' => 'required|max:120|min:10']);
     if ($validation->fails()) {
         return 'Error Happend';
     } else {
         try {
             if ($submit_type == "Send") {
                 $inbox = new Inbox();
                 $inbox->sender_id = Auth::id();
                 $inbox->receiver_id = $recipient;
                 $inbox->unread = 1;
                 $inbox->subject = $subject;
                 $inbox->message = $message;
                 $inbox->time = $now;
                 $inbox->save();
                 return Redirect::route('home');
             } elseif ($submit_type == "Draft") {
                 $draft = new Draft();
                 $draft->creator_id = Auth::id();
                 $draft->send_to_id = $recipient;
                 $draft->subject = $subject;
                 $draft->message = $message;
                 $draft->time = $now;
                 $draft->save();
                 return Redirect::route('home');
             }
         } catch (Exception $e) {
             echo $e;
         }
     }
 }
開發者ID:Nabil5352,項目名稱:Team-Management-Application,代碼行數:37,代碼來源:HomeController.php


注:本文中的Draft::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。