Completed
Pull Request — master (#1322)
by Nick
07:54 queued 02:46
created
classes/Divisions.php 3 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -38,25 +38,25 @@  discard block
 block discarded – undo
38 38
     }
39 39
 
40 40
     public static function getMostRecentDivisionDate() {
41
-      $db = new \ParlDB;
42
-      $q = $db->query(
41
+        $db = new \ParlDB;
42
+        $q = $db->query(
43 43
         "SELECT policy_id, max(division_date) as recent from policydivisions GROUP BY policy_id"
44
-      );
44
+        );
45 45
 
46
-      $policy_maxes = array();
47
-      $row_count = $q->rows();
48
-      for ($n = 0; $n < $row_count; $n++) {
46
+        $policy_maxes = array();
47
+        $row_count = $q->rows();
48
+        for ($n = 0; $n < $row_count; $n++) {
49 49
         $policy_maxes[$q->field($n, 'policy_id')] = $q->field( $n, 'recent' );
50
-      }
51
-      $policy_maxes['latest'] = $policy_maxes ? max(array_values($policy_maxes)) : '';
52
-      return $policy_maxes;
50
+        }
51
+        $policy_maxes['latest'] = $policy_maxes ? max(array_values($policy_maxes)) : '';
52
+        return $policy_maxes;
53 53
     }
54 54
 
55 55
     public function getRecentDivisions($number = 20) {
56 56
         // Grab distinct divisions as sometimes we have the same division for more than one policy
57 57
         // and we don't want to display it twice
58 58
         $q = $this->db->query(
59
-          "SELECT distinct division_id, division_title, yes_text, no_text, division_date, division_number, gid, direction, majority_vote,
59
+            "SELECT distinct division_id, division_title, yes_text, no_text, division_date, division_number, gid, direction, majority_vote,
60 60
           yes_total, no_total, absent_total, both_total
61 61
           FROM policydivisions ORDER BY division_date DESC, division_number DESC LIMIT :count",
62 62
             array(
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         $divisions = array();
95 95
         $row_count = $q->rows();
96 96
         for ($n = 0; $n < $row_count; $n++) {
97
-          $divisions[] = $this->getParliamentDivisionDetails($q->row($n));
97
+            $divisions[] = $this->getParliamentDivisionDetails($q->row($n));
98 98
         }
99 99
 
100 100
         return $divisions;
@@ -148,44 +148,44 @@  discard block
 block discarded – undo
148 148
 
149 149
         $row_count = $q->rows();
150 150
         for ($n = 0; $n < $row_count; $n++) {
151
-          $policy_id = $q->field($n, 'policy_id');
151
+            $policy_id = $q->field($n, 'policy_id');
152 152
 
153
-          if (!array_key_exists($policy_id, $policy_divisions)) {
153
+            if (!array_key_exists($policy_id, $policy_divisions)) {
154 154
             $summary = array(
155
-              'max' => $q->field($n, 'latest'),
156
-              'min' => $q->field($n, 'earliest'),
157
-              'total' => $q->field($n, 'total'),
158
-              'for' => 0, 'against' => 0, 'absent' => 0, 'both' => 0, 'tell' => 0
155
+                'max' => $q->field($n, 'latest'),
156
+                'min' => $q->field($n, 'earliest'),
157
+                'total' => $q->field($n, 'total'),
158
+                'for' => 0, 'against' => 0, 'absent' => 0, 'both' => 0, 'tell' => 0
159 159
             );
160 160
 
161 161
             $policy_divisions[$policy_id] = $summary;
162
-          }
163
-
164
-          $summary = $policy_divisions[$policy_id];
165
-
166
-          $summary['total'] += $q->field($n, 'total');
167
-          if ($summary['max'] < $q->field($n, 'latest')) {
168
-              $summary['max'] = $q->field($n, 'latest');
169
-          }
170
-          if ($summary['min'] > $q->field($n, 'latest')) {
171
-              $summary['min'] = $q->field($n, 'latest');
172
-          }
173
-
174
-          $vote = $q->field($n, 'vote');
175
-          $policy_vote = str_replace('3', '', $q->field($n, 'policy_vote'));
176
-          if ( $vote == 'absent' ) {
177
-              $summary['absent'] += $q->field($n, 'total');
178
-          } else if ( $vote == 'both' ) {
179
-              $summary['both'] += $q->field($n, 'total');
180
-          } else if ( strpos($vote, 'tell') !== FALSE ) {
181
-              $summary['tell'] += $q->field($n, 'total');
182
-          } else if ( $policy_vote == $vote ) {
183
-              $summary['for'] += $q->field($n, 'total');
184
-          } else if ( $policy_vote != $vote ) {
185
-              $summary['against'] += $q->field($n, 'total');
186
-          }
187
-
188
-          $policy_divisions[$policy_id] = $summary;
162
+            }
163
+
164
+            $summary = $policy_divisions[$policy_id];
165
+
166
+            $summary['total'] += $q->field($n, 'total');
167
+            if ($summary['max'] < $q->field($n, 'latest')) {
168
+                $summary['max'] = $q->field($n, 'latest');
169
+            }
170
+            if ($summary['min'] > $q->field($n, 'latest')) {
171
+                $summary['min'] = $q->field($n, 'latest');
172
+            }
173
+
174
+            $vote = $q->field($n, 'vote');
175
+            $policy_vote = str_replace('3', '', $q->field($n, 'policy_vote'));
176
+            if ( $vote == 'absent' ) {
177
+                $summary['absent'] += $q->field($n, 'total');
178
+            } else if ( $vote == 'both' ) {
179
+                $summary['both'] += $q->field($n, 'total');
180
+            } else if ( strpos($vote, 'tell') !== FALSE ) {
181
+                $summary['tell'] += $q->field($n, 'total');
182
+            } else if ( $policy_vote == $vote ) {
183
+                $summary['for'] += $q->field($n, 'total');
184
+            } else if ( $policy_vote != $vote ) {
185
+                $summary['against'] += $q->field($n, 'total');
186
+            }
187
+
188
+            $policy_divisions[$policy_id] = $summary;
189 189
         }
190 190
 
191 191
         return $policy_divisions;
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
         );
220 220
 
221 221
         $votes = array(
222
-          'yes_votes' => array(),
223
-          'no_votes' => array(),
224
-          'absent_votes' => array(),
225
-          'both_votes' => array()
222
+            'yes_votes' => array(),
223
+            'no_votes' => array(),
224
+            'absent_votes' => array(),
225
+            'both_votes' => array()
226 226
         );
227 227
 
228 228
         foreach ($q->data as $vote) {
229 229
             $detail = array(
230
-              'person_id' => $vote['person_id'],
231
-              'name' => $vote['given_name'] . ' ' . $vote['family_name'],
232
-              'teller' => false
230
+                'person_id' => $vote['person_id'],
231
+                'name' => $vote['given_name'] . ' ' . $vote['family_name'],
232
+                'teller' => false
233 233
             );
234 234
 
235 235
             if (strpos($vote['vote'], 'tell') !== FALSE) {
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
             }
238 238
 
239 239
             if ($vote['vote'] == 'aye' or $vote['vote'] == 'tellaye') {
240
-              $votes['yes_votes'][] = $detail;
240
+                $votes['yes_votes'][] = $detail;
241 241
             } else if ($vote['vote'] == 'no' or $vote['vote'] == 'tellno') {
242
-              $votes['no_votes'][] = $detail;
242
+                $votes['no_votes'][] = $detail;
243 243
             } else if ($vote['vote'] == 'absent') {
244
-              $votes['absent_votes'][] = $detail;
244
+                $votes['absent_votes'][] = $detail;
245 245
             } else if ($vote['vote'] == 'both') {
246
-              $votes['both_votes'][] = $detail;
246
+                $votes['both_votes'][] = $detail;
247 247
             }
248 248
 
249 249
         }
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
         $divisions = array();
339 339
         $row_count = $q->rows();
340 340
         for ($n = 0; $n < $row_count; $n++) {
341
-          if ($context == 'Parliament') {
342
-              $divisions[] = $this->getParliamentDivisionDetails($q->row($n));
343
-          } else {
344
-              $divisions[] = $this->getDivisionDetails($q->row($n));
345
-          }
341
+            if ($context == 'Parliament') {
342
+                $divisions[] = $this->getParliamentDivisionDetails($q->row($n));
343
+            } else {
344
+                $divisions[] = $this->getDivisionDetails($q->row($n));
345
+            }
346 346
         }
347 347
 
348 348
         return $divisions;
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
 
445 445
         $division['mp_vote'] = '';
446 446
         if (array_key_exists('vote', $row)) {
447
-          $mp_vote = ' was absent';
448
-          if ($row['vote'] == 'aye') {
449
-              $mp_vote = 'voted in favour';
450
-          } else if ($row['vote'] == 'no') {
451
-              $mp_vote = 'voted against';
452
-          }
453
-          $division['mp_vote'] = $mp_vote;
447
+            $mp_vote = ' was absent';
448
+            if ($row['vote'] == 'aye') {
449
+                $mp_vote = 'voted in favour';
450
+            } else if ($row['vote'] == 'no') {
451
+                $mp_vote = 'voted against';
452
+            }
453
+            $division['mp_vote'] = $mp_vote;
454 454
         }
455 455
         $division['division_title'] = $row['division_title'];
456 456
         $division['vote'] = $vote;
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
       $policy_maxes = array();
47 47
       $row_count = $q->rows();
48 48
       for ($n = 0; $n < $row_count; $n++) {
49
-        $policy_maxes[$q->field($n, 'policy_id')] = $q->field( $n, 'recent' );
49
+        $policy_maxes[$q->field($n, 'policy_id')] = $q->field($n, 'recent');
50 50
       }
51 51
       $policy_maxes['latest'] = $policy_maxes ? max(array_values($policy_maxes)) : '';
52 52
       return $policy_maxes;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     public function getMemberDivisionsForPolicy($policyID = null) {
118 118
         $where_extra = '';
119 119
         $args = array(':person_id' => $this->member->person_id);
120
-        if ( $policyID ) {
120
+        if ($policyID) {
121 121
             $where_extra = 'AND policy_id = :policy_id';
122 122
             $args[':policy_id'] = $policyID;
123 123
         }
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 
174 174
           $vote = $q->field($n, 'vote');
175 175
           $policy_vote = str_replace('3', '', $q->field($n, 'policy_vote'));
176
-          if ( $vote == 'absent' ) {
176
+          if ($vote == 'absent') {
177 177
               $summary['absent'] += $q->field($n, 'total');
178
-          } else if ( $vote == 'both' ) {
178
+          } else if ($vote == 'both') {
179 179
               $summary['both'] += $q->field($n, 'total');
180
-          } else if ( strpos($vote, 'tell') !== FALSE ) {
180
+          } else if (strpos($vote, 'tell') !== FALSE) {
181 181
               $summary['tell'] += $q->field($n, 'total');
182
-          } else if ( $policy_vote == $vote ) {
182
+          } else if ($policy_vote == $vote) {
183 183
               $summary['for'] += $q->field($n, 'total');
184
-          } else if ( $policy_vote != $vote ) {
184
+          } else if ($policy_vote != $vote) {
185 185
               $summary['against'] += $q->field($n, 'total');
186 186
           }
187 187
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         foreach ($q->data as $vote) {
229 229
             $detail = array(
230 230
               'person_id' => $vote['person_id'],
231
-              'name' => $vote['given_name'] . ' ' . $vote['family_name'],
231
+              'name' => $vote['given_name'].' '.$vote['family_name'],
232 232
               'teller' => false
233 233
             );
234 234
 
@@ -280,20 +280,20 @@  discard block
 block discarded – undo
280 280
         $min = $votes['min'];
281 281
 
282 282
         $actions = array(
283
-            $votes['for'] . ' ' . make_plural('vote', $votes['for']) . ' for',
284
-            $votes['against'] . ' ' . make_plural('vote', $votes['against']) . ' against'
283
+            $votes['for'].' '.make_plural('vote', $votes['for']).' for',
284
+            $votes['against'].' '.make_plural('vote', $votes['against']).' against'
285 285
         );
286 286
 
287
-        if ( $votes['both'] ) {
288
-            $actions[] = $votes['both'] . ' ' . make_plural('abstention', $votes['both']);
287
+        if ($votes['both']) {
288
+            $actions[] = $votes['both'].' '.make_plural('abstention', $votes['both']);
289 289
         }
290
-        if ( $votes['absent'] ) {
291
-            $actions[] = $votes['absent'] . ' ' . make_plural('absence', $votes['absent']);
290
+        if ($votes['absent']) {
291
+            $actions[] = $votes['absent'].' '.make_plural('absence', $votes['absent']);
292 292
         }
293 293
         if ($max == $min) {
294
-            return join(', ', $actions) . ', in ' . $max;
294
+            return join(', ', $actions).', in '.$max;
295 295
         } else {
296
-            return join(', ', $actions) . ', between ' . $min . '&ndash;' . $max;
296
+            return join(', ', $actions).', between '.$min.'&ndash;'.$max;
297 297
         }
298 298
     }
299 299
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 
352 352
     private function constructYesNoVoteDescription($direction, $title, $short_text) {
353 353
         $text = ' voted ';
354
-        if ( $short_text ) {
354
+        if ($short_text) {
355 355
             $text .= $short_text;
356 356
         } else {
357 357
             $text .= "$direction on <em>$title</em>";
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
          * votes so we need to generate some text using the title of the division
370 370
          */
371 371
 
372
-        switch ( strtolower($vote) ) {
372
+        switch (strtolower($vote)) {
373 373
             case 'yes':
374 374
             case 'aye':
375 375
                 $description = $this->constructYesNoVoteDescription('yes', $division_title, $yes_text);
@@ -378,15 +378,15 @@  discard block
 block discarded – undo
378 378
                 $description = $this->constructYesNoVoteDescription('no', $division_title, $no_text);
379 379
                 break;
380 380
             case 'absent':
381
-                $description = ' was absent for a vote on <em>' . $division_title . '</em>';
381
+                $description = ' was absent for a vote on <em>'.$division_title.'</em>';
382 382
                 break;
383 383
             case 'both':
384
-                $description = ' abstained on a vote on <em>' . $division_title . '</em>';
384
+                $description = ' abstained on a vote on <em>'.$division_title.'</em>';
385 385
                 break;
386 386
             case 'tellyes':
387 387
             case 'tellno':
388 388
             case 'tellaye':
389
-                $description = ' acted as teller for a vote on <em>' . $division_title . '</em>';
389
+                $description = ' acted as teller for a vote on <em>'.$division_title.'</em>';
390 390
                 break;
391 391
             default:
392 392
                 $description = $division_title;
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         $division = array();
400 400
 
401 401
         $direction = $row['direction'];
402
-        if ( strpos( $direction, 'strong') !== FALSE ) {
402
+        if (strpos($direction, 'strong') !== FALSE) {
403 403
             $division['strong'] = TRUE;
404 404
         } else {
405 405
             $division['strong'] = FALSE;
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
         $division['division_title'] = $row['division_title'];
456 456
         $division['vote'] = $vote;
457 457
 
458
-        $division['summary'] = $row['yes_total'] . ' for, ' . $row['no_total'] . ' against, ' . $row['absent_total'] . ' absent';
458
+        $division['summary'] = $row['yes_total'].' for, '.$row['no_total'].' against, '.$row['absent_total'].' absent';
459 459
         $division['for'] = $row['yes_total'];
460 460
         $division['against'] = $row['no_total'];
461 461
         $division['both'] = $row['both_total'];
@@ -471,24 +471,24 @@  discard block
 block discarded – undo
471 471
         for ($n = 0; $n < $row_count; $n++) {
472 472
             $policy_id = $q->field($n, 'policy_id');
473 473
 
474
-            if ( !array_key_exists($policy_id, $policies) ) {
474
+            if (!array_key_exists($policy_id, $policies)) {
475 475
                 $policies[$policy_id] = array(
476 476
                     'policy_id' => $policy_id,
477 477
                     'weak_count' => 0,
478 478
                     'divisions' => array()
479 479
                 );
480
-                if ( $this->policies ) {
480
+                if ($this->policies) {
481 481
                     $policies[$policy_id]['desc'] = $this->policies->getPolicies()[$policy_id];
482 482
                     $policies[$policy_id]['header'] = $this->policies->getPolicyDetails($policy_id);
483 483
                 }
484
-                if ( $this->positions ) {
484
+                if ($this->positions) {
485 485
                     $policies[$policy_id]['position'] = $this->positions->positionsById[$policy_id];
486 486
                 }
487 487
             }
488 488
 
489 489
             $division = $this->getDivisionDetails($q->row($n));
490 490
 
491
-            if ( !$division['strong'] ) {
491
+            if (!$division['strong']) {
492 492
                 $policies[$policy_id]['weak_count']++;
493 493
             }
494 494
 
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
 
504 504
         $gid = get_canonical_gid($gid);
505 505
 
506
-        $q = $this->db->query("SELECT gid, major FROM hansard WHERE epobject_id = ( SELECT subsection_id FROM hansard WHERE gid = :gid )", array( ':gid' => $gid ));
506
+        $q = $this->db->query("SELECT gid, major FROM hansard WHERE epobject_id = ( SELECT subsection_id FROM hansard WHERE gid = :gid )", array(':gid' => $gid));
507 507
         $parent_gid = $q->field(0, 'gid');
508
-        if ( !$parent_gid ) {
508
+        if (!$parent_gid) {
509 509
             return '';
510 510
         }
511 511
         $parent_gid = fix_gid_from_db($parent_gid);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @param Member   $member   The member to get positions for.
30 30
      */
31 31
 
32
-    public function __construct(Member $member = NULL, PolicyPositions $positions = NULL, Policies $policies = NULL)
32
+    public function __construct(Member $member = null, PolicyPositions $positions = null, Policies $policies = null)
33 33
     {
34 34
         $this->member = $member;
35 35
         $this->positions = $positions;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
               $summary['absent'] += $q->field($n, 'total');
178 178
           } else if ( $vote == 'both' ) {
179 179
               $summary['both'] += $q->field($n, 'total');
180
-          } else if ( strpos($vote, 'tell') !== FALSE ) {
180
+          } else if ( strpos($vote, 'tell') !== false ) {
181 181
               $summary['tell'] += $q->field($n, 'total');
182 182
           } else if ( $policy_vote == $vote ) {
183 183
               $summary['for'] += $q->field($n, 'total');
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
               'teller' => false
233 233
             );
234 234
 
235
-            if (strpos($vote['vote'], 'tell') !== FALSE) {
235
+            if (strpos($vote['vote'], 'tell') !== false) {
236 236
                 $detail['teller'] = true;
237 237
             }
238 238
 
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
         $division = array();
400 400
 
401 401
         $direction = $row['direction'];
402
-        if ( strpos( $direction, 'strong') !== FALSE ) {
403
-            $division['strong'] = TRUE;
402
+        if ( strpos( $direction, 'strong') !== false ) {
403
+            $division['strong'] = true;
404 404
         } else {
405
-            $division['strong'] = FALSE;
405
+            $division['strong'] = false;
406 406
         }
407 407
 
408 408
         $division['division_id'] = $row['division_id'];
Please login to merge, or discard this patch.
classes/Party.php 3 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public function __construct($name) {
21 21
         // treat Labour and Labour/Co-operative the same as that's how
22 22
         // people view them and it'll confuse the results otherwise
23
-        if ( $name == 'Labour/Co-operative' ) {
23
+        if ($name == 'Labour/Co-operative') {
24 24
             $name = 'Labour';
25 25
         }
26 26
         $this->name = $name;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
                 ':date' => date('Y-m-d'),
43 43
             )
44 44
         );
45
-        if ( $member_count->rows ) {
45
+        if ($member_count->rows) {
46 46
             $num_members = $member_count->field(0, 'num_members');
47 47
             return $num_members;
48 48
         } else {
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
             )
71 71
         );
72 72
 
73
-        if ( $position->rows ) {
73
+        if ($position->rows) {
74 74
             $score = $position->field(0, 'score');
75 75
             $score_desc = score_to_strongly($score);
76 76
 
77
-            if ( $want_score ) {
78
-                return array( $score_desc, $score);
77
+            if ($want_score) {
78
+                return array($score_desc, $score);
79 79
             } else {
80 80
                 return $score_desc;
81 81
             }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             ':party' => $this->name
115 115
         );
116 116
 
117
-        if ( $this->name == 'Labour' ) {
117
+        if ($this->name == 'Labour') {
118 118
             $party_where = '( party = :party OR party = :party2 )';
119 119
             $params = array(
120 120
                 ':party' => $this->name,
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             );
123 123
         }
124 124
 
125
-        for ( $i = 0; $i < $num_divs; $i++ ) {
125
+        for ($i = 0; $i < $num_divs; $i++) {
126 126
             $division_id = $divisions->field($i, 'division_id');
127 127
             $weights = $this->get_vote_scores($divisions->field($i, 'policy_vote'));
128 128
 
@@ -142,42 +142,42 @@  discard block
 block discarded – undo
142 142
             );
143 143
 
144 144
             $num_votes = 0;
145
-            for ( $j = 0; $j < $votes->rows(); $j++ ) {
145
+            for ($j = 0; $j < $votes->rows(); $j++) {
146 146
                 $vote_dir = $votes->field($j, 'vote');
147
-                if ( $vote_dir == '' ) continue;
148
-                if ( $vote_dir == 'tellno' ) $vote_dir = 'no';
149
-                if ( $vote_dir == 'tellaye' ) $vote_dir = 'aye';
147
+                if ($vote_dir == '') continue;
148
+                if ($vote_dir == 'tellno') $vote_dir = 'no';
149
+                if ($vote_dir == 'tellaye') $vote_dir = 'aye';
150 150
 
151 151
                 $num_votes += $votes->field($j, 'num_votes');
152 152
                 $score += ($votes->field($j, 'num_votes') * $weights[$vote_dir]);
153 153
             }
154 154
 
155 155
             $total_votes += $num_votes;
156
-            $max_score += $num_votes * max( array_values( $weights ) );
156
+            $max_score += $num_votes * max(array_values($weights));
157 157
         }
158 158
 
159
-        if ( $total_votes == 0 ) {
159
+        if ($total_votes == 0) {
160 160
             return null;
161 161
         }
162 162
 
163 163
         // this implies that all the divisions in the policy have a policy
164 164
         // position of absent so we set weight to -1 to indicate we can't
165 165
         // really say what the parties position is.
166
-        if ( $max_score == 0 ) {
166
+        if ($max_score == 0) {
167 167
             $weight = -1;
168 168
         } else {
169
-            $weight = 1 - ( $score/$max_score );
169
+            $weight = 1 - ($score / $max_score);
170 170
         }
171 171
         $score_desc = score_to_strongly($weight);
172 172
 
173
-        if ( $want_score ) {
174
-            return array( $score_desc, $weight);
173
+        if ($want_score) {
174
+            return array($score_desc, $weight);
175 175
         } else {
176 176
             return $score_desc;
177 177
         }
178 178
     }
179 179
 
180
-    public function cache_position( $position ) {
180
+    public function cache_position($position) {
181 181
         $this->db->query(
182 182
             "REPLACE INTO partypolicy
183 183
                 (party, house, policy_id, score)
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
             return $positions;
198 198
         }
199 199
 
200
-        foreach ( $policies->getPolicies() as $policy_id => $policy_text ) {
201
-            list( $position, $score ) = $this->$method($policy_id, true);
202
-            if ( $position === null ) {
200
+        foreach ($policies->getPolicies() as $policy_id => $policy_text) {
201
+            list($position, $score) = $this->$method($policy_id, true);
202
+            if ($position === null) {
203 203
                 continue;
204 204
             }
205 205
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $both = 1;
220 220
         $agree = 10;
221 221
 
222
-        if ( stripos($vote, '3') !== FALSE ) {
222
+        if (stripos($vote, '3') !== FALSE) {
223 223
             $agree = 50;
224 224
             $absent = 25;
225 225
             $both = 25;
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
             'both' => $both
231 231
         );
232 232
 
233
-        if ( stripos($vote, 'aye') !== FALSE ) {
233
+        if (stripos($vote, 'aye') !== FALSE) {
234 234
             $scores['aye'] = $agree;
235 235
             $scores['no'] = 0;
236
-        } else if ( stripos($vote, 'no') !== FALSE ) {
236
+        } else if (stripos($vote, 'no') !== FALSE) {
237 237
             $scores['no'] = $agree;
238 238
             $scores['aye'] = 0;
239 239
         } else {
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         $parties = array();
257 257
         $party_count = $party_list->rows;
258 258
 
259
-        for ( $i = 0; $i < $party_count; $i++ ) {
259
+        for ($i = 0; $i < $party_count; $i++) {
260 260
             $party = $party_list->field($i, 'party');
261 261
             if (
262 262
                 !$party
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -144,9 +144,15 @@
 block discarded – undo
144 144
             $num_votes = 0;
145 145
             for ( $j = 0; $j < $votes->rows(); $j++ ) {
146 146
                 $vote_dir = $votes->field($j, 'vote');
147
-                if ( $vote_dir == '' ) continue;
148
-                if ( $vote_dir == 'tellno' ) $vote_dir = 'no';
149
-                if ( $vote_dir == 'tellaye' ) $vote_dir = 'aye';
147
+                if ( $vote_dir == '' ) {
148
+                    continue;
149
+                }
150
+                if ( $vote_dir == 'tellno' ) {
151
+                    $vote_dir = 'no';
152
+                }
153
+                if ( $vote_dir == 'tellaye' ) {
154
+                    $vote_dir = 'aye';
155
+                }
150 156
 
151 157
                 $num_votes += $votes->field($j, 'num_votes');
152 158
                 $score += ($votes->field($j, 'num_votes') * $weights[$vote_dir]);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $both = 1;
220 220
         $agree = 10;
221 221
 
222
-        if ( stripos($vote, '3') !== FALSE ) {
222
+        if ( stripos($vote, '3') !== false ) {
223 223
             $agree = 50;
224 224
             $absent = 25;
225 225
             $both = 25;
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
             'both' => $both
231 231
         );
232 232
 
233
-        if ( stripos($vote, 'aye') !== FALSE ) {
233
+        if ( stripos($vote, 'aye') !== false ) {
234 234
             $scores['aye'] = $agree;
235 235
             $scores['no'] = 0;
236
-        } else if ( stripos($vote, 'no') !== FALSE ) {
236
+        } else if ( stripos($vote, 'no') !== false ) {
237 237
             $scores['no'] = $agree;
238 238
             $scores['aye'] = 0;
239 239
         } else {
Please login to merge, or discard this patch.
classes/Office.php 3 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
     public $source;
20 20
 
21 21
     /**
22
-    * To String
23
-    *
24
-    * Return the office title as a string.
25
-    *
26
-    * @return string The title of the office, or "Unnamed Office"
27
-    */
22
+     * To String
23
+     *
24
+     * Return the office title as a string.
25
+     *
26
+     * @return string The title of the office, or "Unnamed Office"
27
+     */
28 28
 
29 29
     public function __toString() {
30 30
         if (isset ($this->title)){
@@ -35,25 +35,25 @@  discard block
 block discarded – undo
35 35
     }
36 36
 
37 37
     /**
38
-    * Pretty Dates
39
-    *
40
-    * Return a string containing prettified dates of this office.
41
-    *
42
-    * 2004-05-28 and 2004-05-13 are the first dates for data scraped from the
43
-    * old selctee/privsec pages on parliament.uk (you can see this in
44
-    * cmpages/chgpages' privsec0001_2004-06-08.html and
45
-    * selctee0001_2004-06-08.html). So if the date is those dates for those two
46
-    * things, you don't want to display it because it's not a known start date,
47
-    * it could have been before that date. 2005-11-10 is because the PPS changes
48
-    * did not all happen on that date but the website did not update until that
49
-    * date so it outputs "before" in either from/to date in that case.
50
-    * 2009-01-16 is the last date before the page disappeared off parliament.uk
51
-    * entirely so that displays that fact that after then we don't know.
52
-    *
53
-    * @todo https://github.com/mysociety/theyworkforyou/issues/632
54
-    *
55
-    * @return string The dates of this office in a readable form.
56
-    */
38
+     * Pretty Dates
39
+     *
40
+     * Return a string containing prettified dates of this office.
41
+     *
42
+     * 2004-05-28 and 2004-05-13 are the first dates for data scraped from the
43
+     * old selctee/privsec pages on parliament.uk (you can see this in
44
+     * cmpages/chgpages' privsec0001_2004-06-08.html and
45
+     * selctee0001_2004-06-08.html). So if the date is those dates for those two
46
+     * things, you don't want to display it because it's not a known start date,
47
+     * it could have been before that date. 2005-11-10 is because the PPS changes
48
+     * did not all happen on that date but the website did not update until that
49
+     * date so it outputs "before" in either from/to date in that case.
50
+     * 2009-01-16 is the last date before the page disappeared off parliament.uk
51
+     * entirely so that displays that fact that after then we don't know.
52
+     *
53
+     * @todo https://github.com/mysociety/theyworkforyou/issues/632
54
+     *
55
+     * @return string The dates of this office in a readable form.
56
+     */
57 57
 
58 58
     public function pretty_dates() {
59 59
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     */
28 28
 
29 29
     public function __toString() {
30
-        if (isset ($this->title)){
30
+        if (isset ($this->title)) {
31 31
             return (string) $this->title;
32 32
         } else {
33 33
             return 'Unnamed Office';
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     public function pretty_dates() {
59 59
 
60 60
         if ($this->to_date == '9999-12-31') {
61
-            return 'since ' . format_date($this->from_date, SHORTDATEFORMAT);
61
+            return 'since '.format_date($this->from_date, SHORTDATEFORMAT);
62 62
         }
63 63
 
64 64
         $output = '';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             if ($this->source == 'chgpages/privsec' && $this->from_date == '2005-11-10') {
71 71
                 $output .= 'before ';
72 72
             }
73
-            $output .= format_date($this->from_date,SHORTDATEFORMAT) . ' ';
73
+            $output .= format_date($this->from_date, SHORTDATEFORMAT).' ';
74 74
         }
75 75
 
76 76
         $output .= 'to ';
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
         $output = '';
65 65
 
66 66
         if (
67
-            !($this->source == 'chgpages/selctee' && $this->from_date == '2004-05-28') AND
67
+            !($this->source == 'chgpages/selctee' && $this->from_date == '2004-05-28') and
68 68
             !($this->source == 'chgpages/privsec' && $this->from_date == '2004-05-13')
69 69
         ) {
70 70
             if ($this->source == 'chgpages/privsec' && $this->from_date == '2005-11-10') {
Please login to merge, or discard this patch.
classes/MiniSurvey.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace MySociety\TheyWorkForYou;
4 4
 
5
-require_once INCLUDESPATH . "../../commonlib/phplib/random.php";
6
-require_once INCLUDESPATH . "../../commonlib/phplib/auth.php";
5
+require_once INCLUDESPATH."../../commonlib/phplib/random.php";
6
+require_once INCLUDESPATH."../../commonlib/phplib/auth.php";
7 7
 
8 8
 class MiniSurvey {
9 9
 
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
         if ($hide_question) {
26 26
             $always_ask = 0;
27 27
             $show_survey_qn = $current_question;
28
-            setcookie('survey', $current_question, time()+60*60*24*365, '/');
28
+            setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/');
29 29
         } elseif ($has_answered_question == $current_question && !$always_ask) {
30 30
             $show_survey_qn = $current_question;
31
-            setcookie('survey', $current_question, time()+60*60*24*365, '/');
31
+            setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/');
32 32
         } elseif (isset($_COOKIE['survey'])) {
33 33
             $show_survey_qn = $_COOKIE['survey'];
34 34
         }
@@ -38,18 +38,18 @@  discard block
 block discarded – undo
38 38
 
39 39
             $page_url = '';
40 40
             $hide_url = '';
41
-            if ( in_array( $this_page, array('mp', 'peer', 'msp', 'mla', 'royal') ) ) {
41
+            if (in_array($this_page, array('mp', 'peer', 'msp', 'mla', 'royal'))) {
42 42
                 global $MEMBER;
43
-                if ( $MEMBER ) {
44
-                    $page_url = $MEMBER->url(true) . "?answered_survey=$current_question";
45
-                    $hide_url = $MEMBER->url() . "?hide_survey=$current_question";
43
+                if ($MEMBER) {
44
+                    $page_url = $MEMBER->url(true)."?answered_survey=$current_question";
45
+                    $hide_url = $MEMBER->url()."?hide_survey=$current_question";
46 46
                 }
47 47
             } else {
48 48
                 $URL = new \URL($this_page);
49
-                $URL->insert(array('answered_survey' => $current_question ));
50
-                $page_url = 'https://' . DOMAIN . $URL->generate();
49
+                $URL->insert(array('answered_survey' => $current_question));
50
+                $page_url = 'https://'.DOMAIN.$URL->generate();
51 51
                 $URL = new \URL($this_page);
52
-                $URL->insert(array('hide_survey' => $current_question ));
52
+                $URL->insert(array('hide_survey' => $current_question));
53 53
                 $hide_url = $URL->generate();
54 54
             }
55 55
 
Please login to merge, or discard this patch.
classes/Search/ParseArgs.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
         $searchstring = '';
14 14
 
15 15
         if ($advphrase = get_http_var('phrase')) {
16
-            $searchstring .= ' "' . $advphrase . '"';
16
+            $searchstring .= ' "'.$advphrase.'"';
17 17
         }
18 18
 
19 19
         if ($advexclude = get_http_var('exclude')) {
20
-            $searchstring .= ' -' . join(' -', preg_split('/\s+/', $advexclude));
20
+            $searchstring .= ' -'.join(' -', preg_split('/\s+/', $advexclude));
21 21
         }
22 22
 
23 23
         return $searchstring;
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
             $q = \MySociety\TheyWorkForYou\Utility\Search::searchMemberDbLookup($searchspeaker);
82 82
             $pids = array();
83 83
             $row_count = $q->rows();
84
-            for ($i=0; $i<$row_count; $i++) {
84
+            for ($i = 0; $i < $row_count; $i++) {
85 85
                 $pids[$q->field($i, 'person_id')] = true;
86 86
             }
87 87
             $pids = array_keys($pids);
88 88
             if (count($pids) > 0) {
89
-                $searchstring .= ' speaker:' . join(' speaker:', $pids);
89
+                $searchstring .= ' speaker:'.join(' speaker:', $pids);
90 90
             }
91 91
         }
92 92
 
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
         $searchstring = '';
98 98
 
99 99
         if ($advdept = get_http_var('department')) {
100
-            $searchstring .= ' department:' . preg_replace('#[^a-z]#i', '', $advdept);
100
+            $searchstring .= ' department:'.preg_replace('#[^a-z]#i', '', $advdept);
101 101
         }
102 102
 
103 103
         if ($advparty = get_http_var('party')) {
104
-            $searchstring .= ' party:' . join(' party:', explode(',', $advparty));
104
+            $searchstring .= ' party:'.join(' party:', explode(',', $advparty));
105 105
         }
106 106
 
107 107
         $advsection = get_http_var('section');
108 108
         if (!$advsection)
109 109
             $advsection = get_http_var('maj'); # Old URLs had this
110 110
         if (is_array($advsection)) {
111
-            $searchstring .= ' section:' . join(' section:', $advsection);
111
+            $searchstring .= ' section:'.join(' section:', $advsection);
112 112
         } elseif ($advsection) {
113 113
             $searchstring .= " section:$advsection";
114 114
         }
Please login to merge, or discard this patch.
Braces   +14 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,11 +28,17 @@  discard block
 block discarded – undo
28 28
 
29 29
         if (get_http_var('from') || get_http_var('to')) {
30 30
             $from = parse_date(get_http_var('from'));
31
-            if ($from) $from = $from['iso'];
32
-            else $from = '1935-10-01';
31
+            if ($from) {
32
+                $from = $from['iso'];
33
+            } else {
34
+                $from = '1935-10-01';
35
+            }
33 36
             $to = parse_date(get_http_var('to'));
34
-            if ($to) $to = $to['iso'];
35
-            else $to = date('Y-m-d');
37
+            if ($to) {
38
+                $to = $to['iso'];
39
+            } else {
40
+                $to = date('Y-m-d');
41
+            }
36 42
             $searchstring .= " $from..$to";
37 43
         }
38 44
 
@@ -105,8 +111,10 @@  discard block
 block discarded – undo
105 111
         }
106 112
 
107 113
         $advsection = get_http_var('section');
108
-        if (!$advsection)
109
-            $advsection = get_http_var('maj'); # Old URLs had this
114
+        if (!$advsection) {
115
+                    $advsection = get_http_var('maj');
116
+        }
117
+        # Old URLs had this
110 118
         if (is_array($advsection)) {
111 119
             $searchstring .= ' section:' . join(' section:', $advsection);
112 120
         } elseif ($advsection) {
Please login to merge, or discard this patch.
classes/Topic.php 3 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $this->db = new \ParlDB;
34 34
 
35 35
         if (is_null($data)) {
36
-          return;
36
+            return;
37 37
         }
38 38
 
39 39
         $this->id = $data['id'];
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
     private function _getContentIDs() {
126 126
         $q = $this->db->query(
127
-          "SELECT body, gid, ep.epobject_id FROM epobject ep
127
+            "SELECT body, gid, ep.epobject_id FROM epobject ep
128 128
            JOIN hansard h on ep.epobject_id = h.epobject_id
129 129
            JOIN topic_epobjects te on te.epobject_id = ep.epobject_id
130 130
            WHERE topic_key = :topic_key",
@@ -180,24 +180,24 @@  discard block
 block discarded – undo
180 180
 
181 181
     function addContent($gid) {
182 182
         $q = $this->db->query(
183
-          "SELECT epobject_id FROM hansard WHERE gid = :gid",
184
-          array(
183
+            "SELECT epobject_id FROM hansard WHERE gid = :gid",
184
+            array(
185 185
             ":gid" => $gid
186
-          )
186
+            )
187 187
         );
188 188
 
189 189
         if (!$q->success() || $q->rows == 0) {
190
-          return false;
190
+            return false;
191 191
         }
192 192
 
193 193
         $epobject_id = $q->field(0, 'epobject_id');
194 194
 
195 195
         $q = $this->db->query(
196
-          "INSERT INTO topic_epobjects (topic_key, epobject_id) VALUES (:topic, :ep_id)",
197
-          array(
196
+            "INSERT INTO topic_epobjects (topic_key, epobject_id) VALUES (:topic, :ep_id)",
197
+            array(
198 198
             ":topic" => $this->id,
199 199
             ":ep_id" => $epobject_id
200
-          )
200
+            )
201 201
         );
202 202
 
203 203
         return $q->success();
@@ -205,31 +205,31 @@  discard block
 block discarded – undo
205 205
 
206 206
     function deleteContent($id) {
207 207
         $q = $this->db->query(
208
-          "DELETE FROM topic_epobjects WHERE topic_key = :topic AND epobject_id = :ep_id",
209
-          array(
208
+            "DELETE FROM topic_epobjects WHERE topic_key = :topic AND epobject_id = :ep_id",
209
+            array(
210 210
             ":topic" => $this->id,
211 211
             ":ep_id" => $id
212
-          )
212
+            )
213 213
         );
214 214
 
215 215
         return $q->success();
216 216
     }
217 217
 
218 218
     function getPolicySets() {
219
-      $q = $this->db->query(
219
+        $q = $this->db->query(
220 220
         "SELECT policyset FROM topic_policysets WHERE topic_key = :key",
221 221
         array(
222
-          ':key' => $this->id
222
+            ':key' => $this->id
223 223
         )
224
-      );
224
+        );
225 225
 
226
-      $sets = array();
227
-      $count = $q->rows;
228
-      for ($i = 0; $i < $count; $i++) {
226
+        $sets = array();
227
+        $count = $q->rows;
228
+        for ($i = 0; $i < $count; $i++) {
229 229
         $sets[] = $q->field($i, 'policyset');
230
-      }
230
+        }
231 231
 
232
-      return $sets;
232
+        return $sets;
233 233
     }
234 234
 
235 235
     function addPolicySets($sets) {
@@ -259,20 +259,20 @@  discard block
 block discarded – undo
259 259
     }
260 260
 
261 261
     function getPolicies() {
262
-      $q = $this->db->query(
262
+        $q = $this->db->query(
263 263
         'SELECT policy_id FROM topic_policies WHERE topic_key = :key',
264 264
         array(
265
-          ':key' => $this->id
265
+            ':key' => $this->id
266 266
         )
267
-      );
267
+        );
268 268
 
269
-      $policies = array();
270
-      $count = $q->rows;
271
-      for ($i = 0; $i < $count; $i++) {
269
+        $policies = array();
270
+        $count = $q->rows;
271
+        for ($i = 0; $i < $count; $i++) {
272 272
         $policies[] = $q->field($i, 'policy_id');
273
-      }
273
+        }
274 274
 
275
-      return $policies;
275
+        return $policies;
276 276
     }
277 277
 
278 278
     function addPolicies($policies) {
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
     function save() {
318 318
         $q = $this->db->query(
319
-          "REPLACE INTO topics
319
+            "REPLACE INTO topics
320 320
           (id, title, slug, description, search_string, front_page, image)
321 321
           VALUES
322 322
           (:id, :title, :slug, :description, :search_string, :front_page, :image)",
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
     function sctitle() {
55 55
         $title = $this->title;
56
-        if (strpos($title, 'The ') === 0 ) {
56
+        if (strpos($title, 'The ') === 0) {
57 57
             $title = lcfirst($title);
58 58
         }
59 59
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
     function url() {
76 76
         $url = new \URL('topic');
77
-        return $url->generate() . $this->slug;
77
+        return $url->generate().$this->slug;
78 78
     }
79 79
 
80 80
     function image() {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     }
83 83
 
84 84
     function image_url() {
85
-        return "/topic/image.php?id=" . $this->slug();
85
+        return "/topic/image.php?id=".$this->slug();
86 86
     }
87 87
 
88 88
     function image_path() {
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
             );
243 243
         } else {
244 244
             foreach ($sets as $set) {
245
-                if ($set == '' ) {
245
+                if ($set == '') {
246 246
                     continue;
247 247
                 }
248 248
                 $q = $this->db->query(
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             );
286 286
         } else {
287 287
             foreach ($policies as $policy) {
288
-                if ($policy == '' ) {
288
+                if ($policy == '') {
289 289
                     continue;
290 290
                 }
291 291
                 $q = $this->db->query(
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      *
29 29
      */
30 30
 
31
-    public function __construct($data = NULL)
31
+    public function __construct($data = null)
32 32
     {
33 33
         $this->db = new \ParlDB;
34 34
 
Please login to merge, or discard this patch.
classes/SectionView/SpwransView.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
         $this_page = 'spwransfront';
22 22
         $data = array();
23 23
 
24
-        $args = array( 'months' => 1 );
24
+        $args = array('months' => 1);
25 25
         $WRANSLIST = new \SPWRANSLIST;
26 26
 
27 27
         $wrans = array();
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
     protected function getSearchSections() {
45 45
         return array(
46
-            array( 'section' => 'spwrans' )
46
+            array('section' => 'spwrans')
47 47
         );
48 48
     }
49 49
 
@@ -54,29 +54,29 @@  discard block
 block discarded – undo
54 54
         $SPWRANSLIST = new \SPWRANSLIST;
55 55
         $gid = $SPWRANSLIST->get_gid_from_spid($spid);
56 56
         if ($gid) {
57
-            if (preg_match('/uk\.org\.publicwhip\/spwa\/(\d{4}-\d\d-\d\d\.(.*))/',$gid,$m)) {
57
+            if (preg_match('/uk\.org\.publicwhip\/spwa\/(\d{4}-\d\d-\d\d\.(.*))/', $gid, $m)) {
58 58
                 $URL = new \URL('spwrans');
59 59
                 $URL->reset();
60
-                $URL->insert( array('id' => $m[1]) );
61
-                $fragment_identifier = '#g' . $m[2];
62
-                header('Location: ' . $URL->generate('none') . $fragment_identifier, true, 303);
60
+                $URL->insert(array('id' => $m[1]));
61
+                $fragment_identifier = '#g'.$m[2];
62
+                header('Location: '.$URL->generate('none').$fragment_identifier, true, 303);
63 63
                 exit;
64
-            } elseif (preg_match('/uk\.org\.publicwhip\/spor\/(\d{4}-\d\d-\d\d\.(.*))/',$gid,$m)) {
64
+            } elseif (preg_match('/uk\.org\.publicwhip\/spor\/(\d{4}-\d\d-\d\d\.(.*))/', $gid, $m)) {
65 65
                 $URL = new \URL('spdebates');
66 66
                 $URL->reset();
67
-                $URL->insert( array('id' => $m[1]) );
68
-                $fragment_identifier = '#g' . $m[2];
69
-                header('Location: ' . $URL->generate('none') . $fragment_identifier, true, 303);
67
+                $URL->insert(array('id' => $m[1]));
68
+                $fragment_identifier = '#g'.$m[2];
69
+                header('Location: '.$URL->generate('none').$fragment_identifier, true, 303);
70 70
                 exit;
71 71
             } else {
72
-                $PAGE->error_message ("Strange GID ($gid) for that Scottish Parliament ID.");
72
+                $PAGE->error_message("Strange GID ($gid) for that Scottish Parliament ID.");
73 73
             }
74 74
         }
75
-        $PAGE->error_message ("Couldn't match that Scottish Parliament ID to a GID.");
75
+        $PAGE->error_message("Couldn't match that Scottish Parliament ID to a GID.");
76 76
     }
77 77
 
78 78
     protected function get_question_mentions_html($row_data) {
79
-        if( count($row_data) == 0 ) {
79
+        if (count($row_data) == 0) {
80 80
             return '';
81 81
         }
82 82
         $result = '';
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
         $first_difference_output = TRUE;
86 86
         // Keep the references until after the history that's in a timeline:
87 87
         $references = array();
88
-        for( $i = 0; $i < $nrows; $i++ ) {
88
+        for ($i = 0; $i < $nrows; $i++) {
89 89
             $row = $row_data[$i];
90
-            if( ! $row["date"] ) {
90
+            if (!$row["date"]) {
91 91
                 // If this mention isn't associated with a date, the difference won't be interesting.
92 92
                 $last_date = NULL;
93 93
             }
94 94
             $description = '';
95 95
             if ($last_date && ($last_date != $row["date"])) {
96 96
                 // Calculate how long the gap was in days:
97
-                $daysdiff = (integer)((strtotime($row["date"]) - strtotime($last_date)) / 86400);
97
+                $daysdiff = (integer) ((strtotime($row["date"]) - strtotime($last_date)) / 86400);
98 98
                 $daysstring = ($daysdiff == 1) ? "day" : "days";
99 99
                 $further = "";
100
-                if( $first_difference_output ) {
100
+                if ($first_difference_output) {
101 101
                     $first_difference_output = FALSE;
102 102
                 } else {
103 103
                     $further = " a further";
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             $inner = "BUG: Unknown mention type $row[type]";
109 109
             $date = format_date($row['date'], SHORTDATEFORMAT);
110 110
             $url = $row['url'];
111
-            if ( strpos($url, 'business/businessBulletin') !== FALSE ) {
111
+            if (strpos($url, 'business/businessBulletin') !== FALSE) {
112 112
                 $url = str_replace('www.scottish', 'archive.scottish', $url);
113 113
             }
114 114
             switch ($row["type"]) {
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
                     $inner = "Mentioned in <a class=\"debate-speech__meta__link\" href=\"$url\">tabled written questions on $date</a>";
123 123
                     break;
124 124
                 case 4:
125
-                    if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['gid'],$m) ) {
125
+                    if (preg_match('/^uk.org.publicwhip\/spq\/(.*)$/', $row['gid'], $m)) {
126 126
                         $URL = new \URL("spwrans");
127
-                        $URL->insert( array('spid' => $m[1]) );
127
+                        $URL->insert(array('spid' => $m[1]));
128 128
                         $relative_url = $URL->generate("none");
129 129
                         $inner = "Given a <a class=\"debate-speech__meta__link\" href=\"$relative_url\">written answer on $date</a>";
130 130
                     }
@@ -133,25 +133,25 @@  discard block
 block discarded – undo
133 133
                     $inner = "Given a holding answer on $date";
134 134
                     break;
135 135
                 case 6:
136
-                    if( preg_match('/^uk.org.publicwhip\/spor\/(.*)$/',$row['mentioned_gid'],$m) ) {
136
+                    if (preg_match('/^uk.org.publicwhip\/spor\/(.*)$/', $row['mentioned_gid'], $m)) {
137 137
                         $URL = new \URL("spdebates");
138
-                        $URL->insert( array('id' => $m[1]) );
138
+                        $URL->insert(array('id' => $m[1]));
139 139
                         $relative_url = $URL->generate("none");
140 140
                         $inner = "<a href=\"$relative_url\">Asked in parliament on $date</a>";
141 141
                     }
142 142
                     break;
143 143
                 case 7:
144
-                    if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['mentioned_gid'],$m) ) {
144
+                    if (preg_match('/^uk.org.publicwhip\/spq\/(.*)$/', $row['mentioned_gid'], $m)) {
145 145
                         $referencing_spid = $m[1];
146 146
                         $URL = new \URL("spwrans");
147
-                        $URL->insert( array('spid' => $referencing_spid) );
147
+                        $URL->insert(array('spid' => $referencing_spid));
148 148
                         $relative_url = $URL->generate("none");
149 149
                         $inner = "Referenced in <a href=\"$relative_url\">question $referencing_spid</a>";
150 150
                         $reference = TRUE;
151 151
                     }
152 152
                     break;
153 153
             }
154
-            if( $reference ) {
154
+            if ($reference) {
155 155
                 $references[] = "\n<li>$inner.";
156 156
             } else {
157 157
                 $result .= "\n<li class=\"link-to-hansard\">$description$inner</span>";
Please login to merge, or discard this patch.
Upper-Lower-Casing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
         }
82 82
         $result = '';
83 83
         $nrows = count($row_data);
84
-        $last_date = NULL;
85
-        $first_difference_output = TRUE;
84
+        $last_date = null;
85
+        $first_difference_output = true;
86 86
         // Keep the references until after the history that's in a timeline:
87 87
         $references = array();
88 88
         for( $i = 0; $i < $nrows; $i++ ) {
89 89
             $row = $row_data[$i];
90 90
             if( ! $row["date"] ) {
91 91
                 // If this mention isn't associated with a date, the difference won't be interesting.
92
-                $last_date = NULL;
92
+                $last_date = null;
93 93
             }
94 94
             $description = '';
95 95
             if ($last_date && ($last_date != $row["date"])) {
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
                 $daysstring = ($daysdiff == 1) ? "day" : "days";
99 99
                 $further = "";
100 100
                 if( $first_difference_output ) {
101
-                    $first_difference_output = FALSE;
101
+                    $first_difference_output = false;
102 102
                 } else {
103 103
                     $further = " a further";
104 104
                 }
105 105
                 $description = "\n<span class=\"question-mention-gap\">After$further $daysdiff $daysstring,</span> ";
106 106
             }
107
-            $reference = FALSE;
107
+            $reference = false;
108 108
             $inner = "BUG: Unknown mention type $row[type]";
109 109
             $date = format_date($row['date'], SHORTDATEFORMAT);
110 110
             $url = $row['url'];
111
-            if ( strpos($url, 'business/businessBulletin') !== FALSE ) {
111
+            if ( strpos($url, 'business/businessBulletin') !== false ) {
112 112
                 $url = str_replace('www.scottish', 'archive.scottish', $url);
113 113
             }
114 114
             switch ($row["type"]) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                         $URL->insert( array('spid' => $referencing_spid) );
148 148
                         $relative_url = $URL->generate("none");
149 149
                         $inner = "Referenced in <a href=\"$relative_url\">question $referencing_spid</a>";
150
-                        $reference = TRUE;
150
+                        $reference = true;
151 151
                     }
152 152
                     break;
153 153
             }
Please login to merge, or discard this patch.
classes/SectionView/SpView.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 
25 25
     protected function getSearchSections() {
26 26
         return array(
27
-            array( 'section' => 'sp' )
27
+            array('section' => 'sp')
28 28
         );
29 29
     }
30 30
 }
Please login to merge, or discard this patch.
classes/SectionView/WransView.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
 
13 13
     protected function display_front() {
14 14
         global $DATA, $this_page;
15
-        if ( get_http_var('type') == 'wrans') {
15
+        if (get_http_var('type') == 'wrans') {
16 16
             return parent::display_front();
17 17
         }
18 18
 
19 19
         $data = array();
20 20
 
21
-        $args = array( 'months' => 1 );
21
+        $args = array('months' => 1);
22 22
         $WRANSLIST = new \WRANSLIST;
23 23
 
24 24
         $wrans = array();
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 
51 51
     protected function getSearchSections() {
52 52
         $sections = array(
53
-            array( 'section' => 'wrans', 'title' => 'Written Answers' ),
53
+            array('section' => 'wrans', 'title' => 'Written Answers'),
54 54
         );
55
-        if ( get_http_var('type') == '') {
56
-            $sections[] = array( 'section' => 'wms', 'title' => 'Written Ministerial Statements' );
55
+        if (get_http_var('type') == '') {
56
+            $sections[] = array('section' => 'wms', 'title' => 'Written Ministerial Statements');
57 57
         }
58 58
         return $sections;
59 59
     }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     # speech bar the first (assuming that's the question)
63 63
     private $votelinks_so_far = 0;
64 64
 
65
-    protected function generate_votes ($votes, $id, $gid) {
65
+    protected function generate_votes($votes, $id, $gid) {
66 66
         /*
67 67
         Returns HTML for the 'Does this answer the question?' links (wrans) in the sidebar.
68 68
         $votes = => array (
Please login to merge, or discard this patch.