r37625 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37624‎ | r37625 | r37626 >
Date:19:03, 13 July 2008
Author:dale
Status:old
Tags:
Comment:
stubs for ordered search results
Modified paths:
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Index.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/languages/MV_Messages.php (modified) (history)

Diff [purge]

Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Index.php
@@ -196,6 +196,10 @@
197197
198198 list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset( 20, 'searchlimit' );
199199 if($this->limit > $mvMediaSearchResultsLimit)$this->limit = $mvMediaSearchResultsLimit;
 200+
 201+ $this->order_type = $wgRequest->getVal('order');
 202+ //force order type:
 203+ if($this->order_type!='relevent' || $this->order_type!='recent' || $this->order_type!='viewed') $this->order_type='relevent';
200204
201205 $group_spoken=true;
202206 $categoryTable = $dbr->tableName( 'categorylinks');
Index: branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php
@@ -1,4 +1,5 @@
22 <?php
 3+
34 /*
45 * Created on Jul 26, 2007
56 *
@@ -7,29 +8,29 @@
89 *
910 * overwrites the existing special search to add in metavid specific features
1011 */
11 -if (!defined('MEDIAWIKI')) die();
 12+if (!defined('MEDIAWIKI'))
 13+ die();
1214
1315 function doSpecialSearch($par = null) {
1416 //list( $limit, $offset ) = wfCheckLimits();
15 - $MvSpecialSearch = new MV_SpecialMediaSearch();
 17+ $MvSpecialSearch = new MV_SpecialMediaSearch();
1618 $MvSpecialSearch->doSearchPage();
1719 }
1820 //metavid search page (only search video media)
1921 SpecialPage :: addPage(new SpecialPage('MediaSearch', '', true, 'doSpecialSearch', false));
2022
21 -
2223 /*
2324 * adds media results to top of special page:
2425 */
25 -class MV_SpecialSearch extends SpecialPage{
26 - function MV_SpecialSearch( ) {
27 - global $wgOut, $wgRequest;
 26+class MV_SpecialSearch extends SpecialPage {
 27+ function MV_SpecialSearch() {
 28+ global $wgOut, $wgRequest;
2829 //mvfAddHTMLHeader('search');
2930 //$MvSpecialSearch = new MV_SpecialMediaSearch();
3031 //$MvSpecialSearch->setupFilters();
3132 //$MvSpecialSearch->doSearch();
3233 //$wgOut->addHTML($MvSpecialSearch->getResultsHTML());
33 - SpecialPage::SpecialPage('Search');
 34+ SpecialPage :: SpecialPage('Search');
3435 }
3536 }
3637 /*
@@ -43,550 +44,583 @@
4445 class MV_SpecialMediaSearch extends SpecialPage {
4546 //initial values for selectors ( keys into language as 'mv_search_$val')
4647 var $sel_filter_types = array (
47 - 'match', //full text search
48 - 'spoken_by',
49 - 'category',
50 - 'date_range', //search in a given date range
 48+ 'match', //full text search
 49+ 'spoken_by',
 50+ 'category',
 51+ 'date_range', //search in a given date range
5152 //not yet active:
5253 //'stream_name', //search within a particular stream
5354 //'layers' //specify a specific meta-layer set
5455 //'smw_property'
5556 //'smw_property_numeric'
56 - );
 57+
 58+ );
5759 var $sel_filter_andor = array (
5860 'and',
5961 'or',
6062 'not',
61 - );
 63+
 64+ );
6265 var $unified_term_search = '';
63 - var $adv_search=false;
64 -
65 - var $results=array();
66 - var $mName = 'MediaSearch';
67 - var $outputInlineHeader =true;
 66+ var $adv_search = false;
 67+
 68+ var $results = array ();
 69+ var $mName = 'MediaSearch';
 70+ var $outputInlineHeader = true;
6871 var $outputContainer = true;
6972 var $outputSeqLinks = false;
70 -
 73+
7174 var $limit = 20;
7275 var $offset = 0;
73 -
74 - function doSearchPage($term='') {
 76+ var $order = 'relevent';
 77+
 78+ function doSearchPage($term = '') {
7579 global $wgRequest, $wgOut, $wgUser;
7680 $this->setUpFilters();
7781 //do the search
7882 $this->doSearch();
7983 //page control:
80 - $this->outputInlineHeader=false;
81 - if($wgRequest->getVal('seq_inline')=='true'){
 84+ $this->outputInlineHeader = false;
 85+ if ($wgRequest->getVal('seq_inline') == 'true') {
8286 $this->outputContainer = false;
83 - $this->outputSeqLinks=true;
 87+ $this->outputSeqLinks = true;
8488 //@@todo add a absolute link to search results
8589 print $this->getResultsHTML();
8690 //@@todo cleaner exit
87 - exit();
88 - }else{
 91+ exit ();
 92+ } else {
8993 //add nessesary js to wgOut:
90 - mvfAddHTMLHeader('search');
 94+ mvfAddHTMLHeader('search');
9195 //add the search placeholder
9296 //$wgOut->addWikiText( wfMsg( 'searchresulttext' ) );
9397 $sk = $wgUser->getSkin();
9498 $title = Title :: MakeTitle(NS_SPECIAL, 'Search');
95 - $wgOut->addHTML( wfMsg('mv_page_search', $sk->makeKnownLinkObj($title, $this->unified_term_search,
96 - http_build_query(array('search'=> $this->unified_term_search))
97 - )
98 - )
99 - );
100 -
 99+ $wgOut->addHTML(wfMsg('mv_page_search', $sk->makeKnownLinkObj($title, $this->unified_term_search, http_build_query(array (
 100+ 'search' => $this->unified_term_search
 101+ )))));
 102+
101103 //check if the skin already includes the dynamicSearchControl
102104 global $wgUser;
103 - $doDSC=false;
104 - $sk = $wgUser->getSkin();
105 - if(isset($sk->skinProvidesMvSearch)){
106 - if($sk->skinProvidesMvSearch==true){
107 - $doDSC=true;
 105+ $doDSC = false;
 106+ $sk = $wgUser->getSkin();
 107+ if (isset ($sk->skinProvidesMvSearch)) {
 108+ if ($sk->skinProvidesMvSearch == true) {
 109+ $doDSC = true;
108110 }
109 - }else{
110 - $doDSC=false;
 111+ } else {
 112+ $doDSC = false;
111113 }
112 - if($doDSC)$wgOut->addHTML($this->dynamicSearchControl());
113 -
 114+ if ($doDSC)
 115+ $wgOut->addHTML($this->dynamicSearchControl());
 116+
114117 //$wgOut->addHTML($this->getResultsBar());
115 - $wgOut->addHTML($this->getUnifiedResultsHTML());
 118+ $wgOut->addHTML($this->getUnifiedResultsHTML());
116119 }
117120 }
118 - function dynamicSearchControl() {
 121+ function dynamicSearchControl() {
119122 $title = SpecialPage :: getTitleFor('MediaSearch');
120 - $action = $title->escapeLocalURL();
121 -
122 - $o ="<div id=\"msms_form_search_row\" class=\"form_search_row\">
123 - <form id=\"mv_media_search\" method=\"get\" " .
124 - "action=\"$action\">\n
125 - <input type=\"hidden\" id=\"advs\" name=\"advs\" value=\"";$o.=($this->adv_search)?'1':'0';$o.="\">
126 - <span class=\"advs_basic\" style=\"display:";$o.=($this->adv_search)?'none':'inline';$o.="\">
127 - <input type=\"text\" class=\"searchField\" name=\"mv_search\" id=\"search_field\" value=\"{$this->unified_term_search}\"/>
128 - </span>
129 - <span class=\"advs_adv\" id=\"adv_filters\" style=\"display:";$o.=($this->adv_search)?'inline':'none';$o.="\">
130 - {$this->list_active_filters()}
131 - </span>
132 - <button class=\"grey_button\" type=\"submit\"><span>&nbsp;&nbsp; ".wfMsg('mv_video_search')." &nbsp;&nbsp;</span></button>
133 - <a href=\"javascript:mv_toggle_advs()\" class=\"advanced_search_tag\">
134 - <span class=\"advs_basic\" style=\"display:";$o.=($this->adv_search)?'none':'inline';$o.="\">advanced search</span>
135 - <span class=\"advs_adv\" style=\"display:";$o.=($this->adv_search)?'inline':'none';$o.="\">basic search</span>
136 - </a>
137 - </form>
138 - </div>";
 123+ $action = $title->escapeLocalURL();
 124+
 125+ $o = "<div id=\"msms_form_search_row\" class=\"form_search_row\">
 126+ <form id=\"mv_media_search\" method=\"get\" " .
 127+ "action=\"$action\">\n
 128+ <input type=\"hidden\" id=\"advs\" name=\"advs\" value=\"";
 129+ $o .= ($this->adv_search) ? '1' : '0';
 130+ $o .= "\">
 131+ <span class=\"advs_basic\" style=\"display:";
 132+ $o .= ($this->adv_search) ? 'none' : 'inline';
 133+ $o .= "\">
 134+ <input type=\"text\" class=\"searchField\" name=\"mv_search\" id=\"search_field\" value=\"{$this->unified_term_search}\"/>
 135+ </span>
 136+ <span class=\"advs_adv\" id=\"adv_filters\" style=\"display:";
 137+ $o .= ($this->adv_search) ? 'inline' : 'none';
 138+ $o .= "\">
 139+ {$this->list_active_filters()}
 140+ </span>
 141+ <button class=\"grey_button\" type=\"submit\"><span>&nbsp;&nbsp; " . wfMsg('mv_video_search') . " &nbsp;&nbsp;</span></button>
 142+ <a href=\"javascript:mv_toggle_advs()\" class=\"advanced_search_tag\">
 143+ <span class=\"advs_basic\" style=\"display:";
 144+ $o .= ($this->adv_search) ? 'none' : 'inline';
 145+ $o .= "\">advanced search</span>
 146+ <span class=\"advs_adv\" style=\"display:";
 147+ $o .= ($this->adv_search) ? 'inline' : 'none';
 148+ $o .= "\">basic search</span>
 149+ </a>
 150+ </form>
 151+ </div>";
139152 return $o;
140 - }
141 - function loadFiltersFromSerialized($sval){
 153+ }
 154+ function loadFiltersFromSerialized($sval) {
142155 $this->filters = unserialize($sval);
143 - }
144 -
145 - function setupFilters($defaultType='empty', $opt=null){
146 - global $wgRequest;
147 -
 156+ }
 157+
 158+ function setupFilters($defaultType = 'empty', $opt = null) {
 159+ global $wgRequest;
 160+
148161 //set advs flag:
149 - $advs =$wgRequest->getVal('advs');
150 - $this->adv_search=($advs=='' || $advs==0)?false:true;
151 -
 162+ $advs = $wgRequest->getVal('advs');
 163+ $this->adv_search = ($advs == '' || $advs == 0) ? false : true;
 164+
152165 //check for unified searchterm:
153 - $term = $wgRequest->getVal('mv_search');
 166+ $term = $wgRequest->getVal('mv_search');
154167 //set input from search (on normal search page)
155 - if($term=='') $term = $wgRequest->getVal('search');
156 - if($term!='') {
157 - //do proccess unified search? or send to semantic query engine?
 168+ if ($term == '')
 169+ $term = $wgRequest->getVal('search');
 170+ if ($term != '') {
158171 $this->filters = array (
159172 array (
160173 't' => 'match',
161174 'v' => $term
162175 )
163 - );
164 - $this->unified_term_search=$term;
 176+ );
 177+ $this->unified_term_search = $term;
165178 //if not doing advanced search we are done
166 - if(!$this->adv_search)return ;
167 - }
 179+ if (!$this->adv_search)
 180+ return;
 181+ }
 182+
168183 //print "CUR un: " . $this->unified_term_search;
169 -
 184+
170185 //first try any key titles:
171186 $title_str = $wgRequest->getVal('title');
172 - $tp = split('/',$title_str);
173 - if(count($tp)==3){
174 - switch($tp[1]){
175 - case 'person':
176 - $this->filters = array(
177 - array(
178 - 't'=>'spoken_by',
179 - 'v'=>str_replace('_',' ',$tp[2])
 187+ $tp = split('/', $title_str);
 188+ if (count($tp) == 3) {
 189+ switch ($tp[1]) {
 190+ case 'person' :
 191+ $this->filters = array (
 192+ array (
 193+ 't' => 'spoken_by',
 194+ 'v' => str_replace('_',
 195+ ' ',
 196+ $tp[2]
180197 )
181 - );
182 - break;
183 - }
184 - }else{
185 - if (isset ($_GET['f'])) {
186 - $this->filters = $_GET['f'];
 198+ ));
 199+ break;
 200+ }
 201+ } else {
 202+ if (isset ($_GET['f'])) {
 203+ $this->filters = $_GET['f'];
187204 //@@todo more input proccessing
188205 //grab unified_term_search if not already listed:
189 - if($this->unified_term_search==''){
190 - foreach($this->filters as $f){
191 - if($f['t']=='match'){
192 - if($this->unified_term_search!='')$this->unified_term_search.=' ';
193 - $this->unified_term_search.=$f['v'];
 206+ if ($this->unified_term_search == '') {
 207+ foreach ($this->filters as $f) {
 208+ if ($f['t'] == 'match') {
 209+ if ($this->unified_term_search != '')
 210+ $this->unified_term_search .= ' ';
 211+ $this->unified_term_search .= $f['v'];
194212 }
195 - }
 213+ }
196214 }
197 - } else {
198 - switch($defaultType){
199 - case 'stream':
 215+ } else {
 216+ switch ($defaultType) {
 217+ case 'stream' :
200218 $this->filters = array (
201 - array(
202 - 't' =>'stream_name',
203 - 'v' =>$opt['stream_name']
 219+ array (
 220+ 't' => 'stream_name',
 221+ 'v' => $opt['stream_name']
204222 )
205 - );
206 - break;
207 - case 'empty':
208 - default:
 223+ );
 224+ break;
 225+ case 'empty' :
 226+ default :
209227 $this->filters = array (
210228 array (
211229 't' => 'match',
212230 'v' => ''
213231 )
214232 );
215 - break;
216 - }
217 - }
218 - }
 233+ break;
 234+ }
 235+ }
 236+ }
219237 //print "CUR un: " . $this->unified_term_search;
220238 }
221 - function doSearch() {
222 - global $mvEnableSearchDigest,$mvSearchDigestTable;
 239+ function doSearch() {
 240+ global $mvEnableSearchDigest, $mvSearchDigestTable;
223241 $mvIndex = new MV_Index();
224242 //do search digest
225243 global $wgRequest;
226 - if($mvEnableSearchDigest && $wgRequest->getVal('tl')!='1') {
227 - $dbw =& wfGetDB(DB_WRITE);
228 - $dbr =& wfGetDB(DB_READ);
 244+ if ($mvEnableSearchDigest && $wgRequest->getVal('tl') != '1') {
 245+ $dbw = & wfGetDB(DB_WRITE);
 246+ $dbr = & wfGetDB(DB_READ);
229247 //@@todo non-blocking insert... is that supported in mysql/php?
230 - $dbw->insert($mvSearchDigestTable,
231 - array('query_key'=>$this->getFilterDesc($query_key=true),'time'=>time()),
232 - 'Database::searchDigestInsert' );
 248+ $dbw->insert($mvSearchDigestTable, array (
 249+ 'query_key' => $this->getFilterDesc($query_key = true
 250+ ), 'time' => time()), 'Database::searchDigestInsert');
233251 //make sure the query key exists and is updated
234252 //@@todo I think we can do a INSERT IF non found here?
235 - $res = $dbr->select('mv_query_key_lookup', array('filters'),
236 - array('query_key'=>$this->getFilterDesc($query_key=true)));
237 - if( $dbr->numRows($res)==0){
238 - $dbr->insert('mv_query_key_lookup', array('query_key'=>$this->getFilterDesc($query_key=true),
239 - 'filters'=>serialize($this->filters)));
 253+ $res = $dbr->select('mv_query_key_lookup', array (
 254+ 'filters'
 255+ ), array (
 256+ 'query_key' => $this->getFilterDesc($query_key = true
 257+ )));
 258+ if ($dbr->numRows($res) == 0) {
 259+ $dbr->insert('mv_query_key_lookup', array (
 260+ 'query_key' => $this->getFilterDesc($query_key = true
 261+ ), 'filters' => serialize($this->filters)));
240262 }
241263 }
242264 $this->results = $mvIndex->doUnifiedFiltersQuery($this->filters);
243265 $this->num = $mvIndex->numResults();
244266 $this->numResultsFound = $mvIndex->numResultsFound();
245 - if(isset($mvIndex->offset)) $this->offset = $mvIndex->offset;
246 - if(isset($mvIndex->limit)) $this->limit = $mvIndex->limit;
 267+ if (isset ($mvIndex->offset))
 268+ $this->offset = $mvIndex->offset;
 269+ if (isset ($mvIndex->limit))
 270+ $this->limit = $mvIndex->limit;
 271+ if (isset ($mvIndex->order))
 272+ $this->order = $mvIndex->order;
247273 }
248274 /*list all the meta *layer* types */
249275 function powerSearchOptions() {
250276 global $mvMVDTypeAllAvailable;
251 - $opt = array();
 277+ $opt = array ();
252278 //group track_req
253 - $opt['tracks']='';
254 - $coma='';
255 - foreach( $mvMVDTypeAllAvailable as $n ) {
256 - $opt['tracks'].= $coma. $n;
257 - $coma=',';
 279+ $opt['tracks'] = '';
 280+ $coma = '';
 281+ foreach ($mvMVDTypeAllAvailable as $n) {
 282+ $opt['tracks'] .= $coma . $n;
 283+ $coma = ',';
258284 }
259285 //$opt['redirs'] = $this->searchRedirects ? 1 : 0;
260286 //$opt['searchx'] = 1;
261287 return $opt;
262288 }
263 - function getResultsCMML(){
264 -
 289+ function getResultsCMML() {
 290+
265291 }
266292 function getUnifiedResultsHTML() {
267 - global $wgUser, $wgStylePath;
 293+ global $wgUser, $wgStylePath, $wgRequest;
268294 $sk = $wgUser->getSkin();
269 -
270 - $o.='<h5 class="search_results_header">'.$this->getFilterDesc().'</h5>';
271295
272 -
273 - $o.='<div id="resultsArea">
274 - <ul id="metaResults">';
 296+ $o .= '<h5 class="search_results_header">' . $this->getFilterDesc() . '</h5>';
 297+
 298+ $o .= '<div id="resultsArea">
 299+ <ul id="metaResults">';
275300 if (count($this->results) == 0) {
276 - $o.= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>';
 301+ $o .= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>';
277302 //close
278 - $o.='</ul></div>';
 303+ $o .= '</ul></div>';
279304 return $o;
280305 }
281 -
 306+
282307 //num of results
283 - if($this->numResultsFound){
284 - $re = ($this->limit+$this->offset > $this->numResultsFound)?$this->numResultsFound:($this->limit+$this->offset);
285 - $rs = ($this->offset==0)?1:$this->offset;
286 - $o.='<li class="results">'.
287 - wfMsg('mv_results_found',$rs,$re , number_format($this->numResultsFound)).
288 - '</li>';
 308+ if ($this->numResultsFound) {
 309+ $re = ($this->limit + $this->offset > $this->numResultsFound) ? $this->numResultsFound : ($this->limit + $this->offset);
 310+ $rs = ($this->offset == 0) ? 1 : $this->offset;
 311+ $o .= '<li class="results">' .
 312+ wfMsg('mv_results_found', $rs, $re, number_format($this->numResultsFound)) .
 313+ '</li>';
289314 }
290315 //pagging
291 - if($this->numResultsFound > $this->limit){
292 - $prevnext = mvViewPrevNext( $this->offset, $this->limit,
293 - SpecialPage::getTitleFor( 'MediaSearch' ),
294 - $this->get_httpd_filters_query(),
295 - ($this->num < $this->limit) );
296 - $o.='<li class="prevnext">'.$prevnext.'</li>';
297 - }
298 -
 316+ if ($this->numResultsFound > $this->limit) {
 317+ $prevnext = mvViewPrevNext($this->offset, $this->limit, SpecialPage :: getTitleFor('MediaSearch'), $this->get_httpd_filters_query(), ($this->num < $this->limit));
 318+ $o .= '<li class="prevnext">' . $prevnext . '</li>';
 319+ }
 320+
299321 //make rss link:
300 - $sTitle=Title::MakeTitle(NS_SPECIAL, 'MvExportSearch');
301 - $o.='<li class="rss">';
302 - $o.=$sk->makeKnownLinkObj($sTitle,
303 - 'RSS',$this->get_httpd_filters_query() );
304 - $o.='</li>';
305 -
 322+ $sTitle = Title :: MakeTitle(NS_SPECIAL, 'MvExportSearch');
 323+ $o .= '<li class="rss">';
 324+ $o .= $sk->makeKnownLinkObj($sTitle, 'RSS', $this->get_httpd_filters_query());
 325+ $o .= '</li>';
 326+
306327 //make miro link:
307 - $o.='<li class="subscribe"><a href="http://subscribe.getMiro.com/?url1='.
308 - 'http%3A%2F%2F' . $_SERVER['HTTP_HOST'] . htmlspecialchars($sTitle->escapeLocalURL($this->get_httpd_filters_query())).'" '.
309 - 'title="Subscribe with Miro"><img src="'.$wgStylePath . '/mvpcf/images/button_subscribe.png" alt="Miro Video Player" border="0" /></a></li>';
310 -
311 - $o.=' <li class="relevant"><br>Most Relevant - </li>
312 - <li class="recent"><a href="#">Most Recent</a> - </li>
313 - <li class="viewed"><a href="#">Most Viewed</a></li>';
314 - $o.='</ul>';
315 -
 328+ $o .= '<li class="subscribe"><a href="http://subscribe.getMiro.com/?url1=' .
 329+ 'http%3A%2F%2F' . $_SERVER['HTTP_HOST'] . htmlspecialchars($sTitle->escapeLocalURL($this->get_httpd_filters_query())) . '" ' .
 330+ 'title="Subscribe with Miro"><img src="' . $wgStylePath . '/mvpcf/images/button_subscribe.png" alt="Miro Video Player" border="0" /></a></li>';
 331+
 332+ //check order prefrence:
 333+ $br='<br>';
 334+ foreach (array ('relevent','recent','viewed') as $type) {
 335+ if ($this->order == $type) {
 336+ $o .= '<li class="relevant">'.$br . wfMsg('mv_most_' . $type) . ' - </li>' ;
 337+ } else {
 338+ $q_req = $this->get_httpd_filters_query();
 339+ if($wgRequest->getVal('limit')!='' || $wgRequest->getVal('order')!='')
 340+ $q_req.='&'.http_build_query(array('limit'=>$this->limit, 'offset'=>$this->offset));
 341+ $q_req.='&order='.$type;
 342+ $o .= '<li class="relevant">'.$br .$sk->makeKnownLinkObj(SpecialPage :: getTitleFor('MediaSearch'),
 343+ wfMsg('mv_most_' . $type), $q_req) . ' - </li>';
 344+ }
 345+ $br='';
 346+ }
 347+ $o .= '</ul>';
 348+
316349 //output results:
317350 //collect categories and people for sidebarbucket
318351 //@@todo a better version would collect
319 - $sideBarLinkBucket = array();
320 - $o.='
321 - <ul id="results">';
322 - foreach ($this->results as $stream_id => & $stream_set) {
 352+ $sideBarLinkBucket = array ();
 353+ $o .= '
 354+ <ul id="results">';
 355+ foreach ($this->results as $stream_id => & $stream_set) {
323356 $matches = 0;
324 - $stream_out = $mvTitle = '';
 357+ $stream_out = $mvTitle = '';
325358 foreach ($stream_set as & $srange) {
326359 $cat_html = $mvd_out = '';
327 - $range_match=0;
328 - foreach ($srange['rows'] as $inx=> & $mvd) {
329 - $matches++;
 360+ $range_match = 0;
 361+ foreach ($srange['rows'] as $inx => & $mvd) {
 362+ $matches++;
330363 $mvTitle = new MV_Title($mvd->wiki_title);
331 - $mvd_cnt_links='';
332 - if(isset($mvd->spoken_by)){
333 - $ptitle = Title::MakeTitle(NS_MAIN, $mvd->spoken_by);
334 - $mvd_cnt_links.=wfMsg('mv_search_spoken_by').': '.$sk->makeKnownLinkObj($ptitle);
335 - $mvd_cnt_links.='<br>';
336 - assoc_array_increment($sideBarLinkBucket,'person', $mvd->spoken_by);
 364+ $mvd_cnt_links = '';
 365+ if (isset ($mvd->spoken_by)) {
 366+ $ptitle = Title :: MakeTitle(NS_MAIN, $mvd->spoken_by);
 367+ $mvd_cnt_links .= wfMsg('mv_search_spoken_by') . ': ' . $sk->makeKnownLinkObj($ptitle);
 368+ $mvd_cnt_links .= '<br>';
 369+ assoc_array_increment($sideBarLinkBucket, 'person', $mvd->spoken_by);
337370 }
338 - $mvd_cat_links=$mvd_bill_links='';
339 - $coma='';
340 - if(isset($mvd->categories)){
341 - foreach($mvd->categories as $cat_id=>$na){
342 - $cTitle= Title::MakeTitle(NS_CATEGORY, $cat_id);
343 - if($mvd_cat_links=='')
344 - $mvd_cat_links.=wfMsg('mv_search_categories').': ';
345 - $mvd_cat_links.=$coma. $sk->makeKnownLinkObj($cTitle, $cTitle->getText() );
346 - $coma=', ';
347 - assoc_array_increment($sideBarLinkBucket,'category', $cat_id);
 371+ $mvd_cat_links = $mvd_bill_links = '';
 372+ $coma = '';
 373+ if (isset ($mvd->categories)) {
 374+ foreach ($mvd->categories as $cat_id => $na) {
 375+ $cTitle = Title :: MakeTitle(NS_CATEGORY, $cat_id);
 376+ if ($mvd_cat_links == '')
 377+ $mvd_cat_links .= wfMsg('mv_search_categories') .
 378+ ': ';
 379+ $mvd_cat_links .= $coma . $sk->makeKnownLinkObj($cTitle, $cTitle->getText());
 380+ $coma = ', ';
 381+ assoc_array_increment($sideBarLinkBucket, 'category', $cat_id);
348382 }
349383 }
350 - $coma='';
351 - if(isset($mvd->bills)){
352 - foreach($mvd->bills as $bill_id=>$na){
353 - $bTitle= Title::newFromText($bill_id);
354 - if($mvd_bill_links=='')
355 - $mvd_bill_links.=wfMsg('mv_search_bills').': ';
356 - $mvd_bill_links.=$coma. $sk->makeKnownLinkObj($bTitle, $bTitle->getText() );
357 - $coma=', ';
358 - assoc_array_increment($sideBarLinkBucket,'bill', $bill_id);
 384+ $coma = '';
 385+ if (isset ($mvd->bills)) {
 386+ foreach ($mvd->bills as $bill_id => $na) {
 387+ $bTitle = Title :: newFromText($bill_id);
 388+ if ($mvd_bill_links == '')
 389+ $mvd_bill_links .= wfMsg('mv_search_bills') .
 390+ ': ';
 391+ $mvd_bill_links .= $coma . $sk->makeKnownLinkObj($bTitle, $bTitle->getText());
 392+ $coma = ', ';
 393+ assoc_array_increment($sideBarLinkBucket, 'bill', $bill_id);
359394 }
360395 }
361396 //link directly to the current range:
362 - $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($extra_range='0'));
 397+ $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($extra_range = '0'));
363398 //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() );
364 - $head_link = $sk->makeKnownLinkObj($mvStreamTitle, $mvTitle->getStreamNameText().' :: '.$mvTitle->getTimeDesc());
365 - $img_link = $sk->makeKnownLinkObj($mvStreamTitle, '<img alt="image for '.$mvTitle->getStreamNameText().' '. $mvTitle->getTimeDesc().'" src="'.$mvTitle->getStreamImageURL('small').'"/>');
 399+ $head_link = $sk->makeKnownLinkObj($mvStreamTitle, $mvTitle->getStreamNameText() . ' :: ' . $mvTitle->getTimeDesc());
 400+ $img_link = $sk->makeKnownLinkObj($mvStreamTitle, '<img alt="image for ' . $mvTitle->getStreamNameText() . ' ' . $mvTitle->getTimeDesc() . '" src="' . $mvTitle->getStreamImageURL('small') . '"/>');
366401 $mvd_text = $mvd->text;
367 -
368 - $o.='<li class="result">
369 - <span class="vid_img" id="mvimg_'.$mvd->id.'">
370 - '.$img_link.'
371 - </span>
372 - <div class="result_description">
373 - <h4>'.$head_link.'</h4>
374 - <p>Matching Phrase:' .$this->termHighlight($mvd->text, implode('|', $this->getTerms()), 1, 100).' </p>
375 - <span class="by">'.$mvd_cnt_links.'</span>
376 - <span class="by">'.$mvd_cat_links.'</span>
377 - <span class="by">'.$mvd_bill_links.'</span>
378 - </div>
379 - <div class="result_meta">
380 - <span class="views">Views: '.$mvd->view_count.'</span>
381 - <span class="duration">'.wfMsg('mv_duration_label').':'.$mvTitle->getSegmentDurationNTP($short_time=true).'</span>
382 - <span class="comments">Comments: NYA</span>
383 - <span class="playinline"><a href="javascript:mv_pl(\'' . $mvd->id . '\')">'
384 - .wfMsg('mv_play_inline').'</a></span>
385 - </div>
386 - </li>';
 402+
 403+ $o .= '<li class="result">
 404+ <span class="vid_img" id="mvimg_' . $mvd->id . '">
 405+ ' . $img_link . '
 406+ </span>
 407+ <div class="result_description">
 408+ <h4>' . $head_link . '</h4>
 409+ <p>Matching Phrase:' . $this->termHighlight($mvd->text, implode('|', $this->getTerms()), 1, 100) . ' </p>
 410+ <span class="by">' . $mvd_cnt_links . '</span>
 411+ <span class="by">' . $mvd_cat_links . '</span>
 412+ <span class="by">' . $mvd_bill_links . '</span>
 413+ </div>
 414+ <div class="result_meta">
 415+ <span class="views">Views: ' . $mvd->view_count . '</span>
 416+ <span class="duration">' . wfMsg('mv_duration_label') . ':' . $mvTitle->getSegmentDurationNTP($short_time = true) . '</span>
 417+ <span class="comments">Comments: NYA</span>
 418+ <span class="playinline"><a href="javascript:mv_pl(\'' . $mvd->id . '\')">' .
 419+ wfMsg('mv_play_inline') . '</a></span>
 420+ </div>
 421+ </li>';
387422 }
388423 }
389 - }
390 - $o.='</ul>';
391 - $o.='<li class="prevnext">'.$prevnext.'</li>';
392 - $o.='</div>';
393 -
 424+ }
 425+ $o .= '</ul>';
 426+ $o .= '<li class="prevnext">' . $prevnext . '</li>';
 427+ $o .= '</div>';
 428+
394429 /*search sidebar*/
395 - $perSectionCount=3;
396 - $o.='<div id="searchSideBar">
397 - <div id="searchSideBarTop">
398 - </div>
399 - <div class="suggestionsBox" id="searchSideBarInner">';
400 -
 430+ $perSectionCount = 3;
 431+ $o .= '<div id="searchSideBar">
 432+ <div id="searchSideBarTop">
 433+ </div>
 434+ <div class="suggestionsBox" id="searchSideBarInner">';
 435+
401436 //look for people matches max of 3
402 - $first_block=' first_block';
403 - $matches=0;
404 - $person_out = MV_SpecialMediaSearch::auto_complete_person($this->unified_term_search, 3, 'person_html', $matches);
405 - if($person_out!='' || count($sideBarLinkBucket['person'])!=0 ){
 437+ $first_block = ' first_block';
 438+ $matches = 0;
 439+ $person_out = MV_SpecialMediaSearch :: auto_complete_person($this->unified_term_search, 3, 'person_html', $matches);
 440+ if ($person_out != '' || count($sideBarLinkBucket['person']) != 0) {
406441 //for now don't include({$matches})
407 - $o.="<div class=\"block{$first_block}\">
408 - <h6>".wfMsg('mv_people_results')."</h6>
409 - </div>";
410 - $o.='<div class="block wide_block">'.
411 - $person_out;
412 - if(isset($sideBarLinkBucket['person'])){
 442+ $o .= "<div class=\"block{$first_block}\">
 443+ <h6>" . wfMsg('mv_people_results') . "</h6>
 444+ </div>";
 445+ $o .= '<div class="block wide_block">' .
 446+ $person_out;
 447+ if (isset ($sideBarLinkBucket['person'])) {
413448 $pAry = & $sideBarLinkBucket['person'];
414 - arsort($pAry);
415 - $i=0;
416 - foreach($pAry as $person_name=>$count){
417 - if($i==$perSectionCount)break;
418 - $o.=MV_SpecialMediaSearch::format_ac_line($person_name, '', '', MV_SpecialMediaSearch::getPersonImageURL($person_name), $format='person_html');
 449+ arsort($pAry);
 450+ $i = 0;
 451+ foreach ($pAry as $person_name => $count) {
 452+ if ($i == $perSectionCount)
 453+ break;
 454+ $o .= MV_SpecialMediaSearch :: format_ac_line($person_name, '', '', MV_SpecialMediaSearch :: getPersonImageURL($person_name), $format = 'person_html');
419455 $i++;
420 - }
421 - }
422 - $o.='</div>';
423 - $first_block='';
424 - }
 456+ }
 457+ }
 458+ $o .= '</div>';
 459+ $first_block = '';
 460+ }
425461 //get categories
426 - $category_out = MV_SpecialMediaSearch::auto_complete_search_categories($this->unified_term_search, 3, 'block_html',$matches);
427 - if($category_out!='' || count($sideBarLinkBucket['category'])!=0 ){
428 - $o.="<div class=\"block{$first_block}\">
429 - <h6>".wfMsg('mv_category_results')."</h6>
430 - </div>";
431 - $o.='<div class="block wide_block">'.$category_out;
432 - if(isset($sideBarLinkBucket['category'])){
 462+ $category_out = MV_SpecialMediaSearch :: auto_complete_search_categories($this->unified_term_search, 3, 'block_html', $matches);
 463+ if ($category_out != '' || count($sideBarLinkBucket['category']) != 0) {
 464+ $o .= "<div class=\"block{$first_block}\">
 465+ <h6>" . wfMsg('mv_category_results') . "</h6>
 466+ </div>";
 467+ $o .= '<div class="block wide_block">' . $category_out;
 468+ if (isset ($sideBarLinkBucket['category'])) {
433469 $cAry = & $sideBarLinkBucket['category'];
434470 arsort($cAry);
435 - $i=0;
436 - foreach($cAry as $cat_name=>$count){
437 - if($i==$perSectionCount)break;
438 - $o.=MV_SpecialMediaSearch::format_ac_line($cat_name, '', '','no_image', $format='block_html');
439 - $i++;
440 - }
 471+ $i = 0;
 472+ foreach ($cAry as $cat_name => $count) {
 473+ if ($i == $perSectionCount)
 474+ break;
 475+ $o .= MV_SpecialMediaSearch :: format_ac_line($cat_name, '', '', 'no_image', $format = 'block_html');
 476+ $i++;
 477+ }
441478 }
442 - $o.='</div>';
443 - $first_block='';
444 - }
 479+ $o .= '</div>';
 480+ $first_block = '';
 481+ }
445482 //get bills:
446 - $bill_out = MV_SpecialMediaSearch::auto_complete_category('Bill', $this->unified_term_search, 3, 'block_html', $matches);
447 - if($bill_out!='' || count($sideBarLinkBucket['bill'])!=0 ){
 483+ $bill_out = MV_SpecialMediaSearch :: auto_complete_category('Bill', $this->unified_term_search, 3, 'block_html', $matches);
 484+ if ($bill_out != '' || count($sideBarLinkBucket['bill']) != 0) {
448485 global $wgContLang;
449 - $o.="<div class=\"block{$first_block}\">
450 - <h6>".wfMsg('mv_bill_results')."</h6>
451 - </div>";
452 - $o.='<div class="block wide_block">'.$bill_out;
453 - if($sideBarLinkBucket['bill']){
 486+ $o .= "<div class=\"block{$first_block}\">
 487+ <h6>" . wfMsg('mv_bill_results') . "</h6>
 488+ </div>";
 489+ $o .= '<div class="block wide_block">' . $bill_out;
 490+ if ($sideBarLinkBucket['bill']) {
454491 $bAry = & $sideBarLinkBucket['bill'];
455492 arsort($bAry);
456 - $i=0;
457 - foreach($bAry as $bill_name=>$count){
458 - if($i==$perSectionCount)break;
459 - $o.=MV_SpecialMediaSearch::format_ac_line($bill_name, '', '','no_image', $format='block_html');
 493+ $i = 0;
 494+ foreach ($bAry as $bill_name => $count) {
 495+ if ($i == $perSectionCount)
 496+ break;
 497+ $o .= MV_SpecialMediaSearch :: format_ac_line($bill_name, '', '', 'no_image', $format = 'block_html');
460498 $i++;
461 - }
 499+ }
462500 }
463 - $o.='</div>';
464 - $first_block='';
 501+ $o .= '</div>';
 502+ $first_block = '';
465503 }
466504 //intrest out is just simple title matching (for now)
467 - $intrest_out = MV_SpecialMediaSearch::auto_complete_category('Interest_Group', $this->unified_term_search, 3, 'block_html', $matches);
468 - if($intrest_out!=''){
469 - $o.="<div class=\"block{$first_block}\">
470 - <h6>".wfMsg('mv_intrest_group_results')."</h6>
471 - </div>";
472 - $o.='<div class="block wide_block">'.$intrest_out.'</div>';
473 - $first_block='';
 505+ $intrest_out = MV_SpecialMediaSearch :: auto_complete_category('Interest_Group', $this->unified_term_search, 3, 'block_html', $matches);
 506+ if ($intrest_out != '') {
 507+ $o .= "<div class=\"block{$first_block}\">
 508+ <h6>" . wfMsg('mv_intrest_group_results') . "</h6>
 509+ </div>";
 510+ $o .= '<div class="block wide_block">' . $intrest_out . '</div>';
 511+ $first_block = '';
474512 }
475 - $o.='</div><!--searchSideBarInner-->
476 - </div>';
 513+ $o .= '</div><!--searchSideBarInner-->
 514+ </div>';
477515 return $o;
478516 }
479517 function getResultsHTML() {
480518 global $mvgIP, $wgOut, $mvgScriptPath, $mvgContLang, $wgUser, $wgParser;
481519 $sk = & $wgUser->getSkin();
482 - $o = '';
483 - if($this->outputContainer)$o.='<div id="mv_search_results_container">';
484 -
 520+ $o = '';
 521+ if ($this->outputContainer)
 522+ $o .= '<div id="mv_search_results_container">';
 523+
485524 //for each stream range:
486525 if (count($this->results) == 0) {
487 - $o.= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>';
488 - if($this->outputContainer)$o.='</div>';
 526+ $o .= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>';
 527+ if ($this->outputContainer)
 528+ $o .= '</div>';
489529 return $o;
490 - }else{
491 - if($this->outputInlineHeader){
492 - $o.='<h2>
493 - <span class="mw-headline">'. wfMsg('mv_media_matches') . '</span>
494 - </h2>';
 530+ } else {
 531+ if ($this->outputInlineHeader) {
 532+ $o .= '<h2>
 533+ <span class="mw-headline">' . wfMsg('mv_media_matches') . '</span>
 534+ </h2>';
495535 $title = Title :: MakeTitle(NS_SPECIAL, 'MediaSearch');
496 - $o.= $sk->makeKnownLinkObj($title, wfMsg('mv_advaced_search'),
497 - $this->get_httpd_filters_query() );
 536+ $o .= $sk->makeKnownLinkObj($title, wfMsg('mv_advaced_search'), $this->get_httpd_filters_query());
498537 }
499 - }
 538+ }
500539 //media pagging: (only display if we have num of results > limit
501 - $prevnext = mvViewPrevNext( $this->offset, $this->limit,
502 - SpecialPage::getTitleFor( 'MediaSearch' ),
503 - $this->get_httpd_filters_query(),
504 - ($this->num < $this->limit) );
505 - $o.="<br /><span id=\"mv_search_pagging\">{$prevnext}</span>\n";
 540+ $prevnext = mvViewPrevNext($this->offset, $this->limit, SpecialPage :: getTitleFor('MediaSearch'), $this->get_httpd_filters_query(), ($this->num < $this->limit));
 541+ $o .= "<br /><span id=\"mv_search_pagging\">{$prevnext}</span>\n";
506542 //add the rss link:
507 - $sTitle=Title::MakeTitle(NS_SPECIAL, 'MvExportSearch');
508 - $o.='<span style="float:right;">';
509 - $o.=$sk->makeKnownLinkObj($sTitle,
510 - '<img border="0" src="' . $mvgScriptPath . '/skins/images/feed-icon-28x28.png">',
511 - $this->get_httpd_filters_query() );
512 - $o.='</span>';
 543+ $sTitle = Title :: MakeTitle(NS_SPECIAL, 'MvExportSearch');
 544+ $o .= '<span style="float:right;">';
 545+ $o .= $sk->makeKnownLinkObj($sTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/feed-icon-28x28.png">', $this->get_httpd_filters_query());
 546+ $o .= '</span>';
513547 //add the results bar:
514 - $o.=$this->getResultsBar();
 548+ $o .= $this->getResultsBar();
515549 //print_r($this->results);
516 - foreach ($this->results as $stream_id => & $stream_set) {
 550+ foreach ($this->results as $stream_id => & $stream_set) {
517551 $matches = 0;
518 - $stream_out = $mvTitle = '';
 552+ $stream_out = $mvTitle = '';
519553 foreach ($stream_set as & $srange) {
520554 $cat_html = $mvd_out = '';
521 - $range_match=0;
522 - foreach ($srange['rows'] as $inx=> & $mvd) {
523 - $matches++;
 555+ $range_match = 0;
 556+ foreach ($srange['rows'] as $inx => & $mvd) {
 557+ $matches++;
524558 $mvTitle = new MV_Title($mvd->wiki_title);
525559
526560 //retrieve only the first article:
527561 //$title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title);
528562 //$article = new Article($title);
529 -
530 - $bgcolor=MV_Overlay::getMvdBgColor($mvd);
 563+
 564+ $bgcolor = MV_Overlay :: getMvdBgColor($mvd);
531565 //output indent if not the first and count more than one
532 - if(count($srange['rows'])!=1 && $inx!=0)
533 - $mvd_out.='&nbsp; &nbsp; &nbsp; &nbsp;';
 566+ if (count($srange['rows']) != 1 && $inx != 0)
 567+ $mvd_out .= '&nbsp; &nbsp; &nbsp; &nbsp;';
534568 //'<img src="'. $mvgScriptPath . '/skins/images/film.png">'
535569 //$mvd_out .= '<div class="mv_rtdesc" title="' . wfMsg('mv_expand_play') . '" '.
536570 // '> ';
537 - $mvd_out .= '<img style="float:left;width:84px;cursor:pointer;border:solid #'.$bgcolor.'" '.
538 - ' onclick="mv_ex(\'' . $mvd->id . '\')" width="80" height="60" src="'.$mvTitle->getStreamImageURL('icon') . '">';
539 - $mvd_out.= '</div>';
540 - $mvd_out.='<b>' .$mvTitle->getTimeDesc() . '</b>&nbsp;';
541 - $mvd_cnt_links='';
542 - if(isset($mvd->spoken_by)){
543 - $ptitle = Title::MakeTitle(NS_MAIN, $mvd->spoken_by);
544 - $mvd_cnt_links.=wfMsg('mv_search_spoken_by').': '.$sk->makeKnownLinkObj($ptitle);
545 - $mvd_cnt_links.='<br>';
 571+ $mvd_out .= '<img style="float:left;width:84px;cursor:pointer;border:solid #' . $bgcolor . '" ' .
 572+ ' onclick="mv_ex(\'' . $mvd->id . '\')" width="80" height="60" src="' . $mvTitle->getStreamImageURL('icon') . '">';
 573+ $mvd_out .= '</div>';
 574+ $mvd_out .= '<b>' . $mvTitle->getTimeDesc() . '</b>&nbsp;';
 575+ $mvd_cnt_links = '';
 576+ if (isset ($mvd->spoken_by)) {
 577+ $ptitle = Title :: MakeTitle(NS_MAIN, $mvd->spoken_by);
 578+ $mvd_cnt_links .= wfMsg('mv_search_spoken_by') . ': ' . $sk->makeKnownLinkObj($ptitle);
 579+ $mvd_cnt_links .= '<br>';
546580 }
547 - if($this->outputSeqLinks==true){
548 - $mvd_cnt_links .='&nbsp;<a href="javascript:mv_add_to_seq({mvclip:\''.
549 - $mvTitle->getStreamName().'/'.$mvTitle->getTimeRequest().'\','.
550 - 'src:\''.$mvTitle->getWebStreamURL().'\','.
551 - 'img_url:\''.$mvTitle->getStreamImageURL().'\'})">'.
552 - '<img style="cursor:pointer;" '.
553 - 'title="'.wfMsg('mv_seq_add_end').'" '.
554 - 'src="'.$mvgScriptPath .'/skins/mv_embed/images/application_side_expand.png">'. wfMsg('mv_seq_add_end').'</a>';
 581+ if ($this->outputSeqLinks == true) {
 582+ $mvd_cnt_links .= '&nbsp;<a href="javascript:mv_add_to_seq({mvclip:\'' .
 583+ $mvTitle->getStreamName() . '/' . $mvTitle->getTimeRequest() . '\',' .
 584+ 'src:\'' . $mvTitle->getWebStreamURL() . '\',' .
 585+ 'img_url:\'' . $mvTitle->getStreamImageURL() . '\'})">' .
 586+ '<img style="cursor:pointer;" ' .
 587+ 'title="' . wfMsg('mv_seq_add_end') . '" ' .
 588+ 'src="' . $mvgScriptPath . '/skins/mv_embed/images/application_side_expand.png">' . wfMsg('mv_seq_add_end') . '</a>';
555589 }
556 - $mvd_cnt_links .= '<a title="' . wfMsg('mv_expand_play') . '" href="javascript:mv_ex(\'' . $mvd->id . '\')">'.
557 - '<img id="mv_img_ex_'.$mvd->id.'" src="' . $mvgScriptPath . '/skins/images/closed.png">'.
558 - '<span id="mv_watch_clip_'.$mvd->id.'">'.wfMsg('mv_watch_clip').'</span>'.
559 - '<span style="display:none;" id="mv_close_clip_'.$mvd->id.'">'.wfMsg('mv_close_clip').'</span>'.
560 - '</a>' .
561 - '&nbsp;&nbsp;';
 590+ $mvd_cnt_links .= '<a title="' . wfMsg('mv_expand_play') . '" href="javascript:mv_ex(\'' . $mvd->id . '\')">' .
 591+ '<img id="mv_img_ex_' . $mvd->id . '" src="' . $mvgScriptPath . '/skins/images/closed.png">' .
 592+ '<span id="mv_watch_clip_' . $mvd->id . '">' . wfMsg('mv_watch_clip') . '</span>' .
 593+ '<span style="display:none;" id="mv_close_clip_' . $mvd->id . '">' . wfMsg('mv_close_clip') . '</span>' .
 594+ '</a>' .
 595+ '&nbsp;&nbsp;';
562596 //output control links:
563597 //make stream title link:
564598 $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName());
565599 //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() );
566 - $mvd_cnt_links .= $sk->makeKnownLinkObj($mvStreamTitle, '<img border="1" src="' . $mvgScriptPath . '/skins/images/run_mv_stream.png"> '.wfMsg('mv_improve_transcript'), '', '', '', '', ' title="' . wfMsg('mv_view_in_stream_interface') . '" ');
567 - $mvd_cnt_links .= '<br>';
 600+ $mvd_cnt_links .= $sk->makeKnownLinkObj($mvStreamTitle, '<img border="1" src="' . $mvgScriptPath . '/skins/images/run_mv_stream.png"> ' . wfMsg('mv_improve_transcript'), '', '', '', '', ' title="' . wfMsg('mv_view_in_stream_interface') . '" ');
 601+ $mvd_cnt_links .= '<br>';
568602 //$title = MakeTitle::()
569603 //don't inclue link to wiki page (too confusing)
570604 //$mvd_out .='&nbsp;';
571 - $mvdTitle = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title);
 605+ $mvdTitle = Title :: MakeTitle(MV_NS_MVD, $mvd->wiki_title);
572606 //$mvd_out .= $sk->makeKnownLinkObj($mvdTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/run_mediawiki.png">', '', '', '', '', ' title="' . wfMsg('mv_view_wiki_page') . '" ');
573 -
574 - $mvd_out.='<span id="mvr_desc_'.$mvd->id.'">';
575 -
576 -
577 - if(!isset($mvd->toplq))$mvd->toplq=false;
 607+
 608+ $mvd_out .= '<span id="mvr_desc_' . $mvd->id . '">';
 609+
 610+ if (!isset ($mvd->toplq))
 611+ $mvd->toplq = false;
578612 //output short desc send partial regEx:
579 - if (!$mvd->toplq){
580 - $mvd_out.= $this->termHighlight($mvd->text, implode('|', $this->getTerms()));
581 - }else {
582 - if($mvdTitle->exists() && !isset($mvd->text)){
 613+ if (!$mvd->toplq) {
 614+ $mvd_out .= $this->termHighlight($mvd->text, implode('|', $this->getTerms()));
 615+ } else {
 616+ if ($mvdTitle->exists() && !isset ($mvd->text)) {
583617 //grab the article text:
584 - $curRevision = Revision::newFromTitle($mvdTitle);
 618+ $curRevision = Revision :: newFromTitle($mvdTitle);
585619 $wikiText = $curRevision->getText();
586 - }else{
 620+ } else {
587621 $wikiText = & $mvd->text;
588622 }
589623 //@@todo parse category info if present
590 - $cat_html = '';
 624+ $cat_html = '';
591625 //run via parser to add in Category info:
592626 $parserOptions = ParserOptions :: newFromUser($wgUser);
593627 $parserOptions->setEditSection(false);
@@ -601,21 +635,19 @@
602636 //add category pre-text:
603637 //if ($cat_html != '')
604638 //$mvd_out.= wfMsg('Categories') . ':' . $cat_html;
605 - $mvd_out.=$cat_html;
606 -
607 - $mvd_out.= (count($srange['rows'])-1==1)
608 - ? wfMsg('mv_match_text_one')
609 - : wfMsg('mv_match_text', count($srange['rows'])-1);
 639+ $mvd_out .= $cat_html;
 640+
 641+ $mvd_out .= (count($srange['rows']) - 1 == 1) ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', count($srange['rows']) - 1);
610642 //$wgOut->addCategoryLinks( $parserOutput->getCategories() );
611643 //$cat_html = $sk->getCategories();
612644 //empty out the categories
613645 //$wgOut->mCategoryLinks = array();
614646 }
615 - $mvd_out.='</span>';
616 - $mvd_out.='<br>'.$mvd_cnt_links;
617 - $mvd_out.='<div style="display:block;clear:both;padding-top:4px;padding-bottom:4px;"/>';
618 - $mvd_out .= '<div id="mvr_' . $mvd->id . '" style="display:none;background:#'.$bgcolor.';" ></div>';
619 - }
 647+ $mvd_out .= '</span>';
 648+ $mvd_out .= '<br>' . $mvd_cnt_links;
 649+ $mvd_out .= '<div style="display:block;clear:both;padding-top:4px;padding-bottom:4px;"/>';
 650+ $mvd_out .= '<div id="mvr_' . $mvd->id . '" style="display:none;background:#' . $bgcolor . ';" ></div>';
 651+ }
620652 $stream_out .= $mvd_out;
621653 /*if(count($srange['rows'])!=1){
622654 $stream_out .= '&nbsp;' . $cat_html . ' In range:' .
@@ -624,43 +656,44 @@
625657 $stream_out .= $mvd_out;
626658 }else{
627659 $stream_out .= $mvd_out;
628 - }*/
 660+ }*/
629661 }
630662 $nsary = $mvgContLang->getNamespaces();
631663 //output stream name and mach count
632664 /*$o.='<br /><img class="mv_stream_play_button" name="'.$nsary[MV_NS_STREAM].':' .
633665 $mvTitle->getStreamName() .
634666 '" align="left" src="'.$mvgScriptPath.'/skins/mv_embed/images/vid_play_sm.png">';
635 - */
636 - $o.= '<h3>' . $mvTitle->getStreamNameText();
637 - $o.=($matches==1)?wfMsg('mv_match_text_one'):wfMsg('mv_match_text', $matches);
638 - $o.='</h3>';
639 - $o.= '<div id="mv_stream_' . $stream_id . '">' . $stream_out . '</div>';
 667+ */
 668+ $o .= '<h3>' . $mvTitle->getStreamNameText();
 669+ $o .= ($matches == 1) ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', $matches);
 670+ $o .= '</h3>';
 671+ $o .= '<div id="mv_stream_' . $stream_id . '">' . $stream_out . '</div>';
640672 }
641 - if($this->outputContainer)$o.='</div>';
 673+ if ($this->outputContainer)
 674+ $o .= '</div>';
642675 return $o;
643676 }
644 - function getTerms(){
645 - $ret_ary = $cat_ary = array();
646 - foreach($this->filters as $filter){
 677+ function getTerms() {
 678+ $ret_ary = $cat_ary = array ();
 679+ foreach ($this->filters as $filter) {
647680 switch ($filter['t']) {
648 - case 'match':
649 - case 'spoken_by':
650 - case 'stream_name':
 681+ case 'match' :
 682+ case 'spoken_by' :
 683+ case 'stream_name' :
651684 $ret_ary[] = $filter['v'];
652 - break;
 685+ break;
653686 case 'category' :
654 - $cat_ary[] =$filter['v'];
655 - break;
 687+ $cat_ary[] = $filter['v'];
 688+ break;
656689 case 'smw_property' :
657 -
658 - break;
659 - case 'smw_property_number':
 690+
 691+ break;
 692+ case 'smw_property_number' :
660693 //should be special case for numeric values
661 - break;
 694+ break;
662695 }
663696 }
664 - return $ret_ary+$cat_ary;
 697+ return $ret_ary + $cat_ary;
665698 }
666699 /*function termHighlightText(&$text, $terms_ary){
667700 if(count($terms_ary)==0)return;
@@ -680,50 +713,50 @@
681714 //print "\n\ncur text:". $text;
682715 }*/
683716 /*very similar to showHit in SpecialSearch.php */
684 - function termHighlight( & $text, $terms, $contextlines=1, $contextchars=50 ) {
 717+ function termHighlight(& $text, $terms, $contextlines = 1, $contextchars = 50) {
685718 //$fname = 'SpecialSearch::termHighlight';
686719 //wfProfileIn( $fname );
687720 global $wgUser, $wgContLang, $wgLang;
688721 $sk = $wgUser->getSkin();
689722
690 - $lines = explode( "\n", $text );
691 - $max = intval( $contextchars ) + 1;
 723+ $lines = explode("\n", $text);
 724+ $max = intval($contextchars) + 1;
692725 $pat1 = "/(.*)($terms)(.{0,$max})/i";
693726
694727 $lineno = 0;
695728
696729 $extract = '';
697 -// wfProfileIn( "$fname-extract" );
698 - foreach ( $lines as $line ) {
699 - if ( 0 == $contextlines ) {
 730+ // wfProfileIn( "$fname-extract" );
 731+ foreach ($lines as $line) {
 732+ if (0 == $contextlines) {
700733 break;
701734 }
702 - ++$lineno;
703 - $m = array();
704 - if ( ! preg_match( $pat1, $line, $m ) ) {
 735+ ++ $lineno;
 736+ $m = array ();
 737+ if (!preg_match($pat1, $line, $m)) {
705738 continue;
706739 }
707 - --$contextlines;
708 - $pre = $wgContLang->truncate( $m[1], -$contextchars, '...' );
 740+ -- $contextlines;
 741+ $pre = $wgContLang->truncate($m[1], - $contextchars, '...');
709742
710 - if ( count( $m ) < 3 ) {
 743+ if (count($m) < 3) {
711744 $post = '';
712745 } else {
713 - $post = $wgContLang->truncate( $m[3], $contextchars, '...' );
 746+ $post = $wgContLang->truncate($m[3], $contextchars, '...');
714747 }
715748
716749 $found = $m[2];
717750
718 - $line = htmlspecialchars( $pre . $found . $post );
 751+ $line = htmlspecialchars($pre . $found . $post);
719752 $pat2 = '/(' . $terms . ")/i";
720 - $line = preg_replace( $pat2,
721 - "<span class='searchmatch'>\\1</span>", $line );
 753+ $line = preg_replace($pat2, "<span class='searchmatch'>\\1</span>", $line);
722754
723755 //$extract .= " <small>{$lineno}: {$line}</small>\n";
724756 $extract .= " {$line}\n";
725 - }
 757+ }
726758 //if we found no matches just return the first line:
727 - if($extract=='')return ' '. $wgContLang->truncate($text, ($contextchars*2), '...').'';
 759+ if ($extract == '')
 760+ return ' ' . $wgContLang->truncate($text, ($contextchars * 2), '...') . '';
728761 //wfProfileOut( "$fname-extract" );
729762 //wfProfileOut( $fname );
730763 //return "<li>{$link} ({$size}){$extract}</li>\n";
@@ -731,31 +764,31 @@
732765 }
733766 //output expanded request via mvd_id
734767 function expand_wt($mvd_id, $terms_ary) {
735 - global $wgOut,$mvgIP;
736 - global $mvDefaultSearchVideoPlaybackRes;
737 -
738 - $mvd = MV_Index::getMVDbyId($mvd_id);
739 - if(count($mvd)!=0){
 768+ global $wgOut, $mvgIP;
 769+ global $mvDefaultSearchVideoPlaybackRes;
 770+
 771+ $mvd = MV_Index :: getMVDbyId($mvd_id);
 772+ if (count($mvd) != 0) {
740773 $mvTitle = new MV_Title($mvd->wiki_title);
741774 //validate title and load stream ref:
742 - if($mvTitle->validRequestTitle()){
743 - list($vWidth, $vHeight) = explode('x', $mvDefaultSearchVideoPlaybackRes);
744 - $embedHTML='<span style="float:left;width:'.($vWidth+20).'px">' .
745 - $mvTitle->getEmbedVideoHtml('vid_'.$mvd_id, $mvDefaultSearchVideoPlaybackRes, '',$autoplay=true) .
746 - '</span>';
 775+ if ($mvTitle->validRequestTitle()) {
 776+ list ($vWidth, $vHeight) = explode('x', $mvDefaultSearchVideoPlaybackRes);
 777+ $embedHTML = '<span style="float:left;width:' . ($vWidth +20) . 'px">' .
 778+ $mvTitle->getEmbedVideoHtml('vid_' . $mvd_id, $mvDefaultSearchVideoPlaybackRes, '', $autoplay = true) .
 779+ '</span>';
747780 $wgOut->clearHTML();
748 - $MvOverlay = new MV_Overlay();
749 - $MvOverlay->outputMVD($mvd, $mvTitle);
750 - $pageHTML='<span style="padding-top:10px;float:left;width:450px">'.
751 - $wgOut->getHTML().
752 - '</span>';
753 -
 781+ $MvOverlay = new MV_Overlay();
 782+ $MvOverlay->outputMVD($mvd, $mvTitle);
 783+ $pageHTML = '<span style="padding-top:10px;float:left;width:450px">' .
 784+ $wgOut->getHTML() .
 785+ '</span>';
 786+
754787 //return page html:
755 - return $embedHTML. $pageHTML. '<div style="clear: both;"/>';
756 - }else{
 788+ return $embedHTML . $pageHTML . '<div style="clear: both;"/>';
 789+ } else {
757790 return wfMsg('mvBadMVDtitle');
758791 }
759 - }else{
 792+ } else {
760793 return wfMsg('mv_error_mvd_not_found');
761794 }
762795 //$title = Title::MakeTitle(MV_NS_MVD, $wiki_title);
@@ -763,70 +796,69 @@
764797 //output table with embed left, and content right
765798 //return $wgOut->parse($article->getContent());
766799 }
767 - function get_httpd_filters_query(){
 800+ function get_httpd_filters_query() {
768801 //get all the mvd ns selected:
769 - $opt = $this->powerSearchOptions();
770 - return http_build_query($opt +array('f'=>$this->filters));
 802+ $opt = $this->powerSearchOptions();
 803+ return http_build_query($opt + array (
 804+ 'f' => $this->filters
 805+ ));
771806 }
772807 function list_active_filters() {
773808 global $mvgScriptPath;
774 - $s=$so='';
775 - $dateObjOut=false;
776 - $s .= '<div id="mv_active_filters" style="margin-bottom:10px;">';
 809+ $s = $so = '';
 810+ $dateObjOut = false;
 811+ $s .= '<div id="mv_active_filters" style="margin-bottom:10px;">';
777812 foreach ($this->filters as $i => $filter) {
778813 if (!isset ($filter['v'])) //value
779814 $filter['v'] = '';
780815 if (!isset ($filter['t'])) //type
781816 $filter['t'] = '';
782817 if (!isset ($filter['a'])) //and, or, not
783 - $filter['a']='';
784 -
 818+ $filter['a'] = '';
 819+
785820 //output the master selecter per line:
786 - $s .= '<span id="mvs_' . $i . '">';
787 - $s .= '&nbsp;&nbsp;';
 821+ $s .= '<span id="mvs_' . $i . '">';
 822+ $s .= '&nbsp;&nbsp;';
788823 //selctor (don't display if i==0')
789 - $s .= $this->selector($i, 'a', $filter['a'],($i==0)?false:true );
 824+ $s .= $this->selector($i, 'a', $filter['a'], ($i == 0) ? false : true);
790825 $s .= $this->selector($i, 't', $filter['t']); //type selector
791826 $s .= '<span id="mvs_' . $i . '_tc">';
792 - switch ($filter['t']) {
 827+ switch ($filter['t']) {
793828 case 'match' :
794829 $s .= $this->text_entry($i, 'v', $filter['v'], 'mv_hl_text');
795830 break;
796831 case 'category' :
797832 //$s.=$this->get_ref_ac($i, $filter['v']);
798833 $s .= $this->text_entry($i, 'v', $filter['v']);
799 - break;
800 - case 'date_range':
801 - $s .=wfMsg('mv_time_separator',
802 - $this->text_entry($i, 'vs', $filter['vs'], 'date-pick_'.$i, 'id="vs_'.$i.'"'),
803 - $this->text_entry($i, 've', $filter['ve'], 'date-pick_'.$i, 'id="ve_'.$i.'"')
804 - );
 834+ break;
 835+ case 'date_range' :
 836+ $s .= wfMsg('mv_time_separator', $this->text_entry($i, 'vs', $filter['vs'], 'date-pick_' . $i, 'id="vs_' . $i . '"'), $this->text_entry($i, 've', $filter['ve'], 'date-pick_' . $i, 'id="ve_' . $i . '"'));
805837 //also output dateObj (if not already output):
806 - if(!$dateObjOut){
 838+ if (!$dateObjOut) {
807839 global $wgOut;
808840 //add all date scripts:
809 - $wgOut->addScript("\n".
810 - '<!-- required plugins -->
811 - <script type="text/javascript" src="'.$mvgScriptPath.'/skins/mv_embed/jquery/plugins/date.js"></script>
812 - <!--[if IE]><script type="text/javascript" src="'.$mvgScriptPath.'/skins/mv_embed/jquery/plugins/jquery.bgiframe.js"></script><![endif]-->
813 -
814 - <!-- jquery.datePicker.js -->
815 - <script type="text/javascript" src="'.$mvgScriptPath.'/skins/mv_embed/jquery/plugins/jquery.datePicker.js"></script>
816 - <script language="javascript" type="text/javascript">'.
817 - $this->getJsonDateObj('mvDateInitObj') .
818 - '</script>');
819 - $dateObjOut=true;
 841+ $wgOut->addScript("\n" .
 842+ '<!-- required plugins -->
 843+ <script type="text/javascript" src="' . $mvgScriptPath . '/skins/mv_embed/jquery/plugins/date.js"></script>
 844+ <!--[if IE]><script type="text/javascript" src="' . $mvgScriptPath . '/skins/mv_embed/jquery/plugins/jquery.bgiframe.js"></script><![endif]-->
 845+
 846+ <!-- jquery.datePicker.js -->
 847+ <script type="text/javascript" src="' . $mvgScriptPath . '/skins/mv_embed/jquery/plugins/jquery.datePicker.js"></script>
 848+ <script language="javascript" type="text/javascript">' .
 849+ $this->getJsonDateObj('mvDateInitObj') .
 850+ '</script>');
 851+ $dateObjOut = true;
820852 }
821 - break;
822 - case 'stream_name':
 853+ break;
 854+ case 'stream_name' :
823855 $s .= $this->text_entry($i, 'v', $filter['v']);
824 - break;
 856+ break;
825857 case 'spoken_by' :
826858 $s .= $this->get_ref_person($i, $filter['v'], true);
827859 break;
828860 case 'smw_property' :
829861
830 - break;
 862+ break;
831863 }
832864 $s .= '</span>';
833865 if ($i > 0)
@@ -835,7 +867,7 @@
836868 '<img title="' . wfMsg('mv_remove_filter') . '" ' .
837869 'src="' . $mvgScriptPath . '/skins/images/cog_delete.png"></a>';
838870 $s .= '</span>';
839 - }
 871+ }
840872 $s .= '</div>';
841873 //reference remove
842874 $s .= '<a id="mv_ref_remove" style="display:none;" ' .
@@ -852,54 +884,55 @@
853885 'src="' . $mvgScriptPath . '/skins/images/cog_add.png"></a> ';
854886
855887 /*$s .= '<input id="mv_do_search" type="submit" ' .
856 - ' value="' . wfMsg('mv_run_search') . '">';*/
857 -
 888+ ' value="' . wfMsg('mv_run_search') . '">';*/
 889+
858890 return $s . $so;
859891 }
860 - function getResultsBar(){
861 - $o='<div class="mv_result_bar">';
862 - if($this->numResultsFound){
863 - $re = ($this->limit+$this->offset > $this->numResultsFound)?$this->numResultsFound:($this->limit+$this->offset);
864 - $rs = ($this->offset==0)?1:$this->offset;
865 - $o.=wfMsg('mv_results_found_for',$rs,$re , number_format($this->numResultsFound));
 892+ function getResultsBar() {
 893+ $o = '<div class="mv_result_bar">';
 894+ if ($this->numResultsFound) {
 895+ $re = ($this->limit + $this->offset > $this->numResultsFound) ? $this->numResultsFound : ($this->limit + $this->offset);
 896+ $rs = ($this->offset == 0) ? 1 : $this->offset;
 897+ $o .= wfMsg('mv_results_found_for', $rs, $re, number_format($this->numResultsFound));
866898 }
867 - $o.=$this->getFilterDesc();
868 - $o.='</div>';
 899+ $o .= $this->getFilterDesc();
 900+ $o .= '</div>';
869901 return $o;
870902 }
871 - function getSearchLink(){
872 - return SpecialPage::getTitleFor( 'MediaSearch' ) .
873 - $this->get_httpd_filters_query();
 903+ function getSearchLink() {
 904+ return SpecialPage :: getTitleFor('MediaSearch') .
 905+ $this->get_httpd_filters_query();
874906 }
875907 /*
876908 * returns human readable description of filters
877909 */
878 - function getFilterDesc($query_key=false){
879 - $o=$a='';
880 - $bo=($query_key)?'':'<b>';
881 - $bc=($query_key)?'':'</b>';
882 - foreach($this->filters as $inx=>$f){
883 - if($inx!=0)$a=' '.wfMsg('mv_search_'.$f['a']).' ';
884 - $o.=($query_key)?$a:$a.wfMsg('mv_'.$f['t']).' ';
885 - if($f['t']=='date_range'){ //handle special case of date range:
886 - $o.=wfMsg('mv_time_separator', $bo.$f['vs'].$bc, $bo.$f['ve'].$bc);
887 - }else{
888 - $o.=$bo. str_replace('_',' ',$f['v']).$bc;
 910+ function getFilterDesc($query_key = false) {
 911+ $o = $a = '';
 912+ $bo = ($query_key) ? '' : '<b>';
 913+ $bc = ($query_key) ? '' : '</b>';
 914+ foreach ($this->filters as $inx => $f) {
 915+ if ($inx != 0)
 916+ $a = ' ' . wfMsg('mv_search_' . $f['a']) . ' ';
 917+ $o .= ($query_key) ? $a : $a . wfMsg('mv_' . $f['t']) . ' ';
 918+ if ($f['t'] == 'date_range') { //handle special case of date range:
 919+ $o .= wfMsg('mv_time_separator', $bo . $f['vs'] . $bc, $bo . $f['ve'] . $bc);
 920+ } else {
 921+ $o .= $bo . str_replace('_', ' ', $f['v']) . $bc;
889922 }
890923 }
891924 return $o;
892 - }
 925+ }
893926 function get_ref_person($inx = '', $person_name = MV_MISSING_PERSON_IMG, $disp = false) {
894 - if($disp) {
 927+ if ($disp) {
895928 $tname = 'f[' . $inx . '][v]';
896929 $inx = '_' . $inx;
897930 $disp = 'inline';
898 - }else{
 931+ } else {
899932 $tname = '';
900933 $inx = '';
901934 $person_name = '';
902935 $disp = 'none';
903 - }
 936+ }
904937 //make the missing person image ref:
905938 $imgTitle = Title :: makeTitle(NS_IMAGE, $person_name . '.jpg');
906939 if (!$imgTitle->exists()) {
@@ -913,21 +946,21 @@
914947 //print "title is: " .$imgTitle->getDBkey() ."IMAGE IS: " . $img->getURL();
915948
916949 return '<span class="mv_person_ac" id="mv_person' . $inx . '" style="display:' . $disp . ';width:90px;">' .
917 - '<img id="mv_person_img' . $inx . '" style="padding:2px;" src="' . $img->getURL() . '" width="44">' .
918 - '<input id="mv_person_input' . $inx . '" class="mv_search_text" style="font-size: 12px;" size="9" ' .
919 - 'type="text" name="' . $tname . '" value="' . $person_name . '" autocomplete="off">' .
920 - '<div id="mv_person_choices'.$inx.'" class="autocomplete"></div>' .
921 - '</span>';
 950+ '<img id="mv_person_img' . $inx . '" style="padding:2px;" src="' . $img->getURL() . '" width="44">' .
 951+ '<input id="mv_person_input' . $inx . '" class="mv_search_text" style="font-size: 12px;" size="9" ' .
 952+ 'type="text" name="' . $tname . '" value="' . $person_name . '" autocomplete="off">' .
 953+ '<div id="mv_person_choices' . $inx . '" class="autocomplete"></div>' .
 954+ '</span>';
922955 }
923 - function selector($i, $key, $selected='', $display=true) {
924 - $disp = ($display)?'':'display:none;';
925 - $s= '<select id="mvsel_'.$key.'_' . $i . '" class="mv_search_select" style="font-size: 12px;'.$disp.'" name="f['.$i .']['.$key.']" >' . "\n";
926 - $items = ($key == 't')?$this->sel_filter_types:$this->sel_filter_andor;
927 - if($key=='a' && $selected=='')
928 - $selected='and';
929 -
 956+ function selector($i, $key, $selected = '', $display = true) {
 957+ $disp = ($display) ? '' : 'display:none;';
 958+ $s = '<select id="mvsel_' . $key . '_' . $i . '" class="mv_search_select" style="font-size: 12px;' . $disp . '" name="f[' . $i . '][' . $key . ']" >' . "\n";
 959+ $items = ($key == 't') ? $this->sel_filter_types : $this->sel_filter_andor;
 960+ if ($key == 'a' && $selected == '')
 961+ $selected = 'and';
 962+
930963 $sel = ($selected == '') ? 'selected' : '';
931 - if($key=='t')
 964+ if ($key == 't')
932965 $s .= '<option value="na" ' . $sel . '>' . wfMsg('mv_search_sel_' . $key) . '</option>' . "\n";
933966 foreach ($items as $item) {
934967 $sel = ($selected == $item) ? $sel = 'selected' : '';
@@ -937,119 +970,125 @@
938971 return $s;
939972 }
940973 //could be a suggest:
941 - function text_entry($i, $key, $val = '', $more_class='', $more_attr='') {
942 - if($more_class!='')$more_class=' '.$more_class;
943 - $s = '<input '.$more_attr.' class="mv_search_text'.$more_class.'" style="font-size: 12px;" onchange=""
944 - size="9" type="text" name="f[' . $i . '][' . $key . ']" value="' . $val . '">';
 974+ function text_entry($i, $key, $val = '', $more_class = '', $more_attr = '') {
 975+ if ($more_class != '')
 976+ $more_class = ' ' . $more_class;
 977+ $s = '<input ' . $more_attr . ' class="mv_search_text' . $more_class . '" style="font-size: 12px;" onchange=""
 978+ size="9" type="text" name="f[' . $i . '][' . $key . ']" value="' . $val . '">';
945979 return $s;
946980 }
947981 /*again here is some possibly metavid congress archive specific stuff:*/
948 - function auto_complete_all($val){
 982+ function auto_complete_all($val) {
949983 global $wgContLang;
950984 //everything is db key based so swap space for underscore:
951 - $val = str_replace(' ','_',$val);
952 -
 985+ $val = str_replace(' ', '_', $val);
 986+
953987 $catNStxt = $wgContLang->getNsText(NS_CATEGORY);
954 -
 988+
955989 //make sure people know they can "search" too (formated by
956 - $out='do_search|'.wfMsg('mv_search_transcripts_for','<B>$1</B>').'|no_image'."\n";
 990+ $out = 'do_search|' . wfMsg('mv_search_transcripts_for', '<B>$1</B>') . '|no_image' . "\n";
957991 //get keywords
958 - $category_out = MV_SpecialMediaSearch::auto_complete_search_categories($val, 3);
959 - if($category_out!=''){
960 - $out.=$catNStxt.':Categories|<h6>'.wfMsg('mv_category_matches').'</h6>|no_image'."\n";
961 - $out.=$category_out;
 992+ $category_out = MV_SpecialMediaSearch :: auto_complete_search_categories($val, 3);
 993+ if ($category_out != '') {
 994+ $out .= $catNStxt . ':Categories|<h6>' . wfMsg('mv_category_matches') . '</h6>|no_image' . "\n";
 995+ $out .= $category_out;
962996 }
963997 //get people
964 - $person_out = MV_SpecialMediaSearch::auto_complete_person($val, 3);
965 - if($person_out!=''){
966 - $out.=$catNStxt.':Person|<h6>'.wfMsg('mv_people_matches').'</h6>|no_image'."\n";
967 - $out.=$person_out;
 998+ $person_out = MV_SpecialMediaSearch :: auto_complete_person($val, 3);
 999+ if ($person_out != '') {
 1000+ $out .= $catNStxt . ':Person|<h6>' . wfMsg('mv_people_matches') . '</h6>|no_image' . "\n";
 1001+ $out .= $person_out;
9681002 }
9691003 //get bills
970 - $bill_out = MV_SpecialMediaSearch::auto_complete_category('Bill', $val, 3);
971 - if($bill_out!=''){
972 - $out.=$catNStxt.':Bill|<h6>'.wfMsg('mv_bill_matches').'</h6>|no_image'."\n";
973 - $out.=$bill_out;
 1004+ $bill_out = MV_SpecialMediaSearch :: auto_complete_category('Bill', $val, 3);
 1005+ if ($bill_out != '') {
 1006+ $out .= $catNStxt . ':Bill|<h6>' . wfMsg('mv_bill_matches') . '</h6>|no_image' . "\n";
 1007+ $out .= $bill_out;
9741008 }
9751009 //get interests
976 - $intrest_out = MV_SpecialMediaSearch::auto_complete_category('Interest_Group', $val, 3);
977 - if($intrest_out!=''){
978 - $out.=$catNStxt.':Interest Group|<h6>'.wfMsg('mv_interest_group_matches').'</h6>|no_image'."\n";
979 - $out.=$intrest_out;
 1010+ $intrest_out = MV_SpecialMediaSearch :: auto_complete_category('Interest_Group', $val, 3);
 1011+ if ($intrest_out != '') {
 1012+ $out .= $catNStxt . ':Interest Group|<h6>' . wfMsg('mv_interest_group_matches') . '</h6>|no_image' . "\n";
 1013+ $out .= $intrest_out;
9801014 }
9811015 return $out;
9821016 }
983 - function auto_complete_search_categories($val, $result_limit='5', $format='ac_line', &$match_count=''){
 1017+ function auto_complete_search_categories($val, $result_limit = '5', $format = 'ac_line', & $match_count = '') {
9841018 global $wgContLang;
985 - $dbr =& wfGetDB(DB_SLAVE);
986 - $result = $dbr->select( 'page', 'page_title',
987 - array('page_namespace'=>NS_CATEGORY,
988 - '`page_title` LIKE \'%'.mysql_escape_string($val).'%\' COLLATE latin1_general_ci'),
989 - __METHOD__,
990 - array('LIMIT'=>$result_limit));
 1019+ $dbr = & wfGetDB(DB_SLAVE);
 1020+ $result = $dbr->select('page', 'page_title', array (
 1021+ 'page_namespace' => NS_CATEGORY,
 1022+ '`page_title` LIKE \'%' . mysql_escape_string($val
 1023+ ) . '%\' COLLATE latin1_general_ci'), __METHOD__, array (
 1024+ 'LIMIT' => $result_limit
 1025+ ));
9911026 $match_count = $dbr->numRows($result);
992 - if($dbr->numRows($result) == 0)return '';
993 - $out='';
994 - $catNStxt = $wgContLang->getNsText(NS_CATEGORY);
995 - while($row = $dbr->fetchObject($result)){
996 - $out.=MV_SpecialMediaSearch::format_ac_line($row->page_title, $val, $catNStxt.':', 'no_image', $format);
 1027+ if ($dbr->numRows($result) == 0)
 1028+ return '';
 1029+ $out = '';
 1030+ $catNStxt = $wgContLang->getNsText(NS_CATEGORY);
 1031+ while ($row = $dbr->fetchObject($result)) {
 1032+ $out .= MV_SpecialMediaSearch :: format_ac_line($row->page_title, $val, $catNStxt . ':', 'no_image', $format);
9971033 }
9981034 return $out;
9991035 }
1000 - function auto_complete_category($category, $val, $result_limit='5', $format='ac_line', &$match_count=''){
1001 - $dbr =& wfGetDB(DB_SLAVE);
1002 - $result = $dbr->select( 'categorylinks', 'cl_sortkey',
1003 - array('cl_to'=>$category,
1004 - '`cl_sortkey` LIKE \'%'.mysql_escape_string($val).'%\' COLLATE latin1_general_ci'),
1005 - __METHOD__,
1006 - array('LIMIT'=>$result_limit));
 1036+ function auto_complete_category($category, $val, $result_limit = '5', $format = 'ac_line', & $match_count = '') {
 1037+ $dbr = & wfGetDB(DB_SLAVE);
 1038+ $result = $dbr->select('categorylinks', 'cl_sortkey', array (
 1039+ 'cl_to' => $category,
 1040+ '`cl_sortkey` LIKE \'%' . mysql_escape_string($val
 1041+ ) . '%\' COLLATE latin1_general_ci'), __METHOD__, array (
 1042+ 'LIMIT' => $result_limit
 1043+ ));
10071044 //print 'ran: ' . $dbr->lastQuery();
10081045 //mention_bill catebory Bill
10091046 $match_count = $dbr->numRows($result);
1010 - if($dbr->numRows($result) == 0)return '';
1011 - $out='';
1012 - while($row = $dbr->fetchObject($result)){
1013 - $out.=MV_SpecialMediaSearch::format_ac_line($row->cl_sortkey, $val, '', 'no_image', $format);
 1047+ if ($dbr->numRows($result) == 0)
 1048+ return '';
 1049+ $out = '';
 1050+ while ($row = $dbr->fetchObject($result)) {
 1051+ $out .= MV_SpecialMediaSearch :: format_ac_line($row->cl_sortkey, $val, '', 'no_image', $format);
10141052 }
10151053 return $out;
10161054 }
10171055 /*@@todo cache result for given values*/
1018 - function auto_complete_person($val, $result_limit='5', $format='ac_line', &$match_count=''){
1019 - $dbr =& wfGetDB(DB_SLAVE);
1020 - $result = $dbr->select( 'categorylinks', 'cl_sortkey',
1021 - array('cl_to'=>'Person',
1022 - '`cl_sortkey` LIKE \'%'.mysql_escape_string($val).'%\' COLLATE latin1_general_ci'),
1023 - __METHOD__,
1024 - array('LIMIT'=>$result_limit));
1025 - $match_count=$dbr->numRows($result);
1026 - if($dbr->numRows($result) == 0)return '';
 1056+ function auto_complete_person($val, $result_limit = '5', $format = 'ac_line', & $match_count = '') {
 1057+ $dbr = & wfGetDB(DB_SLAVE);
 1058+ $result = $dbr->select('categorylinks', 'cl_sortkey', array (
 1059+ 'cl_to' => 'Person',
 1060+ '`cl_sortkey` LIKE \'%' . mysql_escape_string($val
 1061+ ) . '%\' COLLATE latin1_general_ci'), __METHOD__, array (
 1062+ 'LIMIT' => $result_limit
 1063+ ));
 1064+ $match_count = $dbr->numRows($result);
 1065+ if ($dbr->numRows($result) == 0)
 1066+ return '';
10271067 //$out='<ul>'."\n";
1028 - $out='';
1029 - while($row = $dbr->fetchObject($result)){
 1068+ $out = '';
 1069+ while ($row = $dbr->fetchObject($result)) {
10301070 $person_name = $row->cl_sortkey;
10311071 //make sure the person page exists:
1032 - $personTitle = Title::makeTitle(NS_MAIN, $person_name);
1033 - if($personTitle->exists()){
 1072+ $personTitle = Title :: makeTitle(NS_MAIN, $person_name);
 1073+ if ($personTitle->exists()) {
10341074 //get person full name from semantic table if available
1035 - $person_result = $dbr->select('smw_attributes', 'value_xsd', array('attribute_title'=>'Full_Name',
1036 - 'subject_title'=>$personTitle->getDBkey()),
1037 - __METHOD__);
1038 - if($dbr->numRows($person_result)== 0){
 1075+ $person_result = $dbr->select('smw_attributes', 'value_xsd', array (
 1076+ 'attribute_title' => 'Full_Name',
 1077+ 'subject_title' => $personTitle->getDBkey()), __METHOD__);
 1078+ if ($dbr->numRows($person_result) == 0) {
10391079 $person_full_name = $person_name;
1040 - }else{
 1080+ } else {
10411081 $pvalue = $dbr->fetchObject($person_result);
10421082 $person_full_name = $pvalue->value_xsd;
1043 - }
 1083+ }
10441084 //format and output the line:
1045 - $out.=MV_SpecialMediaSearch::format_ac_line($person_full_name, $val, '',
1046 - MV_SpecialMediaSearch::getPersonImageURL($person_name), $format);
1047 - }
 1085+ $out .= MV_SpecialMediaSearch :: format_ac_line($person_full_name, $val, '', MV_SpecialMediaSearch :: getPersonImageURL($person_name), $format);
 1086+ }
10481087 }
10491088 //$out.='</ul>';
10501089 //return people people in the Person Category
10511090 return $out;
10521091 }
1053 - function getPersonImageURL($person_name){
 1092+ function getPersonImageURL($person_name) {
10541093 //make the missing person image ref:
10551094 $imgTitle = Title :: makeTitle(NS_IMAGE, $person_name . '.jpg');
10561095 if (!$imgTitle->exists()) {
@@ -1062,62 +1101,69 @@
10631102 }
10641103 return $img->getURL();
10651104 }
1066 - function format_ac_line(&$page_title, $val, $prefix='', $img_link='no_image', $format='ac_line'){
 1105+ function format_ac_line(& $page_title, $val, $prefix = '', $img_link = 'no_image', $format = 'ac_line') {
10671106 //no underscores in display title:
1068 - $page_title_disp = str_replace('_',' ',$page_title);
 1107+ $page_title_disp = str_replace('_', ' ', $page_title);
10691108 //bold matching part of title:
1070 - $bs = stripos($page_title_disp, str_replace('_',' ',$val) );
1071 - if($bs!==false){
1072 - $page_title_disp = substr($page_title_disp, 0, $bs) .
1073 - '<b>'.substr($page_title_disp, $bs, strlen($val)) .
1074 - '</b>' . substr($page_title_disp, $bs+strlen($val));
 1109+ $bs = stripos($page_title_disp, str_replace('_', ' ', $val));
 1110+ if ($bs !== false) {
 1111+ $page_title_disp = substr($page_title_disp, 0, $bs) .
 1112+ '<b>' . substr($page_title_disp, $bs, strlen($val)) .
 1113+ '</b>' . substr($page_title_disp, $bs +strlen($val));
10751114 }
10761115 //$page_title_bold = str_ireplace($val, '<b>'.$val.'</b>',$page_title);
1077 - if($format=='ac_line'){
1078 - return $prefix.$page_title.'|'.$page_title_disp.'|'.$img_link."\n";
1079 - }else if($format=='block_html' || $format=='person_html'){
1080 - global $wgUser;
1081 - $sk = $wgUser->getSkin();
1082 - $title = Title::newFromText($prefix.$page_title);
1083 -
1084 - if($format=='block_html')
1085 - return "<p class=\"normal_match\">".$sk->makeKnownLinkObj($title,
1086 - '<span>'.$page_title_disp.'</span>').'</p>';
1087 -
1088 - if($format=='person_html')
1089 - return "<p class=\"people2_match last_match\"><img src=\"{$img_link}\">".$sk->makeKnownLinkObj($title, $page_title_disp).'</p>';
1090 - }
 1116+ if ($format == 'ac_line') {
 1117+ return $prefix . $page_title . '|' . $page_title_disp . '|' . $img_link . "\n";
 1118+ } else
 1119+ if ($format == 'block_html' || $format == 'person_html') {
 1120+ global $wgUser;
 1121+ $sk = $wgUser->getSkin();
 1122+ $title = Title :: newFromText($prefix . $page_title);
 1123+
 1124+ if ($format == 'block_html')
 1125+ return "<p class=\"normal_match\">" . $sk->makeKnownLinkObj($title, '<span>' .
 1126+ $page_title_disp . '</span>') . '</p>';
 1127+
 1128+ if ($format == 'person_html')
 1129+ return "<p class=\"people2_match last_match\"><img src=\"{$img_link}\">" . $sk->makeKnownLinkObj($title, $page_title_disp) . '</p>';
 1130+ }
10911131 }
10921132 //return a json date obj
10931133 //@@todo fix for big sites...(will start to be no fun if number of streams is > 2000 )
1094 - function getJsonDateObj($obj_name='mv_result'){
1095 - $dbr =& wfGetDB(DB_SLAVE);
 1134+ function getJsonDateObj($obj_name = 'mv_result') {
 1135+ $dbr = & wfGetDB(DB_SLAVE);
10961136 $sql = 'SELECT `date_start_time` FROM `mv_streams` ' .
1097 - 'WHERE `date_start_time` IS NOT NULL ' .
1098 - 'ORDER BY `date_start_time` ASC LIMIT 0, 2000';
 1137+ 'WHERE `date_start_time` IS NOT NULL ' .
 1138+ 'ORDER BY `date_start_time` ASC LIMIT 0, 2000';
10991139 $res = $dbr->query($sql, 'MV_SpecialMediaSearch:getJsonDateObj');
1100 - $start_day=time();
1101 - $end_day=0;
1102 - $delta=0;
1103 - $sDays = array();
1104 - while($row = $dbr->fetchObject( $res )){
1105 - if($row->date_start_time==0)continue; //skip empty / zero values
1106 - if($row->date_start_time < $start_day)$start_day=$row->date_start_time;
1107 - if($row->date_start_time > $end_day)$end_day = $row->date_start_time;
1108 - list($month,$day, $year) = explode('/',date('m/d/Y',$row->date_start_time));
 1140+ $start_day = time();
 1141+ $end_day = 0;
 1142+ $delta = 0;
 1143+ $sDays = array ();
 1144+ while ($row = $dbr->fetchObject($res)) {
 1145+ if ($row->date_start_time == 0)
 1146+ continue; //skip empty / zero values
 1147+ if ($row->date_start_time < $start_day)
 1148+ $start_day = $row->date_start_time;
 1149+ if ($row->date_start_time > $end_day)
 1150+ $end_day = $row->date_start_time;
 1151+ list ($month, $day, $year) = explode('/', date('m/d/Y', $row->date_start_time));
11091152 $month = trim($month, '0');
11101153 $day = trim($day, '0');
1111 - if(!isset($sDays[$year]))$sDays[$year]=array();
1112 - if(!isset($sDays[$year][$month]))$sDays[$year][$month]=array();
1113 - if(!isset($sDays[$year][$month][$day])){
1114 - $sDays[$year][$month][$day]=1;
1115 - }else{
1116 - $sDays[$year][$month][$day]++;
1117 - }
 1154+ if (!isset ($sDays[$year]))
 1155+ $sDays[$year] = array ();
 1156+ if (!isset ($sDays[$year][$month]))
 1157+ $sDays[$year][$month] = array ();
 1158+ if (!isset ($sDays[$year][$month][$day])) {
 1159+ $sDays[$year][$month][$day] = 1;
 1160+ } else {
 1161+ $sDays[$year][$month][$day]++;
 1162+ }
11181163 }
1119 - return php2jsObj(array('sd'=>date('m/d/Y', $start_day),
1120 - 'ed'=>date('m/d/Y',$end_day),
1121 - 'sdays'=>$sDays), $obj_name);
 1164+ return php2jsObj(array (
 1165+ 'sd' => date('m/d/Y',
 1166+ $start_day
 1167+ ), 'ed' => date('m/d/Y', $end_day), 'sdays' => $sDays), $obj_name);
11221168 }
11231169 }
11241170 ?>
Index: branches/MetavidWiki-exp/MetavidWiki/languages/MV_Messages.php
@@ -201,6 +201,10 @@
202202 'mv_people_results' => 'People Results',
203203 'mv_bill_results' => 'Bill Results',
204204 'mv_intrest_group_results' => 'Interst Groups',
 205+
 206+ 'mv_most_relevent' => 'Most Relevent',
 207+ 'mv_most_recent' => 'Most Recent',
 208+ 'mv_most_viewed' => 'Most Viewed',
205209
206210 'mv_match' => 'match',
207211 'mv_spoken_by' => 'spoken by',

Status & tagging log