Failed Conditions
Pull Request — master (#1327)
by Nick
11:49
created
www/includes/easyparliament/page.php 1 patch
Braces   +15 added lines, -13 removed lines patch added patch discarded remove patch
@@ -114,7 +114,10 @@  discard block
 block discarded – undo
114 114
         //  'foot' - For the bottom stripe on hansard debates/wrans listings.
115 115
         // $id is the value of an id for this div (if blank, not used).
116 116
         ?>
117
-        <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') echo ' ' . $extra_class; ?>"<?php
117
+        <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') {
118
+    echo ' ' . $extra_class;
119
+}
120
+?>"<?php
118 121
         if ($id != '') {
119 122
             print ' id="' . $id . '"';
120 123
         }
@@ -479,7 +482,9 @@  discard block
 block discarded – undo
479 482
 
480 483
         global $DATA, $this_page;
481 484
 
482
-        if ($this->page_started()) return;
485
+        if ($this->page_started()) {
486
+            return;
487
+        }
483 488
         // The page's HTML hasn't been started yet, so we'd better do it.
484 489
 
485 490
         // Set the page title (in the <title></title>).
@@ -629,7 +634,9 @@  discard block
 block discarded – undo
629 634
             $URL->insert(array('adv' => 1));
630 635
                 echo '&nbsp;&nbsp; <a href="' . $URL->generate() . '">More&nbsp;options</a>';
631 636
                 echo '<br>';
632
-                if ($wtt) print '<input type="hidden" name="wtt" value="1">';
637
+                if ($wtt) {
638
+                    print '<input type="hidden" name="wtt" value="1">';
639
+                }
633 640
         } else { ?>
634 641
     <form action="http://www.writetothem.com/lords" method="get">
635 642
     <input type="hidden" name="pid" value="<?=_htmlentities(get_http_var('pid')) ?>">
@@ -743,8 +750,7 @@  discard block
 block discarded – undo
743 750
             // The return url for after the user has logged in.
744 751
             if (get_http_var("ret") != "") {
745 752
                 $returl = get_http_var("ret");
746
-            }
747
-            else {
753
+            } else {
748 754
                 $returl = $glossary_returl;
749 755
             }
750 756
             ?>
@@ -808,15 +814,13 @@  discard block
 block discarded – undo
808 814
                 else {
809 815
                     $letters[] = "<li class=\"on\">" . $letter . "</li>";
810 816
                 }
811
-            }
812
-            elseif (!empty($GLOSSARY->alphabet[$letter])) {
817
+            } elseif (!empty($GLOSSARY->alphabet[$letter])) {
813 818
                 $URL = new \MySociety\TheyWorkForYou\Url('glossary');
814 819
                 $URL->insert(array('az' => $letter));
815 820
                 $letter_link = $URL->generate('url');
816 821
 
817 822
                 $letters[] = "<li><a href=\"" . $letter_link . "\">" . $letter . "</a></li>";
818
-            }
819
-            else {
823
+            } else {
820 824
                 $letters[] = '<li>' . $letter . '</li>';
821 825
             }
822 826
         }
@@ -856,8 +860,7 @@  discard block
 block discarded – undo
856 860
             $URL->insert(array("delete_confirm" => $term['glossary_id']));
857 861
             $delete_url = $URL->generate();
858 862
             $admin_links = "<br><small><a href=\"".$delete_url."\">delete</a></small>";
859
-        }
860
-        else {
863
+        } else {
861 864
             $admin_links = "";
862 865
         }
863 866
 
@@ -867,8 +870,7 @@  discard block
 block discarded – undo
867 870
             $user_link = $URL->generate('url');
868 871
 
869 872
             $user_details = "\t\t\t\t<p><small>contributed by user <a href=\"" . $user_link . "\">" . $term['firstname'] . " " . $term['lastname'] . "</a></small>" . $admin_links . "</p>\n";
870
-        }
871
-        else {
873
+        } else {
872 874
             $user_details = "";
873 875
         }
874 876
 
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/calendar_date.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,10 +18,13 @@
 block discarded – undo
18 18
 # Content goes here
19 19
 foreach ($data['dates'] as $date => $day_events) {
20 20
     foreach ($order as $i => $chamber) {
21
-        if (!array_key_exists($chamber, $day_events))
22
-            continue;
21
+        if (!array_key_exists($chamber, $day_events)) {
22
+                    continue;
23
+        }
23 24
         $events = $day_events[$chamber];
24
-        if ($plural[$i]) $chamber .= 's';
25
+        if ($plural[$i]) {
26
+            $chamber .= 's';
27
+        }
25 28
         print "<h2 class='calendar'>$chamber";
26 29
         if (in_array($major[$i], $data['majors'])) {
27 30
             $URL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$major[$i]]['page_all']);
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/comments_recent.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
     }
19 19
     $PAGE->block_start(array('id'=>'recentcomments', 'title'=>$title));
20 20
 
21
-    if ($this_page != 'home') $PAGE->page_links($data);
21
+    if ($this_page != 'home') {
22
+        $PAGE->page_links($data);
23
+    }
22 24
     $USERURL = new \MySociety\TheyWorkForYou\Url('userview');
23 25
     ?>
24 26
                         <ul>
@@ -50,7 +52,9 @@  discard block
 block discarded – undo
50 52
                         <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments'])+1; ?>">See more annotations posted recently</a></p>
51 53
 <?php
52 54
     }
53
-    if ($this_page != 'home') $PAGE->page_links($data);
55
+    if ($this_page != 'home') {
56
+        $PAGE->page_links($data);
57
+    }
54 58
     $PAGE->block_end();
55 59
 }
56 60
 ?>
Please login to merge, or discard this patch.
www/docs/api/api_getPerson.php 1 patch
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
         $URL = new \MySociety\TheyWorkForYou\Url('mp');
29 29
         $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
30 30
     }
31
-    if ($has_party && isset($parties[$row['party']]))
32
-        $row['party'] = $parties[$row['party']];
31
+    if ($has_party && isset($parties[$row['party']])) {
32
+            $row['party'] = $parties[$row['party']];
33
+    }
33 34
     list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
34 35
     if ($image) {
35 36
         list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
@@ -49,7 +50,9 @@  discard block
 block discarded – undo
49 50
     }
50 51
 
51 52
     foreach ($row as $k => $r) {
52
-        if (is_string($r)) $row[$k] = html_entity_decode($r);
53
+        if (is_string($r)) {
54
+            $row[$k] = html_entity_decode($r);
55
+        }
53 56
     }
54 57
 
55 58
     return $row;
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
         $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true);
86 89
         $output[] = $out;
87 90
         $time = strtotime($q->field($i, 'lastupdate'));
88
-        if ($time > $last_mod)
89
-            $last_mod = $time;
91
+        if ($time > $last_mod) {
92
+                    $last_mod = $time;
93
+        }
90 94
     }
91 95
     # Only one MP, not an array
92 96
     if ($flatten && count($output) == 1 && $house == HOUSE_TYPE_COMMONS) {
@@ -134,13 +138,18 @@  discard block
 block discarded – undo
134 138
 
135 139
     $cons = array();
136 140
     foreach ($constituencies as $constituency) {
137
-        if ($constituency == '') continue;
138
-        if ($constituency == 'Orkney ')
139
-            $constituency = 'Orkney & Shetland';
141
+        if ($constituency == '') {
142
+            continue;
143
+        }
144
+        if ($constituency == 'Orkney ') {
145
+                    $constituency = 'Orkney & Shetland';
146
+        }
140 147
 
141 148
         if ($house == HOUSE_TYPE_COMMONS) {
142 149
             $normalised = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency);
143
-            if ($normalised) $constituency = $normalised;
150
+            if ($normalised) {
151
+                $constituency = $normalised;
152
+            }
144 153
         }
145 154
 
146 155
         $cons[] = $constituency;
Please login to merge, or discard this patch.
classes/Db/Query.php 1 patch
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -130,7 +130,9 @@  discard block
 block discarded – undo
130 130
             $this->error($this->conn->errorCode() . ': ' . $this->conn->errorInfo()[2]);
131 131
         }
132 132
 
133
-        if (!$this->success) return;
133
+        if (!$this->success) {
134
+            return;
135
+        }
134 136
 
135 137
         if ((!$pdoStatement) or (empty($pdoStatement))) {
136 138
             // A failed query.
@@ -180,8 +182,9 @@  discard block
 block discarded – undo
180 182
      * @param string $column_name
181 183
      */
182 184
     public function field($row_index, $column_name) {
183
-        if ($this->rows > 0)
184
-            return $this->data[$row_index][$column_name];
185
+        if ($this->rows > 0) {
186
+                    return $this->data[$row_index][$column_name];
187
+        }
185 188
         return "";
186 189
     }
187 190
 
@@ -196,8 +199,9 @@  discard block
 block discarded – undo
196 199
      * @param integer $row_index
197 200
      */
198 201
     public function row($row_index) {
199
-        if ($this->success && $this->rows > 0)
200
-            return $this->data[$row_index];
202
+        if ($this->success && $this->rows > 0) {
203
+                    return $this->data[$row_index];
204
+        }
201 205
         return array();
202 206
     }
203 207
 
Please login to merge, or discard this patch.
www/includes/easyparliament/hansardlist.php 1 patch
Braces   +70 added lines, -37 removed lines patch added patch discarded remove patch
@@ -138,8 +138,9 @@  discard block
 block discarded – undo
138 138
 
139 139
         global $PAGE;
140 140
 
141
-        if ($view == 'search' && (!defined('FRONT_END_SEARCH') || !FRONT_END_SEARCH))
142
-            return false;
141
+        if ($view == 'search' && (!defined('FRONT_END_SEARCH') || !FRONT_END_SEARCH)) {
142
+                    return false;
143
+        }
143 144
 
144 145
         $validviews = array ('calendar', 'date', 'gid', 'person', 'search', 'search_min', 'search_video', 'recent', 'recent_mostvotes', 'biggest_debates', 'recent_wrans', 'recent_wms', 'column', 'mp', 'bill', 'session', 'recent_debates', 'recent_pbc_debates', 'featured_gid');
145 146
         if (in_array($view, $validviews)) {
@@ -326,10 +327,11 @@  discard block
 block discarded – undo
326 327
             );
327 328
 
328 329
             $subsectiondata = $this->_get_hansard_data($input);
329
-            if (count($subsectiondata) == 0)
330
-                $subsectiondata = null;
331
-            else
332
-                $subsectiondata = $subsectiondata[0];
330
+            if (count($subsectiondata) == 0) {
331
+                            $subsectiondata = null;
332
+            } else {
333
+                            $subsectiondata = $subsectiondata[0];
334
+            }
333 335
 
334 336
         } elseif ($itemdata['htype'] == '11') {
335 337
             // It's a subsection, so use the item itself.
@@ -1018,12 +1020,12 @@  discard block
 block discarded – undo
1018 1020
         // Mainly for glossary term adding
1019 1021
         if (isset($args['num']) && $args['num']) {
1020 1022
             $results_per_page = $args['num']+0;
1021
-        }
1022
-        else {
1023
+        } else {
1023 1024
             $results_per_page = 20;
1024 1025
         }
1025
-        if ($results_per_page > 1000)
1026
-            $results_per_page = 1000;
1026
+        if ($results_per_page > 1000) {
1027
+                    $results_per_page = 1000;
1028
+        }
1027 1029
 
1028 1030
         $data['info']['results_per_page'] = $results_per_page;
1029 1031
 
@@ -1051,10 +1053,16 @@  discard block
 block discarded – undo
1051 1053
         // Get the gids from Xapian
1052 1054
         $sort_order = 'date';
1053 1055
         if (isset($args['o'])) {
1054
-            if ($args['o']=='d') $sort_order = 'newest';
1055
-            if ($args['o']=='o') $sort_order = 'oldest';
1056
-            elseif ($args['o']=='c') $sort_order = 'created';
1057
-            elseif ($args['o']=='r') $sort_order = 'relevance';
1056
+            if ($args['o']=='d') {
1057
+                $sort_order = 'newest';
1058
+            }
1059
+            if ($args['o']=='o') {
1060
+                $sort_order = 'oldest';
1061
+            } elseif ($args['o']=='c') {
1062
+                $sort_order = 'created';
1063
+            } elseif ($args['o']=='r') {
1064
+                $sort_order = 'relevance';
1065
+            }
1058 1066
         }
1059 1067
 
1060 1068
         $data['searchdescription'] = $SEARCHENGINE->query_description_long();
@@ -1114,7 +1122,9 @@  discard block
 block discarded – undo
1114 1122
                     FROM future
1115 1123
                     LEFT JOIN future_people ON id=calendar_id AND witness=0
1116 1124
                     WHERE id = $id AND deleted=0");
1117
-                if ($q->rows() == 0) continue;
1125
+                if ($q->rows() == 0) {
1126
+                    continue;
1127
+                }
1118 1128
 
1119 1129
                 $itemdata = $q->row(0);
1120 1130
 
@@ -1123,8 +1133,9 @@  discard block
 block discarded – undo
1123 1133
                     in_array($itemdata['chamber'], array(
1124 1134
                         'Commons: Main Chamber', 'Lords: Main Chamber',
1125 1135
                         'Commons: Westminster Hall',
1126
-                    )))
1127
-                        continue;
1136
+                    ))) {
1137
+                                        continue;
1138
+                }
1128 1139
 
1129 1140
                 list($cal_item, $cal_meta) = \MySociety\TheyWorkForYou\Utility\Calendar::meta($itemdata);
1130 1141
                 $body = $this->prepare_search_result_for_display($cal_item) . '.';
@@ -1237,10 +1248,17 @@  discard block
 block discarded – undo
1237 1248
                     $section = $this->_get_section($itemdata);
1238 1249
                     $subsection = $this->_get_subsection($itemdata);
1239 1250
                     $body = $hansardmajors[$itemdata['major']]['title'] . ' &#8212; ';
1240
-                    if (isset($section['body'])) $body .= $section['body'];
1241
-                    if (isset($subsection['body'])) $body .= ': ' . $subsection['body'];
1242
-                    if (isset($subsection['listurl'])) $listurl = $subsection['listurl'];
1243
-                    else $listurl = '';
1251
+                    if (isset($section['body'])) {
1252
+                        $body .= $section['body'];
1253
+                    }
1254
+                    if (isset($subsection['body'])) {
1255
+                        $body .= ': ' . $subsection['body'];
1256
+                    }
1257
+                    if (isset($subsection['listurl'])) {
1258
+                        $listurl = $subsection['listurl'];
1259
+                    } else {
1260
+                        $listurl = '';
1261
+                    }
1244 1262
                     $itemdata['parent'] = array (
1245 1263
                         'body' => $body,
1246 1264
                         'listurl' => $listurl
@@ -1565,7 +1583,8 @@  discard block
 block discarded – undo
1565 1583
                     'url' => $YEARURL->generate()
1566 1584
                 );
1567 1585
 
1568
-            } else { // action is 'year'.
1586
+            } else {
1587
+// action is 'year'.
1569 1588
 
1570 1589
                 $nextprev['prev'] = array ('body' => 'Previous year');
1571 1590
                 $nextprev['next'] = array ('body' => 'Next year');
@@ -1980,10 +1999,11 @@  discard block
 block discarded – undo
1980 1999
         // );
1981 2000
 
1982 2001
         // $url_args is an array of other key/value pairs to be appended in the GET string.
1983
-        if ($id_data['major'])
1984
-            $LISTURL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$id_data['major']]['page_all']);
1985
-        else
1986
-            $LISTURL = new \MySociety\TheyWorkForYou\Url('wrans');
2002
+        if ($id_data['major']) {
2003
+                    $LISTURL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$id_data['major']]['page_all']);
2004
+        } else {
2005
+                    $LISTURL = new \MySociety\TheyWorkForYou\Url('wrans');
2006
+        }
1987 2007
 
1988 2008
         $fragment = '';
1989 2009
 
@@ -2633,7 +2653,9 @@  discard block
 block discarded – undo
2633 2653
             array(':gid_from_spid' => 'uk.org.publicwhip/spq/' . $fixed_spid)
2634 2654
         );
2635 2655
         $gid = $q->field(0, 'mentioned_gid');
2636
-        if ($gid) return $gid;
2656
+        if ($gid) {
2657
+            return $gid;
2658
+        }
2637 2659
         return null;
2638 2660
     }
2639 2661
     public function old_get_gid_from_spid($spid) {
@@ -2642,7 +2664,9 @@  discard block
 block discarded – undo
2642 2664
             array(':gid_like' => 'uk.org.publicwhip/spwa/%.' . $spid . '.h')
2643 2665
         );
2644 2666
         $gid = $q->field(0, 'gid');
2645
-        if ($gid) return str_replace('uk.org.publicwhip/spwa/', '', $gid);
2667
+        if ($gid) {
2668
+            return str_replace('uk.org.publicwhip/spwa/', '', $gid);
2669
+        }
2646 2670
         return null;
2647 2671
     }
2648 2672
 }
@@ -2928,7 +2952,9 @@  discard block
 block discarded – undo
2928 2952
 
2929 2953
         // Get the most recent day on which we have a debate.
2930 2954
         $recentday = $this->most_recent_day();
2931
-        if (!count($recentday)) return $data;
2955
+        if (!count($recentday)) {
2956
+            return $data;
2957
+        }
2932 2958
 
2933 2959
         if (!isset($args['days']) || !is_numeric($args['days'])) {
2934 2960
             $args['days'] = 1;
@@ -3055,8 +3081,9 @@  discard block
 block discarded – undo
3055 3081
 
3056 3082
         // Get the most recent day on which we have a debate.
3057 3083
         $recentday = $this->most_recent_day();
3058
-        if (!count($recentday))
3059
-            return array();
3084
+        if (!count($recentday)) {
3085
+                    return array();
3086
+        }
3060 3087
 
3061 3088
         if (!isset($args['days']) || !is_numeric($args['days'])) {
3062 3089
             $args['days'] = 1;
@@ -3189,8 +3216,9 @@  discard block
 block discarded – undo
3189 3216
 
3190 3217
         // Get the most recent day on which we have wrans.
3191 3218
         $recentday = $this->most_recent_day();
3192
-        if (!count($recentday))
3193
-            return $data;
3219
+        if (!count($recentday)) {
3220
+                    return $data;
3221
+        }
3194 3222
 
3195 3223
         if (!isset($args['days']) || !is_numeric($args['days'])) {
3196 3224
             $args['days'] = 1;
@@ -3470,7 +3498,9 @@  discard block
 block discarded – undo
3470 3498
     }
3471 3499
 
3472 3500
     public function _get_data_by_recent_pbc_debates($args) {
3473
-        if (!isset($args['num'])) $args['num'] = 20;
3501
+        if (!isset($args['num'])) {
3502
+            $args['num'] = 20;
3503
+        }
3474 3504
         $q = $this->db->query('select gid, minor, hdate from hansard
3475 3505
             where htype=10 and major=6
3476 3506
             order by hdate desc limit ' . $args['num']);
@@ -3484,7 +3514,9 @@  discard block
 block discarded – undo
3484 3514
             $session = $qq->field(0, 'session');
3485 3515
             list($sitting, $part) = $this->_get_sitting($gid);
3486 3516
             $sitting_txt = make_ranking($sitting) . ' sitting';
3487
-            if ($part>0) $sitting .= ", part $part";
3517
+            if ($part>0) {
3518
+                $sitting .= ", part $part";
3519
+            }
3488 3520
             $data[$hdate][] = array(
3489 3521
                 'bill'=> $title,
3490 3522
                 'sitting' => $sitting_txt,
@@ -3496,8 +3528,9 @@  discard block
 block discarded – undo
3496 3528
 
3497 3529
     # Given a GID, parse out the sitting number and optional part from it
3498 3530
     public function _get_sitting($gid) {
3499
-        if (preg_match('#_(\d\d)-(\d)_#', $gid, $m))
3500
-            return array($m[1]+0, $m[2]);
3531
+        if (preg_match('#_(\d\d)-(\d)_#', $gid, $m)) {
3532
+                    return array($m[1]+0, $m[2]);
3533
+        }
3501 3534
         return array(0, 0);
3502 3535
     }
3503 3536
 }
Please login to merge, or discard this patch.
www/docs/mp/index.php 1 patch
Braces   +145 added lines, -64 removed lines patch added patch discarded remove patch
@@ -62,16 +62,36 @@  discard block
 block discarded – undo
62 62
 $constituency = strtolower(str_replace('_', ' ', get_http_var('c')));
63 63
 
64 64
 // Fix for names with non-ASCII characters
65
-if ($name == 'sion simon') $name = 'si\xf4n simon';
66
-if ($name == 'sian james') $name = 'si\xe2n james';
67
-if ($name == 'lembit opik') $name = 'lembit \xf6pik';
68
-if ($name == 'bairbre de brun') $name = 'bairbre de br\xfan';
69
-if ($name == 'daithi mckay') $name = 'daith\xed mckay';
70
-if ($name == 'caral ni chuilin') $name = 'car\xe1l n\xed chuil\xedn';
71
-if ($name == 'caledon du pre') $name = 'caledon du pr\xe9';
72
-if ($name == 'sean etchingham') $name = 'se\xe1n etchingham';
73
-if ($name == 'john tinne') $name = 'john tinn\xe9';
74
-if ($name == 'renee short') $name = 'ren\xe9e short';
65
+if ($name == 'sion simon') {
66
+    $name = 'si\xf4n simon';
67
+}
68
+if ($name == 'sian james') {
69
+    $name = 'si\xe2n james';
70
+}
71
+if ($name == 'lembit opik') {
72
+    $name = 'lembit \xf6pik';
73
+}
74
+if ($name == 'bairbre de brun') {
75
+    $name = 'bairbre de br\xfan';
76
+}
77
+if ($name == 'daithi mckay') {
78
+    $name = 'daith\xed mckay';
79
+}
80
+if ($name == 'caral ni chuilin') {
81
+    $name = 'car\xe1l n\xed chuil\xedn';
82
+}
83
+if ($name == 'caledon du pre') {
84
+    $name = 'caledon du pr\xe9';
85
+}
86
+if ($name == 'sean etchingham') {
87
+    $name = 'se\xe1n etchingham';
88
+}
89
+if ($name == 'john tinne') {
90
+    $name = 'john tinn\xe9';
91
+}
92
+if ($name == 'renee short') {
93
+    $name = 'ren\xe9e short';
94
+}
75 95
 
76 96
 // Fix for common misspellings, name changes etc
77 97
 $name_fix = array(
@@ -103,7 +123,9 @@  discard block
 block discarded – undo
103 123
 }
104 124
 
105 125
 // Fixes for Ynys Mon, and a Unicode URL
106
-if ($constituency == 'ynys mon') $constituency = "ynys m\xf4n";
126
+if ($constituency == 'ynys mon') {
127
+    $constituency = "ynys m\xf4n";
128
+}
107 129
 if (preg_match("#^ynys m\xc3\xb4n#i", $constituency)) {
108 130
     $constituency = "ynys m\xf4n";
109 131
 }
@@ -126,11 +148,17 @@  discard block
 block discarded – undo
126 148
 
127 149
 /////////////////////////////////////////////////////////
128 150
 // DETERMINE TYPE OF REPRESENTITIVE
129
-if (get_http_var('peer')) $this_page = 'peer';
130
-elseif (get_http_var('royal')) $this_page = 'royal';
131
-elseif (get_http_var('mla')) $this_page = 'mla';
132
-elseif (get_http_var('msp')) $this_page = 'msp';
133
-else $this_page = 'mp';
151
+if (get_http_var('peer')) {
152
+    $this_page = 'peer';
153
+} elseif (get_http_var('royal')) {
154
+    $this_page = 'royal';
155
+} elseif (get_http_var('mla')) {
156
+    $this_page = 'mla';
157
+} elseif (get_http_var('msp')) {
158
+    $this_page = 'msp';
159
+} else {
160
+    $this_page = 'mp';
161
+}
134 162
 
135 163
 try {
136 164
     if (is_numeric($pid)) {
@@ -179,8 +207,9 @@  discard block
 block discarded – undo
179 207
 $desc = "Read $member_name's contributions to Parliament, including speeches and questions";
180 208
 
181 209
 // Enhance description if this is a current member
182
-if ($MEMBER->current_member_anywhere())
210
+if ($MEMBER->current_member_anywhere()) {
183 211
     $desc .= ', investigate their voting record, and get email alerts on their activity';
212
+}
184 213
 
185 214
 // Enhance title if this is a member of the Commons
186 215
 if ($MEMBER->house(HOUSE_TYPE_COMMONS)) {
@@ -188,8 +217,10 @@  discard block
 block discarded – undo
188 217
         $title .= ', former';
189 218
     }
190 219
     $title .= ' MP';
191
-    if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency();
192
-}
220
+    if ($MEMBER->constituency()) {
221
+        $title .= ', ' . $MEMBER->constituency();
222
+    }
223
+    }
193 224
 
194 225
 // Enhance title if this is a member of NIA
195 226
 if ($MEMBER->house(HOUSE_TYPE_NI)) {
@@ -202,8 +233,10 @@  discard block
 block discarded – undo
202 233
         $title .= ', former';
203 234
     }
204 235
     $title .= ' MLA';
205
-    if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency();
206
-}
236
+    if ($MEMBER->constituency()) {
237
+        $title .= ', ' . $MEMBER->constituency();
238
+    }
239
+    }
207 240
 
208 241
 // Enhance title if this is a member of Scottish Parliament
209 242
 if ($MEMBER->house(HOUSE_TYPE_SCOTLAND)) {
@@ -224,14 +257,18 @@  discard block
 block discarded – undo
224 257
 // Position if this is a member of the Commons
225 258
 if ($MEMBER->house(HOUSE_TYPE_COMMONS)) {
226 259
     $position = $MEMBER->current_member(HOUSE_TYPE_COMMONS) ? 'MP' : 'Former MP';
227
-    if ($MEMBER->constituency()) $position .= ', ' . $MEMBER->constituency();
260
+    if ($MEMBER->constituency()) {
261
+        $position .= ', ' . $MEMBER->constituency();
262
+    }
228 263
     $positions[] = $position;
229 264
 }
230 265
 
231 266
 // Position if this is a member of NIA
232 267
 if ($MEMBER->house(HOUSE_TYPE_NI)) {
233 268
     $position = $MEMBER->current_member(HOUSE_TYPE_NI) ? 'MLA' : 'Former MLA';
234
-    if ($MEMBER->constituency()) $position .= ', ' . $MEMBER->constituency();
269
+    if ($MEMBER->constituency()) {
270
+        $position .= ', ' . $MEMBER->constituency();
271
+    }
235 272
     $positions[] = $position;
236 273
 }
237 274
 
@@ -265,8 +302,9 @@  discard block
 block discarded – undo
265 302
 
266 303
 // Build the RSS link and add it to page data.
267 304
 $feedurl = $DATA->page_metadata('mp_rss', 'url') . $MEMBER->person_id() . '.rdf';
268
-if (file_exists(BASEDIR . '/' . $feedurl))
305
+if (file_exists(BASEDIR . '/' . $feedurl)) {
269 306
     $DATA->set_page_metadata($this_page, 'rss', $feedurl);
307
+}
270 308
 
271 309
 // Prepare data for the template
272 310
 $data['full_name'] = $MEMBER->full_name();
@@ -692,11 +730,13 @@  discard block
 block discarded – undo
692 730
         $url = $MEMBER->url();
693 731
         $params = array();
694 732
         foreach ($_GET as $key => $value) {
695
-            if (substr($key, 0, 4) == 'utm_' || $key == 'gclid')
696
-                $params[] = "$key=$value";
733
+            if (substr($key, 0, 4) == 'utm_' || $key == 'gclid') {
734
+                            $params[] = "$key=$value";
735
+            }
736
+        }
737
+        if (count($params)) {
738
+                    $url .= '?' . join('&', $params);
697 739
         }
698
-        if (count($params))
699
-            $url .= '?' . join('&', $params);
700 740
         if ($pagetype) {
701 741
             $pagetype = '/' . $pagetype;
702 742
         } else {
@@ -773,16 +813,21 @@  discard block
 block discarded – undo
773 813
     $current_member = $MEMBER->current_member();
774 814
     $left_house = $MEMBER->left_house();
775 815
 
776
-    if (in_array(HOUSE_TYPE_ROYAL, $MEMBER->houses())) { # Royal short-circuit
816
+    if (in_array(HOUSE_TYPE_ROYAL, $MEMBER->houses())) {
817
+# Royal short-circuit
777 818
         return '<strong>Acceded on ' . $entered_house[HOUSE_TYPE_ROYAL]['date_pretty']
778 819
             . '<br>Coronated on 2 June 1953</strong></li>';
779 820
     }
780 821
     $desc = '';
781 822
     foreach ($MEMBER->houses() as $house) {
782
-        if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS]))
783
-            continue; # Same info is printed further down
823
+        if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS])) {
824
+                    continue;
825
+        }
826
+        # Same info is printed further down
784 827
 
785
-        if (!$current_member[$house]) $desc .= 'Former ';
828
+        if (!$current_member[$house]) {
829
+            $desc .= 'Former ';
830
+        }
786 831
 
787 832
         $party = $left_house[$house]['party'];
788 833
         $party_br = '';
@@ -790,8 +835,9 @@  discard block
 block discarded – undo
790 835
             $party_br = $m[2];
791 836
             $party = $m[1];
792 837
         }
793
-        if ($party != 'unknown')
794
-            $desc .= _htmlentities($party);
838
+        if ($party != 'unknown') {
839
+                    $desc .= _htmlentities($party);
840
+        }
795 841
         if ($party == 'Speaker' || $party == 'Deputy Speaker') {
796 842
             $desc .= ', and ';
797 843
             # XXX: Might go horribly wrong if something odd happens
@@ -802,15 +848,23 @@  discard block
 block discarded – undo
802 848
         }
803 849
         if ($house==HOUSE_TYPE_COMMONS || $house==HOUSE_TYPE_NI || $house==HOUSE_TYPE_SCOTLAND) {
804 850
             $desc .= ' ';
805
-            if ($house==HOUSE_TYPE_COMMONS) $desc .= '<abbr title="Member of Parliament">MP</abbr>';
806
-            if ($house==HOUSE_TYPE_NI) $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>';
807
-            if ($house==HOUSE_TYPE_SCOTLAND) $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>';
851
+            if ($house==HOUSE_TYPE_COMMONS) {
852
+                $desc .= '<abbr title="Member of Parliament">MP</abbr>';
853
+            }
854
+            if ($house==HOUSE_TYPE_NI) {
855
+                $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>';
856
+            }
857
+            if ($house==HOUSE_TYPE_SCOTLAND) {
858
+                $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>';
859
+            }
808 860
             if ($party_br) {
809 861
                 $desc .= " ($party_br)";
810 862
             }
811 863
             $desc .= ' for ' . $left_house[$house]['constituency'];
812 864
         }
813
-        if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') $desc .= ' Peer';
865
+        if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') {
866
+            $desc .= ' Peer';
867
+        }
814 868
         $desc .= ', ';
815 869
     }
816 870
     $desc = preg_replace('#, $#', '', $desc);
@@ -1073,10 +1127,13 @@  discard block
 block discarded – undo
1073 1127
     # Find latest entered house
1074 1128
     $entered_house = null;
1075 1129
     foreach ($member->entered_house() as $h => $eh) {
1076
-        if (!$entered_house || $eh['date'] > $entered_house) $entered_house = $eh['date'];
1130
+        if (!$entered_house || $eh['date'] > $entered_house) {
1131
+            $entered_house = $eh['date'];
1132
+        }
1133
+    }
1134
+    if ($entered_house > $year_ago) {
1135
+            $since_text = 'since joining Parliament';
1077 1136
     }
1078
-    if ($entered_house > $year_ago)
1079
-        $since_text = 'since joining Parliament';
1080 1137
 
1081 1138
     $MOREURL = new \MySociety\TheyWorkForYou\Url('search');
1082 1139
     $section = 'section:debates section:whall section:lords section:ni';
@@ -1089,10 +1146,12 @@  discard block
 block discarded – undo
1089 1146
         $MOREURL->insert(array('pid'=>$member->person_id(), 's'=>'section:wrans', 'pop'=>1));
1090 1147
         // We assume that if they've answered a question, they're a minister
1091 1148
         $minister = 0; $Lminister = false;
1092
-        if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0)
1093
-            $minister = 1;
1094
-        if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0)
1095
-            $Lminister = true;
1149
+        if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0) {
1150
+                    $minister = 1;
1151
+        }
1152
+        if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0) {
1153
+                    $Lminister = true;
1154
+        }
1096 1155
         if ($member->party() == 'SPK' || $member->party() == 'CWM' || $member->party() == 'DCWM') {
1097 1156
             $minister = 2;
1098 1157
         }
@@ -1141,11 +1200,17 @@  discard block
 block discarded – undo
1141 1200
 
1142 1201
     if (isset($extra_info['number_of_alerts']) && ($extra_info['number_of_alerts']>0 || $has_email_alerts)) {
1143 1202
         $line = '<strong>' . _htmlentities($extra_info['number_of_alerts']) . '</strong> ' . ($extra_info['number_of_alerts']==1?'person is':'people are') . ' tracking ';
1144
-        if ($member->house_disp == HOUSE_TYPE_COMMONS) $line .= 'this MP';
1145
-        elseif ($member->house_disp == HOUSE_TYPE_LORDS) $line .= 'this peer';
1146
-        elseif ($member->house_disp == HOUSE_TYPE_NI) $line .= 'this MLA';
1147
-        elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) $line .= 'this MSP';
1148
-        elseif ($member->house_disp == HOUSE_TYPE_ROYAL) $line .= $member->full_name();
1203
+        if ($member->house_disp == HOUSE_TYPE_COMMONS) {
1204
+            $line .= 'this MP';
1205
+        } elseif ($member->house_disp == HOUSE_TYPE_LORDS) {
1206
+            $line .= 'this peer';
1207
+        } elseif ($member->house_disp == HOUSE_TYPE_NI) {
1208
+            $line .= 'this MLA';
1209
+        } elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) {
1210
+            $line .= 'this MSP';
1211
+        } elseif ($member->house_disp == HOUSE_TYPE_ROYAL) {
1212
+            $line .= $member->full_name();
1213
+        }
1149 1214
         if ($has_email_alerts) {
1150 1215
             $line .= ' &mdash; <a href="' . WEBPATH . 'alert/?pid='.$member->person_id().'">email me updates on '. $member->full_name(). '&rsquo;s activity</a>';
1151 1216
         }
@@ -1169,10 +1234,12 @@  discard block
 block discarded – undo
1169 1234
 
1170 1235
 function display_stats_line($category, $blurb, $type, $inwhat, $afterstuff, $extra_info, $minister = false, $Lminister = false) {
1171 1236
     $return = false;
1172
-    if (isset($extra_info[$category]))
1173
-        $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff);
1174
-    if (isset($extra_info["L$category"]))
1175
-        $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff);
1237
+    if (isset($extra_info[$category])) {
1238
+            $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff);
1239
+    }
1240
+    if (isset($extra_info["L$category"])) {
1241
+            $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff);
1242
+    }
1176 1243
     return $return;
1177 1244
 }
1178 1245
 
@@ -1184,17 +1251,21 @@  discard block
 block discarded – undo
1184 1251
             $inwhat = preg_replace('#<\/a>#', '', $inwhat);
1185 1252
         }
1186 1253
     }
1187
-    if ($house==HOUSE_TYPE_LORDS) $inwhat = str_replace('MP', 'Lord', $inwhat);
1254
+    if ($house==HOUSE_TYPE_LORDS) {
1255
+        $inwhat = str_replace('MP', 'Lord', $inwhat);
1256
+    }
1188 1257
     $line = $blurb;
1189 1258
     $line .= '<strong>' . $extra_info[$category];
1190
-    if ($type) $line .= ' ' . make_plural($type, $extra_info[$category]);
1259
+    if ($type) {
1260
+        $line .= ' ' . make_plural($type, $extra_info[$category]);
1261
+    }
1191 1262
     $line .= '</strong>';
1192 1263
     $line .= $inwhat;
1193 1264
     if ($minister===2) {
1194 1265
         $line .= ' &#8212; Speakers/ deputy speakers do not ask written questions';
1195
-    } elseif ($minister)
1196
-        $line .= ' &#8212; Ministers do not ask written questions';
1197
-    else {
1266
+    } elseif ($minister) {
1267
+            $line .= ' &#8212; Ministers do not ask written questions';
1268
+    } else {
1198 1269
         $type = ($house==HOUSE_TYPE_COMMONS?'MP':($house==HOUSE_TYPE_LORDS?'Lord':'MLA'));
1199 1270
         if (!get_http_var('rem') && isset($extra_info[$category . '_quintile'])) {
1200 1271
             $line .= ' &#8212; ';
@@ -1233,11 +1304,21 @@  discard block
 block discarded – undo
1233 1304
         $mean = $extra_info["writetothem_responsiveness_mean_$year"];
1234 1305
 
1235 1306
         $a = $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"];
1236
-        if ($a == 'very low') $a = 'a very low';
1237
-        if ($a == 'low') $a = 'a low';
1238
-        if ($a == 'medium') $a = 'a medium';
1239
-        if ($a == 'high') $a = 'a high';
1240
-        if ($a == 'very high') $a = 'a very high';
1307
+        if ($a == 'very low') {
1308
+            $a = 'a very low';
1309
+        }
1310
+        if ($a == 'low') {
1311
+            $a = 'a low';
1312
+        }
1313
+        if ($a == 'medium') {
1314
+            $a = 'a medium';
1315
+        }
1316
+        if ($a == 'high') {
1317
+            $a = 'a high';
1318
+        }
1319
+        if ($a == 'very high') {
1320
+            $a = 'a very high';
1321
+        }
1241 1322
         $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"] = $a;
1242 1323
 
1243 1324
         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.