public function indexAction() { $request = $this->getRequest(); $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_marker' => $request->getRequest('marker'), 'filter_price_from' => (int) $request->getRequest('price_from'), 'filter_price_to' => (int) $request->getRequest('price_to'), 'allow_gifts' => true, 'filter_categoria_id' => $request->getRequest('category_id') != 9999 ? $request->getRequest('category_id') : null); // if((int)JO_Session::get('user[user_id]')) { // $data['following_users_from_user_id'] = JO_Session::get('user[user_id]'); // } $category_id = $request->getRequest('category_id'); if ($category_id == 9999) { $category_id = null; } $category_info = Model_Categories::getCategory($category_id); /* if($category_info && !$category_info['parent_id']){ $subCats = Model_Categories::getSubcategories($category_id); if($subCats){ $category_id = ''; foreach($subCats as $sc){ $category_id.= $sc['category_id'].","; } $category_id = substr($category_id,0,-1); } } */ if (!$category_info) { $category_info["title"] = "Todo"; } $this->view->category = $category_info; $this->view->price_from = (int) $request->getRequest('price_from'); $this->view->price_to = (int) $request->getRequest('price_to'); $this->view->pins = ''; $pins = Model_Pins::getPins($data); if ($pins) { $banners = Model_Banners::getBanners(new JO_Db_Expr("`controller` = '" . $request->getController() . "' AND position BETWEEN '" . (int) $data['start'] . "' AND '" . (int) $data['limit'] . "'")); $pp = JO_Registry::get('config_front_limit'); foreach ($pins as $row => $pin) { ///banners $key = $row + ($pp * $page - $pp); if (isset($banners[$key])) { $this->view->pins .= Helper_Banners::returnHtml($banners[$key]); } //pins $this->view->pins .= Helper_Pin::returnHtml($pin); } // JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } if ($request->isXmlHttpRequest()) { echo $this->view->pins; $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } }
public function indexAction() { $request = $this->getRequest(); $source_id = $request->getRequest('source_id'); $source_info = Model_Source::getSource($source_id); if (!$source_info) { $this->forward('error', 'error404'); } $this->getLayout()->meta_title = $source_info['source']; $this->view->source = $source_info; $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_source_id' => $request->getRequest('source_id'), 'filter_marker' => $request->getRequest('marker')); // if((int)JO_Session::get('user[user_id]')) { // $data['following_users_from_user_id'] = JO_Session::get('user[user_id]'); // } $this->view->pins = ''; $pins = Model_Pins::getPins($data); if ($pins) { foreach ($pins as $pin) { $this->view->pins .= Helper_Pin::returnHtml($pin); } // JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } if ($request->isXmlHttpRequest()) { echo $this->view->pins; $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } }
public function indexAction() { $request = $this->getRequest(); //JO_Session::clear('categoria_id'); $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_marker' => $request->getRequest('marker')); $this->view->pins = ''; $pins = Model_Pins::getPins($data); if ($pins) { $banners = Model_Banners::getBanners(new JO_Db_Expr("`controller` = '" . $request->getController() . "' AND position BETWEEN '" . (int) $data['start'] . "' AND '" . (int) $data['limit'] . "'")); $pp = JO_Registry::get('config_front_limit'); foreach ($pins as $row => $pin) { ///banners $key = $row + ($pp * $page - $pp); if (isset($banners[$key])) { $this->view->pins .= Helper_Banners::returnHtml($banners[$key]); } //pins $this->view->pins .= Helper_Pin::returnHtml($pin); } // JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } if ($request->isXmlHttpRequest()) { echo $this->view->pins; $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } }
public static function avatar($user, $size = null) { $image = call_user_func(array(Helper_Pin::formatUploadModule($user['store']), 'getUserImage'), $user, $size); if (!$image) { $user['avatar'] = JO_Registry::get('no_avatar'); $image = call_user_func(array(Helper_Pin::formatUploadModule('locale'), 'getUserImage'), $user, $size); } return $image; }
public static function createEvent($user_id, $event_id, $data) { $db = JO_Db::getDefaultAdapter(); $rows = self::describeTable('events'); //$user_info_get = self::getUser($user_id); //$created = WM_Date::format($user_info_get['created'], 'yy-mm-dd H:i:s'); $update = array(); $avatar = ''; $followers = false; foreach ($rows as $row) { if (array_key_exists($row, $data)) { if ($row == 'avatar') { if ($data[$row]) { JO_Session::clear('upload_avatar'); $avatar = $data[$row]; } else { //$update[$row] = $data[$row]; } } else { $update[$row] = $data[$row]; if ($row == 'compartir' && $data[$row] == 'followers') { $followers = true; } if ($row == 'date_event') { $fecha = str_replace("/", "-", $data[$row]); $update[$row] = WM_Date::format($fecha, 'yy-mm-dd H:i:s'); } } } } if (!$update) { if (!$avatar) { return false; } } $user_data = ""; if ($event_id) { $user_data = Model_Events::getEventUser((string) $user_id, $event_id); if (!$user_data) { $db->insert('events', $update); $event_id = $db->lastInsertId(); if ($followers) { $users = Model_Users::getUsers(array('filter_following_user_id' => (string) $user_id)); if ($users) { foreach ($users as $key => $user) { Model_History::addHistory($user['user_id'], Model_History::CREATE_EVENT, $event_id); //self::FollowEvent($event_id, $user['user_id']); } } } if (!$event_id) { return false; } } else { $result = $db->update('events', $update, array('user_id = ' . (string) $user_id . ' AND event_id = ' . (string) $event_id)); if ($followers) { $users = Model_Users::getUsers(array('filter_following_user_id' => (string) $user_id)); if ($users) { foreach ($users as $key => $user) { Model_History::addHistory($user['user_id'], Model_History::CREATE_EVENT, $event_id); //self::FollowEvent($event_id, $user['user_id']); } } } if (!$result) { return false; } } } else { $db->insert('events', $update); $event_id = $db->lastInsertId(); if ($followers) { $users = Model_Users::getUsers(array('filter_following_user_id' => (string) $user_id)); if ($users) { foreach ($users as $key => $user) { Model_History::addHistory($user['user_id'], Model_History::CREATE_EVENT, $event_id); //self::FollowEvent($event_id, $user['user_id']); } } } if (!$event_id) { return false; } } if ($avatar) { ///// upload images //error_log("Vamos a subir la imagen"); $front = JO_Front::getInstance(); $request = JO_Request::getInstance(); $upload_model = Helper_Pin::formatUploadModule(JO_Registry::get('default_upload_method')); $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model); if (!file_exists($upload_model_file)) { $upload_model = Helper_Pin::formatUploadModule('locale'); $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model); } $image = false; if (file_exists($upload_model_file)) { //error_log("EXISTE FILE"); $image = call_user_func(array($upload_model, 'uploadEventImage'), $avatar, $event_id); } if ($image) { //error_log("EXISTE FILE"); $result = $db->update('events', array('avatar' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width'], 'last_action_datetime' => new JO_Db_Expr('NOW()')), array('user_id = ' . (string) $user_id . ' AND event_id = ' . (string) $event_id)); if ($user_data) { if ($user_data['avatar']) { if ($user_data['avatar'] != $image['image']) { call_user_func(array(Helper_Pin::formatUploadModule($user_data['store']), 'deleteEventImage'), $user_data); } } } } } return true; }
public function sendWeeklyAction() { $request = $this->getRequest(); $this->view->base_href = $request->getBaseUrl(); $this->view->site_name = JO_Registry::get('site_name'); $this->view->on_facebook = JO_Registry::get('config_on_facebook'); $this->view->site_logo = $this->view->base_href . 'data/images/logo.png'; if (JO_Registry::get('site_logo') && file_exists(BASE_PATH . '/uploads' . JO_Registry::get('site_logo'))) { $this->view->site_logo = $this->view->base_href . 'uploads' . JO_Registry::get('site_logo'); } $this->view->settings = WM_Router::create($this->view->base_href . '?controller=prefs'); $goodies = Model_Pages::getPage(JO_Registry::get('page_goodies')); if ($goodies) { //$this->view->pin_it = WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_goodies')); $this->view->pin_it = 'http://amatteur.com/apps'; } $this->view->pages = array(); $page = Model_Pages::getPage(JO_Registry::get('page_privacy_policy')); if ($page) { $this->view->pages[] = array('title' => $page['title'], 'href' => WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_privacy_policy'))); } $page = Model_Pages::getPage(JO_Registry::get('page_terms')); if ($page) { $this->view->pages[] = array('title' => $page['title'], 'href' => WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_privacy_policy'))); } $histories = Model_History::getHistoryToday(array('week_range' => WM_Date::x_week_range($this->now))); $no_avatar = JO_Registry::get('no_avatar'); if ($histories) { $model_images = new Helper_Images(); /* BOARDS */ $this->view->popular_bards = array(); $populars = Model_Boards::getBoards(array('start' => 0, 'limit' => 6, 'sort' => 'DESC', 'order' => 'boards.total_views', 'where' => new JO_Db_Expr('pins > 4'))); if ($populars) { foreach ($populars as $board) { $board['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']); $board['thumbs'] = array(); $get_big = false; for ($i = 0; $i < 5; $i++) { $image = isset($board['pins_array'][$i]) ? $board['pins_array'][$i]['image'] : false; if ($image) { if ($get_big) { $size = '_A'; } else { $size = '_C'; $get_big = true; } $data_img = call_user_func(array(Helper_Pin::formatUploadModule($board['pins_array'][$i]['store']), 'getPinImage'), $board['pins_array'][$i], $size); if ($data_img) { $board['thumbs'][] = $data_img['image']; } else { $board['thumbs'][] = false; } } else { $board['thumbs'][] = false; } } $board['user'] = Model_Users::getUser($board['user_id']); $board['user']['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $board['user_id']); $avatar = Helper_Uploadimages::avatar($board['user'], '_A'); $board['user']['avatar'] = $avatar['image']; $this->view->popular_bards[] = $board; } } /* VIDEO */ // $this->view->video = array(); // $video = Model_Pins::getPins(array( // 'start' => 0, // 'limit' => 1, // 'filter_is_video' => 1 // )); // // if($video) { // foreach($video AS $pin) { // $pin['thumb'] = $model_images->resizeWidth($pin['image'], 194); // $pin['thumb_width'] = $model_images->getSizes('width'); // $pin['thumb_height'] = $model_images->getSizes('height'); // $pin['description'] = Helper_Pin::descriptionFix($pin['description']); // $pin['href'] = WM_Router::create( $request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id'] ); // // } // } /* HISTORY */ foreach ($histories as $history) { if (!isset($history['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($history, '_B'); $history['avatar'] = $avatar['image']; $history['user_followers'] = WM_Router::create($this->view->base_href . '?controller=users&action=followers&user_id=' . $history['user_id']); $history['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $history['user_id']); $history['history_comments_total'] = count($history['history_comments']); $history['history_follow_total'] = count($history['history_follow']); $history['history_like_total'] = count($history['history_like']); $history['history_repin_total'] = count($history['history_repin']); $history['history_event_total'] = count($history['history_event']); /////comments if ($history['history_comments_total']) { foreach ($history['history_comments'] as $k => $v) { if (!isset($v['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($v, '_A'); $history['history_comments'][$k]['avatar'] = $avatar['image']; $history['history_comments'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']); } } /////follow if ($history['history_follow_total']) { foreach ($history['history_follow'] as $k => $v) { if (!isset($v['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($v, '_A'); $history['history_follow'][$k]['avatar'] = $avatar['image']; $history['history_follow'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']); } } /////like if ($history['history_like_total']) { foreach ($history['history_like'] as $k => $v) { if (!isset($v['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($v, '_A'); $history['history_like'][$k]['avatar'] = $avatar['image']; $history['history_like'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']); } } /////repin if ($history['history_repin_total']) { foreach ($history['history_repin'] as $k => $v) { if (!isset($v['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($v, '_A'); $history['history_repin'][$k]['avatar'] = $avatar['image']; $history['history_repin'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']); } } ////events if ($history['history_event_total']) { foreach ($history['history_event'] as $k => $v) { if (!isset($v['store'])) { continue; } $avatar = Helper_Uploadimages::event($v, '_A'); $history['history_event'][$k]['avatar'] = $avatar['image']; $history['history_event'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']); } } $this->view->events = array(); $this->view->event = array(); $dataEvents = array('filter_cron' => $history['user_id']); $events = Model_Events::getEvents($dataEvents); if ($events) { foreach ($events as $key => $event) { $href = ""; $view = JO_View::getInstance(); $view->loged = JO_Session::get('user[user_id]'); $model_images = new Helper_Images(); $avatar = Helper_Uploadimages::avatar($event, '_B'); $event['avatar'] = $avatar['image']; $event['thumbs'] = $avatar['image']; $event["sport_category"] = Model_Boards::getCategoryTitle($event["sport_category"]); $data = array('filter_user_id' => $event["user_id"]); $users = Model_Users::getUsers($data); if ($users) { $event['fullname'] = $users[0]["fullname"]; $event['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']); $href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']); } //$view->boxeventdetail = WM_Router::create($request->getBaseUrl() . '?controller=events&action=boxeventdetail&event_id=' . $event['event_id']); $view->boxeventdetail = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']); $this->view->event[] = $event; $view->event = $event; $this->view->events[] = $view->render('boxEvent', 'events'); } } /* PINS */ $likes = Model_History::getHistory(array('history_action' => Model_History::LIKEPIN, 'start' => 0, 'limit' => 30), 'from_user_id', $history['user_id']); $history['pins_likes'] = array(); if ($likes) { $temp = array(); foreach ($likes as $like) { $temp[$like['pin_id']] = $like['pin_id']; } if ($temp) { $pins = Model_Pins::getPins(array('start' => 0, 'limit' => 9, 'filter_id_in' => implode(',', $temp))); if ($pins) { foreach ($pins as $pin) { $image = call_user_func(array(Helper_Pin::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_B'); if ($image) { $pin['thumb'] = $image['image']; $pin['thumb_width'] = $image['width']; $pin['thumb_height'] = $image['height']; } else { continue; } $pin['description'] = Helper_Pin::descriptionFix($pin['description']); $pin['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']); $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']); $avatar = Helper_Uploadimages::avatar($pin['user'], '_A'); $pin['user']['avatar'] = $avatar['image']; $pin['user']['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $pin['user_id']); $pin['via_profile'] = array(); if ($pin['via'] && $pin['user_via']) { $pin['via_profile'] = array('profile' => WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $pin['via']), 'fullname' => $pin['user_via']['fullname']); } $history['pins_likes'][] = $pin; } } } } $this->view->history = $history; $html = $this->view->render('sendWeekly', 'crons'); Model_Email::send($history['email'], JO_Registry::get('noreply_mail'), sprintf($this->translate('Weekly %s'), $this->view->site_name), $html); } } }
public function indexAction() { $request = $this->getRequest(); //JO_Session::clear('categoria_id'); //para las APP's if (isset($_POST['token']) && $_POST['token'] == md5($_POST['userid'])) { $_SESSION['token'] = $_POST['token']; JO_Session::set('token', $_POST['token']); $result = Model_Users::checkLoginAPP($_POST['userid']); if ($result) { if ($result['status']) { @setcookie('csrftoken_', md5($result['user_id'] . $request->getDomain() . $result['date_added']), time() + 86400 * 366 * 5, '/', '.' . $request->getDomain()); JO_Session::set(array('user' => $result)); } } } if ($request->getParam('direct_path') == 'true') { if (JO_Session::get('user[user_id]') && JO_Session::get('category_id')) { Model_Users::edit(JO_Session::get('user[user_id]'), array('first_login' => '0')); JO_Session::clear('category_id'); $this->view->user_info = JO_Session::get('user'); Model_Email::send(JO_Session::get('user[email]'), JO_Registry::get('noreply_mail'), sprintf($this->translate('Welcome to %s!'), JO_Registry::get('site_name')), $this->view->render('welcome', 'mail')); } $this->redirect($request->getBaseUrl()); } /*$img = JO_Phpthumb::getInstance(); var_dump($img->isValidImplementation('imagick')); exit; $img = JO_Phpthumb_Factory::create('http://www.desiredanimations.com/wp-content/uploads/2011/08/Cars-2.jpg'); $img->adaptiveResize(250, 250)->createReflection(40, 40, 80, true, '#a4a4a4'); $img->show(); exit;*/ $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit')); if (JO_Session::get('user[user_id]')) { $data['following_users_from_user_id'] = JO_Session::get('user[user_id]'); $data['filter_marker'] = $request->getRequest('marker'); } else { $data['filter_rand'] = true; } $this->view->pins = ''; //error_log("INICIO PINS: ".date("Y-m-d H:i:s")); $pins = Model_Pins::getPins($data); //error_log("EMPIEZAN PINES: ".self::udate("Y-m-d H:i:s:u")); if ($pins) { $banners = Model_Banners::getBanners(new JO_Db_Expr("`controller` = '" . $request->getController() . "' AND position BETWEEN '" . (int) $data['start'] . "' AND '" . (int) $data['limit'] . "'")); $pp = JO_Registry::get('config_front_limit'); $cuentaPins = 0; foreach ($pins as $row => $pin) { $cuentaPins = $cuentaPins + 1; ///banners $key = $row + ($pp * $page - $pp); if (isset($banners[$key])) { $this->view->pins .= Helper_Banners::returnHtml($banners[$key]); } //pins //error_log("EMPIEZA PIN(".$cuentaPins."): ".self::udate("Y-m-d H:i:s:u")); $this->view->pins .= Helper_Pin::returnHtml($pin); //error_log("FIN PIN(".$cuentaPins."): ".self::udate("Y-m-d H:i:s:u")); } //error_log("FIN BUCLE (".$cuentaPins." PINS): ".date("Y-m-d H:i:s")); if (JO_Session::get('user[user_id]')) { // JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } } //error_log("FIN PINES(".$cuentaPins."): ".self::udate("Y-m-d H:i:s:u")); if (!$request->isXmlHttpRequest() && JO_Session::get('user[user_id]')) { $history = Model_History::getHistory(array('start' => 0, 'limit' => 10, 'sort' => 'DESC', 'order' => 'history_id')); $model_images = new Helper_Images(); foreach ($history as $key => $data) { if (!isset($data['user']['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($data['user'], '_A'); $history[$key]['user']['avatar'] = $avatar['image']; if ($data['history_action'] == Model_History::REPIN) { $history[$key]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $data['pin_id']); } else { $history[$key]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $data['from_user_id']); } } $this->view->history = $history; } if ($request->isXmlHttpRequest()) { echo $this->view->pins; // echo $this->renderScript('json'); $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } // if((int)JO_Registry::get('config_cache_live')) { // $http = new JO_Http(); // $http->setTimeout(1); // $http->execute($request->getBaseUrl() . '?action=generateCache'); // } }
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); }
public static function edit($user_id, $data) { $db = JO_Db::getDefaultAdapter(); $rows = self::describeTable('users'); $user_info_get = self::getUser($user_id); $date_added = WM_Date::format($user_info_get['date_added'], 'yy-mm-dd H:i:s'); $update = array(); $avatar = ''; foreach ($rows as $row) { if (array_key_exists($row, $data)) { if ($row == 'avatar') { if ($data[$row]) { JO_Session::clear('upload_avatar'); $avatar = $data[$row]; } else { //$update[$row] = $data[$row]; } } elseif ($row == 'password' || $row == 'new_password') { $update[$row] = md5($data[$row]); } elseif ($row == 'location') { if ($data[$row] != "Introduce tu ubicación") { $update[$row] = $data[$row]; } } elseif ($row == 'firstname') { $update[$row] = self::quotesFix($data[$row]); } elseif ($row == 'description') { $update[$row] = self::quotesFix($data[$row]); } else { $update[$row] = $data[$row]; } } } if (!$update) { if (!$avatar) { return false; } } $rebuild = $result = $db->update('users', $update, array('user_id = ?' => (string) $user_id)); if ($avatar) { ///// upload images //error_log("Vamos a subir la imagen"); $front = JO_Front::getInstance(); $request = JO_Request::getInstance(); $upload_model = Helper_Pin::formatUploadModule(JO_Registry::get('default_upload_method')); $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model); if (!file_exists($upload_model_file)) { $upload_model = Helper_Pin::formatUploadModule('locale'); $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model); } $image = false; if (file_exists($upload_model_file)) { //error_log("EXISTE FILE"); $image = call_user_func(array($upload_model, 'uploadUserAvatar'), $avatar, $user_id); } if ($image) { //error_log("EXISTE FILE"); $result = $db->update('users', array('avatar' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width'], 'last_action_datetime' => new JO_Db_Expr('NOW()')), array('user_id = ?' => (string) $user_id)); if ($user_info_get && $user_info_get['avatar']) { if ($user_info_get['avatar'] != $image['image']) { call_user_func(array(Helper_Pin::formatUploadModule($user_info_get['store']), 'deleteUserImage'), $user_info_get); } } if (!$rebuild) { $rebuild = $result; } } } if (isset($data['username'])) { $db->query("DELETE FROM url_alias WHERE query = 'user_id=" . (string) $user_id . "'"); $db->insert('url_alias', array('query' => 'user_id=' . (string) $user_id, 'keyword' => $data['username'], 'path' => $data['username'], 'route' => 'users/profile')); } if ($rebuild) { $total = $db->update('pins', array('date_modified' => WM_Date::format(time(), 'yy-mm-dd H:i:s')), array('user_id = ? OR (pin_id IN (SELECT DISTINCT pin_id FROM pins_comments WHERE user_id = ?))' => (string) $user_id)); } $db->update('users', array('pins' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins WHERE user_id = users.user_id)'), 'boards' => new JO_Db_Expr('(SELECT COUNT(DISTINCT board_id) FROM boards WHERE user_id = users.user_id)'), 'likes' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins_likes WHERE user_id = users.user_id)'), 'following' => new JO_Db_Expr('(SELECT COUNT(DISTINCT following_id) FROM users_following_user WHERE user_id = users.user_id AND following_id != users.user_id)'), 'followers' => new JO_Db_Expr('(SELECT COUNT(DISTINCT user_id) FROM users_following_user WHERE following_id = users.user_id AND user_id != users.user_id)'), 'liking' => new JO_Db_Expr('(SELECT COUNT(DISTINCT user_like_id) FROM users_likes WHERE user_id = users.user_id AND user_like_id != users.user_id)'), 'likers' => new JO_Db_Expr('(SELECT COUNT(DISTINCT user_id) FROM users_likes WHERE user_like_id = users.user_id AND user_id != users.user_id)')), array('user_id = ?' => (string) $user_id)); return true; }
public function indexAction() { $request = $this->getRequest(); $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } if ($page > 1) { exit; } $index_id = $request->getRequest('index_id'); if ($index_id == 1) { $this->view->title = 'Top 10 fotos - Últimos 7 días'; $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'order' => 'pins.likes', 'sort' => 'DESC', 'limit' => 10, 'filter_pin_top_10_7' => '7', 'filter_categoria_id' => $request->getRequest('category_id') != 9999 ? $request->getRequest('category_id') : null); } else { if ($index_id == 2) { $this->view->title = 'Top 10 fotos - Absoluto'; $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'order' => 'pins.likes', 'sort' => 'DESC', 'limit' => 10, 'filter_pin_top_10' => true, 'filter_categoria_id' => $request->getRequest('category_id') != 9999 ? $request->getRequest('category_id') : null); } else { if ($index_id == 3) { $this->view->title = 'Top 10 perfiles - Últimos 7 días'; $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'order' => 'users.likers', 'sort' => 'DESC', 'limit' => 10, 'filter_profile_top_10_7' => '7', 'filter_categoria_id' => $request->getRequest('category_id') != 9999 ? $request->getRequest('category_id') : null); } else { if ($index_id == 4) { $this->view->title = 'Top 10 perfiles - Absoluto'; $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'order' => 'users.likers', 'sort' => 'DESC', 'limit' => 10, 'filter_profile_top_10' => true, 'filter_categoria_id' => $request->getRequest('category_id') != 9999 ? $request->getRequest('category_id') : null); } } } } // if((int)JO_Session::get('user[user_id]')) { // $data['following_users_from_user_id'] = JO_Session::get('user[user_id]'); // } $category_id = $request->getRequest('category_id'); if ($category_id == 9999) { $category_id = null; } $category_info = Model_Categories::getCategory($category_id); /* if($category_info && !$category_info['parent_id']){ $subCats = Model_Categories::getSubcategories($category_id); if($subCats){ $category_id = ''; foreach($subCats as $sc){ $category_id.= $sc['category_id'].","; } $category_id = substr($category_id,0,-1); } } */ if (!$category_info) { $category_info["title"] = "Todo"; } $this->view->category = $category_info; $this->view->pins = ''; if ($index_id == 1 || $index_id == 2) { $pins = Model_Pins::getPins($data); } else { if ($index_id == 3 || $index_id == 4) { //$pins = Model_Users::getUsers($data); $pins = Model_Users::getUsers($data); } } if ($pins) { /*$banners = Model_Banners::getBanners( new JO_Db_Expr("`controller` = '".$request->getController()."' AND position BETWEEN '".(int)$data['start']."' AND '".(int)$data['limit']."'") ); $pp = JO_Registry::get('config_front_limit'); * */ $total = 0; foreach ($pins as $row => $pin) { $total++; $this->view->position = $total; ///banners /* $key = $row + (($pp*$page)-$pp); if(isset($banners[$key])) { $this->view->pins .= Helper_Banners::returnHtml($banners[$key]); } */ if ($index_id == 1 || $index_id == 2) { //pins $this->view->pins .= Helper_Pin::returnHtmlTop($pin); } else { if ($index_id == 3 || $index_id == 4) { //users $this->view->pins .= Helper_User::returnHtmlTop($pin); //$this->view->users .= $this->returnHtml($pin); } } if ($total == 10) { break; } } //JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } if ($request->isXmlHttpRequest()) { echo $this->view->pins; $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } }
public static function rebuildCache($pins) { if (!$pins) { return; } if (!is_array($pins)) { $pins = Model_Pins::getPins(array('filter_pin_id' => $pins)); } else { $pins = Model_Pins::getPins(array('filter_id_in' => implode(',', $pins))); } if ($pins) { foreach ($pins as $pin) { self::deleteCache($pin); Helper_Pin::returnHtml($pin, true); } } }
public function left_partAction() { $request = $this->getRequest(); $this->view->pin = JO_Registry::get('pin_info'); // $this->view->onto_board = Helper_Pin::getBoardPins( JO_Registry::getArray('pin_info[board_id]'), 9, 60 ); $boards = Model_Boards::getBoards(array('start' => 0, 'limit' => 1, 'filter_id_in' => JO_Registry::getArray('pin_info[board_id]'))); $this->view->has_edit_boards = true; $this->view->enable_sort = true; $this->view->onto_board = ''; if ($boards) { $view = JO_View::getInstance(); $view->loged = JO_Session::get('user[user_id]'); $view->enable_sort = false; $model_images = new Helper_Images(); foreach ($boards as $board) { $board['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']); $board['thumbs'] = array(); $get_big = false; for ($i = 0; $i < 5; $i++) { $image = isset($board['pins_array'][$i]) ? $board['pins_array'][$i]['image'] : false; if ($image) { if ($get_big) { $size = '_A'; } else { $size = '_C'; $get_big = true; } $data_img = Helper_Uploadimages::pin($board['pins_array'][$i], $size); if ($data_img) { $board['thumbs'][] = $data_img['image']; } else { $board['thumbs'][] = false; } } else { $board['thumbs'][] = false; } } $board['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board['board_id'])); $board['userFollowIgnore'] = $board['user_id'] != JO_Session::get('user[user_id]'); $board['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']); $board['edit'] = false; if ($board['user_id'] == JO_Session::get('user[user_id]')) { $board['edit'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']); } $view->board = $board; $this->view->onto_board .= $view->render('box', 'boards'); } } $this->view->source = Model_Source::getSource(JO_Registry::getArray('pin_info[source_id]')); if ($this->view->source) { $this->view->source_pins = Helper_Pin::getSourcePins(JO_Registry::getArray('pin_info[source_id]'), 6, 75); $this->view->pin['from'] = WM_Router::create($request->getBaseUrl() . '?controller=source&source_id=' . $this->view->pin['source_id']); } else { if (JO_Registry::getArray('pin_info[repin_from]')) { $pin_repin = Model_Pins::getPin(JO_Registry::getArray('pin_info[repin_from]')); if ($pin_repin) { $this->view->source['source'] = $pin_repin['board']; $this->view->pin['from'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_repin['user_id'] . '&board_id=' . $pin_repin['board_id']); $this->view->source_pins = Helper_Pin::getBoardPins($pin_repin['board_id'], 9, 75); } } } $this->view->boardIsFollow = Model_Users::isFollow(array('board_id' => JO_Registry::getArray('pin_info[board_id]'))); $this->view->follow = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $this->view->pin['user_id'] . '&board_id=' . $this->view->pin['board_id']); $this->view->loged = JO_Session::get('user[user_id]'); $this->view->pin['userFollowIgnore'] = ($this->view->pin['via'] ? $this->view->pin['via'] : $this->view->pin['user_id']) == JO_Session::get('user[user_id]'); // var_dump($this->view->onto_board); JO_Registry::set('pin_info', array()); }
public function feedAction() { $request = $this->getRequest(); $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_marker' => $request->getRequest('marker'), 'filter_user_id' => $request->getRequest('user_id')); if ($request->getQuery('filter') == 'likes') { unset($data['filter_user_id']); $data['filter_likes'] = $request->getRequest('user_id'); $this->view->active = 'likes'; } $event_data = Model_Users::getUser($request->getRequest('user_id')); if ($event_data) { JO_Registry::set('meta_title', $event_data['fullname'] . ' - ' . JO_Registry::get('meta_title')); $events = Model_Events::getEvents($data); $this->view->item = array(); if ($events) { $model_images = new Helper_Images(); foreach ($events as $event) { $data_img = Helper_Uploadimages::event($event, '_D'); if (!$data_img) { continue; } $enclosure = $data_img['image']; $category_info = Model_Categories::getCategory($event['category_id']); if ($category_info) { $event['sport_category'] = $category_info['title'] . ' >> ' . $event['sport_category']; } $this->view->item[] = array('guid' => $event['event_id'], 'enclosure' => $enclosure, 'description' => Helper_Pin::descriptionFix($event['description']), 'title' => Helper_Pin::descriptionFix(JO_Utf8::splitText($event['description'], 60, '...')), 'link' => WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']), 'author' => $event['user']['fullname'], 'pubDate' => WM_Date::format($event['date_added'], JO_Date::RSS_FULL), 'category' => $event['sport_category']); } } } echo $this->renderScript('rss'); }
public function searchAction() { $this->noViewRenderer(true); $request = $this->getRequest(); $response = $this->getResponse(); $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $callback = $request->getRequest('callback'); if (!preg_match('/^([a-z0-9_.]{1,})$/', $callback)) { $callback = false; } $data = array(); $url = ""; $return = array(); $kind = $request->getRequest('kind'); $query = $request->getRequest('query'); $userId = $request->getRequest('userId'); if ($kind == 0) { // pins $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_description' => $query, 'filter_marker' => $request->getRequest('marker')); $this->view->pins = ''; $pins = Model_Pins::getPinsAPP($data); if ($pins) { $model_images = new Helper_Images(); foreach ($pins as $pin) { $images = array(); $image = call_user_func(array(Helper_Pin::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_B'); if ($image) { $images['thumb']['src'] = $image['image']; $images['thumb']['width'] = $image['width']; $images['thumb']['height'] = $image['height']; $images['original'] = $image['original']; } $categorias = array(); $categories = Model_Categories::getCategory($pin['category_id']); if ($categories['parent_id'] != 0) { $categorias['category_id'] = $categories['parent_id']; $categorias['subcategory_id'] = $categories['category_id']; } else { $categorias['category_id'] = $categories['category_id']; $categorias['subcategory_id'] = $categories['parent_id']; } $pos = strripos($pin['image'], '.'); $return['data'][] = array('pin_id' => $pin['pin_id'], 'pinFooter' => $pin['description'], 'category_id' => $categorias['category_id'], 'subcategory_id' => $categorias['subcategory_id'], 'pinImage' => substr_replace($pin['image'], '_B.', $pos, 1), 'pinWidth' => $pin['width'], 'pinHeight' => $pin['height'], 'pinUrl' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']), 'userId' => $pin['user_id'], 'username' => $pin['username'], 'avatar' => $pin['avatar'], 'userLike' => $pin['liked'], 'pinVideo' => $pin['from']); } $return['next_page'] = WM_Router::create($request->getBaseUrl() . '?controller=apiv1&action=timeline' . $url); } } else { if ($kind == 1) { //boards $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_title' => $query); $this->view->pins = ''; $boards = Model_Boards::getBoards($data); if ($boards) { $view = JO_View::getInstance(); $view->loged = JO_Session::get('user[user_id]'); $view->enable_sort = false; $model_images = new Helper_Images(); foreach ($boards as $board) { $board['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']); $board['thumbs'] = array(); $get_big = false; for ($i = 0; $i < 5; $i++) { $image = isset($board['pins_array'][$i]) ? $board['pins_array'][$i]['image'] : false; if ($image) { if ($get_big) { $size = '_A'; } else { $size = '_C'; $get_big = true; } $data_img = Helper_Uploadimages::pin($board['pins_array'][$i], $size); if ($data_img) { $board['thumbs'][] = $data_img['image']; } else { $board['thumbs'][] = false; } } else { $board['thumbs'][] = false; } } $board['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board['board_id'])); $board['userFollowIgnore'] = $board['user_id'] != JO_Session::get('user[user_id]'); $board['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']); $board['edit'] = false; if ($board['user_id'] == JO_Session::get('user[user_id]') || Model_Boards::allowEdit($board['board_id'])) { $board['userFollowIgnore'] = false; $board['edit'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']); } $username = Model_Users::getUsername($board["user_id"]); $url_base = WM_Router::create($request->getBaseUrl()); $return['data'][] = array('folderId' => $board['board_id'], 'folderName' => $board['title'], 'folderUrl' => $url_base . $username . "/" . $board['title'], 'folderImage' => $board['image'], 'folderQty' => $board['pins']); //$return[] = $board; } } } else { if ($kind == 2) { //people $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_username' => $query); $users = Model_Users::getUsers($data); if ($users) { $this->view->follow_user = true; $view = JO_View::getInstance(); $view->loged = JO_Session::get('user[user_id]'); $model_images = new Helper_Images(); foreach ($users as $key => $user) { $avatar = Helper_Uploadimages::avatar($user, '_B'); $user['avatar'] = $avatar['image']; if ($view->loged) { $user['userIsFollow'] = Model_Users::isFollowUser($user['user_id']); $user['userFollowIgnore'] = $user['user_id'] == JO_Session::get('user[user_id]'); } else { $user['userFollowIgnore'] = true; } $user['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']); $user['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $user['user_id']); $return['data'][] = array('userId' => $user['user_id'], 'userName' => $user['username'], 'userDesc' => $user['description'], 'userLocation' => $user['location'], 'avatar' => $user['avatar'], 'follower' => $user['followers'], 'following' => $user['following']); } } } } } if ($callback) { $return = $callback . '(' . JO_Json::encode($return) . ')'; } else { $response->addHeader('Cache-Control: no-cache, must-revalidate'); $response->addHeader('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); $response->addHeader('Content-type: application/json'); $return = JO_Json::encode($return); } $response->appendBody($return); }
public function pinsAction() { $request = $this->getRequest(); $user_data = $this->profileHelp(); $this->setViewChange('profile'); $this->view->active = 'pins'; $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $this->view->boards = ''; $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_marker' => $request->getRequest('marker'), 'filter_user_id' => $user_data['user_id']); if ($request->getQuery('filter') == 'likes') { unset($data['filter_user_id']); $data['filter_likes'] = $user_data['user_id']; $this->view->active = 'likes'; } $pins = Model_Pins::getPins($data); if ($pins) { foreach ($pins as $pin) { $this->view->boards .= Helper_Pin::returnHtml($pin); } // JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } if ($request->getQuery('filter') == 'likes') { $events = Model_Events::getEvents($data); if ($events) { $i = 0; foreach ($events as $key => $event) { $this->view->all = false; $href = ""; $view = JO_View::getInstance(); $view->loged = JO_Session::get('user[user_id]'); $model_images = new Helper_Images(); $avatar = Helper_Uploadimages::avatar($event, '_B'); $event['avatar'] = $avatar['image']; $event['original'] = $avatar['original']; $event['width'] = $avatar['width']; $event['height'] = $avatar['height']; $event["sport_category"] = Model_Boards::getCategoryTitle($event["sport_category"]); $event['href'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']); $href = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']); $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_user_id' => $event["user_id"]); $users = Model_Users::getUsers($data); if ($users) { $event['fullname'] = $users[0]["fullname"]; $event['hrefuser'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']); //$href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']); } //$view->boxeventdetail = WM_Router::create($request->getBaseUrl() . '?controller=events&action=boxeventdetail&event_id=' . $event['event_id']); $view->boxeventdetail = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']); $this->view->from_url = WM_Router::create($request->getBaseUrl() . '?controller=addpin&action=fromurl'); $this->view->successfu_edite = false; $view->event = $event; $this->view->boards .= $view->render('boxEventPin', 'events'); $events[$i]["href"] = $href; $eventsTot[] = $events[$i]; $i++; } // JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } } $agendas = Model_Users::getUserAgenda(array('filter_user_id' => $user_data['user_id'])); $this->view->has_agendas = false; $this->view->agendas_users = ""; if ($agendas) { $this->view->has_agendas = true; foreach ($agendas as $agenda) { $agenda['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agendaPopupDelete&agenda_id=' . $agenda['agenda_id'] . '&user_id=' . $user_data['user_id']); $this->view->agenda = $agenda; $this->view->agendas_users .= $this->view->render('agenda', 'users'); } } $session_user = JO_Session::get('user[user_id]'); $this->view->popup_agenda = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agendaPopup&user_id=' . $user_data['user_id']); //no mover de esta ubicación $messages = Model_Users::getUserMessages(array('start' => 0, 'limit' => 100, 'filter_user_id' => $user_data['user_id'], 'idPadre' => 0)); $this->view->has_messages = false; $this->view->messages_users = ""; if ($messages) { $this->view->has_messages = true; foreach ($messages as $message) { $avatar = Helper_Uploadimages::avatar($message, '_A'); $message['avatar'] = $avatar['image']; $message['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $message['user_id']); $message['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopupDelete&message_id=' . $message['message_id'] . '&user_id=' . $user_data['user_id']); $message['hrefResponder'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=' . $message['message_id']); $this->view->message = $message; $this->view->messages_users .= $this->view->render('message', 'users'); //ahora vamos a consultar las respuestas a este: $messagesHijos = Model_Users::getUserMessages(array('start' => 0, 'limit' => 100, 'filter_user_id' => $user_data['user_id'], 'idPadre' => $message['message_id'])); if ($messagesHijos) { foreach ($messagesHijos as $messageHijo) { $avatar = Helper_Uploadimages::avatar($messageHijo, '_A'); $messageHijo['avatar'] = $avatar['image']; $messageHijo['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $messageHijo['user_id']); $messageHijo['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopupDelete&message_id=' . $messageHijo['message_id'] . '&user_id=' . $user_data['user_id']); $messageHijo['hrefResponder'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=' . $messageHijo['message_id']); $this->view->message = $messageHijo; $this->view->messages_users .= $this->view->render('message', 'users'); } } } } $session_user = JO_Session::get('user[user_id]'); $this->view->popup_messages = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=0'); //$this->view->popup_activate = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=activatePopup'); //&user_from=' . $session_user . '&user_to=' . $user_data['user_id'].'&board_user='******'user_id'] .'&message_from_id=0' ); //$this->view->popup_activate = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=activateDetail'); //&user_from=' . $session_user . '&user_to=' . $user_data['user_id'].'&board_user='******'user_id'] .'&message_from_id=0' ); $_SESSION["activate_url"] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')); $this->view->popup_activate = WM_Router::create($request->getBaseUrl() . '?controller=users&action=activate'); $this->view->search_url = WM_Router::create($request->getBaseUrl() . '?controller=search&action=advanced?id=activate'); //$this->view->deportes = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=deportes'); $this->view->addMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=create'); $this->view->stateMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=state'); $this->view->viewMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=view'); $activate = Model_Users::getActivateUser(JO_Session::get('user[user_id]')); if ($activate) { $this->view->userIsActivate = $activate["activate"]; } if ($user_data['type_user']) { $this->view->userCanActivate = Model_Users::getUserTypeNotOthers($user_data['type_user']); } if (JO_Registry::get('isMobile')) { $this->view->urlagenda = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agenda&user_id=' . $user_data['user_id']); $this->view->urlmensajes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=mensajes&user_id=' . $user_data['user_id']); } if ($request->isXmlHttpRequest()) { echo $this->view->boards; $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } }
public function feedAction($data = array()) { $request = $this->getRequest(); if (!$data) { $this->forward('error', 'error404'); } else { $this->view->item = array(); $model_images = new Helper_Images(); foreach ($data['pins'] as $pin) { $image = call_user_func(array(Helper_Pin::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_D'); if ($image) { $enclosure = $image['image']; } else { continue; } $category_info = Model_Categories::getCategory($pin['category_id']); if ($category_info) { $pin['board'] = $category_info['title'] . ' >> ' . $pin['board']; } $this->view->item[] = array('guid' => $pin['pin_id'], 'enclosure' => $enclosure, 'description' => Helper_Pin::descriptionFix($pin['description']), 'title' => Helper_Pin::descriptionFix(JO_Utf8::splitText($pin['description'], 60, '...')), 'link' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']), 'author' => $pin['user']['fullname'], 'pubDate' => WM_Date::format($pin['date_added'], JO_Date::RSS_FULL), 'category' => $pin['board']); } echo $this->renderScript('rss'); } }
public function indexAction() { $request = $this->getRequest(); $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $query = $request->getRequest('q'); $this->view->query = $query; $this->view->menuSearch = $this->searchMenu($query); $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_description' => $query, 'filter_marker' => $request->getRequest('marker')); $this->view->pins = ''; $pins = Model_Pins::getPins($data); if ($pins) { foreach ($pins as $pin) { $this->view->pins .= Helper_Pin::returnHtml($pin); } // JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } if ($request->isXmlHttpRequest()) { echo $this->view->pins; $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } }
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; }