@@ -7,7 +7,7 @@ |
||
7 | 7 | namespace MySociety\TheyWorkForYou; |
8 | 8 | |
9 | 9 | // Disable the old PAGE class. |
10 | -$new_style_template = TRUE; |
|
10 | +$new_style_template = true; |
|
11 | 11 | global $this_page; |
12 | 12 | $this_page = 'topics'; |
13 | 13 |
@@ -8,7 +8,7 @@ |
||
8 | 8 | $topic = $topics->getTopic($slug); |
9 | 9 | } |
10 | 10 | |
11 | -if (!$slug || !isset($topic) || $topic === NULL) { |
|
11 | +if (!$slug || !isset($topic) || $topic === null) { |
|
12 | 12 | header('HTTP/1.0 404 Not Found'); |
13 | 13 | exit(); |
14 | 14 | } |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | $related2 = get_http_var('related2'); |
108 | 108 | $related3 = get_http_var('related3'); |
109 | 109 | |
110 | - $gid = $url ? get_gid_from_url($url) : NULL; |
|
111 | - $related_gid1 = $related1 ? get_gid_from_url($related1) : NULL; |
|
112 | - $related_gid2 = $related2 ? get_gid_from_url($related2) : NULL; |
|
113 | - $related_gid3 = $related3 ? get_gid_from_url($related3) : NULL; |
|
110 | + $gid = $url ? get_gid_from_url($url) : null; |
|
111 | + $related_gid1 = $related1 ? get_gid_from_url($related1) : null; |
|
112 | + $related_gid2 = $related2 ? get_gid_from_url($related2) : null; |
|
113 | + $related_gid3 = $related3 ? get_gid_from_url($related3) : null; |
|
114 | 114 | |
115 | 115 | print "<h2>Preview Content</h2>"; |
116 | - if ( $gid !== NULL ) { |
|
116 | + if ( $gid !== null ) { |
|
117 | 117 | $h = new MySociety\TheyWorkForYou\Homepage; |
118 | 118 | $featured = $h->getFeaturedDebate($gid, $title, $context, array( $related_gid1, $related_gid2, $related_gid3 )); |
119 | 119 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | function get_gid_from_url($url) { |
156 | - $gid = NULL; |
|
156 | + $gid = null; |
|
157 | 157 | $parts = parse_url($url); |
158 | 158 | parse_str($parts['query'], $query); |
159 | 159 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | $out = ''; |
13 | 13 | if (get_http_var('preview')) { |
14 | 14 | preview_featured(); |
15 | -} else if ( get_http_var('confirm') ) { |
|
15 | +} else if (get_http_var('confirm')) { |
|
16 | 16 | $out = update_featured(); |
17 | 17 | } |
18 | 18 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | print '</div>'; |
24 | 24 | |
25 | 25 | function gid_to_url($gid) { |
26 | - if ( !$gid ) { |
|
26 | + if (!$gid) { |
|
27 | 27 | return ''; |
28 | 28 | } |
29 | 29 | global $hansardmajors; |
30 | 30 | global $db; |
31 | 31 | |
32 | - $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array( ':gid' => $gid )); |
|
32 | + $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid)); |
|
33 | 33 | $url_gid = fix_gid_from_db($gid); |
34 | 34 | $url = new \URL($hansardmajors[$q->field(0, 'major')]['page']); |
35 | 35 | $url->insert(array('id' => $url_gid)); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $related = $featured->get_related(); |
44 | 44 | $context = $featured->get_context(); |
45 | 45 | |
46 | - if ( get_http_var('url') ) { |
|
46 | + if (get_http_var('url')) { |
|
47 | 47 | $url = get_http_var('url'); |
48 | 48 | $title = get_http_var('title'); |
49 | 49 | $context = get_http_var('context'); |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | $related_gid3 = $related3 ? get_gid_from_url($related3) : NULL; |
114 | 114 | |
115 | 115 | print "<h2>Preview Content</h2>"; |
116 | - if ( $gid !== NULL ) { |
|
116 | + if ($gid !== NULL) { |
|
117 | 117 | $h = new MySociety\TheyWorkForYou\Homepage; |
118 | - $featured = $h->getFeaturedDebate($gid, $title, $context, array( $related_gid1, $related_gid2, $related_gid3 )); |
|
118 | + $featured = $h->getFeaturedDebate($gid, $title, $context, array($related_gid1, $related_gid2, $related_gid3)); |
|
119 | 119 | |
120 | 120 | include INCLUDESPATH . 'easyparliament/templates/html/homepage/featured.php'; |
121 | 121 | } else { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $parts = parse_url($url); |
158 | 158 | parse_str($parts['query'], $query); |
159 | 159 | |
160 | - if ( $query['id'] ) { |
|
160 | + if ($query['id']) { |
|
161 | 161 | if (strpos($parts['path'], 'lords') !== false) { |
162 | 162 | $gid = 'uk.org.publicwhip/lords/'; |
163 | 163 | } elseif (strpos($parts['path'], 'whall') !== false) { |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | $out = ''; |
13 | 13 | if (get_http_var('preview')) { |
14 | 14 | preview_featured(); |
15 | -} else if ( get_http_var('confirm') ) { |
|
15 | +} |
|
16 | +else if ( get_http_var('confirm') ) { |
|
16 | 17 | $out = update_featured(); |
17 | 18 | } |
18 | 19 | |
@@ -50,7 +51,8 @@ discard block |
||
50 | 51 | $related1 = get_http_var('related1'); |
51 | 52 | $related2 = get_http_var('related2'); |
52 | 53 | $related3 = get_http_var('related3'); |
53 | - } else { |
|
54 | + } |
|
55 | + else { |
|
54 | 56 | $url = gid_to_url($gid); |
55 | 57 | $related1 = gid_to_url($related[0]); |
56 | 58 | $related2 = gid_to_url($related[1]); |
@@ -118,7 +120,8 @@ discard block |
||
118 | 120 | $featured = $h->getFeaturedDebate($gid, $title, $context, array( $related_gid1, $related_gid2, $related_gid3 )); |
119 | 121 | |
120 | 122 | include INCLUDESPATH . 'easyparliament/templates/html/homepage/featured.php'; |
121 | - } else { |
|
123 | + } |
|
124 | + else { |
|
122 | 125 | print "<p>A random debate from the last 7 days will be displayed</p>"; |
123 | 126 | } |
124 | 127 | |
@@ -160,9 +163,11 @@ discard block |
||
160 | 163 | if ( $query['id'] ) { |
161 | 164 | if (strpos($parts['path'], 'lords') !== false) { |
162 | 165 | $gid = 'uk.org.publicwhip/lords/'; |
163 | - } elseif (strpos($parts['path'], 'whall') !== false) { |
|
166 | + } |
|
167 | + elseif (strpos($parts['path'], 'whall') !== false) { |
|
164 | 168 | $gid = 'uk.org.publicwhip/westminhall/'; |
165 | - } else { |
|
169 | + } |
|
170 | + else { |
|
166 | 171 | $gid = 'uk.org.publicwhip/debate/'; |
167 | 172 | } |
168 | 173 | $gid .= $query['id']; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | </form> |
140 | 140 | |
141 | 141 | <p style="clear:both; margin-top: 3em"><a href="/images/mps/photo-status.php">List MPs without photos</a></p> |
142 | -EOF; |
|
142 | +eof; |
|
143 | 143 | |
144 | 144 | return $out; |
145 | 145 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | <span class="formw"><input type="submit" name="submit" value="Update attribution"></span> |
194 | 194 | </div> |
195 | 195 | </form> |
196 | -EOF; |
|
196 | +eof; |
|
197 | 197 | |
198 | 198 | return $out; |
199 | 199 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $houses = array(1 => 'MP', 'Lord', 'MLA', 'MSP'); |
96 | 96 | |
97 | - for ($i=0; $i<$q->rows(); $i++) { |
|
97 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
98 | 98 | $p_id = $q->field($i, 'person_id'); |
99 | 99 | $house = $q->field($i, 'house'); |
100 | 100 | $desc = member_full_name($house, $q->field($i, 'title'), $q->field($i, 'given_name'), $q->field($i, 'family_name'), $q->field($i, 'lordofname')) . |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } else { |
113 | 113 | $desc .= ' [no photo]'; |
114 | 114 | } |
115 | - $out .= '<option value="'.$p_id.'">'.$desc.'</option>' . "\n"; |
|
115 | + $out .= '<option value="' . $p_id . '">' . $desc . '</option>' . "\n"; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $out .= ' </select></span> </div> '; |
@@ -26,7 +26,8 @@ discard block |
||
26 | 26 | $out = ''; |
27 | 27 | if (get_http_var('submit')) { |
28 | 28 | $out = DEVSITE ? submit_photo() : submit_attribution(); |
29 | -} else { |
|
29 | +} |
|
30 | +else { |
|
30 | 31 | $out = DEVSITE ? display_photo_form() : display_attribution_form(); |
31 | 32 | } |
32 | 33 | print $out; |
@@ -36,28 +37,36 @@ discard block |
||
36 | 37 | $pid = intval(get_http_var('pid')); |
37 | 38 | $errors = array(); |
38 | 39 | |
39 | - if (!array_key_exists('photo', $_FILES)) |
|
40 | - array_push($errors, 'Not got the photo.'); |
|
41 | - elseif ($_FILES['photo']['error'] > 0) |
|
42 | - array_push($errors, 'There was an error uploading the photo.'); |
|
43 | - elseif (!is_uploaded_file($_FILES['photo']['tmp_name'])) |
|
44 | - array_push($errors, 'Did not get an uploaded file.'); |
|
40 | + if (!array_key_exists('photo', $_FILES)) { |
|
41 | + array_push($errors, 'Not got the photo.'); |
|
42 | + } |
|
43 | + elseif ($_FILES['photo']['error'] > 0) { |
|
44 | + array_push($errors, 'There was an error uploading the photo.'); |
|
45 | + } |
|
46 | + elseif (!is_uploaded_file($_FILES['photo']['tmp_name'])) { |
|
47 | + array_push($errors, 'Did not get an uploaded file.'); |
|
48 | + } |
|
45 | 49 | else { |
46 | 50 | $tmp_name = $_FILES['photo']['tmp_name']; |
47 | 51 | |
48 | 52 | $image = new Imagick(); |
49 | 53 | $image->readImage($tmp_name); |
50 | - if (!$image) |
|
51 | - array_push($errors, 'Failed to read image from uploaded file'); |
|
54 | + if (!$image) { |
|
55 | + array_push($errors, 'Failed to read image from uploaded file'); |
|
56 | + } |
|
52 | 57 | $imageS = clone $image; |
53 | - if (!$image->scaleImage(0, 118)) |
|
54 | - array_push($errors, 'Scaling large failed'); |
|
55 | - if (!$imageS->scaleImage(0, 59)) |
|
56 | - array_push($errors, 'Scaling small failed'); |
|
57 | - if (!$image->writeImage("$dir/mpsL/$pid.jpeg")) |
|
58 | - array_push($errors, "Saving to $dir/mpsL/$pid.jpeg failed"); |
|
59 | - if (!$imageS->writeImage("$dir/mps/$pid.jpeg")) |
|
60 | - array_push($errors, "Saving to $dir/mps/$pid.jpeg failed"); |
|
58 | + if (!$image->scaleImage(0, 118)) { |
|
59 | + array_push($errors, 'Scaling large failed'); |
|
60 | + } |
|
61 | + if (!$imageS->scaleImage(0, 59)) { |
|
62 | + array_push($errors, 'Scaling small failed'); |
|
63 | + } |
|
64 | + if (!$image->writeImage("$dir/mpsL/$pid.jpeg")) { |
|
65 | + array_push($errors, "Saving to $dir/mpsL/$pid.jpeg failed"); |
|
66 | + } |
|
67 | + if (!$imageS->writeImage("$dir/mps/$pid.jpeg")) { |
|
68 | + array_push($errors, "Saving to $dir/mps/$pid.jpeg failed"); |
|
69 | + } |
|
61 | 70 | if (!$errors) { |
62 | 71 | print "<pre>"; |
63 | 72 | chdir($dir); |
@@ -70,8 +79,9 @@ discard block |
||
70 | 79 | } |
71 | 80 | } |
72 | 81 | |
73 | - if ($errors) |
|
74 | - return display_photo_form($errors); |
|
82 | + if ($errors) { |
|
83 | + return display_photo_form($errors); |
|
84 | + } |
|
75 | 85 | return "<p><em>Photo uploaded and resized for pid $pid</em> — check how it looks <a href=\"/mp?p=$pid\">on their page</a></p>" . display_photo_form(); |
76 | 86 | } |
77 | 87 | |
@@ -99,7 +109,9 @@ discard block |
||
99 | 109 | $house = $q->field($i, 'house'); |
100 | 110 | $desc = member_full_name($house, $q->field($i, 'title'), $q->field($i, 'given_name'), $q->field($i, 'family_name'), $q->field($i, 'lordofname')) . |
101 | 111 | " " . $houses[$house]; |
102 | - if ($q->field($i, 'party')) $desc .= ' (' . $q->field($i, 'party') . ')'; |
|
112 | + if ($q->field($i, 'party')) { |
|
113 | + $desc .= ' (' . $q->field($i, 'party') . ')'; |
|
114 | + } |
|
103 | 115 | if ($q->field($i, 'constituency')) { |
104 | 116 | $desc .= ', ' . $q->field($i, 'constituency'); |
105 | 117 | } |
@@ -107,9 +119,11 @@ discard block |
||
107 | 119 | list($dummy, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($p_id); |
108 | 120 | if ($sz == 'L') { |
109 | 121 | $desc .= ' [has large photo]'; |
110 | - } elseif ($sz == 'S') { |
|
122 | + } |
|
123 | + elseif ($sz == 'S') { |
|
111 | 124 | $desc .= ' [has small photo]'; |
112 | - } else { |
|
125 | + } |
|
126 | + else { |
|
113 | 127 | $desc .= ' [no photo]'; |
114 | 128 | } |
115 | 129 | $out .= '<option value="'.$p_id.'">'.$desc.'</option>' . "\n"; |
@@ -150,13 +164,16 @@ discard block |
||
150 | 164 | $attr_link = get_http_var('attr_link'); |
151 | 165 | $errors = array(); |
152 | 166 | |
153 | - if (!$pid || !$attr_text) |
|
154 | - array_push($errors, 'Missing information'); |
|
155 | - elseif ($attr_link && substr($attr_link, 0, 4) != 'http') |
|
156 | - array_push($errors, 'Bad link'); |
|
167 | + if (!$pid || !$attr_text) { |
|
168 | + array_push($errors, 'Missing information'); |
|
169 | + } |
|
170 | + elseif ($attr_link && substr($attr_link, 0, 4) != 'http') { |
|
171 | + array_push($errors, 'Bad link'); |
|
172 | + } |
|
157 | 173 | |
158 | - if ($errors) |
|
159 | - return display_attribution_form($errors); |
|
174 | + if ($errors) { |
|
175 | + return display_attribution_form($errors); |
|
176 | + } |
|
160 | 177 | |
161 | 178 | # UPDATE |
162 | 179 | global $db; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | if ($type = ucfirst(get_http_var('type'))) { |
16 | - $class_name = "MySociety\TheyWorkForYou\SectionView\\${type}View"; |
|
16 | + $class_name = "MySociety\TheyWorkForYou\SectionView\\${type}view"; |
|
17 | 17 | $view = new $class_name(); |
18 | 18 | $data = $view->display(); |
19 | 19 | if ($data) { |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $view = new $class_name(); |
18 | 18 | $data = $view->display(); |
19 | 19 | if ($data) { |
20 | - if ( !empty($data['template']) ) { |
|
20 | + if (!empty($data['template'])) { |
|
21 | 21 | $template = $data['template']; |
22 | 22 | } else { |
23 | 23 | $template = 'section/section'; |
@@ -19,7 +19,8 @@ |
||
19 | 19 | if ($data) { |
20 | 20 | if ( !empty($data['template']) ) { |
21 | 21 | $template = $data['template']; |
22 | - } else { |
|
22 | + } |
|
23 | + else { |
|
23 | 24 | $template = 'section/section'; |
24 | 25 | } |
25 | 26 | MySociety\TheyWorkForYou\Renderer::output($template, $data); |
@@ -46,7 +46,7 @@ |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | $count = 0; |
49 | -while ( ( $policy = fgetcsv($file) ) !== FALSE ) { |
|
49 | +while ( ( $policy = fgetcsv($file) ) !== false ) { |
|
50 | 50 | if ( intval($policy[0]) ) { |
51 | 51 | $policy_id = $policy[0]; |
52 | 52 | $img_id = $policy[1] ? $policy[1] : $policy_id; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | exit(1); |
34 | 34 | } |
35 | 35 | |
36 | -if ( !file_exists($csvfile) ) { |
|
36 | +if (!file_exists($csvfile)) { |
|
37 | 37 | print "$csvfile cannot be found\n"; |
38 | 38 | exit(1); |
39 | 39 | } |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | $count = 0; |
49 | -while ( ( $policy = fgetcsv($file) ) !== FALSE ) { |
|
50 | - if ( intval($policy[0]) ) { |
|
49 | +while (($policy = fgetcsv($file)) !== FALSE) { |
|
50 | + if (intval($policy[0])) { |
|
51 | 51 | $policy_id = $policy[0]; |
52 | 52 | $img_id = $policy[1] ? $policy[1] : $policy_id; |
53 | 53 | $title = $policy[2]; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | ':image_attribution' => $attribution, |
70 | 70 | ':license_url' => $licence_url) |
71 | 71 | ); |
72 | - if ( $q->success() ) { |
|
72 | + if ($q->success()) { |
|
73 | 73 | $count += $q->affected_rows(); |
74 | 74 | } else { |
75 | 75 | print "failed to update data for $policy_id\n"; |
@@ -71,7 +71,8 @@ |
||
71 | 71 | ); |
72 | 72 | if ( $q->success() ) { |
73 | 73 | $count += $q->affected_rows(); |
74 | - } else { |
|
74 | + } |
|
75 | + else { |
|
75 | 76 | print "failed to update data for $policy_id\n"; |
76 | 77 | } |
77 | 78 | } |
@@ -8,9 +8,9 @@ discard block |
||
8 | 8 | // Test to make sure we have the test DB environment variables. If not, this isn't testing, so abort. |
9 | 9 | // Define the DB connection constants before we do anything else. |
10 | 10 | if ( |
11 | - isset($_SERVER['TWFY_TEST_DB_HOST']) AND |
|
12 | - isset($_SERVER['TWFY_TEST_DB_USER']) AND |
|
13 | - isset($_SERVER['TWFY_TEST_DB_PASS']) AND |
|
11 | + isset($_SERVER['TWFY_TEST_DB_HOST']) and |
|
12 | + isset($_SERVER['TWFY_TEST_DB_USER']) and |
|
13 | + isset($_SERVER['TWFY_TEST_DB_PASS']) and |
|
14 | 14 | isset($_SERVER['TWFY_TEST_DB_NAME']) |
15 | 15 | ) { |
16 | 16 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | // Explicitly declare we're in testing (avoids trying deploy-only things) |
40 | -define('TESTING', TRUE); |
|
40 | +define('TESTING', true); |
|
41 | 41 | |
42 | 42 | // Load up the init script (handles the rest of the config, DB connection etc) |
43 | 43 | include_once('www/includes/easyparliament/init.php'); |
@@ -21,13 +21,13 @@ |
||
21 | 21 | define('OPTION_TWFY_DB_NAME', $_SERVER['TWFY_TEST_DB_NAME']); |
22 | 22 | |
23 | 23 | // Define the base directory |
24 | - define ("BASEDIR", dirname(__FILE__) . '/../www/docs'); |
|
24 | + define("BASEDIR", dirname(__FILE__) . '/../www/docs'); |
|
25 | 25 | |
26 | 26 | # point to the default mapit |
27 | 27 | define('OPTION_MAPIT_URL', 'https://mapit.mysociety.org/'); |
28 | 28 | |
29 | 29 | // If there isn't a config file (most likely this is running an automated test) copy one in. |
30 | - if ( ! file_exists(dirname(__FILE__) . '/../conf/general')) { |
|
30 | + if (!file_exists(dirname(__FILE__) . '/../conf/general')) { |
|
31 | 31 | copy(dirname(__FILE__) . '/../conf/general-example', dirname(__FILE__) . '/../conf/general'); |
32 | 32 | } |
33 | 33 |
@@ -31,7 +31,8 @@ |
||
31 | 31 | copy(dirname(__FILE__) . '/../conf/general-example', dirname(__FILE__) . '/../conf/general'); |
32 | 32 | } |
33 | 33 | |
34 | -} else { |
|
34 | +} |
|
35 | +else { |
|
35 | 36 | echo "Testing environment variables not set. This will cause bad things to happen if testing happens on production. Aborting.\n"; |
36 | 37 | exit(1); |
37 | 38 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$new_style_template = TRUE; |
|
3 | +$new_style_template = true; |
|
4 | 4 | |
5 | 5 | include_once '../../../includes/easyparliament/init.php'; |
6 | 6 | include_once INCLUDESPATH . 'easyparliament/member.php'; |
@@ -9,7 +9,7 @@ |
||
9 | 9 | If the input is not OK, the form is displayed again with error messages. |
10 | 10 | */ |
11 | 11 | |
12 | -$new_style_template = TRUE; |
|
12 | +$new_style_template = true; |
|
13 | 13 | |
14 | 14 | include_once '../../../includes/easyparliament/init.php'; |
15 | 15 | # need to include this as login code uses error_message |
@@ -27,11 +27,11 @@ |
||
27 | 27 | |
28 | 28 | $data['fb_login_url'] = $login->getLoginURL(); |
29 | 29 | if (isset($data['token'])) { |
30 | - $success = $login->loginUser($data['token']); |
|
31 | - if (!$success) { |
|
30 | + $success = $login->loginUser($data['token']); |
|
31 | + if (!$success) { |
|
32 | 32 | $data['error'] = 'Could not login using Facebook token'; |
33 | 33 | \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data); |
34 | - } |
|
34 | + } |
|
35 | 35 | } else { |
36 | 36 | \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data); |
37 | 37 | } |
@@ -32,6 +32,7 @@ |
||
32 | 32 | $data['error'] = 'Could not login using Facebook token'; |
33 | 33 | \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data); |
34 | 34 | } |
35 | -} else { |
|
35 | +} |
|
36 | +else { |
|
36 | 37 | \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data); |
37 | 38 | } |