@@ -194,7 +194,7 @@ |
||
194 | 194 | $this->assertEquals($specific_policy["date_max"], "2002-01-01"); |
195 | 195 | } |
196 | 196 | |
197 | - public function testPartyChangeHistoryRobustness(){ |
|
197 | + public function testPartyChangeHistoryRobustness() { |
|
198 | 198 | //The cohort comparison for a set of MPs does not change if one of those MPs changes party *after* the division. |
199 | 199 | //Person 10 and 11 are in party D. |
200 | 200 | //Person 12 is in Party E the whole time. |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | return $cohorts; |
380 | 380 | } |
381 | 381 | |
382 | - public static function getCohortQuery(){ |
|
382 | + public static function getCohortQuery() { |
|
383 | 383 | $membership_query = ' |
384 | 384 | select member_periods.person_id as person_id, |
385 | 385 | md5(concat(start_party, "|", membership_key, "|", IFNULL(absence_key,""))) as cohort_hash |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | |
411 | - public static function getHashforPerson($person_id){ |
|
411 | + public static function getHashforPerson($person_id) { |
|
412 | 412 | // given a person id, return the hash for that cohort |
413 | 413 | $db = new \ParlDB; |
414 | 414 | $row = $db->query("SELECT cohort_hash |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
426 | - public static function calculatePositions($quiet=true){ |
|
426 | + public static function calculatePositions($quiet = true) { |
|
427 | 427 | // get current hashes available |
428 | 428 | $cohorts = PartyCohort::getCohorts(); |
429 | 429 | $policies = new Policies; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | |
432 | 432 | // iterate through all hashes and create policy positions |
433 | 433 | $cohort_count = 0; |
434 | - foreach ( $cohorts as $cohort ) { |
|
434 | + foreach ($cohorts as $cohort) { |
|
435 | 435 | |
436 | 436 | $cohort = new PartyCohort($cohort, true); |
437 | 437 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | |
440 | 440 | $cohort_count++; |
441 | 441 | |
442 | - foreach ( $positions as $position ) { |
|
443 | - $cohort->cache_position( $position ); |
|
442 | + foreach ($positions as $position) { |
|
443 | + $cohort->cache_position($position); |
|
444 | 444 | } |
445 | 445 | if (!$quiet) { |
446 | 446 | print("$cohort_count/$n_cohorts\n"); |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | # Ignore errors we've asked to ignore |
69 | 69 | if (error_reporting()==0) return; |
70 | 70 | |
71 | - // define an assoc array of error string |
|
72 | - // in reality the only entries we should |
|
73 | - // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
|
74 | - // E_USER_WARNING and E_USER_NOTICE |
|
75 | - # Commented out are ones that a user function cannot handle. |
|
71 | + // define an assoc array of error string |
|
72 | + // in reality the only entries we should |
|
73 | + // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
|
74 | + // E_USER_WARNING and E_USER_NOTICE |
|
75 | + # Commented out are ones that a user function cannot handle. |
|
76 | 76 | $errortype = array ( |
77 | 77 | #E_ERROR => "Error", |
78 | 78 | E_WARNING => "Warning", |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php |
202 | 202 | function adodb_backtrace($print=true) |
203 | 203 | { |
204 | - $s = ''; |
|
205 | - if (PHPVERSION() >= 4.3) { |
|
204 | + $s = ''; |
|
205 | + if (PHPVERSION() >= 4.3) { |
|
206 | 206 | |
207 | 207 | $MAXSTRLEN = 64; |
208 | 208 | |
@@ -210,33 +210,33 @@ discard block |
||
210 | 210 | array_shift($traceArr); |
211 | 211 | $tabs = sizeof($traceArr)-1; |
212 | 212 | foreach ($traceArr as $arr) { |
213 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
214 | - $tabs -= 1; |
|
215 | - if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
216 | - $args = array(); |
|
217 | - if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
|
213 | + for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
214 | + $tabs -= 1; |
|
215 | + if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
216 | + $args = array(); |
|
217 | + if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
|
218 | 218 | if (is_null($v)) $args[] = 'null'; |
219 | 219 | elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']'; |
220 | 220 | elseif (is_object($v)) $args[] = 'Object:'.get_class($v); |
221 | 221 | elseif (is_bool($v)) $args[] = $v ? 'true' : 'false'; |
222 | 222 | else { |
223 | - $v = (string) @$v; |
|
224 | - $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
|
225 | - if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
|
226 | - $args[] = $str; |
|
223 | + $v = (string) @$v; |
|
224 | + $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
|
225 | + if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
|
226 | + $args[] = $str; |
|
227 | 227 | } |
228 | - } |
|
228 | + } |
|
229 | 229 | |
230 | - $s .= $arr['function'].'('.implode(', ',$args).')'; |
|
231 | - // $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". |
|
232 | - // " file: <a href=\"file:/%s\">%s</a></font>", |
|
233 | - // $arr['line'],$arr['file'],$arr['file']); |
|
234 | - $s .= "\n"; |
|
230 | + $s .= $arr['function'].'('.implode(', ',$args).')'; |
|
231 | + // $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". |
|
232 | + // " file: <a href=\"file:/%s\">%s</a></font>", |
|
233 | + // $arr['line'],$arr['file'],$arr['file']); |
|
234 | + $s .= "\n"; |
|
235 | 235 | } |
236 | 236 | if ($print) print $s; |
237 | - } |
|
237 | + } |
|
238 | 238 | |
239 | - return $s; |
|
239 | + return $s; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // Far from foolproof, but better than nothing. |
@@ -576,14 +576,14 @@ discard block |
||
576 | 576 | //$tbl["»"] = "»"; |
577 | 577 | //$tbl["«"] = "«"; |
578 | 578 | |
579 | - // lib_filter will replace unmatched < and > with entities so |
|
580 | - // we abuse strtr's only replace once behaviour to not double |
|
581 | - // encode them. May not be robust. |
|
582 | - // This does mean if anyone actually wants to put > or < |
|
583 | - // in a comment they can't but that's a lot less likely than |
|
584 | - // < or > for less than and greater than. |
|
585 | - $tbl['<'] = "<"; |
|
586 | - $tbl['>'] = ">"; |
|
579 | + // lib_filter will replace unmatched < and > with entities so |
|
580 | + // we abuse strtr's only replace once behaviour to not double |
|
581 | + // encode them. May not be robust. |
|
582 | + // This does mean if anyone actually wants to put > or < |
|
583 | + // in a comment they can't but that's a lot less likely than |
|
584 | + // < or > for less than and greater than. |
|
585 | + $tbl['<'] = "<"; |
|
586 | + $tbl['>'] = ">"; |
|
587 | 587 | |
588 | 588 | // Don't want to encode these things |
589 | 589 | unset ($tbl["<"]); |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | |
1097 | 1097 | $return = '<h4>'; |
1098 | 1098 | if (isset($daytext[$major])) { |
1099 | - $return .= $daytext[$major] . ' '; |
|
1099 | + $return .= $daytext[$major] . ' '; |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | $return .= '<a href="'; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | # Pass it a brief header word and some debug text and it'll be output. |
13 | 13 | # If TEXT is an array, call the user function, assuming it's a class. |
14 | -function twfy_debug($header, $text="") { |
|
14 | +function twfy_debug($header, $text = "") { |
|
15 | 15 | |
16 | 16 | // We set ?DEBUGTAG=n in the URL. |
17 | 17 | // (DEBUGTAG is set in config.php). |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | if ($debug_level != '') { |
29 | 29 | |
30 | 30 | // Set which level shows which types of debug info. |
31 | - $levels = array ( |
|
32 | - 1 => array ('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'), |
|
33 | - 2 => array ('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'), |
|
34 | - 3 => array ('SQLRESULT') |
|
31 | + $levels = array( |
|
32 | + 1 => array('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'), |
|
33 | + 2 => array('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'), |
|
34 | + 3 => array('SQLRESULT') |
|
35 | 35 | // Higher than this: 'DATA', etc. |
36 | 36 | ); |
37 | 37 | |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | for ($n = 1; $n <= $max_level_to_show; $n++) { |
48 | - $allowed_headers = array_merge ($allowed_headers, $levels[$n] ); |
|
48 | + $allowed_headers = array_merge($allowed_headers, $levels[$n]); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // If we can show this header, then, er, show it. |
52 | - if ( in_array($header, $allowed_headers) || $debug_level >= 4) { |
|
52 | + if (in_array($header, $allowed_headers) || $debug_level >= 4) { |
|
53 | 53 | if (is_array($text)) $text = call_user_func($text); |
54 | 54 | print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n"; |
55 | 55 | } |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | global $PAGE; |
67 | 67 | |
68 | 68 | # Ignore errors we've asked to ignore |
69 | - if (error_reporting()==0) return; |
|
69 | + if (error_reporting() == 0) return; |
|
70 | 70 | |
71 | 71 | // define an assoc array of error string |
72 | 72 | // in reality the only entries we should |
73 | 73 | // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
74 | 74 | // E_USER_WARNING and E_USER_NOTICE |
75 | 75 | # Commented out are ones that a user function cannot handle. |
76 | - $errortype = array ( |
|
76 | + $errortype = array( |
|
77 | 77 | #E_ERROR => "Error", |
78 | 78 | E_WARNING => "Warning", |
79 | 79 | #E_PARSE => "Parsing Error", |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | $source = file($filename); |
133 | 133 | $err .= "\nSource:\n\n"; |
134 | 134 | // Show the line, plus prev and next, with line numbers. |
135 | - $err .= $linenum-2 . " " . $source[$linenum-3]; |
|
136 | - $err .= $linenum-1 . " " . $source[$linenum-2]; |
|
137 | - $err .= $linenum . " " . $source[$linenum-1]; |
|
138 | - $err .= $linenum+1 . " " . $source[$linenum]; |
|
139 | - $err .= $linenum+2 . " " . $source[$linenum+1]; |
|
135 | + $err .= $linenum - 2 . " " . $source[$linenum - 3]; |
|
136 | + $err .= $linenum - 1 . " " . $source[$linenum - 2]; |
|
137 | + $err .= $linenum . " " . $source[$linenum - 1]; |
|
138 | + $err .= $linenum + 1 . " " . $source[$linenum]; |
|
139 | + $err .= $linenum + 2 . " " . $source[$linenum + 1]; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | header('HTTP/1.0 500 Internal Server Error'); |
181 | 181 | print "<p>Oops, sorry, an error has occurred!</p>\n"; |
182 | 182 | } |
183 | - if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect')===false && strpos($errmsg, 'mysql_connect')===false) { |
|
184 | - mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n". "X-Mailer: PHP/" . phpversion() ); |
|
183 | + if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect') === false && strpos($errmsg, 'mysql_connect') === false) { |
|
184 | + mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n" . "X-Mailer: PHP/" . phpversion()); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | |
201 | 201 | // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php |
202 | -function adodb_backtrace($print=true) |
|
202 | +function adodb_backtrace($print = true) |
|
203 | 203 | { |
204 | 204 | $s = ''; |
205 | 205 | if (PHPVERSION() >= 4.3) { |
@@ -208,26 +208,26 @@ discard block |
||
208 | 208 | |
209 | 209 | $traceArr = debug_backtrace(); |
210 | 210 | array_shift($traceArr); |
211 | - $tabs = sizeof($traceArr)-1; |
|
211 | + $tabs = sizeof($traceArr) - 1; |
|
212 | 212 | foreach ($traceArr as $arr) { |
213 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
213 | + for ($i = 0; $i < $tabs; $i++) $s .= ' '; |
|
214 | 214 | $tabs -= 1; |
215 | - if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
215 | + if (isset($arr['class'])) $s .= $arr['class'] . '.'; |
|
216 | 216 | $args = array(); |
217 | 217 | if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
218 | 218 | if (is_null($v)) $args[] = 'null'; |
219 | - elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']'; |
|
220 | - elseif (is_object($v)) $args[] = 'Object:'.get_class($v); |
|
219 | + elseif (is_array($v)) $args[] = 'Array[' . sizeof($v) . ']'; |
|
220 | + elseif (is_object($v)) $args[] = 'Object:' . get_class($v); |
|
221 | 221 | elseif (is_bool($v)) $args[] = $v ? 'true' : 'false'; |
222 | 222 | else { |
223 | 223 | $v = (string) @$v; |
224 | - $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
|
224 | + $str = _htmlspecialchars(substr($v, 0, $MAXSTRLEN)); |
|
225 | 225 | if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
226 | 226 | $args[] = $str; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | - $s .= $arr['function'].'('.implode(', ',$args).')'; |
|
230 | + $s .= $arr['function'] . '(' . implode(', ', $args) . ')'; |
|
231 | 231 | // $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". |
232 | 232 | // " file: <a href=\"file:/%s\">%s</a></font>", |
233 | 233 | // $arr['line'],$arr['file'],$arr['file']); |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | |
242 | 242 | // Far from foolproof, but better than nothing. |
243 | 243 | function validate_email($string) { |
244 | - if (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`a-z{|}~]+'. |
|
245 | - '@'. |
|
246 | - '[-!#$%&\'*.\\+\/0-9=?A-Z^_`a-z{|}~]+\.'. |
|
244 | + if (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`a-z{|}~]+' . |
|
245 | + '@' . |
|
246 | + '[-!#$%&\'*.\\+\/0-9=?A-Z^_`a-z{|}~]+\.' . |
|
247 | 247 | '[-!#$%&\'*+\\.\/0-9=?A-Z^_`a-z{|}~]+$/', $string)) { |
248 | 248 | return false; |
249 | 249 | } else { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $nom = '0123456789'; |
266 | 266 | $gap = '\s\.'; |
267 | 267 | |
268 | - if ( preg_match("/^[$fst][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
|
268 | + if (preg_match("/^[$fst][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
|
269 | 269 | preg_match("/^[$fst][$num][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
270 | 270 | preg_match("/^[$fst][$sec][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
271 | 271 | preg_match("/^[$fst][$sec][$num][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | // Returns the unixtime in microseconds. |
282 | 282 | function getmicrotime() { |
283 | 283 | $mtime = microtime(); |
284 | - $mtime = explode(" ",$mtime); |
|
284 | + $mtime = explode(" ", $mtime); |
|
285 | 285 | $mtime = $mtime[1] + $mtime[0]; |
286 | 286 | |
287 | 287 | return $mtime; |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | global $timestamp_last, $timestamp_start; |
295 | 295 | $t = getmicrotime(); |
296 | 296 | twfy_debug("TIME", sprintf("%f msecs since start; %f msecs since last; %s", |
297 | - ($t - $timestamp_start)*1000.0, ($t - $timestamp_last)*1000.0, $label)); |
|
297 | + ($t - $timestamp_start) * 1000.0, ($t - $timestamp_last) * 1000.0, $label)); |
|
298 | 298 | $timestamp_last = $t; |
299 | 299 | } |
300 | 300 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | if (preg_match("/^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/", $timestamp, $matches)) { |
309 | 309 | list($string, $year, $month, $day, $hour, $min, $sec) = $matches; |
310 | 310 | |
311 | - return gmdate ($format, gmmktime($hour, $min, $sec, $month, $day, $year)); |
|
311 | + return gmdate($format, gmmktime($hour, $min, $sec, $month, $day, $year)); |
|
312 | 312 | } else { |
313 | 313 | return ""; |
314 | 314 | } |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | list($string, $year, $month, $day) = $matches; |
330 | 330 | if ($year < 1902) { # gmdate fns only go back to Dec. 1901 |
331 | 331 | if ($format == SHORTDATEFORMAT) { |
332 | - return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year"; |
|
332 | + return ($day + 0) . ' ' . $format_date_months_short[$month + 0] . " $year"; |
|
333 | 333 | } else { |
334 | - return ($day+0) . ' ' . $format_date_months[$month+0] . " $year"; |
|
334 | + return ($day + 0) . ' ' . $format_date_months[$month + 0] . " $year"; |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | - return gmdate ($format, gmmktime(0, 0, 0, $month, $day, $year)); |
|
338 | + return gmdate($format, gmmktime(0, 0, 0, $month, $day, $year)); |
|
339 | 339 | } else { |
340 | 340 | return ""; |
341 | 341 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | if (preg_match("/^(\d\d):(\d\d):(\d\d)$/", $time, $matches)) { |
352 | 352 | list($string, $hour, $min, $sec) = $matches; |
353 | 353 | |
354 | - return gmdate ($format, gmmktime($hour, $min, $sec)); |
|
354 | + return gmdate($format, gmmktime($hour, $min, $sec)); |
|
355 | 355 | } else { |
356 | 356 | return ""; |
357 | 357 | } |
@@ -372,16 +372,16 @@ discard block |
||
372 | 372 | $in_seconds = strtotime($datetime); |
373 | 373 | $now = time(); |
374 | 374 | |
375 | - $diff = $now - $in_seconds; |
|
376 | - $months = floor($diff/2419200); |
|
375 | + $diff = $now - $in_seconds; |
|
376 | + $months = floor($diff / 2419200); |
|
377 | 377 | $diff -= $months * 2419200; |
378 | - $weeks = floor($diff/604800); |
|
379 | - $diff -= $weeks*604800; |
|
380 | - $days = floor($diff/86400); |
|
378 | + $weeks = floor($diff / 604800); |
|
379 | + $diff -= $weeks * 604800; |
|
380 | + $days = floor($diff / 86400); |
|
381 | 381 | $diff -= $days * 86400; |
382 | - $hours = floor($diff/3600); |
|
382 | + $hours = floor($diff / 3600); |
|
383 | 383 | $diff -= $hours * 3600; |
384 | - $minutes = floor($diff/60); |
|
384 | + $minutes = floor($diff / 60); |
|
385 | 385 | $diff -= $minutes * 60; |
386 | 386 | $seconds = $diff; |
387 | 387 | |
@@ -395,27 +395,27 @@ discard block |
||
395 | 395 | $relative_date = ''; |
396 | 396 | if ($weeks > 0) { |
397 | 397 | // Weeks and days |
398 | - $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':''); |
|
399 | - $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):''; |
|
398 | + $relative_date .= ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : ''); |
|
399 | + $relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : ''; |
|
400 | 400 | } elseif ($days > 0) { |
401 | 401 | // days and hours |
402 | - $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':''); |
|
403 | - $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):''; |
|
402 | + $relative_date .= ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : ''); |
|
403 | + $relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : ''; |
|
404 | 404 | } elseif ($hours > 0) { |
405 | 405 | // hours and minutes |
406 | - $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''); |
|
407 | - $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):''; |
|
406 | + $relative_date .= ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : ''); |
|
407 | + $relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : ''; |
|
408 | 408 | } elseif ($minutes > 0) { |
409 | 409 | // minutes only |
410 | - $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''); |
|
410 | + $relative_date .= ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : ''); |
|
411 | 411 | } else { |
412 | 412 | // seconds only |
413 | - $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':''); |
|
413 | + $relative_date .= ($relative_date ? ', ' : '') . $seconds . ' second' . ($seconds > 1 ? 's' : ''); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 | |
417 | 417 | // Return relative date and add proper verbiage |
418 | - return $relative_date.' ago'; |
|
418 | + return $relative_date . ' ago'; |
|
419 | 419 | |
420 | 420 | } |
421 | 421 | |
@@ -464,10 +464,10 @@ discard block |
||
464 | 464 | $text = substr($text, $start); |
465 | 465 | |
466 | 466 | // Word boundary. |
467 | - if (preg_match ("/.+?\b(.*)/", $text, $matches)) { |
|
467 | + if (preg_match("/.+?\b(.*)/", $text, $matches)) { |
|
468 | 468 | $text = $matches[1]; |
469 | 469 | // Strip spare space at the start. |
470 | - $text = preg_replace ("/^\s/", '', $text); |
|
470 | + $text = preg_replace("/^\s/", '', $text); |
|
471 | 471 | } |
472 | 472 | $text = '...' . $text; |
473 | 473 | } |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | $text = substr($text, 0, $length - 3); |
480 | 480 | |
481 | 481 | // Word boundary. |
482 | - if (preg_match ("/(.*)\s.+/", $text, $matches)) { |
|
482 | + if (preg_match("/(.*)\s.+/", $text, $matches)) { |
|
483 | 483 | $text = $matches[1]; |
484 | 484 | // Strip spare space at the end. |
485 | - $text = preg_replace ("/\s$/", '', $text); |
|
485 | + $text = preg_replace("/\s$/", '', $text); |
|
486 | 486 | } |
487 | 487 | // We don't want to use the HTML entity for an ellipsis (…), because then |
488 | 488 | // it screws up when we subsequently use htmlentities() to print the returned |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | |
515 | 515 | if ($filter_type == 'strict') { |
516 | 516 | // No tags allowed at all! |
517 | - $filter->allowed = array (); |
|
517 | + $filter->allowed = array(); |
|
518 | 518 | } else { |
519 | 519 | // Comment. |
520 | 520 | // Only allowing <a href>, <b>, <strong>, <i> and <em> |
521 | - $filter->allowed = array ( |
|
521 | + $filter->allowed = array( |
|
522 | 522 | 'a' => array('href'), |
523 | 523 | 'strong' => array(), |
524 | 524 | 'em' => array(), |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | |
632 | 632 | // $gid will be like 'uk.org.publicwhip/debate/2003-02-28.475.3'. |
633 | 633 | |
634 | - $newgid = substr($gid, strrpos($gid, '/')+1 ); |
|
634 | + $newgid = substr($gid, strrpos($gid, '/') + 1); |
|
635 | 635 | return $newgid; |
636 | 636 | } |
637 | 637 | |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | // will be like 2003-11-20.966.0 |
643 | 643 | // This function returns 966.0 |
644 | 644 | |
645 | - return substr( $gid, (strpos($gid, '.') + 1) ); |
|
645 | + return substr($gid, (strpos($gid, '.') + 1)); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | function preg_replacement_quote($s) { |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | global $PAGE; |
687 | 687 | |
688 | 688 | if (!isset($data['to']) || $data['to'] == '') { |
689 | - $PAGE->error_message ("We need an email address to send to."); |
|
689 | + $PAGE->error_message("We need an email address to send to."); |
|
690 | 690 | return false; |
691 | 691 | } |
692 | 692 | |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | if (isset($data['subject'])) { |
718 | 718 | $subject = trim($data['subject']); |
719 | 719 | } else { |
720 | - $subject = trim( substr($firstline, 8) ); |
|
720 | + $subject = trim(substr($firstline, 8)); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | // Either way, remove this subject line from the template. |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | } elseif (isset($data['subject'])) { |
727 | 727 | $subject = $data['subject']; |
728 | 728 | } else { |
729 | - $PAGE->error_message ("We don't have a subject line for the email, so it wasn't sent."); |
|
729 | + $PAGE->error_message("We don't have a subject line for the email, so it wasn't sent."); |
|
730 | 730 | return false; |
731 | 731 | } |
732 | 732 | |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | $replace = array(); |
737 | 737 | |
738 | 738 | foreach ($merge as $key => $val) { |
739 | - $search[] = '/{'.$key.'}/'; |
|
739 | + $search[] = '/{' . $key . '}/'; |
|
740 | 740 | $replace[] = preg_replacement_quote($val); |
741 | 741 | } |
742 | 742 | |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | $htmltext = preg_replace($search, $replace, $htmltext); |
745 | 745 | |
746 | 746 | // Send it! |
747 | - $success = send_email ($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces, $htmltext); |
|
747 | + $success = send_email($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces, $htmltext); |
|
748 | 748 | |
749 | 749 | return $success; |
750 | 750 | |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | return $envelope_sender; |
760 | 760 | } |
761 | 761 | |
762 | -function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false, $html='') { |
|
762 | +function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false, $html = '') { |
|
763 | 763 | // Use this rather than PHP's mail() direct, so we can make alterations |
764 | 764 | // easily to all the emails we send out from the site. |
765 | 765 | // eg, we might want to add a .sig to everything here... |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | // http://www.iamcal.com/publish/article.php?id=13 |
806 | 806 | |
807 | 807 | // Call this with a key name to get a GET or POST variable. |
808 | -function get_http_var($name, $default='') { |
|
808 | +function get_http_var($name, $default = '') { |
|
809 | 809 | if (array_key_exists($name, $_GET)) { |
810 | 810 | return clean_var($_GET[$name]); |
811 | 811 | } |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | } |
832 | 832 | |
833 | 833 | // Call this with a key name to get a COOKIE variable. |
834 | -function get_cookie_var($name, $default='') { |
|
834 | +function get_cookie_var($name, $default = '') { |
|
835 | 835 | if (array_key_exists($name, $_COOKIE)) { |
836 | 836 | return clean_var($_COOKIE[$name]); |
837 | 837 | } |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | // Pass it an array of key names that should not be generated as |
843 | 843 | // hidden form variables. It then outputs hidden form variables |
844 | 844 | // based on the session_vars for this page. |
845 | -function hidden_form_vars ($omit = array()) { |
|
845 | +function hidden_form_vars($omit = array()) { |
|
846 | 846 | global $DATA, $this_page; |
847 | 847 | |
848 | 848 | $session_vars = $DATA->page_metadata($this_page, "session_vars"); |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | } |
856 | 856 | |
857 | 857 | // Deprecated. Use hidden_form_vars, above, instead. |
858 | -function hidden_vars ($omit = array()) { |
|
858 | +function hidden_vars($omit = array()) { |
|
859 | 859 | global $DATA; |
860 | 860 | |
861 | 861 | foreach ($args as $key => $val) { |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | function entities_to_numbers($string) { |
899 | 899 | $string = str_replace( |
900 | 900 | array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é'), |
901 | - array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é' ), |
|
901 | + array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é'), |
|
902 | 902 | $string |
903 | 903 | ); |
904 | 904 | return $string; |
@@ -915,9 +915,9 @@ discard block |
||
915 | 915 | } |
916 | 916 | } |
917 | 917 | |
918 | - $s = array(' ', '&', 'ô', 'Ö', 'ö', 'â', 'í', 'á', 'ú', 'é', 'ó', 'Ó'); |
|
919 | - $s2 = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93"); |
|
920 | - $r = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o'); |
|
918 | + $s = array(' ', '&', 'ô', 'Ö', 'ö', 'â', 'í', 'á', 'ú', 'é', 'ó', 'Ó'); |
|
919 | + $s2 = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93"); |
|
920 | + $r = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o'); |
|
921 | 921 | $name = preg_replace('#^the #', '', strtolower($name)); |
922 | 922 | |
923 | 923 | $out = ''; |
@@ -1075,8 +1075,8 @@ discard block |
||
1075 | 1075 | } |
1076 | 1076 | $out .= '<li>' . $body . '<ul>'; |
1077 | 1077 | } else { |
1078 | - $LISTURL->insert( array( 'id' => $gid ) ); |
|
1079 | - $out .= '<li><a href="'.$LISTURL->generate().'">'; |
|
1078 | + $LISTURL->insert(array('id' => $gid)); |
|
1079 | + $out .= '<li><a href="' . $LISTURL->generate() . '">'; |
|
1080 | 1080 | $out .= $body . '</a>'; |
1081 | 1081 | } |
1082 | 1082 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | return $return; |
1146 | 1146 | } |
1147 | 1147 | |
1148 | -function redirect($url, $code=302) { |
|
1148 | +function redirect($url, $code = 302) { |
|
1149 | 1149 | if (defined('TESTING')) { |
1150 | 1150 | print "Location: $url"; |
1151 | 1151 | } else { |
@@ -50,7 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | // If we can show this header, then, er, show it. |
52 | 52 | if ( in_array($header, $allowed_headers) || $debug_level >= 4) { |
53 | - if (is_array($text)) $text = call_user_func($text); |
|
53 | + if (is_array($text)) { |
|
54 | + $text = call_user_func($text); |
|
55 | + } |
|
54 | 56 | print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n"; |
55 | 57 | } |
56 | 58 | } |
@@ -66,7 +68,9 @@ discard block |
||
66 | 68 | global $PAGE; |
67 | 69 | |
68 | 70 | # Ignore errors we've asked to ignore |
69 | - if (error_reporting()==0) return; |
|
71 | + if (error_reporting()==0) { |
|
72 | + return; |
|
73 | + } |
|
70 | 74 | |
71 | 75 | // define an assoc array of error string |
72 | 76 | // in reality the only entries we should |
@@ -210,19 +214,29 @@ discard block |
||
210 | 214 | array_shift($traceArr); |
211 | 215 | $tabs = sizeof($traceArr)-1; |
212 | 216 | foreach ($traceArr as $arr) { |
213 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
217 | + for ($i=0; $i < $tabs; $i++) { |
|
218 | + $s .= ' '; |
|
219 | + } |
|
214 | 220 | $tabs -= 1; |
215 | - if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
221 | + if (isset($arr['class'])) { |
|
222 | + $s .= $arr['class'].'.'; |
|
223 | + } |
|
216 | 224 | $args = array(); |
217 | - if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
|
225 | + if (isset($arr['args'])) { |
|
226 | + foreach ($arr['args'] as $v) { |
|
218 | 227 | if (is_null($v)) $args[] = 'null'; |
219 | - elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']'; |
|
220 | - elseif (is_object($v)) $args[] = 'Object:'.get_class($v); |
|
221 | - elseif (is_bool($v)) $args[] = $v ? 'true' : 'false'; |
|
222 | - else { |
|
228 | + } elseif (is_array($v)) { |
|
229 | + $args[] = 'Array['.sizeof($v).']'; |
|
230 | + } elseif (is_object($v)) { |
|
231 | + $args[] = 'Object:'.get_class($v); |
|
232 | + } elseif (is_bool($v)) { |
|
233 | + $args[] = $v ? 'true' : 'false'; |
|
234 | + } else { |
|
223 | 235 | $v = (string) @$v; |
224 | 236 | $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
225 | - if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
|
237 | + if (strlen($v) > $MAXSTRLEN) { |
|
238 | + $str .= '...'; |
|
239 | + } |
|
226 | 240 | $args[] = $str; |
227 | 241 | } |
228 | 242 | } |
@@ -233,7 +247,9 @@ discard block |
||
233 | 247 | // $arr['line'],$arr['file'],$arr['file']); |
234 | 248 | $s .= "\n"; |
235 | 249 | } |
236 | - if ($print) print $s; |
|
250 | + if ($print) { |
|
251 | + print $s; |
|
252 | + } |
|
237 | 253 | } |
238 | 254 | |
239 | 255 | return $s; |
@@ -327,7 +343,8 @@ discard block |
||
327 | 343 | |
328 | 344 | if (preg_match("/^(\d\d\d\d)-(\d\d?)-(\d\d?)$/", $date, $matches)) { |
329 | 345 | list($string, $year, $month, $day) = $matches; |
330 | - if ($year < 1902) { # gmdate fns only go back to Dec. 1901 |
|
346 | + if ($year < 1902) { |
|
347 | +# gmdate fns only go back to Dec. 1901 |
|
331 | 348 | if ($format == SHORTDATEFORMAT) { |
332 | 349 | return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year"; |
333 | 350 | } else { |
@@ -764,7 +781,9 @@ discard block |
||
764 | 781 | // easily to all the emails we send out from the site. |
765 | 782 | // eg, we might want to add a .sig to everything here... |
766 | 783 | |
767 | - if (!$from) $from = CONTACTEMAIL; |
|
784 | + if (!$from) { |
|
785 | + $from = CONTACTEMAIL; |
|
786 | + } |
|
768 | 787 | |
769 | 788 | $mail = new PHPMailer(true); |
770 | 789 | $mail->isSMTP(); |
@@ -870,17 +889,21 @@ discard block |
||
870 | 889 | $rank = $rank + 0; |
871 | 890 | |
872 | 891 | # 11th, 12th, 13th use "th" not "st", "nd", "rd" |
873 | - if (floor(($rank % 100) / 10) == 1) |
|
874 | - return $rank . "th"; |
|
892 | + if (floor(($rank % 100) / 10) == 1) { |
|
893 | + return $rank . "th"; |
|
894 | + } |
|
875 | 895 | # 1st |
876 | - if ($rank % 10 == 1) |
|
877 | - return $rank . "st"; |
|
896 | + if ($rank % 10 == 1) { |
|
897 | + return $rank . "st"; |
|
898 | + } |
|
878 | 899 | # 2nd |
879 | - if ($rank % 10 == 2) |
|
880 | - return $rank . "nd"; |
|
900 | + if ($rank % 10 == 2) { |
|
901 | + return $rank . "nd"; |
|
902 | + } |
|
881 | 903 | # 3rd |
882 | - if ($rank % 10 == 3) |
|
883 | - return $rank . "rd"; |
|
904 | + if ($rank % 10 == 3) { |
|
905 | + return $rank . "rd"; |
|
906 | + } |
|
884 | 907 | # Everything else use th |
885 | 908 | |
886 | 909 | return $rank . "th"; |
@@ -888,8 +911,9 @@ discard block |
||
888 | 911 | |
889 | 912 | function make_plural($word, $number) |
890 | 913 | { |
891 | - if ($number == 1) |
|
892 | - return $word; |
|
914 | + if ($number == 1) { |
|
915 | + return $word; |
|
916 | + } |
|
893 | 917 | return $word . "s"; |
894 | 918 | } |
895 | 919 | |
@@ -923,8 +947,7 @@ discard block |
||
923 | 947 | $out = ''; |
924 | 948 | |
925 | 949 | // Insert the Person ID if known. |
926 | - if ($pid !== null) |
|
927 | - { |
|
950 | + if ($pid !== null) { |
|
928 | 951 | $out .= $pid . '/'; |
929 | 952 | } |
930 | 953 | |
@@ -932,8 +955,7 @@ discard block |
||
932 | 955 | $out .= urlencode(str_replace($s2, $r, str_replace($s, $r, $name))); |
933 | 956 | |
934 | 957 | // If there is a constituency, inject that too |
935 | - if ($const && $house == HOUSE_TYPE_COMMONS) |
|
936 | - { |
|
958 | + if ($const && $house == HOUSE_TYPE_COMMONS) { |
|
937 | 959 | $out .= '/' . urlencode(str_replace($s2, $r, str_replace($s, $r, strtolower($const)))); |
938 | 960 | } |
939 | 961 | |
@@ -945,10 +967,16 @@ discard block |
||
945 | 967 | switch ($house) { |
946 | 968 | case HOUSE_TYPE_LORDS: |
947 | 969 | $s = ''; |
948 | - if (!$family_name) $s = 'the '; |
|
970 | + if (!$family_name) { |
|
971 | + $s = 'the '; |
|
972 | + } |
|
949 | 973 | $s .= $title; |
950 | - if ($family_name) $s .= ' ' . $family_name; |
|
951 | - if ($lordofname) $s .= ' of ' . $lordofname; |
|
974 | + if ($family_name) { |
|
975 | + $s .= ' ' . $family_name; |
|
976 | + } |
|
977 | + if ($lordofname) { |
|
978 | + $s .= ' of ' . $lordofname; |
|
979 | + } |
|
952 | 980 | return $s; |
953 | 981 | |
954 | 982 | case HOUSE_TYPE_ROYAL: |
@@ -966,14 +994,18 @@ discard block |
||
966 | 994 | } |
967 | 995 | |
968 | 996 | function by_peer_name($a, $b) { |
969 | - if (!$a['family_name'] && !$b['family_name']) |
|
970 | - return strcmp($a['lordofname'], $b['lordofname']); |
|
971 | - if (!$a['family_name']) |
|
972 | - return strcmp($a['lordofname'], $b['family_name']); |
|
973 | - if (!$b['family_name']) |
|
974 | - return strcmp($a['family_name'], $b['lordofname']); |
|
975 | - if (strcmp($a['family_name'], $b['family_name'])) |
|
976 | - return strcmp($a['family_name'], $b['family_name']); |
|
997 | + if (!$a['family_name'] && !$b['family_name']) { |
|
998 | + return strcmp($a['lordofname'], $b['lordofname']); |
|
999 | + } |
|
1000 | + if (!$a['family_name']) { |
|
1001 | + return strcmp($a['lordofname'], $b['family_name']); |
|
1002 | + } |
|
1003 | + if (!$b['family_name']) { |
|
1004 | + return strcmp($a['family_name'], $b['lordofname']); |
|
1005 | + } |
|
1006 | + if (strcmp($a['family_name'], $b['family_name'])) { |
|
1007 | + return strcmp($a['family_name'], $b['family_name']); |
|
1008 | + } |
|
977 | 1009 | return strcmp($a['lordofname'], $b['lordofname']); |
978 | 1010 | } |
979 | 1011 | |
@@ -1000,12 +1032,17 @@ discard block |
||
1000 | 1032 | 'Lords in Waiting (HM Household)' => 'Government Whip', |
1001 | 1033 | 'Baronesses in Waiting, HM Household' => 'Government Whip', |
1002 | 1034 | ); |
1003 | - if ($pos) { # Government post, or Chairman of Select Committee |
|
1035 | + if ($pos) { |
|
1036 | +# Government post, or Chairman of Select Committee |
|
1004 | 1037 | $pretty = $pos; |
1005 | - if ($dept && $dept != 'No Department') $pretty .= ", $dept"; |
|
1006 | - if (array_key_exists($pretty, $lookup)) |
|
1007 | - $pretty = $lookup[$pretty]; |
|
1008 | - } else { # Member of Select Committee |
|
1038 | + if ($dept && $dept != 'No Department') { |
|
1039 | + $pretty .= ", $dept"; |
|
1040 | + } |
|
1041 | + if (array_key_exists($pretty, $lookup)) { |
|
1042 | + $pretty = $lookup[$pretty]; |
|
1043 | + } |
|
1044 | + } else { |
|
1045 | +# Member of Select Committee |
|
1009 | 1046 | $pretty = "Member, $dept"; |
1010 | 1047 | } |
1011 | 1048 | return $pretty; |
@@ -1023,13 +1060,16 @@ discard block |
||
1023 | 1060 | } |
1024 | 1061 | |
1025 | 1062 | // single date? |
1026 | - if (isset($data['date'])) $one_date = true; |
|
1063 | + if (isset($data['date'])) { |
|
1064 | + $one_date = true; |
|
1065 | + } |
|
1027 | 1066 | |
1028 | 1067 | // remove empty entries, so they don't produce errors |
1029 | 1068 | foreach (array_keys($hansardmajors) as $major) { |
1030 | 1069 | if (array_key_exists($major, $data)) { |
1031 | - if (count($data[$major]) == 0) |
|
1032 | - unset($data[$major]); |
|
1070 | + if (count($data[$major]) == 0) { |
|
1071 | + unset($data[$major]); |
|
1072 | + } |
|
1033 | 1073 | } |
1034 | 1074 | } |
1035 | 1075 | |
@@ -1038,22 +1078,29 @@ discard block |
||
1038 | 1078 | if (!$one_date) { |
1039 | 1079 | $todaystime = gmmktime(0, 0, 0, date('m'), date('d'), date('Y')); |
1040 | 1080 | foreach ($data as $major => $array) { |
1041 | - if (!in_array('timestamp', $array)) $daytext[$major] = "The most recent "; |
|
1042 | - elseif ($todaystime - $array['timestamp'] == 86400) $daytext[$major] = "Yesterday’s"; |
|
1043 | - elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1044 | - else $daytext[$major] = "The most recent "; |
|
1081 | + if (!in_array('timestamp', $array)) { |
|
1082 | + $daytext[$major] = "The most recent "; |
|
1083 | + } elseif ($todaystime - $array['timestamp'] == 86400) { |
|
1084 | + $daytext[$major] = "Yesterday’s"; |
|
1085 | + } elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) { |
|
1086 | + $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1087 | + } else { |
|
1088 | + $daytext[$major] = "The most recent "; |
|
1089 | + } |
|
1045 | 1090 | } |
1046 | 1091 | } |
1047 | 1092 | |
1048 | 1093 | //build html |
1049 | 1094 | foreach ($printed_majors as $p_major) { |
1050 | - if (!array_key_exists($p_major, $data)) |
|
1051 | - continue; |
|
1095 | + if (!array_key_exists($p_major, $data)) { |
|
1096 | + continue; |
|
1097 | + } |
|
1052 | 1098 | |
1053 | - if ($one_date) |
|
1054 | - $date = $data['date']; |
|
1055 | - else |
|
1056 | - $date = $data[$p_major]['hdate']; |
|
1099 | + if ($one_date) { |
|
1100 | + $date = $data['date']; |
|
1101 | + } else { |
|
1102 | + $date = $data[$p_major]['hdate']; |
|
1103 | + } |
|
1057 | 1104 | $q = $db->query('SELECT section_id, body, gid |
1058 | 1105 | FROM hansard, epobject |
1059 | 1106 | WHERE hansard.epobject_id = epobject.epobject_id ' |
@@ -1105,14 +1152,16 @@ discard block |
||
1105 | 1152 | } |
1106 | 1153 | |
1107 | 1154 | $return .= '<a href="'; |
1108 | - if (isset($data[$major]['listurl'])) |
|
1109 | - $return .= $data[$major]['listurl']; |
|
1110 | - else { |
|
1155 | + if (isset($data[$major]['listurl'])) { |
|
1156 | + $return .= $data[$major]['listurl']; |
|
1157 | + } else { |
|
1111 | 1158 | $LISTURL->reset(); |
1112 | 1159 | $return .= $LISTURL->generate(); |
1113 | 1160 | } |
1114 | 1161 | $return .= '">' . $hansardmajors[$major]['title'] . '</a>'; |
1115 | - if (isset($daytext[$major])) $return; |
|
1162 | + if (isset($daytext[$major])) { |
|
1163 | + $return; |
|
1164 | + } |
|
1116 | 1165 | $return .= '</h4>'; |
1117 | 1166 | |
1118 | 1167 | return $return; |
@@ -1120,20 +1169,21 @@ discard block |
||
1120 | 1169 | |
1121 | 1170 | function score_to_strongly($dmpscore) { |
1122 | 1171 | $dmpdesc = "unknown about"; |
1123 | - if ($dmpscore > 0.95 && $dmpscore <= 1.0) |
|
1124 | - $dmpdesc = "consistently voted against"; |
|
1125 | - elseif ($dmpscore > 0.85) |
|
1126 | - $dmpdesc = "almost always voted against"; |
|
1127 | - elseif ($dmpscore > 0.6) |
|
1128 | - $dmpdesc = "generally voted against"; |
|
1129 | - elseif ($dmpscore > 0.4) |
|
1130 | - $dmpdesc = "voted a mixture of for and against"; |
|
1131 | - elseif ($dmpscore > 0.15) |
|
1132 | - $dmpdesc = "generally voted for"; |
|
1133 | - elseif ($dmpscore > 0.05) |
|
1134 | - $dmpdesc = "almost always voted for"; |
|
1135 | - elseif ($dmpscore >= 0.0) |
|
1136 | - $dmpdesc = "consistently voted for"; |
|
1172 | + if ($dmpscore > 0.95 && $dmpscore <= 1.0) { |
|
1173 | + $dmpdesc = "consistently voted against"; |
|
1174 | + } elseif ($dmpscore > 0.85) { |
|
1175 | + $dmpdesc = "almost always voted against"; |
|
1176 | + } elseif ($dmpscore > 0.6) { |
|
1177 | + $dmpdesc = "generally voted against"; |
|
1178 | + } elseif ($dmpscore > 0.4) { |
|
1179 | + $dmpdesc = "voted a mixture of for and against"; |
|
1180 | + } elseif ($dmpscore > 0.15) { |
|
1181 | + $dmpdesc = "generally voted for"; |
|
1182 | + } elseif ($dmpscore > 0.05) { |
|
1183 | + $dmpdesc = "almost always voted for"; |
|
1184 | + } elseif ($dmpscore >= 0.0) { |
|
1185 | + $dmpdesc = "consistently voted for"; |
|
1186 | + } |
|
1137 | 1187 | return $dmpdesc; |
1138 | 1188 | } |
1139 | 1189 |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <div class="search-page__section__secondary search-page-sidebar"> |
2 | - <?php if ( isset( $search_sidebar['email'] ) ) { ?> |
|
2 | + <?php if (isset($search_sidebar['email'])) { ?> |
|
3 | 3 | <h2>Create an alert</h2> |
4 | 4 | <p class="sidebar-item-with-icon"> |
5 | 5 | <a href="<?= $search_sidebar['email'] ?>">Subscribe to an email alert</a> |
6 | 6 | for <em class="current-search-term"><?= $search_sidebar['email_desc'] ?></em> |
7 | - <?php if (isset( $search_sidebar['email_section'] ) ) { ?> |
|
7 | + <?php if (isset($search_sidebar['email_section'])) { ?> |
|
8 | 8 | <br><small>(or just <a href="<?= $search_sidebar['email_section'] ?>"><?= $search_sidebar['email_desc_section'] ?></a>)</small> |
9 | 9 | <?php } ?> |
10 | 10 | </p> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | Based on postcode <strong><?= $mp_data['postcode'] ?></strong> |
27 | 27 | <a href="<?= $mp_data['change_url'] ?>">(Change postcode)</a> |
28 | 28 | </p> |
29 | - <?php if ( isset( $mp_data ) && $type != 'mlas' ) { ?> |
|
29 | + <?php if (isset($mp_data) && $type != 'mlas') { ?> |
|
30 | 30 | <h3>Your <?= $mp_data['former'] ? $mp_data['former'] . ' ' : '' ?><?= $rep_name ?> is</h3> |
31 | 31 | </div> |
32 | 32 | <a href="<?= $mp_data['mp_url'] ?>" class="people-list__person"> |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | </p> |
39 | 39 | </a> |
40 | 40 | <?php } |
41 | - if ( isset($reps) ) { |
|
42 | - if ( isset($mp_data) && $type != 'mlas' ) { ?> |
|
41 | + if (isset($reps)) { |
|
42 | + if (isset($mp_data) && $type != 'mlas') { ?> |
|
43 | 43 | <div class="people-list__your-mp__replist-header"> |
44 | 44 | <?php } ?> |
45 | 45 | <h3>Your <?=$former ?> <?= $rep_plural == 'MSPs' ? 'regional ' : '' ?><?= $rep_plural ?> are</h3> |
46 | 46 | </div> |
47 | - <?php foreach ( $reps as $rep ) { ?> |
|
47 | + <?php foreach ($reps as $rep) { ?> |
|
48 | 48 | <a href="<?= $rep['mp_url'] ?>" class="people-list__person"> |
49 | 49 | <img class="people-list__person__image" src="<?= $rep['image'] ?>"> |
50 | 50 | <h2 class="people-list__person__name"><?= $rep['name'] ?></h2> |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | <div class="search-page__section search-page__section--search"> |
66 | 66 | <div class="search-page__section__primary"> |
67 | 67 | <p class="search-page-main-inputs"> |
68 | - <?php if ( $type == 'peers' ) { ?> |
|
68 | + <?php if ($type == 'peers') { ?> |
|
69 | 69 | <label for="find-mp-by-name-or-postcode">Find <?= $rep_plural ?> by name:</label> |
70 | - <?php } elseif ( $type == 'mlas' || $type == 'msps' ) { ?> |
|
70 | + <?php } elseif ($type == 'mlas' || $type == 'msps') { ?> |
|
71 | 71 | <label for="find-mp-by-name-or-postcode">Find your <?= $rep_name ?> by postcode:</label> |
72 | 72 | <?php } else { ?> |
73 | 73 | <label for="find-mp-by-name-or-postcode">Find your <?= $rep_name ?> by name or postcode:</label> |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | <div class="search-page__section__primary"> |
109 | 109 | <h2>All <?= $rep_plural ?></h2> |
110 | 110 | |
111 | - <?php if ( $type != 'peers' ) { ?> |
|
111 | + <?php if ($type != 'peers') { ?> |
|
112 | 112 | <ul class="search-result-display-options"> |
113 | - <?php if ( $order == 'given_name' ) { ?> |
|
113 | + <?php if ($order == 'given_name') { ?> |
|
114 | 114 | <li><strong>Sorted by</strong> First name</li> |
115 | 115 | <li>Sort by <a href="<?= $urls['by_last'] ?>">Last name</a> / <a href="<?= $urls['by_party'] ?>">Party</a></li> |
116 | - <?php } else if ( $order == 'party' ) { ?> |
|
116 | + <?php } else if ($order == 'party') { ?> |
|
117 | 117 | <li><strong>Sorted by</strong> Party</li> |
118 | 118 | <li>Sort by <a href="<?= $urls['by_first'] ?>">First name</a> / <a href="<?= $urls['by_last'] ?>">Last name</a></li> |
119 | 119 | <?php } else { ?> |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | </ul> |
124 | 124 | <?php } else { ?> |
125 | 125 | <ul class="search-result-display-options"> |
126 | - <?php if ( $order == 'party' ) { ?> |
|
126 | + <?php if ($order == 'party') { ?> |
|
127 | 127 | <li><strong>Sorted by</strong> Party</li> |
128 | 128 | <li>Sort by <a href="<?= $urls['by_name'] ?>">Name</a></li> |
129 | 129 | <?php } else { ?> |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | } |
174 | 174 | } |
175 | 175 | $initial_link = ''; |
176 | - foreach ( $data as $person ) { |
|
176 | + foreach ($data as $person) { |
|
177 | 177 | if ($order != 'party') { |
178 | - $initial = substr( strtoupper($person[$a_to_z_key]), 0, 1); |
|
179 | - if ( $initial != $current_initial ) { |
|
178 | + $initial = substr(strtoupper($person[$a_to_z_key]), 0, 1); |
|
179 | + if ($initial != $current_initial) { |
|
180 | 180 | $current_initial = $initial; |
181 | 181 | $initial_link = "name=\"$initial\" "; |
182 | 182 | } else { |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | </noscript> |
191 | 191 | <h2 class="people-list__person__name"><?= ucfirst($person['name']) ?></h2> |
192 | 192 | <p class="people-list__person__memberships"> |
193 | - <?php if ( $person['constituency'] ) { ?> |
|
193 | + <?php if ($person['constituency']) { ?> |
|
194 | 194 | <span class="people-list__person__constituency"><?= $person['constituency'] ?></span> |
195 | 195 | <?php } ?> |
196 | 196 | <span class="people-list__person__party <?= slugify($person['party']) ?>"><?= $person['party'] ?></span> |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | <a href="<?= $urls['by_csv'] ?>">Download this list as a CSV</a> |
209 | 209 | suitable for Excel |
210 | 210 | </p> |
211 | - <?php if ( $type == 'mps' ) { ?> |
|
211 | + <?php if ($type == 'mps') { ?> |
|
212 | 212 | <style> |
213 | 213 | .js #past-list-dates { display: none; } |
214 | 214 | </style> |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | </p> |
254 | 254 | </form> |
255 | 255 | |
256 | - <?php } else if ( $type == 'msps' ) { ?> |
|
256 | + <?php } else if ($type == 'msps') { ?> |
|
257 | 257 | <p class="past-list-dates" id="past-list-dates"> |
258 | 258 | <a href="<?= $urls['plain'] ?>?date=2011-05-05">MSPs at 2011 election</a> |
259 | 259 | <a href="<?= $urls['plain'] ?>?date=2007-05-03">MSPs at 2007 election</a> |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | </div> |
7 | 7 | |
8 | 8 | <?php |
9 | - if ( isset($content['data']['data']) ) { |
|
9 | + if (isset($content['data']['data'])) { |
|
10 | 10 | $data = $content['data']['data']; |
11 | 11 | include '_business_list.php'; ?> |
12 | 12 | <div class="business-section__secondary"> |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | include '_calendar_section.php'; |
21 | 21 | ?> |
22 | 22 | </div> |
23 | - <?php if ( isset($content['rssurl']) ) { ?> |
|
23 | + <?php if (isset($content['rssurl'])) { ?> |
|
24 | 24 | <div class="business-section__secondary__item"> |
25 | 25 | <p class="rss-feed"> |
26 | 26 | <a href="<?= WEBPATH . $content['rssurl'] ?>">RSS feed of <?= $title ?></a> |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | $divisions = array(); |
194 | 194 | foreach ($q as $row) { |
195 | - $divisions[] = $this->getParliamentDivisionDetails($row); |
|
195 | + $divisions[] = $this->getParliamentDivisionDetails($row); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | return $divisions; |
@@ -247,44 +247,44 @@ discard block |
||
247 | 247 | ); |
248 | 248 | |
249 | 249 | foreach ($q as $row) { |
250 | - $policy_id = $row['policy_id']; |
|
250 | + $policy_id = $row['policy_id']; |
|
251 | 251 | |
252 | - if (!array_key_exists($policy_id, $policy_divisions)) { |
|
252 | + if (!array_key_exists($policy_id, $policy_divisions)) { |
|
253 | 253 | $summary = array( |
254 | - 'max' => $row['latest'], |
|
255 | - 'min' => $row['earliest'], |
|
256 | - 'total' => $row['total'], |
|
257 | - 'for' => 0, 'against' => 0, 'absent' => 0, 'both' => 0, 'tell' => 0 |
|
254 | + 'max' => $row['latest'], |
|
255 | + 'min' => $row['earliest'], |
|
256 | + 'total' => $row['total'], |
|
257 | + 'for' => 0, 'against' => 0, 'absent' => 0, 'both' => 0, 'tell' => 0 |
|
258 | 258 | ); |
259 | 259 | |
260 | 260 | $policy_divisions[$policy_id] = $summary; |
261 | - } |
|
262 | - |
|
263 | - $summary = $policy_divisions[$policy_id]; |
|
264 | - |
|
265 | - $summary['total'] += $row['total']; |
|
266 | - if ($summary['max'] < $row['latest']) { |
|
267 | - $summary['max'] = $row['latest']; |
|
268 | - } |
|
269 | - if ($summary['min'] > $row['latest']) { |
|
270 | - $summary['min'] = $row['latest']; |
|
271 | - } |
|
272 | - |
|
273 | - $vote = $row['vote']; |
|
274 | - $policy_vote = str_replace('3', '', $row['policy_vote']); |
|
275 | - if ( $vote == 'absent' ) { |
|
276 | - $summary['absent'] += $row['total']; |
|
277 | - } else if ( $vote == 'both' ) { |
|
278 | - $summary['both'] += $row['total']; |
|
279 | - } else if ( strpos($vote, 'tell') !== false ) { |
|
280 | - $summary['tell'] += $row['total']; |
|
281 | - } else if ( $policy_vote == $vote ) { |
|
282 | - $summary['for'] += $row['total']; |
|
283 | - } else if ( $policy_vote != $vote ) { |
|
284 | - $summary['against'] += $row['total']; |
|
285 | - } |
|
286 | - |
|
287 | - $policy_divisions[$policy_id] = $summary; |
|
261 | + } |
|
262 | + |
|
263 | + $summary = $policy_divisions[$policy_id]; |
|
264 | + |
|
265 | + $summary['total'] += $row['total']; |
|
266 | + if ($summary['max'] < $row['latest']) { |
|
267 | + $summary['max'] = $row['latest']; |
|
268 | + } |
|
269 | + if ($summary['min'] > $row['latest']) { |
|
270 | + $summary['min'] = $row['latest']; |
|
271 | + } |
|
272 | + |
|
273 | + $vote = $row['vote']; |
|
274 | + $policy_vote = str_replace('3', '', $row['policy_vote']); |
|
275 | + if ( $vote == 'absent' ) { |
|
276 | + $summary['absent'] += $row['total']; |
|
277 | + } else if ( $vote == 'both' ) { |
|
278 | + $summary['both'] += $row['total']; |
|
279 | + } else if ( strpos($vote, 'tell') !== false ) { |
|
280 | + $summary['tell'] += $row['total']; |
|
281 | + } else if ( $policy_vote == $vote ) { |
|
282 | + $summary['for'] += $row['total']; |
|
283 | + } else if ( $policy_vote != $vote ) { |
|
284 | + $summary['against'] += $row['total']; |
|
285 | + } |
|
286 | + |
|
287 | + $policy_divisions[$policy_id] = $summary; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | return $policy_divisions; |
@@ -338,17 +338,17 @@ discard block |
||
338 | 338 | ); |
339 | 339 | |
340 | 340 | $votes = array( |
341 | - 'yes_votes' => array(), |
|
342 | - 'no_votes' => array(), |
|
343 | - 'absent_votes' => array(), |
|
344 | - 'both_votes' => array() |
|
341 | + 'yes_votes' => array(), |
|
342 | + 'no_votes' => array(), |
|
343 | + 'absent_votes' => array(), |
|
344 | + 'both_votes' => array() |
|
345 | 345 | ); |
346 | 346 | |
347 | 347 | $party_breakdown = array( |
348 | - 'yes_votes' => array(), |
|
349 | - 'no_votes' => array(), |
|
350 | - 'absent_votes' => array(), |
|
351 | - 'both_votes' => array() |
|
348 | + 'yes_votes' => array(), |
|
349 | + 'no_votes' => array(), |
|
350 | + 'absent_votes' => array(), |
|
351 | + 'both_votes' => array() |
|
352 | 352 | ); |
353 | 353 | |
354 | 354 | # Sort Lords specially |
@@ -359,12 +359,12 @@ discard block |
||
359 | 359 | |
360 | 360 | foreach ($data as $vote) { |
361 | 361 | $detail = array( |
362 | - 'person_id' => $vote['person_id'], |
|
363 | - 'name' => ucfirst(member_full_name($args['house'], $vote['title'], $vote['given_name'], |
|
362 | + 'person_id' => $vote['person_id'], |
|
363 | + 'name' => ucfirst(member_full_name($args['house'], $vote['title'], $vote['given_name'], |
|
364 | 364 | $vote['family_name'], $vote['lordofname'])), |
365 | - 'party' => $vote['party'], |
|
366 | - 'proxy' => false, |
|
367 | - 'teller' => false |
|
365 | + 'party' => $vote['party'], |
|
366 | + 'proxy' => false, |
|
367 | + 'teller' => false |
|
368 | 368 | ); |
369 | 369 | |
370 | 370 | if (strpos($vote['vote'], 'tell') !== false) { |
@@ -385,23 +385,23 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | if ($vote['vote'] == 'aye' or $vote['vote'] == 'tellaye') { |
388 | - $votes['yes_votes'][] = $detail; |
|
389 | - @$party_breakdown['yes_votes'][$detail['party']]++; |
|
388 | + $votes['yes_votes'][] = $detail; |
|
389 | + @$party_breakdown['yes_votes'][$detail['party']]++; |
|
390 | 390 | } else if ($vote['vote'] == 'no' or $vote['vote'] == 'tellno') { |
391 | - $votes['no_votes'][] = $detail; |
|
392 | - @$party_breakdown['no_votes'][$detail['party']]++; |
|
391 | + $votes['no_votes'][] = $detail; |
|
392 | + @$party_breakdown['no_votes'][$detail['party']]++; |
|
393 | 393 | } else if ($vote['vote'] == 'absent') { |
394 | - $votes['absent_votes'][] = $detail; |
|
395 | - @$party_breakdown['absent_votes'][$detail['party']]++; |
|
394 | + $votes['absent_votes'][] = $detail; |
|
395 | + @$party_breakdown['absent_votes'][$detail['party']]++; |
|
396 | 396 | } else if ($vote['vote'] == 'both') { |
397 | - $votes['both_votes'][] = $detail; |
|
398 | - @$party_breakdown['both_votes'][$detail['party']]++; |
|
397 | + $votes['both_votes'][] = $detail; |
|
398 | + @$party_breakdown['both_votes'][$detail['party']]++; |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | 402 | foreach ($votes as $vote => $count) { // array('yes_votes', 'no_votes', 'absent_votes', 'both_votes') as $vote) { |
403 | - $votes[$vote . '_by_party'] = $votes[$vote]; |
|
404 | - usort($votes[$vote . '_by_party'], function ($a, $b) { |
|
403 | + $votes[$vote . '_by_party'] = $votes[$vote]; |
|
404 | + usort($votes[$vote . '_by_party'], function ($a, $b) { |
|
405 | 405 | return $a['party']>$b['party']; |
406 | 406 | }); |
407 | 407 | } |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | ':count' => $number |
69 | 69 | ); |
70 | 70 | |
71 | - if ( is_string($houses) ) { |
|
72 | - $houses = array( $houses ); |
|
71 | + if (is_string($houses)) { |
|
72 | + $houses = array($houses); |
|
73 | 73 | } |
74 | 74 | |
75 | - if ( is_array($houses) && count($houses) > 0 ) { |
|
75 | + if (is_array($houses) && count($houses) > 0) { |
|
76 | 76 | $where = 'WHERE house IN ("' . implode('", "', $houses) . '")'; |
77 | 77 | } |
78 | 78 | |
79 | - if ( $this->member ) { |
|
79 | + if ($this->member) { |
|
80 | 80 | $select = "SELECT divisions.*, vote FROM divisions |
81 | 81 | LEFT JOIN persondivisionvotes ON divisions.division_id=persondivisionvotes.division_id AND person_id=:person_id"; |
82 | 82 | $params[':person_id'] = $this->member->person_id; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | public function getMemberDivisionsForPolicy($policyID = null) { |
216 | 216 | $where_extra = ''; |
217 | 217 | $args = array(':person_id' => $this->member->person_id); |
218 | - if ( $policyID ) { |
|
218 | + if ($policyID) { |
|
219 | 219 | $where_extra = 'AND policy_id = :policy_id'; |
220 | 220 | $args[':policy_id'] = $policyID; |
221 | 221 | } |
@@ -272,15 +272,15 @@ discard block |
||
272 | 272 | |
273 | 273 | $vote = $row['vote']; |
274 | 274 | $policy_vote = str_replace('3', '', $row['policy_vote']); |
275 | - if ( $vote == 'absent' ) { |
|
275 | + if ($vote == 'absent') { |
|
276 | 276 | $summary['absent'] += $row['total']; |
277 | - } else if ( $vote == 'both' ) { |
|
277 | + } else if ($vote == 'both') { |
|
278 | 278 | $summary['both'] += $row['total']; |
279 | - } else if ( strpos($vote, 'tell') !== false ) { |
|
279 | + } else if (strpos($vote, 'tell') !== false) { |
|
280 | 280 | $summary['tell'] += $row['total']; |
281 | - } else if ( $policy_vote == $vote ) { |
|
281 | + } else if ($policy_vote == $vote) { |
|
282 | 282 | $summary['for'] += $row['total']; |
283 | - } else if ( $policy_vote != $vote ) { |
|
283 | + } else if ($policy_vote != $vote) { |
|
284 | 284 | $summary['against'] += $row['total']; |
285 | 285 | } |
286 | 286 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | FROM person_names AS pn |
378 | 378 | WHERE person_id = :person_id |
379 | 379 | AND start_date <= :division_date AND end_date >= :division_date", |
380 | - [ ':person_id' => $vote['proxy'], ':division_date' => $row['division_date'] ] |
|
380 | + [':person_id' => $vote['proxy'], ':division_date' => $row['division_date']] |
|
381 | 381 | )->first(); |
382 | 382 | $detail['proxy'] = ucfirst(member_full_name( |
383 | 383 | HOUSE_TYPE_COMMONS, $q['title'], $q['given_name'], |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | |
402 | 402 | foreach ($votes as $vote => $count) { // array('yes_votes', 'no_votes', 'absent_votes', 'both_votes') as $vote) { |
403 | 403 | $votes[$vote . '_by_party'] = $votes[$vote]; |
404 | - usort($votes[$vote . '_by_party'], function ($a, $b) { |
|
405 | - return $a['party']>$b['party']; |
|
404 | + usort($votes[$vote . '_by_party'], function($a, $b) { |
|
405 | + return $a['party'] > $b['party']; |
|
406 | 406 | }); |
407 | 407 | } |
408 | 408 | |
@@ -456,10 +456,10 @@ discard block |
||
456 | 456 | $votes['against'] . ' ' . make_plural('vote', $votes['against']) . ' against' |
457 | 457 | ); |
458 | 458 | |
459 | - if ( $votes['both'] ) { |
|
459 | + if ($votes['both']) { |
|
460 | 460 | $actions[] = $votes['both'] . ' ' . make_plural('abstention', $votes['both']); |
461 | 461 | } |
462 | - if ( $votes['absent'] ) { |
|
462 | + if ($votes['absent']) { |
|
463 | 463 | $actions[] = $votes['absent'] . ' ' . make_plural('absence', $votes['absent']); |
464 | 464 | } |
465 | 465 | if ($max == $min) { |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | |
519 | 519 | private function constructYesNoVoteDescription($direction, $title, $short_text) { |
520 | 520 | $text = ' voted '; |
521 | - if ( $short_text ) { |
|
521 | + if ($short_text) { |
|
522 | 522 | $text .= $short_text; |
523 | 523 | } else { |
524 | 524 | $text .= "$direction on <em>$title</em>"; |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | * votes so we need to generate some text using the title of the division |
537 | 537 | */ |
538 | 538 | |
539 | - switch ( strtolower($vote) ) { |
|
539 | + switch (strtolower($vote)) { |
|
540 | 540 | case 'yes': |
541 | 541 | case 'aye': |
542 | 542 | $description = $this->constructYesNoVoteDescription('yes', $division_title, $yes_text); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | |
585 | 585 | if (array_key_exists('direction', $row)) { |
586 | 586 | $division['direction'] = $row['direction']; |
587 | - if ( strpos( $row['direction'], 'strong') !== false ) { |
|
587 | + if (strpos($row['direction'], 'strong') !== false) { |
|
588 | 588 | $division['strong'] = true; |
589 | 589 | } else { |
590 | 590 | $division['strong'] = false; |
@@ -616,24 +616,24 @@ discard block |
||
616 | 616 | foreach ($q as $row) { |
617 | 617 | $policy_id = $row['policy_id']; |
618 | 618 | |
619 | - if ( !array_key_exists($policy_id, $policies) ) { |
|
619 | + if (!array_key_exists($policy_id, $policies)) { |
|
620 | 620 | $policies[$policy_id] = array( |
621 | 621 | 'policy_id' => $policy_id, |
622 | 622 | 'weak_count' => 0, |
623 | 623 | 'divisions' => array() |
624 | 624 | ); |
625 | - if ( $this->policies ) { |
|
625 | + if ($this->policies) { |
|
626 | 626 | $policies[$policy_id]['desc'] = $this->policies->getPolicies()[$policy_id]; |
627 | 627 | $policies[$policy_id]['header'] = $this->policies->getPolicyDetails($policy_id); |
628 | 628 | } |
629 | - if ( $this->positions ) { |
|
629 | + if ($this->positions) { |
|
630 | 630 | $policies[$policy_id]['position'] = $this->positions->positionsById[$policy_id]; |
631 | 631 | } |
632 | 632 | } |
633 | 633 | |
634 | 634 | $division = $this->getDivisionDetails($row); |
635 | 635 | |
636 | - if ( !$division['strong'] ) { |
|
636 | + if (!$division['strong']) { |
|
637 | 637 | $policies[$policy_id]['weak_count']++; |
638 | 638 | } |
639 | 639 | |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | |
649 | 649 | $gid = get_canonical_gid($gid); |
650 | 650 | |
651 | - $q = $this->db->query("SELECT gid, major FROM hansard WHERE epobject_id = ( SELECT subsection_id FROM hansard WHERE gid = :gid )", array( ':gid' => $gid ))->first(); |
|
651 | + $q = $this->db->query("SELECT gid, major FROM hansard WHERE epobject_id = ( SELECT subsection_id FROM hansard WHERE gid = :gid )", array(':gid' => $gid))->first(); |
|
652 | 652 | if (!$q) { |
653 | 653 | return ''; |
654 | 654 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | if ($q) { |
66 | 66 | $text = $q['value']; |
67 | - if ( trim($text) == '' ) { |
|
67 | + if (trim($text) == '') { |
|
68 | 68 | $text = null; |
69 | 69 | } |
70 | 70 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | private function _set($key, $value) { |
76 | - if ( trim($value) == '' ) { |
|
76 | + if (trim($value) == '') { |
|
77 | 77 | $value = null; |
78 | 78 | } |
79 | 79 | $check_q = $this->db->query( |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ':key' => $key |
83 | 83 | ) |
84 | 84 | ); |
85 | - if ( $check_q->rows() ) { |
|
85 | + if ($check_q->rows()) { |
|
86 | 86 | $set_q = $this->db->query("UPDATE editorial set value = :value WHERE item = :key", |
87 | 87 | array( |
88 | 88 | ':key' => $key, |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | - if ( $set_q->success() ) { |
|
101 | + if ($set_q->success()) { |
|
102 | 102 | return true; |
103 | 103 | } |
104 | 104 | return false; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $this_page = 'spwransfront'; |
22 | 22 | $data = array(); |
23 | 23 | |
24 | - $args = array( 'months' => 1 ); |
|
24 | + $args = array('months' => 1); |
|
25 | 25 | $WRANSLIST = new \SPWRANSLIST; |
26 | 26 | |
27 | 27 | $wrans = array(); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | protected function getSearchSections() { |
45 | 45 | return array( |
46 | - array( 'section' => 'spwrans' ) |
|
46 | + array('section' => 'spwrans') |
|
47 | 47 | ); |
48 | 48 | } |
49 | 49 | |
@@ -54,29 +54,29 @@ discard block |
||
54 | 54 | $SPWRANSLIST = new \SPWRANSLIST; |
55 | 55 | $gid = $SPWRANSLIST->get_gid_from_spid($spid); |
56 | 56 | if ($gid) { |
57 | - if (preg_match('/uk\.org\.publicwhip\/spwa\/(\d{4}-\d\d-\d\d\.(.*))/',$gid,$m)) { |
|
57 | + if (preg_match('/uk\.org\.publicwhip\/spwa\/(\d{4}-\d\d-\d\d\.(.*))/', $gid, $m)) { |
|
58 | 58 | $URL = new \MySociety\TheyWorkForYou\Url('spwrans'); |
59 | 59 | $URL->reset(); |
60 | - $URL->insert( array('id' => $m[1]) ); |
|
60 | + $URL->insert(array('id' => $m[1])); |
|
61 | 61 | $fragment_identifier = '#g' . $m[2]; |
62 | 62 | header('Location: ' . $URL->generate('none') . $fragment_identifier, true, 303); |
63 | 63 | exit; |
64 | - } elseif (preg_match('/uk\.org\.publicwhip\/spor\/(\d{4}-\d\d-\d\d\.(.*))/',$gid,$m)) { |
|
64 | + } elseif (preg_match('/uk\.org\.publicwhip\/spor\/(\d{4}-\d\d-\d\d\.(.*))/', $gid, $m)) { |
|
65 | 65 | $URL = new \MySociety\TheyWorkForYou\Url('spdebates'); |
66 | 66 | $URL->reset(); |
67 | - $URL->insert( array('id' => $m[1]) ); |
|
67 | + $URL->insert(array('id' => $m[1])); |
|
68 | 68 | $fragment_identifier = '#g' . $m[2]; |
69 | 69 | header('Location: ' . $URL->generate('none') . $fragment_identifier, true, 303); |
70 | 70 | exit; |
71 | 71 | } else { |
72 | - $PAGE->error_message ("Strange GID ($gid) for that Scottish Parliament ID."); |
|
72 | + $PAGE->error_message("Strange GID ($gid) for that Scottish Parliament ID."); |
|
73 | 73 | } |
74 | 74 | } |
75 | - $PAGE->error_message ("Couldn't match that Scottish Parliament ID to a GID."); |
|
75 | + $PAGE->error_message("Couldn't match that Scottish Parliament ID to a GID."); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | protected function get_question_mentions_html($row_data) { |
79 | - if( count($row_data) == 0 ) { |
|
79 | + if (count($row_data) == 0) { |
|
80 | 80 | return ''; |
81 | 81 | } |
82 | 82 | $result = ''; |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | // Keep the references until after the history that's in a timeline: |
86 | 86 | $references = array(); |
87 | 87 | foreach ($row_data as $row) { |
88 | - if( ! $row["date"] ) { |
|
88 | + if (!$row["date"]) { |
|
89 | 89 | // If this mention isn't associated with a date, the difference won't be interesting. |
90 | 90 | $last_date = null; |
91 | 91 | } |
92 | 92 | $description = ''; |
93 | 93 | if ($last_date && ($last_date != $row["date"])) { |
94 | 94 | // Calculate how long the gap was in days: |
95 | - $daysdiff = (integer)((strtotime($row["date"]) - strtotime($last_date)) / 86400); |
|
95 | + $daysdiff = (integer) ((strtotime($row["date"]) - strtotime($last_date)) / 86400); |
|
96 | 96 | $daysstring = ($daysdiff == 1) ? "day" : "days"; |
97 | 97 | $further = ""; |
98 | - if( $first_difference_output ) { |
|
98 | + if ($first_difference_output) { |
|
99 | 99 | $first_difference_output = false; |
100 | 100 | } else { |
101 | 101 | $further = " a further"; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $inner = "BUG: Unknown mention type $row[type]"; |
107 | 107 | $date = format_date($row['date'], SHORTDATEFORMAT); |
108 | 108 | $url = $row['url']; |
109 | - if ( strpos($url, 'business/businessBulletin') !== false ) { |
|
109 | + if (strpos($url, 'business/businessBulletin') !== false) { |
|
110 | 110 | $url = str_replace('www.scottish', 'archive.scottish', $url); |
111 | 111 | } |
112 | 112 | switch ($row["type"]) { |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | $inner = "Mentioned in <a class=\"debate-speech__meta__link\" href=\"$url\">tabled written questions on $date</a>"; |
121 | 121 | break; |
122 | 122 | case 4: |
123 | - if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['gid'],$m) ) { |
|
123 | + if (preg_match('/^uk.org.publicwhip\/spq\/(.*)$/', $row['gid'], $m)) { |
|
124 | 124 | $URL = new \MySociety\TheyWorkForYou\Url("spwrans"); |
125 | - $URL->insert( array('spid' => $m[1]) ); |
|
125 | + $URL->insert(array('spid' => $m[1])); |
|
126 | 126 | $relative_url = $URL->generate("none"); |
127 | 127 | $inner = "Given a <a class=\"debate-speech__meta__link\" href=\"$relative_url\">written answer on $date</a>"; |
128 | 128 | } |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | $inner = "Given a holding answer on $date"; |
132 | 132 | break; |
133 | 133 | case 6: |
134 | - if( preg_match('/^uk.org.publicwhip\/spor\/(.*)$/',$row['mentioned_gid'],$m) ) { |
|
134 | + if (preg_match('/^uk.org.publicwhip\/spor\/(.*)$/', $row['mentioned_gid'], $m)) { |
|
135 | 135 | $URL = new \MySociety\TheyWorkForYou\Url("spdebates"); |
136 | - $URL->insert( array('id' => $m[1]) ); |
|
136 | + $URL->insert(array('id' => $m[1])); |
|
137 | 137 | $relative_url = $URL->generate("none"); |
138 | 138 | $inner = "<a href=\"$relative_url\">Asked in parliament on $date</a>"; |
139 | 139 | } |
140 | 140 | break; |
141 | 141 | case 7: |
142 | - if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['mentioned_gid'],$m) ) { |
|
142 | + if (preg_match('/^uk.org.publicwhip\/spq\/(.*)$/', $row['mentioned_gid'], $m)) { |
|
143 | 143 | $referencing_spid = $m[1]; |
144 | 144 | $URL = new \MySociety\TheyWorkForYou\Url("spwrans"); |
145 | - $URL->insert( array('spid' => $referencing_spid) ); |
|
145 | + $URL->insert(array('spid' => $referencing_spid)); |
|
146 | 146 | $relative_url = $URL->generate("none"); |
147 | 147 | $inner = "Referenced in <a href=\"$relative_url\">question $referencing_spid</a>"; |
148 | 148 | $reference = true; |
149 | 149 | } |
150 | 150 | break; |
151 | 151 | } |
152 | - if( $reference ) { |
|
152 | + if ($reference) { |
|
153 | 153 | $references[] = "\n<li>$inner."; |
154 | 154 | } else { |
155 | 155 | $result .= "\n<li class=\"link-to-hansard\">$description$inner</span>"; |