Index: trunk/extensions/MetavidWiki/includes/MV_Index.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | if ( $mvTitle != null ) |
32 | 32 | $this->mvTitle = $mvTitle; |
33 | 33 | } |
34 | | - |
| 34 | + |
35 | 35 | function countMVDInRange( $stream_id, $start_time = null, $end_time = null, $mvd_type = 'all' ) { |
36 | 36 | global $mvDefaultClipLength; |
37 | 37 | $dbr =& wfGetDB( DB_SLAVE ); |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | $dbr =& wfGetDB( DB_SLAVE ); |
53 | 53 | // set up select vars: |
54 | 54 | $conds = $vars = array(); |
55 | | - $from_tables = ''; |
| 55 | + $from_tables = ''; |
56 | 56 | // |
57 | 57 | // set mvd_type if empty: |
58 | 58 | if ( $mvd_type == null )$mvd_type = 'all'; |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | // add in base from: |
63 | 63 | $from_tables .= $dbr->tableName( 'mv_mvd_index' ); |
64 | 64 | $conds = array( 'stream_id' => $stream_id ); |
65 | | - // print_r($smw_properties); |
| 65 | + // print_r($smw_properties); |
66 | 66 | if ( $mvd_type != 'all' ) { |
67 | 67 | $mvd_type = ( is_object( $mvd_type ) ) ? get_object_vars( $mvd_type ):$mvd_type; |
68 | 68 | if ( is_array( $mvd_type ) ) { |
— | — | @@ -80,25 +80,25 @@ |
81 | 81 | // print "Start time: $start_time END TIME: $end_time\n"; |
82 | 82 | if ( $end_time != null ) |
83 | 83 | $conds[] = 'start_time <= ' . $dbr->addQuotes( $end_time ); |
84 | | - |
| 84 | + |
85 | 85 | if ( $start_time != null ) |
86 | 86 | $conds[] = 'end_time >= ' . $dbr->addQuotes( $start_time ); |
87 | | - |
| 87 | + |
88 | 88 | // add in ordering |
89 | 89 | if ( !isset( $options['ORDER BY'] ) ) |
90 | 90 | $options['ORDER BY'] = 'start_time ASC'; |
91 | | - |
| 91 | + |
92 | 92 | // add in limit |
93 | 93 | if ( !isset( $options['LIMIT'] ) ) |
94 | 94 | $options['LIMIT'] = 200; |
95 | | - |
| 95 | + |
96 | 96 | // run query: |
97 | 97 | $result = $dbr->select( $from_tables, |
98 | 98 | $vars, |
99 | 99 | $conds, |
100 | 100 | __METHOD__, |
101 | 101 | $options ); |
102 | | - |
| 102 | + |
103 | 103 | //print $dbr->lastQuery(); |
104 | 104 | //die; |
105 | 105 | return MV_Index::getMVDMeta( $result, $getText, $smw_properties); |
— | — | @@ -106,19 +106,19 @@ |
107 | 107 | function getMVDMeta( &$result, $getText = false, $smw_properties = ''){ |
108 | 108 | $dbr =& wfGetDB( DB_SLAVE ); |
109 | 109 | if ( $dbr->numRows( $result ) == 0 )return array(); |
110 | | - |
| 110 | + |
111 | 111 | $do_cat_lookup = $do_smw_lookup = false; |
112 | 112 | if( !is_array($smw_properties) ){ |
113 | 113 | $smw_properties = explode( ',', $smw_properties ); |
114 | | - } |
| 114 | + } |
115 | 115 | foreach($smw_properties as $propKey){ |
116 | 116 | if($propKey == 'category') |
117 | 117 | $do_cat_lookup=true; |
118 | | - |
| 118 | + |
119 | 119 | if($propKey=='Speech_by'|| $propKey=='Bill') |
120 | 120 | $do_smw_lookup=true; |
121 | | - |
122 | | - } |
| 121 | + |
| 122 | + } |
123 | 123 | //get the results with meta |
124 | 124 | $ret_ary = array(); |
125 | 125 | $from_tables = $vars = $options = array(); |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | $or = ''; |
128 | 128 | while ( $row = $dbr->fetchObject( $result ) ) { |
129 | 129 | $ret_ary[$row->id] = $row; |
130 | | - // init array: |
| 130 | + // init array: |
131 | 131 | if ( $do_cat_lookup ) { |
132 | 132 | if ( !isset( $ret_ary[$row->id]->category ) ) |
133 | 133 | $ret_ary[$row->id]->category = array(); |
— | — | @@ -143,23 +143,23 @@ |
144 | 144 | $dbr->tableName( 'categorylinks' ) . '.cl_from = ' . |
145 | 145 | $dbr->tableName( 'mv_mvd_index' ) . '.mv_page_id' . |
146 | 146 | ' ) '; |
147 | | - |
| 147 | + |
148 | 148 | $vars = array( 'cl_from', 'cl_to' ); |
149 | | - |
| 149 | + |
150 | 150 | $options['LIMIT'] = 2000; // max average 5 categories per page |
151 | 151 | |
152 | 152 | $result_cat = $dbr->select( $from_tables, |
153 | 153 | $vars, |
154 | 154 | $conds, |
155 | 155 | __METHOD__, |
156 | | - $options ); |
157 | | - |
| 156 | + $options ); |
| 157 | + |
158 | 158 | while ( $cat_row = $dbr->fetchObject( $result_cat ) ) { |
159 | 159 | $ret_ary[$cat_row->cl_from]->category[] = $cat_row->cl_to; |
160 | 160 | } |
161 | | - } |
162 | | - // slow epecialy for lots of query results but join Query is crazy complicated for SMW >= 1.2 |
163 | | - // (and I have not been able to construct it without hitting exessive number of rows in the EXPLIN) |
| 161 | + } |
| 162 | + // slow especially for lots of query results but join Query is crazy complicated for SMW >= 1.2 |
| 163 | + // (and I have not been able to construct it without hitting expensive number of rows in the EXPLIN) |
164 | 164 | // @@todo these queries should be merged with semantic wiki Ask with some ~special~ keywords for fulltext search |
165 | 165 | if ( $do_smw_lookup ) { |
166 | 166 | $smwStore =& smwfGetStore(); |
— | — | @@ -167,7 +167,7 @@ |
168 | 168 | $rowTitle = Title::newFromText( $row->wiki_title, MV_NS_MVD ); |
169 | 169 | foreach ( $smw_properties as $propKey ) { |
170 | 170 | if ( $propKey != 'category' ) { |
171 | | - // init property: |
| 171 | + // init property: |
172 | 172 | $row->$propKey = ''; |
173 | 173 | $propTitle = Title::newFromText( $propKey, SMW_NS_PROPERTY ); |
174 | 174 | $smwProps = $smwStore->getPropertyValues( $rowTitle, $propTitle ); |
— | — | @@ -183,59 +183,59 @@ |
184 | 184 | // print_r($ret_ary); |
185 | 185 | // die; |
186 | 186 | |
187 | | - |
| 187 | + |
188 | 188 | // print $dbr->lastQuery(); |
189 | 189 | // die; |
190 | 190 | // echo $sql; |
191 | 191 | // $result =& $dbr->query( $sql, 'MV_Index:time_index_query'); |
192 | 192 | return $ret_ary; |
193 | | - } |
194 | | - //gets an Annotative layer that encapsulates the mvTilte |
| 193 | + } |
| 194 | + //gets an Annotative layer that encapsulates the mvTilte |
195 | 195 | static function getParentAnnotativeLayers(& $mvTitle){ |
196 | | - //first check if we are in range of the cache: |
| 196 | + //first check if we are in range of the cache: |
197 | 197 | if(count(self::$annoCache)!=0){ |
198 | 198 | foreach(self::$annoCache as $aMVD){ |
199 | | - if( $aMVD->start_time <= $mvTitle->getStartTimeSeconds() && |
200 | | - $aMVD->start_time <= $mvTitle->getEndTimeSeconds() && |
201 | | - $aMVD->end_time >= $mvTitle->getEndTimeSeconds() && |
202 | | - $aMVD->end_time >= $mvTitle->getEndTimeSeconds() && |
| 199 | + if( $aMVD->start_time <= $mvTitle->getStartTimeSeconds() && |
| 200 | + $aMVD->start_time <= $mvTitle->getEndTimeSeconds() && |
| 201 | + $aMVD->end_time >= $mvTitle->getEndTimeSeconds() && |
| 202 | + $aMVD->end_time >= $mvTitle->getEndTimeSeconds() && |
203 | 203 | $aMVD->stream_id == $mvTitle->getStreamId() ){ |
204 | | - //just return the cached result (faster than the set of db queries below) |
| 204 | + //just return the cached result (faster than the set of db queries below) |
205 | 205 | return $aMVD; |
206 | 206 | } |
207 | 207 | } |
208 | 208 | } |
209 | | - |
| 209 | + |
210 | 210 | $dbr =& wfGetDB( DB_SLAVE ); |
211 | 211 | $from_tables = $dbr->tableName( 'mv_mvd_index' ); |
212 | 212 | $vars = '`mv_page_id` as `id`, `wiki_title`,`mvd_type`, `stream_id`, `start_time`,`end_time`,`view_count`'; |
213 | 213 | $cond = array( 'stream_id' => $mvTitle->getStreamId() , |
214 | | - 'mvd_type' => 'Anno_en' |
| 214 | + 'mvd_type' => 'Anno_en' |
215 | 215 | ); |
216 | | - |
| 216 | + |
217 | 217 | $cond[] = ' `start_time` <= ' . $mvTitle->getStartTimeSeconds() ; |
218 | 218 | $cond[] = ' `start_time` <= ' . $mvTitle->getEndTimeSeconds() ; |
219 | | - |
| 219 | + |
220 | 220 | $cond[] = ' `end_time` >= ' . $mvTitle->getStartTimeSeconds() ; |
221 | | - $cond[] = ' `end_time` >= ' . $mvTitle->getEndTimeSeconds() ; |
222 | | - |
| 221 | + $cond[] = ' `end_time` >= ' . $mvTitle->getEndTimeSeconds() ; |
| 222 | + |
223 | 223 | $res = $dbr->select( $from_tables, |
224 | 224 | $vars, |
225 | 225 | $cond, |
226 | | - __METHOD__, |
227 | | - array( 'LIMIT' => 1 ) //just get one result |
| 226 | + __METHOD__, |
| 227 | + array( 'LIMIT' => 1 ) //just get one result |
228 | 228 | ); |
229 | 229 | //print $dbr->lastQuery(); |
230 | 230 | //die; |
231 | 231 | $aMvd_rows = MV_Index::getMVDMeta($res, false, 'Speech_by,Bill,category'); |
232 | | - //returns the result in array set to current: |
233 | | - $aMvd = end($aMvd_rows ); |
| 232 | + //returns the result in array set to current: |
| 233 | + $aMvd = end($aMvd_rows ); |
234 | 234 | if(!isset(self::$annoCache[ $aMvd->id ])){ |
235 | 235 | self::$annoCache[ $aMvd->id ] = $aMvd; |
236 | | - }; |
| 236 | + }; |
237 | 237 | return $aMvd; |
238 | 238 | } |
239 | | - |
| 239 | + |
240 | 240 | /*@@todo figure another way to get at this data...this is not a very fast query: */ |
241 | 241 | function getMVDTypeInRange( $stream_id, $start_time = null, $end_time = null ) { |
242 | 242 | $dbr =& wfGetDB( DB_SLAVE ); |
— | — | @@ -274,8 +274,8 @@ |
275 | 275 | $wgRequest, $mvDo_SQL_CALC_FOUND_ROWS, $mvMediaSearchResultsLimit; |
276 | 276 | |
277 | 277 | global $mvSpokenByInSearchResult, $mvCategoryInSearchResult, $mvBillInSearchResult; |
278 | | - |
279 | | - |
| 278 | + |
| 279 | + |
280 | 280 | // init vars |
281 | 281 | $from_tables = ''; |
282 | 282 | $vars = $conds = $options = array(); |
— | — | @@ -284,15 +284,15 @@ |
285 | 285 | $vars_top = $conds_top = $options_top = array(); |
286 | 286 | |
287 | 287 | $do_top_range_query = false; |
288 | | - |
289 | 288 | |
| 289 | + |
290 | 290 | $dbr =& wfGetDB( DB_SLAVE ); |
291 | 291 | // organize the queries (group full-text searches and category/attributes) |
292 | 292 | // if the attribute is not a numerical just add it to the fulltext query |
293 | 293 | $ftq_match_asql = $last_person_aon = $ftq_match = $ftq = $snq = $toplq = $toplq_cat = $date_range_join = $date_range_where = $asql = ''; // top query and full text query ='' |
294 | 294 | if ( $filters == '' )return array(); |
295 | 295 | $ftq_match_asql = $date_cond = ''; |
296 | | - |
| 296 | + |
297 | 297 | $date_range_join = true; |
298 | 298 | |
299 | 299 | // $selOpt = ($mvDo_SQL_CALC_FOUND_ROWS)?'SQL_CALC_FOUND_ROWS':''; |
— | — | @@ -321,9 +321,9 @@ |
322 | 322 | } |
323 | 323 | // add to the fulltext query: |
324 | 324 | switch( $f['t'] ) { |
325 | | - case 'speech_by': |
| 325 | + case 'speech_by': |
326 | 326 | case 'spoken_by': |
327 | | - $skey = str_replace('_', ' ', $f['t']); |
| 327 | + $skey = str_replace('_', ' ', $f['t']); |
328 | 328 | // skip if empty value: |
329 | 329 | if ( trim( $f['v'] ) == '' )continue; |
330 | 330 | // if we have an OR set prev to OR |
— | — | @@ -444,7 +444,7 @@ |
445 | 445 | $dbr->tableName( 'mv_stream_files' ) . '.stream_id ' . |
446 | 446 | ' AND (' . $dbr->tableName( 'mv_stream_files' ) . '.file_desc_msg = ' . |
447 | 447 | $dbr->addQuotes( $mvDefaultVideoQualityKey ) . |
448 | | - //' OR '. $dbr->tableName( 'mv_stream_files' ) .'.file_desc_msg = ' . |
| 448 | + //' OR '. $dbr->tableName( 'mv_stream_files' ) .'.file_desc_msg = ' . |
449 | 449 | // $dbr->addQuotes( $mvDefaultFlashQualityKey ) . |
450 | 450 | ')'. |
451 | 451 | ') '; |
— | — | @@ -462,7 +462,7 @@ |
463 | 463 | ' AND ' . $dbr->tableName( 'smw_relations' ) . '.relation_title = \'Spoken_By\'' . |
464 | 464 | ') '; |
465 | 465 | }*/ |
466 | | - |
| 466 | + |
467 | 467 | // add conditions to last condition element (cuz we have to manually mannage and or): |
468 | 468 | |
469 | 469 | $conds[count( $conds )] = ' ' . $dbr->tableName( 'mv_mvd_index' ) . '.mvd_type = \'ht_en\' ' . |
— | — | @@ -551,18 +551,18 @@ |
552 | 552 | MV_Index::insert_merge_range( $stream_groups[$row->stream_id], $stream_groups, $row ); |
553 | 553 | } |
554 | 554 | } |
555 | | - |
| 555 | + |
556 | 556 | if( $mvCategoryInSearchResult){ |
557 | 557 | $or=''; |
558 | 558 | $conds=''; |
559 | 559 | $options=array(); |
560 | | - //build the category query conditions: |
| 560 | + //build the category query conditions: |
561 | 561 | foreach($ret_ary as $row){ |
562 | 562 | if ( !isset( $ret_ary[$row->id]->category ) ) |
563 | 563 | $ret_ary[$row->id]->categories = array(); |
564 | | - |
| 564 | + |
565 | 565 | $conds .= $or . ' cl_from =' . $dbr->addQuotes( $row->id ); |
566 | | - $or = ' OR '; |
| 566 | + $or = ' OR '; |
567 | 567 | } |
568 | 568 | //do the lookup: |
569 | 569 | $from_tables = $dbr->tableName( 'categorylinks' ); |
— | — | @@ -571,8 +571,8 @@ |
572 | 572 | $dbr->tableName( 'categorylinks' ) . '.cl_from = ' . |
573 | 573 | $dbr->tableName( 'mv_mvd_index' ) . '.mv_page_id' . |
574 | 574 | ' ) '; |
575 | | - |
576 | | - $vars = array( 'cl_from', 'cl_to' ); |
| 575 | + |
| 576 | + $vars = array( 'cl_from', 'cl_to' ); |
577 | 577 | $options['LIMIT'] = 2000; // max avarage 5 categories per page |
578 | 578 | |
579 | 579 | $result_cat = $dbr->select( $from_tables, |
— | — | @@ -584,30 +584,30 @@ |
585 | 585 | $ret_ary[$cat_row->cl_from]->categories[$cat_row->cl_to] = true; |
586 | 586 | } |
587 | 587 | } |
588 | | - |
589 | | - if( $mvSpokenByInSearchResult || $mvBillInSearchResult ){ |
590 | | - // slow especially for lots of query results but join Query is crazy complicated for SMW >= 1.2 |
591 | | - // (and I have not been able to construct it without hitting exessive number of rows in the EXPLIN) |
592 | | - // @@todo these queries should be merged with semantic wiki Ask with some ~special~ keywords for fulltext search |
| 588 | + |
| 589 | + if( $mvSpokenByInSearchResult || $mvBillInSearchResult ){ |
| 590 | + // slow especially for lots of query results but join Query is crazy complicated for SMW >= 1.2 |
| 591 | + // (and I have not been able to construct it without hitting exessive number of rows in the EXPLIN) |
| 592 | + // @@todo these queries should be merged with semantic wiki Ask with some ~special~ keywords for fulltext search |
593 | 593 | $smwStore =& smwfGetStore(); |
594 | 594 | foreach ( $ret_ary as & $row ) { |
595 | 595 | //@@todo this is all very hackish but this is because SMW changed the db schema causing a few hacks: |
596 | | - // obviously this should be rewritten to use some SMW based query system. |
| 596 | + // obviously this should be rewritten to use some SMW based query system. |
597 | 597 | $smw_properties=array(); |
598 | 598 | if($mvSpokenByInSearchResult && strtolower(substr($row->wiki_title,0,2))=='ht') |
599 | 599 | $smw_properties[]='Spoken_By'; |
600 | | - |
| 600 | + |
601 | 601 | if($mvSpokenByInSearchResult && strtolower(substr($row->wiki_title,0,4))=='anno') |
602 | 602 | $smw_properties[]='Speech_by'; |
603 | | - |
| 603 | + |
604 | 604 | if($mvBillInSearchResult) |
605 | | - $smw_properties[]='Bill'; |
606 | | - |
607 | | - |
608 | | - $rowTitle = Title::newFromText( $row->wiki_title, MV_NS_MVD ); |
| 605 | + $smw_properties[]='Bill'; |
| 606 | + |
| 607 | + |
| 608 | + $rowTitle = Title::newFromText( $row->wiki_title, MV_NS_MVD ); |
609 | 609 | foreach ( $smw_properties as $propKey ) { |
610 | | - if ( $propKey != 'category' ) { |
611 | | - //print "on key: $propKey"; |
| 610 | + if ( $propKey != 'category' ) { |
| 611 | + //print "on key: $propKey"; |
612 | 612 | $propTitle = Title::newFromText( $propKey, SMW_NS_PROPERTY ); |
613 | 613 | $smwProps = $smwStore->getPropertyValues( $rowTitle, $propTitle ); |
614 | 614 | // just a temp hack .. we need to think about this abstraction a bit.. |
— | — | @@ -618,18 +618,18 @@ |
619 | 619 | $row->spoken_by = $v->getXSDValue(); |
620 | 620 | }else if($propKey=='Bill'){ |
621 | 621 | $row->bills=array(); |
622 | | - foreach($smwProps as $v){ |
| 622 | + foreach($smwProps as $v){ |
623 | 623 | $row->bills[$v->getXSDValue()] = true; |
624 | | - } |
| 624 | + } |
625 | 625 | } |
626 | 626 | } |
627 | 627 | } |
628 | | - } |
| 628 | + } |
629 | 629 | } |
630 | 630 | } |
631 | | - |
| 631 | + |
632 | 632 | return $ret_ary; |
633 | | - } |
| 633 | + } |
634 | 634 | function numResultsFound() { |
635 | 635 | if ( isset( $this->numResultsFound ) ) { |
636 | 636 | return $this->numResultsFound; |
Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php |
— | — | @@ -479,7 +479,7 @@ |
480 | 480 | $mvStreamTitle = Title :: MakeTitle( MV_NS_STREAM, $mvTitle->getNearStreamName( 0 ) ); |
481 | 481 | } |
482 | 482 | // $mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() ); |
483 | | - $mvd_text = $mvd->text; |
| 483 | + $mvd_text = str_replace(array('u800','u82e'),'', $mvd->text); |
484 | 484 | |
485 | 485 | $o .= '<li class="result"> |
486 | 486 | <span class="vid_img" id="mvimg_' . htmlspecialchars( $mvd->id ) . '"> |
— | — | @@ -493,7 +493,7 @@ |
494 | 494 | $sk->makeKnownLinkObj( $mvStreamTitle, $mvTitle->getStreamNameText() . |
495 | 495 | ' :: ' . $mvTitle->getTimeDesc() ) . |
496 | 496 | '</h4> |
497 | | - <p>Matching Phrase:' . $this->termHighlight( $mvd->text, implode( '|', $this->getTerms() ), 1, 100 ) . ' </p> |
| 497 | + <p>Matching Phrase:' . $this->termHighlight( $mvd_text, implode( '|', $this->getTerms() ), 1, 100 ) . ' </p> |
498 | 498 | <span class="by">' . $mvd_cnt_links . '</span> |
499 | 499 | <span class="by">' . $mvd_cat_links . '</span> |
500 | 500 | <span class="by">' . $mvd_bill_links . '</span> |