r42053 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42052‎ | r42053 | r42054 >
Date:20:06, 13 October 2008
Author:dale
Status:old
Tags:
Comment:
fixed oldS semantic schema search results references
Modified paths:
  • /trunk/extensions/MetavidWiki/MV_LocalSettings.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_Hooks.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_Index.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/MV_LocalSettings.php
@@ -8,7 +8,7 @@
99 * for more info on all overitable settings see base settings in MV_DefaultSettings.php
1010 * eventually we should have some documentation somewhere ;)
1111 */
12 -$mvExternalImages = false;
 12+$mvExternalImages = true;
1313 $mvExternalImgServerPath = 'http://metavid.ucsc.edu/wiki/index.php';
1414
1515 // for sunlight network annalysis we include google analytics
Index: trunk/extensions/MetavidWiki/includes/MV_Index.php
@@ -188,6 +188,7 @@
189189 }
190190 // slow epecialy for lots of query results but join Query is crazy complicated for SMW >= 1.2
191191 // (and I have not been able to construct it without hitting exessive number of rows in the EXPLIN)
 192+ // @@todo these queries should be merged with semantic wiki Ask with some ~special~ keywords for fulltext search
192193 if ( $do_smw_lookup ) {
193194 $smwStore =& smwfGetStore();
194195 foreach ( $ret_ary as & $row ) {
@@ -292,7 +293,8 @@
293294 $wgRequest, $mvDo_SQL_CALC_FOUND_ROWS, $mvMediaSearchResultsLimit;
294295
295296 global $mvSpokenByInSearchResult, $mvCategoryInSearchResult, $mvBillInSearchResult;
296 -
 297+
 298+
297299 // init vars
298300 $from_tables = '';
299301 $vars = $conds = $options = array();
@@ -414,7 +416,7 @@
415417 $valid_filter_count++;
416418 break;
417419 case 'smw_property':
418 - // more complicated query work needed
 420+ //@@todo merge doUnifiedFiltersQuery function with SMW Ask more complicated query work needed
419421 break;
420422 }
421423 }
@@ -429,8 +431,8 @@
430432 'start_time, end_time, view_count, wiki_title,' .
431433 $dbr->tableName( 'searchindex' ) . '.si_text AS `text` ';
432434
433 - if ( $mvSpokenByInSearchResult )
434 - $vars .= ', smw_relations.object_title as spoken_by ';
 435+ /*if ( $mvSpokenByInSearchResult )
 436+ $vars .= ', smw_relations.object_title as spoken_by ';*/
435437
436438 $from_tables .= $dbr->tableName( 'mv_mvd_index' ) . ' ';
437439 $from_tables .= 'JOIN ' . $dbr->tableName( 'searchindex' ) .
@@ -459,16 +461,16 @@
460462 // date range join:
461463
462464 // include spoken by relation in results (LEFT JOIN should not be *that* costly )
463 - if ( $mvSpokenByInSearchResult ) {
464 - /*$sql.="LEFT JOIN `smw_relations` ON (`mv_mvd_index`.`mv_page_id`=`smw_relations`.`subject_id` " .
465 - "AND `smw_relations`.`relation_title`='Spoken_By') ";*/
 465+ /*if ( $mvSpokenByInSearchResult ) {
 466+ //$sql.="LEFT JOIN `smw_relations` ON (`mv_mvd_index`.`mv_page_id`=`smw_relations`.`subject_id` " .
 467+ // "AND `smw_relations`.`relation_title`='Spoken_By') ";
466468 $from_tables .= 'LEFT JOIN ' . $dbr->tableName( 'smw_relations' ) .
467469 ' ON ' .
468470 '( ' . $dbr->tableName( 'mv_mvd_index' ) . '.mv_page_id = ' .
469471 $dbr->tableName( 'smw_relations' ) . '.subject_id ' .
470472 ' AND ' . $dbr->tableName( 'smw_relations' ) . '.relation_title = \'Spoken_By\'' .
471473 ') ';
472 - }
 474+ }*/
473475
474476 // add conditions to last condition element (cuz we have to manually mannage and or):
475477
@@ -558,6 +560,85 @@
559561 MV_Index::insert_merge_range( $stream_groups[$row->stream_id], $stream_groups, $row );
560562 }
561563 }
 564+
 565+ if( $mvCategoryInSearchResult){
 566+ $or='';
 567+ $conds='';
 568+ $options=array();
 569+ //build the category query conditions:
 570+ foreach($ret_ary as $row){
 571+ if ( !isset( $ret_ary[$row->id]->category ) )
 572+ $ret_ary[$row->id]->categories = array();
 573+
 574+ $conds .= $or . ' cl_from =' . $dbr->addQuotes( $row->id );
 575+ $or = ' OR ';
 576+ }
 577+ //do the lookup:
 578+ $from_tables = $dbr->tableName( 'categorylinks' );
 579+ $from_tables .= ' LEFT JOIN ' . $dbr->tableName( 'mv_mvd_index' ) .
 580+ ' ON ( ' .
 581+ $dbr->tableName( 'categorylinks' ) . '.cl_from = ' .
 582+ $dbr->tableName( 'mv_mvd_index' ) . '.mv_page_id' .
 583+ ' ) ';
 584+
 585+ $vars = array( 'cl_from', 'cl_to' );
 586+ $options['LIMIT'] = 2000; // max avarage 5 categories per page
 587+
 588+ $result_cat = $dbr->select( $from_tables,
 589+ $vars,
 590+ $conds,
 591+ __METHOD__,
 592+ $options );
 593+ while ( $cat_row = $dbr->fetchObject( $result_cat ) ) {
 594+ $ret_ary[$cat_row->cl_from]->categories[$cat_row->cl_to] = true;
 595+ }
 596+ }
 597+
 598+ if($mvSpokenByInSearchResult || $mvBillInSearchResult){
 599+ // slow epecialy for lots of query results but join Query is crazy complicated for SMW >= 1.2
 600+ // (and I have not been able to construct it without hitting exessive number of rows in the EXPLIN)
 601+ // @@todo these queries should be merged with semantic wiki Ask with some ~special~ keywords for fulltext search
 602+ $smwStore =& smwfGetStore();
 603+ foreach ( $ret_ary as & $row ) {
 604+ //@@todo this is all very hackish but this is because SMW changed the db schema causing a few hacks:
 605+ // obviously this should be rewritten to use some SMW based query system.
 606+ $smw_properties=array();
 607+ if($mvSpokenByInSearchResult && strtolower(substr($row->wiki_title,0,2))=='ht')
 608+ $smw_properties[]='spoken_by';
 609+
 610+ if($mvSpokenByInSearchResult && strtolower(substr($row->wiki_title,0,4))=='anno')
 611+ $smw_properties[]='speech_by';
 612+
 613+ if($mvBillInSearchResult)
 614+ $smw_properties[]='bill';
 615+
 616+
 617+ $rowTitle = Title::newFromText( $row->wiki_title, MV_NS_MVD );
 618+ foreach ( $smw_properties as $propKey ) {
 619+ if ( $propKey != 'category' ) {
 620+ $propTitle = Title::newFromText( $propKey, SMW_NS_PROPERTY );
 621+ $smwProps = $smwStore->getPropertyValues( $rowTitle, $propTitle );
 622+ // just a temp hack .. we need to think about this abstraction a bit..
 623+ if($propKey=='speech_by' || $propKey=='spoken_by'){
 624+ $v = current( $smwProps );
 625+ $row->spoken_by = $v->getXSDValue();
 626+ }else if($propKey=='bill'){
 627+ $row->bills=array();
 628+ foreach($smwProps as $v){
 629+ $row->bills[$v->getXSDValue()] = true;
 630+ }
 631+ }
 632+ }
 633+ }
 634+ }
 635+ }
 636+
 637+ //print_r($ret_ary);
 638+ //die;
 639+
 640+
 641+
 642+
562643 // print "<pre>";
563644 // print_r($ret_ary);
564645 // die;
@@ -571,7 +652,7 @@
572653 }
573654 }*/
574655 // do category & bill lookup for search result ranges
575 - if ( $mvCategoryInSearchResult || $mvBillInSearchResult ) {
 656+ /*if ( $mvCategoryInSearchResult || $mvBillInSearchResult ) {
576657 $from_tables = $conds = '';
577658 $vars = $options = array();
578659
@@ -641,7 +722,7 @@
642723 }
643724 // print "AFTER MERGE: ";
644725 // print_r($ret_ary);
645 - }
 726+ }*/
646727 // print "<pre>";
647728 // print_r($ret_ary);
648729 // die;
Index: trunk/extensions/MetavidWiki/includes/MV_Hooks.php
@@ -130,15 +130,16 @@
131131 * updates the time stamps when an article is moved
132132 */
133133 function mvMoveHook( &$old_title, &$new_title, &$user, $pageid, $redirid ) {
134 - global $mvgIP;
 134+ global $mvgIP,$wgOut;
135135 // die;
136136 // confirm we are in the mvd Namespace & update the wiki_title
137137 if ( $old_title->getNamespace() == MV_NS_MVD ) {
138138 MV_Index::update_index_title( $old_title->getDBkey() , $new_title->getDBkey() );
139139 //remove the old MVD having lots of redirects around is not fun
140140 $oldArticle = new Article($old_title);
141 - $oldArticle->doDelete( wfMsg('mv_move_delete_msg'), false );
142 -
 141+ $oldArticle->doDelete( wfMsg('mv_move_delete_msg'), false );
 142+ //clear output @@todo (should really check for errors and integrate info into move)
 143+ $wgOut->clearHTML();
143144 }
144145
145146 return true;// always return true, in order not to stop MW's hook processing!

Status & tagging log