Completed
Pull Request — master (#1323)
by Nick
84:26 queued 71:50
created
classes/Utility/Postcode.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
         if ($last_postcode == $postcode) {
41 41
             $return_value = $mp_only ? $last_postcode_value['WMC'] : $last_postcode_value;
42
-            twfy_debug ("TIME", "Postcode $postcode looked up last time, is " . ( is_array($return_value) ? implode(', ', $return_value) : $return_value ));
42
+            twfy_debug ("TIME", "postcode $postcode looked up last time, is " . ( is_array($return_value) ? implode(', ', $return_value) : $return_value ));
43 43
             return $return_value;
44 44
         }
45 45
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
         if ($last_postcode == $postcode) {
41 41
             $return_value = $mp_only ? $last_postcode_value['WMC'] : $last_postcode_value;
42
-            twfy_debug ("TIME", "Postcode $postcode looked up last time, is " . ( is_array($return_value) ? implode(', ', $return_value) : $return_value ));
42
+            twfy_debug("TIME", "Postcode $postcode looked up last time, is " . (is_array($return_value) ? implode(', ', $return_value) : $return_value));
43 43
             return $return_value;
44 44
         }
45 45
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
             $name = $q->field(0, 'name');
76 76
             if (self::postcodeIsScottish($postcode)) {
77 77
                 $name = explode('|', $name);
78
-                if (count($name)==3)
78
+                if (count($name) == 3)
79 79
                     return array('WMC' => $name[0], 'SPC' => $name[1], 'SPE' => $name[2]);
80 80
             } elseif (self::postcodeIsNi($postcode)) {
81 81
                 $name = explode('|', $name);
82
-                if (count($name)==2)
82
+                if (count($name) == 2)
83 83
                     return array('WMC' => $name[0], 'NIE' => $name[1]);
84 84
             } else {
85 85
                 return array('WMC' => $name);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
         $r = json_decode($file, true);
115 115
         if (!$r) {
116
-            trigger_error("Postcode database is not working. Content:\n".$file.", request: ". $filename, E_USER_WARNING);
116
+            trigger_error("Postcode database is not working. Content:\n" . $file . ", request: " . $filename, E_USER_WARNING);
117 117
             return '';
118 118
         }
119 119
         if (isset($r['error']) || !isset($r['areas'])) {
@@ -179,29 +179,29 @@  discard block
 block discarded – undo
179 179
         if (in_array($m[1], array('AB', 'DD', 'EH', 'FK', 'G', 'HS', 'IV', 'KA', 'KW', 'KY', 'ML', 'PA', 'PH', 'ZE')))
180 180
             return true;
181 181
 
182
-        if ($m[1]=='DG') {
183
-            if ($m[2]==16 && $m[3]==5 && in_array($m[4], array('HT','HU','HZ','JA','JB'))) return false; # A few postcodes in England
182
+        if ($m[1] == 'DG') {
183
+            if ($m[2] == 16 && $m[3] == 5 && in_array($m[4], array('HT', 'HU', 'HZ', 'JA', 'JB'))) return false; # A few postcodes in England
184 184
             return true;
185 185
         }
186 186
 
187 187
         # Damn postcodes crossing country boundaries
188
-        if ($m[1]=='TD') {
189
-            if ($m[2]!=15 && $m[2]!=12 && $m[2]!=9) return true; # TD1-8, 10-11, 13-14 all in Scotland
190
-            if ($m[2]==9) {
191
-                if ($m[3]!=0) return true; # TD9 1-9 all in Scotland
192
-                if (!in_array($m[4], array('TJ','TP','TR','TS','TT','TU','TW'))) return true; # Nearly all of TD9 0 in Scotland
188
+        if ($m[1] == 'TD') {
189
+            if ($m[2] != 15 && $m[2] != 12 && $m[2] != 9) return true; # TD1-8, 10-11, 13-14 all in Scotland
190
+            if ($m[2] == 9) {
191
+                if ($m[3] != 0) return true; # TD9 1-9 all in Scotland
192
+                if (!in_array($m[4], array('TJ', 'TP', 'TR', 'TS', 'TT', 'TU', 'TW'))) return true; # Nearly all of TD9 0 in Scotland
193 193
             }
194 194
             $m[5] = substr($m[4], 0, 1);
195
-            if ($m[2]==12) { # $m[3] will be 4 currently.
196
-                if ($m[4]=='XE') return true;
197
-                if (in_array($m[5], array('A','B','D','E','H','J','L','N','W','Y'))) return true; # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
195
+            if ($m[2] == 12) { # $m[3] will be 4 currently.
196
+                if ($m[4] == 'XE') return true;
197
+                if (in_array($m[5], array('A', 'B', 'D', 'E', 'H', 'J', 'L', 'N', 'W', 'Y'))) return true; # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
198 198
             }
199 199
             # TD15 is mostly England
200
-            if ($m[2]==15) {
201
-                if ($m[3]!=1) return false; # TD15 2 and 9 are in England
202
-                if (in_array($m[4], array('BT','SU','SZ','UF','UG','UH','UJ','UL','US','UZ','WY','WZ'))) return true;
203
-                if ($m[5]=='T' && $m[4]!='TA' && $m[4]!='TB') return true; # Most of TD15 1T* in Scotland
204
-                if ($m[5]=='X' && $m[4]!='XX') return true; # TD15 1XX in England, rest of TD15 1X* in Scotland
200
+            if ($m[2] == 15) {
201
+                if ($m[3] != 1) return false; # TD15 2 and 9 are in England
202
+                if (in_array($m[4], array('BT', 'SU', 'SZ', 'UF', 'UG', 'UH', 'UJ', 'UL', 'US', 'UZ', 'WY', 'WZ'))) return true;
203
+                if ($m[5] == 'T' && $m[4] != 'TA' && $m[4] != 'TB') return true; # Most of TD15 1T* in Scotland
204
+                if ($m[5] == 'X' && $m[4] != 'XX') return true; # TD15 1XX in England, rest of TD15 1X* in Scotland
205 205
             }
206 206
         }
207 207
 
Please login to merge, or discard this patch.
Braces   +71 added lines, -29 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
             $ret = self::postcodeFetchFromMapit($postcode);
53 53
         }
54 54
 
55
-        if (is_string($ret)) return $ret;
55
+        if (is_string($ret)) {
56
+            return $ret;
57
+        }
56 58
 
57 59
         $last_postcode = $postcode;
58 60
         $last_postcode_value = $ret;
@@ -75,13 +77,17 @@  discard block
 block discarded – undo
75 77
             $name = $q->field(0, 'name');
76 78
             if (self::postcodeIsScottish($postcode)) {
77 79
                 $name = explode('|', $name);
78
-                if (count($name)==3)
79
-                    return array('WMC' => $name[0], 'SPC' => $name[1], 'SPE' => $name[2]);
80
-            } elseif (self::postcodeIsNi($postcode)) {
80
+                if (count($name)==3) {
81
+                                    return array('WMC' => $name[0], 'SPC' => $name[1], 'SPE' => $name[2]);
82
+                }
83
+            }
84
+            elseif (self::postcodeIsNi($postcode)) {
81 85
                 $name = explode('|', $name);
82
-                if (count($name)==2)
83
-                    return array('WMC' => $name[0], 'NIE' => $name[1]);
84
-            } else {
86
+                if (count($name)==2) {
87
+                                    return array('WMC' => $name[0], 'NIE' => $name[1]);
88
+                }
89
+            }
90
+            else {
85 91
                 return array('WMC' => $name);
86 92
             }
87 93
         }
@@ -121,8 +127,9 @@  discard block
 block discarded – undo
121 127
         }
122 128
         $areas = array();
123 129
         foreach ($r['areas'] as $row) {
124
-            if (in_array($row['type'], array('WMC', 'SPC', 'SPE', 'NIE')))
125
-                $areas[$row['type']] = $row['name'];
130
+            if (in_array($row['type'], array('WMC', 'SPC', 'SPE', 'NIE'))) {
131
+                            $areas[$row['type']] = $row['name'];
132
+            }
126 133
         }
127 134
 
128 135
         if (!isset($areas['WMC'])) {
@@ -135,9 +142,11 @@  discard block
 block discarded – undo
135 142
             $areas['WMC'] = $normalised;
136 143
             if (self::postcodeIsScottish($postcode)) {
137 144
                 $serialized = "$areas[WMC]|$areas[SPC]|$areas[SPE]";
138
-            } elseif (self::postcodeIsNi($postcode)) {
145
+            }
146
+            elseif (self::postcodeIsNi($postcode)) {
139 147
                 $serialized = "$areas[WMC]|$areas[NIE]";
140
-            } else {
148
+            }
149
+            else {
141 150
                 $serialized = $normalised;
142 151
             }
143 152
             $db = new \ParlDB;
@@ -146,7 +155,8 @@  discard block
 block discarded – undo
146 155
                     ':postcode' => $postcode,
147 156
                     ':serialized' => $serialized
148 157
                 ));
149
-        } else {
158
+        }
159
+        else {
150 160
             return '';
151 161
         }
152 162
 
@@ -172,36 +182,67 @@  discard block
 block discarded – undo
172 182
      */
173 183
 
174 184
     public static function postcodeIsScottish($pc) {
175
-        if (!preg_match('#^([A-Z]{1,2})(\d+) (\d)([A-Z]{2})#', self::canonicalisePostcode($pc), $m))
176
-            return false;
185
+        if (!preg_match('#^([A-Z]{1,2})(\d+) (\d)([A-Z]{2})#', self::canonicalisePostcode($pc), $m)) {
186
+                    return false;
187
+        }
177 188
 
178 189
         # Check for Scottish postal areas
179
-        if (in_array($m[1], array('AB', 'DD', 'EH', 'FK', 'G', 'HS', 'IV', 'KA', 'KW', 'KY', 'ML', 'PA', 'PH', 'ZE')))
180
-            return true;
190
+        if (in_array($m[1], array('AB', 'DD', 'EH', 'FK', 'G', 'HS', 'IV', 'KA', 'KW', 'KY', 'ML', 'PA', 'PH', 'ZE'))) {
191
+                    return true;
192
+        }
181 193
 
182 194
         if ($m[1]=='DG') {
183
-            if ($m[2]==16 && $m[3]==5 && in_array($m[4], array('HT','HU','HZ','JA','JB'))) return false; # A few postcodes in England
195
+            if ($m[2]==16 && $m[3]==5 && in_array($m[4], array('HT','HU','HZ','JA','JB'))) {
196
+                return false;
197
+            }
198
+            # A few postcodes in England
184 199
             return true;
185 200
         }
186 201
 
187 202
         # Damn postcodes crossing country boundaries
188 203
         if ($m[1]=='TD') {
189
-            if ($m[2]!=15 && $m[2]!=12 && $m[2]!=9) return true; # TD1-8, 10-11, 13-14 all in Scotland
204
+            if ($m[2]!=15 && $m[2]!=12 && $m[2]!=9) {
205
+                return true;
206
+            }
207
+            # TD1-8, 10-11, 13-14 all in Scotland
190 208
             if ($m[2]==9) {
191
-                if ($m[3]!=0) return true; # TD9 1-9 all in Scotland
192
-                if (!in_array($m[4], array('TJ','TP','TR','TS','TT','TU','TW'))) return true; # Nearly all of TD9 0 in Scotland
209
+                if ($m[3]!=0) {
210
+                    return true;
211
+                }
212
+                # TD9 1-9 all in Scotland
213
+                if (!in_array($m[4], array('TJ','TP','TR','TS','TT','TU','TW'))) {
214
+                    return true;
215
+                }
216
+                # Nearly all of TD9 0 in Scotland
193 217
             }
194 218
             $m[5] = substr($m[4], 0, 1);
195
-            if ($m[2]==12) { # $m[3] will be 4 currently.
196
-                if ($m[4]=='XE') return true;
197
-                if (in_array($m[5], array('A','B','D','E','H','J','L','N','W','Y'))) return true; # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
219
+            if ($m[2]==12) {
220
+# $m[3] will be 4 currently.
221
+                if ($m[4]=='XE') {
222
+                    return true;
223
+                }
224
+                if (in_array($m[5], array('A','B','D','E','H','J','L','N','W','Y'))) {
225
+                    return true;
226
+                }
227
+                # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
198 228
             }
199 229
             # TD15 is mostly England
200 230
             if ($m[2]==15) {
201
-                if ($m[3]!=1) return false; # TD15 2 and 9 are in England
202
-                if (in_array($m[4], array('BT','SU','SZ','UF','UG','UH','UJ','UL','US','UZ','WY','WZ'))) return true;
203
-                if ($m[5]=='T' && $m[4]!='TA' && $m[4]!='TB') return true; # Most of TD15 1T* in Scotland
204
-                if ($m[5]=='X' && $m[4]!='XX') return true; # TD15 1XX in England, rest of TD15 1X* in Scotland
231
+                if ($m[3]!=1) {
232
+                    return false;
233
+                }
234
+                # TD15 2 and 9 are in England
235
+                if (in_array($m[4], array('BT','SU','SZ','UF','UG','UH','UJ','UL','US','UZ','WY','WZ'))) {
236
+                    return true;
237
+                }
238
+                if ($m[5]=='T' && $m[4]!='TA' && $m[4]!='TB') {
239
+                    return true;
240
+                }
241
+                # Most of TD15 1T* in Scotland
242
+                if ($m[5]=='X' && $m[4]!='XX') {
243
+                    return true;
244
+                }
245
+                # TD15 1XX in England, rest of TD15 1X* in Scotland
205 246
             }
206 247
         }
207 248
 
@@ -215,8 +256,9 @@  discard block
 block discarded – undo
215 256
 
216 257
     public static function postcodeIsNi($pc) {
217 258
         $prefix = substr(self::canonicalisePostcode($pc), 0, 2);
218
-        if ($prefix == 'BT')
219
-            return true;
259
+        if ($prefix == 'BT') {
260
+                    return true;
261
+        }
220 262
         return false;
221 263
     }
222 264
 
Please login to merge, or discard this patch.
classes/SPHomepage.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
     }
39 39
 
40 40
     protected function getCalendarData() {
41
-        return NULL;
41
+        return null;
42 42
     }
43 43
 
44 44
 
Please login to merge, or discard this patch.
classes/AlertView.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
     protected $db;
12 12
     protected $alert;
13 13
 
14
-    public function __construct($THEUSER = NULL) {
14
+    public function __construct($THEUSER = null) {
15 15
         $this->user = $THEUSER;
16 16
         $this->db = new \ParlDB;
17 17
         $this->alert = new \ALERT;
Please login to merge, or discard this patch.
classes/SectionView/PbcView.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
         } elseif ($this->session) {
66 66
             # Display the bills for a particular session
67 67
             $this_page = 'pbc_session';
68
-            $DATA->set_page_metadata($this_page, 'title', "Session $this->session");
68
+            $DATA->set_page_metadata($this_page, 'title', "session $this->session");
69 69
             $args = array (
70 70
                 'session' => $this->session,
71 71
             );
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         } elseif ($bill_id) {
48 48
             # Display the page for a particular bill
49 49
             $this_page = 'pbc_bill';
50
-            $args = array (
50
+            $args = array(
51 51
                 'id' => $bill_id,
52 52
                 'title' => $this->bill,
53 53
                 'session' => $this->session,
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             # Display the bills for a particular session
67 67
             $this_page = 'pbc_session';
68 68
             $DATA->set_page_metadata($this_page, 'title', "Session $this->session");
69
-            $args = array (
69
+            $args = array(
70 70
                 'session' => $this->session,
71 71
             );
72 72
             $data = array();
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 
89 89
     protected function getSearchSections() {
90 90
         return array(
91
-            array( 'section' => 'pbc' )
91
+            array('section' => 'pbc')
92 92
         );
93 93
     }
94 94
 
95 95
     protected function front_content() {
96
-        return $this->list->display( 'recent_pbc_debates', array( 'num' => 50 ), 'none' );
96
+        return $this->list->display('recent_pbc_debates', array('num' => 50), 'none');
97 97
     }
98 98
 
99 99
     protected function display_front() {
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,7 +44,8 @@  discard block
 block discarded – undo
44 44
             return $this->display_section_or_speech(array(
45 45
                 'gid' => $standingprefix . $id,
46 46
             ));
47
-        } elseif ($bill_id) {
47
+        }
48
+        elseif ($bill_id) {
48 49
             # Display the page for a particular bill
49 50
             $this_page = 'pbc_bill';
50 51
             $args = array (
@@ -57,12 +58,14 @@  discard block
 block discarded – undo
57 58
             $data['session'] = $this->session;
58 59
             $data['template'] = 'section/pbc_bill';
59 60
             return $this->addCommonData($data);
60
-        } elseif ($this->session && $this->bill) {
61
+        }
62
+        elseif ($this->session && $this->bill) {
61 63
             # Illegal bill title, redirect to session page
62 64
             $URL = new \URL('pbc_session');
63 65
             header('Location: ' . $URL->generate() . urlencode($this->session));
64 66
             exit;
65
-        } elseif ($this->session) {
67
+        }
68
+        elseif ($this->session) {
66 69
             # Display the bills for a particular session
67 70
             $this_page = 'pbc_session';
68 71
             $DATA->set_page_metadata($this_page, 'title', "Session $this->session");
@@ -74,7 +77,8 @@  discard block
 block discarded – undo
74 77
             $data['template'] = 'section/pbc_session';
75 78
             $data['session'] = $this->session;
76 79
             return $this->addCommonData($data);
77
-        } else {
80
+        }
81
+        else {
78 82
             return $this->display_front();
79 83
         }
80 84
     }
Please login to merge, or discard this patch.
classes/SectionView/SpwransView.php 3 patches
Upper-Lower-Casing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
         }
82 82
         $result = '';
83 83
         $nrows = count($row_data);
84
-        $last_date = NULL;
85
-        $first_difference_output = TRUE;
84
+        $last_date = null;
85
+        $first_difference_output = true;
86 86
         // Keep the references until after the history that's in a timeline:
87 87
         $references = array();
88 88
         for( $i = 0; $i < $nrows; $i++ ) {
89 89
             $row = $row_data[$i];
90 90
             if( ! $row["date"] ) {
91 91
                 // If this mention isn't associated with a date, the difference won't be interesting.
92
-                $last_date = NULL;
92
+                $last_date = null;
93 93
             }
94 94
             $description = '';
95 95
             if ($last_date && ($last_date != $row["date"])) {
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
                 $daysstring = ($daysdiff == 1) ? "day" : "days";
99 99
                 $further = "";
100 100
                 if( $first_difference_output ) {
101
-                    $first_difference_output = FALSE;
101
+                    $first_difference_output = false;
102 102
                 } else {
103 103
                     $further = " a further";
104 104
                 }
105 105
                 $description = "\n<span class=\"question-mention-gap\">After$further $daysdiff $daysstring,</span> ";
106 106
             }
107
-            $reference = FALSE;
107
+            $reference = false;
108 108
             $inner = "BUG: Unknown mention type $row[type]";
109 109
             $date = format_date($row['date'], SHORTDATEFORMAT);
110 110
             $url = $row['url'];
111
-            if ( strpos($url, 'business/businessBulletin') !== FALSE ) {
111
+            if ( strpos($url, 'business/businessBulletin') !== false ) {
112 112
                 $url = str_replace('www.scottish', 'archive.scottish', $url);
113 113
             }
114 114
             switch ($row["type"]) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                         $URL->insert( array('spid' => $referencing_spid) );
148 148
                         $relative_url = $URL->generate("none");
149 149
                         $inner = "Referenced in <a href=\"$relative_url\">question $referencing_spid</a>";
150
-                        $reference = TRUE;
150
+                        $reference = true;
151 151
                     }
152 152
                     break;
153 153
             }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
         $this_page = 'spwransfront';
22 22
         $data = array();
23 23
 
24
-        $args = array( 'months' => 1 );
24
+        $args = array('months' => 1);
25 25
         $WRANSLIST = new \SPWRANSLIST;
26 26
 
27 27
         $wrans = array();
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
     protected function getSearchSections() {
45 45
         return array(
46
-            array( 'section' => 'spwrans' )
46
+            array('section' => 'spwrans')
47 47
         );
48 48
     }
49 49
 
@@ -54,29 +54,29 @@  discard block
 block discarded – undo
54 54
         $SPWRANSLIST = new \SPWRANSLIST;
55 55
         $gid = $SPWRANSLIST->get_gid_from_spid($spid);
56 56
         if ($gid) {
57
-            if (preg_match('/uk\.org\.publicwhip\/spwa\/(\d{4}-\d\d-\d\d\.(.*))/',$gid,$m)) {
57
+            if (preg_match('/uk\.org\.publicwhip\/spwa\/(\d{4}-\d\d-\d\d\.(.*))/', $gid, $m)) {
58 58
                 $URL = new \URL('spwrans');
59 59
                 $URL->reset();
60
-                $URL->insert( array('id' => $m[1]) );
60
+                $URL->insert(array('id' => $m[1]));
61 61
                 $fragment_identifier = '#g' . $m[2];
62 62
                 header('Location: ' . $URL->generate('none') . $fragment_identifier, true, 303);
63 63
                 exit;
64
-            } elseif (preg_match('/uk\.org\.publicwhip\/spor\/(\d{4}-\d\d-\d\d\.(.*))/',$gid,$m)) {
64
+            } elseif (preg_match('/uk\.org\.publicwhip\/spor\/(\d{4}-\d\d-\d\d\.(.*))/', $gid, $m)) {
65 65
                 $URL = new \URL('spdebates');
66 66
                 $URL->reset();
67
-                $URL->insert( array('id' => $m[1]) );
67
+                $URL->insert(array('id' => $m[1]));
68 68
                 $fragment_identifier = '#g' . $m[2];
69 69
                 header('Location: ' . $URL->generate('none') . $fragment_identifier, true, 303);
70 70
                 exit;
71 71
             } else {
72
-                $PAGE->error_message ("Strange GID ($gid) for that Scottish Parliament ID.");
72
+                $PAGE->error_message("Strange GID ($gid) for that Scottish Parliament ID.");
73 73
             }
74 74
         }
75
-        $PAGE->error_message ("Couldn't match that Scottish Parliament ID to a GID.");
75
+        $PAGE->error_message("Couldn't match that Scottish Parliament ID to a GID.");
76 76
     }
77 77
 
78 78
     protected function get_question_mentions_html($row_data) {
79
-        if( count($row_data) == 0 ) {
79
+        if (count($row_data) == 0) {
80 80
             return '';
81 81
         }
82 82
         $result = '';
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
         $first_difference_output = TRUE;
86 86
         // Keep the references until after the history that's in a timeline:
87 87
         $references = array();
88
-        for( $i = 0; $i < $nrows; $i++ ) {
88
+        for ($i = 0; $i < $nrows; $i++) {
89 89
             $row = $row_data[$i];
90
-            if( ! $row["date"] ) {
90
+            if (!$row["date"]) {
91 91
                 // If this mention isn't associated with a date, the difference won't be interesting.
92 92
                 $last_date = NULL;
93 93
             }
94 94
             $description = '';
95 95
             if ($last_date && ($last_date != $row["date"])) {
96 96
                 // Calculate how long the gap was in days:
97
-                $daysdiff = (integer)((strtotime($row["date"]) - strtotime($last_date)) / 86400);
97
+                $daysdiff = (integer) ((strtotime($row["date"]) - strtotime($last_date)) / 86400);
98 98
                 $daysstring = ($daysdiff == 1) ? "day" : "days";
99 99
                 $further = "";
100
-                if( $first_difference_output ) {
100
+                if ($first_difference_output) {
101 101
                     $first_difference_output = FALSE;
102 102
                 } else {
103 103
                     $further = " a further";
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             $inner = "BUG: Unknown mention type $row[type]";
109 109
             $date = format_date($row['date'], SHORTDATEFORMAT);
110 110
             $url = $row['url'];
111
-            if ( strpos($url, 'business/businessBulletin') !== FALSE ) {
111
+            if (strpos($url, 'business/businessBulletin') !== FALSE) {
112 112
                 $url = str_replace('www.scottish', 'archive.scottish', $url);
113 113
             }
114 114
             switch ($row["type"]) {
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
                     $inner = "Mentioned in <a class=\"debate-speech__meta__link\" href=\"$url\">tabled written questions on $date</a>";
123 123
                     break;
124 124
                 case 4:
125
-                    if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['gid'],$m) ) {
125
+                    if (preg_match('/^uk.org.publicwhip\/spq\/(.*)$/', $row['gid'], $m)) {
126 126
                         $URL = new \URL("spwrans");
127
-                        $URL->insert( array('spid' => $m[1]) );
127
+                        $URL->insert(array('spid' => $m[1]));
128 128
                         $relative_url = $URL->generate("none");
129 129
                         $inner = "Given a <a class=\"debate-speech__meta__link\" href=\"$relative_url\">written answer on $date</a>";
130 130
                     }
@@ -133,25 +133,25 @@  discard block
 block discarded – undo
133 133
                     $inner = "Given a holding answer on $date";
134 134
                     break;
135 135
                 case 6:
136
-                    if( preg_match('/^uk.org.publicwhip\/spor\/(.*)$/',$row['mentioned_gid'],$m) ) {
136
+                    if (preg_match('/^uk.org.publicwhip\/spor\/(.*)$/', $row['mentioned_gid'], $m)) {
137 137
                         $URL = new \URL("spdebates");
138
-                        $URL->insert( array('id' => $m[1]) );
138
+                        $URL->insert(array('id' => $m[1]));
139 139
                         $relative_url = $URL->generate("none");
140 140
                         $inner = "<a href=\"$relative_url\">Asked in parliament on $date</a>";
141 141
                     }
142 142
                     break;
143 143
                 case 7:
144
-                    if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['mentioned_gid'],$m) ) {
144
+                    if (preg_match('/^uk.org.publicwhip\/spq\/(.*)$/', $row['mentioned_gid'], $m)) {
145 145
                         $referencing_spid = $m[1];
146 146
                         $URL = new \URL("spwrans");
147
-                        $URL->insert( array('spid' => $referencing_spid) );
147
+                        $URL->insert(array('spid' => $referencing_spid));
148 148
                         $relative_url = $URL->generate("none");
149 149
                         $inner = "Referenced in <a href=\"$relative_url\">question $referencing_spid</a>";
150 150
                         $reference = TRUE;
151 151
                     }
152 152
                     break;
153 153
             }
154
-            if( $reference ) {
154
+            if ($reference) {
155 155
                 $references[] = "\n<li>$inner.";
156 156
             } else {
157 157
                 $result .= "\n<li class=\"link-to-hansard\">$description$inner</span>";
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,7 +11,8 @@  discard block
 block discarded – undo
11 11
         if ($spid = get_http_var('spid')) {
12 12
             $this->spwrans_redirect($spid);
13 13
             $PAGE->page_end();
14
-        } else {
14
+        }
15
+        else {
15 16
             return parent::display();
16 17
         }
17 18
     }
@@ -61,14 +62,16 @@  discard block
 block discarded – undo
61 62
                 $fragment_identifier = '#g' . $m[2];
62 63
                 header('Location: ' . $URL->generate('none') . $fragment_identifier, true, 303);
63 64
                 exit;
64
-            } elseif (preg_match('/uk\.org\.publicwhip\/spor\/(\d{4}-\d\d-\d\d\.(.*))/',$gid,$m)) {
65
+            }
66
+            elseif (preg_match('/uk\.org\.publicwhip\/spor\/(\d{4}-\d\d-\d\d\.(.*))/',$gid,$m)) {
65 67
                 $URL = new \URL('spdebates');
66 68
                 $URL->reset();
67 69
                 $URL->insert( array('id' => $m[1]) );
68 70
                 $fragment_identifier = '#g' . $m[2];
69 71
                 header('Location: ' . $URL->generate('none') . $fragment_identifier, true, 303);
70 72
                 exit;
71
-            } else {
73
+            }
74
+            else {
72 75
                 $PAGE->error_message ("Strange GID ($gid) for that Scottish Parliament ID.");
73 76
             }
74 77
         }
@@ -99,7 +102,8 @@  discard block
 block discarded – undo
99 102
                 $further = "";
100 103
                 if( $first_difference_output ) {
101 104
                     $first_difference_output = FALSE;
102
-                } else {
105
+                }
106
+                else {
103 107
                     $further = " a further";
104 108
                 }
105 109
                 $description = "\n<span class=\"question-mention-gap\">After$further $daysdiff $daysstring,</span> ";
@@ -153,7 +157,8 @@  discard block
 block discarded – undo
153 157
             }
154 158
             if( $reference ) {
155 159
                 $references[] = "\n<li>$inner.";
156
-            } else {
160
+            }
161
+            else {
157 162
                 $result .= "\n<li class=\"link-to-hansard\">$description$inner</span>";
158 163
                 $last_date = $row["date"];
159 164
             }
Please login to merge, or discard this patch.
classes/AlertView/Simple.php 3 patches
Upper-Lower-Casing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             $data['postcode'] = $this->user->postcode_is_set() ? $this->user->postcode() : '';
33 33
 
34 34
             if ( $this->isEmailSignedUpForPostCode( $data['email'], $data['postcode'] ) ) {
35
-                $data['already_signed_up'] = True;
35
+                $data['already_signed_up'] = true;
36 36
                 $mp = $this->getPersonFromPostcode($data['postcode']);
37 37
                 $data['mp_name'] = $mp->full_name();
38 38
             }
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 
68 68
     private function createAlertForPostCode($email, $postcode) {
69 69
         if ( !$this->validateDetails($email, $postcode) ) {
70
-            return array('invalid-postcode-or-email' => True);
70
+            return array('invalid-postcode-or-email' => true);
71 71
         }
72 72
 
73 73
         try {
74 74
             $person = $this->getPersonFromPostcode($postcode);
75 75
         } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
76
-            return array('bad-constituency' => True);
76
+            return array('bad-constituency' => true);
77 77
         }
78 78
 
79 79
         $details = array(
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
                     // no logged in user so send them an email to let them
94 94
                     // know someone tried to create an alert
95 95
                     $this->alert->send_already_signedup_email($details);
96
-                    $data['confirmation_sent'] = True;
96
+                    $data['confirmation_sent'] = true;
97 97
                 } else {
98
-                    $data['already_signed_up'] = True;
98
+                    $data['already_signed_up'] = true;
99 99
                 }
100 100
                 break;
101 101
             case self::CREATE_FAILED:
102
-                $data['error'] = True;
102
+                $data['error'] = true;
103 103
                 break;
104 104
             default: // alert created
105 105
                 if ( $not_logged_in ) {
106
-                    $data['confirmation_sent'] = True;
106
+                    $data['confirmation_sent'] = true;
107 107
                 } else {
108
-                    $data['signedup_no_confirm'] = True;
108
+                    $data['signedup_no_confirm'] = true;
109 109
                 }
110 110
         }
111 111
 
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
             }
147 147
 
148 148
             $this->alert->delete($q->field($i, 'alert_id') . '::' . $q->field($i ,'registrationtoken'));
149
-            $this->alert->add($details, False);
149
+            $this->alert->add($details, false);
150 150
         }
151 151
 
152 152
         return array(
153
-            'signedup_no_confirm' => True,
153
+            'signedup_no_confirm' => true,
154 154
             'new_mp' => $new_mp->full_name(),
155 155
         );
156 156
     }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
         if ( $this->alert->fetch_by_mp( $existing['email'], $new_mp->person_id) ) {
185 185
             $data = array(
186
-                'already_signed_up' => True,
186
+                'already_signed_up' => true,
187 187
                 'old_mp' => $old_mp->full_name(),
188 188
                 'mp_name' => $new_mp->full_name(),
189 189
             );
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
             );
195 195
         }
196 196
 
197
-        $data['update'] = True;
197
+        $data['update'] = true;
198 198
         $data['confirmation'] = $confirmation;
199 199
 
200 200
         return $data;
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
     public function display() {
8 8
         $data = array();
9 9
         $data['recent_election'] = false;
10
-        if ( $this->user->loggedin() ) {
10
+        if ($this->user->loggedin()) {
11 11
             $data['user_signed_in'] = true;
12 12
         }
13 13
 
@@ -17,21 +17,21 @@  discard block
 block discarded – undo
17 17
             $data['postcode'] = get_http_var('postcode');
18 18
 
19 19
             $result = $this->createAlertForPostCode($data['email'], $data['postcode']);
20
-            $data = array_merge( $data, $result );
20
+            $data = array_merge($data, $result);
21 21
         } elseif (get_http_var('update')) {
22 22
             $result = $this->getNewMP(get_http_var('update'));
23
-            $data = array_merge( $data, $result );
23
+            $data = array_merge($data, $result);
24 24
         } elseif (get_http_var('update-alert')) {
25
-            $success = $this->replaceAlert( get_http_var('confirmation') );
25
+            $success = $this->replaceAlert(get_http_var('confirmation'));
26 26
             $data['confirmation_received'] = $success;
27 27
         } elseif (get_http_var('confirmed')) {
28
-            $success = $this->confirmAlert( get_http_var('confirmed') );
28
+            $success = $this->confirmAlert(get_http_var('confirmed'));
29 29
             $data['confirmation_received'] = $success;
30 30
         } else {
31 31
             $data['email'] = $this->user->email() ? $this->user->email() : '';
32 32
             $data['postcode'] = $this->user->postcode_is_set() ? $this->user->postcode() : '';
33 33
 
34
-            if ( $this->isEmailSignedUpForPostCode( $data['email'], $data['postcode'] ) ) {
34
+            if ($this->isEmailSignedUpForPostCode($data['email'], $data['postcode'])) {
35 35
                 $data['already_signed_up'] = True;
36 36
                 $mp = $this->getPersonFromPostcode($data['postcode']);
37 37
                 $data['mp_name'] = $mp->full_name();
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
     }
67 67
 
68 68
     private function createAlertForPostCode($email, $postcode) {
69
-        if ( !$this->validateDetails($email, $postcode) ) {
69
+        if (!$this->validateDetails($email, $postcode)) {
70 70
             return array('invalid-postcode-or-email' => True);
71 71
         }
72 72
 
73 73
         try {
74 74
             $person = $this->getPersonFromPostcode($postcode);
75
-        } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
75
+        } catch (\MySociety\TheyWorkForYou\MemberException $e) {
76 76
             return array('bad-constituency' => True);
77 77
         }
78 78
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         switch ($result) {
91 91
             case self::ALERT_EXISTS:
92
-                if ( $not_logged_in ) {
92
+                if ($not_logged_in) {
93 93
                     // no logged in user so send them an email to let them
94 94
                     // know someone tried to create an alert
95 95
                     $this->alert->send_already_signedup_email($details);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 $data['error'] = True;
103 103
                 break;
104 104
             default: // alert created
105
-                if ( $not_logged_in ) {
105
+                if ($not_logged_in) {
106 106
                     $data['confirmation_sent'] = True;
107 107
                 } else {
108 108
                     $data['signedup_no_confirm'] = True;
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
         $existing = $this->alert->fetch_by_token($confirmation);
117 117
         preg_match('/speaker:(\d+)/', $existing['criteria'], $matches);
118 118
         $old_mp_id = $matches[1];
119
-        $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $old_mp_id ) );
120
-        $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 ));
119
+        $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $old_mp_id));
120
+        $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1));
121 121
 
122 122
         $q = $this->db->query(
123 123
             "SELECT alert_id, criteria, registrationtoken FROM alerts
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             )
132 132
         );
133 133
 
134
-        for ( $i = 0; $i < $q->rows; $i++ ) {
134
+        for ($i = 0; $i < $q->rows; $i++) {
135 135
             // need to reset this otherwise delete does not work
136 136
             $this->alert->token_checked = null;
137 137
             $other_criteria = trim(preg_replace('/speaker:\d+/', '', $q->field($i, 'criteria')));
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
                 'pid' => $new_mp->person_id,
142 142
                 'pc' => '',
143 143
             );
144
-            if ( $other_criteria ) {
144
+            if ($other_criteria) {
145 145
                 $details['keyword'] = $other_criteria;
146 146
             }
147 147
 
148
-            $this->alert->delete($q->field($i, 'alert_id') . '::' . $q->field($i ,'registrationtoken'));
148
+            $this->alert->delete($q->field($i, 'alert_id') . '::' . $q->field($i, 'registrationtoken'));
149 149
             $this->alert->add($details, False);
150 150
         }
151 151
 
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
     private function isEmailSignedUpForPostCode($email, $postcode) {
159 159
         $is_signed_up = false;
160 160
 
161
-        if ( $email && $postcode ) {
161
+        if ($email && $postcode) {
162 162
             try {
163 163
                 $person = $this->getPersonFromPostcode($postcode);
164 164
                 $is_signed_up = $this->alert->fetch_by_mp($email, $person->person_id);
165
-            } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
165
+            } catch (\MySociety\TheyWorkForYou\MemberException $e) {
166 166
                 $is_signed_up = false;
167 167
             }
168 168
         }
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
         preg_match('/speaker:(\d+)/', $existing['criteria'], $matches);
179 179
         $criteria = $matches[1];
180 180
 
181
-        $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $criteria ) );
182
-        $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 ));
181
+        $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $criteria));
182
+        $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1));
183 183
 
184
-        if ( $this->alert->fetch_by_mp( $existing['email'], $new_mp->person_id) ) {
184
+        if ($this->alert->fetch_by_mp($existing['email'], $new_mp->person_id)) {
185 185
             $data = array(
186 186
                 'already_signed_up' => True,
187 187
                 'old_mp' => $old_mp->full_name(),
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,16 +18,20 @@  discard block
 block discarded – undo
18 18
 
19 19
             $result = $this->createAlertForPostCode($data['email'], $data['postcode']);
20 20
             $data = array_merge( $data, $result );
21
-        } elseif (get_http_var('update')) {
21
+        }
22
+        elseif (get_http_var('update')) {
22 23
             $result = $this->getNewMP(get_http_var('update'));
23 24
             $data = array_merge( $data, $result );
24
-        } elseif (get_http_var('update-alert')) {
25
+        }
26
+        elseif (get_http_var('update-alert')) {
25 27
             $success = $this->replaceAlert( get_http_var('confirmation') );
26 28
             $data['confirmation_received'] = $success;
27
-        } elseif (get_http_var('confirmed')) {
29
+        }
30
+        elseif (get_http_var('confirmed')) {
28 31
             $success = $this->confirmAlert( get_http_var('confirmed') );
29 32
             $data['confirmation_received'] = $success;
30
-        } else {
33
+        }
34
+        else {
31 35
             $data['email'] = $this->user->email() ? $this->user->email() : '';
32 36
             $data['postcode'] = $this->user->postcode_is_set() ? $this->user->postcode() : '';
33 37
 
@@ -94,7 +98,8 @@  discard block
 block discarded – undo
94 98
                     // know someone tried to create an alert
95 99
                     $this->alert->send_already_signedup_email($details);
96 100
                     $data['confirmation_sent'] = True;
97
-                } else {
101
+                }
102
+                else {
98 103
                     $data['already_signed_up'] = True;
99 104
                 }
100 105
                 break;
@@ -104,7 +109,8 @@  discard block
 block discarded – undo
104 109
             default: // alert created
105 110
                 if ( $not_logged_in ) {
106 111
                     $data['confirmation_sent'] = True;
107
-                } else {
112
+                }
113
+                else {
108 114
                     $data['signedup_no_confirm'] = True;
109 115
                 }
110 116
         }
@@ -187,7 +193,8 @@  discard block
 block discarded – undo
187 193
                 'old_mp' => $old_mp->full_name(),
188 194
                 'mp_name' => $new_mp->full_name(),
189 195
             );
190
-        } else {
196
+        }
197
+        else {
191 198
             $data = array(
192 199
                 'old_mp' => $old_mp->full_name(),
193 200
                 'new_mp' => $new_mp->full_name(),
Please login to merge, or discard this patch.
classes/AlertView/Standard.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 class Standard extends \MySociety\TheyWorkForYou\AlertView {
13 13
     public $data;
14 14
 
15
-    public function __construct($THEUSER = NULL) {
15
+    public function __construct($THEUSER = null) {
16 16
         parent::__construct($THEUSER);
17 17
         $this->data = array();
18 18
     }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                 try {
180 180
                     $MEMBER = new \MEMBER(array('constituency'=>$constituency, 'house' => 1));
181 181
                     $cons[$constituency] = $MEMBER;
182
-                } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
182
+                } catch (\MySociety\TheyWorkForYou\MemberException $e) {
183 183
                     // do nothing
184 184
                 }
185 185
             }
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 
200 200
         // If this goes well, the alert will be added to the database and a confirmation email
201 201
         // will be sent to them.
202
-        $success = $this->alert->add( $this->data, $confirm );
202
+        $success = $this->alert->add($this->data, $confirm);
203 203
 
204
-        if ($success>0 && !$confirm) {
204
+        if ($success > 0 && !$confirm) {
205 205
             $result = 'alert-added';
206
-        } elseif ($success>0) {
206
+        } elseif ($success > 0) {
207 207
             $result = 'alert-confirmation';
208 208
         } elseif ($success == -2) {
209 209
             // we need to make sure we know that the person attempting to sign up
210 210
             // for the alert has that email address to stop people trying to work
211 211
             // out what alerts they are signed up to
212
-            if ( $this->data['email_verified'] || ( $this->user->loggedin && $this->user->email() == $this->data['email'] ) ) {
212
+            if ($this->data['email_verified'] || ($this->user->loggedin && $this->user->email() == $this->data['email'])) {
213 213
                 $result = 'alert-exists';
214 214
             } else {
215 215
                 // don't throw an error message as that implies that they have already signed
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 
235 235
 
236 236
     private function formatSearchTerms() {
237
-        if ( $this->data['alertsearch'] ) {
237
+        if ($this->data['alertsearch']) {
238 238
             $this->data['alertsearch_pretty'] = $this->prettifyCriteria($this->data['alertsearch']);
239 239
             $this->data['search_text'] = $this->data['alertsearch'];
240 240
         } else {
@@ -244,21 +244,21 @@  discard block
 block discarded – undo
244 244
 
245 245
     private function prettifyCriteria($alert_criteria) {
246 246
         $text = '';
247
-        if ( $alert_criteria ) {
247
+        if ($alert_criteria) {
248 248
             $criteria = explode(' ', $alert_criteria);
249 249
             $words = array();
250 250
             $spokenby = array_values(\MySociety\TheyWorkForYou\Utility\Search::speakerNamesForIDs($alert_criteria));
251 251
 
252 252
             foreach ($criteria as $c) {
253
-                if (!preg_match('#^speaker:(\d+)#',$c,$m)) {
253
+                if (!preg_match('#^speaker:(\d+)#', $c, $m)) {
254 254
                     $words[] = $c;
255 255
                 }
256 256
             }
257
-            if ( $spokenby && count($words) ) {
257
+            if ($spokenby && count($words)) {
258 258
                 $text = implode(' or ', $spokenby) . ' mentions [' . implode(' ', $words) . ']';
259
-            } else if ( count( $words ) ) {
259
+            } else if (count($words)) {
260 260
                 $text = '[' . implode(' ', $words) . ']' . ' is mentioned';
261
-            } else if ( $spokenby ) {
261
+            } else if ($spokenby) {
262 262
                 $text = implode(' or ', $spokenby) . " speaks";
263 263
             }
264 264
 
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
     }
294 294
 
295 295
     private function formatSearchMemberData() {
296
-        if ( isset($this->data['postcode']) ) {
296
+        if (isset($this->data['postcode'])) {
297 297
             try {
298 298
                 $postcode = $this->data['postcode'];
299 299
 
300
-                $MEMBER = new \MEMBER( array('postcode' => $postcode) );
300
+                $MEMBER = new \MEMBER(array('postcode' => $postcode));
301 301
                 // move the postcode to the front just to be tidy
302 302
                 $tidy_alertsearch = $postcode . " " . trim(str_replace("$postcode", "", $this->data['alertsearch']));
303 303
                 $alertsearch_display = str_replace("$postcode ", "", $tidy_alertsearch);
@@ -306,25 +306,25 @@  discard block
 block discarded – undo
306 306
                 $this->data['member_displaysearch'] = $alertsearch_display;
307 307
                 $this->data['member'] = $MEMBER;
308 308
 
309
-                if ( $this->data['scottish_text'] ) {
309
+                if ($this->data['scottish_text']) {
310 310
                     $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($postcode);
311
-                    if ( isset($constituencies['SPC']) ) {
311
+                    if (isset($constituencies['SPC'])) {
312 312
                         $MEMBER = new \MEMBER(array('constituency' => $constituencies['SPC'], 'house' => 4));
313 313
                         $this->data['scottish_alertsearch'] = str_replace("$postcode", "speaker:" . $MEMBER->person_id, $tidy_alertsearch);
314 314
                         $this->data['scottish_member'] = $MEMBER;
315 315
                     }
316 316
                 }
317
-            } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
317
+            } catch (\MySociety\TheyWorkForYou\MemberException $e) {
318 318
                 $this->data['member_error'] = 1;
319 319
             }
320 320
         }
321 321
 
322
-        if ( $this->data['pid'] ) {
323
-            $MEMBER = new \MEMBER( array('person_id' => $this->data['pid']) );
322
+        if ($this->data['pid']) {
323
+            $MEMBER = new \MEMBER(array('person_id' => $this->data['pid']));
324 324
             $this->data['pid_member'] = $MEMBER;
325 325
         }
326 326
 
327
-        if ( $this->data['keyword'] ) {
327
+        if ($this->data['keyword']) {
328 328
             $this->data['display_keyword'] = $this->prettifyCriteria($this->data['keyword']);
329 329
         }
330 330
     }
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
             $token = $row['alert_id'] . '-' . $row['registrationtoken'];
358 358
 
359 359
             $status = 'confirmed';
360
-            if ( !$row['confirmed'] ) {
360
+            if (!$row['confirmed']) {
361 361
                 $status = 'unconfirmed';
362
-            } elseif ( $row['deleted'] == 2 ) {
362
+            } elseif ($row['deleted'] == 2) {
363 363
                 $status = 'suspended';
364 364
             }
365 365
 
Please login to merge, or discard this patch.
Braces   +35 added lines, -17 removed lines patch added patch discarded remove patch
@@ -51,17 +51,20 @@  discard block
 block discarded – undo
51 51
                     $this->data['results'] = 'alert-confirmed';
52 52
                     $this->data['criteria'] = $this->prettifyCriteria($this->alert->criteria);
53 53
                 }
54
-            } elseif ($action == 'Suspend') {
54
+            }
55
+            elseif ($action == 'Suspend') {
55 56
                 $success = $this->suspendAlert($token);
56 57
                 if ($success) {
57 58
                     $this->data['results'] = 'alert-suspended';
58 59
                 }
59
-            } elseif ($action == 'Resume') {
60
+            }
61
+            elseif ($action == 'Resume') {
60 62
                 $success = $this->resumeAlert($token);
61 63
                 if ($success) {
62 64
                     $this->data['results'] = 'alert-resumed';
63 65
                 }
64
-            } elseif ($action == 'Delete') {
66
+            }
67
+            elseif ($action == 'Delete') {
65 68
                 $success = $this->deleteAlert($token);
66 69
                 if ($success) {
67 70
                     $this->data['results'] = 'alert-deleted';
@@ -82,10 +85,12 @@  discard block
 block discarded – undo
82 85
         if ($this->user->loggedin()) {
83 86
             $this->data['email'] = $this->user->email();
84 87
             $this->data['email_verified'] = true;
85
-        } elseif ($this->data['alert']) {
88
+        }
89
+        elseif ($this->data['alert']) {
86 90
             $this->data['email'] = $this->data['alert']['email'];
87 91
             $this->data['email_verified'] = true;
88
-        } else {
92
+        }
93
+        else {
89 94
             $this->data["email"] = trim(get_http_var("email"));
90 95
             $this->data['email_verified'] = false;
91 96
         }
@@ -117,7 +122,8 @@  discard block
 block discarded – undo
117 122
         // Check email address is valid and unique.
118 123
         if (!$this->data['email']) {
119 124
             $errors["email"] = "Please enter your email address";
120
-        } elseif (!validate_email($this->data["email"])) {
125
+        }
126
+        elseif (!validate_email($this->data["email"])) {
121 127
             // validate_email() is in includes/utilities.php
122 128
             $errors["email"] = "Please enter a valid email address";
123 129
         }
@@ -127,7 +133,9 @@  discard block
 block discarded – undo
127 133
         }
128 134
 
129 135
         $text = $this->data['alertsearch'];
130
-        if (!$text) $text = $this->data['keyword'];
136
+        if (!$text) {
137
+            $text = $this->data['keyword'];
138
+        }
131 139
 
132 140
         if ($this->data['submitted'] && !$this->data['pid'] && !$text) {
133 141
             $errors['alertsearch'] = 'Please enter what you want to be alerted about';
@@ -191,9 +199,11 @@  discard block
 block discarded – undo
191 199
         $external_auth = auth_verify_with_shared_secret($this->data['email'], OPTION_AUTH_SHARED_SECRET, get_http_var('sign'));
192 200
         if ($external_auth) {
193 201
             $confirm = false;
194
-        } elseif ($this->data['email_verified']) {
202
+        }
203
+        elseif ($this->data['email_verified']) {
195 204
             $confirm = false;
196
-        } else {
205
+        }
206
+        else {
197 207
             $confirm = true;
198 208
         }
199 209
 
@@ -203,22 +213,26 @@  discard block
 block discarded – undo
203 213
 
204 214
         if ($success>0 && !$confirm) {
205 215
             $result = 'alert-added';
206
-        } elseif ($success>0) {
216
+        }
217
+        elseif ($success>0) {
207 218
             $result = 'alert-confirmation';
208
-        } elseif ($success == -2) {
219
+        }
220
+        elseif ($success == -2) {
209 221
             // we need to make sure we know that the person attempting to sign up
210 222
             // for the alert has that email address to stop people trying to work
211 223
             // out what alerts they are signed up to
212 224
             if ( $this->data['email_verified'] || ( $this->user->loggedin && $this->user->email() == $this->data['email'] ) ) {
213 225
                 $result = 'alert-exists';
214
-            } else {
226
+            }
227
+            else {
215 228
                 // don't throw an error message as that implies that they have already signed
216 229
                 // up for the alert but instead pretend all is normal but send an email saying
217 230
                 // that someone tried to sign them up for an existing alert
218 231
                 $result = 'alert-already-signed';
219 232
                 $this->alert->send_already_signedup_email($this->data);
220 233
             }
221
-        } else {
234
+        }
235
+        else {
222 236
             $result = 'alert-fail';
223 237
         }
224 238
 
@@ -237,7 +251,8 @@  discard block
 block discarded – undo
237 251
         if ( $this->data['alertsearch'] ) {
238 252
             $this->data['alertsearch_pretty'] = $this->prettifyCriteria($this->data['alertsearch']);
239 253
             $this->data['search_text'] = $this->data['alertsearch'];
240
-        } else {
254
+        }
255
+        else {
241 256
             $this->data['search_text'] = $this->data['keyword'];
242 257
         }
243 258
     }
@@ -256,9 +271,11 @@  discard block
 block discarded – undo
256 271
             }
257 272
             if ( $spokenby && count($words) ) {
258 273
                 $text = implode(' or ', $spokenby) . ' mentions [' . implode(' ', $words) . ']';
259
-            } else if ( count( $words ) ) {
274
+            }
275
+            else if ( count( $words ) ) {
260 276
                 $text = '[' . implode(' ', $words) . ']' . ' is mentioned';
261
-            } else if ( $spokenby ) {
277
+            }
278
+            else if ( $spokenby ) {
262 279
                 $text = implode(' or ', $spokenby) . " speaks";
263 280
             }
264 281
 
@@ -359,7 +376,8 @@  discard block
 block discarded – undo
359 376
             $status = 'confirmed';
360 377
             if ( !$row['confirmed'] ) {
361 378
                 $status = 'unconfirmed';
362
-            } elseif ( $row['deleted'] == 2 ) {
379
+            }
380
+            elseif ( $row['deleted'] == 2 ) {
363 381
                 $status = 'suspended';
364 382
             }
365 383
 
Please login to merge, or discard this patch.
www/includes/easyparliament/init.php 3 patches
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 include_once (INCLUDESPATH."data.php");
80 80
 include_once (INCLUDESPATH."mysql.php");
81 81
 
82
-Class ParlDB extends MySQL {
82
+class ParlDB extends MySQL {
83 83
     public function __construct() {
84 84
         $this->init (OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME);
85 85
     }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 include_once (INCLUDESPATH."easyparliament/user.php");
91 91
 
92 92
 // Test to see if this is a new-style template using the renderer class.
93
-if (! isset($new_style_template) OR $new_style_template !== TRUE) {
93
+if (! isset($new_style_template) or $new_style_template !== true) {
94 94
 
95 95
     // This is an old-style page. Use the old page classes.
96 96
     include_once (INCLUDESPATH."easyparliament/page.php");
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,7 +41,9 @@  discard block
 block discarded – undo
41 41
 twfy_debug_timestamp("after including utility.php");
42 42
 
43 43
 // Set the default timezone
44
-if(function_exists('date_default_timezone_set')) date_default_timezone_set(TIMEZONE);
44
+if(function_exists('date_default_timezone_set')) {
45
+    date_default_timezone_set(TIMEZONE);
46
+}
45 47
 
46 48
 // Only do clever things with errors if we're not testing, otherwise show as default
47 49
 
@@ -51,7 +53,8 @@  discard block
 block discarded – undo
51 53
     $error_level = E_ALL & ~E_NOTICE;
52 54
     if (DEVSITE) {
53 55
         $error_level = E_ALL | E_STRICT;
54
-    } elseif (version_compare(phpversion(), "5.3") >= 0) {
56
+    }
57
+    elseif (version_compare(phpversion(), "5.3") >= 0) {
55 58
         $error_level = $error_level & ~E_DEPRECATED;
56 59
     }
57 60
 
@@ -62,7 +65,8 @@  discard block
 block discarded – undo
62 65
         $whoops = new \Whoops\Run;
63 66
         $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
64 67
         $whoops->register();
65
-    } else {
68
+    }
69
+    else {
66 70
         set_exception_handler("exception_handler");
67 71
     }
68 72
 
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 First some things to help make our PHP nicer and betterer
5 5
 ********************************************************************************/
6 6
 
7
-error_reporting (E_ALL);
7
+error_reporting(E_ALL);
8 8
 
9 9
 /********************************************************************************
10 10
 Now some constants that are the same for live and dev versions
@@ -12,22 +12,22 @@  discard block
 block discarded – undo
12 12
 ********************************************************************************/
13 13
 
14 14
 // In case we need to switch these off globally at some point...
15
-define ("ALLOWCOMMENTS", true);
16
-define ("ALLOWTRACKBACKS", true);
15
+define("ALLOWCOMMENTS", true);
16
+define("ALLOWTRACKBACKS", true);
17 17
 
18 18
 // These variables are so we can keep date/time formats consistent across the site
19 19
 // and change them easily.
20 20
 // Formats here: http://www.php.net/manual/en/function.date.php
21
-define ("LONGERDATEFORMAT",		"l, j F Y");// Monday, 31 December 2003
22
-define ("LONGDATEFORMAT", 		"j F Y"); 	// 31 December 2003
23
-define ("SHORTDATEFORMAT", 		"j M Y");	// 31 Dec 2003
24
-define ("TIMEFORMAT", 			"g:i a");	// 11:59 pm
21
+define("LONGERDATEFORMAT", "l, j F Y"); // Monday, 31 December 2003
22
+define("LONGDATEFORMAT", "j F Y"); // 31 December 2003
23
+define("SHORTDATEFORMAT", "j M Y"); // 31 Dec 2003
24
+define("TIMEFORMAT", "g:i a"); // 11:59 pm
25 25
 
26
-define ("SHORTDATEFORMAT_SQL",	"%e %b %Y"); // 31 Dec 2003
27
-define ("TIMEFORMAT_SQL", 		"%l:%i %p"); // 11:59 PM
26
+define("SHORTDATEFORMAT_SQL", "%e %b %Y"); // 31 Dec 2003
27
+define("TIMEFORMAT_SQL", "%l:%i %p"); // 11:59 PM
28 28
 
29 29
 // Where we store the postcode of users if they search for an MP by postcode.
30
-define ('POSTCODE_COOKIE', 		'eppc');
30
+define('POSTCODE_COOKIE', 'eppc');
31 31
 
32 32
 /********************************************************************************
33 33
 And now all the files we'll include on every page.
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 twfy_debug_timestamp("after including utility.php");
42 42
 
43 43
 // Set the default timezone
44
-if(function_exists('date_default_timezone_set')) date_default_timezone_set(TIMEZONE);
44
+if (function_exists('date_default_timezone_set')) date_default_timezone_set(TIMEZONE);
45 45
 
46 46
 // Only do clever things with errors if we're not testing, otherwise show as default
47 47
 
@@ -70,40 +70,40 @@  discard block
 block discarded – undo
70 70
 
71 71
 // The time the page starts, so we can display the total at the end.
72 72
 // getmicrotime() is in utiltity.php.
73
-define ("STARTTIME", getmicrotime());
73
+define("STARTTIME", getmicrotime());
74 74
 if (!isset($_SERVER['WINDIR'])) {
75 75
     $rusage = getrusage();
76
-    define ('STARTTIMES', $rusage['ru_stime.tv_sec']*1000000 + $rusage['ru_stime.tv_usec']);
77
-    define ('STARTTIMEU', $rusage['ru_utime.tv_sec']*1000000 + $rusage['ru_utime.tv_usec']);
76
+    define('STARTTIMES', $rusage['ru_stime.tv_sec'] * 1000000 + $rusage['ru_stime.tv_usec']);
77
+    define('STARTTIMEU', $rusage['ru_utime.tv_sec'] * 1000000 + $rusage['ru_utime.tv_usec']);
78 78
 }
79
-include_once (INCLUDESPATH."data.php");
80
-include_once (INCLUDESPATH."mysql.php");
79
+include_once (INCLUDESPATH . "data.php");
80
+include_once (INCLUDESPATH . "mysql.php");
81 81
 
82 82
 Class ParlDB extends MySQL {
83 83
     public function __construct() {
84
-        $this->init (OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME);
84
+        $this->init(OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME);
85 85
     }
86 86
 }
87 87
 
88
-include_once (INCLUDESPATH."url.php");
89
-include_once (INCLUDESPATH."lib_filter.php");
90
-include_once (INCLUDESPATH."easyparliament/user.php");
88
+include_once (INCLUDESPATH . "url.php");
89
+include_once (INCLUDESPATH . "lib_filter.php");
90
+include_once (INCLUDESPATH . "easyparliament/user.php");
91 91
 
92 92
 // Test to see if this is a new-style template using the renderer class.
93
-if (! isset($new_style_template) OR $new_style_template !== TRUE) {
93
+if (!isset($new_style_template) OR $new_style_template !== TRUE) {
94 94
 
95 95
     // This is an old-style page. Use the old page classes.
96
-    include_once (INCLUDESPATH."easyparliament/page.php");
96
+    include_once (INCLUDESPATH . "easyparliament/page.php");
97 97
 
98 98
 }
99 99
 
100
-include_once (INCLUDESPATH."easyparliament/hansardlist.php");
101
-include_once (INCLUDESPATH."dbtypes.php");
102
-include_once (INCLUDESPATH."easyparliament/commentlist.php");
103
-include_once (INCLUDESPATH."easyparliament/comment.php");
104
-include_once (INCLUDESPATH."easyparliament/trackback.php");
100
+include_once (INCLUDESPATH . "easyparliament/hansardlist.php");
101
+include_once (INCLUDESPATH . "dbtypes.php");
102
+include_once (INCLUDESPATH . "easyparliament/commentlist.php");
103
+include_once (INCLUDESPATH . "easyparliament/comment.php");
104
+include_once (INCLUDESPATH . "easyparliament/trackback.php");
105 105
 
106 106
 // Added in as new module by Richard Allan MP
107
-include_once (INCLUDESPATH."easyparliament/alert.php");
107
+include_once (INCLUDESPATH . "easyparliament/alert.php");
108 108
 
109 109
 twfy_debug_timestamp("at end of init.php");
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/mp/divisions.php 3 patches
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
                 </div>
34 34
                 <?php endif; ?>
35 35
 
36
-                <?php $displayed_votes = FALSE; ?>
36
+                <?php $displayed_votes = false; ?>
37 37
                 <?php if ( isset($policydivisions) && $policydivisions ) { ?>
38 38
 
39 39
                     <?php if ($has_voting_record) { ?>
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
 
87 87
                                     <ul class="vote-descriptions policy-votes">
88 88
                                     <?php
89
-                                        $show_all = FALSE;
89
+                                        $show_all = false;
90 90
                                         if ( $policy['weak_count'] == 0 || $policy['weak_count'] == count($policy['divisions']) ) {
91
-                                            $show_all = TRUE;
91
+                                            $show_all = true;
92 92
                                         }
93 93
                                     ?>
94 94
                                     <?php foreach ($policy['divisions'] as $division) {
95 95
                                         include('_division_description.php');
96
-                                        $displayed_votes = TRUE;
96
+                                        $displayed_votes = true;
97 97
                                     } ?>
98 98
                                     </ul>
99 99
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
         </div>
16 16
         <div class="person-panels">
17 17
             <div class="sidebar__unit in-page-nav">
18
-                <?php if ( isset($policydivisions) && $policydivisions && count($policydivisions) == 1 ) { ?>
18
+                <?php if (isset($policydivisions) && $policydivisions && count($policydivisions) == 1) { ?>
19 19
                 <p class="policy-votes-intro">
20 20
                     How <?= $full_name ?> voted on <?= $policydivisions[array_keys($policydivisions)[0]]['desc'] ?>.
21 21
                 </p>
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
                 <?php endif; ?>
35 35
 
36 36
                 <?php $displayed_votes = FALSE; ?>
37
-                <?php if ( isset($policydivisions) && $policydivisions ) { ?>
37
+                <?php if (isset($policydivisions) && $policydivisions) { ?>
38 38
 
39 39
                     <?php if ($has_voting_record) { ?>
40 40
 
41 41
                         <?php foreach ($policydivisions as $policy) { ?>
42 42
 
43
-                            <?php if ( isset($policy['header']) ) { ?>
43
+                            <?php if (isset($policy['header'])) { ?>
44 44
                                 <div class="panel policy-votes-hero" style="background-image: url('<?php echo $policy['header']['image']; ?>');">
45 45
                                     <h2><?php echo $policy['header']['title']; ?></h2>
46 46
                                     <p><?php echo $policy['header']['description']; ?>.</p>
47
-                                    <?php if ( $policy['header']['image_source'] ) { ?>
47
+                                    <?php if ($policy['header']['image_source']) { ?>
48 48
                                     <span class="policy-votes-hero__image-attribution">
49 49
                                         Photo:
50 50
                                         <a href="<?php echo $policy['header']['image_source']; ?>">
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
                             <?php } ?>
60 60
 
61 61
 
62
-                            <?php if ( isset($policy['position']) ) { ?>
62
+                            <?php if (isset($policy['position'])) { ?>
63 63
                                 <div class="panel">
64
-                                    <?php if ( $policy['position']['has_strong'] ) { ?>
64
+                                    <?php if ($policy['position']['has_strong']) { ?>
65 65
                                         <h3 class="policy-vote-overall-stance">
66 66
                                             <?= $full_name . ' ' . $policy['position']['desc'] ?>
67 67
                                         </h3>
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                                     <ul class="vote-descriptions policy-votes">
88 88
                                     <?php
89 89
                                         $show_all = FALSE;
90
-                                        if ( $policy['weak_count'] == 0 || $policy['weak_count'] == count($policy['divisions']) ) {
90
+                                        if ($policy['weak_count'] == 0 || $policy['weak_count'] == count($policy['divisions'])) {
91 91
                                             $show_all = TRUE;
92 92
                                         }
93 93
                                     ?>
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
 
100 100
                                     <div class="policy-votes-list-footer">
101 101
                                     <p class="policy-votes__byline">Vote information from <a href="http://www.publicwhip.org.uk/mp.php?mpid=<?= $member_id ?>&dmp=<?= $policy['policy_id'] ?>">PublicWhip</a>. Last updated: <?= $policy_last_update[$policy['policy_id']] ?></p>
102
-                                        <?php if ( !$show_all && $policy['weak_count'] > 0 ) { ?>
102
+                                        <?php if (!$show_all && $policy['weak_count'] > 0) { ?>
103 103
                                         <p><button class="button secondary-button small js-show-all-votes">Show all votes, including <?= $policy['weak_count'] ?> less important <?= $policy['weak_count'] == 1 ? 'vote' : 'votes' ?></button></p>
104 104
                                         <?php } ?>
105 105
                                     </div>
106 106
 
107 107
                                     <script type="text/javascript">
108 108
                                     $(function(){
109
-                                        <?php if ( !$show_all ) { ?>
109
+                                        <?php if (!$show_all) { ?>
110 110
                                         $('#policy-votes-type').text('Key');
111 111
                                         <?php } ?>
112 112
                                         $('.js-show-all-votes').on('click', function(){
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,8 @@
 block discarded – undo
74 74
                                         </p>
75 75
 
76 76
                                         <h3 class="policy-votes-list-header"><span id="policy-votes-type">All</span> votes about <?= $policy['desc'] ?>:</h3>
77
-                                    <?php } else { ?>
77
+                                    <?php }
78
+else { ?>
78 79
                                         <h3 class="policy-vote-overall-stance">
79 80
                                             We don&rsquo;t have enough information to calculate <?= $full_name ?>&rsquo;s position on this issue
80 81
                                         </h3>
Please login to merge, or discard this patch.