@@ -5,12 +5,12 @@ discard block |
||
5 | 5 | |
6 | 6 | */ |
7 | 7 | |
8 | -include_once INCLUDESPATH . '../../commonlib/phplib/email.php'; |
|
9 | -include_once INCLUDESPATH . '../../commonlib/phplib/datetime.php'; |
|
8 | +include_once INCLUDESPATH.'../../commonlib/phplib/email.php'; |
|
9 | +include_once INCLUDESPATH.'../../commonlib/phplib/datetime.php'; |
|
10 | 10 | |
11 | 11 | # Pass it a brief header word and some debug text and it'll be output. |
12 | 12 | # If TEXT is an array, call the user function, assuming it's a class. |
13 | -function twfy_debug($header, $text="") { |
|
13 | +function twfy_debug($header, $text = "") { |
|
14 | 14 | |
15 | 15 | // We set ?DEBUGTAG=n in the URL. |
16 | 16 | // (DEBUGTAG is set in config.php). |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | if ($debug_level != '') { |
28 | 28 | |
29 | 29 | // Set which level shows which types of debug info. |
30 | - $levels = array ( |
|
31 | - 1 => array ('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'), |
|
32 | - 2 => array ('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'), |
|
33 | - 3 => array ('SQLRESULT') |
|
30 | + $levels = array( |
|
31 | + 1 => array('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'), |
|
32 | + 2 => array('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'), |
|
33 | + 3 => array('SQLRESULT') |
|
34 | 34 | // Higher than this: 'DATA', etc. |
35 | 35 | ); |
36 | 36 | |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | for ($n = 1; $n <= $max_level_to_show; $n++) { |
47 | - $allowed_headers = array_merge ($allowed_headers, $levels[$n] ); |
|
47 | + $allowed_headers = array_merge($allowed_headers, $levels[$n]); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // If we can show this header, then, er, show it. |
51 | - if ( in_array($header, $allowed_headers) || $debug_level >= 4) { |
|
51 | + if (in_array($header, $allowed_headers) || $debug_level >= 4) { |
|
52 | 52 | if (is_array($text)) $text = call_user_func($text); |
53 | 53 | print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n"; |
54 | 54 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | global $PAGE; |
66 | 66 | |
67 | 67 | # Ignore errors we've asked to ignore |
68 | - if (error_reporting()==0) return; |
|
68 | + if (error_reporting() == 0) return; |
|
69 | 69 | |
70 | 70 | // define an assoc array of error string |
71 | 71 | // in reality the only entries we should |
72 | 72 | // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
73 | 73 | // E_USER_WARNING and E_USER_NOTICE |
74 | 74 | # Commented out are ones that a user function cannot handle. |
75 | - $errortype = array ( |
|
75 | + $errortype = array( |
|
76 | 76 | #E_ERROR => "Error", |
77 | 77 | E_WARNING => "Warning", |
78 | 78 | #E_PARSE => "Parsing Error", |
@@ -91,22 +91,22 @@ discard block |
||
91 | 91 | |
92 | 92 | $err = ''; |
93 | 93 | if (isset($_SERVER['REQUEST_URI'])) { |
94 | - $err .= "URL:\t\thttps://" . DOMAIN . $_SERVER['REQUEST_URI'] . "\n"; |
|
94 | + $err .= "URL:\t\thttps://".DOMAIN.$_SERVER['REQUEST_URI']."\n"; |
|
95 | 95 | } else { |
96 | 96 | $err .= "URL:\t\tNone - running from command line?\n"; |
97 | 97 | } |
98 | 98 | if (isset($_SERVER['HTTP_REFERER'])) { |
99 | - $err .= "Referer:\t" . $_SERVER['HTTP_REFERER'] . "\n"; |
|
99 | + $err .= "Referer:\t".$_SERVER['HTTP_REFERER']."\n"; |
|
100 | 100 | } else { |
101 | 101 | $err .= "Referer:\tNone\n"; |
102 | 102 | } |
103 | 103 | if (isset($_SERVER['HTTP_USER_AGENT'])) { |
104 | - $err .= "User-Agent:\t" . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
104 | + $err .= "User-Agent:\t".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
105 | 105 | } else { |
106 | 106 | $err .= "User-Agent:\tNone\n"; |
107 | 107 | } |
108 | 108 | $err .= "Number:\t\t$errno\n"; |
109 | - $err .= "Type:\t\t" . $errortype[$errno] . "\n"; |
|
109 | + $err .= "Type:\t\t".$errortype[$errno]."\n"; |
|
110 | 110 | $err .= "Message:\t$errmsg\n"; |
111 | 111 | $err .= "File:\t\t$filename\n"; |
112 | 112 | $err .= "Line:\t\t$linenum\n"; |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | $source = file($filename); |
132 | 132 | $err .= "\nSource:\n\n"; |
133 | 133 | // Show the line, plus prev and next, with line numbers. |
134 | - $err .= $linenum-2 . " " . $source[$linenum-3]; |
|
135 | - $err .= $linenum-1 . " " . $source[$linenum-2]; |
|
136 | - $err .= $linenum . " " . $source[$linenum-1]; |
|
137 | - $err .= $linenum+1 . " " . $source[$linenum]; |
|
138 | - $err .= $linenum+2 . " " . $source[$linenum+1]; |
|
134 | + $err .= $linenum - 2." ".$source[$linenum - 3]; |
|
135 | + $err .= $linenum - 1." ".$source[$linenum - 2]; |
|
136 | + $err .= $linenum." ".$source[$linenum - 1]; |
|
137 | + $err .= $linenum + 1." ".$source[$linenum]; |
|
138 | + $err .= $linenum + 2." ".$source[$linenum + 1]; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | |
152 | 152 | if (DEVSITE || get_http_var(DEBUGTAG)) { |
153 | 153 | // On a devsite we just display the problem. |
154 | - $errtxt = nl2br($err) . "\n"; |
|
154 | + $errtxt = nl2br($err)."\n"; |
|
155 | 155 | if (!strstr($errmsg, 'mysql_connect')) { |
156 | - $errtxt .= "<br><br>Backtrace:<br>" . nl2br(adodb_backtrace(false)); |
|
156 | + $errtxt .= "<br><br>Backtrace:<br>".nl2br(adodb_backtrace(false)); |
|
157 | 157 | } |
158 | 158 | $message = array( |
159 | 159 | 'title' => "Error", |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | header('HTTP/1.0 500 Internal Server Error'); |
180 | 180 | print "<p>Oops, sorry, an error has occurred!</p>\n"; |
181 | 181 | } |
182 | - if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect')===false && strpos($errmsg, 'mysql_connect')===false) { |
|
183 | - mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n". "X-Mailer: PHP/" . phpversion() ); |
|
182 | + if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect') === false && strpos($errmsg, 'mysql_connect') === false) { |
|
183 | + mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <".CONTACTEMAIL.">\n"."X-Mailer: PHP/".phpversion()); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php |
201 | -function adodb_backtrace($print=true) |
|
201 | +function adodb_backtrace($print = true) |
|
202 | 202 | { |
203 | 203 | $s = ''; |
204 | 204 | if (PHPVERSION() >= 4.3) { |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | |
208 | 208 | $traceArr = debug_backtrace(); |
209 | 209 | array_shift($traceArr); |
210 | - $tabs = sizeof($traceArr)-1; |
|
210 | + $tabs = sizeof($traceArr) - 1; |
|
211 | 211 | foreach ($traceArr as $arr) { |
212 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
212 | + for ($i = 0; $i < $tabs; $i++) $s .= ' '; |
|
213 | 213 | $tabs -= 1; |
214 | 214 | if (isset($arr['class'])) $s .= $arr['class'].'.'; |
215 | 215 | $args = array(); |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | elseif (is_bool($v)) $args[] = $v ? 'true' : 'false'; |
221 | 221 | else { |
222 | 222 | $v = (string) @$v; |
223 | - $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
|
223 | + $str = _htmlspecialchars(substr($v, 0, $MAXSTRLEN)); |
|
224 | 224 | if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
225 | 225 | $args[] = $str; |
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - $s .= $arr['function'].'('.implode(', ',$args).')'; |
|
229 | + $s .= $arr['function'].'('.implode(', ', $args).')'; |
|
230 | 230 | // $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". |
231 | 231 | // " file: <a href=\"file:/%s\">%s</a></font>", |
232 | 232 | // $arr['line'],$arr['file'],$arr['file']); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $nom = '0123456789'; |
265 | 265 | $gap = '\s\.'; |
266 | 266 | |
267 | - if ( preg_match("/^[$fst][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
|
267 | + if (preg_match("/^[$fst][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
|
268 | 268 | preg_match("/^[$fst][$num][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
269 | 269 | preg_match("/^[$fst][$sec][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
270 | 270 | preg_match("/^[$fst][$sec][$num][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | // Returns the unixtime in microseconds. |
281 | 281 | function getmicrotime() { |
282 | 282 | $mtime = microtime(); |
283 | - $mtime = explode(" ",$mtime); |
|
283 | + $mtime = explode(" ", $mtime); |
|
284 | 284 | $mtime = $mtime[1] + $mtime[0]; |
285 | 285 | |
286 | 286 | return $mtime; |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | global $timestamp_last, $timestamp_start; |
294 | 294 | $t = getmicrotime(); |
295 | 295 | twfy_debug("TIME", sprintf("%f msecs since start; %f msecs since last; %s", |
296 | - ($t - $timestamp_start)*1000.0, ($t - $timestamp_last)*1000.0, $label)); |
|
296 | + ($t - $timestamp_start) * 1000.0, ($t - $timestamp_last) * 1000.0, $label)); |
|
297 | 297 | $timestamp_last = $t; |
298 | 298 | } |
299 | 299 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | if (preg_match("/^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/", $timestamp, $matches)) { |
308 | 308 | list($string, $year, $month, $day, $hour, $min, $sec) = $matches; |
309 | 309 | |
310 | - return gmdate ($format, gmmktime($hour, $min, $sec, $month, $day, $year)); |
|
310 | + return gmdate($format, gmmktime($hour, $min, $sec, $month, $day, $year)); |
|
311 | 311 | } else { |
312 | 312 | return ""; |
313 | 313 | } |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | list($string, $year, $month, $day) = $matches; |
329 | 329 | if ($year < 1902) { # gmdate fns only go back to Dec. 1901 |
330 | 330 | if ($format == SHORTDATEFORMAT) { |
331 | - return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year"; |
|
331 | + return ($day + 0).' '.$format_date_months_short[$month + 0]." $year"; |
|
332 | 332 | } else { |
333 | - return ($day+0) . ' ' . $format_date_months[$month+0] . " $year"; |
|
333 | + return ($day + 0).' '.$format_date_months[$month + 0]." $year"; |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | - return gmdate ($format, gmmktime(0, 0, 0, $month, $day, $year)); |
|
337 | + return gmdate($format, gmmktime(0, 0, 0, $month, $day, $year)); |
|
338 | 338 | } else { |
339 | 339 | return ""; |
340 | 340 | } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | if (preg_match("/^(\d\d):(\d\d):(\d\d)$/", $time, $matches)) { |
351 | 351 | list($string, $hour, $min, $sec) = $matches; |
352 | 352 | |
353 | - return gmdate ($format, gmmktime($hour, $min, $sec)); |
|
353 | + return gmdate($format, gmmktime($hour, $min, $sec)); |
|
354 | 354 | } else { |
355 | 355 | return ""; |
356 | 356 | } |
@@ -371,16 +371,16 @@ discard block |
||
371 | 371 | $in_seconds = strtotime($datetime); |
372 | 372 | $now = time(); |
373 | 373 | |
374 | - $diff = $now - $in_seconds; |
|
375 | - $months = floor($diff/2419200); |
|
374 | + $diff = $now - $in_seconds; |
|
375 | + $months = floor($diff / 2419200); |
|
376 | 376 | $diff -= $months * 2419200; |
377 | - $weeks = floor($diff/604800); |
|
378 | - $diff -= $weeks*604800; |
|
379 | - $days = floor($diff/86400); |
|
377 | + $weeks = floor($diff / 604800); |
|
378 | + $diff -= $weeks * 604800; |
|
379 | + $days = floor($diff / 86400); |
|
380 | 380 | $diff -= $days * 86400; |
381 | - $hours = floor($diff/3600); |
|
381 | + $hours = floor($diff / 3600); |
|
382 | 382 | $diff -= $hours * 3600; |
383 | - $minutes = floor($diff/60); |
|
383 | + $minutes = floor($diff / 60); |
|
384 | 384 | $diff -= $minutes * 60; |
385 | 385 | $seconds = $diff; |
386 | 386 | |
@@ -394,22 +394,22 @@ discard block |
||
394 | 394 | $relative_date = ''; |
395 | 395 | if ($weeks > 0) { |
396 | 396 | // Weeks and days |
397 | - $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':''); |
|
398 | - $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):''; |
|
397 | + $relative_date .= ($relative_date ? ', ' : '').$weeks.' week'.($weeks > 1 ? 's' : ''); |
|
398 | + $relative_date .= $days > 0 ? ($relative_date ? ', ' : '').$days.' day'.($days > 1 ? 's' : '') : ''; |
|
399 | 399 | } elseif ($days > 0) { |
400 | 400 | // days and hours |
401 | - $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':''); |
|
402 | - $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):''; |
|
401 | + $relative_date .= ($relative_date ? ', ' : '').$days.' day'.($days > 1 ? 's' : ''); |
|
402 | + $relative_date .= $hours > 0 ? ($relative_date ? ', ' : '').$hours.' hour'.($hours > 1 ? 's' : '') : ''; |
|
403 | 403 | } elseif ($hours > 0) { |
404 | 404 | // hours and minutes |
405 | - $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''); |
|
406 | - $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):''; |
|
405 | + $relative_date .= ($relative_date ? ', ' : '').$hours.' hour'.($hours > 1 ? 's' : ''); |
|
406 | + $relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '').$minutes.' minute'.($minutes > 1 ? 's' : '') : ''; |
|
407 | 407 | } elseif ($minutes > 0) { |
408 | 408 | // minutes only |
409 | - $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''); |
|
409 | + $relative_date .= ($relative_date ? ', ' : '').$minutes.' minute'.($minutes > 1 ? 's' : ''); |
|
410 | 410 | } else { |
411 | 411 | // seconds only |
412 | - $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':''); |
|
412 | + $relative_date .= ($relative_date ? ', ' : '').$seconds.' second'.($seconds > 1 ? 's' : ''); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | |
446 | 446 | // Split long strings up so they don't go too long. |
447 | 447 | // Mainly for URLs which are displayed, but aren't links when trimmed. |
448 | - $text = preg_replace('/(\S{' . $url_length . '})/', "\$1 ", $text); |
|
448 | + $text = preg_replace('/(\S{'.$url_length.'})/', "\$1 ", $text); |
|
449 | 449 | |
450 | 450 | // Otherwise the word boundary matching goes odd... |
451 | 451 | $text = preg_replace("/[\n\r]/", " ", $text); |
@@ -455,12 +455,12 @@ discard block |
||
455 | 455 | $text = substr($text, $start); |
456 | 456 | |
457 | 457 | // Word boundary. |
458 | - if (preg_match ("/.+?\b(.*)/", $text, $matches)) { |
|
458 | + if (preg_match("/.+?\b(.*)/", $text, $matches)) { |
|
459 | 459 | $text = $matches[1]; |
460 | 460 | // Strip spare space at the start. |
461 | - $text = preg_replace ("/^\s/", '', $text); |
|
461 | + $text = preg_replace("/^\s/", '', $text); |
|
462 | 462 | } |
463 | - $text = '...' . $text; |
|
463 | + $text = '...'.$text; |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | // Trim end. |
@@ -470,10 +470,10 @@ discard block |
||
470 | 470 | $text = substr($text, 0, $length - 3); |
471 | 471 | |
472 | 472 | // Word boundary. |
473 | - if (preg_match ("/(.*)\s.+/", $text, $matches)) { |
|
473 | + if (preg_match("/(.*)\s.+/", $text, $matches)) { |
|
474 | 474 | $text = $matches[1]; |
475 | 475 | // Strip spare space at the end. |
476 | - $text = preg_replace ("/\s$/", '', $text); |
|
476 | + $text = preg_replace("/\s$/", '', $text); |
|
477 | 477 | } |
478 | 478 | // We don't want to use the HTML entity for an ellipsis (…), because then |
479 | 479 | // it screws up when we subsequently use htmlentities() to print the returned |
@@ -505,11 +505,11 @@ discard block |
||
505 | 505 | |
506 | 506 | if ($filter_type == 'strict') { |
507 | 507 | // No tags allowed at all! |
508 | - $filter->allowed = array (); |
|
508 | + $filter->allowed = array(); |
|
509 | 509 | } else { |
510 | 510 | // Comment. |
511 | 511 | // Only allowing <a href>, <b>, <strong>, <i> and <em> |
512 | - $filter->allowed = array ( |
|
512 | + $filter->allowed = array( |
|
513 | 513 | 'a' => array('href'), |
514 | 514 | 'strong' => array(), |
515 | 515 | 'em' => array(), |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | "/(?<!\"|\/)((http(s?):\/\/)|(www\.))([a-zA-Z\d_.+,;:?%~\-\/#='*$!()&[\]]+)([a-zA-Z\d_?%~\-\/#='*$!&])/", |
541 | 541 | function($matches) use ($link_length) { |
542 | 542 | if (strlen($matches[0]) > $link_length) { |
543 | - return '<a href="' . $matches[0] . '" rel="nofollow">' . substr($matches[0], 0, $link_length) . "...</a>"; |
|
543 | + return '<a href="'.$matches[0].'" rel="nofollow">'.substr($matches[0], 0, $link_length)."...</a>"; |
|
544 | 544 | } else { |
545 | - return '<a href="' . $matches[0] . '" rel="nofollow">' . $matches[0] . '</a>'; |
|
545 | + return '<a href="'.$matches[0].'" rel="nofollow">'.$matches[0].'</a>'; |
|
546 | 546 | } |
547 | 547 | }, |
548 | 548 | $text); |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | // This returns 'debate_2003-02-28.475.3'. |
631 | 631 | |
632 | 632 | if ($keepmajor) { |
633 | - $newgid = substr($gid, strpos($gid, '/')+1 ); |
|
633 | + $newgid = substr($gid, strpos($gid, '/') + 1); |
|
634 | 634 | $newgid = str_replace('/', '_', $newgid); |
635 | 635 | } else { |
636 | - $newgid = substr($gid, strrpos($gid, '/')+1 ); |
|
636 | + $newgid = substr($gid, strrpos($gid, '/') + 1); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | return $newgid; |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | // will be like 2003-11-20.966.0 |
648 | 648 | // This function returns 966.0 |
649 | 649 | |
650 | - return substr( $gid, (strpos($gid, '.') + 1) ); |
|
650 | + return substr($gid, (strpos($gid, '.') + 1)); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | function preg_replacement_quote($s) { |
@@ -691,14 +691,14 @@ discard block |
||
691 | 691 | global $PAGE; |
692 | 692 | |
693 | 693 | if (!isset($data['to']) || $data['to'] == '') { |
694 | - $PAGE->error_message ("We need an email address to send to."); |
|
694 | + $PAGE->error_message("We need an email address to send to."); |
|
695 | 695 | return false; |
696 | 696 | } |
697 | 697 | |
698 | - $filename = INCLUDESPATH . "easyparliament/templates/emails/" . $data['template'] . ".txt"; |
|
698 | + $filename = INCLUDESPATH."easyparliament/templates/emails/".$data['template'].".txt"; |
|
699 | 699 | |
700 | 700 | if (!file_exists($filename)) { |
701 | - $PAGE->error_message("Sorry, we could not find the email template '" . _htmlentities($data['template']) . "'."); |
|
701 | + $PAGE->error_message("Sorry, we could not find the email template '"._htmlentities($data['template'])."'."); |
|
702 | 702 | return false; |
703 | 703 | } |
704 | 704 | |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | if (isset($data['subject'])) { |
716 | 716 | $subject = trim($data['subject']); |
717 | 717 | } else { |
718 | - $subject = trim( substr($firstline, 8) ); |
|
718 | + $subject = trim(substr($firstline, 8)); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | // Either way, remove this subject line from the template. |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | } elseif (isset($data['subject'])) { |
725 | 725 | $subject = $data['subject']; |
726 | 726 | } else { |
727 | - $PAGE->error_message ("We don't have a subject line for the email, so it wasn't sent."); |
|
727 | + $PAGE->error_message("We don't have a subject line for the email, so it wasn't sent."); |
|
728 | 728 | return false; |
729 | 729 | } |
730 | 730 | |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | $emailtext = preg_replace($search, $replace, $emailtext); |
742 | 742 | |
743 | 743 | // Send it! |
744 | - $success = send_email ($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces); |
|
744 | + $success = send_email($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@'.EMAILDOMAIN, $want_bounces); |
|
745 | 745 | |
746 | 746 | return $success; |
747 | 747 | |
@@ -764,19 +764,19 @@ discard block |
||
764 | 764 | if (!$from) $from = CONTACTEMAIL; |
765 | 765 | |
766 | 766 | $headers = |
767 | - "From: TheyWorkForYou <$from>\r\n" . |
|
768 | - "Content-Type: text/plain; charset=utf-8\r\n" . |
|
769 | - "MIME-Version: 1.0\r\n" . |
|
770 | - "Content-Transfer-Encoding: 8bit\r\n" . |
|
771 | - ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "" ). |
|
772 | - "X-Mailer: PHP/" . phpversion(); |
|
767 | + "From: TheyWorkForYou <$from>\r\n". |
|
768 | + "Content-Type: text/plain; charset=utf-8\r\n". |
|
769 | + "MIME-Version: 1.0\r\n". |
|
770 | + "Content-Transfer-Encoding: 8bit\r\n". |
|
771 | + ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : ""). |
|
772 | + "X-Mailer: PHP/".phpversion(); |
|
773 | 773 | twfy_debug('EMAIL', "Sending email to $to with subject of '$subject'"); |
774 | 774 | |
775 | 775 | if ($want_bounces) { |
776 | 776 | $envelope_sender = twfy_verp_envelope_sender($to); |
777 | - $success = mail ($to, $subject, $message, $headers, '-f ' . $envelope_sender); |
|
777 | + $success = mail($to, $subject, $message, $headers, '-f '.$envelope_sender); |
|
778 | 778 | } else { |
779 | - $success = mail ($to, $subject, $message, $headers); |
|
779 | + $success = mail($to, $subject, $message, $headers); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | return $success; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | // http://www.iamcal.com/publish/article.php?id=13 |
789 | 789 | |
790 | 790 | // Call this with a key name to get a GET or POST variable. |
791 | -function get_http_var($name, $default='') { |
|
791 | +function get_http_var($name, $default = '') { |
|
792 | 792 | if (array_key_exists($name, $_GET)) { |
793 | 793 | return clean_var($_GET[$name]); |
794 | 794 | } |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | } |
815 | 815 | |
816 | 816 | // Call this with a key name to get a COOKIE variable. |
817 | -function get_cookie_var($name, $default='') { |
|
817 | +function get_cookie_var($name, $default = '') { |
|
818 | 818 | if (array_key_exists($name, $_COOKIE)) { |
819 | 819 | return clean_var($_COOKIE[$name]); |
820 | 820 | } |
@@ -825,25 +825,25 @@ discard block |
||
825 | 825 | // Pass it an array of key names that should not be generated as |
826 | 826 | // hidden form variables. It then outputs hidden form variables |
827 | 827 | // based on the session_vars for this page. |
828 | -function hidden_form_vars ($omit = array()) { |
|
828 | +function hidden_form_vars($omit = array()) { |
|
829 | 829 | global $DATA, $this_page; |
830 | 830 | |
831 | 831 | $session_vars = $DATA->page_metadata($this_page, "session_vars"); |
832 | 832 | |
833 | 833 | foreach ($session_vars as $n => $key) { |
834 | 834 | if (!in_array($key, $omit)) { |
835 | - print "<input type=\"hidden\" name=\"$key\" value=\"" . _htmlentities(get_http_var($key)) . "\">\n"; |
|
835 | + print "<input type=\"hidden\" name=\"$key\" value=\""._htmlentities(get_http_var($key))."\">\n"; |
|
836 | 836 | } |
837 | 837 | } |
838 | 838 | } |
839 | 839 | |
840 | 840 | // Deprecated. Use hidden_form_vars, above, instead. |
841 | -function hidden_vars ($omit = array()) { |
|
841 | +function hidden_vars($omit = array()) { |
|
842 | 842 | global $DATA; |
843 | 843 | |
844 | 844 | foreach ($args as $key => $val) { |
845 | 845 | if (!in_array($key, $omit)) { |
846 | - print "<input type=\"hidden\" name=\"$key\" value=\"" . _htmlspecialchars($val) . "\">\n"; |
|
846 | + print "<input type=\"hidden\" name=\"$key\" value=\""._htmlspecialchars($val)."\">\n"; |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | } |
@@ -854,26 +854,26 @@ discard block |
||
854 | 854 | |
855 | 855 | # 11th, 12th, 13th use "th" not "st", "nd", "rd" |
856 | 856 | if (floor(($rank % 100) / 10) == 1) |
857 | - return $rank . "th"; |
|
857 | + return $rank."th"; |
|
858 | 858 | # 1st |
859 | 859 | if ($rank % 10 == 1) |
860 | - return $rank . "st"; |
|
860 | + return $rank."st"; |
|
861 | 861 | # 2nd |
862 | 862 | if ($rank % 10 == 2) |
863 | - return $rank . "nd"; |
|
863 | + return $rank."nd"; |
|
864 | 864 | # 3rd |
865 | 865 | if ($rank % 10 == 3) |
866 | - return $rank . "rd"; |
|
866 | + return $rank."rd"; |
|
867 | 867 | # Everything else use th |
868 | 868 | |
869 | - return $rank . "th"; |
|
869 | + return $rank."th"; |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | function make_plural($word, $number) |
873 | 873 | { |
874 | 874 | if ($number == 1) |
875 | 875 | return $word; |
876 | - return $word . "s"; |
|
876 | + return $word."s"; |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | # Can't have the entities in XML so replace all theones we currently have with numerical entities |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | function entities_to_numbers($string) { |
882 | 882 | $string = str_replace( |
883 | 883 | array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é'), |
884 | - array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é' ), |
|
884 | + array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é'), |
|
885 | 885 | $string |
886 | 886 | ); |
887 | 887 | return $string; |
@@ -895,9 +895,9 @@ discard block |
||
895 | 895 | return 'elizabeth_the_second'; |
896 | 896 | } |
897 | 897 | |
898 | - $s = array(' ', '&', 'ô', 'Ö', 'ö', 'â', 'í', 'á', 'ú', 'é', 'ó', 'Ó'); |
|
899 | - $s2 = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93"); |
|
900 | - $r = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o'); |
|
898 | + $s = array(' ', '&', 'ô', 'Ö', 'ö', 'â', 'í', 'á', 'ú', 'é', 'ó', 'Ó'); |
|
899 | + $s2 = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93"); |
|
900 | + $r = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o'); |
|
901 | 901 | $name = preg_replace('#^the #', '', strtolower($name)); |
902 | 902 | |
903 | 903 | $out = ''; |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | // Insert the Person ID if known. |
906 | 906 | if ($pid !== NULL) |
907 | 907 | { |
908 | - $out .= $pid . '/'; |
|
908 | + $out .= $pid.'/'; |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | // Always inject the person's name |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | // If there is a constituency, inject that too |
915 | 915 | if ($const && $house == HOUSE_TYPE_COMMONS) |
916 | 916 | { |
917 | - $out .= '/' . urlencode(str_replace($s2, $r, str_replace($s, $r, strtolower($const)))); |
|
917 | + $out .= '/'.urlencode(str_replace($s2, $r, str_replace($s, $r, strtolower($const)))); |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | return $out; |
@@ -925,14 +925,14 @@ discard block |
||
925 | 925 | if ($house == HOUSE_TYPE_COMMONS || $house == HOUSE_TYPE_NI || $house == HOUSE_TYPE_SCOTLAND) { |
926 | 926 | $s = "$given_name $family_name"; |
927 | 927 | if ($title) { |
928 | - $s = $title . ' ' . $s; |
|
928 | + $s = $title.' '.$s; |
|
929 | 929 | } |
930 | 930 | } elseif ($house == HOUSE_TYPE_LORDS) { |
931 | 931 | $s = ''; |
932 | 932 | if (!$family_name) $s = 'the '; |
933 | 933 | $s .= $title; |
934 | - if ($family_name) $s .= ' ' . $family_name; |
|
935 | - if ($lordofname) $s .= ' of ' . $lordofname; |
|
934 | + if ($family_name) $s .= ' '.$family_name; |
|
935 | + if ($lordofname) $s .= ' of '.$lordofname; |
|
936 | 936 | } elseif ($house == HOUSE_TYPE_ROYAL) { # Queen |
937 | 937 | $s = "$given_name $family_name"; |
938 | 938 | } |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | foreach ($data as $major => $array) { |
1003 | 1003 | if (!in_array('timestamp', $array)) $daytext[$major] = "The most recent "; |
1004 | 1004 | elseif ($todaystime - $array['timestamp'] == 86400) $daytext[$major] = "Yesterday’s"; |
1005 | - elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1005 | + elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp'])."’s"; |
|
1006 | 1006 | else $daytext[$major] = "The most recent "; |
1007 | 1007 | } |
1008 | 1008 | } |
@@ -1019,9 +1019,9 @@ discard block |
||
1019 | 1019 | $q = $db->query('SELECT section_id, body, gid |
1020 | 1020 | FROM hansard, epobject |
1021 | 1021 | WHERE hansard.epobject_id = epobject.epobject_id ' |
1022 | - . ($p_major == 4 ? 'AND subsection_id=0' : 'AND section_id=0') . |
|
1023 | - ' AND hdate = "' . $date . '" |
|
1024 | - AND major = ' . $p_major . ' |
|
1022 | + . ($p_major == 4 ? 'AND subsection_id=0' : 'AND section_id=0'). |
|
1023 | + ' AND hdate = "'.$date.'" |
|
1024 | + AND major = ' . $p_major.' |
|
1025 | 1025 | ORDER BY hpos'); |
1026 | 1026 | $out = ''; |
1027 | 1027 | $LISTURL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$p_major]['page_all']); |
@@ -1035,11 +1035,11 @@ discard block |
||
1035 | 1035 | if ($current_sid++) { |
1036 | 1036 | $out .= '</ul>'; |
1037 | 1037 | } |
1038 | - $out .= '<li>' . $body . '<ul>'; |
|
1038 | + $out .= '<li>'.$body.'<ul>'; |
|
1039 | 1039 | } else { |
1040 | - $LISTURL->insert( array( 'id' => $gid ) ); |
|
1040 | + $LISTURL->insert(array('id' => $gid)); |
|
1041 | 1041 | $out .= '<li><a href="'.$LISTURL->generate().'">'; |
1042 | - $out .= $body . '</a>'; |
|
1042 | + $out .= $body.'</a>'; |
|
1043 | 1043 | } |
1044 | 1044 | } |
1045 | 1045 | if ($out) { |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | |
1064 | 1064 | $return = '<h4>'; |
1065 | 1065 | if (isset($daytext[$major])) { |
1066 | - $return .= $daytext[$major] . ' '; |
|
1066 | + $return .= $daytext[$major].' '; |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | $return .= '<a href="'; |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | $LISTURL->reset(); |
1074 | 1074 | $return .= $LISTURL->generate(); |
1075 | 1075 | } |
1076 | - $return .= '">' . $hansardmajors[$major]['title'] . '</a>'; |
|
1076 | + $return .= '">'.$hansardmajors[$major]['title'].'</a>'; |
|
1077 | 1077 | if (isset($daytext[$major])) $return; |
1078 | 1078 | $return .= '</h4>'; |
1079 | 1079 | |
@@ -1118,10 +1118,10 @@ discard block |
||
1118 | 1118 | |
1119 | 1119 | function cache_version($file) { |
1120 | 1120 | static $version_hash = array(); |
1121 | - $path = BASEDIR . "/$file"; |
|
1121 | + $path = BASEDIR."/$file"; |
|
1122 | 1122 | if (is_file($path) && (!isset($version_hash[$file]) || DEVSITE)) { |
1123 | 1123 | $version_hash[$file] = stat($path)[9]; |
1124 | - $file .= '?' . $version_hash[$file]; |
|
1124 | + $file .= '?'.$version_hash[$file]; |
|
1125 | 1125 | } |
1126 | - return WEBPATH . $file; |
|
1126 | + return WEBPATH.$file; |
|
1127 | 1127 | } |
@@ -318,6 +318,9 @@ discard block |
||
318 | 318 | $format_date_months = array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); |
319 | 319 | $format_date_months_short = array('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
320 | 320 | |
321 | +/** |
|
322 | + * @param string $format |
|
323 | + */ |
|
321 | 324 | function format_date($date, $format) { |
322 | 325 | global $format_date_months, $format_date_months_short; |
323 | 326 | // Pass it a date (YYYY-MM-DD) and a |
@@ -342,6 +345,9 @@ discard block |
||
342 | 345 | } |
343 | 346 | |
344 | 347 | |
348 | +/** |
|
349 | + * @param string $format |
|
350 | + */ |
|
345 | 351 | function format_time($time, $format) { |
346 | 352 | // Pass it a time (HH:MM:SS) and a |
347 | 353 | // PHP date format string (eg, "H:i") |
@@ -486,6 +492,7 @@ discard block |
||
486 | 492 | |
487 | 493 | /** |
488 | 494 | * Filters user input to remove unwanted HTML tags etc |
495 | + * @param string $filter_type |
|
489 | 496 | */ |
490 | 497 | function filter_user_input($text, $filter_type) { |
491 | 498 | // We use this to filter any major user input, especially comments. |
@@ -750,12 +757,18 @@ discard block |
||
750 | 757 | /* verp_envelope_sender RECIPIENT |
751 | 758 | * Construct a VERP envelope sender for an email to RECIPIENT |
752 | 759 | */ |
760 | +/** |
|
761 | + * @return string|null |
|
762 | + */ |
|
753 | 763 | function twfy_verp_envelope_sender($recipient) { |
754 | 764 | $envelope_sender = verp_envelope_sender($recipient, 'twfy', EMAILDOMAIN); |
755 | 765 | |
756 | 766 | return $envelope_sender; |
757 | 767 | } |
758 | 768 | |
769 | +/** |
|
770 | + * @param string $message |
|
771 | + */ |
|
759 | 772 | function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false) { |
760 | 773 | // Use this rather than PHP's mail() direct, so we can make alterations |
761 | 774 | // easily to all the emails we send out from the site. |
@@ -814,6 +827,9 @@ discard block |
||
814 | 827 | } |
815 | 828 | |
816 | 829 | // Call this with a key name to get a COOKIE variable. |
830 | +/** |
|
831 | + * @param string $name |
|
832 | + */ |
|
817 | 833 | function get_cookie_var($name, $default='') { |
818 | 834 | if (array_key_exists($name, $_COOKIE)) { |
819 | 835 | return clean_var($_COOKIE[$name]); |
@@ -1058,6 +1074,10 @@ discard block |
||
1058 | 1074 | } |
1059 | 1075 | } |
1060 | 1076 | |
1077 | +/** |
|
1078 | + * @param integer $major |
|
1079 | + * @param MySociety\TheyWorkForYou\Url $LISTURL |
|
1080 | + */ |
|
1061 | 1081 | function _major_summary_title($major, $data, $LISTURL, $daytext) { |
1062 | 1082 | global $hansardmajors; |
1063 | 1083 | |
@@ -1107,6 +1127,9 @@ discard block |
||
1107 | 1127 | return $return; |
1108 | 1128 | } |
1109 | 1129 | |
1130 | +/** |
|
1131 | + * @param string|null $url |
|
1132 | + */ |
|
1110 | 1133 | function redirect($url) { |
1111 | 1134 | if (defined('TESTING')) { |
1112 | 1135 | print "Location: $url"; |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | # For looking up a postcode and redirecting or displaying appropriately |
4 | 4 | |
5 | 5 | include_once '../../includes/easyparliament/init.php'; |
6 | -include_once INCLUDESPATH . 'easyparliament/member.php'; |
|
6 | +include_once INCLUDESPATH.'easyparliament/member.php'; |
|
7 | 7 | |
8 | 8 | $errors = array(); |
9 | 9 | |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | |
15 | 15 | $pc = preg_replace('#[^a-z0-9]#i', '', $pc); |
16 | 16 | if (!validate_postcode($pc)) { |
17 | - twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form."); |
|
18 | - postcode_error("Sorry, " . _htmlentities($pc) . " isn't a valid postcode"); |
|
17 | + twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form."); |
|
18 | + postcode_error("Sorry, "._htmlentities($pc)." isn't a valid postcode"); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $constituencies = MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($pc); |
22 | 22 | if ($constituencies == 'CONNECTION_TIMED_OUT') { |
23 | 23 | postcode_error("Sorry, we couldn't check your postcode right now, as our postcode lookup server is under quite a lot of load."); |
24 | 24 | } elseif (!$constituencies) { |
25 | - postcode_error("Sorry, " . _htmlentities($pc) . " isn't a known postcode"); |
|
25 | + postcode_error("Sorry, "._htmlentities($pc)." isn't a known postcode"); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | $out = ''; $sidebars = array(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | exit; |
58 | 58 | } |
59 | 59 | |
60 | -function fetch_mp($pc, $constituencies, $house=null) { |
|
60 | +function fetch_mp($pc, $constituencies, $house = null) { |
|
61 | 61 | global $THEUSER; |
62 | 62 | $args = array('constituency' => $constituencies['WMC']); |
63 | 63 | if ($house) { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | try { |
67 | 67 | $MEMBER = new MEMBER($args); |
68 | - } catch (MySociety\TheyWorkForYou\MemberException $e){ |
|
68 | + } catch (MySociety\TheyWorkForYou\MemberException $e) { |
|
69 | 69 | postcode_error($e->getMessage()); |
70 | 70 | } |
71 | 71 | if ($MEMBER->person_id()) { |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | |
97 | 97 | $query_base = "SELECT member.person_id, given_name, family_name, constituency, house |
98 | 98 | FROM member, person_names pn |
99 | - WHERE constituency IN ('" . join("','", $a) . "') |
|
99 | + WHERE constituency IN ('" . join("','", $a)."') |
|
100 | 100 | AND member.person_id = pn.person_id AND pn.type = 'name' |
101 | 101 | AND pn.end_date = (SELECT MAX(end_date) from person_names where person_names.person_id = member.person_id)"; |
102 | - $q = $db->query($query_base . " AND left_reason = 'still_in_office' AND house in (3,4)"); |
|
102 | + $q = $db->query($query_base." AND left_reason = 'still_in_office' AND house in (3,4)"); |
|
103 | 103 | $current = true; |
104 | 104 | if (!$q->rows() && ($dissolution = MySociety\TheyWorkForYou\Dissolution::db())) { |
105 | 105 | $current = false; |
106 | - $q = $db->query($query_base . " AND $dissolution[query]", |
|
106 | + $q = $db->query($query_base." AND $dissolution[query]", |
|
107 | 107 | $dissolution['params']); |
108 | 108 | } |
109 | 109 | |
110 | 110 | $mcon = array(); $mreg = array(); |
111 | - for ($i=0; $i<$q->rows(); $i++) { |
|
111 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
112 | 112 | $house = $q->field($i, 'house'); |
113 | 113 | $cons = $q->field($i, 'constituency'); |
114 | - if ($house==3) { |
|
114 | + if ($house == 3) { |
|
115 | 115 | $mreg[] = $q->row($i); |
116 | - } elseif ($house==4) { |
|
116 | + } elseif ($house == 4) { |
|
117 | 117 | if ($cons == $areas['SPC']) { |
118 | 118 | $mcon = $q->row($i); |
119 | 119 | } elseif ($cons == $areas['SPE']) { |
@@ -129,32 +129,32 @@ discard block |
||
129 | 129 | $out .= '<p>That postcode has multiple results, please pick who you are interested in:</p>'; |
130 | 130 | $out .= '<ul><li>Your '; |
131 | 131 | if (isset($mp['former'])) $out .= 'former '; |
132 | - $out .= '<strong>MP</strong> (Member of Parliament) is <a href="/mp/?p=' . $mp['person_id'] . '">'; |
|
133 | - $out .= $mp['given_name'] . ' ' . $mp['family_name'] . '</a>, ' . $mp['constituency'] . '</li>'; |
|
132 | + $out .= '<strong>MP</strong> (Member of Parliament) is <a href="/mp/?p='.$mp['person_id'].'">'; |
|
133 | + $out .= $mp['given_name'].' '.$mp['family_name'].'</a>, '.$mp['constituency'].'</li>'; |
|
134 | 134 | if ($mcon) { |
135 | 135 | $out .= '<li>Your <strong>constituency MSP</strong> (Member of the Scottish Parliament) '; |
136 | 136 | $out .= $current ? 'is' : 'was'; |
137 | - $out .= ' <a href="/msp/?p=' . $mcon['person_id'] . '">'; |
|
138 | - $out .= $mcon['given_name'] . ' ' . $mcon['family_name'] . '</a>, ' . $mcon['constituency'] . '</li>'; |
|
137 | + $out .= ' <a href="/msp/?p='.$mcon['person_id'].'">'; |
|
138 | + $out .= $mcon['given_name'].' '.$mcon['family_name'].'</a>, '.$mcon['constituency'].'</li>'; |
|
139 | 139 | } |
140 | - $out .= '<li>Your <strong>' . $areas[$area_type] . ' ' . $rep_type . 's</strong> '; |
|
141 | - if ($rep_type=='MLA') $out .= '(Members of the Legislative Assembly)'; |
|
142 | - $out .= ' ' . ($current ? 'are' : 'were') . ':'; |
|
140 | + $out .= '<li>Your <strong>'.$areas[$area_type].' '.$rep_type.'s</strong> '; |
|
141 | + if ($rep_type == 'MLA') $out .= '(Members of the Legislative Assembly)'; |
|
142 | + $out .= ' '.($current ? 'are' : 'were').':'; |
|
143 | 143 | $out .= '<ul>'; |
144 | 144 | foreach ($mreg as $reg) { |
145 | - $out .= '<li><a href="/' . strtolower($rep_type) . '/?p=' . $reg['person_id'] . '">'; |
|
146 | - $out .= $reg['given_name'] . ' ' . $reg['family_name']; |
|
145 | + $out .= '<li><a href="/'.strtolower($rep_type).'/?p='.$reg['person_id'].'">'; |
|
146 | + $out .= $reg['given_name'].' '.$reg['family_name']; |
|
147 | 147 | $out .= '</a>'; |
148 | 148 | } |
149 | 149 | $out .= '</ul></ul>'; |
150 | 150 | |
151 | 151 | $MPSURL = new \MySociety\TheyWorkForYou\Url('mps'); |
152 | - $REGURL = new \MySociety\TheyWorkForYou\Url(strtolower($rep_type) . 's'); |
|
152 | + $REGURL = new \MySociety\TheyWorkForYou\Url(strtolower($rep_type).'s'); |
|
153 | 153 | $sidebar = array(array( |
154 | 154 | 'type' => 'html', |
155 | 155 | 'content' => '<div class="block"><h4>Browse people</h4> |
156 | - <ul><li><a href="' . $MPSURL->generate() . '">Browse all MPs</a></li> |
|
157 | - <li><a href="' . $REGURL->generate() . '">Browse all ' . $rep_type . 's</a></li> |
|
156 | + <ul><li><a href="' . $MPSURL->generate().'">Browse all MPs</a></li> |
|
157 | + <li><a href="' . $REGURL->generate().'">Browse all '.$rep_type.'s</a></li> |
|
158 | 158 | </ul></div>' |
159 | 159 | )); |
160 | 160 | return array($out, $sidebar); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | if ($THEUSER->isloggedin()) { |
10 | 10 | // They can't change their postcode here, so send them to the editing page. |
11 | 11 | $URL = new \MySociety\TheyWorkForYou\Url('useredit'); |
12 | - header("Location: " . $URL->generate()); |
|
12 | + header("Location: ".$URL->generate()); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | if (get_http_var('forget') == 't') { |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | // The cookie will have already been read for this page, so we need to reload. |
20 | 20 | $URL = new \MySociety\TheyWorkForYou\Url($this_page); |
21 | - header("Location: " . $URL->generate()); |
|
21 | + header("Location: ".$URL->generate()); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | if (!$THEUSER->postcode_is_set()) { |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | $this_page = "home"; |
4 | 4 | |
5 | 5 | include_once '../includes/easyparliament/init.php'; |
6 | -include_once INCLUDESPATH . "easyparliament/member.php"; |
|
6 | +include_once INCLUDESPATH."easyparliament/member.php"; |
|
7 | 7 | |
8 | 8 | $PAGE->page_start(); |
9 | 9 | |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | |
28 | 28 | if (count($debatesdata) > 0 && count($wransdata) > 0 && count($whalldata) > 0 && count($wmsdata) > 0) { |
29 | 29 | // Links to Debates and Wrans. |
30 | - $debatestext = '<a href="' . $debatesdata['listurl'] . '">Debates</a>'; |
|
31 | - $wranstext = '<a href="' . $wransdata['listurl'] . '">Written Answers</a>'; |
|
32 | - $whalltext = '<a href="' . $whalldata['listurl'] . '">Westminster Hall debates</a>'; |
|
33 | - $wmstext = '<a href="' . $wmsdata['listurl'] . '">Written Ministerial Statements</a>'; |
|
30 | + $debatestext = '<a href="'.$debatesdata['listurl'].'">Debates</a>'; |
|
31 | + $wranstext = '<a href="'.$wransdata['listurl'].'">Written Answers</a>'; |
|
32 | + $whalltext = '<a href="'.$whalldata['listurl'].'">Westminster Hall debates</a>'; |
|
33 | + $wmstext = '<a href="'.$wmsdata['listurl'].'">Written Ministerial Statements</a>'; |
|
34 | 34 | |
35 | 35 | // Now we work out whether the debates/wrans are from yesterday or another day... |
36 | 36 | // And create the appropriate text ($daytext) to display accordingly. |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | } elseif ($todaystime - $debatesdata['timestamp'] <= (6 * 86400)) { |
47 | 47 | // Less than a week ago, so like "last Tuesday's". |
48 | - $daytext = gmdate('l', $debatesdata['timestamp']) . "'s"; |
|
48 | + $daytext = gmdate('l', $debatesdata['timestamp'])."'s"; |
|
49 | 49 | |
50 | 50 | } else { |
51 | 51 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $HANSARDURL = new \MySociety\TheyWorkForYou\Url('hansard'); |
73 | 73 | $MPURL = new \MySociety\TheyWorkForYou\Url('yourmp'); |
74 | 74 | |
75 | -$PAGE->block_start(array ('id'=>'intro', 'title'=>'Election special! Find out how they performed for YOU:')); |
|
75 | +$PAGE->block_start(array('id'=>'intro', 'title'=>'Election special! Find out how they performed for YOU:')); |
|
76 | 76 | ?> |
77 | 77 | <ol> |
78 | 78 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } else { |
90 | 90 | $CHANGEURL = new \MySociety\TheyWorkForYou\Url('userchangepc'); |
91 | 91 | } |
92 | - $MEMBER = new MEMBER(array ('postcode'=>$THEUSER->postcode(), 'house'=>1)); |
|
92 | + $MEMBER = new MEMBER(array('postcode'=>$THEUSER->postcode(), 'house'=>1)); |
|
93 | 93 | $mpname = $MEMBER->full_name(); |
94 | 94 | ?> |
95 | 95 | <p><a href="<?php echo $MPURL->generate(); ?>"><strong>Find out more about how <?php echo $mpname; ?>, your ex-MP, represented you over the last parliament</strong></a><br> |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | //$PAGE->block_end(); |
186 | 186 | |
187 | 187 | $PAGE->stripe_end(array( |
188 | - array ( |
|
188 | + array( |
|
189 | 189 | 'type' => 'include', |
190 | 190 | 'content' => 'whatisthissite' |
191 | 191 | ), |
192 | - array ( |
|
192 | + array( |
|
193 | 193 | 'type' => 'include', |
194 | 194 | 'content' => 'sitenews_recent' |
195 | 195 | ) |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $LISTURL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$id_data['major']]['page_all']); |
41 | 41 | $fragment = ''; |
42 | 42 | if ($id_data['htype'] == '11' || $id_data['htype'] == '10') { |
43 | - $LISTURL->insert( array( 'id' => $id_data['gid'] ) ); |
|
43 | + $LISTURL->insert(array('id' => $id_data['gid'])); |
|
44 | 44 | } else { |
45 | 45 | $parent_epobject_id = $id_data['subsection_id']; |
46 | 46 | $parent_gid = ''; |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | ':epobject_id' => $parent_epobject_id |
51 | 51 | )); |
52 | 52 | if ($r->rows() > 0) { |
53 | - $parent_gid = fix_gid_from_db( $r->field(0, 'gid') ); |
|
53 | + $parent_gid = fix_gid_from_db($r->field(0, 'gid')); |
|
54 | 54 | } |
55 | 55 | if ($parent_gid != '') { |
56 | - $LISTURL->insert( array( 'id' => $parent_gid ) ); |
|
57 | - $fragment = '#g' . gid_to_anchor($id_data['gid']); |
|
56 | + $LISTURL->insert(array('id' => $parent_gid)); |
|
57 | + $fragment = '#g'.gid_to_anchor($id_data['gid']); |
|
58 | 58 | } |
59 | 59 | } |
60 | - return $LISTURL->generate('none') . $fragment; |
|
60 | + return $LISTURL->generate('none').$fragment; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | function api_converturl_url_output($q) { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $url = get_listurl($q); |
66 | 66 | $output = array( |
67 | 67 | 'gid' => $gid, |
68 | - 'url' => 'https://www.theyworkforyou.com' . $url |
|
68 | + 'url' => 'https://www.theyworkforyou.com'.$url |
|
69 | 69 | ); |
70 | 70 | api_output($output); |
71 | 71 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | return api_converturl_url_output($q); |
80 | 80 | |
81 | 81 | $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array( |
82 | - ':url' => $url_nohash . '%' |
|
82 | + ':url' => $url_nohash.'%' |
|
83 | 83 | )); |
84 | 84 | if ($q->rows()) |
85 | 85 | return api_converturl_url_output($q); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $url_bound = str_replace('cmhansrd/cm', 'cmhansrd/vo', $url_nohash); |
88 | 88 | if ($url_bound != $url_nohash) { |
89 | 89 | $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array( |
90 | - ':url' => $url_bound . '%' |
|
90 | + ':url' => $url_bound.'%' |
|
91 | 91 | )); |
92 | 92 | if ($q->rows()) |
93 | 93 | return api_converturl_url_output($q); |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | $q = $db->query("SELECT COUNT(*) AS count FROM users WHERE confirmed = '0'"); |
23 | 23 | $unconfirmedusers = $q->field(0, 'count'); |
24 | 24 | |
25 | -$olddate = gmdate("Y-m-d H:i:s", time()-86400); |
|
25 | +$olddate = gmdate("Y-m-d H:i:s", time() - 86400); |
|
26 | 26 | $q = $db->query("SELECT COUNT(*) AS count FROM users WHERE lastvisit > '$olddate'"); |
27 | 27 | $dayusers = $q->field(0, 'count'); |
28 | 28 | |
29 | -$olddate = gmdate("Y-m-d H:i:s", time()-86400*7); |
|
29 | +$olddate = gmdate("Y-m-d H:i:s", time() - 86400 * 7); |
|
30 | 30 | $q = $db->query("SELECT COUNT(*) AS count FROM users WHERE lastvisit > '$olddate'"); |
31 | 31 | $weekusers = $q->field(0, 'count'); |
32 | 32 | ?> |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $rows = array(); |
62 | 62 | $USERURL = new \MySociety\TheyWorkForYou\Url('userview'); |
63 | 63 | |
64 | -for ($row=0; $row<$q->rows(); $row++) { |
|
64 | +for ($row = 0; $row < $q->rows(); $row++) { |
|
65 | 65 | |
66 | 66 | $user_id = $q->field($row, 'user_id'); |
67 | 67 | |
@@ -69,23 +69,23 @@ discard block |
||
69 | 69 | |
70 | 70 | if ($q->field($row, 'confirmed') == 1) { |
71 | 71 | $confirmed = 'Yes'; |
72 | - $name = '<a href="' . $USERURL->generate() . '">' . _htmlspecialchars($q->field($row, 'firstname')) |
|
73 | - . ' ' . _htmlspecialchars($q->field($row, 'lastname')) . '</a>'; |
|
72 | + $name = '<a href="'.$USERURL->generate().'">'._htmlspecialchars($q->field($row, 'firstname')) |
|
73 | + . ' '._htmlspecialchars($q->field($row, 'lastname')).'</a>'; |
|
74 | 74 | } else { |
75 | 75 | $confirmed = 'No'; |
76 | - $name = _htmlspecialchars($q->field($row, 'firstname') . ' ' . $q->field($row, 'lastname')); |
|
76 | + $name = _htmlspecialchars($q->field($row, 'firstname').' '.$q->field($row, 'lastname')); |
|
77 | 77 | } |
78 | 78 | |
79 | - $rows[] = array ( |
|
79 | + $rows[] = array( |
|
80 | 80 | $name, |
81 | - '<a href="mailto:' . $q->field($row, 'email') . '">' . $q->field($row, 'email') . '</a>', |
|
81 | + '<a href="mailto:'.$q->field($row, 'email').'">'.$q->field($row, 'email').'</a>', |
|
82 | 82 | $confirmed, |
83 | 83 | $q->field($row, 'registrationtime') |
84 | 84 | ); |
85 | 85 | } |
86 | 86 | |
87 | -$tabledata = array ( |
|
88 | - 'header' => array ( |
|
87 | +$tabledata = array( |
|
88 | + 'header' => array( |
|
89 | 89 | 'Name', |
90 | 90 | 'Email', |
91 | 91 | 'Confirmed?', |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | $rows = array(); |
33 | 33 | $USERURL = new \MySociety\TheyWorkForYou\Url('userview'); |
34 | 34 | |
35 | -for ($row=0; $row<$q->rows(); $row++) { |
|
35 | +for ($row = 0; $row < $q->rows(); $row++) { |
|
36 | 36 | |
37 | 37 | $user_id = $q->field($row, 'user_id'); |
38 | 38 | |
39 | 39 | // Get the total comments posted for this user. |
40 | 40 | $r = $db->query("SELECT COUNT(*) AS totalcount |
41 | 41 | FROM comments |
42 | - WHERE user_id = '" . $user_id . "'"); |
|
42 | + WHERE user_id = '" . $user_id."'"); |
|
43 | 43 | |
44 | 44 | $totalcomments = $r->field(0, 'totalcount'); |
45 | 45 | |
46 | - $percentagedeleted = ( $q->field($row, 'deletedcount') / $totalcomments ) * 100; |
|
46 | + $percentagedeleted = ($q->field($row, 'deletedcount') / $totalcomments) * 100; |
|
47 | 47 | |
48 | 48 | |
49 | 49 | // Get complaints made about this user's comments, but not upheld. |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | |
60 | 60 | $USERURL->insert(array('u'=>$user_id)); |
61 | 61 | |
62 | - $rows[] = array ( |
|
63 | - '<a href="' . $USERURL->generate() . '">' . $q->field($row, 'firstname') . ' ' . $q->field($row, 'lastname') . '</a>', |
|
62 | + $rows[] = array( |
|
63 | + '<a href="'.$USERURL->generate().'">'.$q->field($row, 'firstname').' '.$q->field($row, 'lastname').'</a>', |
|
64 | 64 | $totalcomments, |
65 | 65 | $q->field($row, 'deletedcount'), |
66 | 66 | $percentagedeleted.'%', |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | ); |
69 | 69 | } |
70 | 70 | |
71 | -$tabledata = array ( |
|
72 | - 'header' => array ( |
|
71 | +$tabledata = array( |
|
72 | + 'header' => array( |
|
73 | 73 | 'Name', |
74 | 74 | 'Total comments', |
75 | 75 | 'Number deleted', |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $rows = array(); |
106 | 106 | $USERURL = new \MySociety\TheyWorkForYou\Url('userview'); |
107 | 107 | |
108 | -for ($row=0; $row<$q->rows(); $row++) { |
|
108 | +for ($row = 0; $row < $q->rows(); $row++) { |
|
109 | 109 | |
110 | 110 | $user_id = $q->field($row, 'user_id'); |
111 | 111 | |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | WHERE user_id = '$user_id' |
118 | 118 | AND upheld = '1'"); |
119 | 119 | |
120 | - $rows[] = array ( |
|
121 | - '<a href="' . $USERURL->generate() . '">' . $q->field($row, 'firstname') . ' ' . $q->field($row, 'lastname') . '</a>', |
|
120 | + $rows[] = array( |
|
121 | + '<a href="'.$USERURL->generate().'">'.$q->field($row, 'firstname').' '.$q->field($row, 'lastname').'</a>', |
|
122 | 122 | $q->field($row, 'rejectedcount'), |
123 | 123 | $r->field(0, 'upheldcount') |
124 | 124 | ); |
125 | 125 | |
126 | 126 | } |
127 | -$tabledata = array ( |
|
128 | - 'header' => array ( |
|
127 | +$tabledata = array( |
|
128 | + 'header' => array( |
|
129 | 129 | 'Name', |
130 | 130 | 'Reports not upheld', |
131 | 131 | 'Reports upheld' |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | if ($REPORT->locked() && $REPORT->lockedby() != $THEUSER->user_id()) { |
48 | 48 | |
49 | - print "<p><strong>Someone else was examining this report at " . $REPORT->locked() . " so you can only look at it, not take any action. You could try again in a few minutes.</strong></p>\n"; |
|
49 | + print "<p><strong>Someone else was examining this report at ".$REPORT->locked()." so you can only look at it, not take any action. You could try again in a few minutes.</strong></p>\n"; |
|
50 | 50 | |
51 | 51 | $COMMENT->display(); |
52 | 52 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | // so may be scope for rationalising... |
154 | 154 | global $PAGE; |
155 | 155 | |
156 | - $filename = INCLUDESPATH . "easyparliament/templates/emails/" . $template . ".txt"; |
|
156 | + $filename = INCLUDESPATH."easyparliament/templates/emails/".$template.".txt"; |
|
157 | 157 | |
158 | 158 | if (!file_exists($filename)) { |
159 | 159 | $PAGE->error_message("Sorry, we could not find the email template."); |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | global $this_page; |
178 | 178 | |
179 | 179 | # $commentermail = preg_replace("/\n/", "<br>\n", get_template_contents('comment_deleted') ); |
180 | - $commentermail = preg_replace('/^Subject:.*\n/', '', get_template_contents('comment_deleted') ); |
|
181 | - $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_upheld') ); |
|
180 | + $commentermail = preg_replace('/^Subject:.*\n/', '', get_template_contents('comment_deleted')); |
|
181 | + $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_upheld')); |
|
182 | 182 | |
183 | 183 | ?> |
184 | 184 | <p><strong>You've chosen to delete this comment.</strong> You can now send an email to both the person who posted the comment, and the person who made the report. Uncheck a box to prevent an email from being sent. The comment will not be deleted until you click the button below.</p> |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | |
212 | 212 | global $this_page; |
213 | 213 | |
214 | - $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_declined') ); |
|
214 | + $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_declined')); |
|
215 | 215 | |
216 | 216 | ?> |
217 | 217 | <p><strong>You have chosen not to delete this comment.</strong> You can now send an email to the person who made the report (uncheck the box to send no email). The report will not be resolved until you click the button below.</p> |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $upheld = false; |
244 | 244 | } |
245 | 245 | |
246 | - $success = $REPORT->resolve ($upheld, $COMMENT); |
|
246 | + $success = $REPORT->resolve($upheld, $COMMENT); |
|
247 | 247 | |
248 | 248 | if ($success) { |
249 | 249 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // The reporting user was logged in at the time, |
262 | 262 | // so get their email address. |
263 | 263 | $USER = new USER; |
264 | - $USER->init( $REPORT->user_id() ); |
|
264 | + $USER->init($REPORT->user_id()); |
|
265 | 265 | $email = $USER->email(); |
266 | 266 | } else { |
267 | 267 | // Non-logged-in user; they should have left their address. |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | // Prepare the data needed for either email. |
272 | - $data = array ( |
|
272 | + $data = array( |
|
273 | 273 | 'to' => $email |
274 | 274 | ); |
275 | - $merge = array ( |
|
275 | + $merge = array( |
|
276 | 276 | 'FIRSTNAME' => $REPORT->firstname(), |
277 | 277 | 'LASTNAME' => $REPORT->lastname(), |
278 | 278 | 'REPORTBODY' => strip_tags($REPORT->body()) |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | } else { |
286 | 286 | $data['template'] = 'report_declined'; |
287 | - $merge['COMMENTURL'] = 'https://' . DOMAIN . $COMMENT->url(); |
|
287 | + $merge['COMMENTURL'] = 'https://'.DOMAIN.$COMMENT->url(); |
|
288 | 288 | $merge['REASON'] = get_http_var('declinedreason'); |
289 | 289 | } |
290 | 290 | |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | |
307 | 307 | // Create the URL for if a user wants to return and post another comment. |
308 | 308 | // Remove the anchor for their now deleted comment. |
309 | - $addcommentsurl = 'https://' . DOMAIN . preg_replace("/#.*$/", '#addcomment', $COMMENT->url()); |
|
309 | + $addcommentsurl = 'https://'.DOMAIN.preg_replace("/#.*$/", '#addcomment', $COMMENT->url()); |
|
310 | 310 | |
311 | - $data = array ( |
|
311 | + $data = array( |
|
312 | 312 | 'to' => $USER->email(), |
313 | 313 | 'template' => 'comment_deleted_blank', |
314 | 314 | 'subject' => 'One of your comments has been deleted', |
315 | 315 | ); |
316 | - $merge = array ( |
|
316 | + $merge = array( |
|
317 | 317 | 'REPLYBODY' => get_http_var('commentermail'), |
318 | 318 | 'FIRSTNAME' => $USER->firstname(), |
319 | 319 | 'LASTNAME' => $USER->lastname(), |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | |
336 | 336 | $URL = new \MySociety\TheyWorkForYou\Url('admin_home'); |
337 | 337 | |
338 | - print '<p><a href="' . $URL->generate() . '">Back</a></p>'; |
|
338 | + print '<p><a href="'.$URL->generate().'">Back</a></p>'; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | ?> |
@@ -20,49 +20,49 @@ discard block |
||
20 | 20 | |
21 | 21 | $starttime = time(); |
22 | 22 | for ($personrow=0; $personrow<$q->rows(); $personrow++) { |
23 | - $person_id = $q->field($personrow, 'person_id'); |
|
23 | + $person_id = $q->field($personrow, 'person_id'); |
|
24 | 24 | |
25 | - $args = array ( 'person_id' => $person_id ); |
|
26 | - $speeches = $HANSARDLIST->display('person', $args, 'none'); |
|
25 | + $args = array ( 'person_id' => $person_id ); |
|
26 | + $speeches = $HANSARDLIST->display('person', $args, 'none'); |
|
27 | 27 | |
28 | - // Some data about this person that we'll need for the feed. |
|
29 | - $MEMBER = new MEMBER(array('person_id' => $person_id)); |
|
30 | - $MPURL = new \MySociety\TheyWorkForYou\Url('mp'); |
|
31 | - $MPURL->insert(array('pid'=>$person_id)); |
|
32 | - $mpurl = $MPURL->generate(); |
|
28 | + // Some data about this person that we'll need for the feed. |
|
29 | + $MEMBER = new MEMBER(array('person_id' => $person_id)); |
|
30 | + $MPURL = new \MySociety\TheyWorkForYou\Url('mp'); |
|
31 | + $MPURL->insert(array('pid'=>$person_id)); |
|
32 | + $mpurl = $MPURL->generate(); |
|
33 | 33 | |
34 | - $date = gmdate('Y-m-d'); |
|
35 | - $time = gmdate('H:i:s'); |
|
36 | - $datenow = $date . 'T' . $time . '+00:00'; |
|
34 | + $date = gmdate('Y-m-d'); |
|
35 | + $time = gmdate('H:i:s'); |
|
36 | + $datenow = $date . 'T' . $time . '+00:00'; |
|
37 | 37 | |
38 | - // Prepare the meat of the RSS file. |
|
39 | - $items = ''; |
|
40 | - $entries = ''; |
|
41 | - if (isset ($speeches['rows']) && count($speeches['rows']) > 0) { |
|
38 | + // Prepare the meat of the RSS file. |
|
39 | + $items = ''; |
|
40 | + $entries = ''; |
|
41 | + if (isset ($speeches['rows']) && count($speeches['rows']) > 0) { |
|
42 | 42 | |
43 | - foreach ($speeches['rows'] as $n => $row) { |
|
43 | + foreach ($speeches['rows'] as $n => $row) { |
|
44 | 44 | |
45 | - // While we're linking to individual speeches, |
|
46 | - // the text is the body of the parent, ie (sub)section. |
|
47 | - $title = _htmlentities(str_replace('—', '-', $row['parent']['body'])); |
|
45 | + // While we're linking to individual speeches, |
|
46 | + // the text is the body of the parent, ie (sub)section. |
|
47 | + $title = _htmlentities(str_replace('—', '-', $row['parent']['body'])); |
|
48 | 48 | |
49 | - $link = isset($row['listurl']) ? $row['listurl'] : ''; |
|
50 | - $link = 'https://' . DOMAIN . $link; |
|
49 | + $link = isset($row['listurl']) ? $row['listurl'] : ''; |
|
50 | + $link = 'https://' . DOMAIN . $link; |
|
51 | 51 | |
52 | - $description = _htmlentities(trim_characters($row['body'], 0, 200)); |
|
53 | - $contentencoded = $row['body']; |
|
52 | + $description = _htmlentities(trim_characters($row['body'], 0, 200)); |
|
53 | + $contentencoded = $row['body']; |
|
54 | 54 | |
55 | - $hdate = format_date($row['hdate'], 'Y-m-d'); |
|
56 | - if ($row['htime'] != NULL) { |
|
57 | - $htime = format_time($row['htime'], 'H:i:s'); |
|
58 | - } else { |
|
59 | - $htime = '00:00:00'; |
|
60 | - } |
|
55 | + $hdate = format_date($row['hdate'], 'Y-m-d'); |
|
56 | + if ($row['htime'] != NULL) { |
|
57 | + $htime = format_time($row['htime'], 'H:i:s'); |
|
58 | + } else { |
|
59 | + $htime = '00:00:00'; |
|
60 | + } |
|
61 | 61 | |
62 | - $date = $hdate . 'T' . $htime . '+00:00'; |
|
62 | + $date = $hdate . 'T' . $htime . '+00:00'; |
|
63 | 63 | |
64 | - $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n"; |
|
65 | - $entries .= "<item rdf:about=\"$link\"> |
|
64 | + $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n"; |
|
65 | + $entries .= "<item rdf:about=\"$link\"> |
|
66 | 66 | <title>$title</title> |
67 | 67 | <link>$link</link> |
68 | 68 | <description>$description</description> |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | </item> |
72 | 72 | "; |
73 | 73 | |
74 | - } |
|
75 | - } |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - // Prepare the whole text of the RSS file. |
|
78 | - $rsstext = '<?xml version="1.0" encoding="utf-8"?> |
|
77 | + // Prepare the whole text of the RSS file. |
|
78 | + $rsstext = '<?xml version="1.0" encoding="utf-8"?> |
|
79 | 79 | <rdf:RDF |
80 | 80 | xmlns:dc="http://purl.org/dc/elements/1.1/" |
81 | 81 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | |
102 | 102 | </rdf:RDF>'; |
103 | 103 | |
104 | - // Write the text to the file... |
|
105 | - $filename = $rsspath . $person_id . '.rdf'; |
|
106 | - $fh = @fopen($filename, "w"); |
|
107 | - if (!$fh) { # Problem writing, just carry on |
|
108 | - echo "Could not write to file ($filename)\n"; |
|
109 | - continue; |
|
110 | - } |
|
111 | - fwrite($fh, $rsstext); |
|
112 | - fclose ($fh); |
|
104 | + // Write the text to the file... |
|
105 | + $filename = $rsspath . $person_id . '.rdf'; |
|
106 | + $fh = @fopen($filename, "w"); |
|
107 | + if (!$fh) { # Problem writing, just carry on |
|
108 | + echo "Could not write to file ($filename)\n"; |
|
109 | + continue; |
|
110 | + } |
|
111 | + fwrite($fh, $rsstext); |
|
112 | + fclose ($fh); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | #print "Took " . (time()-$starttime) . " seconds\n"; |