function get_search_feed() { global $wgSitename, $wgOut; // set up search obj: $sms = new MV_SpecialMediaSearch(); // setup filters: $sms->setUpFilters(); // do the search: $sms->doSearch(); // get the search page title: $msTitle = Title::MakeTitle( NS_SPECIAL, 'MediaSearch' ); $this->feed = new mvRSSFeed( $wgSitename . ' - ' . wfMsg( 'mediasearch' ) . ' : ' . strip_tags( $sms->getFilterDesc() ), // title strip_tags( $sms->getFilterDesc() ), // description $msTitle->getFullUrl() . '?' . $sms->get_httpd_filters_query() // link ); $this->feed->outHeader( $this->output_xml_header ); $MV_Overlay = new MV_Overlay(); // for each search result: foreach ( $sms->results as $inx => & $mvd ) { // get Stream title for mvd match: $mvTitle = new MV_Title( $mvd->wiki_title ); $stremTitle = Title::MakeTitle( MV_NS_STREAM, $mvTitle->getStreamName() . '/' . $mvTitle->getTimeRequest() ); $this->feed->outPutItem( $mvTitle, $MV_Overlay->getMVDhtml( $mvd, $absolute_links = true ) ); } $this->feed->outFooter(); }
function getTopSearches() { $dbr = wfGetDB(DB_READ); $o = ''; $options = array(); /*$result = $dbr->select('mv_search_digest', '`query_key`, COUNT(1) as `hit_count`', "`time` >= '$start_time' ", __METHOD__, array('GROUP BY' => 'query_key', 'ORDER BY `hit_count` ASC', 'LIMIT 0,'.$this->params['num_results']) );*/ /*$sql="SELECT `mv_search_digest`.`query_key`, COUNT(1) as `hit_count`, `mv_query_key_lookup`.`filters` FROM `mv_search_digest` LEFT JOIN `mv_query_key_lookup` ON (`mv_search_digest`.`query_key` = `mv_query_key_lookup`.`query_key`) WHERE `time` >= '{$this->getStartTime()}' GROUP BY `mv_search_digest`.`query_key` LIMIT 0, {$this->params[num_results]}";*/ // $from_tables $vars = array($dbr->tableName('mv_search_digest') . '.query_key', 'COUNT(1) as `hit_count`', $dbr->tableName('mv_query_key_lookup') . '.filters'); $from_tables = $dbr->tableName('mv_search_digest') . ' JOIN' . $dbr->tableName('mv_query_key_lookup') . ' ON ( ' . $dbr->tableName('mv_search_digest') . '.query_key = ' . $dbr->tableName('mv_query_key_lookup') . '.query_key ' . ' ) '; $conds = '`time` >= ' . $dbr->addQuotes($this->getStartTime()); $options['GROUP BY'] = $dbr->tableName('mv_search_digest') . '.query_key'; $options['ORDER BY'] = '`hit_count` DESC'; $options['LIMIT'] = $this->params['num_results']; $result = $dbr->select($from_tables, $vars, $conds, __METHOD__, $options); if ($dbr->numRows($result) == 0) { return ''; } else { // @@todo probably should try to abstract out formating.. // but will need to wait until we have a few more test cases to do a productive abstraction if ($this->params['format'] == 'ul_list') { $class_attr = $this->params['class'] != '' ? ' class="' . htmlspecialchars($this->params['class']) . '"' : ''; $o .= '<ul' . $class_attr . '>'; } $mvms = new MV_SpecialMediaSearch(); $sTitle = Title::MakeTitle(NS_SPECIAL, 'MediaSearch'); while ($row = $dbr->fetchObject($result)) { $title_desc = htmlspecialchars($row->hit_count) . ' ' . wfMsg('mv_date_' . $this->params['time_range']); $mvms->loadFiltersFromSerialized($row->filters); $o .= '<li><a title="' . $title_desc . '" href="' . $sTitle->escapeLocalURL($mvms->get_httpd_filters_query() . '&tl=1') . '">' . $mvms->getFilterDesc($query_key = true) . '</li>'; } if ($this->params['format'] == 'ul_list') { $o .= '</ul>'; } } return $o; }