Exemple #1
0
 protected function _imageprocess($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 = ImageItem::all(array("image_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);
     $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->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;
 }
Exemple #2
0
 /**
  * @before _secure, changeLayout, _admin
  */
 public function imageitem($image_id)
 {
     $this->seo(array("title" => "Image Content", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $image = Image::first(array("id = ?" => $image_id));
     if (RequestMethods::post("action") == "shuffle") {
         $item = new ImageItem(array("image_id" => $image->id, "meta_key" => RequestMethods::post("meta_key", ""), "meta_value" => RequestMethods::post("meta_value", ""), "image" => $this->_upload("image"), "live" => true));
         $item->save();
     }
     $items = ImageItem::all(array("image_id = ?" => $image->id));
     $view->set("image", $image);
     $view->set("items", $items);
 }