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


PHP Participant::first方法代碼示例

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


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

示例1: play

 /**
  * @before _secure
  */
 public function play()
 {
     $this->seo(array("title" => "Play Game", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $session = Registry::get("session");
     $campaign = $session->get('Game\\Authorize:$campaign');
     if (!$campaign) {
         $this->redirect("/index.html");
     }
     $session->erase('Game\\Authorize:$campaign');
     $model = $campaign->type;
     $game = $model::first(array("id = ?" => $campaign->type_id));
     switch ($model) {
         case 'imagetext':
             $img = $this->_imagetextprocess($game, $campaign);
             break;
         case 'image':
             $img = $this->_imageprocess($game, $campaign);
             break;
         case 'text':
             $img = $this->_textprocess($game, $campaign);
             break;
         case 'shuffle':
             $img = $this->_shuffleprocess($game, $campaign);
             break;
     }
     $participant = Participant::first(array("user_id = ?" => $this->user->id, "campaign_id = ?" => $campaign->id));
     $facebook = new Curl();
     $facebook->post('https://graph.facebook.com/?id=' . "http://" . $_SERVER["HTTP_HOST"] . "/game/result/" . $participant->id . '&scrape=true');
     $facebook->close();
     $domain = Meta::first(array("property = ?" => "domain", "live = ?" => true));
     $items = Participant::all(array(), array("DISTINCT campaign_id"), "created", "desc", 3, 1);
     $view->set("items", $items);
     $view->set("img", $img);
     $view->set("participant", $participant);
     $view->set("campaign", $campaign)->set("domain", $domain);
 }
開發者ID:SwiftDeal,項目名稱:fbfunapp,代碼行數:40,代碼來源:game.php

示例2: _shuffleprocess

 protected function _shuffleprocess($game, $campaign, $play_again = true)
 {
     $participant = Participant::first(array("user_id = ?" => $this->user->id, "campaign_id = ?" => $campaign->id));
     if ($participant && !$play_again) {
         return $participant->image;
     }
     $items = ShuffleItem::all(array("shuffle_id = ?" => $game->id, "meta_key = ?" => "gender", "meta_value = ?" => strtolower($this->user->gender)));
     $key = rand(0, count($items) - 1);
     $item = $items[$key];
     $vars = array();
     $user = $this->user;
     $path = APP_PATH . '/public/assets/uploads/images/';
     $user_img = "{$path}user-" . $user->fbid . ".jpg";
     if (!file_exists($user_img)) {
         if (!copy('http://graph.facebook.com/' . $user->fbid . '/picture?width=' . $item->usr_w . '&height=' . $item->usr_h, $user_img)) {
             die('Could not copy image');
         }
     }
     $src_file = $path . $item->base_im;
     $extension = pathinfo($src_file, PATHINFO_EXTENSION);
     if ($participant) {
         $filename = $participant->image;
     } else {
         $filename = Shared\Markup::uniqueString() . ".{$extension}";
     }
     $final_img = $path . $filename;
     copy($src_file, $final_img);
     $dest = Shared\Image::resource($final_img);
     $vars['file'] = $final_img;
     $vars['filename'] = $filename;
     $img = Shared\Image::resize($user_img, $item->usr_w, $item->usr_h);
     $vars['usr'] = Shared\Image::resource($img);
     imagecopymerge($dest, $vars['usr'], $item->usr_x, $item->usr_y, 0, 0, $item->usr_w, $item->usr_h, 100);
     // add text
     $tt_color = $this->_makeColor($dest, $item->txt_color);
     $font = APP_PATH . '/public/assets/fonts/monaco.ttf';
     imagettftext($dest, $item->txt_size, 0, $item->txt_x, $item->txt_y, $tt_color, $font, $user->name);
     Shared\Image::create($dest, $vars['file']);
     $this->_saveParticipant($participant, $campaign, $vars);
     return $participant->image;
 }
開發者ID:SwiftDeal,項目名稱:fbfunapp,代碼行數:41,代碼來源:play.php


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