@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | and party != '' |
138 | 138 | order by entered_house |
139 | 139 | " . $direction, array(":house" => $house, |
140 | - ":person_id" => $person_id))->first(); |
|
140 | + ":person_id" => $person_id))->first(); |
|
141 | 141 | if ($row) { |
142 | 142 | $party = $row["party"]; |
143 | 143 | if ( $party == 'Labour/Co-operative' ) { |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
229 | - * Image |
|
230 | - * |
|
231 | - * Return a URL for the member's image. |
|
232 | - * |
|
233 | - * @return string The URL of the member's image. |
|
234 | - */ |
|
229 | + * Image |
|
230 | + * |
|
231 | + * Return a URL for the member's image. |
|
232 | + * |
|
233 | + * @return string The URL of the member's image. |
|
234 | + */ |
|
235 | 235 | |
236 | 236 | public function image() { |
237 | 237 | |
@@ -284,15 +284,15 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
287 | - * Offices |
|
288 | - * |
|
289 | - * Return an array of Office objects held (or previously held) by the member. |
|
290 | - * |
|
291 | - * @param string $include_only Restrict the list to include only "previous" or "current" offices. |
|
292 | - * @param bool $ignore_committees Ignore offices that appear to be committee memberships. |
|
293 | - * |
|
294 | - * @return array An array of Office objects. |
|
295 | - */ |
|
287 | + * Offices |
|
288 | + * |
|
289 | + * Return an array of Office objects held (or previously held) by the member. |
|
290 | + * |
|
291 | + * @param string $include_only Restrict the list to include only "previous" or "current" offices. |
|
292 | + * @param bool $ignore_committees Ignore offices that appear to be committee memberships. |
|
293 | + * |
|
294 | + * @return array An array of Office objects. |
|
295 | + */ |
|
296 | 296 | |
297 | 297 | public function offices($include_only = null, $ignore_committees = false) { |
298 | 298 | |
@@ -346,12 +346,12 @@ discard block |
||
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
349 | - * Get Other Parties String |
|
350 | - * |
|
351 | - * Return a readable list of party changes for this member. |
|
352 | - * |
|
353 | - * @return string|null A readable list of the party changes for this member. |
|
354 | - */ |
|
349 | + * Get Other Parties String |
|
350 | + * |
|
351 | + * Return a readable list of party changes for this member. |
|
352 | + * |
|
353 | + * @return string|null A readable list of the party changes for this member. |
|
354 | + */ |
|
355 | 355 | |
356 | 356 | public function getOtherPartiesString() { |
357 | 357 | |
@@ -370,12 +370,12 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
373 | - * Get Other Constituencies String |
|
374 | - * |
|
375 | - * Return a readable list of other constituencies for this member. |
|
376 | - * |
|
377 | - * @return string|null A readable list of the other constituencies for this member. |
|
378 | - */ |
|
373 | + * Get Other Constituencies String |
|
374 | + * |
|
375 | + * Return a readable list of other constituencies for this member. |
|
376 | + * |
|
377 | + * @return string|null A readable list of the other constituencies for this member. |
|
378 | + */ |
|
379 | 379 | |
380 | 380 | public function getOtherConstituenciesString() { |
381 | 381 | |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
391 | - * Get Entered/Left Strings |
|
392 | - * |
|
393 | - * Return an array of readable strings covering when people entered or left |
|
394 | - * various houses. Returns an array since it's possible for a member to have |
|
395 | - * done several of these things. |
|
396 | - * |
|
397 | - * @return array An array of strings of when this member entered or left houses. |
|
398 | - */ |
|
391 | + * Get Entered/Left Strings |
|
392 | + * |
|
393 | + * Return an array of readable strings covering when people entered or left |
|
394 | + * various houses. Returns an array since it's possible for a member to have |
|
395 | + * done several of these things. |
|
396 | + * |
|
397 | + * @return array An array of strings of when this member entered or left houses. |
|
398 | + */ |
|
399 | 399 | public function getEnterLeaveStrings() { |
400 | 400 | $output = array(); |
401 | 401 |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | return $direction; |
92 | 92 | } |
93 | 93 | |
94 | - public function currentPartyComparison(){ |
|
94 | + public function currentPartyComparison() { |
|
95 | 95 | # Simplify the current party when being compared to the original |
96 | 96 | # Stops co-op and labour being seen as different |
97 | 97 | $party = $this->party; |
98 | - if ( $party == 'Labour/Co-operative' ) { |
|
98 | + if ($party == 'Labour/Co-operative') { |
|
99 | 99 | $party = 'Labour'; |
100 | 100 | } |
101 | 101 | return $party; |
102 | 102 | } |
103 | 103 | |
104 | - public function cohortParty($house = HOUSE_TYPE_COMMONS){ |
|
104 | + public function cohortParty($house = HOUSE_TYPE_COMMONS) { |
|
105 | 105 | // The party being compared against for party comparison purposes |
106 | 106 | // Unless specified by the condition in cohortPartyComparisonDirection |
107 | 107 | // This is the first, not last, party a person has. |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | ":person_id" => $person_id))->first(); |
127 | 127 | if ($row) { |
128 | 128 | $party = $row["party"]; |
129 | - if ( $party == 'Labour/Co-operative' ) { |
|
129 | + if ($party == 'Labour/Co-operative') { |
|
130 | 130 | $party = 'Labour'; |
131 | 131 | } elseif ($party == 'Sinn Féin') { |
132 | 132 | $party = 'Sinn Fein'; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $now = new \DateTime(); |
157 | 157 | |
158 | 158 | $diff = $date_entered->diff($now); |
159 | - if ( $diff->y == 0 && $diff->m <= 6 ) { |
|
159 | + if ($diff->y == 0 && $diff->m <= 6) { |
|
160 | 160 | return true; |
161 | 161 | } |
162 | 162 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $entered_house = $this->entered_house($house); |
179 | 179 | |
180 | - if ( $entered_house ) { |
|
180 | + if ($entered_house) { |
|
181 | 181 | $date_entered = $entered_house['date']; |
182 | 182 | } |
183 | 183 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | $left_house = $this->left_house($house); |
199 | 199 | |
200 | - if ( $left_house ) { |
|
200 | + if ($left_house) { |
|
201 | 201 | $date_left = $left_house['date']; |
202 | 202 | } |
203 | 203 | |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | |
226 | 226 | $is_lord = $this->house(HOUSE_TYPE_LORDS); |
227 | 227 | if ($is_lord) { |
228 | - list($image,$size) = Utility\Member::findMemberImage($this->person_id(), false, 'lord'); |
|
228 | + list($image, $size) = Utility\Member::findMemberImage($this->person_id(), false, 'lord'); |
|
229 | 229 | } else { |
230 | - list($image,$size) = Utility\Member::findMemberImage($this->person_id(), false, true); |
|
230 | + list($image, $size) = Utility\Member::findMemberImage($this->person_id(), false, true); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | // We can determine if the image exists or not by testing if size is set |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | |
251 | 251 | usort( |
252 | 252 | $departures, |
253 | - function ($a, $b) { |
|
254 | - if ( $a['date'] == $b['date'] ) { |
|
253 | + function($a, $b) { |
|
254 | + if ($a['date'] == $b['date']) { |
|
255 | 255 | return 0; |
256 | - } else if ( $a['date'] < $b['date'] ) { |
|
256 | + } else if ($a['date'] < $b['date']) { |
|
257 | 257 | return -1; |
258 | 258 | } else { |
259 | 259 | return 1; |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $office = $office['office']; |
292 | 292 | |
293 | 293 | foreach ($office as $row) { |
294 | - if ( $officeObject = $this->getOfficeObject($include_only, $ignore_committees, $row) ) { |
|
294 | + if ($officeObject = $this->getOfficeObject($include_only, $ignore_committees, $row)) { |
|
295 | 295 | $out[] = $officeObject; |
296 | 296 | } |
297 | 297 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | private function entered_house_line($house, $house_name) { |
431 | 431 | if (isset($this->entered_house[$house]['date'])) { |
432 | 432 | $string = "<strong>"; |
433 | - if (strlen($this->entered_house[$house]['date_pretty'])==4) { |
|
433 | + if (strlen($this->entered_house[$house]['date_pretty']) == 4) { |
|
434 | 434 | $string .= sprintf(gettext("Entered the %s in %s"), $house_name, $this->entered_house[$house]['date_pretty']); |
435 | 435 | } else { |
436 | 436 | $string .= sprintf(gettext("Entered the %s on %s"), $house_name, $this->entered_house[$house]['date_pretty']); |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | private function left_house_line($house, $house_name) { |
447 | 447 | if ($this->house($house) && !$this->current_member($house)) { |
448 | 448 | $string = "<strong>"; |
449 | - if (strlen($this->left_house[$house]['date_pretty'])==4) { |
|
449 | + if (strlen($this->left_house[$house]['date_pretty']) == 4) { |
|
450 | 450 | $string .= sprintf(gettext("Left the %s in %s"), $house_name, $this->left_house[$house]['date_pretty']); |
451 | 451 | } else { |
452 | 452 | $string .= sprintf(gettext("Left the %s on %s"), $house_name, $this->left_house[$house]['date_pretty']); |
@@ -463,12 +463,12 @@ discard block |
||
463 | 463 | $policy_diffs = array(); |
464 | 464 | $party_positions = $partyCohort->getAllPolicyPositions($policiesList); |
465 | 465 | |
466 | - if ( !$party_positions ) { |
|
466 | + if (!$party_positions) { |
|
467 | 467 | return $policy_diffs; |
468 | 468 | } |
469 | 469 | |
470 | - foreach ( $positions->positionsById as $policy_id => $details ) { |
|
471 | - if ( $details['has_strong'] && $details['score'] != -1 && isset($party_positions[$policy_id])) { |
|
470 | + foreach ($positions->positionsById as $policy_id => $details) { |
|
471 | + if ($details['has_strong'] && $details['score'] != -1 && isset($party_positions[$policy_id])) { |
|
472 | 472 | $mp_score = $details['score']; |
473 | 473 | $party_position = $party_positions[$policy_id]; |
474 | 474 | $party_score = $party_position['score']; |
@@ -500,18 +500,18 @@ discard block |
||
500 | 500 | return $policy_diffs; |
501 | 501 | } |
502 | 502 | |
503 | - private function calculatePolicyDiffScore( $mp_score, $party_score ) { |
|
503 | + private function calculatePolicyDiffScore($mp_score, $party_score) { |
|
504 | 504 | $score_diff = abs($mp_score - $party_score); |
505 | 505 | // if they are on opposite sides of mixture of for and against |
506 | 506 | if ( |
507 | - ( $mp_score < 0.4 && $party_score > 0.6 ) || |
|
508 | - ( $mp_score > 0.6 && $party_score < 0.4 ) |
|
507 | + ($mp_score < 0.4 && $party_score > 0.6) || |
|
508 | + ($mp_score > 0.6 && $party_score < 0.4) |
|
509 | 509 | ) { |
510 | 510 | $score_diff += 2; |
511 | 511 | // if on is mixture of for and against and one is for/against |
512 | 512 | } else if ( |
513 | - ( $mp_score > 0.4 && $mp_score < 0.6 && ( $party_score > 0.6 || $party_score < 0.4 ) ) || |
|
514 | - ( $party_score > 0.4 && $party_score < 0.6 && ( $mp_score > 0.6 || $mp_score < 0.4 ) ) |
|
513 | + ($mp_score > 0.4 && $mp_score < 0.6 && ($party_score > 0.6 || $party_score < 0.4)) || |
|
514 | + ($party_score > 0.4 && $party_score < 0.6 && ($mp_score > 0.6 || $mp_score < 0.4)) |
|
515 | 515 | ) { |
516 | 516 | $score_diff += 1; |
517 | 517 | } |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | |
525 | 525 | $mreg = array(); |
526 | 526 | $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($postcode); |
527 | - if ( isset($constituencies[$type]) ) { |
|
527 | + if (isset($constituencies[$type])) { |
|
528 | 528 | $cons_name = $constituencies[$type]; |
529 | 529 | $query_base = "SELECT member.person_id, title, lordofname, given_name, family_name, constituency, house |
530 | 530 | FROM member, person_names |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | ':cons_name' => $cons_name |
542 | 542 | ) |
543 | 543 | ); |
544 | - if ( !$q->rows() && ($dissolution = Dissolution::db()) ) { |
|
544 | + if (!$q->rows() && ($dissolution = Dissolution::db())) { |
|
545 | 545 | $q = $db->query("$query_base AND $dissolution[query]", |
546 | 546 | array( |
547 | 547 | ':house' => $house, |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | } |
566 | 566 | |
567 | 567 | public static function getRepNameForHouse($house) { |
568 | - switch ( $house ) { |
|
568 | + switch ($house) { |
|
569 | 569 | case HOUSE_TYPE_COMMONS: |
570 | 570 | $name = 'MP'; |
571 | 571 | break; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $file = _load_file($_); |
68 | 68 | $date = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $_); |
69 | 69 | $data[$_] = array(); |
70 | - if (preg_match('#<regmem personid="uk.org.publicwhip/person/'.$p.'" (?:memberid="(.*?)" )?membername="(.*?)" date="(.*?)">(.*?)</regmem>#s', $file, $m)) { |
|
70 | + if (preg_match('#<regmem personid="uk.org.publicwhip/person/' . $p . '" (?:memberid="(.*?)" )?membername="(.*?)" date="(.*?)">(.*?)</regmem>#s', $file, $m)) { |
|
71 | 71 | $earliest = $_; |
72 | 72 | if (!$name) { |
73 | 73 | $name = $m[2]; |
@@ -103,21 +103,21 @@ discard block |
||
103 | 103 | break; |
104 | 104 | } |
105 | 105 | $date_pre = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $_); |
106 | - $date_post = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $files[$i+1]); |
|
106 | + $date_post = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $files[$i + 1]); |
|
107 | 107 | $pretty = format_date($date_pre, LONGDATEFORMAT); |
108 | 108 | $oout = ''; |
109 | 109 | foreach ($data[$_] as $cat_type => $cat_data) { |
110 | - $old = array_key_exists($cat_type, $data[$files[$i+1]]) ? $data[$files[$i+1]][$cat_type] : ''; |
|
110 | + $old = array_key_exists($cat_type, $data[$files[$i + 1]]) ? $data[$files[$i + 1]][$cat_type] : ''; |
|
111 | 111 | $new = $data[$_][$cat_type]; |
112 | 112 | if ($diff = clean_diff($old, $new)) { |
113 | 113 | $oout .= cat_heading($cat_type, $date_pre, $date_post) . $diff; |
114 | 114 | } |
115 | 115 | } |
116 | - foreach ($data[$files[$i+1]] as $cat_type => $cat_data) { |
|
116 | + foreach ($data[$files[$i + 1]] as $cat_type => $cat_data) { |
|
117 | 117 | if (array_key_exists($cat_type, $data[$_])) { |
118 | 118 | continue; |
119 | 119 | } |
120 | - if ($diff = clean_diff($data[$files[$i+1]][$cat_type], '')) { |
|
120 | + if ($diff = clean_diff($data[$files[$i + 1]][$cat_type], '')) { |
|
121 | 121 | $oout .= cat_heading($cat_type, $date_pre, $date_post) . $diff; |
122 | 122 | } |
123 | 123 | } |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | if ($f) { |
150 | 150 | $f = "$dir/regmem$f.xml"; |
151 | 151 | $count = count($files); |
152 | - for ($i=0; $i<$count; ++$i) { |
|
152 | + for ($i = 0; $i < $count; ++$i) { |
|
153 | 153 | if ($files[$i] == $f) { |
154 | 154 | $new = $i; |
155 | 155 | break; |
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
159 | - $old = $new+1; |
|
159 | + $old = $new + 1; |
|
160 | 160 | $old = $files[$old]; |
161 | 161 | $old_iso = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $old); |
162 | 162 | $old_pretty = format_date($old_iso, LONGDATEFORMAT); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $old = _load_file($old); |
167 | 167 | $new = _load_file($new); |
168 | 168 | |
169 | - $DATA->set_page_metadata($this_page, 'heading', 'Changes from '.$old_pretty.' to '.$new_pretty); |
|
169 | + $DATA->set_page_metadata($this_page, 'heading', 'Changes from ' . $old_pretty . ' to ' . $new_pretty); |
|
170 | 170 | $PAGE->stripe_start(); |
171 | 171 | print $link; |
172 | 172 | $data = array(); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $out .= clean_diff($old, $new); |
189 | 189 | } |
190 | 190 | if ($out) { |
191 | - print span_row('<h2>'.$names[$person_id].' - <a href="?p='.$person_id.'">Register history</a> | <a href="/mp/?pid='.$person_id.'">MP’s page</a></h2>', true) . $out; |
|
191 | + print span_row('<h2>' . $names[$person_id] . ' - <a href="?p=' . $person_id . '">Register history</a> | <a href="/mp/?pid=' . $person_id . '">MP’s page</a></h2>', true) . $out; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | print '</table>'; |
@@ -245,28 +245,28 @@ discard block |
||
245 | 245 | $c = 0; $year = 0; |
246 | 246 | $view = ''; $compare = ''; |
247 | 247 | $count = count($files); |
248 | - for ($i=0; $i<$count; ++$i) { |
|
248 | + for ($i = 0; $i < $count; ++$i) { |
|
249 | 249 | preg_match('/(\d\d\d\d)-(\d\d-\d\d)/', $files[$i], $m); |
250 | 250 | $y = $m[1]; $md = $m[2]; |
251 | 251 | if ($c++) { |
252 | 252 | $view .= ' | '; |
253 | - if ($i < $count-1) { |
|
253 | + if ($i < $count - 1) { |
|
254 | 254 | $compare .= ' | '; |
255 | 255 | } |
256 | 256 | } |
257 | 257 | if ($year != $y) { |
258 | 258 | $year = $y; |
259 | 259 | $view .= "<em>$year</em> "; |
260 | - if ($i < $count-1) { |
|
260 | + if ($i < $count - 1) { |
|
261 | 261 | $compare .= "<em>$year</em> "; |
262 | 262 | } |
263 | 263 | } |
264 | 264 | $months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
265 | 265 | preg_match('/(\d\d)-(\d\d)/', $md, $m); |
266 | - $date = ($m[2]+0) . ' '. $months[$m[1]-1]; |
|
267 | - $view .= '<a href="./?d='.$y.'-'.$md.'">'.$date.'</a>'; |
|
268 | - if ($i < $count-1) { |
|
269 | - $compare .= '<a href="?f='.$y.'-'.$md.'">'.$date.'</a>'; |
|
266 | + $date = ($m[2] + 0) . ' ' . $months[$m[1] - 1]; |
|
267 | + $view .= '<a href="./?d=' . $y . '-' . $md . '">' . $date . '</a>'; |
|
268 | + if ($i < $count - 1) { |
|
269 | + $compare .= '<a href="?f=' . $y . '-' . $md . '">' . $date . '</a>'; |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | ?> |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | <?php |
283 | 283 | uasort($names, 'by_name'); |
284 | 284 | foreach ($names as $_ => $value) { |
285 | - print '<li><a href="?p='.$_.'">'.$value.'</a>'; |
|
285 | + print '<li><a href="?p=' . $_ . '">' . $value . '</a>'; |
|
286 | 286 | } |
287 | 287 | print '</ul>'; |
288 | 288 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $data = array(); |
301 | 301 | parse_file($d, $d_iso, 'only', $data); |
302 | 302 | $this_page = 'regmem_date'; |
303 | - $DATA->set_page_metadata($this_page, 'heading', "The Register of Members' Interests, $d_pretty");; |
|
303 | + $DATA->set_page_metadata($this_page, 'heading', "The Register of Members' Interests, $d_pretty"); ; |
|
304 | 304 | $PAGE->stripe_start(); |
305 | 305 | print $link; |
306 | 306 | ?> |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | foreach ($v as $cat_type => $vv) { |
315 | 315 | $out .= cat_heading($cat_type, $d_iso, $d_iso, false); |
316 | 316 | $d = (array_key_exists('only', $data[$person_id][$cat_type]) ? $data[$person_id][$cat_type]['only'] : ''); |
317 | - $out .= prettify($d)."\n"; |
|
317 | + $out .= prettify($d) . "\n"; |
|
318 | 318 | } |
319 | 319 | if ($out) { |
320 | 320 | print '<div class="block">'; |
@@ -364,8 +364,8 @@ discard block |
||
364 | 364 | if (!count($r) && !count($a)) { |
365 | 365 | return ''; |
366 | 366 | } |
367 | - $r = join("\n", $r); $r = $r ? '<td class="r"><ul>'.$r.'</ul></td>' : '<td> </td>'; |
|
368 | - $a = join("\n", $a); $a = $a ? '<td class="a"><ul>'.$a.'</ul></td>' : '<td> </td>'; |
|
367 | + $r = join("\n", $r); $r = $r ? '<td class="r"><ul>' . $r . '</ul></td>' : '<td> </td>'; |
|
368 | + $a = join("\n", $a); $a = $a ? '<td class="a"><ul>' . $a . '</ul></td>' : '<td> </td>'; |
|
369 | 369 | $diff = '<tr>' . $r . $a . '</tr>'; |
370 | 370 | $diff = preg_replace('#<item.*?>(.*?)</item>#', '<li>$1</li>', $diff); |
371 | 371 | return $diff; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | // where rid is a report_id and cid is a comment_id. |
7 | 7 | |
8 | 8 | include_once '../../includes/easyparliament/init.php'; |
9 | -include_once (INCLUDESPATH."easyparliament/commentreport.php"); |
|
9 | +include_once (INCLUDESPATH . "easyparliament/commentreport.php"); |
|
10 | 10 | |
11 | 11 | $this_page = "admin_commentreport"; |
12 | 12 | |
@@ -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 | 'REPORTBODY' => strip_tags($REPORT->body()) |
277 | 277 | ); |
278 | 278 | |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | // Remove the anchor for their now deleted comment. |
307 | 307 | $addcommentsurl = 'https://' . DOMAIN . preg_replace("/#.*$/", '#addcomment', $COMMENT->url()); |
308 | 308 | |
309 | - $data = array ( |
|
309 | + $data = array( |
|
310 | 310 | 'to' => $USER->email(), |
311 | 311 | 'template' => 'comment_deleted_blank', |
312 | 312 | 'subject' => 'One of your comments has been deleted', |
313 | 313 | ); |
314 | - $merge = array ( |
|
314 | + $merge = array( |
|
315 | 315 | 'REPLYBODY' => get_http_var('commentermail'), |
316 | 316 | # 'DELETEDREASON' => get_http_var('deletedreason'), |
317 | 317 | 'ADDCOMMENTURL' => $addcommentsurl, |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | public $firstname = ''; |
28 | 28 | public $lastname = ''; |
29 | 29 | public $body = ''; |
30 | - public $reported = null; // datetime |
|
31 | - public $resolved = null; // datetime |
|
32 | - public $resolvedby = ''; // user_id |
|
33 | - public $locked = null; // datetime |
|
34 | - public $lockedby = ''; // user_id |
|
35 | - public $upheld = ''; // boolean |
|
30 | + public $reported = null; // datetime |
|
31 | + public $resolved = null; // datetime |
|
32 | + public $resolvedby = ''; // user_id |
|
33 | + public $locked = null; // datetime |
|
34 | + public $lockedby = ''; // user_id |
|
35 | + public $upheld = ''; // boolean |
|
36 | 36 | |
37 | 37 | // If the user was logged in, this will be set: |
38 | 38 | public $user_id = ''; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public $email = ''; |
41 | 41 | |
42 | 42 | |
43 | - public function __construct($report_id='') { |
|
43 | + public function __construct($report_id = '') { |
|
44 | 44 | // Pass it a report id and it gets and sets this report's data. |
45 | 45 | |
46 | 46 | $this->db = new ParlDB; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | global $THEUSER, $PAGE; |
162 | 162 | |
163 | 163 | if (!$THEUSER->is_able_to('reportcomment')) { |
164 | - $PAGE->error_message ("Sorry, you are not allowed to post reports."); |
|
164 | + $PAGE->error_message("Sorry, you are not allowed to post reports."); |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
@@ -229,19 +229,19 @@ discard block |
||
229 | 229 | |
230 | 230 | if ($q->success()) { |
231 | 231 | // Inserted OK, so set up this object's variables. |
232 | - $this->report_id = $q->insert_id(); |
|
233 | - $this->comment_id = $COMMENT->comment_id(); |
|
234 | - $this->body = $body; |
|
235 | - $this->reported = $time; |
|
232 | + $this->report_id = $q->insert_id(); |
|
233 | + $this->comment_id = $COMMENT->comment_id(); |
|
234 | + $this->body = $body; |
|
235 | + $this->reported = $time; |
|
236 | 236 | |
237 | 237 | if ($THEUSER->isloggedin()) { |
238 | - $this->user_id = $THEUSER->user_id(); |
|
238 | + $this->user_id = $THEUSER->user_id(); |
|
239 | 239 | $this->firstname = $THEUSER->firstname(); |
240 | 240 | $this->lastname = $THEUSER->lastname(); |
241 | 241 | } else { |
242 | - $this->email = $reportdata['email']; |
|
243 | - $this->firstname = $reportdata['firstname']; |
|
244 | - $this->lastname = $reportdata['lastname']; |
|
242 | + $this->email = $reportdata['email']; |
|
243 | + $this->firstname = $reportdata['firstname']; |
|
244 | + $this->lastname = $reportdata['lastname']; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | |
@@ -273,11 +273,11 @@ discard block |
||
273 | 273 | $email = $this->email(); |
274 | 274 | } |
275 | 275 | |
276 | - $data = array ( |
|
276 | + $data = array( |
|
277 | 277 | 'to' => $email, |
278 | 278 | 'template' => 'report_acknowledge' |
279 | 279 | ); |
280 | - $merge = array ( |
|
280 | + $merge = array( |
|
281 | 281 | 'COMMENTURL' => "https://" . DOMAIN . $COMMENT->url(), |
282 | 282 | 'REPORTBODY' => strip_tags($this->body()) |
283 | 283 | ); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $data = array(); |
300 | 300 | |
301 | 301 | if (is_numeric($this->report_id)) { |
302 | - $data = array ( |
|
302 | + $data = array( |
|
303 | 303 | 'report_id' => $this->report_id(), |
304 | 304 | 'comment_id' => $this->comment_id(), |
305 | 305 | 'user_id' => $this->user_id(), |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | if ($THEUSER->is_able_to('deletecomment')) { |
337 | 337 | $time = gmdate("Y-m-d H:i:s"); |
338 | 338 | |
339 | - $q = $this->db->query ("UPDATE commentreports |
|
339 | + $q = $this->db->query("UPDATE commentreports |
|
340 | 340 | SET locked = '$time', |
341 | 341 | lockedby = '" . $THEUSER->user_id() . "' |
342 | 342 | WHERE report_id = '" . $this->report_id . "' |
@@ -347,11 +347,11 @@ discard block |
||
347 | 347 | $this->lockedby = $THEUSER->user_id(); |
348 | 348 | return true; |
349 | 349 | } else { |
350 | - $PAGE->error_message ("Sorry, we were unable to lock this report."); |
|
350 | + $PAGE->error_message("Sorry, we were unable to lock this report."); |
|
351 | 351 | return false; |
352 | 352 | } |
353 | 353 | } else { |
354 | - $PAGE->error_message ("You are not authorised to delete annotations."); |
|
354 | + $PAGE->error_message("You are not authorised to delete annotations."); |
|
355 | 355 | return false; |
356 | 356 | } |
357 | 357 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | public function unlock() { |
361 | 361 | // Unlock a comment so it can be examined by someone else. |
362 | 362 | |
363 | - $q = $this->db->query ("UPDATE commentreports |
|
363 | + $q = $this->db->query("UPDATE commentreports |
|
364 | 364 | SET locked = NULL, |
365 | 365 | lockedby = NULL |
366 | 366 | WHERE report_id = '" . $this->report_id . "' |
@@ -434,16 +434,16 @@ discard block |
||
434 | 434 | |
435 | 435 | return true; |
436 | 436 | } else { |
437 | - $PAGE->error_message ("Sorry, we couldn't resolve this report."); |
|
437 | + $PAGE->error_message("Sorry, we couldn't resolve this report."); |
|
438 | 438 | return false; |
439 | 439 | } |
440 | 440 | } else { |
441 | - $PAGE->error_message ("This report has already been resolved (on " . $this->resolved . ")"); |
|
441 | + $PAGE->error_message("This report has already been resolved (on " . $this->resolved . ")"); |
|
442 | 442 | return false; |
443 | 443 | } |
444 | 444 | |
445 | 445 | } else { |
446 | - $PAGE->error_message ("You are not authorised to resolve reports."); |
|
446 | + $PAGE->error_message("You are not authorised to resolve reports."); |
|
447 | 447 | return false; |
448 | 448 | } |
449 | 449 | } |
@@ -26,14 +26,14 @@ |
||
26 | 26 | if (isset($THEUSER) && $THEUSER->postcode_is_set()) { |
27 | 27 | try { |
28 | 28 | $MEMBER = new MySociety\TheyWorkForYou\Member(array('postcode' => $THEUSER->postcode(), 'house' => \MySociety\TheyWorkForYou\Utility\House::majorToHouse($view->major)[0])); |
29 | - } catch ( MySociety\TheyWorkForYou\MemberException $e ) { |
|
29 | + } catch (MySociety\TheyWorkForYou\MemberException $e) { |
|
30 | 30 | $MEMBER = null; |
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | 34 | $data = $view->display(); |
35 | 35 | if ($data) { |
36 | - if ( !empty($data['template']) ) { |
|
36 | + if (!empty($data['template'])) { |
|
37 | 37 | $template = $data['template']; |
38 | 38 | } else { |
39 | 39 | $template = 'section/section'; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | $type = ucfirst(get_http_var('type')); |
16 | -$class_name = "MySociety\TheyWorkForYou\SectionView\\${type}View"; |
|
16 | +$class_name = "MySociety\TheyWorkForYou\SectionView\\${type}view"; |
|
17 | 17 | if (!$type || !class_exists($class_name)) { |
18 | 18 | $PAGE->error_message("No type specified", true); |
19 | 19 | exit; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | include_once '../../includes/easyparliament/init.php'; |
4 | -include_once INCLUDESPATH."easyparliament/member.php"; |
|
4 | +include_once INCLUDESPATH . "easyparliament/member.php"; |
|
5 | 5 | |
6 | 6 | $pc = get_http_var('pc'); |
7 | 7 | $pc = preg_replace('#[^a-z0-9]#i', '', $pc); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $errors['pc'] = "Sorry, we couldn't check your postcode right now. Please use the 'All Mps' link above to browse MPs"; |
16 | 16 | } elseif ($constituency == "") { |
17 | 17 | $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a known postcode"; |
18 | - twfy_debug ('MP', "Can't display an MP, as submitted postcode didn't match a constituency"); |
|
18 | + twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency"); |
|
19 | 19 | } else { |
20 | 20 | $MEMBER = new MEMBER(array('constituency' => $constituency)); |
21 | 21 | if ($MEMBER->person_id()) { |
@@ -29,5 +29,5 @@ discard block |
||
29 | 29 | } |
30 | 30 | } else { |
31 | 31 | $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a valid postcode"; |
32 | - twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form."); |
|
32 | + twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form."); |
|
33 | 33 | } |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | # Ignore errors we've asked to ignore |
70 | 70 | if (error_reporting()==0) return; |
71 | 71 | |
72 | - // define an assoc array of error string |
|
73 | - // in reality the only entries we should |
|
74 | - // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
|
75 | - // E_USER_WARNING and E_USER_NOTICE |
|
76 | - # Commented out are ones that a user function cannot handle. |
|
72 | + // define an assoc array of error string |
|
73 | + // in reality the only entries we should |
|
74 | + // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
|
75 | + // E_USER_WARNING and E_USER_NOTICE |
|
76 | + # Commented out are ones that a user function cannot handle. |
|
77 | 77 | $errortype = array ( |
78 | 78 | #E_ERROR => "Error", |
79 | 79 | E_WARNING => "Warning", |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php |
203 | 203 | function adodb_backtrace($print=true) |
204 | 204 | { |
205 | - $s = ''; |
|
206 | - if (PHPVERSION() >= 4.3) { |
|
205 | + $s = ''; |
|
206 | + if (PHPVERSION() >= 4.3) { |
|
207 | 207 | |
208 | 208 | $MAXSTRLEN = 64; |
209 | 209 | |
@@ -211,33 +211,33 @@ discard block |
||
211 | 211 | array_shift($traceArr); |
212 | 212 | $tabs = sizeof($traceArr)-1; |
213 | 213 | foreach ($traceArr as $arr) { |
214 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
215 | - $tabs -= 1; |
|
216 | - if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
217 | - $args = array(); |
|
218 | - if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
|
214 | + for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
215 | + $tabs -= 1; |
|
216 | + if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
217 | + $args = array(); |
|
218 | + if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
|
219 | 219 | if (is_null($v)) $args[] = 'null'; |
220 | 220 | elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']'; |
221 | 221 | elseif (is_object($v)) $args[] = 'Object:'.get_class($v); |
222 | 222 | elseif (is_bool($v)) $args[] = $v ? 'true' : 'false'; |
223 | 223 | else { |
224 | - $v = (string) @$v; |
|
225 | - $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
|
226 | - if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
|
227 | - $args[] = $str; |
|
224 | + $v = (string) @$v; |
|
225 | + $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
|
226 | + if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
|
227 | + $args[] = $str; |
|
228 | 228 | } |
229 | - } |
|
229 | + } |
|
230 | 230 | |
231 | - $s .= $arr['function'].'('.implode(', ',$args).')'; |
|
232 | - // $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". |
|
233 | - // " file: <a href=\"file:/%s\">%s</a></font>", |
|
234 | - // $arr['line'],$arr['file'],$arr['file']); |
|
235 | - $s .= "\n"; |
|
231 | + $s .= $arr['function'].'('.implode(', ',$args).')'; |
|
232 | + // $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". |
|
233 | + // " file: <a href=\"file:/%s\">%s</a></font>", |
|
234 | + // $arr['line'],$arr['file'],$arr['file']); |
|
235 | + $s .= "\n"; |
|
236 | 236 | } |
237 | 237 | if ($print) print $s; |
238 | - } |
|
238 | + } |
|
239 | 239 | |
240 | - return $s; |
|
240 | + return $s; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | // Returns the unixtime in microseconds. |
@@ -538,14 +538,14 @@ discard block |
||
538 | 538 | //$tbl["»"] = "»"; |
539 | 539 | //$tbl["«"] = "«"; |
540 | 540 | |
541 | - // lib_filter will replace unmatched < and > with entities so |
|
542 | - // we abuse strtr's only replace once behaviour to not double |
|
543 | - // encode them. May not be robust. |
|
544 | - // This does mean if anyone actually wants to put > or < |
|
545 | - // in a comment they can't but that's a lot less likely than |
|
546 | - // < or > for less than and greater than. |
|
547 | - $tbl['<'] = "<"; |
|
548 | - $tbl['>'] = ">"; |
|
541 | + // lib_filter will replace unmatched < and > with entities so |
|
542 | + // we abuse strtr's only replace once behaviour to not double |
|
543 | + // encode them. May not be robust. |
|
544 | + // This does mean if anyone actually wants to put > or < |
|
545 | + // in a comment they can't but that's a lot less likely than |
|
546 | + // < or > for less than and greater than. |
|
547 | + $tbl['<'] = "<"; |
|
548 | + $tbl['>'] = ">"; |
|
549 | 549 | |
550 | 550 | // Don't want to encode these things |
551 | 551 | unset ($tbl["<"]); |
@@ -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="'; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | # Pass it a brief header word and some debug text and it'll be output. |
14 | 14 | # If TEXT is an array, call the user function, assuming it's a class. |
15 | -function twfy_debug($header, $text="") { |
|
15 | +function twfy_debug($header, $text = "") { |
|
16 | 16 | |
17 | 17 | // We set ?DEBUGTAG=n in the URL. |
18 | 18 | // (DEBUGTAG is set in config.php). |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | if ($debug_level != '') { |
30 | 30 | |
31 | 31 | // Set which level shows which types of debug info. |
32 | - $levels = array ( |
|
33 | - 1 => array ('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'), |
|
34 | - 2 => array ('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'), |
|
35 | - 3 => array ('SQLRESULT') |
|
32 | + $levels = array( |
|
33 | + 1 => array('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'), |
|
34 | + 2 => array('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'), |
|
35 | + 3 => array('SQLRESULT') |
|
36 | 36 | // Higher than this: 'DATA', etc. |
37 | 37 | ); |
38 | 38 | |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | for ($n = 1; $n <= $max_level_to_show; $n++) { |
49 | - $allowed_headers = array_merge ($allowed_headers, $levels[$n] ); |
|
49 | + $allowed_headers = array_merge($allowed_headers, $levels[$n]); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // If we can show this header, then, er, show it. |
53 | - if ( in_array($header, $allowed_headers) || $debug_level >= 4) { |
|
53 | + if (in_array($header, $allowed_headers) || $debug_level >= 4) { |
|
54 | 54 | if (is_array($text)) $text = call_user_func($text); |
55 | 55 | print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n"; |
56 | 56 | } |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | global $PAGE; |
68 | 68 | |
69 | 69 | # Ignore errors we've asked to ignore |
70 | - if (error_reporting()==0) return; |
|
70 | + if (error_reporting() == 0) return; |
|
71 | 71 | |
72 | 72 | // define an assoc array of error string |
73 | 73 | // in reality the only entries we should |
74 | 74 | // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
75 | 75 | // E_USER_WARNING and E_USER_NOTICE |
76 | 76 | # Commented out are ones that a user function cannot handle. |
77 | - $errortype = array ( |
|
77 | + $errortype = array( |
|
78 | 78 | #E_ERROR => "Error", |
79 | 79 | E_WARNING => "Warning", |
80 | 80 | #E_PARSE => "Parsing Error", |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | $source = file($filename); |
134 | 134 | $err .= "\nSource:\n\n"; |
135 | 135 | // Show the line, plus prev and next, with line numbers. |
136 | - $err .= $linenum-2 . " " . $source[$linenum-3]; |
|
137 | - $err .= $linenum-1 . " " . $source[$linenum-2]; |
|
138 | - $err .= $linenum . " " . $source[$linenum-1]; |
|
139 | - $err .= $linenum+1 . " " . $source[$linenum]; |
|
140 | - $err .= $linenum+2 . " " . $source[$linenum+1]; |
|
136 | + $err .= $linenum - 2 . " " . $source[$linenum - 3]; |
|
137 | + $err .= $linenum - 1 . " " . $source[$linenum - 2]; |
|
138 | + $err .= $linenum . " " . $source[$linenum - 1]; |
|
139 | + $err .= $linenum + 1 . " " . $source[$linenum]; |
|
140 | + $err .= $linenum + 2 . " " . $source[$linenum + 1]; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | header('HTTP/1.0 500 Internal Server Error'); |
182 | 182 | print "<p>Oops, sorry, an error has occurred!</p>\n"; |
183 | 183 | } |
184 | - if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect')===false && strpos($errmsg, 'mysql_connect')===false) { |
|
185 | - mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n". "X-Mailer: PHP/" . phpversion() ); |
|
184 | + if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect') === false && strpos($errmsg, 'mysql_connect') === false) { |
|
185 | + mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n" . "X-Mailer: PHP/" . phpversion()); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php |
203 | -function adodb_backtrace($print=true) |
|
203 | +function adodb_backtrace($print = true) |
|
204 | 204 | { |
205 | 205 | $s = ''; |
206 | 206 | if (PHPVERSION() >= 4.3) { |
@@ -209,26 +209,26 @@ discard block |
||
209 | 209 | |
210 | 210 | $traceArr = debug_backtrace(); |
211 | 211 | array_shift($traceArr); |
212 | - $tabs = sizeof($traceArr)-1; |
|
212 | + $tabs = sizeof($traceArr) - 1; |
|
213 | 213 | foreach ($traceArr as $arr) { |
214 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
214 | + for ($i = 0; $i < $tabs; $i++) $s .= ' '; |
|
215 | 215 | $tabs -= 1; |
216 | - if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
216 | + if (isset($arr['class'])) $s .= $arr['class'] . '.'; |
|
217 | 217 | $args = array(); |
218 | 218 | if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
219 | 219 | if (is_null($v)) $args[] = 'null'; |
220 | - elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']'; |
|
221 | - elseif (is_object($v)) $args[] = 'Object:'.get_class($v); |
|
220 | + elseif (is_array($v)) $args[] = 'Array[' . sizeof($v) . ']'; |
|
221 | + elseif (is_object($v)) $args[] = 'Object:' . get_class($v); |
|
222 | 222 | elseif (is_bool($v)) $args[] = $v ? 'true' : 'false'; |
223 | 223 | else { |
224 | 224 | $v = (string) @$v; |
225 | - $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
|
225 | + $str = _htmlspecialchars(substr($v, 0, $MAXSTRLEN)); |
|
226 | 226 | if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
227 | 227 | $args[] = $str; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | - $s .= $arr['function'].'('.implode(', ',$args).')'; |
|
231 | + $s .= $arr['function'] . '(' . implode(', ', $args) . ')'; |
|
232 | 232 | // $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". |
233 | 233 | // " file: <a href=\"file:/%s\">%s</a></font>", |
234 | 234 | // $arr['line'],$arr['file'],$arr['file']); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | // Returns the unixtime in microseconds. |
244 | 244 | function getmicrotime() { |
245 | 245 | $mtime = microtime(); |
246 | - $mtime = explode(" ",$mtime); |
|
246 | + $mtime = explode(" ", $mtime); |
|
247 | 247 | $mtime = $mtime[1] + $mtime[0]; |
248 | 248 | |
249 | 249 | return $mtime; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | global $timestamp_last, $timestamp_start; |
257 | 257 | $t = getmicrotime(); |
258 | 258 | twfy_debug("TIME", sprintf("%f msecs since start; %f msecs since last; %s", |
259 | - ($t - $timestamp_start)*1000.0, ($t - $timestamp_last)*1000.0, $label)); |
|
259 | + ($t - $timestamp_start) * 1000.0, ($t - $timestamp_last) * 1000.0, $label)); |
|
260 | 260 | $timestamp_last = $t; |
261 | 261 | } |
262 | 262 | |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | list($string, $year, $month, $day) = $matches; |
292 | 292 | if ($year < 1902) { # gmdate fns only go back to Dec. 1901 |
293 | 293 | if ($format == SHORTDATEFORMAT) { |
294 | - return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year"; |
|
294 | + return ($day + 0) . ' ' . $format_date_months_short[$month + 0] . " $year"; |
|
295 | 295 | } else { |
296 | - return ($day+0) . ' ' . $format_date_months[$month+0] . " $year"; |
|
296 | + return ($day + 0) . ' ' . $format_date_months[$month + 0] . " $year"; |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
@@ -334,16 +334,16 @@ discard block |
||
334 | 334 | $in_seconds = strtotime($datetime); |
335 | 335 | $now = time(); |
336 | 336 | |
337 | - $diff = $now - $in_seconds; |
|
338 | - $months = floor($diff/2419200); |
|
337 | + $diff = $now - $in_seconds; |
|
338 | + $months = floor($diff / 2419200); |
|
339 | 339 | $diff -= $months * 2419200; |
340 | - $weeks = floor($diff/604800); |
|
341 | - $diff -= $weeks*604800; |
|
342 | - $days = floor($diff/86400); |
|
340 | + $weeks = floor($diff / 604800); |
|
341 | + $diff -= $weeks * 604800; |
|
342 | + $days = floor($diff / 86400); |
|
343 | 343 | $diff -= $days * 86400; |
344 | - $hours = floor($diff/3600); |
|
344 | + $hours = floor($diff / 3600); |
|
345 | 345 | $diff -= $hours * 3600; |
346 | - $minutes = floor($diff/60); |
|
346 | + $minutes = floor($diff / 60); |
|
347 | 347 | $diff -= $minutes * 60; |
348 | 348 | $seconds = $diff; |
349 | 349 | |
@@ -357,27 +357,27 @@ discard block |
||
357 | 357 | $relative_date = ''; |
358 | 358 | if ($weeks > 0) { |
359 | 359 | // Weeks and days |
360 | - $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':''); |
|
361 | - $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):''; |
|
360 | + $relative_date .= ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : ''); |
|
361 | + $relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : ''; |
|
362 | 362 | } elseif ($days > 0) { |
363 | 363 | // days and hours |
364 | - $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':''); |
|
365 | - $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):''; |
|
364 | + $relative_date .= ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : ''); |
|
365 | + $relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : ''; |
|
366 | 366 | } elseif ($hours > 0) { |
367 | 367 | // hours and minutes |
368 | - $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''); |
|
369 | - $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):''; |
|
368 | + $relative_date .= ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : ''); |
|
369 | + $relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : ''; |
|
370 | 370 | } elseif ($minutes > 0) { |
371 | 371 | // minutes only |
372 | - $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''); |
|
372 | + $relative_date .= ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : ''); |
|
373 | 373 | } else { |
374 | 374 | // seconds only |
375 | - $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':''); |
|
375 | + $relative_date .= ($relative_date ? ', ' : '') . $seconds . ' second' . ($seconds > 1 ? 's' : ''); |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
379 | 379 | // Return relative date and add proper verbiage |
380 | - return $relative_date.' ago'; |
|
380 | + return $relative_date . ' ago'; |
|
381 | 381 | |
382 | 382 | } |
383 | 383 | |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | $text = substr($text, $start); |
427 | 427 | |
428 | 428 | // Word boundary. |
429 | - if (preg_match ("/.+?\b(.*)/", $text, $matches)) { |
|
429 | + if (preg_match("/.+?\b(.*)/", $text, $matches)) { |
|
430 | 430 | $text = $matches[1]; |
431 | 431 | // Strip spare space at the start. |
432 | - $text = preg_replace ("/^\s/", '', $text); |
|
432 | + $text = preg_replace("/^\s/", '', $text); |
|
433 | 433 | } |
434 | 434 | $text = '...' . $text; |
435 | 435 | } |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | $text = substr($text, 0, $length - 3); |
442 | 442 | |
443 | 443 | // Word boundary. |
444 | - if (preg_match ("/(.*)\s.+/", $text, $matches)) { |
|
444 | + if (preg_match("/(.*)\s.+/", $text, $matches)) { |
|
445 | 445 | $text = $matches[1]; |
446 | 446 | // Strip spare space at the end. |
447 | - $text = preg_replace ("/\s$/", '', $text); |
|
447 | + $text = preg_replace("/\s$/", '', $text); |
|
448 | 448 | } |
449 | 449 | // We don't want to use the HTML entity for an ellipsis (…), because then |
450 | 450 | // it screws up when we subsequently use htmlentities() to print the returned |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | |
477 | 477 | if ($filter_type == 'strict') { |
478 | 478 | // No tags allowed at all! |
479 | - $filter->allowed = array (); |
|
479 | + $filter->allowed = array(); |
|
480 | 480 | } else { |
481 | 481 | // Comment. |
482 | 482 | // Only allowing <a href>, <b>, <strong>, <i> and <em> |
483 | - $filter->allowed = array ( |
|
483 | + $filter->allowed = array( |
|
484 | 484 | 'a' => array('href'), |
485 | 485 | 'strong' => array(), |
486 | 486 | 'em' => array(), |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | |
594 | 594 | // $gid will be like 'uk.org.publicwhip/debate/2003-02-28.475.3'. |
595 | 595 | |
596 | - $newgid = substr($gid, strrpos($gid, '/')+1 ); |
|
596 | + $newgid = substr($gid, strrpos($gid, '/') + 1); |
|
597 | 597 | return $newgid; |
598 | 598 | } |
599 | 599 | |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | // will be like 2003-11-20.966.0 |
605 | 605 | // This function returns 966.0 |
606 | 606 | |
607 | - return substr( $gid, (strpos($gid, '.') + 1) ); |
|
607 | + return substr($gid, (strpos($gid, '.') + 1)); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | function preg_replacement_quote($s) { |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | global $PAGE; |
649 | 649 | |
650 | 650 | if (!isset($data['to']) || $data['to'] == '') { |
651 | - $PAGE->error_message ("We need an email address to send to."); |
|
651 | + $PAGE->error_message("We need an email address to send to."); |
|
652 | 652 | return false; |
653 | 653 | } |
654 | 654 | |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | if (isset($data['subject'])) { |
692 | 692 | $subject = trim($data['subject']); |
693 | 693 | } else { |
694 | - $subject = trim( substr($firstline, 8) ); |
|
694 | + $subject = trim(substr($firstline, 8)); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | // Either way, remove this subject line from the template. |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | } elseif (isset($data['subject'])) { |
701 | 701 | $subject = $data['subject']; |
702 | 702 | } else { |
703 | - $PAGE->error_message ("We don't have a subject line for the email, so it wasn't sent."); |
|
703 | + $PAGE->error_message("We don't have a subject line for the email, so it wasn't sent."); |
|
704 | 704 | return false; |
705 | 705 | } |
706 | 706 | |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | $replace = array(); |
711 | 711 | |
712 | 712 | foreach ($merge as $key => $val) { |
713 | - $search[] = '/{'.$key.'}/'; |
|
713 | + $search[] = '/{' . $key . '}/'; |
|
714 | 714 | $replace[] = preg_replacement_quote($val); |
715 | 715 | } |
716 | 716 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | } |
729 | 729 | |
730 | 730 | // Send it! |
731 | - $success = send_email ($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces, $htmltext); |
|
731 | + $success = send_email($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces, $htmltext); |
|
732 | 732 | |
733 | 733 | return $success; |
734 | 734 | |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | return $envelope_sender; |
744 | 744 | } |
745 | 745 | |
746 | -function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false, $html='') { |
|
746 | +function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false, $html = '') { |
|
747 | 747 | // Use this rather than PHP's mail() direct, so we can make alterations |
748 | 748 | // easily to all the emails we send out from the site. |
749 | 749 | // eg, we might want to add a .sig to everything here... |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | // http://www.iamcal.com/publish/article.php?id=13 |
790 | 790 | |
791 | 791 | // Call this with a key name to get a GET or POST variable. |
792 | -function get_http_var($name, $default='', $allow_array=false) { |
|
792 | +function get_http_var($name, $default = '', $allow_array = false) { |
|
793 | 793 | $val = $default; |
794 | 794 | if (array_key_exists($name, $_POST)) { |
795 | 795 | $val = $_POST[$name]; |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | } |
805 | 805 | |
806 | 806 | // Call this with a key name to get a COOKIE variable. |
807 | -function get_cookie_var($name, $default='') { |
|
807 | +function get_cookie_var($name, $default = '') { |
|
808 | 808 | if (array_key_exists($name, $_COOKIE)) { |
809 | 809 | return $_COOKIE[$name]; |
810 | 810 | } |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | // Pass it an array of key names that should not be generated as |
816 | 816 | // hidden form variables. It then outputs hidden form variables |
817 | 817 | // based on the session_vars for this page. |
818 | -function hidden_form_vars ($omit = array()) { |
|
818 | +function hidden_form_vars($omit = array()) { |
|
819 | 819 | global $DATA, $this_page; |
820 | 820 | |
821 | 821 | $session_vars = $DATA->page_metadata($this_page, "session_vars"); |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | } |
829 | 829 | |
830 | 830 | // Deprecated. Use hidden_form_vars, above, instead. |
831 | -function hidden_vars ($omit = array()) { |
|
831 | +function hidden_vars($omit = array()) { |
|
832 | 832 | global $DATA; |
833 | 833 | |
834 | 834 | foreach ($args as $key => $val) { |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | function entities_to_numbers($string) { |
872 | 872 | $string = str_replace( |
873 | 873 | array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é'), |
874 | - array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é' ), |
|
874 | + array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é'), |
|
875 | 875 | $string |
876 | 876 | ); |
877 | 877 | return $string; |
@@ -888,9 +888,9 @@ discard block |
||
888 | 888 | } |
889 | 889 | } |
890 | 890 | |
891 | - $s = array(' ', '&', 'ô', 'Ö', 'ö', 'â', 'í', 'á', 'ú', 'é', 'ó', 'Ó'); |
|
892 | - $s2 = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93"); |
|
893 | - $r = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o'); |
|
891 | + $s = array(' ', '&', 'ô', 'Ö', 'ö', 'â', 'í', 'á', 'ú', 'é', 'ó', 'Ó'); |
|
892 | + $s2 = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93"); |
|
893 | + $r = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o'); |
|
894 | 894 | $name = preg_replace('#^the #', '', strtolower($name)); |
895 | 895 | |
896 | 896 | $out = ''; |
@@ -1048,8 +1048,8 @@ discard block |
||
1048 | 1048 | } |
1049 | 1049 | $out .= '<li>' . $body . '<ul>'; |
1050 | 1050 | } else { |
1051 | - $LISTURL->insert( array( 'id' => $gid ) ); |
|
1052 | - $out .= '<li><a href="'.$LISTURL->generate().'">'; |
|
1051 | + $LISTURL->insert(array('id' => $gid)); |
|
1052 | + $out .= '<li><a href="' . $LISTURL->generate() . '">'; |
|
1053 | 1053 | $out .= $body . '</a>'; |
1054 | 1054 | } |
1055 | 1055 | } |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | return $return; |
1119 | 1119 | } |
1120 | 1120 | |
1121 | -function redirect($url, $code=302) { |
|
1121 | +function redirect($url, $code = 302) { |
|
1122 | 1122 | if (defined('TESTING')) { |
1123 | 1123 | print "Location: $url"; |
1124 | 1124 | } else { |
@@ -51,7 +51,9 @@ discard block |
||
51 | 51 | |
52 | 52 | // If we can show this header, then, er, show it. |
53 | 53 | if ( in_array($header, $allowed_headers) || $debug_level >= 4) { |
54 | - if (is_array($text)) $text = call_user_func($text); |
|
54 | + if (is_array($text)) { |
|
55 | + $text = call_user_func($text); |
|
56 | + } |
|
55 | 57 | print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n"; |
56 | 58 | } |
57 | 59 | } |
@@ -67,7 +69,9 @@ discard block |
||
67 | 69 | global $PAGE; |
68 | 70 | |
69 | 71 | # Ignore errors we've asked to ignore |
70 | - if (error_reporting()==0) return; |
|
72 | + if (error_reporting()==0) { |
|
73 | + return; |
|
74 | + } |
|
71 | 75 | |
72 | 76 | // define an assoc array of error string |
73 | 77 | // in reality the only entries we should |
@@ -211,19 +215,29 @@ discard block |
||
211 | 215 | array_shift($traceArr); |
212 | 216 | $tabs = sizeof($traceArr)-1; |
213 | 217 | foreach ($traceArr as $arr) { |
214 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
218 | + for ($i=0; $i < $tabs; $i++) { |
|
219 | + $s .= ' '; |
|
220 | + } |
|
215 | 221 | $tabs -= 1; |
216 | - if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
222 | + if (isset($arr['class'])) { |
|
223 | + $s .= $arr['class'].'.'; |
|
224 | + } |
|
217 | 225 | $args = array(); |
218 | - if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
|
226 | + if (isset($arr['args'])) { |
|
227 | + foreach ($arr['args'] as $v) { |
|
219 | 228 | if (is_null($v)) $args[] = 'null'; |
220 | - elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']'; |
|
221 | - elseif (is_object($v)) $args[] = 'Object:'.get_class($v); |
|
222 | - elseif (is_bool($v)) $args[] = $v ? 'true' : 'false'; |
|
223 | - else { |
|
229 | + } elseif (is_array($v)) { |
|
230 | + $args[] = 'Array['.sizeof($v).']'; |
|
231 | + } elseif (is_object($v)) { |
|
232 | + $args[] = 'Object:'.get_class($v); |
|
233 | + } elseif (is_bool($v)) { |
|
234 | + $args[] = $v ? 'true' : 'false'; |
|
235 | + } else { |
|
224 | 236 | $v = (string) @$v; |
225 | 237 | $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
226 | - if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
|
238 | + if (strlen($v) > $MAXSTRLEN) { |
|
239 | + $str .= '...'; |
|
240 | + } |
|
227 | 241 | $args[] = $str; |
228 | 242 | } |
229 | 243 | } |
@@ -234,7 +248,9 @@ discard block |
||
234 | 248 | // $arr['line'],$arr['file'],$arr['file']); |
235 | 249 | $s .= "\n"; |
236 | 250 | } |
237 | - if ($print) print $s; |
|
251 | + if ($print) { |
|
252 | + print $s; |
|
253 | + } |
|
238 | 254 | } |
239 | 255 | |
240 | 256 | return $s; |
@@ -289,7 +305,8 @@ discard block |
||
289 | 305 | |
290 | 306 | if (preg_match("/^(\d\d\d\d)-(\d\d?)-(\d\d?)$/", $date, $matches)) { |
291 | 307 | list($string, $year, $month, $day) = $matches; |
292 | - if ($year < 1902) { # gmdate fns only go back to Dec. 1901 |
|
308 | + if ($year < 1902) { |
|
309 | +# gmdate fns only go back to Dec. 1901 |
|
293 | 310 | if ($format == SHORTDATEFORMAT) { |
294 | 311 | return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year"; |
295 | 312 | } else { |
@@ -748,7 +765,9 @@ discard block |
||
748 | 765 | // easily to all the emails we send out from the site. |
749 | 766 | // eg, we might want to add a .sig to everything here... |
750 | 767 | |
751 | - if (!$from) $from = CONTACTEMAIL; |
|
768 | + if (!$from) { |
|
769 | + $from = CONTACTEMAIL; |
|
770 | + } |
|
752 | 771 | |
753 | 772 | $mail = new PHPMailer(true); |
754 | 773 | $mail->isSMTP(); |
@@ -843,17 +862,21 @@ discard block |
||
843 | 862 | $rank = $rank + 0; |
844 | 863 | |
845 | 864 | # 11th, 12th, 13th use "th" not "st", "nd", "rd" |
846 | - if (floor(($rank % 100) / 10) == 1) |
|
847 | - return $rank . "th"; |
|
865 | + if (floor(($rank % 100) / 10) == 1) { |
|
866 | + return $rank . "th"; |
|
867 | + } |
|
848 | 868 | # 1st |
849 | - if ($rank % 10 == 1) |
|
850 | - return $rank . "st"; |
|
869 | + if ($rank % 10 == 1) { |
|
870 | + return $rank . "st"; |
|
871 | + } |
|
851 | 872 | # 2nd |
852 | - if ($rank % 10 == 2) |
|
853 | - return $rank . "nd"; |
|
873 | + if ($rank % 10 == 2) { |
|
874 | + return $rank . "nd"; |
|
875 | + } |
|
854 | 876 | # 3rd |
855 | - if ($rank % 10 == 3) |
|
856 | - return $rank . "rd"; |
|
877 | + if ($rank % 10 == 3) { |
|
878 | + return $rank . "rd"; |
|
879 | + } |
|
857 | 880 | # Everything else use th |
858 | 881 | |
859 | 882 | return $rank . "th"; |
@@ -861,8 +884,9 @@ discard block |
||
861 | 884 | |
862 | 885 | function make_plural($word, $number) |
863 | 886 | { |
864 | - if ($number == 1) |
|
865 | - return $word; |
|
887 | + if ($number == 1) { |
|
888 | + return $word; |
|
889 | + } |
|
866 | 890 | return $word . "s"; |
867 | 891 | } |
868 | 892 | |
@@ -896,8 +920,7 @@ discard block |
||
896 | 920 | $out = ''; |
897 | 921 | |
898 | 922 | // Insert the Person ID if known. |
899 | - if ($pid !== null) |
|
900 | - { |
|
923 | + if ($pid !== null) { |
|
901 | 924 | $out .= $pid . '/'; |
902 | 925 | } |
903 | 926 | |
@@ -905,8 +928,7 @@ discard block |
||
905 | 928 | $out .= urlencode(str_replace($s2, $r, str_replace($s, $r, $name))); |
906 | 929 | |
907 | 930 | // If there is a constituency, inject that too |
908 | - if ($const && $house == HOUSE_TYPE_COMMONS) |
|
909 | - { |
|
931 | + if ($const && $house == HOUSE_TYPE_COMMONS) { |
|
910 | 932 | $out .= '/' . urlencode(str_replace($s2, $r, str_replace($s, $r, strtolower($const)))); |
911 | 933 | } |
912 | 934 | |
@@ -918,10 +940,16 @@ discard block |
||
918 | 940 | switch ($house) { |
919 | 941 | case HOUSE_TYPE_LORDS: |
920 | 942 | $s = ''; |
921 | - if (!$family_name) $s = 'the '; |
|
943 | + if (!$family_name) { |
|
944 | + $s = 'the '; |
|
945 | + } |
|
922 | 946 | $s .= $title; |
923 | - if ($family_name) $s .= ' ' . $family_name; |
|
924 | - if ($lordofname) $s .= ' of ' . $lordofname; |
|
947 | + if ($family_name) { |
|
948 | + $s .= ' ' . $family_name; |
|
949 | + } |
|
950 | + if ($lordofname) { |
|
951 | + $s .= ' of ' . $lordofname; |
|
952 | + } |
|
925 | 953 | return $s; |
926 | 954 | |
927 | 955 | case HOUSE_TYPE_ROYAL: |
@@ -939,14 +967,18 @@ discard block |
||
939 | 967 | } |
940 | 968 | |
941 | 969 | function by_peer_name($a, $b) { |
942 | - if (!$a['family_name'] && !$b['family_name']) |
|
943 | - return strcmp($a['lordofname'], $b['lordofname']); |
|
944 | - if (!$a['family_name']) |
|
945 | - return strcmp($a['lordofname'], $b['family_name']); |
|
946 | - if (!$b['family_name']) |
|
947 | - return strcmp($a['family_name'], $b['lordofname']); |
|
948 | - if (strcmp($a['family_name'], $b['family_name'])) |
|
949 | - return strcmp($a['family_name'], $b['family_name']); |
|
970 | + if (!$a['family_name'] && !$b['family_name']) { |
|
971 | + return strcmp($a['lordofname'], $b['lordofname']); |
|
972 | + } |
|
973 | + if (!$a['family_name']) { |
|
974 | + return strcmp($a['lordofname'], $b['family_name']); |
|
975 | + } |
|
976 | + if (!$b['family_name']) { |
|
977 | + return strcmp($a['family_name'], $b['lordofname']); |
|
978 | + } |
|
979 | + if (strcmp($a['family_name'], $b['family_name'])) { |
|
980 | + return strcmp($a['family_name'], $b['family_name']); |
|
981 | + } |
|
950 | 982 | return strcmp($a['lordofname'], $b['lordofname']); |
951 | 983 | } |
952 | 984 | |
@@ -973,12 +1005,17 @@ discard block |
||
973 | 1005 | 'Lords in Waiting (HM Household)' => 'Government Whip', |
974 | 1006 | 'Baronesses in Waiting, HM Household' => 'Government Whip', |
975 | 1007 | ); |
976 | - if ($pos) { # Government post, or Chairman of Select Committee |
|
1008 | + if ($pos) { |
|
1009 | +# Government post, or Chairman of Select Committee |
|
977 | 1010 | $pretty = $pos; |
978 | - if ($dept && $dept != 'No Department') $pretty .= ", $dept"; |
|
979 | - if (array_key_exists($pretty, $lookup)) |
|
980 | - $pretty = $lookup[$pretty]; |
|
981 | - } else { # Member of Select Committee |
|
1011 | + if ($dept && $dept != 'No Department') { |
|
1012 | + $pretty .= ", $dept"; |
|
1013 | + } |
|
1014 | + if (array_key_exists($pretty, $lookup)) { |
|
1015 | + $pretty = $lookup[$pretty]; |
|
1016 | + } |
|
1017 | + } else { |
|
1018 | +# Member of Select Committee |
|
982 | 1019 | $pretty = "Member, $dept"; |
983 | 1020 | } |
984 | 1021 | return $pretty; |
@@ -996,13 +1033,16 @@ discard block |
||
996 | 1033 | } |
997 | 1034 | |
998 | 1035 | // single date? |
999 | - if (isset($data['date'])) $one_date = true; |
|
1036 | + if (isset($data['date'])) { |
|
1037 | + $one_date = true; |
|
1038 | + } |
|
1000 | 1039 | |
1001 | 1040 | // remove empty entries, so they don't produce errors |
1002 | 1041 | foreach (array_keys($hansardmajors) as $major) { |
1003 | 1042 | if (array_key_exists($major, $data)) { |
1004 | - if (count($data[$major]) == 0) |
|
1005 | - unset($data[$major]); |
|
1043 | + if (count($data[$major]) == 0) { |
|
1044 | + unset($data[$major]); |
|
1045 | + } |
|
1006 | 1046 | } |
1007 | 1047 | } |
1008 | 1048 | |
@@ -1011,22 +1051,29 @@ discard block |
||
1011 | 1051 | if (!$one_date) { |
1012 | 1052 | $todaystime = gmmktime(0, 0, 0, date('m'), date('d'), date('Y')); |
1013 | 1053 | foreach ($data as $major => $array) { |
1014 | - if (!in_array('timestamp', $array)) $daytext[$major] = "The most recent "; |
|
1015 | - elseif ($todaystime - $array['timestamp'] == 86400) $daytext[$major] = "Yesterday’s"; |
|
1016 | - elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1017 | - else $daytext[$major] = "The most recent "; |
|
1054 | + if (!in_array('timestamp', $array)) { |
|
1055 | + $daytext[$major] = "The most recent "; |
|
1056 | + } elseif ($todaystime - $array['timestamp'] == 86400) { |
|
1057 | + $daytext[$major] = "Yesterday’s"; |
|
1058 | + } elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) { |
|
1059 | + $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1060 | + } else { |
|
1061 | + $daytext[$major] = "The most recent "; |
|
1062 | + } |
|
1018 | 1063 | } |
1019 | 1064 | } |
1020 | 1065 | |
1021 | 1066 | //build html |
1022 | 1067 | foreach ($printed_majors as $p_major) { |
1023 | - if (!array_key_exists($p_major, $data)) |
|
1024 | - continue; |
|
1068 | + if (!array_key_exists($p_major, $data)) { |
|
1069 | + continue; |
|
1070 | + } |
|
1025 | 1071 | |
1026 | - if ($one_date) |
|
1027 | - $date = $data['date']; |
|
1028 | - else |
|
1029 | - $date = $data[$p_major]['hdate']; |
|
1072 | + if ($one_date) { |
|
1073 | + $date = $data['date']; |
|
1074 | + } else { |
|
1075 | + $date = $data[$p_major]['hdate']; |
|
1076 | + } |
|
1030 | 1077 | $q = $db->query('SELECT section_id, body, gid |
1031 | 1078 | FROM hansard, epobject |
1032 | 1079 | WHERE hansard.epobject_id = epobject.epobject_id ' |
@@ -1078,14 +1125,16 @@ discard block |
||
1078 | 1125 | } |
1079 | 1126 | |
1080 | 1127 | $return .= '<a href="'; |
1081 | - if (isset($data[$major]['listurl'])) |
|
1082 | - $return .= $data[$major]['listurl']; |
|
1083 | - else { |
|
1128 | + if (isset($data[$major]['listurl'])) { |
|
1129 | + $return .= $data[$major]['listurl']; |
|
1130 | + } else { |
|
1084 | 1131 | $LISTURL->reset(); |
1085 | 1132 | $return .= $LISTURL->generate(); |
1086 | 1133 | } |
1087 | 1134 | $return .= '">' . $hansardmajors[$major]['title'] . '</a>'; |
1088 | - if (isset($daytext[$major])) $return; |
|
1135 | + if (isset($daytext[$major])) { |
|
1136 | + $return; |
|
1137 | + } |
|
1089 | 1138 | $return .= '</h4>'; |
1090 | 1139 | |
1091 | 1140 | return $return; |
@@ -1093,22 +1142,23 @@ discard block |
||
1093 | 1142 | |
1094 | 1143 | function score_to_strongly($dmpscore) { |
1095 | 1144 | $dmpdesc = "unknown about"; |
1096 | - if ($dmpscore > 0.95 && $dmpscore <= 1.0) |
|
1097 | - $dmpdesc = "consistently voted against"; |
|
1098 | - elseif ($dmpscore > 0.85) |
|
1099 | - $dmpdesc = "almost always voted against"; |
|
1100 | - elseif ($dmpscore > 0.6) |
|
1101 | - $dmpdesc = "generally voted against"; |
|
1102 | - elseif ($dmpscore > 0.4) |
|
1103 | - $dmpdesc = "voted a mixture of for and against"; |
|
1104 | - elseif ($dmpscore > 0.15) |
|
1105 | - $dmpdesc = "generally voted for"; |
|
1106 | - elseif ($dmpscore > 0.05) |
|
1107 | - $dmpdesc = "almost always voted for"; |
|
1108 | - elseif ($dmpscore >= 0.0) |
|
1109 | - $dmpdesc = "consistently voted for"; |
|
1110 | - elseif ($dmpscore == -1) |
|
1111 | - $dmpdesc = "has never voted in a major vote about"; |
|
1145 | + if ($dmpscore > 0.95 && $dmpscore <= 1.0) { |
|
1146 | + $dmpdesc = "consistently voted against"; |
|
1147 | + } elseif ($dmpscore > 0.85) { |
|
1148 | + $dmpdesc = "almost always voted against"; |
|
1149 | + } elseif ($dmpscore > 0.6) { |
|
1150 | + $dmpdesc = "generally voted against"; |
|
1151 | + } elseif ($dmpscore > 0.4) { |
|
1152 | + $dmpdesc = "voted a mixture of for and against"; |
|
1153 | + } elseif ($dmpscore > 0.15) { |
|
1154 | + $dmpdesc = "generally voted for"; |
|
1155 | + } elseif ($dmpscore > 0.05) { |
|
1156 | + $dmpdesc = "almost always voted for"; |
|
1157 | + } elseif ($dmpscore >= 0.0) { |
|
1158 | + $dmpdesc = "consistently voted for"; |
|
1159 | + } elseif ($dmpscore == -1) { |
|
1160 | + $dmpdesc = "has never voted in a major vote about"; |
|
1161 | + } |
|
1112 | 1162 | return $dmpdesc; |
1113 | 1163 | } |
1114 | 1164 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | public function display() { |
8 | 8 | $data = array(); |
9 | 9 | $data['recent_election'] = false; |
10 | - if ( $this->user->loggedin() ) { |
|
10 | + if ($this->user->loggedin()) { |
|
11 | 11 | $data['user_signed_in'] = true; |
12 | 12 | } |
13 | 13 | |
@@ -17,21 +17,21 @@ discard block |
||
17 | 17 | $data['postcode'] = trim(get_http_var('postcode')); |
18 | 18 | |
19 | 19 | $result = $this->createAlertForPostCode($data['email'], $data['postcode']); |
20 | - $data = array_merge( $data, $result ); |
|
20 | + $data = array_merge($data, $result); |
|
21 | 21 | } elseif (get_http_var('update')) { |
22 | 22 | $result = $this->getNewMP(get_http_var('update')); |
23 | - $data = array_merge( $data, $result ); |
|
23 | + $data = array_merge($data, $result); |
|
24 | 24 | } elseif (get_http_var('update-alert')) { |
25 | - $success = $this->replaceAlert( get_http_var('confirmation') ); |
|
25 | + $success = $this->replaceAlert(get_http_var('confirmation')); |
|
26 | 26 | $data['confirmation_received'] = $success; |
27 | 27 | } elseif (get_http_var('confirmed')) { |
28 | - $success = $this->confirmAlert( get_http_var('confirmed') ); |
|
28 | + $success = $this->confirmAlert(get_http_var('confirmed')); |
|
29 | 29 | $data['confirmation_received'] = $success; |
30 | 30 | } else { |
31 | 31 | $data['email'] = $this->user->email() ? $this->user->email() : ''; |
32 | 32 | $data['postcode'] = $this->user->postcode_is_set() ? $this->user->postcode() : ''; |
33 | 33 | |
34 | - if ( $this->isEmailSignedUpForPostCode( $data['email'], $data['postcode'] ) ) { |
|
34 | + if ($this->isEmailSignedUpForPostCode($data['email'], $data['postcode'])) { |
|
35 | 35 | $data['already_signed_up'] = true; |
36 | 36 | $mp = $this->getPersonFromPostcode($data['postcode']); |
37 | 37 | $data['mp_name'] = $mp->full_name(); |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | private function createAlertForPostCode($email, $postcode) { |
69 | - if ( !$this->validateDetails($email, $postcode) ) { |
|
69 | + if (!$this->validateDetails($email, $postcode)) { |
|
70 | 70 | return array('invalid-postcode-or-email' => true); |
71 | 71 | } |
72 | 72 | |
73 | 73 | try { |
74 | 74 | $person = $this->getPersonFromPostcode($postcode); |
75 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
75 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
76 | 76 | return array('bad-constituency' => true); |
77 | 77 | } |
78 | 78 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | switch ($result) { |
91 | 91 | case self::ALERT_EXISTS: |
92 | - if ( $not_logged_in ) { |
|
92 | + if ($not_logged_in) { |
|
93 | 93 | // no logged in user so send them an email to let them |
94 | 94 | // know someone tried to create an alert |
95 | 95 | $this->alert->send_already_signedup_email($details); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $data['error'] = true; |
103 | 103 | break; |
104 | 104 | default: // alert created |
105 | - if ( $not_logged_in ) { |
|
105 | + if ($not_logged_in) { |
|
106 | 106 | $data['confirmation_sent'] = true; |
107 | 107 | } else { |
108 | 108 | $data['signedup_no_confirm'] = true; |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | $existing = $this->alert->fetch_by_token($confirmation); |
117 | 117 | preg_match('/speaker:(\d+)/', $existing['criteria'], $matches); |
118 | 118 | $old_mp_id = $matches[1]; |
119 | - $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $old_mp_id ) ); |
|
120 | - $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 )); |
|
119 | + $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $old_mp_id)); |
|
120 | + $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1)); |
|
121 | 121 | |
122 | 122 | $q = $this->db->query( |
123 | 123 | "SELECT alert_id, criteria, registrationtoken FROM alerts |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | 'pid' => $new_mp->person_id, |
142 | 142 | 'pc' => '', |
143 | 143 | ); |
144 | - if ( $other_criteria ) { |
|
144 | + if ($other_criteria) { |
|
145 | 145 | $details['keyword'] = $other_criteria; |
146 | 146 | } |
147 | 147 | |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | private function isEmailSignedUpForPostCode($email, $postcode) { |
159 | 159 | $is_signed_up = false; |
160 | 160 | |
161 | - if ( $email && $postcode ) { |
|
161 | + if ($email && $postcode) { |
|
162 | 162 | try { |
163 | 163 | $person = $this->getPersonFromPostcode($postcode); |
164 | 164 | $is_signed_up = $this->alert->fetch_by_mp($email, $person->person_id); |
165 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
165 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
166 | 166 | $is_signed_up = false; |
167 | 167 | } |
168 | 168 | } |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | preg_match('/speaker:(\d+)/', $existing['criteria'], $matches); |
179 | 179 | $criteria = $matches[1]; |
180 | 180 | |
181 | - $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $criteria ) ); |
|
182 | - $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 )); |
|
181 | + $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $criteria)); |
|
182 | + $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1)); |
|
183 | 183 | |
184 | - if ( $this->alert->fetch_by_mp( $existing['email'], $new_mp->person_id) ) { |
|
184 | + if ($this->alert->fetch_by_mp($existing['email'], $new_mp->person_id)) { |
|
185 | 185 | $data = array( |
186 | 186 | 'already_signed_up' => true, |
187 | 187 | 'old_mp' => $old_mp->full_name(), |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | $DEBATELIST = new \DEBATELIST; |
17 | 17 | $debates = array(); |
18 | 18 | $debates['data'] = $DEBATELIST->display('biggest_debates', array('days'=>7, 'num'=>10), 'none'); |
19 | - $args = array( 'months' => 1 ); |
|
19 | + $args = array('months' => 1); |
|
20 | 20 | $debates['calendar'] = $DEBATELIST->display('calendar', $args, 'none'); |
21 | 21 | $debates['rssurl'] = $DATA->page_metadata($this_page, 'rss'); |
22 | 22 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | $WHALLLIST = new \WHALLLIST; |
28 | 28 | $whall['data'] = $WHALLLIST->display('biggest_debates', array('days'=>7, 'num'=>10), 'none'); |
29 | - $args = array( 'months' => 1 ); |
|
29 | + $args = array('months' => 1); |
|
30 | 30 | $whall['calendar'] = $WHALLLIST->display('calendar', $args, 'none'); |
31 | 31 | $whall['rssurl'] = $DATA->page_metadata($this_page, 'rss'); |
32 | 32 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | $LORDSDEBATELIST = new \LORDSDEBATELIST; |
38 | 38 | $lords['data'] = $LORDSDEBATELIST->display('biggest_debates', array('days'=>7, 'num'=>10), 'none'); |
39 | - $args = array( 'months' => 1 ); |
|
39 | + $args = array('months' => 1); |
|
40 | 40 | $lords['calendar'] = $LORDSDEBATELIST->display('calendar', $args, 'none'); |
41 | 41 | |
42 | 42 | $lords['rssurl'] = $DATA->page_metadata($this_page, 'rss'); |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | |
56 | 56 | protected function getSearchSections() { |
57 | 57 | return array( |
58 | - array( 'section' => 'debates', 'title' => 'House of Commons' ), |
|
59 | - array( 'section' => 'lords', 'title' => 'House of Lords' ), |
|
60 | - array( 'section' => 'whall', 'title' => 'Westminster Hall' ) |
|
58 | + array('section' => 'debates', 'title' => 'House of Commons'), |
|
59 | + array('section' => 'lords', 'title' => 'House of Lords'), |
|
60 | + array('section' => 'whall', 'title' => 'Westminster Hall') |
|
61 | 61 | ); |
62 | 62 | } |
63 | 63 | } |