@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | $rsspath = BASEDIR . '/rss/mp/'; |
10 | 10 | |
11 | 11 | // Make things group writable. |
12 | -umask (002); |
|
12 | +umask(002); |
|
13 | 13 | |
14 | 14 | $HANSARDLIST = new HANSARDLIST(); |
15 | 15 | $db = $HANSARDLIST->db; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | foreach ($q as $person) { |
23 | 23 | $person_id = $person['person_id']; |
24 | 24 | |
25 | - $args = array ( 'person_id' => $person_id ); |
|
25 | + $args = array('person_id' => $person_id); |
|
26 | 26 | $speeches = $HANSARDLIST->display('person', $args, 'none'); |
27 | 27 | |
28 | 28 | // Some data about this person that we'll need for the feed. |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | fwrite($fh, $rsstext); |
112 | - fclose ($fh); |
|
112 | + fclose($fh); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | #print "Took " . (time()-$starttime) . " seconds\n"; |
@@ -24,47 +24,47 @@ discard block |
||
24 | 24 | foreach ($q as $person) { |
25 | 25 | $person_id = $person['person_id']; |
26 | 26 | |
27 | - $args = array ( 'person_id' => $person_id ); |
|
28 | - $speeches = $HANSARDLIST->display('person', $args, 'none'); |
|
27 | + $args = array ( 'person_id' => $person_id ); |
|
28 | + $speeches = $HANSARDLIST->display('person', $args, 'none'); |
|
29 | 29 | |
30 | - // Some data about this person that we'll need for the feed. |
|
31 | - $MEMBER = new MEMBER(array('person_id' => $person_id)); |
|
32 | - $MPURL = new \MySociety\TheyWorkForYou\Url('mp'); |
|
33 | - $MPURL->insert(array('pid'=>$person_id)); |
|
34 | - $mpurl = $MPURL->generate(); |
|
30 | + // Some data about this person that we'll need for the feed. |
|
31 | + $MEMBER = new MEMBER(array('person_id' => $person_id)); |
|
32 | + $MPURL = new \MySociety\TheyWorkForYou\Url('mp'); |
|
33 | + $MPURL->insert(array('pid'=>$person_id)); |
|
34 | + $mpurl = $MPURL->generate(); |
|
35 | 35 | |
36 | - $date = gmdate('Y-m-d'); |
|
37 | - $time = gmdate('H:i:s'); |
|
38 | - $datenow = $date . 'T' . $time . '+00:00'; |
|
36 | + $date = gmdate('Y-m-d'); |
|
37 | + $time = gmdate('H:i:s'); |
|
38 | + $datenow = $date . 'T' . $time . '+00:00'; |
|
39 | 39 | |
40 | - // Prepare the meat of the RSS file. |
|
41 | - $items = ''; |
|
42 | - $entries = ''; |
|
43 | - if (isset ($speeches['rows']) && count($speeches['rows']) > 0) { |
|
40 | + // Prepare the meat of the RSS file. |
|
41 | + $items = ''; |
|
42 | + $entries = ''; |
|
43 | + if (isset ($speeches['rows']) && count($speeches['rows']) > 0) { |
|
44 | 44 | |
45 | - foreach ($speeches['rows'] as $n => $row) { |
|
45 | + foreach ($speeches['rows'] as $n => $row) { |
|
46 | 46 | |
47 | - // While we're linking to individual speeches, |
|
48 | - // the text is the body of the parent, ie (sub)section. |
|
49 | - $title = _htmlentities(str_replace('—', '-', $row['parent']['body'])); |
|
47 | + // While we're linking to individual speeches, |
|
48 | + // the text is the body of the parent, ie (sub)section. |
|
49 | + $title = _htmlentities(str_replace('—', '-', $row['parent']['body'])); |
|
50 | 50 | |
51 | - $link = isset($row['listurl']) ? $row['listurl'] : ''; |
|
52 | - $link = 'https://' . DOMAIN . $link; |
|
51 | + $link = isset($row['listurl']) ? $row['listurl'] : ''; |
|
52 | + $link = 'https://' . DOMAIN . $link; |
|
53 | 53 | |
54 | - $description = _htmlentities(trim_characters($row['body'], 0, 200)); |
|
55 | - $contentencoded = $row['body']; |
|
54 | + $description = _htmlentities(trim_characters($row['body'], 0, 200)); |
|
55 | + $contentencoded = $row['body']; |
|
56 | 56 | |
57 | - $hdate = format_date($row['hdate'], 'Y-m-d'); |
|
58 | - if ($row['htime'] != null) { |
|
59 | - $htime = format_time($row['htime'], 'H:i:s'); |
|
60 | - } else { |
|
61 | - $htime = '00:00:00'; |
|
62 | - } |
|
57 | + $hdate = format_date($row['hdate'], 'Y-m-d'); |
|
58 | + if ($row['htime'] != null) { |
|
59 | + $htime = format_time($row['htime'], 'H:i:s'); |
|
60 | + } else { |
|
61 | + $htime = '00:00:00'; |
|
62 | + } |
|
63 | 63 | |
64 | - $date = $hdate . 'T' . $htime . '+00:00'; |
|
64 | + $date = $hdate . 'T' . $htime . '+00:00'; |
|
65 | 65 | |
66 | - $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n"; |
|
67 | - $entries .= "<item rdf:about=\"$link\"> |
|
66 | + $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n"; |
|
67 | + $entries .= "<item rdf:about=\"$link\"> |
|
68 | 68 | <title>$title</title> |
69 | 69 | <link>$link</link> |
70 | 70 | <description>$description</description> |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | </item> |
74 | 74 | "; |
75 | 75 | |
76 | - } |
|
77 | - } |
|
76 | + } |
|
77 | + } |
|
78 | 78 | |
79 | - // Prepare the whole text of the RSS file. |
|
80 | - $rsstext = '<?xml version="1.0" encoding="utf-8"?> |
|
79 | + // Prepare the whole text of the RSS file. |
|
80 | + $rsstext = '<?xml version="1.0" encoding="utf-8"?> |
|
81 | 81 | <rdf:RDF |
82 | 82 | xmlns:dc="http://purl.org/dc/elements/1.1/" |
83 | 83 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | |
104 | 104 | </rdf:RDF>'; |
105 | 105 | |
106 | - // Write the text to the file... |
|
107 | - $filename = $rsspath . $person_id . '.rdf'; |
|
108 | - $fh = @fopen($filename, "w"); |
|
109 | - if (!$fh) { # Problem writing, just carry on |
|
110 | - echo "Could not write to file ($filename)\n"; |
|
111 | - continue; |
|
112 | - } |
|
113 | - fwrite($fh, $rsstext); |
|
114 | - fclose ($fh); |
|
106 | + // Write the text to the file... |
|
107 | + $filename = $rsspath . $person_id . '.rdf'; |
|
108 | + $fh = @fopen($filename, "w"); |
|
109 | + if (!$fh) { # Problem writing, just carry on |
|
110 | + echo "Could not write to file ($filename)\n"; |
|
111 | + continue; |
|
112 | + } |
|
113 | + fwrite($fh, $rsstext); |
|
114 | + fclose ($fh); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | #print "Took " . (time()-$starttime) . " seconds\n"; |
@@ -106,7 +106,8 @@ |
||
106 | 106 | // Write the text to the file... |
107 | 107 | $filename = $rsspath . $person_id . '.rdf'; |
108 | 108 | $fh = @fopen($filename, "w"); |
109 | - if (!$fh) { # Problem writing, just carry on |
|
109 | + if (!$fh) { |
|
110 | +# Problem writing, just carry on |
|
110 | 111 | echo "Could not write to file ($filename)\n"; |
111 | 112 | continue; |
112 | 113 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | // available for editing, it's accurate. |
25 | 25 | $this->_update_locked(); |
26 | 26 | |
27 | - $data = $this->_get_data_by_recent (); |
|
27 | + $data = $this->_get_data_by_recent(); |
|
28 | 28 | |
29 | 29 | $this->render($data); |
30 | 30 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $data = array(); |
99 | 99 | foreach ($q as $row) { |
100 | - $data[] = array ( |
|
100 | + $data[] = array( |
|
101 | 101 | 'report_id' => $row['report_id'], |
102 | 102 | 'comment_id' => $row['comment_id'], |
103 | 103 | 'firstname' => $row['firstname'], |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ); |
109 | 109 | } |
110 | 110 | foreach ($r as $row) { |
111 | - $data[] = array ( |
|
111 | + $data[] = array( |
|
112 | 112 | 'report_id' => $row['report_id'], |
113 | 113 | 'comment_id' => $row['comment_id'], |
114 | 114 | 'firstname' => $row['firstname'], |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | // Linking to the prev (sub)section. |
431 | 431 | $thing = $hansardmajors[$this->major]['singular']; |
432 | 432 | $nextprevdata['prev'] = array ( |
433 | - 'body' => "Previous $thing", |
|
433 | + 'body' => "previous $thing", |
|
434 | 434 | 'url' => $prevdata[0]['listurl'], |
435 | 435 | 'title' => $prevdata[0]['body'] |
436 | 436 | ); |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | // Linking to the next (sub)section. |
475 | 475 | $thing = $hansardmajors[$this->major]['singular']; |
476 | 476 | $nextprevdata['next'] = array ( |
477 | - 'body' => "Next $thing", |
|
477 | + 'body' => "next $thing", |
|
478 | 478 | 'url' => $nextdata[0]['listurl'], |
479 | 479 | 'title' => $nextdata[0]['body'] |
480 | 480 | ); |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | $URL->remove(array('id')); |
511 | 511 | $things = $hansardmajors[$itemdata['major']]['title']; |
512 | 512 | $nextprevdata['up'] = array( |
513 | - 'body' => "All $things on " . format_date($itemdata['hdate'], SHORTDATEFORMAT), |
|
513 | + 'body' => "all $things on " . format_date($itemdata['hdate'], SHORTDATEFORMAT), |
|
514 | 514 | 'title' => '', |
515 | 515 | 'url' => $URL->generate() |
516 | 516 | ); |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | |
560 | 560 | // The '!= NULL' bit is needed otherwise I was getting errors |
561 | 561 | // when displaying the first day of debates. |
562 | - if ($q && $q['hdate'] != NULL) { |
|
562 | + if ($q && $q['hdate'] != null) { |
|
563 | 563 | |
564 | 564 | $URL->insert( array( 'd' => $q['hdate'] ) ); |
565 | 565 | |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | WHERE major = :major", |
1392 | 1392 | array(':major' => $this->major))->first(); |
1393 | 1393 | |
1394 | - if ($q && $q['hdate'] != NULL) { |
|
1394 | + if ($q && $q['hdate'] != null) { |
|
1395 | 1395 | $recentdate = $q['hdate']; |
1396 | 1396 | } else { |
1397 | 1397 | $PAGE->error_message("Couldn't find the most recent date"); |
@@ -1711,7 +1711,7 @@ discard block |
||
1711 | 1711 | } |
1712 | 1712 | |
1713 | 1713 | // Finally, do the query! |
1714 | - $q = $this->db->query ("SELECT $fields |
|
1714 | + $q = $this->db->query ("select $fields |
|
1715 | 1715 | FROM hansard |
1716 | 1716 | $join |
1717 | 1717 | WHERE $where |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include_once INCLUDESPATH."easyparliament/searchengine.php"; |
|
4 | -include_once INCLUDESPATH."easyparliament/searchlog.php"; |
|
3 | +include_once INCLUDESPATH . "easyparliament/searchengine.php"; |
|
4 | +include_once INCLUDESPATH . "easyparliament/searchlog.php"; |
|
5 | 5 | |
6 | 6 | /* |
7 | 7 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | class HANSARDLIST { |
54 | 54 | // This will be used to cache information about speakers on this page |
55 | 55 | // so we don't have to keep fetching the same data from the DB. |
56 | - public $speakers = array (); |
|
56 | + public $speakers = array(); |
|
57 | 57 | /* |
58 | 58 | $this->speakers[ $person_id ] = array ( |
59 | 59 | "name" => $name, |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | // This will be used to cache mappings from epobject_id to gid, |
68 | 68 | // so we don't have to continually fetch the same data in get_hansard_data(). |
69 | - public $epobjectid_to_gid = array (); |
|
69 | + public $epobjectid_to_gid = array(); |
|
70 | 70 | /* |
71 | 71 | $this->epobjectid_to_gid[ $epobject_id ] => $gid; |
72 | 72 | */ |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | |
116 | 116 | |
117 | - public function display ($view, $args=array(), $format='html') { |
|
117 | + public function display($view, $args = array(), $format = 'html') { |
|
118 | 118 | |
119 | 119 | // $view is what we're viewing by: |
120 | 120 | // 'gid' is the gid of a hansard object, |
@@ -142,17 +142,17 @@ discard block |
||
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | |
145 | - $validviews = array ('calendar', 'date', 'gid', 'person', 'search', 'search_video', 'recent', 'recent_mostvotes', 'biggest_debates', 'recent_wrans', 'recent_wms', 'column', 'mp', 'bill', 'session', 'recent_debates', 'recent_pbc_debates', 'featured_gid'); |
|
145 | + $validviews = array('calendar', 'date', 'gid', 'person', 'search', 'search_video', 'recent', 'recent_mostvotes', 'biggest_debates', 'recent_wrans', 'recent_wms', 'column', 'mp', 'bill', 'session', 'recent_debates', 'recent_pbc_debates', 'featured_gid'); |
|
146 | 146 | if (in_array($view, $validviews)) { |
147 | 147 | |
148 | 148 | // What function do we call for this view? |
149 | - $function = '_get_data_by_'.$view; |
|
149 | + $function = '_get_data_by_' . $view; |
|
150 | 150 | // Get all the data that's to be rendered. |
151 | 151 | $data = $this->$function($args); |
152 | 152 | |
153 | 153 | } else { |
154 | 154 | // Don't have a valid $view. |
155 | - $PAGE->error_message ("You haven't specified a view type."); |
|
155 | + $PAGE->error_message("You haven't specified a view type."); |
|
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | |
174 | 174 | |
175 | 175 | |
176 | - public function render($view, $data, $format='html') { |
|
176 | + public function render($view, $data, $format = 'html') { |
|
177 | 177 | // Once we have the data that's to be rendered, |
178 | 178 | // include the template. |
179 | 179 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | return $data; |
183 | 183 | } |
184 | 184 | |
185 | - include (INCLUDESPATH."easyparliament/templates/$format/hansard_$view" . ".php"); |
|
185 | + include (INCLUDESPATH . "easyparliament/templates/$format/hansard_$view" . ".php"); |
|
186 | 186 | return true; |
187 | 187 | |
188 | 188 | } |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | $hdate = $q['hdate']; |
228 | 228 | if ($hdate) { |
229 | 229 | $URL = new \MySociety\TheyWorkForYou\Url($this->listpage); |
230 | - $URL->insert( array('d'=>$hdate) ); |
|
230 | + $URL->insert(array('d'=>$hdate)); |
|
231 | 231 | |
232 | 232 | // Work out a timestamp which is handy for comparing to now. |
233 | 233 | list($year, $month, $date) = explode('-', $hdate); |
234 | - $timestamp = gmmktime (0, 0, 0, $month, $date, $year); |
|
234 | + $timestamp = gmmktime(0, 0, 0, $month, $date, $year); |
|
235 | 235 | |
236 | - $data = array ( |
|
236 | + $data = array( |
|
237 | 237 | 'hdate' => $hdate, |
238 | 238 | 'timestamp' => $timestamp, |
239 | 239 | 'listurl' => $URL->generate() |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | // Pass it an array of data about an item and it will return an |
268 | 268 | // array of data about the item's section heading. |
269 | 269 | |
270 | - twfy_debug (get_class($this), "getting an item's section"); |
|
270 | + twfy_debug(get_class($this), "getting an item's section"); |
|
271 | 271 | |
272 | 272 | if ($itemdata['htype'] != '10') { |
273 | 273 | |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | // so get the section info above this item. |
277 | 277 | |
278 | 278 | // For getting hansard data. |
279 | - $input = array ( |
|
280 | - 'amount' => array ( |
|
279 | + $input = array( |
|
280 | + 'amount' => array( |
|
281 | 281 | 'body' => true |
282 | 282 | ), |
283 | - 'where' => array ( |
|
283 | + 'where' => array( |
|
284 | 284 | 'hansard.epobject_id=' => $itemdata['section_id'] |
285 | 285 | ) |
286 | 286 | ); |
@@ -307,21 +307,21 @@ discard block |
||
307 | 307 | // Pass it an array of data about an item and it will return an |
308 | 308 | // array of data about the item's subsection heading. |
309 | 309 | |
310 | - twfy_debug (get_class($this), "getting an item's subsection"); |
|
310 | + twfy_debug(get_class($this), "getting an item's subsection"); |
|
311 | 311 | |
312 | 312 | // What we return. |
313 | - $subsectiondata = array (); |
|
313 | + $subsectiondata = array(); |
|
314 | 314 | |
315 | 315 | if ($itemdata['htype'] == '12' || $itemdata['htype'] == '13' || $itemdata['htype'] == '14') { |
316 | 316 | // This item is a speech or procedural, so get the |
317 | 317 | // subsection info above this item. |
318 | 318 | |
319 | 319 | // For getting hansard data. |
320 | - $input = array ( |
|
321 | - 'amount' => array ( |
|
320 | + $input = array( |
|
321 | + 'amount' => array( |
|
322 | 322 | 'body' => true |
323 | 323 | ), |
324 | - 'where' => array ( |
|
324 | + 'where' => array( |
|
325 | 325 | 'hansard.epobject_id=' => $itemdata['subsection_id'] |
326 | 326 | ) |
327 | 327 | ); |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | // Pass it an array of item info, of a section/subsection, and this will return |
350 | 350 | // data for the next/prev items. |
351 | 351 | |
352 | - twfy_debug (get_class($this), "getting next/prev items"); |
|
352 | + twfy_debug(get_class($this), "getting next/prev items"); |
|
353 | 353 | |
354 | 354 | // What we return. |
355 | 355 | $nextprevdata = array(); |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | $wherearr['hansard.epobject_id='] = $prev_item_id; |
416 | 416 | |
417 | 417 | // For getting hansard data. |
418 | - $input = array ( |
|
419 | - 'amount' => array ( |
|
418 | + $input = array( |
|
419 | + 'amount' => array( |
|
420 | 420 | 'body' => true, |
421 | 421 | 'speaker' => true |
422 | 422 | ), |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | if ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') { |
432 | 432 | // Linking to the prev (sub)section. |
433 | 433 | $thing = $hansardmajors[$this->major]['singular']; |
434 | - $nextprevdata['prev'] = array ( |
|
434 | + $nextprevdata['prev'] = array( |
|
435 | 435 | 'body' => "Previous $thing", |
436 | 436 | 'url' => $prevdata[0]['listurl'], |
437 | 437 | 'title' => $prevdata[0]['body'] |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | } else { |
445 | 445 | $title = ''; |
446 | 446 | } |
447 | - $nextprevdata['prev'] = array ( |
|
447 | + $nextprevdata['prev'] = array( |
|
448 | 448 | 'body' => 'Previous speaker', |
449 | 449 | 'url' => $prevdata[0]['commentsurl'], |
450 | 450 | 'title' => $title |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | $wherearr['hansard.epobject_id='] = $next_item_id; |
461 | 461 | |
462 | 462 | // For getting hansard data. |
463 | - $input = array ( |
|
464 | - 'amount' => array ( |
|
463 | + $input = array( |
|
464 | + 'amount' => array( |
|
465 | 465 | 'body' => true, |
466 | 466 | 'speaker' => true |
467 | 467 | ), |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | if ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') { |
476 | 476 | // Linking to the next (sub)section. |
477 | 477 | $thing = $hansardmajors[$this->major]['singular']; |
478 | - $nextprevdata['next'] = array ( |
|
478 | + $nextprevdata['next'] = array( |
|
479 | 479 | 'body' => "Next $thing", |
480 | 480 | 'url' => $nextdata[0]['listurl'], |
481 | 481 | 'title' => $nextdata[0]['body'] |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | } else { |
489 | 489 | $title = ''; |
490 | 490 | } |
491 | - $nextprevdata['next'] = array ( |
|
491 | + $nextprevdata['next'] = array( |
|
492 | 492 | 'body' => 'Next speaker', |
493 | 493 | 'url' => $nextdata[0]['commentsurl'], |
494 | 494 | 'title' => $title |
@@ -532,14 +532,14 @@ discard block |
||
532 | 532 | // containing the next/prev dates that contain items from |
533 | 533 | // $this->major of hansard object. |
534 | 534 | |
535 | - twfy_debug (get_class($this), "getting next/prev dates"); |
|
535 | + twfy_debug(get_class($this), "getting next/prev dates"); |
|
536 | 536 | |
537 | 537 | // What we return. |
538 | - $nextprevdata = array (); |
|
538 | + $nextprevdata = array(); |
|
539 | 539 | |
540 | 540 | $URL = new \MySociety\TheyWorkForYou\Url($this->listpage); |
541 | 541 | |
542 | - $looper = array ("next", "prev"); |
|
542 | + $looper = array("next", "prev"); |
|
543 | 543 | |
544 | 544 | foreach ($looper as $n => $nextorprev) { |
545 | 545 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | // when displaying the first day of debates. |
564 | 564 | if ($q && $q['hdate'] != NULL) { |
565 | 565 | |
566 | - $URL->insert( array( 'd' => $q['hdate'] ) ); |
|
566 | + $URL->insert(array('d' => $q['hdate'])); |
|
567 | 567 | |
568 | 568 | if ($nextorprev == 'next') { |
569 | 569 | $body = 'Next day'; |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | |
574 | 574 | $title = format_date($q['hdate'], SHORTDATEFORMAT); |
575 | 575 | |
576 | - $nextprevdata[$nextorprev] = array ( |
|
576 | + $nextprevdata[$nextorprev] = array( |
|
577 | 577 | 'hdate' => $q['hdate'], |
578 | 578 | 'url' => $URL->generate(), |
579 | 579 | 'body' => $body, |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | $thing = $hansardmajors[$this->major]['plural']; |
588 | 588 | $URL->insert(array('y'=>$year)); |
589 | 589 | |
590 | - $nextprevdata['up'] = array ( |
|
590 | + $nextprevdata['up'] = array( |
|
591 | 591 | 'body' => "All of $year's $thing", |
592 | 592 | 'title' => '', |
593 | 593 | 'url' => $URL->generate() |
@@ -608,19 +608,19 @@ discard block |
||
608 | 608 | if (isset($args['date'])) { |
609 | 609 | $date = $args['date']; |
610 | 610 | } else { |
611 | - $PAGE->error_message ("Sorry, we don't have a date."); |
|
611 | + $PAGE->error_message("Sorry, we don't have a date."); |
|
612 | 612 | return false; |
613 | 613 | } |
614 | 614 | |
615 | 615 | if (!preg_match("/^(\d\d\d\d)-(\d{1,2})-(\d{1,2})$/", $date, $matches)) { |
616 | - $PAGE->error_message ("Sorry, '" . _htmlentities($date) . "' isn't of the right format (YYYY-MM-DD)."); |
|
616 | + $PAGE->error_message("Sorry, '" . _htmlentities($date) . "' isn't of the right format (YYYY-MM-DD)."); |
|
617 | 617 | return false; |
618 | 618 | } |
619 | 619 | |
620 | 620 | list(, $year, $month, $day) = $matches; |
621 | 621 | |
622 | 622 | if (!checkdate($month, $day, $year)) { |
623 | - $PAGE->error_message ("Sorry, '" . _htmlentities($date) . "' isn't a valid date."); |
|
623 | + $PAGE->error_message("Sorry, '" . _htmlentities($date) . "' isn't a valid date."); |
|
624 | 624 | return false; |
625 | 625 | } |
626 | 626 | |
@@ -638,29 +638,29 @@ discard block |
||
638 | 638 | global $PAGE; |
639 | 639 | |
640 | 640 | if (!isset($args['gid']) && $args['gid'] == '') { |
641 | - $PAGE->error_message ("Sorry, we don't have an item gid."); |
|
641 | + $PAGE->error_message("Sorry, we don't have an item gid."); |
|
642 | 642 | return false; |
643 | 643 | } |
644 | 644 | |
645 | 645 | |
646 | 646 | // Get all the data just for this epobject_id. |
647 | - $input = array ( |
|
648 | - 'amount' => array ( |
|
647 | + $input = array( |
|
648 | + 'amount' => array( |
|
649 | 649 | 'body' => true, |
650 | 650 | 'speaker' => true, |
651 | 651 | 'comment' => true, |
652 | 652 | 'votes' => true |
653 | 653 | ), |
654 | - 'where' => array ( |
|
654 | + 'where' => array( |
|
655 | 655 | // Need to add the 'uk.org.publicwhip/debate/' or whatever on before |
656 | 656 | // looking in the DB. |
657 | 657 | 'gid=' => $this->gidprefix . $args['gid'] |
658 | 658 | ) |
659 | 659 | ); |
660 | 660 | |
661 | - twfy_debug (get_class($this), "looking for redirected gid"); |
|
661 | + twfy_debug(get_class($this), "looking for redirected gid"); |
|
662 | 662 | $gid = $this->gidprefix . $args['gid']; |
663 | - $q = $this->db->query ("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid))->first(); |
|
663 | + $q = $this->db->query("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid))->first(); |
|
664 | 664 | if (!$q) { |
665 | 665 | $itemdata = $this->_get_hansard_data($input); |
666 | 666 | } else { |
@@ -668,10 +668,10 @@ discard block |
||
668 | 668 | $gid = $q['gid_to']; |
669 | 669 | $q = $this->db->query("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid))->first(); |
670 | 670 | } while ($q); |
671 | - twfy_debug (get_class($this), "found redirected gid $gid" ); |
|
671 | + twfy_debug(get_class($this), "found redirected gid $gid"); |
|
672 | 672 | $input['where'] = array('gid=' => $gid); |
673 | 673 | $itemdata = $this->_get_hansard_data($input); |
674 | - if (count($itemdata) > 0 ) { |
|
674 | + if (count($itemdata) > 0) { |
|
675 | 675 | throw new RedirectException(fix_gid_from_db($gid)); |
676 | 676 | } |
677 | 677 | } |
@@ -685,9 +685,9 @@ discard block |
||
685 | 685 | $this->check_gid_change($args['gid'], 'a', ''); |
686 | 686 | |
687 | 687 | if (substr($args['gid'], -1) == 'L') { |
688 | - $letts = array('a','b','c','d','e'); |
|
689 | - for ($i=0; $i<4; $i++) { |
|
690 | - $this->check_gid_change($args['gid'], $letts[$i], $letts[$i+1]); |
|
688 | + $letts = array('a', 'b', 'c', 'd', 'e'); |
|
689 | + for ($i = 0; $i < 4; $i++) { |
|
690 | + $this->check_gid_change($args['gid'], $letts[$i], $letts[$i + 1]); |
|
691 | 691 | } |
692 | 692 | } |
693 | 693 | |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | # $u = $q['source_url']; |
721 | 721 | # $u = '<br><a href="'. $u . '">' . $u . '</a>'; |
722 | 722 | #} |
723 | - $PAGE->error_message ("Sorry, there is no Hansard object with a gid of '" . _htmlentities($args['gid']) . "'."); |
|
723 | + $PAGE->error_message("Sorry, there is no Hansard object with a gid of '" . _htmlentities($args['gid']) . "'."); |
|
724 | 724 | return false; |
725 | 725 | } |
726 | 726 | |
@@ -729,8 +729,8 @@ discard block |
||
729 | 729 | } |
730 | 730 | |
731 | 731 | private function check_gid_change($gid, $from, $to) { |
732 | - $input = array ( |
|
733 | - 'amount' => array ( |
|
732 | + $input = array( |
|
733 | + 'amount' => array( |
|
734 | 734 | 'body' => true, |
735 | 735 | 'speaker' => true, |
736 | 736 | 'comment' => true, |
@@ -754,10 +754,10 @@ discard block |
||
754 | 754 | |
755 | 755 | global $DATA, $this_page; |
756 | 756 | |
757 | - twfy_debug (get_class($this), "getting data by date"); |
|
757 | + twfy_debug(get_class($this), "getting data by date"); |
|
758 | 758 | |
759 | 759 | // Where we'll put all the data we want to render. |
760 | - $data = array (); |
|
760 | + $data = array(); |
|
761 | 761 | |
762 | 762 | $date = $this->_validate_date($args); |
763 | 763 | |
@@ -771,13 +771,13 @@ discard block |
||
771 | 771 | |
772 | 772 | // Get all the sections for this date. |
773 | 773 | // Then for each of those we'll get the subsections and rows. |
774 | - $input = array ( |
|
775 | - 'amount' => array ( |
|
774 | + $input = array( |
|
775 | + 'amount' => array( |
|
776 | 776 | 'body' => true, |
777 | 777 | 'comment' => true, |
778 | 778 | 'excerpt' => true |
779 | 779 | ), |
780 | - 'where' => array ( |
|
780 | + 'where' => array( |
|
781 | 781 | 'hdate=' => "$date", |
782 | 782 | 'htype=' => '10', |
783 | 783 | 'major=' => $this->major |
@@ -793,20 +793,20 @@ discard block |
||
793 | 793 | $data['rows'] = array(); |
794 | 794 | |
795 | 795 | $num_sections = count($sections); |
796 | - for ($n=0; $n<$num_sections; $n++) { |
|
796 | + for ($n = 0; $n < $num_sections; $n++) { |
|
797 | 797 | // For each section on this date, get the subsections within it. |
798 | 798 | |
799 | 799 | // Get all the section data. |
800 | 800 | $sectionrow = $this->_get_section($sections[$n]); |
801 | 801 | |
802 | 802 | // Get the subsections within the section. |
803 | - $input = array ( |
|
804 | - 'amount' => array ( |
|
803 | + $input = array( |
|
804 | + 'amount' => array( |
|
805 | 805 | 'body' => true, |
806 | 806 | 'comment' => true, |
807 | 807 | 'excerpt' => true |
808 | 808 | ), |
809 | - 'where' => array ( |
|
809 | + 'where' => array( |
|
810 | 810 | 'section_id=' => $sections[$n]['epobject_id'], |
811 | 811 | 'htype=' => '11', |
812 | 812 | 'major=' => $this->major |
@@ -817,10 +817,10 @@ discard block |
||
817 | 817 | $rows = $this->_get_hansard_data($input); |
818 | 818 | |
819 | 819 | // Put the section at the top of the rows array. |
820 | - array_unshift ($rows, $sectionrow); |
|
820 | + array_unshift($rows, $sectionrow); |
|
821 | 821 | |
822 | 822 | // Add the section heading and the subsections to the full list. |
823 | - $data['rows'] = array_merge ($data['rows'], $rows); |
|
823 | + $data['rows'] = array_merge($data['rows'], $rows); |
|
824 | 824 | } |
825 | 825 | } |
826 | 826 | |
@@ -856,9 +856,9 @@ discard block |
||
856 | 856 | $major = ''; |
857 | 857 | } |
858 | 858 | |
859 | - $data = array (); |
|
859 | + $data = array(); |
|
860 | 860 | |
861 | - $q = $this->db->query ("SELECT DISTINCT(hdate) |
|
861 | + $q = $this->db->query("SELECT DISTINCT(hdate) |
|
862 | 862 | FROM hansard |
863 | 863 | $major |
864 | 864 | ORDER BY hdate DESC |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | $data = array(); |
892 | 892 | |
893 | 893 | if (!isset($args['person_id'])) { |
894 | - $PAGE->error_message ("Sorry, we need a valid person ID."); |
|
894 | + $PAGE->error_message("Sorry, we need a valid person ID."); |
|
895 | 895 | return $data; |
896 | 896 | } |
897 | 897 | |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | |
932 | 932 | $speeches = array(); |
933 | 933 | foreach ($q as $row) { |
934 | - $speech = array ( |
|
934 | + $speech = array( |
|
935 | 935 | 'subsection_id' => $row['subsection_id'], |
936 | 936 | 'section_id' => $row['section_id'], |
937 | 937 | 'htype' => $row['htype'], |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | // Cache parent id to speed up _get_listurl |
949 | 949 | $this->epobjectid_to_gid[$row['subsection_id']] = fix_gid_from_db($row['gid_subsection']); |
950 | 950 | |
951 | - $url_args = array ('p' => $row['person_id']); |
|
951 | + $url_args = array('p' => $row['person_id']); |
|
952 | 952 | $speech['listurl'] = $this->_get_listurl($speech, $url_args); |
953 | 953 | $speeches[] = $speech; |
954 | 954 | } |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | if (count($speeches) > 0) { |
957 | 957 | // Get the subsection texts. |
958 | 958 | $num_speeches = count($speeches); |
959 | - for ($n=0; $n<$num_speeches; $n++) { |
|
959 | + for ($n = 0; $n < $num_speeches; $n++) { |
|
960 | 960 | $thing = $hansardmajors[$speeches[$n]['major']]['title']; |
961 | 961 | // Add the parent's body on... |
962 | 962 | $speeches[$n]['parent']['body'] = $speeches[$n]['body_section'] . ' | ' . $thing; |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | // eg, by doing filter_user_input($s, 'strict'); |
991 | 991 | $searchstring = $args['s']; |
992 | 992 | } else { |
993 | - if ( isset($args['exceptions']) ) { |
|
993 | + if (isset($args['exceptions'])) { |
|
994 | 994 | throw new \Exception('No search string provided.'); |
995 | 995 | } else { |
996 | 996 | $PAGE->error_message("No search string"); |
@@ -999,14 +999,14 @@ discard block |
||
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | // What we'll return. |
1002 | - $data = array (); |
|
1002 | + $data = array(); |
|
1003 | 1003 | |
1004 | 1004 | $data['info']['s'] = $args['s']; |
1005 | 1005 | |
1006 | 1006 | // Allows us to specify how many results we want |
1007 | 1007 | // Mainly for glossary term adding |
1008 | 1008 | if (isset($args['num']) && $args['num']) { |
1009 | - $results_per_page = $args['num']+0; |
|
1009 | + $results_per_page = $args['num'] + 0; |
|
1010 | 1010 | } else { |
1011 | 1011 | $results_per_page = 20; |
1012 | 1012 | } |
@@ -1034,20 +1034,20 @@ discard block |
||
1034 | 1034 | global $SEARCHENGINE; |
1035 | 1035 | |
1036 | 1036 | // For Xapian's equivalent of an SQL LIMIT clause. |
1037 | - $first_result = ($page-1) * $results_per_page; |
|
1037 | + $first_result = ($page - 1) * $results_per_page; |
|
1038 | 1038 | $data['info']['first_result'] = $first_result + 1; // Take account of LIMIT's 0 base. |
1039 | 1039 | |
1040 | 1040 | // Get the gids from Xapian |
1041 | 1041 | $sort_order = 'date'; |
1042 | 1042 | if (isset($args['o'])) { |
1043 | - if ($args['o']=='d') { |
|
1043 | + if ($args['o'] == 'd') { |
|
1044 | 1044 | $sort_order = 'newest'; |
1045 | 1045 | } |
1046 | - if ($args['o']=='o') { |
|
1046 | + if ($args['o'] == 'o') { |
|
1047 | 1047 | $sort_order = 'oldest'; |
1048 | - } elseif ($args['o']=='c') { |
|
1048 | + } elseif ($args['o'] == 'c') { |
|
1049 | 1049 | $sort_order = 'created'; |
1050 | - } elseif ($args['o']=='r') { |
|
1050 | + } elseif ($args['o'] == 'r') { |
|
1051 | 1051 | $sort_order = 'relevance'; |
1052 | 1052 | } |
1053 | 1053 | } |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | |
1060 | 1060 | // Log this query so we can improve them - if it wasn't a "popular |
1061 | 1061 | // query" link |
1062 | - if (! isset($args['pop']) or $args['pop'] != 1) { |
|
1062 | + if (!isset($args['pop']) or $args['pop'] != 1) { |
|
1063 | 1063 | global $SEARCHLOG; |
1064 | 1064 | $SEARCHLOG->add( |
1065 | 1065 | array('query' => $searchstring, |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | |
1075 | 1075 | $SEARCHENGINE->run_search($first_result, $results_per_page, $sort_order); |
1076 | 1076 | $gids = $SEARCHENGINE->get_gids(); |
1077 | - if ($sort_order=='created') { |
|
1077 | + if ($sort_order == 'created') { |
|
1078 | 1078 | $createds = $SEARCHENGINE->get_createds(); |
1079 | 1079 | } |
1080 | 1080 | $relevances = $SEARCHENGINE->get_relevances(); |
@@ -1090,13 +1090,13 @@ discard block |
||
1090 | 1090 | |
1091 | 1091 | // Cycle through each result, munge the data, get more, and put it all in $data. |
1092 | 1092 | $num_gids = count($gids); |
1093 | - for ($n=0; $n<$num_gids; $n++) { |
|
1093 | + for ($n = 0; $n < $num_gids; $n++) { |
|
1094 | 1094 | $gid = $gids[$n]; |
1095 | 1095 | $relevancy = $relevances[$n]; |
1096 | 1096 | $collapsed = $SEARCHENGINE->collapsed[$n]; |
1097 | - if ($sort_order=='created') { |
|
1097 | + if ($sort_order == 'created') { |
|
1098 | 1098 | #$created = substr($createds[$n], 0, strpos($createds[$n], ':')); |
1099 | - if ($createds[$n]<$args['threshold']) { |
|
1099 | + if ($createds[$n] < $args['threshold']) { |
|
1100 | 1100 | $data['info']['total_results'] = $n; |
1101 | 1101 | break; |
1102 | 1102 | } |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | , array(':gid' => $gid)); |
1166 | 1166 | |
1167 | 1167 | if ($q->rows() > 1) { |
1168 | - if ( $isset($args['exceptions']) ) { |
|
1168 | + if ($isset($args['exceptions'])) { |
|
1169 | 1169 | throw new \Exception("Got more than one row getting data for $gid."); |
1170 | 1170 | } else { |
1171 | 1171 | $PAGE->error_message("Got more than one row getting data for $gid"); |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | ////////////////////////// |
1187 | 1187 | // 2. Create the URL to link to this bit of text. |
1188 | 1188 | |
1189 | - $id_data = array ( |
|
1189 | + $id_data = array( |
|
1190 | 1190 | 'major' => $itemdata['major'], |
1191 | 1191 | 'minor' => $itemdata['minor'], |
1192 | 1192 | 'htype' => $itemdata['htype'], |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | |
1198 | 1198 | // We append the query onto the end of the URL as variable 's' |
1199 | 1199 | // so we can highlight them on the debate/wrans list page. |
1200 | - $url_args = array ('s' => $searchstring); |
|
1200 | + $url_args = array('s' => $searchstring); |
|
1201 | 1201 | |
1202 | 1202 | $itemdata['listurl'] = $this->_get_listurl($id_data, $url_args, $encode); |
1203 | 1203 | |
@@ -1250,14 +1250,14 @@ discard block |
||
1250 | 1250 | } else { |
1251 | 1251 | $listurl = ''; |
1252 | 1252 | } |
1253 | - $itemdata['parent'] = array ( |
|
1253 | + $itemdata['parent'] = array( |
|
1254 | 1254 | 'body' => $body, |
1255 | 1255 | 'listurl' => $listurl |
1256 | 1256 | ); |
1257 | 1257 | if ($itemdata['htype'] == 11) { |
1258 | 1258 | # Search result was a subsection heading; fetch the first entry |
1259 | 1259 | # from the wrans/wms to show under the heading |
1260 | - $input = array ( |
|
1260 | + $input = array( |
|
1261 | 1261 | 'amount' => array( |
1262 | 1262 | 'body' => true, |
1263 | 1263 | 'speaker' => true |
@@ -1500,7 +1500,7 @@ discard block |
||
1500 | 1500 | |
1501 | 1501 | $params[':major'] = $this->major; |
1502 | 1502 | $params[':firstdate'] = $firstyear . '-' . $firstmonth . '-01'; |
1503 | - $q = $this->db->query("SELECT DISTINCT(hdate) AS hdate |
|
1503 | + $q = $this->db->query("SELECT DISTINCT(hdate) AS hdate |
|
1504 | 1504 | FROM hansard |
1505 | 1505 | WHERE major = :major |
1506 | 1506 | AND hdate >= :firstdate |
@@ -1566,9 +1566,9 @@ discard block |
||
1566 | 1566 | if ($action == 'recentyear') { |
1567 | 1567 | // Assuming there will be a previous year! |
1568 | 1568 | |
1569 | - $YEARURL->insert(array('y'=> $firstyear-1)); |
|
1569 | + $YEARURL->insert(array('y'=> $firstyear - 1)); |
|
1570 | 1570 | |
1571 | - $nextprev['prev'] = array ( |
|
1571 | + $nextprev['prev'] = array( |
|
1572 | 1572 | 'body' => 'Previous year', |
1573 | 1573 | 'title' => $firstyear - 1, |
1574 | 1574 | 'url' => $YEARURL->generate() |
@@ -1577,8 +1577,8 @@ discard block |
||
1577 | 1577 | } else { |
1578 | 1578 | // action is 'year'. |
1579 | 1579 | |
1580 | - $nextprev['prev'] = array ('body' => 'Previous year'); |
|
1581 | - $nextprev['next'] = array ('body' => 'Next year'); |
|
1580 | + $nextprev['prev'] = array('body' => 'Previous year'); |
|
1581 | + $nextprev['next'] = array('body' => 'Next year'); |
|
1582 | 1582 | |
1583 | 1583 | $q = $this->db->query("SELECT DATE_FORMAT(hdate, '%Y') AS year |
1584 | 1584 | FROM hansard WHERE major = :major |
@@ -1667,14 +1667,14 @@ discard block |
||
1667 | 1667 | // $input['limit'] as a string for the $limit clause, eg '21,20'. |
1668 | 1668 | |
1669 | 1669 | $amount = isset($input['amount']) ? $input['amount'] : array(); |
1670 | - $wherearr = isset($input['where']) ? $input['where'] : array(); |
|
1670 | + $wherearr = isset($input['where']) ? $input['where'] : array(); |
|
1671 | 1671 | $order = isset($input['order']) ? $input['order'] : ''; |
1672 | 1672 | $limit = isset($input['limit']) ? $input['limit'] : ''; |
1673 | 1673 | |
1674 | 1674 | |
1675 | 1675 | // The fields to fetch from db. 'table' => array ('field1', 'field2'). |
1676 | - $fieldsarr = array ( |
|
1677 | - 'hansard' => array ('epobject_id', 'htype', 'gid', 'hpos', 'section_id', 'subsection_id', 'hdate', 'htime', 'source_url', 'major', 'minor', 'video_status', 'colnum') |
|
1676 | + $fieldsarr = array( |
|
1677 | + 'hansard' => array('epobject_id', 'htype', 'gid', 'hpos', 'section_id', 'subsection_id', 'hdate', 'htime', 'source_url', 'major', 'minor', 'video_status', 'colnum') |
|
1678 | 1678 | ); |
1679 | 1679 | |
1680 | 1680 | $params = array(); |
@@ -1686,23 +1686,23 @@ discard block |
||
1686 | 1686 | if ((isset($amount['body']) && $amount['body'] == true) || |
1687 | 1687 | (isset($amount['comment']) && $amount['comment'] == true) |
1688 | 1688 | ) { |
1689 | - $fieldsarr['epobject'] = array ('body'); |
|
1689 | + $fieldsarr['epobject'] = array('body'); |
|
1690 | 1690 | $join = 'LEFT OUTER JOIN epobject ON hansard.epobject_id = epobject.epobject_id'; |
1691 | 1691 | } else { |
1692 | 1692 | $join = ''; |
1693 | 1693 | } |
1694 | 1694 | |
1695 | 1695 | |
1696 | - $fieldsarr2 = array (); |
|
1696 | + $fieldsarr2 = array(); |
|
1697 | 1697 | // Construct the $fields clause. |
1698 | 1698 | foreach ($fieldsarr as $table => $tablesfields) { |
1699 | 1699 | foreach ($tablesfields as $n => $field) { |
1700 | - $fieldsarr2[] = $table.'.'.$field; |
|
1700 | + $fieldsarr2[] = $table . '.' . $field; |
|
1701 | 1701 | } |
1702 | 1702 | } |
1703 | 1703 | $fields = implode(', ', $fieldsarr2); |
1704 | 1704 | |
1705 | - $wherearr2 = array (); |
|
1705 | + $wherearr2 = array(); |
|
1706 | 1706 | // Construct the $where clause. |
1707 | 1707 | $i = 0; |
1708 | 1708 | foreach ($wherearr as $key => $val) { |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | $wherearr2[] = "$key :where$i"; |
1711 | 1711 | $i++; |
1712 | 1712 | } |
1713 | - $where = implode (" AND ", $wherearr2); |
|
1713 | + $where = implode(" AND ", $wherearr2); |
|
1714 | 1714 | |
1715 | 1715 | |
1716 | 1716 | if ($order != '') { |
@@ -1728,7 +1728,7 @@ discard block |
||
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | // Finally, do the query! |
1731 | - $q = $this->db->query ("SELECT $fields |
|
1731 | + $q = $this->db->query("SELECT $fields |
|
1732 | 1732 | FROM hansard |
1733 | 1733 | $join |
1734 | 1734 | WHERE $where |
@@ -1753,23 +1753,23 @@ discard block |
||
1753 | 1753 | if (isset($item['gid'])) { |
1754 | 1754 | // Remove the "uk.org.publicwhip/blah/" from the gid: |
1755 | 1755 | // (In includes/utility.php) |
1756 | - $item['gid'] = fix_gid_from_db( $item['gid'] ); |
|
1756 | + $item['gid'] = fix_gid_from_db($item['gid']); |
|
1757 | 1757 | } |
1758 | 1758 | |
1759 | 1759 | // Add mentions if (a) it's a question in the written |
1760 | 1760 | // answer section or (b) it's in the official reports |
1761 | 1761 | // and the body text ends in a bracketed SPID. |
1762 | - if (($this->major && $hansardmajors[$this->major]['page']=='spwrans') && ($item['htype'] == '12' && $item['minor'] == '1')) { |
|
1762 | + if (($this->major && $hansardmajors[$this->major]['page'] == 'spwrans') && ($item['htype'] == '12' && $item['minor'] == '1')) { |
|
1763 | 1763 | // Get out the SPID: |
1764 | - if ( preg_match('#\d{4}-\d\d-\d\d\.(.*?)\.q#', $item['gid'], $m) ) { |
|
1764 | + if (preg_match('#\d{4}-\d\d-\d\d\.(.*?)\.q#', $item['gid'], $m)) { |
|
1765 | 1765 | $item['mentions'] = $this->_get_mentions($m[1]); |
1766 | 1766 | } |
1767 | 1767 | } |
1768 | 1768 | |
1769 | 1769 | // The second case (b): |
1770 | - if (($this->major && $hansardmajors[$this->major]['page']=='spdebates') && isset($item['body'])) { |
|
1771 | - $stripped_body = preg_replace('/<[^>]+>/ms','',$item['body']); |
|
1772 | - if ( preg_match('/\((S\d+\w+-\d+)\)/ms',$stripped_body,$m) ) { |
|
1770 | + if (($this->major && $hansardmajors[$this->major]['page'] == 'spdebates') && isset($item['body'])) { |
|
1771 | + $stripped_body = preg_replace('/<[^>]+>/ms', '', $item['body']); |
|
1772 | + if (preg_match('/\((S\d+\w+-\d+)\)/ms', $stripped_body, $m)) { |
|
1773 | 1773 | $item['mentions'] = $this->_get_mentions($m[1]); |
1774 | 1774 | } |
1775 | 1775 | } |
@@ -1782,7 +1782,7 @@ discard block |
||
1782 | 1782 | // Get the number of items within a section or subsection. |
1783 | 1783 | // It could be that we can do this in the main query? |
1784 | 1784 | // Not sure. |
1785 | - if ( ($this->major && $hansardmajors[$this->major]['type']=='debate') && ($item['htype'] == '10' || $item['htype'] == '11') ) { |
|
1785 | + if (($this->major && $hansardmajors[$this->major]['type'] == 'debate') && ($item['htype'] == '10' || $item['htype'] == '11')) { |
|
1786 | 1786 | |
1787 | 1787 | if ($item['htype'] == '10') { |
1788 | 1788 | // Section - get a count of items within this section that |
@@ -1860,7 +1860,7 @@ discard block |
||
1860 | 1860 | // 'commentsurl' is the URL of the item on its own page, with comments. |
1861 | 1861 | |
1862 | 1862 | // All the things we need to work out a listurl! |
1863 | - $item_data = array ( |
|
1863 | + $item_data = array( |
|
1864 | 1864 | 'major' => $this->major, |
1865 | 1865 | 'minor' => $item['minor'], |
1866 | 1866 | 'htype' => $item['htype'], |
@@ -1893,11 +1893,11 @@ discard block |
||
1893 | 1893 | $item['htype'] == '12') { |
1894 | 1894 | // Debate speech or written answers (not questions). |
1895 | 1895 | |
1896 | - $item['votes'] = $this->_get_votes( $item['epobject_id'] ); |
|
1896 | + $item['votes'] = $this->_get_votes($item['epobject_id']); |
|
1897 | 1897 | } |
1898 | 1898 | |
1899 | 1899 | // Get the speaker for this item, if applicable. |
1900 | - if ( (isset($amount['speaker']) && $amount['speaker'] == true) && |
|
1900 | + if ((isset($amount['speaker']) && $amount['speaker'] == true) && |
|
1901 | 1901 | $item['person_id'] != '') { |
1902 | 1902 | |
1903 | 1903 | $item['speaker'] = $this->_get_speaker($item['person_id'], $item['hdate'], $item['htime'], $item['major']); |
@@ -1908,7 +1908,7 @@ discard block |
||
1908 | 1908 | if (isset($amount['comment']) && $amount['comment'] == true) { |
1909 | 1909 | |
1910 | 1910 | // All the things we need to get the comment data. |
1911 | - $item_data = array ( |
|
1911 | + $item_data = array( |
|
1912 | 1912 | 'htype' => $item['htype'], |
1913 | 1913 | 'epobject_id' => $item['epobject_id'] |
1914 | 1914 | ); |
@@ -1981,7 +1981,7 @@ discard block |
||
1981 | 1981 | } |
1982 | 1982 | |
1983 | 1983 | |
1984 | - public function _get_listurl ($id_data, $url_args=array(), $encode='html') { |
|
1984 | + public function _get_listurl($id_data, $url_args = array(), $encode = 'html') { |
|
1985 | 1985 | global $hansardmajors; |
1986 | 1986 | // Generates an item's listurl - this is the 'contextual' url |
1987 | 1987 | // for an item, in the full list view with an anchor (if appropriate). |
@@ -2011,7 +2011,7 @@ discard block |
||
2011 | 2011 | $DATA->set_page_metadata('pbc_clause', 'url', 'pbc/' . $this->url . $id); |
2012 | 2012 | $LISTURL->remove(array('id')); |
2013 | 2013 | } else { |
2014 | - $LISTURL->insert( array( 'id' => $id_data['gid'] ) ); |
|
2014 | + $LISTURL->insert(array('id' => $id_data['gid'])); |
|
2015 | 2015 | } |
2016 | 2016 | } else { |
2017 | 2017 | // A debate speech or question/answer, etc. |
@@ -2024,10 +2024,10 @@ discard block |
||
2024 | 2024 | // Find the gid of this item's (sub)section. |
2025 | 2025 | $parent_gid = ''; |
2026 | 2026 | |
2027 | - if (isset($this->epobjectid_to_gid[ $parent_epobject_id ])) { |
|
2027 | + if (isset($this->epobjectid_to_gid[$parent_epobject_id])) { |
|
2028 | 2028 | // We've previously cached the gid for this epobject_id, so use that. |
2029 | 2029 | |
2030 | - $parent_gid = $this->epobjectid_to_gid[ $parent_epobject_id ]; |
|
2030 | + $parent_gid = $this->epobjectid_to_gid[$parent_epobject_id]; |
|
2031 | 2031 | |
2032 | 2032 | } else { |
2033 | 2033 | // We haven't cached the gid, so fetch from db. |
@@ -2043,7 +2043,7 @@ discard block |
||
2043 | 2043 | $parent_gid = fix_gid_from_db($r['gid']); |
2044 | 2044 | |
2045 | 2045 | // Cache it for if we need it again: |
2046 | - $this->epobjectid_to_gid[ $parent_epobject_id ] = $parent_gid; |
|
2046 | + $this->epobjectid_to_gid[$parent_epobject_id] = $parent_gid; |
|
2047 | 2047 | } |
2048 | 2048 | } |
2049 | 2049 | |
@@ -2058,13 +2058,13 @@ discard block |
||
2058 | 2058 | $session = $qq['session']; |
2059 | 2059 | $this->bill_lookup[$minor] = array($title, $session); |
2060 | 2060 | } |
2061 | - $url = "$session/" . urlencode(str_replace(' ','_',$title)); |
|
2061 | + $url = "$session/" . urlencode(str_replace(' ', '_', $title)); |
|
2062 | 2062 | $parent_gid = preg_replace('#^.*?_.*?_#', '', $parent_gid); |
2063 | 2063 | global $DATA; |
2064 | 2064 | $DATA->set_page_metadata('pbc_clause', 'url', "pbc/$url/$parent_gid"); |
2065 | 2065 | $LISTURL->remove(array('id')); |
2066 | 2066 | } else { |
2067 | - $LISTURL->insert( array( 'id' => $parent_gid ) ); |
|
2067 | + $LISTURL->insert(array('id' => $parent_gid)); |
|
2068 | 2068 | } |
2069 | 2069 | // Use a truncated form of this item's gid for the anchor. |
2070 | 2070 | $fragment = '#g' . gid_to_anchor($id_data['gid']); |
@@ -2072,7 +2072,7 @@ discard block |
||
2072 | 2072 | } |
2073 | 2073 | |
2074 | 2074 | if (count($url_args) > 0) { |
2075 | - $LISTURL->insert( $url_args); |
|
2075 | + $LISTURL->insert($url_args); |
|
2076 | 2076 | } |
2077 | 2077 | |
2078 | 2078 | return $LISTURL->generate($encode) . $fragment; |
@@ -2133,10 +2133,10 @@ discard block |
||
2133 | 2133 | $member = $this->_get_speaker_alone($q, $person_id, $hdate, $htime, $major); |
2134 | 2134 | |
2135 | 2135 | $URL = $this->_get_speaker_url($member['house']); |
2136 | - $URL->insert( array ('p' => $person_id) ); |
|
2136 | + $URL->insert(array('p' => $person_id)); |
|
2137 | 2137 | |
2138 | 2138 | $name = member_full_name($member['house'], $member['title'], $member['given_name'], $member['family_name'], $member['lordofname']); |
2139 | - $speaker = array ( |
|
2139 | + $speaker = array( |
|
2140 | 2140 | 'member_id' => $member['member_id'], |
2141 | 2141 | "name" => $name, |
2142 | 2142 | 'house' => $member['house'], |
@@ -2262,12 +2262,12 @@ discard block |
||
2262 | 2262 | array(':epobject_id' => $item_data['epobject_id']))->first(); |
2263 | 2263 | |
2264 | 2264 | // Add this comment to the data structure. |
2265 | - $comment = array ( |
|
2265 | + $comment = array( |
|
2266 | 2266 | 'comment_id' => $q['comment_id'], |
2267 | 2267 | 'user_id' => $q['user_id'], |
2268 | 2268 | 'body' => $q['body'], |
2269 | 2269 | 'posted' => $q['posted'], |
2270 | - 'username' => $q['firstname'] .' '. $q['lastname'] |
|
2270 | + 'username' => $q['firstname'] . ' ' . $q['lastname'] |
|
2271 | 2271 | ); |
2272 | 2272 | } |
2273 | 2273 | |
@@ -2277,7 +2277,7 @@ discard block |
||
2277 | 2277 | // or subsection itself, only the items within them. So |
2278 | 2278 | // we don't get the most recent comment. Because there isn't one. |
2279 | 2279 | |
2280 | - $return = array ( |
|
2280 | + $return = array( |
|
2281 | 2281 | 'totalcomments' => $totalcomments, |
2282 | 2282 | 'comment' => $comment |
2283 | 2283 | ); |
@@ -2291,7 +2291,7 @@ discard block |
||
2291 | 2291 | // What it says on the tin. |
2292 | 2292 | // $item_data must have 'htype' and 'epobject_id' elements. TODO: Check for major==4 |
2293 | 2293 | |
2294 | - if (($hansardmajors[$this->major]['type']=='debate') && |
|
2294 | + if (($hansardmajors[$this->major]['type'] == 'debate') && |
|
2295 | 2295 | ($item_data['htype'] == '10' || $item_data['htype'] == '11') |
2296 | 2296 | ) { |
2297 | 2297 | // We'll be getting a count of the comments on all items |
@@ -2327,7 +2327,7 @@ discard block |
||
2327 | 2327 | // Then depending on what htype it is, we get the data for other items too. |
2328 | 2328 | global $DATA, $this_page, $hansardmajors; |
2329 | 2329 | |
2330 | - twfy_debug (get_class($this), "getting data by gid"); |
|
2330 | + twfy_debug(get_class($this), "getting data by gid"); |
|
2331 | 2331 | |
2332 | 2332 | // Get the information about the item this URL refers to. |
2333 | 2333 | $itemdata = $this->_get_item($args); |
@@ -2336,25 +2336,25 @@ discard block |
||
2336 | 2336 | } |
2337 | 2337 | |
2338 | 2338 | // If part of a Written Answer (just question or just answer), select the whole thing |
2339 | - if (isset($itemdata['major']) && $hansardmajors[$itemdata['major']]['type']=='other' and ($itemdata['htype'] == '12' or $itemdata['htype'] == '13' or $itemdata['htype'] == '14')) { |
|
2339 | + if (isset($itemdata['major']) && $hansardmajors[$itemdata['major']]['type'] == 'other' and ($itemdata['htype'] == '12' or $itemdata['htype'] == '13' or $itemdata['htype'] == '14')) { |
|
2340 | 2340 | // find the gid of the subheading which holds this part |
2341 | - $input = array ( |
|
2341 | + $input = array( |
|
2342 | 2342 | 'amount' => array('gid' => true), |
2343 | - 'where' => array ( |
|
2343 | + 'where' => array( |
|
2344 | 2344 | 'epobject_id=' => $itemdata['subsection_id'], |
2345 | 2345 | ), |
2346 | 2346 | ); |
2347 | 2347 | $parent = $this->_get_hansard_data($input); |
2348 | 2348 | // display that item, i.e. the whole of the Written Answer |
2349 | - twfy_debug (get_class($this), "instead of " . $args['gid'] . " selecting subheading gid " . $parent[0]['gid'] . " to get whole wrans"); |
|
2349 | + twfy_debug(get_class($this), "instead of " . $args['gid'] . " selecting subheading gid " . $parent[0]['gid'] . " to get whole wrans"); |
|
2350 | 2350 | $args['gid'] = $parent[0]['gid']; |
2351 | 2351 | $this->_get_item($args); |
2352 | 2352 | throw new RedirectException($args['gid']); |
2353 | 2353 | } |
2354 | 2354 | |
2355 | 2355 | # If a WMS main heading, go to next gid |
2356 | - if (isset($itemdata['major']) && $itemdata['major']==4 && $itemdata['htype'] == '10') { |
|
2357 | - $input = array ( |
|
2356 | + if (isset($itemdata['major']) && $itemdata['major'] == 4 && $itemdata['htype'] == '10') { |
|
2357 | + $input = array( |
|
2358 | 2358 | 'amount' => array('gid' => true), |
2359 | 2359 | 'where' => array( |
2360 | 2360 | 'section_id=' => $itemdata['epobject_id'], |
@@ -2364,7 +2364,7 @@ discard block |
||
2364 | 2364 | ); |
2365 | 2365 | $next = $this->_get_hansard_data($input); |
2366 | 2366 | if (!empty($next)) { |
2367 | - twfy_debug (get_class($this), 'instead of ' . $args['gid'] . ' moving to ' . $next[0]['gid']); |
|
2367 | + twfy_debug(get_class($this), 'instead of ' . $args['gid'] . ' moving to ' . $next[0]['gid']); |
|
2368 | 2368 | $args['gid'] = $next[0]['gid']; |
2369 | 2369 | $this->_get_item($args); |
2370 | 2370 | throw new RedirectException($args['gid']); |
@@ -2416,16 +2416,16 @@ discard block |
||
2416 | 2416 | // Get the nextprev links for this item, to link to next/prev pages. |
2417 | 2417 | // Duh. |
2418 | 2418 | if ($itemdata['htype'] == '10') { |
2419 | - $nextprev = $this->_get_nextprev_items( $sectionrow ); |
|
2419 | + $nextprev = $this->_get_nextprev_items($sectionrow); |
|
2420 | 2420 | $data['info']['text_heading'] = $itemdata['body']; |
2421 | 2421 | |
2422 | 2422 | } elseif ($itemdata['htype'] == '11') { |
2423 | - $nextprev = $this->_get_nextprev_items( $subsectionrow ); |
|
2423 | + $nextprev = $this->_get_nextprev_items($subsectionrow); |
|
2424 | 2424 | $data['info']['text_heading'] = $itemdata['body']; |
2425 | 2425 | |
2426 | 2426 | } else { |
2427 | 2427 | // Ordinary lowly item. |
2428 | - $nextprev = $this->_get_nextprev_items( $itemdata ); |
|
2428 | + $nextprev = $this->_get_nextprev_items($itemdata); |
|
2429 | 2429 | |
2430 | 2430 | if (isset($subsectionrow['gid'])) { |
2431 | 2431 | $nextprev['up']['url'] = $subsectionrow['listurl']; |
@@ -2434,7 +2434,7 @@ discard block |
||
2434 | 2434 | $nextprev['up']['url'] = $sectionrow['listurl']; |
2435 | 2435 | $nextprev['up']['title'] = $sectionrow['body']; |
2436 | 2436 | } |
2437 | - $nextprev['up']['body'] = 'See the whole debate'; |
|
2437 | + $nextprev['up']['body'] = 'See the whole debate'; |
|
2438 | 2438 | } |
2439 | 2439 | |
2440 | 2440 | // We can then access this from $PAGE and the templates. |
@@ -2443,7 +2443,7 @@ discard block |
||
2443 | 2443 | // Now get all the non-heading rows. |
2444 | 2444 | |
2445 | 2445 | // What data do we want for each item? |
2446 | - $amount = array ( |
|
2446 | + $amount = array( |
|
2447 | 2447 | 'body' => true, |
2448 | 2448 | 'speaker' => true, |
2449 | 2449 | 'comment' => true, |
@@ -2454,9 +2454,9 @@ discard block |
||
2454 | 2454 | // This item is a section, so we're displaying all the items within |
2455 | 2455 | // it that aren't within a subsection. |
2456 | 2456 | |
2457 | - $input = array ( |
|
2457 | + $input = array( |
|
2458 | 2458 | 'amount' => $amount, |
2459 | - 'where' => array ( |
|
2459 | + 'where' => array( |
|
2460 | 2460 | 'section_id=' => $itemdata['epobject_id'], |
2461 | 2461 | 'subsection_id=' => $itemdata['epobject_id'] |
2462 | 2462 | ), |
@@ -2464,15 +2464,15 @@ discard block |
||
2464 | 2464 | ); |
2465 | 2465 | |
2466 | 2466 | $data['rows'] = $this->_get_hansard_data($input); |
2467 | - if (!count($data['rows']) || (count($data['rows'])==1 && strstr($data['rows'][0]['body'], 'was asked'))) { |
|
2467 | + if (!count($data['rows']) || (count($data['rows']) == 1 && strstr($data['rows'][0]['body'], 'was asked'))) { |
|
2468 | 2468 | |
2469 | - $input = array ( |
|
2470 | - 'amount' => array ( |
|
2469 | + $input = array( |
|
2470 | + 'amount' => array( |
|
2471 | 2471 | 'body' => true, |
2472 | 2472 | 'comment' => true, |
2473 | 2473 | 'excerpt' => true |
2474 | 2474 | ), |
2475 | - 'where' => array ( |
|
2475 | + 'where' => array( |
|
2476 | 2476 | 'section_id=' => $sectionrow['epobject_id'], |
2477 | 2477 | 'htype=' => '11', |
2478 | 2478 | 'major=' => $this->major |
@@ -2488,9 +2488,9 @@ discard block |
||
2488 | 2488 | } elseif ($itemdata['htype'] == '11') { |
2489 | 2489 | // This item is a subsection, so we're displaying everything within it. |
2490 | 2490 | |
2491 | - $input = array ( |
|
2491 | + $input = array( |
|
2492 | 2492 | 'amount' => $amount, |
2493 | - 'where' => array ( |
|
2493 | + 'where' => array( |
|
2494 | 2494 | 'subsection_id=' => $itemdata['epobject_id'] |
2495 | 2495 | ), |
2496 | 2496 | 'order' => 'hpos ASC' |
@@ -2511,10 +2511,10 @@ discard block |
||
2511 | 2511 | $subsectionrow['gid'] != $sectionrow['gid']) { |
2512 | 2512 | // If we're looking at a section, there may not be a subsection. |
2513 | 2513 | // And if the subsectionrow and sectionrow aren't the same. |
2514 | - array_unshift ($data['rows'], $subsectionrow); |
|
2514 | + array_unshift($data['rows'], $subsectionrow); |
|
2515 | 2515 | } |
2516 | 2516 | |
2517 | - array_unshift ($data['rows'], $sectionrow); |
|
2517 | + array_unshift($data['rows'], $sectionrow); |
|
2518 | 2518 | |
2519 | 2519 | return $data; |
2520 | 2520 | |
@@ -2523,10 +2523,10 @@ discard block |
||
2523 | 2523 | public function _get_data_by_column($args) { |
2524 | 2524 | global $this_page; |
2525 | 2525 | |
2526 | - twfy_debug (get_class($this), "getting data by column"); |
|
2526 | + twfy_debug(get_class($this), "getting data by column"); |
|
2527 | 2527 | |
2528 | - $input = array( 'amount' => array('body'=>true, 'comment'=>true, 'speaker'=>true), |
|
2529 | - 'where' => array( 'hdate='=>$args['date'], 'major=' => $this->major, 'gid LIKE ' =>'%.'.$args['column'].'.%' ), |
|
2528 | + $input = array('amount' => array('body'=>true, 'comment'=>true, 'speaker'=>true), |
|
2529 | + 'where' => array('hdate='=>$args['date'], 'major=' => $this->major, 'gid LIKE ' =>'%.' . $args['column'] . '.%'), |
|
2530 | 2530 | 'order' => 'hpos' |
2531 | 2531 | ); |
2532 | 2532 | $data = $this->_get_hansard_data($input); |
@@ -2592,8 +2592,8 @@ discard block |
||
2592 | 2592 | public function get_gid_from_spid($spid) { |
2593 | 2593 | // Fix the common errors of S.0 instead of S.O and leading |
2594 | 2594 | // zeros in the numbers: |
2595 | - $fixed_spid = preg_replace('/(S[0-9]+)0-([0-9]+)/','${1}O-${2}',$spid); |
|
2596 | - $fixed_spid = preg_replace('/(S[0-9]+\w+)-0*([0-9]+)/','${1}-${2}',$fixed_spid); |
|
2595 | + $fixed_spid = preg_replace('/(S[0-9]+)0-([0-9]+)/', '${1}O-${2}', $spid); |
|
2596 | + $fixed_spid = preg_replace('/(S[0-9]+\w+)-0*([0-9]+)/', '${1}-${2}', $fixed_spid); |
|
2597 | 2597 | $q = $this->db->query( |
2598 | 2598 | "select mentioned_gid from mentions where gid = :gid_from_spid and (type = 4 or type = 6)", |
2599 | 2599 | array(':gid_from_spid' => 'uk.org.publicwhip/spq/' . $fixed_spid) |
@@ -2672,10 +2672,10 @@ discard block |
||
2672 | 2672 | ", array(':major' => $this->major)); |
2673 | 2673 | |
2674 | 2674 | // What we return. |
2675 | - $data = array (); |
|
2675 | + $data = array(); |
|
2676 | 2676 | $speeches = array(); |
2677 | 2677 | foreach ($q as $row) { |
2678 | - $speech = array ( |
|
2678 | + $speech = array( |
|
2679 | 2679 | 'subsection_id' => $row['subsection_id'], |
2680 | 2680 | 'section_id' => $row['section_id'], |
2681 | 2681 | 'htype' => $row['htype'], |
@@ -2688,9 +2688,9 @@ discard block |
||
2688 | 2688 | |
2689 | 2689 | // Remove the "uk.org.publicwhip/blah/" from the gid: |
2690 | 2690 | // (In includes/utility.php) |
2691 | - $speech['gid'] = fix_gid_from_db( $row['gid'] ); |
|
2691 | + $speech['gid'] = fix_gid_from_db($row['gid']); |
|
2692 | 2692 | $speech['listurl'] = $this->_get_listurl($speech); |
2693 | - $speech['speaker'] = $this->_get_speaker($row['person_id'], $row['hdate'], $row['htime'], $this->major ); |
|
2693 | + $speech['speaker'] = $this->_get_speaker($row['person_id'], $row['hdate'], $row['htime'], $this->major); |
|
2694 | 2694 | $speeches[] = $speech; |
2695 | 2695 | } |
2696 | 2696 | |
@@ -2698,10 +2698,10 @@ discard block |
||
2698 | 2698 | // Get the subsection texts. |
2699 | 2699 | |
2700 | 2700 | $num_speeches = count($speeches); |
2701 | - for ($n=0; $n<$num_speeches; $n++) { |
|
2701 | + for ($n = 0; $n < $num_speeches; $n++) { |
|
2702 | 2702 | //if ($this->major == 1) { |
2703 | 2703 | // Debate. |
2704 | - $parent = $this->_get_subsection ($speeches[$n]); |
|
2704 | + $parent = $this->_get_subsection($speeches[$n]); |
|
2705 | 2705 | |
2706 | 2706 | //} elseif ($this->major == 3) { |
2707 | 2707 | // Wrans. |
@@ -2720,7 +2720,7 @@ discard block |
||
2720 | 2720 | $data['rows'] = $speeches; |
2721 | 2721 | |
2722 | 2722 | } else { |
2723 | - $data['rows'] = array (); |
|
2723 | + $data['rows'] = array(); |
|
2724 | 2724 | } |
2725 | 2725 | |
2726 | 2726 | $data['info']['days'] = $days; |
@@ -2737,13 +2737,13 @@ discard block |
||
2737 | 2737 | } |
2738 | 2738 | |
2739 | 2739 | |
2740 | - public function biggest_debates($args=array()) { |
|
2740 | + public function biggest_debates($args = array()) { |
|
2741 | 2741 | // So we can just get the data back for special formatting |
2742 | 2742 | // on the front page, without doing the whole display() thing. |
2743 | 2743 | return $this->_get_data_by_biggest_debates($args); |
2744 | 2744 | } |
2745 | 2745 | |
2746 | - public function _get_data_by_featured_gid($args=array()) { |
|
2746 | + public function _get_data_by_featured_gid($args = array()) { |
|
2747 | 2747 | $params = array(); |
2748 | 2748 | $data = array(); |
2749 | 2749 | |
@@ -2772,18 +2772,18 @@ discard block |
||
2772 | 2772 | if ($q) { |
2773 | 2773 | |
2774 | 2774 | // This array just used for getting further data about this debate. |
2775 | - $item_data = array ( |
|
2775 | + $item_data = array( |
|
2776 | 2776 | 'major' => $this->major, |
2777 | 2777 | 'minor' => $q['minor'], |
2778 | - 'gid' => fix_gid_from_db( $q['gid'] ), |
|
2778 | + 'gid' => fix_gid_from_db($q['gid']), |
|
2779 | 2779 | 'htype' => $q['htype'], |
2780 | 2780 | 'section_id' => $q['section_id'], |
2781 | 2781 | 'subsection_id' => $q['subsection_id'], |
2782 | 2782 | 'epobject_id' => $q['epobject_id'] |
2783 | 2783 | ); |
2784 | 2784 | |
2785 | - $list_url = $this->_get_listurl( $item_data ); |
|
2786 | - $totalcomments = $this->_get_comment_count_for_epobject( $item_data ); |
|
2785 | + $list_url = $this->_get_listurl($item_data); |
|
2786 | + $totalcomments = $this->_get_comment_count_for_epobject($item_data); |
|
2787 | 2787 | |
2788 | 2788 | $body = $q['body']; |
2789 | 2789 | $hdate = $q['hdate']; |
@@ -2803,21 +2803,21 @@ discard block |
||
2803 | 2803 | ':subsection_id' => $item_data['subsection_id'], |
2804 | 2804 | ) |
2805 | 2805 | )->first(); |
2806 | - $section_body = $r['sec_body']; |
|
2806 | + $section_body = $r['sec_body']; |
|
2807 | 2807 | $subsection_body = $r['sub_body']; |
2808 | - if ( $section_body && $subsection_body ) { |
|
2808 | + if ($section_body && $subsection_body) { |
|
2809 | 2809 | $parentbody = "$section_body : $subsection_body"; |
2810 | 2810 | } else { |
2811 | 2811 | $parentbody = "$section_body$subsection_body"; |
2812 | 2812 | } |
2813 | - } else if ( $item_data['htype'] == 10 ) { |
|
2813 | + } else if ($item_data['htype'] == 10) { |
|
2814 | 2814 | $parentbody = $body; |
2815 | 2815 | } |
2816 | 2816 | |
2817 | 2817 | // Get the question for this item. |
2818 | - if ( $item_data['htype'] == 12 ) { |
|
2818 | + if ($item_data['htype'] == 12) { |
|
2819 | 2819 | $childbody = $body; |
2820 | - $speaker = $this->_get_speaker($q['person_id'], $q['hdate'], $q['htime'], $this->major ); |
|
2820 | + $speaker = $this->_get_speaker($q['person_id'], $q['hdate'], $q['htime'], $this->major); |
|
2821 | 2821 | } else { |
2822 | 2822 | $r = $this->db->query("SELECT e.body, e.title, |
2823 | 2823 | h.person_id, h.hdate, h.htime |
@@ -2827,10 +2827,10 @@ discard block |
||
2827 | 2827 | ORDER BY hpos |
2828 | 2828 | LIMIT 1 |
2829 | 2829 | ", |
2830 | - array( ':object_id' => $item_data['epobject_id'] ) |
|
2830 | + array(':object_id' => $item_data['epobject_id']) |
|
2831 | 2831 | )->first(); |
2832 | 2832 | $childbody = $r['body']; |
2833 | - $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major ); |
|
2833 | + $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major); |
|
2834 | 2834 | } |
2835 | 2835 | |
2836 | 2836 | $contentcount = 0; |
@@ -2846,7 +2846,7 @@ discard block |
||
2846 | 2846 | } |
2847 | 2847 | |
2848 | 2848 | global $hansardmajors; |
2849 | - $more_url = new \MySociety\TheyWorkForYou\Url( $hansardmajors[$this->major]['page_all'] ); |
|
2849 | + $more_url = new \MySociety\TheyWorkForYou\Url($hansardmajors[$this->major]['page_all']); |
|
2850 | 2850 | $details = array( |
2851 | 2851 | 'body' => $body, |
2852 | 2852 | 'contentcount' => $contentcount, |
@@ -2865,7 +2865,7 @@ discard block |
||
2865 | 2865 | 'more_url' => $more_url->generate() |
2866 | 2866 | ); |
2867 | 2867 | |
2868 | - $data = array ( |
|
2868 | + $data = array( |
|
2869 | 2869 | 'gid' => $args['gid'], |
2870 | 2870 | 'major' => $this->major, |
2871 | 2871 | 'info' => array(), |
@@ -2876,7 +2876,7 @@ discard block |
||
2876 | 2876 | return $data; |
2877 | 2877 | |
2878 | 2878 | } |
2879 | - public function _get_data_by_recent_debates($args=array()) { |
|
2879 | + public function _get_data_by_recent_debates($args = array()) { |
|
2880 | 2880 | // Returns an array of some random recent debates from a set number of |
2881 | 2881 | // recent days (that's recent days starting from the most recent day |
2882 | 2882 | // that had any debates on). |
@@ -2938,17 +2938,17 @@ discard block |
||
2938 | 2938 | foreach ($q as $row) { |
2939 | 2939 | |
2940 | 2940 | // This array just used for getting further data about this debate. |
2941 | - $item_data = array ( |
|
2941 | + $item_data = array( |
|
2942 | 2942 | 'major' => $this->major, |
2943 | - 'gid' => fix_gid_from_db( $row['gid'] ), |
|
2943 | + 'gid' => fix_gid_from_db($row['gid']), |
|
2944 | 2944 | 'htype' => $row['htype'], |
2945 | 2945 | 'section_id' => $row['section_id'], |
2946 | 2946 | 'subsection_id' => $row['subsection_id'], |
2947 | 2947 | 'epobject_id' => $row['epobject_id'] |
2948 | 2948 | ); |
2949 | 2949 | |
2950 | - $list_url = $this->_get_listurl( $item_data ); |
|
2951 | - $totalcomments = $this->_get_comment_count_for_epobject( $item_data ); |
|
2950 | + $list_url = $this->_get_listurl($item_data); |
|
2951 | + $totalcomments = $this->_get_comment_count_for_epobject($item_data); |
|
2952 | 2952 | |
2953 | 2953 | $contentcount = $row['count']; |
2954 | 2954 | $body = $row['body']; |
@@ -2976,7 +2976,7 @@ discard block |
||
2976 | 2976 | LIMIT 1 |
2977 | 2977 | ")->first(); |
2978 | 2978 | $childbody = $r['body']; |
2979 | - $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major ); |
|
2979 | + $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major); |
|
2980 | 2980 | |
2981 | 2981 | $data[] = array( |
2982 | 2982 | 'contentcount' => $contentcount, |
@@ -2996,7 +2996,7 @@ discard block |
||
2996 | 2996 | |
2997 | 2997 | } |
2998 | 2998 | |
2999 | - $data = array ( |
|
2999 | + $data = array( |
|
3000 | 3000 | 'info' => array(), |
3001 | 3001 | 'data' => $data |
3002 | 3002 | ); |
@@ -3005,7 +3005,7 @@ discard block |
||
3005 | 3005 | |
3006 | 3006 | } |
3007 | 3007 | |
3008 | - public function _get_data_by_biggest_debates($args=array()) { |
|
3008 | + public function _get_data_by_biggest_debates($args = array()) { |
|
3009 | 3009 | // Returns an array of the debates with most speeches in from |
3010 | 3010 | // a set number of recent days (that's recent days starting from the |
3011 | 3011 | // most recent day that had any debates on). |
@@ -3060,17 +3060,17 @@ discard block |
||
3060 | 3060 | foreach ($q as $row) { |
3061 | 3061 | |
3062 | 3062 | // This array just used for getting further data about this debate. |
3063 | - $item_data = array ( |
|
3063 | + $item_data = array( |
|
3064 | 3064 | 'major' => $this->major, |
3065 | - 'gid' => fix_gid_from_db( $row['gid'] ), |
|
3065 | + 'gid' => fix_gid_from_db($row['gid']), |
|
3066 | 3066 | 'htype' => $row['htype'], |
3067 | 3067 | 'section_id' => $row['section_id'], |
3068 | 3068 | 'subsection_id' => $row['subsection_id'], |
3069 | 3069 | 'epobject_id' => $row['epobject_id'] |
3070 | 3070 | ); |
3071 | 3071 | |
3072 | - $list_url = $this->_get_listurl( $item_data ); |
|
3073 | - $totalcomments = $this->_get_comment_count_for_epobject( $item_data ); |
|
3072 | + $list_url = $this->_get_listurl($item_data); |
|
3073 | + $totalcomments = $this->_get_comment_count_for_epobject($item_data); |
|
3074 | 3074 | |
3075 | 3075 | $contentcount = $row['count']; |
3076 | 3076 | $body = $row['body']; |
@@ -3078,7 +3078,7 @@ discard block |
||
3078 | 3078 | |
3079 | 3079 | |
3080 | 3080 | // This array will be added to $data, which is what gets returned. |
3081 | - $debate = array ( |
|
3081 | + $debate = array( |
|
3082 | 3082 | 'contentcount' => $contentcount, |
3083 | 3083 | 'body' => $body, |
3084 | 3084 | 'hdate' => $hdate, |
@@ -3106,7 +3106,7 @@ discard block |
||
3106 | 3106 | LIMIT 1 |
3107 | 3107 | ")->first(); |
3108 | 3108 | $childbody = $r['body']; |
3109 | - $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major ); |
|
3109 | + $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major); |
|
3110 | 3110 | |
3111 | 3111 | $debate['child'] = array( |
3112 | 3112 | 'body' => $childbody, |
@@ -3116,7 +3116,7 @@ discard block |
||
3116 | 3116 | $data[] = $debate; |
3117 | 3117 | } |
3118 | 3118 | |
3119 | - $data = array ( |
|
3119 | + $data = array( |
|
3120 | 3120 | 'info' => array(), |
3121 | 3121 | 'data' => $data |
3122 | 3122 | ); |
@@ -3139,7 +3139,7 @@ discard block |
||
3139 | 3139 | return $q->first()['count']; |
3140 | 3140 | } |
3141 | 3141 | |
3142 | - public function _get_data_by_recent_wrans ($args=array()) { |
|
3142 | + public function _get_data_by_recent_wrans($args = array()) { |
|
3143 | 3143 | global $hansardmajors; |
3144 | 3144 | |
3145 | 3145 | // $args['days'] is the number of days back to look for biggest debates. |
@@ -3204,17 +3204,17 @@ discard block |
||
3204 | 3204 | |
3205 | 3205 | foreach ($q as $row) { |
3206 | 3206 | // This array just used for getting further data about this debate. |
3207 | - $item_data = array ( |
|
3207 | + $item_data = array( |
|
3208 | 3208 | 'major' => $this->major, |
3209 | - 'gid' => fix_gid_from_db( $row['gid'] ), |
|
3209 | + 'gid' => fix_gid_from_db($row['gid']), |
|
3210 | 3210 | 'htype' => $row['htype'], |
3211 | 3211 | 'section_id' => $row['section_id'], |
3212 | 3212 | 'subsection_id' => $row['subsection_id'], |
3213 | 3213 | 'epobject_id' => $row['epobject_id'] |
3214 | 3214 | ); |
3215 | 3215 | |
3216 | - $list_url = $this->_get_listurl( $item_data ); |
|
3217 | - $totalcomments = $this->_get_comment_count_for_epobject( $item_data ); |
|
3216 | + $list_url = $this->_get_listurl($item_data); |
|
3217 | + $totalcomments = $this->_get_comment_count_for_epobject($item_data); |
|
3218 | 3218 | |
3219 | 3219 | $body = $row['body']; |
3220 | 3220 | $hdate = $row['hdate']; |
@@ -3240,25 +3240,25 @@ discard block |
||
3240 | 3240 | LIMIT 1 |
3241 | 3241 | ")->first(); |
3242 | 3242 | $childbody = $r['body']; |
3243 | - $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major ); |
|
3243 | + $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major); |
|
3244 | 3244 | |
3245 | - $data[] = array ( |
|
3245 | + $data[] = array( |
|
3246 | 3246 | 'body' => $body, |
3247 | 3247 | 'hdate' => $hdate, |
3248 | 3248 | 'list_url' => $list_url, |
3249 | 3249 | 'totalcomments' => $totalcomments, |
3250 | - 'child' => array ( |
|
3250 | + 'child' => array( |
|
3251 | 3251 | 'body' => $childbody, |
3252 | 3252 | 'speaker' => $speaker |
3253 | 3253 | ), |
3254 | - 'parent' => array ( |
|
3254 | + 'parent' => array( |
|
3255 | 3255 | 'body' => $parentbody |
3256 | 3256 | ) |
3257 | 3257 | ); |
3258 | 3258 | |
3259 | 3259 | } |
3260 | 3260 | |
3261 | - $data = array ( |
|
3261 | + $data = array( |
|
3262 | 3262 | 'info' => array(), |
3263 | 3263 | 'data' => $data |
3264 | 3264 | ); |
@@ -3275,7 +3275,7 @@ discard block |
||
3275 | 3275 | public $commentspage = 'pbc_speech'; |
3276 | 3276 | public $gidprefix = 'uk.org.publicwhip/standing/'; |
3277 | 3277 | |
3278 | - public function __construct($session='', $title='') { |
|
3278 | + public function __construct($session = '', $title = '') { |
|
3279 | 3279 | parent::__construct(); |
3280 | 3280 | $this->bill_title = $title; |
3281 | 3281 | $title = str_replace(' ', '_', $title); |
@@ -3283,7 +3283,7 @@ discard block |
||
3283 | 3283 | } |
3284 | 3284 | |
3285 | 3285 | public function _get_committee($bill_id) { |
3286 | - include_once INCLUDESPATH."easyparliament/member.php"; |
|
3286 | + include_once INCLUDESPATH . "easyparliament/member.php"; |
|
3287 | 3287 | $q = $this->db->query( |
3288 | 3288 | 'select count(*) as c from hansard |
3289 | 3289 | where major=6 and minor=:bill_id and htype=10', |
@@ -3317,13 +3317,13 @@ discard block |
||
3317 | 3317 | public function _get_data_by_bill($args) { |
3318 | 3318 | global $DATA, $this_page; |
3319 | 3319 | $data = array(); |
3320 | - $input = array ( |
|
3321 | - 'amount' => array ( |
|
3320 | + $input = array( |
|
3321 | + 'amount' => array( |
|
3322 | 3322 | 'body' => true, |
3323 | 3323 | 'comment' => true, |
3324 | 3324 | 'excerpt' => true |
3325 | 3325 | ), |
3326 | - 'where' => array ( |
|
3326 | + 'where' => array( |
|
3327 | 3327 | 'htype=' => '10', |
3328 | 3328 | 'major=' => $this->major, |
3329 | 3329 | 'minor=' => $args['id'], |
@@ -3334,18 +3334,18 @@ discard block |
||
3334 | 3334 | if (count($sections) > 0) { |
3335 | 3335 | $data['rows'] = array(); |
3336 | 3336 | $num_sections = count($sections); |
3337 | - for ($n=0; $n<$num_sections; $n++) { |
|
3337 | + for ($n = 0; $n < $num_sections; $n++) { |
|
3338 | 3338 | $sectionrow = $sections[$n]; |
3339 | 3339 | list($sitting, $part) = $this->_get_sitting($sectionrow['gid']); |
3340 | 3340 | $sectionrow['sitting'] = $sitting; |
3341 | 3341 | $sectionrow['part'] = $part; |
3342 | - $input = array ( |
|
3343 | - 'amount' => array ( |
|
3342 | + $input = array( |
|
3343 | + 'amount' => array( |
|
3344 | 3344 | 'body' => true, |
3345 | 3345 | 'comment' => true, |
3346 | 3346 | 'excerpt' => true |
3347 | 3347 | ), |
3348 | - 'where' => array ( |
|
3348 | + 'where' => array( |
|
3349 | 3349 | 'section_id=' => $sectionrow['epobject_id'], |
3350 | 3350 | 'htype=' => '11', |
3351 | 3351 | 'major=' => $this->major |
@@ -3353,8 +3353,8 @@ discard block |
||
3353 | 3353 | 'order' => 'hpos' |
3354 | 3354 | ); |
3355 | 3355 | $rows = $this->_get_hansard_data($input); |
3356 | - array_unshift ($rows, $sectionrow); |
|
3357 | - $data['rows'] = array_merge ($data['rows'], $rows); |
|
3356 | + array_unshift($rows, $sectionrow); |
|
3357 | + $data['rows'] = array_merge($data['rows'], $rows); |
|
3358 | 3358 | } |
3359 | 3359 | } |
3360 | 3360 | $data['info']['bill'] = $args['title']; |
@@ -3410,8 +3410,8 @@ discard block |
||
3410 | 3410 | |
3411 | 3411 | $YEARURL = new \MySociety\TheyWorkForYou\Url('pbc_session'); |
3412 | 3412 | $nextprev = array(); |
3413 | - $nextprev['prev'] = array ('body' => 'Previous session', 'title'=>''); |
|
3414 | - $nextprev['next'] = array ('body' => 'Next session', 'title'=>''); |
|
3413 | + $nextprev['prev'] = array('body' => 'Previous session', 'title'=>''); |
|
3414 | + $nextprev['next'] = array('body' => 'Next session', 'title'=>''); |
|
3415 | 3415 | $q = $this->db->query( |
3416 | 3416 | "SELECT session FROM bills WHERE session < :session ORDER BY session DESC LIMIT 1", |
3417 | 3417 | array(':session' => $session) |
@@ -3448,13 +3448,13 @@ discard block |
||
3448 | 3448 | $session = $qq['session']; |
3449 | 3449 | list($sitting, $part) = $this->_get_sitting($gid); |
3450 | 3450 | $sitting_txt = make_ranking($sitting) . ' sitting'; |
3451 | - if ($part>0) { |
|
3451 | + if ($part > 0) { |
|
3452 | 3452 | $sitting .= ", part $part"; |
3453 | 3453 | } |
3454 | 3454 | $data[$hdate][] = array( |
3455 | 3455 | 'bill'=> $title, |
3456 | 3456 | 'sitting' => $sitting_txt, |
3457 | - 'url' => "/pbc/$session/" . urlencode(str_replace(' ','_',$title)) . '/#sitting' . $sitting, |
|
3457 | + 'url' => "/pbc/$session/" . urlencode(str_replace(' ', '_', $title)) . '/#sitting' . $sitting, |
|
3458 | 3458 | ); |
3459 | 3459 | } |
3460 | 3460 | return $data; |
@@ -3463,7 +3463,7 @@ discard block |
||
3463 | 3463 | # Given a GID, parse out the sitting number and optional part from it |
3464 | 3464 | public function _get_sitting($gid) { |
3465 | 3465 | if (preg_match('#_(\d\d)-(\d)_#', $gid, $m)) { |
3466 | - return array($m[1]+0, $m[2]); |
|
3466 | + return array($m[1] + 0, $m[2]); |
|
3467 | 3467 | } |
3468 | 3468 | return array(0, 0); |
3469 | 3469 | } |
@@ -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 { |
@@ -275,15 +275,15 @@ discard block |
||
275 | 275 | foreach ($merged as $row) { |
276 | 276 | $from_id = str_replace('uk.org.publicwhip/person/', '', $row['gid_from']); |
277 | 277 | $to_id = str_replace('uk.org.publicwhip/person/', '', $row['gid_to']); |
278 | - $qd = str_replace("(S$from_id OR S$to_id)", "S$to_id", $qd); |
|
279 | - $qd = str_replace("S$from_id OR S$to_id", "S$to_id", $qd); |
|
278 | + $qd = str_replace("(S$from_id OR S$to_id)", "s$to_id", $qd); |
|
279 | + $qd = str_replace("s$from_id OR S$to_id", "s$to_id", $qd); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | preg_match_all('#S(\d+)#', $qd, $m); |
283 | 283 | foreach ($m[1] as $mm) { |
284 | 284 | $member = new MEMBER(array('person_id' => $mm)); |
285 | 285 | $name = $member->full_name(); |
286 | - $qd = str_replace("S$mm", "speaker:$name", $qd); |
|
286 | + $qd = str_replace("s$mm", "speaker:$name", $qd); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | # Simplify display of excluded words |
@@ -344,7 +344,7 @@ |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | public function get_spelling_correction() { |
347 | - if (!defined('XAPIANDB') || !XAPIANDB) |
|
347 | + if (!defined('XAPIANDB') || !XAPIANDB) |
|
348 | 348 | return null; |
349 | 349 | |
350 | 350 | $qd = $this->queryparser->get_corrected_query_string(); |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | // Split words up into individual words, and quoted phrases |
97 | 97 | preg_match_all('/(' . |
98 | 98 | '"|' . # match either a quote, or... |
99 | - '(?:(?<![' .$this->wordchars. '])-)?' . # optionally a - (exclude) |
|
99 | + '(?:(?<![' . $this->wordchars . '])-)?' . # optionally a - (exclude) |
|
100 | 100 | # if at start of word (i.e. not preceded by a word character, in |
101 | 101 | # which case it is probably a hyphenated-word) |
102 | - '['.$this->wordchars.']+' . # followed by a string of word-characters |
|
102 | + '[' . $this->wordchars . ']+' . # followed by a string of word-characters |
|
103 | 103 | ')/', $this->query, $all_words); |
104 | 104 | if ($all_words) { |
105 | 105 | $all_words = $all_words[0]; |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | if (strpos($word, ':') !== false) { |
125 | 125 | $items = explode(":", strtolower($word)); |
126 | 126 | $type = $items[0]; |
127 | - if (substr($type, 0, 1)=='-') $type = substr($type, 1); |
|
128 | - $value = strtolower(join(":", array_slice($items,1))); |
|
127 | + if (substr($type, 0, 1) == '-') $type = substr($type, 1); |
|
128 | + $value = strtolower(join(":", array_slice($items, 1))); |
|
129 | 129 | if ($type == 'section') { |
130 | 130 | $newv = $value; |
131 | 131 | if ($value == 'debates' || $value == 'debate') $newv = 1; |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | elseif ($value == 'sp') $newv = 7; |
139 | 139 | elseif ($value == 'spwrans' || $value == 'spwran') $newv = 8; |
140 | 140 | elseif ($value == 'lmqs') $newv = 9; |
141 | - elseif ($value == 'uk') $newv = array(1,2,3,4,6,101); |
|
142 | - elseif ($value == 'scotland') $newv = array(7,8); |
|
141 | + elseif ($value == 'uk') $newv = array(1, 2, 3, 4, 6, 101); |
|
142 | + elseif ($value == 'scotland') $newv = array(7, 8); |
|
143 | 143 | elseif ($value == 'future') $newv = 'F'; |
144 | 144 | if (is_array($newv)) { |
145 | 145 | $newv = 'major:' . join(' major:', $newv); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $this->query .= " $from..$to"; |
174 | 174 | } elseif ($from) { |
175 | 175 | $this->query = str_ireplace("from:$from", '', $this->query); |
176 | - $this->query .= " $from..".date('Ymd'); |
|
176 | + $this->query .= " $from.." . date('Ymd'); |
|
177 | 177 | } elseif ($to) { |
178 | 178 | $this->query = str_ireplace("to:$to", '', $this->query); |
179 | 179 | $this->query .= " 19990101..$to"; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | twfy_debug("SEARCH", "prefixed: " . var_export($this->prefixed, true)); |
192 | 192 | |
193 | - twfy_debug("SEARCH", "query -- ". $this->query); |
|
193 | + twfy_debug("SEARCH", "query -- " . $this->query); |
|
194 | 194 | $flags = XapianQueryParser::FLAG_BOOLEAN | XapianQueryParser::FLAG_LOVEHATE | |
195 | 195 | XapianQueryParser::FLAG_WILDCARD | XapianQueryParser::FLAG_SPELLING_CORRECTION; |
196 | 196 | $flags = $flags | XapianQueryParser::FLAG_PHRASE; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | foreach ($m[1] as $phrase) { |
222 | 222 | $phrase_new = preg_replace('# PHRASE \d+#', '', $phrase); |
223 | 223 | #$this->phrases[] = preg_split('#\s+#', $phrase_new); |
224 | - $qd = str_replace("($phrase)", '"'.$phrase_new.'"', $qd); |
|
224 | + $qd = str_replace("($phrase)", '"' . $phrase_new . '"', $qd); |
|
225 | 225 | } |
226 | 226 | preg_match_all('#\(([^(]*? NEAR [^(]*?)\)#', $qd, $m); |
227 | 227 | foreach ($m[1] as $mm) { |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | } |
353 | 353 | |
354 | 354 | // Perform partial query to get a count of number of matches |
355 | - public function run_count($first_result, $results_per_page, $sort_order='relevance') { |
|
355 | + public function run_count($first_result, $results_per_page, $sort_order = 'relevance') { |
|
356 | 356 | if (!defined('XAPIANDB') || !XAPIANDB) |
357 | 357 | return null; |
358 | 358 | |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | #} |
426 | 426 | |
427 | 427 | $duration = getmicrotime() - $start; |
428 | - twfy_debug ("SEARCH", "Search count took $duration seconds."); |
|
428 | + twfy_debug("SEARCH", "Search count took $duration seconds."); |
|
429 | 429 | |
430 | 430 | return $count; |
431 | 431 | } |
432 | 432 | |
433 | 433 | // Perform the full search... |
434 | - public function run_search($first_result, $results_per_page, $sort_order='relevance') { |
|
434 | + public function run_search($first_result, $results_per_page, $sort_order = 'relevance') { |
|
435 | 435 | $start = getmicrotime(); |
436 | 436 | |
437 | 437 | #$matches = $this->enquire->get_mset($first_result, $results_per_page); |
@@ -452,13 +452,13 @@ discard block |
||
452 | 452 | array_push($this->created, join('', unpack('N', $doc->get_value(2)))); # XXX Needs fixing |
453 | 453 | } |
454 | 454 | twfy_debug("SEARCH", "gid: $gid relevancy: $relevancy% weight: $weight"); |
455 | - array_push($this->gids, "uk.org.publicwhip/".$gid); |
|
455 | + array_push($this->gids, "uk.org.publicwhip/" . $gid); |
|
456 | 456 | array_push($this->collapsed, $collapsed); |
457 | 457 | array_push($this->relevances, $relevancy); |
458 | 458 | $iter->next(); |
459 | 459 | } |
460 | 460 | $duration = getmicrotime() - $start; |
461 | - twfy_debug ("SEARCH", "Run search took $duration seconds."); |
|
461 | + twfy_debug("SEARCH", "Run search took $duration seconds."); |
|
462 | 462 | } |
463 | 463 | // ... use these to get the results |
464 | 464 | public function get_gids() { |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | $body = str_replace($this->specialchars, $this->specialchars_upper, $body); |
500 | 500 | $body = mb_convert_encoding($body, "UTF-8", "HTML-ENTITIES"); |
501 | 501 | $body = str_replace($this->specialchars_upper, $this->specialchars, $body); |
502 | - $splitextract = preg_split('/(<[^>]*>|[0-9,.]+|['.$this->wordcharsnodigit.']+)/', $body, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
502 | + $splitextract = preg_split('/(<[^>]*>|[0-9,.]+|[' . $this->wordcharsnodigit . ']+)/', $body, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
503 | 503 | $hlextract = ""; |
504 | 504 | foreach ($splitextract as $extractword) { |
505 | 505 | if (preg_match('/^<[^>]*>$/', $extractword)) { |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | */ |
548 | 548 | |
549 | 549 | foreach ($this->phrases as $phrase) { |
550 | - $phrasematch = join($phrase, '[^'.$this->wordchars.']+'); |
|
550 | + $phrasematch = join($phrase, '[^' . $this->wordchars . ']+'); |
|
551 | 551 | array_push($findwords, "/\b($phrasematch)\b(?!(?>[^<>]*>))/i"); |
552 | 552 | $replacewords[] = "<span class=\"hi\">\\1</span>"; |
553 | 553 | } |
@@ -565,12 +565,12 @@ discard block |
||
565 | 565 | |
566 | 566 | // look for phrases |
567 | 567 | foreach ($this->phrases as $phrase) { |
568 | - $phrasematch = join($phrase, '[^'.$this->wordchars.']+'); |
|
569 | - if (preg_match('/([^'.$this->wordchars.']' . $phrasematch . '[^A-Za-z0-9])/', $lcbody, $matches)) |
|
568 | + $phrasematch = join($phrase, '[^' . $this->wordchars . ']+'); |
|
569 | + if (preg_match('/([^' . $this->wordchars . ']' . $phrasematch . '[^A-Za-z0-9])/', $lcbody, $matches)) |
|
570 | 570 | { |
571 | - $wordpos = strpos( $lcbody, $matches[0] ); |
|
571 | + $wordpos = strpos($lcbody, $matches[0]); |
|
572 | 572 | if ($wordpos) { |
573 | - if ( ($wordpos < $pos) || ($pos==-1) ) { |
|
573 | + if (($wordpos < $pos) || ($pos == -1)) { |
|
574 | 574 | $pos = $wordpos; |
575 | 575 | } |
576 | 576 | } |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | } |
579 | 579 | if ($pos != -1) return $pos; |
580 | 580 | |
581 | - $splitextract = preg_split('/([0-9,.]+|['.$this->wordcharsnodigit.']+)/', $lcbody, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
581 | + $splitextract = preg_split('/([0-9,.]+|[' . $this->wordcharsnodigit . ']+)/', $lcbody, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
582 | 582 | $stemmed_words = array_map(array($this, 'stem'), $this->words); |
583 | 583 | foreach ($splitextract as $extractword) { |
584 | 584 | $extractword = preg_replace('/&$/', '', $extractword); |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | foreach ($stemmed_words as $word) { |
589 | 589 | if ($word == '') continue; |
590 | 590 | $matchword = $this->stem($extractword); |
591 | - if ($matchword == $word && ($wordpos < $pos || $pos==-1)) { |
|
591 | + if ($matchword == $word && ($wordpos < $pos || $pos == -1)) { |
|
592 | 592 | $pos = $wordpos; |
593 | 593 | } |
594 | 594 | } |
@@ -597,11 +597,11 @@ discard block |
||
597 | 597 | if ($pos != -1) return $pos; |
598 | 598 | |
599 | 599 | foreach ($this->words as $word) { |
600 | - if (ctype_digit($word)) $word = '(?:'.$word.'|'.number_format($word).')'; |
|
601 | - if (preg_match('/([^'.$this->wordchars.']' . $word . '[^'.$this->wordchars. '])/', $lcbody, $matches)) { |
|
602 | - $wordpos = strpos( $lcbody, $matches[0] ); |
|
600 | + if (ctype_digit($word)) $word = '(?:' . $word . '|' . number_format($word) . ')'; |
|
601 | + if (preg_match('/([^' . $this->wordchars . ']' . $word . '[^' . $this->wordchars . '])/', $lcbody, $matches)) { |
|
602 | + $wordpos = strpos($lcbody, $matches[0]); |
|
603 | 603 | if ($wordpos) { |
604 | - if ( ($wordpos < $pos) || ($pos==-1) ) { |
|
604 | + if (($wordpos < $pos) || ($pos == -1)) { |
|
605 | 605 | $pos = $wordpos; |
606 | 606 | } |
607 | 607 | } |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | if ($pos != -1) return $pos; |
612 | 612 | |
613 | 613 | foreach ($this->words as $word) { |
614 | - if (ctype_digit($word)) $word = '(?:'.$word.'|'.number_format($word).')'; |
|
614 | + if (ctype_digit($word)) $word = '(?:' . $word . '|' . number_format($word) . ')'; |
|
615 | 615 | if (preg_match('/(' . $word . ')/', $lcbody, $matches)) { |
616 | - $wordpos = strpos( $lcbody, $matches[0] ); |
|
616 | + $wordpos = strpos($lcbody, $matches[0]); |
|
617 | 617 | if ($wordpos) { |
618 | - if ( ($wordpos < $pos) || ($pos==-1) ) { |
|
618 | + if (($wordpos < $pos) || ($pos == -1)) { |
|
619 | 619 | $pos = $wordpos; |
620 | 620 | } |
621 | 621 | } |
@@ -38,8 +38,9 @@ discard block |
||
38 | 38 | public $error; |
39 | 39 | |
40 | 40 | public function __construct($query) { |
41 | - if (!defined('XAPIANDB') || !XAPIANDB) |
|
42 | - return null; |
|
41 | + if (!defined('XAPIANDB') || !XAPIANDB) { |
|
42 | + return null; |
|
43 | + } |
|
43 | 44 | |
44 | 45 | global $xapiandb, $PAGE; |
45 | 46 | if (!$xapiandb) { |
@@ -54,8 +55,12 @@ discard block |
||
54 | 55 | } |
55 | 56 | } |
56 | 57 | $this->query = $query; |
57 | - if (!isset($this->stemmer)) $this->stemmer = new XapianStem('english'); |
|
58 | - if (!isset($this->enquire)) $this->enquire = new XapianEnquire($xapiandb); |
|
58 | + if (!isset($this->stemmer)) { |
|
59 | + $this->stemmer = new XapianStem('english'); |
|
60 | + } |
|
61 | + if (!isset($this->enquire)) { |
|
62 | + $this->enquire = new XapianEnquire($xapiandb); |
|
63 | + } |
|
59 | 64 | if (!isset($this->queryparser)) { |
60 | 65 | $this->queryparser = new XapianQueryParser(); |
61 | 66 | $this->datevaluerange = new XapianDateValueRangeProcessor(1); |
@@ -111,7 +116,9 @@ discard block |
||
111 | 116 | foreach ($all_words as $word) { |
112 | 117 | if ($word == '"') { |
113 | 118 | $in_quote = !$in_quote; |
114 | - if ($in_quote) array_push($this->phrases, array()); |
|
119 | + if ($in_quote) { |
|
120 | + array_push($this->phrases, array()); |
|
121 | + } |
|
115 | 122 | if (!$in_quote && !count($this->phrases[count($this->phrases) - 1])) { |
116 | 123 | array_pop($this->phrases); |
117 | 124 | } |
@@ -124,23 +131,39 @@ discard block |
||
124 | 131 | if (strpos($word, ':') !== false) { |
125 | 132 | $items = explode(":", strtolower($word)); |
126 | 133 | $type = $items[0]; |
127 | - if (substr($type, 0, 1)=='-') $type = substr($type, 1); |
|
134 | + if (substr($type, 0, 1)=='-') { |
|
135 | + $type = substr($type, 1); |
|
136 | + } |
|
128 | 137 | $value = strtolower(join(":", array_slice($items,1))); |
129 | 138 | if ($type == 'section') { |
130 | 139 | $newv = $value; |
131 | - if ($value == 'debates' || $value == 'debate') $newv = 1; |
|
132 | - elseif ($value == 'whall' || $value == 'westminster' || $value == 'westminhall') $newv = 2; |
|
133 | - elseif ($value == 'wrans' || $value == 'wran') $newv = 3; |
|
134 | - elseif ($value == 'wms' || $value == 'statements' || $value == 'statement') $newv = 4; |
|
135 | - elseif ($value == 'lordsdebates' || $value == 'lords') $newv = 101; |
|
136 | - elseif ($value == 'ni' || $value == 'nidebates') $newv = 5; |
|
137 | - elseif ($value == 'pbc' || $value == 'standing') $newv = 6; |
|
138 | - elseif ($value == 'sp') $newv = 7; |
|
139 | - elseif ($value == 'spwrans' || $value == 'spwran') $newv = 8; |
|
140 | - elseif ($value == 'lmqs') $newv = 9; |
|
141 | - elseif ($value == 'uk') $newv = array(1,2,3,4,6,101); |
|
142 | - elseif ($value == 'scotland') $newv = array(7,8); |
|
143 | - elseif ($value == 'future') $newv = 'F'; |
|
140 | + if ($value == 'debates' || $value == 'debate') { |
|
141 | + $newv = 1; |
|
142 | + } elseif ($value == 'whall' || $value == 'westminster' || $value == 'westminhall') { |
|
143 | + $newv = 2; |
|
144 | + } elseif ($value == 'wrans' || $value == 'wran') { |
|
145 | + $newv = 3; |
|
146 | + } elseif ($value == 'wms' || $value == 'statements' || $value == 'statement') { |
|
147 | + $newv = 4; |
|
148 | + } elseif ($value == 'lordsdebates' || $value == 'lords') { |
|
149 | + $newv = 101; |
|
150 | + } elseif ($value == 'ni' || $value == 'nidebates') { |
|
151 | + $newv = 5; |
|
152 | + } elseif ($value == 'pbc' || $value == 'standing') { |
|
153 | + $newv = 6; |
|
154 | + } elseif ($value == 'sp') { |
|
155 | + $newv = 7; |
|
156 | + } elseif ($value == 'spwrans' || $value == 'spwran') { |
|
157 | + $newv = 8; |
|
158 | + } elseif ($value == 'lmqs') { |
|
159 | + $newv = 9; |
|
160 | + } elseif ($value == 'uk') { |
|
161 | + $newv = array(1,2,3,4,6,101); |
|
162 | + } elseif ($value == 'scotland') { |
|
163 | + $newv = array(7,8); |
|
164 | + } elseif ($value == 'future') { |
|
165 | + $newv = 'F'; |
|
166 | + } |
|
144 | 167 | if (is_array($newv)) { |
145 | 168 | $newv = 'major:' . join(' major:', $newv); |
146 | 169 | } else { |
@@ -149,8 +172,12 @@ discard block |
||
149 | 172 | $this->query = str_ireplace("$type:$value", $newv, $this->query); |
150 | 173 | } elseif ($type == 'groupby') { |
151 | 174 | $newv = $value; |
152 | - if ($value == 'debates' || $value == 'debate') $newv = 'debate'; |
|
153 | - if ($value == 'speech' || $value == 'speeches') $newv = 'speech'; |
|
175 | + if ($value == 'debates' || $value == 'debate') { |
|
176 | + $newv = 'debate'; |
|
177 | + } |
|
178 | + if ($value == 'speech' || $value == 'speeches') { |
|
179 | + $newv = 'speech'; |
|
180 | + } |
|
154 | 181 | $this->query = str_ireplace("$type:$value", '', $this->query); |
155 | 182 | array_push($this->prefixed, array($type, $newv)); |
156 | 183 | } elseif ($type == 'from') { |
@@ -265,7 +292,9 @@ discard block |
||
265 | 292 | $end = $this->queryparser->unstem_end($mm); |
266 | 293 | while (!$iter->equals($end)) { |
267 | 294 | $tt = $iter->get_term(); |
268 | - if (!in_array($tt, $used)) break; |
|
295 | + if (!in_array($tt, $used)) { |
|
296 | + break; |
|
297 | + } |
|
269 | 298 | $iter->next(); |
270 | 299 | } |
271 | 300 | $used[] = $tt; |
@@ -344,8 +373,9 @@ discard block |
||
344 | 373 | } |
345 | 374 | |
346 | 375 | public function get_spelling_correction() { |
347 | - if (!defined('XAPIANDB') || !XAPIANDB) |
|
348 | - return null; |
|
376 | + if (!defined('XAPIANDB') || !XAPIANDB) { |
|
377 | + return null; |
|
378 | + } |
|
349 | 379 | |
350 | 380 | $qd = $this->queryparser->get_corrected_query_string(); |
351 | 381 | return $qd; |
@@ -353,8 +383,9 @@ discard block |
||
353 | 383 | |
354 | 384 | // Perform partial query to get a count of number of matches |
355 | 385 | public function run_count($first_result, $results_per_page, $sort_order='relevance') { |
356 | - if (!defined('XAPIANDB') || !XAPIANDB) |
|
357 | - return null; |
|
386 | + if (!defined('XAPIANDB') || !XAPIANDB) { |
|
387 | + return null; |
|
388 | + } |
|
358 | 389 | |
359 | 390 | $start = getmicrotime(); |
360 | 391 | |
@@ -384,16 +415,18 @@ discard block |
||
384 | 415 | $collapsed = true; |
385 | 416 | if ($items[1] == 'speech') |
386 | 417 | ; // no collapse key |
387 | - elseif ($items[1] == 'debate') |
|
388 | - $this->enquire->set_collapse_key(3); |
|
389 | - else |
|
390 | - $PAGE->error_message("Unknown group by '$items[1]' ignored"); |
|
418 | + elseif ($items[1] == 'debate') { |
|
419 | + $this->enquire->set_collapse_key(3); |
|
420 | + } else { |
|
421 | + $PAGE->error_message("Unknown group by '$items[1]' ignored"); |
|
422 | + } |
|
391 | 423 | } |
392 | 424 | } |
393 | 425 | |
394 | 426 | // default to grouping by subdebate, i.e. by page |
395 | - if (!$collapsed) |
|
396 | - $this->enquire->set_collapse_key(3); |
|
427 | + if (!$collapsed) { |
|
428 | + $this->enquire->set_collapse_key(3); |
|
429 | + } |
|
397 | 430 | |
398 | 431 | /* |
399 | 432 | XXX Helping to debug possible Xapian bug |
@@ -473,8 +506,9 @@ discard block |
||
473 | 506 | |
474 | 507 | // Puts HTML highlighting round all the matching words in the text |
475 | 508 | public function highlight($body) { |
476 | - if (!defined('XAPIANDB') || !XAPIANDB) |
|
477 | - return $body; |
|
509 | + if (!defined('XAPIANDB') || !XAPIANDB) { |
|
510 | + return $body; |
|
511 | + } |
|
478 | 512 | |
479 | 513 | $stemmed_words = array_map(array($this, 'stem'), $this->words); |
480 | 514 | if (is_array($body)) { |
@@ -492,8 +526,9 @@ discard block |
||
492 | 526 | private $specialchars_upper = array('<', '>', '"', '&'); |
493 | 527 | |
494 | 528 | public function highlight_internal($body, $stemmed_words) { |
495 | - if (!defined('XAPIANDB') || !XAPIANDB) |
|
496 | - return $body; |
|
529 | + if (!defined('XAPIANDB') || !XAPIANDB) { |
|
530 | + return $body; |
|
531 | + } |
|
497 | 532 | |
498 | 533 | # Does html_entity_decode without the htmlspecialchars |
499 | 534 | $body = str_replace($this->specialchars, $this->specialchars_upper, $body); |
@@ -514,7 +549,9 @@ discard block |
||
514 | 549 | $hl = false; |
515 | 550 | $matchword = $this->stem($extractword); |
516 | 551 | foreach ($stemmed_words as $word) { |
517 | - if ($word == '') continue; |
|
552 | + if ($word == '') { |
|
553 | + continue; |
|
554 | + } |
|
518 | 555 | if ($matchword == $word) { |
519 | 556 | $hl = true; |
520 | 557 | break; |
@@ -566,8 +603,7 @@ discard block |
||
566 | 603 | // look for phrases |
567 | 604 | foreach ($this->phrases as $phrase) { |
568 | 605 | $phrasematch = join($phrase, '[^'.$this->wordchars.']+'); |
569 | - if (preg_match('/([^'.$this->wordchars.']' . $phrasematch . '[^A-Za-z0-9])/', $lcbody, $matches)) |
|
570 | - { |
|
606 | + if (preg_match('/([^'.$this->wordchars.']' . $phrasematch . '[^A-Za-z0-9])/', $lcbody, $matches)) { |
|
571 | 607 | $wordpos = strpos( $lcbody, $matches[0] ); |
572 | 608 | if ($wordpos) { |
573 | 609 | if ( ($wordpos < $pos) || ($pos==-1) ) { |
@@ -576,17 +612,25 @@ discard block |
||
576 | 612 | } |
577 | 613 | } |
578 | 614 | } |
579 | - if ($pos != -1) return $pos; |
|
615 | + if ($pos != -1) { |
|
616 | + return $pos; |
|
617 | + } |
|
580 | 618 | |
581 | 619 | $splitextract = preg_split('/([0-9,.]+|['.$this->wordcharsnodigit.']+)/', $lcbody, -1, PREG_SPLIT_DELIM_CAPTURE); |
582 | 620 | $stemmed_words = array_map(array($this, 'stem'), $this->words); |
583 | 621 | foreach ($splitextract as $extractword) { |
584 | 622 | $extractword = preg_replace('/&$/', '', $extractword); |
585 | - if (!$extractword) continue; |
|
623 | + if (!$extractword) { |
|
624 | + continue; |
|
625 | + } |
|
586 | 626 | $wordpos = strpos($lcbody, $extractword); |
587 | - if (!$wordpos) continue; |
|
627 | + if (!$wordpos) { |
|
628 | + continue; |
|
629 | + } |
|
588 | 630 | foreach ($stemmed_words as $word) { |
589 | - if ($word == '') continue; |
|
631 | + if ($word == '') { |
|
632 | + continue; |
|
633 | + } |
|
590 | 634 | $matchword = $this->stem($extractword); |
591 | 635 | if ($matchword == $word && ($wordpos < $pos || $pos==-1)) { |
592 | 636 | $pos = $wordpos; |
@@ -594,10 +638,14 @@ discard block |
||
594 | 638 | } |
595 | 639 | } |
596 | 640 | // only look for earlier words if phrases weren't found |
597 | - if ($pos != -1) return $pos; |
|
641 | + if ($pos != -1) { |
|
642 | + return $pos; |
|
643 | + } |
|
598 | 644 | |
599 | 645 | foreach ($this->words as $word) { |
600 | - if (ctype_digit($word)) $word = '(?:'.$word.'|'.number_format($word).')'; |
|
646 | + if (ctype_digit($word)) { |
|
647 | + $word = '(?:'.$word.'|'.number_format($word).')'; |
|
648 | + } |
|
601 | 649 | if (preg_match('/([^'.$this->wordchars.']' . $word . '[^'.$this->wordchars. '])/', $lcbody, $matches)) { |
602 | 650 | $wordpos = strpos( $lcbody, $matches[0] ); |
603 | 651 | if ($wordpos) { |
@@ -608,10 +656,14 @@ discard block |
||
608 | 656 | } |
609 | 657 | } |
610 | 658 | // only look for something containing the word (ie. something stemmed, but doesn't work all the time) if no whole word was found |
611 | - if ($pos != -1) return $pos; |
|
659 | + if ($pos != -1) { |
|
660 | + return $pos; |
|
661 | + } |
|
612 | 662 | |
613 | 663 | foreach ($this->words as $word) { |
614 | - if (ctype_digit($word)) $word = '(?:'.$word.'|'.number_format($word).')'; |
|
664 | + if (ctype_digit($word)) { |
|
665 | + $word = '(?:'.$word.'|'.number_format($word).')'; |
|
666 | + } |
|
615 | 667 | if (preg_match('/(' . $word . ')/', $lcbody, $matches)) { |
616 | 668 | $wordpos = strpos( $lcbody, $matches[0] ); |
617 | 669 | if ($wordpos) { |
@@ -622,8 +674,9 @@ discard block |
||
622 | 674 | } |
623 | 675 | } |
624 | 676 | |
625 | - if ($pos == -1) |
|
626 | - $pos = 0; |
|
677 | + if ($pos == -1) { |
|
678 | + $pos = 0; |
|
679 | + } |
|
627 | 680 | |
628 | 681 | return $pos; |
629 | 682 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $divisions_to_link = array(); |
4 | -foreach($data['rows'] as $speech) { |
|
4 | +foreach ($data['rows'] as $speech) { |
|
5 | 5 | |
6 | 6 | # Only care about divisions... |
7 | 7 | if ($speech['htype'] != 14) { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | <li><a href="#g<?= gid_to_anchor($speech['gid']) ?>">Division number <?= $division['number'] ?></a> |
35 | 35 | <?php if ($division['has_description']) { ?> |
36 | 36 | <br><span class="policy-vote__text"> |
37 | - <?php include( dirname(__FILE__) . '/../divisions/_vote_description.php'); ?> |
|
37 | + <?php include(dirname(__FILE__) . '/../divisions/_vote_description.php'); ?> |
|
38 | 38 | </span> |
39 | 39 | <?php } ?> |
40 | 40 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $data = $this->_get_data_by_group($args); |
37 | 37 | |
38 | 38 | $user = new User(); |
39 | - if ( $reps = $this->getRegionalReps($user) ) { |
|
39 | + if ($reps = $this->getRegionalReps($user)) { |
|
40 | 40 | $data['reps'] = $reps; |
41 | 41 | } |
42 | 42 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $args['all'] = true; |
69 | 69 | } |
70 | 70 | |
71 | - if ( $this->type == 'peers' ) { |
|
71 | + if ($this->type == 'peers') { |
|
72 | 72 | $args['order'] = 'name'; |
73 | 73 | } |
74 | 74 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | |
135 | 135 | private function addImagesToData($data) { |
136 | 136 | $new_data = array(); |
137 | - foreach ( $data as $pid => $details ) { |
|
138 | - list($image, ) = Utility\Member::findMemberImage($pid, true, $this->subs_missing_image); |
|
137 | + foreach ($data as $pid => $details) { |
|
138 | + list($image,) = Utility\Member::findMemberImage($pid, true, $this->subs_missing_image); |
|
139 | 139 | $details['image'] = $image; |
140 | 140 | $new_data[$pid] = $details; |
141 | 141 | } |
@@ -152,21 +152,21 @@ discard block |
||
152 | 152 | |
153 | 153 | $urls['plain'] = $URL->generate(); |
154 | 154 | |
155 | - $URL->insert(array( 'o' => 'n')); |
|
155 | + $URL->insert(array('o' => 'n')); |
|
156 | 156 | $urls['by_name'] = $URL->generate(); |
157 | 157 | |
158 | - $URL->insert(array( 'o' => 'l')); |
|
158 | + $URL->insert(array('o' => 'l')); |
|
159 | 159 | $urls['by_last'] = $URL->generate(); |
160 | 160 | |
161 | - $URL->insert(array( 'o' => 'f')); |
|
161 | + $URL->insert(array('o' => 'f')); |
|
162 | 162 | $urls['by_first'] = $URL->generate(); |
163 | 163 | |
164 | - $URL->insert(array( 'o' => 'p')); |
|
164 | + $URL->insert(array('o' => 'p')); |
|
165 | 165 | $urls['by_party'] = $URL->generate(); |
166 | 166 | |
167 | - $URL->insert(array( 'f' => 'csv')); |
|
168 | - $URL->remove(array( 'o')); |
|
169 | - if ( $date = get_http_var('date') ) { |
|
167 | + $URL->insert(array('f' => 'csv')); |
|
168 | + $URL->remove(array('o')); |
|
169 | + if ($date = get_http_var('date')) { |
|
170 | 170 | $URL->insert(array('date' => $date)); |
171 | 171 | } |
172 | 172 | $urls['by_csv'] = $URL->generate(); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $name = member_full_name($this->house, $row['title'], $row['given_name'], $row['family_name'], $row['lordofname']); |
243 | 243 | $constituency = $row['constituency']; |
244 | 244 | $url = make_member_url($name, $constituency, $this->house, $p_id); |
245 | - $narray = array ( |
|
245 | + $narray = array( |
|
246 | 246 | 'person_id' => $p_id, |
247 | 247 | 'given_name' => $row['given_name'], |
248 | 248 | 'family_name' => $row['family_name'], |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | uasort($data, 'by_peer_name'); |
277 | 277 | } |
278 | 278 | |
279 | - $data = array ( |
|
280 | - 'info' => array ( |
|
279 | + $data = array( |
|
280 | + 'info' => array( |
|
281 | 281 | 'order' => $order |
282 | 282 | ), |
283 | 283 | 'data' => $data |
@@ -1,4 +1,4 @@ |
||
1 | -<?php if ( count($divisions) > 0 ) { ?> |
|
1 | +<?php if (count($divisions) > 0) { ?> |
|
2 | 2 | <h2 style="position: relative;"> |
3 | 3 | Recent Votes |
4 | 4 | <div class="meta excerpt__category"><a href="/divisions/">Show all recent votes</a></div> |
@@ -9,7 +9,7 @@ |
||
9 | 9 | remove_form(); |
10 | 10 | list_ignored(); |
11 | 11 | $PAGE->stripe_end([ |
12 | - [ 'type' => 'html', 'content' => $PAGE->admin_menu() ], |
|
12 | + ['type' => 'html', 'content' => $PAGE->admin_menu()], |
|
13 | 13 | ]); |
14 | 14 | $PAGE->page_end(); |
15 | 15 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (!function_exists('print_voter')) { |
4 | - function print_voter($vote){ |
|
4 | + function print_voter($vote) { |
|
5 | 5 | echo sprintf( |
6 | 6 | '<li><a href="/mp/?p=%d">%s</a> <span class="party">%s%s</span></li>', |
7 | 7 | $vote['person_id'], |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | <?php if (count($tellers) > 0) { ?> |
29 | 29 | <h4>Tellers</h4> |
30 | 30 | <ul class="division-names"> |
31 | - <?php foreach($tellers as $teller) { |
|
31 | + <?php foreach ($tellers as $teller) { |
|
32 | 32 | print_voter($teller); |
33 | 33 | } ?> |
34 | 34 | </p> |
@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (!function_exists('print_voter')) { |
4 | - function print_voter($vote){ |
|
4 | + function print_voter($vote){ |
|
5 | 5 | echo sprintf( |
6 | - '<li><a href="/mp/?p=%d">%s</a> <span class="party">%s%s</span></li>', |
|
7 | - $vote['person_id'], |
|
8 | - $vote['name'], |
|
9 | - $vote['party'], |
|
10 | - $vote['proxy'] ? " (proxy vote cast by $vote[proxy])" : '' |
|
6 | + '<li><a href="/mp/?p=%d">%s</a> <span class="party">%s%s</span></li>', |
|
7 | + $vote['person_id'], |
|
8 | + $vote['name'], |
|
9 | + $vote['party'], |
|
10 | + $vote['proxy'] ? " (proxy vote cast by $vote[proxy])" : '' |
|
11 | 11 | ); |
12 | - } |
|
12 | + } |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | if (count($votes) > 0) { ?> |
@@ -18,18 +18,18 @@ discard block |
||
18 | 18 | <?php $tellers = array(); ?> |
19 | 19 | <ul class="division-names js-vote-accordion"> |
20 | 20 | <?php foreach ($votes as $vote) { |
21 | - if ($vote['teller']) { |
|
22 | - $tellers[] = $vote; |
|
23 | - } else { |
|
21 | + if ($vote['teller']) { |
|
22 | + $tellers[] = $vote; |
|
23 | + } else { |
|
24 | 24 | print_voter($vote); |
25 | - } |
|
25 | + } |
|
26 | 26 | } ?> |
27 | 27 | </ul> |
28 | 28 | <?php if (count($tellers) > 0) { ?> |
29 | 29 | <h4>Tellers</h4> |
30 | 30 | <ul class="division-names"> |
31 | 31 | <?php foreach($tellers as $teller) { |
32 | - print_voter($teller); |
|
32 | + print_voter($teller); |
|
33 | 33 | } ?> |
34 | 34 | </p> |
35 | 35 | <?php } ?> |