Failed Conditions
Pull Request — master (#1325)
by Nick
26:10 queued 21:10
created
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&file=$video_id&start=$start";
41 41
         if ($stamping) $flashvars .= '&stamping=1';
42
-        if ($pid) $flashvars .= '&pid=' . $pid;
42
+        if ($pid) $flashvars .= '&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.
classes/Utility/Constituencies.php 2 patches
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.
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.
classes/Utility/Member.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,23 +25,23 @@  discard block
 block discarded – undo
25 25
 
26 26
     public static function findMemberImage($pid, $smallonly = false, $substitute_missing = false) {
27 27
         $image = null; $sz = null;
28
-        if (!$smallonly && is_file(BASEDIR . '/images/mpsL/' . $pid . '.jpeg')) {
29
-            $image = IMAGEPATH . 'mpsL/' . $pid . '.jpeg';
28
+        if (!$smallonly && is_file(BASEDIR.'/images/mpsL/'.$pid.'.jpeg')) {
29
+            $image = IMAGEPATH.'mpsL/'.$pid.'.jpeg';
30 30
             $sz = 'L';
31
-        } elseif (!$smallonly && is_file(BASEDIR . '/images/mpsL/' . $pid . '.jpg')) {
32
-            $image = IMAGEPATH . 'mpsL/' . $pid . '.jpg';
31
+        } elseif (!$smallonly && is_file(BASEDIR.'/images/mpsL/'.$pid.'.jpg')) {
32
+            $image = IMAGEPATH.'mpsL/'.$pid.'.jpg';
33 33
             $sz = 'L';
34
-        } elseif (!$smallonly && is_file(BASEDIR . '/images/mpsL/' . $pid . '.png')) {
35
-            $image = IMAGEPATH . 'mpsL/' . $pid . '.png';
34
+        } elseif (!$smallonly && is_file(BASEDIR.'/images/mpsL/'.$pid.'.png')) {
35
+            $image = IMAGEPATH.'mpsL/'.$pid.'.png';
36 36
             $sz = 'L';
37
-        } elseif (is_file(BASEDIR . '/images/mps/' . $pid . '.jpeg')) {
38
-            $image = IMAGEPATH . 'mps/' . $pid . '.jpeg';
37
+        } elseif (is_file(BASEDIR.'/images/mps/'.$pid.'.jpeg')) {
38
+            $image = IMAGEPATH.'mps/'.$pid.'.jpeg';
39 39
             $sz = 'S';
40
-        } elseif (is_file(BASEDIR . '/images/mps/' . $pid . '.jpg')) {
41
-            $image = IMAGEPATH . 'mps/' . $pid . '.jpg';
40
+        } elseif (is_file(BASEDIR.'/images/mps/'.$pid.'.jpg')) {
41
+            $image = IMAGEPATH.'mps/'.$pid.'.jpg';
42 42
             $sz = 'S';
43
-        } elseif (is_file(BASEDIR . '/images/mps/' . $pid . '.png')) {
44
-            $image = IMAGEPATH . 'mps/' . $pid . '.png';
43
+        } elseif (is_file(BASEDIR.'/images/mps/'.$pid.'.png')) {
44
+            $image = IMAGEPATH.'mps/'.$pid.'.png';
45 45
             $sz = 'S';
46 46
         }
47 47
 
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
         if (!$image && $substitute_missing) {
50 50
             if ($smallonly) {
51 51
                 if ($substitute_missing === "lord") {
52
-                    $image = IMAGEPATH . "unknownlord.png";
52
+                    $image = IMAGEPATH."unknownlord.png";
53 53
                 } else {
54
-                    $image = IMAGEPATH . "unknownperson.png";
54
+                    $image = IMAGEPATH."unknownperson.png";
55 55
                 }
56 56
                 $sz = 'S';
57 57
             } else {
58 58
                 if ($substitute_missing === "lord") {
59
-                    $image = IMAGEPATH . "unknownlord_large.png";
59
+                    $image = IMAGEPATH."unknownlord_large.png";
60 60
                 } else {
61
-                    $image = IMAGEPATH . "unknownperson_large.png";
61
+                    $image = IMAGEPATH."unknownperson_large.png";
62 62
                 }
63 63
                 $sz = 'L';
64 64
             }
Please login to merge, or discard this patch.
classes/Utility/Search.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
         $data = array();
15 15
         $SEARCHENGINE = new \SEARCHENGINE($search);
16 16
         $data['pagetitle'] = $SEARCHENGINE->query_description_short();
17
-        $SEARCHENGINE = new \SEARCHENGINE($search . ' groupby:speech');
17
+        $SEARCHENGINE = new \SEARCHENGINE($search.' groupby:speech');
18 18
         $count = $SEARCHENGINE->run_count(0, 5000, 'date');
19 19
         if ($count <= 0) {
20 20
             $data['error'] = 'No results';
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
         $speaker_count = array();
36 36
         $gids = join('","', $gids);
37 37
         $db = new \ParlDB;
38
-        $q = $db->query('SELECT gid,person_id,hdate FROM hansard WHERE gid IN ("' . $gids . '")');
39
-        for ($n=0; $n<$q->rows(); $n++) {
38
+        $q = $db->query('SELECT gid,person_id,hdate FROM hansard WHERE gid IN ("'.$gids.'")');
39
+        for ($n = 0; $n < $q->rows(); $n++) {
40 40
             $gid = $q->field($n, 'gid');
41 41
             $person_id = $q->field($n, 'person_id');
42 42
             $hdate = $q->field($n, 'hdate');
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
                                 moffice_id, dept, position, from_date, to_date, left_house
61 61
                             FROM member LEFT JOIN moffice ON member.person_id = moffice.person
62 62
                                 JOIN person_names pn ON member.person_id = pn.person_id AND pn.type="name" AND pn.start_date <= left_house AND left_house <= pn.end_date
63
-                            WHERE member.person_id IN (' . $person_ids . ')
64
-                            ' . ($house ? " AND house=$house" : '') . '
63
+                            WHERE member.person_id IN (' . $person_ids.')
64
+                            ' . ($house ? " AND house=$house" : '').'
65 65
                             ORDER BY left_house DESC');
66
-            for ($n=0; $n<$q->rows(); $n++) {
66
+            for ($n = 0; $n < $q->rows(); $n++) {
67 67
                 $mid = $q->field($n, 'member_id');
68 68
                 if (!isset($pids[$mid])) {
69 69
                     $title = $q->field($n, 'title');
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
                 if ($dept && $q->field($n, 'to_date') == '9999-12-31')
85 85
                     $speakers[$pid]['office'][$moffice_id] = prettify_office($posn, $dept);
86 86
                 if (!isset($speakers[$pid]['name'])) {
87
-                    $speakers[$pid]['name'] = $full_name . ($house==1?' MP':'');
87
+                    $speakers[$pid]['name'] = $full_name.($house == 1 ? ' MP' : '');
88 88
                 }
89
-                if ( !isset($speakers[$pid]['party']) && $party ) {
89
+                if (!isset($speakers[$pid]['party']) && $party) {
90 90
                     $speakers[$pid]['party'] = $party;
91 91
                 }
92 92
             }
@@ -139,20 +139,20 @@  discard block
 block discarded – undo
139 139
      * Return query result from looking for MPs
140 140
      */
141 141
 
142
-    public static function searchMemberDbLookup($searchstring, $current_only=false) {
142
+    public static function searchMemberDbLookup($searchstring, $current_only = false) {
143 143
         if (!$searchstring) return false;
144 144
         $searchwords = explode(' ', $searchstring, 3);
145 145
         $params = array();
146 146
         if (count($searchwords) == 1) {
147
-            $params[':like_0'] = '%' . $searchwords[0] . '%';
147
+            $params[':like_0'] = '%'.$searchwords[0].'%';
148 148
             $where = "given_name LIKE :like_0 OR family_name LIKE :like_0 OR lordofname LIKE :like_0";
149 149
         } elseif (count($searchwords) == 2) {
150 150
             // We don't do anything special if there are more than two search words.
151 151
             // And here we're assuming the user's put the names in the right order.
152
-            $params[':like_0'] = '%' . $searchwords[0] . '%';
153
-            $params[':like_1'] = '%' . $searchwords[1] . '%';
154
-            $params[':like_0_and_1'] = '%' . $searchwords[0] . ' '. $searchwords[1] . '%';
155
-            $params[':like_0_and_1_hyphen'] = '%' . $searchwords[0] . '-'. $searchwords[1] . '%';
152
+            $params[':like_0'] = '%'.$searchwords[0].'%';
153
+            $params[':like_1'] = '%'.$searchwords[1].'%';
154
+            $params[':like_0_and_1'] = '%'.$searchwords[0].' '.$searchwords[1].'%';
155
+            $params[':like_0_and_1_hyphen'] = '%'.$searchwords[0].'-'.$searchwords[1].'%';
156 156
             $where = "(given_name LIKE :like_0 AND family_name LIKE :like_1)";
157 157
             $where .= " OR (given_name LIKE :like_1 AND family_name LIKE :like_0)";
158 158
             $where .= " OR (title LIKE :like_0 AND family_name LIKE :like_1)";
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
             }
165 165
         } else {
166 166
             $searchwords[2] = str_replace('of ', '', $searchwords[2]);
167
-            $params[':like_0'] = '%' . $searchwords[0] . '%';
168
-            $params[':like_1'] = '%' . $searchwords[1] . '%';
169
-            $params[':like_2'] = '%' . $searchwords[2] . '%';
170
-            $params[':like_0_and_1'] = '%' . $searchwords[0] . ' '. $searchwords[1] . '%';
171
-            $params[':like_1_and_2'] = '%' . $searchwords[1] . ' '. $searchwords[2] . '%';
172
-            $params[':like_1_and_2_hyphen'] = '%' . $searchwords[1] . '-'. $searchwords[2] . '%';
167
+            $params[':like_0'] = '%'.$searchwords[0].'%';
168
+            $params[':like_1'] = '%'.$searchwords[1].'%';
169
+            $params[':like_2'] = '%'.$searchwords[2].'%';
170
+            $params[':like_0_and_1'] = '%'.$searchwords[0].' '.$searchwords[1].'%';
171
+            $params[':like_1_and_2'] = '%'.$searchwords[1].' '.$searchwords[2].'%';
172
+            $params[':like_1_and_2_hyphen'] = '%'.$searchwords[1].'-'.$searchwords[2].'%';
173 173
             $where = "(given_name LIKE :like_0_and_1 AND family_name LIKE :like_2)";
174 174
             $where .= " OR (given_name LIKE :like_0 AND family_name LIKE :like_1_and_2)";
175 175
             $where .= " OR (given_name LIKE :like_0 AND family_name LIKE :like_1_and_2_hyphen)";
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
         return $q;
185 185
     }
186 186
 
187
-    public static function searchMemberDbLookupWithNames($searchstring, $current_only=false) {
187
+    public static function searchMemberDbLookupWithNames($searchstring, $current_only = false) {
188 188
         $q = self::searchMemberDbLookup($searchstring, $current_only);
189 189
 
190
-        if ( !$q->rows ) {
190
+        if (!$q->rows) {
191 191
             return $q;
192 192
         }
193 193
 
194 194
         $person_ids = array();
195
-        for ($i=0; $i<$q->rows(); ++$i) {
195
+        for ($i = 0; $i < $q->rows(); ++$i) {
196 196
             $pid = $q->field($i, 'person_id');
197 197
             $person_ids[$pid] = 1;
198 198
         }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             // Looks like a postcode - can we find the constituency?
240 240
             $constituency = Postcode::postcodeToConstituency($searchterm);
241 241
             if ($constituency) {
242
-                return array( array($constituency), true );
242
+                return array(array($constituency), true);
243 243
             }
244 244
         }
245 245
 
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
             from constituency AS o where name like :try
251 251
             and from_date <= date(now()) and date(now()) <= to_date";
252 252
         $db = new \ParlDB;
253
-        $q = $db->query($query, array(':try' => '%' . $try . '%'));
253
+        $q = $db->query($query, array(':try' => '%'.$try.'%'));
254 254
 
255 255
         $constituencies = array();
256
-        for ($n=0; $n<$q->rows(); $n++) {
256
+        for ($n = 0; $n < $q->rows(); $n++) {
257 257
             $constituencies[] = $q->field($n, 'name');
258 258
         }
259 259
 
260
-        return array( $constituencies, false );
260
+        return array($constituencies, false);
261 261
     }
262 262
 
263 263
     /**
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         $speakers = [];
274 274
 
275 275
         foreach ($criteria as $c) {
276
-            if (preg_match('#^speaker:(\d+)#',$c,$m)) {
276
+            if (preg_match('#^speaker:(\d+)#', $c, $m)) {
277 277
                 $MEMBER = new \MEMBER(array('person_id'=>$m[1]));
278 278
                 $speakers[$m[1]] = $MEMBER->full_name();
279 279
             }
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
     public static function speakerIDsToNames($searchstring) {
293 293
         $speakers = self::speakerNamesForIDs($searchstring);
294 294
 
295
-        foreach ( $speakers as $id => $name ) {
296
-            $searchstring = str_replace('speaker:' . $id, "speaker:$name", $searchstring);
295
+        foreach ($speakers as $id => $name) {
296
+            $searchstring = str_replace('speaker:'.$id, "speaker:$name", $searchstring);
297 297
         }
298 298
 
299 299
         return $searchstring;
Please login to merge, or discard this patch.
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.