Failed Conditions
Pull Request — master (#1325)
by Nick
26:10 queued 21:10
created
www/docs/mp/index.php 6 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -590,6 +590,7 @@  discard block
 block discarded – undo
590 590
  * Member Redirect
591 591
  *
592 592
  * Redirect to the canonical page for a member.
593
+ * @param MySociety\TheyWorkForYou\Member $MEMBER
593 594
  */
594 595
 
595 596
 function member_redirect (&$MEMBER, $code = 301, $pagetype = NULL) {
@@ -1056,6 +1057,12 @@  discard block
 block discarded – undo
1056 1057
 
1057 1058
 }
1058 1059
 
1060
+/**
1061
+ * @param string $blurb
1062
+ * @param string $type
1063
+ * @param string $inwhat
1064
+ * @param string $afterstuff
1065
+ */
1059 1066
 function display_stats_line($category, $blurb, $type, $inwhat, $afterstuff, $extra_info, $minister = false, $Lminister = false) {
1060 1067
     $return = false;
1061 1068
     if (isset($extra_info[$category]))
@@ -1065,6 +1072,10 @@  discard block
 block discarded – undo
1065 1072
     return $return;
1066 1073
 }
1067 1074
 
1075
+/**
1076
+ * @param integer $house
1077
+ * @param boolean $minister
1078
+ */
1068 1079
 function display_stats_line_house($house, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff) {
1069 1080
     if ($category == 'wrans_asked_inlastyear' || $category == 'debate_sectionsspoken_inlastyear' || $category =='comments_on_speeches' ||
1070 1081
         $category == 'Lwrans_asked_inlastyear' || $category == 'Ldebate_sectionsspoken_inlastyear' || $category =='Lcomments_on_speeches') {
@@ -1163,6 +1174,9 @@  discard block
 block discarded – undo
1163 1174
     return $reg;
1164 1175
 }
1165 1176
 
1177
+/**
1178
+ * @param string $area_type
1179
+ */
1166 1180
 function regional_list($pc, $area_type, $rep_type) {
1167 1181
     $constituencies = MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($pc);
1168 1182
     if ($constituencies == 'CONNECTION_TIMED_OUT') {
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 // Finally, if this is a Votes page, replace the page description with
256 256
 // something more descriptive of the actual data on the page.
257 257
 if ($pagetype == 'votes') {
258
-  $title = "Voting record - " . $title;
259
-  $desc = 'See how ' . $member_name . ' voted on topics like Employment, Social Issues, Foreign Policy, and more.';
258
+    $title = "Voting record - " . $title;
259
+    $desc = 'See how ' . $member_name . ' voted on topics like Employment, Social Issues, Foreign Policy, and more.';
260 260
 }
261 261
 
262 262
 // Set page metadata
@@ -359,19 +359,19 @@  discard block
 block discarded – undo
359 359
         // Generate voting segments
360 360
         $set_descriptions = $policiesList->getSetDescriptions();
361 361
         if ( $policy_set && array_key_exists($policy_set, $set_descriptions) ) {
362
-          $data['key_votes_segments'] = array(
363
-              array(
364
-                  'key' => $policy_set,
365
-                  'title' => $set_descriptions[$policy_set],
366
-                  'votes' => new MySociety\TheyWorkForYou\PolicyPositions(
367
-                      $policiesList->limitToSet($policy_set), $MEMBER, $policyOptions
368
-                  )
369
-              )
370
-          );
371
-          $data['og_image'] = $MEMBER->url(true) . "/policy_set_png?policy_set=" . $policy_set;
372
-          $data['page_title'] = $policiesList->getSetDescriptions()[$policy_set] . ' ' . $title . ' - TheyWorkForYou';
373
-          $data['meta_description'] = 'See how ' . $data['full_name'] . ' voted on ' . $policiesList->getSetDescriptions()[$policy_set];
374
-          $data['single_policy_page'] = true;
362
+            $data['key_votes_segments'] = array(
363
+                array(
364
+                    'key' => $policy_set,
365
+                    'title' => $set_descriptions[$policy_set],
366
+                    'votes' => new MySociety\TheyWorkForYou\PolicyPositions(
367
+                        $policiesList->limitToSet($policy_set), $MEMBER, $policyOptions
368
+                    )
369
+                )
370
+            );
371
+            $data['og_image'] = $MEMBER->url(true) . "/policy_set_png?policy_set=" . $policy_set;
372
+            $data['page_title'] = $policiesList->getSetDescriptions()[$policy_set] . ' ' . $title . ' - TheyWorkForYou';
373
+            $data['meta_description'] = 'See how ' . $data['full_name'] . ' voted on ' . $policiesList->getSetDescriptions()[$policy_set];
374
+            $data['single_policy_page'] = true;
375 375
         } else {
376 376
             $data['single_policy_page'] = false;
377 377
             $data['key_votes_segments'] = array(
@@ -519,11 +519,11 @@  discard block
 block discarded – undo
519 519
 
520 520
         // Generate voting segments
521 521
         $data['segment'] = array(
522
-          'key'   => $policy_set,
523
-          'title' => $policiesList->getSetDescriptions()[$policy_set],
524
-          'votes' => new MySociety\TheyWorkForYou\PolicyPositions(
525
-              $policiesList->limitToSet($policy_set), $MEMBER
526
-          )
522
+            'key'   => $policy_set,
523
+            'title' => $policiesList->getSetDescriptions()[$policy_set],
524
+            'votes' => new MySociety\TheyWorkForYou\PolicyPositions(
525
+                $policiesList->limitToSet($policy_set), $MEMBER
526
+            )
527 527
         );
528 528
 
529 529
         MySociety\TheyWorkForYou\Renderer::output('mp/votes_svg', $data, true);
Please login to merge, or discard this patch.
Switch Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -731,26 +731,26 @@
 block discarded – undo
731 731
 function person_error_page($message) {
732 732
     global $this_page;
733 733
     switch($this_page) {
734
-    case 'mla':
735
-        $rep = 'MLA';
736
-        $SEARCHURL = '/postcode/';
737
-        $MPSURL = new \URL('mlas');
738
-        break;
739
-    case 'msp':
740
-        $rep = 'MSP';
741
-        $SEARCHURL = '/postcode/';
742
-        $MPSURL = new \URL('msps');
743
-        break;
744
-    case 'peer':
745
-        $rep = 'Lord';
746
-        $SEARCHURL = '';
747
-        $MPSURL = new \URL('peers');
748
-        break;
749
-    default:
750
-        $rep = 'MP';
751
-        $SEARCHURL = new \URL('mp');
752
-        $SEARCHURL = $SEARCHURL->generate();
753
-        $MPSURL = new \URL('mps');
734
+        case 'mla':
735
+            $rep = 'MLA';
736
+            $SEARCHURL = '/postcode/';
737
+            $MPSURL = new \URL('mlas');
738
+            break;
739
+        case 'msp':
740
+            $rep = 'MSP';
741
+            $SEARCHURL = '/postcode/';
742
+            $MPSURL = new \URL('msps');
743
+            break;
744
+        case 'peer':
745
+            $rep = 'Lord';
746
+            $SEARCHURL = '';
747
+            $MPSURL = new \URL('peers');
748
+            break;
749
+        default:
750
+            $rep = 'MP';
751
+            $SEARCHURL = new \URL('mp');
752
+            $SEARCHURL = $SEARCHURL->generate();
753
+            $MPSURL = new \URL('mps');
754 754
     }
755 755
 
756 756
     $data = array(
Please login to merge, or discard this patch.
Braces   +143 added lines, -63 removed lines patch added patch discarded remove patch
@@ -62,16 +62,36 @@  discard block
 block discarded – undo
62 62
 $constituency = strtolower(str_replace('_', ' ', get_http_var('c')));
63 63
 
64 64
 // Fix for names with non-ASCII characters
65
-if ($name == 'sion simon') $name = 'si\xf4n simon';
66
-if ($name == 'sian james') $name = 'si\xe2n james';
67
-if ($name == 'lembit opik') $name = 'lembit \xf6pik';
68
-if ($name == 'bairbre de brun') $name = 'bairbre de br\xfan';
69
-if ($name == 'daithi mckay') $name = 'daith\xed mckay';
70
-if ($name == 'caral ni chuilin') $name = 'car\xe1l n\xed chuil\xedn';
71
-if ($name == 'caledon du pre') $name = 'caledon du pr\xe9';
72
-if ($name == 'sean etchingham') $name = 'se\xe1n etchingham';
73
-if ($name == 'john tinne') $name = 'john tinn\xe9';
74
-if ($name == 'renee short') $name = 'ren\xe9e short';
65
+if ($name == 'sion simon') {
66
+    $name = 'si\xf4n simon';
67
+}
68
+if ($name == 'sian james') {
69
+    $name = 'si\xe2n james';
70
+}
71
+if ($name == 'lembit opik') {
72
+    $name = 'lembit \xf6pik';
73
+}
74
+if ($name == 'bairbre de brun') {
75
+    $name = 'bairbre de br\xfan';
76
+}
77
+if ($name == 'daithi mckay') {
78
+    $name = 'daith\xed mckay';
79
+}
80
+if ($name == 'caral ni chuilin') {
81
+    $name = 'car\xe1l n\xed chuil\xedn';
82
+}
83
+if ($name == 'caledon du pre') {
84
+    $name = 'caledon du pr\xe9';
85
+}
86
+if ($name == 'sean etchingham') {
87
+    $name = 'se\xe1n etchingham';
88
+}
89
+if ($name == 'john tinne') {
90
+    $name = 'john tinn\xe9';
91
+}
92
+if ($name == 'renee short') {
93
+    $name = 'ren\xe9e short';
94
+}
75 95
 
76 96
 // Fix for common misspellings, name changes etc
77 97
 $name_fix = array(
@@ -103,7 +123,9 @@  discard block
 block discarded – undo
103 123
 }
104 124
 
105 125
 // Fixes for Ynys Mon, and a Unicode URL
106
-if ($constituency == 'ynys mon') $constituency = "ynys m\xf4n";
126
+if ($constituency == 'ynys mon') {
127
+    $constituency = "ynys m\xf4n";
128
+}
107 129
 if (preg_match("#^ynys m\xc3\xb4n#i", $constituency)) {
108 130
     $constituency = "ynys m\xf4n";
109 131
 }
@@ -126,11 +148,17 @@  discard block
 block discarded – undo
126 148
 
127 149
 /////////////////////////////////////////////////////////
128 150
 // DETERMINE TYPE OF REPRESENTITIVE
129
-if (get_http_var('peer')) $this_page = 'peer';
130
-elseif (get_http_var('royal')) $this_page = 'royal';
131
-elseif (get_http_var('mla')) $this_page = 'mla';
132
-elseif (get_http_var('msp')) $this_page = 'msp';
133
-else $this_page = 'mp';
151
+if (get_http_var('peer')) {
152
+    $this_page = 'peer';
153
+} elseif (get_http_var('royal')) {
154
+    $this_page = 'royal';
155
+} elseif (get_http_var('mla')) {
156
+    $this_page = 'mla';
157
+} elseif (get_http_var('msp')) {
158
+    $this_page = 'msp';
159
+} else {
160
+    $this_page = 'mp';
161
+}
134 162
 
135 163
 try {
136 164
     if (is_numeric($pid)) {
@@ -179,8 +207,9 @@  discard block
 block discarded – undo
179 207
 $desc = "Read $member_name's contributions to Parliament, including speeches and questions";
180 208
 
181 209
 // Enhance description if this is a current member
182
-if ($MEMBER->current_member_anywhere())
210
+if ($MEMBER->current_member_anywhere()) {
183 211
     $desc .= ', investigate their voting record, and get email alerts on their activity';
212
+}
184 213
 
185 214
 // Enhance title if this is a member of the Commons
186 215
 if ($MEMBER->house(HOUSE_TYPE_COMMONS)) {
@@ -188,8 +217,10 @@  discard block
 block discarded – undo
188 217
         $title .= ', former';
189 218
     }
190 219
     $title .= ' MP';
191
-    if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency();
192
-}
220
+    if ($MEMBER->constituency()) {
221
+        $title .= ', ' . $MEMBER->constituency();
222
+    }
223
+    }
193 224
 
194 225
 // Enhance title if this is a member of NIA
195 226
 if ($MEMBER->house(HOUSE_TYPE_NI)) {
@@ -202,8 +233,10 @@  discard block
 block discarded – undo
202 233
         $title .= ', former';
203 234
     }
204 235
     $title .= ' MLA';
205
-    if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency();
206
-}
236
+    if ($MEMBER->constituency()) {
237
+        $title .= ', ' . $MEMBER->constituency();
238
+    }
239
+    }
207 240
 
208 241
 // Enhance title if this is a member of Scottish Parliament
209 242
 if ($MEMBER->house(HOUSE_TYPE_SCOTLAND)) {
@@ -224,14 +257,18 @@  discard block
 block discarded – undo
224 257
 // Position if this is a member of the Commons
225 258
 if ($MEMBER->house(HOUSE_TYPE_COMMONS)) {
226 259
     $position = $MEMBER->current_member(HOUSE_TYPE_COMMONS) ? 'MP' : 'Former MP';
227
-    if ($MEMBER->constituency()) $position .= ', ' . $MEMBER->constituency();
260
+    if ($MEMBER->constituency()) {
261
+        $position .= ', ' . $MEMBER->constituency();
262
+    }
228 263
     $positions[] = $position;
229 264
 }
230 265
 
231 266
 // Position if this is a member of NIA
232 267
 if ($MEMBER->house(HOUSE_TYPE_NI)) {
233 268
     $position = $MEMBER->current_member(HOUSE_TYPE_NI) ? 'MLA' : 'Former MLA';
234
-    if ($MEMBER->constituency()) $position .= ', ' . $MEMBER->constituency();
269
+    if ($MEMBER->constituency()) {
270
+        $position .= ', ' . $MEMBER->constituency();
271
+    }
235 272
     $positions[] = $position;
236 273
 }
237 274
 
@@ -265,8 +302,9 @@  discard block
 block discarded – undo
265 302
 
266 303
 // Build the RSS link and add it to page data.
267 304
 $feedurl = $DATA->page_metadata('mp_rss', 'url') . $MEMBER->person_id() . '.rdf';
268
-if (file_exists(BASEDIR . '/' . $feedurl))
305
+if (file_exists(BASEDIR . '/' . $feedurl)) {
269 306
     $DATA->set_page_metadata($this_page, 'rss', $feedurl);
307
+}
270 308
 
271 309
 // Prepare data for the template
272 310
 $data['full_name'] = $MEMBER->full_name();
@@ -692,11 +730,13 @@  discard block
 block discarded – undo
692 730
         $url = $MEMBER->url();
693 731
         $params = array();
694 732
         foreach ($_GET as $key => $value) {
695
-            if (substr($key, 0, 4) == 'utm_' || $key == 'gclid')
696
-                $params[] = "$key=$value";
733
+            if (substr($key, 0, 4) == 'utm_' || $key == 'gclid') {
734
+                            $params[] = "$key=$value";
735
+            }
736
+        }
737
+        if (count($params)) {
738
+                    $url .= '?' . join('&', $params);
697 739
         }
698
-        if (count($params))
699
-            $url .= '?' . join('&', $params);
700 740
         if ($pagetype) {
701 741
             $pagetype = '/' . $pagetype;
702 742
         } else {
@@ -779,10 +819,14 @@  discard block
 block discarded – undo
779 819
     }
780 820
     $desc = '';
781 821
     foreach ($MEMBER->houses() as $house) {
782
-        if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS]))
783
-            continue; # Same info is printed further down
822
+        if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS])) {
823
+                    continue;
824
+        }
825
+        # Same info is printed further down
784 826
 
785
-        if (!$current_member[$house]) $desc .= 'Former ';
827
+        if (!$current_member[$house]) {
828
+            $desc .= 'Former ';
829
+        }
786 830
 
787 831
         $party = $left_house[$house]['party'];
788 832
         $party_br = '';
@@ -790,8 +834,9 @@  discard block
 block discarded – undo
790 834
             $party_br = $m[2];
791 835
             $party = $m[1];
792 836
         }
793
-        if ($party != 'unknown')
794
-            $desc .= _htmlentities($party);
837
+        if ($party != 'unknown') {
838
+                    $desc .= _htmlentities($party);
839
+        }
795 840
         if ($party == 'Speaker' || $party == 'Deputy Speaker') {
796 841
             $desc .= ', and ';
797 842
             # XXX: Might go horribly wrong if something odd happens
@@ -802,15 +847,23 @@  discard block
 block discarded – undo
802 847
         }
803 848
         if ($house==HOUSE_TYPE_COMMONS || $house==HOUSE_TYPE_NI || $house==HOUSE_TYPE_SCOTLAND) {
804 849
             $desc .= ' ';
805
-            if ($house==HOUSE_TYPE_COMMONS) $desc .= '<abbr title="Member of Parliament">MP</abbr>';
806
-            if ($house==HOUSE_TYPE_NI) $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>';
807
-            if ($house==HOUSE_TYPE_SCOTLAND) $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>';
850
+            if ($house==HOUSE_TYPE_COMMONS) {
851
+                $desc .= '<abbr title="Member of Parliament">MP</abbr>';
852
+            }
853
+            if ($house==HOUSE_TYPE_NI) {
854
+                $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>';
855
+            }
856
+            if ($house==HOUSE_TYPE_SCOTLAND) {
857
+                $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>';
858
+            }
808 859
             if ($party_br) {
809 860
                 $desc .= " ($party_br)";
810 861
             }
811 862
             $desc .= ' for ' . $left_house[$house]['constituency'];
812 863
         }
813
-        if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') $desc .= ' Peer';
864
+        if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') {
865
+            $desc .= ' Peer';
866
+        }
814 867
         $desc .= ', ';
815 868
     }
816 869
     $desc = preg_replace('#, $#', '', $desc);
@@ -1073,10 +1126,13 @@  discard block
 block discarded – undo
1073 1126
     # Find latest entered house
1074 1127
     $entered_house = null;
1075 1128
     foreach ($member->entered_house() as $h => $eh) {
1076
-        if (!$entered_house || $eh['date'] > $entered_house) $entered_house = $eh['date'];
1129
+        if (!$entered_house || $eh['date'] > $entered_house) {
1130
+            $entered_house = $eh['date'];
1131
+        }
1132
+    }
1133
+    if ($entered_house > $year_ago) {
1134
+            $since_text = 'since joining Parliament';
1077 1135
     }
1078
-    if ($entered_house > $year_ago)
1079
-        $since_text = 'since joining Parliament';
1080 1136
 
1081 1137
     $MOREURL = new \URL('search');
1082 1138
     $section = 'section:debates section:whall section:lords section:ni';
@@ -1089,10 +1145,12 @@  discard block
 block discarded – undo
1089 1145
         $MOREURL->insert(array('pid'=>$member->person_id(), 's'=>'section:wrans', 'pop'=>1));
1090 1146
         // We assume that if they've answered a question, they're a minister
1091 1147
         $minister = 0; $Lminister = false;
1092
-        if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0)
1093
-            $minister = 1;
1094
-        if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0)
1095
-            $Lminister = true;
1148
+        if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0) {
1149
+                    $minister = 1;
1150
+        }
1151
+        if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0) {
1152
+                    $Lminister = true;
1153
+        }
1096 1154
         if ($member->party() == 'SPK' || $member->party() == 'CWM' || $member->party() == 'DCWM') {
1097 1155
             $minister = 2;
1098 1156
         }
@@ -1141,11 +1199,17 @@  discard block
 block discarded – undo
1141 1199
 
1142 1200
     if (isset($extra_info['number_of_alerts']) && ($extra_info['number_of_alerts']>0 || $has_email_alerts)) {
1143 1201
         $line = '<strong>' . _htmlentities($extra_info['number_of_alerts']) . '</strong> ' . ($extra_info['number_of_alerts']==1?'person is':'people are') . ' tracking ';
1144
-        if ($member->house_disp == HOUSE_TYPE_COMMONS) $line .= 'this MP';
1145
-        elseif ($member->house_disp == HOUSE_TYPE_LORDS) $line .= 'this peer';
1146
-        elseif ($member->house_disp == HOUSE_TYPE_NI) $line .= 'this MLA';
1147
-        elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) $line .= 'this MSP';
1148
-        elseif ($member->house_disp == HOUSE_TYPE_ROYAL) $line .= $member->full_name();
1202
+        if ($member->house_disp == HOUSE_TYPE_COMMONS) {
1203
+            $line .= 'this MP';
1204
+        } elseif ($member->house_disp == HOUSE_TYPE_LORDS) {
1205
+            $line .= 'this peer';
1206
+        } elseif ($member->house_disp == HOUSE_TYPE_NI) {
1207
+            $line .= 'this MLA';
1208
+        } elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) {
1209
+            $line .= 'this MSP';
1210
+        } elseif ($member->house_disp == HOUSE_TYPE_ROYAL) {
1211
+            $line .= $member->full_name();
1212
+        }
1149 1213
         if ($has_email_alerts) {
1150 1214
             $line .= ' &mdash; <a href="' . WEBPATH . 'alert/?pid='.$member->person_id().'">email me updates on '. $member->full_name(). '&rsquo;s activity</a>';
1151 1215
         }
@@ -1169,10 +1233,12 @@  discard block
 block discarded – undo
1169 1233
 
1170 1234
 function display_stats_line($category, $blurb, $type, $inwhat, $afterstuff, $extra_info, $minister = false, $Lminister = false) {
1171 1235
     $return = false;
1172
-    if (isset($extra_info[$category]))
1173
-        $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff);
1174
-    if (isset($extra_info["L$category"]))
1175
-        $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff);
1236
+    if (isset($extra_info[$category])) {
1237
+            $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff);
1238
+    }
1239
+    if (isset($extra_info["L$category"])) {
1240
+            $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff);
1241
+    }
1176 1242
     return $return;
1177 1243
 }
1178 1244
 
@@ -1184,17 +1250,21 @@  discard block
 block discarded – undo
1184 1250
             $inwhat = preg_replace('#<\/a>#', '', $inwhat);
1185 1251
         }
1186 1252
     }
1187
-    if ($house==HOUSE_TYPE_LORDS) $inwhat = str_replace('MP', 'Lord', $inwhat);
1253
+    if ($house==HOUSE_TYPE_LORDS) {
1254
+        $inwhat = str_replace('MP', 'Lord', $inwhat);
1255
+    }
1188 1256
     $line = $blurb;
1189 1257
     $line .= '<strong>' . $extra_info[$category];
1190
-    if ($type) $line .= ' ' . make_plural($type, $extra_info[$category]);
1258
+    if ($type) {
1259
+        $line .= ' ' . make_plural($type, $extra_info[$category]);
1260
+    }
1191 1261
     $line .= '</strong>';
1192 1262
     $line .= $inwhat;
1193 1263
     if ($minister===2) {
1194 1264
         $line .= ' &#8212; Speakers/ deputy speakers do not ask written questions';
1195
-    } elseif ($minister)
1196
-        $line .= ' &#8212; Ministers do not ask written questions';
1197
-    else {
1265
+    } elseif ($minister) {
1266
+            $line .= ' &#8212; Ministers do not ask written questions';
1267
+    } else {
1198 1268
         $type = ($house==HOUSE_TYPE_COMMONS?'MP':($house==HOUSE_TYPE_LORDS?'Lord':'MLA'));
1199 1269
         if (!get_http_var('rem') && isset($extra_info[$category . '_quintile'])) {
1200 1270
             $line .= ' &#8212; ';
@@ -1233,11 +1303,21 @@  discard block
 block discarded – undo
1233 1303
         $mean = $extra_info["writetothem_responsiveness_mean_$year"];
1234 1304
 
1235 1305
         $a = $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"];
1236
-        if ($a == 'very low') $a = 'a very low';
1237
-        if ($a == 'low') $a = 'a low';
1238
-        if ($a == 'medium') $a = 'a medium';
1239
-        if ($a == 'high') $a = 'a high';
1240
-        if ($a == 'very high') $a = 'a very high';
1306
+        if ($a == 'very low') {
1307
+            $a = 'a very low';
1308
+        }
1309
+        if ($a == 'low') {
1310
+            $a = 'a low';
1311
+        }
1312
+        if ($a == 'medium') {
1313
+            $a = 'a medium';
1314
+        }
1315
+        if ($a == 'high') {
1316
+            $a = 'a high';
1317
+        }
1318
+        if ($a == 'very high') {
1319
+            $a = 'a very high';
1320
+        }
1241 1321
         $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"] = $a;
1242 1322
 
1243 1323
         return display_stats_line("writetothem_responsiveness_fuzzy_response_description_$year", 'Replied within 2 or 3 weeks to <a href="https://www.writetothem.com/stats/'.$year.'/mps" title="From WriteToThem.com">', "", "</a> <!-- Mean: " . $mean . " --> number of messages sent via WriteToThem.com during ".$year.", according to constituents", "", $extra_info);
Please login to merge, or discard this patch.
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
 
34 34
 // Include all the things this page needs.
35 35
 include_once '../../includes/easyparliament/init.php';
36
-include_once INCLUDESPATH . 'easyparliament/member.php';
37
-include_once INCLUDESPATH . 'technorati.php';
38
-include_once INCLUDESPATH . '../../commonlib/phplib/random.php';
39
-include_once INCLUDESPATH . '../../commonlib/phplib/auth.php';
36
+include_once INCLUDESPATH.'easyparliament/member.php';
37
+include_once INCLUDESPATH.'technorati.php';
38
+include_once INCLUDESPATH.'../../commonlib/phplib/random.php';
39
+include_once INCLUDESPATH.'../../commonlib/phplib/auth.php';
40 40
 include_once '../api/api_getGeometry.php';
41 41
 include_once '../api/api_getConstituencies.php';
42 42
 
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
     }
119 119
     if ($pid) {
120 120
         $URL = new URL('search');
121
-        $URL->insert( array('pid'=>$pid, 'pop'=>1) );
122
-        header('Location: ' . $URL->generate('none'));
121
+        $URL->insert(array('pid'=>$pid, 'pop'=>1));
122
+        header('Location: '.$URL->generate('none'));
123 123
         exit;
124 124
     }
125 125
 }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     } elseif ($THEUSER->postcode_is_set()) {
150 150
         get_mp_by_user_postcode($THEUSER->postcode());
151 151
     } else {
152
-        twfy_debug ('MP', "We don't have any way of telling what MP to display");
152
+        twfy_debug('MP', "We don't have any way of telling what MP to display");
153 153
         throw new MySociety\TheyWorkForYou\MemberException('Sorry, but we can&rsquo;t tell which representative to display.');
154 154
     }
155 155
     if (!isset($MEMBER) || !$MEMBER->valid) {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         $title .= ', former';
189 189
     }
190 190
     $title .= ' MP';
191
-    if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency();
191
+    if ($MEMBER->constituency()) $title .= ', '.$MEMBER->constituency();
192 192
 }
193 193
 
194 194
 // Enhance title if this is a member of NIA
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         $title .= ', former';
203 203
     }
204 204
     $title .= ' MLA';
205
-    if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency();
205
+    if ($MEMBER->constituency()) $title .= ', '.$MEMBER->constituency();
206 206
 }
207 207
 
208 208
 // Enhance title if this is a member of Scottish Parliament
@@ -224,21 +224,21 @@  discard block
 block discarded – undo
224 224
 // Position if this is a member of the Commons
225 225
 if ($MEMBER->house(HOUSE_TYPE_COMMONS)) {
226 226
     $position = $MEMBER->current_member(HOUSE_TYPE_COMMONS) ? 'MP' : 'Former MP';
227
-    if ($MEMBER->constituency()) $position .= ', ' . $MEMBER->constituency();
227
+    if ($MEMBER->constituency()) $position .= ', '.$MEMBER->constituency();
228 228
     $positions[] = $position;
229 229
 }
230 230
 
231 231
 // Position if this is a member of NIA
232 232
 if ($MEMBER->house(HOUSE_TYPE_NI)) {
233 233
     $position = $MEMBER->current_member(HOUSE_TYPE_NI) ? 'MLA' : 'Former MLA';
234
-    if ($MEMBER->constituency()) $position .= ', ' . $MEMBER->constituency();
234
+    if ($MEMBER->constituency()) $position .= ', '.$MEMBER->constituency();
235 235
     $positions[] = $position;
236 236
 }
237 237
 
238 238
 // Position if this is a member of Scottish Parliament
239 239
 if ($MEMBER->house(HOUSE_TYPE_SCOTLAND)) {
240 240
     $position = $MEMBER->current_member(HOUSE_TYPE_SCOTLAND) ? 'MSP' : 'Former MSP';
241
-    $position .= ', ' . $MEMBER->constituency();
241
+    $position .= ', '.$MEMBER->constituency();
242 242
     $positions[] = $position;
243 243
 }
244 244
 
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 // Finally, if this is a Votes page, replace the page description with
256 256
 // something more descriptive of the actual data on the page.
257 257
 if ($pagetype == 'votes') {
258
-  $title = "Voting record - " . $title;
259
-  $desc = 'See how ' . $member_name . ' voted on topics like Employment, Social Issues, Foreign Policy, and more.';
258
+  $title = "Voting record - ".$title;
259
+  $desc = 'See how '.$member_name.' voted on topics like Employment, Social Issues, Foreign Policy, and more.';
260 260
 }
261 261
 
262 262
 // Set page metadata
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 $DATA->set_page_metadata($this_page, 'meta_description', $desc);
265 265
 
266 266
 // Build the RSS link and add it to page data.
267
-$feedurl = $DATA->page_metadata('mp_rss', 'url') . $MEMBER->person_id() . '.rdf';
268
-if (file_exists(BASEDIR . '/' . $feedurl))
267
+$feedurl = $DATA->page_metadata('mp_rss', 'url').$MEMBER->person_id().'.rdf';
268
+if (file_exists(BASEDIR.'/'.$feedurl))
269 269
     $DATA->set_page_metadata($this_page, 'rss', $feedurl);
270 270
 
271 271
 // Prepare data for the template
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 $data['eu_stance'] = $MEMBER->getEUStance();
311 311
 
312 312
 # People who are or were MPs and Lords potentially have voting records, except Sinn Fein MPs
313
-$data['has_voting_record'] = ( ($MEMBER->house(HOUSE_TYPE_COMMONS) && $MEMBER->party() != 'Sinn Féin') || $MEMBER->house(HOUSE_TYPE_LORDS) );
313
+$data['has_voting_record'] = (($MEMBER->house(HOUSE_TYPE_COMMONS) && $MEMBER->party() != 'Sinn Féin') || $MEMBER->house(HOUSE_TYPE_LORDS));
314 314
 # Everyone who is currently somewhere has email alert signup, apart from current Sinn Fein MPs who are not MLAs
315 315
 $data['has_email_alerts'] = ($MEMBER->current_member_anywhere() && !($MEMBER->current_member(HOUSE_TYPE_COMMONS) && $MEMBER->party() == 'Sinn Féin' && !$MEMBER->current_member(HOUSE_TYPE_NI)));
316 316
 $data['has_expenses'] = $data['leave_date'] > '2004-01-01';
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 
337 337
 $data['this_page'] = $this_page;
338 338
 $data['current_assembly'] = 'westminster';
339
-if ( $this_page == 'msp' || $this_page == 'yourmsp' ) {
339
+if ($this_page == 'msp' || $this_page == 'yourmsp') {
340 340
     $data['current_assembly'] = 'scotland';
341
-} else if ( $this_page == 'mla' || $this_page == 'yourmla' ) {
341
+} else if ($this_page == 'mla' || $this_page == 'yourmla') {
342 342
     $data['current_assembly'] = 'ni';
343 343
 }
344 344
 
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
         $divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER);
355 355
         $policySummaries = $divisions->getMemberDivisionDetails();
356 356
 
357
-        $policyOptions = array( 'summaries' => $policySummaries);
357
+        $policyOptions = array('summaries' => $policySummaries);
358 358
 
359 359
         // Generate voting segments
360 360
         $set_descriptions = $policiesList->getSetDescriptions();
361
-        if ( $policy_set && array_key_exists($policy_set, $set_descriptions) ) {
361
+        if ($policy_set && array_key_exists($policy_set, $set_descriptions)) {
362 362
           $data['key_votes_segments'] = array(
363 363
               array(
364 364
                   'key' => $policy_set,
@@ -368,9 +368,9 @@  discard block
 block discarded – undo
368 368
                   )
369 369
               )
370 370
           );
371
-          $data['og_image'] = $MEMBER->url(true) . "/policy_set_png?policy_set=" . $policy_set;
372
-          $data['page_title'] = $policiesList->getSetDescriptions()[$policy_set] . ' ' . $title . ' - TheyWorkForYou';
373
-          $data['meta_description'] = 'See how ' . $data['full_name'] . ' voted on ' . $policiesList->getSetDescriptions()[$policy_set];
371
+          $data['og_image'] = $MEMBER->url(true)."/policy_set_png?policy_set=".$policy_set;
372
+          $data['page_title'] = $policiesList->getSetDescriptions()[$policy_set].' '.$title.' - TheyWorkForYou';
373
+          $data['meta_description'] = 'See how '.$data['full_name'].' voted on '.$policiesList->getSetDescriptions()[$policy_set];
374 374
           $data['single_policy_page'] = true;
375 375
         } else {
376 376
             $data['single_policy_page'] = false;
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 
477 477
     case 'recent':
478 478
         $policiesList = new MySociety\TheyWorkForYou\Policies;
479
-        $positions = new MySociety\TheyWorkForYou\PolicyPositions( $policiesList, $MEMBER );
479
+        $positions = new MySociety\TheyWorkForYou\PolicyPositions($policiesList, $MEMBER);
480 480
         $divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER, $positions, $policiesList);
481 481
 
482 482
         $data['divisions'] = $divisions->getRecentMemberDivisions();
@@ -487,15 +487,15 @@  discard block
 block discarded – undo
487 487
 
488 488
     case 'divisions':
489 489
         $policyID = get_http_var('policy');
490
-        if ( $policyID ) {
491
-            $policiesList = new MySociety\TheyWorkForYou\Policies( $policyID );
490
+        if ($policyID) {
491
+            $policiesList = new MySociety\TheyWorkForYou\Policies($policyID);
492 492
         } else {
493 493
             $policiesList = new MySociety\TheyWorkForYou\Policies;
494 494
         }
495
-        $positions = new MySociety\TheyWorkForYou\PolicyPositions( $policiesList, $MEMBER );
495
+        $positions = new MySociety\TheyWorkForYou\PolicyPositions($policiesList, $MEMBER);
496 496
         $divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER, $positions, $policiesList);
497 497
 
498
-        if ( $policyID ) {
498
+        if ($policyID) {
499 499
             $data['policydivisions'] = $divisions->getMemberDivisionsForPolicy($policyID);
500 500
         } else {
501 501
             $data['policydivisions'] = $divisions->getAllMemberDivisionsByPolicy();
@@ -542,15 +542,15 @@  discard block
 block discarded – undo
542 542
         $im = new Imagick();
543 543
         $policiesList = new MySociety\TheyWorkForYou\Policies;
544 544
 
545
-        $url = $MEMBER->url(true) . "/policy_set_svg?policy_set=" . $policy_set;
545
+        $url = $MEMBER->url(true)."/policy_set_svg?policy_set=".$policy_set;
546 546
         $svg = file_get_contents($url);
547 547
         $im->setOption('-antialias', true);
548 548
         $im->readImageBlob($svg);
549 549
         $im->setImageFormat("png24");
550 550
 
551
-        $filename = strtolower(str_replace(' ', '_', $MEMBER->full_name() . "_" . $policiesList->getSetDescriptions()[$policy_set] . ".png"));
551
+        $filename = strtolower(str_replace(' ', '_', $MEMBER->full_name()."_".$policiesList->getSetDescriptions()[$policy_set].".png"));
552 552
         header("Content-type: image/png");
553
-        header('Content-Disposition: filename="' . $filename . '"');
553
+        header('Content-Disposition: filename="'.$filename.'"');
554 554
         print $im->getImageBlob();
555 555
 
556 556
         $im->clear();
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
         // generate party policy diffs
574 574
         $party = new MySociety\TheyWorkForYou\Party($MEMBER->party());
575
-        $positions = new MySociety\TheyWorkForYou\PolicyPositions( $policiesList, $MEMBER );
575
+        $positions = new MySociety\TheyWorkForYou\PolicyPositions($policiesList, $MEMBER);
576 576
         $party_positions = $party->getAllPolicyPositions($policiesList);
577 577
         $policy_diffs = $MEMBER->getPartyPolicyDiffs($party, $policiesList, $positions, true);
578 578
 
@@ -626,16 +626,16 @@  discard block
 block discarded – undo
626 626
     global $THEUSER;
627 627
     $pc = preg_replace('#[^a-z0-9]#i', '', $pc);
628 628
     if (!validate_postcode($pc)) {
629
-        twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
630
-        throw new MySociety\TheyWorkForYou\MemberException('Sorry, '._htmlentities($pc) .' isn&rsquo;t a valid postcode');
629
+        twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
630
+        throw new MySociety\TheyWorkForYou\MemberException('Sorry, '._htmlentities($pc).' isn&rsquo;t a valid postcode');
631 631
     }
632
-    twfy_debug ('MP', "MP lookup by postcode");
632
+    twfy_debug('MP', "MP lookup by postcode");
633 633
     $constituency = strtolower(MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituency($pc));
634 634
     if ($constituency == "connection_timed_out") {
635 635
         throw new MySociety\TheyWorkForYou\MemberException('Sorry, we couldn&rsquo;t check your postcode right now, as our postcode lookup server is under quite a lot of load.');
636 636
     } elseif ($constituency == "") {
637
-        twfy_debug ('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
638
-        throw new MySociety\TheyWorkForYou\MemberException('Sorry, '._htmlentities($pc) .' isn&rsquo;t a known postcode');
637
+        twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
638
+        throw new MySociety\TheyWorkForYou\MemberException('Sorry, '._htmlentities($pc).' isn&rsquo;t a known postcode');
639 639
     } else {
640 640
         // Redirect to the canonical MP page, with a person id.
641 641
         $MEMBER = new MySociety\TheyWorkForYou\Member(array('constituency' => $constituency, 'house' => HOUSE_TYPE_COMMONS));
@@ -647,11 +647,11 @@  discard block
 block discarded – undo
647 647
     }
648 648
 }
649 649
 
650
-function get_person_by_name($name, $const='') {
650
+function get_person_by_name($name, $const = '') {
651 651
     $MEMBER = new MySociety\TheyWorkForYou\Member(array('name' => $name, 'constituency' => $const));
652 652
     // Edge case, only attempt further detection if this isn't the Queen.
653 653
     if ($name !== 'elizabeth the second' || $const) {
654
-        twfy_debug ('MP', 'Redirecting for MP found by name/constituency');
654
+        twfy_debug('MP', 'Redirecting for MP found by name/constituency');
655 655
         member_redirect($MEMBER);
656 656
     }
657 657
     return $MEMBER;
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
  * Redirect to the canonical page for a member.
686 686
  */
687 687
 
688
-function member_redirect (&$MEMBER, $code = 301, $pagetype = NULL) {
688
+function member_redirect(&$MEMBER, $code = 301, $pagetype = NULL) {
689 689
     // We come here after creating a MEMBER object by various methods.
690 690
     // Now we redirect to the canonical MP page, with a person_id.
691 691
     if ($MEMBER->person_id()) {
@@ -696,13 +696,13 @@  discard block
 block discarded – undo
696 696
                 $params[] = "$key=$value";
697 697
         }
698 698
         if (count($params))
699
-            $url .= '?' . join('&', $params);
699
+            $url .= '?'.join('&', $params);
700 700
         if ($pagetype) {
701
-            $pagetype = '/' . $pagetype;
701
+            $pagetype = '/'.$pagetype;
702 702
         } else {
703 703
             $pagetype = '';
704 704
         }
705
-        header('Location: ' . $url . $pagetype, true, $code );
705
+        header('Location: '.$url.$pagetype, true, $code);
706 706
         exit;
707 707
     }
708 708
 }
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
     $data = array('mps' => array());
718 718
     foreach ($ids as $id => $constituency) {
719 719
         $data['mps'][] = array(
720
-            'url'  => WEBPATH . 'mp/?pid=' . $id,
721
-            'name' => ucwords(strtolower($name)) . ', ' . $constituency,
720
+            'url'  => WEBPATH.'mp/?pid='.$id,
721
+            'name' => ucwords(strtolower($name)).', '.$constituency,
722 722
         );
723 723
     }
724 724
     $MPSURL = new \URL('mps');
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 
731 731
 function person_error_page($message) {
732 732
     global $this_page;
733
-    switch($this_page) {
733
+    switch ($this_page) {
734 734
     case 'mla':
735 735
         $rep = 'MLA';
736 736
         $SEARCHURL = '/postcode/';
@@ -768,18 +768,18 @@  discard block
 block discarded – undo
768 768
  * Generate the summary of this person's held positions.
769 769
  */
770 770
 
771
-function person_summary_description ($MEMBER) {
771
+function person_summary_description($MEMBER) {
772 772
     $entered_house = $MEMBER->entered_house();
773 773
     $current_member = $MEMBER->current_member();
774 774
     $left_house = $MEMBER->left_house();
775 775
 
776 776
     if (in_array(HOUSE_TYPE_ROYAL, $MEMBER->houses())) { # Royal short-circuit
777
-        return '<strong>Acceded on ' . $entered_house[HOUSE_TYPE_ROYAL]['date_pretty']
777
+        return '<strong>Acceded on '.$entered_house[HOUSE_TYPE_ROYAL]['date_pretty']
778 778
             . '<br>Coronated on 2 June 1953</strong></li>';
779 779
     }
780 780
     $desc = '';
781 781
     foreach ($MEMBER->houses() as $house) {
782
-        if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS]))
782
+        if ($house == HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS]))
783 783
             continue; # Same info is printed further down
784 784
 
785 785
         if (!$current_member[$house]) $desc .= 'Former ';
@@ -797,20 +797,20 @@  discard block
 block discarded – undo
797 797
             # XXX: Might go horribly wrong if something odd happens
798 798
             if ($party == 'Deputy Speaker') {
799 799
                 $last = end($MEMBER->other_parties);
800
-                $desc .= $last['from'] . ' ';
800
+                $desc .= $last['from'].' ';
801 801
             }
802 802
         }
803
-        if ($house==HOUSE_TYPE_COMMONS || $house==HOUSE_TYPE_NI || $house==HOUSE_TYPE_SCOTLAND) {
803
+        if ($house == HOUSE_TYPE_COMMONS || $house == HOUSE_TYPE_NI || $house == HOUSE_TYPE_SCOTLAND) {
804 804
             $desc .= ' ';
805
-            if ($house==HOUSE_TYPE_COMMONS) $desc .= '<abbr title="Member of Parliament">MP</abbr>';
806
-            if ($house==HOUSE_TYPE_NI) $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>';
807
-            if ($house==HOUSE_TYPE_SCOTLAND) $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>';
805
+            if ($house == HOUSE_TYPE_COMMONS) $desc .= '<abbr title="Member of Parliament">MP</abbr>';
806
+            if ($house == HOUSE_TYPE_NI) $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>';
807
+            if ($house == HOUSE_TYPE_SCOTLAND) $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>';
808 808
             if ($party_br) {
809 809
                 $desc .= " ($party_br)";
810 810
             }
811
-            $desc .= ' for ' . $left_house[$house]['constituency'];
811
+            $desc .= ' for '.$left_house[$house]['constituency'];
812 812
         }
813
-        if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') $desc .= ' Peer';
813
+        if ($house == HOUSE_TYPE_LORDS && $party != 'Bishop') $desc .= ' Peer';
814 814
         $desc .= ', ';
815 815
     }
816 816
     $desc = preg_replace('#, $#', '', $desc);
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
  * @return string A HTML summary of this person's rebellion rate.
828 828
  */
829 829
 
830
-function person_rebellion_rate ($member) {
830
+function person_rebellion_rate($member) {
831 831
 
832 832
     // Rebellion string may be empty.
833 833
     $rebellion_string = '';
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
         $displayed_stuff = 1;
837 837
         $rebels_term = 'rebelled';
838 838
 
839
-        $rebellion_string = 'has <a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/' . $member->member_id() . '#divisions" title="See more details at Public Whip"><strong>' . _htmlentities($member->extra_info['public_whip_rebel_description']) . ' ' . $rebels_term . '</strong></a> against their party';
839
+        $rebellion_string = 'has <a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/'.$member->member_id().'#divisions" title="See more details at Public Whip"><strong>'._htmlentities($member->extra_info['public_whip_rebel_description']).' '.$rebels_term.'</strong></a> against their party';
840 840
 
841 841
         if (isset($member->extra_info['public_whip_rebelrank'])) {
842 842
             if ($member->extra_info['public_whip_data_date'] == 'complete') {
@@ -866,10 +866,10 @@  discard block
 block discarded – undo
866 866
     // benefit unfortunately.
867 867
     twfy_debug_timestamp();
868 868
 
869
-    $person_id= $member->person_id();
869
+    $person_id = $member->person_id();
870 870
 
871 871
     $memcache = new MySociety\TheyWorkForYou\Memcache;
872
-    $recent = $memcache->get('recent_appear:' . $person_id);
872
+    $recent = $memcache->get('recent_appear:'.$person_id);
873 873
 
874 874
     if (!$recent) {
875 875
         // Initialise the search engine
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
         $SEARCHENGINE = new \SEARCHENGINE($searchstring);
878 878
 
879 879
         $hansard = new MySociety\TheyWorkForYou\Hansard();
880
-        $args = array (
880
+        $args = array(
881 881
             's' => $searchstring,
882 882
             'p' => 1,
883 883
             'num' => 3,
@@ -886,21 +886,21 @@  discard block
 block discarded – undo
886 886
         );
887 887
         $results = $hansard->search($searchstring, $args);
888 888
         $recent = serialize($results['rows']);
889
-        $memcache->set('recent_appear:' . $person_id, $recent);
889
+        $memcache->set('recent_appear:'.$person_id, $recent);
890 890
     }
891 891
     $out['appearances'] = unserialize($recent);
892 892
     twfy_debug_timestamp();
893 893
 
894 894
     $MOREURL = new \URL('search');
895
-    $MOREURL->insert( array('pid'=>$person_id, 'pop'=>1) );
895
+    $MOREURL->insert(array('pid'=>$person_id, 'pop'=>1));
896 896
 
897
-    $out['more_href'] = $MOREURL->generate() . '#n4';
898
-    $out['more_text'] = 'More of ' . ucfirst($member->full_name()) . '&rsquo;s recent appearances';
897
+    $out['more_href'] = $MOREURL->generate().'#n4';
898
+    $out['more_text'] = 'More of '.ucfirst($member->full_name()).'&rsquo;s recent appearances';
899 899
 
900 900
     if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
901 901
         // If we set an RSS feed for this page.
902 902
         $HELPURL = new \URL('help');
903
-        $out['additional_links'] = '<a href="' . WEBPATH . $rssurl . '" title="XML version of this person&rsquo;s recent appearances">RSS feed</a> (<a href="' . $HELPURL->generate() . '#rss" title="An explanation of what RSS feeds are for">?</a>)';
903
+        $out['additional_links'] = '<a href="'.WEBPATH.$rssurl.'" title="XML version of this person&rsquo;s recent appearances">RSS feed</a> (<a href="'.$HELPURL->generate().'#rss" title="An explanation of what RSS feeds are for">?</a>)';
904 904
     }
905 905
 
906 906
     return $out;
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
     if (isset($links['maiden_speech'])) {
917 917
         $maiden_speech = fix_gid_from_db($links['maiden_speech']);
918 918
         $out[] = array(
919
-                'href' => WEBPATH . 'debate/?id=' . $maiden_speech,
919
+                'href' => WEBPATH.'debate/?id='.$maiden_speech,
920 920
                 'text' => 'Maiden speech'
921 921
         );
922 922
     }
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
 
961 961
     if ($member->house(HOUSE_TYPE_COMMONS)) {
962 962
         $out[] = array(
963
-                'href' => 'http://www.edms.org.uk/mps/' . $member->person_id(),
963
+                'href' => 'http://www.edms.org.uk/mps/'.$member->person_id(),
964 964
                 'text' => 'Early Day Motions signed by this MP'
965 965
         );
966 966
     }
@@ -983,8 +983,8 @@  discard block
 block discarded – undo
983 983
 
984 984
     if (isset($links['twitter_username'])) {
985 985
         $out[] = array(
986
-                'href' => 'https://twitter.com/' . _htmlentities($links['twitter_username']),
987
-                'text' => '@' . _htmlentities($links['twitter_username']),
986
+                'href' => 'https://twitter.com/'._htmlentities($links['twitter_username']),
987
+                'text' => '@'._htmlentities($links['twitter_username']),
988 988
                 'type' => 'twitter'
989 989
         );
990 990
     }
@@ -1049,11 +1049,11 @@  discard block
 block discarded – undo
1049 1049
             if ($arr['chairman']) {
1050 1050
                 $text .= 'Chairman, ';
1051 1051
             }
1052
-            $text .= $arr['title'] . ' Committee';
1052
+            $text .= $arr['title'].' Committee';
1053 1053
             $out['data'][] = array(
1054
-                'href'      => '/pbc/' . $arr['session'] . '/' . urlencode($arr['title']),
1054
+                'href'      => '/pbc/'.$arr['session'].'/'.urlencode($arr['title']),
1055 1055
                 'text'      => $text,
1056
-                'attending' => $arr['attending'] . ' out of ' . $arr['outof']
1056
+                'attending' => $arr['attending'].' out of '.$arr['outof']
1057 1057
             );
1058 1058
         }
1059 1059
     }
@@ -1082,8 +1082,8 @@  discard block
 block discarded – undo
1082 1082
     $section = 'section:debates section:whall section:lords section:ni';
1083 1083
     $MOREURL->insert(array('pid'=>$member->person_id(), 's'=>$section, 'pop'=>1));
1084 1084
     if ($member->party() != 'Sinn Féin') {
1085
-        if (display_stats_line('debate_sectionsspoken_inlastyear', 'Has spoken in ', 'debate', ' ' . $since_text, ' <a href="' . $MOREURL->generate() . '">See all ' . $member->full_name() . '&rsquo;s speeches</a>', $extra_info)) {
1086
-            $out[] = display_stats_line('debate_sectionsspoken_inlastyear', 'Has spoken in ', 'debate', ' ' . $since_text, ' <a href="' . $MOREURL->generate() . '">See all ' . $member->full_name() . '&rsquo;s speeches</a>', $extra_info);
1085
+        if (display_stats_line('debate_sectionsspoken_inlastyear', 'Has spoken in ', 'debate', ' '.$since_text, ' <a href="'.$MOREURL->generate().'">See all '.$member->full_name().'&rsquo;s speeches</a>', $extra_info)) {
1086
+            $out[] = display_stats_line('debate_sectionsspoken_inlastyear', 'Has spoken in ', 'debate', ' '.$since_text, ' <a href="'.$MOREURL->generate().'">See all '.$member->full_name().'&rsquo;s speeches</a>', $extra_info);
1087 1087
         }
1088 1088
 
1089 1089
         $MOREURL->insert(array('pid'=>$member->person_id(), 's'=>'section:wrans', 'pop'=>1));
@@ -1096,12 +1096,12 @@  discard block
 block discarded – undo
1096 1096
         if ($member->party() == 'SPK' || $member->party() == 'CWM' || $member->party() == 'DCWM') {
1097 1097
             $minister = 2;
1098 1098
         }
1099
-        if (display_stats_line('wrans_asked_inlastyear', 'Has received answers to <a href="' . $MOREURL->generate() . '">', 'written question', '</a> ' . $since_text, '', $extra_info, $minister, $Lminister)) {
1100
-            $out[] = display_stats_line('wrans_asked_inlastyear', 'Has received answers to <a href="' . $MOREURL->generate() . '">', 'written question', '</a> ' . $since_text, '', $extra_info, $minister, $Lminister);
1099
+        if (display_stats_line('wrans_asked_inlastyear', 'Has received answers to <a href="'.$MOREURL->generate().'">', 'written question', '</a> '.$since_text, '', $extra_info, $minister, $Lminister)) {
1100
+            $out[] = display_stats_line('wrans_asked_inlastyear', 'Has received answers to <a href="'.$MOREURL->generate().'">', 'written question', '</a> '.$since_text, '', $extra_info, $minister, $Lminister);
1101 1101
         }
1102 1102
     }
1103 1103
 
1104
-    foreach ( $wtt_stats_years as $year ) {
1104
+    foreach ($wtt_stats_years as $year) {
1105 1105
         $wtt_displayed = display_writetothem_numbers($year, $extra_info);
1106 1106
         if ($wtt_displayed) {
1107 1107
             $out[] = $wtt_displayed;
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
         if ($member->house_disp == HOUSE_TYPE_LORDS) {
1122 1122
             $when = 'in this House with this affiliation up to the 2015 general election';
1123 1123
         }
1124
-        $div_attend = display_stats_line('public_whip_division_attendance', 'Has voted in <a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/' . $member->member_id() . '&amp;showall=yes#divisions" title="See more details at Public Whip">', 'of vote', '</a> ' . $when, $after_stuff, $extra_info);
1124
+        $div_attend = display_stats_line('public_whip_division_attendance', 'Has voted in <a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/'.$member->member_id().'&amp;showall=yes#divisions" title="See more details at Public Whip">', 'of vote', '</a> '.$when, $after_stuff, $extra_info);
1125 1125
         if ($div_attend) {
1126 1126
             $out[] = $div_attend;
1127 1127
         }
@@ -1131,33 +1131,33 @@  discard block
 block discarded – undo
1131 1131
         }
1132 1132
         */
1133 1133
 
1134
-        if (display_stats_line('comments_on_speeches', 'People have made <a href="' . WEBPATH . 'comments/recent/?pid='.$member->person_id().'">', 'annotation', "</a> on this MP&rsquo;s speeches", '', $extra_info)) {
1135
-            $out[] = display_stats_line('comments_on_speeches', 'People have made <a href="' . WEBPATH . 'comments/recent/?pid='.$member->person_id().'">', 'annotation', "</a> on this MP&rsquo;s speeches", '', $extra_info);
1134
+        if (display_stats_line('comments_on_speeches', 'People have made <a href="'.WEBPATH.'comments/recent/?pid='.$member->person_id().'">', 'annotation', "</a> on this MP&rsquo;s speeches", '', $extra_info)) {
1135
+            $out[] = display_stats_line('comments_on_speeches', 'People have made <a href="'.WEBPATH.'comments/recent/?pid='.$member->person_id().'">', 'annotation', "</a> on this MP&rsquo;s speeches", '', $extra_info);
1136 1136
         }
1137 1137
         if (display_stats_line('reading_age', 'This MP&rsquo;s speeches, in Hansard, are readable by an average ', '', ' year old, going by the <a href="https://en.wikipedia.org/wiki/Flesch-Kincaid_Readability_Test">Flesch-Kincaid Grade Level</a> score', '', $extra_info)) {
1138 1138
             $out[] = display_stats_line('reading_age', 'This MP&rsquo;s speeches, in Hansard, are readable by an average ', '', ' year old, going by the <a href="https://en.wikipedia.org/wiki/Flesch-Kincaid_Readability_Test">Flesch-Kincaid Grade Level</a> score', '', $extra_info);
1139 1139
         }
1140 1140
     }
1141 1141
 
1142
-    if (isset($extra_info['number_of_alerts']) && ($extra_info['number_of_alerts']>0 || $has_email_alerts)) {
1143
-        $line = '<strong>' . _htmlentities($extra_info['number_of_alerts']) . '</strong> ' . ($extra_info['number_of_alerts']==1?'person is':'people are') . ' tracking ';
1142
+    if (isset($extra_info['number_of_alerts']) && ($extra_info['number_of_alerts'] > 0 || $has_email_alerts)) {
1143
+        $line = '<strong>'._htmlentities($extra_info['number_of_alerts']).'</strong> '.($extra_info['number_of_alerts'] == 1 ? 'person is' : 'people are').' tracking ';
1144 1144
         if ($member->house_disp == HOUSE_TYPE_COMMONS) $line .= 'this MP';
1145 1145
         elseif ($member->house_disp == HOUSE_TYPE_LORDS) $line .= 'this peer';
1146 1146
         elseif ($member->house_disp == HOUSE_TYPE_NI) $line .= 'this MLA';
1147 1147
         elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) $line .= 'this MSP';
1148 1148
         elseif ($member->house_disp == HOUSE_TYPE_ROYAL) $line .= $member->full_name();
1149 1149
         if ($has_email_alerts) {
1150
-            $line .= ' &mdash; <a href="' . WEBPATH . 'alert/?pid='.$member->person_id().'">email me updates on '. $member->full_name(). '&rsquo;s activity</a>';
1150
+            $line .= ' &mdash; <a href="'.WEBPATH.'alert/?pid='.$member->person_id().'">email me updates on '.$member->full_name().'&rsquo;s activity</a>';
1151 1151
         }
1152 1152
 
1153 1153
         $out[] = $line;
1154 1154
     }
1155 1155
 
1156 1156
     if ($member->party() != 'Sinn Féin') {
1157
-        if (display_stats_line('three_word_alliterations', 'Has used three-word alliterative phrases (e.g. "she sells seashells") ', 'time', ' in debates', ' <small>(<a href="' . WEBPATH . 'help/#numbers">Why is this here?</a>)</small>', $extra_info)) {
1158
-            $line = display_stats_line('three_word_alliterations', 'Has used three-word alliterative phrases (e.g. "she sells seashells") ', 'time', ' in debates', ' <small>(<a href="' . WEBPATH . 'help/#numbers">Why is this here?</a>)</small>', $extra_info);
1157
+        if (display_stats_line('three_word_alliterations', 'Has used three-word alliterative phrases (e.g. "she sells seashells") ', 'time', ' in debates', ' <small>(<a href="'.WEBPATH.'help/#numbers">Why is this here?</a>)</small>', $extra_info)) {
1158
+            $line = display_stats_line('three_word_alliterations', 'Has used three-word alliterative phrases (e.g. "she sells seashells") ', 'time', ' in debates', ' <small>(<a href="'.WEBPATH.'help/#numbers">Why is this here?</a>)</small>', $extra_info);
1159 1159
             if (isset($extra_info['three_word_alliteration_content'])) {
1160
-                $line .= "\n<!-- " . $extra_info['three_word_alliteration_content'] . " -->\n";
1160
+                $line .= "\n<!-- ".$extra_info['three_word_alliteration_content']." -->\n";
1161 1161
             }
1162 1162
             $out[] = $line;
1163 1163
         }
@@ -1177,28 +1177,28 @@  discard block
 block discarded – undo
1177 1177
 }
1178 1178
 
1179 1179
 function display_stats_line_house($house, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff) {
1180
-    if ($category == 'wrans_asked_inlastyear' || $category == 'debate_sectionsspoken_inlastyear' || $category =='comments_on_speeches' ||
1181
-        $category == 'Lwrans_asked_inlastyear' || $category == 'Ldebate_sectionsspoken_inlastyear' || $category =='Lcomments_on_speeches') {
1182
-        if ($extra_info[$category]==0) {
1180
+    if ($category == 'wrans_asked_inlastyear' || $category == 'debate_sectionsspoken_inlastyear' || $category == 'comments_on_speeches' ||
1181
+        $category == 'Lwrans_asked_inlastyear' || $category == 'Ldebate_sectionsspoken_inlastyear' || $category == 'Lcomments_on_speeches') {
1182
+        if ($extra_info[$category] == 0) {
1183 1183
             $blurb = preg_replace('#<a.*?>#', '', $blurb);
1184 1184
             $inwhat = preg_replace('#<\/a>#', '', $inwhat);
1185 1185
         }
1186 1186
     }
1187
-    if ($house==HOUSE_TYPE_LORDS) $inwhat = str_replace('MP', 'Lord', $inwhat);
1187
+    if ($house == HOUSE_TYPE_LORDS) $inwhat = str_replace('MP', 'Lord', $inwhat);
1188 1188
     $line = $blurb;
1189
-    $line .= '<strong>' . $extra_info[$category];
1190
-    if ($type) $line .= ' ' . make_plural($type, $extra_info[$category]);
1189
+    $line .= '<strong>'.$extra_info[$category];
1190
+    if ($type) $line .= ' '.make_plural($type, $extra_info[$category]);
1191 1191
     $line .= '</strong>';
1192 1192
     $line .= $inwhat;
1193
-    if ($minister===2) {
1193
+    if ($minister === 2) {
1194 1194
         $line .= ' &#8212; Speakers/ deputy speakers do not ask written questions';
1195 1195
     } elseif ($minister)
1196 1196
         $line .= ' &#8212; Ministers do not ask written questions';
1197 1197
     else {
1198
-        $type = ($house==HOUSE_TYPE_COMMONS?'MP':($house==HOUSE_TYPE_LORDS?'Lord':'MLA'));
1199
-        if (!get_http_var('rem') && isset($extra_info[$category . '_quintile'])) {
1198
+        $type = ($house == HOUSE_TYPE_COMMONS ? 'MP' : ($house == HOUSE_TYPE_LORDS ? 'Lord' : 'MLA'));
1199
+        if (!get_http_var('rem') && isset($extra_info[$category.'_quintile'])) {
1200 1200
             $line .= ' &#8212; ';
1201
-            $q = $extra_info[$category . '_quintile'];
1201
+            $q = $extra_info[$category.'_quintile'];
1202 1202
             if ($q == 0) {
1203 1203
                 $line .= 'well above average';
1204 1204
             } elseif ($q == 1) {
@@ -1213,13 +1213,13 @@  discard block
 block discarded – undo
1213 1213
                 $line .= '[Impossible quintile!]';
1214 1214
             }
1215 1215
             $line .= ' amongst ';
1216
-            $line .= $type . 's';
1217
-        } elseif (!get_http_var('rem') && isset($extra_info[$category . '_rank'])) {
1216
+            $line .= $type.'s';
1217
+        } elseif (!get_http_var('rem') && isset($extra_info[$category.'_rank'])) {
1218 1218
             $line .= ' &#8212; ';
1219 1219
             #if (isset($extra_info[$category . '_rank_joint']))
1220 1220
             #   print 'joint ';
1221
-            $line .= make_ranking($extra_info[$category . '_rank']) . ' out of ' . $extra_info[$category . '_rank_outof'];
1222
-            $line .= ' ' . $type . 's';
1221
+            $line .= make_ranking($extra_info[$category.'_rank']).' out of '.$extra_info[$category.'_rank_outof'];
1222
+            $line .= ' '.$type.'s';
1223 1223
         }
1224 1224
     }
1225 1225
     $line .= ".$afterstuff";
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
 
1229 1229
 function display_writetothem_numbers($year, $extra_info) {
1230 1230
     if (isset($extra_info["writetothem_responsiveness_notes_$year"])) {
1231
-        return '<li>Responsiveness to messages sent via <a href="https://www.writetothem.com/stats/' . $year . '/mps">WriteToThem.com</a> in ' . $year . ': ' . $extra_info["writetothem_responsiveness_notes_$year"] . '.</li>';
1231
+        return '<li>Responsiveness to messages sent via <a href="https://www.writetothem.com/stats/'.$year.'/mps">WriteToThem.com</a> in '.$year.': '.$extra_info["writetothem_responsiveness_notes_$year"].'.</li>';
1232 1232
     } elseif (isset($extra_info["writetothem_responsiveness_mean_$year"])) {
1233 1233
         $mean = $extra_info["writetothem_responsiveness_mean_$year"];
1234 1234
 
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
         if ($a == 'very high') $a = 'a very high';
1241 1241
         $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"] = $a;
1242 1242
 
1243
-        return display_stats_line("writetothem_responsiveness_fuzzy_response_description_$year", 'Replied within 2 or 3 weeks to <a href="https://www.writetothem.com/stats/'.$year.'/mps" title="From WriteToThem.com">', "", "</a> <!-- Mean: " . $mean . " --> number of messages sent via WriteToThem.com during ".$year.", according to constituents", "", $extra_info);
1243
+        return display_stats_line("writetothem_responsiveness_fuzzy_response_description_$year", 'Replied within 2 or 3 weeks to <a href="https://www.writetothem.com/stats/'.$year.'/mps" title="From WriteToThem.com">', "", "</a> <!-- Mean: ".$mean." --> number of messages sent via WriteToThem.com during ".$year.", according to constituents", "", $extra_info);
1244 1244
     }
1245 1245
 
1246 1246
 }
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
 function get_all_writetothem_strings($member, $wtt_stats_years) {
1249 1249
     $extra_info = $member->extra_info();
1250 1250
     $strings = array();
1251
-    foreach ( $wtt_stats_years as $year ) {
1251
+    foreach ($wtt_stats_years as $year) {
1252 1252
 
1253 1253
         if (isset($extra_info["writetothem_responsiveness_mean_$year"])) {
1254 1254
             $a = $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"];
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
         return;
1265 1265
     }
1266 1266
 
1267
-    $reg = array( 'date' => '', 'data' => '<p>Nil</p>' );
1267
+    $reg = array('date' => '', 'data' => '<p>Nil</p>');
1268 1268
     if (isset($extra_info['register_member_interests_date'])) {
1269 1269
         $reg['date'] = format_date($extra_info['register_member_interests_date'], SHORTDATEFORMAT);
1270 1270
     }
@@ -1279,27 +1279,27 @@  discard block
 block discarded – undo
1279 1279
     if ($constituencies == 'CONNECTION_TIMED_OUT') {
1280 1280
         throw new MySociety\TheyWorkForYou\MemberException('Sorry, we couldn&rsquo;t check your postcode right now, as our postcode lookup server is under quite a lot of load.');
1281 1281
     } elseif (!$constituencies) {
1282
-        throw new MySociety\TheyWorkForYou\MemberException('Sorry, ' . htmlentities($pc) . ' isn&rsquo;t a known postcode');
1282
+        throw new MySociety\TheyWorkForYou\MemberException('Sorry, '.htmlentities($pc).' isn&rsquo;t a known postcode');
1283 1283
     } elseif (!isset($constituencies[$area_type])) {
1284
-        throw new MySociety\TheyWorkForYou\MemberException(htmlentities($pc) . ' does not appear to be a valid postcode');
1284
+        throw new MySociety\TheyWorkForYou\MemberException(htmlentities($pc).' does not appear to be a valid postcode');
1285 1285
     }
1286 1286
     global $PAGE;
1287 1287
     $a = array_values($constituencies);
1288 1288
     $db = new ParlDB;
1289 1289
     $query_base = "SELECT member.person_id, given_name, family_name, constituency, house
1290 1290
         FROM member, person_names pn
1291
-        WHERE constituency IN ('" . join("','", $a) . "')
1291
+        WHERE constituency IN ('" . join("','", $a)."')
1292 1292
             AND member.person_id = pn.person_id AND pn.type = 'name'
1293 1293
             AND pn.end_date = (SELECT MAX(end_date) FROM person_names WHERE person_names.person_id = member.person_id)";
1294
-    $q = $db->query($query_base . " AND left_reason = 'still_in_office' AND house in (" . HOUSE_TYPE_NI . "," . HOUSE_TYPE_SCOTLAND . ")");
1294
+    $q = $db->query($query_base." AND left_reason = 'still_in_office' AND house in (".HOUSE_TYPE_NI.",".HOUSE_TYPE_SCOTLAND.")");
1295 1295
     $current = true;
1296 1296
     if (!$q->rows() && ($dissolution = MySociety\TheyWorkForYou\Dissolution::db())) {
1297 1297
         $current = false;
1298
-        $q = $db->query($query_base . " AND $dissolution[query]",
1298
+        $q = $db->query($query_base." AND $dissolution[query]",
1299 1299
             $dissolution['params']);
1300 1300
     }
1301 1301
     $mcon = array(); $mreg = array();
1302
-    for ($i=0; $i<$q->rows(); $i++) {
1302
+    for ($i = 0; $i < $q->rows(); $i++) {
1303 1303
         $house = $q->field($i, 'house');
1304 1304
         $pid = $q->field($i, 'person_id');
1305 1305
         $cons = $q->field($i, 'constituency');
@@ -1314,33 +1314,33 @@  discard block
 block discarded – undo
1314 1314
                 $mreg[] = $q->row($i);
1315 1315
             }
1316 1316
         } else {
1317
-            throw new MySociety\TheyWorkForYou\MemberException('Odd result returned!' . $house);
1317
+            throw new MySociety\TheyWorkForYou\MemberException('Odd result returned!'.$house);
1318 1318
         }
1319 1319
     }
1320 1320
     if ($rep_type == 'msp') {
1321 1321
         if ($current) {
1322 1322
             $data['members_statement'] = '<p>You have one constituency MSP (Member of the Scottish Parliament) and multiple region MSPs.</p>';
1323
-            $data['members_statement'] .= '<p>Your <strong>constituency MSP</strong> is <a href="/msp/?p=' . $mcon['person_id'] . '">';
1324
-            $data['members_statement'] .= $mcon['given_name'] . ' ' . $mcon['family_name'] . '</a>, MSP for ' . $mcon['constituency'];
1325
-            $data['members_statement'] .= '.</p> <p>Your <strong>' . $constituencies['SPE'] . ' region MSPs</strong> are:</p>';
1323
+            $data['members_statement'] .= '<p>Your <strong>constituency MSP</strong> is <a href="/msp/?p='.$mcon['person_id'].'">';
1324
+            $data['members_statement'] .= $mcon['given_name'].' '.$mcon['family_name'].'</a>, MSP for '.$mcon['constituency'];
1325
+            $data['members_statement'] .= '.</p> <p>Your <strong>'.$constituencies['SPE'].' region MSPs</strong> are:</p>';
1326 1326
         } else {
1327 1327
             $data['members_statement'] = '<p>You had one constituency MSP (Member of the Scottish Parliament) and multiple region MSPs.</p>';
1328
-            $data['members_statement'] .= '<p>Your <strong>constituency MSP</strong> was <a href="/msp/?p=' . $mcon['person_id'] . '">';
1329
-            $data['members_statement'] .= $mcon['given_name'] . ' ' . $mcon['family_name'] . '</a>, MSP for ' . $mcon['constituency'];
1330
-            $data['members_statement'] .= '.</p> <p>Your <strong>' . $constituencies['SPE'] . ' region MSPs</strong> were:</p>';
1328
+            $data['members_statement'] .= '<p>Your <strong>constituency MSP</strong> was <a href="/msp/?p='.$mcon['person_id'].'">';
1329
+            $data['members_statement'] .= $mcon['given_name'].' '.$mcon['family_name'].'</a>, MSP for '.$mcon['constituency'];
1330
+            $data['members_statement'] .= '.</p> <p>Your <strong>'.$constituencies['SPE'].' region MSPs</strong> were:</p>';
1331 1331
         }
1332 1332
     } else {
1333 1333
         if ($current) {
1334
-            $data['members_statement'] = '<p>You have multiple MLAs (Members of the Legislative Assembly) who represent you in ' . $constituencies['NIE'] . '. They are:</p>';
1334
+            $data['members_statement'] = '<p>You have multiple MLAs (Members of the Legislative Assembly) who represent you in '.$constituencies['NIE'].'. They are:</p>';
1335 1335
         } else {
1336
-            $data['members_statement'] = '<p>You had multiple MLAs (Members of the Legislative Assembly) who represented you in ' . $constituencies['NIE'] . '. They were:</p>';
1336
+            $data['members_statement'] = '<p>You had multiple MLAs (Members of the Legislative Assembly) who represented you in '.$constituencies['NIE'].'. They were:</p>';
1337 1337
         }
1338 1338
     }
1339 1339
 
1340
-    foreach($mreg as $reg) {
1341
-        $data['members'][] = array (
1342
-            'url' => '/' . $rep_type . '/?p=' . $reg['person_id'],
1343
-            'name' => $reg['given_name'] . ' ' . $reg['family_name']
1340
+    foreach ($mreg as $reg) {
1341
+        $data['members'][] = array(
1342
+            'url' => '/'.$rep_type.'/?p='.$reg['person_id'],
1343
+            'name' => $reg['given_name'].' '.$reg['family_name']
1344 1344
         );
1345 1345
 
1346 1346
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  */
30 30
 
31 31
 // Disable the old PAGE class.
32
-$new_style_template = TRUE;
32
+$new_style_template = true;
33 33
 
34 34
 // Include all the things this page needs.
35 35
 include_once '../../includes/easyparliament/init.php';
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 // Basic name, title and description
177 177
 $member_name = ucfirst($MEMBER->full_name());
178 178
 $title = $member_name;
179
-$desc = "Read $member_name's contributions to Parliament, including speeches and questions";
179
+$desc = "read $member_name's contributions to Parliament, including speeches and questions";
180 180
 
181 181
 // Enhance description if this is a current member
182 182
 if ($MEMBER->current_member_anywhere())
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 
245 245
 $position = implode('; ', $positions);
246 246
 
247
-$current_offices = $MEMBER->offices('current', TRUE);
248
-$former_offices = $MEMBER->offices('previous', TRUE);
247
+$current_offices = $MEMBER->offices('current', true);
248
+$former_offices = $MEMBER->offices('previous', true);
249 249
 
250 250
 // If this person has named non-committee offices, they override the default
251 251
 if (count($current_offices) > 0) {
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 $data['has_email_alerts'] = ($MEMBER->current_member_anywhere() && !($MEMBER->current_member(HOUSE_TYPE_COMMONS) && $MEMBER->party() == 'Sinn Féin' && !$MEMBER->current_member(HOUSE_TYPE_NI)));
316 316
 $data['has_expenses'] = $data['leave_date'] > '2004-01-01';
317 317
 
318
-$data['pre_2010_expenses'] = False;
318
+$data['pre_2010_expenses'] = false;
319 319
 $data['post_2010_expenses'] = $data['leave_date'] > '2010-05-05';
320 320
 
321 321
 if ($data['entry_date'] < '2010-05-05') {
322
-    $data['pre_2010_expenses'] = True;
322
+    $data['pre_2010_expenses'] = true;
323 323
     // Set the expenses URL if we know it
324 324
     if (isset($MEMBER->extra_info['expenses_url'])) {
325 325
         $data['expenses_url_2004'] = $MEMBER->extra_info['expenses_url'];
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
  * Redirect to the canonical page for a member.
686 686
  */
687 687
 
688
-function member_redirect (&$MEMBER, $code = 301, $pagetype = NULL) {
688
+function member_redirect (&$MEMBER, $code = 301, $pagetype = null) {
689 689
     // We come here after creating a MEMBER object by various methods.
690 690
     // Now we redirect to the canonical MP page, with a person_id.
691 691
     if ($MEMBER->person_id()) {
@@ -1171,8 +1171,8 @@  discard block
 block discarded – undo
1171 1171
     $return = false;
1172 1172
     if (isset($extra_info[$category]))
1173 1173
         $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff);
1174
-    if (isset($extra_info["L$category"]))
1175
-        $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff);
1174
+    if (isset($extra_info["l$category"]))
1175
+        $return = display_stats_line_house(HOUSE_TYPE_LORDS, "l$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff);
1176 1176
     return $return;
1177 1177
 }
1178 1178
 
Please login to merge, or discard this patch.
www/docs/api/api_getPerson.php 4 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -77,6 +77,9 @@  discard block
 block discarded – undo
77 77
     }
78 78
 }
79 79
 
80
+/**
81
+ * @param MySQLQuery $q
82
+ */
80 83
 function _api_getPerson_output($q, $flatten=false) {
81 84
     $output = array();
82 85
     $last_mod = 0;
@@ -95,10 +98,16 @@  discard block
 block discarded – undo
95 98
     api_output($output, $last_mod);
96 99
 }
97 100
 
101
+/**
102
+ * @param integer $house
103
+ */
98 104
 function api_getPerson_constituency($constituency, $house) {
99 105
     _api_getPerson_constituency(array($constituency), $house);
100 106
 }
101 107
 
108
+/**
109
+ * @param integer $house
110
+ */
102 111
 function api_getPerson_postcode($pc, $house) {
103 112
     $pc = preg_replace('#[^a-z0-9 ]#i', '', $pc);
104 113
     $types = array();
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once INCLUDESPATH . 'easyparliament/member.php';
3
+include_once INCLUDESPATH.'easyparliament/member.php';
4 4
 
5 5
 function api_getPerson_front() {
6 6
 ?>
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
 }
19 19
 
20
-function _api_getPerson_row($row, $has_party=FALSE) {
20
+function _api_getPerson_row($row, $has_party = FALSE) {
21 21
     global $parties;
22 22
     $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'],
23 23
         $row['family_name'], $row['lordofname']);
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
     }
27 27
     if ($row['house'] == 1) {
28 28
         $URL = new URL('mp');
29
-        $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
29
+        $row['url'] = $URL->generate('none').make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
30 30
     }
31 31
     if ($has_party && isset($parties[$row['party']]))
32 32
         $row['party'] = $parties[$row['party']];
33
-    list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
33
+    list($image, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
34 34
     if ($image) {
35
-        list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
35
+        list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR.'/images/', $image));
36 36
         $row['image'] = $image;
37 37
         $row['image_height'] = $height;
38 38
         $row['image_width'] = $width;
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
     if ($row['house'] == 1 && ($row['left_house'] == '9999-12-31' || (isset($dissolution[1]) && $row['left_house'] == $dissolution[1]))) {
43 43
         # Ministerialships and Select Committees
44 44
         $db = new ParlDB;
45
-        $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC');
46
-        for ($i=0; $i<$q->rows(); $i++) {
45
+        $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person='.$row['person_id'].' ORDER BY from_date DESC');
46
+        for ($i = 0; $i < $q->rows(); $i++) {
47 47
             $row['office'][] = $q->row($i);
48 48
         }
49 49
     }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     return $row;
56 56
 }
57 57
 
58
-function api_getPerson_id($id, $house='') {
58
+function api_getPerson_id($id, $house = '') {
59 59
     $db = new ParlDB;
60 60
     $params = array(
61 61
         ':person_id' => $id
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
     }
78 78
 }
79 79
 
80
-function _api_getPerson_output($q, $flatten=false) {
80
+function _api_getPerson_output($q, $flatten = false) {
81 81
     $output = array();
82 82
     $last_mod = 0;
83
-    for ($i=0; $i<$q->rows(); $i++) {
83
+    for ($i = 0; $i < $q->rows(); $i++) {
84 84
         $house = $q->field($i, 'house');
85 85
         $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true);
86 86
         $output[] = $out;
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
     $cons_params = array();
150 150
     $params = array(':house' => $house);
151 151
     foreach ($cons as $key => $constituency) {
152
-        $cons_params[] = ':constituency' . $key;
153
-        $params[':constituency' . $key] = $constituency;
152
+        $cons_params[] = ':constituency'.$key;
153
+        $params[':constituency'.$key] = $constituency;
154 154
     }
155 155
 
156 156
     $query_base = "SELECT member.*, p.title, p.given_name, p.family_name, p.lordofname
157 157
         FROM member, person_names p
158
-        WHERE constituency in (" . join(",", $cons_params) . ")
158
+        WHERE constituency in (" . join(",", $cons_params).")
159 159
             AND member.person_id = p.person_id AND p.type = 'name'
160 160
             AND p.start_date <= left_house AND left_house <= p.end_date
161 161
         AND house = :house";
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
         $URL = new URL('mp');
29 29
         $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
30 30
     }
31
-    if ($has_party && isset($parties[$row['party']]))
32
-        $row['party'] = $parties[$row['party']];
31
+    if ($has_party && isset($parties[$row['party']])) {
32
+            $row['party'] = $parties[$row['party']];
33
+    }
33 34
     list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
34 35
     if ($image) {
35 36
         list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
@@ -49,7 +50,9 @@  discard block
 block discarded – undo
49 50
     }
50 51
 
51 52
     foreach ($row as $k => $r) {
52
-        if (is_string($r)) $row[$k] = html_entity_decode($r);
53
+        if (is_string($r)) {
54
+            $row[$k] = html_entity_decode($r);
55
+        }
53 56
     }
54 57
 
55 58
     return $row;
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
         $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true);
86 89
         $output[] = $out;
87 90
         $time = strtotime($q->field($i, 'lastupdate'));
88
-        if ($time > $last_mod)
89
-            $last_mod = $time;
91
+        if ($time > $last_mod) {
92
+                    $last_mod = $time;
93
+        }
90 94
     }
91 95
     # Only one MP, not an array
92 96
     if ($flatten && count($output) == 1 && $house == HOUSE_TYPE_COMMONS) {
@@ -134,13 +138,18 @@  discard block
 block discarded – undo
134 138
 
135 139
     $cons = array();
136 140
     foreach ($constituencies as $constituency) {
137
-        if ($constituency == '') continue;
138
-        if ($constituency == 'Orkney ')
139
-            $constituency = 'Orkney & Shetland';
141
+        if ($constituency == '') {
142
+            continue;
143
+        }
144
+        if ($constituency == 'Orkney ') {
145
+                    $constituency = 'Orkney & Shetland';
146
+        }
140 147
 
141 148
         if ($house == HOUSE_TYPE_COMMONS) {
142 149
             $normalised = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency);
143
-            if ($normalised) $constituency = $normalised;
150
+            if ($normalised) {
151
+                $constituency = $normalised;
152
+            }
144 153
         }
145 154
 
146 155
         $cons[] = $constituency;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 <?php
18 18
 }
19 19
 
20
-function _api_getPerson_row($row, $has_party=FALSE) {
20
+function _api_getPerson_row($row, $has_party=false) {
21 21
     global $parties;
22 22
     $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'],
23 23
         $row['family_name'], $row['lordofname']);
Please login to merge, or discard this patch.
www/includes/utility.php 5 patches
Doc Comments   +23 added lines patch added patch discarded remove patch
@@ -318,6 +318,9 @@  discard block
 block discarded – undo
318 318
 $format_date_months = array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
319 319
 $format_date_months_short = array('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
320 320
 
321
+/**
322
+ * @param string $format
323
+ */
321 324
 function format_date($date, $format) {
322 325
     global $format_date_months, $format_date_months_short;
323 326
     // Pass it a date (YYYY-MM-DD) and a
@@ -342,6 +345,9 @@  discard block
 block discarded – undo
342 345
 }
343 346
 
344 347
 
348
+/**
349
+ * @param string $format
350
+ */
345 351
 function format_time($time, $format) {
346 352
     // Pass it a time (HH:MM:SS) and a
347 353
     // PHP date format string (eg, "H:i")
@@ -486,6 +492,7 @@  discard block
 block discarded – undo
486 492
 
487 493
 /**
488 494
  * Filters user input to remove unwanted HTML tags etc
495
+ * @param string $filter_type
489 496
  */
490 497
 function filter_user_input($text, $filter_type) {
491 498
     // We use this to filter any major user input, especially comments.
@@ -735,12 +742,18 @@  discard block
 block discarded – undo
735 742
 /* verp_envelope_sender RECIPIENT
736 743
  * Construct a VERP envelope sender for an email to RECIPIENT
737 744
  */
745
+/**
746
+ * @return string|null
747
+ */
738 748
 function twfy_verp_envelope_sender($recipient) {
739 749
     $envelope_sender = verp_envelope_sender($recipient, 'twfy', EMAILDOMAIN);
740 750
 
741 751
     return $envelope_sender;
742 752
 }
743 753
 
754
+/**
755
+ * @param string $message
756
+ */
744 757
 function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false) {
745 758
     // Use this rather than PHP's mail() direct, so we can make alterations
746 759
     // easily to all the emails we send out from the site.
@@ -799,6 +812,9 @@  discard block
 block discarded – undo
799 812
 }
800 813
 
801 814
 // Call this with a key name to get a COOKIE variable.
815
+/**
816
+ * @param string $name
817
+ */
802 818
 function get_cookie_var($name, $default='') {
803 819
     if (array_key_exists($name, $_COOKIE)) {
804 820
         return clean_var($_COOKIE[$name]);
@@ -1039,6 +1055,10 @@  discard block
 block discarded – undo
1039 1055
     }
1040 1056
 }
1041 1057
 
1058
+/**
1059
+ * @param integer $major
1060
+ * @param URL $LISTURL
1061
+ */
1042 1062
 function _major_summary_title($major, $data, $LISTURL, $daytext) {
1043 1063
     global $hansardmajors;
1044 1064
 
@@ -1088,6 +1108,9 @@  discard block
 block discarded – undo
1088 1108
     return $return;
1089 1109
 }
1090 1110
 
1111
+/**
1112
+ * @param string|null $url
1113
+ */
1091 1114
 function redirect($url) {
1092 1115
     if (defined('TESTING')) {
1093 1116
         print "Location: $url";
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
     # Ignore errors we've asked to ignore
68 68
     if (error_reporting()==0) return;
69 69
 
70
-   // define an assoc array of error string
71
-   // in reality the only entries we should
72
-   // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
73
-   // E_USER_WARNING and E_USER_NOTICE
74
-   # Commented out are ones that a user function cannot handle.
70
+    // define an assoc array of error string
71
+    // in reality the only entries we should
72
+    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
73
+    // E_USER_WARNING and E_USER_NOTICE
74
+    # Commented out are ones that a user function cannot handle.
75 75
     $errortype = array (
76 76
         #E_ERROR            => "Error",
77 77
         E_WARNING           => "Warning",
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php
201 201
 function adodb_backtrace($print=true)
202 202
 {
203
-  $s = '';
204
-  if (PHPVERSION() >= 4.3) {
203
+    $s = '';
204
+    if (PHPVERSION() >= 4.3) {
205 205
 
206 206
     $MAXSTRLEN = 64;
207 207
 
@@ -209,33 +209,33 @@  discard block
 block discarded – undo
209 209
     array_shift($traceArr);
210 210
     $tabs = sizeof($traceArr)-1;
211 211
     foreach ($traceArr as $arr) {
212
-      for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; ';
213
-      $tabs -= 1;
214
-      if (isset($arr['class'])) $s .= $arr['class'].'.';
215
-      $args = array();
216
-      if (isset($arr['args'])) foreach ($arr['args'] as $v) {
212
+        for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; ';
213
+        $tabs -= 1;
214
+        if (isset($arr['class'])) $s .= $arr['class'].'.';
215
+        $args = array();
216
+        if (isset($arr['args'])) foreach ($arr['args'] as $v) {
217 217
     if (is_null($v)) $args[] = 'null';
218 218
     elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']';
219 219
     elseif (is_object($v)) $args[] = 'Object:'.get_class($v);
220 220
     elseif (is_bool($v)) $args[] = $v ? 'true' : 'false';
221 221
     else {
222
-      $v = (string) @$v;
223
-      $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN));
224
-      if (strlen($v) > $MAXSTRLEN) $str .= '...';
225
-      $args[] = $str;
222
+        $v = (string) @$v;
223
+        $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN));
224
+        if (strlen($v) > $MAXSTRLEN) $str .= '...';
225
+        $args[] = $str;
226 226
     }
227
-      }
227
+        }
228 228
 
229
-      $s .= $arr['function'].'('.implode(', ',$args).')';
230
-      //      $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,".
231
-      //            " file: <a href=\"file:/%s\">%s</a></font>",
232
-      //        $arr['line'],$arr['file'],$arr['file']);
233
-      $s .= "\n";
229
+        $s .= $arr['function'].'('.implode(', ',$args).')';
230
+        //      $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,".
231
+        //            " file: <a href=\"file:/%s\">%s</a></font>",
232
+        //        $arr['line'],$arr['file'],$arr['file']);
233
+        $s .= "\n";
234 234
     }
235 235
     if ($print) print $s;
236
-  }
236
+    }
237 237
 
238
-  return $s;
238
+    return $s;
239 239
 }
240 240
 
241 241
 // Far from foolproof, but better than nothing.
@@ -567,14 +567,14 @@  discard block
 block discarded – undo
567 567
     //$tbl["»"] = "&raquo;";
568 568
     //$tbl["«"] = "&laquo;";
569 569
 
570
-  // lib_filter will replace unmatched < and > with entities so
571
-  // we abuse strtr's only replace once behaviour to not double
572
-  // encode them. May not be robust.
573
-  // This does mean if anyone actually wants to put &gt; or &lt;
574
-  // in a comment they can't but that's a lot less likely than
575
-  // < or > for less than and greater than.
576
-  $tbl['&lt;'] = "&lt;";
577
-  $tbl['&gt;'] = "&gt;";
570
+    // lib_filter will replace unmatched < and > with entities so
571
+    // we abuse strtr's only replace once behaviour to not double
572
+    // encode them. May not be robust.
573
+    // This does mean if anyone actually wants to put &gt; or &lt;
574
+    // in a comment they can't but that's a lot less likely than
575
+    // < or > for less than and greater than.
576
+    $tbl['&lt;'] = "&lt;";
577
+    $tbl['&gt;'] = "&gt;";
578 578
 
579 579
     // Don't want to encode these things
580 580
     unset ($tbl["<"]);
@@ -764,16 +764,16 @@  discard block
 block discarded – undo
764 764
     if (!$from) $from = CONTACTEMAIL;
765 765
 
766 766
     $headers =
767
-     "From: TheyWorkForYou <$from>\r\n" .
768
-     "Content-Type: text/plain; charset=utf-8\r\n" .
769
-     "MIME-Version: 1.0\r\n" .
770
-     "Content-Transfer-Encoding: 8bit\r\n" .
771
-     ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "" ).
772
-     "X-Mailer: PHP/" . phpversion();
767
+        "From: TheyWorkForYou <$from>\r\n" .
768
+        "Content-Type: text/plain; charset=utf-8\r\n" .
769
+        "MIME-Version: 1.0\r\n" .
770
+        "Content-Transfer-Encoding: 8bit\r\n" .
771
+        ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "" ).
772
+        "X-Mailer: PHP/" . phpversion();
773 773
     twfy_debug('EMAIL', "Sending email to $to with subject of '$subject'");
774 774
 
775 775
     if ($want_bounces) {
776
-      $envelope_sender = twfy_verp_envelope_sender($to);
776
+        $envelope_sender = twfy_verp_envelope_sender($to);
777 777
         $success = mail ($to, $subject, $message, $headers, '-f ' . $envelope_sender);
778 778
     } else {
779 779
         $success = mail ($to, $subject, $message, $headers);
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 
1064 1064
     $return = '<h4>';
1065 1065
     if (isset($daytext[$major])) {
1066
-     $return .= $daytext[$major] . ' ';
1066
+        $return .= $daytext[$major] . ' ';
1067 1067
     }
1068 1068
 
1069 1069
     $return .= '<a href="';
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@  discard block
 block discarded – undo
5 5
 
6 6
 */
7 7
 
8
-include_once INCLUDESPATH . '../../commonlib/phplib/email.php';
9
-include_once INCLUDESPATH . '../../commonlib/phplib/datetime.php';
8
+include_once INCLUDESPATH.'../../commonlib/phplib/email.php';
9
+include_once INCLUDESPATH.'../../commonlib/phplib/datetime.php';
10 10
 
11 11
 # Pass it a brief header word and some debug text and it'll be output.
12 12
 # If TEXT is an array, call the user function, assuming it's a class.
13
-function twfy_debug($header, $text="") {
13
+function twfy_debug($header, $text = "") {
14 14
 
15 15
     // We set ?DEBUGTAG=n in the URL.
16 16
     // (DEBUGTAG is set in config.php).
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
     if ($debug_level != '') {
28 28
 
29 29
         // Set which level shows which types of debug info.
30
-        $levels = array (
31
-            1 => array ('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'),
32
-            2 => array ('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'),
33
-            3 => array ('SQLRESULT')
30
+        $levels = array(
31
+            1 => array('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'),
32
+            2 => array('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'),
33
+            3 => array('SQLRESULT')
34 34
             // Higher than this: 'DATA', etc.
35 35
         );
36 36
 
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
         }
45 45
 
46 46
         for ($n = 1; $n <= $max_level_to_show; $n++) {
47
-            $allowed_headers = array_merge ($allowed_headers, $levels[$n] );
47
+            $allowed_headers = array_merge($allowed_headers, $levels[$n]);
48 48
         }
49 49
 
50 50
         // If we can show this header, then, er, show it.
51
-        if ( in_array($header, $allowed_headers) || $debug_level >= 4) {
51
+        if (in_array($header, $allowed_headers) || $debug_level >= 4) {
52 52
             if (is_array($text)) $text = call_user_func($text);
53 53
             print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n";
54 54
         }
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
     global $PAGE;
66 66
 
67 67
     # Ignore errors we've asked to ignore
68
-    if (error_reporting()==0) return;
68
+    if (error_reporting() == 0) return;
69 69
 
70 70
    // define an assoc array of error string
71 71
    // in reality the only entries we should
72 72
    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
73 73
    // E_USER_WARNING and E_USER_NOTICE
74 74
    # Commented out are ones that a user function cannot handle.
75
-    $errortype = array (
75
+    $errortype = array(
76 76
         #E_ERROR            => "Error",
77 77
         E_WARNING           => "Warning",
78 78
         #E_PARSE            => "Parsing Error",
@@ -91,22 +91,22 @@  discard block
 block discarded – undo
91 91
 
92 92
     $err = '';
93 93
     if (isset($_SERVER['REQUEST_URI'])) {
94
-        $err .= "URL:\t\thttps://" . DOMAIN . $_SERVER['REQUEST_URI'] . "\n";
94
+        $err .= "URL:\t\thttps://".DOMAIN.$_SERVER['REQUEST_URI']."\n";
95 95
     } else {
96 96
         $err .= "URL:\t\tNone - running from command line?\n";
97 97
     }
98 98
     if (isset($_SERVER['HTTP_REFERER'])) {
99
-        $err .= "Referer:\t" . $_SERVER['HTTP_REFERER'] . "\n";
99
+        $err .= "Referer:\t".$_SERVER['HTTP_REFERER']."\n";
100 100
     } else {
101 101
         $err .= "Referer:\tNone\n";
102 102
     }
103 103
     if (isset($_SERVER['HTTP_USER_AGENT'])) {
104
-        $err .= "User-Agent:\t" . $_SERVER['HTTP_USER_AGENT'] . "\n";
104
+        $err .= "User-Agent:\t".$_SERVER['HTTP_USER_AGENT']."\n";
105 105
     } else {
106 106
         $err .= "User-Agent:\tNone\n";
107 107
     }
108 108
     $err .= "Number:\t\t$errno\n";
109
-    $err .= "Type:\t\t" . $errortype[$errno] . "\n";
109
+    $err .= "Type:\t\t".$errortype[$errno]."\n";
110 110
     $err .= "Message:\t$errmsg\n";
111 111
     $err .= "File:\t\t$filename\n";
112 112
     $err .= "Line:\t\t$linenum\n";
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
         $source = file($filename);
132 132
         $err .= "\nSource:\n\n";
133 133
         // Show the line, plus prev and next, with line numbers.
134
-        $err .= $linenum-2 . " " . $source[$linenum-3];
135
-        $err .= $linenum-1 . " " . $source[$linenum-2];
136
-        $err .= $linenum . " " . $source[$linenum-1];
137
-        $err .= $linenum+1 . " " . $source[$linenum];
138
-        $err .= $linenum+2 . " " . $source[$linenum+1];
134
+        $err .= $linenum - 2." ".$source[$linenum - 3];
135
+        $err .= $linenum - 1." ".$source[$linenum - 2];
136
+        $err .= $linenum." ".$source[$linenum - 1];
137
+        $err .= $linenum + 1." ".$source[$linenum];
138
+        $err .= $linenum + 2." ".$source[$linenum + 1];
139 139
     }
140 140
 
141 141
 
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
 
152 152
     if (DEVSITE || get_http_var(DEBUGTAG)) {
153 153
         // On a devsite we just display the problem.
154
-        $errtxt = nl2br($err) . "\n";
154
+        $errtxt = nl2br($err)."\n";
155 155
         if (!strstr($errmsg, 'mysql_connect')) {
156
-            $errtxt .= "<br><br>Backtrace:<br>" . nl2br(adodb_backtrace(false));
156
+            $errtxt .= "<br><br>Backtrace:<br>".nl2br(adodb_backtrace(false));
157 157
         }
158 158
         $message = array(
159 159
             'title' => "Error",
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
             header('HTTP/1.0 500 Internal Server Error');
180 180
             print "<p>Oops, sorry, an error has occurred!</p>\n";
181 181
         }
182
-        if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect')===false && strpos($errmsg, 'mysql_connect')===false) {
183
-            mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n".  "X-Mailer: PHP/" . phpversion() );
182
+        if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect') === false && strpos($errmsg, 'mysql_connect') === false) {
183
+            mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <".CONTACTEMAIL.">\n"."X-Mailer: PHP/".phpversion());
184 184
         }
185 185
     }
186 186
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 }
199 199
 
200 200
 // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php
201
-function adodb_backtrace($print=true)
201
+function adodb_backtrace($print = true)
202 202
 {
203 203
   $s = '';
204 204
   if (PHPVERSION() >= 4.3) {
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 
208 208
     $traceArr = debug_backtrace();
209 209
     array_shift($traceArr);
210
-    $tabs = sizeof($traceArr)-1;
210
+    $tabs = sizeof($traceArr) - 1;
211 211
     foreach ($traceArr as $arr) {
212
-      for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; ';
212
+      for ($i = 0; $i < $tabs; $i++) $s .= ' &nbsp; ';
213 213
       $tabs -= 1;
214 214
       if (isset($arr['class'])) $s .= $arr['class'].'.';
215 215
       $args = array();
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
     elseif (is_bool($v)) $args[] = $v ? 'true' : 'false';
221 221
     else {
222 222
       $v = (string) @$v;
223
-      $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN));
223
+      $str = _htmlspecialchars(substr($v, 0, $MAXSTRLEN));
224 224
       if (strlen($v) > $MAXSTRLEN) $str .= '...';
225 225
       $args[] = $str;
226 226
     }
227 227
       }
228 228
 
229
-      $s .= $arr['function'].'('.implode(', ',$args).')';
229
+      $s .= $arr['function'].'('.implode(', ', $args).')';
230 230
       //      $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,".
231 231
       //            " file: <a href=\"file:/%s\">%s</a></font>",
232 232
       //        $arr['line'],$arr['file'],$arr['file']);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     $nom = '0123456789';
265 265
     $gap = '\s\.';
266 266
 
267
-    if (    preg_match("/^[$fst][$num][$gap]*[$nom][$in][$in]$/i", $postcode) ||
267
+    if (preg_match("/^[$fst][$num][$gap]*[$nom][$in][$in]$/i", $postcode) ||
268 268
             preg_match("/^[$fst][$num][$num][$gap]*[$nom][$in][$in]$/i", $postcode) ||
269 269
             preg_match("/^[$fst][$sec][$num][$gap]*[$nom][$in][$in]$/i", $postcode) ||
270 270
             preg_match("/^[$fst][$sec][$num][$num][$gap]*[$nom][$in][$in]$/i", $postcode) ||
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 // Returns the unixtime in microseconds.
281 281
 function getmicrotime() {
282 282
     $mtime = microtime();
283
-    $mtime = explode(" ",$mtime);
283
+    $mtime = explode(" ", $mtime);
284 284
     $mtime = $mtime[1] + $mtime[0];
285 285
 
286 286
     return $mtime;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
     global $timestamp_last, $timestamp_start;
294 294
     $t = getmicrotime();
295 295
     twfy_debug("TIME", sprintf("%f msecs since start; %f msecs since last; %s",
296
-            ($t - $timestamp_start)*1000.0, ($t - $timestamp_last)*1000.0, $label));
296
+            ($t - $timestamp_start) * 1000.0, ($t - $timestamp_last) * 1000.0, $label));
297 297
     $timestamp_last = $t;
298 298
 }
299 299
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
     if (preg_match("/^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/", $timestamp, $matches)) {
308 308
         list($string, $year, $month, $day, $hour, $min, $sec) = $matches;
309 309
 
310
-        return gmdate ($format, gmmktime($hour, $min, $sec, $month, $day, $year));
310
+        return gmdate($format, gmmktime($hour, $min, $sec, $month, $day, $year));
311 311
     } else {
312 312
         return "";
313 313
     }
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
         list($string, $year, $month, $day) = $matches;
329 329
         if ($year < 1902) { # gmdate fns only go back to Dec. 1901
330 330
             if ($format == SHORTDATEFORMAT) {
331
-                return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year";
331
+                return ($day + 0).' '.$format_date_months_short[$month + 0]." $year";
332 332
             } else {
333
-                return ($day+0) . ' ' . $format_date_months[$month+0] . " $year";
333
+                return ($day + 0).' '.$format_date_months[$month + 0]." $year";
334 334
             }
335 335
         }
336 336
 
337
-        return gmdate ($format, gmmktime(0, 0, 0, $month, $day, $year));
337
+        return gmdate($format, gmmktime(0, 0, 0, $month, $day, $year));
338 338
     } else {
339 339
         return "";
340 340
     }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     if (preg_match("/^(\d\d):(\d\d):(\d\d)$/", $time, $matches)) {
351 351
         list($string, $hour, $min, $sec) = $matches;
352 352
 
353
-        return gmdate ($format, gmmktime($hour, $min, $sec));
353
+        return gmdate($format, gmmktime($hour, $min, $sec));
354 354
     } else {
355 355
         return "";
356 356
     }
@@ -371,16 +371,16 @@  discard block
 block discarded – undo
371 371
     $in_seconds = strtotime($datetime);
372 372
     $now = time();
373 373
 
374
-    $diff   =  $now - $in_seconds;
375
-    $months =  floor($diff/2419200);
374
+    $diff   = $now - $in_seconds;
375
+    $months = floor($diff / 2419200);
376 376
     $diff   -= $months * 2419200;
377
-    $weeks  =  floor($diff/604800);
378
-    $diff   -= $weeks*604800;
379
-    $days   =  floor($diff/86400);
377
+    $weeks  = floor($diff / 604800);
378
+    $diff   -= $weeks * 604800;
379
+    $days   = floor($diff / 86400);
380 380
     $diff   -= $days * 86400;
381
-    $hours  =  floor($diff/3600);
381
+    $hours  = floor($diff / 3600);
382 382
     $diff   -= $hours * 3600;
383
-    $minutes = floor($diff/60);
383
+    $minutes = floor($diff / 60);
384 384
     $diff   -= $minutes * 60;
385 385
     $seconds = $diff;
386 386
 
@@ -394,22 +394,22 @@  discard block
 block discarded – undo
394 394
         $relative_date = '';
395 395
         if ($weeks > 0) {
396 396
             // Weeks and days
397
-            $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':'');
398
-            $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):'';
397
+            $relative_date .= ($relative_date ? ', ' : '').$weeks.' week'.($weeks > 1 ? 's' : '');
398
+            $relative_date .= $days > 0 ? ($relative_date ? ', ' : '').$days.' day'.($days > 1 ? 's' : '') : '';
399 399
         } elseif ($days > 0) {
400 400
             // days and hours
401
-            $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':'');
402
-            $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):'';
401
+            $relative_date .= ($relative_date ? ', ' : '').$days.' day'.($days > 1 ? 's' : '');
402
+            $relative_date .= $hours > 0 ? ($relative_date ? ', ' : '').$hours.' hour'.($hours > 1 ? 's' : '') : '';
403 403
         } elseif ($hours > 0) {
404 404
             // hours and minutes
405
-            $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':'');
406
-            $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):'';
405
+            $relative_date .= ($relative_date ? ', ' : '').$hours.' hour'.($hours > 1 ? 's' : '');
406
+            $relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '').$minutes.' minute'.($minutes > 1 ? 's' : '') : '';
407 407
         } elseif ($minutes > 0) {
408 408
             // minutes only
409
-            $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':'');
409
+            $relative_date .= ($relative_date ? ', ' : '').$minutes.' minute'.($minutes > 1 ? 's' : '');
410 410
         } else {
411 411
             // seconds only
412
-            $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':'');
412
+            $relative_date .= ($relative_date ? ', ' : '').$seconds.' second'.($seconds > 1 ? 's' : '');
413 413
         }
414 414
     }
415 415
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 
446 446
     // Split long strings up so they don't go too long.
447 447
     // Mainly for URLs which are displayed, but aren't links when trimmed.
448
-    $text = preg_replace('/(\S{' . $url_length . '})/', "\$1 ", $text);
448
+    $text = preg_replace('/(\S{'.$url_length.'})/', "\$1 ", $text);
449 449
 
450 450
     // Otherwise the word boundary matching goes odd...
451 451
     $text = preg_replace("/[\n\r]/", " ", $text);
@@ -455,12 +455,12 @@  discard block
 block discarded – undo
455 455
         $text = substr($text, $start);
456 456
 
457 457
         // Word boundary.
458
-        if (preg_match ("/.+?\b(.*)/", $text, $matches)) {
458
+        if (preg_match("/.+?\b(.*)/", $text, $matches)) {
459 459
             $text = $matches[1];
460 460
             // Strip spare space at the start.
461
-            $text = preg_replace ("/^\s/", '', $text);
461
+            $text = preg_replace("/^\s/", '', $text);
462 462
         }
463
-        $text = '...' . $text;
463
+        $text = '...'.$text;
464 464
     }
465 465
 
466 466
     // Trim end.
@@ -470,10 +470,10 @@  discard block
 block discarded – undo
470 470
         $text = substr($text, 0, $length - 3);
471 471
 
472 472
         // Word boundary.
473
-        if (preg_match ("/(.*)\s.+/", $text, $matches)) {
473
+        if (preg_match("/(.*)\s.+/", $text, $matches)) {
474 474
             $text = $matches[1];
475 475
             // Strip spare space at the end.
476
-            $text = preg_replace ("/\s$/", '', $text);
476
+            $text = preg_replace("/\s$/", '', $text);
477 477
         }
478 478
         // We don't want to use the HTML entity for an ellipsis (&#8230;), because then
479 479
         // it screws up when we subsequently use htmlentities() to print the returned
@@ -505,11 +505,11 @@  discard block
 block discarded – undo
505 505
 
506 506
     if ($filter_type == 'strict') {
507 507
         // No tags allowed at all!
508
-        $filter->allowed = array ();
508
+        $filter->allowed = array();
509 509
     } else {
510 510
         // Comment.
511 511
         // Only allowing <a href>, <b>, <strong>, <i> and <em>
512
-        $filter->allowed = array (
512
+        $filter->allowed = array(
513 513
             'a' => array('href'),
514 514
             'strong' => array(),
515 515
             'em' => array(),
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
         "/(?<!\"|\/)((http(s?):\/\/)|(www\.))([a-zA-Z\d_.+,;:?%~\-\/#='*$!()&[\]]+)([a-zA-Z\d_?%~\-\/#='*$!&])/",
541 541
         function($matches) use ($link_length) {
542 542
             if (strlen($matches[0]) > $link_length) {
543
-                return '<a href="' . $matches[0] . '" rel="nofollow">' . substr($matches[0], 0, $link_length) . "...</a>";
543
+                return '<a href="'.$matches[0].'" rel="nofollow">'.substr($matches[0], 0, $link_length)."...</a>";
544 544
             } else {
545
-                return '<a href="' . $matches[0] . '" rel="nofollow">' . $matches[0] . '</a>';
545
+                return '<a href="'.$matches[0].'" rel="nofollow">'.$matches[0].'</a>';
546 546
             }
547 547
         },
548 548
         $text);
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
     // This returns 'debate_2003-02-28.475.3'.
631 631
 
632 632
     if ($keepmajor) {
633
-        $newgid = substr($gid, strpos($gid, '/')+1 );
633
+        $newgid = substr($gid, strpos($gid, '/') + 1);
634 634
         $newgid = str_replace('/', '_', $newgid);
635 635
     } else {
636
-        $newgid = substr($gid, strrpos($gid, '/')+1 );
636
+        $newgid = substr($gid, strrpos($gid, '/') + 1);
637 637
     }
638 638
 
639 639
     return $newgid;
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
     // will be like 2003-11-20.966.0
648 648
     // This function returns 966.0
649 649
 
650
-    return substr( $gid, (strpos($gid, '.') + 1) );
650
+    return substr($gid, (strpos($gid, '.') + 1));
651 651
 }
652 652
 
653 653
 function preg_replacement_quote($s) {
@@ -691,14 +691,14 @@  discard block
 block discarded – undo
691 691
     global $PAGE;
692 692
 
693 693
     if (!isset($data['to']) || $data['to'] == '') {
694
-        $PAGE->error_message ("We need an email address to send to.");
694
+        $PAGE->error_message("We need an email address to send to.");
695 695
         return false;
696 696
     }
697 697
 
698
-    $filename = INCLUDESPATH . "easyparliament/templates/emails/" . $data['template'] . ".txt";
698
+    $filename = INCLUDESPATH."easyparliament/templates/emails/".$data['template'].".txt";
699 699
 
700 700
     if (!file_exists($filename)) {
701
-        $PAGE->error_message("Sorry, we could not find the email template '" . _htmlentities($data['template']) . "'.");
701
+        $PAGE->error_message("Sorry, we could not find the email template '"._htmlentities($data['template'])."'.");
702 702
         return false;
703 703
     }
704 704
 
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
         if (isset($data['subject'])) {
716 716
             $subject = trim($data['subject']);
717 717
         } else {
718
-            $subject = trim( substr($firstline, 8) );
718
+            $subject = trim(substr($firstline, 8));
719 719
         }
720 720
 
721 721
         // Either way, remove this subject line from the template.
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
     } elseif (isset($data['subject'])) {
725 725
         $subject = $data['subject'];
726 726
     } else {
727
-        $PAGE->error_message ("We don't have a subject line for the email, so it wasn't sent.");
727
+        $PAGE->error_message("We don't have a subject line for the email, so it wasn't sent.");
728 728
         return false;
729 729
     }
730 730
 
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
     $emailtext = preg_replace($search, $replace, $emailtext);
742 742
 
743 743
     // Send it!
744
-    $success = send_email ($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces);
744
+    $success = send_email($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@'.EMAILDOMAIN, $want_bounces);
745 745
 
746 746
     return $success;
747 747
 
@@ -764,19 +764,19 @@  discard block
 block discarded – undo
764 764
     if (!$from) $from = CONTACTEMAIL;
765 765
 
766 766
     $headers =
767
-     "From: TheyWorkForYou <$from>\r\n" .
768
-     "Content-Type: text/plain; charset=utf-8\r\n" .
769
-     "MIME-Version: 1.0\r\n" .
770
-     "Content-Transfer-Encoding: 8bit\r\n" .
771
-     ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "" ).
772
-     "X-Mailer: PHP/" . phpversion();
767
+     "From: TheyWorkForYou <$from>\r\n".
768
+     "Content-Type: text/plain; charset=utf-8\r\n".
769
+     "MIME-Version: 1.0\r\n".
770
+     "Content-Transfer-Encoding: 8bit\r\n".
771
+     ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "").
772
+     "X-Mailer: PHP/".phpversion();
773 773
     twfy_debug('EMAIL', "Sending email to $to with subject of '$subject'");
774 774
 
775 775
     if ($want_bounces) {
776 776
       $envelope_sender = twfy_verp_envelope_sender($to);
777
-        $success = mail ($to, $subject, $message, $headers, '-f ' . $envelope_sender);
777
+        $success = mail($to, $subject, $message, $headers, '-f '.$envelope_sender);
778 778
     } else {
779
-        $success = mail ($to, $subject, $message, $headers);
779
+        $success = mail($to, $subject, $message, $headers);
780 780
     }
781 781
 
782 782
     return $success;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 // http://www.iamcal.com/publish/article.php?id=13
789 789
 
790 790
 // Call this with a key name to get a GET or POST variable.
791
-function get_http_var($name, $default='') {
791
+function get_http_var($name, $default = '') {
792 792
     if (array_key_exists($name, $_GET)) {
793 793
         return clean_var($_GET[$name]);
794 794
     }
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 }
815 815
 
816 816
 // Call this with a key name to get a COOKIE variable.
817
-function get_cookie_var($name, $default='') {
817
+function get_cookie_var($name, $default = '') {
818 818
     if (array_key_exists($name, $_COOKIE)) {
819 819
         return clean_var($_COOKIE[$name]);
820 820
     }
@@ -825,25 +825,25 @@  discard block
 block discarded – undo
825 825
 // Pass it an array of key names that should not be generated as
826 826
 // hidden form variables. It then outputs hidden form variables
827 827
 // based on the session_vars for this page.
828
-function hidden_form_vars ($omit = array()) {
828
+function hidden_form_vars($omit = array()) {
829 829
     global $DATA, $this_page;
830 830
 
831 831
     $session_vars = $DATA->page_metadata($this_page, "session_vars");
832 832
 
833 833
     foreach ($session_vars as $n => $key) {
834 834
         if (!in_array($key, $omit)) {
835
-            print "<input type=\"hidden\" name=\"$key\" value=\"" . _htmlentities(get_http_var($key)) . "\">\n";
835
+            print "<input type=\"hidden\" name=\"$key\" value=\""._htmlentities(get_http_var($key))."\">\n";
836 836
         }
837 837
     }
838 838
 }
839 839
 
840 840
 // Deprecated. Use hidden_form_vars, above, instead.
841
-function hidden_vars ($omit = array()) {
841
+function hidden_vars($omit = array()) {
842 842
     global $DATA;
843 843
 
844 844
     foreach ($args as $key => $val) {
845 845
         if (!in_array($key, $omit)) {
846
-            print "<input type=\"hidden\" name=\"$key\" value=\"" . _htmlspecialchars($val) . "\">\n";
846
+            print "<input type=\"hidden\" name=\"$key\" value=\""._htmlspecialchars($val)."\">\n";
847 847
         }
848 848
     }
849 849
 }
@@ -854,26 +854,26 @@  discard block
 block discarded – undo
854 854
 
855 855
     # 11th, 12th, 13th use "th" not "st", "nd", "rd"
856 856
     if (floor(($rank % 100) / 10) == 1)
857
-        return $rank . "th";
857
+        return $rank."th";
858 858
     # 1st
859 859
     if ($rank % 10 == 1)
860
-        return $rank . "st";
860
+        return $rank."st";
861 861
     # 2nd
862 862
     if ($rank % 10 == 2)
863
-        return $rank . "nd";
863
+        return $rank."nd";
864 864
     # 3rd
865 865
     if ($rank % 10 == 3)
866
-        return $rank . "rd";
866
+        return $rank."rd";
867 867
     # Everything else use th
868 868
 
869
-    return $rank . "th";
869
+    return $rank."th";
870 870
 }
871 871
 
872 872
 function make_plural($word, $number)
873 873
 {
874 874
     if ($number == 1)
875 875
         return $word;
876
-    return $word . "s";
876
+    return $word."s";
877 877
 }
878 878
 
879 879
 # Can't have the entities in XML so replace all theones we currently have with numerical entities
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 function entities_to_numbers($string) {
882 882
     $string = str_replace(
883 883
         array('&Ouml;', '&acirc;', '&uacute;', '&aacute;', '&iacute;', '&ocirc;', '&eacute;'),
884
-        array('&#214;', '&#226;',  '&#250;',   '&#225;',   '&#237;',   '&#244;',  '&#233;'  ),
884
+        array('&#214;', '&#226;', '&#250;', '&#225;', '&#237;', '&#244;', '&#233;'),
885 885
         $string
886 886
     );
887 887
     return $string;
@@ -895,9 +895,9 @@  discard block
 block discarded – undo
895 895
         return 'elizabeth_the_second';
896 896
     }
897 897
 
898
-    $s   = array(' ', '&amp;', '&ocirc;',  '&Ouml;',  '&ouml;',   '&acirc;',  '&iacute;', '&aacute;', '&uacute;', '&eacute;', '&oacute;', '&Oacute;');
899
-    $s2  = array(" ", "&",     "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93");
900
-    $r   = array('_', 'and',   'o',        'o',       'o',        'a',        'i',        'a',        'u',        'e',        'o',        'o');
898
+    $s   = array(' ', '&amp;', '&ocirc;', '&Ouml;', '&ouml;', '&acirc;', '&iacute;', '&aacute;', '&uacute;', '&eacute;', '&oacute;', '&Oacute;');
899
+    $s2  = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93");
900
+    $r   = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o');
901 901
     $name = preg_replace('#^the #', '', strtolower($name));
902 902
 
903 903
     $out = '';
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
     // Insert the Person ID if known.
906 906
     if ($pid !== NULL)
907 907
     {
908
-        $out .= $pid . '/';
908
+        $out .= $pid.'/';
909 909
     }
910 910
 
911 911
     // Always inject the person's name
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
     // If there is a constituency, inject that too
915 915
     if ($const && $house == HOUSE_TYPE_COMMONS)
916 916
     {
917
-        $out .= '/' . urlencode(str_replace($s2, $r, str_replace($s, $r, strtolower($const))));
917
+        $out .= '/'.urlencode(str_replace($s2, $r, str_replace($s, $r, strtolower($const))));
918 918
     }
919 919
 
920 920
     return $out;
@@ -925,14 +925,14 @@  discard block
 block discarded – undo
925 925
     if ($house == HOUSE_TYPE_COMMONS || $house == HOUSE_TYPE_NI || $house == HOUSE_TYPE_SCOTLAND) {
926 926
         $s = "$given_name $family_name";
927 927
         if ($title) {
928
-            $s = $title . ' ' . $s;
928
+            $s = $title.' '.$s;
929 929
         }
930 930
     } elseif ($house == HOUSE_TYPE_LORDS) {
931 931
         $s = '';
932 932
         if (!$family_name) $s = 'the ';
933 933
         $s .= $title;
934
-        if ($family_name) $s .= ' ' . $family_name;
935
-        if ($lordofname) $s .= ' of ' . $lordofname;
934
+        if ($family_name) $s .= ' '.$family_name;
935
+        if ($lordofname) $s .= ' of '.$lordofname;
936 936
     } elseif ($house == HOUSE_TYPE_ROYAL) { # Queen
937 937
         $s = "$given_name $family_name";
938 938
     }
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
         foreach ($data as $major => $array) {
1003 1003
             if (!in_array('timestamp', $array)) $daytext[$major] = "The most recent ";
1004 1004
             elseif ($todaystime - $array['timestamp'] == 86400) $daytext[$major] = "Yesterday&rsquo;s";
1005
-            elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp']) . "&rsquo;s";
1005
+            elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp'])."&rsquo;s";
1006 1006
             else $daytext[$major] = "The most recent ";
1007 1007
         }
1008 1008
     }
@@ -1019,9 +1019,9 @@  discard block
 block discarded – undo
1019 1019
         $q = $db->query('SELECT section_id, body, gid
1020 1020
                 FROM hansard, epobject
1021 1021
                 WHERE hansard.epobject_id = epobject.epobject_id '
1022
-                . ($p_major == 4 ? 'AND subsection_id=0' : 'AND section_id=0') .
1023
-                ' AND hdate = "' . $date . '"
1024
-                AND major = ' . $p_major . '
1022
+                . ($p_major == 4 ? 'AND subsection_id=0' : 'AND section_id=0').
1023
+                ' AND hdate = "'.$date.'"
1024
+                AND major = ' . $p_major.'
1025 1025
                 ORDER BY hpos');
1026 1026
         $out = '';
1027 1027
         $LISTURL = new URL($hansardmajors[$p_major]['page_all']);
@@ -1035,11 +1035,11 @@  discard block
 block discarded – undo
1035 1035
                 if ($current_sid++) {
1036 1036
                     $out .= '</ul>';
1037 1037
                 }
1038
-                $out .= '<li>' . $body . '<ul>';
1038
+                $out .= '<li>'.$body.'<ul>';
1039 1039
             } else {
1040
-                $LISTURL->insert( array( 'id' => $gid ) );
1040
+                $LISTURL->insert(array('id' => $gid));
1041 1041
                 $out .= '<li><a href="'.$LISTURL->generate().'">';
1042
-                $out .= $body . '</a>';
1042
+                $out .= $body.'</a>';
1043 1043
             }
1044 1044
         }
1045 1045
         if ($out) {
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 
1064 1064
     $return = '<h4>';
1065 1065
     if (isset($daytext[$major])) {
1066
-     $return .= $daytext[$major] . ' ';
1066
+     $return .= $daytext[$major].' ';
1067 1067
     }
1068 1068
 
1069 1069
     $return .= '<a href="';
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
         $LISTURL->reset();
1074 1074
         $return .= $LISTURL->generate();
1075 1075
     }
1076
-    $return .= '">' . $hansardmajors[$major]['title'] . '</a>';
1076
+    $return .= '">'.$hansardmajors[$major]['title'].'</a>';
1077 1077
     if (isset($daytext[$major])) $return;
1078 1078
     $return .= '</h4>';
1079 1079
 
@@ -1118,10 +1118,10 @@  discard block
 block discarded – undo
1118 1118
 
1119 1119
 function cache_version($file) {
1120 1120
     static $version_hash = array();
1121
-    $path = BASEDIR . "/$file";
1121
+    $path = BASEDIR."/$file";
1122 1122
     if (is_file($path) && (!isset($version_hash[$file]) || DEVSITE)) {
1123 1123
         $version_hash[$file] = stat($path)[9];
1124
-        $file .= '?' . $version_hash[$file];
1124
+        $file .= '?'.$version_hash[$file];
1125 1125
     }
1126
-    return WEBPATH . $file;
1126
+    return WEBPATH.$file;
1127 1127
 }
Please login to merge, or discard this patch.
Braces   +104 added lines, -59 removed lines patch added patch discarded remove patch
@@ -49,7 +49,9 @@  discard block
 block discarded – undo
49 49
 
50 50
         // If we can show this header, then, er, show it.
51 51
         if ( in_array($header, $allowed_headers) || $debug_level >= 4) {
52
-            if (is_array($text)) $text = call_user_func($text);
52
+            if (is_array($text)) {
53
+                $text = call_user_func($text);
54
+            }
53 55
             print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n";
54 56
         }
55 57
     }
@@ -65,7 +67,9 @@  discard block
 block discarded – undo
65 67
     global $PAGE;
66 68
 
67 69
     # Ignore errors we've asked to ignore
68
-    if (error_reporting()==0) return;
70
+    if (error_reporting()==0) {
71
+        return;
72
+    }
69 73
 
70 74
    // define an assoc array of error string
71 75
    // in reality the only entries we should
@@ -209,19 +213,29 @@  discard block
 block discarded – undo
209 213
     array_shift($traceArr);
210 214
     $tabs = sizeof($traceArr)-1;
211 215
     foreach ($traceArr as $arr) {
212
-      for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; ';
216
+      for ($i=0; $i < $tabs; $i++) {
217
+          $s .= ' &nbsp; ';
218
+      }
213 219
       $tabs -= 1;
214
-      if (isset($arr['class'])) $s .= $arr['class'].'.';
220
+      if (isset($arr['class'])) {
221
+          $s .= $arr['class'].'.';
222
+      }
215 223
       $args = array();
216
-      if (isset($arr['args'])) foreach ($arr['args'] as $v) {
224
+      if (isset($arr['args'])) {
225
+          foreach ($arr['args'] as $v) {
217 226
     if (is_null($v)) $args[] = 'null';
218
-    elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']';
219
-    elseif (is_object($v)) $args[] = 'Object:'.get_class($v);
220
-    elseif (is_bool($v)) $args[] = $v ? 'true' : 'false';
221
-    else {
227
+      } elseif (is_array($v)) {
228
+        $args[] = 'Array['.sizeof($v).']';
229
+    } elseif (is_object($v)) {
230
+        $args[] = 'Object:'.get_class($v);
231
+    } elseif (is_bool($v)) {
232
+        $args[] = $v ? 'true' : 'false';
233
+    } else {
222 234
       $v = (string) @$v;
223 235
       $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN));
224
-      if (strlen($v) > $MAXSTRLEN) $str .= '...';
236
+      if (strlen($v) > $MAXSTRLEN) {
237
+          $str .= '...';
238
+      }
225 239
       $args[] = $str;
226 240
     }
227 241
       }
@@ -232,7 +246,9 @@  discard block
 block discarded – undo
232 246
       //        $arr['line'],$arr['file'],$arr['file']);
233 247
       $s .= "\n";
234 248
     }
235
-    if ($print) print $s;
249
+    if ($print) {
250
+        print $s;
251
+    }
236 252
   }
237 253
 
238 254
   return $s;
@@ -761,7 +777,9 @@  discard block
 block discarded – undo
761 777
     // easily to all the emails we send out from the site.
762 778
     // eg, we might want to add a .sig to everything here...
763 779
 
764
-    if (!$from) $from = CONTACTEMAIL;
780
+    if (!$from) {
781
+        $from = CONTACTEMAIL;
782
+    }
765 783
 
766 784
     $headers =
767 785
      "From: TheyWorkForYou <$from>\r\n" .
@@ -853,17 +871,21 @@  discard block
 block discarded – undo
853 871
     $rank = $rank + 0;
854 872
 
855 873
     # 11th, 12th, 13th use "th" not "st", "nd", "rd"
856
-    if (floor(($rank % 100) / 10) == 1)
857
-        return $rank . "th";
874
+    if (floor(($rank % 100) / 10) == 1) {
875
+            return $rank . "th";
876
+    }
858 877
     # 1st
859
-    if ($rank % 10 == 1)
860
-        return $rank . "st";
878
+    if ($rank % 10 == 1) {
879
+            return $rank . "st";
880
+    }
861 881
     # 2nd
862
-    if ($rank % 10 == 2)
863
-        return $rank . "nd";
882
+    if ($rank % 10 == 2) {
883
+            return $rank . "nd";
884
+    }
864 885
     # 3rd
865
-    if ($rank % 10 == 3)
866
-        return $rank . "rd";
886
+    if ($rank % 10 == 3) {
887
+            return $rank . "rd";
888
+    }
867 889
     # Everything else use th
868 890
 
869 891
     return $rank . "th";
@@ -871,8 +893,9 @@  discard block
 block discarded – undo
871 893
 
872 894
 function make_plural($word, $number)
873 895
 {
874
-    if ($number == 1)
875
-        return $word;
896
+    if ($number == 1) {
897
+            return $word;
898
+    }
876 899
     return $word . "s";
877 900
 }
878 901
 
@@ -929,10 +952,16 @@  discard block
 block discarded – undo
929 952
         }
930 953
     } elseif ($house == HOUSE_TYPE_LORDS) {
931 954
         $s = '';
932
-        if (!$family_name) $s = 'the ';
955
+        if (!$family_name) {
956
+            $s = 'the ';
957
+        }
933 958
         $s .= $title;
934
-        if ($family_name) $s .= ' ' . $family_name;
935
-        if ($lordofname) $s .= ' of ' . $lordofname;
959
+        if ($family_name) {
960
+            $s .= ' ' . $family_name;
961
+        }
962
+        if ($lordofname) {
963
+            $s .= ' of ' . $lordofname;
964
+        }
936 965
     } elseif ($house == HOUSE_TYPE_ROYAL) { # Queen
937 966
         $s = "$given_name $family_name";
938 967
     }
@@ -964,9 +993,12 @@  discard block
 block discarded – undo
964 993
     );
965 994
     if ($pos) { # Government post, or Chairman of Select Committee
966 995
         $pretty = $pos;
967
-        if ($dept && $dept != 'No Department') $pretty .= ", $dept";
968
-        if (array_key_exists($pretty, $lookup))
969
-            $pretty = $lookup[$pretty];
996
+        if ($dept && $dept != 'No Department') {
997
+            $pretty .= ", $dept";
998
+        }
999
+        if (array_key_exists($pretty, $lookup)) {
1000
+                    $pretty = $lookup[$pretty];
1001
+        }
970 1002
     } else { # Member of Select Committee
971 1003
         $pretty = "Member, $dept";
972 1004
     }
@@ -985,13 +1017,16 @@  discard block
 block discarded – undo
985 1017
     }
986 1018
 
987 1019
     // single date?
988
-    if (isset($data['date'])) $one_date = true;
1020
+    if (isset($data['date'])) {
1021
+        $one_date = true;
1022
+    }
989 1023
 
990 1024
     // remove empty entries, so they don't produce errors
991 1025
     foreach (array_keys($hansardmajors) as $major) {
992 1026
         if (array_key_exists($major, $data)) {
993
-            if (count($data[$major]) == 0)
994
-                unset($data[$major]);
1027
+            if (count($data[$major]) == 0) {
1028
+                            unset($data[$major]);
1029
+            }
995 1030
         }
996 1031
     }
997 1032
 
@@ -1000,22 +1035,29 @@  discard block
 block discarded – undo
1000 1035
     if (!$one_date) {
1001 1036
         $todaystime = gmmktime(0, 0, 0, date('m'), date('d'), date('Y'));
1002 1037
         foreach ($data as $major => $array) {
1003
-            if (!in_array('timestamp', $array)) $daytext[$major] = "The most recent ";
1004
-            elseif ($todaystime - $array['timestamp'] == 86400) $daytext[$major] = "Yesterday&rsquo;s";
1005
-            elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp']) . "&rsquo;s";
1006
-            else $daytext[$major] = "The most recent ";
1038
+            if (!in_array('timestamp', $array)) {
1039
+                $daytext[$major] = "The most recent ";
1040
+            } elseif ($todaystime - $array['timestamp'] == 86400) {
1041
+                $daytext[$major] = "Yesterday&rsquo;s";
1042
+            } elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) {
1043
+                $daytext[$major] = gmdate('l', $array['timestamp']) . "&rsquo;s";
1044
+            } else {
1045
+                $daytext[$major] = "The most recent ";
1046
+            }
1007 1047
         }
1008 1048
     }
1009 1049
 
1010 1050
     //build html
1011 1051
     foreach ($printed_majors as $p_major) {
1012
-        if (!array_key_exists($p_major, $data))
1013
-            continue;
1052
+        if (!array_key_exists($p_major, $data)) {
1053
+                    continue;
1054
+        }
1014 1055
 
1015
-        if ($one_date)
1016
-            $date = $data['date'];
1017
-        else
1018
-            $date = $data[$p_major]['hdate'];
1056
+        if ($one_date) {
1057
+                    $date = $data['date'];
1058
+        } else {
1059
+                    $date = $data[$p_major]['hdate'];
1060
+        }
1019 1061
         $q = $db->query('SELECT section_id, body, gid
1020 1062
                 FROM hansard, epobject
1021 1063
                 WHERE hansard.epobject_id = epobject.epobject_id '
@@ -1067,14 +1109,16 @@  discard block
 block discarded – undo
1067 1109
     }
1068 1110
 
1069 1111
     $return .= '<a href="';
1070
-    if (isset($data[$major]['listurl']))
1071
-        $return .= $data[$major]['listurl'];
1072
-    else {
1112
+    if (isset($data[$major]['listurl'])) {
1113
+            $return .= $data[$major]['listurl'];
1114
+    } else {
1073 1115
         $LISTURL->reset();
1074 1116
         $return .= $LISTURL->generate();
1075 1117
     }
1076 1118
     $return .= '">' . $hansardmajors[$major]['title'] . '</a>';
1077
-    if (isset($daytext[$major])) $return;
1119
+    if (isset($daytext[$major])) {
1120
+        $return;
1121
+    }
1078 1122
     $return .= '</h4>';
1079 1123
 
1080 1124
     return $return;
@@ -1082,20 +1126,21 @@  discard block
 block discarded – undo
1082 1126
 
1083 1127
 function score_to_strongly($dmpscore) {
1084 1128
     $dmpdesc = "unknown about";
1085
-    if ($dmpscore > 0.95 && $dmpscore <= 1.0)
1086
-        $dmpdesc = "consistently voted against";
1087
-    elseif ($dmpscore > 0.85)
1088
-        $dmpdesc = "almost always voted against";
1089
-    elseif ($dmpscore > 0.6)
1090
-        $dmpdesc = "generally voted against";
1091
-    elseif ($dmpscore > 0.4)
1092
-        $dmpdesc = "voted a mixture of for and against";
1093
-    elseif ($dmpscore > 0.15)
1094
-        $dmpdesc = "generally voted for";
1095
-    elseif ($dmpscore > 0.05)
1096
-        $dmpdesc = "almost always voted for";
1097
-    elseif ($dmpscore >= 0.0)
1098
-        $dmpdesc = "consistently voted for";
1129
+    if ($dmpscore > 0.95 && $dmpscore <= 1.0) {
1130
+            $dmpdesc = "consistently voted against";
1131
+    } elseif ($dmpscore > 0.85) {
1132
+            $dmpdesc = "almost always voted against";
1133
+    } elseif ($dmpscore > 0.6) {
1134
+            $dmpdesc = "generally voted against";
1135
+    } elseif ($dmpscore > 0.4) {
1136
+            $dmpdesc = "voted a mixture of for and against";
1137
+    } elseif ($dmpscore > 0.15) {
1138
+            $dmpdesc = "generally voted for";
1139
+    } elseif ($dmpscore > 0.05) {
1140
+            $dmpdesc = "almost always voted for";
1141
+    } elseif ($dmpscore >= 0.0) {
1142
+            $dmpdesc = "consistently voted for";
1143
+    }
1099 1144
     return $dmpdesc;
1100 1145
 }
1101 1146
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
     return $string;
888 888
 }
889 889
 
890
-function make_member_url($name, $const = '', $house = HOUSE_TYPE_COMMONS, $pid = NULL) {
890
+function make_member_url($name, $const = '', $house = HOUSE_TYPE_COMMONS, $pid = null) {
891 891
 
892 892
     // Case for Elizabeth II
893 893
     if ($house == HOUSE_TYPE_ROYAL)
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
     $out = '';
904 904
 
905 905
     // Insert the Person ID if known.
906
-    if ($pid !== NULL)
906
+    if ($pid !== null)
907 907
     {
908 908
         $out .= $pid . '/';
909 909
     }
Please login to merge, or discard this patch.
classes/PolicyPositions.php 5 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,6 @@
 block discarded – undo
53 53
      *
54 54
      * @param Policies $policies The list of policies to get the positions for.
55 55
      * @param Member   $member   The member to get positions for.
56
-     * @param int      $limit    The number of policies to limit the list to.
57 56
      */
58 57
 
59 58
     public function __construct(Policies $policies, Member $member, $options = array())
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@
 block discarded – undo
121 121
                 if (!empty($dream_info)) {
122 122
                     $summary = '';
123 123
                     if (array_key_exists($policy[0], $this->summaries)) {
124
-                      $summary = $this->divisions->generateSummary($this->summaries[$policy[0]]);
124
+                        $summary = $this->divisions->generateSummary($this->summaries[$policy[0]]);
125 125
                     }
126 126
                     $this->positions[] = array(
127 127
                         'policy_id' => $policy[0],
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @param int $limit The number of results to limit the output to.
78 78
      */
79 79
 
80
-    private function getMemberPolicyPositions ($limit = NULL) {
80
+    private function getMemberPolicyPositions($limit = NULL) {
81 81
 
82 82
         // Make sure member info has actually been set.
83 83
         if (count($this->member->extra_info) === 0) {
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
                 // don't return votes where they haven't voted on a strong division
114 114
                 // if we're limiting the number of votes
115
-                if ( $limit && !empty($dream_info) && !$dream_info['has_strong'] ) {
115
+                if ($limit && !empty($dream_info) && !$dream_info['has_strong']) {
116 116
                     continue;
117 117
                 }
118 118
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
             } else {
147 147
                 // We're over the policy limit, no sense still going, break out of the foreach.
148
-                break ;
148
+                break;
149 149
             }
150 150
         }
151 151
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      *
175 175
      */
176 176
 
177
-    private function displayDreamComparison($dreamid, $policy_description, $inverse=false) {
177
+    private function displayDreamComparison($dreamid, $policy_description, $inverse = false) {
178 178
         $out = array();
179 179
 
180 180
         $extra_info = $this->member->extra_info();
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
             if (isset($extra_info["public_whip_dreammp${dreamid}_has_strong_vote"]) && $extra_info["public_whip_dreammp${dreamid}_has_strong_vote"] == 1) {
194 194
                 $has_strong = 1;
195 195
             }
196
-            $full_sentence = $consistency . ' ' . $policy_description;
197
-            $out = array( 'full_sentence' => $full_sentence, 'score' => $dmpscore, 'position' => $consistency, 'has_strong' => $has_strong );
196
+            $full_sentence = $consistency.' '.$policy_description;
197
+            $out = array('full_sentence' => $full_sentence, 'score' => $dmpscore, 'position' => $consistency, 'has_strong' => $has_strong);
198 198
         }
199 199
 
200 200
         return $out;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
             # If not current MP/Lord, but current MLA/MSP, need to say voting record is when MP
226 226
             if (!$current_member[HOUSE_TYPE_COMMONS] AND
227 227
                 !$current_member[HOUSE_TYPE_LORDS] AND
228
-                ( $current_member[HOUSE_TYPE_SCOTLAND] OR $current_member[HOUSE_TYPE_NI] )
228
+                ($current_member[HOUSE_TYPE_SCOTLAND] OR $current_member[HOUSE_TYPE_NI])
229 229
             ) {
230 230
                 $since .= ' whilst an MP';
231 231
             }
@@ -242,23 +242,23 @@  discard block
 block discarded – undo
242 242
         // Links to full record at Guardian and Public Whip
243 243
         $record = array();
244 244
         if (isset($extra_info['guardian_howtheyvoted'])) {
245
-            $record[] = '<a href="' . $extra_info['guardian_howtheyvoted'] .
245
+            $record[] = '<a href="'.$extra_info['guardian_howtheyvoted'].
246 246
                 '" title="At The Guardian">well-known issues</a> <small>(from the Guardian)</small>';
247 247
         }
248 248
         if (
249
-            ( isset($extra_info['public_whip_division_attendance']) AND
250
-            $extra_info['public_whip_division_attendance'] != 'n/a' )
249
+            (isset($extra_info['public_whip_division_attendance']) AND
250
+            $extra_info['public_whip_division_attendance'] != 'n/a')
251 251
             OR
252
-            ( isset($extra_info['Lpublic_whip_division_attendance']) AND
253
-            $extra_info['Lpublic_whip_division_attendance'] != 'n/a' )
252
+            (isset($extra_info['Lpublic_whip_division_attendance']) AND
253
+            $extra_info['Lpublic_whip_division_attendance'] != 'n/a')
254 254
         ) {
255
-            $record[] = '<a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/' .
256
-                $this->member->member_id() .
255
+            $record[] = '<a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/'.
256
+                $this->member->member_id().
257 257
                 '&amp;showall=yes#divisions" title="At Public Whip">their full voting record on Public Whip</a>';
258 258
         }
259 259
 
260 260
         if (count($record) > 0) {
261
-            return 'More on ' . implode(' &amp; ', $record);
261
+            return 'More on '.implode(' &amp; ', $record);
262 262
         } else {
263 263
             return '';
264 264
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -105,8 +105,9 @@  discard block
 block discarded – undo
105 105
         foreach ($policies as $policy) {
106 106
             // Are we still within the policy limit?
107 107
             if ($i < $policy_limit) {
108
-                if (isset($policy[2]) && $policy[2] && !in_array(HOUSE_TYPE_COMMONS, $member_houses))
109
-                    continue;
108
+                if (isset($policy[2]) && $policy[2] && !in_array(HOUSE_TYPE_COMMONS, $member_houses)) {
109
+                                    continue;
110
+                }
110 111
 
111 112
                 $dream_info = $this->displayDreamComparison($policy[0], $policy[1]);
112 113
 
@@ -185,8 +186,9 @@  discard block
 block discarded – undo
185 186
                 $dmpscore = -1;
186 187
             } else {
187 188
                 $dmpscore = floatval($extra_info["public_whip_dreammp${dreamid}_distance"]);
188
-                if ($inverse)
189
-                    $dmpscore = 1.0 - $dmpscore;
189
+                if ($inverse) {
190
+                                    $dmpscore = 1.0 - $dmpscore;
191
+                }
190 192
                 $consistency = score_to_strongly($dmpscore);
191 193
             }
192 194
             $has_strong = 0;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $this->summaries = isset($options['summaries']) ? $options['summaries'] : array();
64 64
         $this->divisions = new \MySociety\TheyWorkForYou\Divisions($member);
65 65
 
66
-        $limit = isset($options['limit']) ? $options['limit'] : NULL;
66
+        $limit = isset($options['limit']) ? $options['limit'] : null;
67 67
 
68 68
         // Do the actual getting of positions
69 69
         $this->getMemberPolicyPositions($limit);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @param int $limit The number of results to limit the output to.
78 78
      */
79 79
 
80
-    private function getMemberPolicyPositions ($limit = NULL) {
80
+    private function getMemberPolicyPositions ($limit = null) {
81 81
 
82 82
         // Make sure member info has actually been set.
83 83
         if (count($this->member->extra_info) === 0) {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         $member_houses = $this->member->houses();
90 90
 
91 91
         // Determine the policy limit.
92
-        if ($limit !== NULL AND is_int($limit))
92
+        if ($limit !== null and is_int($limit))
93 93
         {
94 94
             $policy_limit = $limit;
95 95
         } else {
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
         $current_member = $this->member->current_member();
209 209
 
210 210
         if (count($this->policies) > 0) {
211
-            if (in_array(HOUSE_TYPE_COMMONS, $member_houses) AND
211
+            if (in_array(HOUSE_TYPE_COMMONS, $member_houses) and
212 212
                 $entered_house[HOUSE_TYPE_COMMONS]['date'] > '2001-06-07'
213 213
             ) {
214 214
                 $since = '';
215
-            } elseif (!in_array(HOUSE_TYPE_COMMONS, $member_houses) AND
216
-                in_array(HOUSE_TYPE_LORDS, $member_houses) AND
215
+            } elseif (!in_array(HOUSE_TYPE_COMMONS, $member_houses) and
216
+                in_array(HOUSE_TYPE_LORDS, $member_houses) and
217 217
                 $entered_house[HOUSE_TYPE_LORDS]['date'] > '2001-06-07'
218 218
             ) {
219 219
                 $since = '';
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
                 $since = ' since 2001';
224 224
             }
225 225
             # If not current MP/Lord, but current MLA/MSP, need to say voting record is when MP
226
-            if (!$current_member[HOUSE_TYPE_COMMONS] AND
227
-                !$current_member[HOUSE_TYPE_LORDS] AND
228
-                ( $current_member[HOUSE_TYPE_SCOTLAND] OR $current_member[HOUSE_TYPE_NI] )
226
+            if (!$current_member[HOUSE_TYPE_COMMONS] and
227
+                !$current_member[HOUSE_TYPE_LORDS] and
228
+                ( $current_member[HOUSE_TYPE_SCOTLAND] or $current_member[HOUSE_TYPE_NI] )
229 229
             ) {
230 230
                 $since .= ' whilst an MP';
231 231
             }
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
                 '" title="At The Guardian">well-known issues</a> <small>(from the Guardian)</small>';
247 247
         }
248 248
         if (
249
-            ( isset($extra_info['public_whip_division_attendance']) AND
249
+            ( isset($extra_info['public_whip_division_attendance']) and
250 250
             $extra_info['public_whip_division_attendance'] != 'n/a' )
251
-            OR
252
-            ( isset($extra_info['Lpublic_whip_division_attendance']) AND
251
+            or
252
+            ( isset($extra_info['Lpublic_whip_division_attendance']) and
253 253
             $extra_info['Lpublic_whip_division_attendance'] != 'n/a' )
254 254
         ) {
255 255
             $record[] = '<a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/' .
Please login to merge, or discard this patch.
www/includes/easyparliament/member.php 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -489,6 +489,10 @@  discard block
 block discarded – undo
489 489
     public function house_text($house) {
490 490
         return $this->houses_pretty[$house];
491 491
     }
492
+
493
+    /**
494
+     * @return string
495
+     */
492 496
     public function constituency() { return $this->constituency; }
493 497
     public function party() { return $this->party; }
494 498
     public function party_text($party = null) {
@@ -607,6 +611,9 @@  discard block
 block discarded – undo
607 611
         }
608 612
     }
609 613
 
614
+    /**
615
+     * @param string $direction
616
+     */
610 617
     private function _previous_future_mps_query($direction) {
611 618
         $entered_house = $this->entered_house(HOUSE_TYPE_COMMONS);
612 619
         if (is_null($entered_house)) return '';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
         $this->extra_info = array();
363 363
 
364 364
         $q = $this->db->query('SELECT * FROM moffice WHERE person=:person_id ORDER BY from_date DESC, moffice_id',
365
-                              array(':person_id' => $this->person_id));
365
+                                array(':person_id' => $this->person_id));
366 366
         for ($row=0; $row<$q->rows(); $row++) {
367 367
             $this->extra_info['office'][] = $q->row($row);
368 368
         }
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
         $q = $this->db->query('select bill_id,session,title,sum(attending) as a,sum(chairman) as c
451 451
             from pbc_members, bills
452 452
             where bill_id = bills.id and person_id = ' . $this->person_id()
453
-             . ' group by bill_id order by session desc');
453
+                . ' group by bill_id order by session desc');
454 454
         $this->extra_info['pbc'] = array();
455 455
         for ($i=0; $i<$q->rows(); $i++) {
456 456
             $bill_id = $q->field($i, 'bill_id');
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 
113 113
         $this->house_disp = 0;
114 114
         $last_party = null;
115
-        for ($row=0; $row<$q->rows(); $row++) {
115
+        for ($row = 0; $row < $q->rows(); $row++) {
116 116
             $house          = $q->field($row, 'house');
117 117
             if (!in_array($house, $this->houses)) $this->houses[] = $house;
118 118
             $const          = $q->field($row, 'constituency');
119
-            $party		= $q->field($row, 'party');
120
-            $entered_house	= $q->field($row, 'entered_house');
121
-            $left_house	= $q->field($row, 'left_house');
122
-            $entered_reason	= $q->field($row, 'entered_reason');
123
-            $left_reason	= $q->field($row, 'left_reason');
119
+            $party = $q->field($row, 'party');
120
+            $entered_house = $q->field($row, 'entered_house');
121
+            $left_house = $q->field($row, 'left_house');
122
+            $entered_reason = $q->field($row, 'entered_reason');
123
+            $left_reason = $q->field($row, 'left_reason');
124 124
 
125 125
             if (!isset($this->entered_house[$house]) || $entered_house < $this->entered_house[$house]['date']) {
126 126
                 $this->entered_house[$house] = array(
@@ -140,22 +140,22 @@  discard block
 block discarded – undo
140 140
                 );
141 141
             }
142 142
 
143
-            if ( $house==HOUSE_TYPE_ROYAL 					# The Monarch
144
-                || (!$this->house_disp && $house==HOUSE_TYPE_SCOTLAND)	# MSPs and
145
-                || (!$this->house_disp && $house==HOUSE_TYPE_NI)	# MLAs have lowest priority
146
-                || ($this->house_disp!=HOUSE_TYPE_LORDS && $house==HOUSE_TYPE_LORDS)	# Lords have highest priority
147
-                || (!$this->house_disp && $house==HOUSE_TYPE_COMMONS) # MPs
143
+            if ($house == HOUSE_TYPE_ROYAL 					# The Monarch
144
+                || (!$this->house_disp && $house == HOUSE_TYPE_SCOTLAND)	# MSPs and
145
+                || (!$this->house_disp && $house == HOUSE_TYPE_NI)	# MLAs have lowest priority
146
+                || ($this->house_disp != HOUSE_TYPE_LORDS && $house == HOUSE_TYPE_LORDS)	# Lords have highest priority
147
+                || (!$this->house_disp && $house == HOUSE_TYPE_COMMONS) # MPs
148 148
             ) {
149 149
                 $this->house_disp = $house;
150 150
                 $this->constituency = $const;
151 151
                 $this->party = $party;
152 152
 
153
-                $this->member_id	= $q->field($row, 'member_id');
154
-                $this->title		= $q->field($row, 'title');
153
+                $this->member_id = $q->field($row, 'member_id');
154
+                $this->title = $q->field($row, 'title');
155 155
                 $this->given_name = $q->field($row, 'given_name');
156 156
                 $this->family_name = $q->field($row, 'family_name');
157 157
                 $this->lordofname = $q->field($row, 'lordofname');
158
-                $this->person_id	= $q->field($row, 'person_id');
158
+                $this->person_id = $q->field($row, 'person_id');
159 159
             }
160 160
 
161 161
             if (($last_party && $party && $party != $last_party) || $left_reason == 'changed_party') {
@@ -195,17 +195,17 @@  discard block
 block discarded – undo
195 195
         if ($q->rows > 0) {
196 196
             return $q->field(0, 'person_id');
197 197
         } else {
198
-            throw new MySociety\TheyWorkForYou\MemberException('Sorry, there is no member with a member ID of "' . _htmlentities($member_id) . '".');
198
+            throw new MySociety\TheyWorkForYou\MemberException('Sorry, there is no member with a member ID of "'._htmlentities($member_id).'".');
199 199
         }
200 200
     }
201 201
 
202
-    public function postcode_to_person_id($postcode, $house=null) {
203
-        twfy_debug ('MP', "postcode_to_person_id converting postcode to person");
202
+    public function postcode_to_person_id($postcode, $house = null) {
203
+        twfy_debug('MP', "postcode_to_person_id converting postcode to person");
204 204
         $constituency = strtolower(MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituency($postcode));
205 205
         return $this->constituency_to_person_id($constituency, $house);
206 206
     }
207 207
 
208
-    public function constituency_to_person_id($constituency, $house=null) {
208
+    public function constituency_to_person_id($constituency, $house = null) {
209 209
         if ($constituency == '') {
210 210
             throw new MySociety\TheyWorkForYou\MemberException('Sorry, no constituency was found.');
211 211
         }
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
         if ($q->rows > 0) {
241 241
             return $q->field(0, 'person_id');
242 242
         } else {
243
-            throw new MySociety\TheyWorkForYou\MemberException('Sorry, there is no current member for the "' . _htmlentities(ucwords($constituency)) . '" constituency.');
243
+            throw new MySociety\TheyWorkForYou\MemberException('Sorry, there is no current member for the "'._htmlentities(ucwords($constituency)).'" constituency.');
244 244
         }
245 245
     }
246 246
 
247
-    public function name_to_person_id($name, $const='') {
247
+    public function name_to_person_id($name, $const = '') {
248 248
         global $this_page;
249 249
         if ($name == '') {
250 250
             throw new MySociety\TheyWorkForYou\MemberException('Sorry, no name was found.');
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
             $params[':given_name'] = $m[1];
276 276
             $params[':middle_name'] = $m[2];
277 277
             $params[':family_name'] = $m[3];
278
-            $params[':first_and_middle_names'] = $m[1] . ' ' . $m[2];
279
-            $params[':middle_and_last_names'] = $m[2] . ' ' . $m[3];
278
+            $params[':first_and_middle_names'] = $m[1].' '.$m[2];
279
+            $params[':middle_and_last_names'] = $m[2].' '.$m[3];
280 280
             # Note this works only because MySQL ignores trailing whitespace
281 281
             $q .= "AND (
282 282
                 (given_name=:first_and_middle_names AND family_name=:family_name)
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 
295 295
         # More than one person ID matching the given name
296 296
         $person_ids = array();
297
-        for ($i=0; $i<$q->rows; ++$i) {
297
+        for ($i = 0; $i < $q->rows; ++$i) {
298 298
             $pid = $q->field($i, 'person_id');
299 299
             $person_ids[$pid] = 1;
300 300
         }
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
         $q = $this->db->query($q, $params);
325 325
         if ($q->rows > 1) {
326 326
             $person_ids = array();
327
-            for ($i=0; $i<$q->rows(); ++$i) {
327
+            for ($i = 0; $i < $q->rows(); ++$i) {
328 328
                 $person_ids[$q->field($i, 'person_id')] = $q->field($i, 'constituency');
329 329
             }
330 330
             throw new MySociety\TheyWorkForYou\MemberMultipleException($person_ids);
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
         global $THEUSER;
343 343
         if (is_object($THEUSER) && $THEUSER->postcode_is_set() && $this->current_member(1)) {
344 344
             $pc = $THEUSER->postcode();
345
-            twfy_debug ('MP', "set_users_mp converting postcode to person");
345
+            twfy_debug('MP', "set_users_mp converting postcode to person");
346 346
             $constituency = strtolower(MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituency($pc));
347 347
             if ($constituency == strtolower($this->constituency())) {
348 348
                 $this->the_users_mp = true;
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
     # DISPLAY is whether it's to be displayed on MP page.
355 355
     public function load_extra_info($display = false) {
356 356
         $memcache = new MySociety\TheyWorkForYou\Memcache;
357
-        $memcache_key = 'extra_info:' . $this->person_id . ($display ? '' : ':plain');
357
+        $memcache_key = 'extra_info:'.$this->person_id.($display ? '' : ':plain');
358 358
         $this->extra_info = $memcache->get($memcache_key);
359 359
         if (!DEVSITE && $this->extra_info) {
360 360
             return;
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 
364 364
         $q = $this->db->query('SELECT * FROM moffice WHERE person=:person_id ORDER BY from_date DESC, moffice_id',
365 365
                               array(':person_id' => $this->person_id));
366
-        for ($row=0; $row<$q->rows(); $row++) {
366
+        for ($row = 0; $row < $q->rows(); $row++) {
367 367
             $this->extra_info['office'][] = $q->row($row);
368 368
         }
369 369
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
             $prefix = ($this->house(HOUSE_TYPE_LORDS) ? 'L' : '');
421 421
             $this->extra_info[$prefix.'public_whip_division_attendance_rank'] = $this->extra_info['public_whip_attendrank'];
422 422
             $this->extra_info[$prefix.'public_whip_division_attendance_rank_outof'] = $this->extra_info['public_whip_attendrank_outof'];
423
-            $this->extra_info[$prefix.'public_whip_division_attendance_quintile'] = floor($this->extra_info['public_whip_attendrank'] / ($this->extra_info['public_whip_attendrank_outof']+1) * 5);
423
+            $this->extra_info[$prefix.'public_whip_division_attendance_quintile'] = floor($this->extra_info['public_whip_attendrank'] / ($this->extra_info['public_whip_attendrank_outof'] + 1) * 5);
424 424
         }
425 425
         if ($this->house(HOUSE_TYPE_LORDS) && isset($this->extra_info['public_whip_division_attendance'])) {
426 426
             $this->extra_info['Lpublic_whip_division_attendance'] = $this->extra_info['public_whip_division_attendance'];
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
         }
429 429
 
430 430
         if ($display && array_key_exists('register_member_interests_html', $this->extra_info) && ($this->extra_info['register_member_interests_html'] != '')) {
431
-            $args = array (
431
+            $args = array(
432 432
                 "sort" => "regexp_replace"
433 433
             );
434 434
             $GLOSSARY = new GLOSSARY($args);
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
             $this->extra_info['reading_ease'] = round($this->extra_info['reading_ease'], 2);
444 444
             $this->extra_info['reading_year'] = round($this->extra_info['reading_year'], 0);
445 445
             $this->extra_info['reading_age'] = $this->extra_info['reading_year'] + 4;
446
-            $this->extra_info['reading_age'] .= '&ndash;' . ($this->extra_info['reading_year'] + 5);
446
+            $this->extra_info['reading_age'] .= '&ndash;'.($this->extra_info['reading_year'] + 5);
447 447
         }
448 448
 
449 449
         # Public Bill Committees
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
             where bill_id = bills.id and person_id = ' . $this->person_id()
453 453
              . ' group by bill_id order by session desc');
454 454
         $this->extra_info['pbc'] = array();
455
-        for ($i=0; $i<$q->rows(); $i++) {
455
+        for ($i = 0; $i < $q->rows(); $i++) {
456 456
             $bill_id = $q->field($i, 'bill_id');
457 457
             $c = $this->db->query('select count(*) as c from hansard where major=6 and minor='.$bill_id.' and htype=10');
458 458
             $c = $c->field(0, 'c');
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
             $chairman = $q->field($i, 'c');
462 462
             $this->extra_info['pbc'][$bill_id] = array(
463 463
                 'title' => $title, 'session' => $q->field($i, 'session'),
464
-                'attending'=>$attending, 'chairman'=>($chairman>0), 'outof' => $c
464
+                'attending'=>$attending, 'chairman'=>($chairman > 0), 'outof' => $c
465 465
             );
466 466
         }
467 467
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     public function family_name() { return $this->family_name; }
477 477
     public function full_name($no_mp_title = false) {
478 478
         $title = $this->title;
479
-        if ($no_mp_title && ($this->house_disp==HOUSE_TYPE_COMMONS || $this->house_disp==HOUSE_TYPE_NI || $this->house_disp==HOUSE_TYPE_SCOTLAND))
479
+        if ($no_mp_title && ($this->house_disp == HOUSE_TYPE_COMMONS || $this->house_disp == HOUSE_TYPE_NI || $this->house_disp == HOUSE_TYPE_SCOTLAND))
480 480
             $title = '';
481 481
         return member_full_name($this->house_disp, $title, $this->given_name, $this->family_name, $this->lordofname);
482 482
     }
@@ -509,9 +509,9 @@  discard block
 block discarded – undo
509 509
     public function entered_house_text($entered_house) {
510 510
         if (!$entered_house) return '';
511 511
         list($year, $month, $day) = explode('-', $entered_house);
512
-        if ($month==1 && $day==1 && $this->house(HOUSE_TYPE_LORDS)) {
512
+        if ($month == 1 && $day == 1 && $this->house(HOUSE_TYPE_LORDS)) {
513 513
             return $year;
514
-        } elseif ($month==0 && $day==0) {
514
+        } elseif ($month == 0 && $day == 0) {
515 515
             return $year;
516 516
         } elseif (checkdate($month, $day, $year) && $year != '9999') {
517 517
             return format_date($entered_house, LONGDATEFORMAT);
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         list($year, $month, $day) = explode('-', $left_house);
532 532
         if (checkdate($month, $day, $year) && $year != '9999') {
533 533
             return format_date($left_house, LONGDATEFORMAT);
534
-        } elseif ($month==0 && $day==0) {
534
+        } elseif ($month == 0 && $day == 0) {
535 535
             # Left house date is stored as 1942-00-00 to mean "at some point in 1941"
536 536
             return $year - 1;
537 537
         } else {
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
             if (DEVSITE) {
602 602
                 $protocol = 'http://';
603 603
             }
604
-            return $protocol . DOMAIN . $URL->generate('none') . $member_url;
604
+            return $protocol.DOMAIN.$URL->generate('none').$member_url;
605 605
         } else {
606
-            return $URL->generate('none') . $member_url;
606
+            return $URL->generate('none').$member_url;
607 607
         }
608 608
     }
609 609
 
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
             WHERE member.person_id = pn.person_id AND pn.type = "name"
621 621
                 AND pn.start_date <= member.left_house AND member.left_house <= pn.end_date
622 622
                 AND house = :house AND constituency = :cons
623
-                AND member.person_id != :pid AND entered_house ' . $direction . ' :date ORDER BY entered_house ' . $order,
623
+                AND member.person_id != :pid AND entered_house ' . $direction.' :date ORDER BY entered_house '.$order,
624 624
             array(
625 625
                 ':house' => HOUSE_TYPE_COMMONS,
626 626
                 ':cons' => $this->constituency(),
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
         $mships = array(); $last_pid = null;
631 631
         for ($r = 0; $r < $q->rows(); $r++) {
632 632
             $pid = $q->field($r, 'person_id');
633
-            $name = $q->field($r, 'given_name') . ' ' . $q->field($r, 'family_name');
633
+            $name = $q->field($r, 'given_name').' '.$q->field($r, 'family_name');
634 634
             if ($last_pid != $pid) {
635 635
                 $mships[] = array(
636
-                    'href' => WEBPATH . 'mp/?pid='.$pid,
636
+                    'href' => WEBPATH.'mp/?pid='.$pid,
637 637
                     'text' => $name
638 638
                 );
639 639
                 $last_pid = $pid;
Please login to merge, or discard this patch.
Braces   +50 added lines, -29 removed lines patch added patch discarded remove patch
@@ -114,7 +114,9 @@  discard block
 block discarded – undo
114 114
         $last_party = null;
115 115
         for ($row=0; $row<$q->rows(); $row++) {
116 116
             $house          = $q->field($row, 'house');
117
-            if (!in_array($house, $this->houses)) $this->houses[] = $house;
117
+            if (!in_array($house, $this->houses)) {
118
+                $this->houses[] = $house;
119
+            }
118 120
             $const          = $q->field($row, 'constituency');
119 121
             $party		= $q->field($row, 'party');
120 122
             $entered_house	= $q->field($row, 'entered_house');
@@ -215,7 +217,9 @@  discard block
 block discarded – undo
215 217
         }
216 218
 
217 219
         $normalised = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency);
218
-        if ($normalised) $constituency = $normalised;
220
+        if ($normalised) {
221
+            $constituency = $normalised;
222
+        }
219 223
 
220 224
         $params = array();
221 225
 
@@ -254,10 +258,12 @@  discard block
 block discarded – undo
254 258
         $q = "SELECT person_id FROM person_names WHERE type = 'name' ";
255 259
         if ($this_page == 'peer') {
256 260
             $success = preg_match('#^(.*?) (.*?) of (.*?)$#', $name, $m);
257
-            if (!$success)
258
-                $success = preg_match('#^(.*?)() of (.*?)$#', $name, $m);
259
-            if (!$success)
260
-                $success = preg_match('#^(.*?) (.*?)()$#', $name, $m);
261
+            if (!$success) {
262
+                            $success = preg_match('#^(.*?)() of (.*?)$#', $name, $m);
263
+            }
264
+            if (!$success) {
265
+                            $success = preg_match('#^(.*?) (.*?)()$#', $name, $m);
266
+            }
261 267
             if (!$success) {
262 268
                 throw new MySociety\TheyWorkForYou\MemberException('Sorry, that name was not recognised.');
263 269
             }
@@ -267,8 +273,9 @@  discard block
 block discarded – undo
267 273
             $q .= "AND title = :title AND family_name = :family_name AND lordofname = :lordofname";
268 274
         } elseif ($this_page == 'msp' || $this_page == 'mla' || strstr($this_page, 'mp')) {
269 275
             $success = preg_match('#^(.*?) (.*?) (.*?)$#', $name, $m);
270
-            if (!$success)
271
-                $success = preg_match('#^(.*?)() (.*)$#', $name, $m);
276
+            if (!$success) {
277
+                            $success = preg_match('#^(.*?)() (.*)$#', $name, $m);
278
+            }
272 279
             if (!$success) {
273 280
                 throw new MySociety\TheyWorkForYou\MemberException('Sorry, that name was not recognised.');
274 281
             }
@@ -403,16 +410,17 @@  discard block
 block discarded – undo
403 410
         if (array_key_exists('public_whip_rebellions', $this->extra_info)) {
404 411
             $rebellions = $this->extra_info['public_whip_rebellions'];
405 412
             $rebel_desc = "<unknown>";
406
-            if ($rebellions == 0)
407
-                $rebel_desc = "never";
408
-            elseif ($rebellions <= 1)
409
-                $rebel_desc = "hardly ever";
410
-            elseif ($rebellions <= 3)
411
-                $rebel_desc = "occasionally";
412
-            elseif ($rebellions <= 5)
413
-                $rebel_desc = "sometimes";
414
-            elseif ($rebellions > 5)
415
-                $rebel_desc = "quite often";
413
+            if ($rebellions == 0) {
414
+                            $rebel_desc = "never";
415
+            } elseif ($rebellions <= 1) {
416
+                            $rebel_desc = "hardly ever";
417
+            } elseif ($rebellions <= 3) {
418
+                            $rebel_desc = "occasionally";
419
+            } elseif ($rebellions <= 5) {
420
+                            $rebel_desc = "sometimes";
421
+            } elseif ($rebellions > 5) {
422
+                            $rebel_desc = "quite often";
423
+            }
416 424
             $this->extra_info['public_whip_rebel_description'] = $rebel_desc;
417 425
         }
418 426
 
@@ -476,8 +484,9 @@  discard block
 block discarded – undo
476 484
     public function family_name() { return $this->family_name; }
477 485
     public function full_name($no_mp_title = false) {
478 486
         $title = $this->title;
479
-        if ($no_mp_title && ($this->house_disp==HOUSE_TYPE_COMMONS || $this->house_disp==HOUSE_TYPE_NI || $this->house_disp==HOUSE_TYPE_SCOTLAND))
480
-            $title = '';
487
+        if ($no_mp_title && ($this->house_disp==HOUSE_TYPE_COMMONS || $this->house_disp==HOUSE_TYPE_NI || $this->house_disp==HOUSE_TYPE_SCOTLAND)) {
488
+                    $title = '';
489
+        }
481 490
         return member_full_name($this->house_disp, $title, $this->given_name, $this->family_name, $this->lordofname);
482 491
     }
483 492
     public function houses() {
@@ -493,8 +502,9 @@  discard block
 block discarded – undo
493 502
     public function party() { return $this->party; }
494 503
     public function party_text($party = null) {
495 504
         global $parties;
496
-        if (!$party)
497
-            $party = $this->party;
505
+        if (!$party) {
506
+                    $party = $this->party;
507
+        }
498 508
         if (isset($parties[$party])) {
499 509
             return $parties[$party];
500 510
         } else {
@@ -503,11 +513,15 @@  discard block
 block discarded – undo
503 513
     }
504 514
 
505 515
     public function entered_house($house = 0) {
506
-        if ($house) return array_key_exists($house, $this->entered_house) ? $this->entered_house[$house] : null;
516
+        if ($house) {
517
+            return array_key_exists($house, $this->entered_house) ? $this->entered_house[$house] : null;
518
+        }
507 519
         return $this->entered_house;
508 520
     }
509 521
     public function entered_house_text($entered_house) {
510
-        if (!$entered_house) return '';
522
+        if (!$entered_house) {
523
+            return '';
524
+        }
511 525
         list($year, $month, $day) = explode('-', $entered_house);
512 526
         if ($month==1 && $day==1 && $this->house(HOUSE_TYPE_LORDS)) {
513 527
             return $year;
@@ -521,13 +535,16 @@  discard block
 block discarded – undo
521 535
     }
522 536
 
523 537
     public function left_house($house = null) {
524
-        if (!is_null($house))
525
-            return array_key_exists($house, $this->left_house) ? $this->left_house[$house] : null;
538
+        if (!is_null($house)) {
539
+                    return array_key_exists($house, $this->left_house) ? $this->left_house[$house] : null;
540
+        }
526 541
         return $this->left_house;
527 542
     }
528 543
 
529 544
     public function left_house_text($left_house) {
530
-        if (!$left_house) return '';
545
+        if (!$left_house) {
546
+            return '';
547
+        }
531 548
         list($year, $month, $day) = explode('-', $left_house);
532 549
         if (checkdate($month, $day, $year) && $year != '9999') {
533 550
             return format_date($left_house, LONGDATEFORMAT);
@@ -576,7 +593,9 @@  discard block
 block discarded – undo
576 593
             $lh = $this->left_house($h);
577 594
             $current[$h] = ($lh['date'] == '9999-12-31');
578 595
         }
579
-        if ($house) return $current[$house];
596
+        if ($house) {
597
+            return $current[$house];
598
+        }
580 599
         return $current;
581 600
     }
582 601
 
@@ -609,7 +628,9 @@  discard block
 block discarded – undo
609 628
 
610 629
     private function _previous_future_mps_query($direction) {
611 630
         $entered_house = $this->entered_house(HOUSE_TYPE_COMMONS);
612
-        if (is_null($entered_house)) return '';
631
+        if (is_null($entered_house)) {
632
+            return '';
633
+        }
613 634
         if ($direction == '>') {
614 635
             $order = '';
615 636
         } else {
Please login to merge, or discard this patch.
classes/FacebookLogin.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -23,6 +23,9 @@
 block discarded – undo
23 23
         return $this->fb;
24 24
     }
25 25
 
26
+    /**
27
+     * @return string
28
+     */
26 29
     public function getLoginURL() {
27 30
         $helper = $this->getFacebookObject()->getRedirectLoginHelper();
28 31
         $permissions = ['email'];
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function getFacebookObject() {
15 15
         if (!isset($this->fb)) {
16
-          $this->fb = new \Facebook\Facebook([
16
+            $this->fb = new \Facebook\Facebook([
17 17
             'app_id' => FACEBOOK_APP_ID,
18 18
             'app_secret' => FACEBOOK_APP_SECRET,
19 19
             'default_graph_version' => 'v2.2',
20
-          ]);
20
+            ]);
21 21
         }
22 22
 
23 23
         return $this->fb;
@@ -30,46 +30,46 @@  discard block
 block discarded – undo
30 30
     }
31 31
 
32 32
     public function handleFacebookRedirect() {
33
-      $helper = $this->getFacebookObject()->getRedirectLoginHelper();
33
+        $helper = $this->getFacebookObject()->getRedirectLoginHelper();
34 34
 
35
-      $data = array('login_url' => $this->getLoginURL());
35
+        $data = array('login_url' => $this->getLoginURL());
36 36
 
37
-      try {
37
+        try {
38 38
         $accessToken = $helper->getAccessToken();
39
-      } catch(\Facebook\Exceptions\FacebookResponseException $e) {
39
+        } catch(\Facebook\Exceptions\FacebookResponseException $e) {
40 40
         $data['error'] = 'Graph returned an error: ' . $e->getMessage();
41 41
         return $data;
42
-      } catch(\Facebook\Exceptions\FacebookSDKException $e) {
42
+        } catch(\Facebook\Exceptions\FacebookSDKException $e) {
43 43
         $data['error'] = 'Facebook SDK returned an error: ' . $e->getMessage();
44 44
         return $data;
45
-      }
45
+        }
46 46
 
47
-      $token = $this->checkAccessToken($accessToken);
47
+        $token = $this->checkAccessToken($accessToken);
48 48
 
49
-      if ($token) {
50
-          return array('token' => $token);
51
-      } else {
52
-          $data['error'] = 'Problem getting Facebook token';
53
-          return $data;
54
-      }
49
+        if ($token) {
50
+            return array('token' => $token);
51
+        } else {
52
+            $data['error'] = 'Problem getting Facebook token';
53
+            return $data;
54
+        }
55 55
     }
56 56
 
57 57
 
58 58
     private function checkAccessToken($accessToken) {
59
-      if (!isset($accessToken)) {
60
-          return False;
61
-      }
59
+        if (!isset($accessToken)) {
60
+            return False;
61
+        }
62 62
 
63
-      if (! $accessToken->isLongLived()) {
63
+        if (! $accessToken->isLongLived()) {
64 64
         $oAuth2Client = $this->getFacebookObject()->getOAuth2Client();
65 65
         try {
66
-          $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
66
+            $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
67 67
         } catch (\Facebook\Exceptions\FacebookSDKException $e) {
68
-          return False;
68
+            return False;
69
+        }
69 70
         }
70
-      }
71 71
 
72
-      return $accessToken;
72
+        return $accessToken;
73 73
     }
74 74
 
75 75
     public function loginUser($accessToken) {
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             'optin' => $THEUSER->optin(),
159 159
             'emailpublic' => False,
160 160
             'password' => '',
161
-         );
161
+            );
162 162
 
163 163
         $THEUSER->update_self_no_confirm($details);
164 164
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
     private function checkAccessToken($accessToken) {
59 59
       if (!isset($accessToken)) {
60
-          return False;
60
+          return false;
61 61
       }
62 62
 
63 63
       if (! $accessToken->isLongLived()) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         try {
66 66
           $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
67 67
         } catch (\Facebook\Exceptions\FacebookSDKException $e) {
68
-          return False;
68
+          return false;
69 69
         }
70 70
       }
71 71
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $expires = intval($accessToken->getExpiresAt()->format('U'));
87 87
         twfy_debug("THEUSER", "Facebook access token expires at " . $expires);
88 88
 
89
-        $success = False;
89
+        $success = false;
90 90
         if ($user_id) {
91 91
             twfy_debug("THEUSER", "Faceook user exists in the database: " . $user_id);
92 92
             $success = $THEUSER->init($user_id);
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             return $logged_in;
113 113
         }
114 114
 
115
-        return False;
115
+        return false;
116 116
     }
117 117
 
118 118
     public function createUser($accessToken, $user) {
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
             'url' => '',
129 129
             'status' => '',
130 130
             'password' => '',
131
-            'optin' => False,
132
-            'emailpublic' => False,
133
-            'mp_alert' => False,
131
+            'optin' => false,
132
+            'emailpublic' => false,
133
+            'mp_alert' => false,
134 134
             'facebook_id' => $user['id']
135 135
         );
136 136
         $added = $THEUSER->add($details, false);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             'postcode' => $THEUSER->postcode(),
157 157
             'url' => $THEUSER->url(),
158 158
             'optin' => $THEUSER->optin(),
159
-            'emailpublic' => False,
159
+            'emailpublic' => false,
160 160
             'password' => '',
161 161
          );
162 162
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     public function getLoginURL() {
27 27
         $helper = $this->getFacebookObject()->getRedirectLoginHelper();
28 28
         $permissions = ['email'];
29
-        return $helper->getLoginUrl('https://' . DOMAIN . '/user/login/fb.php', $permissions);
29
+        return $helper->getLoginUrl('https://'.DOMAIN.'/user/login/fb.php', $permissions);
30 30
     }
31 31
 
32 32
     public function handleFacebookRedirect() {
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 
37 37
       try {
38 38
         $accessToken = $helper->getAccessToken();
39
-      } catch(\Facebook\Exceptions\FacebookResponseException $e) {
40
-        $data['error'] = 'Graph returned an error: ' . $e->getMessage();
39
+      } catch (\Facebook\Exceptions\FacebookResponseException $e) {
40
+        $data['error'] = 'Graph returned an error: '.$e->getMessage();
41 41
         return $data;
42
-      } catch(\Facebook\Exceptions\FacebookSDKException $e) {
43
-        $data['error'] = 'Facebook SDK returned an error: ' . $e->getMessage();
42
+      } catch (\Facebook\Exceptions\FacebookSDKException $e) {
43
+        $data['error'] = 'Facebook SDK returned an error: '.$e->getMessage();
44 44
         return $data;
45 45
       }
46 46
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
           return False;
61 61
       }
62 62
 
63
-      if (! $accessToken->isLongLived()) {
63
+      if (!$accessToken->isLongLived()) {
64 64
         $oAuth2Client = $this->getFacebookObject()->getOAuth2Client();
65 65
         try {
66 66
           $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
@@ -84,24 +84,24 @@  discard block
 block discarded – undo
84 84
         }
85 85
 
86 86
         $expires = intval($accessToken->getExpiresAt()->format('U'));
87
-        twfy_debug("THEUSER", "Facebook access token expires at " . $expires);
87
+        twfy_debug("THEUSER", "Facebook access token expires at ".$expires);
88 88
 
89 89
         $success = False;
90 90
         if ($user_id) {
91
-            twfy_debug("THEUSER", "Faceook user exists in the database: " . $user_id);
91
+            twfy_debug("THEUSER", "Faceook user exists in the database: ".$user_id);
92 92
             $success = $THEUSER->init($user_id);
93
-            twfy_debug("THEUSER", "user inited: " . $success);
93
+            twfy_debug("THEUSER", "user inited: ".$success);
94 94
             if ($THEUSER->facebook_id() == "") {
95 95
                 $THEUSER->add_facebook_id($user['id']);
96 96
             }
97
-            twfy_debug("THEUSER", "inited user has id : " . $THEUSER->user_id());
97
+            twfy_debug("THEUSER", "inited user has id : ".$THEUSER->user_id());
98 98
         } else {
99 99
             twfy_debug("THEUSER", "Faceook user does not exist in the database");
100 100
             $success = $this->createUser($accessToken, $user);
101 101
         }
102 102
 
103 103
         if ($success) {
104
-            twfy_debug("THEUSER", "logging in user: " . $THEUSER->user_id());
104
+            twfy_debug("THEUSER", "logging in user: ".$THEUSER->user_id());
105 105
             $logged_in = $THEUSER->facebook_login("/user/", $expires, $accessToken);
106 106
 
107 107
             if ($THEUSER->email() != $user['email']) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         );
136 136
         $added = $THEUSER->add($details, false);
137 137
         if ($added) {
138
-            twfy_debug("THEUSER", "Added new user from facebook details " . $THEUSER->user_id());
138
+            twfy_debug("THEUSER", "Added new user from facebook details ".$THEUSER->user_id());
139 139
             return $THEUSER->confirm_without_token();
140 140
         }
141 141
 
Please login to merge, or discard this patch.
classes/Model/Featured.php 3 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -52,6 +52,11 @@  discard block
 block discarded – undo
52 52
         $this->_set('featured_related', $related);
53 53
     }
54 54
 
55
+    /**
56
+     * @param string $key
57
+     *
58
+     * @return string
59
+     */
55 60
     private function _get($key) {
56 61
         $text = NULL;
57 62
 
@@ -72,6 +77,9 @@  discard block
 block discarded – undo
72 77
         return $text;
73 78
     }
74 79
 
80
+    /**
81
+     * @param string $key
82
+     */
75 83
     private function _set($key, $value) {
76 84
         if ( trim($value) == '' ) {
77 85
             $value = NULL;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
         if ($q->rows) {
66 66
             $text = $q->field(0, 'value');
67
-            if ( trim($text) == '' ) {
67
+            if (trim($text) == '') {
68 68
                 $text = NULL;
69 69
             }
70 70
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     }
74 74
 
75 75
     private function _set($key, $value) {
76
-        if ( trim($value) == '' ) {
76
+        if (trim($value) == '') {
77 77
             $value = NULL;
78 78
         }
79 79
         $check_q = $this->db->query(
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                 ':key' => $key
83 83
             )
84 84
         );
85
-        if ( $check_q->rows ) {
85
+        if ($check_q->rows) {
86 86
             $set_q = $this->db->query("UPDATE editorial set value = :value WHERE item = :key",
87 87
                 array(
88 88
                     ':key' => $key,
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             );
99 99
         }
100 100
 
101
-        if ( $set_q->success() ) {
101
+        if ($set_q->success()) {
102 102
             return true;
103 103
         }
104 104
         return false;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     }
54 54
 
55 55
     private function _get($key) {
56
-        $text = NULL;
56
+        $text = null;
57 57
 
58 58
         $q = $this->db->query(
59 59
             "SELECT value FROM editorial WHERE item = :key",
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         if ($q->rows) {
66 66
             $text = $q->field(0, 'value');
67 67
             if ( trim($text) == '' ) {
68
-                $text = NULL;
68
+                $text = null;
69 69
             }
70 70
         }
71 71
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
     private function _set($key, $value) {
76 76
         if ( trim($value) == '' ) {
77
-            $value = NULL;
77
+            $value = null;
78 78
         }
79 79
         $check_q = $this->db->query(
80 80
             "SELECT value FROM editorial WHERE item = :key",
Please login to merge, or discard this patch.
www/includes/test/utility_test.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@
 block discarded – undo
12 12
 
13 13
 class UtilityTest extends UnitTestCase{
14 14
 
15
-  public function testVerpEnvelopeSenderCanCreateStandardSender() {
15
+    public function testVerpEnvelopeSenderCanCreateStandardSender() {
16 16
     $sender = twfy_verp_envelope_sender('[email protected]');
17 17
     $expected_sender = 'twfy+aperson=a.nother.dom@' + EMAILDOMAIN;
18 18
     $this->assertEqual($sender, $expected_sender, 'verp_envelope_sender can create a sender for a standard address');
19
-  }
19
+    }
20 20
 
21 21
 }
22 22
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,18 +3,18 @@
 block discarded – undo
3 3
  * SimpleTest tests for the functions in utility.php
4 4
  * $Id: utility_test.php,v 1.3 2009-06-25 12:23:58 louise Exp $
5 5
  */
6
-error_reporting (E_ALL);
6
+error_reporting(E_ALL);
7 7
 ini_set("display_errors", 1);
8
-include_once dirname(__FILE__) . '/../../../conf/general';
8
+include_once dirname(__FILE__).'/../../../conf/general';
9 9
 include_once '../utility.php';
10 10
 include_once 'simpletest/unit_tester.php';
11 11
 include_once 'simpletest/reporter.php';
12 12
 
13
-class UtilityTest extends UnitTestCase{
13
+class UtilityTest extends UnitTestCase {
14 14
 
15 15
   public function testVerpEnvelopeSenderCanCreateStandardSender() {
16 16
     $sender = twfy_verp_envelope_sender('[email protected]');
17
-    $expected_sender = 'twfy+aperson=a.nother.dom@' + EMAILDOMAIN;
17
+    $expected_sender = 'twfy+aperson=a.nother.dom@' +EMAILDOMAIN;
18 18
     $this->assertEqual($sender, $expected_sender, 'verp_envelope_sender can create a sender for a standard address');
19 19
   }
20 20
 
Please login to merge, or discard this patch.
www/includes/url.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
         // These stores an associative array of key/value pairs that
66 66
         // we'll want passed on to other pages.
67
-        $this->session_vars = array ();
67
+        $this->session_vars = array();
68 68
 
69 69
         // Prevent things using $DATA running if it hasn't been set, ie in testing
70 70
         if (isset($DATA)) {
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
     public function reset() {
104 104
         // Call this to remove all the session_vars.
105
-        $this->session_vars = array ();
105
+        $this->session_vars = array();
106 106
     }
107 107
 
108 108
     public function insert($arr) {
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         }
137 137
     }
138 138
 
139
-    public function generate($encode = "html", $overrideVars=array()) {
139
+    public function generate($encode = "html", $overrideVars = array()) {
140 140
         // Returns a URL with the appropriate session_vars.
141 141
         // If $encode is "html", the URL will be suitable to be put in HTML.
142 142
         // If $encode is "none", the URL will be as is.
@@ -149,26 +149,26 @@  discard block
 block discarded – undo
149 149
         // them.
150 150
         global $DATA;
151 151
 
152
-        $url_args = array ();
152
+        $url_args = array();
153 153
 
154 154
         foreach (array_merge($this->session_vars, $overrideVars) as $key => $var) {
155 155
             if (is_array($var)) {
156 156
                 foreach ($var as $v) {
157
-                    $url_args[] = "$key=" . urlencode(stripslashes($v));
157
+                    $url_args[] = "$key=".urlencode(stripslashes($v));
158 158
                 }
159 159
             } elseif ($var != null)
160
-                $url_args[] = "$key=" . urlencode(stripslashes($var));
160
+                $url_args[] = "$key=".urlencode(stripslashes($var));
161 161
         }
162 162
 
163
-        $page_url = WEBPATH . $DATA->page_metadata($this->destinationpage, "url");
163
+        $page_url = WEBPATH.$DATA->page_metadata($this->destinationpage, "url");
164 164
 
165 165
         if (sizeof($url_args) == 0) {
166 166
             return $page_url;
167 167
         } else {
168 168
             if ($encode == "html") {
169
-                return $page_url . "?" . implode("&amp;", $url_args);
169
+                return $page_url."?".implode("&amp;", $url_args);
170 170
             } elseif ($encode == "none" || $encode == "url") {
171
-                return $page_url . "?" . implode("&", $url_args);
171
+                return $page_url."?".implode("&", $url_args);
172 172
             }
173 173
         }
174 174
     }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     // If you have a form that changes, say, $s, then you'll need to
181 181
     // pass "s" in in the $remove_vars array, so it isn't created as a
182 182
     // hidden variable.
183
-    public function hidden_form_varsOLD ($remove_vars=array(), $insert_vars=array()) {
183
+    public function hidden_form_varsOLD($remove_vars = array(), $insert_vars = array()) {
184 184
         // This should really be tidied up lots. That $dont_keep array for a start is NASTY!
185 185
         // You can also pass in an array of variables to remove() and insert().
186 186
 
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
         $html = "";
202 202
 
203 203
         // Put keys of any variables you never want to hang on to in here:
204
-        $dont_keep = array();	// VERY BAD!
204
+        $dont_keep = array(); // VERY BAD!
205 205
         $this->remove($dont_keep);
206 206
 
207 207
         foreach ($this->session_vars as $key => $val) {
208 208
             if (!in_array($key, $dont_keep)) {
209
-                $html .= '<input type="hidden" name="' . $key . '" value="' . $val . "\">\n";
209
+                $html .= '<input type="hidden" name="'.$key.'" value="'.$val."\">\n";
210 210
 
211 211
             }
212 212
         }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         $this->session_vars = $old_session_vars;
218 218
 
219 219
         if ($html != "") {
220
-            return $html . "\n";
220
+            return $html."\n";
221 221
         } else {
222 222
             return $html;
223 223
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -156,8 +156,9 @@
 block discarded – undo
156 156
                 foreach ($var as $v) {
157 157
                     $url_args[] = "$key=" . urlencode(stripslashes($v));
158 158
                 }
159
-            } elseif ($var != null)
160
-                $url_args[] = "$key=" . urlencode(stripslashes($var));
159
+            } elseif ($var != null) {
160
+                            $url_args[] = "$key=" . urlencode(stripslashes($var));
161
+            }
161 162
         }
162 163
 
163 164
         $page_url = WEBPATH . $DATA->page_metadata($this->destinationpage, "url");
Please login to merge, or discard this patch.