Completed
Pull Request — master (#1322)
by Nick
07:54 queued 02:46
created
classes/SectionView/DebatesView.php 2 patches
Spacing   +11 added lines, -11 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,11 +104,11 @@  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]");
111
-        $flashvars = 'gid=' . "$gid_type/$row[gid]" . '&amp;file=' . $video['id'] . '&amp;start=' . $start;
111
+        $flashvars = 'gid='."$gid_type/$row[gid]".'&amp;file='.$video['id'].'&amp;start='.$start;
112 112
         $out .= "<strong>Embed this video</strong><p class='video-instructions'>Copy and paste this code on your website</p><input readonly onclick='this.focus();this.select();' type='text' name='embed' size='40' value=\"<embed src='https://www.theyworkforyou.com/video/parlvid.swf' width='320' height='230' allowfullscreen='true' allowscriptaccess='always' flashvars='$flashvars'></embed>\">";
113 113
         if ($count > 1) {
114 114
             $out .= '<p class="hide-video"><a href="" onclick="return showVideo();">Hide</a></p>';
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     <div style="border:solid 1px #9999ff; background-color: #ccccff; padding: 4px; text-align: center;
126 126
     background-image: url(\'/images/video-x-generic.png\'); background-repeat: no-repeat; padding-left: 40px;
127 127
     background-position: 0 2px; margin-bottom: 1em;">
128
-    Help us <a href="/video/?from=debate&amp;gid=' . $gid_type . '/' . $row['gid'] . '">match the video for this speech</a>
128
+    Help us <a href="/video/?from=debate&amp;gid=' . $gid_type.'/'.$row['gid'].'">match the video for this speech</a>
129 129
     to get the right video playing here
130 130
     </div>
131 131
     ';
Please login to merge, or discard this patch.
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.
classes/SectionView/NiView.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
     protected function getSearchSections() {
34 34
         return array(
35
-            array( 'section' => 'ni' )
35
+            array('section' => 'ni')
36 36
         );
37 37
     }
38 38
 
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
 
53 53
         $debates = $DEBATELIST->display('recent_debates', array('days' => 30, 'num' => 6), 'none');
54 54
         $MOREURL = new \URL('nidebatesfront');
55
-        $MOREURL->insert( array( 'more' => 1 ) );
55
+        $MOREURL->insert(array('more' => 1));
56 56
 
57 57
         // this makes sure that we don't repeat this debate in the list below
58 58
         $random_debate = NULL;
59
-        if ( isset($debates['data']) && count($debates['data']) ) {
59
+        if (isset($debates['data']) && count($debates['data'])) {
60 60
             $random_debate = $debates['data'][0];
61 61
         }
62 62
 
63 63
         $recent = array();
64
-        if ( isset($debates['data']) && count($debates['data']) ) {
64
+        if (isset($debates['data']) && count($debates['data'])) {
65 65
             // at the start of a session there may be less than 6
66 66
             // debates
67 67
             $max = 6;
68
-            if ( count($debates['data']) < 6 ) {
68
+            if (count($debates['data']) < 6) {
69 69
                 $max = count($debates['data']);
70 70
             }
71
-            for ( $i = 1; $i < $max; $i++ ) {
71
+            for ($i = 1; $i < $max; $i++) {
72 72
                 $debate = $debates['data'][$i];
73 73
                 $debate['desc'] = "Northern Ireland Assembly debates";
74 74
                 $debate['more_url'] = $MOREURL->generate();
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         }
78 78
 
79 79
         $featured = array();
80
-        if ( $random_debate ) {
80
+        if ($random_debate) {
81 81
             $featured = $random_debate;
82 82
             $featured['more_url'] = $MOREURL->generate();
83 83
             $featured['desc'] = 'Northern Ireland Assembly debate';
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         }
87 87
 
88 88
         $data['featured'] = $featured;
89
-        $data['debates'] = array( 'recent' => $recent);
89
+        $data['debates'] = array('recent' => $recent);
90 90
 
91 91
         $data['regional'] = $this->getMLAList();
92 92
         $data['template'] = 'ni/index';
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $data = array();
44 44
         $urls = array();
45 45
 
46
-        $data['popular_searches'] = NULL;
46
+        $data['popular_searches'] = null;
47 47
 
48 48
 
49 49
         $data['urls'] = $this->getURLs($data);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $MOREURL->insert( array( 'more' => 1 ) );
56 56
 
57 57
         // this makes sure that we don't repeat this debate in the list below
58
-        $random_debate = NULL;
58
+        $random_debate = null;
59 59
         if ( isset($debates['data']) && count($debates['data']) ) {
60 60
             $random_debate = $debates['data'][0];
61 61
         }
Please login to merge, or discard this patch.
classes/Homepage.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
         $gid = $featured->get_gid();
58 58
         $gidCheck = new Gid($gid);
59 59
         $gid = $gidCheck->checkForRedirect();
60
-        if ( $gid ) {
60
+        if ($gid) {
61 61
             $title = $featured->get_title();
62 62
             $context = $featured->get_context();
63 63
             $related = $featured->get_related();
64 64
             $item = $this->getFeaturedDebate($gid, $title, $context, $related);
65 65
         } else {
66 66
             $item = $debatelist->display('recent_debates', array('days' => 7, 'num' => 1), 'none');
67
-            if ( isset($item['data']) && count($item['data']) ) {
67
+            if (isset($item['data']) && count($item['data'])) {
68 68
                 $item = $item['data'][0];
69 69
                 $more_url = new \URL('debates');
70 70
                 $item['more_url'] = $more_url->generate();
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
         $item['featured'] = true;
96 96
 
97 97
         $related_debates = array();
98
-        foreach ( $related as $related_gid ) {
99
-            if ( $related_gid ) {
98
+        foreach ($related as $related_gid) {
99
+            if ($related_gid) {
100 100
                 $related_item = $debatelist->display('featured_gid', array('gid' => $related_gid), 'none');
101 101
                 $related_debates[] = $related_item['data'];
102 102
             }
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
 
122 122
         $recent_content = array();
123 123
 
124
-        foreach ( $this->recent_types as $class => $recent ) {
124
+        foreach ($this->recent_types as $class => $recent) {
125 125
             $class = "\\$class";
126 126
             $instance = new $class();
127 127
             $more_url = new \URL($recent[1]);
128
-            if ( $recent[0] == 'recent_pbc_debates' ) {
129
-                $content = array( 'data' => $instance->display($recent[0], array('num' => 5), 'none') );
128
+            if ($recent[0] == 'recent_pbc_debates') {
129
+                $content = array('data' => $instance->display($recent[0], array('num' => 5), 'none'));
130 130
             } else {
131 131
                 $content = $instance->display($recent[0], array('days' => 7, 'num' => 1), 'none');
132
-                if ( isset($content['data']) && count($content['data']) ) {
132
+                if (isset($content['data']) && count($content['data'])) {
133 133
                     $content = $content['data'][0];
134 134
                 } else {
135 135
                     $content = array();
136 136
                 }
137 137
             }
138
-            if ( $content ) {
138
+            if ($content) {
139 139
                 $content['more_url'] = $more_url->generate();
140 140
                 $content['desc'] = $recent[2];
141 141
                 $recent_content[] = $content;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             WHERE event_date >= :date
155 155
             AND deleted = 0
156 156
             ORDER BY event_date, chamber, pos",
157
-            array( ':date' => $date )
157
+            array(':date' => $date)
158 158
         );
159 159
 
160 160
         if (!$q->rows()) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
     }
49 49
 
50 50
     protected function getRegionalList() {
51
-        return NULL;
51
+        return null;
52 52
     }
53 53
 
54 54
     protected function getEditorialContent() {
Please login to merge, or discard this patch.
classes/Utility/Gaze.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
     public static function getCountryByIp($ip)
21 21
     {
22 22
 
23
-        include_once INCLUDESPATH . '../../commonlib/phplib/gaze.php';
23
+        include_once INCLUDESPATH.'../../commonlib/phplib/gaze.php';
24 24
 
25 25
         if (defined('OPTION_GAZE_URL') && OPTION_GAZE_URL) {
26 26
             return gaze_get_country_from_ip($ip);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         if (defined('OPTION_GAZE_URL') && OPTION_GAZE_URL) {
26 26
             return gaze_get_country_from_ip($ip);
27 27
         } else {
28
-            return NULL;
28
+            return null;
29 29
         }
30 30
 
31 31
     }
Please login to merge, or discard this patch.
classes/Utility/Postcode.php 3 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
         if ($last_postcode == $postcode) {
41 41
             $return_value = $mp_only ? $last_postcode_value['WMC'] : $last_postcode_value;
42
-            twfy_debug ("TIME", "Postcode $postcode looked up last time, is " . ( is_array($return_value) ? implode(', ', $return_value) : $return_value ));
42
+            twfy_debug("TIME", "Postcode $postcode looked up last time, is ".(is_array($return_value) ? implode(', ', $return_value) : $return_value));
43 43
             return $return_value;
44 44
         }
45 45
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
             $name = $q->field(0, 'name');
76 76
             if (self::postcodeIsScottish($postcode)) {
77 77
                 $name = explode('|', $name);
78
-                if (count($name)==3)
78
+                if (count($name) == 3)
79 79
                     return array('WMC' => $name[0], 'SPC' => $name[1], 'SPE' => $name[2]);
80 80
             } elseif (self::postcodeIsNi($postcode)) {
81 81
                 $name = explode('|', $name);
82
-                if (count($name)==2)
82
+                if (count($name) == 2)
83 83
                     return array('WMC' => $name[0], 'NIE' => $name[1]);
84 84
             } else {
85 85
                 return array('WMC' => $name);
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
         if (!defined('OPTION_MAPIT_URL') || !OPTION_MAPIT_URL) {
98 98
             return '';
99 99
         }
100
-        $filename = 'postcode/' . rawurlencode($postcode);
101
-        $ch = curl_init(OPTION_MAPIT_URL . $filename);
100
+        $filename = 'postcode/'.rawurlencode($postcode);
101
+        $ch = curl_init(OPTION_MAPIT_URL.$filename);
102 102
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
103 103
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
104 104
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
         $file = curl_exec($ch);
107 107
         if (curl_errno($ch)) {
108 108
             $errno = curl_errno($ch);
109
-            trigger_error("Postcode database: " . $errno . ' ' . curl_error($ch), E_USER_WARNING);
109
+            trigger_error("Postcode database: ".$errno.' '.curl_error($ch), E_USER_WARNING);
110 110
             return 'CONNECTION_TIMED_OUT';
111 111
         }
112 112
         curl_close($ch);
113 113
 
114 114
         $r = json_decode($file, true);
115 115
         if (!$r) {
116
-            trigger_error("Postcode database is not working. Content:\n".$file.", request: ". $filename, E_USER_WARNING);
116
+            trigger_error("Postcode database is not working. Content:\n".$file.", request: ".$filename, E_USER_WARNING);
117 117
             return '';
118 118
         }
119 119
         if (isset($r['error']) || !isset($r['areas'])) {
@@ -179,29 +179,29 @@  discard block
 block discarded – undo
179 179
         if (in_array($m[1], array('AB', 'DD', 'EH', 'FK', 'G', 'HS', 'IV', 'KA', 'KW', 'KY', 'ML', 'PA', 'PH', 'ZE')))
180 180
             return true;
181 181
 
182
-        if ($m[1]=='DG') {
183
-            if ($m[2]==16 && $m[3]==5 && in_array($m[4], array('HT','HU','HZ','JA','JB'))) return false; # A few postcodes in England
182
+        if ($m[1] == 'DG') {
183
+            if ($m[2] == 16 && $m[3] == 5 && in_array($m[4], array('HT', 'HU', 'HZ', 'JA', 'JB'))) return false; # A few postcodes in England
184 184
             return true;
185 185
         }
186 186
 
187 187
         # Damn postcodes crossing country boundaries
188
-        if ($m[1]=='TD') {
189
-            if ($m[2]!=15 && $m[2]!=12 && $m[2]!=9) return true; # TD1-8, 10-11, 13-14 all in Scotland
190
-            if ($m[2]==9) {
191
-                if ($m[3]!=0) return true; # TD9 1-9 all in Scotland
192
-                if (!in_array($m[4], array('TJ','TP','TR','TS','TT','TU','TW'))) return true; # Nearly all of TD9 0 in Scotland
188
+        if ($m[1] == 'TD') {
189
+            if ($m[2] != 15 && $m[2] != 12 && $m[2] != 9) return true; # TD1-8, 10-11, 13-14 all in Scotland
190
+            if ($m[2] == 9) {
191
+                if ($m[3] != 0) return true; # TD9 1-9 all in Scotland
192
+                if (!in_array($m[4], array('TJ', 'TP', 'TR', 'TS', 'TT', 'TU', 'TW'))) return true; # Nearly all of TD9 0 in Scotland
193 193
             }
194 194
             $m[5] = substr($m[4], 0, 1);
195
-            if ($m[2]==12) { # $m[3] will be 4 currently.
196
-                if ($m[4]=='XE') return true;
197
-                if (in_array($m[5], array('A','B','D','E','H','J','L','N','W','Y'))) return true; # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
195
+            if ($m[2] == 12) { # $m[3] will be 4 currently.
196
+                if ($m[4] == 'XE') return true;
197
+                if (in_array($m[5], array('A', 'B', 'D', 'E', 'H', 'J', 'L', 'N', 'W', 'Y'))) return true; # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
198 198
             }
199 199
             # TD15 is mostly England
200
-            if ($m[2]==15) {
201
-                if ($m[3]!=1) return false; # TD15 2 and 9 are in England
202
-                if (in_array($m[4], array('BT','SU','SZ','UF','UG','UH','UJ','UL','US','UZ','WY','WZ'))) return true;
203
-                if ($m[5]=='T' && $m[4]!='TA' && $m[4]!='TB') return true; # Most of TD15 1T* in Scotland
204
-                if ($m[5]=='X' && $m[4]!='XX') return true; # TD15 1XX in England, rest of TD15 1X* in Scotland
200
+            if ($m[2] == 15) {
201
+                if ($m[3] != 1) return false; # TD15 2 and 9 are in England
202
+                if (in_array($m[4], array('BT', 'SU', 'SZ', 'UF', 'UG', 'UH', 'UJ', 'UL', 'US', 'UZ', 'WY', 'WZ'))) return true;
203
+                if ($m[5] == 'T' && $m[4] != 'TA' && $m[4] != 'TB') return true; # Most of TD15 1T* in Scotland
204
+                if ($m[5] == 'X' && $m[4] != 'XX') return true; # TD15 1XX in England, rest of TD15 1X* in Scotland
205 205
             }
206 206
         }
207 207
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
         if ($last_postcode == $postcode) {
41 41
             $return_value = $mp_only ? $last_postcode_value['WMC'] : $last_postcode_value;
42
-            twfy_debug ("TIME", "Postcode $postcode looked up last time, is " . ( is_array($return_value) ? implode(', ', $return_value) : $return_value ));
42
+            twfy_debug ("TIME", "postcode $postcode looked up last time, is " . ( is_array($return_value) ? implode(', ', $return_value) : $return_value ));
43 43
             return $return_value;
44 44
         }
45 45
 
Please login to merge, or discard this patch.
Braces   +59 added lines, -23 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
             $ret = self::postcodeFetchFromMapit($postcode);
53 53
         }
54 54
 
55
-        if (is_string($ret)) return $ret;
55
+        if (is_string($ret)) {
56
+            return $ret;
57
+        }
56 58
 
57 59
         $last_postcode = $postcode;
58 60
         $last_postcode_value = $ret;
@@ -75,12 +77,14 @@  discard block
 block discarded – undo
75 77
             $name = $q->field(0, 'name');
76 78
             if (self::postcodeIsScottish($postcode)) {
77 79
                 $name = explode('|', $name);
78
-                if (count($name)==3)
79
-                    return array('WMC' => $name[0], 'SPC' => $name[1], 'SPE' => $name[2]);
80
+                if (count($name)==3) {
81
+                                    return array('WMC' => $name[0], 'SPC' => $name[1], 'SPE' => $name[2]);
82
+                }
80 83
             } elseif (self::postcodeIsNi($postcode)) {
81 84
                 $name = explode('|', $name);
82
-                if (count($name)==2)
83
-                    return array('WMC' => $name[0], 'NIE' => $name[1]);
85
+                if (count($name)==2) {
86
+                                    return array('WMC' => $name[0], 'NIE' => $name[1]);
87
+                }
84 88
             } else {
85 89
                 return array('WMC' => $name);
86 90
             }
@@ -121,8 +125,9 @@  discard block
 block discarded – undo
121 125
         }
122 126
         $areas = array();
123 127
         foreach ($r['areas'] as $row) {
124
-            if (in_array($row['type'], array('WMC', 'SPC', 'SPE', 'NIE')))
125
-                $areas[$row['type']] = $row['name'];
128
+            if (in_array($row['type'], array('WMC', 'SPC', 'SPE', 'NIE'))) {
129
+                            $areas[$row['type']] = $row['name'];
130
+            }
126 131
         }
127 132
 
128 133
         if (!isset($areas['WMC'])) {
@@ -172,36 +177,66 @@  discard block
 block discarded – undo
172 177
      */
173 178
 
174 179
     public static function postcodeIsScottish($pc) {
175
-        if (!preg_match('#^([A-Z]{1,2})(\d+) (\d)([A-Z]{2})#', self::canonicalisePostcode($pc), $m))
176
-            return false;
180
+        if (!preg_match('#^([A-Z]{1,2})(\d+) (\d)([A-Z]{2})#', self::canonicalisePostcode($pc), $m)) {
181
+                    return false;
182
+        }
177 183
 
178 184
         # Check for Scottish postal areas
179
-        if (in_array($m[1], array('AB', 'DD', 'EH', 'FK', 'G', 'HS', 'IV', 'KA', 'KW', 'KY', 'ML', 'PA', 'PH', 'ZE')))
180
-            return true;
185
+        if (in_array($m[1], array('AB', 'DD', 'EH', 'FK', 'G', 'HS', 'IV', 'KA', 'KW', 'KY', 'ML', 'PA', 'PH', 'ZE'))) {
186
+                    return true;
187
+        }
181 188
 
182 189
         if ($m[1]=='DG') {
183
-            if ($m[2]==16 && $m[3]==5 && in_array($m[4], array('HT','HU','HZ','JA','JB'))) return false; # A few postcodes in England
190
+            if ($m[2]==16 && $m[3]==5 && in_array($m[4], array('HT','HU','HZ','JA','JB'))) {
191
+                return false;
192
+            }
193
+            # A few postcodes in England
184 194
             return true;
185 195
         }
186 196
 
187 197
         # Damn postcodes crossing country boundaries
188 198
         if ($m[1]=='TD') {
189
-            if ($m[2]!=15 && $m[2]!=12 && $m[2]!=9) return true; # TD1-8, 10-11, 13-14 all in Scotland
199
+            if ($m[2]!=15 && $m[2]!=12 && $m[2]!=9) {
200
+                return true;
201
+            }
202
+            # TD1-8, 10-11, 13-14 all in Scotland
190 203
             if ($m[2]==9) {
191
-                if ($m[3]!=0) return true; # TD9 1-9 all in Scotland
192
-                if (!in_array($m[4], array('TJ','TP','TR','TS','TT','TU','TW'))) return true; # Nearly all of TD9 0 in Scotland
204
+                if ($m[3]!=0) {
205
+                    return true;
206
+                }
207
+                # TD9 1-9 all in Scotland
208
+                if (!in_array($m[4], array('TJ','TP','TR','TS','TT','TU','TW'))) {
209
+                    return true;
210
+                }
211
+                # Nearly all of TD9 0 in Scotland
193 212
             }
194 213
             $m[5] = substr($m[4], 0, 1);
195 214
             if ($m[2]==12) { # $m[3] will be 4 currently.
196
-                if ($m[4]=='XE') return true;
197
-                if (in_array($m[5], array('A','B','D','E','H','J','L','N','W','Y'))) return true; # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
215
+                if ($m[4]=='XE') {
216
+                    return true;
217
+                }
218
+                if (in_array($m[5], array('A','B','D','E','H','J','L','N','W','Y'))) {
219
+                    return true;
220
+                }
221
+                # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
198 222
             }
199 223
             # TD15 is mostly England
200 224
             if ($m[2]==15) {
201
-                if ($m[3]!=1) return false; # TD15 2 and 9 are in England
202
-                if (in_array($m[4], array('BT','SU','SZ','UF','UG','UH','UJ','UL','US','UZ','WY','WZ'))) return true;
203
-                if ($m[5]=='T' && $m[4]!='TA' && $m[4]!='TB') return true; # Most of TD15 1T* in Scotland
204
-                if ($m[5]=='X' && $m[4]!='XX') return true; # TD15 1XX in England, rest of TD15 1X* in Scotland
225
+                if ($m[3]!=1) {
226
+                    return false;
227
+                }
228
+                # TD15 2 and 9 are in England
229
+                if (in_array($m[4], array('BT','SU','SZ','UF','UG','UH','UJ','UL','US','UZ','WY','WZ'))) {
230
+                    return true;
231
+                }
232
+                if ($m[5]=='T' && $m[4]!='TA' && $m[4]!='TB') {
233
+                    return true;
234
+                }
235
+                # Most of TD15 1T* in Scotland
236
+                if ($m[5]=='X' && $m[4]!='XX') {
237
+                    return true;
238
+                }
239
+                # TD15 1XX in England, rest of TD15 1X* in Scotland
205 240
             }
206 241
         }
207 242
 
@@ -215,8 +250,9 @@  discard block
 block discarded – undo
215 250
 
216 251
     public static function postcodeIsNi($pc) {
217 252
         $prefix = substr(self::canonicalisePostcode($pc), 0, 2);
218
-        if ($prefix == 'BT')
219
-            return true;
253
+        if ($prefix == 'BT') {
254
+                    return true;
255
+        }
220 256
         return false;
221 257
     }
222 258
 
Please login to merge, or discard this patch.
classes/Utility/Video.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
     public static function object($video_id, $start, $gid, $stamping = '', $pid = 0) {
40 40
         $flashvars = "gid=$gid&amp;file=$video_id&amp;start=$start";
41 41
         if ($stamping) $flashvars .= '&amp;stamping=1';
42
-        if ($pid) $flashvars .= '&amp;pid=' . $pid;
42
+        if ($pid) $flashvars .= '&amp;pid='.$pid;
43 43
 /*
44 44
 <object width='360' height='300'
45 45
     classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
Please login to merge, or discard this patch.
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.
classes/Utility/Hansard.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
         $parts = parse_url($url);
16 16
         parse_str($parts['query'], $query);
17 17
 
18
-        if ( $query['id'] ) {
18
+        if ($query['id']) {
19 19
             if (strpos($parts['path'], 'lords') !== false) {
20 20
                 $gid = 'uk.org.publicwhip/lords/';
21 21
             } elseif (strpos($parts['path'], 'whall') !== false) {
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 
31 31
 
32 32
     public static function gid_to_url($gid) {
33
-        if ( !$gid ) {
33
+        if (!$gid) {
34 34
             return '';
35 35
         }
36 36
         global $hansardmajors;
37 37
         $db = new \ParlDB();
38 38
 
39
-        $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array( ':gid' => $gid ));
39
+        $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid));
40 40
         $url_gid = fix_gid_from_db($gid);
41 41
         $url = new \URL($hansardmajors[$q->field(0, 'major')]['page']);
42 42
         $url->insert(array('id' => $url_gid));
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 class Hansard
12 12
 {
13 13
     public static function get_gid_from_url($url) {
14
-        $gid = NULL;
14
+        $gid = null;
15 15
         $parts = parse_url($url);
16 16
         parse_str($parts['query'], $query);
17 17
 
Please login to merge, or discard this patch.
classes/Utility/Wikipedia.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -136,63 +136,63 @@
 block discarded – undo
136 136
 
137 137
     public static function antiTagInTag($content = '', $format = 'htmlhead')
138 138
     {
139
-      $contentwalker = 0;
140
-      $length = strlen( $content );
141
-      $tagend = -1;
142
-      for( $tagstart = strpos( $content, '<', $tagend + 1 ) ; $tagstart !== false && $tagstart < strlen( $content ); $tagstart = strpos( $content, '<', $tagend ) )
139
+        $contentwalker = 0;
140
+        $length = strlen( $content );
141
+        $tagend = -1;
142
+        for( $tagstart = strpos( $content, '<', $tagend + 1 ) ; $tagstart !== false && $tagstart < strlen( $content ); $tagstart = strpos( $content, '<', $tagend ) )
143 143
         {
144
-          // got the start of a tag.  Now find the proper end!
145
-          $walker = $tagstart + 1;
146
-          $open = 1;
147
-          while( $open != 0 && $walker < strlen( $content ) )
144
+            // got the start of a tag.  Now find the proper end!
145
+            $walker = $tagstart + 1;
146
+            $open = 1;
147
+            while( $open != 0 && $walker < strlen( $content ) )
148 148
         {
149
-          $nextopen = strpos( $content, '<', $walker );
150
-          $nextclose = strpos( $content, '>', $walker );
151
-          if( $nextclose === false )
149
+            $nextopen = strpos( $content, '<', $walker );
150
+            $nextclose = strpos( $content, '>', $walker );
151
+            if( $nextclose === false )
152 152
             {    // ERROR! Open waka without close waka!
153
-              // echo '<code>Error in antiTagInTag - malformed tag!</code> ';
154
-              return $content;
153
+                // echo '<code>Error in antiTagInTag - malformed tag!</code> ';
154
+                return $content;
155 155
             }
156
-          if( $nextopen === false || $nextopen > $nextclose )
156
+            if( $nextopen === false || $nextopen > $nextclose )
157 157
             { // No more opens, but there was a close; or, a close happens before the next open.
158
-              // walker goes to the close+1, and open decrements
159
-              $open --;
160
-              $walker = $nextclose + 1;
158
+                // walker goes to the close+1, and open decrements
159
+                $open --;
160
+                $walker = $nextclose + 1;
161 161
             }
162
-          elseif( $nextopen < $nextclose )
162
+            elseif( $nextopen < $nextclose )
163 163
             { // an open before the next close
164
-              $open ++;
165
-              $walker = $nextopen + 1;
164
+                $open ++;
165
+                $walker = $nextopen + 1;
166 166
             }
167 167
         }
168
-          $tagend = $walker;
169
-          if( $tagend > strlen( $content ) )
168
+            $tagend = $walker;
169
+            if( $tagend > strlen( $content ) )
170 170
         $tagend = strlen( $content );
171
-          else
171
+            else
172 172
         {
173
-          $tagend --;
174
-          $tagstart ++;
173
+            $tagend --;
174
+            $tagstart ++;
175 175
         }
176
-          $tag = substr( $content, $tagstart, $tagend - $tagstart );
177
-          $tags[] = '<' . $tag . '>';
176
+            $tag = substr( $content, $tagstart, $tagend - $tagstart );
177
+            $tags[] = '<' . $tag . '>';
178 178
 
179
-          if (function_exists('format_to_output')) {
179
+            if (function_exists('format_to_output')) {
180 180
             $newtag = format_to_output($tag, $format);
181
-          } else {
181
+            } else {
182 182
             $newtag = strip_tags($tag);
183
-          }
183
+            }
184 184
 
185
-          $newtags[] = '<' . $newtag . '>';
185
+            $newtags[] = '<' . $newtag . '>';
186 186
 
187
-          if (function_exists('format_to_output')) {
187
+            if (function_exists('format_to_output')) {
188 188
             $newtag = format_to_output($tag, $format);
189
-          } else {
189
+            } else {
190 190
             $newtag = strip_tags($tag);
191
-          }
191
+            }
192
+        }
193
+        if (isset($tags)&&isset($newtags)) {
194
+        $content = str_replace($tags, $newtags, $content);
192 195
         }
193
-      if (isset($tags)&&isset($newtags)) {
194
-      $content = str_replace($tags, $newtags, $content);
195
-      }
196 196
 
197 197
     return $content;
198 198
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         // Assemble the resulting phrases into a parameter array
74 74
         $params = array();
75 75
         foreach ($phrases as $i => $phrase) {
76
-            $params[':phrase' . $i] = $phrase;
76
+            $params[':phrase'.$i] = $phrase;
77 77
         }
78 78
 
79 79
         # Open up a db connection, and whittle our list down even further, against
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
         $matched = array();
82 82
         $db = new \ParlDB;
83 83
         $source = explode('|||', $source);
84
-        $q = $db->query("SELECT titles.title FROM titles LEFT JOIN titles_ignored ON titles.title=titles_ignored.title WHERE titles.title IN (" . join(',', array_keys($params)) . ") AND titles_ignored.title IS NULL", $params);
84
+        $q = $db->query("SELECT titles.title FROM titles LEFT JOIN titles_ignored ON titles.title=titles_ignored.title WHERE titles.title IN (".join(',', array_keys($params)).") AND titles_ignored.title IS NULL", $params);
85 85
         $phrases = array();
86
-        for ($i=0; $i<$q->rows(); $i++) {
86
+        for ($i = 0; $i < $q->rows(); $i++) {
87 87
             $phrases[] = $q->field($i, 'title');
88 88
         }
89 89
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 
106 106
             twfy_debug("WIKIPEDIA", "Matched '$phrase'");
107 107
             # 1 means only replace one match for phrase per paragraph
108
-            $source = preg_replace ('{
109
-            \b(' . $phrase_re . ')\b # Match the phrase itself
108
+            $source = preg_replace('{
109
+            \b(' . $phrase_re.')\b # Match the phrase itself
110 110
             (?!                      # Match as long as the following does *not* apply:
111 111
                 (?:                  #   Match, possessively, as many strings of:
112 112
                  [^<]+               #     non-"<" characters,
@@ -137,44 +137,44 @@  discard block
 block discarded – undo
137 137
     public static function antiTagInTag($content = '', $format = 'htmlhead')
138 138
     {
139 139
       $contentwalker = 0;
140
-      $length = strlen( $content );
140
+      $length = strlen($content);
141 141
       $tagend = -1;
142
-      for( $tagstart = strpos( $content, '<', $tagend + 1 ) ; $tagstart !== false && $tagstart < strlen( $content ); $tagstart = strpos( $content, '<', $tagend ) )
142
+      for ($tagstart = strpos($content, '<', $tagend + 1); $tagstart !== false && $tagstart < strlen($content); $tagstart = strpos($content, '<', $tagend))
143 143
         {
144 144
           // got the start of a tag.  Now find the proper end!
145 145
           $walker = $tagstart + 1;
146 146
           $open = 1;
147
-          while( $open != 0 && $walker < strlen( $content ) )
147
+          while ($open != 0 && $walker < strlen($content))
148 148
         {
149
-          $nextopen = strpos( $content, '<', $walker );
150
-          $nextclose = strpos( $content, '>', $walker );
151
-          if( $nextclose === false )
149
+          $nextopen = strpos($content, '<', $walker);
150
+          $nextclose = strpos($content, '>', $walker);
151
+          if ($nextclose === false)
152 152
             {    // ERROR! Open waka without close waka!
153 153
               // echo '<code>Error in antiTagInTag - malformed tag!</code> ';
154 154
               return $content;
155 155
             }
156
-          if( $nextopen === false || $nextopen > $nextclose )
156
+          if ($nextopen === false || $nextopen > $nextclose)
157 157
             { // No more opens, but there was a close; or, a close happens before the next open.
158 158
               // walker goes to the close+1, and open decrements
159
-              $open --;
159
+              $open--;
160 160
               $walker = $nextclose + 1;
161 161
             }
162
-          elseif( $nextopen < $nextclose )
162
+          elseif ($nextopen < $nextclose)
163 163
             { // an open before the next close
164
-              $open ++;
164
+              $open++;
165 165
               $walker = $nextopen + 1;
166 166
             }
167 167
         }
168 168
           $tagend = $walker;
169
-          if( $tagend > strlen( $content ) )
170
-        $tagend = strlen( $content );
169
+          if ($tagend > strlen($content))
170
+        $tagend = strlen($content);
171 171
           else
172 172
         {
173
-          $tagend --;
174
-          $tagstart ++;
173
+          $tagend--;
174
+          $tagstart++;
175 175
         }
176
-          $tag = substr( $content, $tagstart, $tagend - $tagstart );
177
-          $tags[] = '<' . $tag . '>';
176
+          $tag = substr($content, $tagstart, $tagend - $tagstart);
177
+          $tags[] = '<'.$tag.'>';
178 178
 
179 179
           if (function_exists('format_to_output')) {
180 180
             $newtag = format_to_output($tag, $format);
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
             $newtag = strip_tags($tag);
183 183
           }
184 184
 
185
-          $newtags[] = '<' . $newtag . '>';
185
+          $newtags[] = '<'.$newtag.'>';
186 186
 
187 187
           if (function_exists('format_to_output')) {
188 188
             $newtag = format_to_output($tag, $format);
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
             $newtag = strip_tags($tag);
191 191
           }
192 192
         }
193
-      if (isset($tags)&&isset($newtags)) {
193
+      if (isset($tags) && isset($newtags)) {
194 194
       $content = str_replace($tags, $newtags, $content);
195 195
       }
196 196
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -9 removed lines patch added patch discarded remove patch
@@ -99,8 +99,9 @@  discard block
 block discarded – undo
99 99
 
100 100
             # See if already matched a string this one is contained within
101 101
             foreach ($matched as $got) {
102
-                if (strstr($got, $phrase))
103
-                    continue 2;
102
+                if (strstr($got, $phrase)) {
103
+                                    continue 2;
104
+                }
104 105
             }
105 106
 
106 107
             twfy_debug("WIKIPEDIA", "Matched '$phrase'");
@@ -119,8 +120,9 @@  discard block
 block discarded – undo
119 120
             array_push($matched, $phrase);
120 121
         }
121 122
 
122
-        if (!$was_array)
123
-            $source = join('|||', $source);
123
+        if (!$was_array) {
124
+                    $source = join('|||', $source);
125
+        }
124 126
 
125 127
         return $source;
126 128
 
@@ -158,17 +160,16 @@  discard block
 block discarded – undo
158 160
               // walker goes to the close+1, and open decrements
159 161
               $open --;
160 162
               $walker = $nextclose + 1;
161
-            }
162
-          elseif( $nextopen < $nextclose )
163
+            } elseif( $nextopen < $nextclose )
163 164
             { // an open before the next close
164 165
               $open ++;
165 166
               $walker = $nextopen + 1;
166 167
             }
167 168
         }
168 169
           $tagend = $walker;
169
-          if( $tagend > strlen( $content ) )
170
-        $tagend = strlen( $content );
171
-          else
170
+          if( $tagend > strlen( $content ) ) {
171
+                  $tagend = strlen( $content );
172
+          } else
172 173
         {
173 174
           $tagend --;
174 175
           $tagstart ++;
Please login to merge, or discard this patch.
classes/Utility/Calendar.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
         list($title, $meta) = self::meta($e);
53 53
 
54 54
         if (strstr($e['chamber'], 'Select Committee')) {
55
-            print '<dt class="sc" id="cal' . $e['id'] . '">';
55
+            print '<dt class="sc" id="cal'.$e['id'].'">';
56 56
         } else {
57
-            print '<li id="cal' . $e['id'] . '">';
57
+            print '<li id="cal'.$e['id'].'">';
58 58
         }
59 59
 
60 60
         print "$title ";
61 61
 
62 62
         if ($meta) {
63
-            print '<span>' . join('; ', $meta) . '</span>';
63
+            print '<span>'.join('; ', $meta).'</span>';
64 64
         }
65 65
 
66 66
         if (strstr($e['chamber'], 'Select Committee')) {
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             print "<dd>";
74 74
             print '<a href=" $e[link_calendar] "></a>';
75 75
             print '<a href=" $e[link_external] "></a>';
76
-            print 'Witnesses: ' . $e['witnesses'];
76
+            print 'Witnesses: '.$e['witnesses'];
77 77
             print "</dd>\n";
78 78
         }
79 79
     }
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
             $title = $e['committee_name'];
85 85
             if ($e['title'] == 'to consider the Bill') {
86 86
             } elseif ($e['title'] && $e['title'] != 'This is a private meeting.') {
87
-                $title .= ': ' . $e['title'];
87
+                $title .= ': '.$e['title'];
88 88
             } else {
89 89
                 $private = true;
90 90
             }
91 91
         } else {
92 92
             $title = $e['title'];
93 93
             if ($pid = $e['person_id']) {
94
-                $MEMBER = new \MEMBER(array( 'person_id' => $pid ));
94
+                $MEMBER = new \MEMBER(array('person_id' => $pid));
95 95
                 $name = $MEMBER->full_name();
96 96
                 $title .= " &#8211; <a href='/mp/?p=$pid'>$name</a>";
97 97
             }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                 $time = format_time($e['time_start'], TIMEFORMAT);
116 116
 
117 117
                 if ($e['time_end']) {
118
-                    $time .= ' &#8211; ' . format_time($e['time_end'], TIMEFORMAT);
118
+                    $time .= ' &#8211; '.format_time($e['time_end'], TIMEFORMAT);
119 119
                 }
120 120
 
121 121
                 $meta[] = $time;
Please login to merge, or discard this patch.