Completed
Pull Request — master (#1450)
by Nick
08:21 queued 03:29
created
www/docs/mp/index.php 5 patches
Switch Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -731,26 +731,26 @@
 block discarded – undo
731 731
 function person_error_page($message) {
732 732
     global $this_page;
733 733
     switch($this_page) {
734
-    case 'mla':
735
-        $rep = 'MLA';
736
-        $SEARCHURL = '/postcode/';
737
-        $MPSURL = new \MySociety\TheyWorkForYou\Url('mlas');
738
-        break;
739
-    case 'msp':
740
-        $rep = 'MSP';
741
-        $SEARCHURL = '/postcode/';
742
-        $MPSURL = new \MySociety\TheyWorkForYou\Url('msps');
743
-        break;
744
-    case 'peer':
745
-        $rep = 'Lord';
746
-        $SEARCHURL = '';
747
-        $MPSURL = new \MySociety\TheyWorkForYou\Url('peers');
748
-        break;
749
-    default:
750
-        $rep = 'MP';
751
-        $SEARCHURL = new \MySociety\TheyWorkForYou\Url('mp');
752
-        $SEARCHURL = $SEARCHURL->generate();
753
-        $MPSURL = new \MySociety\TheyWorkForYou\Url('mps');
734
+        case 'mla':
735
+            $rep = 'MLA';
736
+            $SEARCHURL = '/postcode/';
737
+            $MPSURL = new \MySociety\TheyWorkForYou\Url('mlas');
738
+            break;
739
+        case 'msp':
740
+            $rep = 'MSP';
741
+            $SEARCHURL = '/postcode/';
742
+            $MPSURL = new \MySociety\TheyWorkForYou\Url('msps');
743
+            break;
744
+        case 'peer':
745
+            $rep = 'Lord';
746
+            $SEARCHURL = '';
747
+            $MPSURL = new \MySociety\TheyWorkForYou\Url('peers');
748
+            break;
749
+        default:
750
+            $rep = 'MP';
751
+            $SEARCHURL = new \MySociety\TheyWorkForYou\Url('mp');
752
+            $SEARCHURL = $SEARCHURL->generate();
753
+            $MPSURL = new \MySociety\TheyWorkForYou\Url('mps');
754 754
     }
755 755
 
756 756
     $data = array(
Please login to merge, or discard this patch.
Upper-Lower-Casing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  */
30 30
 
31 31
 // Disable the old PAGE class.
32
-$new_style_template = TRUE;
32
+$new_style_template = true;
33 33
 
34 34
 // Include all the things this page needs.
35 35
 include_once '../../includes/easyparliament/init.php';
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 // Basic name, title and description
177 177
 $member_name = ucfirst($MEMBER->full_name());
178 178
 $title = $member_name;
179
-$desc = "Read $member_name's contributions to Parliament, including speeches and questions";
179
+$desc = "read $member_name's contributions to Parliament, including speeches and questions";
180 180
 
181 181
 // Enhance description if this is a current member
182 182
 if ($MEMBER->current_member_anywhere())
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 }
221 221
 
222 222
 $known_for = '';
223
-$current_offices_ignoring_committees = $MEMBER->offices('current', TRUE);
223
+$current_offices_ignoring_committees = $MEMBER->offices('current', true);
224 224
 if (count($current_offices_ignoring_committees) > 0) {
225 225
     $known_for = $current_offices_ignoring_committees[0];
226 226
 }
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
 $data['has_email_alerts'] = ($MEMBER->current_member_anywhere() && !($MEMBER->current_member(HOUSE_TYPE_COMMONS) && $MEMBER->party() == 'Sinn Féin' && !$MEMBER->current_member(HOUSE_TYPE_NI)));
308 308
 $data['has_expenses'] = $data['leave_date'] > '2004-01-01';
309 309
 
310
-$data['pre_2010_expenses'] = False;
310
+$data['pre_2010_expenses'] = false;
311 311
 $data['post_2010_expenses'] = $data['leave_date'] > '2010-05-05';
312 312
 
313 313
 if ($data['entry_date'] < '2010-05-05') {
314
-    $data['pre_2010_expenses'] = True;
314
+    $data['pre_2010_expenses'] = true;
315 315
     // Set the expenses URL if we know it
316 316
     if (isset($MEMBER->extra_info['expenses_url'])) {
317 317
         $data['expenses_url_2004'] = $MEMBER->extra_info['expenses_url'];
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
  * Redirect to the canonical page for a member.
678 678
  */
679 679
 
680
-function member_redirect (&$MEMBER, $code = 301, $pagetype = NULL) {
680
+function member_redirect (&$MEMBER, $code = 301, $pagetype = null) {
681 681
     // We come here after creating a MEMBER object by various methods.
682 682
     // Now we redirect to the canonical MP page, with a person_id.
683 683
     if ($MEMBER->person_id()) {
@@ -1163,8 +1163,8 @@  discard block
 block discarded – undo
1163 1163
     $return = false;
1164 1164
     if (isset($extra_info[$category]))
1165 1165
         $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff);
1166
-    if (isset($extra_info["L$category"]))
1167
-        $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff);
1166
+    if (isset($extra_info["l$category"]))
1167
+        $return = display_stats_line_house(HOUSE_TYPE_LORDS, "l$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff);
1168 1168
     return $return;
1169 1169
 }
1170 1170
 
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 // Finally, if this is a Votes page, replace the page description with
228 228
 // something more descriptive of the actual data on the page.
229 229
 if ($pagetype == 'votes') {
230
-  $title = "Voting record - " . $title;
231
-  $desc = 'See how ' . $member_name . ' voted on topics like Employment, Social Issues, Foreign Policy, and more.';
230
+    $title = "Voting record - " . $title;
231
+    $desc = 'See how ' . $member_name . ' voted on topics like Employment, Social Issues, Foreign Policy, and more.';
232 232
 }
233 233
 
234 234
 // Set page metadata
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 
403 403
         // Generate voting segments
404 404
         $data['segment'] = array(
405
-          'key'   => $policy_set,
406
-          'title' => $policiesList->getSetDescriptions()[$policy_set],
407
-          'votes' => new MySociety\TheyWorkForYou\PolicyPositions(
408
-              $policiesList->limitToSet($policy_set), $MEMBER
409
-          )
405
+            'key'   => $policy_set,
406
+            'title' => $policiesList->getSetDescriptions()[$policy_set],
407
+            'votes' => new MySociety\TheyWorkForYou\PolicyPositions(
408
+                $policiesList->limitToSet($policy_set), $MEMBER
409
+            )
410 410
         );
411 411
 
412 412
         MySociety\TheyWorkForYou\Renderer::output('mp/votes_svg', $data, true);
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     }
118 118
     if ($pid) {
119 119
         $URL = new \MySociety\TheyWorkForYou\Url('search');
120
-        $URL->insert( array('pid'=>$pid, 'pop'=>1) );
120
+        $URL->insert(array('pid'=>$pid, 'pop'=>1));
121 121
         header('Location: ' . $URL->generate('none'));
122 122
         exit;
123 123
     }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     } elseif ($THEUSER->postcode_is_set()) {
149 149
         get_mp_by_user_postcode($THEUSER->postcode());
150 150
     } else {
151
-        twfy_debug ('MP', "We don't have any way of telling what MP to display");
151
+        twfy_debug('MP', "We don't have any way of telling what MP to display");
152 152
         throw new MySociety\TheyWorkForYou\MemberException('Sorry, but we can&rsquo;t tell which representative to display.');
153 153
     }
154 154
     if (!isset($MEMBER) || !$MEMBER->valid) {
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     if (!$MEMBER->current_member(HOUSE_TYPE_SCOTLAND)) {
216 216
         $title .= ', former';
217 217
     }
218
-    $title .= ' MSP, '.$MEMBER->constituency();
218
+    $title .= ' MSP, ' . $MEMBER->constituency();
219 219
 }
220 220
 
221 221
 $known_for = '';
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 $data['eu_stance'] = $MEMBER->getEUStance();
284 284
 
285 285
 # People who are or were MPs and Lords potentially have voting records, except Sinn Fein MPs
286
-$data['has_voting_record'] = ( ($MEMBER->house(HOUSE_TYPE_COMMONS) && $MEMBER->party() != 'Sinn Féin') || $MEMBER->house(HOUSE_TYPE_LORDS) );
286
+$data['has_voting_record'] = (($MEMBER->house(HOUSE_TYPE_COMMONS) && $MEMBER->party() != 'Sinn Féin') || $MEMBER->house(HOUSE_TYPE_LORDS));
287 287
 # Everyone who is currently somewhere has email alert signup, apart from current Sinn Fein MPs who are not MLAs
288 288
 $data['has_email_alerts'] = ($MEMBER->current_member_anywhere() && !($MEMBER->current_member(HOUSE_TYPE_COMMONS) && $MEMBER->party() == 'Sinn Féin' && !$MEMBER->current_member(HOUSE_TYPE_NI)));
289 289
 $data['has_expenses'] = $data['leave_date'] > '2004-01-01';
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
 
310 310
 $data['this_page'] = $this_page;
311 311
 $data['current_assembly'] = 'westminster';
312
-if ( $this_page == 'msp' || $this_page == 'yourmsp' ) {
312
+if ($this_page == 'msp' || $this_page == 'yourmsp') {
313 313
     $data['current_assembly'] = 'scotland';
314
-} else if ( $this_page == 'mla' || $this_page == 'yourmla' ) {
314
+} else if ($this_page == 'mla' || $this_page == 'yourmla') {
315 315
     $data['current_assembly'] = 'ni';
316 316
 }
317 317
 
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
         $divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER);
328 328
         $policySummaries = $divisions->getMemberDivisionDetails();
329 329
 
330
-        $policyOptions = array( 'summaries' => $policySummaries);
330
+        $policyOptions = array('summaries' => $policySummaries);
331 331
 
332 332
         // Generate voting segments
333 333
         $set_descriptions = $policiesList->getSetDescriptions();
334
-        if ( $policy_set && array_key_exists($policy_set, $set_descriptions) ) {
334
+        if ($policy_set && array_key_exists($policy_set, $set_descriptions)) {
335 335
             $sets = array($policy_set);
336 336
             $data['og_image'] = $MEMBER->url(true) . "/policy_set_png?policy_set=" . $policy_set;
337 337
             $data['page_title'] = $policiesList->getSetDescriptions()[$policy_set] . ' ' . $title . ' - TheyWorkForYou';
@@ -370,15 +370,15 @@  discard block
 block discarded – undo
370 370
 
371 371
     case 'divisions':
372 372
         $policyID = get_http_var('policy');
373
-        if ( $policyID ) {
374
-            $policiesList = new MySociety\TheyWorkForYou\Policies( $policyID );
373
+        if ($policyID) {
374
+            $policiesList = new MySociety\TheyWorkForYou\Policies($policyID);
375 375
         } else {
376 376
             $policiesList = new MySociety\TheyWorkForYou\Policies;
377 377
         }
378
-        $positions = new MySociety\TheyWorkForYou\PolicyPositions( $policiesList, $MEMBER );
378
+        $positions = new MySociety\TheyWorkForYou\PolicyPositions($policiesList, $MEMBER);
379 379
         $divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER, $positions, $policiesList);
380 380
 
381
-        if ( $policyID ) {
381
+        if ($policyID) {
382 382
             $data['policydivisions'] = $divisions->getMemberDivisionsForPolicy($policyID);
383 383
         } else {
384 384
             $data['policydivisions'] = $divisions->getAllMemberDivisionsByPolicy();
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 
456 456
         // generate party policy diffs
457 457
         $party = new MySociety\TheyWorkForYou\Party($MEMBER->party());
458
-        $positions = new MySociety\TheyWorkForYou\PolicyPositions( $policiesList, $MEMBER );
458
+        $positions = new MySociety\TheyWorkForYou\PolicyPositions($policiesList, $MEMBER);
459 459
         $party_positions = $party->getAllPolicyPositions($policiesList);
460 460
         $policy_diffs = $MEMBER->getPartyPolicyDiffs($party, $policiesList, $positions, true);
461 461
 
@@ -509,16 +509,16 @@  discard block
 block discarded – undo
509 509
     global $THEUSER;
510 510
     $pc = preg_replace('#[^a-z0-9]#i', '', $pc);
511 511
     if (!validate_postcode($pc)) {
512
-        twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
513
-        throw new MySociety\TheyWorkForYou\MemberException('Sorry, '._htmlentities($pc) .' isn&rsquo;t a valid postcode');
512
+        twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
513
+        throw new MySociety\TheyWorkForYou\MemberException('Sorry, ' . _htmlentities($pc) . ' isn&rsquo;t a valid postcode');
514 514
     }
515
-    twfy_debug ('MP', "MP lookup by postcode");
515
+    twfy_debug('MP', "MP lookup by postcode");
516 516
     $constituency = strtolower(MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituency($pc));
517 517
     if ($constituency == "connection_timed_out") {
518 518
         throw new MySociety\TheyWorkForYou\MemberException('Sorry, we couldn&rsquo;t check your postcode right now, as our postcode lookup server is under quite a lot of load.');
519 519
     } elseif ($constituency == "") {
520
-        twfy_debug ('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
521
-        throw new MySociety\TheyWorkForYou\MemberException('Sorry, '._htmlentities($pc) .' isn&rsquo;t a known postcode');
520
+        twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
521
+        throw new MySociety\TheyWorkForYou\MemberException('Sorry, ' . _htmlentities($pc) . ' isn&rsquo;t a known postcode');
522 522
     } else {
523 523
         // Redirect to the canonical MP page, with a person id.
524 524
         $MEMBER = new MySociety\TheyWorkForYou\Member(array('constituency' => $constituency, 'house' => HOUSE_TYPE_COMMONS));
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
     }
531 531
 }
532 532
 
533
-function get_person_by_name($name, $const='') {
533
+function get_person_by_name($name, $const = '') {
534 534
     $MEMBER = new MySociety\TheyWorkForYou\Member(array('name' => $name, 'constituency' => $const));
535 535
     // Edge case, only attempt further detection if this isn't the Queen.
536 536
     if ($name !== 'elizabeth the second' || $const) {
537
-        twfy_debug ('MP', 'Redirecting for MP found by name/constituency');
537
+        twfy_debug('MP', 'Redirecting for MP found by name/constituency');
538 538
         member_redirect($MEMBER);
539 539
     }
540 540
     return $MEMBER;
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
  * Redirect to the canonical page for a member.
569 569
  */
570 570
 
571
-function member_redirect (&$MEMBER, $code = 301, $pagetype = NULL) {
571
+function member_redirect(&$MEMBER, $code = 301, $pagetype = NULL) {
572 572
     // We come here after creating a MEMBER object by various methods.
573 573
     // Now we redirect to the canonical MP page, with a person_id.
574 574
     if ($MEMBER->person_id()) {
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
         } else {
586 586
             $pagetype = '';
587 587
         }
588
-        header('Location: ' . $url . $pagetype, true, $code );
588
+        header('Location: ' . $url . $pagetype, true, $code);
589 589
         exit;
590 590
     }
591 591
 }
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 
614 614
 function person_error_page($message) {
615 615
     global $this_page;
616
-    switch($this_page) {
616
+    switch ($this_page) {
617 617
     case 'mla':
618 618
         $rep = 'MLA';
619 619
         $SEARCHURL = '/postcode/';
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
  * Generate the summary of this person's held positions.
652 652
  */
653 653
 
654
-function person_summary_description ($MEMBER) {
654
+function person_summary_description($MEMBER) {
655 655
     $entered_house = $MEMBER->entered_house();
656 656
     $current_member = $MEMBER->current_member();
657 657
     $left_house = $MEMBER->left_house();
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
     }
663 663
     $desc = '';
664 664
     foreach ($MEMBER->houses() as $house) {
665
-        if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS]))
665
+        if ($house == HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS]))
666 666
             continue; # Same info is printed further down
667 667
 
668 668
         if (!$current_member[$house]) $desc .= 'Former ';
@@ -683,17 +683,17 @@  discard block
 block discarded – undo
683 683
                 $desc .= $last['from'] . ' ';
684 684
             }
685 685
         }
686
-        if ($house==HOUSE_TYPE_COMMONS || $house==HOUSE_TYPE_NI || $house==HOUSE_TYPE_SCOTLAND) {
686
+        if ($house == HOUSE_TYPE_COMMONS || $house == HOUSE_TYPE_NI || $house == HOUSE_TYPE_SCOTLAND) {
687 687
             $desc .= ' ';
688
-            if ($house==HOUSE_TYPE_COMMONS) $desc .= '<abbr title="Member of Parliament">MP</abbr>';
689
-            if ($house==HOUSE_TYPE_NI) $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>';
690
-            if ($house==HOUSE_TYPE_SCOTLAND) $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>';
688
+            if ($house == HOUSE_TYPE_COMMONS) $desc .= '<abbr title="Member of Parliament">MP</abbr>';
689
+            if ($house == HOUSE_TYPE_NI) $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>';
690
+            if ($house == HOUSE_TYPE_SCOTLAND) $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>';
691 691
             if ($party_br) {
692 692
                 $desc .= " ($party_br)";
693 693
             }
694 694
             $desc .= ' for ' . $left_house[$house]['constituency'];
695 695
         }
696
-        if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') $desc .= ' Peer';
696
+        if ($house == HOUSE_TYPE_LORDS && $party != 'Bishop') $desc .= ' Peer';
697 697
         $desc .= ', ';
698 698
     }
699 699
     $desc = preg_replace('#, $#', '', $desc);
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
  * @return string A HTML summary of this person's rebellion rate.
711 711
  */
712 712
 
713
-function person_rebellion_rate ($member) {
713
+function person_rebellion_rate($member) {
714 714
 
715 715
     // Rebellion string may be empty.
716 716
     $rebellion_string = '';
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
     // benefit unfortunately.
749 749
     twfy_debug_timestamp();
750 750
 
751
-    $person_id= $member->person_id();
751
+    $person_id = $member->person_id();
752 752
 
753 753
     $memcache = new MySociety\TheyWorkForYou\Memcache;
754 754
     $recent = $memcache->get('recent_appear:' . $person_id);
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
         $SEARCHENGINE = new \SEARCHENGINE($searchstring);
760 760
 
761 761
         $hansard = new MySociety\TheyWorkForYou\Hansard();
762
-        $args = array (
762
+        $args = array(
763 763
             's' => $searchstring,
764 764
             'p' => 1,
765 765
             'num' => 3,
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
     twfy_debug_timestamp();
775 775
 
776 776
     $MOREURL = new \MySociety\TheyWorkForYou\Url('search');
777
-    $MOREURL->insert( array('pid'=>$person_id, 'pop'=>1) );
777
+    $MOREURL->insert(array('pid'=>$person_id, 'pop'=>1));
778 778
 
779 779
     $out['more_href'] = $MOREURL->generate() . '#n4';
780 780
     $out['more_text'] = 'More of ' . ucfirst($member->full_name()) . '&rsquo;s recent appearances';
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
         }
986 986
     }
987 987
 
988
-    foreach ( $wtt_stats_years as $year ) {
988
+    foreach ($wtt_stats_years as $year) {
989 989
         $wtt_displayed = display_writetothem_numbers($year, $extra_info);
990 990
         if ($wtt_displayed) {
991 991
             $out[] = $wtt_displayed;
@@ -1021,15 +1021,15 @@  discard block
 block discarded – undo
1021 1021
         }
1022 1022
     }
1023 1023
 
1024
-    if (isset($extra_info['number_of_alerts']) && ($extra_info['number_of_alerts']>0 || $has_email_alerts)) {
1025
-        $line = '<strong>' . _htmlentities($extra_info['number_of_alerts']) . '</strong> ' . ($extra_info['number_of_alerts']==1?'person is':'people are') . ' tracking ';
1024
+    if (isset($extra_info['number_of_alerts']) && ($extra_info['number_of_alerts'] > 0 || $has_email_alerts)) {
1025
+        $line = '<strong>' . _htmlentities($extra_info['number_of_alerts']) . '</strong> ' . ($extra_info['number_of_alerts'] == 1 ? 'person is' : 'people are') . ' tracking ';
1026 1026
         if ($member->house_disp == HOUSE_TYPE_COMMONS) $line .= 'this MP';
1027 1027
         elseif ($member->house_disp == HOUSE_TYPE_LORDS) $line .= 'this peer';
1028 1028
         elseif ($member->house_disp == HOUSE_TYPE_NI) $line .= 'this MLA';
1029 1029
         elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) $line .= 'this MSP';
1030 1030
         elseif ($member->house_disp == HOUSE_TYPE_ROYAL) $line .= $member->full_name();
1031 1031
         if ($has_email_alerts) {
1032
-            $line .= ' &mdash; <a href="' . WEBPATH . 'alert/?pid='.$member->person_id().'">email me updates on '. $member->full_name(). '&rsquo;s activity</a>';
1032
+            $line .= ' &mdash; <a href="' . WEBPATH . 'alert/?pid=' . $member->person_id() . '">email me updates on ' . $member->full_name() . '&rsquo;s activity</a>';
1033 1033
         }
1034 1034
 
1035 1035
         $out[] = $line;
@@ -1059,25 +1059,25 @@  discard block
 block discarded – undo
1059 1059
 }
1060 1060
 
1061 1061
 function display_stats_line_house($house, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff) {
1062
-    if ($category == 'wrans_asked_inlastyear' || $category == 'debate_sectionsspoken_inlastyear' || $category =='comments_on_speeches' ||
1063
-        $category == 'Lwrans_asked_inlastyear' || $category == 'Ldebate_sectionsspoken_inlastyear' || $category =='Lcomments_on_speeches') {
1064
-        if ($extra_info[$category]==0) {
1062
+    if ($category == 'wrans_asked_inlastyear' || $category == 'debate_sectionsspoken_inlastyear' || $category == 'comments_on_speeches' ||
1063
+        $category == 'Lwrans_asked_inlastyear' || $category == 'Ldebate_sectionsspoken_inlastyear' || $category == 'Lcomments_on_speeches') {
1064
+        if ($extra_info[$category] == 0) {
1065 1065
             $blurb = preg_replace('#<a.*?>#', '', $blurb);
1066 1066
             $inwhat = preg_replace('#<\/a>#', '', $inwhat);
1067 1067
         }
1068 1068
     }
1069
-    if ($house==HOUSE_TYPE_LORDS) $inwhat = str_replace('MP', 'Lord', $inwhat);
1069
+    if ($house == HOUSE_TYPE_LORDS) $inwhat = str_replace('MP', 'Lord', $inwhat);
1070 1070
     $line = $blurb;
1071 1071
     $line .= '<strong>' . $extra_info[$category];
1072 1072
     if ($type) $line .= ' ' . make_plural($type, $extra_info[$category]);
1073 1073
     $line .= '</strong>';
1074 1074
     $line .= $inwhat;
1075
-    if ($minister===2) {
1075
+    if ($minister === 2) {
1076 1076
         $line .= ' &#8212; Speakers/ deputy speakers do not ask written questions';
1077 1077
     } elseif ($minister)
1078 1078
         $line .= ' &#8212; Ministers do not ask written questions';
1079 1079
     else {
1080
-        $type = ($house==HOUSE_TYPE_COMMONS?'MP':($house==HOUSE_TYPE_LORDS?'Lord':'MLA'));
1080
+        $type = ($house == HOUSE_TYPE_COMMONS ? 'MP' : ($house == HOUSE_TYPE_LORDS ? 'Lord' : 'MLA'));
1081 1081
         if (!get_http_var('rem') && isset($extra_info[$category . '_quintile'])) {
1082 1082
             $line .= ' &#8212; ';
1083 1083
             $q = $extra_info[$category . '_quintile'];
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
         if ($a == 'very high') $a = 'a very high';
1123 1123
         $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"] = $a;
1124 1124
 
1125
-        return display_stats_line("writetothem_responsiveness_fuzzy_response_description_$year", 'Replied within 2 or 3 weeks to <a href="https://www.writetothem.com/stats/'.$year.'/mps" title="From WriteToThem.com">', "", "</a> <!-- Mean: " . $mean . " --> number of messages sent via WriteToThem.com during ".$year.", according to constituents", "", $extra_info);
1125
+        return display_stats_line("writetothem_responsiveness_fuzzy_response_description_$year", 'Replied within 2 or 3 weeks to <a href="https://www.writetothem.com/stats/' . $year . '/mps" title="From WriteToThem.com">', "", "</a> <!-- Mean: " . $mean . " --> number of messages sent via WriteToThem.com during " . $year . ", according to constituents", "", $extra_info);
1126 1126
     }
1127 1127
 
1128 1128
 }
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 function get_all_writetothem_strings($member, $wtt_stats_years) {
1131 1131
     $extra_info = $member->extra_info();
1132 1132
     $strings = array();
1133
-    foreach ( $wtt_stats_years as $year ) {
1133
+    foreach ($wtt_stats_years as $year) {
1134 1134
 
1135 1135
         if (isset($extra_info["writetothem_responsiveness_mean_$year"])) {
1136 1136
             $a = $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"];
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
         return;
1147 1147
     }
1148 1148
 
1149
-    $reg = array( 'date' => '', 'data' => '<p>Nil</p>' );
1149
+    $reg = array('date' => '', 'data' => '<p>Nil</p>');
1150 1150
     if (isset($extra_info['register_member_interests_date'])) {
1151 1151
         $reg['date'] = format_date($extra_info['register_member_interests_date'], SHORTDATEFORMAT);
1152 1152
     }
@@ -1218,8 +1218,8 @@  discard block
 block discarded – undo
1218 1218
         }
1219 1219
     }
1220 1220
 
1221
-    foreach($mreg as $reg) {
1222
-        $data['members'][] = array (
1221
+    foreach ($mreg as $reg) {
1222
+        $data['members'][] = array(
1223 1223
             'url' => '/' . $rep_type . '/?p=' . $reg['person_id'],
1224 1224
             'name' => $reg['given_name'] . ' ' . $reg['family_name']
1225 1225
         );
Please login to merge, or discard this patch.
Braces   +128 added lines, -57 removed lines patch added patch discarded remove patch
@@ -61,16 +61,36 @@  discard block
 block discarded – undo
61 61
 $constituency = strtolower(str_replace('_', ' ', get_http_var('c')));
62 62
 
63 63
 // Fix for names with non-ASCII characters
64
-if ($name == 'sion simon') $name = 'si\xf4n simon';
65
-if ($name == 'sian james') $name = 'si\xe2n james';
66
-if ($name == 'lembit opik') $name = 'lembit \xf6pik';
67
-if ($name == 'bairbre de brun') $name = 'bairbre de br\xfan';
68
-if ($name == 'daithi mckay') $name = 'daith\xed mckay';
69
-if ($name == 'caral ni chuilin') $name = 'car\xe1l n\xed chuil\xedn';
70
-if ($name == 'caledon du pre') $name = 'caledon du pr\xe9';
71
-if ($name == 'sean etchingham') $name = 'se\xe1n etchingham';
72
-if ($name == 'john tinne') $name = 'john tinn\xe9';
73
-if ($name == 'renee short') $name = 'ren\xe9e short';
64
+if ($name == 'sion simon') {
65
+    $name = 'si\xf4n simon';
66
+}
67
+if ($name == 'sian james') {
68
+    $name = 'si\xe2n james';
69
+}
70
+if ($name == 'lembit opik') {
71
+    $name = 'lembit \xf6pik';
72
+}
73
+if ($name == 'bairbre de brun') {
74
+    $name = 'bairbre de br\xfan';
75
+}
76
+if ($name == 'daithi mckay') {
77
+    $name = 'daith\xed mckay';
78
+}
79
+if ($name == 'caral ni chuilin') {
80
+    $name = 'car\xe1l n\xed chuil\xedn';
81
+}
82
+if ($name == 'caledon du pre') {
83
+    $name = 'caledon du pr\xe9';
84
+}
85
+if ($name == 'sean etchingham') {
86
+    $name = 'se\xe1n etchingham';
87
+}
88
+if ($name == 'john tinne') {
89
+    $name = 'john tinn\xe9';
90
+}
91
+if ($name == 'renee short') {
92
+    $name = 'ren\xe9e short';
93
+}
74 94
 
75 95
 // Fix for common misspellings, name changes etc
76 96
 $name_fix = array(
@@ -102,7 +122,9 @@  discard block
 block discarded – undo
102 122
 }
103 123
 
104 124
 // Fixes for Ynys Mon, and a Unicode URL
105
-if ($constituency == 'ynys mon') $constituency = "ynys m\xf4n";
125
+if ($constituency == 'ynys mon') {
126
+    $constituency = "ynys m\xf4n";
127
+}
106 128
 if (preg_match("#^ynys m\xc3\xb4n#i", $constituency)) {
107 129
     $constituency = "ynys m\xf4n";
108 130
 }
@@ -194,8 +216,9 @@  discard block
 block discarded – undo
194 216
 $desc = "Read $member_name's contributions to Parliament, including speeches and questions";
195 217
 
196 218
 // Enhance description if this is a current member
197
-if ($MEMBER->current_member_anywhere())
219
+if ($MEMBER->current_member_anywhere()) {
198 220
     $desc .= ', investigate their voting record, and get email alerts on their activity';
221
+}
199 222
 
200 223
 // Enhance title if this is a member of the Commons
201 224
 if ($MEMBER->house(HOUSE_TYPE_COMMONS)) {
@@ -203,8 +226,10 @@  discard block
 block discarded – undo
203 226
         $title .= ', former';
204 227
     }
205 228
     $title .= ' MP';
206
-    if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency();
207
-}
229
+    if ($MEMBER->constituency()) {
230
+        $title .= ', ' . $MEMBER->constituency();
231
+    }
232
+    }
208 233
 
209 234
 // Enhance title if this is a member of NIA
210 235
 if ($MEMBER->house(HOUSE_TYPE_NI)) {
@@ -217,8 +242,10 @@  discard block
 block discarded – undo
217 242
         $title .= ', former';
218 243
     }
219 244
     $title .= ' MLA';
220
-    if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency();
221
-}
245
+    if ($MEMBER->constituency()) {
246
+        $title .= ', ' . $MEMBER->constituency();
247
+    }
248
+    }
222 249
 
223 250
 // Enhance title if this is a member of Scottish Parliament
224 251
 if ($MEMBER->house(HOUSE_TYPE_SCOTLAND)) {
@@ -253,8 +280,9 @@  discard block
 block discarded – undo
253 280
 
254 281
 // Build the RSS link and add it to page data.
255 282
 $feedurl = $DATA->page_metadata('mp_rss', 'url') . $MEMBER->person_id() . '.rdf';
256
-if (file_exists(BASEDIR . '/' . $feedurl))
283
+if (file_exists(BASEDIR . '/' . $feedurl)) {
257 284
     $DATA->set_page_metadata($this_page, 'rss', $feedurl);
285
+}
258 286
 
259 287
 // Prepare data for the template
260 288
 $data['full_name'] = $MEMBER->full_name();
@@ -591,11 +619,13 @@  discard block
 block discarded – undo
591 619
         $url = $MEMBER->url();
592 620
         $params = array();
593 621
         foreach ($_GET as $key => $value) {
594
-            if (substr($key, 0, 4) == 'utm_' || $key == 'gclid')
595
-                $params[] = "$key=$value";
622
+            if (substr($key, 0, 4) == 'utm_' || $key == 'gclid') {
623
+                            $params[] = "$key=$value";
624
+            }
625
+        }
626
+        if (count($params)) {
627
+                    $url .= '?' . join('&', $params);
596 628
         }
597
-        if (count($params))
598
-            $url .= '?' . join('&', $params);
599 629
         if ($pagetype) {
600 630
             $pagetype = '/' . $pagetype;
601 631
         } else {
@@ -672,16 +702,21 @@  discard block
 block discarded – undo
672 702
     $current_member = $MEMBER->current_member();
673 703
     $left_house = $MEMBER->left_house();
674 704
 
675
-    if (in_array(HOUSE_TYPE_ROYAL, $MEMBER->houses())) { # Royal short-circuit
705
+    if (in_array(HOUSE_TYPE_ROYAL, $MEMBER->houses())) {
706
+# Royal short-circuit
676 707
         return '<strong>Acceded on ' . $entered_house[HOUSE_TYPE_ROYAL]['date_pretty']
677 708
             . '<br>Coronated on 2 June 1953</strong></li>';
678 709
     }
679 710
     $desc = '';
680 711
     foreach ($MEMBER->houses() as $house) {
681
-        if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS]))
682
-            continue; # Same info is printed further down
712
+        if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS])) {
713
+                    continue;
714
+        }
715
+        # Same info is printed further down
683 716
 
684
-        if (!$current_member[$house]) $desc .= 'Former ';
717
+        if (!$current_member[$house]) {
718
+            $desc .= 'Former ';
719
+        }
685 720
 
686 721
         $party = $left_house[$house]['party'];
687 722
         $party_br = '';
@@ -689,8 +724,9 @@  discard block
 block discarded – undo
689 724
             $party_br = $m[2];
690 725
             $party = $m[1];
691 726
         }
692
-        if ($party != 'unknown')
693
-            $desc .= _htmlentities($party);
727
+        if ($party != 'unknown') {
728
+                    $desc .= _htmlentities($party);
729
+        }
694 730
         if ($party == 'Speaker' || $party == 'Deputy Speaker') {
695 731
             $desc .= ', and ';
696 732
             # XXX: Might go horribly wrong if something odd happens
@@ -701,15 +737,23 @@  discard block
 block discarded – undo
701 737
         }
702 738
         if ($house==HOUSE_TYPE_COMMONS || $house==HOUSE_TYPE_NI || $house==HOUSE_TYPE_SCOTLAND) {
703 739
             $desc .= ' ';
704
-            if ($house==HOUSE_TYPE_COMMONS) $desc .= '<abbr title="Member of Parliament">MP</abbr>';
705
-            if ($house==HOUSE_TYPE_NI) $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>';
706
-            if ($house==HOUSE_TYPE_SCOTLAND) $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>';
740
+            if ($house==HOUSE_TYPE_COMMONS) {
741
+                $desc .= '<abbr title="Member of Parliament">MP</abbr>';
742
+            }
743
+            if ($house==HOUSE_TYPE_NI) {
744
+                $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>';
745
+            }
746
+            if ($house==HOUSE_TYPE_SCOTLAND) {
747
+                $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>';
748
+            }
707 749
             if ($party_br) {
708 750
                 $desc .= " ($party_br)";
709 751
             }
710 752
             $desc .= ' for ' . $left_house[$house]['constituency'];
711 753
         }
712
-        if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') $desc .= ' Peer';
754
+        if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') {
755
+            $desc .= ' Peer';
756
+        }
713 757
         $desc .= ', ';
714 758
     }
715 759
     $desc = preg_replace('#, $#', '', $desc);
@@ -971,10 +1015,13 @@  discard block
 block discarded – undo
971 1015
     # Find latest entered house
972 1016
     $entered_house = null;
973 1017
     foreach ($member->entered_house() as $h => $eh) {
974
-        if (!$entered_house || $eh['date'] > $entered_house) $entered_house = $eh['date'];
1018
+        if (!$entered_house || $eh['date'] > $entered_house) {
1019
+            $entered_house = $eh['date'];
1020
+        }
1021
+    }
1022
+    if ($entered_house > $year_ago) {
1023
+            $since_text = 'since joining Parliament';
975 1024
     }
976
-    if ($entered_house > $year_ago)
977
-        $since_text = 'since joining Parliament';
978 1025
 
979 1026
     $MOREURL = new \MySociety\TheyWorkForYou\Url('search');
980 1027
     $section = 'section:debates section:whall section:lords section:ni';
@@ -988,10 +1035,12 @@  discard block
 block discarded – undo
988 1035
         $MOREURL->insert(array('pid'=>$member->person_id(), 's'=>'section:wrans', 'pop'=>1));
989 1036
         // We assume that if they've answered a question, they're a minister
990 1037
         $minister = 0; $Lminister = false;
991
-        if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0)
992
-            $minister = 1;
993
-        if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0)
994
-            $Lminister = true;
1038
+        if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0) {
1039
+                    $minister = 1;
1040
+        }
1041
+        if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0) {
1042
+                    $Lminister = true;
1043
+        }
995 1044
         if ($member->party() == 'SPK' || $member->party() == 'CWM' || $member->party() == 'DCWM') {
996 1045
             $minister = 2;
997 1046
         }
@@ -1039,11 +1088,17 @@  discard block
 block discarded – undo
1039 1088
 
1040 1089
     if (isset($extra_info['number_of_alerts']) && ($extra_info['number_of_alerts']>0 || $has_email_alerts)) {
1041 1090
         $line = '<strong>' . _htmlentities($extra_info['number_of_alerts']) . '</strong> ' . ($extra_info['number_of_alerts']==1?'person is':'people are') . ' tracking ';
1042
-        if ($member->house_disp == HOUSE_TYPE_COMMONS) $line .= 'this MP';
1043
-        elseif ($member->house_disp == HOUSE_TYPE_LORDS) $line .= 'this peer';
1044
-        elseif ($member->house_disp == HOUSE_TYPE_NI) $line .= 'this MLA';
1045
-        elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) $line .= 'this MSP';
1046
-        elseif ($member->house_disp == HOUSE_TYPE_ROYAL) $line .= $member->full_name();
1091
+        if ($member->house_disp == HOUSE_TYPE_COMMONS) {
1092
+            $line .= 'this MP';
1093
+        } elseif ($member->house_disp == HOUSE_TYPE_LORDS) {
1094
+            $line .= 'this peer';
1095
+        } elseif ($member->house_disp == HOUSE_TYPE_NI) {
1096
+            $line .= 'this MLA';
1097
+        } elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) {
1098
+            $line .= 'this MSP';
1099
+        } elseif ($member->house_disp == HOUSE_TYPE_ROYAL) {
1100
+            $line .= $member->full_name();
1101
+        }
1047 1102
         if ($has_email_alerts) {
1048 1103
             $line .= ' &mdash; <a href="' . WEBPATH . 'alert/?pid='.$member->person_id().'">email me updates on '. $member->full_name(). '&rsquo;s activity</a>';
1049 1104
         }
@@ -1067,10 +1122,12 @@  discard block
 block discarded – undo
1067 1122
 
1068 1123
 function display_stats_line($category, $blurb, $type, $inwhat, $afterstuff, $extra_info, $minister = false, $Lminister = false) {
1069 1124
     $return = false;
1070
-    if (isset($extra_info[$category]))
1071
-        $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff);
1072
-    if (isset($extra_info["L$category"]))
1073
-        $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff);
1125
+    if (isset($extra_info[$category])) {
1126
+            $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff);
1127
+    }
1128
+    if (isset($extra_info["L$category"])) {
1129
+            $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff);
1130
+    }
1074 1131
     return $return;
1075 1132
 }
1076 1133
 
@@ -1082,17 +1139,21 @@  discard block
 block discarded – undo
1082 1139
             $inwhat = preg_replace('#<\/a>#', '', $inwhat);
1083 1140
         }
1084 1141
     }
1085
-    if ($house==HOUSE_TYPE_LORDS) $inwhat = str_replace('MP', 'Lord', $inwhat);
1142
+    if ($house==HOUSE_TYPE_LORDS) {
1143
+        $inwhat = str_replace('MP', 'Lord', $inwhat);
1144
+    }
1086 1145
     $line = $blurb;
1087 1146
     $line .= '<strong>' . $extra_info[$category];
1088
-    if ($type) $line .= ' ' . make_plural($type, $extra_info[$category]);
1147
+    if ($type) {
1148
+        $line .= ' ' . make_plural($type, $extra_info[$category]);
1149
+    }
1089 1150
     $line .= '</strong>';
1090 1151
     $line .= $inwhat;
1091 1152
     if ($minister===2) {
1092 1153
         $line .= ' &#8212; Speakers/ deputy speakers do not ask written questions';
1093
-    } elseif ($minister)
1094
-        $line .= ' &#8212; Ministers do not ask written questions';
1095
-    else {
1154
+    } elseif ($minister) {
1155
+            $line .= ' &#8212; Ministers do not ask written questions';
1156
+    } else {
1096 1157
         $type = ($house==HOUSE_TYPE_COMMONS?'MP':($house==HOUSE_TYPE_LORDS?'Lord':'MLA'));
1097 1158
         if (!get_http_var('rem') && isset($extra_info[$category . '_quintile'])) {
1098 1159
             $line .= ' &#8212; ';
@@ -1131,11 +1192,21 @@  discard block
 block discarded – undo
1131 1192
         $mean = $extra_info["writetothem_responsiveness_mean_$year"];
1132 1193
 
1133 1194
         $a = $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"];
1134
-        if ($a == 'very low') $a = 'a very low';
1135
-        if ($a == 'low') $a = 'a low';
1136
-        if ($a == 'medium') $a = 'a medium';
1137
-        if ($a == 'high') $a = 'a high';
1138
-        if ($a == 'very high') $a = 'a very high';
1195
+        if ($a == 'very low') {
1196
+            $a = 'a very low';
1197
+        }
1198
+        if ($a == 'low') {
1199
+            $a = 'a low';
1200
+        }
1201
+        if ($a == 'medium') {
1202
+            $a = 'a medium';
1203
+        }
1204
+        if ($a == 'high') {
1205
+            $a = 'a high';
1206
+        }
1207
+        if ($a == 'very high') {
1208
+            $a = 'a very high';
1209
+        }
1139 1210
         $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"] = $a;
1140 1211
 
1141 1212
         return display_stats_line("writetothem_responsiveness_fuzzy_response_description_$year", 'Replied within 2 or 3 weeks to <a href="https://www.writetothem.com/stats/'.$year.'/mps" title="From WriteToThem.com">', "", "</a> <!-- Mean: " . $mean . " --> number of messages sent via WriteToThem.com during ".$year.", according to constituents", "", $extra_info);
Please login to merge, or discard this patch.
classes/SectionView/NiView.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
     protected function getSearchSections() {
34 34
         return array(
35
-            array( 'section' => 'ni' )
35
+            array('section' => 'ni')
36 36
         );
37 37
     }
38 38
 
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
 
53 53
         $debates = $DEBATELIST->display('recent_debates', array('days' => 30, 'num' => 6), 'none');
54 54
         $MOREURL = new \MySociety\TheyWorkForYou\Url('nidebatesfront');
55
-        $MOREURL->insert( array( 'more' => 1 ) );
55
+        $MOREURL->insert(array('more' => 1));
56 56
 
57 57
         // this makes sure that we don't repeat this debate in the list below
58 58
         $random_debate = NULL;
59
-        if ( isset($debates['data']) && count($debates['data']) ) {
59
+        if (isset($debates['data']) && count($debates['data'])) {
60 60
             $random_debate = $debates['data'][0];
61 61
         }
62 62
 
63 63
         $recent = array();
64
-        if ( isset($debates['data']) && count($debates['data']) ) {
64
+        if (isset($debates['data']) && count($debates['data'])) {
65 65
             // at the start of a session there may be less than 6
66 66
             // debates
67 67
             $max = 6;
68
-            if ( count($debates['data']) < 6 ) {
68
+            if (count($debates['data']) < 6) {
69 69
                 $max = count($debates['data']);
70 70
             }
71
-            for ( $i = 1; $i < $max; $i++ ) {
71
+            for ($i = 1; $i < $max; $i++) {
72 72
                 $debate = $debates['data'][$i];
73 73
                 $debate['desc'] = "Northern Ireland Assembly debates";
74 74
                 $debate['more_url'] = $MOREURL->generate();
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         }
78 78
 
79 79
         $featured = array();
80
-        if ( $random_debate ) {
80
+        if ($random_debate) {
81 81
             $featured = $random_debate;
82 82
             $featured['more_url'] = $MOREURL->generate();
83 83
             $featured['desc'] = 'Northern Ireland Assembly debate';
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         }
87 87
 
88 88
         $data['featured'] = $featured;
89
-        $data['debates'] = array( 'recent' => $recent);
89
+        $data['debates'] = array('recent' => $recent);
90 90
 
91 91
         $data['regional'] = $this->getMLAList();
92 92
         $data['template'] = 'ni/index';
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
         $data = array();
44 44
 
45
-        $data['popular_searches'] = NULL;
45
+        $data['popular_searches'] = null;
46 46
 
47 47
 
48 48
         $data['urls'] = $this->getURLs($data);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $MOREURL->insert( array( 'more' => 1 ) );
55 55
 
56 56
         // this makes sure that we don't repeat this debate in the list below
57
-        $random_debate = NULL;
57
+        $random_debate = null;
58 58
         if ( isset($debates['data']) && count($debates['data']) ) {
59 59
             $random_debate = $debates['data'][0];
60 60
         }
Please login to merge, or discard this patch.
classes/GlossaryEditQueue.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@
 block discarded – undo
68 68
                             WHERE edit_id=" . $approval_id . ";");
69 69
             if (!$q->success()) {
70 70
                 break;
71
-            }
72
-            else {
71
+            } else {
73 72
                 // Scrub that one from the list of pending items
74 73
                 unset ($this->pending[$approval_id]);
75 74
             }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
             // the new epobject id and approval details.
62 62
             $q = $this->db->query("UPDATE editqueue
63 63
                             SET
64
-                            glossary_id='" .  $this->current_epobject_id. "',
64
+                            glossary_id='" .  $this->current_epobject_id . "',
65 65
                             editor_id='" . addslashes($THEUSER->user_id()) . "',
66 66
                             approved='1',
67 67
                             decided='" . $timestamp . "'
Please login to merge, or discard this patch.
classes/Memcache.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function set($key, $value, $timeout = 3600) {
28 28
         if (class_exists('\Memcached')) {
29
-            self::$memcache->set(OPTION_TWFY_DB_NAME.':'.$key, $value, $timeout);
29
+            self::$memcache->set(OPTION_TWFY_DB_NAME . ':' . $key, $value, $timeout);
30 30
         } else {
31
-            self::$memcache->set(OPTION_TWFY_DB_NAME.':'.$key, $value, MEMCACHE_COMPRESSED, $timeout);
31
+            self::$memcache->set(OPTION_TWFY_DB_NAME . ':' . $key, $value, MEMCACHE_COMPRESSED, $timeout);
32 32
         }
33 33
     }
34 34
 
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
         // see http://php.net/manual/en/memcache.get.php#112056 for explanation of this
37 37
         $was_found = false;
38 38
         if (class_exists('\Memcached')) {
39
-            $value = self::$memcache->get(OPTION_TWFY_DB_NAME.':'.$key, null, $was_found);
39
+            $value = self::$memcache->get(OPTION_TWFY_DB_NAME . ':' . $key, null, $was_found);
40 40
         } else {
41
-            $value = self::$memcache->get(OPTION_TWFY_DB_NAME.':'.$key, $was_found);
41
+            $value = self::$memcache->get(OPTION_TWFY_DB_NAME . ':' . $key, $was_found);
42 42
         }
43 43
         if ($was_found === false) {
44 44
             return false; // mmmmm
Please login to merge, or discard this patch.
classes/SectionView/DebatesView.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
         if (!$this->first_gid) $this->first_gid = $row['gid'];
70 70
 
71 71
         $video_content = '';
72
-        if (!$this->first_video_displayed && $row['video_status']&4 && !($row['video_status']&8)) {
72
+        if (!$this->first_video_displayed && $row['video_status'] & 4 && !($row['video_status'] & 8)) {
73 73
             $video_content = $this->video_sidebar($row, $heading_hpos, $speeches);
74 74
             $this->first_video_displayed = true;
75 75
         }
76
-        if (!$video_content && !$this->first_speech_displayed && $row['video_status']&1 && !($row['video_status']&12)) {
76
+        if (!$video_content && !$this->first_speech_displayed && $row['video_status'] & 1 && !($row['video_status'] & 12)) {
77 77
             $video_content = $this->video_advert($row);
78 78
             $this->first_speech_displayed = true;
79 79
         }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         if ($count > 1) {
105 105
             $out .= '<div class="debate__video" id="video_wrap"><div>';
106 106
             if ($row['gid'] != $this->first_gid) {
107
-                $out .= '<p class="video-instructions">This video starts around ' . ($row['hpos']-$heading_hpos) . ' speeches in (<a href="#g' . gid_to_anchor($row['gid']) . '">move there in text</a>)</p>';
107
+                $out .= '<p class="video-instructions">This video starts around ' . ($row['hpos'] - $heading_hpos) . ' speeches in (<a href="#g' . gid_to_anchor($row['gid']) . '">move there in text</a>)</p>';
108 108
             }
109 109
         }
110 110
         $out .= \MySociety\TheyWorkForYou\Utility\Video::object($video['id'], $start, "$gid_type/$row[gid]");
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@  discard block
 block discarded – undo
66 66
     private $first_gid = '';
67 67
 
68 68
     protected function get_video_html($row, $heading_hpos, $speeches) {
69
-        if (!$this->first_gid) $this->first_gid = $row['gid'];
69
+        if (!$this->first_gid) {
70
+            $this->first_gid = $row['gid'];
71
+        }
70 72
 
71 73
         $video_content = '';
72 74
         if (!$this->first_video_displayed && $row['video_status']&4 && !($row['video_status']&8)) {
@@ -97,7 +99,9 @@  discard block
 block discarded – undo
97 99
         $adate = $vq['adate'];
98 100
         $time = $vq['atime'];
99 101
         $videodb = \MySociety\TheyWorkForYou\Utility\Video::dbConnect();
100
-        if (!$videodb) return '';
102
+        if (!$videodb) {
103
+            return '';
104
+        }
101 105
         $video = \MySociety\TheyWorkForYou\Utility\Video::fromTimestamp($videodb, $adate, $time);
102 106
         $start = $video['offset'];
103 107
         $out = '';
Please login to merge, or discard this patch.
classes/FacebookLogin.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 
37 37
       try {
38 38
         $accessToken = $helper->getAccessToken();
39
-      } catch(\Facebook\Exceptions\FacebookResponseException $e) {
39
+      } catch (\Facebook\Exceptions\FacebookResponseException $e) {
40 40
         $data['error'] = 'Graph returned an error: ' . $e->getMessage();
41 41
         return $data;
42
-      } catch(\Facebook\Exceptions\FacebookSDKException $e) {
42
+      } catch (\Facebook\Exceptions\FacebookSDKException $e) {
43 43
         $data['error'] = 'Facebook SDK returned an error: ' . $e->getMessage();
44 44
         return $data;
45 45
       }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
           return False;
61 61
       }
62 62
 
63
-      if (! $accessToken->isLongLived()) {
63
+      if (!$accessToken->isLongLived()) {
64 64
         $oAuth2Client = $this->getFacebookObject()->getOAuth2Client();
65 65
         try {
66 66
           $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function getFacebookObject() {
15 15
         if (!isset($this->fb)) {
16
-          $this->fb = new \Facebook\Facebook([
16
+            $this->fb = new \Facebook\Facebook([
17 17
             'app_id' => FACEBOOK_APP_ID,
18 18
             'app_secret' => FACEBOOK_APP_SECRET,
19 19
             'default_graph_version' => 'v2.2',
20
-          ]);
20
+            ]);
21 21
         }
22 22
 
23 23
         return $this->fb;
@@ -30,46 +30,46 @@  discard block
 block discarded – undo
30 30
     }
31 31
 
32 32
     public function handleFacebookRedirect() {
33
-      $helper = $this->getFacebookObject()->getRedirectLoginHelper();
33
+        $helper = $this->getFacebookObject()->getRedirectLoginHelper();
34 34
 
35
-      $data = array('login_url' => $this->getLoginURL());
35
+        $data = array('login_url' => $this->getLoginURL());
36 36
 
37
-      try {
37
+        try {
38 38
         $accessToken = $helper->getAccessToken();
39
-      } catch(\Facebook\Exceptions\FacebookResponseException $e) {
39
+        } catch(\Facebook\Exceptions\FacebookResponseException $e) {
40 40
         $data['error'] = 'Graph returned an error: ' . $e->getMessage();
41 41
         return $data;
42
-      } catch(\Facebook\Exceptions\FacebookSDKException $e) {
42
+        } catch(\Facebook\Exceptions\FacebookSDKException $e) {
43 43
         $data['error'] = 'Facebook SDK returned an error: ' . $e->getMessage();
44 44
         return $data;
45
-      }
45
+        }
46 46
 
47
-      $token = $this->checkAccessToken($accessToken);
47
+        $token = $this->checkAccessToken($accessToken);
48 48
 
49
-      if ($token) {
50
-          return array('token' => $token);
51
-      } else {
52
-          $data['error'] = 'Problem getting Facebook token';
53
-          return $data;
54
-      }
49
+        if ($token) {
50
+            return array('token' => $token);
51
+        } else {
52
+            $data['error'] = 'Problem getting Facebook token';
53
+            return $data;
54
+        }
55 55
     }
56 56
 
57 57
 
58 58
     private function checkAccessToken($accessToken) {
59
-      if (!isset($accessToken)) {
60
-          return False;
61
-      }
59
+        if (!isset($accessToken)) {
60
+            return False;
61
+        }
62 62
 
63
-      if (! $accessToken->isLongLived()) {
63
+        if (! $accessToken->isLongLived()) {
64 64
         $oAuth2Client = $this->getFacebookObject()->getOAuth2Client();
65 65
         try {
66
-          $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
66
+            $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
67 67
         } catch (\Facebook\Exceptions\FacebookSDKException $e) {
68
-          return False;
68
+            return False;
69
+        }
69 70
         }
70
-      }
71 71
 
72
-      return $accessToken;
72
+        return $accessToken;
73 73
     }
74 74
 
75 75
     public function loginUser($accessToken) {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             'url' => $THEUSER->url(),
157 157
             'optin' => $THEUSER->optin(),
158 158
             'password' => '',
159
-         );
159
+            );
160 160
 
161 161
         $THEUSER->update_self_no_confirm($details);
162 162
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
     private function checkAccessToken($accessToken) {
59 59
       if (!isset($accessToken)) {
60
-          return False;
60
+          return false;
61 61
       }
62 62
 
63 63
       if (! $accessToken->isLongLived()) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         try {
66 66
           $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
67 67
         } catch (\Facebook\Exceptions\FacebookSDKException $e) {
68
-          return False;
68
+          return false;
69 69
         }
70 70
       }
71 71
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $expires = intval($accessToken->getExpiresAt()->format('U'));
87 87
         twfy_debug("THEUSER", "Facebook access token expires at " . $expires);
88 88
 
89
-        $success = False;
89
+        $success = false;
90 90
         if ($user_id) {
91 91
             twfy_debug("THEUSER", "Faceook user exists in the database: " . $user_id);
92 92
             $success = $THEUSER->init($user_id);
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             return $logged_in;
113 113
         }
114 114
 
115
-        return False;
115
+        return false;
116 116
     }
117 117
 
118 118
     public function createUser($accessToken, $user) {
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
             'url' => '',
129 129
             'status' => '',
130 130
             'password' => '',
131
-            'optin' => False,
132
-            'mp_alert' => False,
131
+            'optin' => false,
132
+            'mp_alert' => false,
133 133
             'facebook_id' => $user['id']
134 134
         );
135 135
         $added = $THEUSER->add($details, false);
Please login to merge, or discard this patch.
classes/Utility/Calendar.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
         } else {
92 92
             $title = $e['title'];
93 93
             if ($pid = $e['person_id']) {
94
-                $MEMBER = new \MEMBER(array( 'person_id' => $pid ));
94
+                $MEMBER = new \MEMBER(array('person_id' => $pid));
95 95
                 $name = $MEMBER->full_name();
96 96
                 $title .= " &#8211; <a href='/mp/?p=$pid'>$name</a>";
97 97
             }
Please login to merge, or discard this patch.
tests/TopicsTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      */
12 12
     public function getDataSet()
13 13
     {
14
-        return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/topics.xml');
14
+        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/topics.xml');
15 15
     }
16 16
 
17 17
     private function fetch_topics_page($vars)
Please login to merge, or discard this patch.
tests/AlertsPageTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function getDataSet()
13 13
     {
14
-        return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/alertspage.xml');
14
+        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/alertspage.xml');
15 15
     }
16 16
 
17 17
     private function fetch_page($vars)
@@ -21,37 +21,37 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function testFetchPage()
23 23
     {
24
-        $page = $this->fetch_page( array() );
24
+        $page = $this->fetch_page(array());
25 25
         $this->assertContains('TheyWorkForYou Email Alerts', $page);
26 26
     }
27 27
 
28 28
     public function testKeywordOnly() {
29
-        $page = $this->fetch_page( array( 'alertsearch' => 'elephant') );
29
+        $page = $this->fetch_page(array('alertsearch' => 'elephant'));
30 30
         $this->assertContains('Receive alerts when [elephant] is mentioned', $page);
31 31
     }
32 32
 
33 33
     public function testPostCodeOnly() {
34
-        $page = $this->fetch_page( array( 'alertsearch' => 'SE17 3HE') );
34
+        $page = $this->fetch_page(array('alertsearch' => 'SE17 3HE'));
35 35
         $this->assertContains('when Mrs Test Current-MP', $page);
36 36
     }
37 37
 
38 38
     public function testPostCodeWithKeyWord()
39 39
     {
40
-        $page = $this->fetch_page( array( 'alertsearch' => 'SE17 3HE elephant') );
40
+        $page = $this->fetch_page(array('alertsearch' => 'SE17 3HE elephant'));
41 41
         $this->assertContains('You have used a postcode and something else', $page);
42 42
         $this->assertContains('Mentions of [elephant] by Mrs Test Current-MP', $page);
43 43
         $this->assertNotContains('by your MSP', $page);
44 44
     }
45 45
 
46 46
     public function testScottishPostcodeWithKeyword() {
47
-        $page = $this->fetch_page( array( 'alertsearch' => 'PH6 2DB elephant') );
47
+        $page = $this->fetch_page(array('alertsearch' => 'PH6 2DB elephant'));
48 48
         $this->assertContains('You have used a postcode and something else', $page);
49 49
         $this->assertContains('Mentions of [elephant] by your MP, Mr Test2 Current-MP', $page);
50 50
         $this->assertContains('Mentions of [elephant] by your MSP, Mrs Test Current-MSP', $page);
51 51
     }
52 52
 
53 53
     public function testPostcodeAndKeywordWithNoSittingMP() {
54
-        $page = $this->fetch_page( array( 'alertsearch' => 'OX1 4LF elephant') );
54
+        $page = $this->fetch_page(array('alertsearch' => 'OX1 4LF elephant'));
55 55
         $this->assertContains('You have used a postcode and something else', $page);
56 56
         $this->assertNotContains('Did you mean to get alerts for when your MP', $page);
57 57
     }
Please login to merge, or discard this patch.