Index: trunk/extensions/MetavidWiki/includes/MV_Index.php |
— | — | @@ -4,396 +4,396 @@ |
5 | 5 | * |
6 | 6 | * All Metavid Wiki code is Released under the GPL2 |
7 | 7 | * for more info visit http:/metavid.ucsc.edu/code |
8 | | - * |
| 8 | + * |
9 | 9 | * @author Michael Dale |
10 | 10 | * @email dale@ucsc.edu |
11 | 11 | * @url http://metavid.ucsc.edu |
12 | | - * |
| 12 | + * |
13 | 13 | */ |
14 | 14 | /* |
15 | | - * maintains the index table state on various updates |
16 | | - * (need for indexed time ranged queries) |
17 | | - * (currently stored in a mysql table) |
18 | | - * in the future we should shift this to a search engine of some sort |
| 15 | + * maintains the index table state on various updates |
| 16 | + * (need for indexed time ranged queries) |
| 17 | + * (currently stored in a mysql table) |
| 18 | + * in the future we should shift this to a search engine of some sort |
19 | 19 | * (ie lucene or sphinx) or just do everything with semantic relations |
20 | 20 | * if we can get the speed to an acceptable level... |
21 | | - * |
| 21 | + * |
22 | 22 | * keep an additional copy of the text table is not ideal but... |
23 | 23 | * we keep a copy of every version of the page so its not so bad ;P |
24 | 24 | */ |
25 | 25 | if ( !defined( 'MEDIAWIKI' ) ) die( 1 ); |
26 | 26 | |
27 | 27 | class MV_Index { |
28 | | - var $mvTitle =null; |
29 | | - function __construct(& $mvTitle=null){ |
30 | | - if($mvTitle!=null) |
31 | | - $this->mvTitle=$mvTitle; |
32 | | - } |
33 | | - /* |
34 | | - * grabs near options count |
35 | | - * (similar to getNearStreams but returns a count instead of a result set) |
36 | | - * |
37 | | - * @params: |
38 | | - * $range_offset |
39 | | - * |
40 | | - * options: |
41 | | - * limit_by_current_type *default ...only include meta chunks of the current mvTitle type |
42 | | - * limit_by_type = $type ...include stream of given $type |
43 | | - * all_in_rage *default...include all meta that have any portion in range |
44 | | - * contained_in_range ...include only meta that are contained in the given range |
45 | | - * start_or_end_in_range ...include only meta that start or end in the given range |
46 | | - */ |
47 | | - /*function getNearCount($range_offset='', $options=array()){ |
48 | | - global $mvDefaultClipLength, $mvIndexTableName; |
49 | | - if($range_offset=='')$range_offset=$mvDefaultClipLength; |
50 | | - $dbr =& wfGetDB(DB_SLAVE); |
51 | | - //set up the count sql query: |
52 | | - $sql = "SELECT COUNT(1) as `count` FROM {$dbr->tableName($mvIndexTableName)} " . |
53 | | - "WHERE `stream_id`={$this->mvTitle->getStreamId()} "; |
54 | | - if(isset($options['limit_by_type'])){ |
55 | | - $sql.="AND `mvd_type`='{$options[limit_by_type]}' "; |
56 | | - }else{ |
57 | | - $sql.="AND `mvd_type`='{$this->mvTitle->getMvdTypeKey()}' "; |
58 | | - } |
59 | | - $st = $this->mvTitle->getStartTimeSeconds() - $range_offset; |
60 | | - if($st<0)$st=0; |
61 | | - //if end time not present use startTime |
62 | | - if($this->mvTitle->getStartTimeSeconds()){ |
63 | | - $et = $this->mvTitle->getStartTimeSeconds() + $range_offset; |
64 | | - }else{ |
65 | | - $et = $this->mvTitle->getStartTimeSeconds() + $range_offset; |
66 | | - } |
67 | | - //make sure we don't exceed the stream duration |
68 | | - if($et > $this->mvTitle->getDuration())$et=$this->mvTitle->getDuration(); |
69 | | - //default all in range: |
70 | | - $sql.=' AND ( '; |
71 | | - // double or set for null or non-null end time range queries: |
72 | | - $sql.=" (`end_time` IS NULL |
73 | | - AND `start_time` > {$st} |
74 | | - AND `start_time` < {$et} |
75 | | - ) |
76 | | - OR |
77 | | - (`end_time` IS NOT NULL |
78 | | - AND `end_time` > {$st} |
79 | | - AND `start_time` < {$et} |
80 | | - ) |
81 | | - )"; |
82 | | - $result = $dbr->query($sql, 'MV_Index:getNearCount'); |
83 | | - $row = $dbr->fetchObject( $result ); |
84 | | - //print_r($row); |
85 | | - return $row->count; |
86 | | - }*/ |
87 | | - function countMVDInRange($stream_id, $start_time=null, $end_time=null, $mvd_type='all'){ |
88 | | - global $mvDefaultClipLength; |
89 | | - $dbr =& wfGetDB(DB_SLAVE); |
| 28 | + var $mvTitle =null; |
| 29 | + function __construct(& $mvTitle=null){ |
| 30 | + if($mvTitle!=null) |
| 31 | + $this->mvTitle=$mvTitle; |
| 32 | + } |
| 33 | + /* |
| 34 | + * grabs near options count |
| 35 | + * (similar to getNearStreams but returns a count instead of a result set) |
| 36 | + * |
| 37 | + * @params: |
| 38 | + * $range_offset |
| 39 | + * |
| 40 | + * options: |
| 41 | + * limit_by_current_type *default ...only include meta chunks of the current mvTitle type |
| 42 | + * limit_by_type = $type ...include stream of given $type |
| 43 | + * all_in_rage *default...include all meta that have any portion in range |
| 44 | + * contained_in_range ...include only meta that are contained in the given range |
| 45 | + * start_or_end_in_range ...include only meta that start or end in the given range |
| 46 | + */ |
| 47 | + /*function getNearCount($range_offset='', $options=array()){ |
| 48 | + global $mvDefaultClipLength, $mvIndexTableName; |
| 49 | + if($range_offset=='')$range_offset=$mvDefaultClipLength; |
| 50 | + $dbr =& wfGetDB(DB_SLAVE); |
| 51 | + //set up the count sql query: |
| 52 | + $sql = "SELECT COUNT(1) as `count` FROM {$dbr->tableName($mvIndexTableName)} " . |
| 53 | + "WHERE `stream_id`={$this->mvTitle->getStreamId()} "; |
| 54 | + if(isset($options['limit_by_type'])){ |
| 55 | + $sql.="AND `mvd_type`='{$options[limit_by_type]}' "; |
| 56 | + }else{ |
| 57 | + $sql.="AND `mvd_type`='{$this->mvTitle->getMvdTypeKey()}' "; |
| 58 | + } |
| 59 | + $st = $this->mvTitle->getStartTimeSeconds() - $range_offset; |
| 60 | + if($st<0)$st=0; |
| 61 | + //if end time not present use startTime |
| 62 | + if($this->mvTitle->getStartTimeSeconds()){ |
| 63 | + $et = $this->mvTitle->getStartTimeSeconds() + $range_offset; |
| 64 | + }else{ |
| 65 | + $et = $this->mvTitle->getStartTimeSeconds() + $range_offset; |
| 66 | + } |
| 67 | + //make sure we don't exceed the stream duration |
| 68 | + if($et > $this->mvTitle->getDuration())$et=$this->mvTitle->getDuration(); |
| 69 | + //default all in range: |
| 70 | + $sql.=' AND ( '; |
| 71 | + // double or set for null or non-null end time range queries: |
| 72 | + $sql.=" (`end_time` IS NULL |
| 73 | + AND `start_time` > {$st} |
| 74 | + AND `start_time` < {$et} |
| 75 | + ) |
| 76 | + OR |
| 77 | + (`end_time` IS NOT NULL |
| 78 | + AND `end_time` > {$st} |
| 79 | + AND `start_time` < {$et} |
| 80 | + ) |
| 81 | + )"; |
| 82 | + $result = $dbr->query($sql, 'MV_Index:getNearCount'); |
| 83 | + $row = $dbr->fetchObject( $result ); |
| 84 | + //print_r($row); |
| 85 | + return $row->count; |
| 86 | + }*/ |
| 87 | + function countMVDInRange($stream_id, $start_time=null, $end_time=null, $mvd_type='all'){ |
| 88 | + global $mvDefaultClipLength; |
| 89 | + $dbr =& wfGetDB(DB_SLAVE); |
90 | 90 | |
91 | | - $cond=array('stream_id'=>$stream_id); |
92 | | - if($end_time) |
93 | | - $cond[]='AND start_time <= '. $dbr->addQuotes($end_time); |
94 | | - if($start_time) |
95 | | - $cond[]='AND end_time >= '. $dbr->addQuotes($start_time); |
| 91 | + $cond=array('stream_id'=>$stream_id); |
| 92 | + if($end_time) |
| 93 | + $cond[]='AND start_time <= '. $dbr->addQuotes($end_time); |
| 94 | + if($start_time) |
| 95 | + $cond[]='AND end_time >= '. $dbr->addQuotes($start_time); |
96 | 96 | return $dbr->selectField('mv_mvd_index', 'COUNT(*)', $cond, __METHOD__ ); |
97 | | - } |
98 | | - /* |
99 | | - * getMVDInRange returns the mvd titles that are in the given range |
100 | | - * param list got kind of crazy long... @@todo re-factor int a request object or something cleaner |
101 | | - */ |
102 | | - function getMVDInRange($stream_id, $start_time=null, $end_time=null, $mvd_type='all',$getText=false,$smw_properties='', $limit='200'){ |
103 | | - global $mvIndexTableName, $mvDefaultClipLength; |
104 | | - $dbr =& wfGetDB(DB_SLAVE); |
105 | | - //set up select vars: |
106 | | - $conds=$options=$vars=array(); |
107 | | - $from_tables =''; |
108 | | - // |
109 | | - //set mvd_type if empty: |
110 | | - if($mvd_type==null)$mvd_type='all'; |
111 | | - if($start_time<0)$start_time=0; |
112 | | - //add base select vars: |
113 | | - $vars= array('mv_page_id as id', 'mvd_type', 'wiki_title', 'stream_id', 'start_time', 'end_time'); |
114 | | - //add in base from: |
115 | | - $from_tables.= $dbr->tableName('mv_mvd_index'); |
116 | | - if($smw_properties!=''){ |
117 | | - if(!isset($options['STRAIGHT_JOIN'])) |
118 | | - $options['STRAIGHT_JOIN']=''; |
119 | | - if(!is_array($smw_properties)) |
120 | | - $smw_properties = explode(',',$smw_properties); |
121 | | - foreach($smw_properties as $prop_name){ |
122 | | - $vars[] = mysql_real_escape_string($prop_name).'.object_title as '.mysql_real_escape_string($prop_name); |
123 | | - $from_tables.=' LEFT JOIN '. $dbr->tableName('smw_relations') . |
124 | | - ' as ' . mysql_real_escape_string($prop_name) . |
125 | | - ' ON (' . $dbr->tableName('mv_mvd_index') . '.mv_page_id'. |
126 | | - ' = ' . mysql_real_escape_string($prop_name) . '.subject_id'. |
127 | | - ' AND '. mysql_real_escape_string($prop_name).'.relation_title'. |
128 | | - ' = ' . $dbr->addQuotes($prop_name) . ')'; |
129 | | - } |
130 | | - } |
131 | | - $conds = array('stream_id'=>$stream_id); |
132 | | - if($mvd_type!='all'){ |
133 | | - $mvd_type=(is_object($mvd_type))?get_object_vars($mvd_type):$mvd_type; |
134 | | - if(is_array($mvd_type)){ |
135 | | - $mvd_type_cond = ''; |
136 | | - foreach($mvd_type as $mtype){ |
| 97 | + } |
| 98 | + /* |
| 99 | + * getMVDInRange returns the mvd titles that are in the given range |
| 100 | + * param list got kind of crazy long... @@todo re-factor int a request object or something cleaner |
| 101 | + */ |
| 102 | + function getMVDInRange($stream_id, $start_time=null, $end_time=null, $mvd_type='all',$getText=false,$smw_properties='', $limit='200'){ |
| 103 | + global $mvIndexTableName, $mvDefaultClipLength; |
| 104 | + $dbr =& wfGetDB(DB_SLAVE); |
| 105 | + //set up select vars: |
| 106 | + $conds=$options=$vars=array(); |
| 107 | + $from_tables =''; |
| 108 | + // |
| 109 | + //set mvd_type if empty: |
| 110 | + if($mvd_type==null)$mvd_type='all'; |
| 111 | + if($start_time<0)$start_time=0; |
| 112 | + //add base select vars: |
| 113 | + $vars= array('mv_page_id as id', 'mvd_type', 'wiki_title', 'stream_id', 'start_time', 'end_time'); |
| 114 | + //add in base from: |
| 115 | + $from_tables.= $dbr->tableName('mv_mvd_index'); |
| 116 | + if($smw_properties!=''){ |
| 117 | + if(!isset($options['STRAIGHT_JOIN'])) |
| 118 | + $options['STRAIGHT_JOIN']=''; |
| 119 | + if(!is_array($smw_properties)) |
| 120 | + $smw_properties = explode(',',$smw_properties); |
| 121 | + foreach($smw_properties as $prop_name){ |
| 122 | + $vars[] = mysql_real_escape_string($prop_name).'.object_title as '.mysql_real_escape_string($prop_name); |
| 123 | + $from_tables.=' LEFT JOIN '. $dbr->tableName('smw_relations') . |
| 124 | + ' as ' . mysql_real_escape_string($prop_name) . |
| 125 | + ' ON (' . $dbr->tableName('mv_mvd_index') . '.mv_page_id'. |
| 126 | + ' = ' . mysql_real_escape_string($prop_name) . '.subject_id'. |
| 127 | + ' AND '. mysql_real_escape_string($prop_name).'.relation_title'. |
| 128 | + ' = ' . $dbr->addQuotes($prop_name) . ')'; |
| 129 | + } |
| 130 | + } |
| 131 | + $conds = array('stream_id'=>$stream_id); |
| 132 | + if($mvd_type!='all'){ |
| 133 | + $mvd_type=(is_object($mvd_type))?get_object_vars($mvd_type):$mvd_type; |
| 134 | + if(is_array($mvd_type)){ |
| 135 | + $mvd_type_cond = ''; |
| 136 | + foreach($mvd_type as $mtype){ |
137 | 137 | //@@todo confirm its a valid mvd_type: |
138 | | - $mvd_type_cond.= $or."mvd_type=".$dbr->addQuotes($mtype); |
| 138 | + $mvd_type_cond.= $or."mvd_type=".$dbr->addQuotes($mtype); |
139 | 139 | $or=' OR '; |
140 | | - } |
141 | | - $conds[] = $mvd_type_cond; |
142 | | - }else if(is_string($mvd_type)){ |
143 | | - $conds['mvd_type']=$mvd_type; |
144 | | - } |
145 | | - |
146 | | - } |
147 | | - if($end_time) |
148 | | - $conds[]='start_time <= '. $dbr->addQuotes($end_time); |
149 | | - if($start_time) |
150 | | - $conds[]='end_time >= '. $dbr->addQuotes($start_time); |
151 | | - |
152 | | - //add in ordering |
153 | | - $options['ORDER BY']= 'start_time ASC'; |
154 | | - //add in limit |
155 | | - $options['LIMIT'] = $limit; |
156 | | - //run query: |
157 | | - $result = $dbr->select( $from_tables, |
| 140 | + } |
| 141 | + $conds[] = $mvd_type_cond; |
| 142 | + }else if(is_string($mvd_type)){ |
| 143 | + $conds['mvd_type']=$mvd_type; |
| 144 | + } |
| 145 | + |
| 146 | + } |
| 147 | + if($end_time) |
| 148 | + $conds[]='start_time <= '. $dbr->addQuotes($end_time); |
| 149 | + if($start_time) |
| 150 | + $conds[]='end_time >= '. $dbr->addQuotes($start_time); |
| 151 | + |
| 152 | + //add in ordering |
| 153 | + $options['ORDER BY']= 'start_time ASC'; |
| 154 | + //add in limit |
| 155 | + $options['LIMIT'] = $limit; |
| 156 | + //run query: |
| 157 | + $result = $dbr->select( $from_tables, |
158 | 158 | $vars, |
159 | 159 | $conds, |
160 | | - __METHOD__, |
161 | | - $options); |
| 160 | + __METHOD__, |
| 161 | + $options); |
162 | 162 | //print $dbr->lastQuery(); |
163 | 163 | //die; |
164 | 164 | //echo $sql; |
165 | | - //$result =& $dbr->query( $sql, 'MV_Index:time_index_query'); |
166 | | - return $result; |
167 | | - } |
| 165 | + //$result =& $dbr->query( $sql, 'MV_Index:time_index_query'); |
| 166 | + return $result; |
| 167 | + } |
168 | 168 | /*@@todo figure another way to get at this data...this is not a very fast query: */ |
169 | | - function getMVDTypeInRange($stream_id, $start_time=null, $end_time=null){ |
170 | | - $dbr =& wfGetDB(DB_SLAVE); |
171 | | - //init vars |
172 | | - $from_tables=$vars= $conds= $options=array(); |
173 | | - |
174 | | - $from_tables = $dbr->tableName('mv_mvd_index'); |
175 | | - $vars = 'COUNT(*) as count, mvd_type'; |
176 | | - $conds = array('stream_id'=>$stream_id); |
177 | | - if($end_time) |
178 | | - $cond[] = ' AND start_time <= '. $dbr->addQuotes($end_time); |
179 | | - if($start_time) |
180 | | - $cond[] = ' AND end_time >= '. $dbr->addQuotes($start_time); |
181 | | - $options['GROUP BY'] = 'mvd_type'; |
182 | | - return $dbr->select( $from_tables, |
| 169 | + function getMVDTypeInRange($stream_id, $start_time=null, $end_time=null){ |
| 170 | + $dbr =& wfGetDB(DB_SLAVE); |
| 171 | + //init vars |
| 172 | + $from_tables=$vars= $conds= $options=array(); |
| 173 | + |
| 174 | + $from_tables = $dbr->tableName('mv_mvd_index'); |
| 175 | + $vars = 'COUNT(*) as count, mvd_type'; |
| 176 | + $conds = array('stream_id'=>$stream_id); |
| 177 | + if($end_time) |
| 178 | + $cond[] = ' AND start_time <= '. $dbr->addQuotes($end_time); |
| 179 | + if($start_time) |
| 180 | + $cond[] = ' AND end_time >= '. $dbr->addQuotes($start_time); |
| 181 | + $options['GROUP BY'] = 'mvd_type'; |
| 182 | + return $dbr->select( $from_tables, |
183 | 183 | $vars, |
184 | 184 | $conds, |
185 | | - __METHOD__, |
| 185 | + __METHOD__, |
186 | 186 | $options); ; |
187 | | - } |
188 | | - function remove_by_stream_id($stream_id){ |
189 | | - global $mvIndexTableName; |
190 | | - $dbw =& wfGetDB(DB_WRITE); |
191 | | - $dbw->delete($mvIndexTableName, array('stream_id'=>$stream_id)); |
192 | | - } |
193 | | - /* |
194 | | - * removes a single entry by wiki_title name |
195 | | - */ |
196 | | - function remove_by_wiki_title($wiki_title){ |
197 | | - global $mvIndexTableName; |
198 | | - $dbw =& wfGetDB(DB_WRITE); |
199 | | - $dbw->delete($mvIndexTableName, array('wiki_title'=>$wiki_title)); |
200 | | - //print "ran sql:" . $dbw->lastQuery() . "\n"; |
201 | | - return true; |
202 | | - } |
203 | | - /*function doUnifiedFiltersQuery(&$filters, $metaDataIncludes=null){ |
204 | | - global $wgRequest, $mvDo_SQL_CALC_FOUND_ROWS, $mvMediaSearchResultsLimit; |
205 | | - $dbr =& wfGetDB(DB_SLAVE); |
206 | | - //init vars |
207 | | - $from_tables=''; |
208 | | - $vars= $conds= $options=array(); |
209 | | - |
210 | | - //set options |
211 | | - if( $mvDo_SQL_CALC_FOUND_ROWS) |
212 | | - $options['SQL_CALC_FOUND_ROWS']=true; |
213 | | - //set limit offset: |
214 | | - list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset( 20, 'searchlimit' ); |
215 | | - if($this->limit > $mvMediaSearchResultsLimit)$this->limit = $mvMediaSearchResultsLimit; |
216 | | - $this->order = strtolower($wgRequest->getVal('order')); |
| 187 | + } |
| 188 | + function remove_by_stream_id($stream_id){ |
| 189 | + global $mvIndexTableName; |
| 190 | + $dbw =& wfGetDB(DB_WRITE); |
| 191 | + $dbw->delete($mvIndexTableName, array('stream_id'=>$stream_id)); |
| 192 | + } |
| 193 | + /* |
| 194 | + * removes a single entry by wiki_title name |
| 195 | + */ |
| 196 | + function remove_by_wiki_title($wiki_title){ |
| 197 | + global $mvIndexTableName; |
| 198 | + $dbw =& wfGetDB(DB_WRITE); |
| 199 | + $dbw->delete($mvIndexTableName, array('wiki_title'=>$wiki_title)); |
| 200 | + //print "ran sql:" . $dbw->lastQuery() . "\n"; |
| 201 | + return true; |
| 202 | + } |
| 203 | + /*function doUnifiedFiltersQuery(&$filters, $metaDataIncludes=null){ |
| 204 | + global $wgRequest, $mvDo_SQL_CALC_FOUND_ROWS, $mvMediaSearchResultsLimit; |
| 205 | + $dbr =& wfGetDB(DB_SLAVE); |
| 206 | + //init vars |
| 207 | + $from_tables=''; |
| 208 | + $vars= $conds= $options=array(); |
| 209 | + |
| 210 | + //set options |
| 211 | + if( $mvDo_SQL_CALC_FOUND_ROWS) |
| 212 | + $options['SQL_CALC_FOUND_ROWS']=true; |
| 213 | + //set limit offset: |
| 214 | + list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset( 20, 'searchlimit' ); |
| 215 | + if($this->limit > $mvMediaSearchResultsLimit)$this->limit = $mvMediaSearchResultsLimit; |
| 216 | + $this->order = strtolower($wgRequest->getVal('order')); |
217 | 217 | //force order type: |
218 | | - if( !($this->order=='relevent' || $this->order=='recent' || $this->order=='viewed') )$this->order='relevent'; |
219 | | - |
220 | | - foreach($filters as $f){ |
221 | | - $cur_cond=$aon=$asql=''; |
222 | | - //proocc and or for fulltext: |
223 | | - if(!isset($f['a']))$f['a']='and'; |
224 | | - switch($f['a']){ |
225 | | - case 'and':$aon='+';$asql='AND';break; |
226 | | - case 'or':$aon='';$asql='OR';break; |
227 | | - case 'not':$aon='-';$asql='NOT';break; |
228 | | - } |
229 | | - |
230 | | - } |
231 | | - |
232 | | - |
233 | | - $result = $dbr->select( $from_tables, |
| 218 | + if( !($this->order=='relevant' || $this->order=='recent' || $this->order=='viewed') )$this->order='relevant'; |
| 219 | + |
| 220 | + foreach($filters as $f){ |
| 221 | + $cur_cond=$aon=$asql=''; |
| 222 | + //proocc and or for fulltext: |
| 223 | + if(!isset($f['a']))$f['a']='and'; |
| 224 | + switch($f['a']){ |
| 225 | + case 'and':$aon='+';$asql='AND';break; |
| 226 | + case 'or':$aon='';$asql='OR';break; |
| 227 | + case 'not':$aon='-';$asql='NOT';break; |
| 228 | + } |
| 229 | + |
| 230 | + } |
| 231 | + |
| 232 | + |
| 233 | + $result = $dbr->select( $from_tables, |
234 | 234 | $vars, |
235 | 235 | $conds, |
236 | | - __METHOD__, |
237 | | - $options); |
238 | | - }*/ |
239 | | - |
240 | | - function doUnifiedFiltersQuery(&$filters, $metaDataIncludes=null){ |
241 | | - global $mvIndexTableName,$mvStreamFilesTable, $mvDefaultClipLength,$mvStreamTable, |
242 | | - $wgRequest, $mvDo_SQL_CALC_FOUND_ROWS, $mvMediaSearchResultsLimit; |
243 | | - |
244 | | - global $mvSpokenByInSearchResult, $mvCategoryInSearchResult, $mvBillInSearchResult; |
| 236 | + __METHOD__, |
| 237 | + $options); |
| 238 | + }*/ |
245 | 239 | |
246 | | - //init vars |
247 | | - $from_tables=''; |
248 | | - $vars= $conds= $options=array(); |
249 | | - //init top range generation query |
250 | | - $from_tables_top=''; |
251 | | - $vars_top= $conds_top= $options_top=array(); |
252 | | - |
253 | | - $do_top_range_query = false; |
254 | | - $date_range_join=true; |
255 | | - |
256 | | - $dbr =& wfGetDB(DB_SLAVE); |
257 | | - //organize the queries (group full-text searches and category/attributes) |
258 | | - //if the attribute is not a numerical just add it to the fulltext query |
259 | | - //$ftq_match_asql=$last_person_aon=$ftq_match=$ftq=$snq=$toplq_cat=$date_range_join=$date_range_where=$asql=''; //top query and full text query ='' |
260 | | - if($filters=='')return array(); |
261 | | - $ftq_match_asql=$date_cond=''; |
262 | | - |
263 | | - //$selOpt = ($mvDo_SQL_CALC_FOUND_ROWS)?'SQL_CALC_FOUND_ROWS':''; |
264 | | - if( $mvDo_SQL_CALC_FOUND_ROWS) |
265 | | - $options[]='SQL_CALC_FOUND_ROWS'; |
266 | | - |
267 | | - //set limit offset: |
268 | | - list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset( 20, 'searchlimit' ); |
269 | | - if($this->limit > $mvMediaSearchResultsLimit)$this->limit = $mvMediaSearchResultsLimit; |
270 | | - |
271 | | - $this->order = strtolower($wgRequest->getVal('order')); |
272 | | - //force order type: |
273 | | - if( !($this->order=='relevent' || $this->order=='recent' || $this->order=='viewed') )$this->order='relevent'; |
274 | | - |
| 240 | + function doUnifiedFiltersQuery(&$filters, $metaDataIncludes=null){ |
| 241 | + global $mvIndexTableName,$mvStreamFilesTable, $mvDefaultClipLength,$mvStreamTable, |
| 242 | + $wgRequest, $mvDo_SQL_CALC_FOUND_ROWS, $mvMediaSearchResultsLimit; |
275 | 243 | |
276 | | - $group_spoken=true; |
277 | | - //$categoryTable = ; |
278 | | - $valid_filter_count=0; |
279 | | - foreach($filters as $f){ |
280 | | - //proocc and or for fulltext: |
281 | | - if(!isset($f['a']))$f['a']='and'; |
282 | | - switch($f['a']){ |
283 | | - case 'and':$aon='+';$asql='AND';break; |
284 | | - case 'or':$aon='';$asql='OR';break; |
285 | | - case 'not':$aon='-';$asql='NOT';break; |
286 | | - } |
287 | | - //add to the fulltext query: |
288 | | - switch($f['t']){ |
289 | | - case 'spoken_by': |
290 | | - //skip if empty value: |
291 | | - if(trim($f['v'])=='')continue; |
292 | | - //if we have an OR set prev to OR |
293 | | - if($last_person_aon=='+' && $aon==''){ |
294 | | - $ftq=str_replace('+"spoken by', '"spoken by', $ftq); |
295 | | - $group_spoken=false; |
296 | | - } |
297 | | - //full text based semantic query: |
298 | | - $ftq.=' '.$aon.'"spoken by '. mysql_real_escape_string($f['v']).'" '; |
299 | | - //table based query: |
300 | | - $last_person_aon=$aon; |
301 | | - $valid_filter_count++; |
302 | | - //$conds[]= |
303 | | - break; |
304 | | - case 'match': |
305 | | - //skip if empty value: |
306 | | - if(trim($f['v'])=='')continue; |
307 | | - $ftq_match.=$aon.'"'.mysql_real_escape_string($f['v']).'"'; |
308 | | - //only need to split out ftq match if spoken by is more than one |
309 | | - if($ftq_match_asql!='') |
310 | | - $ftq_match_asql = $asql; |
311 | | - $valid_filter_count++; |
312 | | - break; |
313 | | - //top level queries (sets up time ranges ) |
314 | | - case 'category': |
315 | | - //skip if empty value: |
316 | | - if(trim($f['v'])=='')continue; |
317 | | - $do_top_range_query=true; |
318 | | - //full text based category query: |
319 | | - $toplq.=' '.$aon.'"category '.mysql_real_escape_string($f['v']).'" '; |
320 | | - //$ftq.=' '.$aon.'category:'.mysql_escape_string($f['v']); |
321 | | - |
322 | | - //table based query: |
323 | | - switch($f['a']){ |
324 | | - case 'and':$toplq_cat='AND';break; |
325 | | - case 'or':$toplq_cat='OR';break; |
326 | | - case 'not':$toplq_cat='NOT';break; |
327 | | - } |
328 | | - $toplq_cat.=$dbr->tableName( 'categorylinks').'.cl_to='.$dbr->addQuotes($f['v']); |
329 | | - $valid_filter_count++; |
330 | | - break; |
331 | | - case 'date_range': |
332 | | - $date_range_join = true; |
333 | | - list($month, $day, $year) = explode('/',$f['vs']); |
334 | | - $sts = mktime(0,0,0,$month, $day, $year); |
335 | | - list($month, $day, $year) = explode('/',$f['ve']); |
336 | | - $ets = mktime(0,0,0,$month, $day+1, $year); //(the start of the next day) |
337 | | - //add date condtion: |
338 | | - //note dissable and or for date range for now: $asql |
339 | | - $conds[] = ' ( `mv_streams`.`date_start_time` > ' |
340 | | - . $dbr->addQuotes($sts) . |
341 | | - ' AND `mv_streams`.`date_start_time` < '. $dbr->addQuotes($ets) . |
342 | | - ') '; |
343 | | - //print $date_cond; |
344 | | - $valid_filter_count++; |
345 | | - break; |
346 | | - case 'stream_name': |
347 | | - //skip if empty value: |
348 | | - if(trim($f['v'])=='')continue; |
349 | | - $stream =& mvGetMVStream($f['v']); |
350 | | - //add stream cond |
351 | | - $conds[]=$asql." stream_id = ". $dbr->addQuotes($stream->getStreamId()); |
352 | | - $valid_filter_count++; |
353 | | - break; |
354 | | - case 'smw_property': |
355 | | - //more complicated query work needed |
356 | | - break; |
357 | | - } |
358 | | - } |
| 244 | + global $mvSpokenByInSearchResult, $mvCategoryInSearchResult, $mvBillInSearchResult; |
| 245 | + |
| 246 | + //init vars |
| 247 | + $from_tables=''; |
| 248 | + $vars= $conds= $options=array(); |
| 249 | + //init top range generation query |
| 250 | + $from_tables_top=''; |
| 251 | + $vars_top= $conds_top= $options_top=array(); |
| 252 | + |
| 253 | + $do_top_range_query = false; |
| 254 | + $date_range_join=true; |
| 255 | + |
| 256 | + $dbr =& wfGetDB(DB_SLAVE); |
| 257 | + //organize the queries (group full-text searches and category/attributes) |
| 258 | + //if the attribute is not a numerical just add it to the fulltext query |
| 259 | + //$ftq_match_asql=$last_person_aon=$ftq_match=$ftq=$snq=$toplq_cat=$date_range_join=$date_range_where=$asql=''; //top query and full text query ='' |
| 260 | + if($filters=='')return array(); |
| 261 | + $ftq_match_asql=$date_cond=''; |
| 262 | + |
| 263 | + //$selOpt = ($mvDo_SQL_CALC_FOUND_ROWS)?'SQL_CALC_FOUND_ROWS':''; |
| 264 | + if( $mvDo_SQL_CALC_FOUND_ROWS) |
| 265 | + $options[]='SQL_CALC_FOUND_ROWS'; |
| 266 | + |
| 267 | + //set limit offset: |
| 268 | + list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset( 20, 'searchlimit' ); |
| 269 | + if($this->limit > $mvMediaSearchResultsLimit)$this->limit = $mvMediaSearchResultsLimit; |
| 270 | + |
| 271 | + $this->order = strtolower($wgRequest->getVal('order')); |
| 272 | + //force order type: |
| 273 | + if( !($this->order=='relevant' || $this->order=='recent' || $this->order=='viewed') )$this->order='relevant'; |
| 274 | + |
| 275 | + |
| 276 | + $group_spoken=true; |
| 277 | + //$categoryTable = ; |
| 278 | + $valid_filter_count=0; |
| 279 | + foreach($filters as $f){ |
| 280 | + //proocc and or for fulltext: |
| 281 | + if(!isset($f['a']))$f['a']='and'; |
| 282 | + switch($f['a']){ |
| 283 | + case 'and':$aon='+';$asql='AND';break; |
| 284 | + case 'or':$aon='';$asql='OR';break; |
| 285 | + case 'not':$aon='-';$asql='NOT';break; |
| 286 | + } |
| 287 | + //add to the fulltext query: |
| 288 | + switch($f['t']){ |
| 289 | + case 'spoken_by': |
| 290 | + //skip if empty value: |
| 291 | + if(trim($f['v'])=='')continue; |
| 292 | + //if we have an OR set prev to OR |
| 293 | + if($last_person_aon=='+' && $aon==''){ |
| 294 | + $ftq=str_replace('+"spoken by', '"spoken by', $ftq); |
| 295 | + $group_spoken=false; |
| 296 | + } |
| 297 | + //full text based semantic query: |
| 298 | + $ftq.=' '.$aon.'"spoken by '. mysql_real_escape_string($f['v']).'" '; |
| 299 | + //table based query: |
| 300 | + $last_person_aon=$aon; |
| 301 | + $valid_filter_count++; |
| 302 | + //$conds[]= |
| 303 | + break; |
| 304 | + case 'match': |
| 305 | + //skip if empty value: |
| 306 | + if(trim($f['v'])=='')continue; |
| 307 | + $ftq_match.=$aon.'"'.mysql_real_escape_string($f['v']).'"'; |
| 308 | + //only need to split out ftq match if spoken by is more than one |
| 309 | + if($ftq_match_asql!='') |
| 310 | + $ftq_match_asql = $asql; |
| 311 | + $valid_filter_count++; |
| 312 | + break; |
| 313 | + //top level queries (sets up time ranges ) |
| 314 | + case 'category': |
| 315 | + //skip if empty value: |
| 316 | + if(trim($f['v'])=='')continue; |
| 317 | + $do_top_range_query=true; |
| 318 | + //full text based category query: |
| 319 | + $toplq.=' '.$aon.'"category '.mysql_real_escape_string($f['v']).'" '; |
| 320 | + //$ftq.=' '.$aon.'category:'.mysql_escape_string($f['v']); |
| 321 | + |
| 322 | + //table based query: |
| 323 | + switch($f['a']){ |
| 324 | + case 'and':$toplq_cat='AND';break; |
| 325 | + case 'or':$toplq_cat='OR';break; |
| 326 | + case 'not':$toplq_cat='NOT';break; |
| 327 | + } |
| 328 | + $toplq_cat.=$dbr->tableName( 'categorylinks').'.cl_to='.$dbr->addQuotes($f['v']); |
| 329 | + $valid_filter_count++; |
| 330 | + break; |
| 331 | + case 'date_range': |
| 332 | + $date_range_join = true; |
| 333 | + list($month, $day, $year) = explode('/',$f['vs']); |
| 334 | + $sts = mktime(0,0,0,$month, $day, $year); |
| 335 | + list($month, $day, $year) = explode('/',$f['ve']); |
| 336 | + $ets = mktime(0,0,0,$month, $day+1, $year); //(the start of the next day) |
| 337 | + //add date condtion: |
| 338 | + //note dissable and or for date range for now: $asql |
| 339 | + $conds[] = ' ( `mv_streams`.`date_start_time` > ' |
| 340 | + . $dbr->addQuotes($sts) . |
| 341 | + ' AND `mv_streams`.`date_start_time` < '. $dbr->addQuotes($ets) . |
| 342 | + ') '; |
| 343 | + //print $date_cond; |
| 344 | + $valid_filter_count++; |
| 345 | + break; |
| 346 | + case 'stream_name': |
| 347 | + //skip if empty value: |
| 348 | + if(trim($f['v'])=='')continue; |
| 349 | + $stream =& mvGetMVStream($f['v']); |
| 350 | + //add stream cond |
| 351 | + $conds[]=$asql." stream_id = ". $dbr->addQuotes($stream->getStreamId()); |
| 352 | + $valid_filter_count++; |
| 353 | + break; |
| 354 | + case 'smw_property': |
| 355 | + //more complicated query work needed |
| 356 | + break; |
| 357 | + } |
| 358 | + } |
359 | 359 | if($valid_filter_count==0){ |
360 | 360 | return array(); |
361 | 361 | } |
362 | | - //add the top query to the base query: |
363 | | - $ftq.=$toplq; |
| 362 | + //add the top query to the base query: |
| 363 | + $ftq.=$toplq; |
364 | 364 | $vars = "mv_page_id as id,". $dbr->tableName('mv_mvd_index').'.stream_id, |
365 | 365 | ('.$dbr->tableName('mv_streams').'.date_start_time+'.$dbr->tableName('mv_mvd_index'). |
366 | | - '.start_time) AS mvd_date_start_time, '. |
| 366 | + '.start_time) AS mvd_date_start_time, '. |
367 | 367 | 'start_time, end_time, view_count, wiki_title,'. |
368 | | - $dbr->tableName( 'searchindex' ).'.si_text AS `text` '; |
369 | | - |
370 | | - if($mvSpokenByInSearchResult) |
371 | | - $vars.=', smw_relations.object_title as spoken_by '; |
372 | | - |
373 | | - $from_tables.=$dbr->tableName('mv_mvd_index') . ' '; |
374 | | - $from_tables.='JOIN '.$dbr->tableName( 'searchindex' ). |
375 | | - ' ON (' . |
376 | | - $dbr->tableName('mv_mvd_index').'.mv_page_id = '. |
377 | | - $dbr->tableName( 'searchindex' ).'.si_page ) '; |
378 | | - |
379 | | - if($date_range_join) |
380 | | - $from_tables.='LEFT JOIN '. $dbr->tableName('mv_streams'). |
381 | | - ' ON (' . |
382 | | - $dbr->tableName('mv_mvd_index').'.stream_id = ' . |
383 | | - $dbr->tableName('mv_streams').'.id ) '; |
384 | | - |
385 | | - |
386 | | - //restrict to streams with valid $mvDefaultVideoQualityKey files: |
| 368 | + $dbr->tableName( 'searchindex' ).'.si_text AS `text` '; |
| 369 | + |
| 370 | + if($mvSpokenByInSearchResult) |
| 371 | + $vars.=', smw_relations.object_title as spoken_by '; |
| 372 | + |
| 373 | + $from_tables.=$dbr->tableName('mv_mvd_index') . ' '; |
| 374 | + $from_tables.='JOIN '.$dbr->tableName( 'searchindex' ). |
| 375 | + ' ON (' . |
| 376 | + $dbr->tableName('mv_mvd_index').'.mv_page_id = '. |
| 377 | + $dbr->tableName( 'searchindex' ).'.si_page ) '; |
| 378 | + |
| 379 | + if($date_range_join) |
| 380 | + $from_tables.='LEFT JOIN '. $dbr->tableName('mv_streams'). |
| 381 | + ' ON (' . |
| 382 | + $dbr->tableName('mv_mvd_index').'.stream_id = ' . |
| 383 | + $dbr->tableName('mv_streams').'.id ) '; |
| 384 | + |
| 385 | + |
| 386 | + //restrict to streams with valid $mvDefaultVideoQualityKey files: |
387 | 387 | global $mvDefaultVideoQualityKey; |
388 | | - $from_tables.= 'JOIN '. $dbr->tableName('mv_stream_files'). |
389 | | - ' ON ' . |
390 | | - '( '.$dbr->tableName('mv_mvd_index').'.stream_id = '. |
391 | | - $dbr->tableName('mv_stream_files').'.stream_id '. |
392 | | - ' AND '. $dbr->tableName('mv_stream_files').'.file_desc_msg = '. |
393 | | - $dbr->addQuotes($mvDefaultVideoQualityKey). |
394 | | - ') '; |
| 388 | + $from_tables.= 'JOIN '. $dbr->tableName('mv_stream_files'). |
| 389 | + ' ON ' . |
| 390 | + '( '.$dbr->tableName('mv_mvd_index').'.stream_id = '. |
| 391 | + $dbr->tableName('mv_stream_files').'.stream_id '. |
| 392 | + ' AND '. $dbr->tableName('mv_stream_files').'.file_desc_msg = '. |
| 393 | + $dbr->addQuotes($mvDefaultVideoQualityKey). |
| 394 | + ') '; |
395 | 395 | |
396 | | - //date range join: |
397 | | - |
| 396 | + //date range join: |
| 397 | + |
398 | 398 | //include spoken by relation in results (LEFT JOIN should not be *that* costly ) |
399 | 399 | if($mvSpokenByInSearchResult){ |
400 | 400 | /*$sql.="LEFT JOIN `smw_relations` ON (`mv_mvd_index`.`mv_page_id`=`smw_relations`.`subject_id` " . |
— | — | @@ -402,43 +402,43 @@ |
403 | 403 | ' ON ' . |
404 | 404 | '( '.$dbr->tableName('mv_mvd_index').'.mv_page_id = '. |
405 | 405 | $dbr->tableName('smw_relations').'.subject_id '. |
406 | | - ' AND '.$dbr->tableName('smw_relations').'.relation_title = \'Spoken_By\''. |
| 406 | + ' AND '.$dbr->tableName('smw_relations').'.relation_title = \'Spoken_By\''. |
407 | 407 | ') '; |
408 | 408 | } |
409 | | - //$sql.="WHERE "; |
| 409 | + //$sql.="WHERE "; |
410 | 410 | //$sql.=" ( `{$mvIndexTableName}`.`mvd_type`='ht_en' OR `{$mvIndexTableName}`.`mvd_type`='anno_en') AND" ; |
411 | 411 | |
412 | | - //add conditions to last condition element (cuz we have to manually mannage and or): |
413 | | - |
414 | | - $conds[count($conds)]= ' '.$dbr->tableName('mv_mvd_index') . '.mvd_type = \'ht_en\' '. |
415 | | - ' OR '. $dbr->tableName('mv_mvd_index') . '.mvd_type=\'anno_en\' '; |
416 | | - |
417 | | - //limit to ht_en & anno_en (for now) (future allow selection |
418 | | - //$conds_inx = (count($conds)==0)?0:count($conds)-1; |
419 | | - $two_part_anor=''; |
420 | | - if($group_spoken){ |
421 | | - $ftq.=$ftq_match; |
422 | | - }else{ |
423 | | - if($ftq_match!=''){ |
424 | | - $conds[].=$ftq_match_asql.' MATCH ( '. $dbr->tableName( 'searchindex' ).'.si_text )'. |
425 | | - ' AGAINST(\''.$ftq_match.'\' IN BOOLEAN MODE) '; |
426 | | - //if($ftq!='')$sql.=' AND '; |
427 | | - } |
428 | | - } |
429 | | - if($ftq!=''){ |
430 | | - $conds[].=" MATCH ( ".$dbr->tableName( 'searchindex' ).'.si_text ) '. |
431 | | - ' AGAINST(\''.$ftq.'\' IN BOOLEAN MODE) '; |
432 | | - } |
433 | | - //print_r($conds); |
| 412 | + //add conditions to last condition element (cuz we have to manually mannage and or): |
| 413 | + |
| 414 | + $conds[count($conds)]= ' '.$dbr->tableName('mv_mvd_index') . '.mvd_type = \'ht_en\' '. |
| 415 | + ' OR '. $dbr->tableName('mv_mvd_index') . '.mvd_type=\'anno_en\' '; |
| 416 | + |
| 417 | + //limit to ht_en & anno_en (for now) (future allow selection |
| 418 | + //$conds_inx = (count($conds)==0)?0:count($conds)-1; |
| 419 | + $two_part_anor=''; |
| 420 | + if($group_spoken){ |
| 421 | + $ftq.=$ftq_match; |
| 422 | + }else{ |
| 423 | + if($ftq_match!=''){ |
| 424 | + $conds[].=$ftq_match_asql.' MATCH ( '. $dbr->tableName( 'searchindex' ).'.si_text )'. |
| 425 | + ' AGAINST(\''.$ftq_match.'\' IN BOOLEAN MODE) '; |
| 426 | + //if($ftq!='')$sql.=' AND '; |
| 427 | + } |
| 428 | + } |
| 429 | + if($ftq!=''){ |
| 430 | + $conds[].=" MATCH ( ".$dbr->tableName( 'searchindex' ).'.si_text ) '. |
| 431 | + ' AGAINST(\''.$ftq.'\' IN BOOLEAN MODE) '; |
| 432 | + } |
| 433 | + //print_r($conds); |
434 | 434 | //die; |
435 | | - //date range stuff is SLOW when its the only filter (pulls up matches for everything) |
436 | | - /*if($snq!='' || $ftq!='' && isset($date_range_andor)) |
437 | | - $sql.=$date_range_andor; |
438 | | - $sql.=" $date_range_where ";*/ |
439 | | - |
| 435 | + //date range stuff is SLOW when its the only filter (pulls up matches for everything) |
| 436 | + /*if($snq!='' || $ftq!='' && isset($date_range_andor)) |
| 437 | + $sql.=$date_range_andor; |
| 438 | + $sql.=" $date_range_where ";*/ |
| 439 | + |
440 | 440 | switch($this->order){ |
441 | | - case 'relevent': |
442 | | - //@@todo need to add in some relevence metrics |
| 441 | + case 'relevant': |
| 442 | + //@@todo need to add in some relevence metrics |
443 | 443 | break; |
444 | 444 | case 'recent': |
445 | 445 | $options['ORDER BY']='mvd_date_start_time DESC '; |
— | — | @@ -447,564 +447,563 @@ |
448 | 448 | $options['ORDER BY']='view_count DESC '; |
449 | 449 | break; |
450 | 450 | } |
451 | | - //echo $this->order; |
| 451 | + //echo $this->order; |
452 | 452 | //$sql.="LIMIT {$this->offset}, {$this->limit} "; |
453 | 453 | $options['LIMIT']=$this->limit; |
454 | 454 | $options['OFFSET']=$this->offset; |
455 | | - |
456 | | - $result = $dbr->select( $from_tables, |
| 455 | + |
| 456 | + $result = $dbr->select( $from_tables, |
457 | 457 | $vars, |
458 | 458 | $conds, |
459 | | - __METHOD__, |
460 | | - $options); |
461 | | - |
462 | | - //echo "SQL:".$dbr->lastQuery($result)." \n"; |
| 459 | + __METHOD__, |
| 460 | + $options); |
| 461 | + |
| 462 | + //echo "SQL:".$dbr->lastQuery($result)." \n"; |
463 | 463 | //die; |
464 | | - //$result = $dbr->query($sql, 'MV_Index:doFiltersQuery_base'); |
465 | | - |
466 | | - $this->numResults=$dbr->numRows($result); |
467 | | - if($dbr->numRows($result)==0) return array(); |
468 | | - |
469 | | - if($mvDo_SQL_CALC_FOUND_ROWS){ |
470 | | - $resFound = $dbr->query('SELECT FOUND_ROWS() as `count`;'); |
471 | | - $found = $dbr->fetchObject( $resFound ); |
472 | | - $this->numResultsFound = $found->count; |
473 | | - }else{ |
474 | | - $this->numResultsFound =null; |
475 | | - } |
476 | | - |
477 | | - //@@TODO hide empty categories (if limit > rows found ) |
478 | | - //while($row = $dbr->fetchObject( $result )){ |
479 | | - // $ret_ary[]=$row; |
480 | | - //} |
481 | | - //return $ret_ary; |
482 | | - //group by stream_name & time range: |
| 464 | + //$result = $dbr->query($sql, 'MV_Index:doFiltersQuery_base'); |
483 | 465 | |
484 | | - //init ret_ary & stream_group |
485 | | - $ret_ary = $stream_groups = array(); |
486 | | - while($row = $dbr->fetchObject( $result )){ |
487 | | - $ret_ary[$row->id]=$row; |
488 | | - if(!isset($stream_groups[$row->stream_id])){ |
489 | | - $stream_groups[$row->stream_id]=array(); |
490 | | - } |
491 | | - if(count($stream_groups[$row->stream_id])==0){ |
492 | | - $new_srange = array('s'=>$row->start_time, |
| 466 | + $this->numResults=$dbr->numRows($result); |
| 467 | + if($dbr->numRows($result)==0) return array(); |
| 468 | + |
| 469 | + if($mvDo_SQL_CALC_FOUND_ROWS){ |
| 470 | + $resFound = $dbr->query('SELECT FOUND_ROWS() as `count`;'); |
| 471 | + $found = $dbr->fetchObject( $resFound ); |
| 472 | + $this->numResultsFound = $found->count; |
| 473 | + }else{ |
| 474 | + $this->numResultsFound =null; |
| 475 | + } |
| 476 | + |
| 477 | + //@@TODO hide empty categories (if limit > rows found ) |
| 478 | + //while($row = $dbr->fetchObject( $result )){ |
| 479 | + // $ret_ary[]=$row; |
| 480 | + //} |
| 481 | + //return $ret_ary; |
| 482 | + //group by stream_name & time range: |
| 483 | + |
| 484 | + //init ret_ary & stream_group |
| 485 | + $ret_ary = $stream_groups = array(); |
| 486 | + while($row = $dbr->fetchObject( $result )){ |
| 487 | + $ret_ary[$row->id]=$row; |
| 488 | + if(!isset($stream_groups[$row->stream_id])){ |
| 489 | + $stream_groups[$row->stream_id]=array(); |
| 490 | + } |
| 491 | + if(count($stream_groups[$row->stream_id])==0){ |
| 492 | + $new_srange = array('s'=>$row->start_time, |
493 | 493 | 'e'=> $row->end_time, |
494 | 494 | 'rows'=>array($row)); |
495 | | - $stream_groups[$row->stream_id][]=$new_srange; |
496 | | - }else{ |
497 | | - MV_Index::insert_merge_range($stream_groups[$row->stream_id], $stream_groups, $row); |
498 | | - } |
499 | | - } |
500 | | - //print "<pre>"; |
501 | | - //print_r($ret_ary); |
502 | | - //die; |
503 | | - //throw out empty top level ranges |
504 | | - /*foreach($ret_ary as &$stream_set){ |
505 | | - foreach($stream_set as $k=> &$srange){ |
506 | | - if(count($srange['rows'])==0){ |
507 | | - //print "throw out: ". $srange['s'] . $srange['e']; |
508 | | - unset($stream_set[$k]); |
509 | | - } |
510 | | - } |
511 | | - }*/ |
512 | | - //do category & bill lookup for search result ranges |
513 | | - if($mvCategoryInSearchResult || $mvBillInSearchResult){ |
514 | | - $from_tables=$conds=''; |
515 | | - $vars= $options=array(); |
516 | | - |
517 | | - //set up selected vars: |
518 | | - $vars[]=$dbr->tableName('categorylinks').'.cl_to'; |
519 | | - $vars[]=$dbr->tableName('mv_mvd_index').'.stream_id'; |
520 | | - $vars[]=$dbr->tableName('mv_mvd_index').'.start_time'; |
| 495 | + $stream_groups[$row->stream_id][]=$new_srange; |
| 496 | + }else{ |
| 497 | + MV_Index::insert_merge_range($stream_groups[$row->stream_id], $stream_groups, $row); |
| 498 | + } |
| 499 | + } |
| 500 | + //print "<pre>"; |
| 501 | + //print_r($ret_ary); |
| 502 | + //die; |
| 503 | + //throw out empty top level ranges |
| 504 | + /*foreach($ret_ary as &$stream_set){ |
| 505 | + foreach($stream_set as $k=> &$srange){ |
| 506 | + if(count($srange['rows'])==0){ |
| 507 | + //print "throw out: ". $srange['s'] . $srange['e']; |
| 508 | + unset($stream_set[$k]); |
| 509 | + } |
| 510 | + } |
| 511 | + }*/ |
| 512 | + //do category & bill lookup for search result ranges |
| 513 | + if($mvCategoryInSearchResult || $mvBillInSearchResult){ |
| 514 | + $from_tables=$conds=''; |
| 515 | + $vars= $options=array(); |
| 516 | + |
| 517 | + //set up selected vars: |
| 518 | + $vars[]=$dbr->tableName('categorylinks').'.cl_to'; |
| 519 | + $vars[]=$dbr->tableName('mv_mvd_index').'.stream_id'; |
| 520 | + $vars[]=$dbr->tableName('mv_mvd_index').'.start_time'; |
521 | 521 | $vars[]=$dbr->tableName('mv_mvd_index').'.end_time'; |
522 | 522 | $vars[]=$dbr->tableName('smw_relations').'.object_title as bill_to '; |
523 | | - |
| 523 | + |
524 | 524 | //set up from_tables |
525 | | - $from_tables.=$dbr->tableName('mv_mvd_index') . |
| 525 | + $from_tables.=$dbr->tableName('mv_mvd_index') . |
526 | 526 | ' LEFT JOIN '.$dbr->tableName('categorylinks') . |
527 | | - ' ON ( ' . |
528 | | - $dbr->tableName('mv_mvd_index').'.mv_page_id = ' . |
| 527 | + ' ON ( ' . |
| 528 | + $dbr->tableName('mv_mvd_index').'.mv_page_id = ' . |
529 | 529 | $dbr->tableName('categorylinks').'.cl_from ' . |
530 | | - ' ) ' . |
| 530 | + ' ) ' . |
531 | 531 | ' LEFT JOIN '. $dbr->tableName('smw_relations') . |
532 | | - ' ON ( ' . |
533 | | - $dbr->tableName('mv_mvd_index').'.mv_page_id = ' . |
| 532 | + ' ON ( ' . |
| 533 | + $dbr->tableName('mv_mvd_index').'.mv_page_id = ' . |
534 | 534 | $dbr->tableName('smw_relations').'.subject_id '. |
535 | 535 | ' AND ' . |
536 | 536 | $dbr->tableName('smw_relations').'.relation_title=\'bill\' '. |
537 | | - ' ) '; |
| 537 | + ' ) '; |
538 | 538 | //generate stream_id, range sets |
539 | | - $conds.= $dbr->tableName('mv_mvd_index').'.mvd_type=\'Anno_en\' ' . |
| 539 | + $conds.= $dbr->tableName('mv_mvd_index').'.mvd_type=\'Anno_en\' ' . |
540 | 540 | ' AND ('; |
541 | 541 | $or=''; |
542 | 542 | foreach($stream_groups as $stream_id=>$rangeSet){ |
543 | | - foreach($rangeSet as $range){ |
| 543 | + foreach($rangeSet as $range){ |
544 | 544 | $conds.= $or . ' ( '.$dbr->tableName('mv_mvd_index').'.stream_id ='. |
545 | | - $dbr->addQuotes($stream_id); |
| 545 | + $dbr->addQuotes($stream_id); |
546 | 546 | $conds.=" AND `start_time` <= " . $dbr->addQuotes($range['s']).""; |
547 | 547 | $conds.=" AND `end_time` >= " . $dbr->addQuotes($range['e']) . ' ) '; |
548 | | - $or = ' OR '; |
549 | | - |
| 548 | + $or = ' OR '; |
| 549 | + |
550 | 550 | } |
551 | | - } |
552 | | - $conds.=' ) '; |
| 551 | + } |
| 552 | + $conds.=' ) '; |
553 | 553 | $options['LIMIT']=200; |
554 | | - |
555 | | - $result = $dbr->select( $from_tables, |
| 554 | + |
| 555 | + $result = $dbr->select( $from_tables, |
556 | 556 | $vars, |
557 | 557 | $conds, |
558 | | - __METHOD__, |
559 | | - $options); |
| 558 | + __METHOD__, |
| 559 | + $options); |
560 | 560 | //print "BEFORE merge: "; |
561 | 561 | //print_r($ret_ary); |
562 | 562 | //print_r($stream_groups); |
563 | | - |
564 | | - //merge category info back into base results: |
| 563 | + |
| 564 | + //merge category info back into base results: |
565 | 565 | //$result = $dbr->query($sql, 'MV_Index:doCategorySearchResult'); |
566 | 566 | while($cl_row = $dbr->fetchObject( $result )){ |
567 | | - //print_r($cl_row); |
568 | | - foreach($stream_groups[$cl_row->stream_id] as &$range){ |
| 567 | + //print_r($cl_row); |
| 568 | + foreach($stream_groups[$cl_row->stream_id] as &$range){ |
569 | 569 | foreach($range['rows'] as &$result_row){ |
570 | | - if($result_row->start_time <= $cl_row->end_time && |
| 570 | + if($result_row->start_time <= $cl_row->end_time && |
571 | 571 | $result_row->end_time >= $cl_row->start_time){ |
572 | | - //print "result row:"; print_r($result_row); |
573 | | - if(isset($cl_row->cl_to) && isset($ret_ary[$result_row->id])) |
| 572 | + //print "result row:"; print_r($result_row); |
| 573 | + if(isset($cl_row->cl_to) && isset($ret_ary[$result_row->id])) |
574 | 574 | $ret_ary[$result_row->id]->categories[$cl_row->cl_to]=true; |
575 | 575 | if(isset($cl_row->bill_to) && isset($ret_ary[$result_row->id])) |
576 | 576 | $ret_ary[$result_row->id]->bills[$cl_row->bill_to]=true; |
577 | | - } |
| 577 | + } |
578 | 578 | } |
579 | 579 | } |
580 | 580 | } |
581 | 581 | //print "AFTER MERGE: "; |
582 | 582 | //print_r($ret_ary); |
583 | | - } |
584 | | - //print "<pre>"; |
585 | | - //print_r($ret_ary); |
586 | | - //die; |
587 | | - return $ret_ary; |
588 | | - } |
589 | | - /* do filter query with stream grouping */ |
590 | | - /*function doFiltersQuery(&$filters, $metaDataIncludes=null){ |
591 | | - global $mvIndexTableName,$mvStreamFilesTable, $mvDefaultClipLength, |
592 | | - $wgRequest, $mvDo_SQL_CALC_FOUND_ROWS, $mvMediaSearchResultsLimit; |
593 | | - |
594 | | - global $mvSpokenByInSearchResult, $mvCategoryInSearchResult, $mvBillInSearchResult; |
595 | | - |
596 | | - $dbr =& wfGetDB(DB_SLAVE); |
597 | | - //organize the queries (group full-text searches and category/attributes) |
598 | | - //if the attribute is not a numerical just add it to the fulltext query |
599 | | - $ftq_match_asql=$last_person_aon=$ftq_match=$ftq=$snq=$toplq_cat=$date_range_join=$date_range_where=$asql=''; //top query and full text query ='' |
600 | | - if($filters=='')return array(); |
601 | | - |
602 | | - $selOpt = ($mvDo_SQL_CALC_FOUND_ROWS)?'SQL_CALC_FOUND_ROWS':''; |
603 | | - |
604 | | - list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset( 20, 'searchlimit' ); |
605 | | - if($this->limit > $mvMediaSearchResultsLimit)$this->limit = $mvMediaSearchResultsLimit; |
| 583 | + } |
| 584 | + //print "<pre>"; |
| 585 | + //print_r($ret_ary); |
| 586 | + //die; |
| 587 | + return $ret_ary; |
| 588 | + } |
| 589 | + /* do filter query with stream grouping */ |
| 590 | + /*function doFiltersQuery(&$filters, $metaDataIncludes=null){ |
| 591 | + global $mvIndexTableName,$mvStreamFilesTable, $mvDefaultClipLength, |
| 592 | + $wgRequest, $mvDo_SQL_CALC_FOUND_ROWS, $mvMediaSearchResultsLimit; |
606 | 593 | |
607 | | - $group_spoken=true; |
608 | | - $categoryTable = $dbr->tableName( 'categorylinks'); |
609 | | - foreach($filters as $f){ |
610 | | - //proocc and or for fulltext: |
611 | | - if(!isset($f['a']))$f['a']='and'; |
612 | | - switch($f['a']){ |
613 | | - case 'and':$aon='+';$asql='AND';break; |
614 | | - case 'or':$aon='';$asql='OR';break; |
615 | | - case 'not':$aon='-';$asql='NOT';break; |
616 | | - } |
617 | | - //add to the fulltext query: |
618 | | - switch($f['t']){ |
619 | | - case 'spoken_by': |
620 | | - //if we have an OR set prev to OR |
621 | | - if($last_person_aon=='+' && $aon==''){ |
622 | | - $ftq=str_replace('+"spoken by', '"spoken by', $ftq); |
623 | | - $group_spoken=false; |
624 | | - } |
625 | | - //full text based semantic query: |
626 | | - $ftq.=' '.$aon.'"spoken by '.mysql_escape_string($f['v']).'"'; |
627 | | - //table based query: |
628 | | - $last_person_aon=$aon; |
629 | | - break; |
630 | | - case 'match': |
631 | | - $ftq_match.=' '.$aon.'"'.mysql_escape_string($f['v']).'"'; |
632 | | - //only need to split out ftq match if spoken by is more than one |
633 | | - if($ftq_match_asql!='') |
634 | | - $ftq_match_asql = $asql; |
635 | | - break; |
636 | | - //top level queries (sets up time ranges ) |
637 | | - case 'category': |
638 | | - //full text based category query: |
639 | | - $toplq.=' '.$aon.'"category '.mysql_escape_string($f['v']).'" '; |
640 | | - //$ftq.=' '.$aon.'category:'.mysql_escape_string($f['v']); |
641 | | - |
642 | | - //table based query: |
643 | | - switch($f['a']){ |
644 | | - case 'and':$toplq_cat='AND';break; |
645 | | - case 'or':$toplq_cat='OR';break; |
646 | | - case 'not':$toplq_cat='NOT';break; |
647 | | - } |
648 | | - $toplq_cat.=" $categoryTable.`cl_to`='".mysql_escape_string($f['v'])."'"; |
649 | | - break; |
650 | | - case 'date_range': |
651 | | - $date_range_join = ' JOIN `mv_streams` ' . |
652 | | - 'ON `'.$mvIndexTableName.'`.`stream_id` =`mv_streams`.`id` '; |
653 | | - |
654 | | - list($month, $day, $year) = explode('/',$f['vs']); |
655 | | - $sts = mktime(0,0,0,$month, $day, $year); |
656 | | - list($month, $day, $year) = explode('/',$f['ve']); |
657 | | - $ets = mktime(0,0,0,$month, $day+1, $year); //(the start of the next day) |
658 | | - $date_range_where.= '( `mv_streams`.`date_start_time` > ' |
659 | | - . mysql_escape_string($sts) . |
660 | | - ' AND `mv_streams`.`date_start_time` < '. mysql_escape_string($ets) . |
| 594 | + global $mvSpokenByInSearchResult, $mvCategoryInSearchResult, $mvBillInSearchResult; |
| 595 | + |
| 596 | + $dbr =& wfGetDB(DB_SLAVE); |
| 597 | + //organize the queries (group full-text searches and category/attributes) |
| 598 | + //if the attribute is not a numerical just add it to the fulltext query |
| 599 | + $ftq_match_asql=$last_person_aon=$ftq_match=$ftq=$snq=$toplq_cat=$date_range_join=$date_range_where=$asql=''; //top query and full text query ='' |
| 600 | + if($filters=='')return array(); |
| 601 | + |
| 602 | + $selOpt = ($mvDo_SQL_CALC_FOUND_ROWS)?'SQL_CALC_FOUND_ROWS':''; |
| 603 | + |
| 604 | + list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset( 20, 'searchlimit' ); |
| 605 | + if($this->limit > $mvMediaSearchResultsLimit)$this->limit = $mvMediaSearchResultsLimit; |
| 606 | + |
| 607 | + $group_spoken=true; |
| 608 | + $categoryTable = $dbr->tableName( 'categorylinks'); |
| 609 | + foreach($filters as $f){ |
| 610 | + //proocc and or for fulltext: |
| 611 | + if(!isset($f['a']))$f['a']='and'; |
| 612 | + switch($f['a']){ |
| 613 | + case 'and':$aon='+';$asql='AND';break; |
| 614 | + case 'or':$aon='';$asql='OR';break; |
| 615 | + case 'not':$aon='-';$asql='NOT';break; |
| 616 | + } |
| 617 | + //add to the fulltext query: |
| 618 | + switch($f['t']){ |
| 619 | + case 'spoken_by': |
| 620 | + //if we have an OR set prev to OR |
| 621 | + if($last_person_aon=='+' && $aon==''){ |
| 622 | + $ftq=str_replace('+"spoken by', '"spoken by', $ftq); |
| 623 | + $group_spoken=false; |
| 624 | + } |
| 625 | + //full text based semantic query: |
| 626 | + $ftq.=' '.$aon.'"spoken by '.mysql_escape_string($f['v']).'"'; |
| 627 | + //table based query: |
| 628 | + $last_person_aon=$aon; |
| 629 | + break; |
| 630 | + case 'match': |
| 631 | + $ftq_match.=' '.$aon.'"'.mysql_escape_string($f['v']).'"'; |
| 632 | + //only need to split out ftq match if spoken by is more than one |
| 633 | + if($ftq_match_asql!='') |
| 634 | + $ftq_match_asql = $asql; |
| 635 | + break; |
| 636 | + //top level queries (sets up time ranges ) |
| 637 | + case 'category': |
| 638 | + //full text based category query: |
| 639 | + $toplq.=' '.$aon.'"category '.mysql_escape_string($f['v']).'" '; |
| 640 | + //$ftq.=' '.$aon.'category:'.mysql_escape_string($f['v']); |
| 641 | + |
| 642 | + //table based query: |
| 643 | + switch($f['a']){ |
| 644 | + case 'and':$toplq_cat='AND';break; |
| 645 | + case 'or':$toplq_cat='OR';break; |
| 646 | + case 'not':$toplq_cat='NOT';break; |
| 647 | + } |
| 648 | + $toplq_cat.=" $categoryTable.`cl_to`='".mysql_escape_string($f['v'])."'"; |
| 649 | + break; |
| 650 | + case 'date_range': |
| 651 | + $date_range_join = ' JOIN `mv_streams` ' . |
| 652 | + 'ON `'.$mvIndexTableName.'`.`stream_id` =`mv_streams`.`id` '; |
| 653 | + |
| 654 | + list($month, $day, $year) = explode('/',$f['vs']); |
| 655 | + $sts = mktime(0,0,0,$month, $day, $year); |
| 656 | + list($month, $day, $year) = explode('/',$f['ve']); |
| 657 | + $ets = mktime(0,0,0,$month, $day+1, $year); //(the start of the next day) |
| 658 | + $date_range_where.= '( `mv_streams`.`date_start_time` > ' |
| 659 | + . mysql_escape_string($sts) . |
| 660 | + ' AND `mv_streams`.`date_start_time` < '. mysql_escape_string($ets) . |
661 | 661 | ')'; |
662 | 662 | $date_range_andor = ' '.$asql.' '; |
663 | | - break; |
664 | | - case 'stream_name': |
665 | | - if($snq!=''){ |
| 663 | + break; |
| 664 | + case 'stream_name': |
| 665 | + if($snq!=''){ |
666 | 666 | switch($f['a']){ |
667 | | - case 'and':$snq='AND';break; |
668 | | - case 'or':$snq='OR';break; |
669 | | - case 'not':$snq='NOT';break; |
670 | | - } |
671 | | - } |
672 | | - //get stream name: |
673 | | - //print "f: " . $f['v']; |
674 | | - $stream =& mvGetMVStream($f['v']); |
675 | | - $snq.=" `stream_id` = {$stream->getStreamId()} "; |
676 | | - break; |
677 | | - case 'smw_property': |
678 | | - //more complicated query work needed ;) |
679 | | - break; |
680 | | - } |
681 | | - } |
682 | | - $searchindexTable = $dbr->tableName( 'searchindex' ); |
683 | | - $ret_ary = array(); |
684 | | - //a join operation to restrict search results to streams with files |
685 | | - $join_streams_with_low_ogg_sql = "JOIN `$mvStreamFilesTable` ON (`$mvIndexTableName`.`stream_id` = `$mvStreamFilesTable`.`stream_id` AND `$mvStreamFilesTable`.`file_desc_msg`='mv_ogg_low_quality') "; |
686 | | - //only run the top range query if we have no secondary query |
687 | | - if($toplq_cat!='' && $ftq==''){ |
688 | | - //@@todo unify top query with rannged query ... kind of tricky |
689 | | - |
690 | | - //@@todo we should only look in annotative layer for top level queries? ... |
691 | | - //@@todo paging for top level queries? ... 200 hit limit is probably ok |
692 | | - |
693 | | - $sql = "SELECT `mv_page_id` as `id`, `$mvIndexTableName`.`stream_id`,`$mvIndexTableName`.`start_time`,`$mvIndexTableName`.`end_time`,`$mvIndexTableName`.`view_count`, `wiki_title`, $searchindexTable.`si_text` as `text` |
694 | | - FROM `$mvIndexTableName` |
695 | | - $date_range_join |
696 | | - JOIN $categoryTable ON `$mvIndexTableName`.`mv_page_id` = $categoryTable.`cl_from` |
697 | | - $join_streams_with_low_ogg_sql |
698 | | - LEFT JOIN $searchindexTable ON `$mvIndexTableName`.`mv_page_id` = $searchindexTable.`si_page` |
699 | | - WHERE |
| 667 | + case 'and':$snq='AND';break; |
| 668 | + case 'or':$snq='OR';break; |
| 669 | + case 'not':$snq='NOT';break; |
| 670 | + } |
| 671 | + } |
| 672 | + //get stream name: |
| 673 | + //print "f: " . $f['v']; |
| 674 | + $stream =& mvGetMVStream($f['v']); |
| 675 | + $snq.=" `stream_id` = {$stream->getStreamId()} "; |
| 676 | + break; |
| 677 | + case 'smw_property': |
| 678 | + //more complicated query work needed ;) |
| 679 | + break; |
| 680 | + } |
| 681 | + } |
| 682 | + $searchindexTable = $dbr->tableName( 'searchindex' ); |
| 683 | + $ret_ary = array(); |
| 684 | + //a join operation to restrict search results to streams with files |
| 685 | + $join_streams_with_low_ogg_sql = "JOIN `$mvStreamFilesTable` ON (`$mvIndexTableName`.`stream_id` = `$mvStreamFilesTable`.`stream_id` AND `$mvStreamFilesTable`.`file_desc_msg`='mv_ogg_low_quality') "; |
| 686 | + //only run the top range query if we have no secondary query |
| 687 | + if($toplq_cat!='' && $ftq==''){ |
| 688 | + //@@todo unify top query with rannged query ... kind of tricky |
| 689 | + |
| 690 | + //@@todo we should only look in annotative layer for top level queries? ... |
| 691 | + //@@todo paging for top level queries? ... 200 hit limit is probably ok |
| 692 | + |
| 693 | + $sql = "SELECT `mv_page_id` as `id`, `$mvIndexTableName`.`stream_id`,`$mvIndexTableName`.`start_time`,`$mvIndexTableName`.`end_time`,`$mvIndexTableName`.`view_count`, `wiki_title`, $searchindexTable.`si_text` as `text` |
| 694 | + FROM `$mvIndexTableName` |
| 695 | + $date_range_join |
| 696 | + JOIN $categoryTable ON `$mvIndexTableName`.`mv_page_id` = $categoryTable.`cl_from` |
| 697 | + $join_streams_with_low_ogg_sql |
| 698 | + LEFT JOIN $searchindexTable ON `$mvIndexTableName`.`mv_page_id` = $searchindexTable.`si_page` |
| 699 | + WHERE |
700 | 700 | `mvd_type`='Anno_en' " . |
701 | | - " $toplq_cat " . |
702 | | - " $snq " . |
703 | | - "$date_range_andor $date_range_where " . |
704 | | - "LIMIT 0, 200"; |
705 | | - //echo "topQ: $sql \n\n"; |
706 | | - $top_result = $dbr->query($sql, 'MV_Index:doFiltersQuery_topQ'); |
707 | | - if($dbr->numRows($top_result)==0)return array(); |
708 | | - //set up ranges sql query |
709 | | - $sql="SELECT $selOpt `mv_page_id` as `id`, `$mvIndexTableName`.`stream_id`,`start_time`,`end_time`,`view_count`, `wiki_title`, $searchindexTable.`si_text` as `text` "; |
710 | | - if($mvSpokenByInSearchResult)$sql.=",`smw_relations`.`object_title` as `spoken_by` "; |
711 | | - $sql.="FROM `$mvIndexTableName` " . |
712 | | - $join_streams_with_low_ogg_sql . |
713 | | - "JOIN $searchindexTable ON `$mvIndexTableName`.`mv_page_id` = $searchindexTable.`si_page` "; |
714 | | - if($mvSpokenByInSearchResult){ |
715 | | - $sql.="LEFT JOIN `smw_relations` ON (`mv_mvd_index`.`mv_page_id`=`smw_relations`.`subject_id` " . |
716 | | - "AND `smw_relations`.`relation_title`='Spoken_By') "; |
717 | | - } |
718 | | - $sql.="WHERE "; |
719 | | - $or=''; |
720 | | - $sql.='( '; |
721 | | - while($row = $dbr->fetchObject( $top_result )){ |
722 | | - //also set initial sranges: |
723 | | - if(!isset($ret_ary[$row->stream_id]))$ret_ary[$row->stream_id]=array(); |
724 | | - //insert into return ary: |
725 | | - $insertRow = ($ftq=='')?true:false; |
726 | | - //add that its a top level query to the row: |
727 | | - $row->toplq=true; |
728 | | - MV_Index::insert_merge_range($ret_ary[$row->stream_id], $ret_ary, $row, $insertRow); |
729 | | - |
730 | | - $sql.=$or. " (`$mvIndexTableName`.`stream_id`='{$row->stream_id}' AND " . |
731 | | - '`start_time`>='.$row->start_time.' AND '. |
732 | | - '`end_time`<='.$row->end_time.' ) '; |
733 | | - $or=' OR '; |
734 | | - } |
735 | | - $sql.=') '; |
736 | | - //if($ftq!='') |
737 | | - // $sql.=" AND MATCH (text) |
738 | | - // AGAINST('$ftq' IN BOOLEAN MODE) "; |
739 | | - $sql.="LIMIT {$this->offset}, {$this->limit} "; |
740 | | - }else{ |
741 | | - //add the top query to the base query: |
742 | | - $ftq.=$toplq; |
743 | | - $sql = "SELECT $selOpt `mv_page_id` as `id`,`$mvIndexTableName`.`stream_id`,`start_time`,`end_time`, `view_count`,`wiki_title`, $searchindexTable.`si_text` AS `text` "; |
744 | | - if($mvSpokenByInSearchResult)$sql.=",`smw_relations`.`object_title` as `spoken_by` "; |
745 | | - $sql.="FROM `$mvIndexTableName` |
746 | | - JOIN $searchindexTable ON `$mvIndexTableName`.`mv_page_id` = $searchindexTable.`si_page` |
747 | | - $join_streams_with_low_ogg_sql |
748 | | - $date_range_join "; |
749 | | - |
750 | | - //include spoken by relation in results (LEFT JOIN should not be *that* costly ) |
751 | | - if($mvSpokenByInSearchResult){ |
752 | | - $sql.="LEFT JOIN `smw_relations` ON (`mv_mvd_index`.`mv_page_id`=`smw_relations`.`subject_id` " . |
753 | | - "AND `smw_relations`.`relation_title`='Spoken_By') "; |
754 | | - } |
755 | | - $sql.="WHERE "; |
756 | | - $sql.=" ( `{$mvIndexTableName}`.`mvd_type`='ht_en' OR `{$mvIndexTableName}`.`mvd_type`='anno_en') AND" ; |
757 | | - $sql.=" $snq "; |
758 | | - //limit to ht_en & anno_en (for now) |
759 | | - |
760 | | - $two_part_anor=''; |
761 | | - if($group_spoken){ |
762 | | - $ftq.=$ftq_match; |
763 | | - }else{ |
764 | | - if($ftq_match_asql)$sql.=' '.$ftq_match_asql.' '; |
765 | | - if($ftq_match!=''){ |
766 | | - $sql.=" MATCH ( $searchindexTable.`si_text` ) |
767 | | - AGAINST('$ftq_match' IN BOOLEAN MODE) "; |
768 | | - if($ftq!='')$sql.=' AND '; |
769 | | - } |
770 | | - } |
771 | | - if($ftq!=''){ |
772 | | - $sql.=" MATCH ( $searchindexTable.`si_text` ) |
773 | | - AGAINST('$ftq' IN BOOLEAN MODE) "; |
774 | | - } |
775 | | - //date range stuff is SLOW when its the only filter (pulls up matches for everything) |
776 | | - if($snq!='' || $ftq!='' && isset($date_range_andor)) |
777 | | - $sql.=$date_range_andor; |
778 | | - $sql.=" $date_range_where "; |
779 | | - $sql.="LIMIT {$this->offset}, {$this->limit} "; |
780 | | - } |
781 | | - //echo "SQL:".$sql." \n"; |
| 701 | + " $toplq_cat " . |
| 702 | + " $snq " . |
| 703 | + "$date_range_andor $date_range_where " . |
| 704 | + "LIMIT 0, 200"; |
| 705 | + //echo "topQ: $sql \n\n"; |
| 706 | + $top_result = $dbr->query($sql, 'MV_Index:doFiltersQuery_topQ'); |
| 707 | + if($dbr->numRows($top_result)==0)return array(); |
| 708 | + //set up ranges sql query |
| 709 | + $sql="SELECT $selOpt `mv_page_id` as `id`, `$mvIndexTableName`.`stream_id`,`start_time`,`end_time`,`view_count`, `wiki_title`, $searchindexTable.`si_text` as `text` "; |
| 710 | + if($mvSpokenByInSearchResult)$sql.=",`smw_relations`.`object_title` as `spoken_by` "; |
| 711 | + $sql.="FROM `$mvIndexTableName` " . |
| 712 | + $join_streams_with_low_ogg_sql . |
| 713 | + "JOIN $searchindexTable ON `$mvIndexTableName`.`mv_page_id` = $searchindexTable.`si_page` "; |
| 714 | + if($mvSpokenByInSearchResult){ |
| 715 | + $sql.="LEFT JOIN `smw_relations` ON (`mv_mvd_index`.`mv_page_id`=`smw_relations`.`subject_id` " . |
| 716 | + "AND `smw_relations`.`relation_title`='Spoken_By') "; |
| 717 | + } |
| 718 | + $sql.="WHERE "; |
| 719 | + $or=''; |
| 720 | + $sql.='( '; |
| 721 | + while($row = $dbr->fetchObject( $top_result )){ |
| 722 | + //also set initial sranges: |
| 723 | + if(!isset($ret_ary[$row->stream_id]))$ret_ary[$row->stream_id]=array(); |
| 724 | + //insert into return ary: |
| 725 | + $insertRow = ($ftq=='')?true:false; |
| 726 | + //add that its a top level query to the row: |
| 727 | + $row->toplq=true; |
| 728 | + MV_Index::insert_merge_range($ret_ary[$row->stream_id], $ret_ary, $row, $insertRow); |
| 729 | + |
| 730 | + $sql.=$or. " (`$mvIndexTableName`.`stream_id`='{$row->stream_id}' AND " . |
| 731 | + '`start_time`>='.$row->start_time.' AND '. |
| 732 | + '`end_time`<='.$row->end_time.' ) '; |
| 733 | + $or=' OR '; |
| 734 | + } |
| 735 | + $sql.=') '; |
| 736 | + //if($ftq!='') |
| 737 | + // $sql.=" AND MATCH (text) |
| 738 | + // AGAINST('$ftq' IN BOOLEAN MODE) "; |
| 739 | + $sql.="LIMIT {$this->offset}, {$this->limit} "; |
| 740 | + }else{ |
| 741 | + //add the top query to the base query: |
| 742 | + $ftq.=$toplq; |
| 743 | + $sql = "SELECT $selOpt `mv_page_id` as `id`,`$mvIndexTableName`.`stream_id`,`start_time`,`end_time`, `view_count`,`wiki_title`, $searchindexTable.`si_text` AS `text` "; |
| 744 | + if($mvSpokenByInSearchResult)$sql.=",`smw_relations`.`object_title` as `spoken_by` "; |
| 745 | + $sql.="FROM `$mvIndexTableName` |
| 746 | + JOIN $searchindexTable ON `$mvIndexTableName`.`mv_page_id` = $searchindexTable.`si_page` |
| 747 | + $join_streams_with_low_ogg_sql |
| 748 | + $date_range_join "; |
| 749 | + |
| 750 | + //include spoken by relation in results (LEFT JOIN should not be *that* costly ) |
| 751 | + if($mvSpokenByInSearchResult){ |
| 752 | + $sql.="LEFT JOIN `smw_relations` ON (`mv_mvd_index`.`mv_page_id`=`smw_relations`.`subject_id` " . |
| 753 | + "AND `smw_relations`.`relation_title`='Spoken_By') "; |
| 754 | + } |
| 755 | + $sql.="WHERE "; |
| 756 | + $sql.=" ( `{$mvIndexTableName}`.`mvd_type`='ht_en' OR `{$mvIndexTableName}`.`mvd_type`='anno_en') AND" ; |
| 757 | + $sql.=" $snq "; |
| 758 | + //limit to ht_en & anno_en (for now) |
| 759 | + |
| 760 | + $two_part_anor=''; |
| 761 | + if($group_spoken){ |
| 762 | + $ftq.=$ftq_match; |
| 763 | + }else{ |
| 764 | + if($ftq_match_asql)$sql.=' '.$ftq_match_asql.' '; |
| 765 | + if($ftq_match!=''){ |
| 766 | + $sql.=" MATCH ( $searchindexTable.`si_text` ) |
| 767 | + AGAINST('$ftq_match' IN BOOLEAN MODE) "; |
| 768 | + if($ftq!='')$sql.=' AND '; |
| 769 | + } |
| 770 | + } |
| 771 | + if($ftq!=''){ |
| 772 | + $sql.=" MATCH ( $searchindexTable.`si_text` ) |
| 773 | + AGAINST('$ftq' IN BOOLEAN MODE) "; |
| 774 | + } |
| 775 | + //date range stuff is SLOW when its the only filter (pulls up matches for everything) |
| 776 | + if($snq!='' || $ftq!='' && isset($date_range_andor)) |
| 777 | + $sql.=$date_range_andor; |
| 778 | + $sql.=" $date_range_where "; |
| 779 | + $sql.="LIMIT {$this->offset}, {$this->limit} "; |
| 780 | + } |
| 781 | + //echo "SQL:".$sql." \n"; |
782 | 782 | //die; |
783 | | - $result = $dbr->query($sql, 'MV_Index:doFiltersQuery_base'); |
784 | | - |
785 | | - $this->numResults=$dbr->numRows($result); |
786 | | - if($dbr->numRows($result)==0) return array(); |
787 | | - |
788 | | - if($mvDo_SQL_CALC_FOUND_ROWS){ |
789 | | - $resFound = $dbr->query('SELECT FOUND_ROWS() as `count`;'); |
790 | | - $found = $dbr->fetchObject( $resFound ); |
791 | | - $this->numResultsFound = $found->count; |
792 | | - }else{ |
793 | | - $this->numResultsFound =null; |
794 | | - } |
795 | | - |
796 | | - |
797 | | - //@@TODO hide empty categories (if limit > rows found ) |
798 | | - |
799 | | - //group by time range in a given stream |
800 | | - |
801 | | - //while($row = $dbr->fetchObject( $result )){ |
802 | | - // $ret_ary[]=$row; |
803 | | - //} |
804 | | - //return $ret_ary; |
805 | | - //group by stream_name & time range: |
806 | | - |
807 | | - //@@todo we should deprecate stream grouping |
808 | | - while($row = $dbr->fetchObject( $result )){ |
809 | | - if(!isset($ret_ary[$row->stream_id])){ |
810 | | - $ret_ary[$row->stream_id]=array(); |
811 | | - } |
812 | | - if(count($ret_ary[$row->stream_id])==0){ |
813 | | - $new_srange = array('s'=>$row->start_time, |
| 783 | + $result = $dbr->query($sql, 'MV_Index:doFiltersQuery_base'); |
| 784 | + |
| 785 | + $this->numResults=$dbr->numRows($result); |
| 786 | + if($dbr->numRows($result)==0) return array(); |
| 787 | + |
| 788 | + if($mvDo_SQL_CALC_FOUND_ROWS){ |
| 789 | + $resFound = $dbr->query('SELECT FOUND_ROWS() as `count`;'); |
| 790 | + $found = $dbr->fetchObject( $resFound ); |
| 791 | + $this->numResultsFound = $found->count; |
| 792 | + }else{ |
| 793 | + $this->numResultsFound =null; |
| 794 | + } |
| 795 | + |
| 796 | + |
| 797 | + //@@TODO hide empty categories (if limit > rows found ) |
| 798 | + |
| 799 | + //group by time range in a given stream |
| 800 | + |
| 801 | + //while($row = $dbr->fetchObject( $result )){ |
| 802 | + // $ret_ary[]=$row; |
| 803 | + //} |
| 804 | + //return $ret_ary; |
| 805 | + //group by stream_name & time range: |
| 806 | + |
| 807 | + //@@todo we should deprecate stream grouping |
| 808 | + while($row = $dbr->fetchObject( $result )){ |
| 809 | + if(!isset($ret_ary[$row->stream_id])){ |
| 810 | + $ret_ary[$row->stream_id]=array(); |
| 811 | + } |
| 812 | + if(count($ret_ary[$row->stream_id])==0){ |
| 813 | + $new_srange = array('s'=>$row->start_time, |
814 | 814 | 'e'=> $row->end_time, |
815 | 815 | 'rows'=>array($row)); |
816 | | - $ret_ary[$row->stream_id][]=$new_srange; |
817 | | - }else{ |
818 | | - MV_Index::insert_merge_range($ret_ary[$row->stream_id], $ret_ary, $row); |
819 | | - } |
820 | | - } |
821 | | - //throw out empty top level ranges |
822 | | - foreach($ret_ary as &$stream_set){ |
823 | | - foreach($stream_set as $k=> &$srange){ |
824 | | - if(count($srange['rows'])==0){ |
825 | | - //print "throw out: ". $srange['s'] . $srange['e']; |
826 | | - unset($stream_set[$k]); |
827 | | - } |
828 | | - } |
829 | | - } |
830 | | - //do category & bill lookup for search result ranges |
831 | | - if($mvCategoryInSearchResult || $mvBillInSearchResult){ |
832 | | - $sql="SELECT {$dbr->tableName('categorylinks')}.`cl_to`, `mv_mvd_index`.`stream_id`, |
833 | | - `$mvIndexTableName`.`start_time`, |
| 816 | + $ret_ary[$row->stream_id][]=$new_srange; |
| 817 | + }else{ |
| 818 | + MV_Index::insert_merge_range($ret_ary[$row->stream_id], $ret_ary, $row); |
| 819 | + } |
| 820 | + } |
| 821 | + //throw out empty top level ranges |
| 822 | + foreach($ret_ary as &$stream_set){ |
| 823 | + foreach($stream_set as $k=> &$srange){ |
| 824 | + if(count($srange['rows'])==0){ |
| 825 | + //print "throw out: ". $srange['s'] . $srange['e']; |
| 826 | + unset($stream_set[$k]); |
| 827 | + } |
| 828 | + } |
| 829 | + } |
| 830 | + //do category & bill lookup for search result ranges |
| 831 | + if($mvCategoryInSearchResult || $mvBillInSearchResult){ |
| 832 | + $sql="SELECT {$dbr->tableName('categorylinks')}.`cl_to`, `mv_mvd_index`.`stream_id`, |
| 833 | + `$mvIndexTableName`.`start_time`, |
834 | 834 | `$mvIndexTableName`.`end_time`, |
835 | 835 | {$dbr->tableName('smw_relations')}.`object_title` as bill_to"; |
836 | 836 | $sql.=" FROM `$mvIndexTableName` |
837 | | - LEFT JOIN {$dbr->tableName('categorylinks')} ON (`$mvIndexTableName`.`mv_page_id` = {$dbr->tableName('categorylinks')}.`cl_from`) |
| 837 | + LEFT JOIN {$dbr->tableName('categorylinks')} ON (`$mvIndexTableName`.`mv_page_id` = {$dbr->tableName('categorylinks')}.`cl_from`) |
838 | 838 | LEFT JOIN {$dbr->tableName('smw_relations')} ON ( |
839 | 839 | `$mvIndexTableName`.`mv_page_id` = {$dbr->tableName('smw_relations')}.`subject_id` AND |
840 | | - {$dbr->tableName('smw_relations')}.`relation_title`='bill' ) "; |
| 840 | + {$dbr->tableName('smw_relations')}.`relation_title`='bill' ) "; |
841 | 841 | //generate stream_id, range sets |
842 | 842 | $sql.=" WHERE `$mvIndexTableName`.`mvd_type`='Anno_en' AND ("; |
843 | 843 | $or=''; |
844 | 844 | foreach($ret_ary as $stream_id=>$rangeSet){ |
845 | 845 | foreach($rangeSet as $range){ |
846 | | - $sql.=$or . "( `$mvIndexTableName`.`stream_id`='$stream_id'"; |
| 846 | + $sql.=$or . "( `$mvIndexTableName`.`stream_id`='$stream_id'"; |
847 | 847 | $sql.=" AND `start_time` <= '" . $range['s']."'"; |
848 | 848 | $sql.=" AND `end_time` >= '" . $range['e'] . '\' ) '; |
849 | | - $or = ' OR '; |
| 849 | + $or = ' OR '; |
850 | 850 | } |
851 | 851 | } |
852 | | - $sql.=') LIMIT 0, 200'; |
853 | | - //merge category info back into base results: |
| 852 | + $sql.=') LIMIT 0, 200'; |
| 853 | + //merge category info back into base results: |
854 | 854 | $result = $dbr->query($sql, 'MV_Index:doCategorySearchResult'); |
855 | | - while($cl_row = $dbr->fetchObject( $result )){ |
856 | | - foreach($ret_ary[$cl_row->stream_id] as &$range){ |
| 855 | + while($cl_row = $dbr->fetchObject( $result )){ |
| 856 | + foreach($ret_ary[$cl_row->stream_id] as &$range){ |
857 | 857 | foreach($range['rows'] as &$result_row){ |
858 | | - if($result_row->start_time <= $cl_row->end_time && |
| 858 | + if($result_row->start_time <= $cl_row->end_time && |
859 | 859 | $result_row->end_time >= $cl_row->start_time){ |
860 | | - if($cl_row->cl_to) |
| 860 | + if($cl_row->cl_to) |
861 | 861 | $result_row->categories[$cl_row->cl_to]=true; |
862 | 862 | if($cl_row->bill_to) |
863 | | - $result_row->bills[$cl_row->bill_to]=true; |
864 | | - } |
| 863 | + $result_row->bills[$cl_row->bill_to]=true; |
| 864 | + } |
865 | 865 | } |
866 | 866 | } |
867 | 867 | } |
868 | | - } |
869 | | - //print "<pre>"; |
870 | | - //print_r($ret_ary); |
871 | | - //die; |
872 | | - return $ret_ary; |
873 | | - }*/ |
874 | | - function numResultsFound(){ |
875 | | - if(isset($this->numResultsFound)){ |
876 | | - return $this->numResultsFound; |
877 | | - }else{ |
878 | | - return null; |
879 | | - } |
880 | | - } |
881 | | - function numResults(){ |
882 | | - if(isset($this->numResults)) |
883 | | - return $this->numResults; |
884 | | - return 0; |
885 | | - } |
886 | | - /*inserts search result into proper range and stream */ |
887 | | - function insert_merge_range(& $sranges, &$ret_ary, $row, $doRowInsert=true){ |
888 | | - foreach($sranges as & $srange){ |
889 | | - //skip if srange row 0 has same mvd (topq already inserted) |
890 | | - //if($srange['rows'][0]->id==$row->id )continue ; |
891 | | - //check if current $srow encapsulate and insert |
892 | | - if($row->start_time <= $srange['s'] && $row->end_time >= $srange['e']){ |
893 | | - $srange['s']= $row->start_time; |
894 | | - $srange['e']= $row->end_time; |
895 | | - if($doRowInsert) |
896 | | - $srange['rows'][]=$row; |
897 | | - //grab rows from any other stream segment that fits in new srange: |
898 | | - foreach($ret_ary as &$sbrange){ |
899 | | - if($row->start_time <= $sbrange['s'] && $row->end_time >= $sbrange['e']){ |
900 | | - foreach($sbrange['rows'] as $sbrow){ |
901 | | - $srange['rows'][]=$sbrow; |
902 | | - } |
903 | | - unset($sbrange); |
904 | | - } |
905 | | - } |
906 | | - return ; |
907 | | - }//else if current fits into srange insert |
908 | | - else if($row->start_time >= $srange['s'] && $row->end_time <= $srange['e']){ |
909 | | - if($doRowInsert) |
910 | | - $srange['rows'][]=$row; |
911 | | - return ; |
912 | | - } |
913 | | - //make sure the current row does not already exist: |
914 | | - foreach($srange['rows'] as $sbrow){ |
915 | | - if($sbrow->wiki_title == $row->wiki_title){ |
916 | | - return ; |
917 | | - } |
918 | | - } |
919 | | - } |
| 868 | + } |
| 869 | + //print "<pre>"; |
| 870 | + //print_r($ret_ary); |
| 871 | + //die; |
| 872 | + return $ret_ary; |
| 873 | + }*/ |
| 874 | + function numResultsFound(){ |
| 875 | + if(isset($this->numResultsFound)){ |
| 876 | + return $this->numResultsFound; |
| 877 | + }else{ |
| 878 | + return null; |
| 879 | + } |
| 880 | + } |
| 881 | + function numResults(){ |
| 882 | + if(isset($this->numResults)) |
| 883 | + return $this->numResults; |
| 884 | + return 0; |
| 885 | + } |
| 886 | + /*inserts search result into proper range and stream */ |
| 887 | + function insert_merge_range(& $sranges, &$ret_ary, $row, $doRowInsert=true){ |
| 888 | + foreach($sranges as & $srange){ |
| 889 | + //skip if srange row 0 has same mvd (topq already inserted) |
| 890 | + //if($srange['rows'][0]->id==$row->id )continue ; |
| 891 | + //check if current $srow encapsulate and insert |
| 892 | + if($row->start_time <= $srange['s'] && $row->end_time >= $srange['e']){ |
| 893 | + $srange['s']= $row->start_time; |
| 894 | + $srange['e']= $row->end_time; |
| 895 | + if($doRowInsert) |
| 896 | + $srange['rows'][]=$row; |
| 897 | + //grab rows from any other stream segment that fits in new srange: |
| 898 | + foreach($ret_ary as &$sbrange){ |
| 899 | + if($row->start_time <= $sbrange['s'] && $row->end_time >= $sbrange['e']){ |
| 900 | + foreach($sbrange['rows'] as $sbrow){ |
| 901 | + $srange['rows'][]=$sbrow; |
| 902 | + } |
| 903 | + unset($sbrange); |
| 904 | + } |
| 905 | + } |
| 906 | + return ; |
| 907 | + }//else if current fits into srange insert |
| 908 | + else if($row->start_time >= $srange['s'] && $row->end_time <= $srange['e']){ |
| 909 | + if($doRowInsert) |
| 910 | + $srange['rows'][]=$row; |
| 911 | + return ; |
| 912 | + } |
| 913 | + //make sure the current row does not already exist: |
| 914 | + foreach($srange['rows'] as $sbrow){ |
| 915 | + if($sbrow->wiki_title == $row->wiki_title){ |
| 916 | + return ; |
| 917 | + } |
| 918 | + } |
| 919 | + } |
920 | 920 | //just add as new srange |
921 | | - $new_srange = array('s'=>$row->start_time, |
| 921 | + $new_srange = array('s'=>$row->start_time, |
922 | 922 | 'e'=> $row->end_time); |
923 | 923 | if($doRowInsert){ |
924 | 924 | $new_srange['rows']=array($row); |
925 | 925 | }else{ |
926 | 926 | $new_srange['rows']=array(); |
927 | 927 | } |
928 | | - $ret_ary[$row->stream_id][]=$new_srange; |
929 | | - } |
930 | | - function getMVDbyId($id, $fields='*'){ |
931 | | - global $mvIndexTableName; |
932 | | - $dbr =& wfGetDB(DB_SLAVE); |
933 | | - $result = $dbr->select( $mvIndexTableName, $fields, |
934 | | - array('mv_page_id'=>$id) ); |
935 | | - if($dbr->numRows($result)==0){ |
936 | | - return array(); |
937 | | - }else{ |
938 | | - //(mvd->id got renamed to more accurate mv_page_id) |
939 | | - $row = $dbr->fetchObject( $result ); |
940 | | - $row->id=$row->mv_page_id; |
941 | | - return $row; |
942 | | - } |
943 | | - } |
944 | | - function getMVDbyTitle($title_key, $fields='*'){ |
945 | | - global $mvIndexTableName; |
946 | | - $dbr =& wfGetDB(DB_SLAVE); |
947 | | - $result = $dbr->select( $mvIndexTableName, $fields, |
948 | | - array('wiki_title'=>$title_key) ); |
949 | | - if($dbr->numRows($result)==0){ |
950 | | - return null; |
951 | | - }else{ |
952 | | - $row = $dbr->fetchObject( $result ); |
953 | | - $row->id=$row->mv_page_id; |
954 | | - return $row; |
955 | | - } |
956 | | - } |
957 | | - function update_index_title($old_title, $new_title){ |
958 | | - global $mvIndexTableName; |
| 928 | + $ret_ary[$row->stream_id][]=$new_srange; |
| 929 | + } |
| 930 | + function getMVDbyId($id, $fields='*'){ |
| 931 | + global $mvIndexTableName; |
| 932 | + $dbr =& wfGetDB(DB_SLAVE); |
| 933 | + $result = $dbr->select( $mvIndexTableName, $fields, |
| 934 | + array('mv_page_id'=>$id) ); |
| 935 | + if($dbr->numRows($result)==0){ |
| 936 | + return array(); |
| 937 | + }else{ |
| 938 | + //(mvd->id got renamed to more accurate mv_page_id) |
| 939 | + $row = $dbr->fetchObject( $result ); |
| 940 | + $row->id=$row->mv_page_id; |
| 941 | + return $row; |
| 942 | + } |
| 943 | + } |
| 944 | + function getMVDbyTitle($title_key, $fields='*'){ |
| 945 | + global $mvIndexTableName; |
| 946 | + $dbr =& wfGetDB(DB_SLAVE); |
| 947 | + $result = $dbr->select( $mvIndexTableName, $fields, |
| 948 | + array('wiki_title'=>$title_key) ); |
| 949 | + if($dbr->numRows($result)==0){ |
| 950 | + return null; |
| 951 | + }else{ |
| 952 | + $row = $dbr->fetchObject( $result ); |
| 953 | + $row->id=$row->mv_page_id; |
| 954 | + return $row; |
| 955 | + } |
| 956 | + } |
| 957 | + function update_index_title($old_title, $new_title){ |
| 958 | + global $mvIndexTableName; |
959 | 959 | |
960 | | - //make sure the new title is valid: |
961 | | - $mvTitle = new MV_Title( $new_title ); |
962 | | - if( $mvTitle->validRequestTitle() ){ |
963 | | - //build the update row |
964 | | - $update_ary = array( |
| 960 | + //make sure the new title is valid: |
| 961 | + $mvTitle = new MV_Title( $new_title ); |
| 962 | + if( $mvTitle->validRequestTitle() ){ |
| 963 | + //build the update row |
| 964 | + $update_ary = array( |
965 | 965 | 'wiki_title'=>$mvTitle->getWikiTitle(), |
966 | 966 | 'mvd_type'=>$mvTitle->getTypeMarker(), |
967 | | - 'stream_id'=>$mvTitle->getStreamId(), |
| 967 | + 'stream_id'=>$mvTitle->getStreamId(), |
968 | 968 | 'start_time'=>$mvTitle->getStartTimeSeconds(), |
969 | 969 | 'end_time'=>$mvTitle->getEndTimeSeconds() ); |
970 | | - //get old row |
971 | | - $mvd_row = MV_Index::getMVDbyTitle( $old_title ); |
972 | | - $dbw =& wfGetDB(DB_WRITE); |
973 | | - $dbw->update($mvIndexTableName, $update_ary, |
974 | | - array('mv_page_id'=>$mvd_row->mv_page_id)); |
975 | | - }else{ |
976 | | - //print "NOT VALID MOVE"; |
977 | | - //@@todo better error handling (tyring to move a MVD data into bad request form) |
978 | | - throw new MWException("Invalid Page name for MVD namespace \n"); |
979 | | - } |
980 | | - } |
981 | | - /* |
982 | | - * update_index_page updates the `mv_mvd_index` table (on MVD namespace saves) |
983 | | - */ |
984 | | - function update_index_page(&$article, &$text){ |
985 | | - global $mvgIP, $mvIndexTableName; |
986 | | - //check static or $this usage context |
987 | | - //use mv title to split up the values: |
| 970 | + //get old row |
| 971 | + $mvd_row = MV_Index::getMVDbyTitle( $old_title ); |
| 972 | + $dbw =& wfGetDB(DB_WRITE); |
| 973 | + $dbw->update($mvIndexTableName, $update_ary, |
| 974 | + array('mv_page_id'=>$mvd_row->mv_page_id)); |
| 975 | + }else{ |
| 976 | + //print "NOT VALID MOVE"; |
| 977 | + //@@todo better error handling (tyring to move a MVD data into bad request form) |
| 978 | + throw new MWException("Invalid Page name for MVD namespace \n"); |
| 979 | + } |
| 980 | + } |
| 981 | + /* |
| 982 | + * update_index_page updates the `mv_mvd_index` table (on MVD namespace saves) |
| 983 | + */ |
| 984 | + function update_index_page(&$article, &$text){ |
| 985 | + global $mvgIP, $mvIndexTableName; |
| 986 | + //check static or $this usage context |
| 987 | + //use mv title to split up the values: |
988 | 988 | $mvTitle = new MV_Title($article->mTitle->getDBkey()); |
989 | | - //print "Wiki title: " . $mvTitle->getWikiTitle(); |
990 | | - //fist check if an mvd entry for this stream already exists: |
| 989 | + //print "Wiki title: " . $mvTitle->getWikiTitle(); |
| 990 | + //fist check if an mvd entry for this stream already exists: |
991 | 991 | $mvd_row = MV_Index::getMVDbyTitle( $mvTitle->getWikiTitle() ); |
992 | 992 | //set up the insert values: |
993 | 993 | $insAry = array( |
994 | 994 | 'mv_page_id'=>$article->mTitle->getArticleID(), |
995 | 995 | 'wiki_title'=>$mvTitle->getWikiTitle(), |
996 | 996 | 'mvd_type'=>$mvTitle->getTypeMarker(), |
997 | | - 'stream_id'=>$mvTitle->getStreamId(), |
| 997 | + 'stream_id'=>$mvTitle->getStreamId(), |
998 | 998 | 'start_time'=>$mvTitle->getStartTimeSeconds(), |
999 | | - 'end_time'=>$mvTitle->getEndTimeSeconds(), |
| 999 | + 'end_time'=>$mvTitle->getEndTimeSeconds(), |
1000 | 1000 | ); |
1001 | | - |
1002 | | - $dbw =& wfGetDB(DB_WRITE); |
1003 | | - if(count($mvd_row)==0){ |
1004 | | - return $dbw->insert( $mvIndexTableName , $insAry); |
1005 | | - }else{ |
1006 | | - $dbw->update($mvIndexTableName, $insAry, |
1007 | | - array('mv_page_id'=>$mvd_row->mv_page_id)); |
1008 | | - } |
1009 | | - } |
1010 | | - } |
1011 | | -?> |
| 1001 | + |
| 1002 | + $dbw =& wfGetDB(DB_WRITE); |
| 1003 | + if(count($mvd_row)==0){ |
| 1004 | + return $dbw->insert( $mvIndexTableName , $insAry); |
| 1005 | + }else{ |
| 1006 | + $dbw->update($mvIndexTableName, $insAry, |
| 1007 | + array('mv_page_id'=>$mvd_row->mv_page_id)); |
| 1008 | + } |
| 1009 | + } |
| 1010 | +} |
Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * |
6 | 6 | * All Metavid Wiki code is Released Under the GPL2 |
7 | 7 | * for more info visit http:/metavid.ucsc.edu/code |
8 | | - * |
| 8 | + * |
9 | 9 | * overwrites the existing special search to add in metavid specific features |
10 | 10 | */ |
11 | 11 | if (!defined('MEDIAWIKI')) |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | |
14 | 14 | class MediaSearch extends SpecialPage{ |
15 | 15 | function __construct(){ |
16 | | - parent::__construct('MediaSearch'); |
| 16 | + parent::__construct('MediaSearch'); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | function wfSpecialMediaSearch(){ |
— | — | @@ -26,16 +26,16 @@ |
27 | 27 | global $wgOut, $wgRequest; |
28 | 28 | mvfAddHTMLHeader('search'); |
29 | 29 | $MvSpecialSearch = new MV_SpecialMediaSearch(); |
30 | | - $MvSpecialSearch->doSearchPage( $wgRequest->getVal('search') ); |
| 30 | + $MvSpecialSearch->doSearchPage( $wgRequest->getVal('search') ); |
31 | 31 | SpecialPage :: SpecialPage('Search'); |
32 | 32 | } |
33 | 33 | } |
34 | 34 | /* |
35 | | - * simple/quick implementation ... |
36 | | - * @@todo future version should be better integrated with semantic wiki and or |
| 35 | + * simple/quick implementation ... |
| 36 | + * @@todo future version should be better integrated with semantic wiki and or |
37 | 37 | * an external scalable search engine ie sphinx or lucene |
38 | | - * |
39 | | - * example get request: filter 0, type match, value = wars |
| 38 | + * |
| 39 | + * example get request: filter 0, type match, value = wars |
40 | 40 | * ?f[0]['t']=m&f[0]['v']=wars |
41 | 41 | */ |
42 | 42 | class MV_SpecialMediaSearch { |
— | — | @@ -45,18 +45,18 @@ |
46 | 46 | 'spoken_by', |
47 | 47 | 'category', |
48 | 48 | 'date_range', //search in a given date range |
49 | | - //not yet active: |
| 49 | + //not yet active: |
50 | 50 | //'stream_name', //search within a particular stream |
51 | 51 | //'layers' //specify a specific meta-layer set |
52 | | - //'smw_property' |
| 52 | + //'smw_property' |
53 | 53 | //'smw_property_numeric' |
54 | | - |
| 54 | + |
55 | 55 | ); |
56 | 56 | var $sel_filter_andor = array ( |
57 | 57 | 'and', |
58 | 58 | 'or', |
59 | 59 | 'not', |
60 | | - |
| 60 | + |
61 | 61 | ); |
62 | 62 | var $unified_term_search = ''; |
63 | 63 | var $adv_search = false; |
— | — | @@ -69,14 +69,14 @@ |
70 | 70 | |
71 | 71 | var $limit = 20; |
72 | 72 | var $offset = 0; |
73 | | - var $order = 'relevent'; |
| 73 | + var $order = 'relevant'; |
74 | 74 | |
75 | 75 | function doSearchPage($term = '') { |
76 | 76 | global $wgRequest, $wgOut, $wgUser; |
77 | 77 | $this->setUpFilters(); |
78 | 78 | //do the search |
79 | 79 | $this->doSearch(); |
80 | | - //page control: |
| 80 | + //page control: |
81 | 81 | $this->outputInlineHeader = false; |
82 | 82 | if ($wgRequest->getVal('seq_inline') == 'true') { |
83 | 83 | $this->outputContainer = false; |
— | — | @@ -87,9 +87,9 @@ |
88 | 88 | //@@todo cleaner exit |
89 | 89 | //exit (); |
90 | 90 | } else { |
91 | | - //add nessesary js to wgOut: |
| 91 | + //add nessesary js to wgOut: |
92 | 92 | mvfAddHTMLHeader('search'); |
93 | | - //add the search placeholder |
| 93 | + //add the search placeholder |
94 | 94 | //$wgOut->addWikiText( wfMsg( 'searchresulttext' ) ); |
95 | 95 | $sk = $wgUser->getSkin(); |
96 | 96 | $title = Title :: MakeTitle(NS_SPECIAL, 'Search'); |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | if ($doDSC) |
113 | 113 | $wgOut->addHTML($this->dynamicSearchControl()); |
114 | 114 | |
115 | | - //$wgOut->addHTML($this->getResultsBar()); |
| 115 | + //$wgOut->addHTML($this->getResultsBar()); |
116 | 116 | $wgOut->addHTML($this->getUnifiedResultsHTML()); |
117 | 117 | } |
118 | 118 | } |
— | — | @@ -121,20 +121,20 @@ |
122 | 122 | |
123 | 123 | $o = "<div id=\"msms_form_search_row\" class=\"form_search_row\"> |
124 | 124 | <form id=\"mv_media_search\" method=\"get\" " . |
125 | | - "action=\"$action\">\n |
| 125 | + "action=\"$action\">\n |
126 | 126 | <input type=\"hidden\" id=\"advs\" name=\"advs\" value=\""; |
127 | 127 | $o .= ($this->adv_search) ? '1' : '0'; |
128 | | - $o .= "\"> |
| 128 | + $o .= "\"> |
129 | 129 | <span class=\"advs_basic\" style=\"display:"; |
130 | 130 | $o .= ($this->adv_search) ? 'none' : 'inline'; |
131 | 131 | $o .= "\"> |
132 | | - <input type=\"text\" class=\"searchField\" name=\"mv_search\" id=\"searchInput\" value=\"{$this->unified_term_search}\"/> |
| 132 | + <input type=\"text\" class=\"searchField\" name=\"mv_search\" id=\"searchInput\" value=\"{$this->unified_term_search}\"/> |
133 | 133 | </span> |
134 | 134 | <span class=\"advs_adv\" id=\"adv_filters\" style=\"display:"; |
135 | 135 | $o .= ($this->adv_search) ? 'inline' : 'none'; |
136 | | - $o .= "\"> |
| 136 | + $o .= "\"> |
137 | 137 | {$this->list_active_filters()} |
138 | | - </span> |
| 138 | + </span> |
139 | 139 | <button class=\"grey_button\" type=\"submit\"><span> " . wfMsg('mv_video_search') . " </span></button> |
140 | 140 | <a href=\"javascript:mv_toggle_advs()\" class=\"advanced_search_tag\"> |
141 | 141 | <span class=\"advs_basic\" style=\"display:"; |
— | — | @@ -155,7 +155,7 @@ |
156 | 156 | function setupFilters($defaultType = 'empty', $opt = null) { |
157 | 157 | global $wgRequest; |
158 | 158 | |
159 | | - //set advs flag: |
| 159 | + //set advs flag: |
160 | 160 | $advs = $wgRequest->getVal('advs'); |
161 | 161 | $this->adv_search = ($advs == '' || $advs == 0) ? false : true; |
162 | 162 | |
— | — | @@ -173,14 +173,14 @@ |
174 | 174 | ); |
175 | 175 | $this->unified_term_search = $term; |
176 | 176 | //if not doing advanced search we are done |
177 | | - |
| 177 | + |
178 | 178 | if (!$this->adv_search) |
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | 182 | //print "CUR un: " . $this->unified_term_search; |
183 | 183 | |
184 | | - //first try any key titles: |
| 184 | + //first try any key titles: |
185 | 185 | $title_str = $wgRequest->getVal('title'); |
186 | 186 | $tp = split('/', $title_str); |
187 | 187 | if (count($tp) == 3) { |
— | — | @@ -200,7 +200,7 @@ |
201 | 201 | if (isset ($_GET['f'])) { |
202 | 202 | $this->filters = $_GET['f']; |
203 | 203 | //@@todo more input proccessing |
204 | | - //grab unified_term_search if not already listed: |
| 204 | + //grab unified_term_search if not already listed: |
205 | 205 | if ($this->unified_term_search == '') { |
206 | 206 | foreach ($this->filters as $f) { |
207 | 207 | if ($f['t'] == 'match') { |
— | — | @@ -210,7 +210,7 @@ |
211 | 211 | }else if($f['t']=='spoken_by'){ |
212 | 212 | $this->unified_term_search = $f['v']; |
213 | 213 | } |
214 | | - |
| 214 | + |
215 | 215 | } |
216 | 216 | } |
217 | 217 | } else { |
— | — | @@ -234,7 +234,7 @@ |
235 | 235 | break; |
236 | 236 | } |
237 | 237 | } |
238 | | - } |
| 238 | + } |
239 | 239 | } |
240 | 240 | function doSearch($log_search=true) { |
241 | 241 | global $mvEnableSearchDigest, $mvSearchDigestTable; |
— | — | @@ -244,15 +244,15 @@ |
245 | 245 | if ($mvEnableSearchDigest && $wgRequest->getVal('tl') != '1' && $log_search) { |
246 | 246 | $dbw = & wfGetDB(DB_WRITE); |
247 | 247 | $dbr = & wfGetDB(DB_READ); |
248 | | - //print "DO SEARCH FOR: ". $this->getFilterDesc($query_key = true) . "\n"; |
| 248 | + //print "DO SEARCH FOR: ". $this->getFilterDesc($query_key = true) . "\n"; |
249 | 249 | //print var_dump(debug_backtrace()); |
250 | | - |
251 | | - //@@todo non-blocking insert... is that supported in mysql/php? |
| 250 | + |
| 251 | + //@@todo non-blocking insert... is that supported in mysql/php? |
252 | 252 | $dbw->insert($mvSearchDigestTable, array ( |
253 | 253 | 'query_key' => $this->getFilterDesc($query_key = true |
254 | 254 | ), 'time' => time()), 'Database::searchDigestInsert'); |
255 | 255 | //make sure the query key exists and is updated |
256 | | - //@@todo I think we can do a INSERT IF not found here? |
| 256 | + //@@todo I think we can do a INSERT IF not found here? |
257 | 257 | $res = $dbr->select('mv_query_key_lookup', array ( |
258 | 258 | 'filters' |
259 | 259 | ), array ( |
— | — | @@ -264,7 +264,7 @@ |
265 | 265 | ), 'filters' => serialize($this->filters))); |
266 | 266 | } |
267 | 267 | } |
268 | | - |
| 268 | + |
269 | 269 | $this->results = $mvIndex->doUnifiedFiltersQuery($this->filters); |
270 | 270 | $this->num = $mvIndex->numResults(); |
271 | 271 | $this->numResultsFound = $mvIndex->numResultsFound(); |
— | — | @@ -299,7 +299,7 @@ |
300 | 300 | |
301 | 301 | $o .= '<h5 class="search_results_header">' . $this->getFilterDesc() . '</h5>'; |
302 | 302 | |
303 | | - $o .= '<div id="resultsArea"> |
| 303 | + $o .= '<div id="resultsArea"> |
304 | 304 | <ul id="metaResults">'; |
305 | 305 | if (count($this->results) == 0) { |
306 | 306 | $o .= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>'; |
— | — | @@ -323,13 +323,13 @@ |
324 | 324 | $o .= '<li class="prevnext">' . $prevnext . '</li>'; |
325 | 325 | } |
326 | 326 | |
327 | | - //make rss link: |
| 327 | + //make rss link: |
328 | 328 | $sTitle = Title :: MakeTitle(NS_SPECIAL, 'MvExportSearch'); |
329 | 329 | $o .= '<li class="rss">'; |
330 | 330 | $o .= $sk->makeKnownLinkObj($sTitle, 'RSS', $this->get_httpd_filters_query()); |
331 | 331 | $o .= '</li>'; |
332 | 332 | |
333 | | - //make miro link: |
| 333 | + //make miro link: |
334 | 334 | $o .= '<li class="subscribe"><a href="http://subscribe.getMiro.com/?url1=' . |
335 | 335 | 'http%3A%2F%2F' . $_SERVER['HTTP_HOST'] . htmlspecialchars($sTitle->escapeLocalURL($this->get_httpd_filters_query())) . '" ' . |
336 | 336 | 'title="Subscribe with Miro"><img src="' . $wgStylePath . '/mvpcf/images/button_subscribe.png" alt="Miro Video Player" border="0" /></a></li>'; |
— | — | @@ -337,15 +337,15 @@ |
338 | 338 | //check order prefrence: |
339 | 339 | $br='<br>'; |
340 | 340 | $enddash=''; |
341 | | - foreach (array ('relevent','recent','viewed') as $type) { |
| 341 | + foreach (array ('relevant','recent','viewed') as $type) { |
342 | 342 | if ($this->order == $type) { |
343 | 343 | $o .= $enddash.'<li class="relevant">'.$br . wfMsg('mv_most_' . $type) . '</li>' ; |
344 | 344 | } else { |
345 | 345 | $q_req = $this->get_httpd_filters_query(); |
346 | 346 | if($wgRequest->getVal('limit')!='' || $wgRequest->getVal('order')!='') |
347 | 347 | $q_req.='&'.http_build_query(array('limit'=>$this->limit, 'offset'=>$this->offset)); |
348 | | - $q_req.='&order='.$type; |
349 | | - $o .= $enddash.'<li class="relevant">'.$br .$sk->makeKnownLinkObj(SpecialPage :: getTitleFor('MediaSearch'), |
| 348 | + $q_req.='&order='.$type; |
| 349 | + $o .= $enddash.'<li class="relevant">'.$br .$sk->makeKnownLinkObj(SpecialPage :: getTitleFor('MediaSearch'), |
350 | 350 | wfMsg('mv_most_' . $type), $q_req) . '</li>'; |
351 | 351 | } |
352 | 352 | $br=''; |
— | — | @@ -353,11 +353,11 @@ |
354 | 354 | } |
355 | 355 | $o .= '</ul>'; |
356 | 356 | |
357 | | - //output results: |
| 357 | + //output results: |
358 | 358 | //collect categories and people for sidebarbucket |
359 | 359 | $sideBarLinkBucket = array (); |
360 | 360 | $o .= ' <ul id="results">'; |
361 | | - foreach ($this->results as $inx => & $mvd) { |
| 361 | + foreach ($this->results as $inx => & $mvd) { |
362 | 362 | $mvTitle = new MV_Title($mvd->wiki_title); |
363 | 363 | $mvd_cnt_links = ''; |
364 | 364 | if (isset ($mvd->spoken_by)) { |
— | — | @@ -391,20 +391,20 @@ |
392 | 392 | assoc_array_increment($sideBarLinkBucket, 'bill', $bill_id); |
393 | 393 | } |
394 | 394 | } |
395 | | - //link directly to the current range: |
| 395 | + //link directly to the current range: |
396 | 396 | $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($extra_range = '0')); |
397 | | - //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() ); |
| 397 | + //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() ); |
398 | 398 | $mvd_text = $mvd->text; |
399 | 399 | |
400 | 400 | $o .= '<li class="result"> |
401 | 401 | <span class="vid_img" id="mvimg_' . htmlspecialchars($mvd->id) . '"> |
402 | | - ' . $sk->makeKnownLinkObj($mvStreamTitle, |
403 | | - '<img alt="image for ' . htmlspecialchars($mvTitle->getStreamNameText()) . |
| 402 | + ' . $sk->makeKnownLinkObj($mvStreamTitle, |
| 403 | + '<img alt="image for ' . htmlspecialchars($mvTitle->getStreamNameText()) . |
404 | 404 | ' ' . $mvTitle->getTimeDesc() . '" src="' . $mvTitle->getStreamImageURL('small') . |
405 | | - '"/>') . ' |
| 405 | + '"/>') . ' |
406 | 406 | </span> |
407 | 407 | <div class="result_description"> |
408 | | - <h4>' . |
| 408 | + <h4>' . |
409 | 409 | $sk->makeKnownLinkObj($mvStreamTitle, $mvTitle->getStreamNameText() . |
410 | 410 | ' :: ' . $mvTitle->getTimeDesc()) . |
411 | 411 | '</h4> |
— | — | @@ -421,9 +421,9 @@ |
422 | 422 | wfMsg('mv_play_inline') . '</a></span> |
423 | 423 | </div> |
424 | 424 | </li>'; |
425 | | - } |
| 425 | + } |
426 | 426 | $o .= '</ul>'; |
427 | | - //add in prev-next at bottom too: |
| 427 | + //add in prev-next at bottom too: |
428 | 428 | $o .= '<li class="prevnext">' . $prevnext . '</li>'; |
429 | 429 | $o .= '</div>'; |
430 | 430 | if(!$show_sidebar)return $o; |
— | — | @@ -437,7 +437,7 @@ |
438 | 438 | $first_block = ' first_block'; |
439 | 439 | $matches = 0; |
440 | 440 | $person_out_ary=array(); |
441 | | - $person_out = MV_SpecialMediaSearch :: auto_complete_person($this->unified_term_search, 3, 'person_html', $matches, $person_out_ary); |
| 441 | + $person_out = MV_SpecialMediaSearch :: auto_complete_person($this->unified_term_search, 3, 'person_html', $matches, $person_out_ary); |
442 | 442 | if ($person_out != '' || count($sideBarLinkBucket['person']) != 0) { |
443 | 443 | //for now don't include({$matches}) |
444 | 444 | $o .= "<div class=\"block{$first_block}\"> |
— | — | @@ -460,10 +460,10 @@ |
461 | 461 | $o .= '</div>'; |
462 | 462 | $first_block = ''; |
463 | 463 | } |
464 | | - //get categories |
| 464 | + //get categories |
465 | 465 | $category_out = MV_SpecialMediaSearch :: auto_complete_search_categories($this->unified_term_search, 3, 'block_html', $matches); |
466 | 466 | if ($category_out != '' || count($sideBarLinkBucket['category']) != 0) { |
467 | | - $o .= '<div class="block'.htmlspecialchars($first_block).'\"> |
| 467 | + $o .= '<div class="block'.htmlspecialchars($first_block).'\"> |
468 | 468 | <h6>' . wfMsg('mv_category_results') . '</h6> |
469 | 469 | </div>'; |
470 | 470 | $o .= '<div class="block wide_block">' . $category_out; |
— | — | @@ -504,7 +504,7 @@ |
505 | 505 | $o .= '</div>'; |
506 | 506 | $first_block = ''; |
507 | 507 | } |
508 | | - //intrest out is just simple title matching (for now) |
| 508 | + //intrest out is just simple title matching (for now) |
509 | 509 | $intrest_out = MV_SpecialMediaSearch :: auto_complete_category('Interest_Group', $this->unified_term_search, 3, 'block_html', $matches); |
510 | 510 | if ($intrest_out != '') { |
511 | 511 | $o .= "<div class=\"block{$first_block}\"> |
— | — | @@ -525,7 +525,7 @@ |
526 | 526 | if ($this->outputContainer) |
527 | 527 | $o .= '<div id="mv_search_results_container">'; |
528 | 528 | |
529 | | - //for each stream range: |
| 529 | + //for each stream range: |
530 | 530 | if (count($this->results) == 0) { |
531 | 531 | $o .= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>'; |
532 | 532 | if ($this->outputContainer) |
— | — | @@ -543,7 +543,7 @@ |
544 | 544 | //media pagging: (only display if we have num of results > limit |
545 | 545 | $prevnext = mvViewPrevNext($this->offset, $this->limit, SpecialPage :: getTitleFor('MediaSearch'), $this->get_httpd_filters_query(), ($this->num < $this->limit)); |
546 | 546 | $o .= "<br /><span id=\"mv_search_pagging\">{$prevnext}</span>\n"; |
547 | | - //add the rss link: |
| 547 | + //add the rss link: |
548 | 548 | $sTitle = Title :: MakeTitle(NS_SPECIAL, 'MvExportSearch'); |
549 | 549 | $o .= '<span style="float:right;">'; |
550 | 550 | $o .= $sk->makeKnownLinkObj($sTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/feed-icon-28x28.png">', $this->get_httpd_filters_query()); |
— | — | @@ -561,16 +561,16 @@ |
562 | 562 | $matches++; |
563 | 563 | $mvTitle = new MV_Title($mvd->wiki_title); |
564 | 564 | |
565 | | - //retrieve only the first article: |
| 565 | + //retrieve only the first article: |
566 | 566 | //$title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); |
567 | | - //$article = new Article($title); |
| 567 | + //$article = new Article($title); |
568 | 568 | |
569 | 569 | $bgcolor = MV_Overlay :: getMvdBgColor($mvd); |
570 | | - //output indent if not the first and count more than one |
| 570 | + //output indent if not the first and count more than one |
571 | 571 | if (count($srange['rows']) != 1 && $inx != 0) |
572 | 572 | $mvd_out .= ' '; |
573 | | - //'<img src="'. $mvgScriptPath . '/skins/images/film.png">' |
574 | | - //$mvd_out .= '<div class="mv_rtdesc" title="' . wfMsg('mv_expand_play') . '" '. |
| 573 | + //'<img src="'. $mvgScriptPath . '/skins/images/film.png">' |
| 574 | + //$mvd_out .= '<div class="mv_rtdesc" title="' . wfMsg('mv_expand_play') . '" '. |
575 | 575 | // '> '; |
576 | 576 | $mvd_out .= '<img style="float:left;width:84px;cursor:pointer;border:solid #' .htmlspecialchars($bgcolor) . '" ' . |
577 | 577 | ' onclick="mv_ex(\'' . htmlspecialchars($mvd->id) . '\')" width="80" height="60" src="' . htmlspecialchars($mvTitle->getStreamImageURL('icon')) . '">'; |
— | — | @@ -598,22 +598,22 @@ |
599 | 599 | '</a>' . |
600 | 600 | ' '; |
601 | 601 | //output control links: |
602 | | - //make stream title link: |
| 602 | + //make stream title link: |
603 | 603 | $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName()); |
604 | 604 | //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() ); |
605 | 605 | $mvd_cnt_links .= $sk->makeKnownLinkObj($mvStreamTitle, '<img border="1" src="' . $mvgScriptPath . '/skins/images/run_mv_stream.png"> ' . wfMsg('mv_improve_transcript'), '', '', '', '', ' title="' . htmlspecialchars(wfMsg('mv_view_in_stream_interface')) . '" '); |
606 | 606 | $mvd_cnt_links .= '<br>'; |
607 | 607 | //$title = MakeTitle::() |
608 | | - //don't inclue link to wiki page (too confusing) |
| 608 | + //don't inclue link to wiki page (too confusing) |
609 | 609 | //$mvd_out .=' '; |
610 | 610 | $mvdTitle = Title :: MakeTitle(MV_NS_MVD, $mvd->wiki_title); |
611 | | - //$mvd_out .= $sk->makeKnownLinkObj($mvdTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/run_mediawiki.png">', '', '', '', '', ' title="' . wfMsg('mv_view_wiki_page') . '" '); |
| 611 | + //$mvd_out .= $sk->makeKnownLinkObj($mvdTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/run_mediawiki.png">', '', '', '', '', ' title="' . wfMsg('mv_view_wiki_page') . '" '); |
612 | 612 | |
613 | 613 | $mvd_out .= '<span id="mvr_desc_' . htmlspecialchars($mvd->id) . '">'; |
614 | 614 | |
615 | 615 | if (!isset ($mvd->toplq)) |
616 | 616 | $mvd->toplq = false; |
617 | | - //output short desc send partial regEx: |
| 617 | + //output short desc send partial regEx: |
618 | 618 | if (!$mvd->toplq) { |
619 | 619 | $mvd_out .= $this->termHighlight($mvd->text, implode('|', $this->getTerms())); |
620 | 620 | } else { |
— | — | @@ -626,7 +626,7 @@ |
627 | 627 | } |
628 | 628 | //@@todo parse category info if present |
629 | 629 | $cat_html = ''; |
630 | | - //run via parser to add in Category info: |
| 630 | + //run via parser to add in Category info: |
631 | 631 | $parserOptions = ParserOptions :: newFromUser($wgUser); |
632 | 632 | $parserOptions->setEditSection(false); |
633 | 633 | $parserOptions->setTidy(true); |
— | — | @@ -643,10 +643,10 @@ |
644 | 644 | $mvd_out .= $cat_html; |
645 | 645 | |
646 | 646 | $mvd_out .= (count($srange['rows']) - 1 == 1) ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', count($srange['rows']) - 1); |
647 | | - //$wgOut->addCategoryLinks( $parserOutput->getCategories() ); |
| 647 | + //$wgOut->addCategoryLinks( $parserOutput->getCategories() ); |
648 | 648 | //$cat_html = $sk->getCategories(); |
649 | 649 | //empty out the categories |
650 | | - //$wgOut->mCategoryLinks = array(); |
| 650 | + //$wgOut->mCategoryLinks = array(); |
651 | 651 | } |
652 | 652 | $mvd_out .= '</span>'; |
653 | 653 | $mvd_out .= '<br>' . $mvd_cnt_links; |
— | — | @@ -654,12 +654,12 @@ |
655 | 655 | $mvd_out .= '<div id="mvr_' . htmlspecialchars($mvd->id) . '" style="display:none;background:#' . htmlspecialchars($bgcolor) . ';" ></div>'; |
656 | 656 | } |
657 | 657 | $stream_out .= $mvd_out; |
658 | | - /*if(count($srange['rows'])!=1){ |
659 | | - $stream_out .= ' ' . $cat_html . ' In range:' . |
| 658 | + /*if(count($srange['rows'])!=1){ |
| 659 | + $stream_out .= ' ' . $cat_html . ' In range:' . |
660 | 660 | seconds2ntp($srange['s']) . ' to ' . seconds2ntp($srange['e']) . |
661 | 661 | wfMsg('mv_match_text', count($srange['rows'])).'<br />' . "\n"; |
662 | 662 | $stream_out .= $mvd_out; |
663 | | - }else{ |
| 663 | + }else{ |
664 | 664 | $stream_out .= $mvd_out; |
665 | 665 | }*/ |
666 | 666 | } |
— | — | @@ -694,7 +694,7 @@ |
695 | 695 | |
696 | 696 | break; |
697 | 697 | case 'smw_property_number' : |
698 | | - //should be special case for numeric values |
| 698 | + //should be special case for numeric values |
699 | 699 | break; |
700 | 700 | } |
701 | 701 | } |
— | — | @@ -708,14 +708,14 @@ |
709 | 709 | $term_pat.=$or.$term; |
710 | 710 | $or='|'; |
711 | 711 | } |
712 | | - } |
| 712 | + } |
713 | 713 | if($term_pat=='')return; |
714 | 714 | //@@TODO:: someone somewhere has written a better wiki_text page highlighter |
715 | 715 | $pat1 = "/(\[\[(.*)\]\]|(.*)($term_pat)(.*)/i"; |
716 | 716 | //print "pattern: ". $pat1 . "\n\n"; |
717 | 717 | return preg_replace( $pat1, |
718 | 718 | "$1<span class='searchmatch'>\\2</span>$3", $text ); |
719 | | - //print "\n\ncur text:". $text; |
| 719 | + //print "\n\ncur text:". $text; |
720 | 720 | }*/ |
721 | 721 | /*very similar to showHit in SpecialSearch.php */ |
722 | 722 | function termHighlight(& $text, $terms, $contextlines = 1, $contextchars = 50) { |
— | — | @@ -759,7 +759,7 @@ |
760 | 760 | //$extract .= " <small>{$lineno}: {$line}</small>\n"; |
761 | 761 | $extract .= " {$line}\n"; |
762 | 762 | } |
763 | | - //if we found no matches just return the first line: |
| 763 | + //if we found no matches just return the first line: |
764 | 764 | if ($extract == '') |
765 | 765 | return ' ' . $wgContLang->truncate($text, ($contextchars * 2), '...') . ''; |
766 | 766 | //wfProfileOut( "$fname-extract" ); |
— | — | @@ -788,7 +788,7 @@ |
789 | 789 | $wgOut->getHTML() . |
790 | 790 | '</span>'; |
791 | 791 | |
792 | | - //return page html: |
| 792 | + //return page html: |
793 | 793 | return $embedHTML . $pageHTML . '<div style="clear: both;"/>'; |
794 | 794 | } else { |
795 | 795 | return wfMsg('mvBadMVDtitle'); |
— | — | @@ -802,7 +802,7 @@ |
803 | 803 | //return $wgOut->parse($article->getContent()); |
804 | 804 | } |
805 | 805 | function get_httpd_filters_query() { |
806 | | - //get all the mvd ns selected: |
| 806 | + //get all the mvd ns selected: |
807 | 807 | $opt = $this->powerSearchOptions(); |
808 | 808 | return http_build_query($opt + array ( |
809 | 809 | 'f' => $this->filters |
— | — | @@ -821,8 +821,8 @@ |
822 | 822 | if (!isset ($filter['a'])) //and, or, not |
823 | 823 | $filter['a'] = ''; |
824 | 824 | |
825 | | - //output the master selecter per line: |
826 | | - $s .= '<br><span id="mvs_' . htmlspecialchars($i) . '">'; |
| 825 | + //output the master selecter per line: |
| 826 | + $s .= '<br><span id="mvs_' . htmlspecialchars($i) . '">'; |
827 | 827 | $s .= ' '; |
828 | 828 | //selctor (don't display if i==0') |
829 | 829 | $s .= $this->selector($i, 'a', $filter['a'], ($i == 0) ? false : true); |
— | — | @@ -837,7 +837,7 @@ |
838 | 838 | $s .= $this->text_entry($i, 'v', $filter['v']); |
839 | 839 | break; |
840 | 840 | case 'date_range' : |
841 | | - $s .= wfMsg('mv_time_separator', $this->text_entry($i, 'vs', $filter['vs'], 'date-pick_' . $i, array('id'=>'vs_' . $i )), |
| 841 | + $s .= wfMsg('mv_time_separator', $this->text_entry($i, 'vs', $filter['vs'], 'date-pick_' . $i, array('id'=>'vs_' . $i )), |
842 | 842 | $this->text_entry($i, 've', $filter['ve'], 'date-pick_' . $i, array('id'=>'ve_' . $i ))); |
843 | 843 | //also output dateObj (if not already output): |
844 | 844 | if (!$dateObjOut) { |
— | — | @@ -848,7 +848,7 @@ |
849 | 849 | '<!-- required plugins --> |
850 | 850 | <script type="text/javascript" src="' . $mvgScriptPath . '/skins/mv_embed/jquery/plugins/date.js"></script> |
851 | 851 | <!--[if IE]><script type="text/javascript" src="' . $mvgScriptPath . '/skins/mv_embed/jquery/plugins/jquery.bgiframe.js"></script><![endif]--> |
852 | | - |
| 852 | + |
853 | 853 | <!-- jquery.datePicker.js --> |
854 | 854 | <script type="text/javascript" src="' . $mvgScriptPath . '/skins/mv_embed/jquery/plugins/jquery.datePicker.js"></script> |
855 | 855 | <script language="javascript" type="text/javascript">' . |
— | — | @@ -876,13 +876,13 @@ |
877 | 877 | $s .= '</span>'; |
878 | 878 | } |
879 | 879 | $s .= '</div>'; |
880 | | - //reference remove |
| 880 | + //reference remove |
881 | 881 | $s .= '<a id="mv_ref_remove" style="display:none;" ' . |
882 | 882 | 'href="">' . |
883 | 883 | '<img title="' . htmlspecialchars( wfMsg('mv_remove_filter') ) . '" ' . |
884 | 884 | 'src="' . $mvgScriptPath . '/skins/images/cog_delete.png"></a>'; |
885 | 885 | |
886 | | - //ref missing person image ref: |
| 886 | + //ref missing person image ref: |
887 | 887 | $s .= $this->get_ref_person(); |
888 | 888 | |
889 | 889 | //add link: |
— | — | @@ -921,7 +921,7 @@ |
922 | 922 | if ($inx != 0) |
923 | 923 | $a = ' ' . wfMsg('mv_search_' . $f['a']) . ' '; |
924 | 924 | $o .= ($query_key) ? $a : $a . wfMsg('mv_' . $f['t']) . ' '; |
925 | | - if ($f['t'] == 'date_range') { //handle special case of date range: |
| 925 | + if ($f['t'] == 'date_range') { //handle special case of date range: |
926 | 926 | $o .= wfMsg('mv_time_separator', $bo . htmlspecialchars($f['vs']) . $bc, $bo . htmlspecialchars($f['ve']) . $bc); |
927 | 927 | } else { |
928 | 928 | $o .= $bo . str_replace('_', ' ', htmlspecialchars($f['v'])) . $bc; |
— | — | @@ -940,7 +940,7 @@ |
941 | 941 | $person_name = ''; |
942 | 942 | $disp = 'none'; |
943 | 943 | } |
944 | | - //make the missing person image ref: |
| 944 | + //make the missing person image ref: |
945 | 945 | $imgTitle = Title :: makeTitle(NS_IMAGE, $person_name . '.jpg'); |
946 | 946 | if (!$imgTitle->exists()) { |
947 | 947 | $imgTitle = Title :: makeTitle(NS_IMAGE, MV_MISSING_PERSON_IMG); |
— | — | @@ -961,9 +961,9 @@ |
962 | 962 | } |
963 | 963 | function selector($i, $key, $selected = '', $display = true) { |
964 | 964 | $disp = ($display) ? '' : 'display:none;'; |
965 | | - $s = '<select id="mvsel_' . htmlspecialchars($key) . '_' . |
| 965 | + $s = '<select id="mvsel_' . htmlspecialchars($key) . '_' . |
966 | 966 | htmlspecialchars($i) . '" class="mv_search_select" style="font-size: 12px;' . |
967 | | - htmlspecialchars($disp) . '" name="f[' . htmlspecialchars($i) . '][' . |
| 967 | + htmlspecialchars($disp) . '" name="f[' . htmlspecialchars($i) . '][' . |
968 | 968 | htmlspecialchars($key) . ']" >' . "\n"; |
969 | 969 | $items = ($key == 't') ? $this->sel_filter_types : $this->sel_filter_andor; |
970 | 970 | if ($key == 'a' && $selected == '') |
— | — | @@ -979,14 +979,14 @@ |
980 | 980 | $s .= '</select>'; |
981 | 981 | return $s; |
982 | 982 | } |
983 | | - //could be a suggest: |
| 983 | + //could be a suggest: |
984 | 984 | function text_entry($i, $key, $val = '', $more_class = '', $more_attr = array()) { |
985 | 985 | if ($more_class != '') |
986 | 986 | $more_class = ' ' . $more_class; |
987 | 987 | foreach($more_attr as $k=>$v){ |
988 | 988 | $more_attr_out.=' '.htmlspecialchars($k).'="'.$v.'"'; |
989 | 989 | } |
990 | | - $s = '<input ' . $more_attr_out . ' class="mv_search_text' . htmlspecialchars($more_class) . '" style="font-size: 12px;" onchange="" |
| 990 | + $s = '<input ' . $more_attr_out . ' class="mv_search_text' . htmlspecialchars($more_class) . '" style="font-size: 12px;" onchange="" |
991 | 991 | size="9" type="text" name="f[' . htmlspecialchars($i) . '][' . htmlspecialchars($key) . ']" value="' . htmlspecialchars($val) . '">'; |
992 | 992 | return $s; |
993 | 993 | } |
— | — | @@ -998,7 +998,7 @@ |
999 | 999 | |
1000 | 1000 | $catNStxt = $wgContLang->getNsText(NS_CATEGORY); |
1001 | 1001 | |
1002 | | - //make sure people know they can "search" too (formated by |
| 1002 | + //make sure people know they can "search" too (formated by |
1003 | 1003 | $out = 'do_search|' . wfMsg('mv_search_transcripts_for', '<B>$1</B>') . '|no_image' . "\n"; |
1004 | 1004 | //get keywords |
1005 | 1005 | $category_out = MV_SpecialMediaSearch :: auto_complete_search_categories($val, 3); |
— | — | @@ -1012,7 +1012,7 @@ |
1013 | 1013 | $out .= $catNStxt . ':Person|<h6>' . wfMsg('mv_people_matches') . '</h6>|no_image' . "\n"; |
1014 | 1014 | $out .= $person_out; |
1015 | 1015 | } |
1016 | | - //get bills |
| 1016 | + //get bills |
1017 | 1017 | $bill_out = MV_SpecialMediaSearch :: auto_complete_category('Bill', $val, 3); |
1018 | 1018 | if ($bill_out != '') { |
1019 | 1019 | $out .= $catNStxt . ':Bill|<h6>' . wfMsg('mv_bill_matches') . '</h6>|no_image' . "\n"; |
— | — | @@ -1081,7 +1081,7 @@ |
1082 | 1082 | while ($row = $dbr->fetchObject($result)) { |
1083 | 1083 | $person_name = $row->cl_sortkey; |
1084 | 1084 | $person_ary[$person_name]=true; |
1085 | | - //make sure the person page exists: |
| 1085 | + //make sure the person page exists: |
1086 | 1086 | $personTitle = Title :: makeTitle(NS_MAIN, $person_name); |
1087 | 1087 | if ($personTitle->exists()) { |
1088 | 1088 | //get person full name from semantic table if available |
— | — | @@ -1103,7 +1103,7 @@ |
1104 | 1104 | return $out; |
1105 | 1105 | } |
1106 | 1106 | function getPersonImageURL($person_name) { |
1107 | | - //make the missing person image ref: |
| 1107 | + //make the missing person image ref: |
1108 | 1108 | $imgTitle = Title :: makeTitle(NS_IMAGE, $person_name . '.jpg'); |
1109 | 1109 | if (!$imgTitle->exists()) { |
1110 | 1110 | $imgTitle = Title :: makeTitle(NS_IMAGE, MV_MISSING_PERSON_IMG); |
— | — | @@ -1116,9 +1116,9 @@ |
1117 | 1117 | return $img->getURL(); |
1118 | 1118 | } |
1119 | 1119 | function format_ac_line(& $page_title, $val, $prefix = '', $img_link = 'no_image', $format = 'ac_line') { |
1120 | | - //no underscores in display title: |
| 1120 | + //no underscores in display title: |
1121 | 1121 | $page_title_disp = str_replace('_', ' ', $page_title); |
1122 | | - //bold matching part of title: |
| 1122 | + //bold matching part of title: |
1123 | 1123 | $bs = stripos($page_title_disp, str_replace('_', ' ', $val)); |
1124 | 1124 | if ($bs !== false) { |
1125 | 1125 | $page_title_disp = substr($page_title_disp, 0, $bs) . |
— | — | @@ -1142,7 +1142,7 @@ |
1143 | 1143 | return "<p class=\"people2_match last_match\"><img src=\"{$img_link}\">" . $sk->makeKnownLinkObj($title, $page_title_disp) . '</p>'; |
1144 | 1144 | } |
1145 | 1145 | } |
1146 | | - //return a json date obj |
| 1146 | + //return a json date obj |
1147 | 1147 | //@@todo fix for big sites...(will start to be no fun if number of streams is > 2000 ) |
1148 | 1148 | function getJsonDateObj($obj_name = 'mv_result') { |
1149 | 1149 | $dbr = & wfGetDB(DB_SLAVE); |
— | — | @@ -1180,4 +1180,3 @@ |
1181 | 1181 | ), 'ed' => date('m/d/Y', $end_day), 'sdays' => $sDays), $obj_name); |
1182 | 1182 | } |
1183 | 1183 | } |
1184 | | -?> |
Index: trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_MetavidInterface.php |
— | — | @@ -4,152 +4,151 @@ |
5 | 5 | * |
6 | 6 | * All Metavid Wiki code is Released Under the GPL2 |
7 | 7 | * for more info visit http:/metavid.ucsc.edu/code |
8 | | - * |
9 | | - * |
| 8 | + * |
| 9 | + * |
10 | 10 | * The metavid interface class |
11 | 11 | * provides the metavid interface for Metavid: requests |
12 | 12 | * provides the base metadata |
13 | | - * |
| 13 | + * |
14 | 14 | */ |
15 | 15 | if ( !defined( 'MEDIAWIKI' ) ) die( 1 ); |
16 | 16 | |
17 | | - |
| 17 | + |
18 | 18 | class MV_MetavidInterface{ |
19 | | - var $components = array(); |
20 | | - var $context=null; |
21 | | - var $page_title=''; |
22 | | - var $page_header=''; |
23 | | - //list the properties we are intersted and there default values: |
24 | | - var $smwProperties = array('playback_resolution'=>null); |
25 | | - function __construct($contextType, & $contextArticle=null ){ |
26 | | - global $mv_default_view; |
27 | | - $this->context = $contextType; |
28 | | - if($contextArticle) |
29 | | - $this->article = & $contextArticle; |
30 | | - //set up base layout for each context: |
31 | | - switch($contextType){ |
32 | | - case 'special': |
33 | | - $this->setupSpecialView(); |
34 | | - break; |
35 | | - case 'edit_sequence': |
36 | | - $this->setupEditSequenceView(); |
37 | | - break; |
38 | | - case 'sequence': |
39 | | - $this->setupSequenceView(); |
40 | | - break; |
41 | | - case 'stream': |
42 | | - $this->setupStreamView(); |
43 | | - break; |
44 | | - } |
45 | | - } |
46 | | - /*function setupSequenceView(){ |
47 | | - global $mvgIP; |
48 | | - //set up the base sequence: |
49 | | - foreach(array('MV_VideoPlayer', '' |
50 | | - /*foreach(array('MV_VideoPlayer') as $cp_name){ |
| 19 | + var $components = array(); |
| 20 | + var $context=null; |
| 21 | + var $page_title=''; |
| 22 | + var $page_header=''; |
| 23 | + //list the properties we are intersted and there default values: |
| 24 | + var $smwProperties = array('playback_resolution'=>null); |
| 25 | + function __construct($contextType, & $contextArticle=null ){ |
| 26 | + global $mv_default_view; |
| 27 | + $this->context = $contextType; |
| 28 | + if($contextArticle) |
| 29 | + $this->article = & $contextArticle; |
| 30 | + //set up base layout for each context: |
| 31 | + switch($contextType){ |
| 32 | + case 'special': |
| 33 | + $this->setupSpecialView(); |
| 34 | + break; |
| 35 | + case 'edit_sequence': |
| 36 | + $this->setupEditSequenceView(); |
| 37 | + break; |
| 38 | + case 'sequence': |
| 39 | + $this->setupSequenceView(); |
| 40 | + break; |
| 41 | + case 'stream': |
| 42 | + $this->setupStreamView(); |
| 43 | + break; |
| 44 | + } |
| 45 | + } |
| 46 | + /*function setupSequenceView(){ |
| 47 | + global $mvgIP; |
| 48 | + //set up the base sequence: |
| 49 | + foreach(array('MV_VideoPlayer', '' |
| 50 | + /*foreach(array('MV_VideoPlayer') as $cp_name){ |
51 | 51 | require_once($mvgIP . '/includes/MV_MetavidInterface/'.$cp_name.'.php'); |
52 | | - $this->components[$cp_name] = new $cp_name( |
| 52 | + $this->components[$cp_name] = new $cp_name( |
53 | 53 | array('mv_interface'=>&$this) |
54 | | - ); |
| 54 | + ); |
55 | 55 | } |
56 | | - }*/ |
57 | | - function setupEditSequenceView(){ |
58 | | - global $mvgIP, $wgTitle; |
59 | | - foreach(array('MV_SequencePlayer', 'MV_SequenceTools', 'MV_SequenceTimeline') as $cp_name){ |
60 | | - $this->components[$cp_name] = new $cp_name( |
| 56 | + }*/ |
| 57 | + function setupEditSequenceView(){ |
| 58 | + global $mvgIP, $wgTitle; |
| 59 | + foreach(array('MV_SequencePlayer', 'MV_SequenceTools', 'MV_SequenceTimeline') as $cp_name){ |
| 60 | + $this->components[$cp_name] = new $cp_name( |
61 | 61 | array('mv_interface'=>&$this) |
62 | | - ); |
| 62 | + ); |
63 | 63 | } |
64 | 64 | //set up additonal pieces |
65 | | - $this->page_title=wfMsg('mv_edit_sequence', $wgTitle->getText() ); |
66 | | - } |
67 | | - function setupStreamView(){ |
68 | | - global $mvgIP, $mvDefaultStreamViewLength, $wgOut,$mvgScriptPath,$wgUser; |
69 | | - |
70 | | - //set default time range if null time range request |
71 | | - $this->article->mvTitle->setStartEndIfEmpty(); |
72 | | - //grab relevent article semantic properties (so far playback_resolution) for user overwriting playback res |
73 | | - $this->grabSemanticProp(); |
74 | | - |
| 65 | + $this->page_title=wfMsg('mv_edit_sequence', $wgTitle->getText() ); |
| 66 | + } |
| 67 | + function setupStreamView(){ |
| 68 | + global $mvgIP, $mvDefaultStreamViewLength, $wgOut,$mvgScriptPath,$wgUser; |
| 69 | + |
| 70 | + //set default time range if null time range request |
| 71 | + $this->article->mvTitle->setStartEndIfEmpty(); |
| 72 | + //grab relevant article semantic properties (so far playback_resolution) for user overwriting playback res |
| 73 | + $this->grabSemanticProp(); |
| 74 | + |
75 | 75 | //set up the interface objects: |
76 | 76 | foreach(array('MV_VideoPlayer', 'MV_Overlay','MV_Tools') as $cp_name){ |
77 | | - $this->components[$cp_name] = new $cp_name( |
| 77 | + $this->components[$cp_name] = new $cp_name( |
78 | 78 | array('mv_interface'=>&$this) |
79 | | - ); |
| 79 | + ); |
80 | 80 | } |
81 | 81 | //process track request: |
82 | | - $this->components['MV_Overlay']->procMVDReqSet(); |
| 82 | + $this->components['MV_Overlay']->procMVDReqSet(); |
83 | 83 | //add in title & tracks var: |
84 | 84 | global $mvgScriptPath; |
85 | | - $wgOut->addScript('<script type="text/javascript">/*<![CDATA[*/'.' |
86 | | - var mvTitle = \''.htmlspecialchars($this->article->mvTitle->getWikiTitle()).'\'; |
87 | | - var mvTracks = \''.htmlspecialchars($this->components['MV_Overlay']->getMVDReqString()). '\'; |
88 | | - var mvgScriptPath = \''.htmlspecialchars($mvgScriptPath).'\'; |
89 | | - /*]]>*/</script>'); |
90 | | - |
91 | | - //also add prev next paging |
| 85 | + $wgOut->addScript('<script type="text/javascript">/*<![CDATA[*/'.' |
| 86 | + var mvTitle = \''.htmlspecialchars($this->article->mvTitle->getWikiTitle()).'\'; |
| 87 | + var mvTracks = \''.htmlspecialchars($this->components['MV_Overlay']->getMVDReqString()). '\'; |
| 88 | + var mvgScriptPath = \''.htmlspecialchars($mvgScriptPath).'\'; |
| 89 | + /*]]>*/</script>'); |
| 90 | + |
| 91 | + //also add prev next paging |
92 | 92 | $this->page_header ='<h1 class="videoHeader">'. |
93 | | - $this->article->mvTitle->getStreamNameText().' :: '. |
94 | | - $this->components['MV_Tools']->stream_paging_links('prev') . |
| 93 | + $this->article->mvTitle->getStreamNameText().' :: '. |
| 94 | + $this->components['MV_Tools']->stream_paging_links('prev') . |
95 | 95 | ' <span title="'.htmlspecialchars(wfMsg('mv_click_to_edit')).'" id="mv_stream_time">'.$this->article->mvTitle->getTimeDesc($span_separated=true) . '</span>'. |
96 | 96 | $this->components['MV_Tools']->stream_paging_links('next') . |
97 | | - wfMsg('mv_of') . seconds2ntp($this->article->mvTitle->getDuration()) . |
98 | | - '</h1>'; |
99 | | - |
| 97 | + wfMsg('mv_of') . seconds2ntp($this->article->mvTitle->getDuration()) . |
| 98 | + '</h1>'; |
| 99 | + |
100 | 100 | //add export cmml icon |
101 | 101 | $this->page_header.='<span id="cmml_link"/>'; |
102 | | - $sTitle = Title::makeTitle(NS_SPECIAL, 'MvExportStream'); |
| 102 | + $sTitle = Title::makeTitle(NS_SPECIAL, 'MvExportStream'); |
103 | 103 | $sk = $wgUser->getSkin(); |
104 | 104 | $this->page_header.= $sk->makeKnownLinkObj($sTitle, |
105 | 105 | '<img style="width:28px;height:28px;" src="'.htmlspecialchars($mvgScriptPath) . '/skins/images/Feed-icon_cmml_28x28.png">', |
106 | 106 | 'feed_format=roe&stream_name='.htmlspecialchars($this->article->mvTitle->getStreamName()).'&t='.htmlspecialchars($this->article->mvTitle->getTimeRequest()), |
107 | 107 | '','','title="'.htmlspecialchars(wfMsg('mv_export_cmml')).'"'); |
108 | | - $this->page_header.='</span>'; |
| 108 | + $this->page_header.='</span>'; |
109 | 109 | $this->page_title = $this->article->mvTitle->getStreamNameText().' '.$this->article->mvTitle->getTimeDesc(); |
110 | | - } |
111 | | - //grab semantic properties if availiable: |
112 | | - //@@todo we need to think this through a bit |
113 | | - function grabSemanticProp(){ |
114 | | - if(SMW_VERSION){ |
115 | | - //global $smwgIP; |
116 | | - $smwStore =& smwfGetStore(); |
117 | | - foreach($this->smwProperties as $propKey=>$val){ |
118 | | - $propTitle = Title::newFromText($propKey, SMW_NS_PROPERTY); |
119 | | - $smwProps = $smwStore->getPropertyValues($this->article->mTitle,$propTitle ); |
120 | | - //just a temp hack .. we need to think about this abstraction a bit... |
121 | | - if(count($smwProps)!=0){ |
122 | | - $v = current($smwProps); |
123 | | - $this->smwProperties[$propKey]=$v->getXSDValue(); |
124 | | - } |
125 | | - } |
126 | | - } |
127 | | - } |
128 | | - /* |
129 | | - * renders the full page to the wgOut object |
130 | | - */ |
131 | | - function render_full(){ |
132 | | - global $wgOut; |
133 | | - //add some variables for the interface: |
134 | | - |
135 | | - //output title and header: |
136 | | - $wgOut->setHTMLTitle($this->page_title); |
137 | | - |
138 | | - if($this->page_header=='')$this->page_header = '<span style="position:relative;top:-12px;font-weight:bold">' . |
139 | | - htmlspecialchars($this->page_title) . '</span>'; |
140 | | - $wgOut->addHTML($this->page_header); |
141 | | - |
142 | | - //@@todo dynamic re-size page_spacer: |
143 | | - $wgOut->addHTML('<div id="mv_interface_container">'); |
144 | | - foreach($this->components as $cpKey => &$component){ |
145 | | - $component->render_full(); |
146 | | - } |
147 | | - $wgOut->addHTML('</div>'); |
148 | | - //for now output spacers |
149 | | - //@@todo output a dynamic spacer javascript layout |
150 | | - //$out=''; |
151 | | - //for($i=0;$i<28;$i++)$out.="<br />"; |
152 | | - //$wgOut->addHTML($out); |
153 | | - //} |
154 | | - } |
155 | | - } |
156 | | -?> |
| 110 | + } |
| 111 | + //grab semantic properties if availiable: |
| 112 | + //@@todo we need to think this through a bit |
| 113 | + function grabSemanticProp(){ |
| 114 | + if(SMW_VERSION){ |
| 115 | + //global $smwgIP; |
| 116 | + $smwStore =& smwfGetStore(); |
| 117 | + foreach($this->smwProperties as $propKey=>$val){ |
| 118 | + $propTitle = Title::newFromText($propKey, SMW_NS_PROPERTY); |
| 119 | + $smwProps = $smwStore->getPropertyValues($this->article->mTitle,$propTitle ); |
| 120 | + //just a temp hack .. we need to think about this abstraction a bit... |
| 121 | + if(count($smwProps)!=0){ |
| 122 | + $v = current($smwProps); |
| 123 | + $this->smwProperties[$propKey]=$v->getXSDValue(); |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | + /* |
| 129 | + * renders the full page to the wgOut object |
| 130 | + */ |
| 131 | + function render_full(){ |
| 132 | + global $wgOut; |
| 133 | + //add some variables for the interface: |
| 134 | + |
| 135 | + //output title and header: |
| 136 | + $wgOut->setHTMLTitle($this->page_title); |
| 137 | + |
| 138 | + if($this->page_header=='')$this->page_header = '<span style="position:relative;top:-12px;font-weight:bold">' . |
| 139 | + htmlspecialchars($this->page_title) . '</span>'; |
| 140 | + $wgOut->addHTML($this->page_header); |
| 141 | + |
| 142 | + //@@todo dynamic re-size page_spacer: |
| 143 | + $wgOut->addHTML('<div id="mv_interface_container">'); |
| 144 | + foreach($this->components as $cpKey => &$component){ |
| 145 | + $component->render_full(); |
| 146 | + } |
| 147 | + $wgOut->addHTML('</div>'); |
| 148 | + //for now output spacers |
| 149 | + //@@todo output a dynamic spacer javascript layout |
| 150 | + //$out=''; |
| 151 | + //for($i=0;$i<28;$i++)$out.="<br />"; |
| 152 | + //$wgOut->addHTML($out); |
| 153 | + //} |
| 154 | + } |
| 155 | +} |
Index: trunk/extensions/MetavidWiki/languages/MV_Messages.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | 'mvexportsearch' => 'Metavid export', |
35 | 35 | 'mvexportsequence' => 'Metavid export sequence', |
36 | 36 | 'mvexportstream' => 'Metavid export stream', |
37 | | - |
| 37 | + |
38 | 38 | 'mv_add_stream_page' => 'Mv add stream', |
39 | 39 | 'mv_edit_strea_docu' => '<p>Edit stream <b>admin</b><br />for normal user view/edit see $1 page', |
40 | 40 | 'mv_add_stream_docu' => '<p>Add a new Stream with the field below.</p> |
— | — | @@ -63,8 +63,8 @@ |
64 | 64 | 'mv_label_stream_name' => 'Stream name', |
65 | 65 | 'mv_label_stream_desc' => 'Stream description', |
66 | 66 | 'add_stream_permission' => 'You lack permission to add a new stream', |
67 | | - 'edit_stream_missing' => 'Missing stream name', |
68 | | - 'mv_missing_req_time' => 'Missing request time', |
| 67 | + 'edit_stream_missing' => 'Missing stream name', |
| 68 | + 'mv_missing_req_time' => 'Missing request time', |
69 | 69 | 'mv_missing_cat' => 'Missing category name', |
70 | 70 | 'mv_stream_already_exists' => 'The stream <a href="$2">$1</a> already exists', |
71 | 71 | 'mv_summary_add_stream' => 'stream added by form', |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | 'mv_metavid_live' => 'Set up live stream', |
81 | 81 | 'mv_upload_file' => 'Upload file', |
82 | 82 | 'mv_external_file' => 'External file', |
83 | | - 'mv_stream_delete_warning' => 'Deleting this stream will additionally remove $1 pages of metadata', |
| 83 | + 'mv_stream_delete_warning' => 'Deleting this stream will additionally remove $1 pages of metadata', |
84 | 84 | |
85 | 85 | #tools |
86 | 86 | 'mv_tool_search' => 'Search', |
— | — | @@ -102,7 +102,7 @@ |
103 | 103 | 'mv_people_matches' => 'People matches', |
104 | 104 | 'mv_category_matches' => 'Category matches', |
105 | 105 | 'mv_bill_matches' => 'Bill matches', |
106 | | - 'mv_interest_group_matches' => 'Interest group matches', |
| 106 | + 'mv_interest_group_matches' => 'Interest group matches', |
107 | 107 | 'mv_click_to_edit' => 'click to edit', |
108 | 108 | |
109 | 109 | #mvd types: |
— | — | @@ -131,7 +131,7 @@ |
132 | 132 | 'mv_list_streams_none' => 'No streams exist', |
133 | 133 | |
134 | 134 | #messages for metavid export feed: |
135 | | - 'mvvideofeed' => 'Metavid video feed export', |
| 135 | + 'mvvideofeed' => 'Metavid video feed export', |
136 | 136 | 'mvexportask' => 'Semantic video feed export', |
137 | 137 | 'video_feed_cat' => 'Video feed for category:', |
138 | 138 | 'mv_cat_search_note' => 'Note: Categories only lists top level categories. |
— | — | @@ -166,16 +166,16 @@ |
167 | 167 | 'mv_start_desc' => 'Start time', |
168 | 168 | 'mv_end_desc' => 'End time', |
169 | 169 | 'mv_of' => ' of ', |
170 | | - |
| 170 | + |
171 | 171 | 'mv_edit_metadata' => 'Edit metadata', |
172 | 172 | 'mv_advanced_edit' => 'Advanced edit', |
173 | 173 | 'mv_basic_edit' => 'Basic edit', |
174 | 174 | 'mv_remove_category' => 'Remove category', |
175 | 175 | 'mv_existing_categories' => 'Existing categories:', |
176 | | - 'mv_add_category' => 'Add a categorization', |
| 176 | + 'mv_add_category' => 'Add a categorization', |
177 | 177 | 'mv_basic_text_desc' => 'Text description (optional)', |
178 | | - |
179 | | - |
| 178 | + |
| 179 | + |
180 | 180 | #search |
181 | 181 | 'mediasearch' => 'Media search', |
182 | 182 | 'mv_search_sel_t' => 'Select search type', |
— | — | @@ -197,13 +197,13 @@ |
198 | 198 | 'mv_stream_name' => 'stream name', |
199 | 199 | 'mv_date_range' => 'date range', |
200 | 200 | 'mv_date_last_week' => 'Last week', |
201 | | - |
| 201 | + |
202 | 202 | 'mv_category_results' => 'Category results', |
203 | 203 | 'mv_people_results' => 'People results', |
204 | 204 | 'mv_bill_results' => 'Bill results', |
205 | 205 | 'mv_intrest_group_results' => 'Interst groups', |
206 | | - |
207 | | - 'mv_most_relevent' => 'Most relevent', |
| 206 | + |
| 207 | + 'mv_most_relevant' => 'Most relevant', |
208 | 208 | 'mv_most_recent' => 'Most recent', |
209 | 209 | 'mv_most_viewed' => 'Most viewed', |
210 | 210 | |
— | — | @@ -437,7 +437,7 @@ |
438 | 438 | 'thomas_en_desc' => "ترانس سكريبت توماس الرسمي من خدمة تسجيل THOMAS الرسمية. |
439 | 439 | وقت المصدر معدل بواسطة C-SPAN's c-spanarchives.org", |
440 | 440 | 'mvd_default_mismatch' => 'خطأ في ملف الإعدادات', |
441 | | - 'mvd_default_mismatch_text' => 'هناك خطأ في ملف إعداداتك. |
| 441 | + 'mvd_default_mismatch_text' => 'هناك خطأ في ملف إعداداتك. |
442 | 442 | $mvMVDTypeDefaultDisp يجب أن تكون جزء من $mvMVDTypeAllAvailable', |
443 | 443 | 'mv_data_page_title' => '$1 ل$2 من $3', |
444 | 444 | 'mv_time_separator' => '$1 إلى $2', |
— | — | @@ -3672,4 +3672,3 @@ |
3673 | 3673 | $messages['vo'] = array( |
3674 | 3674 | 'mv_search_category' => 'Klad', |
3675 | 3675 | ); |
3676 | | - |