예제 #1
0
 public function embedAction()
 {
     $request = $this->getRequest();
     $pin_id = $request->getRequest('pin_id');
     $pin = new Model_Pins_Pin($pin_id);
     if (!$pin->count()) {
         $this->forward('error', 'error404');
     }
     $pin = $pin->data;
     $pin = array_merge((array) $pin, Helper_Pin::formatPinData((array) $pin, true));
     $max_width = $max_height = 0;
     $image_original = $image_thumb = $size_pref = '';
     if (isset($pin['pin_thumbs']) && is_array($pin['pin_thumbs'])) {
         foreach ($pin['pin_thumbs'] as $key => $data) {
             if (strpos($key, 'thumb_width_') !== false && $data) {
                 $max_width = max($max_width, $data);
                 if ($data > 150 && !$size_pref) {
                     $size_pref = str_replace('thumb_width_', '', $key);
                 }
             }
             if (strpos($key, 'thumb_height_') !== false && $data) {
                 $max_height = max($max_height, $data);
             }
             if (strpos($key, 'thumb_original_') !== false && $data) {
                 $image_original = $data;
             }
             if (strpos($key, 'thumb_image_') !== false && $data) {
                 $image_thumb = $data;
             }
         }
     }
     if (!$size_pref) {
         $this->forward('error', 'error404');
     }
     $pin['thumb'] = $image_thumb;
     $pin['thumb_width'] = $pin['pin_thumbs']['thumb_width_' . $size_pref];
     $pin['thumb_height'] = $pin['pin_thumbs']['thumb_height_' . $size_pref];
     $pin['thumb_width_max'] = $max_width;
     $pin['thumb_height_max'] = $max_height;
     $pin['original'] = $image_original;
     $this->view->pin = $pin;
     $this->noLayout(true);
 }
예제 #2
0
 public function fromatList($pin)
 {
     static $extensions = null;
     if ($extensions === null) {
         $extensions = Model_Extensions::getByMethod('pin_list');
     }
     $pin = array_merge($pin, Helper_Pin::formatPinData($pin));
     $pin_data = array('template' => 'pins', 'pin_id' => $pin['pin_id'], 'pin_row' => $pin['pin_pin_row'], 'category_id' => $pin['board_category_id'], 'loged' => JO_Session::get('user[user_id]') ? true : false, 'is_liked' => $pin['pin_is_liked'], 'from' => $pin['pin_from'], 'vip' => $pin['pin_vip'], 'gift' => $pin['pin_gift'], 'price' => $pin['pin_price_formated'], 'date_added' => $pin['pin_date_added'], 'is_video' => $pin['pin_is_video'], 'description' => str_replace('&', '&', $pin['pin_description']), 'likes' => $pin['pin_likes'], 'comments' => $pin['pin_comments'], 'repins' => $pin['pin_repins'], 'set_activity_title' => isset($pin['set_activity_title']) ? $pin['set_activity_title'] : false, 'via_profile' => $pin['via_profile'] ? $pin['via_profile'] : false, 'self_profile' => $pin['self_profile'], 'author_profile' => array('avatars' => $pin['user_avatars'], 'fullname' => $pin['user_fullname'], 'user_id' => $pin['user_user_id'], 'href' => $pin['user_href']), 'url_repin' => $pin['pin_url_repin'], 'url_edit' => $pin['pin_edit'], 'url_like' => $pin['pin_url_like'], 'url_comment' => $pin['pin_url_comment'], 'pin_url' => $pin['pin_href'], 'board_url' => $pin['pin_onto_href'], 'pin_comments_data' => $pin['pin_latest_comments'] ? $pin['pin_latest_comments'] : false, 'images' => $pin['pin_thumbs'], 'text_vip' => $this->translate('VIP'), 'text_add_comment' => $this->translate('Add a comment...'), 'text_delete_comment' => $this->translate('Delete Comment'), 'text_via' => $pin['via_profile'] ? $this->translate('via') : '', 'text_onto' => $this->translate('onto'), 'text_repin' => $this->translate('Repin'), 'text_edit' => $this->translate('Edit'), 'text_like_unlike' => $pin['pin_is_liked'] ? $this->translate('Unlike') : $this->translate('Like'), 'text_comment' => $this->translate('Comment'), 'text_total_likes' => sprintf($this->translate('%d like' . ($pin['pin_likes'] == 1 ? '' : 's')), $pin['pin_likes']), 'text_total_comments' => sprintf($this->translate('%d comment' . ($pin['pin_comments'] == 1 ? '' : 's')), $pin['pin_comments']), 'text_total_repins' => sprintf($this->translate('%d repin' . ($pin['pin_repins'] == 1 ? '' : 's')), $pin['pin_repins']), 'text_date_dif' => sprintf($this->translate('%d %s ago'), $pin['pin_date_dif']['value'], $this->translate($pin['pin_date_dif']['key'])), 'text_board' => $pin['board_title'], 'text_all_comments' => $pin['pin_comments'] && $pin['pin_comments'] > (int) Helper_Config::get('config_comments_list') ? sprintf($this->translate('All %d comments...'), $pin['pin_comments']) : false);
     if ($extensions) {
         $front = JO_Front::getInstance();
         foreach ($extensions as $id => $ext) {
             $pin_data_ext = call_user_func(array($front->formatModuleName('model_' . $ext . '_pin'), 'listing'), $pin, $pin_data);
             if ($pin_data_ext && is_array($pin_data_ext)) {
                 $pin_data = array_merge($pin_data, $pin_data_ext);
             }
         }
     }
     return $pin_data;
 }