r37127 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37126‎ | r37127 | r37128 >
Date:19:38, 5 July 2008
Author:dale
Status:old
Tags:
Comment:
search interface sidebar tabs complete
Modified paths:
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Index.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Title.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/languages/MV_Messages.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/sample_page.php (modified) (history)

Diff [purge]

Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Index.php
@@ -184,7 +184,7 @@
185185 global $mvIndexTableName,$mvStreamFilesTable, $mvDefaultClipLength,
186186 $wgRequest, $mvDo_SQL_CALC_FOUND_ROWS, $mvMediaSearchResultsLimit;
187187
188 - global $mvSpokenByInSearchResult, $mvCategoryInSearchResult;
 188+ global $mvSpokenByInSearchResult, $mvCategoryInSearchResult, $mvBillInSearchResult;
189189
190190 $dbr =& wfGetDB(DB_SLAVE);
191191 //organize the queries (group full-text searches and category/attributes)
@@ -345,7 +345,11 @@
346346 $sql.="LEFT JOIN `smw_relations` ON (`mv_mvd_index`.`mv_page_id`=`smw_relations`.`subject_id` " .
347347 "AND `smw_relations`.`relation_title`='Spoken_By') ";
348348 }
349 - $sql.="WHERE $snq ";
 349+ $sql.="WHERE ";
 350+ $sql.=" ( `{$mvIndexTableName}`.`mvd_type`='ht_en' OR `{$mvIndexTableName}`.`mvd_type`='anno_en') AND" ;
 351+ $sql.=" $snq ";
 352+ //limit to ht_en & anno_en (for now)
 353+
350354 $two_part_anor='';
351355 if($group_spoken){
352356 $ftq.=$ftq_match;
@@ -417,34 +421,40 @@
418422 }
419423
420424
421 -
422 - //do category lookup for all search result ranges
423 - if($mvCategoryInSearchResult){
424 - $sql='SELECT `categorylinks`.`cl_to`, `mv_mvd_index`.`stream_id`,
425 - `mv_mvd_index`.`start_time`,
426 - `mv_mvd_index`.`end_time`';
427 - $sql.='FROM `mv_mvd_index`
428 - JOIN `categorylinks` ON (`mv_mvd_index`.`mv_page_id` = `categorylinks`.`cl_from`)';
 425+ //do category & bill lookup for search result ranges
 426+ if($mvCategoryInSearchResult || $mvBillInSearchResult){
 427+ $sql="SELECT {$dbr->tableName('categorylinks')}.`cl_to`, `mv_mvd_index`.`stream_id`,
 428+ `$mvIndexTableName`.`start_time`,
 429+ `$mvIndexTableName`.`end_time`,
 430+ {$dbr->tableName('smw_relations')}.`object_title` as bill_to";
 431+ $sql.=" FROM `$mvIndexTableName`
 432+ LEFT JOIN {$dbr->tableName('categorylinks')} ON (`$mvIndexTableName`.`mv_page_id` = {$dbr->tableName('categorylinks')}.`cl_from`)
 433+ LEFT JOIN {$dbr->tableName('smw_relations')} ON (
 434+ `$mvIndexTableName`.`mv_page_id` = {$dbr->tableName('smw_relations')}.`subject_id` AND
 435+ {$dbr->tableName('smw_relations')}.`relation_title`='bill' ) ";
429436 //generate stream_id, range sets
430 - $sql.=' WHERE `mv_mvd_index`.`mvd_type`=\'Anno_en\' AND (';
 437+ $sql.=" WHERE `$mvIndexTableName`.`mvd_type`='Anno_en' AND (";
431438 $or='';
432439 foreach($ret_ary as $stream_id=>$rangeSet){
433440 foreach($rangeSet as $range){
434 - $sql.=$or . '( `mv_mvd_index`.`stream_id`='.$stream_id;
435 - $sql.=" AND `start_time` <= " . $range['s'];
436 - $sql.=" AND `end_time` >= " . $range['e'] . ' ) ';
 441+ $sql.=$or . "( `$mvIndexTableName`.`stream_id`='$stream_id'";
 442+ $sql.=" AND `start_time` <= '" . $range['s']."'";
 443+ $sql.=" AND `end_time` >= '" . $range['e'] . '\' ) ';
437444 $or = ' OR ';
438445 }
439446 }
440 - $sql.=') LIMIT 0, 200';
 447+ $sql.=') LIMIT 0, 200';
441448 //merge category info back into base results:
442 - $result = $dbr->query($sql, 'MV_Index:doCategoryInSearchResult');
 449+ $result = $dbr->query($sql, 'MV_Index:doCategorySearchResult');
443450 while($cl_row = $dbr->fetchObject( $result )){
444451 foreach($ret_ary[$cl_row->stream_id] as &$range){
445452 foreach($range['rows'] as &$result_row){
446453 if($result_row->start_time <= $cl_row->end_time &&
447454 $result_row->end_time >= $cl_row->start_time){
448 - $result_row->categories[$cl_row->cl_to]=true;
 455+ if($cl_row->cl_to)
 456+ $result_row->categories[$cl_row->cl_to]=true;
 457+ if($cl_row->bill_to)
 458+ $result_row->bills[$cl_row->bill_to]=true;
449459 }
450460 }
451461 }
Index: branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php
@@ -311,20 +311,31 @@
312312 $mvd_cnt_links.='<br>';
313313 assoc_array_increment($sideBarLinkBucket,'person', $mvd->spoken_by);
314314 }
315 - $mvd_cat_links='';
 315+ $mvd_cat_links=$mvd_bill_links='';
316316 $coma='';
317317 if(isset($mvd->categories)){
318318 foreach($mvd->categories as $cat_id=>$na){
319319 $cTitle= Title::MakeTitle(NS_CATEGORY, $cat_id);
320320 if($mvd_cat_links=='')
321321 $mvd_cat_links.=wfMsg('mv_search_categories').': ';
322 - $mvd_cat_links.=$sk->makeKnownLinkObj($cTitle, $cTitle->getText() );
 322+ $mvd_cat_links.=$coma. $sk->makeKnownLinkObj($cTitle, $cTitle->getText() );
323323 $coma=', ';
324324 assoc_array_increment($sideBarLinkBucket,'category', $cat_id);
325325 }
326326 }
327 -
328 - $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName());
 327+ $coma='';
 328+ if(isset($mvd->bills)){
 329+ foreach($mvd->bills as $bill_id=>$na){
 330+ $bTitle= Title::newFromText($bill_id);
 331+ if($mvd_bill_links=='')
 332+ $mvd_bill_links.=wfMsg('mv_search_bills').': ';
 333+ $mvd_bill_links.=$coma. $sk->makeKnownLinkObj($bTitle, $bTitle->getText() );
 334+ $coma=', ';
 335+ assoc_array_increment($sideBarLinkBucket,'bill', $bill_id);
 336+ }
 337+ }
 338+ //link directly to the current range:
 339+ $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($extra_range='0'));
329340 //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() );
330341 $head_link = $sk->makeKnownLinkObj($mvStreamTitle, $mvTitle->getStreamNameText().' :: '.$mvTitle->getTimeDesc());
331342 $img_link = $sk->makeKnownLinkObj($mvStreamTitle, '<img alt="image for '.$mvTitle->getStreamNameText().' '. $mvTitle->getTimeDesc().'" src="'.$mvTitle->getStreamImageURL('small').'"/>');
@@ -339,6 +350,7 @@
340351 <p>Matching Phrase:' .$this->termHighlight($mvd->text, implode('|', $this->getTerms()), 2, 150).' </p>
341352 <span class="by">'.$mvd_cnt_links.'</span>
342353 <span class="by">'.$mvd_cat_links.'</span>
 354+ <span class="by">'.$mvd_bill_links.'</span>
343355 </div>
344356 <div class="result_meta">
345357 <span class="views">Views: NYA</span>
@@ -363,74 +375,81 @@
364376 <div class="suggestionsBox" id="searchSideBarInner">';
365377
366378 //look for people matches max of 3
367 - $fist_block=' fist_block';
 379+ $first_block=' first_block';
368380 $matches=0;
369381 $person_out = MV_SpecialMediaSearch::auto_complete_person($this->unified_term_search, 3, 'person_html', $matches);
370382 if($person_out!='' || count($sideBarLinkBucket['person'])!=0 ){
371383 //for now don't include({$matches})
372 - $o.="<div class=\"block{$fist_block}\">
373 - <h6>People Results </h6>
 384+ $o.="<div class=\"block{$first_block}\">
 385+ <h6>".wfMsg('mv_people_results')."</h6>
374386 </div>";
375387 $o.='<div class="block wide_block">'.
376388 $person_out;
377 - $pAry = & $sideBarLinkBucket['person'];
378 - arsort($pAry);
379 - $i=0;
380 - foreach($pAry as $person_name=>$count){
381 - if($i==$perSectionCount)break;
382 - $o.=MV_SpecialMediaSearch::format_ac_line($person_name, '', '', MV_SpecialMediaSearch::getPersonImageURL($person_name), $format='person_html');
383 - $i++;
384 - }
 389+ if(isset($sideBarLinkBucket['person'])){
 390+ $pAry = & $sideBarLinkBucket['person'];
 391+ arsort($pAry);
 392+ $i=0;
 393+ foreach($pAry as $person_name=>$count){
 394+ if($i==$perSectionCount)break;
 395+ $o.=MV_SpecialMediaSearch::format_ac_line($person_name, '', '', MV_SpecialMediaSearch::getPersonImageURL($person_name), $format='person_html');
 396+ $i++;
 397+ }
 398+ }
385399 $o.='</div>';
386 - $fist_block='';
 400+ $first_block='';
387401 }
388402 //get categories
389403 $category_out = MV_SpecialMediaSearch::auto_complete_search_categories($this->unified_term_search, 3, 'block_html',$matches);
390404 if($category_out!='' || count($sideBarLinkBucket['category'])!=0 ){
391 - $o.="<div class=\"block{$fist_block}\">
392 - <h6>Category Results (3)</h6>
 405+ $o.="<div class=\"block{$first_block}\">
 406+ <h6>".wfMsg('mv_category_results')."</h6>
393407 </div>";
394408 $o.='<div class="block wide_block">'.$category_out;
395 - $cAry = & $sideBarLinkBucket['category'];
396 - arsort($cAry);
397 - $i=0;
398 - foreach($cAry as $cat_name=>$count){
399 - if($i==$perSectionCount)break;
400 - $o.=MV_SpecialMediaSearch::format_ac_line($cat_name, '', '','no_image', $format='block_html');
401 - $i++;
402 - }
 409+ if(isset($sideBarLinkBucket['category'])){
 410+ $cAry = & $sideBarLinkBucket['category'];
 411+ arsort($cAry);
 412+ $i=0;
 413+ foreach($cAry as $cat_name=>$count){
 414+ if($i==$perSectionCount)break;
 415+ $o.=MV_SpecialMediaSearch::format_ac_line($cat_name, '', '','no_image', $format='block_html');
 416+ $i++;
 417+ }
 418+ }
403419 $o.='</div>';
404 - $fist_block='';
405 - }
406 -
407 -
408 -
409 - /*$bill_out = MV_SpecialMediaSearch::auto_complete_category('Bill', $this->unified_term_search, 3, 'block_html', $matches);
410 - if($bill_out!=''){
411 - $out.=$catNStxt.':Bill|<h6>'.wfMsg('mv_bill_matches').'</h6>|no_image'."\n";
412 - $out.=$bill_out;
413 - }*/
414 -
415 - $o.='
416 - <div class="block">
417 - <h6>Bill Results (2)</h6>
418 - </div>
419 -
420 - <div class="block wide_block">
421 - <p class="normal_match"><a href="#"><span>H.R. 3238: United-S<strong>ta</strong>tes-Israel Energy Cooperation Act</span></a></p>
422 - <p class="normal_match"><a class="last_match" href="#"><span>H.R. 3238: United-S<strong>ta</strong>tes-Israel Energy Cooperation Act</span></a></p>
423 - </div>
424 -
425 - <div class="block">
426 - <h6>Interest Groups (2)</h6>
427 - </div>
428 -
429 - <div class="block wide_block">
430 - <p class="normal_match"><a href="#"><span>Pillow Makers</span></a></p>
431 - <p class="normal_match"><a href="#"><span>Pill Companies</span></a></p>
432 - </div>
433 - </div><!--searchSideBarInner-->
434 - </div>';
 420+ $first_block='';
 421+ }
 422+ //get bills:
 423+ $bill_out = MV_SpecialMediaSearch::auto_complete_category('Bill', $this->unified_term_search, 3, 'block_html', $matches);
 424+ if($bill_out!='' || count($sideBarLinkBucket['bill'])!=0 ){
 425+ global $wgContLang;
 426+ $o.="<div class=\"block{$first_block}\">
 427+ <h6>".wfMsg('mv_bill_results')."</h6>
 428+ </div>";
 429+ $o.='<div class="block wide_block">'.$bill_out;
 430+ if($sideBarLinkBucket['bill']){
 431+ $bAry = & $sideBarLinkBucket['bill'];
 432+ arsort($bAry);
 433+ $i=0;
 434+ foreach($bAry as $bill_name=>$count){
 435+ if($i==$perSectionCount)break;
 436+ $o.=MV_SpecialMediaSearch::format_ac_line($bill_name, '', '','no_image', $format='block_html');
 437+ $i++;
 438+ }
 439+ }
 440+ $o.='</div>';
 441+ $first_block='';
 442+ }
 443+ //intrest out is just simple title matching (for now)
 444+ $intrest_out = MV_SpecialMediaSearch::auto_complete_category('Interest_Group', $this->unified_term_search, 3, 'block_html', $matches);
 445+ if($intrest_out!=''){
 446+ $o.="<div class=\"block{$first_block}\">
 447+ <h6>".wfMsg('mv_intrest_group_results')."</h6>
 448+ </div>";
 449+ $o.='<div class="block wide_block">'.$intrest_out.'</div>';
 450+ $first_block='';
 451+ }
 452+ $o.='</div><!--searchSideBarInner-->
 453+ </div>';
435454 return $o;
436455 }
437456 function getResultsHTML() {
@@ -517,8 +536,7 @@
518537 '</a>' .
519538 '&nbsp;&nbsp;';
520539 //output control links:
521 - //make stream title link:
522 -
 540+ //make stream title link:
523541 $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName());
524542 //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() );
525543 $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') . '" ');
@@ -948,7 +966,7 @@
949967 }
950968 return $out;
951969 }
952 - function auto_complete_category($category, $val, $result_limit='5'){
 970+ function auto_complete_category($category, $val, $result_limit='5', $format='ac_line', &$match_count=''){
953971 $dbr =& wfGetDB(DB_SLAVE);
954972 $result = $dbr->select( 'categorylinks', 'cl_sortkey',
955973 array('cl_to'=>$category,
@@ -957,10 +975,11 @@
958976 array('LIMIT'=>$result_limit));
959977 //print 'ran: ' . $dbr->lastQuery();
960978 //mention_bill catebory Bill
 979+ $match_count = $dbr->numRows($result);
961980 if($dbr->numRows($result) == 0)return '';
962981 $out='';
963982 while($row = $dbr->fetchObject($result)){
964 - $out.=MV_SpecialMediaSearch::format_ac_line($row->cl_sortkey, $val);
 983+ $out.=MV_SpecialMediaSearch::format_ac_line($row->cl_sortkey, $val, '', 'no_image', $format);
965984 }
966985 return $out;
967986 }
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Title.php
@@ -172,13 +172,14 @@
173173 /*
174174 * returns a near by stream range:
175175 */
176 - function getNearStreamName($range='', $length=''){
 176+ function getNearStreamName($range=null, $length=null){
177177 global $mvDefaultClipLength, $mvDefaultClipRange;
178178
179179 $stream = & mvGetMVStream($this->stream_name);
180 -
181 - if($range=='')$range = $mvDefaultClipRange;
182 - if($length=='')$length=$mvDefaultClipLength;
 180+
 181+ if($range==null)$range = $mvDefaultClipRange;
 182+ if($length==null)$length=$mvDefaultClipLength;
 183+
183184 //subtract $range seconds from the start time:
184185 $start_t = $this->getStartTimeSeconds() - $range;
185186 if($start_t<0)$start_t=0;
Index: branches/MetavidWiki-exp/MetavidWiki/languages/MV_Messages.php
@@ -175,6 +175,7 @@
176176 'mv_search_match' => 'Search text',
177177 'mv_search_spoken_by' => 'Spoken by',
178178 'mv_search_categories' => 'Categories',
 179+ 'mv_search_bills' => 'Bills',
179180 'mv_search_category' => 'Category',
180181 'mv_search_smw_property' => 'Semantic properties',
181182 'mv_search_smw_property_numeric' => 'Numeric semantic value',
@@ -185,6 +186,11 @@
186187 'mv_search_date_range' => 'Date range',
187188 'mv_stream_name' => 'stream name',
188189 'mv_date_range' => 'date range',
 190+
 191+ 'mv_category_results' => 'Category Results',
 192+ 'mv_people_results' => 'People Results',
 193+ 'mv_bill_results' => 'Bill Results',
 194+ 'mv_intrest_group_results' => 'Interst Groups',
189195
190196 'mv_match' => 'match',
191197 'mv_spoken_by' => 'spoken by',
Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -1392,24 +1392,26 @@
13931393 addROE:function(roe_data)
13941394 {
13951395 var _this = this;
1396 - $j.each(roe_data.getElementsByTagName('mediaSource'), function(inx, source)
1397 - {
1398 - _this.tryAddSource(source);
1399 - });
1400 - //set the thumbnail:
1401 - $j.each(roe_data.getElementsByTagName('img'), function(inx, n){
1402 - if(n.getAttribute("id")=="stream_thumb"){
1403 - js_log('set thumb to '+n.getAttribute("src"));
1404 - _this['thumbnail'] = n.getAttribute("src");
1405 - }
1406 - })
1407 - //set the linkback:
1408 - $j.each(_this.roe_data.getElementsByTagName('link'), function(inx, n){
1409 - if(n.getAttribute('id')=='html_linkback'){
1410 - js_log('set linkback to '+n.getAttribute("href"));
1411 - _this['linkback'] = n.getAttribute('href');
1412 - }
1413 - })
 1396+ if(this.roe_data){
 1397+ $j.each(roe_data.getElementsByTagName('mediaSource'), function(inx, source)
 1398+ {
 1399+ _this.tryAddSource(source);
 1400+ });
 1401+ //set the thumbnail:
 1402+ $j.each(roe_data.getElementsByTagName('img'), function(inx, n){
 1403+ if(n.getAttribute("id")=="stream_thumb"){
 1404+ js_log('set thumb to '+n.getAttribute("src"));
 1405+ _this['thumbnail'] = n.getAttribute("src");
 1406+ }
 1407+ })
 1408+ //set the linkback:
 1409+ $j.each(_this.roe_data.getElementsByTagName('link'), function(inx, n){
 1410+ if(n.getAttribute('id')=='html_linkback'){
 1411+ js_log('set linkback to '+n.getAttribute("href"));
 1412+ _this['linkback'] = n.getAttribute('href');
 1413+ }
 1414+ })
 1415+ }
14141416 }
14151417 };
14161418
Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/sample_page.php
@@ -25,11 +25,14 @@
2626 src="http://128.114.20.64/media/senate_proceeding_08-01-07.ogg.anx?t=0:27:16/0:27:32"
2727 roe="http://localhost/mvw-exp/index.php?title=Special:MvExportStream&feed_format=roe&stream_name=senate_proceeding_08-01-07&t=0:27:16/0:27:32"
2828 show_meta_link="false" autoplay="true" style="width:160px;height:120px" controls="true" embed_link="true" />';
29 -$sample_embed[0]['desc']=' auto play test';
 29+$sample_embed[0]['desc']=' auto play test (similar embed syntax to the metavidWiki site)';
 30+
3031 /*$sample_embed[0]['tag']='<video id="v0" src="sample.ogg" thumbnail="sample.jpg"></video>';
3132 $sample_embed[0]['desc']='basic usage with manual controls:<br />'.
3233 '<a href="javascript:document.getElementById(\'v1\').play();">Play</a> | '.
3334 '<a href="javascript:document.getElementById(\'v1\').stop();">Stop</a> <br />';*/
 35+
 36+
3437 //'<b>Exported functions:</b><br />'.
3538 //'<a href="javascript:document.getElementById(\'v1\').mute();">Get Time</a> | ';
3639 //'thumbnail="http://metavid.ucsc.edu/image_media/senate_proceeding_06-20-07_09?t=3:50:27&size=320x240" ' .

Status & tagging log