Passed
Push — master ( 9b6994...2073b4 )
by Struan
17:27
created
classes/Search/Normal.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,9 @@
 block discarded – undo
141 141
 
142 142
     private function find_members() {
143 143
         $searchstring = trim(preg_replace('#-?[a-z]+:[a-z0-9]+#', '', $this->searchstring));
144
-        if (!$searchstring) return array();
144
+        if (!$searchstring) {
145
+            return array();
146
+        }
145 147
 
146 148
         $members = array();
147 149
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
         }
13 13
 
14 14
         $o = get_http_var('o');
15
-        $args = array (
15
+        $args = array(
16 16
             's' => $this->searchstring,
17 17
             'p' => $pagenum,
18 18
             'num' => get_http_var('num'),
19 19
             'pop' => get_http_var('pop'),
20
-            'o' => ($o=='d' || $o=='r' || $o=='o') ? $o : 'd',
20
+            'o' => ($o == 'd' || $o == 'r' || $o == 'o') ? $o : 'd',
21 21
         );
22 22
 
23 23
         return $args;
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
         }
56 56
 
57 57
         $sort_order = 'newest';
58
-        if ( $args['o'] == 'o' ) {
58
+        if ($args['o'] == 'o') {
59 59
             $sort_order = 'oldest';
60
-        } else if ( $args['o'] == 'r' ) {
60
+        } else if ($args['o'] == 'r') {
61 61
             $sort_order = 'relevance';
62 62
         }
63 63
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             return array('error' => $SEARCHENGINE->error);
74 74
         } else {
75 75
             $LIST = new \HANSARDLIST();
76
-            $data = $LIST->display('search', $args , 'none');
76
+            $data = $LIST->display('search', $args, 'none');
77 77
             $data['search_type'] = 'normal';
78 78
             $data['sort_order'] = $sort_order;
79 79
             $data['members'] = $members;
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
             return false;
94 94
         }
95 95
 
96
-        list ($constituencies, ) = \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery($searchterm);
96
+        list ($constituencies,) = \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery($searchterm);
97 97
 
98 98
         $constituency = "";
99
-        if (count($constituencies)==1) {
99
+        if (count($constituencies) == 1) {
100 100
             $constituency = $constituencies[0];
101 101
         }
102 102
 
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 
113 113
                 $MEMBER = new \MySociety\TheyWorkForYou\Member(array('constituency'=>$constituency, 'house' => 1));
114 114
                 $cons[] = $MEMBER;
115
-                if ( $MEMBER->current_member(1) ) {
115
+                if ($MEMBER->current_member(1)) {
116 116
                     $mp_types['mp']++;
117 117
                 } else {
118 118
                     $mp_types['former']++;
119 119
                 }
120
-            } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
120
+            } catch (\MySociety\TheyWorkForYou\MemberException $e) {
121 121
                 $cons = array();
122 122
             }
123 123
         } elseif (count($constituencies)) {
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
                 try {
126 126
                     $MEMBER = new \MySociety\TheyWorkForYou\Member(array('constituency'=>$constituency, 'house' => 1));
127 127
                     $cons[] = $MEMBER;
128
-                    if ( $MEMBER->current_member(1) ) {
128
+                    if ($MEMBER->current_member(1)) {
129 129
                         $mp_types['mp']++;
130 130
                     } else {
131 131
                         $mp_types['former']++;
132 132
                     }
133
-                } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
133
+                } catch (\MySociety\TheyWorkForYou\MemberException $e) {
134 134
                     continue;
135 135
                 }
136 136
             }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
         $q = \MySociety\TheyWorkForYou\Utility\Search::searchMemberDbLookup($searchstring);
149 149
         $row_count = $q->rows();
150
-        for ($n=0; $n<$row_count; $n++) {
150
+        for ($n = 0; $n < $row_count; $n++) {
151 151
             $members[] = $q->field($n, 'person_id');
152 152
         }
153 153
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         $q = $db->query("SELECT person FROM moffice WHERE position LIKE :pos ORDER BY from_date DESC, moffice_id",
156 156
             array('pos' => "%$searchstring%"));
157 157
         $row_count = $q->rows();
158
-        for ($n=0; $n<$row_count; $n++) {
158
+        for ($n = 0; $n < $row_count; $n++) {
159 159
             $members[] = $q->field($n, 'person');
160 160
         }
161 161
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
             $link = array(
204 204
                 'url' => $url->generate(),
205 205
                 'page' => $n,
206
-                'current' => ( $n == $data['page'] )
206
+                'current' => ($n == $data['page'])
207 207
             );
208 208
 
209 209
             $links[] = $link;
@@ -244,27 +244,27 @@  discard block
 block discarded – undo
244 244
             $numlinks = $this->generate_pagination_links($data, $URL, $firstpage, $lastpage);
245 245
 
246 246
             $pagelinks['nums'] = $numlinks;
247
-            $pagelinks['first_result'] = $page == 1 ? 1 : ( ( $page - 1 ) * $results_per_page ) + 1;
248
-            $pagelinks['last_result'] = $page == $numpages ? $total_results : $pagelinks['first_result'] + ( $results_per_page - 1 );
247
+            $pagelinks['first_result'] = $page == 1 ? 1 : (($page - 1) * $results_per_page) + 1;
248
+            $pagelinks['last_result'] = $page == $numpages ? $total_results : $pagelinks['first_result'] + ($results_per_page - 1);
249 249
 
250
-            if ( $page != 1 ) {
250
+            if ($page != 1) {
251 251
                 $prev_page = $page - 1;
252
-                $URL->insert(array( 'p' => $prev_page ) );
252
+                $URL->insert(array('p' => $prev_page));
253 253
                 $pagelinks['prev'] = array(
254 254
                     'url' => $URL->generate()
255 255
                 );
256
-                $URL->insert(array( 'p' => 1 ) );
256
+                $URL->insert(array('p' => 1));
257 257
                 $pagelinks['firstpage'] = array(
258 258
                     'url' => $URL->generate()
259 259
                 );
260 260
             }
261 261
             if ($page != $numpages) {
262 262
                 $next_page = $page + 1;
263
-                $URL->insert(array( 'p' => $next_page ) );
263
+                $URL->insert(array('p' => $next_page));
264 264
                 $pagelinks['next'] = array(
265 265
                     'url' => $URL->generate()
266 266
                 );
267
-                $URL->insert(array( 'p' => $numpages ) );
267
+                $URL->insert(array('p' => $numpages));
268 268
                 $pagelinks['lastpage'] = array(
269 269
                     'url' => $URL->generate()
270 270
                 );
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
         $links['rss'] = $DATA->page_metadata($this_page, 'rss');
282 282
 
283 283
         if ($SEARCHENGINE) {
284
-            $links['email'] = '/alert/?' . ($this->searchstring ? 'alertsearch='.urlencode($this->searchstring) : '');
284
+            $links['email'] = '/alert/?' . ($this->searchstring ? 'alertsearch=' . urlencode($this->searchstring) : '');
285 285
             $links['email_desc'] = $SEARCHENGINE->query_description_long();
286 286
         }
287 287
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             $search_engine = new \SEARCHENGINE($filter_ss);
296 296
             $links['email_section'] = $links['email'];
297 297
             $links['email_desc_section'] = $links['email_desc'];
298
-            $links['email'] = '/alert/?' . ($filter_ss ? 'alertsearch='.urlencode($filter_ss) : '');
298
+            $links['email'] = '/alert/?' . ($filter_ss ? 'alertsearch=' . urlencode($filter_ss) : '');
299 299
             $links['email_desc'] = $search_engine->query_description_long();
300 300
         }
301 301
 
Please login to merge, or discard this patch.
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.
classes/SectionView/DebatesView.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@  discard block
 block discarded – undo
66 66
     private $first_gid = '';
67 67
 
68 68
     protected function get_video_html($row, $heading_hpos, $speeches) {
69
-        if (!$this->first_gid) $this->first_gid = $row['gid'];
69
+        if (!$this->first_gid) {
70
+            $this->first_gid = $row['gid'];
71
+        }
70 72
 
71 73
         $video_content = '';
72 74
         if (!$this->first_video_displayed && $row['video_status']&4 && !($row['video_status']&8)) {
@@ -97,7 +99,9 @@  discard block
 block discarded – undo
97 99
         $adate = $vq->field(0, 'adate');
98 100
         $time = $vq->field(0, 'atime');
99 101
         $videodb = \MySociety\TheyWorkForYou\Utility\Video::dbConnect();
100
-        if (!$videodb) return '';
102
+        if (!$videodb) {
103
+            return '';
104
+        }
101 105
         $video = \MySociety\TheyWorkForYou\Utility\Video::fromTimestamp($videodb, $adate, $time);
102 106
         $start = $video['offset'];
103 107
         $out = '';
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 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
 
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
         if (!$this->first_gid) $this->first_gid = $row['gid'];
70 70
 
71 71
         $video_content = '';
72
-        if (!$this->first_video_displayed && $row['video_status']&4 && !($row['video_status']&8)) {
72
+        if (!$this->first_video_displayed && $row['video_status'] & 4 && !($row['video_status'] & 8)) {
73 73
             $video_content = $this->video_sidebar($row, $heading_hpos, $speeches);
74 74
             $this->first_video_displayed = true;
75 75
         }
76
-        if (!$video_content && !$this->first_speech_displayed && $row['video_status']&1 && !($row['video_status']&12)) {
76
+        if (!$video_content && !$this->first_speech_displayed && $row['video_status'] & 1 && !($row['video_status'] & 12)) {
77 77
             $video_content = $this->video_advert($row);
78 78
             $this->first_speech_displayed = true;
79 79
         }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         if ($count > 1) {
105 105
             $out .= '<div class="debate__video" id="video_wrap"><div>';
106 106
             if ($row['gid'] != $this->first_gid) {
107
-                $out .= '<p class="video-instructions">This video starts around ' . ($row['hpos']-$heading_hpos) . ' speeches in (<a href="#g' . gid_to_anchor($row['gid']) . '">move there in text</a>)</p>';
107
+                $out .= '<p class="video-instructions">This video starts around ' . ($row['hpos'] - $heading_hpos) . ' speeches in (<a href="#g' . gid_to_anchor($row['gid']) . '">move there in text</a>)</p>';
108 108
             }
109 109
         }
110 110
         $out .= \MySociety\TheyWorkForYou\Utility\Video::object($video['id'], $start, "$gid_type/$row[gid]");
Please login to merge, or discard this patch.
classes/Utility/Video.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
     }
20 20
 
21 21
     public static function fromTimestamp($videodb, $date, $time) {
22
-        if (!$videodb) return null;
22
+        if (!$videodb) {
23
+            return null;
24
+        }
23 25
         date_default_timezone_set('Europe/London');
24 26
         $epoch = strtotime("$date $time");
25 27
         $timestamp = gmdate('c', $epoch);
@@ -38,9 +40,13 @@  discard block
 block discarded – undo
38 40
 
39 41
     public static function object($video_id, $start, $gid, $stamping = '', $pid = 0) {
40 42
         $flashvars = "gid=$gid&amp;file=$video_id&amp;start=$start";
41
-        if ($stamping) $flashvars .= '&amp;stamping=1';
42
-        if ($pid) $flashvars .= '&amp;pid=' . $pid;
43
-/*
43
+        if ($stamping) {
44
+            $flashvars .= '&amp;stamping=1';
45
+        }
46
+        if ($pid) {
47
+            $flashvars .= '&amp;pid=' . $pid;
48
+        }
49
+        /*
44 50
 <object width='360' height='300'
45 51
     classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
46 52
     codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
     public static function dbConnect() {
15
-        $connstr = 'host='.OPTION_BBC_DB_HOST.' port='.OPTION_BBC_DB_PORT.' dbname='.OPTION_BBC_DB_NAME.' user='.OPTION_BBC_DB_USER.' password='.OPTION_BBC_DB_PASS;
15
+        $connstr = 'host=' . OPTION_BBC_DB_HOST . ' port=' . OPTION_BBC_DB_PORT . ' dbname=' . OPTION_BBC_DB_NAME . ' user=' . OPTION_BBC_DB_USER . ' password=' . OPTION_BBC_DB_PASS;
16 16
         $videodb = pg_connect($connstr);
17 17
 
18 18
         return $videodb;
Please login to merge, or discard this patch.
classes/Utility/Constituencies.php 2 patches
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,13 +31,15 @@
 block discarded – undo
31 31
         $q1 = $db->query($query, array(
32 32
             ':name' => $name
33 33
             ));
34
-        if ($q1->rows <= 0)
35
-            return false;
34
+        if ($q1->rows <= 0) {
35
+                    return false;
36
+        }
36 37
 
37 38
         $query = "select name from constituency where main_name and cons_id = '".$q1->field(0,'cons_id')."'";
38 39
         $q2 = $db->query($query);
39
-        if ($q2->rows <= 0)
40
-            return false;
40
+        if ($q2->rows <= 0) {
41
+                    return false;
42
+        }
41 43
 
42 44
         return $q2->field(0, "name");
43 45
     }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
         if ($q1->rows <= 0)
35 35
             return false;
36 36
 
37
-        $query = "select name from constituency where main_name and cons_id = '".$q1->field(0,'cons_id')."'";
37
+        $query = "select name from constituency where main_name and cons_id = '" . $q1->field(0, 'cons_id') . "'";
38 38
         $q2 = $db->query($query);
39 39
         if ($q2->rows <= 0)
40 40
             return false;
Please login to merge, or discard this patch.
classes/Utility/Search.php 2 patches
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
             return $data;
30 30
         }
31
-        if (count($gids) == 5000)
32
-            $data['limit_reached'] = true;
31
+        if (count($gids) == 5000) {
32
+                    $data['limit_reached'] = true;
33
+        }
33 34
 
34 35
         # Fetch all the speakers of the results, count them up and get min/max date usage
35 36
         $speaker_count = array();
@@ -46,8 +47,12 @@  discard block
 block discarded – undo
46 47
                 $mindate[$person_id] = '9999-12-31';
47 48
             }
48 49
             $speaker_count[$person_id]++;
49
-            if ($hdate < $mindate[$person_id]) $mindate[$person_id] = $hdate;
50
-            if ($hdate > $maxdate[$person_id]) $maxdate[$person_id] = $hdate;
50
+            if ($hdate < $mindate[$person_id]) {
51
+                $mindate[$person_id] = $hdate;
52
+            }
53
+            if ($hdate > $maxdate[$person_id]) {
54
+                $maxdate[$person_id] = $hdate;
55
+            }
51 56
         }
52 57
 
53 58
         # Fetch details of all the speakers
@@ -81,8 +86,9 @@  discard block
 block discarded – undo
81 86
                 $dept = $q->field($n, 'dept');
82 87
                 $posn = $q->field($n, 'position');
83 88
                 $moffice_id = $q->field($n, 'moffice_id');
84
-                if ($dept && $q->field($n, 'to_date') == '9999-12-31')
85
-                    $speakers[$pid]['office'][$moffice_id] = prettify_office($posn, $dept);
89
+                if ($dept && $q->field($n, 'to_date') == '9999-12-31') {
90
+                                    $speakers[$pid]['office'][$moffice_id] = prettify_office($posn, $dept);
91
+                }
86 92
                 if (!isset($speakers[$pid]['name'])) {
87 93
                     $speakers[$pid]['name'] = $full_name . ($house==1?' MP':'');
88 94
                 }
@@ -140,7 +146,9 @@  discard block
 block discarded – undo
140 146
      */
141 147
 
142 148
     public static function searchMemberDbLookup($searchstring, $current_only=false) {
143
-        if (!$searchstring) return false;
149
+        if (!$searchstring) {
150
+            return false;
151
+        }
144 152
         $searchwords = explode(' ', $searchstring, 3);
145 153
         $params = array();
146 154
         if (count($searchwords) == 1) {
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $gids = join('","', $gids);
37 37
         $db = new \ParlDB;
38 38
         $q = $db->query('SELECT person_id,hdate FROM hansard WHERE gid IN ("' . $gids . '")');
39
-        for ($n=0; $n<$q->rows(); $n++) {
39
+        for ($n = 0; $n < $q->rows(); $n++) {
40 40
             $person_id = $q->field($n, 'person_id');
41 41
             $hdate = $q->field($n, 'hdate');
42 42
             if (!isset($speaker_count[$person_id])) {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                             WHERE member.person_id IN (' . $person_ids . ')
63 63
                             ' . ($house ? " AND house=$house" : '') . '
64 64
                             ORDER BY left_house DESC');
65
-            for ($n=0; $n<$q->rows(); $n++) {
65
+            for ($n = 0; $n < $q->rows(); $n++) {
66 66
                 $mid = $q->field($n, 'member_id');
67 67
                 if (!isset($pids[$mid])) {
68 68
                     $title = $q->field($n, 'title');
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
                 if ($dept && $q->field($n, 'to_date') == '9999-12-31')
84 84
                     $speakers[$pid]['office'][$moffice_id] = prettify_office($posn, $dept);
85 85
                 if (!isset($speakers[$pid]['name'])) {
86
-                    $speakers[$pid]['name'] = $full_name . ($house==1?' MP':'');
86
+                    $speakers[$pid]['name'] = $full_name . ($house == 1 ? ' MP' : '');
87 87
                 }
88
-                if ( !isset($speakers[$pid]['party']) && $party ) {
88
+                if (!isset($speakers[$pid]['party']) && $party) {
89 89
                     $speakers[$pid]['party'] = $party;
90 90
                 }
91 91
             }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * Return query result from looking for MPs
139 139
      */
140 140
 
141
-    public static function searchMemberDbLookup($searchstring, $current_only=false) {
141
+    public static function searchMemberDbLookup($searchstring, $current_only = false) {
142 142
         if (!$searchstring) return false;
143 143
         $searchwords = explode(' ', $searchstring, 3);
144 144
         $params = array();
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
             // And here we're assuming the user's put the names in the right order.
151 151
             $params[':like_0'] = '%' . $searchwords[0] . '%';
152 152
             $params[':like_1'] = '%' . $searchwords[1] . '%';
153
-            $params[':like_0_and_1'] = '%' . $searchwords[0] . ' '. $searchwords[1] . '%';
154
-            $params[':like_0_and_1_hyphen'] = '%' . $searchwords[0] . '-'. $searchwords[1] . '%';
153
+            $params[':like_0_and_1'] = '%' . $searchwords[0] . ' ' . $searchwords[1] . '%';
154
+            $params[':like_0_and_1_hyphen'] = '%' . $searchwords[0] . '-' . $searchwords[1] . '%';
155 155
             $where = "(given_name LIKE :like_0 AND family_name LIKE :like_1)";
156 156
             $where .= " OR (given_name LIKE :like_1 AND family_name LIKE :like_0)";
157 157
             $where .= " OR (title LIKE :like_0 AND family_name LIKE :like_1)";
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
             $params[':like_0'] = '%' . $searchwords[0] . '%';
167 167
             $params[':like_1'] = '%' . $searchwords[1] . '%';
168 168
             $params[':like_2'] = '%' . $searchwords[2] . '%';
169
-            $params[':like_0_and_1'] = '%' . $searchwords[0] . ' '. $searchwords[1] . '%';
170
-            $params[':like_1_and_2'] = '%' . $searchwords[1] . ' '. $searchwords[2] . '%';
171
-            $params[':like_1_and_2_hyphen'] = '%' . $searchwords[1] . '-'. $searchwords[2] . '%';
169
+            $params[':like_0_and_1'] = '%' . $searchwords[0] . ' ' . $searchwords[1] . '%';
170
+            $params[':like_1_and_2'] = '%' . $searchwords[1] . ' ' . $searchwords[2] . '%';
171
+            $params[':like_1_and_2_hyphen'] = '%' . $searchwords[1] . '-' . $searchwords[2] . '%';
172 172
             $where = "(given_name LIKE :like_0_and_1 AND family_name LIKE :like_2)";
173 173
             $where .= " OR (given_name LIKE :like_0 AND family_name LIKE :like_1_and_2)";
174 174
             $where .= " OR (given_name LIKE :like_0 AND family_name LIKE :like_1_and_2_hyphen)";
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
         return $q;
184 184
     }
185 185
 
186
-    public static function searchMemberDbLookupWithNames($searchstring, $current_only=false) {
186
+    public static function searchMemberDbLookupWithNames($searchstring, $current_only = false) {
187 187
         $q = self::searchMemberDbLookup($searchstring, $current_only);
188 188
 
189
-        if ( !$q->rows ) {
189
+        if (!$q->rows) {
190 190
             return $q;
191 191
         }
192 192
 
193 193
         $person_ids = array();
194
-        for ($i=0; $i<$q->rows(); ++$i) {
194
+        for ($i = 0; $i < $q->rows(); ++$i) {
195 195
             $pid = $q->field($i, 'person_id');
196 196
             $person_ids[$pid] = 1;
197 197
         }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
             // Looks like a postcode - can we find the constituency?
239 239
             $constituency = Postcode::postcodeToConstituency($searchterm);
240 240
             if ($constituency) {
241
-                return array( array($constituency), true );
241
+                return array(array($constituency), true);
242 242
             }
243 243
         }
244 244
 
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
         $q = $db->query($query, array(':try' => '%' . $try . '%'));
253 253
 
254 254
         $constituencies = array();
255
-        for ($n=0; $n<$q->rows(); $n++) {
255
+        for ($n = 0; $n < $q->rows(); $n++) {
256 256
             $constituencies[] = $q->field($n, 'name');
257 257
         }
258 258
 
259
-        return array( $constituencies, false );
259
+        return array($constituencies, false);
260 260
     }
261 261
 
262 262
     /**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         $speakers = [];
273 273
 
274 274
         foreach ($criteria as $c) {
275
-            if (preg_match('#^speaker:(\d+)#',$c,$m)) {
275
+            if (preg_match('#^speaker:(\d+)#', $c, $m)) {
276 276
                 $MEMBER = new \MEMBER(array('person_id'=>$m[1]));
277 277
                 $speakers[$m[1]] = $MEMBER->full_name();
278 278
             }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
     public static function speakerIDsToNames($searchstring) {
292 292
         $speakers = self::speakerNamesForIDs($searchstring);
293 293
 
294
-        foreach ( $speakers as $id => $name ) {
294
+        foreach ($speakers as $id => $name) {
295 295
             $searchstring = str_replace('speaker:' . $id, "speaker:$name", $searchstring);
296 296
         }
297 297
 
Please login to merge, or discard this patch.
classes/Topics.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
       $topics = array();
31 31
       $count = $q->rows();
32 32
 
33
-      for ($i = 0; $i < $count; $i++ ) {
33
+      for ($i = 0; $i < $count; $i++) {
34 34
           $topic = $q->row($i);
35 35
           $topics[$topic['slug']] = new Topic($topic);
36 36
       }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
       $topics = array();
58 58
       $count = $q->rows();
59 59
 
60
-      for ($i = 0; $i < $count; $i++ ) {
60
+      for ($i = 0; $i < $count; $i++) {
61 61
           $topic = $q->row($i);
62 62
           $topics[$topic['slug']] = new Topic($topic);
63 63
       }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
           return new Topic($q->row(0));
47 47
       }
48 48
 
49
-      return NULL;
49
+      return null;
50 50
     }
51 51
 
52 52
     public function getFrontPageTopics() {
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -25,58 +25,58 @@
 block discarded – undo
25 25
     }
26 26
 
27 27
     public function getTopics() {
28
-      $q = $this->db->query("SELECT id, slug, title, description, search_string, front_page, image FROM topics");
28
+        $q = $this->db->query("SELECT id, slug, title, description, search_string, front_page, image FROM topics");
29 29
 
30
-      $topics = array();
31
-      $count = $q->rows();
30
+        $topics = array();
31
+        $count = $q->rows();
32 32
 
33
-      for ($i = 0; $i < $count; $i++ ) {
34
-          $topic = $q->row($i);
35
-          $topics[$topic['slug']] = new Topic($topic);
36
-      }
37
-      return $topics;
33
+        for ($i = 0; $i < $count; $i++ ) {
34
+            $topic = $q->row($i);
35
+            $topics[$topic['slug']] = new Topic($topic);
36
+        }
37
+        return $topics;
38 38
     }
39 39
 
40 40
     public function getTopic($topic_name) {
41
-      $q = $this->db->query(
42
-          "SELECT id, slug, title, description, search_string, front_page, image FROM topics WHERE slug = :slug",
43
-          array(':slug' => $topic_name)
44
-      );
45
-      if ($q->rows) {
46
-          return new Topic($q->row(0));
47
-      }
48
-
49
-      return NULL;
41
+        $q = $this->db->query(
42
+            "SELECT id, slug, title, description, search_string, front_page, image FROM topics WHERE slug = :slug",
43
+            array(':slug' => $topic_name)
44
+        );
45
+        if ($q->rows) {
46
+            return new Topic($q->row(0));
47
+        }
48
+
49
+        return NULL;
50 50
     }
51 51
 
52 52
     public function getFrontPageTopics() {
53
-      $q = $this->db->query(
54
-          "SELECT id, slug, title, description, search_string, front_page, image FROM topics WHERE front_page = TRUE"
55
-      );
56
-
57
-      $topics = array();
58
-      $count = $q->rows();
59
-
60
-      for ($i = 0; $i < $count; $i++ ) {
61
-          $topic = $q->row($i);
62
-          $topics[$topic['slug']] = new Topic($topic);
63
-      }
64
-      return $topics;
53
+        $q = $this->db->query(
54
+            "SELECT id, slug, title, description, search_string, front_page, image FROM topics WHERE front_page = TRUE"
55
+        );
56
+
57
+        $topics = array();
58
+        $count = $q->rows();
59
+
60
+        for ($i = 0; $i < $count; $i++ ) {
61
+            $topic = $q->row($i);
62
+            $topics[$topic['slug']] = new Topic($topic);
63
+        }
64
+        return $topics;
65 65
     }
66 66
 
67 67
     public function updateFrontPageTopics($topics) {
68 68
         // PDO doesn't cope with arrays so we have to do this by hand :|
69 69
         $quoted = array();
70 70
         if ($topics) {
71
-          foreach ($topics as $topic) {
72
-              $quoted[] = $this->db->quote($topic);
73
-          }
74
-          $topics_str = implode(',', $quoted);
71
+            foreach ($topics as $topic) {
72
+                $quoted[] = $this->db->quote($topic);
73
+            }
74
+            $topics_str = implode(',', $quoted);
75 75
 
76
-          $this->db->query("UPDATE topics SET front_page = TRUE WHERE slug IN ($topics_str)");
77
-          $this->db->query("UPDATE topics SET front_page = FALSE WHERE slug NOT IN ($topics_str)");
76
+            $this->db->query("UPDATE topics SET front_page = TRUE WHERE slug IN ($topics_str)");
77
+            $this->db->query("UPDATE topics SET front_page = FALSE WHERE slug NOT IN ($topics_str)");
78 78
         } else {
79
-          $this->db->query("UPDATE topics SET front_page = FALSE");
79
+            $this->db->query("UPDATE topics SET front_page = FALSE");
80 80
         }
81 81
 
82 82
         return true;
Please login to merge, or discard this patch.
classes/Policies.php 4 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     }
310 310
 
311 311
     public function getSetDescriptions() {
312
-      return $this->set_descs;
312
+        return $this->set_descs;
313 313
     }
314 314
 
315 315
     /**
@@ -397,18 +397,18 @@  discard block
 block discarded – undo
397 397
     }
398 398
 
399 399
     public function limitToArray($policies) {
400
-          $out = array();
401
-          // Reassemble the new policies list based on the set.
402
-          foreach ($policies as $policy) {
403
-              if (isset($this->policies[$policy])) {
404
-                  $out[$policy] = $this->policies[$policy];
405
-              }
406
-          }
407
-
408
-          $new_policies = new self();
409
-          $new_policies->policies = $out;
410
-
411
-          return $new_policies;
400
+            $out = array();
401
+            // Reassemble the new policies list based on the set.
402
+            foreach ($policies as $policy) {
403
+                if (isset($this->policies[$policy])) {
404
+                    $out[$policy] = $this->policies[$policy];
405
+                }
406
+            }
407
+
408
+            $new_policies = new self();
409
+            $new_policies->policies = $out;
410
+
411
+            return $new_policies;
412 412
     }
413 413
 
414 414
     public function getPolicyDetails($policyID) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -293,7 +293,7 @@
 block discarded – undo
293 293
 
294 294
     private $policy_id;
295 295
 
296
-    public function __construct($policy_id = NULL) {
296
+    public function __construct($policy_id = null) {
297 297
         $this->db = new \ParlDB;
298 298
 
299 299
         if ( $policy_id ) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
     public function __construct($policy_id = NULL) {
297 297
         $this->db = new \ParlDB;
298 298
 
299
-        if ( $policy_id ) {
299
+        if ($policy_id) {
300 300
             $this->policy_id = $policy_id;
301 301
             $this->policies = array(
302 302
                 $policy_id => $this->policies[$policy_id]
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
                     // want to complain here if we're looking for that policy and
381 381
                     // it does not exist. Otherwise, if the single policy isn't in
382 382
                     // the set we want to return an empty set
383
-                    if ( !isset($this->policy_id) || $set_policy == $this->policy_id ) {
384
-                        throw new \Exception ('Policy ' . $set_policy . ' in set "' . $set . '" does not exist.');
383
+                    if (!isset($this->policy_id) || $set_policy == $this->policy_id) {
384
+                        throw new \Exception('Policy ' . $set_policy . ' in set "' . $set . '" does not exist.');
385 385
                     }
386 386
                 }
387 387
             }
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
             return $new_policies;
393 393
 
394 394
         } else {
395
-            throw new \Exception ('Policy set "' . $set . '" does not exist.');
395
+            throw new \Exception('Policy set "' . $set . '" does not exist.');
396 396
         }
397 397
     }
398 398
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 
434 434
         $image = $q->field(0, 'image');
435 435
 
436
-        if ( $image && file_exists(BASEDIR . '/' . $image)) {
436
+        if ($image && file_exists(BASEDIR . '/' . $image)) {
437 437
             $props['image'] = $image;
438 438
             $props['image_license'] = $q->field(0, 'image_license');
439 439
             $props['image_attribution'] = $q->field(0, 'image_attrib');
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -366,14 +366,12 @@
 block discarded – undo
366 366
     public function limitToSet($set) {
367 367
 
368 368
         // Sanity check the set exists
369
-        if (isset($this->sets[$set]))
370
-        {
369
+        if (isset($this->sets[$set])) {
371 370
             $out = array();
372 371
             // Reassemble the new policies list based on the set.
373 372
             foreach ($this->sets[$set] as $set_policy)
374 373
             {
375
-                if (isset($this->policies[$set_policy]))
376
-                {
374
+                if (isset($this->policies[$set_policy])) {
377 375
                     $out[$set_policy] = $this->policies[$set_policy];
378 376
                 } else {
379 377
                     // if we've limited the policies to a single one then we only
Please login to merge, or discard this patch.