Example #1
0
 public function onQuickSearch($term)
 {
     $posts = GDO::table('GWF_ForumPost');
     $fields = $posts->getSearchableFields(GWF_User::getStaticOrGuest());
     $_GET['term'] = $term = trim($term);
     //		$term = Common::getRequest('term', '');
     if (false === ($conditions = GWF_QuickSearch::getQuickSearchConditions($posts, $fields, $term))) {
         $conditions = '0';
     }
     $permQuery = GWF_ForumPost::getPermQuery();
     $conditions .= ' AND (' . $permQuery . ')';
     $by = Common::getGet('by', 'post_date');
     $dir = Common::getGet('dir', 'DESC');
     $orderby = $posts->getMultiOrderby($by, $dir);
     $ipp = $this->module->getThreadsPerPage();
     $nItems = $posts->countRows($conditions);
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp(Common::getGet('page', 1), 1, $nPages);
     $href = $this->getMethodHref(sprintf('&term=%s&by=%s&dir=%s&page=%%PAGE%%', urlencode($term), urlencode($by), urlencode($dir)));
     $this->pagemenu = GWF_PageMenu::display($page, $nPages, $href);
     $result = GWF_QuickSearch::search($posts, $fields, $term, $orderby, $ipp, GWF_PageMenu::getFrom($page, $ipp), $permQuery);
     $this->sortURL = $this->getMethodHref(sprintf('&term=%s&by=%%BY%%&dir=%%DIR%%&page=1', urlencode($term)));
     return $this->templateSearch($result, $term);
 }