@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | public $source; |
20 | 20 | |
21 | 21 | /** |
22 | - * To String |
|
23 | - * |
|
24 | - * Return the office title as a string. |
|
25 | - * |
|
26 | - * @return string The title of the office, or "Unnamed Office" |
|
27 | - */ |
|
22 | + * To String |
|
23 | + * |
|
24 | + * Return the office title as a string. |
|
25 | + * |
|
26 | + * @return string The title of the office, or "Unnamed Office" |
|
27 | + */ |
|
28 | 28 | |
29 | 29 | public function __toString() { |
30 | 30 | if (isset ($this->title)){ |
@@ -35,25 +35,25 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Pretty Dates |
|
39 | - * |
|
40 | - * Return a string containing prettified dates of this office. |
|
41 | - * |
|
42 | - * 2004-05-28 and 2004-05-13 are the first dates for data scraped from the |
|
43 | - * old selctee/privsec pages on parliament.uk (you can see this in |
|
44 | - * cmpages/chgpages' privsec0001_2004-06-08.html and |
|
45 | - * selctee0001_2004-06-08.html). So if the date is those dates for those two |
|
46 | - * things, you don't want to display it because it's not a known start date, |
|
47 | - * it could have been before that date. 2005-11-10 is because the PPS changes |
|
48 | - * did not all happen on that date but the website did not update until that |
|
49 | - * date so it outputs "before" in either from/to date in that case. |
|
50 | - * 2009-01-16 is the last date before the page disappeared off parliament.uk |
|
51 | - * entirely so that displays that fact that after then we don't know. |
|
52 | - * |
|
53 | - * @todo https://github.com/mysociety/theyworkforyou/issues/632 |
|
54 | - * |
|
55 | - * @return string The dates of this office in a readable form. |
|
56 | - */ |
|
38 | + * Pretty Dates |
|
39 | + * |
|
40 | + * Return a string containing prettified dates of this office. |
|
41 | + * |
|
42 | + * 2004-05-28 and 2004-05-13 are the first dates for data scraped from the |
|
43 | + * old selctee/privsec pages on parliament.uk (you can see this in |
|
44 | + * cmpages/chgpages' privsec0001_2004-06-08.html and |
|
45 | + * selctee0001_2004-06-08.html). So if the date is those dates for those two |
|
46 | + * things, you don't want to display it because it's not a known start date, |
|
47 | + * it could have been before that date. 2005-11-10 is because the PPS changes |
|
48 | + * did not all happen on that date but the website did not update until that |
|
49 | + * date so it outputs "before" in either from/to date in that case. |
|
50 | + * 2009-01-16 is the last date before the page disappeared off parliament.uk |
|
51 | + * entirely so that displays that fact that after then we don't know. |
|
52 | + * |
|
53 | + * @todo https://github.com/mysociety/theyworkforyou/issues/632 |
|
54 | + * |
|
55 | + * @return string The dates of this office in a readable form. |
|
56 | + */ |
|
57 | 57 | |
58 | 58 | public function pretty_dates() { |
59 | 59 |
@@ -64,7 +64,7 @@ |
||
64 | 64 | $output = ''; |
65 | 65 | |
66 | 66 | if ( |
67 | - !($this->source == 'chgpages/selctee' && $this->from_date == '2004-05-28') AND |
|
67 | + !($this->source == 'chgpages/selctee' && $this->from_date == '2004-05-28') and |
|
68 | 68 | !($this->source == 'chgpages/privsec' && $this->from_date == '2004-05-13') |
69 | 69 | ) { |
70 | 70 | if ($this->source == 'chgpages/privsec' && $this->from_date == '2005-11-10') { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | |
29 | 29 | public function __toString() { |
30 | - if (isset ($this->title)){ |
|
30 | + if (isset ($this->title)) { |
|
31 | 31 | return (string) $this->title; |
32 | 32 | } else { |
33 | 33 | return 'Unnamed Office'; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if ($this->source == 'chgpages/privsec' && $this->from_date == '2005-11-10') { |
71 | 71 | $output .= 'before '; |
72 | 72 | } |
73 | - $output .= format_date($this->from_date,SHORTDATEFORMAT) . ' '; |
|
73 | + $output .= format_date($this->from_date, SHORTDATEFORMAT) . ' '; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $output .= 'to '; |
@@ -27,7 +27,7 @@ |
||
27 | 27 | */ |
28 | 28 | |
29 | 29 | public function __toString() { |
30 | - if (isset ($this->title)){ |
|
30 | + if (isset ($this->title)) { |
|
31 | 31 | return (string) $this->title; |
32 | 32 | } else { |
33 | 33 | return 'Unnamed Office'; |
@@ -141,7 +141,9 @@ |
||
141 | 141 | |
142 | 142 | private function find_members() { |
143 | 143 | $searchstring = trim(preg_replace('#-?[a-z]+:[a-z0-9]+#', '', $this->searchstring)); |
144 | - if (!$searchstring) return array(); |
|
144 | + if (!$searchstring) { |
|
145 | + return array(); |
|
146 | + } |
|
145 | 147 | |
146 | 148 | $members = array(); |
147 | 149 |
@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | $o = get_http_var('o'); |
15 | - $args = array ( |
|
15 | + $args = array( |
|
16 | 16 | 's' => $this->searchstring, |
17 | 17 | 'p' => $pagenum, |
18 | 18 | 'num' => get_http_var('num'), |
19 | 19 | 'pop' => get_http_var('pop'), |
20 | - 'o' => ($o=='d' || $o=='r' || $o=='o') ? $o : 'd', |
|
20 | + 'o' => ($o == 'd' || $o == 'r' || $o == 'o') ? $o : 'd', |
|
21 | 21 | ); |
22 | 22 | |
23 | 23 | return $args; |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | $sort_order = 'newest'; |
58 | - if ( $args['o'] == 'o' ) { |
|
58 | + if ($args['o'] == 'o') { |
|
59 | 59 | $sort_order = 'oldest'; |
60 | - } else if ( $args['o'] == 'r' ) { |
|
60 | + } else if ($args['o'] == 'r') { |
|
61 | 61 | $sort_order = 'relevance'; |
62 | 62 | } |
63 | 63 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | return array('error' => $SEARCHENGINE->error); |
74 | 74 | } else { |
75 | 75 | $LIST = new \HANSARDLIST(); |
76 | - $data = $LIST->display('search', $args , 'none'); |
|
76 | + $data = $LIST->display('search', $args, 'none'); |
|
77 | 77 | $data['search_type'] = 'normal'; |
78 | 78 | $data['sort_order'] = $sort_order; |
79 | 79 | $data['members'] = $members; |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | return false; |
94 | 94 | } |
95 | 95 | |
96 | - list ($constituencies, ) = \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery($searchterm); |
|
96 | + list ($constituencies,) = \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery($searchterm); |
|
97 | 97 | |
98 | 98 | $constituency = ""; |
99 | - if (count($constituencies)==1) { |
|
99 | + if (count($constituencies) == 1) { |
|
100 | 100 | $constituency = $constituencies[0]; |
101 | 101 | } |
102 | 102 | |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | |
113 | 113 | $MEMBER = new \MySociety\TheyWorkForYou\Member(array('constituency'=>$constituency, 'house' => 1)); |
114 | 114 | $cons[] = $MEMBER; |
115 | - if ( $MEMBER->current_member(1) ) { |
|
115 | + if ($MEMBER->current_member(1)) { |
|
116 | 116 | $mp_types['mp']++; |
117 | 117 | } else { |
118 | 118 | $mp_types['former']++; |
119 | 119 | } |
120 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
120 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
121 | 121 | $cons = array(); |
122 | 122 | } |
123 | 123 | } elseif (count($constituencies)) { |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | try { |
126 | 126 | $MEMBER = new \MySociety\TheyWorkForYou\Member(array('constituency'=>$constituency, 'house' => 1)); |
127 | 127 | $cons[] = $MEMBER; |
128 | - if ( $MEMBER->current_member(1) ) { |
|
128 | + if ($MEMBER->current_member(1)) { |
|
129 | 129 | $mp_types['mp']++; |
130 | 130 | } else { |
131 | 131 | $mp_types['former']++; |
132 | 132 | } |
133 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
133 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
134 | 134 | continue; |
135 | 135 | } |
136 | 136 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $link = array( |
202 | 202 | 'url' => $url->generate(), |
203 | 203 | 'page' => $n, |
204 | - 'current' => ( $n == $data['page'] ) |
|
204 | + 'current' => ($n == $data['page']) |
|
205 | 205 | ); |
206 | 206 | |
207 | 207 | $links[] = $link; |
@@ -242,27 +242,27 @@ discard block |
||
242 | 242 | $numlinks = $this->generate_pagination_links($data, $URL, $firstpage, $lastpage); |
243 | 243 | |
244 | 244 | $pagelinks['nums'] = $numlinks; |
245 | - $pagelinks['first_result'] = $page == 1 ? 1 : ( ( $page - 1 ) * $results_per_page ) + 1; |
|
246 | - $pagelinks['last_result'] = $page == $numpages ? $total_results : $pagelinks['first_result'] + ( $results_per_page - 1 ); |
|
245 | + $pagelinks['first_result'] = $page == 1 ? 1 : (($page - 1) * $results_per_page) + 1; |
|
246 | + $pagelinks['last_result'] = $page == $numpages ? $total_results : $pagelinks['first_result'] + ($results_per_page - 1); |
|
247 | 247 | |
248 | - if ( $page != 1 ) { |
|
248 | + if ($page != 1) { |
|
249 | 249 | $prev_page = $page - 1; |
250 | - $URL->insert(array( 'p' => $prev_page ) ); |
|
250 | + $URL->insert(array('p' => $prev_page)); |
|
251 | 251 | $pagelinks['prev'] = array( |
252 | 252 | 'url' => $URL->generate() |
253 | 253 | ); |
254 | - $URL->insert(array( 'p' => 1 ) ); |
|
254 | + $URL->insert(array('p' => 1)); |
|
255 | 255 | $pagelinks['firstpage'] = array( |
256 | 256 | 'url' => $URL->generate() |
257 | 257 | ); |
258 | 258 | } |
259 | 259 | if ($page != $numpages) { |
260 | 260 | $next_page = $page + 1; |
261 | - $URL->insert(array( 'p' => $next_page ) ); |
|
261 | + $URL->insert(array('p' => $next_page)); |
|
262 | 262 | $pagelinks['next'] = array( |
263 | 263 | 'url' => $URL->generate() |
264 | 264 | ); |
265 | - $URL->insert(array( 'p' => $numpages ) ); |
|
265 | + $URL->insert(array('p' => $numpages)); |
|
266 | 266 | $pagelinks['lastpage'] = array( |
267 | 267 | 'url' => $URL->generate() |
268 | 268 | ); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $links['rss'] = $DATA->page_metadata($this_page, 'rss'); |
280 | 280 | |
281 | 281 | if ($SEARCHENGINE) { |
282 | - $links['email'] = '/alert/?' . ($this->searchstring ? 'alertsearch='.urlencode($this->searchstring) : ''); |
|
282 | + $links['email'] = '/alert/?' . ($this->searchstring ? 'alertsearch=' . urlencode($this->searchstring) : ''); |
|
283 | 283 | $links['email_desc'] = $SEARCHENGINE->query_description_long(); |
284 | 284 | } |
285 | 285 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | $search_engine = new \SEARCHENGINE($filter_ss); |
294 | 294 | $links['email_section'] = $links['email']; |
295 | 295 | $links['email_desc_section'] = $links['email_desc']; |
296 | - $links['email'] = '/alert/?' . ($filter_ss ? 'alertsearch='.urlencode($filter_ss) : ''); |
|
296 | + $links['email'] = '/alert/?' . ($filter_ss ? 'alertsearch=' . urlencode($filter_ss) : ''); |
|
297 | 297 | $links['email_desc'] = $search_engine->query_description_long(); |
298 | 298 | } |
299 | 299 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | protected function getSearchSections() { |
26 | 26 | return array( |
27 | - array( 'section' => 'sp' ) |
|
27 | + array('section' => 'sp') |
|
28 | 28 | ); |
29 | 29 | } |
30 | 30 | } |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | |
13 | 13 | protected function display_front() { |
14 | 14 | global $DATA, $this_page; |
15 | - if ( get_http_var('type') == 'wrans') { |
|
15 | + if (get_http_var('type') == 'wrans') { |
|
16 | 16 | return parent::display_front(); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $data = array(); |
20 | 20 | |
21 | - $args = array( 'months' => 1 ); |
|
21 | + $args = array('months' => 1); |
|
22 | 22 | $WRANSLIST = new \WRANSLIST; |
23 | 23 | |
24 | 24 | $wrans = array(); |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | |
51 | 51 | protected function getSearchSections() { |
52 | 52 | $sections = array( |
53 | - array( 'section' => 'wrans', 'title' => 'Written Answers' ), |
|
53 | + array('section' => 'wrans', 'title' => 'Written Answers'), |
|
54 | 54 | ); |
55 | - if ( get_http_var('type') == '') { |
|
56 | - $sections[] = array( 'section' => 'wms', 'title' => 'Written Ministerial Statements' ); |
|
55 | + if (get_http_var('type') == '') { |
|
56 | + $sections[] = array('section' => 'wms', 'title' => 'Written Ministerial Statements'); |
|
57 | 57 | } |
58 | 58 | return $sections; |
59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | # speech bar the first (assuming that's the question) |
63 | 63 | private $votelinks_so_far = 0; |
64 | 64 | |
65 | - protected function generate_votes ($votes, $id, $gid) { |
|
65 | + protected function generate_votes($votes, $id, $gid) { |
|
66 | 66 | /* |
67 | 67 | Returns HTML for the 'Does this answer the question?' links (wrans) in the sidebar. |
68 | 68 | $votes = => array ( |
@@ -19,7 +19,9 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function fromTimestamp($videodb, $date, $time) { |
22 | - if (!$videodb) return null; |
|
22 | + if (!$videodb) { |
|
23 | + return null; |
|
24 | + } |
|
23 | 25 | date_default_timezone_set('Europe/London'); |
24 | 26 | $epoch = strtotime("$date $time"); |
25 | 27 | $timestamp = gmdate('c', $epoch); |
@@ -38,9 +40,13 @@ discard block |
||
38 | 40 | |
39 | 41 | public static function object($video_id, $start, $gid, $stamping = '', $pid = 0) { |
40 | 42 | $flashvars = "gid=$gid&file=$video_id&start=$start"; |
41 | - if ($stamping) $flashvars .= '&stamping=1'; |
|
42 | - if ($pid) $flashvars .= '&pid=' . $pid; |
|
43 | -/* |
|
43 | + if ($stamping) { |
|
44 | + $flashvars .= '&stamping=1'; |
|
45 | + } |
|
46 | + if ($pid) { |
|
47 | + $flashvars .= '&pid=' . $pid; |
|
48 | + } |
|
49 | + /* |
|
44 | 50 | <object width='360' height='300' |
45 | 51 | classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' |
46 | 52 | codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'> |
@@ -12,7 +12,7 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | public static function dbConnect() { |
15 | - $connstr = 'host='.OPTION_BBC_DB_HOST.' port='.OPTION_BBC_DB_PORT.' dbname='.OPTION_BBC_DB_NAME.' user='.OPTION_BBC_DB_USER.' password='.OPTION_BBC_DB_PASS; |
|
15 | + $connstr = 'host=' . OPTION_BBC_DB_HOST . ' port=' . OPTION_BBC_DB_PORT . ' dbname=' . OPTION_BBC_DB_NAME . ' user=' . OPTION_BBC_DB_USER . ' password=' . OPTION_BBC_DB_PASS; |
|
16 | 16 | $videodb = pg_connect($connstr); |
17 | 17 | |
18 | 18 | return $videodb; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | public function getSetDescriptions() { |
312 | - return $this->set_descs; |
|
312 | + return $this->set_descs; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -397,18 +397,18 @@ discard block |
||
397 | 397 | } |
398 | 398 | |
399 | 399 | public function limitToArray($policies) { |
400 | - $out = array(); |
|
401 | - // Reassemble the new policies list based on the set. |
|
402 | - foreach ($policies as $policy) { |
|
403 | - if (isset($this->policies[$policy])) { |
|
404 | - $out[$policy] = $this->policies[$policy]; |
|
405 | - } |
|
406 | - } |
|
407 | - |
|
408 | - $new_policies = new self(); |
|
409 | - $new_policies->policies = $out; |
|
410 | - |
|
411 | - return $new_policies; |
|
400 | + $out = array(); |
|
401 | + // Reassemble the new policies list based on the set. |
|
402 | + foreach ($policies as $policy) { |
|
403 | + if (isset($this->policies[$policy])) { |
|
404 | + $out[$policy] = $this->policies[$policy]; |
|
405 | + } |
|
406 | + } |
|
407 | + |
|
408 | + $new_policies = new self(); |
|
409 | + $new_policies->policies = $out; |
|
410 | + |
|
411 | + return $new_policies; |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | public function getPolicyDetails($policyID) { |
@@ -293,7 +293,7 @@ |
||
293 | 293 | |
294 | 294 | private $policy_id; |
295 | 295 | |
296 | - public function __construct($policy_id = NULL) { |
|
296 | + public function __construct($policy_id = null) { |
|
297 | 297 | $this->db = new \ParlDB; |
298 | 298 | |
299 | 299 | if ( $policy_id ) { |
@@ -366,14 +366,12 @@ |
||
366 | 366 | public function limitToSet($set) { |
367 | 367 | |
368 | 368 | // Sanity check the set exists |
369 | - if (isset($this->sets[$set])) |
|
370 | - { |
|
369 | + if (isset($this->sets[$set])) { |
|
371 | 370 | $out = array(); |
372 | 371 | // Reassemble the new policies list based on the set. |
373 | 372 | foreach ($this->sets[$set] as $set_policy) |
374 | 373 | { |
375 | - if (isset($this->policies[$set_policy])) |
|
376 | - { |
|
374 | + if (isset($this->policies[$set_policy])) { |
|
377 | 375 | $out[$set_policy] = $this->policies[$set_policy]; |
378 | 376 | } else { |
379 | 377 | // if we've limited the policies to a single one then we only |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | public function __construct($policy_id = NULL) { |
303 | 303 | $this->db = new \ParlDB; |
304 | 304 | |
305 | - if ( $policy_id ) { |
|
305 | + if ($policy_id) { |
|
306 | 306 | $this->policy_id = $policy_id; |
307 | 307 | $this->policies = array( |
308 | 308 | $policy_id => $this->policies[$policy_id] |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | // want to complain here if we're looking for that policy and |
387 | 387 | // it does not exist. Otherwise, if the single policy isn't in |
388 | 388 | // the set we want to return an empty set |
389 | - if ( !isset($this->policy_id) || $set_policy == $this->policy_id ) { |
|
390 | - throw new \Exception ('Policy ' . $set_policy . ' in set "' . $set . '" does not exist.'); |
|
389 | + if (!isset($this->policy_id) || $set_policy == $this->policy_id) { |
|
390 | + throw new \Exception('Policy ' . $set_policy . ' in set "' . $set . '" does not exist.'); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | return $new_policies; |
399 | 399 | |
400 | 400 | } else { |
401 | - throw new \Exception ('Policy set "' . $set . '" does not exist.'); |
|
401 | + throw new \Exception('Policy set "' . $set . '" does not exist.'); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | |
440 | 440 | $image = $q['image']; |
441 | 441 | |
442 | - if ( $image && file_exists(BASEDIR . '/' . $image)) { |
|
442 | + if ($image && file_exists(BASEDIR . '/' . $image)) { |
|
443 | 443 | $props['image'] = $image; |
444 | 444 | $props['image_license'] = $q['image_license']; |
445 | 445 | $props['image_attribution'] = $q['image_attrib']; |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * Image |
|
137 | - * |
|
138 | - * Return a URL for the member's image. |
|
139 | - * |
|
140 | - * @return string The URL of the member's image. |
|
141 | - */ |
|
136 | + * Image |
|
137 | + * |
|
138 | + * Return a URL for the member's image. |
|
139 | + * |
|
140 | + * @return string The URL of the member's image. |
|
141 | + */ |
|
142 | 142 | |
143 | 143 | public function image() { |
144 | 144 | |
@@ -207,15 +207,15 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | - * Offices |
|
211 | - * |
|
212 | - * Return an array of Office objects held (or previously held) by the member. |
|
213 | - * |
|
214 | - * @param string $include_only Restrict the list to include only "previous" or "current" offices. |
|
215 | - * @param bool $ignore_committees Ignore offices that appear to be committee memberships. |
|
216 | - * |
|
217 | - * @return array An array of Office objects. |
|
218 | - */ |
|
210 | + * Offices |
|
211 | + * |
|
212 | + * Return an array of Office objects held (or previously held) by the member. |
|
213 | + * |
|
214 | + * @param string $include_only Restrict the list to include only "previous" or "current" offices. |
|
215 | + * @param bool $ignore_committees Ignore offices that appear to be committee memberships. |
|
216 | + * |
|
217 | + * @return array An array of Office objects. |
|
218 | + */ |
|
219 | 219 | |
220 | 220 | public function offices($include_only = NULL, $ignore_committees = FALSE) { |
221 | 221 | |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
272 | - * Get Other Parties String |
|
273 | - * |
|
274 | - * Return a readable list of party changes for this member. |
|
275 | - * |
|
276 | - * @return string|null A readable list of the party changes for this member. |
|
277 | - */ |
|
272 | + * Get Other Parties String |
|
273 | + * |
|
274 | + * Return a readable list of party changes for this member. |
|
275 | + * |
|
276 | + * @return string|null A readable list of the party changes for this member. |
|
277 | + */ |
|
278 | 278 | |
279 | 279 | public function getOtherPartiesString() { |
280 | 280 | |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
305 | - * Get Other Constituencies String |
|
306 | - * |
|
307 | - * Return a readable list of other constituencies for this member. |
|
308 | - * |
|
309 | - * @return string|null A readable list of the other constituencies for this member. |
|
310 | - */ |
|
305 | + * Get Other Constituencies String |
|
306 | + * |
|
307 | + * Return a readable list of other constituencies for this member. |
|
308 | + * |
|
309 | + * @return string|null A readable list of the other constituencies for this member. |
|
310 | + */ |
|
311 | 311 | |
312 | 312 | public function getOtherConstituenciesString() { |
313 | 313 | |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
323 | - * Get Entered/Left Strings |
|
324 | - * |
|
325 | - * Return an array of readable strings covering when people entered or left |
|
326 | - * various houses. Returns an array since it's possible for a member to have |
|
327 | - * done several of these things. |
|
328 | - * |
|
329 | - * @return array An array of strings of when this member entered or left houses. |
|
330 | - */ |
|
323 | + * Get Entered/Left Strings |
|
324 | + * |
|
325 | + * Return an array of readable strings covering when people entered or left |
|
326 | + * various houses. Returns an array since it's possible for a member to have |
|
327 | + * done several of these things. |
|
328 | + * |
|
329 | + * @return array An array of strings of when this member entered or left houses. |
|
330 | + */ |
|
331 | 331 | public function getEnterLeaveStrings() { |
332 | 332 | $output = array(); |
333 | 333 |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | |
40 | 40 | foreach ($house_types as $house_type) { |
41 | 41 | |
42 | - if (in_array($house_type, $left_house) AND |
|
43 | - $left_house[$house_type]['reason'] AND |
|
42 | + if (in_array($house_type, $left_house) and |
|
43 | + $left_house[$house_type]['reason'] and |
|
44 | 44 | $left_house[$house_type]['reason'] == 'Died' |
45 | 45 | ) { |
46 | 46 | |
47 | 47 | // This member has left a house because of death. |
48 | - return TRUE; |
|
48 | + return true; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | // If we get this far the member hasn't left a house due to death, and |
56 | 56 | // is presumably alive. |
57 | - return FALSE; |
|
57 | + return false; |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | |
77 | 77 | $diff = $date_entered->diff($now); |
78 | 78 | if ( $diff->y == 0 && $diff->m <= 6 ) { |
79 | - return TRUE; |
|
79 | + return true; |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - return FALSE; |
|
83 | + return false; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /* |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | return $this->extra_info()['eu_ref_stance']; |
130 | 130 | } |
131 | 131 | |
132 | - return FALSE; |
|
132 | + return false; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | // We can determine if the image exists or not by testing if size is set |
153 | - if ($size !== NULL) { |
|
154 | - $exists = TRUE; |
|
153 | + if ($size !== null) { |
|
154 | + $exists = true; |
|
155 | 155 | } else { |
156 | - $exists = FALSE; |
|
156 | + $exists = false; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return array( |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @return array An array of Office objects. |
218 | 218 | */ |
219 | 219 | |
220 | - public function offices($include_only = NULL, $ignore_committees = FALSE) { |
|
220 | + public function offices($include_only = null, $ignore_committees = false) { |
|
221 | 221 | |
222 | 222 | $out = array(); |
223 | 223 | |
@@ -253,16 +253,16 @@ discard block |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | private function includeOffice($include_only, $to_date) { |
256 | - $include_office = TRUE; |
|
256 | + $include_office = true; |
|
257 | 257 | |
258 | 258 | // If we should only include previous offices, and the to date is in the future, suppress this office. |
259 | - if ($include_only == 'previous' AND $to_date == '9999-12-31') { |
|
260 | - $include_office = FALSE; |
|
259 | + if ($include_only == 'previous' and $to_date == '9999-12-31') { |
|
260 | + $include_office = false; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | // If we should only include previous offices, and the to date is in the past, suppress this office. |
264 | - if ($include_only == 'current' AND $to_date != '9999-12-31') { |
|
265 | - $include_office = FALSE; |
|
264 | + if ($include_only == 'current' and $to_date != '9999-12-31') { |
|
265 | + $include_office = false; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | return $include_office; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $output .= join('; ', $other_parties); |
288 | 288 | return $output; |
289 | 289 | } else { |
290 | - return NULL; |
|
290 | + return null; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | if ($this->other_constituencies) { |
315 | 315 | return 'Also represented ' . join('; ', array_keys($this->other_constituencies)); |
316 | 316 | } else { |
317 | - return NULL; |
|
317 | + return null; |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $now = new \DateTime(); |
77 | 77 | |
78 | 78 | $diff = $date_entered->diff($now); |
79 | - if ( $diff->y == 0 && $diff->m <= 6 ) { |
|
79 | + if ($diff->y == 0 && $diff->m <= 6) { |
|
80 | 80 | return TRUE; |
81 | 81 | } |
82 | 82 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $entered_house = $this->entered_house($house); |
99 | 99 | |
100 | - if ( $entered_house ) { |
|
100 | + if ($entered_house) { |
|
101 | 101 | $date_entered = $entered_house['date']; |
102 | 102 | } |
103 | 103 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | $left_house = $this->left_house($house); |
119 | 119 | |
120 | - if ( $left_house ) { |
|
120 | + if ($left_house) { |
|
121 | 121 | $date_left = $left_house['date']; |
122 | 122 | } |
123 | 123 | |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | |
146 | 146 | $is_lord = $this->house(HOUSE_TYPE_LORDS); |
147 | 147 | if ($is_lord) { |
148 | - list($image,$size) = Utility\Member::findMemberImage($this->person_id(), false, 'lord'); |
|
148 | + list($image, $size) = Utility\Member::findMemberImage($this->person_id(), false, 'lord'); |
|
149 | 149 | } else { |
150 | - list($image,$size) = Utility\Member::findMemberImage($this->person_id(), false, true); |
|
150 | + list($image, $size) = Utility\Member::findMemberImage($this->person_id(), false, true); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // We can determine if the image exists or not by testing if size is set |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | |
171 | 171 | usort( |
172 | 172 | $departures, |
173 | - function ($a, $b) { |
|
174 | - if ( $a['date'] == $b['date'] ) { |
|
173 | + function($a, $b) { |
|
174 | + if ($a['date'] == $b['date']) { |
|
175 | 175 | return 0; |
176 | - } else if ( $a['date'] < $b['date'] ) { |
|
176 | + } else if ($a['date'] < $b['date']) { |
|
177 | 177 | return -1; |
178 | 178 | } else { |
179 | 179 | return 1; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $office = $office['office']; |
212 | 212 | |
213 | 213 | foreach ($office as $row) { |
214 | - if ( $officeObject = $this->getOfficeObject($include_only, $ignore_committees, $row) ) { |
|
214 | + if ($officeObject = $this->getOfficeObject($include_only, $ignore_committees, $row)) { |
|
215 | 215 | $out[] = $officeObject; |
216 | 216 | } |
217 | 217 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | private function entered_house_line($house, $house_name) { |
349 | 349 | if (isset($this->entered_house[$house]['date'])) { |
350 | 350 | $string = "<strong>Entered the $house_name "; |
351 | - $string .= strlen($this->entered_house[$house]['date_pretty'])==HOUSE_TYPE_SCOTLAND ? 'in ' : 'on '; |
|
351 | + $string .= strlen($this->entered_house[$house]['date_pretty']) == HOUSE_TYPE_SCOTLAND ? 'in ' : 'on '; |
|
352 | 352 | $string .= $this->entered_house[$house]['date_pretty'] . '</strong>'; |
353 | 353 | if ($this->entered_house[$house]['reason']) { |
354 | 354 | $string .= ' — ' . $this->entered_house[$house]['reason']; |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | private function left_house_line($house, $house_name) { |
361 | 361 | if ($this->house($house) && !$this->current_member($house)) { |
362 | 362 | $string = "<strong>Left the $house_name "; |
363 | - $string .= strlen($this->left_house[$house]['date_pretty'])==4 ? 'in ' : 'on '; |
|
363 | + $string .= strlen($this->left_house[$house]['date_pretty']) == 4 ? 'in ' : 'on '; |
|
364 | 364 | $string .= $this->left_house[$house]['date_pretty'] . '</strong>'; |
365 | 365 | if ($this->left_house[$house]['reason']) { |
366 | 366 | $string .= ' — ' . $this->left_house[$house]['reason']; |
@@ -373,19 +373,19 @@ discard block |
||
373 | 373 | $policy_diffs = array(); |
374 | 374 | $party_positions = $party->getAllPolicyPositions($policiesList); |
375 | 375 | |
376 | - if ( !$party_positions ) { |
|
376 | + if (!$party_positions) { |
|
377 | 377 | return $policy_diffs; |
378 | 378 | } |
379 | 379 | |
380 | - foreach ( $positions->positionsById as $policy_id => $details ) { |
|
381 | - if ( $details['has_strong'] && $details['score'] != -1 && isset($party_positions[$policy_id])) { |
|
380 | + foreach ($positions->positionsById as $policy_id => $details) { |
|
381 | + if ($details['has_strong'] && $details['score'] != -1 && isset($party_positions[$policy_id])) { |
|
382 | 382 | $mp_score = $details['score']; |
383 | 383 | $party_score = $party_positions[$policy_id]['score']; |
384 | 384 | |
385 | 385 | $score_diff = $this->calculatePolicyDiffScore($mp_score, $party_score); |
386 | 386 | |
387 | 387 | // skip anything that isn't a yes vs no diff |
388 | - if ( $only_diffs && $score_diff < 2 ) { |
|
388 | + if ($only_diffs && $score_diff < 2) { |
|
389 | 389 | continue; |
390 | 390 | } |
391 | 391 | $policy_diffs[$policy_id] = $score_diff; |
@@ -397,18 +397,18 @@ discard block |
||
397 | 397 | return $policy_diffs; |
398 | 398 | } |
399 | 399 | |
400 | - private function calculatePolicyDiffScore( $mp_score, $party_score ) { |
|
400 | + private function calculatePolicyDiffScore($mp_score, $party_score) { |
|
401 | 401 | $score_diff = abs($mp_score - $party_score); |
402 | 402 | // if they are on opposite sides of mixture of for and against |
403 | 403 | if ( |
404 | - ( $mp_score < 0.4 && $party_score > 0.6 ) || |
|
405 | - ( $mp_score > 0.6 && $party_score < 0.4 ) |
|
404 | + ($mp_score < 0.4 && $party_score > 0.6) || |
|
405 | + ($mp_score > 0.6 && $party_score < 0.4) |
|
406 | 406 | ) { |
407 | 407 | $score_diff += 2; |
408 | 408 | // if on is mixture of for and against and one is for/against |
409 | 409 | } else if ( |
410 | - ( $mp_score > 0.4 && $mp_score < 0.6 && ( $party_score > 0.6 || $party_score < 0.4 ) ) || |
|
411 | - ( $party_score > 0.4 && $party_score < 0.6 && ( $mp_score > 0.6 || $mp_score < 0.4 ) ) |
|
410 | + ($mp_score > 0.4 && $mp_score < 0.6 && ($party_score > 0.6 || $party_score < 0.4)) || |
|
411 | + ($party_score > 0.4 && $party_score < 0.6 && ($mp_score > 0.6 || $mp_score < 0.4)) |
|
412 | 412 | ) { |
413 | 413 | $score_diff += 1; |
414 | 414 | } |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | |
422 | 422 | $mreg = array(); |
423 | 423 | $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($postcode); |
424 | - if ( isset($constituencies[$type]) ) { |
|
424 | + if (isset($constituencies[$type])) { |
|
425 | 425 | $cons_name = $constituencies[$type]; |
426 | 426 | $query_base = "SELECT member.person_id, title, lordofname, given_name, family_name, constituency, house |
427 | 427 | FROM member, person_names |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | ':cons_name' => $cons_name |
439 | 439 | ) |
440 | 440 | ); |
441 | - if ( !$q->rows() && ($dissolution = Dissolution::db()) ) { |
|
441 | + if (!$q->rows() && ($dissolution = Dissolution::db())) { |
|
442 | 442 | $q = $db->query("$query_base AND $dissolution[query]", |
443 | 443 | array( |
444 | 444 | ':house' => $house, |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | } |
463 | 463 | |
464 | 464 | public static function getRepNameForHouse($house) { |
465 | - switch ( $house ) { |
|
465 | + switch ($house) { |
|
466 | 466 | case HOUSE_TYPE_COMMONS: |
467 | 467 | $name = 'MP'; |
468 | 468 | break; |
@@ -48,7 +48,7 @@ |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | protected function getRegionalList() { |
51 | - return NULL; |
|
51 | + return null; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | protected function getEditorialContent() { |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | $gid = $featured->get_gid(); |
58 | 58 | $gidCheck = new Gid($gid); |
59 | 59 | $gid = $gidCheck->checkForRedirect(); |
60 | - if ( $gid ) { |
|
60 | + if ($gid) { |
|
61 | 61 | $title = $featured->get_title(); |
62 | 62 | $context = $featured->get_context(); |
63 | 63 | $related = $featured->get_related(); |
64 | 64 | $item = $this->getFeaturedDebate($gid, $title, $context, $related); |
65 | 65 | } else { |
66 | 66 | $item = $debatelist->display('recent_debates', array('days' => 7, 'num' => 1), 'none'); |
67 | - if ( isset($item['data']) && count($item['data']) ) { |
|
67 | + if (isset($item['data']) && count($item['data'])) { |
|
68 | 68 | $item = $item['data'][0]; |
69 | 69 | $more_url = new Url('debates'); |
70 | 70 | $item['more_url'] = $more_url->generate(); |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | $item['featured'] = true; |
96 | 96 | |
97 | 97 | $related_debates = array(); |
98 | - foreach ( $related as $related_gid ) { |
|
99 | - if ( $related_gid ) { |
|
98 | + foreach ($related as $related_gid) { |
|
99 | + if ($related_gid) { |
|
100 | 100 | $related_item = $debatelist->display('featured_gid', array('gid' => $related_gid), 'none'); |
101 | 101 | $related_debates[] = $related_item['data']; |
102 | 102 | } |
@@ -121,21 +121,21 @@ discard block |
||
121 | 121 | |
122 | 122 | $recent_content = array(); |
123 | 123 | |
124 | - foreach ( $this->recent_types as $class => $recent ) { |
|
124 | + foreach ($this->recent_types as $class => $recent) { |
|
125 | 125 | $class = "\\$class"; |
126 | 126 | $instance = new $class(); |
127 | 127 | $more_url = new Url($recent[1]); |
128 | - if ( $recent[0] == 'recent_pbc_debates' ) { |
|
129 | - $content = array( 'data' => $instance->display($recent[0], array('num' => 5), 'none') ); |
|
128 | + if ($recent[0] == 'recent_pbc_debates') { |
|
129 | + $content = array('data' => $instance->display($recent[0], array('num' => 5), 'none')); |
|
130 | 130 | } else { |
131 | 131 | $content = $instance->display($recent[0], array('days' => 7, 'num' => 1), 'none'); |
132 | - if ( isset($content['data']) && count($content['data']) ) { |
|
132 | + if (isset($content['data']) && count($content['data'])) { |
|
133 | 133 | $content = $content['data'][0]; |
134 | 134 | } else { |
135 | 135 | $content = array(); |
136 | 136 | } |
137 | 137 | } |
138 | - if ( $content ) { |
|
138 | + if ($content) { |
|
139 | 139 | $content['more_url'] = $more_url->generate(); |
140 | 140 | $content['desc'] = $recent[2]; |
141 | 141 | $recent_content[] = $content; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | WHERE event_date >= :date |
155 | 155 | AND deleted = 0 |
156 | 156 | ORDER BY event_date, chamber, pos", |
157 | - array( ':date' => $date ) |
|
157 | + array(':date' => $date) |
|
158 | 158 | ); |
159 | 159 | |
160 | 160 | $data = array(); |
@@ -11,7 +11,7 @@ |
||
11 | 11 | class Hansard |
12 | 12 | { |
13 | 13 | public static function get_gid_from_url($url) { |
14 | - $gid = NULL; |
|
14 | + $gid = null; |
|
15 | 15 | $parts = parse_url($url); |
16 | 16 | parse_str($parts['query'], $query); |
17 | 17 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $parts = parse_url($url); |
16 | 16 | parse_str($parts['query'], $query); |
17 | 17 | |
18 | - if ( $query['id'] ) { |
|
18 | + if ($query['id']) { |
|
19 | 19 | if (strpos($parts['path'], 'lords') !== false) { |
20 | 20 | $gid = 'uk.org.publicwhip/lords/'; |
21 | 21 | } elseif (strpos($parts['path'], 'whall') !== false) { |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | |
31 | 31 | |
32 | 32 | public static function gid_to_url($gid) { |
33 | - if ( !$gid ) { |
|
33 | + if (!$gid) { |
|
34 | 34 | return ''; |
35 | 35 | } |
36 | 36 | global $hansardmajors; |
37 | 37 | $db = new \ParlDB(); |
38 | 38 | |
39 | - $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array( ':gid' => $gid ))->first(); |
|
39 | + $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid))->first(); |
|
40 | 40 | $url_gid = fix_gid_from_db($gid); |
41 | 41 | $url = new \MySociety\TheyWorkForYou\Url($hansardmajors[$q['major']]['page']); |
42 | 42 | $url->insert(array('id' => $url_gid)); |