public function getSearchResultAction($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'); } $query = $request->getRequest('q'); $data = array('start' => $pp * $page - $pp, 'limit' => $pp, 'filter_title' => $query); $return = array(); /* set board count */ $has_boards = true; if (!trim($query)) { $has_boards = false; } // pins data $boards = $has_boards ? new Model_Boards_Search($data) : new ArrayObject(); //format response data $formatObject = new Helper_Format(); if ($has_boards && $boards->count()) { foreach ($boards as $row => $board) { //boards $return[] = $formatObject->fromatListBoard($board); } } else { if ($page == 1) { $message = $this->translate('No boards!'); } else { $message = $this->translate('No more boards!'); } $return[] = $formatObject->fromatListNoResults($message); } if ($return_data) { return $return; } $formatObject->responseJsonCallback($return); $this->noViewRenderer(true); }
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); }
public function boardsAction() { $request = $this->getRequest(); $category_id = $request->getPost('category_id'); $this->view->boards = array(); if ($category_id) { /* v2.2 */ $config_enable_follow_private_profile = ''; if (Helper_Config::get('config_enable_follow_private_profile')) { $config_enable_follow_private_profile = ' AND boards.user_id IN (SELECT user_id FROM users WHERE public = 1)'; } /* v2.2 */ $boards = new Model_Boards_PopularBoards(array('start' => 0, 'limit' => 25, 'sort' => 'DESC', 'order' => 'boards.total_views', 'where' => new JO_Db_Expr("boards.category_id = '" . $category_id . "' AND boards.pins > 0 " . $config_enable_follow_private_profile))); if ($boards->count()) { $formatObject = new Helper_Format(); foreach ($boards as $board) { $data = $formatObject->fromatListBoard($board); $this->view->boards[] = array('board_id' => $data['board_id'], 'thumbs' => $data['thumbs'], 'title' => $data['title'], 'fullname' => $data['fullname'], 'autor_id' => $board['board_user_id'], 'following_board' => $data['following_board'], 'text_by' => $this->translate('by'), 'text_follow' => $this->translate('Follow'), 'text_unfollow' => $this->translate('Unfollow'), 'board_follow_href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $data['autor_id'] . '&board_id=' . $data['board_id'])); } } else { $this->view->error = $this->translate('No boards in this category!'); } } echo $this->renderScript('json'); }