getProject(); $lang = Session::getSession()->getLanguage(); $template = new ProjectTemplate(); if (isset($_REQUEST['do_search'])) { $search=(isset($_REQUEST['search']) ? $_REQUEST['search'] : array()); $words =(isset($_REQUEST['words']) ? Validator::sanitizeString($_REQUEST['words']) : ''); $search_params['template'] = $template; $search_params['project'] = $project; $search_params['search']= $search; $search_params['words'] = $words; } else { $words = ''; $search = array(); } $params = array( 'selectedbottomtab'=>'ftsearch', 'project' => $project, 'title'=>'FullText Search', 'feedback'=>isset($_REQUEST['feedback']) ? $_REQUEST['feedback'] : (isset($feedback) ? $feedback : '') ); $template->header($params); $theader = array('Search Criteria'); //echo ''; echo $template->tableTop($theader); $trow = array(); echo '
'; $trow[0] = ''.$lang->getText('Search.Keywords').': '; $trow[0] .= '' . HTMLWidget::button("submit",$language->getSessText('SearchBox.search'),"do_search","","") . '
'; echo $template->tableRow($trow,array(),true); echo $template->tableBottom(); echo '

'; /**************** sphinx var define *****************/ $q = ""; $mode = SPH_MATCH_ALL; $host = "localhost"; $port = 3312; $index = "*"; $groupby = ""; $groupsort = "@group desc"; $filterPrj = "project_id"; $filterprjvals = array($project->getProjectId()); //$filter = ""; //$filtervals = array(); $distinct = ""; $sortby = ""; $limit = 50; $ranker = SPH_RANK_PROXIMITY_BM25; //End sphinx var define if (array_key_exists('do_search',$_REQUEST)) { if (strlen($_REQUEST['words'])>0) { try { /**************** sphinx do query *****************/ // do query $q = $_REQUEST['words']; $cl = new SphinxClient (); $cl->SetServer ( $host, $port ); $cl->SetWeights ( array ( 100, 1 ) ); $cl->SetMatchMode ( $mode ); if ( count($filterprjvals) ) $cl->SetFilter ( $filterPrj, $filterprjvals ); if ( $groupby ) $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort ); if ( $sortby ) $cl->SetSortMode ( SPH_SORT_EXTENDED, $sortby ); //if ( $sortexpr ) $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr ); if ( $distinct ) $cl->SetGroupDistinct ( $distinct ); if ( $limit ) $cl->SetLimits ( 0, $limit, ( $limit>1000 ) ? $limit : 1000 ); $cl->SetRankingMode ( $ranker ); $cl->SetArrayResult ( true ); $res = $cl->Query ( $q, $index ); // print me out if ( $res===false ) { echo "

Query failed:". $cl->GetLastError() . "

"; } else { if ( $cl->GetLastWarning() ) echo "

WARNING:". $cl->GetLastWarning() . "

"; //echo "

projectId = ".$project->getProjectId()."

"; echo "

'$q' retrieved $res[total] of $res[total_found] matches in $res[time] sec .". "

"; echo "

"; /* echo "

Query stats:

"; if ( is_array($res["words"]) ) foreach ( $res["words"] as $word => $info ) //print " '$word' found $info[hits] times in $info[docs] documents\n"; echo "

'$word' found $info[hits] times in $info[docs] documents

"; */ $url = GFurl::getUrl(); //Forum Message if ( is_array($res["matches"]) ) { $n = 1; echo "

Forum Message Matches:

"; //$theader = array('Forum Message Id','Summary','Date'); $theader = array('Forum Message Id','Summary'); echo $template->tableTop($theader); $ForumMessagePeer = new ForumMessagePeer(); foreach ( $res["matches"] as $docinfo ) { $trow = array(); $ForumMessage = $ForumMessagePeer->retrieveByPk($docinfo['id']); if($ForumMessage) { $ForumMessageUrl = $ForumMessage->getForumMessageLink(); $trow[0]="" . $docinfo['id'] . ""; $trow[1]="" . $ForumMessage->getSubject(). ""; } else { $trow[0]=$docinfo['id']; $trow[1]="summary"; } foreach ( $res["attrs"] as $attrname => $attrtype ) { $value = $docinfo["attrs"][$attrname]; if ( $attrtype & SPH_ATTR_MULTI ) { $value = "(" . join ( ",", $value ) .")"; } else { if ( $attrtype==SPH_ATTR_TIMESTAMP ) $value = date ( "Y-m-d H:i:s", $value ); } /* if ($attrname == "doc_date") { $trow[2] = $value; } */ if ($attrname == "doc_cat_id") { $doc_cat_id = $value; } } $n++; // doc_cat_id = 1 : froum message if ($doc_cat_id == 1) { echo $template->tableRow($trow,array(),true); } } echo $template->tableBottom(); } //Tracker Item if ( is_array($res["matches"]) ) { $n = 1; echo "

Tracker Item Matches:

"; //$theader = array('Tracker Item Id','Summary','Date'); $theader = array('Tracker Item Id','Summary'); echo $template->tableTop($theader); $TrackerItemPeer = new TrackerItemPeer(); foreach ( $res["matches"] as $docinfo ) { $trow = array(); $TrackerItem = $TrackerItemPeer->retrieveByPk($docinfo['id']); if ($TrackerItem) { $TRackerItemUrl = $TrackerItem->getTrackerItemUrl(); $trow[0]="".$docinfo['id'].""; $trow[1]="".$TrackerItem->getName().""; }else { $trow[0]=$docinfo['id']; $trow[1]="summary"; } foreach ( $res["attrs"] as $attrname => $attrtype ) { $value = $docinfo["attrs"][$attrname]; if ( $attrtype & SPH_ATTR_MULTI ) { $value = "(" . join ( ",", $value ) .")"; } else { if ( $attrtype==SPH_ATTR_TIMESTAMP ) $value = date ( "Y-m-d H:i:s", $value ); } /* if ($attrname == "doc_date") { $trow[2] = $value; } */ if ($attrname == "doc_cat_id") { $doc_cat_id = $value; } } $n++; // doc_cat_id = 2 : Tracker Item if ($doc_cat_id == 2) { echo $template->tableRow($trow,array(),true); } } echo $template->tableBottom(); } // wiki page //wiki page if ( is_array($res["matches"]) ) { $n = 1; echo "

Wiki Page Matches:

"; $theader = array('wiki page Id','Summary'); echo $template->tableTop($theader); $WikiPagePeer = new WikiPagePeer(); foreach ( $res["matches"] as $docinfo ) { $trow = array(); $WikiPage = $WikiPagePeer->retrieveByPk($docinfo['id']); $WikiPageUrl = $WikiPage->getWikiPageLink(); if ($WikiPageUrl) { $trow[0]="".$docinfo['id'].""; $trow[1]="". $WikiPage->getPageName() . ""; }else { $trow[0]=$docinfo['id']; $trow[1]="summary"; } foreach ( $res["attrs"] as $attrname => $attrtype ) { $value = $docinfo["attrs"][$attrname]; if ( $attrtype & SPH_ATTR_MULTI ) { $value = "(" . join ( ",", $value ) .")"; } else { if ( $attrtype==SPH_ATTR_TIMESTAMP ) $value = date ( "Y-m-d H:i:s", $value ); } if ($attrname == "doc_date") { $doc_date = $value; }elseif ($attrname == "doc_cat_id") { $doc_cat_id = $value; }elseif ($attrname == "project_id") { $project_id = $value; }elseif ($attrname == "pagename") { $pagename = $value; } } $n++; //$wikiproject = ProjectPeer::retrieveByPk($project_id); //$pagenameurl = GFUrl::getURL()->projectURL($wikiproject,'','wiki','',array('pageid'=>$pageid)); // doc_cat_id = 3 : wiki page if ($doc_cat_id == 3) { echo $template->tableRow($trow,array(),true); } } echo $template->tableBottom(); } } // sphinx End do query /**************** sphinx code End *****************/ } catch (SQLException $e) { // SQL exception here means that there was a syntax error on the search terms echo ''.$lang->getText('Search.InvalidSearch').''; } } else { echo "

Empty Search

"; } } $template->footer(); ?>