Completed
Pull Request — master (#1323)
by Nick
84:26 queued 71:50
created
classes/People.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@
 block discarded – undo
30 30
         $this->db = new \ParlDB();
31 31
     }
32 32
 
33
+    /**
34
+     * @param User $user
35
+     */
33 36
     protected function getRegionalReps($user) {
34 37
         return $user->getRegionalReps($this->reg_cons_type, $this->house);
35 38
     }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
 namespace MySociety\TheyWorkForYou;
9 9
 
10
-include_once( dirname(__FILE__) . '/../www/includes/easyparliament/people.php' );
10
+include_once(dirname(__FILE__) . '/../www/includes/easyparliament/people.php');
11 11
 
12 12
 /**
13 13
  * People
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $data = $this->display($this->type, $args, 'none');
39 39
 
40 40
         $user = new User();
41
-        if ( $reps = $this->getRegionalReps($user) ) {
41
+        if ($reps = $this->getRegionalReps($user)) {
42 42
             $data['reps'] = $reps;
43 43
         }
44 44
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             $args['all'] = true;
71 71
         }
72 72
 
73
-        if ( $this->type == 'peers' ) {
73
+        if ($this->type == 'peers') {
74 74
             $args['order'] = 'name';
75 75
         }
76 76
 
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 
137 137
     private function addImagesToData($data) {
138 138
         $new_data = array();
139
-        foreach ( $data as $pid => $details ) {
140
-            list($image, ) = Utility\Member::findMemberImage($pid, true, $this->subs_missing_image);
139
+        foreach ($data as $pid => $details) {
140
+            list($image,) = Utility\Member::findMemberImage($pid, true, $this->subs_missing_image);
141 141
             $details['image'] = $image;
142 142
             $new_data[$pid] = $details;
143 143
         }
@@ -154,21 +154,21 @@  discard block
 block discarded – undo
154 154
 
155 155
         $urls['plain'] = $URL->generate();
156 156
 
157
-        $URL->insert(array( 'o' => 'n'));
157
+        $URL->insert(array('o' => 'n'));
158 158
         $urls['by_name'] = $URL->generate();
159 159
 
160
-        $URL->insert(array( 'o' => 'l'));
160
+        $URL->insert(array('o' => 'l'));
161 161
         $urls['by_last'] = $URL->generate();
162 162
 
163
-        $URL->insert(array( 'o' => 'f'));
163
+        $URL->insert(array('o' => 'f'));
164 164
         $urls['by_first'] = $URL->generate();
165 165
 
166
-        $URL->insert(array( 'o' => 'p'));
166
+        $URL->insert(array('o' => 'p'));
167 167
         $urls['by_party'] = $URL->generate();
168 168
 
169
-        $URL->insert(array( 'f' => 'csv'));
170
-        $URL->remove(array( 'o'));
171
-        if ( $date = get_http_var('date') ) {
169
+        $URL->insert(array('f' => 'csv'));
170
+        $URL->remove(array('o'));
171
+        if ($date = get_http_var('date')) {
172 172
             $URL->insert(array('date' => $date));
173 173
         }
174 174
         $urls['by_csv'] = $URL->generate();
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,8 @@  discard block
 block discarded – undo
66 66
             if ($date) {
67 67
                 $args['date'] = $date['iso'];
68 68
             }
69
-        } elseif (get_http_var('all')) {
69
+        }
70
+        elseif (get_http_var('all')) {
70 71
             $args['all'] = true;
71 72
         }
72 73
 
@@ -91,9 +92,11 @@  discard block
 block discarded – undo
91 92
 
92 93
         if (isset($args['date'])) {
93 94
             $DATA->set_page_metadata($this_page, 'title', $this->rep_plural . ', as on ' . format_date($args['date'], LONGDATEFORMAT));
94
-        } elseif (isset($args['all'])) {
95
+        }
96
+        elseif (isset($args['all'])) {
95 97
             $DATA->set_page_metadata($this_page, 'title', 'All ' . $this->rep_plural . ', including former ones');
96
-        } else {
98
+        }
99
+        else {
97 100
             $DATA->set_page_metadata($this_page, 'title', 'All ' . $this->rep_plural);
98 101
         }
99 102
     }
Please login to merge, or discard this patch.
classes/Renderer/Header.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -110,6 +110,9 @@
 block discarded – undo
110 110
         }
111 111
     }
112 112
 
113
+    /**
114
+     * @param string $linktype
115
+     */
113 116
     private function generate_next_prev_link($nextprev, $linktype) {
114 117
         $link = null;
115 118
         if (isset($nextprev[$linktype]) && isset($nextprev[$linktype]['url'])) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
     private function get_page_url() {
50 50
         $protocol = 'https://';
51 51
         if (DEVSITE) {
52
-          $protocol = 'http://';
52
+            $protocol = 'http://';
53 53
         }
54 54
         $url = $protocol . DOMAIN;
55 55
         if (array_key_exists('REQUEST_URI', $_SERVER)) {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         if (isset($nextprev[$linktype]) && isset($nextprev[$linktype]['url'])) {
136 136
 
137 137
             if (isset($nextprev[$linktype]['body'])) {
138
-                $linktitle = _htmlentities( trim_characters($nextprev[$linktype]['body'], 0, 40) );
138
+                $linktitle = _htmlentities(trim_characters($nextprev[$linktype]['body'], 0, 40));
139 139
                 if (isset($nextprev[$linktype]['speaker']) &&
140 140
                     count($nextprev[$linktype]['speaker']) > 0) {
141 141
                     $linktitle = $nextprev[$linktype]['speaker']['name'] . ': ' . $linktitle;
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 
163 163
         if ($nextprev) {
164 164
             // Four different kinds of back/forth links we might build.
165
-            $links = array ("first", "prev", "up", "next", "last");
165
+            $links = array("first", "prev", "up", "next", "last");
166 166
 
167 167
             foreach ($links as $type) {
168
-                if ( $link = $this->generate_next_prev_link( $nextprev, $type ) ) {
168
+                if ($link = $this->generate_next_prev_link($nextprev, $type)) {
169 169
 
170 170
                     $this->data['header_links'][] = $link;
171 171
                 }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         // Page names mapping to those in metadata.php.
259 259
         // Links in the top menu, and the sublinks we see if
260 260
         // we're within that section.
261
-        $nav_items = array (
261
+        $nav_items = array(
262 262
             array('home'),
263 263
             array('hansard', 'mps', 'peers', 'alldebatesfront', 'wranswmsfront', 'pbc_front', 'divisions_recent', 'calendar_summary', 'contact'),
264 264
             array('sp_home', 'spoverview', 'msps', 'spdebatesfront', 'spwransfront', 'contact'),
Please login to merge, or discard this patch.
Braces   +30 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,7 +38,8 @@  discard block
 block discarded – undo
38 38
         # Robots header
39 39
         if (DEVSITE) {
40 40
             $this->data['robots'] = 'noindex,nofollow';
41
-        } elseif ($robots = $DATA->page_metadata($this_page, 'robots')) {
41
+        }
42
+        elseif ($robots = $DATA->page_metadata($this_page, 'robots')) {
42 43
             $this->data['robots'] = $robots;
43 44
         }
44 45
     }
@@ -71,7 +72,8 @@  discard block
 block discarded – undo
71 72
         if ($this_page == 'overview') {
72 73
             $this->data['page_title'] = $sitetitle . ': ' . $DATA->page_metadata($this_page, "title");
73 74
 
74
-        } else {
75
+        }
76
+        else {
75 77
 
76 78
             if ($page_title = $DATA->page_metadata($this_page, "title")) {
77 79
                 $this->data['page_title'] = $page_title;
@@ -81,13 +83,16 @@  discard block
 block discarded – undo
81 83
 
82 84
             $parent_page = $DATA->page_metadata($this_page, 'parent');
83 85
             if ($parent_title = $DATA->page_metadata($parent_page, 'title')) {
84
-                if ($this->data['page_title']) $this->data['page_title'] .= ': ';
86
+                if ($this->data['page_title']) {
87
+                    $this->data['page_title'] .= ': ';
88
+                }
85 89
                 $this->data['page_title'] .= $parent_title;
86 90
             }
87 91
 
88 92
             if ($this->data['page_title'] == '') {
89 93
                 $this->data['page_title'] = $sitetitle;
90
-            } else {
94
+            }
95
+            else {
91 96
                 $this->data['page_title'] .= ' - ' . $sitetitle;
92 97
             }
93 98
         }
@@ -103,7 +108,9 @@  discard block
 block discarded – undo
103 108
         // Meta keywords
104 109
         if (!$this->data['meta_keywords'] = $DATA->page_metadata($this_page, "meta_keywords")) {
105 110
             $this->data['meta_keywords'] = $this->keywords_title;
106
-            if ($this->data['meta_keywords']) $this->data['meta_keywords'] .= ', ';
111
+            if ($this->data['meta_keywords']) {
112
+                $this->data['meta_keywords'] .= ', ';
113
+            }
107 114
             $this->data['meta_keywords'] .= 'Hansard, Official Report, Parliament, government, House of Commons, House of Lords, MP, Peer, Member of Parliament, MPs, Peers, Lords, Commons, Scottish Parliament, Northern Ireland Assembly, MSP, MLA, MSPs, MLAs';
108 115
         }
109 116
 
@@ -141,7 +148,8 @@  discard block
 block discarded – undo
141 148
                     $linktitle = $nextprev[$linktype]['speaker']['name'] . ': ' . $linktitle;
142 149
                 }
143 150
 
144
-            } elseif (isset($nextprev[$linktype]['hdate'])) {
151
+            }
152
+            elseif (isset($nextprev[$linktype]['hdate'])) {
145 153
                 $linktitle = format_date($nextprev[$linktype]['hdate'], SHORTDATEFORMAT);
146 154
             }
147 155
 
@@ -198,13 +206,16 @@  discard block
 block discarded – undo
198 206
             $url = new \URL('hansard');
199 207
             $selected_top_link['link'] = $url->generate();
200 208
 
201
-        } else {
209
+        }
210
+        else {
202 211
 
203 212
             $parents = array($parent);
204 213
             $p = $parent;
205 214
             while ($p) {
206 215
                 $p = $DATA->page_metadata($p, 'parent');
207
-                if ($p) $parents[] = $p;
216
+                if ($p) {
217
+                    $parents[] = $p;
218
+                }
208 219
             }
209 220
 
210 221
             $top_highlight = array_pop($parents);
@@ -213,7 +224,8 @@  discard block
 block discarded – undo
213 224
                 // We're on one of the pages linked to by the bottom menu.
214 225
                 // So highlight it and its parent.
215 226
                 $bottom_highlight = $this_page;
216
-            } else {
227
+            }
228
+            else {
217 229
                 // This page is not in either menu. So highlight its parent
218 230
                 // (in the bottom menu) and its grandparent (in the top).
219 231
                 $bottom_highlight = array_pop($parents);
@@ -232,13 +244,16 @@  discard block
 block discarded – undo
232 244
         if ($top_highlight == 'hansard') {
233 245
             $section = 'uk';
234 246
             $selected_top_link['text'] = 'UK';
235
-        } elseif ($top_highlight == 'ni_home') {
247
+        }
248
+        elseif ($top_highlight == 'ni_home') {
236 249
             $section = 'ni';
237 250
             $selected_top_link['text'] = 'NORTHERN IRELAND';
238
-        } elseif ($top_highlight == 'sp_home') {
251
+        }
252
+        elseif ($top_highlight == 'sp_home') {
239 253
             $section = 'scotland';
240 254
             $selected_top_link['text'] = 'SCOTLAND';
241
-        } else {
255
+        }
256
+        else {
242 257
             $section = '';
243 258
         }
244 259
 
@@ -279,7 +294,9 @@  discard block
 block discarded – undo
279 294
             $menudata = $DATA->page_metadata($toppage, 'menu');
280 295
                 $text = $menudata['text'];
281 296
                 $title = $menudata['title'];
282
-            if (!$title) continue;
297
+            if (!$title) {
298
+                continue;
299
+            }
283 300
 
284 301
                 //get link and description for the menu ans add it to the array
285 302
             $class = $toppage == $this->nav_highlights['top'] ? 'on' : '';
Please login to merge, or discard this patch.
classes/Search/Normal.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -177,6 +177,9 @@
 block discarded – undo
177 177
         return $items;
178 178
     }
179 179
 
180
+    /**
181
+     * @param \URL $url
182
+     */
180 183
     private function generate_pagination_links($data, $url, $first, $last) {
181 184
         $links = array();
182 185
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
         }
13 13
 
14 14
         $o = get_http_var('o');
15
-        $args = array (
15
+        $args = array(
16 16
             's' => $this->searchstring,
17 17
             'p' => $pagenum,
18 18
             'num' => get_http_var('num'),
19 19
             'pop' => get_http_var('pop'),
20
-            'o' => ($o=='d' || $o=='r' || $o=='o') ? $o : 'd',
20
+            'o' => ($o == 'd' || $o == 'r' || $o == 'o') ? $o : 'd',
21 21
         );
22 22
 
23 23
         return $args;
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
         }
56 56
 
57 57
         $sort_order = 'newest';
58
-        if ( $args['o'] == 'o' ) {
58
+        if ($args['o'] == 'o') {
59 59
             $sort_order = 'oldest';
60
-        } else if ( $args['o'] == 'r' ) {
60
+        } else if ($args['o'] == 'r') {
61 61
             $sort_order = 'relevance';
62 62
         }
63 63
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             return array('error' => $SEARCHENGINE->error);
74 74
         } else {
75 75
             $LIST = new \HANSARDLIST();
76
-            $data = $LIST->display('search', $args , 'none');
76
+            $data = $LIST->display('search', $args, 'none');
77 77
             $data['search_type'] = 'normal';
78 78
             $data['sort_order'] = $sort_order;
79 79
             $data['members'] = $members;
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
             return false;
94 94
         }
95 95
 
96
-        list ($constituencies, ) = \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery($searchterm);
96
+        list ($constituencies,) = \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery($searchterm);
97 97
 
98 98
         $constituency = "";
99
-        if (count($constituencies)==1) {
99
+        if (count($constituencies) == 1) {
100 100
             $constituency = $constituencies[0];
101 101
         }
102 102
 
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 
113 113
                 $MEMBER = new \MySociety\TheyWorkForYou\Member(array('constituency'=>$constituency, 'house' => 1));
114 114
                 $cons[] = $MEMBER;
115
-                if ( $MEMBER->current_member(1) ) {
115
+                if ($MEMBER->current_member(1)) {
116 116
                     $mp_types['mp']++;
117 117
                 } else {
118 118
                     $mp_types['former']++;
119 119
                 }
120
-            } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
120
+            } catch (\MySociety\TheyWorkForYou\MemberException $e) {
121 121
                 $cons = array();
122 122
             }
123 123
         } elseif (count($constituencies)) {
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
                 try {
126 126
                     $MEMBER = new \MySociety\TheyWorkForYou\Member(array('constituency'=>$constituency, 'house' => 1));
127 127
                     $cons[] = $MEMBER;
128
-                    if ( $MEMBER->current_member(1) ) {
128
+                    if ($MEMBER->current_member(1)) {
129 129
                         $mp_types['mp']++;
130 130
                     } else {
131 131
                         $mp_types['former']++;
132 132
                     }
133
-                } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
133
+                } catch (\MySociety\TheyWorkForYou\MemberException $e) {
134 134
                     continue;
135 135
                 }
136 136
             }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
         $q = \MySociety\TheyWorkForYou\Utility\Search::searchMemberDbLookup($searchstring);
149 149
         $row_count = $q->rows();
150
-        for ($n=0; $n<$row_count; $n++) {
150
+        for ($n = 0; $n < $row_count; $n++) {
151 151
             $members[] = $q->field($n, 'person_id');
152 152
         }
153 153
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         $q = $db->query("SELECT person FROM moffice WHERE position LIKE :pos ORDER BY from_date DESC, moffice_id",
156 156
             array('pos' => "%$searchstring%"));
157 157
         $row_count = $q->rows();
158
-        for ($n=0; $n<$row_count; $n++) {
158
+        for ($n = 0; $n < $row_count; $n++) {
159 159
             $members[] = $q->field($n, 'person');
160 160
         }
161 161
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
             $link = array(
204 204
                 'url' => $url->generate(),
205 205
                 'page' => $n,
206
-                'current' => ( $n == $data['page'] )
206
+                'current' => ($n == $data['page'])
207 207
             );
208 208
 
209 209
             $links[] = $link;
@@ -244,27 +244,27 @@  discard block
 block discarded – undo
244 244
             $numlinks = $this->generate_pagination_links($data, $URL, $firstpage, $lastpage);
245 245
 
246 246
             $pagelinks['nums'] = $numlinks;
247
-            $pagelinks['first_result'] = $page == 1 ? 1 : ( ( $page - 1 ) * $results_per_page ) + 1;
248
-            $pagelinks['last_result'] = $page == $numpages ? $total_results : $pagelinks['first_result'] + ( $results_per_page - 1 );
247
+            $pagelinks['first_result'] = $page == 1 ? 1 : (($page - 1) * $results_per_page) + 1;
248
+            $pagelinks['last_result'] = $page == $numpages ? $total_results : $pagelinks['first_result'] + ($results_per_page - 1);
249 249
 
250
-            if ( $page != 1 ) {
250
+            if ($page != 1) {
251 251
                 $prev_page = $page - 1;
252
-                $URL->insert(array( 'p' => $prev_page ) );
252
+                $URL->insert(array('p' => $prev_page));
253 253
                 $pagelinks['prev'] = array(
254 254
                     'url' => $URL->generate()
255 255
                 );
256
-                $URL->insert(array( 'p' => 1 ) );
256
+                $URL->insert(array('p' => 1));
257 257
                 $pagelinks['firstpage'] = array(
258 258
                     'url' => $URL->generate()
259 259
                 );
260 260
             }
261 261
             if ($page != $numpages) {
262 262
                 $next_page = $page + 1;
263
-                $URL->insert(array( 'p' => $next_page ) );
263
+                $URL->insert(array('p' => $next_page));
264 264
                 $pagelinks['next'] = array(
265 265
                     'url' => $URL->generate()
266 266
                 );
267
-                $URL->insert(array( 'p' => $numpages ) );
267
+                $URL->insert(array('p' => $numpages));
268 268
                 $pagelinks['lastpage'] = array(
269 269
                     'url' => $URL->generate()
270 270
                 );
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
         $links['rss'] = $DATA->page_metadata($this_page, 'rss');
282 282
 
283 283
         if ($SEARCHENGINE) {
284
-            $links['email'] = '/alert/?' . ($this->searchstring ? 'alertsearch='.urlencode($this->searchstring) : '');
284
+            $links['email'] = '/alert/?' . ($this->searchstring ? 'alertsearch=' . urlencode($this->searchstring) : '');
285 285
             $links['email_desc'] = $SEARCHENGINE->query_description_long();
286 286
         }
287 287
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             $search_engine = new \SEARCHENGINE($filter_ss);
296 296
             $links['email_section'] = $links['email'];
297 297
             $links['email_desc_section'] = $links['email_desc'];
298
-            $links['email'] = '/alert/?' . ($filter_ss ? 'alertsearch='.urlencode($filter_ss) : '');
298
+            $links['email'] = '/alert/?' . ($filter_ss ? 'alertsearch=' . urlencode($filter_ss) : '');
299 299
             $links['email_desc'] = $search_engine->query_description_long();
300 300
         }
301 301
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -57,7 +57,8 @@  discard block
 block discarded – undo
57 57
         $sort_order = 'newest';
58 58
         if ( $args['o'] == 'o' ) {
59 59
             $sort_order = 'oldest';
60
-        } else if ( $args['o'] == 'r' ) {
60
+        }
61
+        else if ( $args['o'] == 'r' ) {
61 62
             $sort_order = 'relevance';
62 63
         }
63 64
 
@@ -71,7 +72,8 @@  discard block
 block discarded – undo
71 72
 
72 73
         if (!$SEARCHENGINE->valid) {
73 74
             return array('error' => $SEARCHENGINE->error);
74
-        } else {
75
+        }
76
+        else {
75 77
             $LIST = new \HANSARDLIST();
76 78
             $data = $LIST->display('search', $args , 'none');
77 79
             $data['search_type'] = 'normal';
@@ -89,7 +91,8 @@  discard block
 block discarded – undo
89 91
     private function find_constituency($args) {
90 92
         if ($args['s'] != '') {
91 93
             $searchterm = $args['s'];
92
-        } else {
94
+        }
95
+        else {
93 96
             return false;
94 97
         }
95 98
 
@@ -114,20 +117,23 @@  discard block
 block discarded – undo
114 117
                 $cons[] = $MEMBER;
115 118
                 if ( $MEMBER->current_member(1) ) {
116 119
                     $mp_types['mp']++;
117
-                } else {
120
+                }
121
+                else {
118 122
                     $mp_types['former']++;
119 123
                 }
120 124
             } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
121 125
                 $cons = array();
122 126
             }
123
-        } elseif (count($constituencies)) {
127
+        }
128
+        elseif (count($constituencies)) {
124 129
             foreach ($constituencies as $constituency) {
125 130
                 try {
126 131
                     $MEMBER = new \MySociety\TheyWorkForYou\Member(array('constituency'=>$constituency, 'house' => 1));
127 132
                     $cons[] = $MEMBER;
128 133
                     if ( $MEMBER->current_member(1) ) {
129 134
                         $mp_types['mp']++;
130
-                    } else {
135
+                    }
136
+                    else {
131 137
                         $mp_types['former']++;
132 138
                     }
133 139
                 } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
@@ -141,7 +147,9 @@  discard block
 block discarded – undo
141 147
 
142 148
     private function find_members() {
143 149
         $searchstring = trim(preg_replace('#-?[a-z]+:[a-z0-9]+#', '', $this->searchstring));
144
-        if (!$searchstring) return array();
150
+        if (!$searchstring) {
151
+            return array();
152
+        }
145 153
 
146 154
         $members = array();
147 155
 
@@ -195,7 +203,8 @@  discard block
 block discarded – undo
195 203
 
196 204
             if ($n > 1) {
197 205
                 $url->insert(array('p'=>$n));
198
-            } else {
206
+            }
207
+            else {
199 208
                 // No page number for the first page.
200 209
                 $url->remove(array('p'));
201 210
             }
@@ -229,7 +238,8 @@  discard block
 block discarded – undo
229 238
             if ($page < 10) {
230 239
                 $firstpage = 1;
231 240
                 $lastpage = 10;
232
-            } else {
241
+            }
242
+            else {
233 243
                 $firstpage = $page - 4;
234 244
                 $lastpage = $page + 5;
235 245
             }
Please login to merge, or discard this patch.
classes/SectionView/SectionView.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -347,6 +347,9 @@
 block discarded – undo
347 347
         return array($bodies, $speeches);
348 348
     }
349 349
 
350
+    /**
351
+     * @param integer $speeches
352
+     */
350 353
     private function annotateSpeeches($data, $bodies, $speeches) {
351 354
         global $THEUSER;
352 355
         $first_speech = null;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -512,7 +512,7 @@
 block discarded – undo
512 512
             if ($row['totalcomments'] > 1) {
513 513
                 $morecount = $row['totalcomments'] - 1;
514 514
                 $plural = $morecount == 1 ? 'annotation' : 'annotations';
515
-                $linktext = "Read $morecount more $plural";
515
+                $linktext = "read $morecount more $plural";
516 516
             }
517 517
 
518 518
         } else {
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             $data = $this->addCommonData($data);
33 33
         } elseif ($date = get_http_var('d')) {
34 34
             $data = $this->display_day($date);
35
-            if ( !isset($data['template']) ) {
35
+            if (!isset($data['template'])) {
36 36
                 $data['template'] = 'section/day';
37 37
             }
38 38
             $data = $this->addCommonData($data);
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             $data = $this->display_section_or_speech();
41 41
         } else {
42 42
             $data = $this->display_front();
43
-            if ( !isset($data['template']) ) {
43
+            if (!isset($data['template'])) {
44 44
                 $data['template'] = 'section/recent';
45 45
             }
46 46
             $data['search_sections'] = $this->getSearchSections();
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
         $data['recess_major'] = $this->getRecessMajor($data);
60 60
 
61 61
         $nextprev = $DATA->page_metadata($this_page, 'nextprev');
62
-        if ( isset($nextprev['next']['url']) ) {
62
+        if (isset($nextprev['next']['url'])) {
63 63
             $data['next'] = $nextprev['next'];
64 64
         }
65
-        if ( isset($nextprev['prev']['url']) ) {
65
+        if (isset($nextprev['prev']['url'])) {
66 66
             $data['prev'] = $nextprev['prev'];
67 67
         }
68 68
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         if (!isset($data['title']) && $parent_page != '') {
72 72
             $data['title'] = $DATA->page_metadata($parent_page, 'title');
73 73
         }
74
-        if ( $parent_page ) {
74
+        if ($parent_page) {
75 75
             $data['parent_title'] = $DATA->page_metadata($parent_page, 'title');
76 76
         }
77 77
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
         $urls = array_merge($urls, $this->getViewUrls());
89 89
 
90
-        if ( isset($data['info']['page']) ) {
90
+        if (isset($data['info']['page'])) {
91 91
             $day = new \URL($data['info']['page']);
92 92
             $urls['day'] = $day;
93 93
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             $DATA->set_page_metadata($this_page, 'title', $year);
134 134
         }
135 135
 
136
-        $args = array ( 'year' => $year );
136
+        $args = array('year' => $year);
137 137
         $data = $this->list->display('calendar', $args, 'none');
138 138
         return $data;
139 139
     }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     protected function display_column($date, $column) {
142 142
         global $this_page;
143 143
         $this_page = $this->page_base;
144
-        $args = array( 'date' => $date, 'column' => $column );
144
+        $args = array('date' => $date, 'column' => $column);
145 145
         $content = $this->list->display('column', $args, 'none');
146 146
 
147 147
         $data = array();
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
     protected function display_day($date) {
167 167
         global $this_page;
168 168
         $this_page = $this->page_base . 'day';
169
-        $args = array ( 'date' => get_http_var('d') );
169
+        $args = array('date' => get_http_var('d'));
170 170
         $data = $this->list->display('date', $args, 'none');
171 171
         list($year, $month, $day) = explode('-', $date);
172
-        $args = array( 'year' => $year, 'month' => $month, 'day' => $day);
172
+        $args = array('year' => $year, 'month' => $month, 'day' => $day);
173 173
         $calendar = $this->list->display('calendar', $args, 'none');
174
-        if ( isset($calendar['years']) ) {
174
+        if (isset($calendar['years'])) {
175 175
             $data['calendar'] = $calendar['years'];
176 176
         }
177 177
         return $data;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         global $DATA, $this_page, $THEUSER;
182 182
 
183 183
         # += as we *don't* want to override any already supplied argument
184
-        $args += array (
184
+        $args += array(
185 185
             'gid' => get_http_var('id'),
186 186
             's' => get_http_var('s'), // Search terms to be highlighted.
187 187
             'member_id' => get_http_var('m'), // Member's speeches to be highlighted.
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
             if ($this->major == 6) {
199 199
                 # Magically (as in I can't remember quite why), pbc_clause will
200 200
                 # contain the new URL without any change...
201
-                $URL->remove( array('id') );
201
+                $URL->remove(array('id'));
202 202
             } else {
203
-                $URL->insert( array('id'=>$e->getMessage()) );
203
+                $URL->insert(array('id'=>$e->getMessage()));
204 204
             }
205 205
             # put the search term back in so highlighting works.
206 206
             # NB: as we don't see the # part of the URL we lose this :(
207
-            if ( $args['s'] !== '' ) {
208
-                $URL->insert( array('s'=>$args['s']) );
207
+            if ($args['s'] !== '') {
208
+                $URL->insert(array('s'=>$args['s']));
209 209
             }
210 210
             redirect($URL->generate('none'));
211 211
         }
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         if (array_key_exists('text_heading', $data['info'])) {
274 274
             // avoid having Clause 1 etc as the alert text search string on PBC pages as it's
275 275
             // almost certainly not what the person wants
276
-            if ( $this->major == 6 ) {
276
+            if ($this->major == 6) {
277 277
                 $data['email_alert_text'] = $data['section_title'];
278 278
             } else {
279 279
                 $data['email_alert_text'] = $data['info']['text_heading'];
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
             $body = preg_replace('#<phrase class="honfriend" id="uk.org.publicwhip/member/(\d+)" name="([^"]*?)">(.*?\s*\((.*?)\))</phrase>#', '<a href="/mp/?m=$1" title="Our page on $2 - \'$3\'">$4</a>', $body);
321 321
             $body = preg_replace('#<phrase class="honfriend" name="([^"]*?)" person_id="uk.org.publicwhip/person/(\d+)">(.*?\s*\((.*?)\))</phrase>#', '<a href="/mp/?p=$2" title="Our page on $1 - \'$3\'">$4</a>', $body);
322 322
             $body = preg_replace_callback('#<phrase class="offrep" id="(.*?)/(\d+)-(\d+)-(\d+)\.(.*?)">(.*?)</phrase>#', function($matches) {
323
-                return '<a href="/search/?pop=1&s=date:' . $matches[2] . $matches[3] . $matches[4] . '+column:' . $matches[5] . '+section:' . $matches[1] .'">' . str_replace("Official Report", "Hansard", $matches[6]) . '</a>';
323
+                return '<a href="/search/?pop=1&s=date:' . $matches[2] . $matches[3] . $matches[4] . '+column:' . $matches[5] . '+section:' . $matches[1] . '">' . str_replace("Official Report", "Hansard", $matches[6]) . '</a>';
324 324
             }, $body);
325 325
             #$body = preg_replace('#<phrase class="offrep" id="((.*?)/(\d+)-(\d+)-(\d+)\.(.*?))">(.*?)</phrase>#e', "\"<a href='/search/?pop=1&amp;s=date:$3$4$5+column:$6+section:$2&amp;match=$1'>\" . str_replace('Official Report', 'Hansard', '$7') . '</a>'", $body);
326 326
             $bodies[] = $body;
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
         $first_speech = null;
353 353
         $data['section_title'] = '';
354 354
         $subsection_title = '';
355
-        for ($i=0; $i<count($data['rows']); $i++) {
355
+        for ($i = 0; $i < count($data['rows']); $i++) {
356 356
             $row = $data['rows'][$i];
357 357
             $htype = $row['htype'];
358 358
             // HPOS should be defined below if it's needed; otherwise default to 0
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                 # Voting links
376 376
                 $data['rows'][$i]['voting_data'] = '';
377 377
                 if (isset($row['votes'])) {
378
-                    $data['rows'][$i]['voting_data'] = $this->generate_votes( $row['votes'], $row['epobject_id'], $row['gid'] );
378
+                    $data['rows'][$i]['voting_data'] = $this->generate_votes($row['votes'], $row['epobject_id'], $row['gid']);
379 379
                 }
380 380
 
381 381
                 # Annotation link
@@ -398,47 +398,47 @@  discard block
 block discarded – undo
398 398
 
399 399
     private function getCountryDetails() {
400 400
         $details = array(
401
-            1 => array (
401
+            1 => array(
402 402
                 'country' => 'UK',
403 403
                 'assembly' => 'uk-commons',
404 404
                 'location' => '&ndash; in the House of Commons'
405 405
             ),
406
-            2 => array (
406
+            2 => array(
407 407
                 'country' => 'UK',
408 408
                 'assembly' => 'uk-commons',
409 409
                 'location' => '&ndash; in Westminster Hall'
410 410
             ),
411
-            3 => array (
411
+            3 => array(
412 412
                 'country' => 'UK',
413 413
                 'assembly' => 'uk-commons',
414 414
                 'location' => 'written question &ndash; answered'
415 415
             ),
416
-            4 => array (
416
+            4 => array(
417 417
                 'country' => 'UK',
418 418
                 'assembly' => 'uk-commons',
419 419
                 'location' => 'written statement &ndash; made'
420 420
             ),
421
-            5 => array (
421
+            5 => array(
422 422
                 'country' => 'NORTHERN IRELAND',
423 423
                 'assembly' => 'ni',
424 424
                 'location' => '&ndash; in the Northern Ireland Assembly'
425 425
             ),
426
-            6 => array (
426
+            6 => array(
427 427
                 'country' => 'UK',
428 428
                 'assembly' => 'uk-commons',
429 429
                 'location' => '&ndash; in a Public Bill Committee'
430 430
             ),
431
-            7 => array (
431
+            7 => array(
432 432
                 'country' => 'SCOTLAND',
433 433
                 'assembly' => 'scotland',
434 434
                 'location' => '&ndash; in the Scottish Parliament'
435 435
             ),
436
-            8 => array (
436
+            8 => array(
437 437
                 'country' => 'SCOTLAND',
438 438
                 'assembly' => 'scotland',
439 439
                 'location' => '&ndash; Scottish Parliament written question &ndash; answered'
440 440
             ),
441
-            101 => array (
441
+            101 => array(
442 442
                 'country' => 'UK',
443 443
                 'assembly' => 'uk-lords',
444 444
                 'location' => '&ndash; in the House of Lords'
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
         global $DATA, $this_page;
454 454
         $this_page = $this->page_base . 'front';
455 455
         $data = array();
456
-        if ( $this->index_template ) {
456
+        if ($this->index_template) {
457 457
             $data['template'] = $this->index_template;
458 458
         }
459 459
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 
464 464
         $content['calendar'] = $class->display('calendar', array('months' => 1), 'none');
465 465
 
466
-        if ( $rssurl = $DATA->page_metadata($this_page, 'rss') ) {
466
+        if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
467 467
             $content['rssurl'] = $rssurl;
468 468
         }
469 469
 
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
     }
479 479
 
480 480
     //$totalcomments, $comment, $commenturl
481
-    function generate_commentteaser ($row) {
481
+    function generate_commentteaser($row) {
482 482
         // Returns HTML for the one fragment of comment and link for the sidebar.
483 483
         // $totalcomments is the number of comments this item has on it.
484 484
         // $comment is an array like:
Please login to merge, or discard this patch.
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -27,18 +27,22 @@  discard block
 block discarded – undo
27 27
             $data['year'] = $year;
28 28
             $data['template'] = 'section/year';
29 29
             $data = $this->addCommonData($data);
30
-        } elseif (($date = get_http_var('d')) && ($column = get_http_var('c'))) {
30
+        }
31
+        elseif (($date = get_http_var('d')) && ($column = get_http_var('c'))) {
31 32
             $data = $this->display_column($date, $column);
32 33
             $data = $this->addCommonData($data);
33
-        } elseif ($date = get_http_var('d')) {
34
+        }
35
+        elseif ($date = get_http_var('d')) {
34 36
             $data = $this->display_day($date);
35 37
             if ( !isset($data['template']) ) {
36 38
                 $data['template'] = 'section/day';
37 39
             }
38 40
             $data = $this->addCommonData($data);
39
-        } elseif (get_http_var('id')) {
41
+        }
42
+        elseif (get_http_var('id')) {
40 43
             $data = $this->display_section_or_speech();
41
-        } else {
44
+        }
45
+        else {
42 46
             $data = $this->display_front();
43 47
             if ( !isset($data['template']) ) {
44 48
                 $data['template'] = 'section/recent';
@@ -117,9 +121,11 @@  discard block
 block discarded – undo
117 121
         $recess_major = 1; # For all of UK Parliament
118 122
         if ($hansardmajors[$this->major]['location'] == 'NI') {
119 123
             $recess_major = 5;
120
-        } elseif ($hansardmajors[$this->major]['location'] == 'Scotland') {
124
+        }
125
+        elseif ($hansardmajors[$this->major]['location'] == 'Scotland') {
121 126
             $recess_major = 4; # For all of Scotland
122
-        } elseif ($this->major == 101) {
127
+        }
128
+        elseif ($this->major == 101) {
123 129
             $recess_major = 101; # Lords slightly different
124 130
         }
125 131
 
@@ -199,7 +205,8 @@  discard block
 block discarded – undo
199 205
                 # Magically (as in I can't remember quite why), pbc_clause will
200 206
                 # contain the new URL without any change...
201 207
                 $URL->remove( array('id') );
202
-            } else {
208
+            }
209
+            else {
203 210
                 $URL->insert( array('id'=>$e->getMessage()) );
204 211
             }
205 212
             # put the search term back in so highlighting works.
@@ -260,13 +267,15 @@  discard block
 block discarded – undo
260 267
     private function setTitleAndAlertText($data, $subsection_title) {
261 268
         if ($subsection_title) {
262 269
             $data['heading'] = $subsection_title;
263
-        } else {
270
+        }
271
+        else {
264 272
             $data['heading'] = $data['section_title'];
265 273
         }
266 274
 
267 275
         if ($subsection_title) {
268 276
             $data['intro'] = "$data[section_title]";
269
-        } else {
277
+        }
278
+        else {
270 279
             $data['intro'] = "";
271 280
         }
272 281
 
@@ -275,14 +284,17 @@  discard block
 block discarded – undo
275 284
             // almost certainly not what the person wants
276 285
             if ( $this->major == 6 ) {
277 286
                 $data['email_alert_text'] = $data['section_title'];
278
-            } else {
287
+            }
288
+            else {
279 289
                 $data['email_alert_text'] = $data['info']['text_heading'];
280 290
             }
281
-        } else {
291
+        }
292
+        else {
282 293
             // The user has requested only part of a debate, so find a suitable title
283 294
             if ($subsection_title) {
284 295
                 $data['intro'] = "Part of $data[section_title]";
285
-            } else {
296
+            }
297
+            else {
286 298
                 $data['intro'] = "Part of the debate";
287 299
             }
288 300
             foreach ($data['rows'] as $row) {
@@ -360,10 +372,12 @@  discard block
 block discarded – undo
360 372
             if ($htype == 10) {
361 373
                 $data['section_title'] = $row['body'];
362 374
                 $heading_hpos = $row['hpos'];
363
-            } elseif ($htype == 11) {
375
+            }
376
+            elseif ($htype == 11) {
364 377
                 $subsection_title = $row['body'];
365 378
                 $heading_hpos = $row['hpos'];
366
-            } elseif ($htype == 12) {
379
+            }
380
+            elseif ($htype == 12) {
367 381
                 # Splitting out highlighting results back into individual bits
368 382
                 $data['rows'][$i]['body'] = $bodies[$i];
369 383
             }
@@ -397,7 +411,8 @@  discard block
 block discarded – undo
397 411
                         ucfirst($data['rows'][$i]['speaker']['name']),
398 412
                         $data['section_title']
399 413
                     );
400
-                } else {
414
+                }
415
+                else {
401 416
                     $data['rows'][$i]['socialteaser'] = sprintf(
402 417
                         '%s on TheyWorkForYou',
403 418
                         $data['section_title']
@@ -533,14 +548,16 @@  discard block
 block discarded – undo
533 548
                 $linktext = "Read $morecount more $plural";
534 549
             }
535 550
 
536
-        } else {
551
+        }
552
+        else {
537 553
             // This comment needs trimming.
538 554
             $commentbody = trim_characters($comment['body'], 0, $targetsize, 1000);
539 555
             if ($row['totalcomments'] > 1) {
540 556
                 $morecount = $row['totalcomments'] - 1;
541 557
                 $plural = $morecount == 1 ? 'annotation' : 'annotations';
542 558
                 $linktext = "Continue reading (and $morecount more $plural)";
543
-            } else {
559
+            }
560
+            else {
544 561
                 $linktext = 'Continue reading';
545 562
             }
546 563
         }
Please login to merge, or discard this patch.
tests/PartyTest.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -118,6 +118,9 @@
 block discarded – undo
118 118
         $this->assertEquals($expected, $position);
119 119
     }
120 120
 
121
+    /**
122
+     * @param string $method
123
+     */
121 124
     private function getAllPositions($method, $party = 'A Party') {
122 125
         $party = new MySociety\TheyWorkForYou\Party($party);
123 126
         $policies = new MySociety\TheyWorkForYou\Policies();
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function getDataSet()
13 13
     {
14
-        return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/party.xml');
14
+        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/party.xml');
15 15
     }
16 16
 
17 17
     private function fetch_page($vars)
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
         $party = new MySociety\TheyWorkForYou\Party('A Party');
24 24
 
25 25
         $this->assertNotNull($party);
26
-        $this->assertEquals( 'A Party', $party->name );
26
+        $this->assertEquals('A Party', $party->name);
27 27
     }
28 28
 
29 29
     public function testCountMembers() {
30 30
         $party = new MySociety\TheyWorkForYou\Party('A Party');
31
-        $this->assertEquals( $party->getCurrentMemberCount(HOUSE_TYPE_COMMONS), 2 );
31
+        $this->assertEquals($party->getCurrentMemberCount(HOUSE_TYPE_COMMONS), 2);
32 32
     }
33 33
 
34 34
     public function testGetPolicyPositions() {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $this->assertEquals($expectedResults, $positions);
116 116
 
117 117
         $party = new MySociety\TheyWorkForYou\Party('Labour/Co-operative');
118
-        $party->cache_position( $positions['810'] );
118
+        $party->cache_position($positions['810']);
119 119
 
120 120
         $position = $party->policy_position(810);
121 121
         $expected = ('voted a mixture of for and against');
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
     public function testMPPartyPolicyTextWhenDiffers()
135 135
     {
136
-        $page = $this->fetch_page( array( 'pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency' ) );
136
+        $page = $this->fetch_page(array('pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency'));
137 137
         $this->assertContains('Test Current-MP', $page);
138 138
         $this->assertContains('is a A Party MP', $page);
139 139
         $this->assertContains('sometimes <b>differs</b> from their party', $page);
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
 
142 142
     public function testSingleMemberPartyPolicyText()
143 143
     {
144
-        $page = $this->fetch_page( array( 'pid' => 7, 'url' => '/mp/7/test_second-party-mp/test_westminster_constituency' ) );
144
+        $page = $this->fetch_page(array('pid' => 7, 'url' => '/mp/7/test_second-party-mp/test_westminster_constituency'));
145 145
         $this->assertContains('Test Second-Party-MP', $page);
146 146
         $this->assertNotContains('is a A Second Party MP', $page);
147 147
     }
148 148
 
149 149
     public function testMPPartyPolicyWherePartyMissingPositions()
150 150
     {
151
-        $page = $this->fetch_page( array( 'pid' => 3, 'url' => '/mp/3/test_current-mp/test_westminster_constituency' ) );
151
+        $page = $this->fetch_page(array('pid' => 3, 'url' => '/mp/3/test_current-mp/test_westminster_constituency'));
152 152
         $this->assertContains('Test Current-MP', $page);
153 153
         $this->assertContains('is a A Party MP', $page);
154 154
         $this->assertNotContains('while most A Party MPs voted', $page);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
     public function testMPPartyPolicyTextWhenAgrees()
158 158
     {
159
-        $page = $this->fetch_page( array( 'pid' => 6, 'url' => '/mp/6/test_further-mp/test_westminster_constituency' ) );
159
+        $page = $this->fetch_page(array('pid' => 6, 'url' => '/mp/6/test_further-mp/test_westminster_constituency'));
160 160
         $this->assertContains('Test Further-MP', $page);
161 161
         $this->assertContains('This is a selection of Miss Test Further-MP&rsquo;s votes', $page);
162 162
     }
Please login to merge, or discard this patch.
www/docs/admin/report.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -146,6 +146,9 @@
 block discarded – undo
146 146
 
147 147
 
148 148
 
149
+/**
150
+ * @param string $template
151
+ */
149 152
 function get_template_contents($template) {
150 153
     // Fetches the contents of an email template so we can then
151 154
     // display it on the screen.
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 // where rid is a report_id and cid is a comment_id.
7 7
 
8 8
 include_once '../../includes/easyparliament/init.php';
9
-include_once (INCLUDESPATH."easyparliament/commentreport.php");
9
+include_once (INCLUDESPATH . "easyparliament/commentreport.php");
10 10
 
11 11
 $this_page = "admin_commentreport";
12 12
 
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
     global $this_page;
178 178
 
179 179
 #	$commentermail = preg_replace("/\n/", "<br>\n", get_template_contents('comment_deleted') );
180
-    $commentermail = preg_replace('/^Subject:.*\n/', '', get_template_contents('comment_deleted') );
181
-    $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_upheld') );
180
+    $commentermail = preg_replace('/^Subject:.*\n/', '', get_template_contents('comment_deleted'));
181
+    $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_upheld'));
182 182
 
183 183
     ?>
184 184
         <p><strong>You've chosen to delete this comment.</strong> You can now send an email to both the person who posted the comment, and the person who made the report. Uncheck a box to prevent an email from being sent. The comment will not be deleted until you click the button below.</p>
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
     global $this_page;
213 213
 
214
-    $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_declined') );
214
+    $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_declined'));
215 215
 
216 216
     ?>
217 217
         <p><strong>You have chosen not to delete this comment.</strong> You can now send an email to the person who made the report (uncheck the box to send no email). The report will not be resolved until you click the button below.</p>
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         $upheld = false;
244 244
     }
245 245
 
246
-    $success = $REPORT->resolve ($upheld, $COMMENT);
246
+    $success = $REPORT->resolve($upheld, $COMMENT);
247 247
 
248 248
     if ($success) {
249 249
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                 // The reporting user was logged in at the time,
262 262
                 // so get their email address.
263 263
                 $USER = new USER;
264
-                $USER->init( $REPORT->user_id() );
264
+                $USER->init($REPORT->user_id());
265 265
                 $email = $USER->email();
266 266
             } else {
267 267
                 // Non-logged-in user; they should have left their address.
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
             }
270 270
 
271 271
             // Prepare the data needed for either email.
272
-            $data = array (
272
+            $data = array(
273 273
                 'to' 			=> $email
274 274
             );
275
-            $merge = array (
275
+            $merge = array(
276 276
                 'FIRSTNAME' 	=> $REPORT->firstname(),
277 277
                 'LASTNAME' 		=> $REPORT->lastname(),
278 278
                 'REPORTBODY' 	=> strip_tags($REPORT->body())
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
             // Remove the anchor for their now deleted comment.
309 309
             $addcommentsurl = 'https://' . DOMAIN . preg_replace("/#.*$/", '#addcomment', $COMMENT->url());
310 310
 
311
-            $data = array (
311
+            $data = array(
312 312
                 'to' => $USER->email(),
313 313
                 'template' => 'comment_deleted_blank',
314 314
                 'subject' => 'One of your comments has been deleted',
315 315
             );
316
-            $merge = array (
316
+            $merge = array(
317 317
                 'REPLYBODY' => get_http_var('commentermail'),
318 318
                 'FIRSTNAME' 	=> $USER->firstname(),
319 319
                 'LASTNAME' 	=> $USER->lastname(),
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -62,7 +62,8 @@  discard block
 block discarded – undo
62 62
     $PAGE->page_end();
63 63
     exit;
64 64
 
65
-} elseif ($THEUSER->is_able_to('deletecomment')) {
65
+}
66
+elseif ($THEUSER->is_able_to('deletecomment')) {
66 67
 
67 68
     // Prevent anyone else from editing this report.
68 69
     $REPORT->lock();
@@ -81,7 +82,8 @@  discard block
 block discarded – undo
81 82
     resolve($REPORT, $COMMENT);
82 83
 
83 84
 
84
-} elseif (get_http_var('takingaction') == 'true') {
85
+}
86
+elseif (get_http_var('takingaction') == 'true') {
85 87
 
86 88
     // The user has chosen to delete or not delete the comment.
87 89
     // So we need to let them prepare the appropriate emails.
@@ -94,11 +96,13 @@  discard block
 block discarded – undo
94 96
     if (get_http_var('yes') != '') {
95 97
         prepare_emails_for_deleting($REPORT, $COMMENT, $FORMURL);
96 98
 
97
-    } else {
99
+    }
100
+    else {
98 101
         prepare_emails_for_not_deleting($REPORT, $COMMENT, $FORMURL);
99 102
     }
100 103
 
101
-} else {
104
+}
105
+else {
102 106
 
103 107
 
104 108
     // The user is viewing a comment and its report.
@@ -239,7 +243,8 @@  discard block
 block discarded – undo
239 243
 
240 244
     if (get_http_var('deletecomment') == 'true') {
241 245
         $upheld = true;
242
-    } else {
246
+    }
247
+    else {
243 248
         $upheld = false;
244 249
     }
245 250
 
@@ -263,7 +268,8 @@  discard block
 block discarded – undo
263 268
                 $USER = new USER;
264 269
                 $USER->init( $REPORT->user_id() );
265 270
                 $email = $USER->email();
266
-            } else {
271
+            }
272
+            else {
267 273
                 // Non-logged-in user; they should have left their address.
268 274
                 $email = $REPORT->email();
269 275
             }
@@ -282,7 +288,8 @@  discard block
 block discarded – undo
282 288
             if ($upheld == true) {
283 289
                 $data['template'] = 'report_upheld';
284 290
 
285
-            } else {
291
+            }
292
+            else {
286 293
                 $data['template'] = 'report_declined';
287 294
                 $merge['COMMENTURL'] = 'https://' . DOMAIN . $COMMENT->url();
288 295
                 $merge['REASON'] = get_http_var('declinedreason');
@@ -293,7 +300,8 @@  discard block
 block discarded – undo
293 300
 
294 301
             if ($success) {
295 302
                 print "<p>An email has been sent to the person who made the report.</p>\n";
296
-            } else {
303
+            }
304
+            else {
297 305
                 $PAGE->error_message("Failed when sending an email to the person who made the report.");
298 306
             }
299 307
 
@@ -327,7 +335,8 @@  discard block
 block discarded – undo
327 335
 
328 336
             if ($success) {
329 337
                 print "<p>An email has been sent to the person who posted the comment.</p>\n";
330
-            } else {
338
+            }
339
+            else {
331 340
                 $PAGE->error_message("Failed when sending an email to the person who posted the comment.");
332 341
             }
333 342
         }
Please login to merge, or discard this patch.
www/docs/api/api_functions.php 5 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -197,6 +197,9 @@  discard block
 block discarded – undo
197 197
 
198 198
 # Output functions
199 199
 
200
+/**
201
+ * @param integer $last_mod
202
+ */
200 203
 function api_output($arr, $last_mod=null) {
201 204
     $output = get_http_var('output');
202 205
     if (!get_http_var('docs')) {
@@ -325,6 +328,11 @@  discard block
 block discarded – undo
325 328
 
326 329
 # Call an API function
327 330
 
331
+/**
332
+ * @param string $function
333
+ * @param string $error
334
+ * @param string $type
335
+ */
328 336
 function api_call_user_func_or_error($function, $params, $error, $type) {
329 337
     if (function_exists($function))
330 338
         call_user_func_array($function, $params);
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 }
147 147
 
148 148
 function api_is_superuser_key($key) {
149
-  $db = new ParlDB;
150
-  $q = $db->query('SELECT api_key.user_id, users.status
149
+    $db = new ParlDB;
150
+    $q = $db->query('SELECT api_key.user_id, users.status
151 151
                FROM   api_key, users
152 152
                WHERE  users.user_id = api_key.user_id
153 153
                AND    api_key.api_key = :key', array(
154 154
                 ':key' => $key
155 155
                 ));
156
-  if (!$q->rows())
156
+    if (!$q->rows())
157 157
     return false;
158
-  if ($q->field(0, 'status') == 'Superuser')
158
+    if ($q->field(0, 'status') == 'Superuser')
159 159
     return true;
160
-  else
160
+    else
161 161
     return false;
162 162
 }
163 163
 
@@ -335,12 +335,12 @@  discard block
 block discarded – undo
335 335
     // we only want to convert to iso if it's an actual API call
336 336
     // so skip this if it's a documentation page
337 337
     if (!get_http_var('docs')) {
338
-      // and then catch any errors in the conversion and just ignore
339
-      // them and return the unconverted results
340
-      $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
341
-      if ($converted_out !== FALSE) {
338
+        // and then catch any errors in the conversion and just ignore
339
+        // them and return the unconverted results
340
+        $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
341
+        if ($converted_out !== FALSE) {
342 342
         $out = $converted_out;
343
-      }
343
+        }
344 344
     }
345 345
 
346 346
     return $out;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -338,7 +338,7 @@
 block discarded – undo
338 338
       // and then catch any errors in the conversion and just ignore
339 339
       // them and return the unconverted results
340 340
       $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
341
-      if ($converted_out !== FALSE) {
341
+      if ($converted_out !== false) {
342 342
         $out = $converted_out;
343 343
       }
344 344
     }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 # Key-related functions
133 133
 
134 134
 function api_log_call($key) {
135
-    if ($key=='DOCS') return;
135
+    if ($key == 'DOCS') return;
136 136
     $ip = $_SERVER['REMOTE_ADDR'];
137 137
     $query = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
138 138
     $query = preg_replace('#key=[A-Za-z0-9]+&?#', '', $query);
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 
198 198
 # Output functions
199 199
 
200
-function api_output($arr, $last_mod=null) {
200
+function api_output($arr, $last_mod = null) {
201 201
     $output = get_http_var('output');
202 202
     if (!get_http_var('docs')) {
203 203
         $cond = api_header($output, $last_mod);
204 204
         if ($cond) return;
205 205
     }
206 206
     if ($output == 'xml') {
207
-        $out = '<?xml version="1.0" encoding="utf-8"?>'."\n";
207
+        $out = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
208 208
         $out .= '<twfy>' . api_output_xml($arr) . '</twfy>';
209 209
     } elseif ($output == 'php') {
210 210
         $out = api_output_php($arr);
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     print $out;
223 223
 }
224 224
 
225
-function api_header($o, $last_mod=null) {
225
+function api_header($o, $last_mod = null) {
226 226
     if ($last_mod && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
227 227
         $t = cond_parse_http_date($_SERVER['HTTP_IF_MODIFIED_SINCE']);
228 228
         if (isset($t) && $t >= $last_mod) {
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
     }
249 249
     #$type = 'text/plain';
250 250
     header("Content-Type: $type; charset=$charset");
251
-    if ($last_mod>0)
251
+    if ($last_mod > 0)
252 252
         header('Last-Modified: ' . date('r', $last_mod));
253 253
     return false;
254 254
 }
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 }
272 272
 
273 273
 $api_xml_arr = 0;
274
-function api_output_xml($v, $k=null) {
274
+function api_output_xml($v, $k = null) {
275 275
     global $api_xml_arr;
276 276
     $verbose = get_http_var('verbose') ? "\n" : '';
277 277
     if (is_array($v)) {
278
-        if (count($v) && array_keys($v) === range(0, count($v)-1)) {
278
+        if (count($v) && array_keys($v) === range(0, count($v) - 1)) {
279 279
             $elt = 'match';
280 280
             $api_xml_arr++;
281 281
             $out = "<$elt>";
@@ -296,36 +296,36 @@  discard block
 block discarded – undo
296 296
     }
297 297
 }
298 298
 
299
-function api_output_js($v, $level=0) {
299
+function api_output_js($v, $level = 0) {
300 300
     $verbose = get_http_var('verbose') ? "\n" : '';
301 301
     $out = '';
302 302
     if (is_array($v)) {
303 303
         # PHP arrays are both JS arrays and objects
304
-        if (count($v) && array_keys($v) === range(0, count($v)-1)) {
305
-            $out = '[' . join(",$verbose" , array_map('api_output_js', $v)) . ']';
304
+        if (count($v) && array_keys($v) === range(0, count($v) - 1)) {
305
+            $out = '[' . join(",$verbose", array_map('api_output_js', $v)) . ']';
306 306
         } else {
307 307
             $out = '{' . $verbose;
308 308
             $b = false;
309 309
             foreach ($v as $k => $vv) {
310 310
                 if ($b) $out .= ",$verbose";
311 311
                 if ($verbose) {
312
-                    $out .= str_repeat(' ', ($level+1)*2);
312
+                    $out .= str_repeat(' ', ($level + 1) * 2);
313 313
                     $out .= '"' . $k . '" : ';
314 314
                 } else {
315 315
                     $out .= '"' . $k . '":';
316 316
                 }
317
-                $out .= api_output_js($vv, $level+1);
317
+                $out .= api_output_js($vv, $level + 1);
318 318
                 $b = true;
319 319
             }
320
-            if ($verbose) $out .= "\n" . str_repeat(' ', $level*2);
320
+            if ($verbose) $out .= "\n" . str_repeat(' ', $level * 2);
321 321
             $out .= '}';
322 322
         }
323 323
     } elseif (is_null($v)) {
324 324
         $out = "null";
325 325
     } elseif (is_string($v)) {
326 326
         $out = '"' . str_replace(
327
-            array("\\",'"',"\n","\t","\r", "‶", "″", "“", "”"),
328
-            array("\\\\",'\"','\n','\t','\r', '\"', '\"', '\"', '\"'), $v) . '"';
327
+            array("\\", '"', "\n", "\t", "\r", "‶", "″", "“", "”"),
328
+            array("\\\\", '\"', '\n', '\t', '\r', '\"', '\"', '\"', '\"'), $v) . '"';
329 329
     } elseif (is_bool($v)) {
330 330
         $out = $v ? 'true' : 'false';
331 331
     } elseif (is_int($v) || is_float($v)) {
Please login to merge, or discard this patch.
Braces   +86 added lines, -45 removed lines patch added patch discarded remove patch
@@ -132,7 +132,9 @@  discard block
 block discarded – undo
132 132
 # Key-related functions
133 133
 
134 134
 function api_log_call($key) {
135
-    if ($key=='DOCS') return;
135
+    if ($key=='DOCS') {
136
+        return;
137
+    }
136 138
     $ip = $_SERVER['REMOTE_ADDR'];
137 139
     $query = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
138 140
     $query = preg_replace('#key=[A-Za-z0-9]+&?#', '', $query);
@@ -153,23 +155,28 @@  discard block
 block discarded – undo
153 155
                AND    api_key.api_key = :key', array(
154 156
                 ':key' => $key
155 157
                 ));
156
-  if (!$q->rows())
157
-    return false;
158
-  if ($q->field(0, 'status') == 'Superuser')
159
-    return true;
160
-  else
161
-    return false;
162
-}
158
+  if (!$q->rows()) {
159
+      return false;
160
+  }
161
+  if ($q->field(0, 'status') == 'Superuser') {
162
+      return true;
163
+  }
164
+  else {
165
+      return false;
166
+  }
167
+  }
163 168
 
164 169
 function api_check_key($key) {
165 170
     $db = new ParlDB;
166 171
     $q = $db->query('SELECT user_id, disabled FROM api_key WHERE api_key = :key', array(
167 172
         ':key' => $key
168 173
         ));
169
-    if (!$q->rows())
170
-        return false;
171
-    if ($q->field(0, 'disabled'))
172
-        return 'disabled';
174
+    if (!$q->rows()) {
175
+            return false;
176
+    }
177
+    if ($q->field(0, 'disabled')) {
178
+            return 'disabled';
179
+    }
173 180
     return true;
174 181
 }
175 182
 
@@ -201,18 +208,25 @@  discard block
 block discarded – undo
201 208
     $output = get_http_var('output');
202 209
     if (!get_http_var('docs')) {
203 210
         $cond = api_header($output, $last_mod);
204
-        if ($cond) return;
211
+        if ($cond) {
212
+            return;
213
+        }
205 214
     }
206 215
     if ($output == 'xml') {
207 216
         $out = '<?xml version="1.0" encoding="utf-8"?>'."\n";
208 217
         $out .= '<twfy>' . api_output_xml($arr) . '</twfy>';
209
-    } elseif ($output == 'php') {
218
+    }
219
+    elseif ($output == 'php') {
210 220
         $out = api_output_php($arr);
211
-    } elseif ($output == 'rabx') {
221
+    }
222
+    elseif ($output == 'rabx') {
212 223
         $out = api_output_rabx($arr);
213
-    } elseif ($output == 'json') {
224
+    }
225
+    elseif ($output == 'json') {
214 226
         $out = json_encode($arr, JSON_PRETTY_PRINT);
215
-    } else { # JS
227
+    }
228
+    else {
229
+# JS
216 230
         $out = api_output_js($arr);
217 231
         $callback = get_http_var('callback');
218 232
         if (preg_match('#^[A-Za-z0-9._[\]]+$#', $callback)) {
@@ -234,22 +248,27 @@  discard block
 block discarded – undo
234 248
     $charset = 'utf-8';
235 249
     if ($o == 'xml') {
236 250
         $type = 'text/xml';
237
-    } elseif ($o == 'php') {
251
+    }
252
+    elseif ($o == 'php') {
238 253
         $type = 'text/php';
239
-    } elseif ($o == 'rabx') {
254
+    }
255
+    elseif ($o == 'rabx') {
240 256
         $type = 'application/octet-stream';
241
-    } elseif ($o == 'json') {
257
+    }
258
+    elseif ($o == 'json') {
242 259
         header('Access-Control-Allow-Origin: *');
243 260
         $type = 'application/json';
244
-    } else {
261
+    }
262
+    else {
245 263
         header('Access-Control-Allow-Origin: *');
246 264
         $charset = 'iso-8859-1';
247 265
         $type = 'text/javascript';
248 266
     }
249 267
     #$type = 'text/plain';
250 268
     header("Content-Type: $type; charset=$charset");
251
-    if ($last_mod>0)
252
-        header('Last-Modified: ' . date('r', $last_mod));
269
+    if ($last_mod>0) {
270
+            header('Last-Modified: ' . date('r', $last_mod));
271
+    }
253 272
     return false;
254 273
 }
255 274
 
@@ -259,14 +278,18 @@  discard block
 block discarded – undo
259 278
 
260 279
 function api_output_php($arr) {
261 280
     $out = serialize($arr);
262
-    if (get_http_var('verbose')) $out = str_replace(';', ";\n", $out);
281
+    if (get_http_var('verbose')) {
282
+        $out = str_replace(';', ";\n", $out);
283
+    }
263 284
     return $out;
264 285
 }
265 286
 
266 287
 function api_output_rabx($arr) {
267 288
     $out = '';
268 289
     rabx_wire_wr($arr, $out);
269
-    if (get_http_var('verbose')) $out = str_replace(',', ",\n", $out);
290
+    if (get_http_var('verbose')) {
291
+        $out = str_replace(',', ",\n", $out);
292
+    }
270 293
     return $out;
271 294
 }
272 295
 
@@ -291,7 +314,8 @@  discard block
 block discarded – undo
291 314
             $out .= $verbose;
292 315
         }
293 316
         return $out;
294
-    } else {
317
+    }
318
+    else {
295 319
         return _htmlspecialchars($v);
296 320
     }
297 321
 }
@@ -303,32 +327,42 @@  discard block
 block discarded – undo
303 327
         # PHP arrays are both JS arrays and objects
304 328
         if (count($v) && array_keys($v) === range(0, count($v)-1)) {
305 329
             $out = '[' . join(",$verbose" , array_map('api_output_js', $v)) . ']';
306
-        } else {
330
+        }
331
+        else {
307 332
             $out = '{' . $verbose;
308 333
             $b = false;
309 334
             foreach ($v as $k => $vv) {
310
-                if ($b) $out .= ",$verbose";
335
+                if ($b) {
336
+                    $out .= ",$verbose";
337
+                }
311 338
                 if ($verbose) {
312 339
                     $out .= str_repeat(' ', ($level+1)*2);
313 340
                     $out .= '"' . $k . '" : ';
314
-                } else {
341
+                }
342
+                else {
315 343
                     $out .= '"' . $k . '":';
316 344
                 }
317 345
                 $out .= api_output_js($vv, $level+1);
318 346
                 $b = true;
319 347
             }
320
-            if ($verbose) $out .= "\n" . str_repeat(' ', $level*2);
348
+            if ($verbose) {
349
+                $out .= "\n" . str_repeat(' ', $level*2);
350
+            }
321 351
             $out .= '}';
322 352
         }
323
-    } elseif (is_null($v)) {
353
+    }
354
+    elseif (is_null($v)) {
324 355
         $out = "null";
325
-    } elseif (is_string($v)) {
356
+    }
357
+    elseif (is_string($v)) {
326 358
         $out = '"' . str_replace(
327 359
             array("\\",'"',"\n","\t","\r", "‶", "″", "“", "”"),
328 360
             array("\\\\",'\"','\n','\t','\r', '\"', '\"', '\"', '\"'), $v) . '"';
329
-    } elseif (is_bool($v)) {
361
+    }
362
+    elseif (is_bool($v)) {
330 363
         $out = $v ? 'true' : 'false';
331
-    } elseif (is_int($v) || is_float($v)) {
364
+    }
365
+    elseif (is_int($v) || is_float($v)) {
332 366
         $out = $v;
333 367
     }
334 368
 
@@ -349,13 +383,16 @@  discard block
 block discarded – undo
349 383
 # Call an API function
350 384
 
351 385
 function api_call_user_func_or_error($function, $params, $error, $type) {
352
-    if (function_exists($function))
353
-        call_user_func_array($function, $params);
354
-    elseif ($type == 'api')
355
-        api_error($error);
356
-    else
357
-        print "<p style='color:#cc0000'>$error</p>";
358
-}
386
+    if (function_exists($function)) {
387
+            call_user_func_array($function, $params);
388
+    }
389
+    elseif ($type == 'api') {
390
+            api_error($error);
391
+    }
392
+    else {
393
+            print "<p style='color:#cc0000'>$error</p>";
394
+    }
395
+    }
359 396
 
360 397
 # Used for testing for conditional responses
361 398
 
@@ -389,7 +426,8 @@  discard block
 block discarded – undo
389 426
         $H = $ma[5];
390 427
         $M = $ma[6];
391 428
         $S = $ma[7];
392
-    } elseif (preg_match("/^$cond_weekday_re, $cond_date2_re $cond_time_re GMT\$/", $date, $ma)) {
429
+    }
430
+    elseif (preg_match("/^$cond_weekday_re, $cond_date2_re $cond_time_re GMT\$/", $date, $ma)) {
393 431
         /* RFC 850 */
394 432
         $d = $ma[2];
395 433
         $m = $cond_month_map[$ma[3]];
@@ -397,7 +435,8 @@  discard block
 block discarded – undo
397 435
         $H = $ma[5];
398 436
         $M = $ma[6];
399 437
         $S = $ma[7];
400
-    } elseif (preg_match("/^$cond_wkday_re $cond_date3_re $cond_time_re (\\d{4})\$/", $date, $ma)) {
438
+    }
439
+    elseif (preg_match("/^$cond_wkday_re $cond_date3_re $cond_time_re (\\d{4})\$/", $date, $ma)) {
401 440
         /* asctime(3) */
402 441
         $d = preg_replace('/ /', '', $ma[3]);
403 442
         $m = $cond_month_map[$ma[2]];
@@ -405,8 +444,10 @@  discard block
 block discarded – undo
405 444
         $H = $ma[4];
406 445
         $M = $ma[5];
407 446
         $S = $ma[6];
408
-    } else
409
-        return null;
447
+    }
448
+    else {
449
+            return null;
450
+    }
410 451
 
411 452
     return gmmktime($H, $M, $S, $m, $d, $Y);
412 453
 }
Please login to merge, or discard this patch.
www/docs/api/api_getConstituencies.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -143,6 +143,10 @@
 block discarded – undo
143 143
  * Given two angles A1 and A2 on a circle expressed in radians, return the
144 144
  * smallest angle between them.
145 145
  */
146
+/**
147
+ * @param double $a1
148
+ * @param double $a2
149
+ */
146 150
 function _api_angle_between($a1, $a2) {
147 151
     if (abs($a1 - $a2) > M_PI) return 2*M_PI - abs($a1 - $a2);
148 152
     return abs($a1 - $a2);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
         and c_main.main_name and constituency.name like :constituency_name and constituency.from_date <= date(now())
42 42
         and date(now()) <= constituency.to_date
43 43
         order by name', array(
44
-        ':constituency_name' => '%' . $s .'%'
44
+        ':constituency_name' => '%' . $s . '%'
45 45
         ));
46 46
     $output = array();
47 47
     $done = array();
48
-    for ($i=0; $i<$q->rows(); $i++) {
48
+    for ($i = 0; $i < $q->rows(); $i++) {
49 49
         $name = $q->field($i, 'name');
50 50
         if (!in_array($name, $done)) {
51 51
             $output[] = array(
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
 function api_getConstituencies($date = 'now()') {
71 71
     $db = new ParlDB;
72 72
     $q = $db->query('select cons_id, name from constituency
73
-        where main_name and from_date <= date('.$date.') and date('.$date.') <= to_date
73
+        where main_name and from_date <= date('.$date . ') and date(' . $date . ') <= to_date
74 74
         order by name');
75 75
     $output = array();
76
-    for ($i=0; $i<$q->rows(); $i++) {
76
+    for ($i = 0; $i < $q->rows(); $i++) {
77 77
         $output[] = array(
78 78
             # 'id' => $q->field($i, 'cons_id'),
79 79
             'name' => $q->field($i, 'name')
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
  * smallest angle between them.
145 145
  */
146 146
 function _api_angle_between($a1, $a2) {
147
-    if (abs($a1 - $a2) > M_PI) return 2*M_PI - abs($a1 - $a2);
147
+    if (abs($a1 - $a2) > M_PI) return 2 * M_PI - abs($a1 - $a2);
148 148
     return abs($a1 - $a2);
149 149
 }
150 150
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,7 +62,8 @@  discard block
 block discarded – undo
62 62
 function api_getConstituencies_date($date) {
63 63
     if ($date = parse_date($date)) {
64 64
         api_getConstituencies('"' . $date['iso'] . '"');
65
-    } else {
65
+    }
66
+    else {
66 67
         api_error('Invalid date format');
67 68
     }
68 69
 }
@@ -108,7 +109,9 @@  discard block
 block discarded – undo
108 109
     $geometry = _api_getGeometry();
109 110
     $out = array();
110 111
     foreach ($geometry['data'] as $name => $data) {
111
-        if (!isset($data['centre_lat']) || !isset($data['centre_lon'])) continue;
112
+        if (!isset($data['centre_lat']) || !isset($data['centre_lon'])) {
113
+            continue;
114
+        }
112 115
         $distance = R_e * acos(
113 116
             sin(deg2rad($lat)) * sin(deg2rad($data['centre_lat']))
114 117
             + cos(deg2rad($lat)) * cos(deg2rad($data['centre_lat']))
@@ -144,7 +147,9 @@  discard block
 block discarded – undo
144 147
  * smallest angle between them.
145 148
  */
146 149
 function _api_angle_between($a1, $a2) {
147
-    if (abs($a1 - $a2) > M_PI) return 2*M_PI - abs($a1 - $a2);
150
+    if (abs($a1 - $a2) > M_PI) {
151
+        return 2*M_PI - abs($a1 - $a2);
152
+    }
148 153
     return abs($a1 - $a2);
149 154
 }
150 155
 
Please login to merge, or discard this patch.
www/docs/api/api_getHansard.php 3 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -36,11 +36,17 @@  discard block
 block discarded – undo
36 36
     ));
37 37
 }
38 38
 
39
+/**
40
+ * @param string $type
41
+ */
39 42
 function _api_getHansard_date($type, $d) {
40 43
     $args = array ('date' => $d);
41 44
     $LIST = _api_getListObject($type);
42 45
     $LIST->display('date', $args, 'api');
43 46
 }
47
+/**
48
+ * @param string $type
49
+ */
44 50
 function _api_getHansard_year($type, $y) {
45 51
     $args = array('year' => $y);
46 52
     $LIST = _api_getListObject($type);
@@ -98,6 +104,9 @@  discard block
 block discarded – undo
98 104
     $LIST->display('search', $args, 'api');
99 105
 }
100 106
 
107
+/**
108
+ * @param string $type
109
+ */
101 110
 function _api_getHansard_gid($type, $gid) {
102 111
     $args = array('gid' => $gid);
103 112
     $LIST = _api_getListObject($type);
@@ -112,6 +121,9 @@  discard block
 block discarded – undo
112 121
     }
113 122
 }
114 123
 
124
+/**
125
+ * @param string $type
126
+ */
115 127
 function _api_getHansard_department($type, $dept) {
116 128
     $args = array('department' => $dept);
117 129
     $LIST = _api_getListObject($type);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@
 block discarded – undo
66 66
     if ($o == 'p') {
67 67
         $data = \MySociety\TheyWorkForYou\Utility\Search::searchByUsage($search);
68 68
         $out = array();
69
-        if (!isset($data['speakers'])) $data['speakers'] = array();
69
+        if (!isset($data['speakers'])) {
70
+            $data['speakers'] = array();
71
+        }
70 72
         foreach ($data['speakers'] as $pid => $s) {
71 73
             $out[$pid] = array(
72 74
                 'house' => $s['house'],
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once INCLUDESPATH."easyparliament/member.php";
3
+include_once INCLUDESPATH . "easyparliament/member.php";
4 4
 
5 5
 function api_getHansard_front() {
6 6
 ?>
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 }
30 30
 
31 31
 function api_getHansard_search($s) {
32
-    _api_getHansard_search( array(
32
+    _api_getHansard_search(array(
33 33
         's' => $s,
34 34
         'pid' => get_http_var('person')
35
-    ) );
35
+    ));
36 36
 }
37 37
 function api_getHansard_person($pid) {
38 38
     _api_getHansard_search(array(
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 }
42 42
 
43 43
 function _api_getHansard_date($type, $d) {
44
-    $args = array ('date' => $d);
44
+    $args = array('date' => $d);
45 45
     $LIST = _api_getListObject($type);
46 46
     $LIST->display('date', $args, 'api');
47 47
 }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     $type = isset($array['type']) ? $array['type'] : '';
57 57
     $search = filter_user_input($search, 'strict');
58 58
     if ($pid) {
59
-        $search .= ($search?' ':'') . 'speaker:' . $pid;
59
+        $search .= ($search ? ' ' : '') . 'speaker:' . $pid;
60 60
     }
61 61
     if ($type) {
62 62
         $search .= " section:" . $type;
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
     }
92 92
 #    $query_desc_short = $SEARCHENGINE->query_description_short();
93 93
     $pagenum = get_http_var('page');
94
-    $args = array (
94
+    $args = array(
95 95
         's' => $search,
96 96
         'p' => $pagenum,
97 97
         'num' => get_http_var('num'),
98 98
         'pop' => 1,
99
-        'o' => ($o=='d' || $o=='r') ? $o : 'd',
99
+        'o' => ($o == 'd' || $o == 'r') ? $o : 'd',
100 100
     );
101 101
     $LIST = new HANSARDLIST();
102 102
     $LIST->display('search', $args, 'api');
Please login to merge, or discard this patch.