@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | |
19 | 19 | var $types = array('debates', 'whall', 'wrans', 'wms', 'ni', 'sp', 'spwrans', 'lords'); |
20 | 20 | |
21 | - public function testDebatesFront() { |
|
21 | + public function testDebatesFront() { |
|
22 | 22 | foreach ($this->types as $type) { |
23 | 23 | $this->fetch_page( array( 'type' => $type ) ); |
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | - public function testDebatesYear() { |
|
27 | + public function testDebatesYear() { |
|
28 | 28 | foreach ($this->types as $type) { |
29 | 29 | $page = $this->fetch_page( array( 'type' => $type, 'y' => '2014' ) ); |
30 | 30 | $this->assertContains('<div class="calendar">', $page); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
36 | - public function testDebatesDay() { |
|
36 | + public function testDebatesDay() { |
|
37 | 37 | foreach ($this->types as $type) { |
38 | 38 | $page = $this->fetch_page( array( 'type' => $type, 'd' => '2014-01-01' ) ); |
39 | 39 | $this->assertContains('Wednesday, 1 January 2014', $page); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - public function testDebatesHeading() { |
|
56 | + public function testDebatesHeading() { |
|
57 | 57 | foreach ($this->types as $type) { |
58 | 58 | if ($type == 'spwrans') { |
59 | 59 | # Only one level of headings on spwrans |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - public function testDebatesSubheading() { |
|
73 | + public function testDebatesSubheading() { |
|
74 | 74 | foreach ($this->types as $type) { |
75 | 75 | $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.2' ) ); |
76 | 76 | $this->assertContains("HeadingA", $page); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - public function testDebatesSpeech() { |
|
102 | + public function testDebatesSpeech() { |
|
103 | 103 | foreach ($this->types as $type) { |
104 | 104 | $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.3' ) ); |
105 | 105 | if ($type == 'wrans' || $type == 'spwrans' || $type == 'wms') { |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | |
21 | 21 | public function testDebatesFront() { |
22 | 22 | foreach ($this->types as $type) { |
23 | - $this->fetch_page( array( 'type' => $type ) ); |
|
23 | + $this->fetch_page(array('type' => $type)); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function testDebatesYear() { |
28 | 28 | foreach ($this->types as $type) { |
29 | - $page = $this->fetch_page( array( 'type' => $type, 'y' => '2014' ) ); |
|
29 | + $page = $this->fetch_page(array('type' => $type, 'y' => '2014')); |
|
30 | 30 | $this->assertContains('<div class="calendar">', $page); |
31 | 31 | $this->assertContains('January', $page); |
32 | 32 | $this->assertRegExp('/<td colspan="2"> <\/td><td[^>]*><a href="\/' . $type . '\/\?d=2014-01-01">1<\/a><\/td><td[^>]*><span>2<\/span><\/td>/', $page); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | public function testDebatesDay() { |
37 | 37 | foreach ($this->types as $type) { |
38 | - $page = $this->fetch_page( array( 'type' => $type, 'd' => '2014-01-01' ) ); |
|
38 | + $page = $this->fetch_page(array('type' => $type, 'd' => '2014-01-01')); |
|
39 | 39 | $this->assertContains('Wednesday, 1 January 2014', $page); |
40 | 40 | $this->assertContains('HeadingA', $page); |
41 | 41 | if ($type == 'wrans') { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | continue; |
61 | 61 | } |
62 | 62 | |
63 | - $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.1' ) ); |
|
63 | + $page = $this->fetch_page(array('type' => $type, 'id' => '2014-01-01b.1.1')); |
|
64 | 64 | if ($type == 'wrans') { |
65 | 65 | $this->assertRegexp("#All .*?written answers on 1 Jan 2014#i", $page); |
66 | 66 | $this->assertContains("QuestionA", $page); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | public function testDebatesSubheading() { |
74 | 74 | foreach ($this->types as $type) { |
75 | - $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.2' ) ); |
|
75 | + $page = $this->fetch_page(array('type' => $type, 'id' => '2014-01-01b.1.2')); |
|
76 | 76 | $this->assertContains("HeadingA", $page); |
77 | 77 | if ($type == 'spwrans') { |
78 | 78 | $this->assertContains("QuestionA", $page); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | public function testDebatesSpeech() { |
103 | 103 | foreach ($this->types as $type) { |
104 | - $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.3' ) ); |
|
104 | + $page = $this->fetch_page(array('type' => $type, 'id' => '2014-01-01b.1.3')); |
|
105 | 105 | if ($type == 'wrans' || $type == 'spwrans' || $type == 'wms') { |
106 | 106 | $this->assertRegexp("#Location: .*?/$type/\?id=2014-01-01b\.1\.2#", $page); |
107 | 107 | } else { |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | * @group xapian |
126 | 126 | */ |
127 | 127 | public function testGlossaryAndSearchHighlights() { |
128 | - $page = $this->fetch_page( array( 'type' => 'lords', 's' => 'constituency', 'id' => '2014-02-02b.1.3' ) ); |
|
128 | + $page = $this->fetch_page(array('type' => 'lords', 's' => 'constituency', 'id' => '2014-02-02b.1.3')); |
|
129 | 129 | $this->assertContains("constituency", $page); |
130 | 130 | $this->assertContains("<span class=\"hi\"><a href=\"/glossary/?gl=1\" title=\"In a general election, each Constituency chooses an MP to represent them....\" class=\"glossary\">constituency</a></span>", $page); |
131 | 131 | } |
132 | 132 | |
133 | 133 | public function testGidRedirect() { |
134 | - $page = $this->fetch_page( array( 'type' => 'wrans', 'id' => '2014-01-01a.187335.h' ) ); |
|
134 | + $page = $this->fetch_page(array('type' => 'wrans', 'id' => '2014-01-01a.187335.h')); |
|
135 | 135 | $this->assertRegexp("#Location: .*?/wrans/\?id=2014-01-01b\.1\.2#", $page); |
136 | 136 | } |
137 | 137 | } |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | |
8 | 8 | class SearchTest extends FetchPageTestCase |
9 | 9 | { |
10 | - public function setUp() |
|
11 | - { |
|
10 | + public function setUp() |
|
11 | + { |
|
12 | 12 | parent::setUp(); |
13 | 13 | include_once('www/includes/easyparliament/searchengine.php'); |
14 | 14 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @group xapian |
89 | 89 | */ |
90 | - public function testSearchNormal() |
|
90 | + public function testSearchNormal() |
|
91 | 91 | { |
92 | 92 | $SEARCHENGINE = new SEARCHENGINE('test'); |
93 | 93 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @group xapian |
104 | 104 | */ |
105 | - public function testSearchLink() |
|
105 | + public function testSearchLink() |
|
106 | 106 | { |
107 | 107 | $SEARCHENGINE = new SEARCHENGINE('test'); |
108 | 108 |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | public function testConstituencySearch() |
27 | 27 | { |
28 | 28 | $this->assertEquals( |
29 | - array( array( 'Alyn and Deeside' ), false ), |
|
29 | + array(array('Alyn and Deeside'), false), |
|
30 | 30 | \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery('Alyn') |
31 | 31 | ); |
32 | 32 | $this->assertEquals( |
33 | - array( array( 'Alyn and Deeside' ), false ), |
|
33 | + array(array('Alyn and Deeside'), false), |
|
34 | 34 | \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery('Alyn and Deeside') |
35 | 35 | ); |
36 | 36 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function testSearchPage() |
121 | 121 | { |
122 | - $page = $this->fetch_page( array( ) ); |
|
122 | + $page = $this->fetch_page(array( )); |
|
123 | 123 | $this->assertContains('Search', $page); |
124 | 124 | } |
125 | 125 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function testSearchPageMP() |
132 | 132 | { |
133 | - $page = $this->fetch_page( array( 'q' => 'Mary Smith' ) ); |
|
133 | + $page = $this->fetch_page(array('q' => 'Mary Smith')); |
|
134 | 134 | $this->assertContains('Mary Smith', $page); |
135 | 135 | $this->assertContains('MP, Amber Valley', $page); |
136 | 136 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function testSearchPageMultipleMP() |
144 | 144 | { |
145 | - $page = $this->fetch_page( array( 'q' => 'Jones' ) ); |
|
145 | + $page = $this->fetch_page(array('q' => 'Jones')); |
|
146 | 146 | $this->assertContains('People matching <em class="current-search-term">Jones</em>', $page); |
147 | 147 | $this->assertContains('Andrew Jones', $page); |
148 | 148 | $this->assertContains('Simon Jones', $page); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @group xapian |
155 | 155 | */ |
156 | 156 | public function testSearchPageCons() { |
157 | - $page = $this->fetch_page( array( 'q' => 'Amber' ) ); |
|
157 | + $page = $this->fetch_page(array('q' => 'Amber')); |
|
158 | 158 | $this->assertContains('MP for <em class="current-search-term">Amber</em>', $page); |
159 | 159 | $this->assertContains('Mary Smith', $page); |
160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @group xapian |
167 | 167 | */ |
168 | 168 | public function testSearchPageConsWithNoMp() { |
169 | - $page = $this->fetch_page( array( 'q' => 'Alyn' ) ); |
|
169 | + $page = $this->fetch_page(array('q' => 'Alyn')); |
|
170 | 170 | $this->assertNotContains('MP for <em class="current-search-term">Alyn</em>', $page); |
171 | 171 | $this->assertNotContains('MPs in constituencies matching', $page); |
172 | 172 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @group xapian |
179 | 179 | */ |
180 | 180 | public function testSearchPageMultipleCons() { |
181 | - $page = $this->fetch_page( array( 'q' => 'Liverpool' ) ); |
|
181 | + $page = $this->fetch_page(array('q' => 'Liverpool')); |
|
182 | 182 | $this->assertContains('MPs in constituencies matching <em class="current-search-term">Liverpool</em>', $page); |
183 | 183 | $this->assertContains('Susan Brown', $page); |
184 | 184 | $this->assertContains('MP, Liverpool, Riverside', $page); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @group xapian |
193 | 193 | */ |
194 | 194 | public function testSearchPageGlossary() { |
195 | - $page = $this->fetch_page( array( 'q' => 'other place' ) ); |
|
195 | + $page = $this->fetch_page(array('q' => 'other place')); |
|
196 | 196 | $this->assertContains('Glossary items matching', $page); |
197 | 197 | $this->assertContains('<a href="/glossary/?gl=1">“other place', $page); |
198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @group xapian |
204 | 204 | */ |
205 | 205 | public function testSearchPageSpellCorrect() { |
206 | - $page = $this->fetch_page( array( 'q' => 'plice' ) ); |
|
206 | + $page = $this->fetch_page(array('q' => 'plice')); |
|
207 | 207 | $this->assertContains('Did you mean <a href="/search/?q=place">place', $page); |
208 | 208 | } |
209 | 209 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @group xapian |
214 | 214 | */ |
215 | 215 | public function testSearchBySpeakerNoResults() { |
216 | - $page = $this->fetch_page( array( 'q' => 'splice', 'o' => 'p' ) ); |
|
216 | + $page = $this->fetch_page(array('q' => 'splice', 'o' => 'p')); |
|
217 | 217 | $this->assertContains('Who says splice the most', $page); |
218 | 218 | $this->assertContains('No results', $page); |
219 | 219 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @group xapian |
241 | 241 | */ |
242 | 242 | public function testSearchPageRSS() { |
243 | - $page = $this->fetch_page( array( 'q' => 'test' ) ); |
|
243 | + $page = $this->fetch_page(array('q' => 'test')); |
|
244 | 244 | $this->assertContains('<a href="/search/rss/?s=test">get an RSS feed', $page); |
245 | 245 | } |
246 | 246 |
@@ -84,12 +84,12 @@ |
||
84 | 84 | // Require the templates and output |
85 | 85 | |
86 | 86 | if ($template_only) { |
87 | - require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php'; |
|
87 | + require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php'; |
|
88 | 88 | } else { |
89 | - header('Content-Type: text/html; charset=utf-8'); |
|
90 | - require_once INCLUDESPATH . 'easyparliament/templates/html/header.php'; |
|
91 | - require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php'; |
|
92 | - require_once INCLUDESPATH . 'easyparliament/templates/html/footer.php'; |
|
89 | + header('Content-Type: text/html; charset=utf-8'); |
|
90 | + require_once INCLUDESPATH . 'easyparliament/templates/html/header.php'; |
|
91 | + require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php'; |
|
92 | + require_once INCLUDESPATH . 'easyparliament/templates/html/footer.php'; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $user = new Renderer\User(); |
44 | 44 | $data = array_merge($user->data, $data); |
45 | 45 | |
46 | - if ( isset($page_errors) ) { |
|
46 | + if (isset($page_errors)) { |
|
47 | 47 | $data['page_errors'] = $page_errors; |
48 | 48 | } |
49 | 49 | |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | |
96 | 96 | private static function addCommonURLs($data) { |
97 | 97 | $urls = array(); |
98 | - if ( isset($data['urls']) ) { |
|
98 | + if (isset($data['urls'])) { |
|
99 | 99 | $urls = $data['urls']; |
100 | 100 | } |
101 | 101 | |
102 | 102 | $common_urls = array('search', 'alert'); |
103 | 103 | |
104 | - foreach ( $common_urls as $path ) { |
|
105 | - if (!isset($urls[$path]) ) { |
|
104 | + foreach ($common_urls as $path) { |
|
105 | + if (!isset($urls[$path])) { |
|
106 | 106 | $url = new Url($path); |
107 | 107 | $urls[$path] = $url->generate(); |
108 | 108 | } |
@@ -127,7 +127,9 @@ |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | $text = $this->data['alertsearch']; |
130 | - if (!$text) $text = $this->data['keyword']; |
|
130 | + if (!$text) { |
|
131 | + $text = $this->data['keyword']; |
|
132 | + } |
|
131 | 133 | |
132 | 134 | if ($this->data['submitted'] && !$this->data['pid'] && !$text) { |
133 | 135 | $errors['alertsearch'] = 'Please enter what you want to be alerted about'; |
@@ -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 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | try { |
178 | 178 | $MEMBER = new \MEMBER(array('constituency'=>$constituency, 'house' => 1)); |
179 | 179 | $cons[$constituency] = $MEMBER; |
180 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
180 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
181 | 181 | // do nothing |
182 | 182 | } |
183 | 183 | } |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | |
198 | 198 | // If this goes well, the alert will be added to the database and a confirmation email |
199 | 199 | // will be sent to them. |
200 | - $success = $this->alert->add( $this->data, $confirm ); |
|
200 | + $success = $this->alert->add($this->data, $confirm); |
|
201 | 201 | |
202 | - if ($success>0 && !$confirm) { |
|
202 | + if ($success > 0 && !$confirm) { |
|
203 | 203 | $result = 'alert-added'; |
204 | - } elseif ($success>0) { |
|
204 | + } elseif ($success > 0) { |
|
205 | 205 | $result = 'alert-confirmation'; |
206 | 206 | } elseif ($success == -2) { |
207 | 207 | // we need to make sure we know that the person attempting to sign up |
208 | 208 | // for the alert has that email address to stop people trying to work |
209 | 209 | // out what alerts they are signed up to |
210 | - if ( $this->data['email_verified'] || ( $this->user->loggedin && $this->user->email() == $this->data['email'] ) ) { |
|
210 | + if ($this->data['email_verified'] || ($this->user->loggedin && $this->user->email() == $this->data['email'])) { |
|
211 | 211 | $result = 'alert-exists'; |
212 | 212 | } else { |
213 | 213 | // don't throw an error message as that implies that they have already signed |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | |
234 | 234 | private function formatSearchTerms() { |
235 | - if ( $this->data['alertsearch'] ) { |
|
235 | + if ($this->data['alertsearch']) { |
|
236 | 236 | $this->data['alertsearch_pretty'] = \MySociety\TheyWorkForYou\Utility\Alert::prettifyCriteria($this->data['alertsearch']); |
237 | 237 | $this->data['search_text'] = $this->data['alertsearch']; |
238 | 238 | } else { |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | private function formatSearchMemberData() { |
268 | - if ( isset($this->data['postcode']) ) { |
|
268 | + if (isset($this->data['postcode'])) { |
|
269 | 269 | try { |
270 | 270 | $postcode = $this->data['postcode']; |
271 | 271 | |
272 | - $MEMBER = new \MEMBER( array('postcode' => $postcode) ); |
|
272 | + $MEMBER = new \MEMBER(array('postcode' => $postcode)); |
|
273 | 273 | // move the postcode to the front just to be tidy |
274 | 274 | $tidy_alertsearch = $postcode . " " . trim(str_replace("$postcode", "", $this->data['alertsearch'])); |
275 | 275 | $alertsearch_display = str_replace("$postcode ", "", $tidy_alertsearch); |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | $this->data['member_displaysearch'] = $alertsearch_display; |
279 | 279 | $this->data['member'] = $MEMBER; |
280 | 280 | |
281 | - if ( $this->data['scottish_text'] ) { |
|
281 | + if ($this->data['scottish_text']) { |
|
282 | 282 | $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($postcode); |
283 | - if ( isset($constituencies['SPC']) ) { |
|
283 | + if (isset($constituencies['SPC'])) { |
|
284 | 284 | $MEMBER = new \MEMBER(array('constituency' => $constituencies['SPC'], 'house' => 4)); |
285 | 285 | $this->data['scottish_alertsearch'] = str_replace("$postcode", "speaker:" . $MEMBER->person_id, $tidy_alertsearch); |
286 | 286 | $this->data['scottish_member'] = $MEMBER; |
287 | 287 | } |
288 | 288 | } |
289 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
289 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
290 | 290 | $this->data['member_error'] = 1; |
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | - if ( $this->data['pid'] ) { |
|
295 | - $MEMBER = new \MEMBER( array('person_id' => $this->data['pid']) ); |
|
294 | + if ($this->data['pid']) { |
|
295 | + $MEMBER = new \MEMBER(array('person_id' => $this->data['pid'])); |
|
296 | 296 | $this->data['pid_member'] = $MEMBER; |
297 | 297 | } |
298 | 298 | |
299 | - if ( $this->data['keyword'] ) { |
|
299 | + if ($this->data['keyword']) { |
|
300 | 300 | $this->data['display_keyword'] = \MySociety\TheyWorkForYou\Utility\Alert::prettifyCriteria($this->data['keyword']); |
301 | 301 | } |
302 | 302 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | private function get_page_url() { |
50 | 50 | $protocol = 'https://'; |
51 | 51 | if (DEVSITE) { |
52 | - $protocol = 'http://'; |
|
52 | + $protocol = 'http://'; |
|
53 | 53 | } |
54 | 54 | $url = $protocol . DOMAIN; |
55 | 55 | if (array_key_exists('REQUEST_URI', $_SERVER)) { |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | if (isset($nextprev[$linktype]) && isset($nextprev[$linktype]['url'])) { |
136 | 136 | |
137 | 137 | if (isset($nextprev[$linktype]['body'])) { |
138 | - $linktitle = _htmlentities( trim_characters($nextprev[$linktype]['body'], 0, 40) ); |
|
138 | + $linktitle = _htmlentities(trim_characters($nextprev[$linktype]['body'], 0, 40)); |
|
139 | 139 | if (isset($nextprev[$linktype]['speaker']) && |
140 | 140 | count($nextprev[$linktype]['speaker']) > 0) { |
141 | 141 | $linktitle = $nextprev[$linktype]['speaker']['name'] . ': ' . $linktitle; |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | |
163 | 163 | if ($nextprev) { |
164 | 164 | // Four different kinds of back/forth links we might build. |
165 | - $links = array ("first", "prev", "up", "next", "last"); |
|
165 | + $links = array("first", "prev", "up", "next", "last"); |
|
166 | 166 | |
167 | 167 | foreach ($links as $type) { |
168 | - if ( $link = $this->generate_next_prev_link( $nextprev, $type ) ) { |
|
168 | + if ($link = $this->generate_next_prev_link($nextprev, $type)) { |
|
169 | 169 | |
170 | 170 | $this->data['header_links'][] = $link; |
171 | 171 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | // Page names mapping to those in metadata.php. |
259 | 259 | // Links in the top menu, and the sublinks we see if |
260 | 260 | // we're within that section. |
261 | - $nav_items = array ( |
|
261 | + $nav_items = array( |
|
262 | 262 | array('home'), |
263 | 263 | array('hansard', 'mps', 'peers', 'alldebatesfront', 'wranswmsfront', 'pbc_front', 'divisions_recent', 'calendar_summary'), |
264 | 264 | array('sp_home', 'spoverview', 'msps', 'spdebatesfront', 'spwransfront'), |
@@ -81,7 +81,9 @@ discard block |
||
81 | 81 | |
82 | 82 | $parent_page = $DATA->page_metadata($this_page, 'parent'); |
83 | 83 | if ($parent_title = $DATA->page_metadata($parent_page, 'title')) { |
84 | - if ($this->data['page_title']) $this->data['page_title'] .= ': '; |
|
84 | + if ($this->data['page_title']) { |
|
85 | + $this->data['page_title'] .= ': '; |
|
86 | + } |
|
85 | 87 | $this->data['page_title'] .= $parent_title; |
86 | 88 | } |
87 | 89 | |
@@ -103,7 +105,9 @@ discard block |
||
103 | 105 | // Meta keywords |
104 | 106 | if (!$this->data['meta_keywords'] = $DATA->page_metadata($this_page, "meta_keywords")) { |
105 | 107 | $this->data['meta_keywords'] = $this->keywords_title; |
106 | - if ($this->data['meta_keywords']) $this->data['meta_keywords'] .= ', '; |
|
108 | + if ($this->data['meta_keywords']) { |
|
109 | + $this->data['meta_keywords'] .= ', '; |
|
110 | + } |
|
107 | 111 | $this->data['meta_keywords'] .= 'Hansard, Official Report, Parliament, government, House of Commons, House of Lords, MP, Peer, Member of Parliament, MPs, Peers, Lords, Commons, Scottish Parliament, Northern Ireland Assembly, MSP, MLA, MSPs, MLAs'; |
108 | 112 | } |
109 | 113 | |
@@ -204,7 +208,9 @@ discard block |
||
204 | 208 | $p = $parent; |
205 | 209 | while ($p) { |
206 | 210 | $p = $DATA->page_metadata($p, 'parent'); |
207 | - if ($p) $parents[] = $p; |
|
211 | + if ($p) { |
|
212 | + $parents[] = $p; |
|
213 | + } |
|
208 | 214 | } |
209 | 215 | |
210 | 216 | $top_highlight = array_pop($parents); |
@@ -279,7 +285,9 @@ discard block |
||
279 | 285 | $menudata = $DATA->page_metadata($toppage, 'menu'); |
280 | 286 | $text = $menudata['text']; |
281 | 287 | $title = $menudata['title']; |
282 | - if (!$title) continue; |
|
288 | + if (!$title) { |
|
289 | + continue; |
|
290 | + } |
|
283 | 291 | |
284 | 292 | //get link and description for the menu ans add it to the array |
285 | 293 | $class = $toppage == $this->nav_highlights['top'] ? 'on' : ''; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | public $data; |
16 | 16 | |
17 | - private $about_links = array ('help', 'about', 'linktous', 'houserules', 'blog', 'news', 'contact', 'privacy'); |
|
17 | + private $about_links = array('help', 'about', 'linktous', 'houserules', 'blog', 'news', 'contact', 'privacy'); |
|
18 | 18 | private $assemblies_links = array('hansard', 'sp_home', 'ni_home', 'wales_home'); |
19 | 19 | private $international_links = array('newzealand', 'australia', 'ireland', 'mzalendo'); |
20 | 20 | private $tech_links = array('code', 'api', 'data', 'pombola', 'devmailinglist', 'irc'); |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | public function __construct() { |
29 | 29 | $this->data = array(); |
30 | 30 | |
31 | - $this->data['about'] = $this->get_menu_links( $this->about_links ); |
|
32 | - $this->data['assemblies'] = $this->get_menu_links( $this->assemblies_links ); |
|
33 | - $this->data['international'] = $this->get_menu_links( $this->international_links ); |
|
34 | - $this->data['tech'] = $this->get_menu_links( $this->tech_links ); |
|
31 | + $this->data['about'] = $this->get_menu_links($this->about_links); |
|
32 | + $this->data['assemblies'] = $this->get_menu_links($this->assemblies_links); |
|
33 | + $this->data['international'] = $this->get_menu_links($this->international_links); |
|
34 | + $this->data['tech'] = $this->get_menu_links($this->tech_links); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | if ($q->rows) { |
66 | 66 | $text = $q->field(0, '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->rows) { |
66 | 66 | $text = $q->field(0, '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", |
@@ -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'"); |
33 | 33 | |
34 | 34 | if ($q->rows) { |
35 | 35 | $text = $q->field(0, '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->rows) { |
35 | 35 | $text = $q->field(0, '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; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public function __construct($name) { |
21 | 21 | // treat Labour and Labour/Co-operative the same as that's how |
22 | 22 | // people view them and it'll confuse the results otherwise |
23 | - if ( $name == 'Labour/Co-operative' ) { |
|
23 | + if ($name == 'Labour/Co-operative') { |
|
24 | 24 | $name = 'Labour'; |
25 | 25 | } |
26 | 26 | $this->name = $name; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | ':date' => date('Y-m-d'), |
43 | 43 | ) |
44 | 44 | ); |
45 | - if ( $member_count->rows ) { |
|
45 | + if ($member_count->rows) { |
|
46 | 46 | $num_members = $member_count->field(0, 'num_members'); |
47 | 47 | return $num_members; |
48 | 48 | } else { |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | ) |
71 | 71 | ); |
72 | 72 | |
73 | - if ( $position->rows ) { |
|
73 | + if ($position->rows) { |
|
74 | 74 | $score = $position->field(0, 'score'); |
75 | 75 | $score_desc = score_to_strongly($score); |
76 | 76 | |
77 | - if ( $want_score ) { |
|
78 | - return array( $score_desc, $score); |
|
77 | + if ($want_score) { |
|
78 | + return array($score_desc, $score); |
|
79 | 79 | } else { |
80 | 80 | return $score_desc; |
81 | 81 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ':party' => $this->name |
115 | 115 | ); |
116 | 116 | |
117 | - if ( $this->name == 'Labour' ) { |
|
117 | + if ($this->name == 'Labour') { |
|
118 | 118 | $party_where = '( party = :party OR party = :party2 )'; |
119 | 119 | $params = array( |
120 | 120 | ':party' => $this->name, |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
125 | - for ( $i = 0; $i < $num_divs; $i++ ) { |
|
125 | + for ($i = 0; $i < $num_divs; $i++) { |
|
126 | 126 | $division_id = $divisions->field($i, 'division_id'); |
127 | 127 | $weights = $this->get_vote_scores($divisions->field($i, 'policy_vote')); |
128 | 128 | |
@@ -142,42 +142,42 @@ discard block |
||
142 | 142 | ); |
143 | 143 | |
144 | 144 | $num_votes = 0; |
145 | - for ( $j = 0; $j < $votes->rows(); $j++ ) { |
|
145 | + for ($j = 0; $j < $votes->rows(); $j++) { |
|
146 | 146 | $vote_dir = $votes->field($j, 'vote'); |
147 | - if ( $vote_dir == '' ) continue; |
|
148 | - if ( $vote_dir == 'tellno' ) $vote_dir = 'no'; |
|
149 | - if ( $vote_dir == 'tellaye' ) $vote_dir = 'aye'; |
|
147 | + if ($vote_dir == '') continue; |
|
148 | + if ($vote_dir == 'tellno') $vote_dir = 'no'; |
|
149 | + if ($vote_dir == 'tellaye') $vote_dir = 'aye'; |
|
150 | 150 | |
151 | 151 | $num_votes += $votes->field($j, 'num_votes'); |
152 | 152 | $score += ($votes->field($j, 'num_votes') * $weights[$vote_dir]); |
153 | 153 | } |
154 | 154 | |
155 | 155 | $total_votes += $num_votes; |
156 | - $max_score += $num_votes * max( array_values( $weights ) ); |
|
156 | + $max_score += $num_votes * max(array_values($weights)); |
|
157 | 157 | } |
158 | 158 | |
159 | - if ( $total_votes == 0 ) { |
|
159 | + if ($total_votes == 0) { |
|
160 | 160 | return null; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // this implies that all the divisions in the policy have a policy |
164 | 164 | // position of absent so we set weight to -1 to indicate we can't |
165 | 165 | // really say what the parties position is. |
166 | - if ( $max_score == 0 ) { |
|
166 | + if ($max_score == 0) { |
|
167 | 167 | $weight = -1; |
168 | 168 | } else { |
169 | - $weight = 1 - ( $score/$max_score ); |
|
169 | + $weight = 1 - ($score / $max_score); |
|
170 | 170 | } |
171 | 171 | $score_desc = score_to_strongly($weight); |
172 | 172 | |
173 | - if ( $want_score ) { |
|
174 | - return array( $score_desc, $weight); |
|
173 | + if ($want_score) { |
|
174 | + return array($score_desc, $weight); |
|
175 | 175 | } else { |
176 | 176 | return $score_desc; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - public function cache_position( $position ) { |
|
180 | + public function cache_position($position) { |
|
181 | 181 | $this->db->query( |
182 | 182 | "REPLACE INTO partypolicy |
183 | 183 | (party, house, policy_id, score) |
@@ -197,9 +197,9 @@ discard block |
||
197 | 197 | return $positions; |
198 | 198 | } |
199 | 199 | |
200 | - foreach ( $policies->getPolicies() as $policy_id => $policy_text ) { |
|
201 | - list( $position, $score ) = $this->$method($policy_id, true); |
|
202 | - if ( $position === null ) { |
|
200 | + foreach ($policies->getPolicies() as $policy_id => $policy_text) { |
|
201 | + list($position, $score) = $this->$method($policy_id, true); |
|
202 | + if ($position === null) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $both = 1; |
220 | 220 | $agree = 10; |
221 | 221 | |
222 | - if ( stripos($vote, '3') !== FALSE ) { |
|
222 | + if (stripos($vote, '3') !== FALSE) { |
|
223 | 223 | $agree = 50; |
224 | 224 | $absent = 25; |
225 | 225 | $both = 25; |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | 'both' => $both |
231 | 231 | ); |
232 | 232 | |
233 | - if ( stripos($vote, 'aye') !== FALSE ) { |
|
233 | + if (stripos($vote, 'aye') !== FALSE) { |
|
234 | 234 | $scores['aye'] = $agree; |
235 | 235 | $scores['no'] = 0; |
236 | - } else if ( stripos($vote, 'no') !== FALSE ) { |
|
236 | + } else if (stripos($vote, 'no') !== FALSE) { |
|
237 | 237 | $scores['no'] = $agree; |
238 | 238 | $scores['aye'] = 0; |
239 | 239 | } else { |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $parties = array(); |
257 | 257 | $party_count = $party_list->rows; |
258 | 258 | |
259 | - for ( $i = 0; $i < $party_count; $i++ ) { |
|
259 | + for ($i = 0; $i < $party_count; $i++) { |
|
260 | 260 | $party = $party_list->field($i, 'party'); |
261 | 261 | if ( |
262 | 262 | !$party |
@@ -144,9 +144,15 @@ |
||
144 | 144 | $num_votes = 0; |
145 | 145 | for ( $j = 0; $j < $votes->rows(); $j++ ) { |
146 | 146 | $vote_dir = $votes->field($j, 'vote'); |
147 | - if ( $vote_dir == '' ) continue; |
|
148 | - if ( $vote_dir == 'tellno' ) $vote_dir = 'no'; |
|
149 | - if ( $vote_dir == 'tellaye' ) $vote_dir = 'aye'; |
|
147 | + if ( $vote_dir == '' ) { |
|
148 | + continue; |
|
149 | + } |
|
150 | + if ( $vote_dir == 'tellno' ) { |
|
151 | + $vote_dir = 'no'; |
|
152 | + } |
|
153 | + if ( $vote_dir == 'tellaye' ) { |
|
154 | + $vote_dir = 'aye'; |
|
155 | + } |
|
150 | 156 | |
151 | 157 | $num_votes += $votes->field($j, 'num_votes'); |
152 | 158 | $score += ($votes->field($j, 'num_votes') * $weights[$vote_dir]); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $both = 1; |
220 | 220 | $agree = 10; |
221 | 221 | |
222 | - if ( stripos($vote, '3') !== FALSE ) { |
|
222 | + if ( stripos($vote, '3') !== false ) { |
|
223 | 223 | $agree = 50; |
224 | 224 | $absent = 25; |
225 | 225 | $both = 25; |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | 'both' => $both |
231 | 231 | ); |
232 | 232 | |
233 | - if ( stripos($vote, 'aye') !== FALSE ) { |
|
233 | + if ( stripos($vote, 'aye') !== false ) { |
|
234 | 234 | $scores['aye'] = $agree; |
235 | 235 | $scores['no'] = 0; |
236 | - } else if ( stripos($vote, 'no') !== FALSE ) { |
|
236 | + } else if ( stripos($vote, 'no') !== false ) { |
|
237 | 237 | $scores['no'] = $agree; |
238 | 238 | $scores['aye'] = 0; |
239 | 239 | } else { |