@@ -17,17 +17,17 @@ discard block |
||
17 | 17 | } |
18 | 18 | |
19 | 19 | private function fetch_division_page() { |
20 | - return $this->fetch_page( array( 'pagetype' => 'divisions', 'pid' => 2, 'policy' => 363, 'url' => '/mp/2/test_current-mp/test_westminster_constituency/divisions' ) ); |
|
20 | + return $this->fetch_page(array('pagetype' => 'divisions', 'pid' => 2, 'policy' => 363, 'url' => '/mp/2/test_current-mp/test_westminster_constituency/divisions')); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | private function fetch_mp_recent_page() |
24 | 24 | { |
25 | - $vars = array( 'pagetype' => 'recent', 'pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency/recent' ); |
|
25 | + $vars = array('pagetype' => 'recent', 'pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency/recent'); |
|
26 | 26 | return $this->base_fetch_page($vars, 'mp', 'index.php', '/mp/recent.php'); |
27 | 27 | } |
28 | 28 | |
29 | 29 | private function fetch_recent_page() { |
30 | - return $this->base_fetch_page( array('url' => '/divisions' ), 'divisions', 'index.php', '/divisions/index.php' ); |
|
30 | + return $this->base_fetch_page(array('url' => '/divisions'), 'divisions', 'index.php', '/divisions/index.php'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | public function testNotEnoughInfoStatement() { |
116 | - return $this->fetch_page( array( 'pagetype' => 'divisions', 'pid' => 2, 'policy' => 810, 'url' => '/mp/2/test_current-mp/test_westminster_constituency/divisions' ) ); |
|
116 | + return $this->fetch_page(array('pagetype' => 'divisions', 'pid' => 2, 'policy' => 810, 'url' => '/mp/2/test_current-mp/test_westminster_constituency/divisions')); |
|
117 | 117 | $this->assertContains('we don’t have enough information to calculate Test Current-MP’s position', $page); |
118 | 118 | } |
119 | 119 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | public function testSingleDivision() { |
127 | - $page = $this->base_fetch_page( array('url' => '/divisions/division.php', 'vote' => 'pw-3012-01-01-1-commons' ), 'divisions', 'division.php', '/divisions/division.php' ); |
|
127 | + $page = $this->base_fetch_page(array('url' => '/divisions/division.php', 'vote' => 'pw-3012-01-01-1-commons'), 'divisions', 'division.php', '/divisions/division.php'); |
|
128 | 128 | $this->assertContains('A majority of MPs <b>voted in favour</b> of a thing', $page); |
129 | 129 | $this->assertContains('Aye: 200', $page); |
130 | 130 | $this->assertNotContains('No:', $page); # Summary 100, but no actual votes. In reality, summary can only be <= actual. |
@@ -28,8 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | return $data; |
30 | 30 | } |
31 | - if (count($gids) == 5000) |
|
32 | - $data['limit_reached'] = true; |
|
31 | + if (count($gids) == 5000) { |
|
32 | + $data['limit_reached'] = true; |
|
33 | + } |
|
33 | 34 | |
34 | 35 | # Fetch all the speakers of the results, count them up and get min/max date usage |
35 | 36 | $speaker_count = array(); |
@@ -45,8 +46,12 @@ discard block |
||
45 | 46 | $mindate[$person_id] = '9999-12-31'; |
46 | 47 | } |
47 | 48 | $speaker_count[$person_id]++; |
48 | - if ($hdate < $mindate[$person_id]) $mindate[$person_id] = $hdate; |
|
49 | - if ($hdate > $maxdate[$person_id]) $maxdate[$person_id] = $hdate; |
|
49 | + if ($hdate < $mindate[$person_id]) { |
|
50 | + $mindate[$person_id] = $hdate; |
|
51 | + } |
|
52 | + if ($hdate > $maxdate[$person_id]) { |
|
53 | + $maxdate[$person_id] = $hdate; |
|
54 | + } |
|
50 | 55 | } |
51 | 56 | |
52 | 57 | # Fetch details of all the speakers |
@@ -80,8 +85,9 @@ discard block |
||
80 | 85 | $dept = $row['dept']; |
81 | 86 | $posn = $row['position']; |
82 | 87 | $moffice_id = $row['moffice_id']; |
83 | - if ($dept && $row['to_date'] == '9999-12-31') |
|
84 | - $speakers[$pid]['office'][$moffice_id] = prettify_office($posn, $dept); |
|
88 | + if ($dept && $row['to_date'] == '9999-12-31') { |
|
89 | + $speakers[$pid]['office'][$moffice_id] = prettify_office($posn, $dept); |
|
90 | + } |
|
85 | 91 | if (!isset($speakers[$pid]['name'])) { |
86 | 92 | $speakers[$pid]['name'] = $full_name . ($house==1?' MP':''); |
87 | 93 | } |
@@ -139,7 +145,9 @@ discard block |
||
139 | 145 | */ |
140 | 146 | |
141 | 147 | public static function searchMemberDbLookup($searchstring, $current_only=false) { |
142 | - if (!$searchstring) return false; |
|
148 | + if (!$searchstring) { |
|
149 | + return false; |
|
150 | + } |
|
143 | 151 | $searchwords = explode(' ', $searchstring, 3); |
144 | 152 | $params = array(); |
145 | 153 | if (count($searchwords) == 1) { |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | if ($dept && $row['to_date'] == '9999-12-31') |
84 | 84 | $speakers[$pid]['office'][$moffice_id] = prettify_office($posn, $dept); |
85 | 85 | if (!isset($speakers[$pid]['name'])) { |
86 | - $speakers[$pid]['name'] = $full_name . ($house==1?' MP':''); |
|
86 | + $speakers[$pid]['name'] = $full_name . ($house == 1 ? ' MP' : ''); |
|
87 | 87 | } |
88 | - if ( !isset($speakers[$pid]['party']) && $party ) { |
|
88 | + if (!isset($speakers[$pid]['party']) && $party) { |
|
89 | 89 | $speakers[$pid]['party'] = $party; |
90 | 90 | } |
91 | 91 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * Return query result from looking for MPs |
139 | 139 | */ |
140 | 140 | |
141 | - public static function searchMemberDbLookup($searchstring, $current_only=false) { |
|
141 | + public static function searchMemberDbLookup($searchstring, $current_only = false) { |
|
142 | 142 | if (!$searchstring) return false; |
143 | 143 | $searchwords = explode(' ', $searchstring, 3); |
144 | 144 | $params = array(); |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | // And here we're assuming the user's put the names in the right order. |
151 | 151 | $params[':like_0'] = '%' . $searchwords[0] . '%'; |
152 | 152 | $params[':like_1'] = '%' . $searchwords[1] . '%'; |
153 | - $params[':like_0_and_1'] = '%' . $searchwords[0] . ' '. $searchwords[1] . '%'; |
|
154 | - $params[':like_0_and_1_hyphen'] = '%' . $searchwords[0] . '-'. $searchwords[1] . '%'; |
|
153 | + $params[':like_0_and_1'] = '%' . $searchwords[0] . ' ' . $searchwords[1] . '%'; |
|
154 | + $params[':like_0_and_1_hyphen'] = '%' . $searchwords[0] . '-' . $searchwords[1] . '%'; |
|
155 | 155 | $where = "(given_name LIKE :like_0 AND family_name LIKE :like_1)"; |
156 | 156 | $where .= " OR (given_name LIKE :like_1 AND family_name LIKE :like_0)"; |
157 | 157 | $where .= " OR (title LIKE :like_0 AND family_name LIKE :like_1)"; |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | $params[':like_0'] = '%' . $searchwords[0] . '%'; |
167 | 167 | $params[':like_1'] = '%' . $searchwords[1] . '%'; |
168 | 168 | $params[':like_2'] = '%' . $searchwords[2] . '%'; |
169 | - $params[':like_0_and_1'] = '%' . $searchwords[0] . ' '. $searchwords[1] . '%'; |
|
170 | - $params[':like_1_and_2'] = '%' . $searchwords[1] . ' '. $searchwords[2] . '%'; |
|
171 | - $params[':like_1_and_2_hyphen'] = '%' . $searchwords[1] . '-'. $searchwords[2] . '%'; |
|
169 | + $params[':like_0_and_1'] = '%' . $searchwords[0] . ' ' . $searchwords[1] . '%'; |
|
170 | + $params[':like_1_and_2'] = '%' . $searchwords[1] . ' ' . $searchwords[2] . '%'; |
|
171 | + $params[':like_1_and_2_hyphen'] = '%' . $searchwords[1] . '-' . $searchwords[2] . '%'; |
|
172 | 172 | $where = "(given_name LIKE :like_0_and_1 AND family_name LIKE :like_2)"; |
173 | 173 | $where .= " OR (given_name LIKE :like_0 AND family_name LIKE :like_1_and_2)"; |
174 | 174 | $where .= " OR (given_name LIKE :like_0 AND family_name LIKE :like_1_and_2_hyphen)"; |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | return $q; |
184 | 184 | } |
185 | 185 | |
186 | - public static function searchMemberDbLookupWithNames($searchstring, $current_only=false) { |
|
186 | + public static function searchMemberDbLookupWithNames($searchstring, $current_only = false) { |
|
187 | 187 | $q = self::searchMemberDbLookup($searchstring, $current_only); |
188 | 188 | |
189 | 189 | if (!$q->rows()) { |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | // Looks like a postcode - can we find the constituency? |
239 | 239 | $constituency = Postcode::postcodeToConstituency($searchterm); |
240 | 240 | if ($constituency) { |
241 | - return array( array($constituency), true ); |
|
241 | + return array(array($constituency), true); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $constituencies[] = $row['name']; |
257 | 257 | } |
258 | 258 | |
259 | - return array( $constituencies, false ); |
|
259 | + return array($constituencies, false); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $speakers = []; |
273 | 273 | |
274 | 274 | foreach ($criteria as $c) { |
275 | - if (preg_match('#^speaker:(\d+)#',$c,$m)) { |
|
275 | + if (preg_match('#^speaker:(\d+)#', $c, $m)) { |
|
276 | 276 | $MEMBER = new \MEMBER(array('person_id'=>$m[1])); |
277 | 277 | $speakers[$m[1]] = $MEMBER->full_name(); |
278 | 278 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | public static function speakerIDsToNames($searchstring) { |
292 | 292 | $speakers = self::speakerNamesForIDs($searchstring); |
293 | 293 | |
294 | - foreach ( $speakers as $id => $name ) { |
|
294 | + foreach ($speakers as $id => $name) { |
|
295 | 295 | $searchstring = str_replace('speaker:' . $id, "speaker:$name", $searchstring); |
296 | 296 | } |
297 | 297 |
@@ -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,17 +85,17 @@ discard block |
||
85 | 85 | // Keep the references until after the history that's in a timeline: |
86 | 86 | $references = array(); |
87 | 87 | foreach ($row_data as $row) { |
88 | - if( ! $row["date"] ) { |
|
88 | + if (!$row["date"]) { |
|
89 | 89 | // If this mention isn't associated with a date, the difference won't be interesting. |
90 | 90 | $last_date = NULL; |
91 | 91 | } |
92 | 92 | $description = ''; |
93 | 93 | if ($last_date && ($last_date != $row["date"])) { |
94 | 94 | // Calculate how long the gap was in days: |
95 | - $daysdiff = (integer)((strtotime($row["date"]) - strtotime($last_date)) / 86400); |
|
95 | + $daysdiff = (integer) ((strtotime($row["date"]) - strtotime($last_date)) / 86400); |
|
96 | 96 | $daysstring = ($daysdiff == 1) ? "day" : "days"; |
97 | 97 | $further = ""; |
98 | - if( $first_difference_output ) { |
|
98 | + if ($first_difference_output) { |
|
99 | 99 | $first_difference_output = FALSE; |
100 | 100 | } else { |
101 | 101 | $further = " a further"; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $inner = "BUG: Unknown mention type $row[type]"; |
107 | 107 | $date = format_date($row['date'], SHORTDATEFORMAT); |
108 | 108 | $url = $row['url']; |
109 | - if ( strpos($url, 'business/businessBulletin') !== FALSE ) { |
|
109 | + if (strpos($url, 'business/businessBulletin') !== FALSE) { |
|
110 | 110 | $url = str_replace('www.scottish', 'archive.scottish', $url); |
111 | 111 | } |
112 | 112 | switch ($row["type"]) { |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | $inner = "Mentioned in <a class=\"debate-speech__meta__link\" href=\"$url\">tabled written questions on $date</a>"; |
121 | 121 | break; |
122 | 122 | case 4: |
123 | - if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['gid'],$m) ) { |
|
123 | + if (preg_match('/^uk.org.publicwhip\/spq\/(.*)$/', $row['gid'], $m)) { |
|
124 | 124 | $URL = new \MySociety\TheyWorkForYou\Url("spwrans"); |
125 | - $URL->insert( array('spid' => $m[1]) ); |
|
125 | + $URL->insert(array('spid' => $m[1])); |
|
126 | 126 | $relative_url = $URL->generate("none"); |
127 | 127 | $inner = "Given a <a class=\"debate-speech__meta__link\" href=\"$relative_url\">written answer on $date</a>"; |
128 | 128 | } |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | $inner = "Given a holding answer on $date"; |
132 | 132 | break; |
133 | 133 | case 6: |
134 | - if( preg_match('/^uk.org.publicwhip\/spor\/(.*)$/',$row['mentioned_gid'],$m) ) { |
|
134 | + if (preg_match('/^uk.org.publicwhip\/spor\/(.*)$/', $row['mentioned_gid'], $m)) { |
|
135 | 135 | $URL = new \MySociety\TheyWorkForYou\Url("spdebates"); |
136 | - $URL->insert( array('id' => $m[1]) ); |
|
136 | + $URL->insert(array('id' => $m[1])); |
|
137 | 137 | $relative_url = $URL->generate("none"); |
138 | 138 | $inner = "<a href=\"$relative_url\">Asked in parliament on $date</a>"; |
139 | 139 | } |
140 | 140 | break; |
141 | 141 | case 7: |
142 | - if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['mentioned_gid'],$m) ) { |
|
142 | + if (preg_match('/^uk.org.publicwhip\/spq\/(.*)$/', $row['mentioned_gid'], $m)) { |
|
143 | 143 | $referencing_spid = $m[1]; |
144 | 144 | $URL = new \MySociety\TheyWorkForYou\Url("spwrans"); |
145 | - $URL->insert( array('spid' => $referencing_spid) ); |
|
145 | + $URL->insert(array('spid' => $referencing_spid)); |
|
146 | 146 | $relative_url = $URL->generate("none"); |
147 | 147 | $inner = "Referenced in <a href=\"$relative_url\">question $referencing_spid</a>"; |
148 | 148 | $reference = TRUE; |
149 | 149 | } |
150 | 150 | break; |
151 | 151 | } |
152 | - if( $reference ) { |
|
152 | + if ($reference) { |
|
153 | 153 | $references[] = "\n<li>$inner."; |
154 | 154 | } else { |
155 | 155 | $result .= "\n<li class=\"link-to-hansard\">$description$inner</span>"; |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | return ''; |
81 | 81 | } |
82 | 82 | $result = ''; |
83 | - $last_date = NULL; |
|
84 | - $first_difference_output = TRUE; |
|
83 | + $last_date = null; |
|
84 | + $first_difference_output = true; |
|
85 | 85 | // Keep the references until after the history that's in a timeline: |
86 | 86 | $references = array(); |
87 | 87 | foreach ($row_data as $row) { |
88 | 88 | if( ! $row["date"] ) { |
89 | 89 | // If this mention isn't associated with a date, the difference won't be interesting. |
90 | - $last_date = NULL; |
|
90 | + $last_date = null; |
|
91 | 91 | } |
92 | 92 | $description = ''; |
93 | 93 | if ($last_date && ($last_date != $row["date"])) { |
@@ -96,17 +96,17 @@ discard block |
||
96 | 96 | $daysstring = ($daysdiff == 1) ? "day" : "days"; |
97 | 97 | $further = ""; |
98 | 98 | if( $first_difference_output ) { |
99 | - $first_difference_output = FALSE; |
|
99 | + $first_difference_output = false; |
|
100 | 100 | } else { |
101 | 101 | $further = " a further"; |
102 | 102 | } |
103 | 103 | $description = "\n<span class=\"question-mention-gap\">After$further $daysdiff $daysstring,</span> "; |
104 | 104 | } |
105 | - $reference = FALSE; |
|
105 | + $reference = false; |
|
106 | 106 | $inner = "BUG: Unknown mention type $row[type]"; |
107 | 107 | $date = format_date($row['date'], SHORTDATEFORMAT); |
108 | 108 | $url = $row['url']; |
109 | - if ( strpos($url, 'business/businessBulletin') !== FALSE ) { |
|
109 | + if ( strpos($url, 'business/businessBulletin') !== false ) { |
|
110 | 110 | $url = str_replace('www.scottish', 'archive.scottish', $url); |
111 | 111 | } |
112 | 112 | switch ($row["type"]) { |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $URL->insert( array('spid' => $referencing_spid) ); |
146 | 146 | $relative_url = $URL->generate("none"); |
147 | 147 | $inner = "Referenced in <a href=\"$relative_url\">question $referencing_spid</a>"; |
148 | - $reference = TRUE; |
|
148 | + $reference = true; |
|
149 | 149 | } |
150 | 150 | break; |
151 | 151 | } |
@@ -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 |
@@ -141,7 +141,7 @@ 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 | |
@@ -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(), |
@@ -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($row['alert_id'] . '::' . $row['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; |
@@ -23,7 +23,7 @@ |
||
23 | 23 | $this->db = new \ParlDB; |
24 | 24 | } |
25 | 25 | |
26 | - private function query($where='') { |
|
26 | + private function query($where = '') { |
|
27 | 27 | $q = $this->db->query( |
28 | 28 | "SELECT id, slug, title, description, search_string, front_page, image FROM topics $where" |
29 | 29 | ); |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | public function getTopic($topic_name) { |
44 | - $q = $this->db->query( |
|
45 | - "SELECT id, slug, title, description, search_string, front_page, image FROM topics WHERE slug = :slug", |
|
46 | - array(':slug' => $topic_name) |
|
47 | - )->first(); |
|
48 | - if ($q) { |
|
49 | - return new Topic($q); |
|
50 | - } |
|
44 | + $q = $this->db->query( |
|
45 | + "SELECT id, slug, title, description, search_string, front_page, image FROM topics WHERE slug = :slug", |
|
46 | + array(':slug' => $topic_name) |
|
47 | + )->first(); |
|
48 | + if ($q) { |
|
49 | + return new Topic($q); |
|
50 | + } |
|
51 | 51 | |
52 | - return NULL; |
|
52 | + return NULL; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | public function getFrontPageTopics() { |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | // PDO doesn't cope with arrays so we have to do this by hand :| |
61 | 61 | $quoted = array(); |
62 | 62 | if ($topics) { |
63 | - foreach ($topics as $topic) { |
|
64 | - $quoted[] = $this->db->quote($topic); |
|
65 | - } |
|
66 | - $topics_str = implode(',', $quoted); |
|
63 | + foreach ($topics as $topic) { |
|
64 | + $quoted[] = $this->db->quote($topic); |
|
65 | + } |
|
66 | + $topics_str = implode(',', $quoted); |
|
67 | 67 | |
68 | - $this->db->query("UPDATE topics SET front_page = TRUE WHERE slug IN ($topics_str)"); |
|
69 | - $this->db->query("UPDATE topics SET front_page = FALSE WHERE slug NOT IN ($topics_str)"); |
|
68 | + $this->db->query("UPDATE topics SET front_page = TRUE WHERE slug IN ($topics_str)"); |
|
69 | + $this->db->query("UPDATE topics SET front_page = FALSE WHERE slug NOT IN ($topics_str)"); |
|
70 | 70 | } else { |
71 | - $this->db->query("UPDATE topics SET front_page = FALSE"); |
|
71 | + $this->db->query("UPDATE topics SET front_page = FALSE"); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return true; |
@@ -49,7 +49,7 @@ |
||
49 | 49 | return new Topic($q); |
50 | 50 | } |
51 | 51 | |
52 | - return NULL; |
|
52 | + return null; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | public function getFrontPageTopics() { |
@@ -10,12 +10,12 @@ |
||
10 | 10 | order by hdate, hpos'); |
11 | 11 | $last = array('hdate'=>''); |
12 | 12 | foreach ($q as $row) { |
13 | - if ($row['hdate'] != $last['hdate']) |
|
14 | - $last = array(); |
|
15 | - if ($last && $row['atime'] < $last['atime']-5) { |
|
16 | - print "PROBLEM; current row is $row[gid] $row[hdate] $row[atime]\n"; |
|
17 | - print " Last was $last[gid] $last[hdate] $last[atime]\n"; |
|
18 | - } |
|
19 | - $last = $row; |
|
13 | + if ($row['hdate'] != $last['hdate']) |
|
14 | + $last = array(); |
|
15 | + if ($last && $row['atime'] < $last['atime']-5) { |
|
16 | + print "PROBLEM; current row is $row[gid] $row[hdate] $row[atime]\n"; |
|
17 | + print " Last was $last[gid] $last[hdate] $last[atime]\n"; |
|
18 | + } |
|
19 | + $last = $row; |
|
20 | 20 | } |
21 | 21 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | foreach ($q as $row) { |
13 | 13 | if ($row['hdate'] != $last['hdate']) |
14 | 14 | $last = array(); |
15 | - if ($last && $row['atime'] < $last['atime']-5) { |
|
15 | + if ($last && $row['atime'] < $last['atime'] - 5) { |
|
16 | 16 | print "PROBLEM; current row is $row[gid] $row[hdate] $row[atime]\n"; |
17 | 17 | print " Last was $last[gid] $last[hdate] $last[atime]\n"; |
18 | 18 | } |
@@ -10,8 +10,9 @@ |
||
10 | 10 | order by hdate, hpos'); |
11 | 11 | $last = array('hdate'=>''); |
12 | 12 | foreach ($q as $row) { |
13 | - if ($row['hdate'] != $last['hdate']) |
|
14 | - $last = array(); |
|
13 | + if ($row['hdate'] != $last['hdate']) { |
|
14 | + $last = array(); |
|
15 | + } |
|
15 | 16 | if ($last && $row['atime'] < $last['atime']-5) { |
16 | 17 | print "PROBLEM; current row is $row[gid] $row[hdate] $row[atime]\n"; |
17 | 18 | print " Last was $last[gid] $last[hdate] $last[atime]\n"; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | $db = new ParlDB; |
7 | 7 | |
8 | 8 | $q = $db->query( |
9 | - 'select person_id, |
|
9 | + 'select person_id, |
|
10 | 10 | count(hansard.epobject_id) as wrans, |
11 | 11 | sum(yes_votes) + IFNULL((select sum(vote) from uservotes, hansard as hansard2 |
12 | 12 | where uservotes.epobject_id=hansard2.epobject_id |
@@ -20,23 +20,23 @@ discard block |
||
20 | 20 | group by person_id'); |
21 | 21 | |
22 | 22 | foreach ($q as $row) { |
23 | - $p_id = $row['person_id']; |
|
24 | - $name = $row['first_name'] . ' ' . $row['last_name']; |
|
25 | - $con = $row['constituency']; |
|
26 | - $wrans = $row['wrans']; |
|
27 | - $yes = $row['yes']; |
|
28 | - $no = $row['no']; |
|
29 | - if ($p_id) { |
|
30 | - $qq = $db->query('(select hansard.epobject_id from hansard, uservotes |
|
23 | + $p_id = $row['person_id']; |
|
24 | + $name = $row['first_name'] . ' ' . $row['last_name']; |
|
25 | + $con = $row['constituency']; |
|
26 | + $wrans = $row['wrans']; |
|
27 | + $yes = $row['yes']; |
|
28 | + $no = $row['no']; |
|
29 | + if ($p_id) { |
|
30 | + $qq = $db->query('(select hansard.epobject_id from hansard, uservotes |
|
31 | 31 | where hansard.epobject_id=uservotes.epobject_id |
32 | 32 | and hansard.person_id = '.$p_id.' and major=3 and minor=2 and left_house>curdate()) |
33 | 33 | union |
34 | 34 | (select hansard.epobject_id from hansard,member,anonvotes |
35 | 35 | where hansard.epobject_id=anonvotes.epobject_id |
36 | 36 | and hansard.person_id = '.$p_id.' and major=3 and minor=2 and left_house>curdate())'); |
37 | - $wrans_with_votes = $qq->rows(); |
|
38 | - } else { |
|
39 | - $wrans_with_votes = ''; |
|
40 | - } |
|
41 | - print "$name\t$con\t$wrans\t$wrans_with_votes\t$yes\t$no\n"; |
|
37 | + $wrans_with_votes = $qq->rows(); |
|
38 | + } else { |
|
39 | + $wrans_with_votes = ''; |
|
40 | + } |
|
41 | + print "$name\t$con\t$wrans\t$wrans_with_votes\t$yes\t$no\n"; |
|
42 | 42 | } |
@@ -29,11 +29,11 @@ |
||
29 | 29 | if ($p_id) { |
30 | 30 | $qq = $db->query('(select hansard.epobject_id from hansard, uservotes |
31 | 31 | where hansard.epobject_id=uservotes.epobject_id |
32 | - and hansard.person_id = '.$p_id.' and major=3 and minor=2 and left_house>curdate()) |
|
32 | + and hansard.person_id = '.$p_id . ' and major=3 and minor=2 and left_house>curdate()) |
|
33 | 33 | union |
34 | 34 | (select hansard.epobject_id from hansard,member,anonvotes |
35 | 35 | where hansard.epobject_id=anonvotes.epobject_id |
36 | - and hansard.person_id = '.$p_id.' and major=3 and minor=2 and left_house>curdate())'); |
|
36 | + and hansard.person_id = '.$p_id . ' and major=3 and minor=2 and left_house>curdate())'); |
|
37 | 37 | $wrans_with_votes = $qq->rows(); |
38 | 38 | } else { |
39 | 39 | $wrans_with_votes = ''; |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | public function get_text() { |
29 | 29 | $text = $this->mem->get('banner'); |
30 | 30 | |
31 | - if ( $text === false ) { |
|
31 | + if ($text === false) { |
|
32 | 32 | $q = $this->db->query("SELECT value FROM editorial WHERE item = 'banner'")->first(); |
33 | 33 | |
34 | 34 | if ($q) { |
35 | 35 | $text = $q['value']; |
36 | - if ( trim($text) == '' ) { |
|
36 | + if (trim($text) == '') { |
|
37 | 37 | $text = NULL; |
38 | 38 | } |
39 | 39 | $this->mem->set('banner', $text, 86400); |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | |
53 | - if ( $q->success() ) { |
|
54 | - if ( trim($text) == '' ) { |
|
53 | + if ($q->success()) { |
|
54 | + if (trim($text) == '') { |
|
55 | 55 | $text = NULL; |
56 | 56 | } |
57 | 57 | $this->mem->set('banner', $text, 86400); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | if ($q) { |
35 | 35 | $text = $q['value']; |
36 | 36 | if ( trim($text) == '' ) { |
37 | - $text = NULL; |
|
37 | + $text = null; |
|
38 | 38 | } |
39 | 39 | $this->mem->set('banner', $text, 86400); |
40 | 40 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | if ( $q->success() ) { |
54 | 54 | if ( trim($text) == '' ) { |
55 | - $text = NULL; |
|
55 | + $text = null; |
|
56 | 56 | } |
57 | 57 | $this->mem->set('banner', $text, 86400); |
58 | 58 | return true; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | if ($q) { |
66 | 66 | $text = $q['value']; |
67 | - if ( trim($text) == '' ) { |
|
67 | + if (trim($text) == '') { |
|
68 | 68 | $text = NULL; |
69 | 69 | } |
70 | 70 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | private function _set($key, $value) { |
76 | - if ( trim($value) == '' ) { |
|
76 | + if (trim($value) == '') { |
|
77 | 77 | $value = NULL; |
78 | 78 | } |
79 | 79 | $check_q = $this->db->query( |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ':key' => $key |
83 | 83 | ) |
84 | 84 | ); |
85 | - if ( $check_q->rows() ) { |
|
85 | + if ($check_q->rows()) { |
|
86 | 86 | $set_q = $this->db->query("UPDATE editorial set value = :value WHERE item = :key", |
87 | 87 | array( |
88 | 88 | ':key' => $key, |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | - if ( $set_q->success() ) { |
|
101 | + if ($set_q->success()) { |
|
102 | 102 | return true; |
103 | 103 | } |
104 | 104 | return false; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | private function _get($key) { |
56 | - $text = NULL; |
|
56 | + $text = null; |
|
57 | 57 | |
58 | 58 | $q = $this->db->query( |
59 | 59 | "SELECT value FROM editorial WHERE item = :key", |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | if ($q) { |
66 | 66 | $text = $q['value']; |
67 | 67 | if ( trim($text) == '' ) { |
68 | - $text = NULL; |
|
68 | + $text = null; |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | private function _set($key, $value) { |
76 | 76 | if ( trim($value) == '' ) { |
77 | - $value = NULL; |
|
77 | + $value = null; |
|
78 | 78 | } |
79 | 79 | $check_q = $this->db->query( |
80 | 80 | "SELECT value FROM editorial WHERE item = :key", |