Example #1
0
 /**
  * @before _secure, changeLayout, _admin
  */
 public function textitem($text_id)
 {
     $this->seo(array("title" => "ImageText Content", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $text = Text::first(array("id = ?" => $text_id));
     if (RequestMethods::post("action") == "shuffle") {
         $item = new TextItem(array("text_id" => $text->id, "meta_key" => "", "meta_value" => "", "live" => true, "text" => RequestMethods::post("text")));
         $item->save();
     }
     $items = TextItem::all(array("text_id = ?" => $text->id));
     $view->set("text", $text);
     $view->set("items", $items);
 }
Example #2
0
 protected function _textprocess($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 = TextItem::all(array("text_id = ?" => $game->id));
     $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);
     // replace $font with font path
     $font = APP_PATH . '/public/assets/fonts/monaco.ttf';
     $tt_color = $this->_makeColor($dest, $game->txt_color);
     imagettftext($dest, $game->txt_size, $game->txt_angle, $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);
     unlink($vars['file']);
     Shared\Image::create($dest, $vars['file']);
     $this->_saveParticipant($participant, $campaign, $vars);
     return $participant->image;
 }