@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | |
7 | 7 | class UtilityTest extends PHPUnit_Framework_TestCase |
8 | 8 | { |
9 | - public function setUp() |
|
10 | - { |
|
9 | + public function setUp() |
|
10 | + { |
|
11 | 11 | parent::setUp(); |
12 | 12 | include_once('www/includes/utility.php'); |
13 | 13 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * Test the escaping of replacement strings for use with |
17 | 17 | * preg_replace. |
18 | 18 | */ |
19 | - public function testPregReplacement() |
|
19 | + public function testPregReplacement() |
|
20 | 20 | { |
21 | 21 | $example = 'try \1 and $0, also backslash \ and dollar $ alone'; |
22 | 22 | $this->assertEquals( |
@@ -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') { |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | public function getDataSet() |
10 | 10 | { |
11 | - return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/section.xml'); |
|
11 | + return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/section.xml'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | private function fetch_page($vars) |
@@ -20,22 +20,22 @@ 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 | - $this->assertRegExp('/<td colspan="2"> <\/td><td[^>]*><a href="\/' . $type . '\/\?d=2014-01-01">1<\/a><\/td><td[^>]*><span>2<\/span><\/td>/', $page); |
|
32 | + $this->assertRegExp('/<td colspan="2"> <\/td><td[^>]*><a href="\/'.$type.'\/\?d=2014-01-01">1<\/a><\/td><td[^>]*><span>2<\/span><\/td>/', $page); |
|
33 | 33 | } |
34 | 34 | } |
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 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function getDataSet() |
17 | 17 | { |
18 | - return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/search.xml'); |
|
18 | + return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/search.xml'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | private function fetch_page($vars) |
@@ -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 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | $ALERT = new ALERT(); |
33 | 33 | |
34 | - $response = $ALERT->fetch(0,0); |
|
34 | + $response = $ALERT->fetch(0, 0); |
|
35 | 35 | |
36 | 36 | // Make sure we only get one response |
37 | 37 | $this->assertEquals(1, count($response['data'])); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $ALERT = new ALERT(); |
50 | 50 | |
51 | - $response = $ALERT->fetch(1,0); |
|
51 | + $response = $ALERT->fetch(1, 0); |
|
52 | 52 | |
53 | 53 | // Make sure we only get two responses |
54 | 54 | $this->assertEquals(2, count($response['data'])); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $ALERT = new ALERT(); |
67 | 67 | |
68 | - $response = $ALERT->fetch(0,1); |
|
68 | + $response = $ALERT->fetch(0, 1); |
|
69 | 69 | |
70 | 70 | // Make sure we only get one response |
71 | 71 | $this->assertEquals(1, count($response['data'])); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | $ALERT = new ALERT(); |
84 | 84 | |
85 | - $response = $ALERT->fetch(1,1); |
|
85 | + $response = $ALERT->fetch(1, 1); |
|
86 | 86 | |
87 | 87 | // Make sure we only get one response |
88 | 88 | $this->assertEquals(1, count($response['data'])); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | $ALERT = new ALERT(); |
101 | 101 | |
102 | - $response = $ALERT->fetch_between(1,1, '2014-02-01', '2014-02-02'); |
|
102 | + $response = $ALERT->fetch_between(1, 1, '2014-02-01', '2014-02-02'); |
|
103 | 103 | |
104 | 104 | // Make sure we only get one response |
105 | 105 | $this->assertEquals(1, count($response['alerts'])); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | */ |
16 | 16 | public function getConnection() |
17 | 17 | { |
18 | - $dsn = 'mysql:host=' . OPTION_TWFY_DB_HOST . ' ;dbname=' . OPTION_TWFY_DB_NAME . ';charset=utf8'; |
|
18 | + $dsn = 'mysql:host='.OPTION_TWFY_DB_HOST.' ;dbname='.OPTION_TWFY_DB_NAME.';charset=utf8'; |
|
19 | 19 | $username = OPTION_TWFY_DB_USER; |
20 | 20 | $password = OPTION_TWFY_DB_PASS; |
21 | 21 | $pdo = new PDO($dsn, $username, $password); |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | public function tearDown() |
27 | 27 | { |
28 | - $this->db = NULL; |
|
28 | + $this->db = null; |
|
29 | 29 | |
30 | 30 | parent::tearDown(); |
31 | 31 | } |
@@ -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 | |
@@ -84,25 +84,25 @@ discard block |
||
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 | 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'; |
|
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 | |
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 | } |
@@ -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 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | 'email' => $email, |
81 | 81 | 'pid' => $person->person_id, |
82 | 82 | 'pc' => $postcode, |
83 | - 'confirm_base' => 'https://' . DOMAIN . '/alert/by-postcode?confirmed=', |
|
83 | + 'confirm_base' => 'https://'.DOMAIN.'/alert/by-postcode?confirmed=', |
|
84 | 84 | ); |
85 | 85 | |
86 | 86 | $data = array(); |
@@ -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 |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | AND deleted = 0", |
128 | 128 | array( |
129 | 129 | ':email' => $existing['email'], |
130 | - ':criteria' => '%speaker:' . $old_mp_id . '%' |
|
130 | + ':criteria' => '%speaker:'.$old_mp_id.'%' |
|
131 | 131 | ) |
132 | 132 | ); |
133 | 133 | |
134 | - for ( $i = 0; $i < $q->rows; $i++ ) { |
|
134 | + for ($i = 0; $i < $q->rows; $i++) { |
|
135 | 135 | // need to reset this otherwise delete does not work |
136 | 136 | $this->alert->token_checked = null; |
137 | 137 | $other_criteria = trim(preg_replace('/speaker:\d+/', '', $q->field($i, 'criteria'))); |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | 'pid' => $new_mp->person_id, |
142 | 142 | 'pc' => '', |
143 | 143 | ); |
144 | - if ( $other_criteria ) { |
|
144 | + if ($other_criteria) { |
|
145 | 145 | $details['keyword'] = $other_criteria; |
146 | 146 | } |
147 | 147 | |
148 | - $this->alert->delete($q->field($i, 'alert_id') . '::' . $q->field($i ,'registrationtoken')); |
|
148 | + $this->alert->delete($q->field($i, 'alert_id').'::'.$q->field($i, 'registrationtoken')); |
|
149 | 149 | $this->alert->add($details, False); |
150 | 150 | } |
151 | 151 | |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | private function isEmailSignedUpForPostCode($email, $postcode) { |
159 | 159 | $is_signed_up = false; |
160 | 160 | |
161 | - if ( $email && $postcode ) { |
|
161 | + if ($email && $postcode) { |
|
162 | 162 | try { |
163 | 163 | $person = $this->getPersonFromPostcode($postcode); |
164 | 164 | $is_signed_up = $this->alert->fetch_by_mp($email, $person->person_id); |
165 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
165 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
166 | 166 | $is_signed_up = false; |
167 | 167 | } |
168 | 168 | } |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | preg_match('/speaker:(\d+)/', $existing['criteria'], $matches); |
179 | 179 | $criteria = $matches[1]; |
180 | 180 | |
181 | - $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $criteria ) ); |
|
182 | - $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 )); |
|
181 | + $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $criteria)); |
|
182 | + $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1)); |
|
183 | 183 | |
184 | - if ( $this->alert->fetch_by_mp( $existing['email'], $new_mp->person_id) ) { |
|
184 | + if ($this->alert->fetch_by_mp($existing['email'], $new_mp->person_id)) { |
|
185 | 185 | $data = array( |
186 | 186 | 'already_signed_up' => True, |
187 | 187 | 'old_mp' => $old_mp->full_name(), |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $data['postcode'] = $this->user->postcode_is_set() ? $this->user->postcode() : ''; |
33 | 33 | |
34 | 34 | if ( $this->isEmailSignedUpForPostCode( $data['email'], $data['postcode'] ) ) { |
35 | - $data['already_signed_up'] = True; |
|
35 | + $data['already_signed_up'] = true; |
|
36 | 36 | $mp = $this->getPersonFromPostcode($data['postcode']); |
37 | 37 | $data['mp_name'] = $mp->full_name(); |
38 | 38 | } |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | |
68 | 68 | private function createAlertForPostCode($email, $postcode) { |
69 | 69 | if ( !$this->validateDetails($email, $postcode) ) { |
70 | - return array('invalid-postcode-or-email' => True); |
|
70 | + return array('invalid-postcode-or-email' => true); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | try { |
74 | 74 | $person = $this->getPersonFromPostcode($postcode); |
75 | 75 | } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
76 | - return array('bad-constituency' => True); |
|
76 | + return array('bad-constituency' => true); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $details = array( |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | // no logged in user so send them an email to let them |
94 | 94 | // know someone tried to create an alert |
95 | 95 | $this->alert->send_already_signedup_email($details); |
96 | - $data['confirmation_sent'] = True; |
|
96 | + $data['confirmation_sent'] = true; |
|
97 | 97 | } else { |
98 | - $data['already_signed_up'] = True; |
|
98 | + $data['already_signed_up'] = true; |
|
99 | 99 | } |
100 | 100 | break; |
101 | 101 | case self::CREATE_FAILED: |
102 | - $data['error'] = True; |
|
102 | + $data['error'] = true; |
|
103 | 103 | break; |
104 | 104 | default: // alert created |
105 | 105 | if ( $not_logged_in ) { |
106 | - $data['confirmation_sent'] = True; |
|
106 | + $data['confirmation_sent'] = true; |
|
107 | 107 | } else { |
108 | - $data['signedup_no_confirm'] = True; |
|
108 | + $data['signedup_no_confirm'] = true; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | $this->alert->delete($q->field($i, 'alert_id') . '::' . $q->field($i ,'registrationtoken')); |
149 | - $this->alert->add($details, False); |
|
149 | + $this->alert->add($details, false); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return array( |
153 | - 'signedup_no_confirm' => True, |
|
153 | + 'signedup_no_confirm' => true, |
|
154 | 154 | 'new_mp' => $new_mp->full_name(), |
155 | 155 | ); |
156 | 156 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | if ( $this->alert->fetch_by_mp( $existing['email'], $new_mp->person_id) ) { |
185 | 185 | $data = array( |
186 | - 'already_signed_up' => True, |
|
186 | + 'already_signed_up' => true, |
|
187 | 187 | 'old_mp' => $old_mp->full_name(), |
188 | 188 | 'mp_name' => $new_mp->full_name(), |
189 | 189 | ); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | ); |
195 | 195 | } |
196 | 196 | |
197 | - $data['update'] = True; |
|
197 | + $data['update'] = true; |
|
198 | 198 | $data['confirmation'] = $confirmation; |
199 | 199 | |
200 | 200 | return $data; |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | namespace MySociety\TheyWorkForYou\AlertView; |
4 | 4 | |
5 | 5 | include_once '../../../www/includes/easyparliament/init.php'; |
6 | -include_once INCLUDESPATH . "easyparliament/people.php"; |
|
7 | -include_once INCLUDESPATH . "easyparliament/member.php"; |
|
8 | -include_once INCLUDESPATH . "easyparliament/searchengine.php"; |
|
9 | -include_once INCLUDESPATH . '../../commonlib/phplib/auth.php'; |
|
10 | -include_once INCLUDESPATH . '../../commonlib/phplib/crosssell.php'; |
|
6 | +include_once INCLUDESPATH."easyparliament/people.php"; |
|
7 | +include_once INCLUDESPATH."easyparliament/member.php"; |
|
8 | +include_once INCLUDESPATH."easyparliament/searchengine.php"; |
|
9 | +include_once INCLUDESPATH.'../../commonlib/phplib/auth.php'; |
|
10 | +include_once INCLUDESPATH.'../../commonlib/phplib/crosssell.php'; |
|
11 | 11 | |
12 | 12 | class Standard extends \MySociety\TheyWorkForYou\AlertView { |
13 | 13 | public $data; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | $se = new \SEARCHENGINE($text); |
141 | 141 | if (!$se->valid) { |
142 | - $errors['alertsearch'] = 'That search appears to be invalid - ' . $se->error . ' - please check and try again.'; |
|
142 | + $errors['alertsearch'] = 'That search appears to be invalid - '.$se->error.' - please check and try again.'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | if (strlen($text) > 255) { |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | try { |
180 | 180 | $MEMBER = new \MEMBER(array('constituency'=>$constituency, 'house' => 1)); |
181 | 181 | $cons[$constituency] = $MEMBER; |
182 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
182 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
183 | 183 | // do nothing |
184 | 184 | } |
185 | 185 | } |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | |
200 | 200 | // If this goes well, the alert will be added to the database and a confirmation email |
201 | 201 | // will be sent to them. |
202 | - $success = $this->alert->add( $this->data, $confirm ); |
|
202 | + $success = $this->alert->add($this->data, $confirm); |
|
203 | 203 | |
204 | - if ($success>0 && !$confirm) { |
|
204 | + if ($success > 0 && !$confirm) { |
|
205 | 205 | $result = 'alert-added'; |
206 | - } elseif ($success>0) { |
|
206 | + } elseif ($success > 0) { |
|
207 | 207 | $result = 'alert-confirmation'; |
208 | 208 | } elseif ($success == -2) { |
209 | 209 | // we need to make sure we know that the person attempting to sign up |
210 | 210 | // for the alert has that email address to stop people trying to work |
211 | 211 | // out what alerts they are signed up to |
212 | - if ( $this->data['email_verified'] || ( $this->user->loggedin && $this->user->email() == $this->data['email'] ) ) { |
|
212 | + if ($this->data['email_verified'] || ($this->user->loggedin && $this->user->email() == $this->data['email'])) { |
|
213 | 213 | $result = 'alert-exists'; |
214 | 214 | } else { |
215 | 215 | // don't throw an error message as that implies that they have already signed |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | |
236 | 236 | private function formatSearchTerms() { |
237 | - if ( $this->data['alertsearch'] ) { |
|
237 | + if ($this->data['alertsearch']) { |
|
238 | 238 | $this->data['alertsearch_pretty'] = $this->prettifyCriteria($this->data['alertsearch']); |
239 | 239 | $this->data['search_text'] = $this->data['alertsearch']; |
240 | 240 | } else { |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | |
245 | 245 | private function prettifyCriteria($alert_criteria) { |
246 | 246 | $text = ''; |
247 | - if ( $alert_criteria ) { |
|
247 | + if ($alert_criteria) { |
|
248 | 248 | $criteria = explode(' ', $alert_criteria); |
249 | 249 | $words = array(); |
250 | 250 | $spokenby = array_values(\MySociety\TheyWorkForYou\Utility\Search::speakerNamesForIDs($alert_criteria)); |
251 | 251 | |
252 | 252 | foreach ($criteria as $c) { |
253 | - if (!preg_match('#^speaker:(\d+)#',$c,$m)) { |
|
253 | + if (!preg_match('#^speaker:(\d+)#', $c, $m)) { |
|
254 | 254 | $words[] = $c; |
255 | 255 | } |
256 | 256 | } |
257 | - if ( $spokenby && count($words) ) { |
|
258 | - $text = implode(' or ', $spokenby) . ' mentions [' . implode(' ', $words) . ']'; |
|
259 | - } else if ( count( $words ) ) { |
|
260 | - $text = '[' . implode(' ', $words) . ']' . ' is mentioned'; |
|
261 | - } else if ( $spokenby ) { |
|
262 | - $text = implode(' or ', $spokenby) . " speaks"; |
|
257 | + if ($spokenby && count($words)) { |
|
258 | + $text = implode(' or ', $spokenby).' mentions ['.implode(' ', $words).']'; |
|
259 | + } else if (count($words)) { |
|
260 | + $text = '['.implode(' ', $words).']'.' is mentioned'; |
|
261 | + } else if ($spokenby) { |
|
262 | + $text = implode(' or ', $spokenby)." speaks"; |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | return $text; |
@@ -293,38 +293,38 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | private function formatSearchMemberData() { |
296 | - if ( isset($this->data['postcode']) ) { |
|
296 | + if (isset($this->data['postcode'])) { |
|
297 | 297 | try { |
298 | 298 | $postcode = $this->data['postcode']; |
299 | 299 | |
300 | - $MEMBER = new \MEMBER( array('postcode' => $postcode) ); |
|
300 | + $MEMBER = new \MEMBER(array('postcode' => $postcode)); |
|
301 | 301 | // move the postcode to the front just to be tidy |
302 | - $tidy_alertsearch = $postcode . " " . trim(str_replace("$postcode", "", $this->data['alertsearch'])); |
|
302 | + $tidy_alertsearch = $postcode." ".trim(str_replace("$postcode", "", $this->data['alertsearch'])); |
|
303 | 303 | $alertsearch_display = str_replace("$postcode ", "", $tidy_alertsearch); |
304 | 304 | |
305 | - $this->data['member_alertsearch'] = str_replace("$postcode", "speaker:" . $MEMBER->person_id, $tidy_alertsearch); |
|
305 | + $this->data['member_alertsearch'] = str_replace("$postcode", "speaker:".$MEMBER->person_id, $tidy_alertsearch); |
|
306 | 306 | $this->data['member_displaysearch'] = $alertsearch_display; |
307 | 307 | $this->data['member'] = $MEMBER; |
308 | 308 | |
309 | - if ( $this->data['scottish_text'] ) { |
|
309 | + if ($this->data['scottish_text']) { |
|
310 | 310 | $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($postcode); |
311 | - if ( isset($constituencies['SPC']) ) { |
|
311 | + if (isset($constituencies['SPC'])) { |
|
312 | 312 | $MEMBER = new \MEMBER(array('constituency' => $constituencies['SPC'], 'house' => 4)); |
313 | - $this->data['scottish_alertsearch'] = str_replace("$postcode", "speaker:" . $MEMBER->person_id, $tidy_alertsearch); |
|
313 | + $this->data['scottish_alertsearch'] = str_replace("$postcode", "speaker:".$MEMBER->person_id, $tidy_alertsearch); |
|
314 | 314 | $this->data['scottish_member'] = $MEMBER; |
315 | 315 | } |
316 | 316 | } |
317 | - } catch ( \MySociety\TheyWorkForYou\MemberException $e ) { |
|
317 | + } catch (\MySociety\TheyWorkForYou\MemberException $e) { |
|
318 | 318 | $this->data['member_error'] = 1; |
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | - if ( $this->data['pid'] ) { |
|
323 | - $MEMBER = new \MEMBER( array('person_id' => $this->data['pid']) ); |
|
322 | + if ($this->data['pid']) { |
|
323 | + $MEMBER = new \MEMBER(array('person_id' => $this->data['pid'])); |
|
324 | 324 | $this->data['pid_member'] = $MEMBER; |
325 | 325 | } |
326 | 326 | |
327 | - if ( $this->data['keyword'] ) { |
|
327 | + if ($this->data['keyword']) { |
|
328 | 328 | $this->data['display_keyword'] = $this->prettifyCriteria($this->data['keyword']); |
329 | 329 | } |
330 | 330 | } |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | for ($i = 0; $i < $num_alerts; $i++) { |
355 | 355 | $row = $q->row($i); |
356 | 356 | $criteria = $this->prettifyCriteria($row['criteria']); |
357 | - $token = $row['alert_id'] . '-' . $row['registrationtoken']; |
|
357 | + $token = $row['alert_id'].'-'.$row['registrationtoken']; |
|
358 | 358 | |
359 | 359 | $status = 'confirmed'; |
360 | - if ( !$row['confirmed'] ) { |
|
360 | + if (!$row['confirmed']) { |
|
361 | 361 | $status = 'unconfirmed'; |
362 | - } elseif ( $row['deleted'] == 2 ) { |
|
362 | + } elseif ($row['deleted'] == 2) { |
|
363 | 363 | $status = 'suspended'; |
364 | 364 | } |
365 | 365 |
@@ -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 | } |
@@ -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 | /** |