@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - public function display ($view, $args=array(), $format='html') { |
|
45 | + public function display($view, $args = array(), $format = 'html') { |
|
46 | 46 | // $view is what we're viewing by: |
47 | 47 | // 'ep' is all the comments attached to an epobject. |
48 | 48 | // 'user' is all the comments written by a user. |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | } else { |
68 | 68 | // Don't have a valid $view; |
69 | - $PAGE->error_message ("You haven't specified a view type."); |
|
69 | + $PAGE->error_message("You haven't specified a view type."); |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return true; |
86 | 86 | } |
87 | 87 | |
88 | - public function render($data, $format='html', $template='comments') { |
|
88 | + public function render($data, $format = 'html', $template = 'comments') { |
|
89 | 89 | include (INCLUDESPATH."easyparliament/templates/$format/$template.php"); |
90 | 90 | } |
91 | 91 | |
@@ -93,21 +93,21 @@ discard block |
||
93 | 93 | // Get all the data attached to an epobject. |
94 | 94 | global $PAGE; |
95 | 95 | |
96 | - twfy_debug (get_class($this), "getting data by epobject"); |
|
96 | + twfy_debug(get_class($this), "getting data by epobject"); |
|
97 | 97 | |
98 | 98 | // What we return. |
99 | 99 | $data = array(); |
100 | 100 | if (!is_numeric($args['epobject_id'])) { |
101 | - $PAGE->error_message ("Sorry, we don't have a valid epobject id"); |
|
101 | + $PAGE->error_message("Sorry, we don't have a valid epobject id"); |
|
102 | 102 | return $data; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // For getting the data. |
106 | - $input = array ( |
|
107 | - 'amount' => array ( |
|
106 | + $input = array( |
|
107 | + 'amount' => array( |
|
108 | 108 | 'user' => true |
109 | 109 | ), |
110 | - 'where' => array ( |
|
110 | + 'where' => array( |
|
111 | 111 | 'comments.epobject_id=' => $args['epobject_id'], |
112 | 112 | #'visible=' => '1' |
113 | 113 | ), |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | // comments by things in $args? |
136 | 136 | global $PAGE; |
137 | 137 | |
138 | - twfy_debug (get_class($this), "getting data by user"); |
|
138 | + twfy_debug(get_class($this), "getting data by user"); |
|
139 | 139 | |
140 | 140 | // What we return. |
141 | 141 | $data = array(); |
142 | 142 | |
143 | 143 | if (!is_numeric($args['user_id'])) { |
144 | - $PAGE->error_message ("Sorry, we don't have a valid user id"); |
|
144 | + $PAGE->error_message("Sorry, we don't have a valid user id"); |
|
145 | 145 | return $data; |
146 | 146 | } |
147 | 147 | |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | $num = 10; |
152 | 152 | } |
153 | 153 | |
154 | - if (isset($args['page']) && is_numeric($args['page']) && $args['page']>1) { |
|
154 | + if (isset($args['page']) && is_numeric($args['page']) && $args['page'] > 1) { |
|
155 | 155 | $page = $args['page']; |
156 | 156 | } else { |
157 | 157 | $page = 1; |
158 | 158 | } |
159 | 159 | |
160 | - $limit = $num*($page-1) . ',' . $num; |
|
160 | + $limit = $num * ($page - 1).','.$num; |
|
161 | 161 | |
162 | 162 | // We're getting the most recent comments posted to epobjects. |
163 | 163 | // We're grouping them by epobject so we can just link to each hansard thing once. |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | |
194 | 194 | if ($q->rows() > 0) { |
195 | 195 | |
196 | - for ($n=0; $n<$q->rows(); $n++) { |
|
196 | + for ($n = 0; $n < $q->rows(); $n++) { |
|
197 | 197 | |
198 | 198 | // All the basic stuff... |
199 | - $comments[$n] = array ( |
|
199 | + $comments[$n] = array( |
|
200 | 200 | 'comment_id' => $q->field($n, 'comment_id'), |
201 | 201 | 'posted' => $q->field($n, 'posted'), |
202 | 202 | 'total_comments' => $q->field($n, 'total_comments'), |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | ); |
209 | 209 | |
210 | 210 | // Add the URL... |
211 | - $urldata = array ( |
|
211 | + $urldata = array( |
|
212 | 212 | 'major' => $q->field($n, 'major'), |
213 | 213 | 'gid' => $q->field($n, 'gid'), |
214 | 214 | 'comment_id' => $q->field($n, 'comment_id'), |
@@ -234,14 +234,14 @@ discard block |
||
234 | 234 | |
235 | 235 | $commentbodies = array(); |
236 | 236 | |
237 | - for ($n=0; $n<$r->rows(); $n++) { |
|
238 | - $commentbodies[ $r->field($n, 'comment_id') ] = $r->field($n, 'body'); |
|
237 | + for ($n = 0; $n < $r->rows(); $n++) { |
|
238 | + $commentbodies[$r->field($n, 'comment_id')] = $r->field($n, 'body'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | // This does rely on both this and the previous query returning |
242 | 242 | // stuff in the same order... |
243 | 243 | foreach ($comments as $n => $commentdata) { |
244 | - $comments[$n]['body'] = $commentbodies[ $comments[$n]['comment_id'] ]; |
|
244 | + $comments[$n]['body'] = $commentbodies[$comments[$n]['comment_id']]; |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $data['comments'] = $comments; |
250 | 250 | $data['results_per_page'] = $num; |
251 | 251 | $data['page'] = $page; |
252 | - $q = $this->db->query('SELECT COUNT(DISTINCT(epobject_id)) AS count FROM comments WHERE visible=1 AND user_id=' . $args['user_id']); |
|
252 | + $q = $this->db->query('SELECT COUNT(DISTINCT(epobject_id)) AS count FROM comments WHERE visible=1 AND user_id='.$args['user_id']); |
|
253 | 253 | $data['total_results'] = $q->field(0, 'count'); |
254 | 254 | return $data; |
255 | 255 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // $args should contain 'num', indicating how many to get. |
262 | 262 | // and perhaps pid too, for a particular person |
263 | 263 | |
264 | - twfy_debug (get_class($this), "getting data by recent"); |
|
264 | + twfy_debug(get_class($this), "getting data by recent"); |
|
265 | 265 | |
266 | 266 | // What we return. |
267 | 267 | $data = array(); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $page = 1; |
279 | 279 | } |
280 | 280 | |
281 | - $limit = $num*($page-1) . ',' . $num; |
|
281 | + $limit = $num * ($page - 1).','.$num; |
|
282 | 282 | |
283 | 283 | $where = array( |
284 | 284 | 'visible=' => '1' |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | if (isset($args['pid']) && is_numeric($args['pid'])) { |
287 | 287 | $where['person_id='] = $args['pid']; |
288 | 288 | } |
289 | - $input = array ( |
|
290 | - 'amount' => array ( |
|
289 | + $input = array( |
|
290 | + 'amount' => array( |
|
291 | 291 | 'user' => true |
292 | 292 | ), |
293 | 293 | 'where' => $where, |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $data['pid'] = $args['pid']; |
306 | 306 | $q = 'SELECT title, given_name, family_name, lordofname, house FROM member m, person_names p WHERE m.person_id=p.person_id AND p.type="name" AND left_house="9999-12-31" AND m.person_id = :pid'; |
307 | 307 | $q = $this->db->query($q, array(':pid' => $args['pid'])); |
308 | - $data['full_name'] = member_full_name($q->field(0, 'house'), $q->field(0, 'title'), $q->field(0, 'given_name'), $q->field(0, 'family_name'), $q->field(0,'lordofname')); |
|
308 | + $data['full_name'] = member_full_name($q->field(0, 'house'), $q->field(0, 'title'), $q->field(0, 'given_name'), $q->field(0, 'family_name'), $q->field(0, 'lordofname')); |
|
309 | 309 | $q = 'SELECT COUNT(*) AS count FROM comments,hansard WHERE visible=1 AND comments.epobject_id = hansard.epobject_id and hansard.person_id = :pid'; |
310 | 310 | $params[':pid'] = $args['pid']; |
311 | 311 | } else { |
@@ -319,15 +319,15 @@ discard block |
||
319 | 319 | public function _get_data_by_dates($args) { |
320 | 320 | // $args should contain start_date and end_date |
321 | 321 | |
322 | - twfy_debug (get_class($this), "getting data by recent"); |
|
322 | + twfy_debug(get_class($this), "getting data by recent"); |
|
323 | 323 | $data = array(); |
324 | 324 | $where = array( |
325 | 325 | 'visible=' => '1', |
326 | 326 | 'date(posted)>=' => $args['start_date'], |
327 | 327 | 'date(posted)<=' => $args['end_date'] |
328 | 328 | ); |
329 | - $input = array ( |
|
330 | - 'amount' => array ( |
|
329 | + $input = array( |
|
330 | + 'amount' => array( |
|
331 | 331 | 'user' => true |
332 | 332 | ), |
333 | 333 | 'where' => $where, |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | public function _get_data_by_search($args) { |
342 | 342 | // $args should contain 'num', indicating how many to get. |
343 | 343 | |
344 | - twfy_debug (get_class($this), "getting data by search"); |
|
344 | + twfy_debug(get_class($this), "getting data by search"); |
|
345 | 345 | |
346 | 346 | // What we return. |
347 | 347 | $data = array(); |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | $page = 1; |
359 | 359 | } |
360 | 360 | |
361 | - $limit = $num*($page-1) . ',' . $num; |
|
361 | + $limit = $num * ($page - 1).','.$num; |
|
362 | 362 | |
363 | - $input = array ( |
|
364 | - 'amount' => array ( |
|
363 | + $input = array( |
|
364 | + 'amount' => array( |
|
365 | 365 | 'user'=> true |
366 | 366 | ), |
367 | - 'where' => array ( |
|
367 | + 'where' => array( |
|
368 | 368 | 'comments.body LIKE' => "%$args[s]%" |
369 | 369 | ), |
370 | 370 | 'order' => 'posted DESC', |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | // It returns the URL for the comment. |
392 | 392 | |
393 | 393 | $major = $urldata['major']; |
394 | - $gid = $urldata['gid']; |
|
394 | + $gid = $urldata['gid']; |
|
395 | 395 | $comment_id = $urldata['comment_id']; |
396 | 396 | $user_id = isset($urldata['user_id']) ? $urldata['user_id'] : false; |
397 | 397 | |
@@ -405,11 +405,11 @@ discard block |
||
405 | 405 | $URL = new URL($page); |
406 | 406 | |
407 | 407 | $gid = fix_gid_from_db($gid); // In includes/utility.php |
408 | - $URL->insert(array('id' => $gid )); |
|
408 | + $URL->insert(array('id' => $gid)); |
|
409 | 409 | if ($user_id) { |
410 | 410 | $URL->insert(array('u' => $user_id)); |
411 | 411 | } |
412 | - $url = $URL->generate() . '#c' . $comment_id; |
|
412 | + $url = $URL->generate().'#c'.$comment_id; |
|
413 | 413 | |
414 | 414 | return $url; |
415 | 415 | } |
@@ -483,9 +483,9 @@ discard block |
||
483 | 483 | $limit = isset($input['limit']) ? $input['limit'] : ''; |
484 | 484 | |
485 | 485 | // The fields to fetch from db. 'table' => array ('field1', 'field2'). |
486 | - $fieldsarr = array ( |
|
487 | - 'comments' => array ('comment_id', 'user_id', 'epobject_id', 'body', 'posted', 'modflagged', 'visible'), |
|
488 | - 'hansard' => array ('major', 'gid') |
|
486 | + $fieldsarr = array( |
|
487 | + 'comments' => array('comment_id', 'user_id', 'epobject_id', 'body', 'posted', 'modflagged', 'visible'), |
|
488 | + 'hansard' => array('major', 'gid') |
|
489 | 489 | ); |
490 | 490 | |
491 | 491 | // Yes, we need the gid of a comment's associated hansard object |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | |
497 | 497 | // Add on the stuff for getting a user's details. |
498 | 498 | if (isset($amount['user']) && $amount['user'] == true) { |
499 | - $fieldsarr['users'] = array ('firstname', 'lastname', 'user_id'); |
|
499 | + $fieldsarr['users'] = array('firstname', 'lastname', 'user_id'); |
|
500 | 500 | // Like doing "FROM comments, users" but it's easier to add |
501 | 501 | // an "INNER JOIN..." automatically to the query. |
502 | 502 | $join .= ' INNER JOIN users ON comments.user_id = users.user_id '; |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | $fieldsarr['epobject'] = array('body'); |
508 | 508 | } |
509 | 509 | |
510 | - $fieldsarr2 = array (); |
|
510 | + $fieldsarr2 = array(); |
|
511 | 511 | // Construct the $fields clause. |
512 | 512 | foreach ($fieldsarr as $table => $tablesfields) { |
513 | 513 | foreach ($tablesfields as $n => $field) { |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | $fields = implode(', ', $fieldsarr2); |
525 | 525 | |
526 | 526 | |
527 | - $wherearr2 = array (); |
|
527 | + $wherearr2 = array(); |
|
528 | 528 | $params = array(); |
529 | 529 | $i = 0; |
530 | 530 | // Construct the $where clause. |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $params[":where$i"] = $val; |
534 | 534 | $i++; |
535 | 535 | } |
536 | - $where = implode (" AND ", $wherearr2); |
|
536 | + $where = implode(" AND ", $wherearr2); |
|
537 | 537 | |
538 | 538 | if ($order != '') { |
539 | 539 | $order = "ORDER BY $order"; |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | } |
545 | 545 | |
546 | 546 | // Finally, do the query! |
547 | - $q = $this->db->query ("SELECT $fields |
|
547 | + $q = $this->db->query("SELECT $fields |
|
548 | 548 | FROM comments |
549 | 549 | $join |
550 | 550 | WHERE $where |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | ", $params); |
554 | 554 | |
555 | 555 | // Format the data into an array for returning. |
556 | - $data = array (); |
|
556 | + $data = array(); |
|
557 | 557 | |
558 | 558 | if ($q->rows() > 0) { |
559 | 559 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | // We'll generate permalinks for each comment. |
564 | 564 | // Assuming every comment is from the same major... |
565 | 565 | |
566 | - for ($n=0; $n<$q->rows(); $n++) { |
|
566 | + for ($n = 0; $n < $q->rows(); $n++) { |
|
567 | 567 | |
568 | 568 | // Put each row returned into its own array in $data. |
569 | 569 | foreach ($fieldsarr as $table => $tablesfields) { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | if (strstr(XAPIANDB, ":")) { |
47 | 47 | //ini_set('display_errors', 'On'); |
48 | 48 | list ($xapian_host, $xapian_port) = explode(":", XAPIANDB); |
49 | - twfy_debug("SEARCH", "Using Xapian remote backend: " . $xapian_host . " port " . $xapian_port); |
|
49 | + twfy_debug("SEARCH", "Using Xapian remote backend: ".$xapian_host." port ".$xapian_port); |
|
50 | 50 | $xapiandb_remote = remote_open($xapian_host, intval($xapian_port)); |
51 | 51 | $xapiandb = new XapianDatabase($xapiandb_remote); |
52 | 52 | } else { |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | $this->prefixed = array(); |
93 | 93 | |
94 | 94 | // Split words up into individual words, and quoted phrases |
95 | - preg_match_all('/(' . |
|
96 | - '"|' . # match either a quote, or... |
|
97 | - '(?:(?<![' .$this->wordchars. '])-)?' . # optionally a - (exclude) |
|
95 | + preg_match_all('/('. |
|
96 | + '"|'.# match either a quote, or... |
|
97 | + '(?:(?<!['.$this->wordchars.'])-)?'.# optionally a - (exclude) |
|
98 | 98 | # if at start of word (i.e. not preceded by a word character, in |
99 | 99 | # which case it is probably a hyphenated-word) |
100 | - '['.$this->wordchars.']+' . # followed by a string of word-characters |
|
100 | + '['.$this->wordchars.']+'.# followed by a string of word-characters |
|
101 | 101 | ')/', $this->query, $all_words); |
102 | 102 | if ($all_words) { |
103 | 103 | $all_words = $all_words[0]; |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | if (strpos($word, ':') !== false) { |
123 | 123 | $items = explode(":", strtolower($word)); |
124 | 124 | $type = $items[0]; |
125 | - if (substr($type, 0, 1)=='-') $type = substr($type, 1); |
|
126 | - $value = strtolower(join(":", array_slice($items,1))); |
|
125 | + if (substr($type, 0, 1) == '-') $type = substr($type, 1); |
|
126 | + $value = strtolower(join(":", array_slice($items, 1))); |
|
127 | 127 | if ($type == 'section') { |
128 | 128 | $newv = $value; |
129 | 129 | if ($value == 'debates' || $value == 'debate') $newv = 1; |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | elseif ($value == 'pbc' || $value == 'standing') $newv = 6; |
136 | 136 | elseif ($value == 'sp') $newv = 7; |
137 | 137 | elseif ($value == 'spwrans' || $value == 'spwran') $newv = 8; |
138 | - elseif ($value == 'uk') $newv = array(1,2,3,4,6,101); |
|
139 | - elseif ($value == 'scotland') $newv = array(7,8); |
|
138 | + elseif ($value == 'uk') $newv = array(1, 2, 3, 4, 6, 101); |
|
139 | + elseif ($value == 'scotland') $newv = array(7, 8); |
|
140 | 140 | elseif ($value == 'future') $newv = 'F'; |
141 | 141 | if (is_array($newv)) { |
142 | - $newv = 'major:' . join(' major:', $newv); |
|
142 | + $newv = 'major:'.join(' major:', $newv); |
|
143 | 143 | } else { |
144 | 144 | $newv = "major:$newv"; |
145 | 145 | } |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | # Merged people |
180 | 180 | $db = new ParlDB; |
181 | 181 | $merged = $db->query('SELECT * FROM gidredirect WHERE gid_from LIKE :gid_from', array(':gid_from' => "uk.org.publicwhip/person/%")); |
182 | - for ($n=0; $n<$merged->rows(); $n++) { |
|
182 | + for ($n = 0; $n < $merged->rows(); $n++) { |
|
183 | 183 | $from_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_from')); |
184 | 184 | $to_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_to')); |
185 | 185 | $this->query = preg_replace("#speaker:($from_id|$to_id)#i", "(speaker:$from_id OR speaker:$to_id)", $this->query); |
186 | 186 | } |
187 | 187 | |
188 | - twfy_debug("SEARCH", "prefixed: " . var_export($this->prefixed, true)); |
|
188 | + twfy_debug("SEARCH", "prefixed: ".var_export($this->prefixed, true)); |
|
189 | 189 | |
190 | - twfy_debug("SEARCH", "query -- ". $this->query); |
|
190 | + twfy_debug("SEARCH", "query -- ".$this->query); |
|
191 | 191 | $flags = XapianQueryParser::FLAG_BOOLEAN | XapianQueryParser::FLAG_LOVEHATE | |
192 | 192 | XapianQueryParser::FLAG_WILDCARD | XapianQueryParser::FLAG_SPELLING_CORRECTION; |
193 | 193 | $flags = $flags | XapianQueryParser::FLAG_PHRASE; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | # Now parse the parsed query back into a query string, yummy |
206 | 206 | |
207 | 207 | $qd = $query->get_description(); |
208 | - twfy_debug("SEARCH", "queryparser original description -- " . $qd); |
|
208 | + twfy_debug("SEARCH", "queryparser original description -- ".$qd); |
|
209 | 209 | $qd = substr($qd, 14, -1); # Strip Xapian::Query() |
210 | 210 | $qd = preg_replace('#:\(.*?\)#', '', $qd); # Don't need pos or weight |
211 | 211 | # Date range |
@@ -256,11 +256,11 @@ discard block |
||
256 | 256 | $iter->next(); |
257 | 257 | } |
258 | 258 | $used[] = $tt; |
259 | - $qd = preg_replace('#' . preg_quote($mm, '#') . '#', $tt, $qd, 1); |
|
259 | + $qd = preg_replace('#'.preg_quote($mm, '#').'#', $tt, $qd, 1); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | # Speakers |
263 | - for ($n=0; $n<$merged->rows(); $n++) { |
|
263 | + for ($n = 0; $n < $merged->rows(); $n++) { |
|
264 | 264 | $from_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_from')); |
265 | 265 | $to_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_to')); |
266 | 266 | $qd = str_replace("(S$from_id OR S$to_id)", "S$to_id", $qd); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $qd = preg_replace('#AND_NOT ([a-z0-9"]+)#', '-$1', $qd); |
279 | 279 | preg_match_all('#AND_NOT \((.*?)\)#', $qd, $m); |
280 | 280 | foreach ($m[1] as $mm) { |
281 | - $mmn = '-' . join(' -', explode(' OR ', $mm)); |
|
281 | + $mmn = '-'.join(' -', explode(' OR ', $mm)); |
|
282 | 282 | $qd = str_replace("AND_NOT ($mm)", $mmn, $qd); |
283 | 283 | } |
284 | 284 | |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | $this->query_desc = trim($qd); |
298 | 298 | |
299 | 299 | #print 'DEBUG: ' . $query->get_description(); |
300 | - twfy_debug("SEARCH", "words: " . var_export($this->words, true)); |
|
301 | - twfy_debug("SEARCH", "phrases: " . var_export($this->phrases, true)); |
|
302 | - twfy_debug("SEARCH", "queryparser description -- " . $this->query_desc); |
|
300 | + twfy_debug("SEARCH", "words: ".var_export($this->words, true)); |
|
301 | + twfy_debug("SEARCH", "phrases: ".var_export($this->phrases, true)); |
|
302 | + twfy_debug("SEARCH", "queryparser description -- ".$this->query_desc); |
|
303 | 303 | |
304 | 304 | $this->valid = true; |
305 | 305 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | } |
340 | 340 | |
341 | 341 | // Perform partial query to get a count of number of matches |
342 | - public function run_count($first_result, $results_per_page, $sort_order='relevance') { |
|
342 | + public function run_count($first_result, $results_per_page, $sort_order = 'relevance') { |
|
343 | 343 | if (!defined('XAPIANDB') || !XAPIANDB) |
344 | 344 | return null; |
345 | 345 | |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | #} |
413 | 413 | |
414 | 414 | $duration = getmicrotime() - $start; |
415 | - twfy_debug ("SEARCH", "Search count took $duration seconds."); |
|
415 | + twfy_debug("SEARCH", "Search count took $duration seconds."); |
|
416 | 416 | |
417 | 417 | return $count; |
418 | 418 | } |
419 | 419 | |
420 | 420 | // Perform the full search... |
421 | - public function run_search($first_result, $results_per_page, $sort_order='relevance') { |
|
421 | + public function run_search($first_result, $results_per_page, $sort_order = 'relevance') { |
|
422 | 422 | $start = getmicrotime(); |
423 | 423 | |
424 | 424 | #$matches = $this->enquire->get_mset($first_result, $results_per_page); |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | $iter->next(); |
446 | 446 | } |
447 | 447 | $duration = getmicrotime() - $start; |
448 | - twfy_debug ("SEARCH", "Run search took $duration seconds."); |
|
448 | + twfy_debug("SEARCH", "Run search took $duration seconds."); |
|
449 | 449 | } |
450 | 450 | // ... use these to get the results |
451 | 451 | public function get_gids() { |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | if ($hl) { |
511 | 511 | $hlextract .= "<span class=\"hi\">$extractword</span>$endswithamp"; |
512 | 512 | } else { |
513 | - $hlextract .= $extractword . $endswithamp; |
|
513 | + $hlextract .= $extractword.$endswithamp; |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | $body = preg_replace("#</span>\s+<span class=\"hi\">#", " ", $hlextract); |
@@ -547,17 +547,17 @@ discard block |
||
547 | 547 | |
548 | 548 | // Find the position of the first of the search words/phrases in $body. |
549 | 549 | public function position_of_first_word($body) { |
550 | - $lcbody = ' ' . html_entity_decode(strtolower($body)) . ' '; // spaces to make regexp mapping easier |
|
550 | + $lcbody = ' '.html_entity_decode(strtolower($body)).' '; // spaces to make regexp mapping easier |
|
551 | 551 | $pos = -1; |
552 | 552 | |
553 | 553 | // look for phrases |
554 | 554 | foreach ($this->phrases as $phrase) { |
555 | 555 | $phrasematch = join($phrase, '[^'.$this->wordchars.']+'); |
556 | - if (preg_match('/([^'.$this->wordchars.']' . $phrasematch . '[^A-Za-z0-9])/', $lcbody, $matches)) |
|
556 | + if (preg_match('/([^'.$this->wordchars.']'.$phrasematch.'[^A-Za-z0-9])/', $lcbody, $matches)) |
|
557 | 557 | { |
558 | - $wordpos = strpos( $lcbody, $matches[0] ); |
|
558 | + $wordpos = strpos($lcbody, $matches[0]); |
|
559 | 559 | if ($wordpos) { |
560 | - if ( ($wordpos < $pos) || ($pos==-1) ) { |
|
560 | + if (($wordpos < $pos) || ($pos == -1)) { |
|
561 | 561 | $pos = $wordpos; |
562 | 562 | } |
563 | 563 | } |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | foreach ($stemmed_words as $word) { |
576 | 576 | if ($word == '') continue; |
577 | 577 | $matchword = $this->stem($extractword); |
578 | - if ($matchword == $word && ($wordpos < $pos || $pos==-1)) { |
|
578 | + if ($matchword == $word && ($wordpos < $pos || $pos == -1)) { |
|
579 | 579 | $pos = $wordpos; |
580 | 580 | } |
581 | 581 | } |
@@ -585,10 +585,10 @@ discard block |
||
585 | 585 | |
586 | 586 | foreach ($this->words as $word) { |
587 | 587 | if (ctype_digit($word)) $word = '(?:'.$word.'|'.number_format($word).')'; |
588 | - if (preg_match('/([^'.$this->wordchars.']' . $word . '[^'.$this->wordchars. '])/', $lcbody, $matches)) { |
|
589 | - $wordpos = strpos( $lcbody, $matches[0] ); |
|
588 | + if (preg_match('/([^'.$this->wordchars.']'.$word.'[^'.$this->wordchars.'])/', $lcbody, $matches)) { |
|
589 | + $wordpos = strpos($lcbody, $matches[0]); |
|
590 | 590 | if ($wordpos) { |
591 | - if ( ($wordpos < $pos) || ($pos==-1) ) { |
|
591 | + if (($wordpos < $pos) || ($pos == -1)) { |
|
592 | 592 | $pos = $wordpos; |
593 | 593 | } |
594 | 594 | } |
@@ -599,10 +599,10 @@ discard block |
||
599 | 599 | |
600 | 600 | foreach ($this->words as $word) { |
601 | 601 | if (ctype_digit($word)) $word = '(?:'.$word.'|'.number_format($word).')'; |
602 | - if (preg_match('/(' . $word . ')/', $lcbody, $matches)) { |
|
603 | - $wordpos = strpos( $lcbody, $matches[0] ); |
|
602 | + if (preg_match('/('.$word.')/', $lcbody, $matches)) { |
|
603 | + $wordpos = strpos($lcbody, $matches[0]); |
|
604 | 604 | if ($wordpos) { |
605 | - if ( ($wordpos < $pos) || ($pos==-1) ) { |
|
605 | + if (($wordpos < $pos) || ($pos == -1)) { |
|
606 | 606 | $pos = $wordpos; |
607 | 607 | } |
608 | 608 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | */ |
27 | 27 | |
28 | -if (defined('XAPIANDB') AND XAPIANDB != '') { |
|
28 | +if (defined('XAPIANDB') and XAPIANDB != '') { |
|
29 | 29 | if (file_exists('/usr/share/php/xapian.php')) { |
30 | 30 | include_once '/usr/share/php/xapian.php'; |
31 | 31 | } else { |
@@ -263,15 +263,15 @@ discard block |
||
263 | 263 | for ($n=0; $n<$merged->rows(); $n++) { |
264 | 264 | $from_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_from')); |
265 | 265 | $to_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_to')); |
266 | - $qd = str_replace("(S$from_id OR S$to_id)", "S$to_id", $qd); |
|
267 | - $qd = str_replace("S$from_id OR S$to_id", "S$to_id", $qd); |
|
266 | + $qd = str_replace("(S$from_id OR S$to_id)", "s$to_id", $qd); |
|
267 | + $qd = str_replace("s$from_id OR S$to_id", "s$to_id", $qd); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | preg_match_all('#S(\d+)#', $qd, $m); |
271 | 271 | foreach ($m[1] as $mm) { |
272 | 272 | $member = new MEMBER(array('person_id' => $mm)); |
273 | 273 | $name = $member->full_name(); |
274 | - $qd = str_replace("S$mm", "speaker:$name", $qd); |
|
274 | + $qd = str_replace("s$mm", "speaker:$name", $qd); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | # Simplify display of excluded words |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * Test that the Royal edge-case house is correctly defined. |
11 | 11 | */ |
12 | - public function testRoyalHouseDefined() |
|
12 | + public function testRoyalHouseDefined() |
|
13 | 13 | { |
14 | 14 | $this->assertEquals(0, HOUSE_TYPE_ROYAL); |
15 | 15 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Test that the House of Commons is correctly defined. |
19 | 19 | */ |
20 | - public function testCommonsHouseDefined() |
|
20 | + public function testCommonsHouseDefined() |
|
21 | 21 | { |
22 | 22 | $this->assertEquals(1, HOUSE_TYPE_COMMONS); |
23 | 23 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * Test that the House of Lords is correctly defined. |
27 | 27 | */ |
28 | - public function testLordsHouseDefined() |
|
28 | + public function testLordsHouseDefined() |
|
29 | 29 | { |
30 | 30 | $this->assertEquals(2, HOUSE_TYPE_LORDS); |
31 | 31 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * Test that the Northern Ireland Assembly is correctly defined. |
35 | 35 | */ |
36 | - public function testNIHouseDefined() |
|
36 | + public function testNIHouseDefined() |
|
37 | 37 | { |
38 | 38 | $this->assertEquals(3, HOUSE_TYPE_NI); |
39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * Test that the Scottish Parliament is correctly defined. |
43 | 43 | */ |
44 | - public function testScotlandHouseDefined() |
|
44 | + public function testScotlandHouseDefined() |
|
45 | 45 | { |
46 | 46 | $this->assertEquals(4, HOUSE_TYPE_SCOTLAND); |
47 | 47 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Test that the Assembly for Wales is correctly defined. |
51 | 51 | */ |
52 | - public function testWalesHouseDefined() |
|
52 | + public function testWalesHouseDefined() |
|
53 | 53 | { |
54 | 54 | $this->assertEquals(5, HOUSE_TYPE_WALES); |
55 | 55 | } |