@@ -321,6 +321,9 @@ |
||
321 | 321 | return array(); |
322 | 322 | } |
323 | 323 | |
324 | + /** |
|
325 | + * @param Member $member |
|
326 | + */ |
|
324 | 327 | private function constructMPData($member, $user, $mp_house) { |
325 | 328 | $mp_data = array(); |
326 | 329 | $mp_data['name'] = $member->full_name(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | class User { |
15 | - public function getUserDetails($user_id = False) { |
|
15 | + public function getUserDetails($user_id = false) { |
|
16 | 16 | global $THEUSER; |
17 | 17 | |
18 | 18 | $user = $THEUSER; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | return $data; |
56 | 56 | } |
57 | 57 | |
58 | - public function getUpdateDetails($this_page, $is_facebook_user = False) { |
|
58 | + public function getUpdateDetails($this_page, $is_facebook_user = false) { |
|
59 | 59 | $details = array(); |
60 | 60 | |
61 | 61 | if ($is_facebook_user) { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | if ($details['email'] != $THEUSER->email()) { |
265 | - $results['email_changed'] = True; |
|
265 | + $results['email_changed'] = true; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | $data = array(); |
29 | 29 | $data['firstname'] = $user->firstname(); |
30 | 30 | $data['lastname'] = $user->lastname(); |
31 | - $data['name'] = $user->firstname() . " " . $user->lastname(); |
|
31 | + $data['name'] = $user->firstname()." ".$user->lastname(); |
|
32 | 32 | $data['url'] = $user->url(); |
33 | 33 | $data['email'] = $user->email(); |
34 | 34 | $data['emailpublic'] = $user->emailpublic() == true ? "Yes" : "No"; |
35 | 35 | $data['optin'] = $user->optin() == true ? "Yes" : "No"; |
36 | - $data['postcode'] = $user->postcode(); |
|
36 | + $data['postcode'] = $user->postcode(); |
|
37 | 37 | $data['website'] = $user->url(); |
38 | - $data['registrationtime'] = $user->registrationtime(); |
|
39 | - $data['status']= $user->status(); |
|
38 | + $data['registrationtime'] = $user->registrationtime(); |
|
39 | + $data['status'] = $user->status(); |
|
40 | 40 | $data["deleted"] = $user->deleted(); |
41 | 41 | $data["confirmed"] = $user->confirmed(); |
42 | 42 | $data["status"] = $user->status(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | if ($details['url'] != '' && !preg_match('/^http/', $details['url'])) { |
85 | - $details['url'] = 'http://' . $details['url']; |
|
85 | + $details['url'] = 'http://'.$details['url']; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | // Who are we updating? $THEUSER or someone else? |
244 | 244 | if ($this_page == "otheruseredit") { |
245 | 245 | $who = 'the user’s'; |
246 | - $success = $THEUSER->update_other_user ( $details ); |
|
246 | + $success = $THEUSER->update_other_user($details); |
|
247 | 247 | } else { |
248 | 248 | $who = 'your'; |
249 | - $success = $THEUSER->update_self ( $details ); |
|
249 | + $success = $THEUSER->update_self($details); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | |
266 | 266 | |
267 | 267 | } else { |
268 | - $results['errors'] = array("db" => "Sorry, we were unable to update $who details. Please <a href=\"mailto:" . str_replace('@', '@', CONTACTEMAIL) . "\">let us know</a> what you were trying to change. Thanks."); |
|
268 | + $results['errors'] = array("db" => "Sorry, we were unable to update $who details. Please <a href=\"mailto:".str_replace('@', '@', CONTACTEMAIL)."\">let us know</a> what you were trying to change. Thanks."); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | return $results; |
@@ -278,12 +278,12 @@ discard block |
||
278 | 278 | // If this goes well, the user will have their data |
279 | 279 | // added to the database and a confirmation email |
280 | 280 | // will be sent to them. |
281 | - $success = $THEUSER->add ( $details ); |
|
281 | + $success = $THEUSER->add($details); |
|
282 | 282 | |
283 | 283 | $errors = array(); |
284 | 284 | |
285 | 285 | if (!$success) { |
286 | - $errors["db"] = "Sorry, we were unable to create an account for you. Please <a href=\"mailto:". str_replace('@', '@', CONTACTEMAIL) . "\">let us know</a>. Thanks."; |
|
286 | + $errors["db"] = "Sorry, we were unable to create an account for you. Please <a href=\"mailto:".str_replace('@', '@', CONTACTEMAIL)."\">let us know</a>. Thanks."; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | return $errors; |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | |
292 | 292 | public function getRep($cons_type, $mp_house) { |
293 | 293 | global $THEUSER; |
294 | - if ( !$THEUSER->has_postcode() ) { |
|
294 | + if (!$THEUSER->has_postcode()) { |
|
295 | 295 | return array(); |
296 | 296 | } |
297 | 297 | |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | // Scottish homepage |
305 | 305 | try { |
306 | 306 | $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($THEUSER->postcode()); |
307 | - if ( isset($constituencies[$cons_type]) ) { |
|
307 | + if (isset($constituencies[$cons_type])) { |
|
308 | 308 | $constituency = $constituencies[$cons_type]; |
309 | 309 | $MEMBER = new Member(array('constituency'=>$constituency, 'house'=> $mp_house)); |
310 | 310 | } |
311 | - } catch ( MemberException $e ) { |
|
311 | + } catch (MemberException $e) { |
|
312 | 312 | return array(); |
313 | 313 | } |
314 | 314 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $mreg = array(); |
346 | 346 | if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) { |
347 | 347 | $reps = \MySociety\TheyWorkForYou\Member::getRegionalList($THEUSER->postcode, $mp_house, $cons_type); |
348 | - foreach ( $reps as $rep ) { |
|
348 | + foreach ($reps as $rep) { |
|
349 | 349 | $member = new \MySociety\TheyWorkForYou\Member(array('person_id' => $rep['person_id'])); |
350 | 350 | $mreg[$rep['person_id']] = $this->constructMPData($member, $THEUSER, $mp_house); |
351 | 351 | } |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | if (get_http_var("submitted") == "true") { |
20 | 20 | // Form has been submitted, so check input. |
21 | 21 | |
22 | - $email = get_http_var("email"); |
|
22 | + $email = get_http_var("email"); |
|
23 | 23 | $password = get_http_var("password"); |
24 | 24 | $remember = get_http_var("remember"); |
25 | 25 | |
26 | 26 | // The user may have tried to do something that requires being logged in. |
27 | 27 | // In which case we should arrive here with that page's URL in 'ret'. |
28 | 28 | // We can then send the user there after log in. |
29 | - $returnurl = get_http_var("ret"); |
|
29 | + $returnurl = get_http_var("ret"); |
|
30 | 30 | |
31 | 31 | $errors = array(); |
32 | 32 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if ($remember == "true") { |
54 | 54 | $expire = "never"; |
55 | 55 | } else { |
56 | - $expire ="session"; |
|
56 | + $expire = "session"; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // $returnurl is the url of where we'll send the user after login. |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | |
99 | -function display_page( $errors=array() ) { |
|
99 | +function display_page($errors = array()) { |
|
100 | 100 | global $PAGE, $this_page, $THEUSER; |
101 | 101 | |
102 | 102 | $PAGE->page_start(); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | <?php |
128 | 128 | |
129 | 129 | $PAGE->stripe_end(array( |
130 | - array ( |
|
130 | + array( |
|
131 | 131 | 'type' => 'include', |
132 | 132 | 'content' => 'userlogin' |
133 | 133 | ) |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * Test that the Royal edge-case house is correctly defined. |
11 | 11 | */ |
12 | - public function testRoyalHouseDefined() |
|
12 | + public function testRoyalHouseDefined() |
|
13 | 13 | { |
14 | 14 | $this->assertEquals(0, HOUSE_TYPE_ROYAL); |
15 | 15 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Test that the House of Commons is correctly defined. |
19 | 19 | */ |
20 | - public function testCommonsHouseDefined() |
|
20 | + public function testCommonsHouseDefined() |
|
21 | 21 | { |
22 | 22 | $this->assertEquals(1, HOUSE_TYPE_COMMONS); |
23 | 23 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * Test that the House of Lords is correctly defined. |
27 | 27 | */ |
28 | - public function testLordsHouseDefined() |
|
28 | + public function testLordsHouseDefined() |
|
29 | 29 | { |
30 | 30 | $this->assertEquals(2, HOUSE_TYPE_LORDS); |
31 | 31 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * Test that the Northern Ireland Assembly is correctly defined. |
35 | 35 | */ |
36 | - public function testNIHouseDefined() |
|
36 | + public function testNIHouseDefined() |
|
37 | 37 | { |
38 | 38 | $this->assertEquals(3, HOUSE_TYPE_NI); |
39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * Test that the Scottish Parliament is correctly defined. |
43 | 43 | */ |
44 | - public function testScotlandHouseDefined() |
|
44 | + public function testScotlandHouseDefined() |
|
45 | 45 | { |
46 | 46 | $this->assertEquals(4, HOUSE_TYPE_SCOTLAND); |
47 | 47 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Test that the Assembly for Wales is correctly defined. |
51 | 51 | */ |
52 | - public function testWalesHouseDefined() |
|
52 | + public function testWalesHouseDefined() |
|
53 | 53 | { |
54 | 54 | $this->assertEquals(5, HOUSE_TYPE_WALES); |
55 | 55 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | public function escape_comments($data) { |
156 | 156 | |
157 | 157 | $data = preg_replace_callback("/<!--(.*?)-->/s", function($matches) { |
158 | - return '<!--' . HtmlSpecialChars($this->StripSingle($matches[1])) . '-->'; |
|
158 | + return '<!--'.HtmlSpecialChars($this->StripSingle($matches[1])).'-->'; |
|
159 | 159 | }, $data); |
160 | 160 | |
161 | 161 | return $data; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | }, $data); |
210 | 210 | |
211 | 211 | foreach (array_keys($this->tag_counts) as $tag) { |
212 | - for ($i=0; $i<$this->tag_counts[$tag]; $i++) { |
|
212 | + for ($i = 0; $i < $this->tag_counts[$tag]; $i++) { |
|
213 | 213 | $data .= "</$tag>"; |
214 | 214 | } |
215 | 215 | } |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | $ending = $matches[3]; |
245 | 245 | if (in_array($name, array_keys($this->allowed))) { |
246 | 246 | $params = ""; |
247 | - preg_match_all("/([a-z0-9]+)=([\"'])(.*?)\\2/si", $body, $matches_2, PREG_SET_ORDER); # <foo a="b" /> |
|
248 | - preg_match_all("/([a-z0-9]+)(=)([^\"\s']+)/si", $body, $matches_1, PREG_SET_ORDER); # <foo a=b /> |
|
249 | - preg_match_all("/([a-z0-9]+)=([\"'])([^\"']*?)\s*$/si", $body, $matches_3, PREG_SET_ORDER); # <foo a="b /> |
|
247 | + preg_match_all("/([a-z0-9]+)=([\"'])(.*?)\\2/si", $body, $matches_2, PREG_SET_ORDER); # <foo a="b" /> |
|
248 | + preg_match_all("/([a-z0-9]+)(=)([^\"\s']+)/si", $body, $matches_1, PREG_SET_ORDER); # <foo a=b /> |
|
249 | + preg_match_all("/([a-z0-9]+)=([\"'])([^\"']*?)\s*$/si", $body, $matches_3, PREG_SET_ORDER); # <foo a="b /> |
|
250 | 250 | $matches = array_merge($matches_1, $matches_2, $matches_3); |
251 | 251 | |
252 | 252 | foreach ($matches as $match) { |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | if (preg_match("/^([^:]+)\:/si", $data, $matches)) { |
304 | 304 | if (!in_array($matches[1], $this->allowed_protocols)) { |
305 | - $data = '#'.substr($data, strlen($matches[1])+1); |
|
305 | + $data = '#'.substr($data, strlen($matches[1]) + 1); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | # if there are less than 5, just allow it as-is |
353 | 353 | # |
354 | 354 | |
355 | - if (strlen($data_notags)<5) { |
|
355 | + if (strlen($data_notags) < 5) { |
|
356 | 356 | return $data; |
357 | 357 | } |
358 | 358 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | # inside strings. within general text, we decode hex/dec entities. |
563 | 563 | # |
564 | 564 | |
565 | - public function decode_entities($data, $in_attribute=1) { |
|
565 | + public function decode_entities($data, $in_attribute = 1) { |
|
566 | 566 | |
567 | 567 | $data = preg_replace_callback('!(&)#(\d+);?!', array($this, 'decode_dec_entity'), $data); |
568 | 568 | $data = preg_replace_callback('!(&)#x([0-9a-f]+);?!i', array($this, 'decode_hex_entity'), $data); |
@@ -324,7 +324,9 @@ |
||
324 | 324 | while (1) { |
325 | 325 | $len = strlen($data); |
326 | 326 | $data = preg_replace("/<({$tags})(\s[^>]*)?(><\\/\\1>|\\/>)/", '', $data); |
327 | - if ($len == strlen($data)) break; |
|
327 | + if ($len == strlen($data)) { |
|
328 | + break; |
|
329 | + } |
|
328 | 330 | } |
329 | 331 | } |
330 | 332 |
@@ -159,6 +159,9 @@ |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | + /** |
|
163 | + * @param string $type |
|
164 | + */ |
|
162 | 165 | private function getMetadata($args="", $type) { |
163 | 166 | // $type is either 'page' or 'section' |
164 | 167 | global $this_page, $this_section; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function __construct() { |
56 | 56 | |
57 | - include_once METADATAPATH; // defined in config.php |
|
57 | + include_once METADATAPATH; // defined in config.php |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | |
116 | 116 | public function set_page_metadata($page, $key, $value) { |
117 | - $this->setMetadata(array("page"=>$page,"key"=>$key,"value"=>$value)); |
|
117 | + $this->setMetadata(array("page"=>$page, "key"=>$key, "value"=>$value)); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | |
128 | 128 | public function set_section_metadata($section, $key, $value) { |
129 | - $this->setMetadata(array("section"=>$section,"key"=>$key,"value"=>$value)); |
|
129 | + $this->setMetadata(array("section"=>$section, "key"=>$key, "value"=>$value)); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | |
152 | 152 | public function test_for_metadata($type, $item, $key) { |
153 | - $dataarray =& $this->$type; |
|
153 | + $dataarray = & $this->$type; |
|
154 | 154 | |
155 | 155 | if (isset($dataarray[$item][$key])) { |
156 | 156 | return true; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - private function getMetadata($args="", $type) { |
|
162 | + private function getMetadata($args = "", $type) { |
|
163 | 163 | // $type is either 'page' or 'section' |
164 | 164 | global $this_page, $this_section; |
165 | 165 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | twfy_debug("DATA", "$type: $item, $key"); |
176 | - $dataarray =& $this->$type; |
|
176 | + $dataarray = & $this->$type; |
|
177 | 177 | |
178 | 178 | if ($this->test_for_metadata($type, $item, $key)) { |
179 | 179 | $return = $dataarray[$item][$key]; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $debugtext = "No metadata found for key '$key'"; |
189 | 189 | } |
190 | 190 | |
191 | - twfy_debug("DATA", "$debugtext, returning '" . (is_scalar($return) ? $return : gettype($return)) . "'."); |
|
191 | + twfy_debug("DATA", "$debugtext, returning '".(is_scalar($return) ? $return : gettype($return))."'."); |
|
192 | 192 | |
193 | 193 | return $return; |
194 | 194 | } |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | $key = $args["key"]; |
207 | 207 | $value = $args["value"]; |
208 | 208 | |
209 | - twfy_debug("DATA", "Setting: ".$type."[".$item."][".$key."] = '" . print_r($value, 1) . "'"); |
|
209 | + twfy_debug("DATA", "Setting: ".$type."[".$item."][".$key."] = '".print_r($value, 1)."'"); |
|
210 | 210 | |
211 | - $dataarray =& $this->$type; |
|
211 | + $dataarray = & $this->$type; |
|
212 | 212 | $dataarray[$item][$key] = $value; |
213 | 213 | } |
214 | 214 |