コード例 #1
0
 public function getSearchResultAction($return_data = false)
 {
     $request = $this->getRequest();
     $response = $this->getResponse();
     $query = $request->getRequest('q');
     $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_description' => $query);
     $return = array();
     /* set board count */
     $has_pins = true;
     if (!trim($query)) {
         $has_pins = false;
     }
     // pins data
     $pins = $has_pins ? new Model_Pins_Search($data) : new ArrayObject();
     //format response data
     $formatObject = new Helper_Format();
     if ($has_pins && $pins->count()) {
         $banners = Model_Banners::getBanners(new JO_Db_Expr("`controller` = '" . $request->getController() . "' AND position >= '" . (int) $data['start'] . "' AND position <= '" . (int) ($data['start'] + $pp) . "'"));
         foreach ($pins->data as $row => $pin) {
             ///banners
             $key = $row + ($pp * $page - $pp);
             if (isset($banners[$key]) && $banners[$key]) {
                 if (($banners_result = $formatObject->fromatListBanners($banners[$key])) !== false) {
                     $return[] = $banners_result;
                 }
             }
             //pins
             $return[] = $formatObject->fromatList($pin);
         }
     } else {
         if ($page == 1) {
             $message = $this->translate('No pyngs!');
         } else {
             $message = $this->translate('No more pyngs!');
         }
         $return[] = $formatObject->fromatListNoResults($message);
     }
     if ($return_data) {
         return $return;
     }
     $formatObject->responseJsonCallback($return);
     $this->noViewRenderer(true);
 }
コード例 #2
0
 public function getPinsAction($return_data = false)
 {
     $request = $this->getRequest();
     $response = $this->getResponse();
     $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);
     $return = array();
     //Recent Activity
     if ($page == 1 && JO_Session::get('user[user_id]')) {
         $history_data = Model_History_Activity::getHistoryV2(array('start' => 0, 'limit' => 10, 'sort' => 'DESC', 'order' => 'history_id'));
         $history = array();
         foreach ($history_data as $row) {
             $user_avatars = Helper_Uploadimages::userAvatars(array('avatar' => $row['user_avatar'], 'store' => $row['user_store'], 'user_id' => $row['user_user_id']));
             $haystack_pins = array(Model_History_Abstract::REPIN, Model_History_Abstract::ADDPIN, Model_History_Abstract::COMMENTPIN, Model_History_Abstract::LIKEPIN);
             $text = $row['history_text_type'];
             $href_pin = false;
             /*if( in_array($row['history_history_action'], $haystack_pins) ) {
             // 				if($row['history_history_action'] == Model_History_Abstract::REPIN) {
             					$href = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $row['history_pin_id']);
             				} else {*/
             $href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $row['history_from_user_id']);
             if (Model_History_Abstract::REPIN == $row['history_history_action']) {
                 $text = array($this->translate('repinned your'), $this->translate('pin'), 1);
                 $href_pin = WM_Router::pinAction($row['history_pin_id']);
             } elseif (Model_History_Abstract::LIKEPIN == $row['history_history_action']) {
                 $text = array($this->translate('like your'), $this->translate('pin'), 1);
                 $href_pin = WM_Router::pinAction($row['history_pin_id']);
             } elseif (Model_History_Abstract::UNLIKEPIN == $row['history_history_action']) {
                 $text = array($this->translate('unlike your'), $this->translate('pin'), 1);
                 $href_pin = WM_Router::pinAction($row['history_pin_id']);
             } elseif (Model_History_Abstract::COMMENTPIN == $row['history_history_action']) {
                 $text = array($this->translate('comment your'), $this->translate('pin'), 1);
                 $href_pin = WM_Router::pinAction($row['history_pin_id']);
             } elseif (Model_History_Abstract::FOLLOW == $row['history_history_action']) {
                 $board_info = new Model_Boards_Board($row['history_board_id']);
                 if ($board_info->count()) {
                     $text = array($this->translate('is now following your'), $board_info['board_title']);
                     $href_pin = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['board_user_id'] . '&board_id=' . $board_info['board_board_id']);
                 }
             } elseif (Model_History_Abstract::UNFOLLOW == $row['history_history_action']) {
                 $board_info = new Model_Boards_Board($row['history_board_id']);
                 if ($board_info->count()) {
                     $text = array($this->translate('has unfollow your'), $board_info['board_title']);
                     $href_pin = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['board_user_id'] . '&board_id=' . $board_info['board_board_id']);
                 }
             }
             //}
             $history[] = array('history_id' => $row['history_history_id'], 'date_added' => $row['history_date_added'], 'profile' => array('fullname' => $row['user_fullname'], 'avatars' => $user_avatars), 'href' => $href, 'href_pin' => $href_pin, 'text_type' => $text, 'text_date_dif' => sprintf($this->translate('%d %s ago'), $row['history_date_dif']['value'], $this->translate($row['history_date_dif']['key'])));
         }
         if ($history) {
             $return[] = array('template' => 'home_history', 'history' => $history, 'text_title_box' => $this->translate('Recent Activity'));
         }
     }
     // pins data
     $pins = new Model_Pins_HomePage($data);
     //format response data
     $formatObject = new Helper_Format();
     if ($pins->count()) {
         $banners = Model_Banners::getBanners(new JO_Db_Expr("`controller` = '" . $request->getController() . "' AND position >= '" . (int) $data['start'] . "' AND position <= '" . (int) ($data['start'] + $pp) . "'"));
         foreach ($pins->data as $row => $pin) {
             ///banners
             $key = $row + ($pp * $page - $pp);
             if (isset($banners[$key]) && $banners[$key]) {
                 if (($banners_result = $formatObject->fromatListBanners($banners[$key])) !== false) {
                     $return[] = $banners_result;
                 }
             }
             //pins
             $return[] = $formatObject->fromatList($pin);
         }
     } else {
         if ($page == 1) {
             $message = $this->translate('No pyngs!');
         } else {
             $message = $this->translate('No more pyngs!');
         }
         $return[] = $formatObject->fromatListNoResults($message);
     }
     if ($return_data) {
         return $return;
     }
     $formatObject->responseJsonCallback($return);
     $this->noViewRenderer(true);
 }