示例#1
0
 /**
  * @before _secure, changeLayout, _admin
  */
 public function imagetextitem($imagetext_id)
 {
     $this->seo(array("title" => "Looklike Content", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $imagetext = ImageText::first(array("id = ?" => $imagetext_id));
     if (RequestMethods::post("action") == "shuffle") {
         $imagetextitem = new ImageTextItem(array("imagetext_id" => $imagetext->id, "meta_key" => "gender", "meta_value" => RequestMethods::post("gender"), "image" => $this->_upload("image"), "live" => true, "text" => RequestMethods::post("text")));
         $imagetextitem->save();
         $view->set("success", true);
     }
     $imagetextitems = ImageTextItem::all(array("imagetext_id = ?" => $imagetext->id));
     $view->set("imagetext", $imagetext);
     $view->set("imagetextitems", $imagetextitems);
 }
示例#2
0
 /**
  * @param object $game
  * @param object $campaign object of class \Campaign
  * @param boolean $play_agin If user wishes to play the game again
  *
  * @return string String containing the filename of the resultant image
  */
 protected function _imagetextprocess($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;
     }
     $path = APP_PATH . '/public/assets/uploads/images/';
     $vars = $this->_setup($path, $game, $participant);
     $dest = $vars['dest'];
     $items = ImageTextItem::all(array("imagetext_id = ?" => $game->id, "meta_key = ?" => "gender", "meta_value = ?" => strtolower($this->user->gender)));
     $key = rand(0, count($items) - 1);
     $item = $items[$key];
     imagecopymerge($dest, $vars['usr'], $game->usr_x, $game->usr_y, 0, 0, $game->usr_w, $game->usr_h, 100);
     $item_img = Shared\Image::resize($path . $item->image, $game->src_w, $game->src_h);
     $item_res = Shared\Image::resource($item_img);
     $font = APP_PATH . '/public/assets/fonts/monaco.ttf';
     $tt_color = $this->_makeColor($dest, $game->txt_color);
     imagettftext($dest, $game->txt_size, 0, $game->txt_x, $game->txt_y, $tt_color, $font, $item->text);
     $tt_color = $this->_makeColor($dest, $game->utxt_color);
     imagettftext($dest, $game->utxt_size, 0, $game->utxt_x, $game->utxt_y, $tt_color, $font, $this->user->name);
     imagecopymerge($dest, $item_res, $game->src_x, $game->src_y, 0, 0, $game->src_w, $game->src_h, 100);
     unlink($vars['file']);
     Shared\Image::create($dest, $vars['file']);
     $this->_saveParticipant($participant, $campaign, $vars);
     return $participant->image;
 }