Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Index.php |
— | — | @@ -196,6 +196,10 @@ |
197 | 197 | |
198 | 198 | list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset( 20, 'searchlimit' ); |
199 | 199 | if($this->limit > $mvMediaSearchResultsLimit)$this->limit = $mvMediaSearchResultsLimit; |
| 200 | + |
| 201 | + $this->order_type = $wgRequest->getVal('order'); |
| 202 | + //force order type: |
| 203 | + if($this->order_type!='relevent' || $this->order_type!='recent' || $this->order_type!='viewed') $this->order_type='relevent'; |
200 | 204 | |
201 | 205 | $group_spoken=true; |
202 | 206 | $categoryTable = $dbr->tableName( 'categorylinks'); |
Index: branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /* |
4 | 5 | * Created on Jul 26, 2007 |
5 | 6 | * |
— | — | @@ -7,29 +8,29 @@ |
8 | 9 | * |
9 | 10 | * overwrites the existing special search to add in metavid specific features |
10 | 11 | */ |
11 | | -if (!defined('MEDIAWIKI')) die(); |
| 12 | +if (!defined('MEDIAWIKI')) |
| 13 | + die(); |
12 | 14 | |
13 | 15 | function doSpecialSearch($par = null) { |
14 | 16 | //list( $limit, $offset ) = wfCheckLimits(); |
15 | | - $MvSpecialSearch = new MV_SpecialMediaSearch(); |
| 17 | + $MvSpecialSearch = new MV_SpecialMediaSearch(); |
16 | 18 | $MvSpecialSearch->doSearchPage(); |
17 | 19 | } |
18 | 20 | //metavid search page (only search video media) |
19 | 21 | SpecialPage :: addPage(new SpecialPage('MediaSearch', '', true, 'doSpecialSearch', false)); |
20 | 22 | |
21 | | - |
22 | 23 | /* |
23 | 24 | * adds media results to top of special page: |
24 | 25 | */ |
25 | | -class MV_SpecialSearch extends SpecialPage{ |
26 | | - function MV_SpecialSearch( ) { |
27 | | - global $wgOut, $wgRequest; |
| 26 | +class MV_SpecialSearch extends SpecialPage { |
| 27 | + function MV_SpecialSearch() { |
| 28 | + global $wgOut, $wgRequest; |
28 | 29 | //mvfAddHTMLHeader('search'); |
29 | 30 | //$MvSpecialSearch = new MV_SpecialMediaSearch(); |
30 | 31 | //$MvSpecialSearch->setupFilters(); |
31 | 32 | //$MvSpecialSearch->doSearch(); |
32 | 33 | //$wgOut->addHTML($MvSpecialSearch->getResultsHTML()); |
33 | | - SpecialPage::SpecialPage('Search'); |
| 34 | + SpecialPage :: SpecialPage('Search'); |
34 | 35 | } |
35 | 36 | } |
36 | 37 | /* |
— | — | @@ -43,550 +44,583 @@ |
44 | 45 | class MV_SpecialMediaSearch extends SpecialPage { |
45 | 46 | //initial values for selectors ( keys into language as 'mv_search_$val') |
46 | 47 | var $sel_filter_types = array ( |
47 | | - 'match', //full text search |
48 | | - 'spoken_by', |
49 | | - 'category', |
50 | | - 'date_range', //search in a given date range |
| 48 | + 'match', //full text search |
| 49 | + 'spoken_by', |
| 50 | + 'category', |
| 51 | + 'date_range', //search in a given date range |
51 | 52 | //not yet active: |
52 | 53 | //'stream_name', //search within a particular stream |
53 | 54 | //'layers' //specify a specific meta-layer set |
54 | 55 | //'smw_property' |
55 | 56 | //'smw_property_numeric' |
56 | | - ); |
| 57 | + |
| 58 | + ); |
57 | 59 | var $sel_filter_andor = array ( |
58 | 60 | 'and', |
59 | 61 | 'or', |
60 | 62 | 'not', |
61 | | - ); |
| 63 | + |
| 64 | + ); |
62 | 65 | var $unified_term_search = ''; |
63 | | - var $adv_search=false; |
64 | | - |
65 | | - var $results=array(); |
66 | | - var $mName = 'MediaSearch'; |
67 | | - var $outputInlineHeader =true; |
| 66 | + var $adv_search = false; |
| 67 | + |
| 68 | + var $results = array (); |
| 69 | + var $mName = 'MediaSearch'; |
| 70 | + var $outputInlineHeader = true; |
68 | 71 | var $outputContainer = true; |
69 | 72 | var $outputSeqLinks = false; |
70 | | - |
| 73 | + |
71 | 74 | var $limit = 20; |
72 | 75 | var $offset = 0; |
73 | | - |
74 | | - function doSearchPage($term='') { |
| 76 | + var $order = 'relevent'; |
| 77 | + |
| 78 | + function doSearchPage($term = '') { |
75 | 79 | global $wgRequest, $wgOut, $wgUser; |
76 | 80 | $this->setUpFilters(); |
77 | 81 | //do the search |
78 | 82 | $this->doSearch(); |
79 | 83 | //page control: |
80 | | - $this->outputInlineHeader=false; |
81 | | - if($wgRequest->getVal('seq_inline')=='true'){ |
| 84 | + $this->outputInlineHeader = false; |
| 85 | + if ($wgRequest->getVal('seq_inline') == 'true') { |
82 | 86 | $this->outputContainer = false; |
83 | | - $this->outputSeqLinks=true; |
| 87 | + $this->outputSeqLinks = true; |
84 | 88 | //@@todo add a absolute link to search results |
85 | 89 | print $this->getResultsHTML(); |
86 | 90 | //@@todo cleaner exit |
87 | | - exit(); |
88 | | - }else{ |
| 91 | + exit (); |
| 92 | + } else { |
89 | 93 | //add nessesary js to wgOut: |
90 | | - mvfAddHTMLHeader('search'); |
| 94 | + mvfAddHTMLHeader('search'); |
91 | 95 | //add the search placeholder |
92 | 96 | //$wgOut->addWikiText( wfMsg( 'searchresulttext' ) ); |
93 | 97 | $sk = $wgUser->getSkin(); |
94 | 98 | $title = Title :: MakeTitle(NS_SPECIAL, 'Search'); |
95 | | - $wgOut->addHTML( wfMsg('mv_page_search', $sk->makeKnownLinkObj($title, $this->unified_term_search, |
96 | | - http_build_query(array('search'=> $this->unified_term_search)) |
97 | | - ) |
98 | | - ) |
99 | | - ); |
100 | | - |
| 99 | + $wgOut->addHTML(wfMsg('mv_page_search', $sk->makeKnownLinkObj($title, $this->unified_term_search, http_build_query(array ( |
| 100 | + 'search' => $this->unified_term_search |
| 101 | + ))))); |
| 102 | + |
101 | 103 | //check if the skin already includes the dynamicSearchControl |
102 | 104 | global $wgUser; |
103 | | - $doDSC=false; |
104 | | - $sk = $wgUser->getSkin(); |
105 | | - if(isset($sk->skinProvidesMvSearch)){ |
106 | | - if($sk->skinProvidesMvSearch==true){ |
107 | | - $doDSC=true; |
| 105 | + $doDSC = false; |
| 106 | + $sk = $wgUser->getSkin(); |
| 107 | + if (isset ($sk->skinProvidesMvSearch)) { |
| 108 | + if ($sk->skinProvidesMvSearch == true) { |
| 109 | + $doDSC = true; |
108 | 110 | } |
109 | | - }else{ |
110 | | - $doDSC=false; |
| 111 | + } else { |
| 112 | + $doDSC = false; |
111 | 113 | } |
112 | | - if($doDSC)$wgOut->addHTML($this->dynamicSearchControl()); |
113 | | - |
| 114 | + if ($doDSC) |
| 115 | + $wgOut->addHTML($this->dynamicSearchControl()); |
| 116 | + |
114 | 117 | //$wgOut->addHTML($this->getResultsBar()); |
115 | | - $wgOut->addHTML($this->getUnifiedResultsHTML()); |
| 118 | + $wgOut->addHTML($this->getUnifiedResultsHTML()); |
116 | 119 | } |
117 | 120 | } |
118 | | - function dynamicSearchControl() { |
| 121 | + function dynamicSearchControl() { |
119 | 122 | $title = SpecialPage :: getTitleFor('MediaSearch'); |
120 | | - $action = $title->escapeLocalURL(); |
121 | | - |
122 | | - $o ="<div id=\"msms_form_search_row\" class=\"form_search_row\"> |
123 | | - <form id=\"mv_media_search\" method=\"get\" " . |
124 | | - "action=\"$action\">\n |
125 | | - <input type=\"hidden\" id=\"advs\" name=\"advs\" value=\"";$o.=($this->adv_search)?'1':'0';$o.="\"> |
126 | | - <span class=\"advs_basic\" style=\"display:";$o.=($this->adv_search)?'none':'inline';$o.="\"> |
127 | | - <input type=\"text\" class=\"searchField\" name=\"mv_search\" id=\"search_field\" value=\"{$this->unified_term_search}\"/> |
128 | | - </span> |
129 | | - <span class=\"advs_adv\" id=\"adv_filters\" style=\"display:";$o.=($this->adv_search)?'inline':'none';$o.="\"> |
130 | | - {$this->list_active_filters()} |
131 | | - </span> |
132 | | - <button class=\"grey_button\" type=\"submit\"><span> ".wfMsg('mv_video_search')." </span></button> |
133 | | - <a href=\"javascript:mv_toggle_advs()\" class=\"advanced_search_tag\"> |
134 | | - <span class=\"advs_basic\" style=\"display:";$o.=($this->adv_search)?'none':'inline';$o.="\">advanced search</span> |
135 | | - <span class=\"advs_adv\" style=\"display:";$o.=($this->adv_search)?'inline':'none';$o.="\">basic search</span> |
136 | | - </a> |
137 | | - </form> |
138 | | - </div>"; |
| 123 | + $action = $title->escapeLocalURL(); |
| 124 | + |
| 125 | + $o = "<div id=\"msms_form_search_row\" class=\"form_search_row\"> |
| 126 | + <form id=\"mv_media_search\" method=\"get\" " . |
| 127 | + "action=\"$action\">\n |
| 128 | + <input type=\"hidden\" id=\"advs\" name=\"advs\" value=\""; |
| 129 | + $o .= ($this->adv_search) ? '1' : '0'; |
| 130 | + $o .= "\"> |
| 131 | + <span class=\"advs_basic\" style=\"display:"; |
| 132 | + $o .= ($this->adv_search) ? 'none' : 'inline'; |
| 133 | + $o .= "\"> |
| 134 | + <input type=\"text\" class=\"searchField\" name=\"mv_search\" id=\"search_field\" value=\"{$this->unified_term_search}\"/> |
| 135 | + </span> |
| 136 | + <span class=\"advs_adv\" id=\"adv_filters\" style=\"display:"; |
| 137 | + $o .= ($this->adv_search) ? 'inline' : 'none'; |
| 138 | + $o .= "\"> |
| 139 | + {$this->list_active_filters()} |
| 140 | + </span> |
| 141 | + <button class=\"grey_button\" type=\"submit\"><span> " . wfMsg('mv_video_search') . " </span></button> |
| 142 | + <a href=\"javascript:mv_toggle_advs()\" class=\"advanced_search_tag\"> |
| 143 | + <span class=\"advs_basic\" style=\"display:"; |
| 144 | + $o .= ($this->adv_search) ? 'none' : 'inline'; |
| 145 | + $o .= "\">advanced search</span> |
| 146 | + <span class=\"advs_adv\" style=\"display:"; |
| 147 | + $o .= ($this->adv_search) ? 'inline' : 'none'; |
| 148 | + $o .= "\">basic search</span> |
| 149 | + </a> |
| 150 | + </form> |
| 151 | + </div>"; |
139 | 152 | return $o; |
140 | | - } |
141 | | - function loadFiltersFromSerialized($sval){ |
| 153 | + } |
| 154 | + function loadFiltersFromSerialized($sval) { |
142 | 155 | $this->filters = unserialize($sval); |
143 | | - } |
144 | | - |
145 | | - function setupFilters($defaultType='empty', $opt=null){ |
146 | | - global $wgRequest; |
147 | | - |
| 156 | + } |
| 157 | + |
| 158 | + function setupFilters($defaultType = 'empty', $opt = null) { |
| 159 | + global $wgRequest; |
| 160 | + |
148 | 161 | //set advs flag: |
149 | | - $advs =$wgRequest->getVal('advs'); |
150 | | - $this->adv_search=($advs=='' || $advs==0)?false:true; |
151 | | - |
| 162 | + $advs = $wgRequest->getVal('advs'); |
| 163 | + $this->adv_search = ($advs == '' || $advs == 0) ? false : true; |
| 164 | + |
152 | 165 | //check for unified searchterm: |
153 | | - $term = $wgRequest->getVal('mv_search'); |
| 166 | + $term = $wgRequest->getVal('mv_search'); |
154 | 167 | //set input from search (on normal search page) |
155 | | - if($term=='') $term = $wgRequest->getVal('search'); |
156 | | - if($term!='') { |
157 | | - //do proccess unified search? or send to semantic query engine? |
| 168 | + if ($term == '') |
| 169 | + $term = $wgRequest->getVal('search'); |
| 170 | + if ($term != '') { |
158 | 171 | $this->filters = array ( |
159 | 172 | array ( |
160 | 173 | 't' => 'match', |
161 | 174 | 'v' => $term |
162 | 175 | ) |
163 | | - ); |
164 | | - $this->unified_term_search=$term; |
| 176 | + ); |
| 177 | + $this->unified_term_search = $term; |
165 | 178 | //if not doing advanced search we are done |
166 | | - if(!$this->adv_search)return ; |
167 | | - } |
| 179 | + if (!$this->adv_search) |
| 180 | + return; |
| 181 | + } |
| 182 | + |
168 | 183 | //print "CUR un: " . $this->unified_term_search; |
169 | | - |
| 184 | + |
170 | 185 | //first try any key titles: |
171 | 186 | $title_str = $wgRequest->getVal('title'); |
172 | | - $tp = split('/',$title_str); |
173 | | - if(count($tp)==3){ |
174 | | - switch($tp[1]){ |
175 | | - case 'person': |
176 | | - $this->filters = array( |
177 | | - array( |
178 | | - 't'=>'spoken_by', |
179 | | - 'v'=>str_replace('_',' ',$tp[2]) |
| 187 | + $tp = split('/', $title_str); |
| 188 | + if (count($tp) == 3) { |
| 189 | + switch ($tp[1]) { |
| 190 | + case 'person' : |
| 191 | + $this->filters = array ( |
| 192 | + array ( |
| 193 | + 't' => 'spoken_by', |
| 194 | + 'v' => str_replace('_', |
| 195 | + ' ', |
| 196 | + $tp[2] |
180 | 197 | ) |
181 | | - ); |
182 | | - break; |
183 | | - } |
184 | | - }else{ |
185 | | - if (isset ($_GET['f'])) { |
186 | | - $this->filters = $_GET['f']; |
| 198 | + )); |
| 199 | + break; |
| 200 | + } |
| 201 | + } else { |
| 202 | + if (isset ($_GET['f'])) { |
| 203 | + $this->filters = $_GET['f']; |
187 | 204 | //@@todo more input proccessing |
188 | 205 | //grab unified_term_search if not already listed: |
189 | | - if($this->unified_term_search==''){ |
190 | | - foreach($this->filters as $f){ |
191 | | - if($f['t']=='match'){ |
192 | | - if($this->unified_term_search!='')$this->unified_term_search.=' '; |
193 | | - $this->unified_term_search.=$f['v']; |
| 206 | + if ($this->unified_term_search == '') { |
| 207 | + foreach ($this->filters as $f) { |
| 208 | + if ($f['t'] == 'match') { |
| 209 | + if ($this->unified_term_search != '') |
| 210 | + $this->unified_term_search .= ' '; |
| 211 | + $this->unified_term_search .= $f['v']; |
194 | 212 | } |
195 | | - } |
| 213 | + } |
196 | 214 | } |
197 | | - } else { |
198 | | - switch($defaultType){ |
199 | | - case 'stream': |
| 215 | + } else { |
| 216 | + switch ($defaultType) { |
| 217 | + case 'stream' : |
200 | 218 | $this->filters = array ( |
201 | | - array( |
202 | | - 't' =>'stream_name', |
203 | | - 'v' =>$opt['stream_name'] |
| 219 | + array ( |
| 220 | + 't' => 'stream_name', |
| 221 | + 'v' => $opt['stream_name'] |
204 | 222 | ) |
205 | | - ); |
206 | | - break; |
207 | | - case 'empty': |
208 | | - default: |
| 223 | + ); |
| 224 | + break; |
| 225 | + case 'empty' : |
| 226 | + default : |
209 | 227 | $this->filters = array ( |
210 | 228 | array ( |
211 | 229 | 't' => 'match', |
212 | 230 | 'v' => '' |
213 | 231 | ) |
214 | 232 | ); |
215 | | - break; |
216 | | - } |
217 | | - } |
218 | | - } |
| 233 | + break; |
| 234 | + } |
| 235 | + } |
| 236 | + } |
219 | 237 | //print "CUR un: " . $this->unified_term_search; |
220 | 238 | } |
221 | | - function doSearch() { |
222 | | - global $mvEnableSearchDigest,$mvSearchDigestTable; |
| 239 | + function doSearch() { |
| 240 | + global $mvEnableSearchDigest, $mvSearchDigestTable; |
223 | 241 | $mvIndex = new MV_Index(); |
224 | 242 | //do search digest |
225 | 243 | global $wgRequest; |
226 | | - if($mvEnableSearchDigest && $wgRequest->getVal('tl')!='1') { |
227 | | - $dbw =& wfGetDB(DB_WRITE); |
228 | | - $dbr =& wfGetDB(DB_READ); |
| 244 | + if ($mvEnableSearchDigest && $wgRequest->getVal('tl') != '1') { |
| 245 | + $dbw = & wfGetDB(DB_WRITE); |
| 246 | + $dbr = & wfGetDB(DB_READ); |
229 | 247 | //@@todo non-blocking insert... is that supported in mysql/php? |
230 | | - $dbw->insert($mvSearchDigestTable, |
231 | | - array('query_key'=>$this->getFilterDesc($query_key=true),'time'=>time()), |
232 | | - 'Database::searchDigestInsert' ); |
| 248 | + $dbw->insert($mvSearchDigestTable, array ( |
| 249 | + 'query_key' => $this->getFilterDesc($query_key = true |
| 250 | + ), 'time' => time()), 'Database::searchDigestInsert'); |
233 | 251 | //make sure the query key exists and is updated |
234 | 252 | //@@todo I think we can do a INSERT IF non found here? |
235 | | - $res = $dbr->select('mv_query_key_lookup', array('filters'), |
236 | | - array('query_key'=>$this->getFilterDesc($query_key=true))); |
237 | | - if( $dbr->numRows($res)==0){ |
238 | | - $dbr->insert('mv_query_key_lookup', array('query_key'=>$this->getFilterDesc($query_key=true), |
239 | | - 'filters'=>serialize($this->filters))); |
| 253 | + $res = $dbr->select('mv_query_key_lookup', array ( |
| 254 | + 'filters' |
| 255 | + ), array ( |
| 256 | + 'query_key' => $this->getFilterDesc($query_key = true |
| 257 | + ))); |
| 258 | + if ($dbr->numRows($res) == 0) { |
| 259 | + $dbr->insert('mv_query_key_lookup', array ( |
| 260 | + 'query_key' => $this->getFilterDesc($query_key = true |
| 261 | + ), 'filters' => serialize($this->filters))); |
240 | 262 | } |
241 | 263 | } |
242 | 264 | $this->results = $mvIndex->doUnifiedFiltersQuery($this->filters); |
243 | 265 | $this->num = $mvIndex->numResults(); |
244 | 266 | $this->numResultsFound = $mvIndex->numResultsFound(); |
245 | | - if(isset($mvIndex->offset)) $this->offset = $mvIndex->offset; |
246 | | - if(isset($mvIndex->limit)) $this->limit = $mvIndex->limit; |
| 267 | + if (isset ($mvIndex->offset)) |
| 268 | + $this->offset = $mvIndex->offset; |
| 269 | + if (isset ($mvIndex->limit)) |
| 270 | + $this->limit = $mvIndex->limit; |
| 271 | + if (isset ($mvIndex->order)) |
| 272 | + $this->order = $mvIndex->order; |
247 | 273 | } |
248 | 274 | /*list all the meta *layer* types */ |
249 | 275 | function powerSearchOptions() { |
250 | 276 | global $mvMVDTypeAllAvailable; |
251 | | - $opt = array(); |
| 277 | + $opt = array (); |
252 | 278 | //group track_req |
253 | | - $opt['tracks']=''; |
254 | | - $coma=''; |
255 | | - foreach( $mvMVDTypeAllAvailable as $n ) { |
256 | | - $opt['tracks'].= $coma. $n; |
257 | | - $coma=','; |
| 279 | + $opt['tracks'] = ''; |
| 280 | + $coma = ''; |
| 281 | + foreach ($mvMVDTypeAllAvailable as $n) { |
| 282 | + $opt['tracks'] .= $coma . $n; |
| 283 | + $coma = ','; |
258 | 284 | } |
259 | 285 | //$opt['redirs'] = $this->searchRedirects ? 1 : 0; |
260 | 286 | //$opt['searchx'] = 1; |
261 | 287 | return $opt; |
262 | 288 | } |
263 | | - function getResultsCMML(){ |
264 | | - |
| 289 | + function getResultsCMML() { |
| 290 | + |
265 | 291 | } |
266 | 292 | function getUnifiedResultsHTML() { |
267 | | - global $wgUser, $wgStylePath; |
| 293 | + global $wgUser, $wgStylePath, $wgRequest; |
268 | 294 | $sk = $wgUser->getSkin(); |
269 | | - |
270 | | - $o.='<h5 class="search_results_header">'.$this->getFilterDesc().'</h5>'; |
271 | 295 | |
272 | | - |
273 | | - $o.='<div id="resultsArea"> |
274 | | - <ul id="metaResults">'; |
| 296 | + $o .= '<h5 class="search_results_header">' . $this->getFilterDesc() . '</h5>'; |
| 297 | + |
| 298 | + $o .= '<div id="resultsArea"> |
| 299 | + <ul id="metaResults">'; |
275 | 300 | if (count($this->results) == 0) { |
276 | | - $o.= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>'; |
| 301 | + $o .= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>'; |
277 | 302 | //close |
278 | | - $o.='</ul></div>'; |
| 303 | + $o .= '</ul></div>'; |
279 | 304 | return $o; |
280 | 305 | } |
281 | | - |
| 306 | + |
282 | 307 | //num of results |
283 | | - if($this->numResultsFound){ |
284 | | - $re = ($this->limit+$this->offset > $this->numResultsFound)?$this->numResultsFound:($this->limit+$this->offset); |
285 | | - $rs = ($this->offset==0)?1:$this->offset; |
286 | | - $o.='<li class="results">'. |
287 | | - wfMsg('mv_results_found',$rs,$re , number_format($this->numResultsFound)). |
288 | | - '</li>'; |
| 308 | + if ($this->numResultsFound) { |
| 309 | + $re = ($this->limit + $this->offset > $this->numResultsFound) ? $this->numResultsFound : ($this->limit + $this->offset); |
| 310 | + $rs = ($this->offset == 0) ? 1 : $this->offset; |
| 311 | + $o .= '<li class="results">' . |
| 312 | + wfMsg('mv_results_found', $rs, $re, number_format($this->numResultsFound)) . |
| 313 | + '</li>'; |
289 | 314 | } |
290 | 315 | //pagging |
291 | | - if($this->numResultsFound > $this->limit){ |
292 | | - $prevnext = mvViewPrevNext( $this->offset, $this->limit, |
293 | | - SpecialPage::getTitleFor( 'MediaSearch' ), |
294 | | - $this->get_httpd_filters_query(), |
295 | | - ($this->num < $this->limit) ); |
296 | | - $o.='<li class="prevnext">'.$prevnext.'</li>'; |
297 | | - } |
298 | | - |
| 316 | + if ($this->numResultsFound > $this->limit) { |
| 317 | + $prevnext = mvViewPrevNext($this->offset, $this->limit, SpecialPage :: getTitleFor('MediaSearch'), $this->get_httpd_filters_query(), ($this->num < $this->limit)); |
| 318 | + $o .= '<li class="prevnext">' . $prevnext . '</li>'; |
| 319 | + } |
| 320 | + |
299 | 321 | //make rss link: |
300 | | - $sTitle=Title::MakeTitle(NS_SPECIAL, 'MvExportSearch'); |
301 | | - $o.='<li class="rss">'; |
302 | | - $o.=$sk->makeKnownLinkObj($sTitle, |
303 | | - 'RSS',$this->get_httpd_filters_query() ); |
304 | | - $o.='</li>'; |
305 | | - |
| 322 | + $sTitle = Title :: MakeTitle(NS_SPECIAL, 'MvExportSearch'); |
| 323 | + $o .= '<li class="rss">'; |
| 324 | + $o .= $sk->makeKnownLinkObj($sTitle, 'RSS', $this->get_httpd_filters_query()); |
| 325 | + $o .= '</li>'; |
| 326 | + |
306 | 327 | //make miro link: |
307 | | - $o.='<li class="subscribe"><a href="http://subscribe.getMiro.com/?url1='. |
308 | | - 'http%3A%2F%2F' . $_SERVER['HTTP_HOST'] . htmlspecialchars($sTitle->escapeLocalURL($this->get_httpd_filters_query())).'" '. |
309 | | - 'title="Subscribe with Miro"><img src="'.$wgStylePath . '/mvpcf/images/button_subscribe.png" alt="Miro Video Player" border="0" /></a></li>'; |
310 | | - |
311 | | - $o.=' <li class="relevant"><br>Most Relevant - </li> |
312 | | - <li class="recent"><a href="#">Most Recent</a> - </li> |
313 | | - <li class="viewed"><a href="#">Most Viewed</a></li>'; |
314 | | - $o.='</ul>'; |
315 | | - |
| 328 | + $o .= '<li class="subscribe"><a href="http://subscribe.getMiro.com/?url1=' . |
| 329 | + 'http%3A%2F%2F' . $_SERVER['HTTP_HOST'] . htmlspecialchars($sTitle->escapeLocalURL($this->get_httpd_filters_query())) . '" ' . |
| 330 | + 'title="Subscribe with Miro"><img src="' . $wgStylePath . '/mvpcf/images/button_subscribe.png" alt="Miro Video Player" border="0" /></a></li>'; |
| 331 | + |
| 332 | + //check order prefrence: |
| 333 | + $br='<br>'; |
| 334 | + foreach (array ('relevent','recent','viewed') as $type) { |
| 335 | + if ($this->order == $type) { |
| 336 | + $o .= '<li class="relevant">'.$br . wfMsg('mv_most_' . $type) . ' - </li>' ; |
| 337 | + } else { |
| 338 | + $q_req = $this->get_httpd_filters_query(); |
| 339 | + if($wgRequest->getVal('limit')!='' || $wgRequest->getVal('order')!='') |
| 340 | + $q_req.='&'.http_build_query(array('limit'=>$this->limit, 'offset'=>$this->offset)); |
| 341 | + $q_req.='&order='.$type; |
| 342 | + $o .= '<li class="relevant">'.$br .$sk->makeKnownLinkObj(SpecialPage :: getTitleFor('MediaSearch'), |
| 343 | + wfMsg('mv_most_' . $type), $q_req) . ' - </li>'; |
| 344 | + } |
| 345 | + $br=''; |
| 346 | + } |
| 347 | + $o .= '</ul>'; |
| 348 | + |
316 | 349 | //output results: |
317 | 350 | //collect categories and people for sidebarbucket |
318 | 351 | //@@todo a better version would collect |
319 | | - $sideBarLinkBucket = array(); |
320 | | - $o.=' |
321 | | - <ul id="results">'; |
322 | | - foreach ($this->results as $stream_id => & $stream_set) { |
| 352 | + $sideBarLinkBucket = array (); |
| 353 | + $o .= ' |
| 354 | + <ul id="results">'; |
| 355 | + foreach ($this->results as $stream_id => & $stream_set) { |
323 | 356 | $matches = 0; |
324 | | - $stream_out = $mvTitle = ''; |
| 357 | + $stream_out = $mvTitle = ''; |
325 | 358 | foreach ($stream_set as & $srange) { |
326 | 359 | $cat_html = $mvd_out = ''; |
327 | | - $range_match=0; |
328 | | - foreach ($srange['rows'] as $inx=> & $mvd) { |
329 | | - $matches++; |
| 360 | + $range_match = 0; |
| 361 | + foreach ($srange['rows'] as $inx => & $mvd) { |
| 362 | + $matches++; |
330 | 363 | $mvTitle = new MV_Title($mvd->wiki_title); |
331 | | - $mvd_cnt_links=''; |
332 | | - if(isset($mvd->spoken_by)){ |
333 | | - $ptitle = Title::MakeTitle(NS_MAIN, $mvd->spoken_by); |
334 | | - $mvd_cnt_links.=wfMsg('mv_search_spoken_by').': '.$sk->makeKnownLinkObj($ptitle); |
335 | | - $mvd_cnt_links.='<br>'; |
336 | | - assoc_array_increment($sideBarLinkBucket,'person', $mvd->spoken_by); |
| 364 | + $mvd_cnt_links = ''; |
| 365 | + if (isset ($mvd->spoken_by)) { |
| 366 | + $ptitle = Title :: MakeTitle(NS_MAIN, $mvd->spoken_by); |
| 367 | + $mvd_cnt_links .= wfMsg('mv_search_spoken_by') . ': ' . $sk->makeKnownLinkObj($ptitle); |
| 368 | + $mvd_cnt_links .= '<br>'; |
| 369 | + assoc_array_increment($sideBarLinkBucket, 'person', $mvd->spoken_by); |
337 | 370 | } |
338 | | - $mvd_cat_links=$mvd_bill_links=''; |
339 | | - $coma=''; |
340 | | - if(isset($mvd->categories)){ |
341 | | - foreach($mvd->categories as $cat_id=>$na){ |
342 | | - $cTitle= Title::MakeTitle(NS_CATEGORY, $cat_id); |
343 | | - if($mvd_cat_links=='') |
344 | | - $mvd_cat_links.=wfMsg('mv_search_categories').': '; |
345 | | - $mvd_cat_links.=$coma. $sk->makeKnownLinkObj($cTitle, $cTitle->getText() ); |
346 | | - $coma=', '; |
347 | | - assoc_array_increment($sideBarLinkBucket,'category', $cat_id); |
| 371 | + $mvd_cat_links = $mvd_bill_links = ''; |
| 372 | + $coma = ''; |
| 373 | + if (isset ($mvd->categories)) { |
| 374 | + foreach ($mvd->categories as $cat_id => $na) { |
| 375 | + $cTitle = Title :: MakeTitle(NS_CATEGORY, $cat_id); |
| 376 | + if ($mvd_cat_links == '') |
| 377 | + $mvd_cat_links .= wfMsg('mv_search_categories') . |
| 378 | + ': '; |
| 379 | + $mvd_cat_links .= $coma . $sk->makeKnownLinkObj($cTitle, $cTitle->getText()); |
| 380 | + $coma = ', '; |
| 381 | + assoc_array_increment($sideBarLinkBucket, 'category', $cat_id); |
348 | 382 | } |
349 | 383 | } |
350 | | - $coma=''; |
351 | | - if(isset($mvd->bills)){ |
352 | | - foreach($mvd->bills as $bill_id=>$na){ |
353 | | - $bTitle= Title::newFromText($bill_id); |
354 | | - if($mvd_bill_links=='') |
355 | | - $mvd_bill_links.=wfMsg('mv_search_bills').': '; |
356 | | - $mvd_bill_links.=$coma. $sk->makeKnownLinkObj($bTitle, $bTitle->getText() ); |
357 | | - $coma=', '; |
358 | | - assoc_array_increment($sideBarLinkBucket,'bill', $bill_id); |
| 384 | + $coma = ''; |
| 385 | + if (isset ($mvd->bills)) { |
| 386 | + foreach ($mvd->bills as $bill_id => $na) { |
| 387 | + $bTitle = Title :: newFromText($bill_id); |
| 388 | + if ($mvd_bill_links == '') |
| 389 | + $mvd_bill_links .= wfMsg('mv_search_bills') . |
| 390 | + ': '; |
| 391 | + $mvd_bill_links .= $coma . $sk->makeKnownLinkObj($bTitle, $bTitle->getText()); |
| 392 | + $coma = ', '; |
| 393 | + assoc_array_increment($sideBarLinkBucket, 'bill', $bill_id); |
359 | 394 | } |
360 | 395 | } |
361 | 396 | //link directly to the current range: |
362 | | - $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($extra_range='0')); |
| 397 | + $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($extra_range = '0')); |
363 | 398 | //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() ); |
364 | | - $head_link = $sk->makeKnownLinkObj($mvStreamTitle, $mvTitle->getStreamNameText().' :: '.$mvTitle->getTimeDesc()); |
365 | | - $img_link = $sk->makeKnownLinkObj($mvStreamTitle, '<img alt="image for '.$mvTitle->getStreamNameText().' '. $mvTitle->getTimeDesc().'" src="'.$mvTitle->getStreamImageURL('small').'"/>'); |
| 399 | + $head_link = $sk->makeKnownLinkObj($mvStreamTitle, $mvTitle->getStreamNameText() . ' :: ' . $mvTitle->getTimeDesc()); |
| 400 | + $img_link = $sk->makeKnownLinkObj($mvStreamTitle, '<img alt="image for ' . $mvTitle->getStreamNameText() . ' ' . $mvTitle->getTimeDesc() . '" src="' . $mvTitle->getStreamImageURL('small') . '"/>'); |
366 | 401 | $mvd_text = $mvd->text; |
367 | | - |
368 | | - $o.='<li class="result"> |
369 | | - <span class="vid_img" id="mvimg_'.$mvd->id.'"> |
370 | | - '.$img_link.' |
371 | | - </span> |
372 | | - <div class="result_description"> |
373 | | - <h4>'.$head_link.'</h4> |
374 | | - <p>Matching Phrase:' .$this->termHighlight($mvd->text, implode('|', $this->getTerms()), 1, 100).' </p> |
375 | | - <span class="by">'.$mvd_cnt_links.'</span> |
376 | | - <span class="by">'.$mvd_cat_links.'</span> |
377 | | - <span class="by">'.$mvd_bill_links.'</span> |
378 | | - </div> |
379 | | - <div class="result_meta"> |
380 | | - <span class="views">Views: '.$mvd->view_count.'</span> |
381 | | - <span class="duration">'.wfMsg('mv_duration_label').':'.$mvTitle->getSegmentDurationNTP($short_time=true).'</span> |
382 | | - <span class="comments">Comments: NYA</span> |
383 | | - <span class="playinline"><a href="javascript:mv_pl(\'' . $mvd->id . '\')">' |
384 | | - .wfMsg('mv_play_inline').'</a></span> |
385 | | - </div> |
386 | | - </li>'; |
| 402 | + |
| 403 | + $o .= '<li class="result"> |
| 404 | + <span class="vid_img" id="mvimg_' . $mvd->id . '"> |
| 405 | + ' . $img_link . ' |
| 406 | + </span> |
| 407 | + <div class="result_description"> |
| 408 | + <h4>' . $head_link . '</h4> |
| 409 | + <p>Matching Phrase:' . $this->termHighlight($mvd->text, implode('|', $this->getTerms()), 1, 100) . ' </p> |
| 410 | + <span class="by">' . $mvd_cnt_links . '</span> |
| 411 | + <span class="by">' . $mvd_cat_links . '</span> |
| 412 | + <span class="by">' . $mvd_bill_links . '</span> |
| 413 | + </div> |
| 414 | + <div class="result_meta"> |
| 415 | + <span class="views">Views: ' . $mvd->view_count . '</span> |
| 416 | + <span class="duration">' . wfMsg('mv_duration_label') . ':' . $mvTitle->getSegmentDurationNTP($short_time = true) . '</span> |
| 417 | + <span class="comments">Comments: NYA</span> |
| 418 | + <span class="playinline"><a href="javascript:mv_pl(\'' . $mvd->id . '\')">' . |
| 419 | + wfMsg('mv_play_inline') . '</a></span> |
| 420 | + </div> |
| 421 | + </li>'; |
387 | 422 | } |
388 | 423 | } |
389 | | - } |
390 | | - $o.='</ul>'; |
391 | | - $o.='<li class="prevnext">'.$prevnext.'</li>'; |
392 | | - $o.='</div>'; |
393 | | - |
| 424 | + } |
| 425 | + $o .= '</ul>'; |
| 426 | + $o .= '<li class="prevnext">' . $prevnext . '</li>'; |
| 427 | + $o .= '</div>'; |
| 428 | + |
394 | 429 | /*search sidebar*/ |
395 | | - $perSectionCount=3; |
396 | | - $o.='<div id="searchSideBar"> |
397 | | - <div id="searchSideBarTop"> |
398 | | - </div> |
399 | | - <div class="suggestionsBox" id="searchSideBarInner">'; |
400 | | - |
| 430 | + $perSectionCount = 3; |
| 431 | + $o .= '<div id="searchSideBar"> |
| 432 | + <div id="searchSideBarTop"> |
| 433 | + </div> |
| 434 | + <div class="suggestionsBox" id="searchSideBarInner">'; |
| 435 | + |
401 | 436 | //look for people matches max of 3 |
402 | | - $first_block=' first_block'; |
403 | | - $matches=0; |
404 | | - $person_out = MV_SpecialMediaSearch::auto_complete_person($this->unified_term_search, 3, 'person_html', $matches); |
405 | | - if($person_out!='' || count($sideBarLinkBucket['person'])!=0 ){ |
| 437 | + $first_block = ' first_block'; |
| 438 | + $matches = 0; |
| 439 | + $person_out = MV_SpecialMediaSearch :: auto_complete_person($this->unified_term_search, 3, 'person_html', $matches); |
| 440 | + if ($person_out != '' || count($sideBarLinkBucket['person']) != 0) { |
406 | 441 | //for now don't include({$matches}) |
407 | | - $o.="<div class=\"block{$first_block}\"> |
408 | | - <h6>".wfMsg('mv_people_results')."</h6> |
409 | | - </div>"; |
410 | | - $o.='<div class="block wide_block">'. |
411 | | - $person_out; |
412 | | - if(isset($sideBarLinkBucket['person'])){ |
| 442 | + $o .= "<div class=\"block{$first_block}\"> |
| 443 | + <h6>" . wfMsg('mv_people_results') . "</h6> |
| 444 | + </div>"; |
| 445 | + $o .= '<div class="block wide_block">' . |
| 446 | + $person_out; |
| 447 | + if (isset ($sideBarLinkBucket['person'])) { |
413 | 448 | $pAry = & $sideBarLinkBucket['person']; |
414 | | - arsort($pAry); |
415 | | - $i=0; |
416 | | - foreach($pAry as $person_name=>$count){ |
417 | | - if($i==$perSectionCount)break; |
418 | | - $o.=MV_SpecialMediaSearch::format_ac_line($person_name, '', '', MV_SpecialMediaSearch::getPersonImageURL($person_name), $format='person_html'); |
| 449 | + arsort($pAry); |
| 450 | + $i = 0; |
| 451 | + foreach ($pAry as $person_name => $count) { |
| 452 | + if ($i == $perSectionCount) |
| 453 | + break; |
| 454 | + $o .= MV_SpecialMediaSearch :: format_ac_line($person_name, '', '', MV_SpecialMediaSearch :: getPersonImageURL($person_name), $format = 'person_html'); |
419 | 455 | $i++; |
420 | | - } |
421 | | - } |
422 | | - $o.='</div>'; |
423 | | - $first_block=''; |
424 | | - } |
| 456 | + } |
| 457 | + } |
| 458 | + $o .= '</div>'; |
| 459 | + $first_block = ''; |
| 460 | + } |
425 | 461 | //get categories |
426 | | - $category_out = MV_SpecialMediaSearch::auto_complete_search_categories($this->unified_term_search, 3, 'block_html',$matches); |
427 | | - if($category_out!='' || count($sideBarLinkBucket['category'])!=0 ){ |
428 | | - $o.="<div class=\"block{$first_block}\"> |
429 | | - <h6>".wfMsg('mv_category_results')."</h6> |
430 | | - </div>"; |
431 | | - $o.='<div class="block wide_block">'.$category_out; |
432 | | - if(isset($sideBarLinkBucket['category'])){ |
| 462 | + $category_out = MV_SpecialMediaSearch :: auto_complete_search_categories($this->unified_term_search, 3, 'block_html', $matches); |
| 463 | + if ($category_out != '' || count($sideBarLinkBucket['category']) != 0) { |
| 464 | + $o .= "<div class=\"block{$first_block}\"> |
| 465 | + <h6>" . wfMsg('mv_category_results') . "</h6> |
| 466 | + </div>"; |
| 467 | + $o .= '<div class="block wide_block">' . $category_out; |
| 468 | + if (isset ($sideBarLinkBucket['category'])) { |
433 | 469 | $cAry = & $sideBarLinkBucket['category']; |
434 | 470 | arsort($cAry); |
435 | | - $i=0; |
436 | | - foreach($cAry as $cat_name=>$count){ |
437 | | - if($i==$perSectionCount)break; |
438 | | - $o.=MV_SpecialMediaSearch::format_ac_line($cat_name, '', '','no_image', $format='block_html'); |
439 | | - $i++; |
440 | | - } |
| 471 | + $i = 0; |
| 472 | + foreach ($cAry as $cat_name => $count) { |
| 473 | + if ($i == $perSectionCount) |
| 474 | + break; |
| 475 | + $o .= MV_SpecialMediaSearch :: format_ac_line($cat_name, '', '', 'no_image', $format = 'block_html'); |
| 476 | + $i++; |
| 477 | + } |
441 | 478 | } |
442 | | - $o.='</div>'; |
443 | | - $first_block=''; |
444 | | - } |
| 479 | + $o .= '</div>'; |
| 480 | + $first_block = ''; |
| 481 | + } |
445 | 482 | //get bills: |
446 | | - $bill_out = MV_SpecialMediaSearch::auto_complete_category('Bill', $this->unified_term_search, 3, 'block_html', $matches); |
447 | | - if($bill_out!='' || count($sideBarLinkBucket['bill'])!=0 ){ |
| 483 | + $bill_out = MV_SpecialMediaSearch :: auto_complete_category('Bill', $this->unified_term_search, 3, 'block_html', $matches); |
| 484 | + if ($bill_out != '' || count($sideBarLinkBucket['bill']) != 0) { |
448 | 485 | global $wgContLang; |
449 | | - $o.="<div class=\"block{$first_block}\"> |
450 | | - <h6>".wfMsg('mv_bill_results')."</h6> |
451 | | - </div>"; |
452 | | - $o.='<div class="block wide_block">'.$bill_out; |
453 | | - if($sideBarLinkBucket['bill']){ |
| 486 | + $o .= "<div class=\"block{$first_block}\"> |
| 487 | + <h6>" . wfMsg('mv_bill_results') . "</h6> |
| 488 | + </div>"; |
| 489 | + $o .= '<div class="block wide_block">' . $bill_out; |
| 490 | + if ($sideBarLinkBucket['bill']) { |
454 | 491 | $bAry = & $sideBarLinkBucket['bill']; |
455 | 492 | arsort($bAry); |
456 | | - $i=0; |
457 | | - foreach($bAry as $bill_name=>$count){ |
458 | | - if($i==$perSectionCount)break; |
459 | | - $o.=MV_SpecialMediaSearch::format_ac_line($bill_name, '', '','no_image', $format='block_html'); |
| 493 | + $i = 0; |
| 494 | + foreach ($bAry as $bill_name => $count) { |
| 495 | + if ($i == $perSectionCount) |
| 496 | + break; |
| 497 | + $o .= MV_SpecialMediaSearch :: format_ac_line($bill_name, '', '', 'no_image', $format = 'block_html'); |
460 | 498 | $i++; |
461 | | - } |
| 499 | + } |
462 | 500 | } |
463 | | - $o.='</div>'; |
464 | | - $first_block=''; |
| 501 | + $o .= '</div>'; |
| 502 | + $first_block = ''; |
465 | 503 | } |
466 | 504 | //intrest out is just simple title matching (for now) |
467 | | - $intrest_out = MV_SpecialMediaSearch::auto_complete_category('Interest_Group', $this->unified_term_search, 3, 'block_html', $matches); |
468 | | - if($intrest_out!=''){ |
469 | | - $o.="<div class=\"block{$first_block}\"> |
470 | | - <h6>".wfMsg('mv_intrest_group_results')."</h6> |
471 | | - </div>"; |
472 | | - $o.='<div class="block wide_block">'.$intrest_out.'</div>'; |
473 | | - $first_block=''; |
| 505 | + $intrest_out = MV_SpecialMediaSearch :: auto_complete_category('Interest_Group', $this->unified_term_search, 3, 'block_html', $matches); |
| 506 | + if ($intrest_out != '') { |
| 507 | + $o .= "<div class=\"block{$first_block}\"> |
| 508 | + <h6>" . wfMsg('mv_intrest_group_results') . "</h6> |
| 509 | + </div>"; |
| 510 | + $o .= '<div class="block wide_block">' . $intrest_out . '</div>'; |
| 511 | + $first_block = ''; |
474 | 512 | } |
475 | | - $o.='</div><!--searchSideBarInner--> |
476 | | - </div>'; |
| 513 | + $o .= '</div><!--searchSideBarInner--> |
| 514 | + </div>'; |
477 | 515 | return $o; |
478 | 516 | } |
479 | 517 | function getResultsHTML() { |
480 | 518 | global $mvgIP, $wgOut, $mvgScriptPath, $mvgContLang, $wgUser, $wgParser; |
481 | 519 | $sk = & $wgUser->getSkin(); |
482 | | - $o = ''; |
483 | | - if($this->outputContainer)$o.='<div id="mv_search_results_container">'; |
484 | | - |
| 520 | + $o = ''; |
| 521 | + if ($this->outputContainer) |
| 522 | + $o .= '<div id="mv_search_results_container">'; |
| 523 | + |
485 | 524 | //for each stream range: |
486 | 525 | if (count($this->results) == 0) { |
487 | | - $o.= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>'; |
488 | | - if($this->outputContainer)$o.='</div>'; |
| 526 | + $o .= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>'; |
| 527 | + if ($this->outputContainer) |
| 528 | + $o .= '</div>'; |
489 | 529 | return $o; |
490 | | - }else{ |
491 | | - if($this->outputInlineHeader){ |
492 | | - $o.='<h2> |
493 | | - <span class="mw-headline">'. wfMsg('mv_media_matches') . '</span> |
494 | | - </h2>'; |
| 530 | + } else { |
| 531 | + if ($this->outputInlineHeader) { |
| 532 | + $o .= '<h2> |
| 533 | + <span class="mw-headline">' . wfMsg('mv_media_matches') . '</span> |
| 534 | + </h2>'; |
495 | 535 | $title = Title :: MakeTitle(NS_SPECIAL, 'MediaSearch'); |
496 | | - $o.= $sk->makeKnownLinkObj($title, wfMsg('mv_advaced_search'), |
497 | | - $this->get_httpd_filters_query() ); |
| 536 | + $o .= $sk->makeKnownLinkObj($title, wfMsg('mv_advaced_search'), $this->get_httpd_filters_query()); |
498 | 537 | } |
499 | | - } |
| 538 | + } |
500 | 539 | //media pagging: (only display if we have num of results > limit |
501 | | - $prevnext = mvViewPrevNext( $this->offset, $this->limit, |
502 | | - SpecialPage::getTitleFor( 'MediaSearch' ), |
503 | | - $this->get_httpd_filters_query(), |
504 | | - ($this->num < $this->limit) ); |
505 | | - $o.="<br /><span id=\"mv_search_pagging\">{$prevnext}</span>\n"; |
| 540 | + $prevnext = mvViewPrevNext($this->offset, $this->limit, SpecialPage :: getTitleFor('MediaSearch'), $this->get_httpd_filters_query(), ($this->num < $this->limit)); |
| 541 | + $o .= "<br /><span id=\"mv_search_pagging\">{$prevnext}</span>\n"; |
506 | 542 | //add the rss link: |
507 | | - $sTitle=Title::MakeTitle(NS_SPECIAL, 'MvExportSearch'); |
508 | | - $o.='<span style="float:right;">'; |
509 | | - $o.=$sk->makeKnownLinkObj($sTitle, |
510 | | - '<img border="0" src="' . $mvgScriptPath . '/skins/images/feed-icon-28x28.png">', |
511 | | - $this->get_httpd_filters_query() ); |
512 | | - $o.='</span>'; |
| 543 | + $sTitle = Title :: MakeTitle(NS_SPECIAL, 'MvExportSearch'); |
| 544 | + $o .= '<span style="float:right;">'; |
| 545 | + $o .= $sk->makeKnownLinkObj($sTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/feed-icon-28x28.png">', $this->get_httpd_filters_query()); |
| 546 | + $o .= '</span>'; |
513 | 547 | //add the results bar: |
514 | | - $o.=$this->getResultsBar(); |
| 548 | + $o .= $this->getResultsBar(); |
515 | 549 | //print_r($this->results); |
516 | | - foreach ($this->results as $stream_id => & $stream_set) { |
| 550 | + foreach ($this->results as $stream_id => & $stream_set) { |
517 | 551 | $matches = 0; |
518 | | - $stream_out = $mvTitle = ''; |
| 552 | + $stream_out = $mvTitle = ''; |
519 | 553 | foreach ($stream_set as & $srange) { |
520 | 554 | $cat_html = $mvd_out = ''; |
521 | | - $range_match=0; |
522 | | - foreach ($srange['rows'] as $inx=> & $mvd) { |
523 | | - $matches++; |
| 555 | + $range_match = 0; |
| 556 | + foreach ($srange['rows'] as $inx => & $mvd) { |
| 557 | + $matches++; |
524 | 558 | $mvTitle = new MV_Title($mvd->wiki_title); |
525 | 559 | |
526 | 560 | //retrieve only the first article: |
527 | 561 | //$title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); |
528 | 562 | //$article = new Article($title); |
529 | | - |
530 | | - $bgcolor=MV_Overlay::getMvdBgColor($mvd); |
| 563 | + |
| 564 | + $bgcolor = MV_Overlay :: getMvdBgColor($mvd); |
531 | 565 | //output indent if not the first and count more than one |
532 | | - if(count($srange['rows'])!=1 && $inx!=0) |
533 | | - $mvd_out.=' '; |
| 566 | + if (count($srange['rows']) != 1 && $inx != 0) |
| 567 | + $mvd_out .= ' '; |
534 | 568 | //'<img src="'. $mvgScriptPath . '/skins/images/film.png">' |
535 | 569 | //$mvd_out .= '<div class="mv_rtdesc" title="' . wfMsg('mv_expand_play') . '" '. |
536 | 570 | // '> '; |
537 | | - $mvd_out .= '<img style="float:left;width:84px;cursor:pointer;border:solid #'.$bgcolor.'" '. |
538 | | - ' onclick="mv_ex(\'' . $mvd->id . '\')" width="80" height="60" src="'.$mvTitle->getStreamImageURL('icon') . '">'; |
539 | | - $mvd_out.= '</div>'; |
540 | | - $mvd_out.='<b>' .$mvTitle->getTimeDesc() . '</b> '; |
541 | | - $mvd_cnt_links=''; |
542 | | - if(isset($mvd->spoken_by)){ |
543 | | - $ptitle = Title::MakeTitle(NS_MAIN, $mvd->spoken_by); |
544 | | - $mvd_cnt_links.=wfMsg('mv_search_spoken_by').': '.$sk->makeKnownLinkObj($ptitle); |
545 | | - $mvd_cnt_links.='<br>'; |
| 571 | + $mvd_out .= '<img style="float:left;width:84px;cursor:pointer;border:solid #' . $bgcolor . '" ' . |
| 572 | + ' onclick="mv_ex(\'' . $mvd->id . '\')" width="80" height="60" src="' . $mvTitle->getStreamImageURL('icon') . '">'; |
| 573 | + $mvd_out .= '</div>'; |
| 574 | + $mvd_out .= '<b>' . $mvTitle->getTimeDesc() . '</b> '; |
| 575 | + $mvd_cnt_links = ''; |
| 576 | + if (isset ($mvd->spoken_by)) { |
| 577 | + $ptitle = Title :: MakeTitle(NS_MAIN, $mvd->spoken_by); |
| 578 | + $mvd_cnt_links .= wfMsg('mv_search_spoken_by') . ': ' . $sk->makeKnownLinkObj($ptitle); |
| 579 | + $mvd_cnt_links .= '<br>'; |
546 | 580 | } |
547 | | - if($this->outputSeqLinks==true){ |
548 | | - $mvd_cnt_links .=' <a href="javascript:mv_add_to_seq({mvclip:\''. |
549 | | - $mvTitle->getStreamName().'/'.$mvTitle->getTimeRequest().'\','. |
550 | | - 'src:\''.$mvTitle->getWebStreamURL().'\','. |
551 | | - 'img_url:\''.$mvTitle->getStreamImageURL().'\'})">'. |
552 | | - '<img style="cursor:pointer;" '. |
553 | | - 'title="'.wfMsg('mv_seq_add_end').'" '. |
554 | | - 'src="'.$mvgScriptPath .'/skins/mv_embed/images/application_side_expand.png">'. wfMsg('mv_seq_add_end').'</a>'; |
| 581 | + if ($this->outputSeqLinks == true) { |
| 582 | + $mvd_cnt_links .= ' <a href="javascript:mv_add_to_seq({mvclip:\'' . |
| 583 | + $mvTitle->getStreamName() . '/' . $mvTitle->getTimeRequest() . '\',' . |
| 584 | + 'src:\'' . $mvTitle->getWebStreamURL() . '\',' . |
| 585 | + 'img_url:\'' . $mvTitle->getStreamImageURL() . '\'})">' . |
| 586 | + '<img style="cursor:pointer;" ' . |
| 587 | + 'title="' . wfMsg('mv_seq_add_end') . '" ' . |
| 588 | + 'src="' . $mvgScriptPath . '/skins/mv_embed/images/application_side_expand.png">' . wfMsg('mv_seq_add_end') . '</a>'; |
555 | 589 | } |
556 | | - $mvd_cnt_links .= '<a title="' . wfMsg('mv_expand_play') . '" href="javascript:mv_ex(\'' . $mvd->id . '\')">'. |
557 | | - '<img id="mv_img_ex_'.$mvd->id.'" src="' . $mvgScriptPath . '/skins/images/closed.png">'. |
558 | | - '<span id="mv_watch_clip_'.$mvd->id.'">'.wfMsg('mv_watch_clip').'</span>'. |
559 | | - '<span style="display:none;" id="mv_close_clip_'.$mvd->id.'">'.wfMsg('mv_close_clip').'</span>'. |
560 | | - '</a>' . |
561 | | - ' '; |
| 590 | + $mvd_cnt_links .= '<a title="' . wfMsg('mv_expand_play') . '" href="javascript:mv_ex(\'' . $mvd->id . '\')">' . |
| 591 | + '<img id="mv_img_ex_' . $mvd->id . '" src="' . $mvgScriptPath . '/skins/images/closed.png">' . |
| 592 | + '<span id="mv_watch_clip_' . $mvd->id . '">' . wfMsg('mv_watch_clip') . '</span>' . |
| 593 | + '<span style="display:none;" id="mv_close_clip_' . $mvd->id . '">' . wfMsg('mv_close_clip') . '</span>' . |
| 594 | + '</a>' . |
| 595 | + ' '; |
562 | 596 | //output control links: |
563 | 597 | //make stream title link: |
564 | 598 | $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName()); |
565 | 599 | //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() ); |
566 | | - $mvd_cnt_links .= $sk->makeKnownLinkObj($mvStreamTitle, '<img border="1" src="' . $mvgScriptPath . '/skins/images/run_mv_stream.png"> '.wfMsg('mv_improve_transcript'), '', '', '', '', ' title="' . wfMsg('mv_view_in_stream_interface') . '" '); |
567 | | - $mvd_cnt_links .= '<br>'; |
| 600 | + $mvd_cnt_links .= $sk->makeKnownLinkObj($mvStreamTitle, '<img border="1" src="' . $mvgScriptPath . '/skins/images/run_mv_stream.png"> ' . wfMsg('mv_improve_transcript'), '', '', '', '', ' title="' . wfMsg('mv_view_in_stream_interface') . '" '); |
| 601 | + $mvd_cnt_links .= '<br>'; |
568 | 602 | //$title = MakeTitle::() |
569 | 603 | //don't inclue link to wiki page (too confusing) |
570 | 604 | //$mvd_out .=' '; |
571 | | - $mvdTitle = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); |
| 605 | + $mvdTitle = Title :: MakeTitle(MV_NS_MVD, $mvd->wiki_title); |
572 | 606 | //$mvd_out .= $sk->makeKnownLinkObj($mvdTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/run_mediawiki.png">', '', '', '', '', ' title="' . wfMsg('mv_view_wiki_page') . '" '); |
573 | | - |
574 | | - $mvd_out.='<span id="mvr_desc_'.$mvd->id.'">'; |
575 | | - |
576 | | - |
577 | | - if(!isset($mvd->toplq))$mvd->toplq=false; |
| 607 | + |
| 608 | + $mvd_out .= '<span id="mvr_desc_' . $mvd->id . '">'; |
| 609 | + |
| 610 | + if (!isset ($mvd->toplq)) |
| 611 | + $mvd->toplq = false; |
578 | 612 | //output short desc send partial regEx: |
579 | | - if (!$mvd->toplq){ |
580 | | - $mvd_out.= $this->termHighlight($mvd->text, implode('|', $this->getTerms())); |
581 | | - }else { |
582 | | - if($mvdTitle->exists() && !isset($mvd->text)){ |
| 613 | + if (!$mvd->toplq) { |
| 614 | + $mvd_out .= $this->termHighlight($mvd->text, implode('|', $this->getTerms())); |
| 615 | + } else { |
| 616 | + if ($mvdTitle->exists() && !isset ($mvd->text)) { |
583 | 617 | //grab the article text: |
584 | | - $curRevision = Revision::newFromTitle($mvdTitle); |
| 618 | + $curRevision = Revision :: newFromTitle($mvdTitle); |
585 | 619 | $wikiText = $curRevision->getText(); |
586 | | - }else{ |
| 620 | + } else { |
587 | 621 | $wikiText = & $mvd->text; |
588 | 622 | } |
589 | 623 | //@@todo parse category info if present |
590 | | - $cat_html = ''; |
| 624 | + $cat_html = ''; |
591 | 625 | //run via parser to add in Category info: |
592 | 626 | $parserOptions = ParserOptions :: newFromUser($wgUser); |
593 | 627 | $parserOptions->setEditSection(false); |
— | — | @@ -601,21 +635,19 @@ |
602 | 636 | //add category pre-text: |
603 | 637 | //if ($cat_html != '') |
604 | 638 | //$mvd_out.= wfMsg('Categories') . ':' . $cat_html; |
605 | | - $mvd_out.=$cat_html; |
606 | | - |
607 | | - $mvd_out.= (count($srange['rows'])-1==1) |
608 | | - ? wfMsg('mv_match_text_one') |
609 | | - : wfMsg('mv_match_text', count($srange['rows'])-1); |
| 639 | + $mvd_out .= $cat_html; |
| 640 | + |
| 641 | + $mvd_out .= (count($srange['rows']) - 1 == 1) ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', count($srange['rows']) - 1); |
610 | 642 | //$wgOut->addCategoryLinks( $parserOutput->getCategories() ); |
611 | 643 | //$cat_html = $sk->getCategories(); |
612 | 644 | //empty out the categories |
613 | 645 | //$wgOut->mCategoryLinks = array(); |
614 | 646 | } |
615 | | - $mvd_out.='</span>'; |
616 | | - $mvd_out.='<br>'.$mvd_cnt_links; |
617 | | - $mvd_out.='<div style="display:block;clear:both;padding-top:4px;padding-bottom:4px;"/>'; |
618 | | - $mvd_out .= '<div id="mvr_' . $mvd->id . '" style="display:none;background:#'.$bgcolor.';" ></div>'; |
619 | | - } |
| 647 | + $mvd_out .= '</span>'; |
| 648 | + $mvd_out .= '<br>' . $mvd_cnt_links; |
| 649 | + $mvd_out .= '<div style="display:block;clear:both;padding-top:4px;padding-bottom:4px;"/>'; |
| 650 | + $mvd_out .= '<div id="mvr_' . $mvd->id . '" style="display:none;background:#' . $bgcolor . ';" ></div>'; |
| 651 | + } |
620 | 652 | $stream_out .= $mvd_out; |
621 | 653 | /*if(count($srange['rows'])!=1){ |
622 | 654 | $stream_out .= ' ' . $cat_html . ' In range:' . |
— | — | @@ -624,43 +656,44 @@ |
625 | 657 | $stream_out .= $mvd_out; |
626 | 658 | }else{ |
627 | 659 | $stream_out .= $mvd_out; |
628 | | - }*/ |
| 660 | + }*/ |
629 | 661 | } |
630 | 662 | $nsary = $mvgContLang->getNamespaces(); |
631 | 663 | //output stream name and mach count |
632 | 664 | /*$o.='<br /><img class="mv_stream_play_button" name="'.$nsary[MV_NS_STREAM].':' . |
633 | 665 | $mvTitle->getStreamName() . |
634 | 666 | '" align="left" src="'.$mvgScriptPath.'/skins/mv_embed/images/vid_play_sm.png">'; |
635 | | - */ |
636 | | - $o.= '<h3>' . $mvTitle->getStreamNameText(); |
637 | | - $o.=($matches==1)?wfMsg('mv_match_text_one'):wfMsg('mv_match_text', $matches); |
638 | | - $o.='</h3>'; |
639 | | - $o.= '<div id="mv_stream_' . $stream_id . '">' . $stream_out . '</div>'; |
| 667 | + */ |
| 668 | + $o .= '<h3>' . $mvTitle->getStreamNameText(); |
| 669 | + $o .= ($matches == 1) ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', $matches); |
| 670 | + $o .= '</h3>'; |
| 671 | + $o .= '<div id="mv_stream_' . $stream_id . '">' . $stream_out . '</div>'; |
640 | 672 | } |
641 | | - if($this->outputContainer)$o.='</div>'; |
| 673 | + if ($this->outputContainer) |
| 674 | + $o .= '</div>'; |
642 | 675 | return $o; |
643 | 676 | } |
644 | | - function getTerms(){ |
645 | | - $ret_ary = $cat_ary = array(); |
646 | | - foreach($this->filters as $filter){ |
| 677 | + function getTerms() { |
| 678 | + $ret_ary = $cat_ary = array (); |
| 679 | + foreach ($this->filters as $filter) { |
647 | 680 | switch ($filter['t']) { |
648 | | - case 'match': |
649 | | - case 'spoken_by': |
650 | | - case 'stream_name': |
| 681 | + case 'match' : |
| 682 | + case 'spoken_by' : |
| 683 | + case 'stream_name' : |
651 | 684 | $ret_ary[] = $filter['v']; |
652 | | - break; |
| 685 | + break; |
653 | 686 | case 'category' : |
654 | | - $cat_ary[] =$filter['v']; |
655 | | - break; |
| 687 | + $cat_ary[] = $filter['v']; |
| 688 | + break; |
656 | 689 | case 'smw_property' : |
657 | | - |
658 | | - break; |
659 | | - case 'smw_property_number': |
| 690 | + |
| 691 | + break; |
| 692 | + case 'smw_property_number' : |
660 | 693 | //should be special case for numeric values |
661 | | - break; |
| 694 | + break; |
662 | 695 | } |
663 | 696 | } |
664 | | - return $ret_ary+$cat_ary; |
| 697 | + return $ret_ary + $cat_ary; |
665 | 698 | } |
666 | 699 | /*function termHighlightText(&$text, $terms_ary){ |
667 | 700 | if(count($terms_ary)==0)return; |
— | — | @@ -680,50 +713,50 @@ |
681 | 714 | //print "\n\ncur text:". $text; |
682 | 715 | }*/ |
683 | 716 | /*very similar to showHit in SpecialSearch.php */ |
684 | | - function termHighlight( & $text, $terms, $contextlines=1, $contextchars=50 ) { |
| 717 | + function termHighlight(& $text, $terms, $contextlines = 1, $contextchars = 50) { |
685 | 718 | //$fname = 'SpecialSearch::termHighlight'; |
686 | 719 | //wfProfileIn( $fname ); |
687 | 720 | global $wgUser, $wgContLang, $wgLang; |
688 | 721 | $sk = $wgUser->getSkin(); |
689 | 722 | |
690 | | - $lines = explode( "\n", $text ); |
691 | | - $max = intval( $contextchars ) + 1; |
| 723 | + $lines = explode("\n", $text); |
| 724 | + $max = intval($contextchars) + 1; |
692 | 725 | $pat1 = "/(.*)($terms)(.{0,$max})/i"; |
693 | 726 | |
694 | 727 | $lineno = 0; |
695 | 728 | |
696 | 729 | $extract = ''; |
697 | | -// wfProfileIn( "$fname-extract" ); |
698 | | - foreach ( $lines as $line ) { |
699 | | - if ( 0 == $contextlines ) { |
| 730 | + // wfProfileIn( "$fname-extract" ); |
| 731 | + foreach ($lines as $line) { |
| 732 | + if (0 == $contextlines) { |
700 | 733 | break; |
701 | 734 | } |
702 | | - ++$lineno; |
703 | | - $m = array(); |
704 | | - if ( ! preg_match( $pat1, $line, $m ) ) { |
| 735 | + ++ $lineno; |
| 736 | + $m = array (); |
| 737 | + if (!preg_match($pat1, $line, $m)) { |
705 | 738 | continue; |
706 | 739 | } |
707 | | - --$contextlines; |
708 | | - $pre = $wgContLang->truncate( $m[1], -$contextchars, '...' ); |
| 740 | + -- $contextlines; |
| 741 | + $pre = $wgContLang->truncate($m[1], - $contextchars, '...'); |
709 | 742 | |
710 | | - if ( count( $m ) < 3 ) { |
| 743 | + if (count($m) < 3) { |
711 | 744 | $post = ''; |
712 | 745 | } else { |
713 | | - $post = $wgContLang->truncate( $m[3], $contextchars, '...' ); |
| 746 | + $post = $wgContLang->truncate($m[3], $contextchars, '...'); |
714 | 747 | } |
715 | 748 | |
716 | 749 | $found = $m[2]; |
717 | 750 | |
718 | | - $line = htmlspecialchars( $pre . $found . $post ); |
| 751 | + $line = htmlspecialchars($pre . $found . $post); |
719 | 752 | $pat2 = '/(' . $terms . ")/i"; |
720 | | - $line = preg_replace( $pat2, |
721 | | - "<span class='searchmatch'>\\1</span>", $line ); |
| 753 | + $line = preg_replace($pat2, "<span class='searchmatch'>\\1</span>", $line); |
722 | 754 | |
723 | 755 | //$extract .= " <small>{$lineno}: {$line}</small>\n"; |
724 | 756 | $extract .= " {$line}\n"; |
725 | | - } |
| 757 | + } |
726 | 758 | //if we found no matches just return the first line: |
727 | | - if($extract=='')return ' '. $wgContLang->truncate($text, ($contextchars*2), '...').''; |
| 759 | + if ($extract == '') |
| 760 | + return ' ' . $wgContLang->truncate($text, ($contextchars * 2), '...') . ''; |
728 | 761 | //wfProfileOut( "$fname-extract" ); |
729 | 762 | //wfProfileOut( $fname ); |
730 | 763 | //return "<li>{$link} ({$size}){$extract}</li>\n"; |
— | — | @@ -731,31 +764,31 @@ |
732 | 765 | } |
733 | 766 | //output expanded request via mvd_id |
734 | 767 | function expand_wt($mvd_id, $terms_ary) { |
735 | | - global $wgOut,$mvgIP; |
736 | | - global $mvDefaultSearchVideoPlaybackRes; |
737 | | - |
738 | | - $mvd = MV_Index::getMVDbyId($mvd_id); |
739 | | - if(count($mvd)!=0){ |
| 768 | + global $wgOut, $mvgIP; |
| 769 | + global $mvDefaultSearchVideoPlaybackRes; |
| 770 | + |
| 771 | + $mvd = MV_Index :: getMVDbyId($mvd_id); |
| 772 | + if (count($mvd) != 0) { |
740 | 773 | $mvTitle = new MV_Title($mvd->wiki_title); |
741 | 774 | //validate title and load stream ref: |
742 | | - if($mvTitle->validRequestTitle()){ |
743 | | - list($vWidth, $vHeight) = explode('x', $mvDefaultSearchVideoPlaybackRes); |
744 | | - $embedHTML='<span style="float:left;width:'.($vWidth+20).'px">' . |
745 | | - $mvTitle->getEmbedVideoHtml('vid_'.$mvd_id, $mvDefaultSearchVideoPlaybackRes, '',$autoplay=true) . |
746 | | - '</span>'; |
| 775 | + if ($mvTitle->validRequestTitle()) { |
| 776 | + list ($vWidth, $vHeight) = explode('x', $mvDefaultSearchVideoPlaybackRes); |
| 777 | + $embedHTML = '<span style="float:left;width:' . ($vWidth +20) . 'px">' . |
| 778 | + $mvTitle->getEmbedVideoHtml('vid_' . $mvd_id, $mvDefaultSearchVideoPlaybackRes, '', $autoplay = true) . |
| 779 | + '</span>'; |
747 | 780 | $wgOut->clearHTML(); |
748 | | - $MvOverlay = new MV_Overlay(); |
749 | | - $MvOverlay->outputMVD($mvd, $mvTitle); |
750 | | - $pageHTML='<span style="padding-top:10px;float:left;width:450px">'. |
751 | | - $wgOut->getHTML(). |
752 | | - '</span>'; |
753 | | - |
| 781 | + $MvOverlay = new MV_Overlay(); |
| 782 | + $MvOverlay->outputMVD($mvd, $mvTitle); |
| 783 | + $pageHTML = '<span style="padding-top:10px;float:left;width:450px">' . |
| 784 | + $wgOut->getHTML() . |
| 785 | + '</span>'; |
| 786 | + |
754 | 787 | //return page html: |
755 | | - return $embedHTML. $pageHTML. '<div style="clear: both;"/>'; |
756 | | - }else{ |
| 788 | + return $embedHTML . $pageHTML . '<div style="clear: both;"/>'; |
| 789 | + } else { |
757 | 790 | return wfMsg('mvBadMVDtitle'); |
758 | 791 | } |
759 | | - }else{ |
| 792 | + } else { |
760 | 793 | return wfMsg('mv_error_mvd_not_found'); |
761 | 794 | } |
762 | 795 | //$title = Title::MakeTitle(MV_NS_MVD, $wiki_title); |
— | — | @@ -763,70 +796,69 @@ |
764 | 797 | //output table with embed left, and content right |
765 | 798 | //return $wgOut->parse($article->getContent()); |
766 | 799 | } |
767 | | - function get_httpd_filters_query(){ |
| 800 | + function get_httpd_filters_query() { |
768 | 801 | //get all the mvd ns selected: |
769 | | - $opt = $this->powerSearchOptions(); |
770 | | - return http_build_query($opt +array('f'=>$this->filters)); |
| 802 | + $opt = $this->powerSearchOptions(); |
| 803 | + return http_build_query($opt + array ( |
| 804 | + 'f' => $this->filters |
| 805 | + )); |
771 | 806 | } |
772 | 807 | function list_active_filters() { |
773 | 808 | global $mvgScriptPath; |
774 | | - $s=$so=''; |
775 | | - $dateObjOut=false; |
776 | | - $s .= '<div id="mv_active_filters" style="margin-bottom:10px;">'; |
| 809 | + $s = $so = ''; |
| 810 | + $dateObjOut = false; |
| 811 | + $s .= '<div id="mv_active_filters" style="margin-bottom:10px;">'; |
777 | 812 | foreach ($this->filters as $i => $filter) { |
778 | 813 | if (!isset ($filter['v'])) //value |
779 | 814 | $filter['v'] = ''; |
780 | 815 | if (!isset ($filter['t'])) //type |
781 | 816 | $filter['t'] = ''; |
782 | 817 | if (!isset ($filter['a'])) //and, or, not |
783 | | - $filter['a']=''; |
784 | | - |
| 818 | + $filter['a'] = ''; |
| 819 | + |
785 | 820 | //output the master selecter per line: |
786 | | - $s .= '<span id="mvs_' . $i . '">'; |
787 | | - $s .= ' '; |
| 821 | + $s .= '<span id="mvs_' . $i . '">'; |
| 822 | + $s .= ' '; |
788 | 823 | //selctor (don't display if i==0') |
789 | | - $s .= $this->selector($i, 'a', $filter['a'],($i==0)?false:true ); |
| 824 | + $s .= $this->selector($i, 'a', $filter['a'], ($i == 0) ? false : true); |
790 | 825 | $s .= $this->selector($i, 't', $filter['t']); //type selector |
791 | 826 | $s .= '<span id="mvs_' . $i . '_tc">'; |
792 | | - switch ($filter['t']) { |
| 827 | + switch ($filter['t']) { |
793 | 828 | case 'match' : |
794 | 829 | $s .= $this->text_entry($i, 'v', $filter['v'], 'mv_hl_text'); |
795 | 830 | break; |
796 | 831 | case 'category' : |
797 | 832 | //$s.=$this->get_ref_ac($i, $filter['v']); |
798 | 833 | $s .= $this->text_entry($i, 'v', $filter['v']); |
799 | | - break; |
800 | | - case 'date_range': |
801 | | - $s .=wfMsg('mv_time_separator', |
802 | | - $this->text_entry($i, 'vs', $filter['vs'], 'date-pick_'.$i, 'id="vs_'.$i.'"'), |
803 | | - $this->text_entry($i, 've', $filter['ve'], 'date-pick_'.$i, 'id="ve_'.$i.'"') |
804 | | - ); |
| 834 | + break; |
| 835 | + case 'date_range' : |
| 836 | + $s .= wfMsg('mv_time_separator', $this->text_entry($i, 'vs', $filter['vs'], 'date-pick_' . $i, 'id="vs_' . $i . '"'), $this->text_entry($i, 've', $filter['ve'], 'date-pick_' . $i, 'id="ve_' . $i . '"')); |
805 | 837 | //also output dateObj (if not already output): |
806 | | - if(!$dateObjOut){ |
| 838 | + if (!$dateObjOut) { |
807 | 839 | global $wgOut; |
808 | 840 | //add all date scripts: |
809 | | - $wgOut->addScript("\n". |
810 | | - '<!-- required plugins --> |
811 | | - <script type="text/javascript" src="'.$mvgScriptPath.'/skins/mv_embed/jquery/plugins/date.js"></script> |
812 | | - <!--[if IE]><script type="text/javascript" src="'.$mvgScriptPath.'/skins/mv_embed/jquery/plugins/jquery.bgiframe.js"></script><![endif]--> |
813 | | - |
814 | | - <!-- jquery.datePicker.js --> |
815 | | - <script type="text/javascript" src="'.$mvgScriptPath.'/skins/mv_embed/jquery/plugins/jquery.datePicker.js"></script> |
816 | | - <script language="javascript" type="text/javascript">'. |
817 | | - $this->getJsonDateObj('mvDateInitObj') . |
818 | | - '</script>'); |
819 | | - $dateObjOut=true; |
| 841 | + $wgOut->addScript("\n" . |
| 842 | + '<!-- required plugins --> |
| 843 | + <script type="text/javascript" src="' . $mvgScriptPath . '/skins/mv_embed/jquery/plugins/date.js"></script> |
| 844 | + <!--[if IE]><script type="text/javascript" src="' . $mvgScriptPath . '/skins/mv_embed/jquery/plugins/jquery.bgiframe.js"></script><![endif]--> |
| 845 | + |
| 846 | + <!-- jquery.datePicker.js --> |
| 847 | + <script type="text/javascript" src="' . $mvgScriptPath . '/skins/mv_embed/jquery/plugins/jquery.datePicker.js"></script> |
| 848 | + <script language="javascript" type="text/javascript">' . |
| 849 | + $this->getJsonDateObj('mvDateInitObj') . |
| 850 | + '</script>'); |
| 851 | + $dateObjOut = true; |
820 | 852 | } |
821 | | - break; |
822 | | - case 'stream_name': |
| 853 | + break; |
| 854 | + case 'stream_name' : |
823 | 855 | $s .= $this->text_entry($i, 'v', $filter['v']); |
824 | | - break; |
| 856 | + break; |
825 | 857 | case 'spoken_by' : |
826 | 858 | $s .= $this->get_ref_person($i, $filter['v'], true); |
827 | 859 | break; |
828 | 860 | case 'smw_property' : |
829 | 861 | |
830 | | - break; |
| 862 | + break; |
831 | 863 | } |
832 | 864 | $s .= '</span>'; |
833 | 865 | if ($i > 0) |
— | — | @@ -835,7 +867,7 @@ |
836 | 868 | '<img title="' . wfMsg('mv_remove_filter') . '" ' . |
837 | 869 | 'src="' . $mvgScriptPath . '/skins/images/cog_delete.png"></a>'; |
838 | 870 | $s .= '</span>'; |
839 | | - } |
| 871 | + } |
840 | 872 | $s .= '</div>'; |
841 | 873 | //reference remove |
842 | 874 | $s .= '<a id="mv_ref_remove" style="display:none;" ' . |
— | — | @@ -852,54 +884,55 @@ |
853 | 885 | 'src="' . $mvgScriptPath . '/skins/images/cog_add.png"></a> '; |
854 | 886 | |
855 | 887 | /*$s .= '<input id="mv_do_search" type="submit" ' . |
856 | | - ' value="' . wfMsg('mv_run_search') . '">';*/ |
857 | | - |
| 888 | + ' value="' . wfMsg('mv_run_search') . '">';*/ |
| 889 | + |
858 | 890 | return $s . $so; |
859 | 891 | } |
860 | | - function getResultsBar(){ |
861 | | - $o='<div class="mv_result_bar">'; |
862 | | - if($this->numResultsFound){ |
863 | | - $re = ($this->limit+$this->offset > $this->numResultsFound)?$this->numResultsFound:($this->limit+$this->offset); |
864 | | - $rs = ($this->offset==0)?1:$this->offset; |
865 | | - $o.=wfMsg('mv_results_found_for',$rs,$re , number_format($this->numResultsFound)); |
| 892 | + function getResultsBar() { |
| 893 | + $o = '<div class="mv_result_bar">'; |
| 894 | + if ($this->numResultsFound) { |
| 895 | + $re = ($this->limit + $this->offset > $this->numResultsFound) ? $this->numResultsFound : ($this->limit + $this->offset); |
| 896 | + $rs = ($this->offset == 0) ? 1 : $this->offset; |
| 897 | + $o .= wfMsg('mv_results_found_for', $rs, $re, number_format($this->numResultsFound)); |
866 | 898 | } |
867 | | - $o.=$this->getFilterDesc(); |
868 | | - $o.='</div>'; |
| 899 | + $o .= $this->getFilterDesc(); |
| 900 | + $o .= '</div>'; |
869 | 901 | return $o; |
870 | 902 | } |
871 | | - function getSearchLink(){ |
872 | | - return SpecialPage::getTitleFor( 'MediaSearch' ) . |
873 | | - $this->get_httpd_filters_query(); |
| 903 | + function getSearchLink() { |
| 904 | + return SpecialPage :: getTitleFor('MediaSearch') . |
| 905 | + $this->get_httpd_filters_query(); |
874 | 906 | } |
875 | 907 | /* |
876 | 908 | * returns human readable description of filters |
877 | 909 | */ |
878 | | - function getFilterDesc($query_key=false){ |
879 | | - $o=$a=''; |
880 | | - $bo=($query_key)?'':'<b>'; |
881 | | - $bc=($query_key)?'':'</b>'; |
882 | | - foreach($this->filters as $inx=>$f){ |
883 | | - if($inx!=0)$a=' '.wfMsg('mv_search_'.$f['a']).' '; |
884 | | - $o.=($query_key)?$a:$a.wfMsg('mv_'.$f['t']).' '; |
885 | | - if($f['t']=='date_range'){ //handle special case of date range: |
886 | | - $o.=wfMsg('mv_time_separator', $bo.$f['vs'].$bc, $bo.$f['ve'].$bc); |
887 | | - }else{ |
888 | | - $o.=$bo. str_replace('_',' ',$f['v']).$bc; |
| 910 | + function getFilterDesc($query_key = false) { |
| 911 | + $o = $a = ''; |
| 912 | + $bo = ($query_key) ? '' : '<b>'; |
| 913 | + $bc = ($query_key) ? '' : '</b>'; |
| 914 | + foreach ($this->filters as $inx => $f) { |
| 915 | + if ($inx != 0) |
| 916 | + $a = ' ' . wfMsg('mv_search_' . $f['a']) . ' '; |
| 917 | + $o .= ($query_key) ? $a : $a . wfMsg('mv_' . $f['t']) . ' '; |
| 918 | + if ($f['t'] == 'date_range') { //handle special case of date range: |
| 919 | + $o .= wfMsg('mv_time_separator', $bo . $f['vs'] . $bc, $bo . $f['ve'] . $bc); |
| 920 | + } else { |
| 921 | + $o .= $bo . str_replace('_', ' ', $f['v']) . $bc; |
889 | 922 | } |
890 | 923 | } |
891 | 924 | return $o; |
892 | | - } |
| 925 | + } |
893 | 926 | function get_ref_person($inx = '', $person_name = MV_MISSING_PERSON_IMG, $disp = false) { |
894 | | - if($disp) { |
| 927 | + if ($disp) { |
895 | 928 | $tname = 'f[' . $inx . '][v]'; |
896 | 929 | $inx = '_' . $inx; |
897 | 930 | $disp = 'inline'; |
898 | | - }else{ |
| 931 | + } else { |
899 | 932 | $tname = ''; |
900 | 933 | $inx = ''; |
901 | 934 | $person_name = ''; |
902 | 935 | $disp = 'none'; |
903 | | - } |
| 936 | + } |
904 | 937 | //make the missing person image ref: |
905 | 938 | $imgTitle = Title :: makeTitle(NS_IMAGE, $person_name . '.jpg'); |
906 | 939 | if (!$imgTitle->exists()) { |
— | — | @@ -913,21 +946,21 @@ |
914 | 947 | //print "title is: " .$imgTitle->getDBkey() ."IMAGE IS: " . $img->getURL(); |
915 | 948 | |
916 | 949 | return '<span class="mv_person_ac" id="mv_person' . $inx . '" style="display:' . $disp . ';width:90px;">' . |
917 | | - '<img id="mv_person_img' . $inx . '" style="padding:2px;" src="' . $img->getURL() . '" width="44">' . |
918 | | - '<input id="mv_person_input' . $inx . '" class="mv_search_text" style="font-size: 12px;" size="9" ' . |
919 | | - 'type="text" name="' . $tname . '" value="' . $person_name . '" autocomplete="off">' . |
920 | | - '<div id="mv_person_choices'.$inx.'" class="autocomplete"></div>' . |
921 | | - '</span>'; |
| 950 | + '<img id="mv_person_img' . $inx . '" style="padding:2px;" src="' . $img->getURL() . '" width="44">' . |
| 951 | + '<input id="mv_person_input' . $inx . '" class="mv_search_text" style="font-size: 12px;" size="9" ' . |
| 952 | + 'type="text" name="' . $tname . '" value="' . $person_name . '" autocomplete="off">' . |
| 953 | + '<div id="mv_person_choices' . $inx . '" class="autocomplete"></div>' . |
| 954 | + '</span>'; |
922 | 955 | } |
923 | | - function selector($i, $key, $selected='', $display=true) { |
924 | | - $disp = ($display)?'':'display:none;'; |
925 | | - $s= '<select id="mvsel_'.$key.'_' . $i . '" class="mv_search_select" style="font-size: 12px;'.$disp.'" name="f['.$i .']['.$key.']" >' . "\n"; |
926 | | - $items = ($key == 't')?$this->sel_filter_types:$this->sel_filter_andor; |
927 | | - if($key=='a' && $selected=='') |
928 | | - $selected='and'; |
929 | | - |
| 956 | + function selector($i, $key, $selected = '', $display = true) { |
| 957 | + $disp = ($display) ? '' : 'display:none;'; |
| 958 | + $s = '<select id="mvsel_' . $key . '_' . $i . '" class="mv_search_select" style="font-size: 12px;' . $disp . '" name="f[' . $i . '][' . $key . ']" >' . "\n"; |
| 959 | + $items = ($key == 't') ? $this->sel_filter_types : $this->sel_filter_andor; |
| 960 | + if ($key == 'a' && $selected == '') |
| 961 | + $selected = 'and'; |
| 962 | + |
930 | 963 | $sel = ($selected == '') ? 'selected' : ''; |
931 | | - if($key=='t') |
| 964 | + if ($key == 't') |
932 | 965 | $s .= '<option value="na" ' . $sel . '>' . wfMsg('mv_search_sel_' . $key) . '</option>' . "\n"; |
933 | 966 | foreach ($items as $item) { |
934 | 967 | $sel = ($selected == $item) ? $sel = 'selected' : ''; |
— | — | @@ -937,119 +970,125 @@ |
938 | 971 | return $s; |
939 | 972 | } |
940 | 973 | //could be a suggest: |
941 | | - function text_entry($i, $key, $val = '', $more_class='', $more_attr='') { |
942 | | - if($more_class!='')$more_class=' '.$more_class; |
943 | | - $s = '<input '.$more_attr.' class="mv_search_text'.$more_class.'" style="font-size: 12px;" onchange="" |
944 | | - size="9" type="text" name="f[' . $i . '][' . $key . ']" value="' . $val . '">'; |
| 974 | + function text_entry($i, $key, $val = '', $more_class = '', $more_attr = '') { |
| 975 | + if ($more_class != '') |
| 976 | + $more_class = ' ' . $more_class; |
| 977 | + $s = '<input ' . $more_attr . ' class="mv_search_text' . $more_class . '" style="font-size: 12px;" onchange="" |
| 978 | + size="9" type="text" name="f[' . $i . '][' . $key . ']" value="' . $val . '">'; |
945 | 979 | return $s; |
946 | 980 | } |
947 | 981 | /*again here is some possibly metavid congress archive specific stuff:*/ |
948 | | - function auto_complete_all($val){ |
| 982 | + function auto_complete_all($val) { |
949 | 983 | global $wgContLang; |
950 | 984 | //everything is db key based so swap space for underscore: |
951 | | - $val = str_replace(' ','_',$val); |
952 | | - |
| 985 | + $val = str_replace(' ', '_', $val); |
| 986 | + |
953 | 987 | $catNStxt = $wgContLang->getNsText(NS_CATEGORY); |
954 | | - |
| 988 | + |
955 | 989 | //make sure people know they can "search" too (formated by |
956 | | - $out='do_search|'.wfMsg('mv_search_transcripts_for','<B>$1</B>').'|no_image'."\n"; |
| 990 | + $out = 'do_search|' . wfMsg('mv_search_transcripts_for', '<B>$1</B>') . '|no_image' . "\n"; |
957 | 991 | //get keywords |
958 | | - $category_out = MV_SpecialMediaSearch::auto_complete_search_categories($val, 3); |
959 | | - if($category_out!=''){ |
960 | | - $out.=$catNStxt.':Categories|<h6>'.wfMsg('mv_category_matches').'</h6>|no_image'."\n"; |
961 | | - $out.=$category_out; |
| 992 | + $category_out = MV_SpecialMediaSearch :: auto_complete_search_categories($val, 3); |
| 993 | + if ($category_out != '') { |
| 994 | + $out .= $catNStxt . ':Categories|<h6>' . wfMsg('mv_category_matches') . '</h6>|no_image' . "\n"; |
| 995 | + $out .= $category_out; |
962 | 996 | } |
963 | 997 | //get people |
964 | | - $person_out = MV_SpecialMediaSearch::auto_complete_person($val, 3); |
965 | | - if($person_out!=''){ |
966 | | - $out.=$catNStxt.':Person|<h6>'.wfMsg('mv_people_matches').'</h6>|no_image'."\n"; |
967 | | - $out.=$person_out; |
| 998 | + $person_out = MV_SpecialMediaSearch :: auto_complete_person($val, 3); |
| 999 | + if ($person_out != '') { |
| 1000 | + $out .= $catNStxt . ':Person|<h6>' . wfMsg('mv_people_matches') . '</h6>|no_image' . "\n"; |
| 1001 | + $out .= $person_out; |
968 | 1002 | } |
969 | 1003 | //get bills |
970 | | - $bill_out = MV_SpecialMediaSearch::auto_complete_category('Bill', $val, 3); |
971 | | - if($bill_out!=''){ |
972 | | - $out.=$catNStxt.':Bill|<h6>'.wfMsg('mv_bill_matches').'</h6>|no_image'."\n"; |
973 | | - $out.=$bill_out; |
| 1004 | + $bill_out = MV_SpecialMediaSearch :: auto_complete_category('Bill', $val, 3); |
| 1005 | + if ($bill_out != '') { |
| 1006 | + $out .= $catNStxt . ':Bill|<h6>' . wfMsg('mv_bill_matches') . '</h6>|no_image' . "\n"; |
| 1007 | + $out .= $bill_out; |
974 | 1008 | } |
975 | 1009 | //get interests |
976 | | - $intrest_out = MV_SpecialMediaSearch::auto_complete_category('Interest_Group', $val, 3); |
977 | | - if($intrest_out!=''){ |
978 | | - $out.=$catNStxt.':Interest Group|<h6>'.wfMsg('mv_interest_group_matches').'</h6>|no_image'."\n"; |
979 | | - $out.=$intrest_out; |
| 1010 | + $intrest_out = MV_SpecialMediaSearch :: auto_complete_category('Interest_Group', $val, 3); |
| 1011 | + if ($intrest_out != '') { |
| 1012 | + $out .= $catNStxt . ':Interest Group|<h6>' . wfMsg('mv_interest_group_matches') . '</h6>|no_image' . "\n"; |
| 1013 | + $out .= $intrest_out; |
980 | 1014 | } |
981 | 1015 | return $out; |
982 | 1016 | } |
983 | | - function auto_complete_search_categories($val, $result_limit='5', $format='ac_line', &$match_count=''){ |
| 1017 | + function auto_complete_search_categories($val, $result_limit = '5', $format = 'ac_line', & $match_count = '') { |
984 | 1018 | global $wgContLang; |
985 | | - $dbr =& wfGetDB(DB_SLAVE); |
986 | | - $result = $dbr->select( 'page', 'page_title', |
987 | | - array('page_namespace'=>NS_CATEGORY, |
988 | | - '`page_title` LIKE \'%'.mysql_escape_string($val).'%\' COLLATE latin1_general_ci'), |
989 | | - __METHOD__, |
990 | | - array('LIMIT'=>$result_limit)); |
| 1019 | + $dbr = & wfGetDB(DB_SLAVE); |
| 1020 | + $result = $dbr->select('page', 'page_title', array ( |
| 1021 | + 'page_namespace' => NS_CATEGORY, |
| 1022 | + '`page_title` LIKE \'%' . mysql_escape_string($val |
| 1023 | + ) . '%\' COLLATE latin1_general_ci'), __METHOD__, array ( |
| 1024 | + 'LIMIT' => $result_limit |
| 1025 | + )); |
991 | 1026 | $match_count = $dbr->numRows($result); |
992 | | - if($dbr->numRows($result) == 0)return ''; |
993 | | - $out=''; |
994 | | - $catNStxt = $wgContLang->getNsText(NS_CATEGORY); |
995 | | - while($row = $dbr->fetchObject($result)){ |
996 | | - $out.=MV_SpecialMediaSearch::format_ac_line($row->page_title, $val, $catNStxt.':', 'no_image', $format); |
| 1027 | + if ($dbr->numRows($result) == 0) |
| 1028 | + return ''; |
| 1029 | + $out = ''; |
| 1030 | + $catNStxt = $wgContLang->getNsText(NS_CATEGORY); |
| 1031 | + while ($row = $dbr->fetchObject($result)) { |
| 1032 | + $out .= MV_SpecialMediaSearch :: format_ac_line($row->page_title, $val, $catNStxt . ':', 'no_image', $format); |
997 | 1033 | } |
998 | 1034 | return $out; |
999 | 1035 | } |
1000 | | - function auto_complete_category($category, $val, $result_limit='5', $format='ac_line', &$match_count=''){ |
1001 | | - $dbr =& wfGetDB(DB_SLAVE); |
1002 | | - $result = $dbr->select( 'categorylinks', 'cl_sortkey', |
1003 | | - array('cl_to'=>$category, |
1004 | | - '`cl_sortkey` LIKE \'%'.mysql_escape_string($val).'%\' COLLATE latin1_general_ci'), |
1005 | | - __METHOD__, |
1006 | | - array('LIMIT'=>$result_limit)); |
| 1036 | + function auto_complete_category($category, $val, $result_limit = '5', $format = 'ac_line', & $match_count = '') { |
| 1037 | + $dbr = & wfGetDB(DB_SLAVE); |
| 1038 | + $result = $dbr->select('categorylinks', 'cl_sortkey', array ( |
| 1039 | + 'cl_to' => $category, |
| 1040 | + '`cl_sortkey` LIKE \'%' . mysql_escape_string($val |
| 1041 | + ) . '%\' COLLATE latin1_general_ci'), __METHOD__, array ( |
| 1042 | + 'LIMIT' => $result_limit |
| 1043 | + )); |
1007 | 1044 | //print 'ran: ' . $dbr->lastQuery(); |
1008 | 1045 | //mention_bill catebory Bill |
1009 | 1046 | $match_count = $dbr->numRows($result); |
1010 | | - if($dbr->numRows($result) == 0)return ''; |
1011 | | - $out=''; |
1012 | | - while($row = $dbr->fetchObject($result)){ |
1013 | | - $out.=MV_SpecialMediaSearch::format_ac_line($row->cl_sortkey, $val, '', 'no_image', $format); |
| 1047 | + if ($dbr->numRows($result) == 0) |
| 1048 | + return ''; |
| 1049 | + $out = ''; |
| 1050 | + while ($row = $dbr->fetchObject($result)) { |
| 1051 | + $out .= MV_SpecialMediaSearch :: format_ac_line($row->cl_sortkey, $val, '', 'no_image', $format); |
1014 | 1052 | } |
1015 | 1053 | return $out; |
1016 | 1054 | } |
1017 | 1055 | /*@@todo cache result for given values*/ |
1018 | | - function auto_complete_person($val, $result_limit='5', $format='ac_line', &$match_count=''){ |
1019 | | - $dbr =& wfGetDB(DB_SLAVE); |
1020 | | - $result = $dbr->select( 'categorylinks', 'cl_sortkey', |
1021 | | - array('cl_to'=>'Person', |
1022 | | - '`cl_sortkey` LIKE \'%'.mysql_escape_string($val).'%\' COLLATE latin1_general_ci'), |
1023 | | - __METHOD__, |
1024 | | - array('LIMIT'=>$result_limit)); |
1025 | | - $match_count=$dbr->numRows($result); |
1026 | | - if($dbr->numRows($result) == 0)return ''; |
| 1056 | + function auto_complete_person($val, $result_limit = '5', $format = 'ac_line', & $match_count = '') { |
| 1057 | + $dbr = & wfGetDB(DB_SLAVE); |
| 1058 | + $result = $dbr->select('categorylinks', 'cl_sortkey', array ( |
| 1059 | + 'cl_to' => 'Person', |
| 1060 | + '`cl_sortkey` LIKE \'%' . mysql_escape_string($val |
| 1061 | + ) . '%\' COLLATE latin1_general_ci'), __METHOD__, array ( |
| 1062 | + 'LIMIT' => $result_limit |
| 1063 | + )); |
| 1064 | + $match_count = $dbr->numRows($result); |
| 1065 | + if ($dbr->numRows($result) == 0) |
| 1066 | + return ''; |
1027 | 1067 | //$out='<ul>'."\n"; |
1028 | | - $out=''; |
1029 | | - while($row = $dbr->fetchObject($result)){ |
| 1068 | + $out = ''; |
| 1069 | + while ($row = $dbr->fetchObject($result)) { |
1030 | 1070 | $person_name = $row->cl_sortkey; |
1031 | 1071 | //make sure the person page exists: |
1032 | | - $personTitle = Title::makeTitle(NS_MAIN, $person_name); |
1033 | | - if($personTitle->exists()){ |
| 1072 | + $personTitle = Title :: makeTitle(NS_MAIN, $person_name); |
| 1073 | + if ($personTitle->exists()) { |
1034 | 1074 | //get person full name from semantic table if available |
1035 | | - $person_result = $dbr->select('smw_attributes', 'value_xsd', array('attribute_title'=>'Full_Name', |
1036 | | - 'subject_title'=>$personTitle->getDBkey()), |
1037 | | - __METHOD__); |
1038 | | - if($dbr->numRows($person_result)== 0){ |
| 1075 | + $person_result = $dbr->select('smw_attributes', 'value_xsd', array ( |
| 1076 | + 'attribute_title' => 'Full_Name', |
| 1077 | + 'subject_title' => $personTitle->getDBkey()), __METHOD__); |
| 1078 | + if ($dbr->numRows($person_result) == 0) { |
1039 | 1079 | $person_full_name = $person_name; |
1040 | | - }else{ |
| 1080 | + } else { |
1041 | 1081 | $pvalue = $dbr->fetchObject($person_result); |
1042 | 1082 | $person_full_name = $pvalue->value_xsd; |
1043 | | - } |
| 1083 | + } |
1044 | 1084 | //format and output the line: |
1045 | | - $out.=MV_SpecialMediaSearch::format_ac_line($person_full_name, $val, '', |
1046 | | - MV_SpecialMediaSearch::getPersonImageURL($person_name), $format); |
1047 | | - } |
| 1085 | + $out .= MV_SpecialMediaSearch :: format_ac_line($person_full_name, $val, '', MV_SpecialMediaSearch :: getPersonImageURL($person_name), $format); |
| 1086 | + } |
1048 | 1087 | } |
1049 | 1088 | //$out.='</ul>'; |
1050 | 1089 | //return people people in the Person Category |
1051 | 1090 | return $out; |
1052 | 1091 | } |
1053 | | - function getPersonImageURL($person_name){ |
| 1092 | + function getPersonImageURL($person_name) { |
1054 | 1093 | //make the missing person image ref: |
1055 | 1094 | $imgTitle = Title :: makeTitle(NS_IMAGE, $person_name . '.jpg'); |
1056 | 1095 | if (!$imgTitle->exists()) { |
— | — | @@ -1062,62 +1101,69 @@ |
1063 | 1102 | } |
1064 | 1103 | return $img->getURL(); |
1065 | 1104 | } |
1066 | | - function format_ac_line(&$page_title, $val, $prefix='', $img_link='no_image', $format='ac_line'){ |
| 1105 | + function format_ac_line(& $page_title, $val, $prefix = '', $img_link = 'no_image', $format = 'ac_line') { |
1067 | 1106 | //no underscores in display title: |
1068 | | - $page_title_disp = str_replace('_',' ',$page_title); |
| 1107 | + $page_title_disp = str_replace('_', ' ', $page_title); |
1069 | 1108 | //bold matching part of title: |
1070 | | - $bs = stripos($page_title_disp, str_replace('_',' ',$val) ); |
1071 | | - if($bs!==false){ |
1072 | | - $page_title_disp = substr($page_title_disp, 0, $bs) . |
1073 | | - '<b>'.substr($page_title_disp, $bs, strlen($val)) . |
1074 | | - '</b>' . substr($page_title_disp, $bs+strlen($val)); |
| 1109 | + $bs = stripos($page_title_disp, str_replace('_', ' ', $val)); |
| 1110 | + if ($bs !== false) { |
| 1111 | + $page_title_disp = substr($page_title_disp, 0, $bs) . |
| 1112 | + '<b>' . substr($page_title_disp, $bs, strlen($val)) . |
| 1113 | + '</b>' . substr($page_title_disp, $bs +strlen($val)); |
1075 | 1114 | } |
1076 | 1115 | //$page_title_bold = str_ireplace($val, '<b>'.$val.'</b>',$page_title); |
1077 | | - if($format=='ac_line'){ |
1078 | | - return $prefix.$page_title.'|'.$page_title_disp.'|'.$img_link."\n"; |
1079 | | - }else if($format=='block_html' || $format=='person_html'){ |
1080 | | - global $wgUser; |
1081 | | - $sk = $wgUser->getSkin(); |
1082 | | - $title = Title::newFromText($prefix.$page_title); |
1083 | | - |
1084 | | - if($format=='block_html') |
1085 | | - return "<p class=\"normal_match\">".$sk->makeKnownLinkObj($title, |
1086 | | - '<span>'.$page_title_disp.'</span>').'</p>'; |
1087 | | - |
1088 | | - if($format=='person_html') |
1089 | | - return "<p class=\"people2_match last_match\"><img src=\"{$img_link}\">".$sk->makeKnownLinkObj($title, $page_title_disp).'</p>'; |
1090 | | - } |
| 1116 | + if ($format == 'ac_line') { |
| 1117 | + return $prefix . $page_title . '|' . $page_title_disp . '|' . $img_link . "\n"; |
| 1118 | + } else |
| 1119 | + if ($format == 'block_html' || $format == 'person_html') { |
| 1120 | + global $wgUser; |
| 1121 | + $sk = $wgUser->getSkin(); |
| 1122 | + $title = Title :: newFromText($prefix . $page_title); |
| 1123 | + |
| 1124 | + if ($format == 'block_html') |
| 1125 | + return "<p class=\"normal_match\">" . $sk->makeKnownLinkObj($title, '<span>' . |
| 1126 | + $page_title_disp . '</span>') . '</p>'; |
| 1127 | + |
| 1128 | + if ($format == 'person_html') |
| 1129 | + return "<p class=\"people2_match last_match\"><img src=\"{$img_link}\">" . $sk->makeKnownLinkObj($title, $page_title_disp) . '</p>'; |
| 1130 | + } |
1091 | 1131 | } |
1092 | 1132 | //return a json date obj |
1093 | 1133 | //@@todo fix for big sites...(will start to be no fun if number of streams is > 2000 ) |
1094 | | - function getJsonDateObj($obj_name='mv_result'){ |
1095 | | - $dbr =& wfGetDB(DB_SLAVE); |
| 1134 | + function getJsonDateObj($obj_name = 'mv_result') { |
| 1135 | + $dbr = & wfGetDB(DB_SLAVE); |
1096 | 1136 | $sql = 'SELECT `date_start_time` FROM `mv_streams` ' . |
1097 | | - 'WHERE `date_start_time` IS NOT NULL ' . |
1098 | | - 'ORDER BY `date_start_time` ASC LIMIT 0, 2000'; |
| 1137 | + 'WHERE `date_start_time` IS NOT NULL ' . |
| 1138 | + 'ORDER BY `date_start_time` ASC LIMIT 0, 2000'; |
1099 | 1139 | $res = $dbr->query($sql, 'MV_SpecialMediaSearch:getJsonDateObj'); |
1100 | | - $start_day=time(); |
1101 | | - $end_day=0; |
1102 | | - $delta=0; |
1103 | | - $sDays = array(); |
1104 | | - while($row = $dbr->fetchObject( $res )){ |
1105 | | - if($row->date_start_time==0)continue; //skip empty / zero values |
1106 | | - if($row->date_start_time < $start_day)$start_day=$row->date_start_time; |
1107 | | - if($row->date_start_time > $end_day)$end_day = $row->date_start_time; |
1108 | | - list($month,$day, $year) = explode('/',date('m/d/Y',$row->date_start_time)); |
| 1140 | + $start_day = time(); |
| 1141 | + $end_day = 0; |
| 1142 | + $delta = 0; |
| 1143 | + $sDays = array (); |
| 1144 | + while ($row = $dbr->fetchObject($res)) { |
| 1145 | + if ($row->date_start_time == 0) |
| 1146 | + continue; //skip empty / zero values |
| 1147 | + if ($row->date_start_time < $start_day) |
| 1148 | + $start_day = $row->date_start_time; |
| 1149 | + if ($row->date_start_time > $end_day) |
| 1150 | + $end_day = $row->date_start_time; |
| 1151 | + list ($month, $day, $year) = explode('/', date('m/d/Y', $row->date_start_time)); |
1109 | 1152 | $month = trim($month, '0'); |
1110 | 1153 | $day = trim($day, '0'); |
1111 | | - if(!isset($sDays[$year]))$sDays[$year]=array(); |
1112 | | - if(!isset($sDays[$year][$month]))$sDays[$year][$month]=array(); |
1113 | | - if(!isset($sDays[$year][$month][$day])){ |
1114 | | - $sDays[$year][$month][$day]=1; |
1115 | | - }else{ |
1116 | | - $sDays[$year][$month][$day]++; |
1117 | | - } |
| 1154 | + if (!isset ($sDays[$year])) |
| 1155 | + $sDays[$year] = array (); |
| 1156 | + if (!isset ($sDays[$year][$month])) |
| 1157 | + $sDays[$year][$month] = array (); |
| 1158 | + if (!isset ($sDays[$year][$month][$day])) { |
| 1159 | + $sDays[$year][$month][$day] = 1; |
| 1160 | + } else { |
| 1161 | + $sDays[$year][$month][$day]++; |
| 1162 | + } |
1118 | 1163 | } |
1119 | | - return php2jsObj(array('sd'=>date('m/d/Y', $start_day), |
1120 | | - 'ed'=>date('m/d/Y',$end_day), |
1121 | | - 'sdays'=>$sDays), $obj_name); |
| 1164 | + return php2jsObj(array ( |
| 1165 | + 'sd' => date('m/d/Y', |
| 1166 | + $start_day |
| 1167 | + ), 'ed' => date('m/d/Y', $end_day), 'sdays' => $sDays), $obj_name); |
1122 | 1168 | } |
1123 | 1169 | } |
1124 | 1170 | ?> |
Index: branches/MetavidWiki-exp/MetavidWiki/languages/MV_Messages.php |
— | — | @@ -201,6 +201,10 @@ |
202 | 202 | 'mv_people_results' => 'People Results', |
203 | 203 | 'mv_bill_results' => 'Bill Results', |
204 | 204 | 'mv_intrest_group_results' => 'Interst Groups', |
| 205 | + |
| 206 | + 'mv_most_relevent' => 'Most Relevent', |
| 207 | + 'mv_most_recent' => 'Most Recent', |
| 208 | + 'mv_most_viewed' => 'Most Viewed', |
205 | 209 | |
206 | 210 | 'mv_match' => 'match', |
207 | 211 | 'mv_spoken_by' => 'spoken by', |