Passed
Push — master ( ad0ec6...39c00e )
by Matthew
06:23 queued 02:14
created
www/docs/regmem/index.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $file = _load_file($_);
68 68
         $date = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $_);
69 69
         $data[$_] = array();
70
-        if (preg_match('#<regmem personid="uk.org.publicwhip/person/'.$p.'" (?:memberid="(.*?)" )?membername="(.*?)" date="(.*?)">(.*?)</regmem>#s', $file, $m)) {
70
+        if (preg_match('#<regmem personid="uk.org.publicwhip/person/' . $p . '" (?:memberid="(.*?)" )?membername="(.*?)" date="(.*?)">(.*?)</regmem>#s', $file, $m)) {
71 71
             $earliest = $_;
72 72
             if (!$name) {
73 73
                 $name = $m[2];
@@ -103,21 +103,21 @@  discard block
 block discarded – undo
103 103
             break;
104 104
         }
105 105
         $date_pre = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $_);
106
-        $date_post = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $files[$i+1]);
106
+        $date_post = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $files[$i + 1]);
107 107
         $pretty = format_date($date_pre, LONGDATEFORMAT);
108 108
         $oout = '';
109 109
         foreach ($data[$_] as $cat_type => $cat_data) {
110
-            $old = array_key_exists($cat_type, $data[$files[$i+1]]) ? $data[$files[$i+1]][$cat_type] : '';
110
+            $old = array_key_exists($cat_type, $data[$files[$i + 1]]) ? $data[$files[$i + 1]][$cat_type] : '';
111 111
             $new = $data[$_][$cat_type];
112 112
             if ($diff = clean_diff($old, $new)) {
113 113
                 $oout .= cat_heading($cat_type, $date_pre, $date_post) . $diff;
114 114
             }
115 115
         }
116
-        foreach ($data[$files[$i+1]] as $cat_type => $cat_data) {
116
+        foreach ($data[$files[$i + 1]] as $cat_type => $cat_data) {
117 117
             if (array_key_exists($cat_type, $data[$_])) {
118 118
                 continue;
119 119
             }
120
-            if ($diff = clean_diff($data[$files[$i+1]][$cat_type], '')) {
120
+            if ($diff = clean_diff($data[$files[$i + 1]][$cat_type], '')) {
121 121
                 $oout .= cat_heading($cat_type, $date_pre, $date_post) . $diff;
122 122
             }
123 123
         }
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
     if ($f) {
150 150
         $f = "$dir/regmem$f.xml";
151 151
         $count = count($files);
152
-        for ($i=0; $i<$count; ++$i) {
152
+        for ($i = 0; $i < $count; ++$i) {
153 153
             if ($files[$i] == $f) {
154 154
                 $new = $i;
155 155
                 break;
156 156
             }
157 157
         }
158 158
     }
159
-    $old = $new+1;
159
+    $old = $new + 1;
160 160
     $old = $files[$old];
161 161
     $old_iso = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $old);
162 162
     $old_pretty = format_date($old_iso, LONGDATEFORMAT);
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     $old = _load_file($old);
167 167
     $new = _load_file($new);
168 168
 
169
-    $DATA->set_page_metadata($this_page, 'heading', 'Changes from '.$old_pretty.' to '.$new_pretty);
169
+    $DATA->set_page_metadata($this_page, 'heading', 'Changes from ' . $old_pretty . ' to ' . $new_pretty);
170 170
     $PAGE->stripe_start();
171 171
     print $link;
172 172
     $data = array();
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             $out .= clean_diff($old, $new);
189 189
         }
190 190
         if ($out) {
191
-            print span_row('<h2>'.$names[$person_id].' - <a href="?p='.$person_id.'">Register history</a> | <a href="/mp/?pid='.$person_id.'">MP&rsquo;s page</a></h2>', true) . $out;
191
+            print span_row('<h2>' . $names[$person_id] . ' - <a href="?p=' . $person_id . '">Register history</a> | <a href="/mp/?pid=' . $person_id . '">MP&rsquo;s page</a></h2>', true) . $out;
192 192
         }
193 193
     }
194 194
     print '</table>';
@@ -245,28 +245,28 @@  discard block
 block discarded – undo
245 245
     $c = 0; $year = 0;
246 246
     $view = ''; $compare = '';
247 247
     $count = count($files);
248
-    for ($i=0; $i<$count; ++$i) {
248
+    for ($i = 0; $i < $count; ++$i) {
249 249
         preg_match('/(\d\d\d\d)-(\d\d-\d\d)/', $files[$i], $m);
250 250
         $y = $m[1]; $md = $m[2];
251 251
         if ($c++) {
252 252
             $view .= ' | ';
253
-            if ($i < $count-1) {
253
+            if ($i < $count - 1) {
254 254
                 $compare .= ' | ';
255 255
             }
256 256
         }
257 257
         if ($year != $y) {
258 258
             $year = $y;
259 259
             $view .= "<em>$year</em> ";
260
-            if ($i < $count-1) {
260
+            if ($i < $count - 1) {
261 261
                 $compare .= "<em>$year</em> ";
262 262
             }
263 263
         }
264 264
         $months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
265 265
         preg_match('/(\d\d)-(\d\d)/', $md, $m);
266
-        $date = ($m[2]+0) . ' '. $months[$m[1]-1];
267
-        $view .= '<a href="./?d='.$y.'-'.$md.'">'.$date.'</a>';
268
-        if ($i < $count-1) {
269
-            $compare .= '<a href="?f='.$y.'-'.$md.'">'.$date.'</a>';
266
+        $date = ($m[2] + 0) . ' ' . $months[$m[1] - 1];
267
+        $view .= '<a href="./?d=' . $y . '-' . $md . '">' . $date . '</a>';
268
+        if ($i < $count - 1) {
269
+            $compare .= '<a href="?f=' . $y . '-' . $md . '">' . $date . '</a>';
270 270
         }
271 271
     }
272 272
 ?>
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 <?php
283 283
     uasort($names, 'by_name');
284 284
     foreach ($names as $_ => $value) {
285
-        print '<li><a href="?p='.$_.'">'.$value.'</a>';
285
+        print '<li><a href="?p=' . $_ . '">' . $value . '</a>';
286 286
     }
287 287
     print '</ul>';
288 288
 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     $data = array();
301 301
     parse_file($d, $d_iso, 'only', $data);
302 302
     $this_page = 'regmem_date';
303
-    $DATA->set_page_metadata($this_page, 'heading', "The Register of Members' Interests, $d_pretty");;
303
+    $DATA->set_page_metadata($this_page, 'heading', "The Register of Members' Interests, $d_pretty"); ;
304 304
     $PAGE->stripe_start();
305 305
     print $link;
306 306
 ?>
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         foreach ($v as $cat_type => $vv) {
315 315
             $out .= cat_heading($cat_type, $d_iso, $d_iso, false);
316 316
             $d = (array_key_exists('only', $data[$person_id][$cat_type]) ? $data[$person_id][$cat_type]['only'] : '');
317
-            $out .= prettify($d)."\n";
317
+            $out .= prettify($d) . "\n";
318 318
         }
319 319
         if ($out) {
320 320
             print '<div class="block">';
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
     if (!count($r) && !count($a)) {
365 365
         return '';
366 366
     }
367
-    $r = join("\n", $r); $r = $r ? '<td class="r"><ul>'.$r.'</ul></td>' : '<td>&nbsp;</td>';
368
-    $a = join("\n", $a); $a = $a ? '<td class="a"><ul>'.$a.'</ul></td>' : '<td>&nbsp;</td>';
367
+    $r = join("\n", $r); $r = $r ? '<td class="r"><ul>' . $r . '</ul></td>' : '<td>&nbsp;</td>';
368
+    $a = join("\n", $a); $a = $a ? '<td class="a"><ul>' . $a . '</ul></td>' : '<td>&nbsp;</td>';
369 369
     $diff = '<tr>' . $r . $a . '</tr>';
370 370
     $diff = preg_replace('#<item.*?>(.*?)</item>#', '<li>$1</li>', $diff);
371 371
     return $diff;
Please login to merge, or discard this patch.
www/docs/admin/report.php 1 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
                 'REPORTBODY' 	=> strip_tags($REPORT->body())
277 277
             );
278 278
 
@@ -306,12 +306,12 @@  discard block
 block discarded – undo
306 306
             // Remove the anchor for their now deleted comment.
307 307
             $addcommentsurl = 'https://' . DOMAIN . preg_replace("/#.*$/", '#addcomment', $COMMENT->url());
308 308
 
309
-            $data = array (
309
+            $data = array(
310 310
                 'to' => $USER->email(),
311 311
                 'template' => 'comment_deleted_blank',
312 312
                 'subject' => 'One of your comments has been deleted',
313 313
             );
314
-            $merge = array (
314
+            $merge = array(
315 315
                 'REPLYBODY' => get_http_var('commentermail'),
316 316
 #				'DELETEDREASON'	=> get_http_var('deletedreason'),
317 317
                 'ADDCOMMENTURL'	=> $addcommentsurl,
Please login to merge, or discard this patch.
www/includes/easyparliament/commentreport.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
     public $firstname = '';
28 28
     public $lastname = '';
29 29
     public $body = '';
30
-    public $reported = null;	// datetime
31
-    public $resolved = null; 	// datetime
32
-    public $resolvedby = ''; 	// user_id
33
-    public $locked = null; 	// datetime
34
-    public $lockedby = '';		// user_id
35
-    public $upheld = ''; 		// boolean
30
+    public $reported = null; // datetime
31
+    public $resolved = null; // datetime
32
+    public $resolvedby = ''; // user_id
33
+    public $locked = null; // datetime
34
+    public $lockedby = ''; // user_id
35
+    public $upheld = ''; // boolean
36 36
 
37 37
     // If the user was logged in, this will be set:
38 38
     public $user_id = '';
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public $email = '';
41 41
 
42 42
 
43
-    public function __construct($report_id='') {
43
+    public function __construct($report_id = '') {
44 44
         // Pass it a report id and it gets and sets this report's data.
45 45
 
46 46
         $this->db = new ParlDB;
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         global $THEUSER, $PAGE;
162 162
 
163 163
         if (!$THEUSER->is_able_to('reportcomment')) {
164
-            $PAGE->error_message ("Sorry, you are not allowed to post reports.");
164
+            $PAGE->error_message("Sorry, you are not allowed to post reports.");
165 165
             return false;
166 166
         }
167 167
 
@@ -229,19 +229,19 @@  discard block
 block discarded – undo
229 229
 
230 230
         if ($q->success()) {
231 231
             // Inserted OK, so set up this object's variables.
232
-            $this->report_id 	= $q->insert_id();
233
-            $this->comment_id 	= $COMMENT->comment_id();
234
-            $this->body			= $body;
235
-            $this->reported		= $time;
232
+            $this->report_id = $q->insert_id();
233
+            $this->comment_id = $COMMENT->comment_id();
234
+            $this->body = $body;
235
+            $this->reported = $time;
236 236
 
237 237
             if ($THEUSER->isloggedin()) {
238
-                $this->user_id		= $THEUSER->user_id();
238
+                $this->user_id = $THEUSER->user_id();
239 239
                 $this->firstname	= $THEUSER->firstname();
240 240
                 $this->lastname		= $THEUSER->lastname();
241 241
             } else {
242
-                $this->email		= $reportdata['email'];
243
-                $this->firstname 	= $reportdata['firstname'];
244
-                $this->lastname		= $reportdata['lastname'];
242
+                $this->email = $reportdata['email'];
243
+                $this->firstname = $reportdata['firstname'];
244
+                $this->lastname = $reportdata['lastname'];
245 245
             }
246 246
 
247 247
 
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
                 $email = $this->email();
274 274
             }
275 275
 
276
-            $data = array (
276
+            $data = array(
277 277
                 'to' 			=> $email,
278 278
                 'template' 		=> 'report_acknowledge'
279 279
             );
280
-            $merge = array (
280
+            $merge = array(
281 281
                 'COMMENTURL' 	=> "https://" . DOMAIN . $COMMENT->url(),
282 282
                 'REPORTBODY' 	=> strip_tags($this->body())
283 283
             );
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         $data = array();
300 300
 
301 301
         if (is_numeric($this->report_id)) {
302
-            $data = array (
302
+            $data = array(
303 303
                 'report_id' 	=> $this->report_id(),
304 304
                 'comment_id' 	=> $this->comment_id(),
305 305
                 'user_id' 		=> $this->user_id(),
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         if ($THEUSER->is_able_to('deletecomment')) {
337 337
             $time = gmdate("Y-m-d H:i:s");
338 338
 
339
-            $q = $this->db->query ("UPDATE commentreports
339
+            $q = $this->db->query("UPDATE commentreports
340 340
                             SET		locked = '$time',
341 341
                                     lockedby = '" . $THEUSER->user_id() . "'
342 342
                             WHERE	report_id = '" . $this->report_id . "'
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
                 $this->lockedby = $THEUSER->user_id();
348 348
                 return true;
349 349
             } else {
350
-                $PAGE->error_message ("Sorry, we were unable to lock this report.");
350
+                $PAGE->error_message("Sorry, we were unable to lock this report.");
351 351
                 return false;
352 352
             }
353 353
         } else {
354
-            $PAGE->error_message ("You are not authorised to delete annotations.");
354
+            $PAGE->error_message("You are not authorised to delete annotations.");
355 355
             return false;
356 356
         }
357 357
     }
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
     public function unlock() {
361 361
         // Unlock a comment so it can be examined by someone else.
362 362
 
363
-        $q = $this->db->query ("UPDATE commentreports
363
+        $q = $this->db->query("UPDATE commentreports
364 364
                         SET		locked = NULL,
365 365
                                 lockedby = NULL
366 366
                         WHERE	report_id = '" . $this->report_id . "'
@@ -434,16 +434,16 @@  discard block
 block discarded – undo
434 434
 
435 435
                     return true;
436 436
                 } else {
437
-                    $PAGE->error_message ("Sorry, we couldn't resolve this report.");
437
+                    $PAGE->error_message("Sorry, we couldn't resolve this report.");
438 438
                     return false;
439 439
                 }
440 440
             } else {
441
-                $PAGE->error_message ("This report has already been resolved (on " . $this->resolved . ")");
441
+                $PAGE->error_message("This report has already been resolved (on " . $this->resolved . ")");
442 442
                 return false;
443 443
             }
444 444
 
445 445
         } else {
446
-            $PAGE->error_message ("You are not authorised to resolve reports.");
446
+            $PAGE->error_message("You are not authorised to resolve reports.");
447 447
             return false;
448 448
         }
449 449
     }
Please login to merge, or discard this patch.
www/docs/section.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@
 block discarded – undo
26 26
 if (isset($THEUSER) && $THEUSER->postcode_is_set()) {
27 27
     try {
28 28
         $MEMBER = new MySociety\TheyWorkForYou\Member(array('postcode' => $THEUSER->postcode(), 'house' => \MySociety\TheyWorkForYou\Utility\House::majorToHouse($view->major)[0]));
29
-    } catch ( MySociety\TheyWorkForYou\MemberException $e ) {
29
+    } catch (MySociety\TheyWorkForYou\MemberException $e) {
30 30
         $MEMBER = null;
31 31
     }
32 32
 }
33 33
 
34 34
 $data = $view->display();
35 35
 if ($data) {
36
-    if ( !empty($data['template']) ) {
36
+    if (!empty($data['template'])) {
37 37
         $template = $data['template'];
38 38
     } else {
39 39
         $template = 'section/section';
Please login to merge, or discard this patch.
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
 $type = ucfirst(get_http_var('type'));
16
-$class_name = "MySociety\TheyWorkForYou\SectionView\\${type}View";
16
+$class_name = "MySociety\TheyWorkForYou\SectionView\\${type}view";
17 17
 if (!$type || !class_exists($class_name)) {
18 18
     $PAGE->error_message("No type specified", true);
19 19
     exit;
Please login to merge, or discard this patch.
www/docs/rss/index.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 include_once '../../includes/easyparliament/init.php';
4
-include_once INCLUDESPATH."easyparliament/member.php";
4
+include_once INCLUDESPATH . "easyparliament/member.php";
5 5
 
6 6
 $pc = get_http_var('pc');
7 7
 $pc = preg_replace('#[^a-z0-9]#i', '', $pc);
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
             $errors['pc'] = "Sorry, we couldn't check your postcode right now. Please use the 'All Mps' link above to browse MPs";
16 16
     } elseif ($constituency == "") {
17 17
         $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a known postcode";
18
-        twfy_debug ('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
18
+        twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
19 19
     } else {
20 20
         $MEMBER = new MEMBER(array('constituency' => $constituency));
21 21
         if ($MEMBER->person_id()) {
@@ -29,5 +29,5 @@  discard block
 block discarded – undo
29 29
     }
30 30
 } else {
31 31
     $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a valid postcode";
32
-    twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
32
+    twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
33 33
 }
Please login to merge, or discard this patch.
www/includes/utility.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
     # Ignore errors we've asked to ignore
70 70
     if (error_reporting()==0) return;
71 71
 
72
-   // define an assoc array of error string
73
-   // in reality the only entries we should
74
-   // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
75
-   // E_USER_WARNING and E_USER_NOTICE
76
-   # Commented out are ones that a user function cannot handle.
72
+    // define an assoc array of error string
73
+    // in reality the only entries we should
74
+    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
75
+    // E_USER_WARNING and E_USER_NOTICE
76
+    # Commented out are ones that a user function cannot handle.
77 77
     $errortype = array (
78 78
         #E_ERROR            => "Error",
79 79
         E_WARNING           => "Warning",
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php
203 203
 function adodb_backtrace($print=true)
204 204
 {
205
-  $s = '';
206
-  if (PHPVERSION() >= 4.3) {
205
+    $s = '';
206
+    if (PHPVERSION() >= 4.3) {
207 207
 
208 208
     $MAXSTRLEN = 64;
209 209
 
@@ -211,33 +211,33 @@  discard block
 block discarded – undo
211 211
     array_shift($traceArr);
212 212
     $tabs = sizeof($traceArr)-1;
213 213
     foreach ($traceArr as $arr) {
214
-      for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; ';
215
-      $tabs -= 1;
216
-      if (isset($arr['class'])) $s .= $arr['class'].'.';
217
-      $args = array();
218
-      if (isset($arr['args'])) foreach ($arr['args'] as $v) {
214
+        for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; ';
215
+        $tabs -= 1;
216
+        if (isset($arr['class'])) $s .= $arr['class'].'.';
217
+        $args = array();
218
+        if (isset($arr['args'])) foreach ($arr['args'] as $v) {
219 219
     if (is_null($v)) $args[] = 'null';
220 220
     elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']';
221 221
     elseif (is_object($v)) $args[] = 'Object:'.get_class($v);
222 222
     elseif (is_bool($v)) $args[] = $v ? 'true' : 'false';
223 223
     else {
224
-      $v = (string) @$v;
225
-      $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN));
226
-      if (strlen($v) > $MAXSTRLEN) $str .= '...';
227
-      $args[] = $str;
224
+        $v = (string) @$v;
225
+        $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN));
226
+        if (strlen($v) > $MAXSTRLEN) $str .= '...';
227
+        $args[] = $str;
228 228
     }
229
-      }
229
+        }
230 230
 
231
-      $s .= $arr['function'].'('.implode(', ',$args).')';
232
-      //      $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,".
233
-      //            " file: <a href=\"file:/%s\">%s</a></font>",
234
-      //        $arr['line'],$arr['file'],$arr['file']);
235
-      $s .= "\n";
231
+        $s .= $arr['function'].'('.implode(', ',$args).')';
232
+        //      $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,".
233
+        //            " file: <a href=\"file:/%s\">%s</a></font>",
234
+        //        $arr['line'],$arr['file'],$arr['file']);
235
+        $s .= "\n";
236 236
     }
237 237
     if ($print) print $s;
238
-  }
238
+    }
239 239
 
240
-  return $s;
240
+    return $s;
241 241
 }
242 242
 
243 243
 // Returns the unixtime in microseconds.
@@ -538,14 +538,14 @@  discard block
 block discarded – undo
538 538
     //$tbl["»"] = "&raquo;";
539 539
     //$tbl["«"] = "&laquo;";
540 540
 
541
-  // lib_filter will replace unmatched < and > with entities so
542
-  // we abuse strtr's only replace once behaviour to not double
543
-  // encode them. May not be robust.
544
-  // This does mean if anyone actually wants to put &gt; or &lt;
545
-  // in a comment they can't but that's a lot less likely than
546
-  // < or > for less than and greater than.
547
-  $tbl['&lt;'] = "&lt;";
548
-  $tbl['&gt;'] = "&gt;";
541
+    // lib_filter will replace unmatched < and > with entities so
542
+    // we abuse strtr's only replace once behaviour to not double
543
+    // encode them. May not be robust.
544
+    // This does mean if anyone actually wants to put &gt; or &lt;
545
+    // in a comment they can't but that's a lot less likely than
546
+    // < or > for less than and greater than.
547
+    $tbl['&lt;'] = "&lt;";
548
+    $tbl['&gt;'] = "&gt;";
549 549
 
550 550
     // Don't want to encode these things
551 551
     unset ($tbl["<"]);
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 
1064 1064
     $return = '<h4>';
1065 1065
     if (isset($daytext[$major])) {
1066
-     $return .= $daytext[$major] . ' ';
1066
+        $return .= $daytext[$major] . ' ';
1067 1067
     }
1068 1068
 
1069 1069
     $return .= '<a href="';
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 # Pass it a brief header word and some debug text and it'll be output.
14 14
 # If TEXT is an array, call the user function, assuming it's a class.
15
-function twfy_debug($header, $text="") {
15
+function twfy_debug($header, $text = "") {
16 16
 
17 17
     // We set ?DEBUGTAG=n in the URL.
18 18
     // (DEBUGTAG is set in config.php).
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
     if ($debug_level != '') {
30 30
 
31 31
         // Set which level shows which types of debug info.
32
-        $levels = array (
33
-            1 => array ('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'),
34
-            2 => array ('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'),
35
-            3 => array ('SQLRESULT')
32
+        $levels = array(
33
+            1 => array('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'),
34
+            2 => array('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'),
35
+            3 => array('SQLRESULT')
36 36
             // Higher than this: 'DATA', etc.
37 37
         );
38 38
 
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
         }
47 47
 
48 48
         for ($n = 1; $n <= $max_level_to_show; $n++) {
49
-            $allowed_headers = array_merge ($allowed_headers, $levels[$n] );
49
+            $allowed_headers = array_merge($allowed_headers, $levels[$n]);
50 50
         }
51 51
 
52 52
         // If we can show this header, then, er, show it.
53
-        if ( in_array($header, $allowed_headers) || $debug_level >= 4) {
53
+        if (in_array($header, $allowed_headers) || $debug_level >= 4) {
54 54
             if (is_array($text)) $text = call_user_func($text);
55 55
             print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n";
56 56
         }
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
     global $PAGE;
68 68
 
69 69
     # Ignore errors we've asked to ignore
70
-    if (error_reporting()==0) return;
70
+    if (error_reporting() == 0) return;
71 71
 
72 72
    // define an assoc array of error string
73 73
    // in reality the only entries we should
74 74
    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
75 75
    // E_USER_WARNING and E_USER_NOTICE
76 76
    # Commented out are ones that a user function cannot handle.
77
-    $errortype = array (
77
+    $errortype = array(
78 78
         #E_ERROR            => "Error",
79 79
         E_WARNING           => "Warning",
80 80
         #E_PARSE            => "Parsing Error",
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
         $source = file($filename);
134 134
         $err .= "\nSource:\n\n";
135 135
         // Show the line, plus prev and next, with line numbers.
136
-        $err .= $linenum-2 . " " . $source[$linenum-3];
137
-        $err .= $linenum-1 . " " . $source[$linenum-2];
138
-        $err .= $linenum . " " . $source[$linenum-1];
139
-        $err .= $linenum+1 . " " . $source[$linenum];
140
-        $err .= $linenum+2 . " " . $source[$linenum+1];
136
+        $err .= $linenum - 2 . " " . $source[$linenum - 3];
137
+        $err .= $linenum - 1 . " " . $source[$linenum - 2];
138
+        $err .= $linenum . " " . $source[$linenum - 1];
139
+        $err .= $linenum + 1 . " " . $source[$linenum];
140
+        $err .= $linenum + 2 . " " . $source[$linenum + 1];
141 141
     }
142 142
 
143 143
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
             header('HTTP/1.0 500 Internal Server Error');
182 182
             print "<p>Oops, sorry, an error has occurred!</p>\n";
183 183
         }
184
-        if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect')===false && strpos($errmsg, 'mysql_connect')===false) {
185
-            mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n".  "X-Mailer: PHP/" . phpversion() );
184
+        if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect') === false && strpos($errmsg, 'mysql_connect') === false) {
185
+            mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n" . "X-Mailer: PHP/" . phpversion());
186 186
         }
187 187
     }
188 188
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 }
201 201
 
202 202
 // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php
203
-function adodb_backtrace($print=true)
203
+function adodb_backtrace($print = true)
204 204
 {
205 205
   $s = '';
206 206
   if (PHPVERSION() >= 4.3) {
@@ -209,26 +209,26 @@  discard block
 block discarded – undo
209 209
 
210 210
     $traceArr = debug_backtrace();
211 211
     array_shift($traceArr);
212
-    $tabs = sizeof($traceArr)-1;
212
+    $tabs = sizeof($traceArr) - 1;
213 213
     foreach ($traceArr as $arr) {
214
-      for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; ';
214
+      for ($i = 0; $i < $tabs; $i++) $s .= ' &nbsp; ';
215 215
       $tabs -= 1;
216
-      if (isset($arr['class'])) $s .= $arr['class'].'.';
216
+      if (isset($arr['class'])) $s .= $arr['class'] . '.';
217 217
       $args = array();
218 218
       if (isset($arr['args'])) foreach ($arr['args'] as $v) {
219 219
     if (is_null($v)) $args[] = 'null';
220
-    elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']';
221
-    elseif (is_object($v)) $args[] = 'Object:'.get_class($v);
220
+    elseif (is_array($v)) $args[] = 'Array[' . sizeof($v) . ']';
221
+    elseif (is_object($v)) $args[] = 'Object:' . get_class($v);
222 222
     elseif (is_bool($v)) $args[] = $v ? 'true' : 'false';
223 223
     else {
224 224
       $v = (string) @$v;
225
-      $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN));
225
+      $str = _htmlspecialchars(substr($v, 0, $MAXSTRLEN));
226 226
       if (strlen($v) > $MAXSTRLEN) $str .= '...';
227 227
       $args[] = $str;
228 228
     }
229 229
       }
230 230
 
231
-      $s .= $arr['function'].'('.implode(', ',$args).')';
231
+      $s .= $arr['function'] . '(' . implode(', ', $args) . ')';
232 232
       //      $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,".
233 233
       //            " file: <a href=\"file:/%s\">%s</a></font>",
234 234
       //        $arr['line'],$arr['file'],$arr['file']);
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 // Returns the unixtime in microseconds.
244 244
 function getmicrotime() {
245 245
     $mtime = microtime();
246
-    $mtime = explode(" ",$mtime);
246
+    $mtime = explode(" ", $mtime);
247 247
     $mtime = $mtime[1] + $mtime[0];
248 248
 
249 249
     return $mtime;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
     global $timestamp_last, $timestamp_start;
257 257
     $t = getmicrotime();
258 258
     twfy_debug("TIME", sprintf("%f msecs since start; %f msecs since last; %s",
259
-            ($t - $timestamp_start)*1000.0, ($t - $timestamp_last)*1000.0, $label));
259
+            ($t - $timestamp_start) * 1000.0, ($t - $timestamp_last) * 1000.0, $label));
260 260
     $timestamp_last = $t;
261 261
 }
262 262
 
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
         list($string, $year, $month, $day) = $matches;
292 292
         if ($year < 1902) { # gmdate fns only go back to Dec. 1901
293 293
             if ($format == SHORTDATEFORMAT) {
294
-                return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year";
294
+                return ($day + 0) . ' ' . $format_date_months_short[$month + 0] . " $year";
295 295
             } else {
296
-                return ($day+0) . ' ' . $format_date_months[$month+0] . " $year";
296
+                return ($day + 0) . ' ' . $format_date_months[$month + 0] . " $year";
297 297
             }
298 298
         }
299 299
 
@@ -334,16 +334,16 @@  discard block
 block discarded – undo
334 334
     $in_seconds = strtotime($datetime);
335 335
     $now = time();
336 336
 
337
-    $diff   =  $now - $in_seconds;
338
-    $months =  floor($diff/2419200);
337
+    $diff   = $now - $in_seconds;
338
+    $months = floor($diff / 2419200);
339 339
     $diff   -= $months * 2419200;
340
-    $weeks  =  floor($diff/604800);
341
-    $diff   -= $weeks*604800;
342
-    $days   =  floor($diff/86400);
340
+    $weeks  = floor($diff / 604800);
341
+    $diff   -= $weeks * 604800;
342
+    $days   = floor($diff / 86400);
343 343
     $diff   -= $days * 86400;
344
-    $hours  =  floor($diff/3600);
344
+    $hours  = floor($diff / 3600);
345 345
     $diff   -= $hours * 3600;
346
-    $minutes = floor($diff/60);
346
+    $minutes = floor($diff / 60);
347 347
     $diff   -= $minutes * 60;
348 348
     $seconds = $diff;
349 349
 
@@ -357,27 +357,27 @@  discard block
 block discarded – undo
357 357
         $relative_date = '';
358 358
         if ($weeks > 0) {
359 359
             // Weeks and days
360
-            $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':'');
361
-            $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):'';
360
+            $relative_date .= ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '');
361
+            $relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : '';
362 362
         } elseif ($days > 0) {
363 363
             // days and hours
364
-            $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':'');
365
-            $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):'';
364
+            $relative_date .= ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '');
365
+            $relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : '';
366 366
         } elseif ($hours > 0) {
367 367
             // hours and minutes
368
-            $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':'');
369
-            $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):'';
368
+            $relative_date .= ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '');
369
+            $relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : '';
370 370
         } elseif ($minutes > 0) {
371 371
             // minutes only
372
-            $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':'');
372
+            $relative_date .= ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '');
373 373
         } else {
374 374
             // seconds only
375
-            $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':'');
375
+            $relative_date .= ($relative_date ? ', ' : '') . $seconds . ' second' . ($seconds > 1 ? 's' : '');
376 376
         }
377 377
     }
378 378
 
379 379
     // Return relative date and add proper verbiage
380
-    return $relative_date.' ago';
380
+    return $relative_date . ' ago';
381 381
 
382 382
 }
383 383
 
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
         $text = substr($text, $start);
427 427
 
428 428
         // Word boundary.
429
-        if (preg_match ("/.+?\b(.*)/", $text, $matches)) {
429
+        if (preg_match("/.+?\b(.*)/", $text, $matches)) {
430 430
             $text = $matches[1];
431 431
             // Strip spare space at the start.
432
-            $text = preg_replace ("/^\s/", '', $text);
432
+            $text = preg_replace("/^\s/", '', $text);
433 433
         }
434 434
         $text = '...' . $text;
435 435
     }
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
         $text = substr($text, 0, $length - 3);
442 442
 
443 443
         // Word boundary.
444
-        if (preg_match ("/(.*)\s.+/", $text, $matches)) {
444
+        if (preg_match("/(.*)\s.+/", $text, $matches)) {
445 445
             $text = $matches[1];
446 446
             // Strip spare space at the end.
447
-            $text = preg_replace ("/\s$/", '', $text);
447
+            $text = preg_replace("/\s$/", '', $text);
448 448
         }
449 449
         // We don't want to use the HTML entity for an ellipsis (&#8230;), because then
450 450
         // it screws up when we subsequently use htmlentities() to print the returned
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 
477 477
     if ($filter_type == 'strict') {
478 478
         // No tags allowed at all!
479
-        $filter->allowed = array ();
479
+        $filter->allowed = array();
480 480
     } else {
481 481
         // Comment.
482 482
         // Only allowing <a href>, <b>, <strong>, <i> and <em>
483
-        $filter->allowed = array (
483
+        $filter->allowed = array(
484 484
             'a' => array('href'),
485 485
             'strong' => array(),
486 486
             'em' => array(),
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 
594 594
     // $gid will be like 'uk.org.publicwhip/debate/2003-02-28.475.3'.
595 595
 
596
-    $newgid = substr($gid, strrpos($gid, '/')+1 );
596
+    $newgid = substr($gid, strrpos($gid, '/') + 1);
597 597
     return $newgid;
598 598
 }
599 599
 
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
     // will be like 2003-11-20.966.0
605 605
     // This function returns 966.0
606 606
 
607
-    return substr( $gid, (strpos($gid, '.') + 1) );
607
+    return substr($gid, (strpos($gid, '.') + 1));
608 608
 }
609 609
 
610 610
 function preg_replacement_quote($s) {
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
     global $PAGE;
649 649
 
650 650
     if (!isset($data['to']) || $data['to'] == '') {
651
-        $PAGE->error_message ("We need an email address to send to.");
651
+        $PAGE->error_message("We need an email address to send to.");
652 652
         return false;
653 653
     }
654 654
 
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
         if (isset($data['subject'])) {
692 692
             $subject = trim($data['subject']);
693 693
         } else {
694
-            $subject = trim( substr($firstline, 8) );
694
+            $subject = trim(substr($firstline, 8));
695 695
         }
696 696
 
697 697
         // Either way, remove this subject line from the template.
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
     } elseif (isset($data['subject'])) {
701 701
         $subject = $data['subject'];
702 702
     } else {
703
-        $PAGE->error_message ("We don't have a subject line for the email, so it wasn't sent.");
703
+        $PAGE->error_message("We don't have a subject line for the email, so it wasn't sent.");
704 704
         return false;
705 705
     }
706 706
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
     $replace = array();
711 711
 
712 712
     foreach ($merge as $key => $val) {
713
-        $search[] = '/{'.$key.'}/';
713
+        $search[] = '/{' . $key . '}/';
714 714
         $replace[] = preg_replacement_quote($val);
715 715
     }
716 716
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
     }
729 729
 
730 730
     // Send it!
731
-    $success = send_email ($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces, $htmltext);
731
+    $success = send_email($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces, $htmltext);
732 732
 
733 733
     return $success;
734 734
 
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
     return $envelope_sender;
744 744
 }
745 745
 
746
-function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false, $html='') {
746
+function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false, $html = '') {
747 747
     // Use this rather than PHP's mail() direct, so we can make alterations
748 748
     // easily to all the emails we send out from the site.
749 749
     // eg, we might want to add a .sig to everything here...
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 // http://www.iamcal.com/publish/article.php?id=13
790 790
 
791 791
 // Call this with a key name to get a GET or POST variable.
792
-function get_http_var($name, $default='', $allow_array=false) {
792
+function get_http_var($name, $default = '', $allow_array = false) {
793 793
     $val = $default;
794 794
     if (array_key_exists($name, $_POST)) {
795 795
         $val = $_POST[$name];
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 }
805 805
 
806 806
 // Call this with a key name to get a COOKIE variable.
807
-function get_cookie_var($name, $default='') {
807
+function get_cookie_var($name, $default = '') {
808 808
     if (array_key_exists($name, $_COOKIE)) {
809 809
         return $_COOKIE[$name];
810 810
     }
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 // Pass it an array of key names that should not be generated as
816 816
 // hidden form variables. It then outputs hidden form variables
817 817
 // based on the session_vars for this page.
818
-function hidden_form_vars ($omit = array()) {
818
+function hidden_form_vars($omit = array()) {
819 819
     global $DATA, $this_page;
820 820
 
821 821
     $session_vars = $DATA->page_metadata($this_page, "session_vars");
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 }
829 829
 
830 830
 // Deprecated. Use hidden_form_vars, above, instead.
831
-function hidden_vars ($omit = array()) {
831
+function hidden_vars($omit = array()) {
832 832
     global $DATA;
833 833
 
834 834
     foreach ($args as $key => $val) {
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 function entities_to_numbers($string) {
872 872
     $string = str_replace(
873 873
         array('&Ouml;', '&acirc;', '&uacute;', '&aacute;', '&iacute;', '&ocirc;', '&eacute;'),
874
-        array('&#214;', '&#226;',  '&#250;',   '&#225;',   '&#237;',   '&#244;',  '&#233;'  ),
874
+        array('&#214;', '&#226;', '&#250;', '&#225;', '&#237;', '&#244;', '&#233;'),
875 875
         $string
876 876
     );
877 877
     return $string;
@@ -888,9 +888,9 @@  discard block
 block discarded – undo
888 888
         }
889 889
     }
890 890
 
891
-    $s   = array(' ', '&amp;', '&ocirc;',  '&Ouml;',  '&ouml;',   '&acirc;',  '&iacute;', '&aacute;', '&uacute;', '&eacute;', '&oacute;', '&Oacute;');
892
-    $s2  = array(" ", "&",     "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93");
893
-    $r   = array('_', 'and',   'o',        'o',       'o',        'a',        'i',        'a',        'u',        'e',        'o',        'o');
891
+    $s   = array(' ', '&amp;', '&ocirc;', '&Ouml;', '&ouml;', '&acirc;', '&iacute;', '&aacute;', '&uacute;', '&eacute;', '&oacute;', '&Oacute;');
892
+    $s2  = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93");
893
+    $r   = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o');
894 894
     $name = preg_replace('#^the #', '', strtolower($name));
895 895
 
896 896
     $out = '';
@@ -1048,8 +1048,8 @@  discard block
 block discarded – undo
1048 1048
                 }
1049 1049
                 $out .= '<li>' . $body . '<ul>';
1050 1050
             } else {
1051
-                $LISTURL->insert( array( 'id' => $gid ) );
1052
-                $out .= '<li><a href="'.$LISTURL->generate().'">';
1051
+                $LISTURL->insert(array('id' => $gid));
1052
+                $out .= '<li><a href="' . $LISTURL->generate() . '">';
1053 1053
                 $out .= $body . '</a>';
1054 1054
             }
1055 1055
         }
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
     return $return;
1119 1119
 }
1120 1120
 
1121
-function redirect($url, $code=302) {
1121
+function redirect($url, $code = 302) {
1122 1122
     if (defined('TESTING')) {
1123 1123
         print "Location: $url";
1124 1124
     } else {
Please login to merge, or discard this patch.
Braces   +126 added lines, -76 removed lines patch added patch discarded remove patch
@@ -51,7 +51,9 @@  discard block
 block discarded – undo
51 51
 
52 52
         // If we can show this header, then, er, show it.
53 53
         if ( in_array($header, $allowed_headers) || $debug_level >= 4) {
54
-            if (is_array($text)) $text = call_user_func($text);
54
+            if (is_array($text)) {
55
+                $text = call_user_func($text);
56
+            }
55 57
             print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n";
56 58
         }
57 59
     }
@@ -67,7 +69,9 @@  discard block
 block discarded – undo
67 69
     global $PAGE;
68 70
 
69 71
     # Ignore errors we've asked to ignore
70
-    if (error_reporting()==0) return;
72
+    if (error_reporting()==0) {
73
+        return;
74
+    }
71 75
 
72 76
    // define an assoc array of error string
73 77
    // in reality the only entries we should
@@ -211,19 +215,29 @@  discard block
 block discarded – undo
211 215
     array_shift($traceArr);
212 216
     $tabs = sizeof($traceArr)-1;
213 217
     foreach ($traceArr as $arr) {
214
-      for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; ';
218
+      for ($i=0; $i < $tabs; $i++) {
219
+          $s .= ' &nbsp; ';
220
+      }
215 221
       $tabs -= 1;
216
-      if (isset($arr['class'])) $s .= $arr['class'].'.';
222
+      if (isset($arr['class'])) {
223
+          $s .= $arr['class'].'.';
224
+      }
217 225
       $args = array();
218
-      if (isset($arr['args'])) foreach ($arr['args'] as $v) {
226
+      if (isset($arr['args'])) {
227
+          foreach ($arr['args'] as $v) {
219 228
     if (is_null($v)) $args[] = 'null';
220
-    elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']';
221
-    elseif (is_object($v)) $args[] = 'Object:'.get_class($v);
222
-    elseif (is_bool($v)) $args[] = $v ? 'true' : 'false';
223
-    else {
229
+      } elseif (is_array($v)) {
230
+        $args[] = 'Array['.sizeof($v).']';
231
+    } elseif (is_object($v)) {
232
+        $args[] = 'Object:'.get_class($v);
233
+    } elseif (is_bool($v)) {
234
+        $args[] = $v ? 'true' : 'false';
235
+    } else {
224 236
       $v = (string) @$v;
225 237
       $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN));
226
-      if (strlen($v) > $MAXSTRLEN) $str .= '...';
238
+      if (strlen($v) > $MAXSTRLEN) {
239
+          $str .= '...';
240
+      }
227 241
       $args[] = $str;
228 242
     }
229 243
       }
@@ -234,7 +248,9 @@  discard block
 block discarded – undo
234 248
       //        $arr['line'],$arr['file'],$arr['file']);
235 249
       $s .= "\n";
236 250
     }
237
-    if ($print) print $s;
251
+    if ($print) {
252
+        print $s;
253
+    }
238 254
   }
239 255
 
240 256
   return $s;
@@ -289,7 +305,8 @@  discard block
 block discarded – undo
289 305
 
290 306
     if (preg_match("/^(\d\d\d\d)-(\d\d?)-(\d\d?)$/", $date, $matches)) {
291 307
         list($string, $year, $month, $day) = $matches;
292
-        if ($year < 1902) { # gmdate fns only go back to Dec. 1901
308
+        if ($year < 1902) {
309
+# gmdate fns only go back to Dec. 1901
293 310
             if ($format == SHORTDATEFORMAT) {
294 311
                 return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year";
295 312
             } else {
@@ -748,7 +765,9 @@  discard block
 block discarded – undo
748 765
     // easily to all the emails we send out from the site.
749 766
     // eg, we might want to add a .sig to everything here...
750 767
 
751
-    if (!$from) $from = CONTACTEMAIL;
768
+    if (!$from) {
769
+        $from = CONTACTEMAIL;
770
+    }
752 771
 
753 772
     $mail = new PHPMailer(true);
754 773
     $mail->isSMTP();
@@ -843,17 +862,21 @@  discard block
 block discarded – undo
843 862
     $rank = $rank + 0;
844 863
 
845 864
     # 11th, 12th, 13th use "th" not "st", "nd", "rd"
846
-    if (floor(($rank % 100) / 10) == 1)
847
-        return $rank . "th";
865
+    if (floor(($rank % 100) / 10) == 1) {
866
+            return $rank . "th";
867
+    }
848 868
     # 1st
849
-    if ($rank % 10 == 1)
850
-        return $rank . "st";
869
+    if ($rank % 10 == 1) {
870
+            return $rank . "st";
871
+    }
851 872
     # 2nd
852
-    if ($rank % 10 == 2)
853
-        return $rank . "nd";
873
+    if ($rank % 10 == 2) {
874
+            return $rank . "nd";
875
+    }
854 876
     # 3rd
855
-    if ($rank % 10 == 3)
856
-        return $rank . "rd";
877
+    if ($rank % 10 == 3) {
878
+            return $rank . "rd";
879
+    }
857 880
     # Everything else use th
858 881
 
859 882
     return $rank . "th";
@@ -861,8 +884,9 @@  discard block
 block discarded – undo
861 884
 
862 885
 function make_plural($word, $number)
863 886
 {
864
-    if ($number == 1)
865
-        return $word;
887
+    if ($number == 1) {
888
+            return $word;
889
+    }
866 890
     return $word . "s";
867 891
 }
868 892
 
@@ -896,8 +920,7 @@  discard block
 block discarded – undo
896 920
     $out = '';
897 921
 
898 922
     // Insert the Person ID if known.
899
-    if ($pid !== null)
900
-    {
923
+    if ($pid !== null) {
901 924
         $out .= $pid . '/';
902 925
     }
903 926
 
@@ -905,8 +928,7 @@  discard block
 block discarded – undo
905 928
     $out .= urlencode(str_replace($s2, $r, str_replace($s, $r, $name)));
906 929
 
907 930
     // If there is a constituency, inject that too
908
-    if ($const && $house == HOUSE_TYPE_COMMONS)
909
-    {
931
+    if ($const && $house == HOUSE_TYPE_COMMONS) {
910 932
         $out .= '/' . urlencode(str_replace($s2, $r, str_replace($s, $r, strtolower($const))));
911 933
     }
912 934
 
@@ -918,10 +940,16 @@  discard block
 block discarded – undo
918 940
     switch ($house) {
919 941
         case HOUSE_TYPE_LORDS:
920 942
             $s = '';
921
-            if (!$family_name) $s = 'the ';
943
+            if (!$family_name) {
944
+                $s = 'the ';
945
+            }
922 946
             $s .= $title;
923
-            if ($family_name) $s .= ' ' . $family_name;
924
-            if ($lordofname) $s .= ' of ' . $lordofname;
947
+            if ($family_name) {
948
+                $s .= ' ' . $family_name;
949
+            }
950
+            if ($lordofname) {
951
+                $s .= ' of ' . $lordofname;
952
+            }
925 953
             return $s;
926 954
 
927 955
         case HOUSE_TYPE_ROYAL:
@@ -939,14 +967,18 @@  discard block
 block discarded – undo
939 967
 }
940 968
 
941 969
 function by_peer_name($a, $b) {
942
-    if (!$a['family_name'] && !$b['family_name'])
943
-        return strcmp($a['lordofname'], $b['lordofname']);
944
-    if (!$a['family_name'])
945
-        return strcmp($a['lordofname'], $b['family_name']);
946
-    if (!$b['family_name'])
947
-        return strcmp($a['family_name'], $b['lordofname']);
948
-    if (strcmp($a['family_name'], $b['family_name']))
949
-        return strcmp($a['family_name'], $b['family_name']);
970
+    if (!$a['family_name'] && !$b['family_name']) {
971
+            return strcmp($a['lordofname'], $b['lordofname']);
972
+    }
973
+    if (!$a['family_name']) {
974
+            return strcmp($a['lordofname'], $b['family_name']);
975
+    }
976
+    if (!$b['family_name']) {
977
+            return strcmp($a['family_name'], $b['lordofname']);
978
+    }
979
+    if (strcmp($a['family_name'], $b['family_name'])) {
980
+            return strcmp($a['family_name'], $b['family_name']);
981
+    }
950 982
     return strcmp($a['lordofname'], $b['lordofname']);
951 983
 }
952 984
 
@@ -973,12 +1005,17 @@  discard block
 block discarded – undo
973 1005
         'Lords in Waiting (HM Household)' => 'Government Whip',
974 1006
         'Baronesses in Waiting, HM Household' => 'Government Whip',
975 1007
     );
976
-    if ($pos) { # Government post, or Chairman of Select Committee
1008
+    if ($pos) {
1009
+# Government post, or Chairman of Select Committee
977 1010
         $pretty = $pos;
978
-        if ($dept && $dept != 'No Department') $pretty .= ", $dept";
979
-        if (array_key_exists($pretty, $lookup))
980
-            $pretty = $lookup[$pretty];
981
-    } else { # Member of Select Committee
1011
+        if ($dept && $dept != 'No Department') {
1012
+            $pretty .= ", $dept";
1013
+        }
1014
+        if (array_key_exists($pretty, $lookup)) {
1015
+                    $pretty = $lookup[$pretty];
1016
+        }
1017
+    } else {
1018
+# Member of Select Committee
982 1019
         $pretty = "Member, $dept";
983 1020
     }
984 1021
     return $pretty;
@@ -996,13 +1033,16 @@  discard block
 block discarded – undo
996 1033
     }
997 1034
 
998 1035
     // single date?
999
-    if (isset($data['date'])) $one_date = true;
1036
+    if (isset($data['date'])) {
1037
+        $one_date = true;
1038
+    }
1000 1039
 
1001 1040
     // remove empty entries, so they don't produce errors
1002 1041
     foreach (array_keys($hansardmajors) as $major) {
1003 1042
         if (array_key_exists($major, $data)) {
1004
-            if (count($data[$major]) == 0)
1005
-                unset($data[$major]);
1043
+            if (count($data[$major]) == 0) {
1044
+                            unset($data[$major]);
1045
+            }
1006 1046
         }
1007 1047
     }
1008 1048
 
@@ -1011,22 +1051,29 @@  discard block
 block discarded – undo
1011 1051
     if (!$one_date) {
1012 1052
         $todaystime = gmmktime(0, 0, 0, date('m'), date('d'), date('Y'));
1013 1053
         foreach ($data as $major => $array) {
1014
-            if (!in_array('timestamp', $array)) $daytext[$major] = "The most recent ";
1015
-            elseif ($todaystime - $array['timestamp'] == 86400) $daytext[$major] = "Yesterday&rsquo;s";
1016
-            elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp']) . "&rsquo;s";
1017
-            else $daytext[$major] = "The most recent ";
1054
+            if (!in_array('timestamp', $array)) {
1055
+                $daytext[$major] = "The most recent ";
1056
+            } elseif ($todaystime - $array['timestamp'] == 86400) {
1057
+                $daytext[$major] = "Yesterday&rsquo;s";
1058
+            } elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) {
1059
+                $daytext[$major] = gmdate('l', $array['timestamp']) . "&rsquo;s";
1060
+            } else {
1061
+                $daytext[$major] = "The most recent ";
1062
+            }
1018 1063
         }
1019 1064
     }
1020 1065
 
1021 1066
     //build html
1022 1067
     foreach ($printed_majors as $p_major) {
1023
-        if (!array_key_exists($p_major, $data))
1024
-            continue;
1068
+        if (!array_key_exists($p_major, $data)) {
1069
+                    continue;
1070
+        }
1025 1071
 
1026
-        if ($one_date)
1027
-            $date = $data['date'];
1028
-        else
1029
-            $date = $data[$p_major]['hdate'];
1072
+        if ($one_date) {
1073
+                    $date = $data['date'];
1074
+        } else {
1075
+                    $date = $data[$p_major]['hdate'];
1076
+        }
1030 1077
         $q = $db->query('SELECT section_id, body, gid
1031 1078
                 FROM hansard, epobject
1032 1079
                 WHERE hansard.epobject_id = epobject.epobject_id '
@@ -1078,14 +1125,16 @@  discard block
 block discarded – undo
1078 1125
     }
1079 1126
 
1080 1127
     $return .= '<a href="';
1081
-    if (isset($data[$major]['listurl']))
1082
-        $return .= $data[$major]['listurl'];
1083
-    else {
1128
+    if (isset($data[$major]['listurl'])) {
1129
+            $return .= $data[$major]['listurl'];
1130
+    } else {
1084 1131
         $LISTURL->reset();
1085 1132
         $return .= $LISTURL->generate();
1086 1133
     }
1087 1134
     $return .= '">' . $hansardmajors[$major]['title'] . '</a>';
1088
-    if (isset($daytext[$major])) $return;
1135
+    if (isset($daytext[$major])) {
1136
+        $return;
1137
+    }
1089 1138
     $return .= '</h4>';
1090 1139
 
1091 1140
     return $return;
@@ -1093,22 +1142,23 @@  discard block
 block discarded – undo
1093 1142
 
1094 1143
 function score_to_strongly($dmpscore) {
1095 1144
     $dmpdesc = "unknown about";
1096
-    if ($dmpscore > 0.95 && $dmpscore <= 1.0)
1097
-        $dmpdesc = "consistently voted against";
1098
-    elseif ($dmpscore > 0.85)
1099
-        $dmpdesc = "almost always voted against";
1100
-    elseif ($dmpscore > 0.6)
1101
-        $dmpdesc = "generally voted against";
1102
-    elseif ($dmpscore > 0.4)
1103
-        $dmpdesc = "voted a mixture of for and against";
1104
-    elseif ($dmpscore > 0.15)
1105
-        $dmpdesc = "generally voted for";
1106
-    elseif ($dmpscore > 0.05)
1107
-        $dmpdesc = "almost always voted for";
1108
-    elseif ($dmpscore >= 0.0)
1109
-        $dmpdesc = "consistently voted for";
1110
-    elseif ($dmpscore == -1)
1111
-        $dmpdesc = "has never voted in a major vote about";
1145
+    if ($dmpscore > 0.95 && $dmpscore <= 1.0) {
1146
+            $dmpdesc = "consistently voted against";
1147
+    } elseif ($dmpscore > 0.85) {
1148
+            $dmpdesc = "almost always voted against";
1149
+    } elseif ($dmpscore > 0.6) {
1150
+            $dmpdesc = "generally voted against";
1151
+    } elseif ($dmpscore > 0.4) {
1152
+            $dmpdesc = "voted a mixture of for and against";
1153
+    } elseif ($dmpscore > 0.15) {
1154
+            $dmpdesc = "generally voted for";
1155
+    } elseif ($dmpscore > 0.05) {
1156
+            $dmpdesc = "almost always voted for";
1157
+    } elseif ($dmpscore >= 0.0) {
1158
+            $dmpdesc = "consistently voted for";
1159
+    } elseif ($dmpscore == -1) {
1160
+            $dmpdesc = "has never voted in a major vote about";
1161
+    }
1112 1162
     return $dmpdesc;
1113 1163
 }
1114 1164
 
Please login to merge, or discard this patch.
classes/AlertView/Simple.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
     public function display() {
8 8
         $data = array();
9 9
         $data['recent_election'] = false;
10
-        if ( $this->user->loggedin() ) {
10
+        if ($this->user->loggedin()) {
11 11
             $data['user_signed_in'] = true;
12 12
         }
13 13
 
@@ -17,21 +17,21 @@  discard block
 block discarded – undo
17 17
             $data['postcode'] = trim(get_http_var('postcode'));
18 18
 
19 19
             $result = $this->createAlertForPostCode($data['email'], $data['postcode']);
20
-            $data = array_merge( $data, $result );
20
+            $data = array_merge($data, $result);
21 21
         } elseif (get_http_var('update')) {
22 22
             $result = $this->getNewMP(get_http_var('update'));
23
-            $data = array_merge( $data, $result );
23
+            $data = array_merge($data, $result);
24 24
         } elseif (get_http_var('update-alert')) {
25
-            $success = $this->replaceAlert( get_http_var('confirmation') );
25
+            $success = $this->replaceAlert(get_http_var('confirmation'));
26 26
             $data['confirmation_received'] = $success;
27 27
         } elseif (get_http_var('confirmed')) {
28
-            $success = $this->confirmAlert( get_http_var('confirmed') );
28
+            $success = $this->confirmAlert(get_http_var('confirmed'));
29 29
             $data['confirmation_received'] = $success;
30 30
         } else {
31 31
             $data['email'] = $this->user->email() ? $this->user->email() : '';
32 32
             $data['postcode'] = $this->user->postcode_is_set() ? $this->user->postcode() : '';
33 33
 
34
-            if ( $this->isEmailSignedUpForPostCode( $data['email'], $data['postcode'] ) ) {
34
+            if ($this->isEmailSignedUpForPostCode($data['email'], $data['postcode'])) {
35 35
                 $data['already_signed_up'] = true;
36 36
                 $mp = $this->getPersonFromPostcode($data['postcode']);
37 37
                 $data['mp_name'] = $mp->full_name();
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
     }
67 67
 
68 68
     private function createAlertForPostCode($email, $postcode) {
69
-        if ( !$this->validateDetails($email, $postcode) ) {
69
+        if (!$this->validateDetails($email, $postcode)) {
70 70
             return array('invalid-postcode-or-email' => true);
71 71
         }
72 72
 
73 73
         try {
74 74
             $person = $this->getPersonFromPostcode($postcode);
75
-        } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
75
+        } catch (\MySociety\TheyWorkForYou\MemberException $e) {
76 76
             return array('bad-constituency' => true);
77 77
         }
78 78
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         switch ($result) {
91 91
             case self::ALERT_EXISTS:
92
-                if ( $not_logged_in ) {
92
+                if ($not_logged_in) {
93 93
                     // no logged in user so send them an email to let them
94 94
                     // know someone tried to create an alert
95 95
                     $this->alert->send_already_signedup_email($details);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 $data['error'] = true;
103 103
                 break;
104 104
             default: // alert created
105
-                if ( $not_logged_in ) {
105
+                if ($not_logged_in) {
106 106
                     $data['confirmation_sent'] = true;
107 107
                 } else {
108 108
                     $data['signedup_no_confirm'] = true;
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
         $existing = $this->alert->fetch_by_token($confirmation);
117 117
         preg_match('/speaker:(\d+)/', $existing['criteria'], $matches);
118 118
         $old_mp_id = $matches[1];
119
-        $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $old_mp_id ) );
120
-        $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 ));
119
+        $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $old_mp_id));
120
+        $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1));
121 121
 
122 122
         $q = $this->db->query(
123 123
             "SELECT alert_id, criteria, registrationtoken FROM alerts
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                 'pid' => $new_mp->person_id,
142 142
                 'pc' => '',
143 143
             );
144
-            if ( $other_criteria ) {
144
+            if ($other_criteria) {
145 145
                 $details['keyword'] = $other_criteria;
146 146
             }
147 147
 
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
     private function isEmailSignedUpForPostCode($email, $postcode) {
159 159
         $is_signed_up = false;
160 160
 
161
-        if ( $email && $postcode ) {
161
+        if ($email && $postcode) {
162 162
             try {
163 163
                 $person = $this->getPersonFromPostcode($postcode);
164 164
                 $is_signed_up = $this->alert->fetch_by_mp($email, $person->person_id);
165
-            } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
165
+            } catch (\MySociety\TheyWorkForYou\MemberException $e) {
166 166
                 $is_signed_up = false;
167 167
             }
168 168
         }
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
         preg_match('/speaker:(\d+)/', $existing['criteria'], $matches);
179 179
         $criteria = $matches[1];
180 180
 
181
-        $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $criteria ) );
182
-        $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 ));
181
+        $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $criteria));
182
+        $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1));
183 183
 
184
-        if ( $this->alert->fetch_by_mp( $existing['email'], $new_mp->person_id) ) {
184
+        if ($this->alert->fetch_by_mp($existing['email'], $new_mp->person_id)) {
185 185
             $data = array(
186 186
                 'already_signed_up' => true,
187 187
                 'old_mp' => $old_mp->full_name(),
Please login to merge, or discard this patch.
classes/SectionView/DebatesView.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
         $DEBATELIST = new \DEBATELIST;
17 17
         $debates = array();
18 18
         $debates['data'] = $DEBATELIST->display('biggest_debates', array('days'=>7, 'num'=>10), 'none');
19
-        $args = array( 'months' => 1 );
19
+        $args = array('months' => 1);
20 20
         $debates['calendar'] = $DEBATELIST->display('calendar', $args, 'none');
21 21
         $debates['rssurl'] = $DATA->page_metadata($this_page, 'rss');
22 22
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
         $WHALLLIST = new \WHALLLIST;
28 28
         $whall['data'] = $WHALLLIST->display('biggest_debates', array('days'=>7, 'num'=>10), 'none');
29
-        $args = array( 'months' => 1 );
29
+        $args = array('months' => 1);
30 30
         $whall['calendar'] = $WHALLLIST->display('calendar', $args, 'none');
31 31
         $whall['rssurl'] = $DATA->page_metadata($this_page, 'rss');
32 32
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
         $LORDSDEBATELIST = new \LORDSDEBATELIST;
38 38
         $lords['data'] = $LORDSDEBATELIST->display('biggest_debates', array('days'=>7, 'num'=>10), 'none');
39
-        $args = array( 'months' => 1 );
39
+        $args = array('months' => 1);
40 40
         $lords['calendar'] = $LORDSDEBATELIST->display('calendar', $args, 'none');
41 41
 
42 42
         $lords['rssurl'] = $DATA->page_metadata($this_page, 'rss');
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 
56 56
     protected function getSearchSections() {
57 57
         return array(
58
-            array( 'section' => 'debates', 'title' => 'House of Commons' ),
59
-            array( 'section' => 'lords', 'title' => 'House of Lords' ),
60
-            array( 'section' => 'whall', 'title' => 'Westminster Hall' )
58
+            array('section' => 'debates', 'title' => 'House of Commons'),
59
+            array('section' => 'lords', 'title' => 'House of Lords'),
60
+            array('section' => 'whall', 'title' => 'Westminster Hall')
61 61
         );
62 62
     }
63 63
 }
Please login to merge, or discard this patch.
www/includes/easyparliament/hansardlist.php 2 patches
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 
562 562
             // The '!= NULL' bit is needed otherwise I was getting errors
563 563
             // when displaying the first day of debates.
564
-            if ($q && $q['hdate'] != NULL) {
564
+            if ($q && $q['hdate'] != null) {
565 565
 
566 566
                 $URL->insert( array( 'd' => $q['hdate'] ) );
567 567
 
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
                             WHERE	major = :major",
1411 1411
                 array(':major' => $this->major))->first();
1412 1412
 
1413
-            if ($q && $q['hdate'] != NULL) {
1413
+            if ($q && $q['hdate'] != null) {
1414 1414
                 $recentdate = $q['hdate'];
1415 1415
             } else {
1416 1416
                 $PAGE->error_message("Couldn't find the most recent date");
@@ -1725,7 +1725,7 @@  discard block
 block discarded – undo
1725 1725
         }
1726 1726
 
1727 1727
         // Finally, do the query!
1728
-        $q = $this->db->query ("SELECT $fields
1728
+        $q = $this->db->query ("select $fields
1729 1729
                         FROM 	hansard
1730 1730
                         $join
1731 1731
                         WHERE $where
Please login to merge, or discard this patch.
Spacing   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once INCLUDESPATH."easyparliament/searchengine.php";
4
-include_once INCLUDESPATH."easyparliament/searchlog.php";
3
+include_once INCLUDESPATH . "easyparliament/searchengine.php";
4
+include_once INCLUDESPATH . "easyparliament/searchlog.php";
5 5
 
6 6
 /*
7 7
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 class HANSARDLIST {
54 54
     // This will be used to cache information about speakers on this page
55 55
     // so we don't have to keep fetching the same data from the DB.
56
-    public $speakers = array ();
56
+    public $speakers = array();
57 57
     /*
58 58
     $this->speakers[ $person_id ] = array (
59 59
         "name" => $name,
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
     // This will be used to cache mappings from epobject_id to gid,
68 68
     // so we don't have to continually fetch the same data in get_hansard_data().
69
-    public $epobjectid_to_gid = array ();
69
+    public $epobjectid_to_gid = array();
70 70
     /*
71 71
     $this->epobjectid_to_gid[ $epobject_id ] => $gid;
72 72
     */
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
 
116 116
 
117
-    public function display ($view, $args=array(), $format='html') {
117
+    public function display($view, $args = array(), $format = 'html') {
118 118
 
119 119
         // $view is what we're viewing by:
120 120
         // 	'gid' is the gid of a hansard object,
@@ -142,17 +142,17 @@  discard block
 block discarded – undo
142 142
             return false;
143 143
         }
144 144
 
145
-        $validviews = array ('calendar', 'date', 'gid', 'person', 'search', 'recent', 'recent_mostvotes', 'biggest_debates', 'recent_wrans', 'recent_wms', 'column', 'mp', 'bill', 'session', 'recent_debates', 'recent_pbc_debates', 'featured_gid');
145
+        $validviews = array('calendar', 'date', 'gid', 'person', 'search', 'recent', 'recent_mostvotes', 'biggest_debates', 'recent_wrans', 'recent_wms', 'column', 'mp', 'bill', 'session', 'recent_debates', 'recent_pbc_debates', 'featured_gid');
146 146
         if (in_array($view, $validviews)) {
147 147
 
148 148
             // What function do we call for this view?
149
-            $function = '_get_data_by_'.$view;
149
+            $function = '_get_data_by_' . $view;
150 150
             // Get all the data that's to be rendered.
151 151
             $data = $this->$function($args);
152 152
 
153 153
         } else {
154 154
             // Don't have a valid $view.
155
-            $PAGE->error_message ("You haven't specified a view type.");
155
+            $PAGE->error_message("You haven't specified a view type.");
156 156
             return false;
157 157
         }
158 158
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
 
175 175
 
176
-    public function render($view, $data, $format='html') {
176
+    public function render($view, $data, $format = 'html') {
177 177
         // Once we have the data that's to be rendered,
178 178
         // include the template.
179 179
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
             return $data;
183 183
         }
184 184
 
185
-        include (INCLUDESPATH."easyparliament/templates/$format/hansard_$view" . ".php");
185
+        include (INCLUDESPATH . "easyparliament/templates/$format/hansard_$view" . ".php");
186 186
         return true;
187 187
 
188 188
     }
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
             $hdate = $q['hdate'];
228 228
             if ($hdate) {
229 229
                 $URL = new \MySociety\TheyWorkForYou\Url($this->listpage);
230
-                $URL->insert( array('d'=>$hdate) );
230
+                $URL->insert(array('d'=>$hdate));
231 231
 
232 232
                 // Work out a timestamp which is handy for comparing to now.
233 233
                 list($year, $month, $date) = explode('-', $hdate);
234
-                $timestamp = gmmktime (0, 0, 0, $month, $date, $year);
234
+                $timestamp = gmmktime(0, 0, 0, $month, $date, $year);
235 235
 
236
-                $data = array (
236
+                $data = array(
237 237
                     'hdate'		=> $hdate,
238 238
                     'timestamp'	=> $timestamp,
239 239
                     'listurl'	=> $URL->generate()
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         // Pass it an array of data about an item and it will return an
268 268
         // array of data about the item's section heading.
269 269
 
270
-        twfy_debug (get_class($this), "getting an item's section");
270
+        twfy_debug(get_class($this), "getting an item's section");
271 271
 
272 272
         if ($itemdata['htype'] != '10') {
273 273
 
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
             // so get the section info above this item.
277 277
 
278 278
             // For getting hansard data.
279
-            $input = array (
280
-                'amount' => array (
279
+            $input = array(
280
+                'amount' => array(
281 281
                     'body' => true
282 282
                 ),
283
-                'where' => array (
283
+                'where' => array(
284 284
                     'hansard.epobject_id=' => $itemdata['section_id']
285 285
                 )
286 286
             );
@@ -307,21 +307,21 @@  discard block
 block discarded – undo
307 307
         // Pass it an array of data about an item and it will return an
308 308
         // array of data about the item's subsection heading.
309 309
 
310
-        twfy_debug (get_class($this), "getting an item's subsection");
310
+        twfy_debug(get_class($this), "getting an item's subsection");
311 311
 
312 312
         // What we return.
313
-        $subsectiondata = array ();
313
+        $subsectiondata = array();
314 314
 
315 315
         if ($itemdata['htype'] == '12' || $itemdata['htype'] == '13' || $itemdata['htype'] == '14') {
316 316
             // This item is a speech or procedural, so get the
317 317
             // subsection info above this item.
318 318
 
319 319
             // For getting hansard data.
320
-            $input = array (
321
-                'amount' => array (
320
+            $input = array(
321
+                'amount' => array(
322 322
                     'body' => true
323 323
                 ),
324
-                'where' => array (
324
+                'where' => array(
325 325
                     'hansard.epobject_id=' => $itemdata['subsection_id']
326 326
                 )
327 327
             );
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         // Pass it an array of item info, of a section/subsection, and this will return
350 350
         // data for the next/prev items.
351 351
 
352
-        twfy_debug (get_class($this), "getting next/prev items");
352
+        twfy_debug(get_class($this), "getting next/prev items");
353 353
 
354 354
         // What we return.
355 355
         $nextprevdata = array();
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
             $wherearr['hansard.epobject_id='] = $prev_item_id;
416 416
 
417 417
             // For getting hansard data.
418
-            $input = array (
419
-                'amount' => array (
418
+            $input = array(
419
+                'amount' => array(
420 420
                     'body' => true,
421 421
                     'speaker' => true
422 422
                 ),
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
                 if ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') {
432 432
                     // Linking to the prev (sub)section.
433 433
                     $thing = $hansardmajors[$this->major]['singular'];
434
-                    $nextprevdata['prev'] = array (
434
+                    $nextprevdata['prev'] = array(
435 435
                         'body'		=> sprintf(gettext("Previous %s"), $thing),
436 436
                         'url'		=> $prevdata[0]['listurl'],
437 437
                         'title'		=> $prevdata[0]['body']
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
                     } else {
445 445
                         $title = '';
446 446
                     }
447
-                    $nextprevdata['prev'] = array (
447
+                    $nextprevdata['prev'] = array(
448 448
                         'body'		=> gettext('Previous speaker'),
449 449
                         'url'		=> $prevdata[0]['commentsurl'],
450 450
                         'title'		=> $title
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
             $wherearr['hansard.epobject_id='] = $next_item_id;
461 461
 
462 462
             // For getting hansard data.
463
-            $input = array (
464
-                'amount' => array (
463
+            $input = array(
464
+                'amount' => array(
465 465
                     'body' => true,
466 466
                     'speaker' => true
467 467
                 ),
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
                 if ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') {
476 476
                     // Linking to the next (sub)section.
477 477
                     $thing = $hansardmajors[$this->major]['singular'];
478
-                    $nextprevdata['next'] = array (
478
+                    $nextprevdata['next'] = array(
479 479
                         'body'		=> sprintf(gettext("Next %s"), $thing),
480 480
                         'url'		=> $nextdata[0]['listurl'],
481 481
                         'title'		=> $nextdata[0]['body']
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
                     } else {
489 489
                         $title = '';
490 490
                     }
491
-                    $nextprevdata['next'] = array (
491
+                    $nextprevdata['next'] = array(
492 492
                         'body'		=> gettext('Next speaker'),
493 493
                         'url'		=> $nextdata[0]['commentsurl'],
494 494
                         'title'		=> $title
@@ -532,14 +532,14 @@  discard block
 block discarded – undo
532 532
         // containing the next/prev dates that contain items from
533 533
         // $this->major of hansard object.
534 534
 
535
-        twfy_debug (get_class($this), "getting next/prev dates");
535
+        twfy_debug(get_class($this), "getting next/prev dates");
536 536
 
537 537
         // What we return.
538
-        $nextprevdata = array ();
538
+        $nextprevdata = array();
539 539
 
540 540
         $URL = new \MySociety\TheyWorkForYou\Url($this->listpage);
541 541
 
542
-        $looper = array ("next", "prev");
542
+        $looper = array("next", "prev");
543 543
 
544 544
         foreach ($looper as $n => $nextorprev) {
545 545
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
             // when displaying the first day of debates.
564 564
             if ($q && $q['hdate'] != NULL) {
565 565
 
566
-                $URL->insert( array( 'd' => $q['hdate'] ) );
566
+                $URL->insert(array('d' => $q['hdate']));
567 567
 
568 568
                 if ($nextorprev == 'next') {
569 569
                     $body = gettext('Next day');
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 
574 574
                 $title = format_date($q['hdate'], SHORTDATEFORMAT);
575 575
 
576
-                $nextprevdata[$nextorprev] = array (
576
+                $nextprevdata[$nextorprev] = array(
577 577
                     'hdate' => $q['hdate'],
578 578
                     'url' => $URL->generate(),
579 579
                     'body' => $body,
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
         $thing = $hansardmajors[$this->major]['plural'];
588 588
         $URL->insert(array('y'=>$year));
589 589
 
590
-        $nextprevdata['up'] = array (
590
+        $nextprevdata['up'] = array(
591 591
             'body' 	=> sprintf(gettext("All of %s’s %s"), $year, $thing),
592 592
             'title'	=> '',
593 593
             'url' 	=> $URL->generate()
@@ -608,19 +608,19 @@  discard block
 block discarded – undo
608 608
         if (isset($args['date'])) {
609 609
             $date = $args['date'];
610 610
         } else {
611
-            $PAGE->error_message ("Sorry, we don't have a date.");
611
+            $PAGE->error_message("Sorry, we don't have a date.");
612 612
             return false;
613 613
         }
614 614
 
615 615
         if (!preg_match("/^(\d\d\d\d)-(\d{1,2})-(\d{1,2})$/", $date, $matches)) {
616
-            $PAGE->error_message ("Sorry, '" . _htmlentities($date) . "' isn't of the right format (YYYY-MM-DD).");
616
+            $PAGE->error_message("Sorry, '" . _htmlentities($date) . "' isn't of the right format (YYYY-MM-DD).");
617 617
             return false;
618 618
         }
619 619
 
620 620
         list(, $year, $month, $day) = $matches;
621 621
 
622 622
         if (!checkdate($month, $day, $year)) {
623
-            $PAGE->error_message ("Sorry, '" . _htmlentities($date) . "' isn't a valid date.");
623
+            $PAGE->error_message("Sorry, '" . _htmlentities($date) . "' isn't a valid date.");
624 624
             return false;
625 625
         }
626 626
 
@@ -638,29 +638,29 @@  discard block
 block discarded – undo
638 638
         global $PAGE;
639 639
 
640 640
         if (!isset($args['gid']) && $args['gid'] == '') {
641
-            $PAGE->error_message ("Sorry, we don't have an item gid.");
641
+            $PAGE->error_message("Sorry, we don't have an item gid.");
642 642
             return false;
643 643
         }
644 644
 
645 645
 
646 646
         // Get all the data just for this epobject_id.
647
-        $input = array (
648
-            'amount' => array (
647
+        $input = array(
648
+            'amount' => array(
649 649
                 'body' => true,
650 650
                 'speaker' => true,
651 651
                 'comment' => true,
652 652
                 'votes' => true
653 653
             ),
654
-            'where' => array (
654
+            'where' => array(
655 655
                 // Need to add the 'uk.org.publicwhip/debate/' or whatever on before
656 656
                 // looking in the DB.
657 657
                 'gid=' => $this->gidprefix . $args['gid']
658 658
             )
659 659
         );
660 660
 
661
-        twfy_debug (get_class($this), "looking for redirected gid");
661
+        twfy_debug(get_class($this), "looking for redirected gid");
662 662
         $gid = $this->gidprefix . $args['gid'];
663
-        $q = $this->db->query ("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid))->first();
663
+        $q = $this->db->query("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid))->first();
664 664
         if (!$q) {
665 665
             $itemdata = $this->_get_hansard_data($input);
666 666
         } else {
@@ -668,10 +668,10 @@  discard block
 block discarded – undo
668 668
                 $gid = $q['gid_to'];
669 669
                 $q = $this->db->query("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid))->first();
670 670
             } while ($q);
671
-            twfy_debug (get_class($this), "found redirected gid $gid" );
671
+            twfy_debug(get_class($this), "found redirected gid $gid");
672 672
             $input['where'] = array('gid=' => $gid);
673 673
             $itemdata = $this->_get_hansard_data($input);
674
-            if (count($itemdata) > 0 ) {
674
+            if (count($itemdata) > 0) {
675 675
                 throw new RedirectException(fix_gid_from_db($gid));
676 676
             }
677 677
         }
@@ -685,9 +685,9 @@  discard block
 block discarded – undo
685 685
             $this->check_gid_change($args['gid'], 'a', '');
686 686
 
687 687
             if (substr($args['gid'], -1) == 'L') {
688
-                $letts = array('a','b','c','d','e');
689
-                for ($i=0; $i<4; $i++) {
690
-                    $this->check_gid_change($args['gid'], $letts[$i], $letts[$i+1]);
688
+                $letts = array('a', 'b', 'c', 'd', 'e');
689
+                for ($i = 0; $i < 4; $i++) {
690
+                    $this->check_gid_change($args['gid'], $letts[$i], $letts[$i + 1]);
691 691
                 }
692 692
             }
693 693
 
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
             #	$u = $q['source_url'];
721 721
             #	$u = '<br><a href="'. $u . '">' . $u . '</a>';
722 722
             #}
723
-            $PAGE->error_message ("Sorry, there is no Hansard object with a gid of '" . _htmlentities($args['gid']) . "'.");
723
+            $PAGE->error_message("Sorry, there is no Hansard object with a gid of '" . _htmlentities($args['gid']) . "'.");
724 724
             return false;
725 725
         }
726 726
 
@@ -729,8 +729,8 @@  discard block
 block discarded – undo
729 729
     }
730 730
 
731 731
     private function check_gid_change($gid, $from, $to) {
732
-        $input = array (
733
-            'amount' => array (
732
+        $input = array(
733
+            'amount' => array(
734 734
                 'body' => true,
735 735
                 'speaker' => true,
736 736
                 'comment' => true,
@@ -754,10 +754,10 @@  discard block
 block discarded – undo
754 754
 
755 755
         global $DATA, $this_page;
756 756
 
757
-        twfy_debug (get_class($this), "getting data by date");
757
+        twfy_debug(get_class($this), "getting data by date");
758 758
 
759 759
         // Where we'll put all the data we want to render.
760
-        $data = array ();
760
+        $data = array();
761 761
 
762 762
         $date = $this->_validate_date($args);
763 763
 
@@ -771,13 +771,13 @@  discard block
 block discarded – undo
771 771
 
772 772
             // Get all the sections for this date.
773 773
             // Then for each of those we'll get the subsections and rows.
774
-            $input = array (
775
-                'amount' => array (
774
+            $input = array(
775
+                'amount' => array(
776 776
                     'body' => true,
777 777
                     'comment' => true,
778 778
                     'excerpt' => true
779 779
                 ),
780
-                'where' => array (
780
+                'where' => array(
781 781
                     'hdate=' => "$date",
782 782
                     'htype=' => '10',
783 783
                     'major=' => $this->major
@@ -793,20 +793,20 @@  discard block
 block discarded – undo
793 793
                 $data['rows'] = array();
794 794
 
795 795
                 $num_sections = count($sections);
796
-                for ($n=0; $n<$num_sections; $n++) {
796
+                for ($n = 0; $n < $num_sections; $n++) {
797 797
                     // For each section on this date, get the subsections within it.
798 798
 
799 799
                     // Get all the section data.
800 800
                     $sectionrow = $this->_get_section($sections[$n]);
801 801
 
802 802
                     // Get the subsections within the section.
803
-                    $input = array (
804
-                        'amount' => array (
803
+                    $input = array(
804
+                        'amount' => array(
805 805
                             'body' => true,
806 806
                             'comment' => true,
807 807
                             'excerpt' => true
808 808
                         ),
809
-                        'where' => array (
809
+                        'where' => array(
810 810
                             'section_id='	=> $sections[$n]['epobject_id'],
811 811
                             'htype='		=> '11',
812 812
                             'major='		=> $this->major
@@ -817,10 +817,10 @@  discard block
 block discarded – undo
817 817
                     $rows = $this->_get_hansard_data($input);
818 818
 
819 819
                     // Put the section at the top of the rows array.
820
-                    array_unshift ($rows, $sectionrow);
820
+                    array_unshift($rows, $sectionrow);
821 821
 
822 822
                     // Add the section heading and the subsections to the full list.
823
-                    $data['rows'] = array_merge ($data['rows'], $rows);
823
+                    $data['rows'] = array_merge($data['rows'], $rows);
824 824
                 }
825 825
             }
826 826
 
@@ -856,9 +856,9 @@  discard block
 block discarded – undo
856 856
             $major = '';
857 857
         }
858 858
 
859
-        $data = array ();
859
+        $data = array();
860 860
 
861
-        $q = $this->db->query ("SELECT DISTINCT(hdate)
861
+        $q = $this->db->query("SELECT DISTINCT(hdate)
862 862
                         FROM 	hansard
863 863
                         $major
864 864
                         ORDER BY hdate DESC
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
         $data = array();
892 892
 
893 893
         if (!isset($args['person_id'])) {
894
-            $PAGE->error_message ("Sorry, we need a valid person ID.");
894
+            $PAGE->error_message("Sorry, we need a valid person ID.");
895 895
             return $data;
896 896
         }
897 897
 
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 
932 932
         $speeches = array();
933 933
         foreach ($q as $row) {
934
-            $speech = array (
934
+            $speech = array(
935 935
                 'subsection_id' => $row['subsection_id'],
936 936
                 'section_id' => $row['section_id'],
937 937
                 'htype' => $row['htype'],
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
             // Cache parent id to speed up _get_listurl
949 949
             $this->epobjectid_to_gid[$row['subsection_id']] = fix_gid_from_db($row['gid_subsection']);
950 950
 
951
-            $url_args = array ('p' => $row['person_id']);
951
+            $url_args = array('p' => $row['person_id']);
952 952
             $speech['listurl'] = $this->_get_listurl($speech, $url_args);
953 953
             $speeches[] = $speech;
954 954
         }
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
         if (count($speeches) > 0) {
957 957
             // Get the subsection texts.
958 958
             $num_speeches = count($speeches);
959
-            for ($n=0; $n<$num_speeches; $n++) {
959
+            for ($n = 0; $n < $num_speeches; $n++) {
960 960
                 $thing = $hansardmajors[$speeches[$n]['major']]['title'];
961 961
                 // Add the parent's body on...
962 962
                 $speeches[$n]['parent']['body'] = $speeches[$n]['body_section'] . ' | ' . $thing;
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
             // eg, by doing filter_user_input($s, 'strict');
988 988
             $searchstring = $args['s'];
989 989
         } else {
990
-            if ( isset($args['exceptions']) ) {
990
+            if (isset($args['exceptions'])) {
991 991
                 throw new \Exception('No search string provided.');
992 992
             } else {
993 993
                 $PAGE->error_message("No search string");
@@ -996,14 +996,14 @@  discard block
 block discarded – undo
996 996
         }
997 997
 
998 998
         // What we'll return.
999
-        $data = array ();
999
+        $data = array();
1000 1000
 
1001 1001
         $data['info']['s'] = $args['s'];
1002 1002
 
1003 1003
         // Allows us to specify how many results we want
1004 1004
         // Mainly for glossary term adding
1005 1005
         if (isset($args['num']) && is_numeric($args['num'])) {
1006
-            $results_per_page = (int)$args['num'];
1006
+            $results_per_page = (int) $args['num'];
1007 1007
         } else {
1008 1008
             $results_per_page = 20;
1009 1009
         }
@@ -1031,20 +1031,20 @@  discard block
 block discarded – undo
1031 1031
         global $SEARCHENGINE;
1032 1032
 
1033 1033
         // For Xapian's equivalent of an SQL LIMIT clause.
1034
-        $first_result = ($page-1) * $results_per_page;
1034
+        $first_result = ($page - 1) * $results_per_page;
1035 1035
         $data['info']['first_result'] = $first_result + 1; // Take account of LIMIT's 0 base.
1036 1036
 
1037 1037
         // Get the gids from Xapian
1038 1038
         $sort_order = 'date';
1039 1039
         if (isset($args['o'])) {
1040
-            if ($args['o']=='d') {
1040
+            if ($args['o'] == 'd') {
1041 1041
                 $sort_order = 'newest';
1042 1042
             }
1043
-            if ($args['o']=='o') {
1043
+            if ($args['o'] == 'o') {
1044 1044
                 $sort_order = 'oldest';
1045
-            } elseif ($args['o']=='c') {
1045
+            } elseif ($args['o'] == 'c') {
1046 1046
                 $sort_order = 'created';
1047
-            } elseif ($args['o']=='r') {
1047
+            } elseif ($args['o'] == 'r') {
1048 1048
                 $sort_order = 'relevance';
1049 1049
             }
1050 1050
         }
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
 
1057 1057
         // Log this query so we can improve them - if it wasn't a "popular
1058 1058
         // query" link
1059
-        if (! isset($args['pop']) or $args['pop'] != 1) {
1059
+        if (!isset($args['pop']) or $args['pop'] != 1) {
1060 1060
             global $SEARCHLOG;
1061 1061
             $SEARCHLOG->add(
1062 1062
             array('query' => $searchstring,
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 
1072 1072
         $SEARCHENGINE->run_search($first_result, $results_per_page, $sort_order);
1073 1073
         $gids = $SEARCHENGINE->get_gids();
1074
-        if ($sort_order=='created') {
1074
+        if ($sort_order == 'created') {
1075 1075
             $createds = $SEARCHENGINE->get_createds();
1076 1076
         }
1077 1077
         $relevances = $SEARCHENGINE->get_relevances();
@@ -1087,13 +1087,13 @@  discard block
 block discarded – undo
1087 1087
 
1088 1088
         // Cycle through each result, munge the data, get more, and put it all in $data.
1089 1089
         $num_gids = count($gids);
1090
-        for ($n=0; $n<$num_gids; $n++) {
1090
+        for ($n = 0; $n < $num_gids; $n++) {
1091 1091
             $gid = $gids[$n];
1092 1092
             $relevancy = $relevances[$n];
1093 1093
             $collapsed = $SEARCHENGINE->collapsed[$n];
1094
-            if ($sort_order=='created') {
1094
+            if ($sort_order == 'created') {
1095 1095
                 #$created = substr($createds[$n], 0, strpos($createds[$n], ':'));
1096
-                if ($createds[$n]<$args['threshold']) {
1096
+                if ($createds[$n] < $args['threshold']) {
1097 1097
                     $data['info']['total_results'] = $n;
1098 1098
                     break;
1099 1099
                 }
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
                 , array(':gid' => $gid));
1163 1163
 
1164 1164
                 if ($q->rows() > 1) {
1165
-                    if ( $isset($args['exceptions']) ) {
1165
+                    if ($isset($args['exceptions'])) {
1166 1166
                         throw new \Exception("Got more than one row getting data for $gid.");
1167 1167
                     } else {
1168 1168
                         $PAGE->error_message("Got more than one row getting data for $gid");
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
                 //////////////////////////
1184 1184
                 // 2. Create the URL to link to this bit of text.
1185 1185
 
1186
-                $id_data = array (
1186
+                $id_data = array(
1187 1187
                     'major'            => $itemdata['major'],
1188 1188
                     'minor'            => $itemdata['minor'],
1189 1189
                     'htype'         => $itemdata['htype'],
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
 
1195 1195
                 // We append the query onto the end of the URL as variable 's'
1196 1196
                 // so we can highlight them on the debate/wrans list page.
1197
-                $url_args = array ('s' => $searchstring);
1197
+                $url_args = array('s' => $searchstring);
1198 1198
 
1199 1199
                 $itemdata['listurl'] = $this->_get_listurl($id_data, $url_args, $encode);
1200 1200
 
@@ -1247,14 +1247,14 @@  discard block
 block discarded – undo
1247 1247
                     } else {
1248 1248
                         $listurl = '';
1249 1249
                     }
1250
-                    $itemdata['parent'] = array (
1250
+                    $itemdata['parent'] = array(
1251 1251
                         'body' => $body,
1252 1252
                         'listurl' => $listurl
1253 1253
                     );
1254 1254
                     if ($itemdata['htype'] == 11) {
1255 1255
                         # Search result was a subsection heading; fetch the first entry
1256 1256
                         # from the wrans/wms to show under the heading
1257
-                        $input = array (
1257
+                        $input = array(
1258 1258
                             'amount' => array(
1259 1259
                                 'body' => true,
1260 1260
                                 'speaker' => true
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
         $extract = trim_characters(html_entity_decode($extract), $startpos, $length_of_extract);
1314 1314
 
1315 1315
         // Highlight search words
1316
-        $extract = mb_encode_numericentity( htmlentities($extract, ENT_QUOTES, 'UTF-8'), [0x80, 0x10FFFF, 0, ~0], 'UTF-8');
1316
+        $extract = mb_encode_numericentity(htmlentities($extract, ENT_QUOTES, 'UTF-8'), [0x80, 0x10FFFF, 0, ~0], 'UTF-8');
1317 1317
         $extract = $SEARCHENGINE->highlight($extract);
1318 1318
 
1319 1319
         return $extract;
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
 
1499 1499
         $params[':major'] = $this->major;
1500 1500
         $params[':firstdate'] = $firstyear . '-' . $firstmonth . '-01';
1501
-        $q =  $this->db->query("SELECT 	DISTINCT(hdate) AS hdate
1501
+        $q = $this->db->query("SELECT 	DISTINCT(hdate) AS hdate
1502 1502
                         FROM		hansard
1503 1503
                         WHERE		major = :major
1504 1504
                         AND			hdate >= :firstdate
@@ -1564,9 +1564,9 @@  discard block
 block discarded – undo
1564 1564
             if ($action == 'recentyear') {
1565 1565
                 // Assuming there will be a previous year!
1566 1566
 
1567
-                $YEARURL->insert(array('y'=> $firstyear-1));
1567
+                $YEARURL->insert(array('y'=> $firstyear - 1));
1568 1568
 
1569
-                $nextprev['prev'] = array (
1569
+                $nextprev['prev'] = array(
1570 1570
                     'body' => 'Previous year',
1571 1571
                     'title' => $firstyear - 1,
1572 1572
                     'url' => $YEARURL->generate()
@@ -1575,8 +1575,8 @@  discard block
 block discarded – undo
1575 1575
             } else {
1576 1576
                 // action is 'year'.
1577 1577
 
1578
-                $nextprev['prev'] = array ('body' => 'Previous year');
1579
-                $nextprev['next'] = array ('body' => 'Next year');
1578
+                $nextprev['prev'] = array('body' => 'Previous year');
1579
+                $nextprev['next'] = array('body' => 'Next year');
1580 1580
 
1581 1581
                 $q = $this->db->query("SELECT DATE_FORMAT(hdate, '%Y') AS year
1582 1582
                             FROM hansard WHERE major = :major
@@ -1665,14 +1665,14 @@  discard block
 block discarded – undo
1665 1665
         // $input['limit'] as a string for the $limit clause, eg '21,20'.
1666 1666
 
1667 1667
         $amount 		= isset($input['amount']) ? $input['amount'] : array();
1668
-        $wherearr 		= isset($input['where']) ? $input['where'] : array();
1668
+        $wherearr = isset($input['where']) ? $input['where'] : array();
1669 1669
         $order 			= isset($input['order']) ? $input['order'] : '';
1670 1670
         $limit 			= isset($input['limit']) ? $input['limit'] : '';
1671 1671
 
1672 1672
 
1673 1673
         // The fields to fetch from db. 'table' => array ('field1', 'field2').
1674
-        $fieldsarr = array (
1675
-            'hansard' => array ('epobject_id', 'htype', 'gid', 'hpos', 'section_id', 'subsection_id', 'hdate', 'htime', 'source_url', 'major', 'minor', 'colnum')
1674
+        $fieldsarr = array(
1675
+            'hansard' => array('epobject_id', 'htype', 'gid', 'hpos', 'section_id', 'subsection_id', 'hdate', 'htime', 'source_url', 'major', 'minor', 'colnum')
1676 1676
         );
1677 1677
 
1678 1678
         $params = array();
@@ -1684,23 +1684,23 @@  discard block
 block discarded – undo
1684 1684
         if ((isset($amount['body']) && $amount['body'] == true) ||
1685 1685
             (isset($amount['comment']) && $amount['comment'] == true)
1686 1686
             ) {
1687
-            $fieldsarr['epobject'] = array ('body');
1687
+            $fieldsarr['epobject'] = array('body');
1688 1688
             $join = 'LEFT OUTER JOIN epobject ON hansard.epobject_id = epobject.epobject_id';
1689 1689
         } else {
1690 1690
             $join = '';
1691 1691
         }
1692 1692
 
1693 1693
 
1694
-        $fieldsarr2 = array ();
1694
+        $fieldsarr2 = array();
1695 1695
         // Construct the $fields clause.
1696 1696
         foreach ($fieldsarr as $table => $tablesfields) {
1697 1697
             foreach ($tablesfields as $n => $field) {
1698
-                $fieldsarr2[] = $table.'.'.$field;
1698
+                $fieldsarr2[] = $table . '.' . $field;
1699 1699
             }
1700 1700
         }
1701 1701
         $fields = implode(', ', $fieldsarr2);
1702 1702
 
1703
-        $wherearr2 = array ();
1703
+        $wherearr2 = array();
1704 1704
         // Construct the $where clause.
1705 1705
         $i = 0;
1706 1706
         foreach ($wherearr as $key => $val) {
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
             $wherearr2[] = "$key :where$i";
1709 1709
             $i++;
1710 1710
         }
1711
-        $where = implode (" AND ", $wherearr2);
1711
+        $where = implode(" AND ", $wherearr2);
1712 1712
 
1713 1713
 
1714 1714
         if ($order != '') {
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
         }
1727 1727
 
1728 1728
         // Finally, do the query!
1729
-        $q = $this->db->query ("SELECT $fields
1729
+        $q = $this->db->query("SELECT $fields
1730 1730
                         FROM 	hansard
1731 1731
                         $join
1732 1732
                         WHERE $where
@@ -1751,23 +1751,23 @@  discard block
 block discarded – undo
1751 1751
             if (isset($item['gid'])) {
1752 1752
                 // Remove the "uk.org.publicwhip/blah/" from the gid:
1753 1753
                 // (In includes/utility.php)
1754
-                $item['gid'] = fix_gid_from_db( $item['gid'] );
1754
+                $item['gid'] = fix_gid_from_db($item['gid']);
1755 1755
             }
1756 1756
 
1757 1757
             // Add mentions if (a) it's a question in the written
1758 1758
             // answer section or (b) it's in the official reports
1759 1759
             // and the body text ends in a bracketed SPID.
1760
-            if (($this->major && $hansardmajors[$this->major]['page']=='spwrans') && ($item['htype'] == '12' && $item['minor'] == '1')) {
1760
+            if (($this->major && $hansardmajors[$this->major]['page'] == 'spwrans') && ($item['htype'] == '12' && $item['minor'] == '1')) {
1761 1761
                 // Get out the SPID:
1762
-                if ( preg_match('#\d{4}-\d\d-\d\d\.(.*?)\.q#', $item['gid'], $m) ) {
1762
+                if (preg_match('#\d{4}-\d\d-\d\d\.(.*?)\.q#', $item['gid'], $m)) {
1763 1763
                     $item['mentions'] = $this->_get_mentions($m[1]);
1764 1764
                 }
1765 1765
             }
1766 1766
 
1767 1767
             // The second case (b):
1768
-            if (($this->major && $hansardmajors[$this->major]['page']=='spdebates') && isset($item['body'])) {
1769
-                $stripped_body = preg_replace('/<[^>]+>/ms','',$item['body']);
1770
-                if ( preg_match('/\((S\d+\w+-\d+)\)/ms',$stripped_body,$m) ) {
1768
+            if (($this->major && $hansardmajors[$this->major]['page'] == 'spdebates') && isset($item['body'])) {
1769
+                $stripped_body = preg_replace('/<[^>]+>/ms', '', $item['body']);
1770
+                if (preg_match('/\((S\d+\w+-\d+)\)/ms', $stripped_body, $m)) {
1771 1771
                     $item['mentions'] = $this->_get_mentions($m[1]);
1772 1772
                 }
1773 1773
             }
@@ -1780,7 +1780,7 @@  discard block
 block discarded – undo
1780 1780
             // Get the number of items within a section or subsection.
1781 1781
             // It could be that we can do this in the main query?
1782 1782
             // Not sure.
1783
-            if ( ($this->major && $hansardmajors[$this->major]['type']=='debate') && ($item['htype'] == '10' || $item['htype'] == '11') ) {
1783
+            if (($this->major && $hansardmajors[$this->major]['type'] == 'debate') && ($item['htype'] == '10' || $item['htype'] == '11')) {
1784 1784
 
1785 1785
                 if ($item['htype'] == '10') {
1786 1786
                     // Section - get a count of items within this section that
@@ -1858,7 +1858,7 @@  discard block
 block discarded – undo
1858 1858
             // 'commentsurl' is the URL of the item on its own page, with comments.
1859 1859
 
1860 1860
             // All the things we need to work out a listurl!
1861
-            $item_data = array (
1861
+            $item_data = array(
1862 1862
                 'major'			=> $this->major,
1863 1863
                 'minor' 		=> $item['minor'],
1864 1864
                 'htype' 		=> $item['htype'],
@@ -1891,11 +1891,11 @@  discard block
 block discarded – undo
1891 1891
                 $item['htype'] == '12') {
1892 1892
                 // Debate speech or written answers (not questions).
1893 1893
 
1894
-                $item['votes'] = $this->_get_votes( $item['epobject_id'] );
1894
+                $item['votes'] = $this->_get_votes($item['epobject_id']);
1895 1895
             }
1896 1896
 
1897 1897
             // Get the speaker for this item, if applicable.
1898
-            if ( (isset($amount['speaker']) && $amount['speaker'] == true) &&
1898
+            if ((isset($amount['speaker']) && $amount['speaker'] == true) &&
1899 1899
                 $item['person_id'] != '') {
1900 1900
 
1901 1901
                 $item['speaker'] = $this->_get_speaker($item['person_id'], $item['hdate'], $item['htime'], $item['major']);
@@ -1906,7 +1906,7 @@  discard block
 block discarded – undo
1906 1906
             if (isset($amount['comment']) && $amount['comment'] == true) {
1907 1907
 
1908 1908
                 // All the things we need to get the comment data.
1909
-                $item_data = array (
1909
+                $item_data = array(
1910 1910
                     'htype' => $item['htype'],
1911 1911
                     'epobject_id' => $item['epobject_id']
1912 1912
                 );
@@ -1979,7 +1979,7 @@  discard block
 block discarded – undo
1979 1979
     }
1980 1980
 
1981 1981
 
1982
-    public function _get_listurl ($id_data, $url_args=array(), $encode='html') {
1982
+    public function _get_listurl($id_data, $url_args = array(), $encode = 'html') {
1983 1983
         global $hansardmajors;
1984 1984
         // Generates an item's listurl - this is the 'contextual' url
1985 1985
         // for an item, in the full list view with an anchor (if appropriate).
@@ -2009,7 +2009,7 @@  discard block
 block discarded – undo
2009 2009
                 $DATA->set_page_metadata('pbc_clause', 'url', 'pbc/' . $this->url . $id);
2010 2010
                 $LISTURL->remove(array('id'));
2011 2011
             } else {
2012
-                $LISTURL->insert( array( 'id' => $id_data['gid'] ) );
2012
+                $LISTURL->insert(array('id' => $id_data['gid']));
2013 2013
             }
2014 2014
         } else {
2015 2015
             // A debate speech or question/answer, etc.
@@ -2022,10 +2022,10 @@  discard block
 block discarded – undo
2022 2022
             // Find the gid of this item's (sub)section.
2023 2023
             $parent_gid = '';
2024 2024
 
2025
-            if (isset($this->epobjectid_to_gid[ $parent_epobject_id ])) {
2025
+            if (isset($this->epobjectid_to_gid[$parent_epobject_id])) {
2026 2026
                 // We've previously cached the gid for this epobject_id, so use that.
2027 2027
 
2028
-                $parent_gid = $this->epobjectid_to_gid[ $parent_epobject_id ];
2028
+                $parent_gid = $this->epobjectid_to_gid[$parent_epobject_id];
2029 2029
 
2030 2030
             } else {
2031 2031
                 // We haven't cached the gid, so fetch from db.
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
                     $parent_gid = fix_gid_from_db($r['gid']);
2042 2042
 
2043 2043
                     // Cache it for if we need it again:
2044
-                    $this->epobjectid_to_gid[ $parent_epobject_id ] = $parent_gid;
2044
+                    $this->epobjectid_to_gid[$parent_epobject_id] = $parent_gid;
2045 2045
                 }
2046 2046
             }
2047 2047
 
@@ -2056,13 +2056,13 @@  discard block
 block discarded – undo
2056 2056
                         $session = $qq['session'];
2057 2057
                         $this->bill_lookup[$minor] = array($title, $session);
2058 2058
                     }
2059
-                    $url = "$session/" . urlencode(str_replace(' ','_',$title));
2059
+                    $url = "$session/" . urlencode(str_replace(' ', '_', $title));
2060 2060
                     $parent_gid = preg_replace('#^.*?_.*?_#', '', $parent_gid);
2061 2061
                     global $DATA;
2062 2062
                     $DATA->set_page_metadata('pbc_clause', 'url', "pbc/$url/$parent_gid");
2063 2063
                     $LISTURL->remove(array('id'));
2064 2064
                 } else {
2065
-                    $LISTURL->insert( array( 'id' => $parent_gid ) );
2065
+                    $LISTURL->insert(array('id' => $parent_gid));
2066 2066
                 }
2067 2067
                 // Use a truncated form of this item's gid for the anchor.
2068 2068
                 $fragment = '#g' . gid_to_anchor($id_data['gid']);
@@ -2070,7 +2070,7 @@  discard block
 block discarded – undo
2070 2070
         }
2071 2071
 
2072 2072
         if (count($url_args) > 0) {
2073
-            $LISTURL->insert( $url_args);
2073
+            $LISTURL->insert($url_args);
2074 2074
         }
2075 2075
 
2076 2076
         return $LISTURL->generate($encode) . $fragment;
@@ -2135,10 +2135,10 @@  discard block
 block discarded – undo
2135 2135
         $member = $this->_get_speaker_alone($q, $person_id, $hdate, $htime, $major);
2136 2136
 
2137 2137
         $URL = $this->_get_speaker_url($member['house']);
2138
-        $URL->insert( array ('p' => $person_id) );
2138
+        $URL->insert(array('p' => $person_id));
2139 2139
 
2140 2140
         $name = member_full_name($member['house'], $member['title'], $member['given_name'], $member['family_name'], $member['lordofname']);
2141
-        $speaker = array (
2141
+        $speaker = array(
2142 2142
             'member_id' => $member['member_id'],
2143 2143
             "name" => $name,
2144 2144
             'house' => $member['house'],
@@ -2266,12 +2266,12 @@  discard block
 block discarded – undo
2266 2266
                     array(':epobject_id' => $item_data['epobject_id']))->first();
2267 2267
 
2268 2268
                 // Add this comment to the data structure.
2269
-                $comment = array (
2269
+                $comment = array(
2270 2270
                     'comment_id' => $q['comment_id'],
2271 2271
                     'user_id'	=> $q['user_id'],
2272 2272
                     'body'		=> $q['body'],
2273 2273
                     'posted'	=> $q['posted'],
2274
-                    'username'	=> $q['firstname'] .' '. $q['lastname']
2274
+                    'username'	=> $q['firstname'] . ' ' . $q['lastname']
2275 2275
                 );
2276 2276
             }
2277 2277
 
@@ -2281,7 +2281,7 @@  discard block
 block discarded – undo
2281 2281
         // or subsection itself, only the items within them. So
2282 2282
         // we don't get the most recent comment. Because there isn't one.
2283 2283
 
2284
-        $return = array (
2284
+        $return = array(
2285 2285
             'totalcomments' => $totalcomments,
2286 2286
             'comment' => $comment
2287 2287
         );
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
         // What it says on the tin.
2296 2296
         // $item_data must have 'htype' and 'epobject_id' elements. TODO: Check for major==4
2297 2297
 
2298
-        if (($hansardmajors[$this->major]['type']=='debate') &&
2298
+        if (($hansardmajors[$this->major]['type'] == 'debate') &&
2299 2299
             ($item_data['htype'] == '10' || $item_data['htype'] == '11')
2300 2300
             ) {
2301 2301
             // We'll be getting a count of the comments on all items
@@ -2331,7 +2331,7 @@  discard block
 block discarded – undo
2331 2331
         // Then depending on what htype it is, we get the data for other items too.
2332 2332
         global $DATA, $this_page, $hansardmajors;
2333 2333
 
2334
-        twfy_debug (get_class($this), "getting data by gid");
2334
+        twfy_debug(get_class($this), "getting data by gid");
2335 2335
 
2336 2336
         // Get the information about the item this URL refers to.
2337 2337
         $itemdata = $this->_get_item($args);
@@ -2340,25 +2340,25 @@  discard block
 block discarded – undo
2340 2340
         }
2341 2341
 
2342 2342
         // If part of a Written Answer (just question or just answer), select the whole thing
2343
-        if (isset($itemdata['major']) && $hansardmajors[$itemdata['major']]['type']=='other' and ($itemdata['htype'] == '12' or $itemdata['htype'] == '13' or $itemdata['htype'] == '14')) {
2343
+        if (isset($itemdata['major']) && $hansardmajors[$itemdata['major']]['type'] == 'other' and ($itemdata['htype'] == '12' or $itemdata['htype'] == '13' or $itemdata['htype'] == '14')) {
2344 2344
             // find the gid of the subheading which holds this part
2345
-            $input = array (
2345
+            $input = array(
2346 2346
                 'amount' => array('gid' => true),
2347
-                'where' => array (
2347
+                'where' => array(
2348 2348
                     'epobject_id=' => $itemdata['subsection_id'],
2349 2349
                 ),
2350 2350
             );
2351 2351
             $parent = $this->_get_hansard_data($input);
2352 2352
             // display that item, i.e. the whole of the Written Answer
2353
-            twfy_debug (get_class($this), "instead of " . $args['gid'] . " selecting subheading gid " . $parent[0]['gid'] . " to get whole wrans");
2353
+            twfy_debug(get_class($this), "instead of " . $args['gid'] . " selecting subheading gid " . $parent[0]['gid'] . " to get whole wrans");
2354 2354
             $args['gid'] = $parent[0]['gid'];
2355 2355
             $this->_get_item($args);
2356 2356
             throw new RedirectException($args['gid']);
2357 2357
         }
2358 2358
 
2359 2359
         # If a WMS main heading, go to next gid
2360
-        if (isset($itemdata['major']) && $itemdata['major']==4 && $itemdata['htype'] == '10') {
2361
-            $input = array (
2360
+        if (isset($itemdata['major']) && $itemdata['major'] == 4 && $itemdata['htype'] == '10') {
2361
+            $input = array(
2362 2362
                 'amount' => array('gid' => true),
2363 2363
                 'where' => array(
2364 2364
                     'section_id=' => $itemdata['epobject_id'],
@@ -2368,7 +2368,7 @@  discard block
 block discarded – undo
2368 2368
             );
2369 2369
             $next = $this->_get_hansard_data($input);
2370 2370
             if (!empty($next)) {
2371
-                twfy_debug (get_class($this), 'instead of ' . $args['gid'] . ' moving to ' . $next[0]['gid']);
2371
+                twfy_debug(get_class($this), 'instead of ' . $args['gid'] . ' moving to ' . $next[0]['gid']);
2372 2372
                 $args['gid'] = $next[0]['gid'];
2373 2373
                 $this->_get_item($args);
2374 2374
                 throw new RedirectException($args['gid']);
@@ -2420,16 +2420,16 @@  discard block
 block discarded – undo
2420 2420
         // Get the nextprev links for this item, to link to next/prev pages.
2421 2421
         // Duh.
2422 2422
         if ($itemdata['htype'] == '10') {
2423
-            $nextprev = $this->_get_nextprev_items( $sectionrow );
2423
+            $nextprev = $this->_get_nextprev_items($sectionrow);
2424 2424
             $data['info']['text_heading'] = $itemdata['body'];
2425 2425
 
2426 2426
         } elseif ($itemdata['htype'] == '11') {
2427
-            $nextprev = $this->_get_nextprev_items( $subsectionrow );
2427
+            $nextprev = $this->_get_nextprev_items($subsectionrow);
2428 2428
             $data['info']['text_heading'] = $itemdata['body'];
2429 2429
 
2430 2430
         } else {
2431 2431
             // Ordinary lowly item.
2432
-            $nextprev = $this->_get_nextprev_items( $itemdata );
2432
+            $nextprev = $this->_get_nextprev_items($itemdata);
2433 2433
 
2434 2434
             if (isset($subsectionrow['gid'])) {
2435 2435
                 $nextprev['up']['url'] 		= $subsectionrow['listurl'];
@@ -2438,7 +2438,7 @@  discard block
 block discarded – undo
2438 2438
                 $nextprev['up']['url'] 		= $sectionrow['listurl'];
2439 2439
                 $nextprev['up']['title'] 	= $sectionrow['body'];
2440 2440
             }
2441
-            $nextprev['up']['body']		= gettext('See the whole debate');
2441
+            $nextprev['up']['body'] = gettext('See the whole debate');
2442 2442
         }
2443 2443
 
2444 2444
         // We can then access this from $PAGE and the templates.
@@ -2447,7 +2447,7 @@  discard block
 block discarded – undo
2447 2447
         // Now get all the non-heading rows.
2448 2448
 
2449 2449
         // What data do we want for each item?
2450
-        $amount = array (
2450
+        $amount = array(
2451 2451
             'body' => true,
2452 2452
             'speaker' => true,
2453 2453
             'comment' => true,
@@ -2458,9 +2458,9 @@  discard block
 block discarded – undo
2458 2458
             // This item is a section, so we're displaying all the items within
2459 2459
             // it that aren't within a subsection.
2460 2460
 
2461
-            $input = array (
2461
+            $input = array(
2462 2462
                 'amount' => $amount,
2463
-                'where' => array (
2463
+                'where' => array(
2464 2464
                     'section_id=' => $itemdata['epobject_id'],
2465 2465
                     'subsection_id=' => $itemdata['epobject_id']
2466 2466
                 ),
@@ -2468,15 +2468,15 @@  discard block
 block discarded – undo
2468 2468
             );
2469 2469
 
2470 2470
             $data['rows'] = $this->_get_hansard_data($input);
2471
-            if (!count($data['rows']) || (count($data['rows'])==1 && strstr($data['rows'][0]['body'], 'was asked'))) {
2471
+            if (!count($data['rows']) || (count($data['rows']) == 1 && strstr($data['rows'][0]['body'], 'was asked'))) {
2472 2472
 
2473
-                $input = array (
2474
-                    'amount' => array (
2473
+                $input = array(
2474
+                    'amount' => array(
2475 2475
                         'body' => true,
2476 2476
                         'comment' => true,
2477 2477
                         'excerpt' => true
2478 2478
                     ),
2479
-                    'where' => array (
2479
+                    'where' => array(
2480 2480
                         'section_id='	=> $sectionrow['epobject_id'],
2481 2481
                         'htype='		=> '11',
2482 2482
                         'major='		=> $this->major
@@ -2492,9 +2492,9 @@  discard block
 block discarded – undo
2492 2492
         } elseif ($itemdata['htype'] == '11') {
2493 2493
             // This item is a subsection, so we're displaying everything within it.
2494 2494
 
2495
-            $input = array (
2495
+            $input = array(
2496 2496
                 'amount' => $amount,
2497
-                'where' => array (
2497
+                'where' => array(
2498 2498
                     'subsection_id=' => $itemdata['epobject_id']
2499 2499
                 ),
2500 2500
                 'order' => 'hpos ASC'
@@ -2515,10 +2515,10 @@  discard block
 block discarded – undo
2515 2515
             $subsectionrow['gid'] != $sectionrow['gid']) {
2516 2516
             // If we're looking at a section, there may not be a subsection.
2517 2517
             // And if the subsectionrow and sectionrow aren't the same.
2518
-            array_unshift ($data['rows'], $subsectionrow);
2518
+            array_unshift($data['rows'], $subsectionrow);
2519 2519
         }
2520 2520
 
2521
-        array_unshift ($data['rows'], $sectionrow);
2521
+        array_unshift($data['rows'], $sectionrow);
2522 2522
 
2523 2523
         return $data;
2524 2524
 
@@ -2527,10 +2527,10 @@  discard block
 block discarded – undo
2527 2527
     public function _get_data_by_column($args) {
2528 2528
         global $this_page;
2529 2529
 
2530
-        twfy_debug (get_class($this), "getting data by column");
2530
+        twfy_debug(get_class($this), "getting data by column");
2531 2531
 
2532
-        $input = array( 'amount' => array('body'=>true, 'comment'=>true, 'speaker'=>true),
2533
-        'where' => array( 'hdate='=>$args['date'], 'major=' => $this->major, 'gid LIKE ' =>'%.'.$args['column'].'.%' ),
2532
+        $input = array('amount' => array('body'=>true, 'comment'=>true, 'speaker'=>true),
2533
+        'where' => array('hdate='=>$args['date'], 'major=' => $this->major, 'gid LIKE ' =>'%.' . $args['column'] . '.%'),
2534 2534
         'order' => 'hpos'
2535 2535
         );
2536 2536
         $data = $this->_get_hansard_data($input);
@@ -2610,8 +2610,8 @@  discard block
 block discarded – undo
2610 2610
     public function get_gid_from_spid($spid) {
2611 2611
         // Fix the common errors of S.0 instead of S.O and leading
2612 2612
         // zeros in the numbers:
2613
-        $fixed_spid = preg_replace('/(S[0-9]+)0-([0-9]+)/','${1}O-${2}',$spid);
2614
-        $fixed_spid = preg_replace('/(S[0-9]+\w+)-0*([0-9]+)/','${1}-${2}',$fixed_spid);
2613
+        $fixed_spid = preg_replace('/(S[0-9]+)0-([0-9]+)/', '${1}O-${2}', $spid);
2614
+        $fixed_spid = preg_replace('/(S[0-9]+\w+)-0*([0-9]+)/', '${1}-${2}', $fixed_spid);
2615 2615
         $q = $this->db->query(
2616 2616
             "select mentioned_gid from mentions where gid = :gid_from_spid and (type = 4 or type = 6)",
2617 2617
             array(':gid_from_spid' => 'uk.org.publicwhip/spq/' . $fixed_spid)
@@ -2690,10 +2690,10 @@  discard block
 block discarded – undo
2690 2690
                         ", array(':major' => $this->major));
2691 2691
 
2692 2692
         // What we return.
2693
-        $data = array ();
2693
+        $data = array();
2694 2694
         $speeches = array();
2695 2695
         foreach ($q as $row) {
2696
-            $speech = array (
2696
+            $speech = array(
2697 2697
                 'subsection_id' => $row['subsection_id'],
2698 2698
                 'section_id' => $row['section_id'],
2699 2699
                 'htype' => $row['htype'],
@@ -2706,9 +2706,9 @@  discard block
 block discarded – undo
2706 2706
 
2707 2707
             // Remove the "uk.org.publicwhip/blah/" from the gid:
2708 2708
             // (In includes/utility.php)
2709
-            $speech['gid'] = fix_gid_from_db( $row['gid'] );
2709
+            $speech['gid'] = fix_gid_from_db($row['gid']);
2710 2710
             $speech['listurl'] = $this->_get_listurl($speech);
2711
-            $speech['speaker'] = $this->_get_speaker($row['person_id'], $row['hdate'], $row['htime'], $this->major );
2711
+            $speech['speaker'] = $this->_get_speaker($row['person_id'], $row['hdate'], $row['htime'], $this->major);
2712 2712
             $speeches[] = $speech;
2713 2713
         }
2714 2714
 
@@ -2716,10 +2716,10 @@  discard block
 block discarded – undo
2716 2716
             // Get the subsection texts.
2717 2717
 
2718 2718
             $num_speeches = count($speeches);
2719
-            for ($n=0; $n<$num_speeches; $n++) {
2719
+            for ($n = 0; $n < $num_speeches; $n++) {
2720 2720
                 //if ($this->major == 1) {
2721 2721
                     // Debate.
2722
-                    $parent = $this->_get_subsection ($speeches[$n]);
2722
+                    $parent = $this->_get_subsection($speeches[$n]);
2723 2723
 
2724 2724
                 //} elseif ($this->major == 3) {
2725 2725
                     // Wrans.
@@ -2738,7 +2738,7 @@  discard block
 block discarded – undo
2738 2738
             $data['rows'] = $speeches;
2739 2739
 
2740 2740
         } else {
2741
-            $data['rows'] = array ();
2741
+            $data['rows'] = array();
2742 2742
         }
2743 2743
 
2744 2744
         $data['info']['days'] = $days;
@@ -2755,13 +2755,13 @@  discard block
 block discarded – undo
2755 2755
     }
2756 2756
 
2757 2757
 
2758
-    public function biggest_debates($args=array()) {
2758
+    public function biggest_debates($args = array()) {
2759 2759
         // So we can just get the data back for special formatting
2760 2760
         // on the front page, without doing the whole display() thing.
2761 2761
         return $this->_get_data_by_biggest_debates($args);
2762 2762
     }
2763 2763
 
2764
-    public function _get_data_by_featured_gid($args=array()) {
2764
+    public function _get_data_by_featured_gid($args = array()) {
2765 2765
         $params = array();
2766 2766
         $data = array();
2767 2767
 
@@ -2790,18 +2790,18 @@  discard block
 block discarded – undo
2790 2790
         if ($q) {
2791 2791
 
2792 2792
             // This array just used for getting further data about this debate.
2793
-            $item_data = array (
2793
+            $item_data = array(
2794 2794
                 'major'         => $this->major,
2795 2795
                 'minor'         => $q['minor'],
2796
-                'gid'           => fix_gid_from_db( $q['gid'] ),
2796
+                'gid'           => fix_gid_from_db($q['gid']),
2797 2797
                 'htype'         => $q['htype'],
2798 2798
                 'section_id'    => $q['section_id'],
2799 2799
                 'subsection_id' => $q['subsection_id'],
2800 2800
                 'epobject_id'   => $q['epobject_id']
2801 2801
             );
2802 2802
 
2803
-            $list_url      = $this->_get_listurl( $item_data );
2804
-            $totalcomments = $this->_get_comment_count_for_epobject( $item_data );
2803
+            $list_url      = $this->_get_listurl($item_data);
2804
+            $totalcomments = $this->_get_comment_count_for_epobject($item_data);
2805 2805
 
2806 2806
             $body          = $q['body'];
2807 2807
             $hdate         = $q['hdate'];
@@ -2822,7 +2822,7 @@  discard block
 block discarded – undo
2822 2822
                             )->first();
2823 2823
                 $section_body = $r['sec_body'];
2824 2824
                 $subsection_body = $r['sub_body'];
2825
-                if ( $section_body != $subsection_body ) {
2825
+                if ($section_body != $subsection_body) {
2826 2826
                     $parentbody = "$section_body : $subsection_body";
2827 2827
                 } else {
2828 2828
                     $parentbody = $section_body;
@@ -2834,14 +2834,14 @@  discard block
 block discarded – undo
2834 2834
                                 )
2835 2835
                             )->first();
2836 2836
                 $parentbody = $r['body'];
2837
-            } else if ( $item_data['htype'] == 10 ) {
2837
+            } else if ($item_data['htype'] == 10) {
2838 2838
                 $parentbody = $body;
2839 2839
             }
2840 2840
 
2841 2841
             // Get the question for this item.
2842
-            if ( $item_data['htype'] == 12 ) {
2842
+            if ($item_data['htype'] == 12) {
2843 2843
                 $childbody = $body;
2844
-                $speaker = $this->_get_speaker($q['person_id'], $q['hdate'], $q['htime'], $this->major );
2844
+                $speaker = $this->_get_speaker($q['person_id'], $q['hdate'], $q['htime'], $this->major);
2845 2845
             } else {
2846 2846
                 $r = $this->db->query("SELECT e.body, e.title,
2847 2847
                                         h.person_id, h.hdate, h.htime
@@ -2851,10 +2851,10 @@  discard block
 block discarded – undo
2851 2851
                                 ORDER BY hpos
2852 2852
                                 LIMIT 1
2853 2853
                                 ",
2854
-                                array( ':object_id' => $item_data['epobject_id'] )
2854
+                                array(':object_id' => $item_data['epobject_id'])
2855 2855
                 )->first();
2856 2856
                 $childbody = $r['body'];
2857
-                $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major );
2857
+                $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major);
2858 2858
             }
2859 2859
 
2860 2860
             $contentcount = 0;
@@ -2870,7 +2870,7 @@  discard block
 block discarded – undo
2870 2870
             }
2871 2871
 
2872 2872
             global $hansardmajors;
2873
-            $more_url = new \MySociety\TheyWorkForYou\Url( $hansardmajors[$this->major]['page_all'] );
2873
+            $more_url = new \MySociety\TheyWorkForYou\Url($hansardmajors[$this->major]['page_all']);
2874 2874
             $details = array(
2875 2875
                 'body'          => $body,
2876 2876
                 'contentcount'  => $contentcount,
@@ -2889,7 +2889,7 @@  discard block
 block discarded – undo
2889 2889
                 'more_url' => $more_url->generate()
2890 2890
             );
2891 2891
 
2892
-            $data = array (
2892
+            $data = array(
2893 2893
                 'gid' => $args['gid'],
2894 2894
                 'major' => $this->major,
2895 2895
                 'info' => array(),
@@ -2900,7 +2900,7 @@  discard block
 block discarded – undo
2900 2900
         return $data;
2901 2901
 
2902 2902
     }
2903
-    public function _get_data_by_recent_debates($args=array()) {
2903
+    public function _get_data_by_recent_debates($args = array()) {
2904 2904
         // Returns an array of some random recent debates from a set number of
2905 2905
         // recent days (that's recent days starting from the most recent day
2906 2906
         // that had any debates on).
@@ -2962,17 +2962,17 @@  discard block
 block discarded – undo
2962 2962
         foreach ($q as $row) {
2963 2963
 
2964 2964
             // This array just used for getting further data about this debate.
2965
-            $item_data = array (
2965
+            $item_data = array(
2966 2966
                 'major' => $this->major,
2967
-                'gid' => fix_gid_from_db( $row['gid'] ),
2967
+                'gid' => fix_gid_from_db($row['gid']),
2968 2968
                 'htype' => $row['htype'],
2969 2969
                 'section_id' => $row['section_id'],
2970 2970
                 'subsection_id' => $row['subsection_id'],
2971 2971
                 'epobject_id' => $row['epobject_id']
2972 2972
             );
2973 2973
 
2974
-            $list_url      = $this->_get_listurl( $item_data );
2975
-            $totalcomments = $this->_get_comment_count_for_epobject( $item_data );
2974
+            $list_url      = $this->_get_listurl($item_data);
2975
+            $totalcomments = $this->_get_comment_count_for_epobject($item_data);
2976 2976
 
2977 2977
             $contentcount  = $row['count'];
2978 2978
             $body          = $row['body'];
@@ -3000,7 +3000,7 @@  discard block
 block discarded – undo
3000 3000
                             LIMIT 1
3001 3001
                             ")->first();
3002 3002
             $childbody = $r['body'];
3003
-            $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major );
3003
+            $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major);
3004 3004
 
3005 3005
             $data[] = array(
3006 3006
                 'contentcount'  => $contentcount,
@@ -3020,7 +3020,7 @@  discard block
 block discarded – undo
3020 3020
 
3021 3021
         }
3022 3022
 
3023
-        $data = array (
3023
+        $data = array(
3024 3024
             'info' => array(),
3025 3025
             'data' => $data
3026 3026
         );
@@ -3029,7 +3029,7 @@  discard block
 block discarded – undo
3029 3029
 
3030 3030
     }
3031 3031
 
3032
-    public function _get_data_by_biggest_debates($args=array()) {
3032
+    public function _get_data_by_biggest_debates($args = array()) {
3033 3033
         // Returns an array of the debates with most speeches in from
3034 3034
         // a set number of recent days (that's recent days starting from the
3035 3035
         // most recent day that had any debates on).
@@ -3084,17 +3084,17 @@  discard block
 block discarded – undo
3084 3084
         foreach ($q as $row) {
3085 3085
 
3086 3086
             // This array just used for getting further data about this debate.
3087
-            $item_data = array (
3087
+            $item_data = array(
3088 3088
                 'major' => $this->major,
3089
-                'gid' => fix_gid_from_db( $row['gid'] ),
3089
+                'gid' => fix_gid_from_db($row['gid']),
3090 3090
                 'htype' => $row['htype'],
3091 3091
                 'section_id' => $row['section_id'],
3092 3092
                 'subsection_id' => $row['subsection_id'],
3093 3093
                 'epobject_id' => $row['epobject_id']
3094 3094
             );
3095 3095
 
3096
-            $list_url 		= $this->_get_listurl( $item_data );
3097
-            $totalcomments	= $this->_get_comment_count_for_epobject( $item_data );
3096
+            $list_url = $this->_get_listurl($item_data);
3097
+            $totalcomments = $this->_get_comment_count_for_epobject($item_data);
3098 3098
 
3099 3099
             $contentcount = $row['count'];
3100 3100
             $body = $row['body'];
@@ -3102,7 +3102,7 @@  discard block
 block discarded – undo
3102 3102
 
3103 3103
 
3104 3104
             // This array will be added to $data, which is what gets returned.
3105
-            $debate = array (
3105
+            $debate = array(
3106 3106
                 'contentcount'	=> $contentcount,
3107 3107
                 'body'			=> $body,
3108 3108
                 'hdate'			=> $hdate,
@@ -3130,7 +3130,7 @@  discard block
 block discarded – undo
3130 3130
                             LIMIT 1
3131 3131
                             ")->first();
3132 3132
             $childbody = $r['body'];
3133
-            $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major );
3133
+            $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major);
3134 3134
 
3135 3135
             $debate['child'] = array(
3136 3136
                 'body' => $childbody,
@@ -3140,7 +3140,7 @@  discard block
 block discarded – undo
3140 3140
             $data[] = $debate;
3141 3141
         }
3142 3142
 
3143
-        $data = array (
3143
+        $data = array(
3144 3144
             'info' => array(),
3145 3145
             'data' => $data
3146 3146
         );
@@ -3163,7 +3163,7 @@  discard block
 block discarded – undo
3163 3163
         return $q->first()['count'];
3164 3164
     }
3165 3165
 
3166
-    public function _get_data_by_recent_wrans ($args=array()) {
3166
+    public function _get_data_by_recent_wrans($args = array()) {
3167 3167
         global $hansardmajors;
3168 3168
 
3169 3169
         // $args['days'] is the number of days back to look for biggest debates.
@@ -3228,17 +3228,17 @@  discard block
 block discarded – undo
3228 3228
 
3229 3229
         foreach ($q as $row) {
3230 3230
             // This array just used for getting further data about this debate.
3231
-            $item_data = array (
3231
+            $item_data = array(
3232 3232
                 'major' => $this->major,
3233
-                'gid' => fix_gid_from_db( $row['gid'] ),
3233
+                'gid' => fix_gid_from_db($row['gid']),
3234 3234
                 'htype' => $row['htype'],
3235 3235
                 'section_id' => $row['section_id'],
3236 3236
                 'subsection_id' => $row['subsection_id'],
3237 3237
                 'epobject_id' => $row['epobject_id']
3238 3238
             );
3239 3239
 
3240
-            $list_url 		= $this->_get_listurl( $item_data );
3241
-            $totalcomments	= $this->_get_comment_count_for_epobject( $item_data );
3240
+            $list_url = $this->_get_listurl($item_data);
3241
+            $totalcomments = $this->_get_comment_count_for_epobject($item_data);
3242 3242
 
3243 3243
             $body = $row['body'];
3244 3244
             $hdate = $row['hdate'];
@@ -3264,25 +3264,25 @@  discard block
 block discarded – undo
3264 3264
                             LIMIT 1
3265 3265
                             ")->first();
3266 3266
             $childbody = $r['body'];
3267
-            $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major );
3267
+            $speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major);
3268 3268
 
3269
-            $data[] = array (
3269
+            $data[] = array(
3270 3270
                 'body'			=> $body,
3271 3271
                 'hdate'			=> $hdate,
3272 3272
                 'list_url'		=> $list_url,
3273 3273
                 'totalcomments'	=> $totalcomments,
3274
-                'child'			=> array (
3274
+                'child'			=> array(
3275 3275
                     'body'		=> $childbody,
3276 3276
                     'speaker'	=> $speaker
3277 3277
                 ),
3278
-                'parent'		=> array (
3278
+                'parent'		=> array(
3279 3279
                     'body'		=> $parentbody
3280 3280
                 )
3281 3281
             );
3282 3282
 
3283 3283
         }
3284 3284
 
3285
-        $data = array (
3285
+        $data = array(
3286 3286
             'info' => array(),
3287 3287
             'data' => $data
3288 3288
         );
@@ -3299,7 +3299,7 @@  discard block
 block discarded – undo
3299 3299
     public $commentspage = 'pbc_speech';
3300 3300
     public $gidprefix = 'uk.org.publicwhip/standing/';
3301 3301
 
3302
-    public function __construct($session='', $title='') {
3302
+    public function __construct($session = '', $title = '') {
3303 3303
         parent::__construct();
3304 3304
         $this->bill_title = $title;
3305 3305
         $title = str_replace(' ', '_', $title);
@@ -3307,7 +3307,7 @@  discard block
 block discarded – undo
3307 3307
     }
3308 3308
 
3309 3309
     public function _get_committee($bill_id) {
3310
-        include_once INCLUDESPATH."easyparliament/member.php";
3310
+        include_once INCLUDESPATH . "easyparliament/member.php";
3311 3311
         $q = $this->db->query(
3312 3312
             'select count(*) as c from hansard
3313 3313
                 where major=6 and minor=:bill_id and htype=10',
@@ -3341,13 +3341,13 @@  discard block
 block discarded – undo
3341 3341
     public function _get_data_by_bill($args) {
3342 3342
         global $DATA, $this_page;
3343 3343
         $data = array();
3344
-        $input = array (
3345
-            'amount' => array (
3344
+        $input = array(
3345
+            'amount' => array(
3346 3346
                 'body' => true,
3347 3347
                 'comment' => true,
3348 3348
                 'excerpt' => true
3349 3349
             ),
3350
-            'where' => array (
3350
+            'where' => array(
3351 3351
                 'htype=' => '10',
3352 3352
                 'major=' => $this->major,
3353 3353
                 'minor=' => $args['id'],
@@ -3358,18 +3358,18 @@  discard block
 block discarded – undo
3358 3358
         $data['rows'] = array();
3359 3359
         if (count($sections) > 0) {
3360 3360
             $num_sections = count($sections);
3361
-            for ($n=0; $n<$num_sections; $n++) {
3361
+            for ($n = 0; $n < $num_sections; $n++) {
3362 3362
                 $sectionrow = $sections[$n];
3363 3363
                 list($sitting, $part) = $this->_get_sitting($sectionrow['gid']);
3364 3364
                 $sectionrow['sitting'] = $sitting;
3365 3365
                 $sectionrow['part'] = $part;
3366
-                $input = array (
3367
-                    'amount' => array (
3366
+                $input = array(
3367
+                    'amount' => array(
3368 3368
                         'body' => true,
3369 3369
                         'comment' => true,
3370 3370
                         'excerpt' => true
3371 3371
                     ),
3372
-                    'where' => array (
3372
+                    'where' => array(
3373 3373
                         'section_id='	=> $sectionrow['epobject_id'],
3374 3374
                         'htype='	=> '11',
3375 3375
                         'major='	=> $this->major
@@ -3377,8 +3377,8 @@  discard block
 block discarded – undo
3377 3377
                     'order' => 'hpos'
3378 3378
                 );
3379 3379
                 $rows = $this->_get_hansard_data($input);
3380
-                array_unshift ($rows, $sectionrow);
3381
-                $data['rows'] = array_merge ($data['rows'], $rows);
3380
+                array_unshift($rows, $sectionrow);
3381
+                $data['rows'] = array_merge($data['rows'], $rows);
3382 3382
             }
3383 3383
         }
3384 3384
         $data['info']['bill'] = $args['title'];
@@ -3434,8 +3434,8 @@  discard block
 block discarded – undo
3434 3434
 
3435 3435
         $YEARURL = new \MySociety\TheyWorkForYou\Url('pbc_session');
3436 3436
         $nextprev = array();
3437
-        $nextprev['prev'] = array ('body' => 'Previous session', 'title'=>'');
3438
-        $nextprev['next'] = array ('body' => 'Next session', 'title'=>'');
3437
+        $nextprev['prev'] = array('body' => 'Previous session', 'title'=>'');
3438
+        $nextprev['next'] = array('body' => 'Next session', 'title'=>'');
3439 3439
         $q = $this->db->query(
3440 3440
             "SELECT session FROM bills WHERE session < :session ORDER BY session DESC LIMIT 1",
3441 3441
             array(':session' => $session)
@@ -3472,13 +3472,13 @@  discard block
 block discarded – undo
3472 3472
             $session = $qq['session'];
3473 3473
             list($sitting, $part) = $this->_get_sitting($gid);
3474 3474
             $sitting_txt = make_ranking($sitting) . ' sitting';
3475
-            if ($part>0) {
3475
+            if ($part > 0) {
3476 3476
                 $sitting .= ", part $part";
3477 3477
             }
3478 3478
             $data[$hdate][] = array(
3479 3479
                 'bill'=> $title,
3480 3480
                 'sitting' => $sitting_txt,
3481
-                'url' => "/pbc/$session/" . urlencode(str_replace(' ','_',$title)) . '/#sitting' . $sitting,
3481
+                'url' => "/pbc/$session/" . urlencode(str_replace(' ', '_', $title)) . '/#sitting' . $sitting,
3482 3482
             );
3483 3483
         }
3484 3484
         return $data;
@@ -3487,7 +3487,7 @@  discard block
 block discarded – undo
3487 3487
     # Given a GID, parse out the sitting number and optional part from it
3488 3488
     public function _get_sitting($gid) {
3489 3489
         if (preg_match('#_(\d\d)-(\d)_#', $gid, $m)) {
3490
-            return array($m[1]+0, $m[2]);
3490
+            return array($m[1] + 0, $m[2]);
3491 3491
         }
3492 3492
         return array(0, 0);
3493 3493
     }
Please login to merge, or discard this patch.