Пример #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);
 }
Пример #3
0
 public function getActivityAction($user_data = array(), $return_data = false)
 {
     if (!$user_data) {
         $this->forward('error', 'error404');
     }
     $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);
     $history = new Model_History_Activity($data, 'from_user_id', $user_data['user_id']);
     $return = array();
     $formatObject = new Helper_Format();
     if ($history->count()) {
         foreach ($history as $key => $row) {
             $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $row['to_user_id']);
             if ($row['history_action'] == Model_History_Abstract::REPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate('Repinned to %s via %s.'), '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>', '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_repin';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::ADDPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate('Pinned to %s.'), '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>');
                 $row_data['activity_class'] = 'a_addpin';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::LIKEPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate("Liked %s's pin on %s."), '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>', '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_like';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::UNLIKEPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate("Unliked %s's pin on %s."), '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>', '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_unlike';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::COMMENTPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate("Commented on %s's pin and said \"%s\"."), '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>', JO_Utf8::splitText($row['comment'], 60, '...'));
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_comment';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::ADDBOARD) {
                 $row['user_user_id'] = $row['from_user_id'];
                 $row_data = $formatObject->fromatListBoard($row);
                 $row_data['set_activity_title'] = $this->translate('Created');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_addboard';
                 $return[] = $row_data;
             } else {
                 if ($row['history_action'] == Model_History_Abstract::FOLLOW_USER) {
                     $row_data = $formatObject->fromatUserFollow($row);
                     $row_data['activity_class'] = 'a_follow_user';
                     $return[] = $row_data;
                 } elseif ($row['history_action'] == Model_History_Abstract::UNFOLLOW_USER) {
                     $row_data = $formatObject->fromatUserFollow($row);
                     $row_data['activity_class'] = 'a_unfollow_user';
                     $return[] = $row_data;
                 } elseif ($row['history_action'] == Model_History_Abstract::FOLLOW) {
                     $row['user_user_id'] = $row['from_user_id'];
                     $row_data = $formatObject->fromatListBoard($row);
                     $row_data['set_activity_title'] = $this->translate('Follow');
                     $row_data['history_id'] = $row['history_id'];
                     $row_data['activity_class'] = 'a_follow_board';
                     $return[] = $row_data;
                 } elseif ($row['history_action'] == Model_History_Abstract::UNFOLLOW) {
                     $row['user_user_id'] = $row['from_user_id'];
                     $row_data = $formatObject->fromatListBoard($row);
                     $row_data['set_activity_title'] = $this->translate('Unfollow');
                     $row_data['history_id'] = $row['history_id'];
                     $row_data['activity_class'] = 'a_unfollow_board';
                     $return[] = $row_data;
                 }
             }
         }
     } else {
         if ($page == 1) {
             $message = $this->translate('No activity!');
         } else {
             $message = $this->translate('No more activity!');
         }
         $return[] = $formatObject->fromatListNoResults($message);
     }
     if ($return_data) {
         return $return;
     }
     $formatObject->responseJsonCallback($return);
     $this->noViewRenderer(true);
 }
Пример #4
0
 public function feedAction($data = array())
 {
     $request = $this->getRequest();
     if (!$data) {
         $this->forward('error', 'error404');
     } else {
         $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_board_id' => $request->getParam('board_id'));
         $pins = new Model_Pins_Boards($data);
         $formatObject = new Helper_Format();
         $this->view->item = array();
         if ($pins->count()) {
             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');
     }
 }