示例#1
0
 public function feedAction()
 {
     $request = $this->getRequest();
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $pp = (int) Helper_Config::get('config_front_limit');
     if (!(int) $pp) {
         $pp = 50;
     }
     if ((int) $request->getRequest('per_page') > 0 && (int) $request->getRequest('per_page') < 300) {
         $pp = (int) $request->getRequest('per_page');
     }
     $data = array('start' => $pp * $page - $pp, 'limit' => $pp, 'filter_user_id' => $request->getRequest('user_id'));
     $user_data = new Model_Users_User($request->getRequest('user_id'));
     if ($user_data->count()) {
         JO_Registry::set('meta_title', $user_data['fullname'] . ' - ' . Helper_Config::get('meta_title'));
         if ($user_data['pins']) {
             $pins = new Model_Pins_Users($data);
             $this->view->item = array();
             if ($pins->count()) {
                 $formatObject = new Helper_Format();
                 foreach ($pins->data as $pin) {
                     $pin = $formatObject->fromatList($pin);
                     $category_info = Model_Categories::getCategory($pin['category_id']);
                     if ($category_info) {
                         $pin['text_board'] = $category_info['title'] . ' >> ' . $pin['text_board'];
                     }
                     $this->view->item[] = array('guid' => $pin['pin_id'], 'enclosure' => $pin['images']['thumb_image_b'], 'description' => $pin['description'], 'title' => JO_Utf8::splitText($pin['description'], 60, '...'), 'link' => $pin['pin_url'], 'author' => $pin['author_profile']['fullname'], 'pubDate' => WM_Date::format($pin['date_added'], JO_Date::RSS_FULL), 'category' => $pin['text_board']);
                 }
             }
         }
     }
     echo $this->renderScript('rss');
 }
示例#2
0
 public function getOtherDataAction()
 {
     $request = $this->getRequest();
     $response = $this->getResponse();
     $pin_id = $request->getRequest('pin_id');
     $pin_info = new Model_Pins_Pin($pin_id);
     $return = array();
     $formatObject = new Helper_Format();
     if ($pin_info->count()) {
         $pin_info = $pin_info->data;
         $pin_info = array_merge((array) $pin_info, Helper_Pin::formatPinData((array) $pin_info));
         $loged = JO_Session::get('user[user_id]');
         /* v2.2 */
         $config_enable_follow_private_profile = Helper_Config::get('config_enable_follow_private_profile');
         if ($config_enable_follow_private_profile) {
             $user_enable_follow = $pin_info['via_user_id'] ? $pin_info['via_enable_follow'] : $pin_info['user_enable_follow'];
         } else {
             $user_enable_follow = true;
         }
         /* v2.2 */
         $return = array('loged' => $loged, 'enable_follow_board' => $loged ? $pin_info['board_user_id'] != $loged && $user_enable_follow : false, 'enable_follow_user' => $loged ? $pin_info['user_user_id'] != $loged && $user_enable_follow : false, 'enable_follow_via' => $loged ? ($pin_info['via_user_id'] ? $pin_info['via_user_id'] : $pin_info['user_user_id']) != $loged && $user_enable_follow : false, 'board_is_follow' => $pin_info['following_board'], 'via_is_follow' => $pin_info['via_user_id'] ? $pin_info['following_via'] : $pin_info['following_user'], 'pin_likes' => $pin_info['pin_likes'], 'pin_likes_total' => $pin_info['pin_likes'] > 20 ? $pin_info['pin_likes'] - 20 : 0, 'user_follow_href' => $pin_info['user_follow_href'], 'board_follow_href' => $pin_info['board_follow_href'], 'via_follow_href' => $pin_info['via_follow_href'], 'text_unfollow' => $this->translate('Unfollow'), 'text_follow' => $this->translate('Follow'), 'text_likes' => $this->translate('Likes'), 'text_repins' => $this->translate('Repins'), 'text_onto_board' => $this->translate('Pinned onto the board'), 'text_onto' => $this->translate('onto'), 'text_originally_pinned' => $this->translate('Originally pinned by'), 'text_pined_via' => sprintf($this->translate('Pinned via %s from'), Helper_Config::get('site_name')), 'pin_likes_total_text' => sprintf($this->translate('+%d more likes'), $pin_info['pin_likes'] - 20));
         //other pins from board
         $return['onto_board'] = false;
         $pins = new Model_Pins_Boards(array('start' => 0, 'limit' => 12, 'filter_board_id' => $pin_info['pin_board_id']));
         if ($pins->count()) {
             $board_info = new Model_Boards_Board($pin_info['pin_board_id']);
             if ($board_info->count()) {
                 $href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_info['pin_user_id'] . '&board_id=' . $pin_info['pin_board_id']);
                 $return['onto_board'] = array('pins' => array(), 'url' => $href, 'name' => $pin_info['board_title'], 'user_id' => $board_info['user_user_id']);
                 $total = $pins->count();
                 foreach ($pins->data as $row => $pin) {
                     $pin['pin_id'] = $pin['pin_pin_id'];
                     $key = false;
                     if ($row == 0) {
                         $key = 'first';
                     } else {
                         if ($row == $total - 1) {
                             $key = 'last';
                         }
                     }
                     $return['onto_board']['pins'][] = array('images' => Helper_Uploadimages::pinThumbs($pin), 'href' => $href, 'key' => $key);
                 }
             }
         }
         // others pin from via or user
         $return['originally_pinned'] = false;
         $pins = new Model_Pins_Users(array('start' => 0, 'limit' => 6, 'filter_user_id' => $pin_info['via_user_id'] ? $pin_info['via_user_id'] : $pin_info['pin_user_id']));
         if ($pins->count()) {
             $href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . ($pin_info['via_user_id'] ? $pin_info['via_user_id'] : $pin_info['pin_user_id']));
             $return['originally_pinned'] = array('pins' => array(), 'url' => $href, 'name' => $pin_info['via_user_id'] ? $pin_info['via_fullname'] : $pin_info['user_fullname'], 'via' => $pin_info['via_user_id'] ? true : false, 'user_id' => $pin_info['via_user_id'] ? $pin_info['via_user_id'] : $pin_info['pin_user_id']);
             $total = $pins->count();
             foreach ($pins->data as $row => $pin) {
                 $pin['pin_id'] = $pin['pin_pin_id'];
                 $key = false;
                 if ($row == 0) {
                     $key = 'first';
                 } else {
                     if ($row == $total - 1) {
                         $key = 'last';
                     }
                 }
                 $return['originally_pinned']['pins'][] = array('images' => Helper_Uploadimages::pinThumbs($pin), 'href' => $href, 'key' => $key);
             }
         }
         // others pin from source
         $return['source'] = false;
         if ($pin_info['pin_source_id']) {
             $pins = new Model_Pins_Source(array('start' => 0, 'limit' => 5, 'filter_source_id' => $pin_info['pin_source_id']));
             if ($pins->count()) {
                 $href = WM_Router::create($request->getBaseUrl() . '?controller=source&source_id=' . $pin_info['pin_source_id']);
                 $return['source'] = array('pins' => array(), 'url' => $href, 'name' => $pin_info['source_source']);
                 $total = $pins->count();
                 foreach ($pins->data as $row => $pin) {
                     $pin['pin_id'] = $pin['pin_pin_id'];
                     $key = false;
                     if ($row == 0) {
                         $key = 'first';
                     } else {
                         if ($row == $total - 1) {
                             $key = 'last';
                         }
                     }
                     $return['source']['pins'][] = array('images' => Helper_Uploadimages::pinThumbs($pin), 'href' => $href, 'key' => $key);
                 }
             }
         }
         // others pin likes
         $return['users_likes'] = false;
         if ($pin_info['pin_likes']) {
             $users = new Model_Users_LikesPin(array('start' => 0, 'limit' => 20, 'filter_like_pin_id' => $pin_info['pin_id']));
             if ($users->count()) {
                 $total = $users->count();
                 foreach ($users as $row => $user) {
                     $user['pin_id'] = $pin['pin_pin_id'];
                     $key = false;
                     if ($row == 0) {
                         $key = 'first';
                     } else {
                         if ($row == $total - 1) {
                             $key = 'last';
                         }
                     }
                     $return['users_likes'][] = array('avatars' => Helper_Uploadimages::userAvatars($user), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']), 'fullname' => $user['fullname'], 'key' => $key);
                 }
             }
         }
         // others pin from source
         $return['users_repins'] = false;
         if ($pin_info['pin_repins']) {
             $pins = new Model_Pins_Repins(array('start' => 0, 'limit' => 6, 'filter_like_pin_id' => $pin_info['pin_id']));
             if ($pins->count()) {
                 $total = $pins->count();
                 foreach ($pins->data as $row => $pin) {
                     $pin['pin_id'] = $pin['pin_pin_id'];
                     $key = false;
                     if ($row == 0) {
                         $key = 'first';
                     } else {
                         if ($row == $total - 1) {
                             $key = 'last';
                         }
                     }
                     $return['users_repins'][$pin['user_user_id']] = array('user' => array('fullname' => $pin['user_fullname'], 'avatars' => Helper_Uploadimages::userAvatars(array('avatar' => $pin['user_avatar'], 'store' => $pin['user_store'], 'user_id' => $pin['user_user_id'])), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['user_user_id'])), 'board' => array('name' => $pin['board_title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin['user_user_id'] . '&board_id=' . $pin['board_board_id'])), 'key' => $key);
                 }
             }
         }
     }
     //format response data
     $formatObject = new Helper_Format();
     $formatObject->responseJsonCallback($return);
     $this->noViewRenderer(true);
 }