function getSearch() { $query_string = isset(Request::$get_normal['q']) ? trim(Request::$get_normal['q']) : false; $search = Search::getInstance(); /* @var $search Search */ $cond = new Conditions(); $per_page = 0; if (isset($this->params['per_page'])) { $per_page = (int) $this->params['per_page']; } $per_page = $per_page > 0 ? $per_page : 5; $cond->setPaging(1000, $per_page); $offset = $cond->getMongoLimit(); list($sids, $count, $hl) = $search->searchMagazinesByString($query_string, $offset, $per_page); $cond = new Conditions(); $cond->setPaging($count, $per_page); if ($count) { $query = 'SELECT * FROM `magazines` WHERE `id` IN(' . implode(',', $sids) . ')'; $series = Database::sql2array($query); $this->data['magazines'] = $series; } else { $this->data['magazines'] = array(); } $this->data['conditions'] = $cond->getConditions(); foreach ($this->data['magazines'] as &$m) { if (isset($hl[$m['id']])) { $m['path'] = Config::need('www_path') . '/m/' . $m['id'] . '#hl=' . implode(' ', $hl[$m['id']]); } else { $m['path'] = Config::need('www_path') . '/m/' . $m['id'] . '#hl=' . Request::$get_normal['q']; } } $this->data['magazines']['title'] = 'Журналы по запросу «' . $query_string . '»'; $this->data['magazines']['count'] = $count; }
function getBookContributionComments() { global $current_user; /* @var $current_user CurrentUser */ $id_book = isset($this->params['book_id']) ? (int) $this->params['book_id'] : false; if (!$id_book) { return; } $book = Books::getInstance()->getByIdLoaded($id_book); /* @var $book Book */ if (!$book->exists) { throw new Exception('book #' . $book->id . ' not exists'); } $cond = new Conditions(); $per_page = 0; if (isset($this->params['per_page'])) { $per_page = (int) $this->params['per_page']; } $per_page = $per_page > 0 ? $per_page : 20; $pagingName = isset($this->params['paging_parameter_name']) ? $this->params['paging_parameter_name'] : 'p'; $cond->setPaging(1000, $per_page, $pagingName); $limit = $cond->getMongoLimit(); list($comments, $count) = MongoDatabase::getBookComments($id_book, $per_page, $limit); $uids = array(); $comments['comments'] = isset($comments['comments']) ? $comments['comments'] : array(); foreach ($comments['comments'] as &$comment) { $comment['commenter_id'] = $comment['user_id']; $comment['type'] = 'book'; $comment['time'] = date('Y/m/d H:i:s', $comment['time']); $uids[$comment['user_id']] = $comment['user_id']; } $cond = new Conditions(); $cond->setPaging($count, $per_page, $pagingName); $this->data['conditions'] = $cond->getConditions(); $this->data['comments'] = isset($comments['comments']) ? $comments['comments'] : array(); $this->data['comments']['title'] = 'Обсуждение книги «' . $book->getTitle(true) . '»'; $this->data['comments']['count'] = $count; $this->data['users'] = $this->getCommentsUsers($uids); }
function getSearch() { $query_string = isset(Request::$get_normal['q']) ? trim(Request::$get_normal['q']) : false; $search = Search::getInstance(); /* @var $search Search */ $cond = new Conditions(); $per_page = 0; if (isset($this->params['per_page'])) { $per_page = (int) $this->params['per_page']; } $per_page = $per_page > 0 ? $per_page : 5; $cond->setPaging(1000, $per_page); $offset = $cond->getMongoLimit(); list($aids, $count, $hl) = $search->searchAuthorsByString($query_string, $offset, $per_page); $cond = new Conditions(); $cond->setPaging($count, $per_page); $this->data = $this->_idsToData($aids); $this->data['conditions'] = $cond->getConditions(); foreach ($this->data['authors'] as &$a) { if (isset($hl[$a['id']])) { $a['path'] .= '#hl=' . implode(' ', $hl[$a['id']]); } else { $a['path'] .= '#hl=' . Request::$get_normal['q']; } } $this->data['authors']['title'] = 'Авторы по запросу «' . $query_string . '»'; $this->data['authors']['count'] = $count; }
function getUserEvents($all = false) { $cond = new Conditions(); $per_page = 0; if (isset($this->params['per_page'])) { $per_page = (int) $this->params['per_page']; } $per_page = $per_page > 0 ? $per_page : self::PER_PAGE; $pagingName = isset($this->params['paging_parameter_name']) ? $this->params['paging_parameter_name'] : 'p'; $cond->setPaging(self::MAX_EVENTS_ON_WALL, $per_page, $pagingName); $limit = $cond->getMongoLimit(); // показываем просто последнюю активность $events = MongoDatabase::findReviewEvents(false, $this->user_id, $per_page, $limit); $this->_list($events); }