Failed Conditions
Pull Request — master (#1327)
by Nick
69:15 queued 59:17
created
www/docs/topic/topic.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 namespace MySociety\TheyWorkForYou;
12 12
 
13 13
 // Disable the old PAGE class.
14
-$new_style_template = TRUE;
14
+$new_style_template = true;
15 15
 
16 16
 // Include all the things this page needs.
17 17
 include_once '../../includes/easyparliament/init.php';
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
                 $pc = get_http_var('pc');
55 55
                 $pc = preg_replace('#[^a-z0-9]#i', '', $pc);
56 56
                 if (validate_postcode($pc)) {
57
-                    twfy_debug ('MP', "MP lookup by postcode");
57
+                    twfy_debug('MP', "MP lookup by postcode");
58 58
                     $constituency = strtolower(Utility\Postcode::postcodeToConstituency($pc));
59 59
                     if ($constituency == "connection_timed_out") {
60 60
                         throw new Exception('Sorry, we couldn’t check your postcode right now, as our postcode lookup server is under quite a lot of load.');
61 61
                     } elseif ($constituency == "") {
62
-                        twfy_debug ('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
62
+                        twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
63 63
                         throw new Exception('Sorry, ' . _htmlentities($pc) . ' isn’t a known postcode');
64 64
                     } else {
65 65
                         // Generate the Member object
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         }
71 71
                     }
72 72
                 } else {
73
-                    twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
73
+                    twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
74 74
                     throw new Exception('Sorry, ' . _htmlentities($pc) . ' isn’t a valid postcode');
75 75
                 }
76 76
             } catch (Exception $e) {
Please login to merge, or discard this patch.
Braces   +11 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
 $this_page = 'topic';
28 28
 
29 29
 // Make sure the requested topic actually exists, otherwise throw a 404.
30
-if ($topic = $topics->getTopic($topicname))
31
-{
30
+if ($topic = $topics->getTopic($topicname)) {
32 31
 
33 32
     $data = array();
34 33
     $data['topic'] = $topic;
@@ -45,8 +44,7 @@  discard block
 block discarded – undo
45 44
         include_once INCLUDESPATH . 'easyparliament/member.php';
46 45
 
47 46
         // Check to see if there's a submitted postcode to try determine policy positions.
48
-        if (get_http_var('pc') != '')
49
-        {
47
+        if (get_http_var('pc') != '') {
50 48
 
51 49
             // Try all this, as it might go wrong.
52 50
             try {
@@ -58,10 +56,12 @@  discard block
 block discarded – undo
58 56
                     $constituency = strtolower(Utility\Postcode::postcodeToConstituency($pc));
59 57
                     if ($constituency == "connection_timed_out") {
60 58
                         throw new Exception('Sorry, we couldn’t check your postcode right now, as our postcode lookup server is under quite a lot of load.');
61
-                    } elseif ($constituency == "") {
59
+                    }
60
+                    elseif ($constituency == "") {
62 61
                         twfy_debug ('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
63 62
                         throw new Exception('Sorry, ' . _htmlentities($pc) . ' isn’t a known postcode');
64
-                    } else {
63
+                    }
64
+                    else {
65 65
                         // Generate the Member object
66 66
                         $member = new Member(array('constituency' => $constituency, 'house' => HOUSE_TYPE_COMMONS));
67 67
                         if ($member->person_id()) {
@@ -69,7 +69,8 @@  discard block
 block discarded – undo
69 69
                             $THEUSER->set_postcode_cookie($pc);
70 70
                         }
71 71
                     }
72
-                } else {
72
+                }
73
+                else {
73 74
                     twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
74 75
                     throw new Exception('Sorry, ' . _htmlentities($pc) . ' isn’t a valid postcode');
75 76
                 }
@@ -81,8 +82,7 @@  discard block
 block discarded – undo
81 82
 
82 83
         /////////////////////////////////////////////////////////
83 84
         // DOES THE USER HAVE A POSTCODE ALREADY SET?
84
-        elseif ($THEUSER->postcode_is_set())
85
-        {
85
+        elseif ($THEUSER->postcode_is_set()) {
86 86
             $member = new Member(array('postcode' => $THEUSER->postcode(), 'house' => HOUSE_TYPE_COMMONS));
87 87
         }
88 88
 
@@ -122,7 +122,8 @@  discard block
 block discarded – undo
122 122
     // Send for rendering!
123 123
     Renderer::output('topic/topic', $data);
124 124
 
125
-} else {
125
+}
126
+else {
126 127
 
127 128
     header('HTTP/1.0 404 Not Found');
128 129
     Renderer::output('topic/error', array('error' => 'Sorry, but there isn’t a topic page by that name.'));
Please login to merge, or discard this patch.
www/docs/topic/index.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
www/docs/topic/image.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
www/docs/api/api_getPerson.php 4 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 <?php
18 18
 }
19 19
 
20
-function _api_getPerson_row($row, $has_party=FALSE) {
20
+function _api_getPerson_row($row, $has_party=false) {
21 21
     global $parties;
22 22
     $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'],
23 23
         $row['family_name'], $row['lordofname']);
Please login to merge, or discard this patch.
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -77,6 +77,9 @@  discard block
 block discarded – undo
77 77
     }
78 78
 }
79 79
 
80
+/**
81
+ * @param MySociety\TheyWorkForYou\Db\Query $q
82
+ */
80 83
 function _api_getPerson_output($q, $flatten=false) {
81 84
     $output = array();
82 85
     $last_mod = 0;
@@ -95,10 +98,16 @@  discard block
 block discarded – undo
95 98
     api_output($output, $last_mod);
96 99
 }
97 100
 
101
+/**
102
+ * @param integer $house
103
+ */
98 104
 function api_getPerson_constituency($constituency, $house) {
99 105
     _api_getPerson_constituency(array($constituency), $house);
100 106
 }
101 107
 
108
+/**
109
+ * @param integer $house
110
+ */
102 111
 function api_getPerson_postcode($pc, $house) {
103 112
     $pc = preg_replace('#[^a-z0-9 ]#i', '', $pc);
104 113
     $types = array();
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
 }
19 19
 
20
-function _api_getPerson_row($row, $has_party=FALSE) {
20
+function _api_getPerson_row($row, $has_party = FALSE) {
21 21
     global $parties;
22 22
     $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'],
23 23
         $row['family_name'], $row['lordofname']);
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     }
31 31
     if ($has_party && isset($parties[$row['party']]))
32 32
         $row['party'] = $parties[$row['party']];
33
-    list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
33
+    list($image, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
34 34
     if ($image) {
35 35
         list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
36 36
         $row['image'] = $image;
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         # Ministerialships and Select Committees
44 44
         $db = new ParlDB;
45 45
         $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC');
46
-        for ($i=0; $i<$q->rows(); $i++) {
46
+        for ($i = 0; $i < $q->rows(); $i++) {
47 47
             $row['office'][] = $q->row($i);
48 48
         }
49 49
     }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     return $row;
56 56
 }
57 57
 
58
-function api_getPerson_id($id, $house='') {
58
+function api_getPerson_id($id, $house = '') {
59 59
     $db = new ParlDB;
60 60
     $params = array(
61 61
         ':person_id' => $id
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
     }
78 78
 }
79 79
 
80
-function _api_getPerson_output($q, $flatten=false) {
80
+function _api_getPerson_output($q, $flatten = false) {
81 81
     $output = array();
82 82
     $last_mod = 0;
83
-    for ($i=0; $i<$q->rows(); $i++) {
83
+    for ($i = 0; $i < $q->rows(); $i++) {
84 84
         $house = $q->field($i, 'house');
85 85
         $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true);
86 86
         $output[] = $out;
Please login to merge, or discard this patch.
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
         $URL = new \MySociety\TheyWorkForYou\Url('mp');
29 29
         $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
30 30
     }
31
-    if ($has_party && isset($parties[$row['party']]))
32
-        $row['party'] = $parties[$row['party']];
31
+    if ($has_party && isset($parties[$row['party']])) {
32
+            $row['party'] = $parties[$row['party']];
33
+    }
33 34
     list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
34 35
     if ($image) {
35 36
         list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
@@ -49,7 +50,9 @@  discard block
 block discarded – undo
49 50
     }
50 51
 
51 52
     foreach ($row as $k => $r) {
52
-        if (is_string($r)) $row[$k] = html_entity_decode($r);
53
+        if (is_string($r)) {
54
+            $row[$k] = html_entity_decode($r);
55
+        }
53 56
     }
54 57
 
55 58
     return $row;
@@ -72,7 +75,8 @@  discard block
 block discarded – undo
72 75
         order by left_house desc", $params);
73 76
     if ($q->rows()) {
74 77
         _api_getPerson_output($q);
75
-    } else {
78
+    }
79
+    else {
76 80
         api_error('Unknown person ID');
77 81
     }
78 82
 }
@@ -85,8 +89,9 @@  discard block
 block discarded – undo
85 89
         $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true);
86 90
         $output[] = $out;
87 91
         $time = strtotime($q->field($i, 'lastupdate'));
88
-        if ($time > $last_mod)
89
-            $last_mod = $time;
92
+        if ($time > $last_mod) {
93
+                    $last_mod = $time;
94
+        }
90 95
     }
91 96
     # Only one MP, not an array
92 97
     if ($flatten && count($output) == 1 && $house == HOUSE_TYPE_COMMONS) {
@@ -104,24 +109,30 @@  discard block
 block discarded – undo
104 109
     $types = array();
105 110
     if ($house == HOUSE_TYPE_NI) {
106 111
         $types = array('NIE');
107
-    } elseif ($house == HOUSE_TYPE_SCOTLAND) {
112
+    }
113
+    elseif ($house == HOUSE_TYPE_SCOTLAND) {
108 114
         $types = array('SPC', 'SPE');
109 115
     }
110 116
     if (validate_postcode($pc)) {
111 117
         $constituencies = MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($pc);
112 118
         if ($constituencies == 'CONNECTION_TIMED_OUT') {
113 119
             api_error('Connection timed out');
114
-        } elseif ($types && isset($constituencies[$types[0]])) {
120
+        }
121
+        elseif ($types && isset($constituencies[$types[0]])) {
115 122
             $constituencies = array_map(function($c) use ($constituencies) { return $constituencies[$c]; }, $types);
116 123
             _api_getPerson_constituency($constituencies, $house);
117
-        } elseif ($types && isset($constituencies['WMC'])) {
124
+        }
125
+        elseif ($types && isset($constituencies['WMC'])) {
118 126
             api_error('Postcode not in correct region');
119
-        } elseif (isset($constituencies['WMC'])) {
127
+        }
128
+        elseif (isset($constituencies['WMC'])) {
120 129
             _api_getPerson_constituency(array($constituencies['WMC']), $house);
121
-        } else {
130
+        }
131
+        else {
122 132
             api_error('Unknown postcode');
123 133
         }
124
-    } else {
134
+    }
135
+    else {
125 136
         api_error('Invalid postcode');
126 137
     }
127 138
 }
@@ -134,13 +145,18 @@  discard block
 block discarded – undo
134 145
 
135 146
     $cons = array();
136 147
     foreach ($constituencies as $constituency) {
137
-        if ($constituency == '') continue;
138
-        if ($constituency == 'Orkney ')
139
-            $constituency = 'Orkney & Shetland';
148
+        if ($constituency == '') {
149
+            continue;
150
+        }
151
+        if ($constituency == 'Orkney ') {
152
+                    $constituency = 'Orkney & Shetland';
153
+        }
140 154
 
141 155
         if ($house == HOUSE_TYPE_COMMONS) {
142 156
             $normalised = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency);
143
-            if ($normalised) $constituency = $normalised;
157
+            if ($normalised) {
158
+                $constituency = $normalised;
159
+            }
144 160
         }
145 161
 
146 162
         $cons[] = $constituency;
@@ -167,7 +183,8 @@  discard block
 block discarded – undo
167 183
 
168 184
     if ($q->rows > 0) {
169 185
         _api_getPerson_output($q, true);
170
-    } else {
186
+    }
187
+    else {
171 188
         api_error('Unknown constituency, or no results for that constituency');
172 189
     }
173 190
 }
Please login to merge, or discard this patch.
www/docs/admin/featured.php 3 patches
Upper-Lower-Casing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'];
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 \MySociety\TheyWorkForYou\Url($hansardmajors[$q->field(0, 'major')]['page']);
35 35
     $url->insert(array('id' => $url_gid));
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
www/docs/admin/photos.php 3 patches
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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> ';
Please login to merge, or discard this patch.
Braces   +45 added lines, -28 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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> &mdash; 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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
www/docs/section.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
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';
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
scripts/mprss.php 4 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 			$contentencoded = $row['body'];
54 54
 				
55 55
 			$hdate = format_date($row['hdate'], 'Y-m-d');
56
-			if ($row['htime'] != NULL) {
56
+			if ($row['htime'] != null) {
57 57
 				$htime = format_time($row['htime'], 'H:i:s');
58 58
 			} else {
59 59
 				$htime = '00:00:00';
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -20,49 +20,49 @@  discard block
 block discarded – undo
20 20
 
21 21
 $starttime = time();
22 22
 for ($personrow=0; $personrow<$q->rows(); $personrow++) {
23
-	$person_id = $q->field($personrow, 'person_id');
23
+    $person_id = $q->field($personrow, 'person_id');
24 24
 
25
-	$args = array ( 'person_id' => $person_id );
26
-	$speeches = $HANSARDLIST->display('person', $args, 'none');
25
+    $args = array ( 'person_id' => $person_id );
26
+    $speeches = $HANSARDLIST->display('person', $args, 'none');
27 27
 
28
-	// Some data about this person that we'll need for the feed.
29
-	$MEMBER = new MEMBER(array('person_id' => $person_id));
30
-	$MPURL = new \MySociety\TheyWorkForYou\Url('mp');
31
-	$MPURL->insert(array('pid'=>$person_id));
32
-	$mpurl = $MPURL->generate();
28
+    // Some data about this person that we'll need for the feed.
29
+    $MEMBER = new MEMBER(array('person_id' => $person_id));
30
+    $MPURL = new \MySociety\TheyWorkForYou\Url('mp');
31
+    $MPURL->insert(array('pid'=>$person_id));
32
+    $mpurl = $MPURL->generate();
33 33
 
34
-	$date = gmdate('Y-m-d');
35
-	$time = gmdate('H:i:s');
36
-	$datenow = $date . 'T' . $time . '+00:00';
34
+    $date = gmdate('Y-m-d');
35
+    $time = gmdate('H:i:s');
36
+    $datenow = $date . 'T' . $time . '+00:00';
37 37
 
38
-	// Prepare the meat of the RSS file.
39
-	$items = '';
40
-	$entries = '';
41
-	if (isset ($speeches['rows']) && count($speeches['rows']) > 0) {
38
+    // Prepare the meat of the RSS file.
39
+    $items = '';
40
+    $entries = '';
41
+    if (isset ($speeches['rows']) && count($speeches['rows']) > 0) {
42 42
 
43
-		foreach ($speeches['rows'] as $n => $row) {
43
+        foreach ($speeches['rows'] as $n => $row) {
44 44
 
45
-			// While we're linking to individual speeches,
46
-			// the text is the body of the parent, ie (sub)section.
47
-			$title = _htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
45
+            // While we're linking to individual speeches,
46
+            // the text is the body of the parent, ie (sub)section.
47
+            $title = _htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
48 48
 
49
-			$link = isset($row['listurl']) ? $row['listurl'] : '';
50
-			$link = 'https://' . DOMAIN . $link;
49
+            $link = isset($row['listurl']) ? $row['listurl'] : '';
50
+            $link = 'https://' . DOMAIN . $link;
51 51
 
52
-			$description = _htmlentities(trim_characters($row['body'], 0, 200));
53
-			$contentencoded = $row['body'];
52
+            $description = _htmlentities(trim_characters($row['body'], 0, 200));
53
+            $contentencoded = $row['body'];
54 54
 
55
-			$hdate = format_date($row['hdate'], 'Y-m-d');
56
-			if ($row['htime'] != NULL) {
57
-				$htime = format_time($row['htime'], 'H:i:s');
58
-			} else {
59
-				$htime = '00:00:00';
60
-			}
55
+            $hdate = format_date($row['hdate'], 'Y-m-d');
56
+            if ($row['htime'] != NULL) {
57
+                $htime = format_time($row['htime'], 'H:i:s');
58
+            } else {
59
+                $htime = '00:00:00';
60
+            }
61 61
 
62
-			$date = $hdate . 'T' . $htime . '+00:00';
62
+            $date = $hdate . 'T' . $htime . '+00:00';
63 63
 
64
-			$items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
65
-			$entries .= "<item rdf:about=\"$link\">
64
+            $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
65
+            $entries .= "<item rdf:about=\"$link\">
66 66
 	<title>$title</title>
67 67
 	<link>$link</link>
68 68
 	<description>$description</description>
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 </item>
72 72
 ";
73 73
 
74
-		}
75
-	}
74
+        }
75
+    }
76 76
 
77
-	// Prepare the whole text of the RSS file.
78
-	$rsstext = '<?xml version="1.0" encoding="utf-8"?>
77
+    // Prepare the whole text of the RSS file.
78
+    $rsstext = '<?xml version="1.0" encoding="utf-8"?>
79 79
 <rdf:RDF
80 80
   xmlns:dc="http://purl.org/dc/elements/1.1/"
81 81
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 
102 102
 </rdf:RDF>';
103 103
 
104
-	// Write the text to the file...
105
-	$filename = $rsspath . $person_id . '.rdf';
106
-	$fh = @fopen($filename, "w");
107
-	if (!$fh) { # Problem writing, just carry on
108
-		echo "Could not write to file ($filename)\n";
109
-		continue;
110
-	}
111
-	fwrite($fh, $rsstext);
112
-	fclose ($fh);
104
+    // Write the text to the file...
105
+    $filename = $rsspath . $person_id . '.rdf';
106
+    $fh = @fopen($filename, "w");
107
+    if (!$fh) { # Problem writing, just carry on
108
+        echo "Could not write to file ($filename)\n";
109
+        continue;
110
+    }
111
+    fwrite($fh, $rsstext);
112
+    fclose ($fh);
113 113
 }
114 114
 
115 115
 #print "Took " . (time()-$starttime) . " seconds\n";
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 $rsspath = BASEDIR . '/rss/mp/';
10 10
 
11 11
 // Make things group writable.
12
-umask (002);
12
+umask(002);
13 13
 
14 14
 $HANSARDLIST = new HANSARDLIST();
15 15
 $db = $HANSARDLIST->db;
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
 if ($q->rows() <= 0) exit;
20 20
 
21 21
 $starttime = time();
22
-for ($personrow=0; $personrow<$q->rows(); $personrow++) {
22
+for ($personrow = 0; $personrow < $q->rows(); $personrow++) {
23 23
 	$person_id = $q->field($personrow, 'person_id');
24 24
 
25
-	$args = array ( 'person_id' => $person_id );
25
+	$args = array('person_id' => $person_id);
26 26
 	$speeches = $HANSARDLIST->display('person', $args, 'none');
27 27
 		
28 28
 	// Some data about this person that we'll need for the feed.
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		continue;
110 110
 	}
111 111
 	fwrite($fh, $rsstext);
112
-	fclose ($fh);
112
+	fclose($fh);
113 113
 }
114 114
 
115 115
 #print "Took " . (time()-$starttime) . " seconds\n";
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 
17 17
 // Get all the person ids we need feeds for...
18 18
 $q = $db->query("SELECT person_id FROM member WHERE left_house='9999-12-31'");
19
-if ($q->rows() <= 0) exit;
19
+if ($q->rows() <= 0) {
20
+    exit;
21
+}
20 22
 
21 23
 $starttime = time();
22 24
 for ($personrow=0; $personrow<$q->rows(); $personrow++) {
@@ -55,7 +57,8 @@  discard block
 block discarded – undo
55 57
 			$hdate = format_date($row['hdate'], 'Y-m-d');
56 58
 			if ($row['htime'] != NULL) {
57 59
 				$htime = format_time($row['htime'], 'H:i:s');
58
-			} else {
60
+			}
61
+			else {
59 62
 				$htime = '00:00:00';
60 63
 			}
61 64
 				
@@ -104,7 +107,8 @@  discard block
 block discarded – undo
104 107
 	// Write the text to the file...
105 108
 	$filename = $rsspath . $person_id . '.rdf';
106 109
 	$fh = @fopen($filename, "w");
107
-	if (!$fh) { # Problem writing, just carry on
110
+	if (!$fh) {
111
+# Problem writing, just carry on
108 112
 		echo "Could not write to file ($filename)\n";
109 113
 		continue;
110 114
 	}
Please login to merge, or discard this patch.
scripts/populate-policy-images.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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";
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,8 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.