@@ -18,10 +18,13 @@ |
||
18 | 18 | # Content goes here |
19 | 19 | foreach ($data['dates'] as $date => $day_events) { |
20 | 20 | foreach ($order as $i => $chamber) { |
21 | - if (!array_key_exists($chamber, $day_events)) |
|
22 | - continue; |
|
21 | + if (!array_key_exists($chamber, $day_events)) { |
|
22 | + continue; |
|
23 | + } |
|
23 | 24 | $events = $day_events[$chamber]; |
24 | - if ($plural[$i]) $chamber .= 's'; |
|
25 | + if ($plural[$i]) { |
|
26 | + $chamber .= 's'; |
|
27 | + } |
|
25 | 28 | print "<h2 class='calendar'>$chamber"; |
26 | 29 | if (in_array($major[$i], $data['majors'])) { |
27 | 30 | $URL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$major[$i]]['page_all']); |
@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | } |
19 | 19 | $PAGE->block_start(array('id'=>'recentcomments', 'title'=>$title)); |
20 | 20 | |
21 | - if ($this_page != 'home') $PAGE->page_links($data); |
|
21 | + if ($this_page != 'home') { |
|
22 | + $PAGE->page_links($data); |
|
23 | + } |
|
22 | 24 | $USERURL = new \MySociety\TheyWorkForYou\Url('userview'); |
23 | 25 | ?> |
24 | 26 | <ul> |
@@ -50,7 +52,9 @@ discard block |
||
50 | 52 | <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments'])+1; ?>">See more annotations posted recently</a></p> |
51 | 53 | <?php |
52 | 54 | } |
53 | - if ($this_page != 'home') $PAGE->page_links($data); |
|
55 | + if ($this_page != 'home') { |
|
56 | + $PAGE->page_links($data); |
|
57 | + } |
|
54 | 58 | $PAGE->block_end(); |
55 | 59 | } |
56 | 60 | ?> |
@@ -177,7 +177,8 @@ discard block |
||
177 | 177 | $data = preg_replace("/<([^>]*?)(?=<|$)/", "<$1>", $data); |
178 | 178 | $data = preg_replace("/(^|>)([^<]*?)(?=>)/", "$1<$2", $data); |
179 | 179 | |
180 | - } else { |
|
180 | + } |
|
181 | + else { |
|
181 | 182 | |
182 | 183 | # |
183 | 184 | # escape stray brackets |
@@ -231,7 +232,8 @@ discard block |
||
231 | 232 | return '</'.$name.'>'; |
232 | 233 | } |
233 | 234 | } |
234 | - } else { |
|
235 | + } |
|
236 | + else { |
|
235 | 237 | return ''; |
236 | 238 | } |
237 | 239 | } |
@@ -268,7 +270,8 @@ discard block |
||
268 | 270 | if (!$ending) { |
269 | 271 | if (isset($this->tag_counts[$name])) { |
270 | 272 | $this->tag_counts[$name]++; |
271 | - } else { |
|
273 | + } |
|
274 | + else { |
|
272 | 275 | $this->tag_counts[$name] = 1; |
273 | 276 | } |
274 | 277 | } |
@@ -276,7 +279,8 @@ discard block |
||
276 | 279 | $ending = ' /'; |
277 | 280 | } |
278 | 281 | return '<'.$name.$params.$ending.'>'; |
279 | - } else { |
|
282 | + } |
|
283 | + else { |
|
280 | 284 | return ''; |
281 | 285 | } |
282 | 286 | } |
@@ -285,7 +289,8 @@ discard block |
||
285 | 289 | if (preg_match("/^!--(.*)--$/si", $data)) { |
286 | 290 | if ($this->strip_comments) { |
287 | 291 | return ''; |
288 | - } else { |
|
292 | + } |
|
293 | + else { |
|
289 | 294 | return '<'.$data.'>'; |
290 | 295 | } |
291 | 296 | } |
@@ -324,7 +329,9 @@ discard block |
||
324 | 329 | while (1) { |
325 | 330 | $len = strlen($data); |
326 | 331 | $data = preg_replace("/<({$tags})(\s[^>]*)?(><\\/\\1>|\\/>)/", '', $data); |
327 | - if ($len == strlen($data)) break; |
|
332 | + if ($len == strlen($data)) { |
|
333 | + break; |
|
334 | + } |
|
328 | 335 | } |
329 | 336 | } |
330 | 337 |
@@ -112,7 +112,8 @@ discard block |
||
112 | 112 | |
113 | 113 | if (is_int($paramValue)) { |
114 | 114 | $paramType = \PDO::PARAM_INT; |
115 | - } else { |
|
115 | + } |
|
116 | + else { |
|
116 | 117 | $paramType = \PDO::PARAM_STR; |
117 | 118 | } |
118 | 119 | |
@@ -121,7 +122,8 @@ discard block |
||
121 | 122 | |
122 | 123 | $pdoStatement->execute(); |
123 | 124 | |
124 | - } else { |
|
125 | + } |
|
126 | + else { |
|
125 | 127 | // Execute the raw query |
126 | 128 | $pdoStatement = $this->conn->query($sql); |
127 | 129 | } |
@@ -131,13 +133,16 @@ discard block |
||
131 | 133 | $this->error($this->conn->errorCode() . ': ' . $this->conn->errorInfo()[2]); |
132 | 134 | } |
133 | 135 | |
134 | - if (!$this->success) return; |
|
136 | + if (!$this->success) { |
|
137 | + return; |
|
138 | + } |
|
135 | 139 | |
136 | 140 | if ( (!$pdoStatement) or (empty($pdoStatement)) ) { |
137 | 141 | // A failed query. |
138 | 142 | $this->success = false; |
139 | 143 | |
140 | - } else { |
|
144 | + } |
|
145 | + else { |
|
141 | 146 | |
142 | 147 | // A successful SELECT, SHOW, EXPLAIN or DESCRIBE query. |
143 | 148 | $this->success = true; |
@@ -150,7 +155,8 @@ discard block |
||
150 | 155 | // Sanity check that lastInsertId() is actually a number, otherwise panic |
151 | 156 | if (is_numeric($this->conn->lastInsertId())) { |
152 | 157 | $this->insert_id = (int) $this->conn->lastInsertId(); |
153 | - } else { |
|
158 | + } |
|
159 | + else { |
|
154 | 160 | throw new Exception('Last connection ID was not numeric!'); |
155 | 161 | } |
156 | 162 | $this->affected_rows = $pdoStatement->rowCount(); |
@@ -176,8 +182,9 @@ discard block |
||
176 | 182 | |
177 | 183 | // After SELECT. |
178 | 184 | public function field($row_index, $column_name) { |
179 | - if ($this->rows > 0) |
|
180 | - return $this->data[$row_index][$column_name]; |
|
185 | + if ($this->rows > 0) { |
|
186 | + return $this->data[$row_index][$column_name]; |
|
187 | + } |
|
181 | 188 | return ""; |
182 | 189 | } |
183 | 190 | |
@@ -188,8 +195,9 @@ discard block |
||
188 | 195 | |
189 | 196 | // After SELECT. |
190 | 197 | public function row($row_index) { |
191 | - if ($this->success && $this->rows > 0) |
|
192 | - return $this->data[$row_index]; |
|
198 | + if ($this->success && $this->rows > 0) { |
|
199 | + return $this->data[$row_index]; |
|
200 | + } |
|
193 | 201 | return array(); |
194 | 202 | } |
195 | 203 | |
@@ -212,7 +220,8 @@ discard block |
||
212 | 220 | if ($n == "email" || $n == "password" || $n == "postcode") { |
213 | 221 | // Don't want to risk this data being displayed on any page. |
214 | 222 | $html .= "<td>**MASKED**</td>"; |
215 | - } else { |
|
223 | + } |
|
224 | + else { |
|
216 | 225 | $html .= "<td>" . _htmlentities($field) . "</td>"; |
217 | 226 | } |
218 | 227 | } |
@@ -32,7 +32,8 @@ |
||
32 | 32 | $URL = new \MySociety\TheyWorkForYou\Url('member'); |
33 | 33 | $URL->insert(array('id'=>$row['speaker']['member_id'])); |
34 | 34 | $member = '<a href="' . $URL->generate() . '">' . $row['speaker']['name'] . '</a>: '; |
35 | - } else { |
|
35 | + } |
|
36 | + else { |
|
36 | 37 | $member = ''; |
37 | 38 | } |
38 | 39 | ?> |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | $LOGINURL->insert(array('ret' => $THISPAGE->generate('none') )); |
56 | 56 | |
57 | 57 | $text = "<a href=\"" . $LOGINURL->generate() . "\">You'd better sign in!</a>"; |
58 | - } else { |
|
58 | + } |
|
59 | + else { |
|
59 | 60 | $text = "That's all folks!"; |
60 | 61 | } |
61 | 62 | $this_page = 'home'; |
@@ -88,7 +89,8 @@ discard block |
||
88 | 89 | public function within_stripe() { |
89 | 90 | if ($this->within_stripe_main == true || $this->within_stripe_sidebar == true) { |
90 | 91 | return true; |
91 | - } else { |
|
92 | + } |
|
93 | + else { |
|
92 | 94 | return false; |
93 | 95 | } |
94 | 96 | } |
@@ -96,7 +98,8 @@ discard block |
||
96 | 98 | public function within_stripe_sidebar() { |
97 | 99 | if ($this->within_stripe_sidebar == true) { |
98 | 100 | return true; |
99 | - } else { |
|
101 | + } |
|
102 | + else { |
|
100 | 103 | return false; |
101 | 104 | } |
102 | 105 | } |
@@ -114,7 +117,10 @@ discard block |
||
114 | 117 | // 'foot' - For the bottom stripe on hansard debates/wrans listings. |
115 | 118 | // $id is the value of an id for this div (if blank, not used). |
116 | 119 | ?> |
117 | - <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') echo ' ' . $extra_class; ?>"<?php |
|
120 | + <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') { |
|
121 | + echo ' ' . $extra_class; |
|
122 | +} |
|
123 | +?>"<?php |
|
118 | 124 | if ($id != '') { |
119 | 125 | print ' id="' . $id . '"'; |
120 | 126 | } |
@@ -192,20 +198,24 @@ discard block |
||
192 | 198 | |
193 | 199 | if (count($contents) == 0) { |
194 | 200 | print "\t\t\t \n"; |
195 | - } else { |
|
201 | + } |
|
202 | + else { |
|
196 | 203 | #print '<div class="sidebar">'; |
197 | 204 | foreach ($contents as $hash) { |
198 | 205 | if (isset($hash['type'])) { |
199 | 206 | if ($hash['type'] == 'include') { |
200 | 207 | $this->include_sidebar_template($hash['content']); |
201 | 208 | |
202 | - } elseif ($hash['type'] == 'nextprev') { |
|
209 | + } |
|
210 | + elseif ($hash['type'] == 'nextprev') { |
|
203 | 211 | $this->nextprevlinks(); |
204 | 212 | |
205 | - } elseif ($hash['type'] == 'html') { |
|
213 | + } |
|
214 | + elseif ($hash['type'] == 'html') { |
|
206 | 215 | print $hash['content']; |
207 | 216 | |
208 | - } elseif ($hash['type'] == 'extrahtml') { |
|
217 | + } |
|
218 | + elseif ($hash['type'] == 'extrahtml') { |
|
209 | 219 | $extrahtml .= $hash['content']; |
210 | 220 | } |
211 | 221 | } |
@@ -256,7 +266,8 @@ discard block |
||
256 | 266 | |
257 | 267 | if (isset($data['id']) && $data['id'] != '') { |
258 | 268 | $id = ' id="' . $data['id'] . '"'; |
259 | - } else { |
|
269 | + } |
|
270 | + else { |
|
260 | 271 | $id = ''; |
261 | 272 | } |
262 | 273 | |
@@ -304,7 +315,8 @@ discard block |
||
304 | 315 | // This is the page title of the parent. |
305 | 316 | $section_text = $DATA->page_metadata($parent_page, 'title'); |
306 | 317 | |
307 | - } else { |
|
318 | + } |
|
319 | + else { |
|
308 | 320 | // Top level page - no parent, hence no parental title. |
309 | 321 | $section_text = ''; |
310 | 322 | } |
@@ -318,7 +330,8 @@ discard block |
||
318 | 330 | |
319 | 331 | if ($page_text == '' && !is_bool($page_text)) { |
320 | 332 | // If the metadata 'heading' is set, but empty, we display nothing. |
321 | - } elseif ($page_text == false) { |
|
333 | + } |
|
334 | + elseif ($page_text == false) { |
|
322 | 335 | // But if it just hasn't been set, we use the 'title'. |
323 | 336 | $page_text = $DATA->page_metadata($this_page, "title"); |
324 | 337 | } |
@@ -326,7 +339,8 @@ discard block |
||
326 | 339 | if ($page_text == $section_text) { |
327 | 340 | // We don't want to print both. |
328 | 341 | $section_text = ''; |
329 | - } elseif (!$page_text && $section_text) { |
|
342 | + } |
|
343 | + elseif (!$page_text && $section_text) { |
|
330 | 344 | // Bodge for if we have a section_text but no page_text. |
331 | 345 | $page_text = $section_text; |
332 | 346 | $section_text = ''; |
@@ -340,7 +354,8 @@ discard block |
||
340 | 354 | print "\n\t\t\t\t<br><span>$page_text</span>\n"; |
341 | 355 | } |
342 | 356 | print "</h1>\n"; |
343 | - } elseif ($page_text) { |
|
357 | + } |
|
358 | + elseif ($page_text) { |
|
344 | 359 | print "\t\t\t\t<h1>$page_text</h1>\n"; |
345 | 360 | } |
346 | 361 | } |
@@ -399,7 +414,8 @@ discard block |
||
399 | 414 | // global which will then be displayed by the header template |
400 | 415 | if ( $this->page_started() ) { |
401 | 416 | $this->message($message, 'error'); |
402 | - } else { |
|
417 | + } |
|
418 | + else { |
|
403 | 419 | if ( !isset($page_errors) ) { |
404 | 420 | $page_errors = array(); |
405 | 421 | } |
@@ -479,7 +495,9 @@ discard block |
||
479 | 495 | |
480 | 496 | global $DATA, $this_page; |
481 | 497 | |
482 | - if ($this->page_started()) return; |
|
498 | + if ($this->page_started()) { |
|
499 | + return; |
|
500 | + } |
|
483 | 501 | // The page's HTML hasn't been started yet, so we'd better do it. |
484 | 502 | |
485 | 503 | // Set the page title (in the <title></title>). |
@@ -487,7 +505,8 @@ discard block |
||
487 | 505 | |
488 | 506 | if (isset($info['text_heading'])) { |
489 | 507 | $page_title = $info['text_heading']; |
490 | - } elseif (isset($info['text'])) { |
|
508 | + } |
|
509 | + elseif (isset($info['text'])) { |
|
491 | 510 | // Use a truncated version of the page's main item's body text. |
492 | 511 | // trim_words() is in utility.php. Trim to 40 chars. |
493 | 512 | $page_title = trim_characters($info['text'], 0, 40); |
@@ -539,7 +558,8 @@ discard block |
||
539 | 558 | if (isset($prev['url'])) { |
540 | 559 | $prevlink = '<a href="' . $prev['url'] . '" title="' . $prev['title'] . '" class="linkbutton">« ' . $prev['body'] . '</a>'; |
541 | 560 | |
542 | - } else { |
|
561 | + } |
|
562 | + else { |
|
543 | 563 | $prevlink = '« ' . $prev['body']; |
544 | 564 | } |
545 | 565 | } |
@@ -569,7 +589,8 @@ discard block |
||
569 | 589 | |
570 | 590 | if (isset($next['url'])) { |
571 | 591 | $nextlink = '<a href="' . $next['url'] . '" title="' . $next['title'] . '" class="linkbutton">' . $next['body'] . ' »</a>'; |
572 | - } else { |
|
592 | + } |
|
593 | + else { |
|
573 | 594 | $nextlink = $next['body'] . ' »'; |
574 | 595 | } |
575 | 596 | } |
@@ -599,7 +620,8 @@ discard block |
||
599 | 620 | if ($value == '') { |
600 | 621 | if (get_http_var('q') !== '') { |
601 | 622 | $value = get_http_var('q'); |
602 | - } else { |
|
623 | + } |
|
624 | + else { |
|
603 | 625 | $value = get_http_var('s'); |
604 | 626 | } |
605 | 627 | } |
@@ -629,8 +651,11 @@ discard block |
||
629 | 651 | $URL->insert(array('adv' => 1)); |
630 | 652 | echo ' <a href="' . $URL->generate() . '">More options</a>'; |
631 | 653 | echo '<br>'; |
632 | - if ($wtt) print '<input type="hidden" name="wtt" value="1">'; |
|
633 | - } else { ?> |
|
654 | + if ($wtt) { |
|
655 | + print '<input type="hidden" name="wtt" value="1">'; |
|
656 | + } |
|
657 | + } |
|
658 | + else { ?> |
|
634 | 659 | <form action="http://www.writetothem.com/lords" method="get"> |
635 | 660 | <input type="hidden" name="pid" value="<?=_htmlentities(get_http_var('pid')) ?>"> |
636 | 661 | <input type="submit" style="font-size: 150%" value=" I want to write to this Lord "><br> |
@@ -648,16 +673,19 @@ discard block |
||
648 | 673 | |
649 | 674 | if ($ordering=='r') { |
650 | 675 | print '<strong>Sorted by relevance</strong>'; |
651 | - } else { |
|
676 | + } |
|
677 | + else { |
|
652 | 678 | printf("<a href='%s'>Sort by relevance</a>", $orderUrl->generate('html', array('o'=>'r'))); |
653 | 679 | } |
654 | 680 | |
655 | 681 | print " | "; |
656 | 682 | if ($ordering=='d') { |
657 | 683 | print '<strong>Sorted by date: newest</strong> / <a href="' . $orderUrl->generate('html', array('o'=>'o')) . '">oldest</a>'; |
658 | - } elseif ($ordering=='o') { |
|
684 | + } |
|
685 | + elseif ($ordering=='o') { |
|
659 | 686 | print '<strong>Sorted by date:</strong> <a href="' . $orderUrl->generate('html', array('o'=>'d')) . '">newest</a> / <strong>oldest</strong>'; |
660 | - } else { |
|
687 | + } |
|
688 | + else { |
|
661 | 689 | printf("Sort by date: <a href='%s'>newest</a> / <a href='%s'>oldest</a>", |
662 | 690 | $orderUrl->generate('html', array('o'=>'d')), $orderUrl->generate('html', array('o'=>'o'))); |
663 | 691 | } |
@@ -665,7 +693,8 @@ discard block |
||
665 | 693 | print " | "; |
666 | 694 | if ($ordering=='p') { |
667 | 695 | print '<strong>Use by person</strong>'; |
668 | - } else { |
|
696 | + } |
|
697 | + else { |
|
669 | 698 | printf('<a href="%s">Show use by person</a>', $orderUrl->generate('html', array('o'=>'p'))); |
670 | 699 | } |
671 | 700 | echo '</div>'; |
@@ -888,7 +917,8 @@ discard block |
||
888 | 917 | if ($GLOSSARY->num_search_matches > 1) { |
889 | 918 | $plural = "them"; |
890 | 919 | $definition = "some definitions"; |
891 | - } else { |
|
920 | + } |
|
921 | + else { |
|
892 | 922 | $plural = "it"; |
893 | 923 | $definition = "a definition"; |
894 | 924 | } |
@@ -941,7 +971,8 @@ discard block |
||
941 | 971 | if ($page < 10) { |
942 | 972 | $firstpage = 1; |
943 | 973 | $lastpage = 10; |
944 | - } else { |
|
974 | + } |
|
975 | + else { |
|
945 | 976 | $firstpage = $page - 10; |
946 | 977 | $lastpage = $page + 9; |
947 | 978 | } |
@@ -971,7 +1002,8 @@ discard block |
||
971 | 1002 | |
972 | 1003 | if ($n > 1) { |
973 | 1004 | $URL->insert(array('p'=>$n)); |
974 | - } else { |
|
1005 | + } |
|
1006 | + else { |
|
975 | 1007 | // No page number for the first page. |
976 | 1008 | $URL->remove(array('p')); |
977 | 1009 | } |
@@ -981,7 +1013,8 @@ discard block |
||
981 | 1013 | |
982 | 1014 | if ($n != $page) { |
983 | 1015 | $pagelinks[] = '<a href="' . $URL->generate() . '">' . $n . '</a>'; |
984 | - } else { |
|
1016 | + } |
|
1017 | + else { |
|
985 | 1018 | $pagelinks[] = "<strong>$n</strong>"; |
986 | 1019 | } |
987 | 1020 | } |
@@ -1028,7 +1061,8 @@ discard block |
||
1028 | 1061 | $USERURL = new \MySociety\TheyWorkForYou\Url('userview'); |
1029 | 1062 | $USERURL->insert(array('id'=>$data['user_id'])); |
1030 | 1063 | $username = '<a href="' . $USERURL->generate() . '">' . _htmlentities($data['user_name']) . '</a>'; |
1031 | - } else { |
|
1064 | + } |
|
1065 | + else { |
|
1032 | 1066 | $username = _htmlentities($data['user_name']); |
1033 | 1067 | } |
1034 | 1068 | ?> |
@@ -1043,7 +1077,8 @@ discard block |
||
1043 | 1077 | ?> |
1044 | 1078 | <p> <br><em>This report has not been resolved.</em></p> |
1045 | 1079 | <?php |
1046 | - } else { |
|
1080 | + } |
|
1081 | + else { |
|
1047 | 1082 | ?> |
1048 | 1083 | <p><em>This report was resolved on <?php echo $data['resolved']; ?></em></p> |
1049 | 1084 | <?php |
@@ -1087,7 +1122,8 @@ discard block |
||
1087 | 1122 | 'cid' => $report['comment_id'], |
1088 | 1123 | )); |
1089 | 1124 | $editlink = '<a href="' . $EDITURL->generate() . '">View</a>'; |
1090 | - } else { |
|
1125 | + } |
|
1126 | + else { |
|
1091 | 1127 | $editlink = 'Locked'; |
1092 | 1128 | } |
1093 | 1129 | |
@@ -1104,7 +1140,8 @@ discard block |
||
1104 | 1140 | |
1105 | 1141 | $this->display_table($tabledata); |
1106 | 1142 | |
1107 | - } else { |
|
1143 | + } |
|
1144 | + else { |
|
1108 | 1145 | |
1109 | 1146 | print "<p>There are no outstanding annotation reports.</p>\n"; |
1110 | 1147 | } |
@@ -1144,7 +1181,8 @@ discard block |
||
1144 | 1181 | $nowDateComponents = getdate(); |
1145 | 1182 | if ($nowDateComponents['mon'] == $month && $nowDateComponents['year'] == $year) { |
1146 | 1183 | $toDay = $nowDateComponents['mday']; |
1147 | - } else { |
|
1184 | + } |
|
1185 | + else { |
|
1148 | 1186 | $toDay = ''; |
1149 | 1187 | } |
1150 | 1188 | |
@@ -1205,7 +1243,8 @@ discard block |
||
1205 | 1243 | // If so, higlight it. |
1206 | 1244 | if ($currentDay == $toDay) { |
1207 | 1245 | $calendar .= '<td class="on">'; |
1208 | - } else { |
|
1246 | + } |
|
1247 | + else { |
|
1209 | 1248 | $calendar .= '<td>'; |
1210 | 1249 | } |
1211 | 1250 | |
@@ -1221,7 +1260,8 @@ discard block |
||
1221 | 1260 | |
1222 | 1261 | // $currentDay is not a member of $dateArray. |
1223 | 1262 | |
1224 | - } else { |
|
1263 | + } |
|
1264 | + else { |
|
1225 | 1265 | |
1226 | 1266 | $calendar .= "$currentDay</td>"; |
1227 | 1267 | } |
@@ -1327,7 +1367,8 @@ discard block |
||
1327 | 1367 | if ($page != $this_page) { |
1328 | 1368 | $URL = new \MySociety\TheyWorkForYou\Url($page); |
1329 | 1369 | $title = '<a href="' . $URL->generate() . '">' . $title . '</a>'; |
1330 | - } else { |
|
1370 | + } |
|
1371 | + else { |
|
1331 | 1372 | $title = '<strong>' . $title . '</strong>'; |
1332 | 1373 | } |
1333 | 1374 |
@@ -138,8 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | global $PAGE; |
140 | 140 | |
141 | - if ($view == 'search' && (!defined('FRONT_END_SEARCH') || !FRONT_END_SEARCH)) |
|
142 | - return false; |
|
141 | + if ($view == 'search' && (!defined('FRONT_END_SEARCH') || !FRONT_END_SEARCH)) { |
|
142 | + return false; |
|
143 | + } |
|
143 | 144 | |
144 | 145 | $validviews = array ('calendar', 'date', 'gid', 'person', 'search', 'search_min', 'search_video', 'recent', 'recent_mostvotes', 'biggest_debates', 'recent_wrans', 'recent_wms', 'column', 'mp', 'bill', 'session', 'recent_debates', 'recent_pbc_debates', 'featured_gid'); |
145 | 146 | if (in_array($view, $validviews)) { |
@@ -149,7 +150,8 @@ discard block |
||
149 | 150 | // Get all the data that's to be rendered. |
150 | 151 | $data = $this->$function($args); |
151 | 152 | |
152 | - } else { |
|
153 | + } |
|
154 | + else { |
|
153 | 155 | // Don't have a valid $view. |
154 | 156 | $PAGE->error_message ("You haven't specified a view type."); |
155 | 157 | return false; |
@@ -290,7 +292,8 @@ discard block |
||
290 | 292 | $sectiondata = $sectiondata[0]; |
291 | 293 | } |
292 | 294 | |
293 | - } else { |
|
295 | + } |
|
296 | + else { |
|
294 | 297 | // This item *is* a section, so just return that. |
295 | 298 | |
296 | 299 | $sectiondata = $itemdata; |
@@ -326,12 +329,15 @@ discard block |
||
326 | 329 | ); |
327 | 330 | |
328 | 331 | $subsectiondata = $this->_get_hansard_data($input); |
329 | - if (count($subsectiondata) == 0) |
|
330 | - $subsectiondata = null; |
|
331 | - else |
|
332 | - $subsectiondata = $subsectiondata[0]; |
|
332 | + if (count($subsectiondata) == 0) { |
|
333 | + $subsectiondata = null; |
|
334 | + } |
|
335 | + else { |
|
336 | + $subsectiondata = $subsectiondata[0]; |
|
337 | + } |
|
333 | 338 | |
334 | - } elseif ($itemdata['htype'] == '11') { |
|
339 | + } |
|
340 | + elseif ($itemdata['htype'] == '11') { |
|
335 | 341 | // It's a subsection, so use the item itself. |
336 | 342 | $subsectiondata = $itemdata; |
337 | 343 | } |
@@ -359,10 +365,12 @@ discard block |
||
359 | 365 | // Debate subsection or section - get the next one. |
360 | 366 | if ($hansardmajors[$itemdata['major']]['type'] == 'other' && $hansardmajors[$itemdata['major']]['location'] == 'UK') { |
361 | 367 | $where = 'htype = 11'; |
362 | - } else { |
|
368 | + } |
|
369 | + else { |
|
363 | 370 | $where = "(htype = 10 OR htype = 11)"; |
364 | 371 | } |
365 | - } else { |
|
372 | + } |
|
373 | + else { |
|
366 | 374 | // Anything else in debates - get the next element that isn't |
367 | 375 | // a subsection or section, and is within THIS subsection. |
368 | 376 | $where = "subsection_id = '" . $itemdata['subsection_id'] . "' AND (htype != 10 AND htype != 11)"; |
@@ -434,12 +442,14 @@ discard block |
||
434 | 442 | 'url' => $prevdata[0]['listurl'], |
435 | 443 | 'title' => $prevdata[0]['body'] |
436 | 444 | ); |
437 | - } else { |
|
445 | + } |
|
446 | + else { |
|
438 | 447 | // Linking to the prev speaker. |
439 | 448 | |
440 | 449 | if (isset($prevdata[0]['speaker']) && count($prevdata[0]['speaker']) > 0) { |
441 | 450 | $title = $prevdata[0]['speaker']['name']; |
442 | - } else { |
|
451 | + } |
|
452 | + else { |
|
443 | 453 | $title = ''; |
444 | 454 | } |
445 | 455 | $nextprevdata['prev'] = array ( |
@@ -478,12 +488,14 @@ discard block |
||
478 | 488 | 'url' => $nextdata[0]['listurl'], |
479 | 489 | 'title' => $nextdata[0]['body'] |
480 | 490 | ); |
481 | - } else { |
|
491 | + } |
|
492 | + else { |
|
482 | 493 | // Linking to the next speaker. |
483 | 494 | |
484 | 495 | if (isset($nextdata[0]['speaker']) && count($nextdata[0]['speaker']) > 0) { |
485 | 496 | $title = $nextdata[0]['speaker']['name']; |
486 | - } else { |
|
497 | + } |
|
498 | + else { |
|
487 | 499 | $title = ''; |
488 | 500 | } |
489 | 501 | $nextprevdata['next'] = array ( |
@@ -503,7 +515,8 @@ discard block |
||
503 | 515 | 'title' => '', |
504 | 516 | 'url' => $URL->generate() . $this->url, |
505 | 517 | ); |
506 | - } elseif ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') { |
|
518 | + } |
|
519 | + elseif ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') { |
|
507 | 520 | $URL = new \MySociety\TheyWorkForYou\Url($this->listpage); |
508 | 521 | // Create URL for this (sub)section's date. |
509 | 522 | $URL->insert(array('d' => $itemdata['hdate'])); |
@@ -514,7 +527,8 @@ discard block |
||
514 | 527 | 'title' => '', |
515 | 528 | 'url' => $URL->generate() |
516 | 529 | ); |
517 | - } else { |
|
530 | + } |
|
531 | + else { |
|
518 | 532 | // We'll be setting $nextprevdata['up'] within $this->get_data_by_gid() |
519 | 533 | // because we need to know the name and url of the parent item, which |
520 | 534 | // we don't have here. Life sucks. |
@@ -550,7 +564,8 @@ discard block |
||
550 | 564 | FROM hansard |
551 | 565 | WHERE major = :major |
552 | 566 | AND hdate > :date", $params); |
553 | - } else { |
|
567 | + } |
|
568 | + else { |
|
554 | 569 | $q = $this->db->query("SELECT MAX(hdate) AS hdate |
555 | 570 | FROM hansard |
556 | 571 | WHERE major = :major |
@@ -565,7 +580,8 @@ discard block |
||
565 | 580 | |
566 | 581 | if ($nextorprev == 'next') { |
567 | 582 | $body = 'Next day'; |
568 | - } else { |
|
583 | + } |
|
584 | + else { |
|
569 | 585 | $body = 'Previous day'; |
570 | 586 | } |
571 | 587 | |
@@ -605,7 +621,8 @@ discard block |
||
605 | 621 | |
606 | 622 | if (isset($args['date'])) { |
607 | 623 | $date = $args['date']; |
608 | - } else { |
|
624 | + } |
|
625 | + else { |
|
609 | 626 | $PAGE->error_message ("Sorry, we don't have a date."); |
610 | 627 | return false; |
611 | 628 | } |
@@ -661,7 +678,8 @@ discard block |
||
661 | 678 | $q = $this->db->query ("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid)); |
662 | 679 | if ($q->rows() == 0) { |
663 | 680 | $itemdata = $this->_get_hansard_data($input); |
664 | - } else { |
|
681 | + } |
|
682 | + else { |
|
665 | 683 | do { |
666 | 684 | $gid = $q->field(0, 'gid_to'); |
667 | 685 | $q = $this->db->query("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid)); |
@@ -841,7 +859,8 @@ discard block |
||
841 | 859 | if (isset($args['days']) && is_numeric($args['days'])) { |
842 | 860 | $limit = 'LIMIT :limit'; |
843 | 861 | $params[':limit'] = $args['days']; |
844 | - } else { |
|
862 | + } |
|
863 | + else { |
|
845 | 864 | $limit = ''; |
846 | 865 | } |
847 | 866 | |
@@ -850,7 +869,8 @@ discard block |
||
850 | 869 | |
851 | 870 | $major = 'WHERE major = :major'; |
852 | 871 | $params[':major'] = $this->major; |
853 | - } else { |
|
872 | + } |
|
873 | + else { |
|
854 | 874 | $major = ''; |
855 | 875 | } |
856 | 876 | |
@@ -908,7 +928,8 @@ discard block |
||
908 | 928 | if (isset($this->major)) { |
909 | 929 | $majorwhere = "AND hansard.major = :hansard_major "; |
910 | 930 | $params[':hansard_major'] = $this->major; |
911 | - } else { |
|
931 | + } |
|
932 | + else { |
|
912 | 933 | // We're getting results for all debates/wrans/etc. |
913 | 934 | $majorwhere = ''; |
914 | 935 | } |
@@ -973,7 +994,8 @@ discard block |
||
973 | 994 | } |
974 | 995 | } |
975 | 996 | $data['rows'] = $speeches; |
976 | - } else { |
|
997 | + } |
|
998 | + else { |
|
977 | 999 | $data['rows'] = array(); |
978 | 1000 | } |
979 | 1001 | return $data; |
@@ -1000,10 +1022,12 @@ discard block |
||
1000 | 1022 | // $args['s'] should have been tidied up by the time we get here. |
1001 | 1023 | // eg, by doing filter_user_input($s, 'strict'); |
1002 | 1024 | $searchstring = $args['s']; |
1003 | - } else { |
|
1025 | + } |
|
1026 | + else { |
|
1004 | 1027 | if ( isset($args['exceptions']) ) { |
1005 | 1028 | throw new \Exception('No search string provided.'); |
1006 | - } else { |
|
1029 | + } |
|
1030 | + else { |
|
1007 | 1031 | $PAGE->error_message("No search string"); |
1008 | 1032 | return false; |
1009 | 1033 | } |
@@ -1022,22 +1046,25 @@ discard block |
||
1022 | 1046 | else { |
1023 | 1047 | $results_per_page = 20; |
1024 | 1048 | } |
1025 | - if ($results_per_page > 1000) |
|
1026 | - $results_per_page = 1000; |
|
1049 | + if ($results_per_page > 1000) { |
|
1050 | + $results_per_page = 1000; |
|
1051 | + } |
|
1027 | 1052 | |
1028 | 1053 | $data['info']['results_per_page'] = $results_per_page; |
1029 | 1054 | |
1030 | 1055 | // What page are we on? |
1031 | 1056 | if (isset($args['p']) && is_numeric($args['p'])) { |
1032 | 1057 | $page = $args['p']; |
1033 | - } else { |
|
1058 | + } |
|
1059 | + else { |
|
1034 | 1060 | $page = 1; |
1035 | 1061 | } |
1036 | 1062 | $data['info']['page'] = $page; |
1037 | 1063 | |
1038 | 1064 | if (isset($args['e'])) { |
1039 | 1065 | $encode = 'url'; |
1040 | - } else { |
|
1066 | + } |
|
1067 | + else { |
|
1041 | 1068 | $encode = 'html'; |
1042 | 1069 | } |
1043 | 1070 | |
@@ -1051,10 +1078,18 @@ discard block |
||
1051 | 1078 | // Get the gids from Xapian |
1052 | 1079 | $sort_order = 'date'; |
1053 | 1080 | if (isset($args['o'])) { |
1054 | - if ($args['o']=='d') $sort_order = 'newest'; |
|
1055 | - if ($args['o']=='o') $sort_order = 'oldest'; |
|
1056 | - elseif ($args['o']=='c') $sort_order = 'created'; |
|
1057 | - elseif ($args['o']=='r') $sort_order = 'relevance'; |
|
1081 | + if ($args['o']=='d') { |
|
1082 | + $sort_order = 'newest'; |
|
1083 | + } |
|
1084 | + if ($args['o']=='o') { |
|
1085 | + $sort_order = 'oldest'; |
|
1086 | + } |
|
1087 | + elseif ($args['o']=='c') { |
|
1088 | + $sort_order = 'created'; |
|
1089 | + } |
|
1090 | + elseif ($args['o']=='r') { |
|
1091 | + $sort_order = 'relevance'; |
|
1092 | + } |
|
1058 | 1093 | } |
1059 | 1094 | |
1060 | 1095 | $data['searchdescription'] = $SEARCHENGINE->query_description_long(); |
@@ -1114,7 +1149,9 @@ discard block |
||
1114 | 1149 | FROM future |
1115 | 1150 | LEFT JOIN future_people ON id=calendar_id AND witness=0 |
1116 | 1151 | WHERE id = $id AND deleted=0"); |
1117 | - if ($q->rows() == 0) continue; |
|
1152 | + if ($q->rows() == 0) { |
|
1153 | + continue; |
|
1154 | + } |
|
1118 | 1155 | |
1119 | 1156 | $itemdata = $q->row(0); |
1120 | 1157 | |
@@ -1123,8 +1160,9 @@ discard block |
||
1123 | 1160 | in_array($itemdata['chamber'], array( |
1124 | 1161 | 'Commons: Main Chamber', 'Lords: Main Chamber', |
1125 | 1162 | 'Commons: Westminster Hall', |
1126 | - ))) |
|
1127 | - continue; |
|
1163 | + ))) { |
|
1164 | + continue; |
|
1165 | + } |
|
1128 | 1166 | |
1129 | 1167 | list($cal_item, $cal_meta) = \MySociety\TheyWorkForYou\Utility\Calendar::meta($itemdata); |
1130 | 1168 | $body = $this->prepare_search_result_for_display($cal_item) . '.'; |
@@ -1139,7 +1177,8 @@ discard block |
||
1139 | 1177 | |
1140 | 1178 | if ($itemdata['event_date'] >= date('Y-m-d')) { |
1141 | 1179 | $title = 'Upcoming Business'; |
1142 | - } else { |
|
1180 | + } |
|
1181 | + else { |
|
1143 | 1182 | $title = 'Previous Business'; |
1144 | 1183 | } |
1145 | 1184 | $itemdata['gid'] = $id; |
@@ -1149,7 +1188,8 @@ discard block |
||
1149 | 1188 | $itemdata['listurl'] = '/calendar/?d=' . $itemdata['event_date'] . '#cal' . $itemdata['id']; |
1150 | 1189 | $itemdata['major'] = 'F'; |
1151 | 1190 | |
1152 | - } else { |
|
1191 | + } |
|
1192 | + else { |
|
1153 | 1193 | |
1154 | 1194 | // Get the data for the gid from the database |
1155 | 1195 | $q = $this->db->query("SELECT hansard.gid, hansard.hdate, |
@@ -1165,7 +1205,8 @@ discard block |
||
1165 | 1205 | if ($q->rows() > 1) { |
1166 | 1206 | if ( $isset($args['exceptions']) ) { |
1167 | 1207 | throw new \Exception("Got more than one row getting data for $gid."); |
1168 | - } else { |
|
1208 | + } |
|
1209 | + else { |
|
1169 | 1210 | $PAGE->error_message("Got more than one row getting data for $gid"); |
1170 | 1211 | } |
1171 | 1212 | } |
@@ -1220,27 +1261,39 @@ discard block |
||
1220 | 1261 | } |
1221 | 1262 | if ($itemdata['major'] == 5) { |
1222 | 1263 | $itemdata['parent']['body'] = 'Northern Ireland Assembly: ' . $itemdata['parent']['body']; |
1223 | - } elseif ($itemdata['major'] == 6) { |
|
1264 | + } |
|
1265 | + elseif ($itemdata['major'] == 6) { |
|
1224 | 1266 | $itemdata['parent']['body'] = 'Public Bill Committee: ' . $itemdata['parent']['body']; |
1225 | - } elseif ($itemdata['major'] == 7) { |
|
1267 | + } |
|
1268 | + elseif ($itemdata['major'] == 7) { |
|
1226 | 1269 | $itemdata['parent']['body'] = 'Scottish Parliament: ' . $itemdata['parent']['body']; |
1227 | 1270 | } |
1228 | 1271 | |
1229 | - } else { |
|
1272 | + } |
|
1273 | + else { |
|
1230 | 1274 | // It's a section, so it will be its own title. |
1231 | 1275 | $itemdata['parent']['body'] = $itemdata['body']; |
1232 | 1276 | $itemdata['body'] = ''; |
1233 | 1277 | } |
1234 | 1278 | |
1235 | - } else { |
|
1279 | + } |
|
1280 | + else { |
|
1236 | 1281 | // Wrans or WMS |
1237 | 1282 | $section = $this->_get_section($itemdata); |
1238 | 1283 | $subsection = $this->_get_subsection($itemdata); |
1239 | 1284 | $body = $hansardmajors[$itemdata['major']]['title'] . ' — '; |
1240 | - if (isset($section['body'])) $body .= $section['body']; |
|
1241 | - if (isset($subsection['body'])) $body .= ': ' . $subsection['body']; |
|
1242 | - if (isset($subsection['listurl'])) $listurl = $subsection['listurl']; |
|
1243 | - else $listurl = ''; |
|
1285 | + if (isset($section['body'])) { |
|
1286 | + $body .= $section['body']; |
|
1287 | + } |
|
1288 | + if (isset($subsection['body'])) { |
|
1289 | + $body .= ': ' . $subsection['body']; |
|
1290 | + } |
|
1291 | + if (isset($subsection['listurl'])) { |
|
1292 | + $listurl = $subsection['listurl']; |
|
1293 | + } |
|
1294 | + else { |
|
1295 | + $listurl = ''; |
|
1296 | + } |
|
1244 | 1297 | $itemdata['parent'] = array ( |
1245 | 1298 | 'body' => $body, |
1246 | 1299 | 'listurl' => $listurl |
@@ -1268,7 +1321,8 @@ discard block |
||
1268 | 1321 | $itemdata['speaker'] = $this->_get_speaker($itemdata['person_id'], $itemdata['hdate'], $itemdata['htime'], $itemdata['major']); |
1269 | 1322 | } |
1270 | 1323 | } |
1271 | - } elseif ($itemdata['htype'] == 10) { |
|
1324 | + } |
|
1325 | + elseif ($itemdata['htype'] == 10) { |
|
1272 | 1326 | $itemdata['body'] = ''; |
1273 | 1327 | $itemdata['extract'] = ''; |
1274 | 1328 | } |
@@ -1367,17 +1421,20 @@ discard block |
||
1367 | 1421 | return $data; |
1368 | 1422 | } |
1369 | 1423 | |
1370 | - } elseif (isset($args['year']) && is_numeric($args['year'])) { |
|
1424 | + } |
|
1425 | + elseif (isset($args['year']) && is_numeric($args['year'])) { |
|
1371 | 1426 | |
1372 | 1427 | if (isset($args['month']) && is_numeric($args['month'])) { |
1373 | 1428 | // A particular month. |
1374 | 1429 | $action = 'month'; |
1375 | - } else { |
|
1430 | + } |
|
1431 | + else { |
|
1376 | 1432 | // A single year. |
1377 | 1433 | $action = 'year'; |
1378 | 1434 | } |
1379 | 1435 | |
1380 | - } else { |
|
1436 | + } |
|
1437 | + else { |
|
1381 | 1438 | // The year to date so far. |
1382 | 1439 | $action = 'recentyear'; |
1383 | 1440 | } |
@@ -1405,7 +1462,8 @@ discard block |
||
1405 | 1462 | |
1406 | 1463 | if ($q->field(0, 'hdate') != NULL) { |
1407 | 1464 | $recentdate = $q->field(0, 'hdate'); |
1408 | - } else { |
|
1465 | + } |
|
1466 | + else { |
|
1409 | 1467 | $PAGE->error_message("Couldn't find the most recent date"); |
1410 | 1468 | return $data; |
1411 | 1469 | } |
@@ -1433,7 +1491,8 @@ discard block |
||
1433 | 1491 | $firstmonth = 12 + $firstmonth; // () |
1434 | 1492 | }; |
1435 | 1493 | |
1436 | - } else { |
|
1494 | + } |
|
1495 | + else { |
|
1437 | 1496 | // $action == 'recentyear' |
1438 | 1497 | |
1439 | 1498 | // Get the most recent year's results. |
@@ -1443,7 +1502,8 @@ discard block |
||
1443 | 1502 | |
1444 | 1503 | |
1445 | 1504 | |
1446 | - } else { |
|
1505 | + } |
|
1506 | + else { |
|
1447 | 1507 | // $action == 'year' or 'month'. |
1448 | 1508 | |
1449 | 1509 | $firstyear = $args['year']; |
@@ -1452,7 +1512,8 @@ discard block |
||
1452 | 1512 | if ($action == 'month') { |
1453 | 1513 | $firstmonth = intval($args['month']); |
1454 | 1514 | $finalmonth = intval($args['month']); |
1455 | - } else { |
|
1515 | + } |
|
1516 | + else { |
|
1456 | 1517 | $firstmonth = 1; |
1457 | 1518 | $finalmonth = 12; |
1458 | 1519 | } |
@@ -1524,7 +1585,8 @@ discard block |
||
1524 | 1585 | |
1525 | 1586 | if (!isset($years[$y])) { |
1526 | 1587 | $years[$y] = array(1=>array(), 2=>array(), 3=>array(), 4=>array(), 5=>array(), 6=>array(), 7=>array(), 8=>array(), 9=>array(), 10=>array(), 11=>array(), 12=>array()); |
1527 | - } else { |
|
1588 | + } |
|
1589 | + else { |
|
1528 | 1590 | |
1529 | 1591 | // This year is set. Check it has all the months... |
1530 | 1592 | |
@@ -1565,7 +1627,9 @@ discard block |
||
1565 | 1627 | 'url' => $YEARURL->generate() |
1566 | 1628 | ); |
1567 | 1629 | |
1568 | - } else { // action is 'year'. |
|
1630 | + } |
|
1631 | + else { |
|
1632 | +// action is 'year'. |
|
1569 | 1633 | |
1570 | 1634 | $nextprev['prev'] = array ('body' => 'Previous year'); |
1571 | 1635 | $nextprev['next'] = array ('body' => 'Next year'); |
@@ -1684,7 +1748,8 @@ discard block |
||
1684 | 1748 | ) { |
1685 | 1749 | $fieldsarr['epobject'] = array ('body'); |
1686 | 1750 | $join = 'LEFT OUTER JOIN epobject ON hansard.epobject_id = epobject.epobject_id'; |
1687 | - } else { |
|
1751 | + } |
|
1752 | + else { |
|
1688 | 1753 | $join = ''; |
1689 | 1754 | } |
1690 | 1755 | |
@@ -1712,14 +1777,16 @@ discard block |
||
1712 | 1777 | if ($order != '') { |
1713 | 1778 | # You can't use parameters for order by clauses |
1714 | 1779 | $order_by_clause = "ORDER BY $order"; |
1715 | - } else { |
|
1780 | + } |
|
1781 | + else { |
|
1716 | 1782 | $order_by_clause = ''; |
1717 | 1783 | } |
1718 | 1784 | |
1719 | 1785 | if ($limit != '') { |
1720 | 1786 | $params[':limit'] = $limit; |
1721 | 1787 | $limit = "LIMIT :limit"; |
1722 | - } else { |
|
1788 | + } |
|
1789 | + else { |
|
1723 | 1790 | $limit = ''; |
1724 | 1791 | } |
1725 | 1792 | |
@@ -1790,7 +1857,8 @@ discard block |
||
1790 | 1857 | $where = "section_id = '" . $item['epobject_id'] . "' |
1791 | 1858 | AND subsection_id = '" . $item['epobject_id'] . "'"; |
1792 | 1859 | |
1793 | - } else { |
|
1860 | + } |
|
1861 | + else { |
|
1794 | 1862 | // Subsection - get a count of items within this subsection. |
1795 | 1863 | $where = "subsection_id = '" . $item['epobject_id'] . "'"; |
1796 | 1864 | } |
@@ -1803,7 +1871,8 @@ discard block |
||
1803 | 1871 | |
1804 | 1872 | if ($r->rows() > 0) { |
1805 | 1873 | $item['contentcount'] = $r->field(0, 'count'); |
1806 | - } else { |
|
1874 | + } |
|
1875 | + else { |
|
1807 | 1876 | $item['contentcount'] = '0'; |
1808 | 1877 | } |
1809 | 1878 | } |
@@ -1820,7 +1889,8 @@ discard block |
||
1820 | 1889 | if ($item['htype'] == '10') { |
1821 | 1890 | $where = 'hansard.section_id = :epobject_id |
1822 | 1891 | AND hansard.subsection_id = :epobject_id'; |
1823 | - } elseif ($item['htype'] == '11') { |
|
1892 | + } |
|
1893 | + elseif ($item['htype'] == '11') { |
|
1824 | 1894 | $where = 'hansard.subsection_id = :epobject_id'; |
1825 | 1895 | } |
1826 | 1896 | |
@@ -1865,7 +1935,8 @@ discard block |
||
1865 | 1935 | $id = preg_replace('#^.*?_.*?_#', '', $item['gid']); |
1866 | 1936 | $fragment = $this->url . $id; |
1867 | 1937 | $item['commentsurl'] = $COMMENTSURL->generate() . $fragment; |
1868 | - } else { |
|
1938 | + } |
|
1939 | + else { |
|
1869 | 1940 | $COMMENTSURL->insert(array('id' => $item['gid'])); |
1870 | 1941 | $item['commentsurl'] = $COMMENTSURL->generate(); |
1871 | 1942 | } |
@@ -1927,7 +1998,8 @@ discard block |
||
1927 | 1998 | |
1928 | 1999 | if ($q->rows() > 0) { |
1929 | 2000 | $votes['user']['yes'] = $q->field(0, 'totalvotes'); |
1930 | - } else { |
|
2001 | + } |
|
2002 | + else { |
|
1931 | 2003 | $votes['user']['yes'] = '0'; |
1932 | 2004 | } |
1933 | 2005 | |
@@ -1940,7 +2012,8 @@ discard block |
||
1940 | 2012 | |
1941 | 2013 | if ($q->rows() > 0) { |
1942 | 2014 | $votes['user']['no'] = $q->field(0, 'totalvotes'); |
1943 | - } else { |
|
2015 | + } |
|
2016 | + else { |
|
1944 | 2017 | $votes['user']['no'] = '0'; |
1945 | 2018 | } |
1946 | 2019 | |
@@ -1956,7 +2029,8 @@ discard block |
||
1956 | 2029 | if ($q->rows() > 0) { |
1957 | 2030 | $votes['anon']['yes'] = $q->field(0, 'yes_votes'); |
1958 | 2031 | $votes['anon']['no'] = $q->field(0, 'no_votes'); |
1959 | - } else { |
|
2032 | + } |
|
2033 | + else { |
|
1960 | 2034 | $votes['anon']['yes'] = '0'; |
1961 | 2035 | $votes['anon']['no'] = '0'; |
1962 | 2036 | } |
@@ -1980,10 +2054,12 @@ discard block |
||
1980 | 2054 | // ); |
1981 | 2055 | |
1982 | 2056 | // $url_args is an array of other key/value pairs to be appended in the GET string. |
1983 | - if ($id_data['major']) |
|
1984 | - $LISTURL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$id_data['major']]['page_all']); |
|
1985 | - else |
|
1986 | - $LISTURL = new \MySociety\TheyWorkForYou\Url('wrans'); |
|
2057 | + if ($id_data['major']) { |
|
2058 | + $LISTURL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$id_data['major']]['page_all']); |
|
2059 | + } |
|
2060 | + else { |
|
2061 | + $LISTURL = new \MySociety\TheyWorkForYou\Url('wrans'); |
|
2062 | + } |
|
1987 | 2063 | |
1988 | 2064 | $fragment = ''; |
1989 | 2065 | |
@@ -1993,10 +2069,12 @@ discard block |
||
1993 | 2069 | global $DATA; |
1994 | 2070 | $DATA->set_page_metadata('pbc_clause', 'url', 'pbc/' . $this->url . $id); |
1995 | 2071 | $LISTURL->remove(array('id')); |
1996 | - } else { |
|
2072 | + } |
|
2073 | + else { |
|
1997 | 2074 | $LISTURL->insert( array( 'id' => $id_data['gid'] ) ); |
1998 | 2075 | } |
1999 | - } else { |
|
2076 | + } |
|
2077 | + else { |
|
2000 | 2078 | // A debate speech or question/answer, etc. |
2001 | 2079 | // We need to get the gid of the parent (sub)section for this item. |
2002 | 2080 | // We use this with the gid of the item itself as an #anchor. |
@@ -2012,7 +2090,8 @@ discard block |
||
2012 | 2090 | |
2013 | 2091 | $parent_gid = $this->epobjectid_to_gid[ $parent_epobject_id ]; |
2014 | 2092 | |
2015 | - } else { |
|
2093 | + } |
|
2094 | + else { |
|
2016 | 2095 | // We haven't cached the gid, so fetch from db. |
2017 | 2096 | |
2018 | 2097 | $r = $this->db->query("SELECT gid |
@@ -2035,7 +2114,8 @@ discard block |
||
2035 | 2114 | if ($id_data['major'] == 6) { |
2036 | 2115 | if (isset($this->bill_lookup[$minor])) { |
2037 | 2116 | list($title, $session) = $this->bill_lookup[$minor]; |
2038 | - } else { |
|
2117 | + } |
|
2118 | + else { |
|
2039 | 2119 | $qq = $this->db->query('select title, session from bills where id='.$minor); |
2040 | 2120 | $title = $qq->field(0, 'title'); |
2041 | 2121 | $session = $qq->field(0, 'session'); |
@@ -2046,7 +2126,8 @@ discard block |
||
2046 | 2126 | global $DATA; |
2047 | 2127 | $DATA->set_page_metadata('pbc_clause', 'url', "pbc/$url/$parent_gid"); |
2048 | 2128 | $LISTURL->remove(array('id')); |
2049 | - } else { |
|
2129 | + } |
|
2130 | + else { |
|
2050 | 2131 | $LISTURL->insert( array( 'id' => $parent_gid ) ); |
2051 | 2132 | } |
2052 | 2133 | // Use a truncated form of this item's gid for the anchor. |
@@ -2088,9 +2169,11 @@ discard block |
||
2088 | 2169 | # Note identical code to this in search/index.pl |
2089 | 2170 | if ($person_id == 10170 && $hdate == '2014-09-08') { |
2090 | 2171 | $hdate = '2014-09-07'; |
2091 | - } elseif ($person_id == 11068 && substr($hdate, 0, 7) == '2008-09') { |
|
2172 | + } |
|
2173 | + elseif ($person_id == 11068 && substr($hdate, 0, 7) == '2008-09') { |
|
2092 | 2174 | $hdate = '2008-08-13'; |
2093 | - } elseif ($person_id == 25394 && $hdate == '2016-07-01') { |
|
2175 | + } |
|
2176 | + elseif ($person_id == 25394 && $hdate == '2016-07-01') { |
|
2094 | 2177 | $hdate = '2016-06-16'; |
2095 | 2178 | } |
2096 | 2179 | |
@@ -2155,7 +2238,8 @@ discard block |
||
2155 | 2238 | # Couple of special cases for the election of the NI Speaker |
2156 | 2239 | if ($person_id == 13799 && $hdate == '2007-05-08') { |
2157 | 2240 | $members = array($members[$htime < '11:00' ? 0 : 1]); |
2158 | - } elseif ($person_id == 13831 && $hdate == '2015-01-12') { |
|
2241 | + } |
|
2242 | + elseif ($person_id == 13831 && $hdate == '2015-01-12') { |
|
2159 | 2243 | $members = array($members[$htime < '13:00' ? 0 : 1]); |
2160 | 2244 | } |
2161 | 2245 | } |
@@ -2170,11 +2254,14 @@ discard block |
||
2170 | 2254 | $URL = new \MySociety\TheyWorkForYou\Url('mp'); # Default, house=1 |
2171 | 2255 | if ($house==2) { |
2172 | 2256 | $URL = new \MySociety\TheyWorkForYou\Url('peer'); |
2173 | - } elseif ($house==3) { |
|
2257 | + } |
|
2258 | + elseif ($house==3) { |
|
2174 | 2259 | $URL = new \MySociety\TheyWorkForYou\Url('mla'); |
2175 | - } elseif ($house==4) { |
|
2260 | + } |
|
2261 | + elseif ($house==4) { |
|
2176 | 2262 | $URL = new \MySociety\TheyWorkForYou\Url('msp'); |
2177 | - } elseif ($house==0) { |
|
2263 | + } |
|
2264 | + elseif ($house==0) { |
|
2178 | 2265 | $URL = new \MySociety\TheyWorkForYou\Url('royal'); |
2179 | 2266 | } |
2180 | 2267 | return $URL; |
@@ -2293,7 +2380,8 @@ discard block |
||
2293 | 2380 | $where .= " AND section_id = :epobject_id"; |
2294 | 2381 | } |
2295 | 2382 | |
2296 | - } else { |
|
2383 | + } |
|
2384 | + else { |
|
2297 | 2385 | // Just getting a count of the comments on this item. |
2298 | 2386 | $from = "comments"; |
2299 | 2387 | $where = 'epobject_id = :epobject_id'; |
@@ -2413,7 +2501,8 @@ discard block |
||
2413 | 2501 | $this->htype = $itemdata['htype']; |
2414 | 2502 | if ($this->htype >= 12) { |
2415 | 2503 | $this_page = $this->commentspage; |
2416 | - } else { |
|
2504 | + } |
|
2505 | + else { |
|
2417 | 2506 | $this_page = $this->listpage; |
2418 | 2507 | } |
2419 | 2508 | } |
@@ -2454,18 +2543,21 @@ discard block |
||
2454 | 2543 | $nextprev = $this->_get_nextprev_items( $sectionrow ); |
2455 | 2544 | $data['info']['text_heading'] = $itemdata['body']; |
2456 | 2545 | |
2457 | - } elseif ($itemdata['htype'] == '11') { |
|
2546 | + } |
|
2547 | + elseif ($itemdata['htype'] == '11') { |
|
2458 | 2548 | $nextprev = $this->_get_nextprev_items( $subsectionrow ); |
2459 | 2549 | $data['info']['text_heading'] = $itemdata['body']; |
2460 | 2550 | |
2461 | - } else { |
|
2551 | + } |
|
2552 | + else { |
|
2462 | 2553 | // Ordinary lowly item. |
2463 | 2554 | $nextprev = $this->_get_nextprev_items( $itemdata ); |
2464 | 2555 | |
2465 | 2556 | if (isset($subsectionrow['gid'])) { |
2466 | 2557 | $nextprev['up']['url'] = $subsectionrow['listurl']; |
2467 | 2558 | $nextprev['up']['title'] = $subsectionrow['body']; |
2468 | - } else { |
|
2559 | + } |
|
2560 | + else { |
|
2469 | 2561 | $nextprev['up']['url'] = $sectionrow['listurl']; |
2470 | 2562 | $nextprev['up']['title'] = $sectionrow['body']; |
2471 | 2563 | } |
@@ -2522,7 +2614,8 @@ discard block |
||
2522 | 2614 | throw new RedirectException($data['subrows'][0]['gid']); |
2523 | 2615 | } |
2524 | 2616 | } |
2525 | - } elseif ($itemdata['htype'] == '11') { |
|
2617 | + } |
|
2618 | + elseif ($itemdata['htype'] == '11') { |
|
2526 | 2619 | // This item is a subsection, so we're displaying everything within it. |
2527 | 2620 | |
2528 | 2621 | # $subsectionrow['trackback'] = $this->_get_trackback_data($subsectionrow); |
@@ -2538,7 +2631,8 @@ discard block |
||
2538 | 2631 | $data['rows'] = $this->_get_hansard_data($input); |
2539 | 2632 | |
2540 | 2633 | |
2541 | - } elseif ($itemdata['htype'] == '12' || $itemdata['htype'] == '13') { |
|
2634 | + } |
|
2635 | + elseif ($itemdata['htype'] == '12' || $itemdata['htype'] == '13') { |
|
2542 | 2636 | // Debate speech or procedural, so we're just displaying this one item. |
2543 | 2637 | |
2544 | 2638 | # $itemdata['trackback'] = $this->_get_trackback_data($itemdata); |
@@ -2633,7 +2727,9 @@ discard block |
||
2633 | 2727 | array(':gid_from_spid' => 'uk.org.publicwhip/spq/' . $fixed_spid) |
2634 | 2728 | ); |
2635 | 2729 | $gid = $q->field(0, 'mentioned_gid'); |
2636 | - if ($gid) return $gid; |
|
2730 | + if ($gid) { |
|
2731 | + return $gid; |
|
2732 | + } |
|
2637 | 2733 | return null; |
2638 | 2734 | } |
2639 | 2735 | public function old_get_gid_from_spid($spid) { |
@@ -2642,7 +2738,9 @@ discard block |
||
2642 | 2738 | array(':gid_like' => 'uk.org.publicwhip/spwa/%.' . $spid . '.h') |
2643 | 2739 | ); |
2644 | 2740 | $gid = $q->field(0, 'gid'); |
2645 | - if ($gid) return str_replace('uk.org.publicwhip/spwa/', '', $gid); |
|
2741 | + if ($gid) { |
|
2742 | + return str_replace('uk.org.publicwhip/spwa/', '', $gid); |
|
2743 | + } |
|
2646 | 2744 | return null; |
2647 | 2745 | } |
2648 | 2746 | } |
@@ -2668,14 +2766,16 @@ discard block |
||
2668 | 2766 | // The most voted on things during how many recent days? |
2669 | 2767 | if (isset($args['days']) && is_numeric($args['days'])) { |
2670 | 2768 | $days = $args['days']; |
2671 | - } else { |
|
2769 | + } |
|
2770 | + else { |
|
2672 | 2771 | $days = 7; |
2673 | 2772 | } |
2674 | 2773 | |
2675 | 2774 | // How many results? |
2676 | 2775 | if (isset($args['num']) && is_numeric($args['num'])) { |
2677 | 2776 | $items_to_list = $args['num']; |
2678 | - } else { |
|
2777 | + } |
|
2778 | + else { |
|
2679 | 2779 | $items_to_list = 5; |
2680 | 2780 | } |
2681 | 2781 | |
@@ -2757,7 +2857,8 @@ discard block |
||
2757 | 2857 | |
2758 | 2858 | $data['rows'] = $speeches; |
2759 | 2859 | |
2760 | - } else { |
|
2860 | + } |
|
2861 | + else { |
|
2761 | 2862 | $data['rows'] = array (); |
2762 | 2863 | } |
2763 | 2864 | |
@@ -2845,10 +2946,12 @@ discard block |
||
2845 | 2946 | $subsection_body = $r->field(0, 'sub_body'); |
2846 | 2947 | if ( $section_body && $subsection_body ) { |
2847 | 2948 | $parentbody = "$section_body : $subsection_body"; |
2848 | - } else { |
|
2949 | + } |
|
2950 | + else { |
|
2849 | 2951 | $parentbody = "$section_body$subsection_body"; |
2850 | 2952 | } |
2851 | - } else if ( $item_data['htype'] == 10 ) { |
|
2953 | + } |
|
2954 | + else if ( $item_data['htype'] == 10 ) { |
|
2852 | 2955 | $parentbody = $body; |
2853 | 2956 | } |
2854 | 2957 | |
@@ -2856,7 +2959,8 @@ discard block |
||
2856 | 2959 | if ( $item_data['htype'] == 12 ) { |
2857 | 2960 | $childbody = $body; |
2858 | 2961 | $speaker = $this->_get_speaker($q->field(0, 'person_id'), $q->field(0, 'hdate'), $q->field(0, 'htime'), $this->major ); |
2859 | - } else { |
|
2962 | + } |
|
2963 | + else { |
|
2860 | 2964 | $r = $this->db->query("SELECT e.body, e.title, |
2861 | 2965 | h.person_id, h.hdate, h.htime |
2862 | 2966 | FROM hansard h, epobject e |
@@ -2928,7 +3032,9 @@ discard block |
||
2928 | 3032 | |
2929 | 3033 | // Get the most recent day on which we have a debate. |
2930 | 3034 | $recentday = $this->most_recent_day(); |
2931 | - if (!count($recentday)) return $data; |
|
3035 | + if (!count($recentday)) { |
|
3036 | + return $data; |
|
3037 | + } |
|
2932 | 3038 | |
2933 | 3039 | if (!isset($args['days']) || !is_numeric($args['days'])) { |
2934 | 3040 | $args['days'] = 1; |
@@ -2940,7 +3046,8 @@ discard block |
||
2940 | 3046 | if ($args['num'] == 1) { |
2941 | 3047 | $datewhere = "h.hdate = :hdate"; |
2942 | 3048 | $params[':hdate'] = $recentday['hdate']; |
2943 | - } else { |
|
3049 | + } |
|
3050 | + else { |
|
2944 | 3051 | $firstdate = gmdate('Y-m-d', $recentday['timestamp'] - (86400 * $args['days'])); |
2945 | 3052 | $datewhere = "h.hdate >= :firstdate |
2946 | 3053 | AND h.hdate <= :hdate"; |
@@ -3055,8 +3162,9 @@ discard block |
||
3055 | 3162 | |
3056 | 3163 | // Get the most recent day on which we have a debate. |
3057 | 3164 | $recentday = $this->most_recent_day(); |
3058 | - if (!count($recentday)) |
|
3059 | - return array(); |
|
3165 | + if (!count($recentday)) { |
|
3166 | + return array(); |
|
3167 | + } |
|
3060 | 3168 | |
3061 | 3169 | if (!isset($args['days']) || !is_numeric($args['days'])) { |
3062 | 3170 | $args['days'] = 1; |
@@ -3068,7 +3176,8 @@ discard block |
||
3068 | 3176 | $params = array(':recentdate' => $recentday['hdate']); |
3069 | 3177 | if ($args['num'] == 1) { |
3070 | 3178 | $datewhere = "h.hdate = :recentdate"; |
3071 | - } else { |
|
3179 | + } |
|
3180 | + else { |
|
3072 | 3181 | $params[':firstdate'] = gmdate('Y-m-d', $recentday['timestamp'] - (86400 * $args['days'])); |
3073 | 3182 | $datewhere = "h.hdate >= :firstdate AND h.hdate <= :recentdate"; |
3074 | 3183 | } |
@@ -3189,8 +3298,9 @@ discard block |
||
3189 | 3298 | |
3190 | 3299 | // Get the most recent day on which we have wrans. |
3191 | 3300 | $recentday = $this->most_recent_day(); |
3192 | - if (!count($recentday)) |
|
3193 | - return $data; |
|
3301 | + if (!count($recentday)) { |
|
3302 | + return $data; |
|
3303 | + } |
|
3194 | 3304 | |
3195 | 3305 | if (!isset($args['days']) || !is_numeric($args['days'])) { |
3196 | 3306 | $args['days'] = 1; |
@@ -3202,7 +3312,8 @@ discard block |
||
3202 | 3312 | if ($args['num'] == 1) { |
3203 | 3313 | $datewhere = "h.hdate = :datewhere"; |
3204 | 3314 | $params[':datewhere'] = $recentday['hdate']; |
3205 | - } else { |
|
3315 | + } |
|
3316 | + else { |
|
3206 | 3317 | $firstdate = gmdate('Y-m-d', $recentday['timestamp'] - (86400 * $args['days'])); |
3207 | 3318 | $datewhere = "h.hdate >= :firstdate AND h.hdate <= :hdate"; |
3208 | 3319 | $params[':firstdate'] = $firstdate; |
@@ -3213,7 +3324,8 @@ discard block |
||
3213 | 3324 | // Get a random selection of subsections in wrans. |
3214 | 3325 | if ($hansardmajors[$this->major]['location'] == 'Scotland') { |
3215 | 3326 | $htype = 'htype = 10 and section_id = 0'; |
3216 | - } else { |
|
3327 | + } |
|
3328 | + else { |
|
3217 | 3329 | $htype = 'htype = 11 and section_id != 0'; |
3218 | 3330 | } |
3219 | 3331 | |
@@ -3343,7 +3455,8 @@ discard block |
||
3343 | 3455 | ); |
3344 | 3456 | if ($chairman) { |
3345 | 3457 | $comm['chairmen'][$person_id] = $arr; |
3346 | - } else { |
|
3458 | + } |
|
3459 | + else { |
|
3347 | 3460 | $comm['members'][$person_id] = $arr; |
3348 | 3461 | } |
3349 | 3462 | } |
@@ -3470,7 +3583,9 @@ discard block |
||
3470 | 3583 | } |
3471 | 3584 | |
3472 | 3585 | public function _get_data_by_recent_pbc_debates($args) { |
3473 | - if (!isset($args['num'])) $args['num'] = 20; |
|
3586 | + if (!isset($args['num'])) { |
|
3587 | + $args['num'] = 20; |
|
3588 | + } |
|
3474 | 3589 | $q = $this->db->query('select gid, minor, hdate from hansard |
3475 | 3590 | where htype=10 and major=6 |
3476 | 3591 | order by hdate desc limit ' . $args['num']); |
@@ -3484,7 +3599,9 @@ discard block |
||
3484 | 3599 | $session = $qq->field(0, 'session'); |
3485 | 3600 | list($sitting, $part) = $this->_get_sitting($gid); |
3486 | 3601 | $sitting_txt = make_ranking($sitting) . ' sitting'; |
3487 | - if ($part>0) $sitting .= ", part $part"; |
|
3602 | + if ($part>0) { |
|
3603 | + $sitting .= ", part $part"; |
|
3604 | + } |
|
3488 | 3605 | $data[$hdate][] = array( |
3489 | 3606 | 'bill'=> $title, |
3490 | 3607 | 'sitting' => $sitting_txt, |
@@ -3496,8 +3613,9 @@ discard block |
||
3496 | 3613 | |
3497 | 3614 | # Given a GID, parse out the sitting number and optional part from it |
3498 | 3615 | public function _get_sitting($gid) { |
3499 | - if (preg_match('#_(\d\d)-(\d)_#', $gid, $m)) |
|
3500 | - return array($m[1]+0, $m[2]); |
|
3616 | + if (preg_match('#_(\d\d)-(\d)_#', $gid, $m)) { |
|
3617 | + return array($m[1]+0, $m[2]); |
|
3618 | + } |
|
3501 | 3619 | return array(0, 0); |
3502 | 3620 | } |
3503 | 3621 | } |
@@ -71,15 +71,19 @@ discard block |
||
71 | 71 | $person_id = ''; |
72 | 72 | if (isset($args['member_id']) && is_numeric($args['member_id'])) { |
73 | 73 | $person_id = $this->member_id_to_person_id($args['member_id']); |
74 | - } elseif (isset($args['name'])) { |
|
74 | + } |
|
75 | + elseif (isset($args['name'])) { |
|
75 | 76 | $con = isset($args['constituency']) ? $args['constituency'] : ''; |
76 | 77 | $person_id = $this->name_to_person_id($args['name'], $con); |
77 | - } elseif (isset($args['constituency'])) { |
|
78 | + } |
|
79 | + elseif (isset($args['constituency'])) { |
|
78 | 80 | $still_in_office = isset($args['still_in_office']) ? $args['still_in_office'] : false; |
79 | 81 | $person_id = $this->constituency_to_person_id($args['constituency'], $house, $still_in_office); |
80 | - } elseif (isset($args['postcode'])) { |
|
82 | + } |
|
83 | + elseif (isset($args['postcode'])) { |
|
81 | 84 | $person_id = $this->postcode_to_person_id($args['postcode'], $house); |
82 | - } elseif (isset($args['person_id']) && is_numeric($args['person_id'])) { |
|
85 | + } |
|
86 | + elseif (isset($args['person_id']) && is_numeric($args['person_id'])) { |
|
83 | 87 | $person_id = $args['person_id']; |
84 | 88 | $q = $this->db->query("SELECT gid_to FROM gidredirect |
85 | 89 | WHERE gid_from = :gid_from", |
@@ -114,7 +118,9 @@ discard block |
||
114 | 118 | $last_party = null; |
115 | 119 | for ($row=0; $row<$q->rows(); $row++) { |
116 | 120 | $house = $q->field($row, 'house'); |
117 | - if (!in_array($house, $this->houses)) $this->houses[] = $house; |
|
121 | + if (!in_array($house, $this->houses)) { |
|
122 | + $this->houses[] = $house; |
|
123 | + } |
|
118 | 124 | $const = $q->field($row, 'constituency'); |
119 | 125 | $party = $q->field($row, 'party'); |
120 | 126 | $entered_house = $q->field($row, 'entered_house'); |
@@ -194,7 +200,8 @@ discard block |
||
194 | 200 | } |
195 | 201 | if ($q->rows > 0) { |
196 | 202 | return $q->field(0, 'person_id'); |
197 | - } else { |
|
203 | + } |
|
204 | + else { |
|
198 | 205 | throw new MySociety\TheyWorkForYou\MemberException('Sorry, there is no member with a member ID of "' . _htmlentities($member_id) . '".'); |
199 | 206 | } |
200 | 207 | } |
@@ -215,7 +222,9 @@ discard block |
||
215 | 222 | } |
216 | 223 | |
217 | 224 | $normalised = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency); |
218 | - if ($normalised) $constituency = $normalised; |
|
225 | + if ($normalised) { |
|
226 | + $constituency = $normalised; |
|
227 | + } |
|
219 | 228 | |
220 | 229 | $params = array(); |
221 | 230 | |
@@ -239,7 +248,8 @@ discard block |
||
239 | 248 | |
240 | 249 | if ($q->rows > 0) { |
241 | 250 | return $q->field(0, 'person_id'); |
242 | - } else { |
|
251 | + } |
|
252 | + else { |
|
243 | 253 | throw new MySociety\TheyWorkForYou\MemberException('Sorry, there is no current member for the "' . _htmlentities(ucwords($constituency)) . '" constituency.'); |
244 | 254 | } |
245 | 255 | } |
@@ -254,10 +264,12 @@ discard block |
||
254 | 264 | $q = "SELECT person_id FROM person_names WHERE type = 'name' "; |
255 | 265 | if ($this_page == 'peer') { |
256 | 266 | $success = preg_match('#^(.*?) (.*?) of (.*?)$#', $name, $m); |
257 | - if (!$success) |
|
258 | - $success = preg_match('#^(.*?)() of (.*?)$#', $name, $m); |
|
259 | - if (!$success) |
|
260 | - $success = preg_match('#^(.*?) (.*?)()$#', $name, $m); |
|
267 | + if (!$success) { |
|
268 | + $success = preg_match('#^(.*?)() of (.*?)$#', $name, $m); |
|
269 | + } |
|
270 | + if (!$success) { |
|
271 | + $success = preg_match('#^(.*?) (.*?)()$#', $name, $m); |
|
272 | + } |
|
261 | 273 | if (!$success) { |
262 | 274 | throw new MySociety\TheyWorkForYou\MemberException('Sorry, that name was not recognised.'); |
263 | 275 | } |
@@ -265,10 +277,12 @@ discard block |
||
265 | 277 | $params[':family_name'] = $m[2]; |
266 | 278 | $params[':lordofname'] = $m[3]; |
267 | 279 | $q .= "AND title = :title AND family_name = :family_name AND lordofname = :lordofname"; |
268 | - } elseif ($this_page == 'msp' || $this_page == 'mla' || strstr($this_page, 'mp')) { |
|
280 | + } |
|
281 | + elseif ($this_page == 'msp' || $this_page == 'mla' || strstr($this_page, 'mp')) { |
|
269 | 282 | $success = preg_match('#^(.*?) (.*?) (.*?)$#', $name, $m); |
270 | - if (!$success) |
|
271 | - $success = preg_match('#^(.*?)() (.*)$#', $name, $m); |
|
283 | + if (!$success) { |
|
284 | + $success = preg_match('#^(.*?)() (.*)$#', $name, $m); |
|
285 | + } |
|
272 | 286 | if (!$success) { |
273 | 287 | throw new MySociety\TheyWorkForYou\MemberException('Sorry, that name was not recognised.'); |
274 | 288 | } |
@@ -288,7 +302,8 @@ discard block |
||
288 | 302 | $q = $this->db->query($q, $params); |
289 | 303 | if (!$q->rows) { |
290 | 304 | throw new MySociety\TheyWorkForYou\MemberException('Sorry, we could not find anyone with that name.'); |
291 | - } elseif ($q->rows == 1) { |
|
305 | + } |
|
306 | + elseif ($q->rows == 1) { |
|
292 | 307 | return $q->field(0, 'person_id'); |
293 | 308 | } |
294 | 309 | |
@@ -303,13 +318,17 @@ discard block |
||
303 | 318 | $params = array(); |
304 | 319 | if ($this_page == 'peer') { |
305 | 320 | $params[':house'] = HOUSE_TYPE_LORDS; |
306 | - } elseif ($this_page == 'msp') { |
|
321 | + } |
|
322 | + elseif ($this_page == 'msp') { |
|
307 | 323 | $params[':house'] = HOUSE_TYPE_SCOTLAND; |
308 | - } elseif ($this_page == 'mla') { |
|
324 | + } |
|
325 | + elseif ($this_page == 'mla') { |
|
309 | 326 | $params[':house'] = HOUSE_TYPE_NI; |
310 | - } elseif ($this_page == 'royal') { |
|
327 | + } |
|
328 | + elseif ($this_page == 'royal') { |
|
311 | 329 | $params[':house'] = HOUSE_TYPE_ROYAL; |
312 | - } else { |
|
330 | + } |
|
331 | + else { |
|
313 | 332 | $params[':house'] = HOUSE_TYPE_COMMONS; |
314 | 333 | } |
315 | 334 | |
@@ -328,11 +347,14 @@ discard block |
||
328 | 347 | $person_ids[$q->field($i, 'person_id')] = $q->field($i, 'constituency'); |
329 | 348 | } |
330 | 349 | throw new MySociety\TheyWorkForYou\MemberMultipleException($person_ids); |
331 | - } elseif ($q->rows > 0) { |
|
350 | + } |
|
351 | + elseif ($q->rows > 0) { |
|
332 | 352 | return $q->field(0, 'person_id'); |
333 | - } elseif ($const) { |
|
353 | + } |
|
354 | + elseif ($const) { |
|
334 | 355 | return $this->name_to_person_id($name); |
335 | - } else { |
|
356 | + } |
|
357 | + else { |
|
336 | 358 | throw new MySociety\TheyWorkForYou\MemberException('Sorry, there is no current member with that name.'); |
337 | 359 | } |
338 | 360 | } |
@@ -403,16 +425,21 @@ discard block |
||
403 | 425 | if (array_key_exists('public_whip_rebellions', $this->extra_info)) { |
404 | 426 | $rebellions = $this->extra_info['public_whip_rebellions']; |
405 | 427 | $rebel_desc = "<unknown>"; |
406 | - if ($rebellions == 0) |
|
407 | - $rebel_desc = "never"; |
|
408 | - elseif ($rebellions <= 1) |
|
409 | - $rebel_desc = "hardly ever"; |
|
410 | - elseif ($rebellions <= 3) |
|
411 | - $rebel_desc = "occasionally"; |
|
412 | - elseif ($rebellions <= 5) |
|
413 | - $rebel_desc = "sometimes"; |
|
414 | - elseif ($rebellions > 5) |
|
415 | - $rebel_desc = "quite often"; |
|
428 | + if ($rebellions == 0) { |
|
429 | + $rebel_desc = "never"; |
|
430 | + } |
|
431 | + elseif ($rebellions <= 1) { |
|
432 | + $rebel_desc = "hardly ever"; |
|
433 | + } |
|
434 | + elseif ($rebellions <= 3) { |
|
435 | + $rebel_desc = "occasionally"; |
|
436 | + } |
|
437 | + elseif ($rebellions <= 5) { |
|
438 | + $rebel_desc = "sometimes"; |
|
439 | + } |
|
440 | + elseif ($rebellions > 5) { |
|
441 | + $rebel_desc = "quite often"; |
|
442 | + } |
|
416 | 443 | $this->extra_info['public_whip_rebel_description'] = $rebel_desc; |
417 | 444 | } |
418 | 445 | |
@@ -476,8 +503,9 @@ discard block |
||
476 | 503 | public function family_name() { return $this->family_name; } |
477 | 504 | public function full_name($no_mp_title = false) { |
478 | 505 | $title = $this->title; |
479 | - if ($no_mp_title && ($this->house_disp==HOUSE_TYPE_COMMONS || $this->house_disp==HOUSE_TYPE_NI || $this->house_disp==HOUSE_TYPE_SCOTLAND)) |
|
480 | - $title = ''; |
|
506 | + if ($no_mp_title && ($this->house_disp==HOUSE_TYPE_COMMONS || $this->house_disp==HOUSE_TYPE_NI || $this->house_disp==HOUSE_TYPE_SCOTLAND)) { |
|
507 | + $title = ''; |
|
508 | + } |
|
481 | 509 | return member_full_name($this->house_disp, $title, $this->given_name, $this->family_name, $this->lordofname); |
482 | 510 | } |
483 | 511 | public function houses() { |
@@ -493,48 +521,62 @@ discard block |
||
493 | 521 | public function party() { return $this->party; } |
494 | 522 | public function party_text($party = null) { |
495 | 523 | global $parties; |
496 | - if (!$party) |
|
497 | - $party = $this->party; |
|
524 | + if (!$party) { |
|
525 | + $party = $this->party; |
|
526 | + } |
|
498 | 527 | if (isset($parties[$party])) { |
499 | 528 | return $parties[$party]; |
500 | - } else { |
|
529 | + } |
|
530 | + else { |
|
501 | 531 | return $party; |
502 | 532 | } |
503 | 533 | } |
504 | 534 | |
505 | 535 | public function entered_house($house = 0) { |
506 | - if ($house) return array_key_exists($house, $this->entered_house) ? $this->entered_house[$house] : null; |
|
536 | + if ($house) { |
|
537 | + return array_key_exists($house, $this->entered_house) ? $this->entered_house[$house] : null; |
|
538 | + } |
|
507 | 539 | return $this->entered_house; |
508 | 540 | } |
509 | 541 | public function entered_house_text($entered_house) { |
510 | - if (!$entered_house) return ''; |
|
542 | + if (!$entered_house) { |
|
543 | + return ''; |
|
544 | + } |
|
511 | 545 | list($year, $month, $day) = explode('-', $entered_house); |
512 | 546 | if ($month==1 && $day==1 && $this->house(HOUSE_TYPE_LORDS)) { |
513 | 547 | return $year; |
514 | - } elseif ($month==0 && $day==0) { |
|
548 | + } |
|
549 | + elseif ($month==0 && $day==0) { |
|
515 | 550 | return $year; |
516 | - } elseif (checkdate($month, $day, $year) && $year != '9999') { |
|
551 | + } |
|
552 | + elseif (checkdate($month, $day, $year) && $year != '9999') { |
|
517 | 553 | return format_date($entered_house, LONGDATEFORMAT); |
518 | - } else { |
|
554 | + } |
|
555 | + else { |
|
519 | 556 | return "n/a"; |
520 | 557 | } |
521 | 558 | } |
522 | 559 | |
523 | 560 | public function left_house($house = null) { |
524 | - if (!is_null($house)) |
|
525 | - return array_key_exists($house, $this->left_house) ? $this->left_house[$house] : null; |
|
561 | + if (!is_null($house)) { |
|
562 | + return array_key_exists($house, $this->left_house) ? $this->left_house[$house] : null; |
|
563 | + } |
|
526 | 564 | return $this->left_house; |
527 | 565 | } |
528 | 566 | |
529 | 567 | public function left_house_text($left_house) { |
530 | - if (!$left_house) return ''; |
|
568 | + if (!$left_house) { |
|
569 | + return ''; |
|
570 | + } |
|
531 | 571 | list($year, $month, $day) = explode('-', $left_house); |
532 | 572 | if (checkdate($month, $day, $year) && $year != '9999') { |
533 | 573 | return format_date($left_house, LONGDATEFORMAT); |
534 | - } elseif ($month==0 && $day==0) { |
|
574 | + } |
|
575 | + elseif ($month==0 && $day==0) { |
|
535 | 576 | # Left house date is stored as 1942-00-00 to mean "at some point in 1941" |
536 | 577 | return $year - 1; |
537 | - } else { |
|
578 | + } |
|
579 | + else { |
|
538 | 580 | return "n/a"; |
539 | 581 | } |
540 | 582 | } |
@@ -543,7 +585,8 @@ discard block |
||
543 | 585 | public function entered_reason_text($entered_reason) { |
544 | 586 | if (isset($this->reasons[$entered_reason])) { |
545 | 587 | return $this->reasons[$entered_reason]; |
546 | - } else { |
|
588 | + } |
|
589 | + else { |
|
547 | 590 | return $entered_reason; |
548 | 591 | } |
549 | 592 | } |
@@ -557,13 +600,16 @@ discard block |
||
557 | 600 | $max = $q->field(0, 'max'); |
558 | 601 | if ($max == $left_house) { |
559 | 602 | return $left_reason[0]; |
560 | - } else { |
|
603 | + } |
|
604 | + else { |
|
561 | 605 | return $left_reason[1]; |
562 | 606 | } |
563 | - } else { |
|
607 | + } |
|
608 | + else { |
|
564 | 609 | return $left_reason; |
565 | 610 | } |
566 | - } else { |
|
611 | + } |
|
612 | + else { |
|
567 | 613 | return $left_reason; |
568 | 614 | } |
569 | 615 | } |
@@ -576,7 +622,9 @@ discard block |
||
576 | 622 | $lh = $this->left_house($h); |
577 | 623 | $current[$h] = ($lh['date'] == '9999-12-31'); |
578 | 624 | } |
579 | - if ($house) return $current[$house]; |
|
625 | + if ($house) { |
|
626 | + return $current[$house]; |
|
627 | + } |
|
580 | 628 | return $current; |
581 | 629 | } |
582 | 630 | |
@@ -586,13 +634,17 @@ discard block |
||
586 | 634 | $house = $this->house_disp; |
587 | 635 | if ($house == HOUSE_TYPE_COMMONS) { |
588 | 636 | $URL = new \MySociety\TheyWorkForYou\Url('mp'); |
589 | - } elseif ($house == HOUSE_TYPE_LORDS) { |
|
637 | + } |
|
638 | + elseif ($house == HOUSE_TYPE_LORDS) { |
|
590 | 639 | $URL = new \MySociety\TheyWorkForYou\Url('peer'); |
591 | - } elseif ($house == HOUSE_TYPE_NI) { |
|
640 | + } |
|
641 | + elseif ($house == HOUSE_TYPE_NI) { |
|
592 | 642 | $URL = new \MySociety\TheyWorkForYou\Url('mla'); |
593 | - } elseif ($house == HOUSE_TYPE_SCOTLAND) { |
|
643 | + } |
|
644 | + elseif ($house == HOUSE_TYPE_SCOTLAND) { |
|
594 | 645 | $URL = new \MySociety\TheyWorkForYou\Url('msp'); |
595 | - } elseif ($house == HOUSE_TYPE_ROYAL) { |
|
646 | + } |
|
647 | + elseif ($house == HOUSE_TYPE_ROYAL) { |
|
596 | 648 | $URL = new \MySociety\TheyWorkForYou\Url('royal'); |
597 | 649 | } |
598 | 650 | $member_url = make_member_url($this->full_name(true), $this->constituency(), $house, $this->person_id()); |
@@ -602,17 +654,21 @@ discard block |
||
602 | 654 | $protocol = 'http://'; |
603 | 655 | } |
604 | 656 | return $protocol . DOMAIN . $URL->generate('none') . $member_url; |
605 | - } else { |
|
657 | + } |
|
658 | + else { |
|
606 | 659 | return $URL->generate('none') . $member_url; |
607 | 660 | } |
608 | 661 | } |
609 | 662 | |
610 | 663 | private function _previous_future_mps_query($direction) { |
611 | 664 | $entered_house = $this->entered_house(HOUSE_TYPE_COMMONS); |
612 | - if (is_null($entered_house)) return ''; |
|
665 | + if (is_null($entered_house)) { |
|
666 | + return ''; |
|
667 | + } |
|
613 | 668 | if ($direction == '>') { |
614 | 669 | $order = ''; |
615 | - } else { |
|
670 | + } |
|
671 | + else { |
|
616 | 672 | $order = 'DESC'; |
617 | 673 | } |
618 | 674 | $q = $this->db->query('SELECT * |
@@ -34,10 +34,12 @@ discard block |
||
34 | 34 | $always_ask = 0; |
35 | 35 | $show_survey_qn = $current_question; |
36 | 36 | setcookie('survey', $current_question, time()+60*60*24*365, '/'); |
37 | -} elseif ($has_answered_question == $current_question && !$always_ask) { |
|
37 | +} |
|
38 | +elseif ($has_answered_question == $current_question && !$always_ask) { |
|
38 | 39 | $show_survey_qn = $current_question; |
39 | 40 | setcookie('survey', $current_question, time()+60*60*24*365, '/'); |
40 | -} elseif (isset($_COOKIE['survey'])) { |
|
41 | +} |
|
42 | +elseif (isset($_COOKIE['survey'])) { |
|
41 | 43 | $show_survey_qn = $_COOKIE['survey']; |
42 | 44 | } |
43 | 45 | |
@@ -53,7 +55,8 @@ discard block |
||
53 | 55 | global $MEMBER; |
54 | 56 | $page_url = $MEMBER->url(true) . "?answered_survey=$current_question"; |
55 | 57 | $hide_url = $MEMBER->url() . "?hide_survey=$current_question"; |
56 | - } else { |
|
58 | + } |
|
59 | + else { |
|
57 | 60 | $URL = new \MySociety\TheyWorkForYou\Url($this_page); |
58 | 61 | $URL->insert(array('answered_survey' => $current_question )); |
59 | 62 | $page_url = 'https://' . DOMAIN . $URL->generate(); |
@@ -105,7 +108,8 @@ discard block |
||
105 | 108 | |
106 | 109 | <?php |
107 | 110 | $this->block_end(); |
108 | -} elseif ($has_answered_question) { |
|
111 | +} |
|
112 | +elseif ($has_answered_question) { |
|
109 | 113 | $this->block_start(array('id'=>'survey', 'title'=>"Mini survey")); |
110 | 114 | ?> |
111 | 115 | Thanks for answering. |