public static function returnHtmlDetail($pin, $banners = false) { //XPER: función que carga PIN static $view = null, $model_images = null, $request = null; if ($view === null) { $view = JO_View::getInstance(); } if ($model_images === null) { $model_images = new Helper_Images(); } if ($request === null) { $request = JO_Request::getInstance(); } $next_pin = Model_Pins::getNextPin($pin['pin_id']); if ($next_pin) { $view->next_navigation_pin = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $next_pin['pin_id']); } $prev_pin = Model_Pins::getPrevPin($pin['pin_id']); if ($prev_pin) { $view->prev_navigation_pin = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $prev_pin['pin_id']); } $image = call_user_func(array(self::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_B'); if ($image) { $pin['thumb'] = $image['image']; $pin['thumb_width'] = $image['width']; $pin['thumb_height'] = $image['height']; $pin['original_image'] = $image['original']; } else { JO_Action::getInstance()->forward('error', 'error404'); } $image = call_user_func(array(self::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_D'); if ($image) { $pin['popup'] = $image['image']; $pin['popup_width'] = $image['width']; $pin['popup_height'] = $image['height']; $pin['original_image'] = $image['original']; } else { JO_Action::getInstance()->forward('error', 'error404'); } $pin_description = self::descriptionFix($pin['description']); $pin['real_description'] = self::descriptionFix($pin['description']); $pin['description'] = self::descriptionFix($pin['description']); $pin['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']); $pin['pinmarklet_href'] = WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_pinmarklet')); $pin['onto_href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin['user_id'] . '&board_id=' . $pin['board_id']); $pin['price_formated'] = WM_Currency::format($pin['price']); $view->author = $pin['user']; $avatar = Helper_Uploadimages::avatar($pin['user'], '_A'); $view->author['avatar'] = $avatar['image']; $view->author['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['user_id']); $view->comments = array(); if ($pin['latest_comments']) { foreach ($pin['latest_comments'] as $key => $comment) { if (!isset($comment['user']['store'])) { unset($pin['latest_comments'][$key]); continue; } $avatar = Helper_Uploadimages::avatar($comment['user'], '_A'); $comment['user']['avatar'] = $avatar['image']; $comment['user']['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $comment['user_id']); $comment['delete'] = ''; if (!Model_Pins::commentIsReported($comment['comment_id'])) { $comment['report'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=reportComment&comment_id=' . $comment['comment_id']); } else { $comment['report'] = ''; } if (JO_Session::get('user[user_id]')) { if (JO_Session::get('user[is_admin]') || JO_Session::get('user[user_id]') == $comment['user_id'] || JO_Session::get('user[user_id]') == $pin['board_data']['user_id']) { $comment['delete'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=deleteComment&comment_id=' . $comment['comment_id']); } } $view->comments[] = $comment; } } $view->via = array(); $view->via_repin = array(); if ($pin['via'] && $pin['user_via']) { $view->via = array('profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['via']), 'fullname' => $pin['user_via']['fullname']); } $view->replin_info = false; if ($request->isXmlHttpRequest()) { $view->target_repin = false; if ($pin['repin_from']) { $pin_repin = Model_Pins::getPin($pin['repin_from']); if ($pin_repin) { $view->source = array(); $view->source['source'] = $pin_repin['board']; $pin['from'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_repin['user_id'] . '&board_id=' . $pin_repin['board_id']); $view->target_repin = true; } else { $view->source = Model_Source::getSource($pin['source_id']); } } else { $view->source = Model_Source::getSource($pin['source_id']); } } else { $view->source = Model_Source::getSource($pin['source_id']); if ($pin['repin_from']) { $repina = Model_Pins::getPin($pin['repin_from']); if ($repina) { $view->replin_info = array('pin_href' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['repin_from']), 'profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $repina['user_id']), 'fullname' => $repina['user']['fullname']); } } } if ($pin['from'] && !preg_match('/^https?:\\/\\//', $pin['from'])) { $pin['from'] = 'http://' . $pin['from']; } if ($pin['from_repin'] && !preg_match('/^https?:\\/\\//', $pin['from_repin'])) { $pin['from_repin'] = 'http://' . $pin['from_repin']; } $pin['onto_board'] = $pin['onto_board2'] = array(); $pin['originally_pinned'] = $pin['originally_pinned2'] = array(); if ($request->isXmlHttpRequest()) { $pin['onto_board'] = self::getBoardPins($pin['board_id']); $pin['originally_pinned'] = self::getOriginallyPinned($pin['via'] ? $pin['via'] : $pin['user_id']); } else { $pin['onto_board2'] = self::getBoardPins($pin['board_id']); $pin['originally_pinned2'] = self::getOriginallyPinned($pin['via'] ? $pin['via'] : $pin['user_id']); } if ($view->source && $request->isXmlHttpRequest()) { $pin['source_pins'] = self::getSourcePins($pin['source_id']); } else { $pin['source_pins'] = array(); } $pin['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $pin['board_id'])); $pin['userIsFollow'] = Model_Users::isFollowUser($pin['user_id']); if ($pin['via']) { $pin['userViaIsFollow'] = Model_Users::isFollowUser($pin['via']); } else { $pin['userViaIsFollow'] = Model_Users::isFollowUser($pin['user_id']); } $pin['userFollowIgnore'] = $pin['user_id'] == JO_Session::get('user[user_id]'); $pin['userViaFollowIgnore'] = ($pin['via'] ? $pin['via'] : $pin['user_id']) == JO_Session::get('user[user_id]'); $view->follow = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $pin['user_id'] . '&board_id=' . $pin['board_id']); $view->follow_user = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['user_id']); if ($pin['via']) { $view->follow_user_via = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['via']); } else { $view->follow_user_via = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['user_id']); } $view->get_user_friends = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends'); if (JO_Session::get('user[user_id]')) { $view->enable_follow = $pin['user_id'] != JO_Session::get('user[user_id]'); } else { $view->enable_follow = false; } if (JO_Session::get('user[user_id]')) { $pin['url_like'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=like&pin_id=' . $pin['pin_id']); $pin['url_repin'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=repin&pin_id=' . $pin['pin_id']); $pin['url_comment'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=comment&pin_id=' . $pin['pin_id']); $pin['comment'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=comment&pin_id=' . $pin['pin_id']); $pin['edit'] = JO_Session::get('user[user_id]') == $pin['user_id'] ? WM_Router::create($request->getBaseUrl() . '?controller=pin&action=edit&pin_id=' . $pin['pin_id']) : false; } else { $pin['url_like'] = $pin['url_repin'] = $pin['url_comment'] = $pin['comment'] = WM_Router::create($request->getBaseUrl() . '?controller=landing'); $pin['edit'] = false; } $likes = self::getPinLikes($pin['pin_id']); $pin['likes'] = $likes['data']; $pin['likes_total'] = $likes['total']; $pin['repins'] = self::getRePins($pin['pin_id']); $pin['pinIsReported'] = Model_Pins::pinIsReported($pin['pin_id']); $date_dif = array_shift(WM_Date::dateDiff($pin['date_added'], time())); $pin['date_dif'] = $date_dif; $view->loged = JO_Session::get('user[user_id]'); $view->site_name = JO_Registry::get('site_name'); if ($view->loged) { $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_A'); $view->self_avatar = $avatar['image']; $view->self_profile = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $view->loged); $view->self_fullname = JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]'); } if ($pin['is_video']) { $auto = new Helper_AutoEmbed(); if ($pin['repin_from'] && $auto->parseUrl($pin['from_repin'])) { $auto->setWidth('100%'); $auto->setHeight('350'); $pin['video_code'] = $auto->getEmbedCode(); $attr = $auto->getObjectAttribs(); $pin['thumb_width'] = $attr['width']; $pin['thumb_height'] = $attr['height']; } else { if ($auto->parseUrl($pin['from'])) { $auto->setWidth('100%'); $auto->setHeight('350'); $pin['video_code'] = $auto->getEmbedCode(); $attr = $auto->getObjectAttribs(); $pin['thumb_width'] = $attr['width']; $pin['thumb_height'] = $attr['height']; } else { $pin['is_video'] = false; } } } else { $auto = new Helper_AutoEmbed(); if ($pin['repin_from'] && $auto->parseUrl($pin['from_repin'])) { $auto->setWidth('100%'); $auto->setHeight('350'); $pin['video_code'] = $auto->getEmbedCode(); $attr = $auto->getObjectAttribs(); $pin['thumb_width'] = $attr['width']; $pin['thumb_height'] = $attr['height']; $pin['is_video'] = true; } else { if ($auto->parseUrl($pin['from'])) { $auto->setWidth('100%'); $auto->setHeight('350'); $pin['video_code'] = $auto->getEmbedCode(); $attr = $auto->getObjectAttribs(); $pin['thumb_width'] = $attr['width']; $pin['thumb_height'] = $attr['height']; $pin['is_video'] = true; } else { $pin['is_video'] = false; } } } $view->pin_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']); $view->login_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&next=' . urlencode($pin['href'])); Model_Pins::updateViewed($pin['pin_id']); JO_Layout::getInstance()->meta_title = $pin['board'] . ' - ' . strip_tags(html_entity_decode($pin_description)); JO_Layout::getInstance()->placeholder('pin_url', $view->replin_info ? $view->replin_info['pin_href'] : $view->pin_url); JO_Layout::getInstance()->placeholder('pin_description', $pin_description); $params = array(); $params['content'] = html_entity_decode($pin['description'] . ' ' . $pin['board'], ENT_QUOTES, 'UTF-8'); //page content $keywords = new WM_Keywords($params); $get_keywords = $keywords->get_keywords(); if ($get_keywords) { JO_Layout::getInstance()->placeholder('keywords', $get_keywords); } JO_Layout::getInstance()->placeholder('pin_image', $pin['thumb']); JO_Layout::getInstance()->placeholder('board_title', $pin['board']); $view->banners = array(); if ($banners) { foreach ($banners as $banner1) { foreach ($banner1 as $e) { $e['html'] = html_entity_decode($e['html']); $view->banners[] = $e; } } } $view->pin = $pin; return $view->render('pinBoxDetail', 'pin'); }
public static function formatPinData($pin, $detail = false) { static $model_images = null, $request = null; if ($model_images === null) { $model_images = new Helper_Images(); } if ($request === null) { $request = JO_Request::getInstance(); } ///////////////////////////////////// PIN INFO ///////////////////////////////////// $pin['pin_id'] = $pin['pin_pin_id']; $pin['image'] = $pin['pin_image']; //url's $pin['pin_url_embed'] = WM_Router::pinAction($pin['pin_pin_id'], 'embed'); if (!JO_Session::get('user[user_id]')) { $login_url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); if (Helper_Config::get('enable_free_registration')) { //$login_url = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=register' ); } $pin['pin_url_email'] = $pin['pin_url_report'] = $pin['pin_url_like'] = $pin['pin_url_repin'] = $pin['pin_url_comment'] = $login_url; $pin['pin_edit'] = false; } else { $pin['pin_url_email'] = WM_Router::pinAction($pin['pin_pin_id'], 'email'); $pin['pin_url_report'] = WM_Router::pinAction($pin['pin_pin_id'], 'report'); $pin['pin_url_like'] = WM_Router::pinAction($pin['pin_pin_id'], 'like'); $pin['pin_url_repin'] = WM_Router::pinAction($pin['pin_pin_id'], 'repin'); $pin['pin_url_comment'] = WM_Router::pinAction($pin['pin_pin_id']); $pin['pin_edit'] = JO_Session::get('user[user_id]') == $pin['pin_user_id'] ? WM_Router::pinAction($pin['pin_pin_id'], 'edit') : false; } //$pin['pin_description'] = self::descriptionFix($pin['pin_description']); $pin['pin_href'] = WM_Router::pinAction($pin['pin_pin_id']); if ($pin['pin_gift']) { $pin['pin_price_formated'] = WM_Currency::format($pin['pin_price']); } else { $pin['pin_price_formated'] = 0; } //return all image sizes $pin['pin_thumbs'] = Helper_Uploadimages::pinThumbs($pin); //array_merge($pin, Helper_Uploadimages::pinThumbs($pin)); $date_dif = array_shift(WM_Date::dateDiff($pin['pin_date_added'], time())); $pin['pin_date_dif'] = $date_dif; /* URL'S*/ $pin['pin_onto_href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin['board_user_id'] . '&board_id=' . $pin['board_board_id']); ////follow urls $pin['board_follow_href'] = $pin['user_follow_href'] = $pin['via_follow_href'] = false; if (JO_Session::get('user[user_id]') ? $pin['board_user_id'] != JO_Session::get('user[user_id]') : false) { $pin['board_follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $pin['board_user_id'] . '&board_id=' . $pin['board_board_id']); } if (JO_Session::get('user[user_id]') ? $pin['user_user_id'] != JO_Session::get('user[user_id]') : false) { $pin['user_follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['user_user_id']); } if ($pin['via_user_id']) { if (JO_Session::get('user[user_id]') ? $pin['via_user_id'] != JO_Session::get('user[user_id]') : false) { $pin['via_follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['via_user_id']); } } else { if (JO_Session::get('user[user_id]') ? $pin['user_user_id'] != JO_Session::get('user[user_id]') : false) { $pin['via_follow_href'] = $pin['user_follow_href']; } } if ($detail) { $pin['pin_next_href'] = ''; if (isset($pin['pin_next']) && $pin['pin_next']) { $pin['pin_next_href'] = WM_Router::pinAction($pin['pin_next']); } $pin['pin_prev_href'] = ''; if (isset($pin['pin_prev']) && $pin['pin_prev']) { $pin['pin_prev_href'] = WM_Router::pinAction($pin['pin_prev']); } } if (Helper_Config::get('config_comments_list') && !$detail && $pin['pin_comments']) { $latest_comments = Model_Comments::getLatestComments2($pin['pin_latest_comments']); $pin['pin_latest_comments'] = array(); $user_id = JO_Session::get('user[user_id]'); $is_admin = JO_Session::get('user[is_admin]'); $is_developer = JO_Session::get('user[is_developer]'); foreach ($latest_comments as $key => $comment) { $user_avatars = Helper_Uploadimages::userAvatars(array('avatar' => $comment['avatar'], 'store' => $comment['store'], 'user_id' => $comment['user_id'])); $enable_delete = false; if ($is_admin) { $enable_delete = true; } elseif ($is_developer) { $enable_delete = true; } elseif ($user_id == $comment['user_id']) { $enable_delete = true; } elseif ($comment['pin_user_id'] == $user_id) { $enable_delete = true; } $delete = false; if ($enable_delete) { $delete = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=deleteComment&comment_id=' . $comment['comment_id']); } $pin['pin_latest_comments'][] = array('user' => array('profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $comment['user_id']), 'avatars' => $user_avatars, 'fullname' => $comment['fullname']), 'comment' => $comment['comment'], 'delete' => $delete); } } else { $pin['pin_latest_comments'] = array(); } $pin['pin_video_code'] = false; if ($detail) { if ($pin['pin_is_video']) { $auto = new Helper_AutoEmbed(); if ($pin['pin_repin_from'] && $auto->parseUrl($pin['pin_from_repin'])) { $auto->setWidth('100%'); $auto->setHeight('350'); $pin['pin_video_code'] = $auto->getEmbedCode(); } else { if ($auto->parseUrl($pin['pin_from'])) { $auto->setWidth('100%'); $auto->setHeight('350'); $pin['pin_video_code'] = $auto->getEmbedCode(); } else { $pin['pin_is_video'] = false; } } } else { $auto = new Helper_AutoEmbed(); if ($pin['pin_repin_from'] && $auto->parseUrl($pin['pin_from_repin'])) { $auto->setWidth('100%'); $auto->setHeight('350'); $pin['pin_video_code'] = $auto->getEmbedCode(); $pin['pin_is_video'] = true; } else { if ($auto->parseUrl($pin['pin_from'])) { $auto->setWidth('100%'); $auto->setHeight('350'); $pin['pin_video_code'] = $auto->getEmbedCode(); $pin['pin_is_video'] = true; } else { $pin['pin_is_video'] = false; } } } $pin['pin_gallery'] = array(); $gallery = new Model_Pins_Gallery($pin['pin_pin_id']); if ($gallery->count()) { foreach ($gallery->data as $gal) { $pin['pin_gallery'][] = Helper_Uploadimages::pinThumbs(array('pin_pin_id' => $gal['pin_id'], 'pin_store' => $gal['store'], 'gallery_id' => $gal['gallery_id'], 'pin_image' => $gal['image'])); } } } ///////////////////////////////////// AUTHOR INFO ///////////////////////////////////// //return author all images $user_data = array('avatar' => $pin['user_avatar'], 'store' => $pin['user_store'], 'user_id' => $pin['user_user_id']); foreach ($pin as $k => $v) { if (strpos($k, 'user_avatar_') === 0) { $user_data[$k] = $v; } } $pin['user_avatars'] = Helper_Uploadimages::userAvatars($user_data); $pin['user_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['user_user_id']); ///////////////////////////////////// VIA INFO ///////////////////////////////////// $pin['via_profile'] = array(); if ($pin['via_user_id']) { $via_avatars = Helper_Uploadimages::userAvatars(array('avatar' => $pin['via_avatar'], 'store' => $pin['via_store'], 'user_id' => $pin['via_user_id'])); $pin['via_profile'] = array('avatars' => $via_avatars, 'profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['via_user_id']), 'fullname' => $pin['via_fullname']); } ///////////////////////////////////// SELF INFO ///////////////////////////////////// $pin['self_profile'] = false; if (JO_Session::get('user[user_id]')) { $user_avatars = Helper_Uploadimages::userAvatars(array('avatar' => JO_Session::get('user[avatar]'), 'store' => JO_Session::get('user[store]'), 'user_id' => JO_Session::get('user[user_id]'))); $pin['self_profile']['avatars'] = $user_avatars; $pin['self_profile']['fullname'] = JO_Session::get('user[fullname]'); $pin['self_profile']['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')); } ///////////////////////////////////// SOURCE INFO ///////////////////////////////////// $pin['pin_source'] = array(); $pin['pin_target_repin'] = false; if ($detail) { if ($pin['pin_repin_from']) { $pin_repin = new Model_Pins_Pin($pin['pin_repin_from']); if ($pin_repin->count()) { $pin_repin = $pin_repin->data; $pin['pin_source']['source'] = $pin_repin['board_title']; $pin['pin_from'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_repin['user_user_id'] . '&board_id=' . $pin_repin['board_board_id']); $pin['pin_target_repin'] = true; } else { $source = new Model_Sources_Source($pin['pin_source_id']); if ($source->count()) { $pin['pin_source']['source'] = $source['source']; } } } else { $source = new Model_Sources_Source($pin['pin_source_id']); if ($source->count()) { $pin['pin_source']['source'] = $source['source']; } } } ///for mobile $pin['mobile_upload'] = false; if ($pin['pin_from'] == 'Mobile') { $pin['pin_from'] = ''; $pin['mobile_upload'] = true; } return $pin; }