@@ -25,7 +25,7 @@ |
||
25 | 25 | if (defined('OPTION_GAZE_URL') && OPTION_GAZE_URL) { |
26 | 26 | return gaze_get_country_from_ip($ip); |
27 | 27 | } else { |
28 | - return NULL; |
|
28 | + return null; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | } |
@@ -24,7 +24,8 @@ |
||
24 | 24 | |
25 | 25 | if (defined('OPTION_GAZE_URL') && OPTION_GAZE_URL) { |
26 | 26 | return gaze_get_country_from_ip($ip); |
27 | - } else { |
|
27 | + } |
|
28 | + else { |
|
28 | 29 | return NULL; |
29 | 30 | } |
30 | 31 |
@@ -39,7 +39,7 @@ |
||
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 |
@@ -39,7 +39,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -52,7 +52,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | protected function getCalendarData() { |
41 | - return NULL; |
|
41 | + return null; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 |
@@ -11,7 +11,7 @@ |
||
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; |
@@ -65,7 +65,7 @@ |
||
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 | ); |
@@ -47,7 +47,7 @@ discard block |
||
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 |
||
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 |
||
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() { |
@@ -44,7 +44,8 @@ discard block |
||
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 |
||
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 \MySociety\TheyWorkForYou\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 |
||
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 | } |
@@ -81,15 +81,15 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -21,7 +21,7 @@ discard block |
||
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 |
||
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 |
||
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 \MySociety\TheyWorkForYou\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 \MySociety\TheyWorkForYou\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 |
||
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 |
||
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 |
||
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 \MySociety\TheyWorkForYou\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 |
||
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 \MySociety\TheyWorkForYou\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 \MySociety\TheyWorkForYou\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>"; |
@@ -11,7 +11,8 @@ discard block |
||
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 |
||
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 \MySociety\TheyWorkForYou\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 |
||
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 |
||
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 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $data = array(); |
44 | 44 | $urls = array(); |
45 | 45 | |
46 | - $data['popular_searches'] = NULL; |
|
46 | + $data['popular_searches'] = null; |
|
47 | 47 | |
48 | 48 | |
49 | 49 | $data['urls'] = $this->getURLs($data); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $MOREURL->insert( array( 'more' => 1 ) ); |
56 | 56 | |
57 | 57 | // this makes sure that we don't repeat this debate in the list below |
58 | - $random_debate = NULL; |
|
58 | + $random_debate = null; |
|
59 | 59 | if ( isset($debates['data']) && count($debates['data']) ) { |
60 | 60 | $random_debate = $debates['data'][0]; |
61 | 61 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | protected function getSearchSections() { |
34 | 34 | return array( |
35 | - array( 'section' => 'ni' ) |
|
35 | + array('section' => 'ni') |
|
36 | 36 | ); |
37 | 37 | } |
38 | 38 | |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | |
53 | 53 | $debates = $DEBATELIST->display('recent_debates', array('days' => 30, 'num' => 6), 'none'); |
54 | 54 | $MOREURL = new \MySociety\TheyWorkForYou\Url('nidebatesfront'); |
55 | - $MOREURL->insert( array( 'more' => 1 ) ); |
|
55 | + $MOREURL->insert(array('more' => 1)); |
|
56 | 56 | |
57 | 57 | // this makes sure that we don't repeat this debate in the list below |
58 | 58 | $random_debate = NULL; |
59 | - if ( isset($debates['data']) && count($debates['data']) ) { |
|
59 | + if (isset($debates['data']) && count($debates['data'])) { |
|
60 | 60 | $random_debate = $debates['data'][0]; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $recent = array(); |
64 | - if ( isset($debates['data']) && count($debates['data']) ) { |
|
64 | + if (isset($debates['data']) && count($debates['data'])) { |
|
65 | 65 | // at the start of a session there may be less than 6 |
66 | 66 | // debates |
67 | 67 | $max = 6; |
68 | - if ( count($debates['data']) < 6 ) { |
|
68 | + if (count($debates['data']) < 6) { |
|
69 | 69 | $max = count($debates['data']); |
70 | 70 | } |
71 | - for ( $i = 1; $i < $max; $i++ ) { |
|
71 | + for ($i = 1; $i < $max; $i++) { |
|
72 | 72 | $debate = $debates['data'][$i]; |
73 | 73 | $debate['desc'] = "Northern Ireland Assembly debates"; |
74 | 74 | $debate['more_url'] = $MOREURL->generate(); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | $featured = array(); |
80 | - if ( $random_debate ) { |
|
80 | + if ($random_debate) { |
|
81 | 81 | $featured = $random_debate; |
82 | 82 | $featured['more_url'] = $MOREURL->generate(); |
83 | 83 | $featured['desc'] = 'Northern Ireland Assembly debate'; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | $data['featured'] = $featured; |
89 | - $data['debates'] = array( 'recent' => $recent); |
|
89 | + $data['debates'] = array('recent' => $recent); |
|
90 | 90 | |
91 | 91 | $data['regional'] = $this->getMLAList(); |
92 | 92 | $data['template'] = 'ni/index'; |
@@ -10,7 +10,8 @@ |
||
10 | 10 | protected function display_front() { |
11 | 11 | if (get_http_var('more')) { |
12 | 12 | return parent::display_front(); |
13 | - } else { |
|
13 | + } |
|
14 | + else { |
|
14 | 15 | return $this->display_front_ni(); |
15 | 16 | } |
16 | 17 | } |
@@ -32,7 +32,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | public function display() { |
8 | 8 | $data = array(); |
9 | 9 | $data['recent_election'] = false; |
10 | - if ( $this->user->loggedin() ) { |
|
10 | + if ($this->user->loggedin()) { |
|
11 | 11 | $data['user_signed_in'] = true; |
12 | 12 | } |
13 | 13 | |
@@ -17,21 +17,21 @@ discard block |
||
17 | 17 | $data['postcode'] = get_http_var('postcode'); |
18 | 18 | |
19 | 19 | $result = $this->createAlertForPostCode($data['email'], $data['postcode']); |
20 | - $data = array_merge( $data, $result ); |
|
20 | + $data = array_merge($data, $result); |
|
21 | 21 | } elseif (get_http_var('update')) { |
22 | 22 | $result = $this->getNewMP(get_http_var('update')); |
23 | - $data = array_merge( $data, $result ); |
|
23 | + $data = array_merge($data, $result); |
|
24 | 24 | } elseif (get_http_var('update-alert')) { |
25 | - $success = $this->replaceAlert( get_http_var('confirmation') ); |
|
25 | + $success = $this->replaceAlert(get_http_var('confirmation')); |
|
26 | 26 | $data['confirmation_received'] = $success; |
27 | 27 | } elseif (get_http_var('confirmed')) { |
28 | - $success = $this->confirmAlert( get_http_var('confirmed') ); |
|
28 | + $success = $this->confirmAlert(get_http_var('confirmed')); |
|
29 | 29 | $data['confirmation_received'] = $success; |
30 | 30 | } else { |
31 | 31 | $data['email'] = $this->user->email() ? $this->user->email() : ''; |
32 | 32 | $data['postcode'] = $this->user->postcode_is_set() ? $this->user->postcode() : ''; |
33 | 33 | |
34 | - if ( $this->isEmailSignedUpForPostCode( $data['email'], $data['postcode'] ) ) { |
|
34 | + if ($this->isEmailSignedUpForPostCode($data['email'], $data['postcode'])) { |
|
35 | 35 | $data['already_signed_up'] = True; |
36 | 36 | $mp = $this->getPersonFromPostcode($data['postcode']); |
37 | 37 | $data['mp_name'] = $mp->full_name(); |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | private function createAlertForPostCode($email, $postcode) { |
69 | - if ( !$this->validateDetails($email, $postcode) ) { |
|
69 | + if (!$this->validateDetails($email, $postcode)) { |
|
70 | 70 | return array('invalid-postcode-or-email' => True); |
71 | 71 | } |
72 | 72 | |
73 | 73 | try { |
74 | 74 | $person = $this->getPersonFromPostcode($postcode); |
75 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
75 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
76 | 76 | return array('bad-constituency' => True); |
77 | 77 | } |
78 | 78 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | switch ($result) { |
91 | 91 | case self::ALERT_EXISTS: |
92 | - if ( $not_logged_in ) { |
|
92 | + if ($not_logged_in) { |
|
93 | 93 | // no logged in user so send them an email to let them |
94 | 94 | // know someone tried to create an alert |
95 | 95 | $this->alert->send_already_signedup_email($details); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $data['error'] = True; |
103 | 103 | break; |
104 | 104 | default: // alert created |
105 | - if ( $not_logged_in ) { |
|
105 | + if ($not_logged_in) { |
|
106 | 106 | $data['confirmation_sent'] = True; |
107 | 107 | } else { |
108 | 108 | $data['signedup_no_confirm'] = True; |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | $existing = $this->alert->fetch_by_token($confirmation); |
117 | 117 | preg_match('/speaker:(\d+)/', $existing['criteria'], $matches); |
118 | 118 | $old_mp_id = $matches[1]; |
119 | - $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $old_mp_id ) ); |
|
120 | - $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 )); |
|
119 | + $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $old_mp_id)); |
|
120 | + $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1)); |
|
121 | 121 | |
122 | 122 | $q = $this->db->query( |
123 | 123 | "SELECT alert_id, criteria, registrationtoken FROM alerts |
@@ -131,7 +131,7 @@ discard block |
||
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 |
||
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 |
||
158 | 158 | private function isEmailSignedUpForPostCode($email, $postcode) { |
159 | 159 | $is_signed_up = false; |
160 | 160 | |
161 | - if ( $email && $postcode ) { |
|
161 | + if ($email && $postcode) { |
|
162 | 162 | try { |
163 | 163 | $person = $this->getPersonFromPostcode($postcode); |
164 | 164 | $is_signed_up = $this->alert->fetch_by_mp($email, $person->person_id); |
165 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
165 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
166 | 166 | $is_signed_up = false; |
167 | 167 | } |
168 | 168 | } |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | preg_match('/speaker:(\d+)/', $existing['criteria'], $matches); |
179 | 179 | $criteria = $matches[1]; |
180 | 180 | |
181 | - $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $criteria ) ); |
|
182 | - $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 )); |
|
181 | + $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $criteria)); |
|
182 | + $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1)); |
|
183 | 183 | |
184 | - if ( $this->alert->fetch_by_mp( $existing['email'], $new_mp->person_id) ) { |
|
184 | + if ($this->alert->fetch_by_mp($existing['email'], $new_mp->person_id)) { |
|
185 | 185 | $data = array( |
186 | 186 | 'already_signed_up' => True, |
187 | 187 | 'old_mp' => $old_mp->full_name(), |
@@ -18,16 +18,20 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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(), |
@@ -12,7 +12,7 @@ |
||
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 | } |
@@ -179,7 +179,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -51,17 +51,20 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |