@@ -49,7 +49,9 @@ discard block |
||
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 |
||
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 |
||
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 .= ' '; |
|
216 | + for ($i=0; $i < $tabs; $i++) { |
|
217 | + $s .= ' '; |
|
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 |
||
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; |
@@ -326,7 +342,8 @@ discard block |
||
326 | 342 | |
327 | 343 | if (preg_match("/^(\d\d\d\d)-(\d\d?)-(\d\d?)$/", $date, $matches)) { |
328 | 344 | list($string, $year, $month, $day) = $matches; |
329 | - if ($year < 1902) { # gmdate fns only go back to Dec. 1901 |
|
345 | + if ($year < 1902) { |
|
346 | +# gmdate fns only go back to Dec. 1901 |
|
330 | 347 | if ($format == SHORTDATEFORMAT) { |
331 | 348 | return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year"; |
332 | 349 | } else { |
@@ -755,7 +772,9 @@ discard block |
||
755 | 772 | // easily to all the emails we send out from the site. |
756 | 773 | // eg, we might want to add a .sig to everything here... |
757 | 774 | |
758 | - if (!$from) $from = CONTACTEMAIL; |
|
775 | + if (!$from) { |
|
776 | + $from = CONTACTEMAIL; |
|
777 | + } |
|
759 | 778 | |
760 | 779 | $headers = |
761 | 780 | "From: TheyWorkForYou <$from>\r\n" . |
@@ -847,17 +866,21 @@ discard block |
||
847 | 866 | $rank = $rank + 0; |
848 | 867 | |
849 | 868 | # 11th, 12th, 13th use "th" not "st", "nd", "rd" |
850 | - if (floor(($rank % 100) / 10) == 1) |
|
851 | - return $rank . "th"; |
|
869 | + if (floor(($rank % 100) / 10) == 1) { |
|
870 | + return $rank . "th"; |
|
871 | + } |
|
852 | 872 | # 1st |
853 | - if ($rank % 10 == 1) |
|
854 | - return $rank . "st"; |
|
873 | + if ($rank % 10 == 1) { |
|
874 | + return $rank . "st"; |
|
875 | + } |
|
855 | 876 | # 2nd |
856 | - if ($rank % 10 == 2) |
|
857 | - return $rank . "nd"; |
|
877 | + if ($rank % 10 == 2) { |
|
878 | + return $rank . "nd"; |
|
879 | + } |
|
858 | 880 | # 3rd |
859 | - if ($rank % 10 == 3) |
|
860 | - return $rank . "rd"; |
|
881 | + if ($rank % 10 == 3) { |
|
882 | + return $rank . "rd"; |
|
883 | + } |
|
861 | 884 | # Everything else use th |
862 | 885 | |
863 | 886 | return $rank . "th"; |
@@ -865,8 +888,9 @@ discard block |
||
865 | 888 | |
866 | 889 | function make_plural($word, $number) |
867 | 890 | { |
868 | - if ($number == 1) |
|
869 | - return $word; |
|
891 | + if ($number == 1) { |
|
892 | + return $word; |
|
893 | + } |
|
870 | 894 | return $word . "s"; |
871 | 895 | } |
872 | 896 | |
@@ -884,8 +908,7 @@ discard block |
||
884 | 908 | function make_member_url($name, $const = '', $house = HOUSE_TYPE_COMMONS, $pid = NULL) { |
885 | 909 | |
886 | 910 | // Case for Elizabeth II |
887 | - if ($house == HOUSE_TYPE_ROYAL) |
|
888 | - { |
|
911 | + if ($house == HOUSE_TYPE_ROYAL) { |
|
889 | 912 | return 'elizabeth_the_second'; |
890 | 913 | } |
891 | 914 | |
@@ -897,8 +920,7 @@ discard block |
||
897 | 920 | $out = ''; |
898 | 921 | |
899 | 922 | // Insert the Person ID if known. |
900 | - if ($pid !== NULL) |
|
901 | - { |
|
923 | + if ($pid !== NULL) { |
|
902 | 924 | $out .= $pid . '/'; |
903 | 925 | } |
904 | 926 | |
@@ -906,8 +928,7 @@ discard block |
||
906 | 928 | $out .= urlencode(str_replace($s2, $r, str_replace($s, $r, $name))); |
907 | 929 | |
908 | 930 | // If there is a constituency, inject that too |
909 | - if ($const && $house == HOUSE_TYPE_COMMONS) |
|
910 | - { |
|
931 | + if ($const && $house == HOUSE_TYPE_COMMONS) { |
|
911 | 932 | $out .= '/' . urlencode(str_replace($s2, $r, str_replace($s, $r, strtolower($const)))); |
912 | 933 | } |
913 | 934 | |
@@ -919,10 +940,16 @@ discard block |
||
919 | 940 | switch ($house) { |
920 | 941 | case HOUSE_TYPE_LORDS: |
921 | 942 | $s = ''; |
922 | - if (!$family_name) $s = 'the '; |
|
943 | + if (!$family_name) { |
|
944 | + $s = 'the '; |
|
945 | + } |
|
923 | 946 | $s .= $title; |
924 | - if ($family_name) $s .= ' ' . $family_name; |
|
925 | - if ($lordofname) $s .= ' of ' . $lordofname; |
|
947 | + if ($family_name) { |
|
948 | + $s .= ' ' . $family_name; |
|
949 | + } |
|
950 | + if ($lordofname) { |
|
951 | + $s .= ' of ' . $lordofname; |
|
952 | + } |
|
926 | 953 | return $s; |
927 | 954 | |
928 | 955 | case HOUSE_TYPE_ROYAL: |
@@ -940,14 +967,18 @@ discard block |
||
940 | 967 | } |
941 | 968 | |
942 | 969 | function by_peer_name($a, $b) { |
943 | - if (!$a['family_name'] && !$b['family_name']) |
|
944 | - return strcmp($a['lordofname'], $b['lordofname']); |
|
945 | - if (!$a['family_name']) |
|
946 | - return strcmp($a['lordofname'], $b['family_name']); |
|
947 | - if (!$b['family_name']) |
|
948 | - return strcmp($a['family_name'], $b['lordofname']); |
|
949 | - if (strcmp($a['family_name'], $b['family_name'])) |
|
950 | - return strcmp($a['family_name'], $b['family_name']); |
|
970 | + if (!$a['family_name'] && !$b['family_name']) { |
|
971 | + return strcmp($a['lordofname'], $b['lordofname']); |
|
972 | + } |
|
973 | + if (!$a['family_name']) { |
|
974 | + return strcmp($a['lordofname'], $b['family_name']); |
|
975 | + } |
|
976 | + if (!$b['family_name']) { |
|
977 | + return strcmp($a['family_name'], $b['lordofname']); |
|
978 | + } |
|
979 | + if (strcmp($a['family_name'], $b['family_name'])) { |
|
980 | + return strcmp($a['family_name'], $b['family_name']); |
|
981 | + } |
|
951 | 982 | return strcmp($a['lordofname'], $b['lordofname']); |
952 | 983 | } |
953 | 984 | |
@@ -974,12 +1005,17 @@ discard block |
||
974 | 1005 | 'Lords in Waiting (HM Household)' => 'Government Whip', |
975 | 1006 | 'Baronesses in Waiting, HM Household' => 'Government Whip', |
976 | 1007 | ); |
977 | - if ($pos) { # Government post, or Chairman of Select Committee |
|
1008 | + if ($pos) { |
|
1009 | +# Government post, or Chairman of Select Committee |
|
978 | 1010 | $pretty = $pos; |
979 | - if ($dept && $dept != 'No Department') $pretty .= ", $dept"; |
|
980 | - if (array_key_exists($pretty, $lookup)) |
|
981 | - $pretty = $lookup[$pretty]; |
|
982 | - } else { # Member of Select Committee |
|
1011 | + if ($dept && $dept != 'No Department') { |
|
1012 | + $pretty .= ", $dept"; |
|
1013 | + } |
|
1014 | + if (array_key_exists($pretty, $lookup)) { |
|
1015 | + $pretty = $lookup[$pretty]; |
|
1016 | + } |
|
1017 | + } else { |
|
1018 | +# Member of Select Committee |
|
983 | 1019 | $pretty = "Member, $dept"; |
984 | 1020 | } |
985 | 1021 | return $pretty; |
@@ -997,13 +1033,16 @@ discard block |
||
997 | 1033 | } |
998 | 1034 | |
999 | 1035 | // single date? |
1000 | - if (isset($data['date'])) $one_date = true; |
|
1036 | + if (isset($data['date'])) { |
|
1037 | + $one_date = true; |
|
1038 | + } |
|
1001 | 1039 | |
1002 | 1040 | // remove empty entries, so they don't produce errors |
1003 | 1041 | foreach (array_keys($hansardmajors) as $major) { |
1004 | 1042 | if (array_key_exists($major, $data)) { |
1005 | - if (count($data[$major]) == 0) |
|
1006 | - unset($data[$major]); |
|
1043 | + if (count($data[$major]) == 0) { |
|
1044 | + unset($data[$major]); |
|
1045 | + } |
|
1007 | 1046 | } |
1008 | 1047 | } |
1009 | 1048 | |
@@ -1012,22 +1051,29 @@ discard block |
||
1012 | 1051 | if (!$one_date) { |
1013 | 1052 | $todaystime = gmmktime(0, 0, 0, date('m'), date('d'), date('Y')); |
1014 | 1053 | foreach ($data as $major => $array) { |
1015 | - if (!in_array('timestamp', $array)) $daytext[$major] = "The most recent "; |
|
1016 | - elseif ($todaystime - $array['timestamp'] == 86400) $daytext[$major] = "Yesterday’s"; |
|
1017 | - elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1018 | - else $daytext[$major] = "The most recent "; |
|
1054 | + if (!in_array('timestamp', $array)) { |
|
1055 | + $daytext[$major] = "The most recent "; |
|
1056 | + } elseif ($todaystime - $array['timestamp'] == 86400) { |
|
1057 | + $daytext[$major] = "Yesterday’s"; |
|
1058 | + } elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) { |
|
1059 | + $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1060 | + } else { |
|
1061 | + $daytext[$major] = "The most recent "; |
|
1062 | + } |
|
1019 | 1063 | } |
1020 | 1064 | } |
1021 | 1065 | |
1022 | 1066 | //build html |
1023 | 1067 | foreach ($printed_majors as $p_major) { |
1024 | - if (!array_key_exists($p_major, $data)) |
|
1025 | - continue; |
|
1068 | + if (!array_key_exists($p_major, $data)) { |
|
1069 | + continue; |
|
1070 | + } |
|
1026 | 1071 | |
1027 | - if ($one_date) |
|
1028 | - $date = $data['date']; |
|
1029 | - else |
|
1030 | - $date = $data[$p_major]['hdate']; |
|
1072 | + if ($one_date) { |
|
1073 | + $date = $data['date']; |
|
1074 | + } else { |
|
1075 | + $date = $data[$p_major]['hdate']; |
|
1076 | + } |
|
1031 | 1077 | $q = $db->query('SELECT section_id, body, gid |
1032 | 1078 | FROM hansard, epobject |
1033 | 1079 | WHERE hansard.epobject_id = epobject.epobject_id ' |
@@ -1079,14 +1125,16 @@ discard block |
||
1079 | 1125 | } |
1080 | 1126 | |
1081 | 1127 | $return .= '<a href="'; |
1082 | - if (isset($data[$major]['listurl'])) |
|
1083 | - $return .= $data[$major]['listurl']; |
|
1084 | - else { |
|
1128 | + if (isset($data[$major]['listurl'])) { |
|
1129 | + $return .= $data[$major]['listurl']; |
|
1130 | + } else { |
|
1085 | 1131 | $LISTURL->reset(); |
1086 | 1132 | $return .= $LISTURL->generate(); |
1087 | 1133 | } |
1088 | 1134 | $return .= '">' . $hansardmajors[$major]['title'] . '</a>'; |
1089 | - if (isset($daytext[$major])) $return; |
|
1135 | + if (isset($daytext[$major])) { |
|
1136 | + $return; |
|
1137 | + } |
|
1090 | 1138 | $return .= '</h4>'; |
1091 | 1139 | |
1092 | 1140 | return $return; |
@@ -1094,20 +1142,21 @@ discard block |
||
1094 | 1142 | |
1095 | 1143 | function score_to_strongly($dmpscore) { |
1096 | 1144 | $dmpdesc = "unknown about"; |
1097 | - if ($dmpscore > 0.95 && $dmpscore <= 1.0) |
|
1098 | - $dmpdesc = "consistently voted against"; |
|
1099 | - elseif ($dmpscore > 0.85) |
|
1100 | - $dmpdesc = "almost always voted against"; |
|
1101 | - elseif ($dmpscore > 0.6) |
|
1102 | - $dmpdesc = "generally voted against"; |
|
1103 | - elseif ($dmpscore > 0.4) |
|
1104 | - $dmpdesc = "voted a mixture of for and against"; |
|
1105 | - elseif ($dmpscore > 0.15) |
|
1106 | - $dmpdesc = "generally voted for"; |
|
1107 | - elseif ($dmpscore > 0.05) |
|
1108 | - $dmpdesc = "almost always voted for"; |
|
1109 | - elseif ($dmpscore >= 0.0) |
|
1110 | - $dmpdesc = "consistently voted for"; |
|
1145 | + if ($dmpscore > 0.95 && $dmpscore <= 1.0) { |
|
1146 | + $dmpdesc = "consistently voted against"; |
|
1147 | + } elseif ($dmpscore > 0.85) { |
|
1148 | + $dmpdesc = "almost always voted against"; |
|
1149 | + } elseif ($dmpscore > 0.6) { |
|
1150 | + $dmpdesc = "generally voted against"; |
|
1151 | + } elseif ($dmpscore > 0.4) { |
|
1152 | + $dmpdesc = "voted a mixture of for and against"; |
|
1153 | + } elseif ($dmpscore > 0.15) { |
|
1154 | + $dmpdesc = "generally voted for"; |
|
1155 | + } elseif ($dmpscore > 0.05) { |
|
1156 | + $dmpdesc = "almost always voted for"; |
|
1157 | + } elseif ($dmpscore >= 0.0) { |
|
1158 | + $dmpdesc = "consistently voted for"; |
|
1159 | + } |
|
1111 | 1160 | return $dmpdesc; |
1112 | 1161 | } |
1113 | 1162 |
@@ -61,16 +61,36 @@ discard block |
||
61 | 61 | $constituency = strtolower(str_replace('_', ' ', get_http_var('c'))); |
62 | 62 | |
63 | 63 | // Fix for names with non-ASCII characters |
64 | -if ($name == 'sion simon') $name = 'si\xf4n simon'; |
|
65 | -if ($name == 'sian james') $name = 'si\xe2n james'; |
|
66 | -if ($name == 'lembit opik') $name = 'lembit \xf6pik'; |
|
67 | -if ($name == 'bairbre de brun') $name = 'bairbre de br\xfan'; |
|
68 | -if ($name == 'daithi mckay') $name = 'daith\xed mckay'; |
|
69 | -if ($name == 'caral ni chuilin') $name = 'car\xe1l n\xed chuil\xedn'; |
|
70 | -if ($name == 'caledon du pre') $name = 'caledon du pr\xe9'; |
|
71 | -if ($name == 'sean etchingham') $name = 'se\xe1n etchingham'; |
|
72 | -if ($name == 'john tinne') $name = 'john tinn\xe9'; |
|
73 | -if ($name == 'renee short') $name = 'ren\xe9e short'; |
|
64 | +if ($name == 'sion simon') { |
|
65 | + $name = 'si\xf4n simon'; |
|
66 | +} |
|
67 | +if ($name == 'sian james') { |
|
68 | + $name = 'si\xe2n james'; |
|
69 | +} |
|
70 | +if ($name == 'lembit opik') { |
|
71 | + $name = 'lembit \xf6pik'; |
|
72 | +} |
|
73 | +if ($name == 'bairbre de brun') { |
|
74 | + $name = 'bairbre de br\xfan'; |
|
75 | +} |
|
76 | +if ($name == 'daithi mckay') { |
|
77 | + $name = 'daith\xed mckay'; |
|
78 | +} |
|
79 | +if ($name == 'caral ni chuilin') { |
|
80 | + $name = 'car\xe1l n\xed chuil\xedn'; |
|
81 | +} |
|
82 | +if ($name == 'caledon du pre') { |
|
83 | + $name = 'caledon du pr\xe9'; |
|
84 | +} |
|
85 | +if ($name == 'sean etchingham') { |
|
86 | + $name = 'se\xe1n etchingham'; |
|
87 | +} |
|
88 | +if ($name == 'john tinne') { |
|
89 | + $name = 'john tinn\xe9'; |
|
90 | +} |
|
91 | +if ($name == 'renee short') { |
|
92 | + $name = 'ren\xe9e short'; |
|
93 | +} |
|
74 | 94 | |
75 | 95 | // Fix for common misspellings, name changes etc |
76 | 96 | $name_fix = array( |
@@ -102,7 +122,9 @@ discard block |
||
102 | 122 | } |
103 | 123 | |
104 | 124 | // Fixes for Ynys Mon, and a Unicode URL |
105 | -if ($constituency == 'ynys mon') $constituency = "ynys m\xf4n"; |
|
125 | +if ($constituency == 'ynys mon') { |
|
126 | + $constituency = "ynys m\xf4n"; |
|
127 | +} |
|
106 | 128 | if (preg_match("#^ynys m\xc3\xb4n#i", $constituency)) { |
107 | 129 | $constituency = "ynys m\xf4n"; |
108 | 130 | } |
@@ -194,8 +216,9 @@ discard block |
||
194 | 216 | $desc = "Read $member_name's contributions to Parliament, including speeches and questions"; |
195 | 217 | |
196 | 218 | // Enhance description if this is a current member |
197 | -if ($MEMBER->current_member_anywhere()) |
|
219 | +if ($MEMBER->current_member_anywhere()) { |
|
198 | 220 | $desc .= ', investigate their voting record, and get email alerts on their activity'; |
221 | +} |
|
199 | 222 | |
200 | 223 | // Enhance title if this is a member of the Commons |
201 | 224 | if ($MEMBER->house(HOUSE_TYPE_COMMONS)) { |
@@ -203,8 +226,10 @@ discard block |
||
203 | 226 | $title .= ', former'; |
204 | 227 | } |
205 | 228 | $title .= ' MP'; |
206 | - if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency(); |
|
207 | -} |
|
229 | + if ($MEMBER->constituency()) { |
|
230 | + $title .= ', ' . $MEMBER->constituency(); |
|
231 | + } |
|
232 | + } |
|
208 | 233 | |
209 | 234 | // Enhance title if this is a member of NIA |
210 | 235 | if ($MEMBER->house(HOUSE_TYPE_NI)) { |
@@ -217,8 +242,10 @@ discard block |
||
217 | 242 | $title .= ', former'; |
218 | 243 | } |
219 | 244 | $title .= ' MLA'; |
220 | - if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency(); |
|
221 | -} |
|
245 | + if ($MEMBER->constituency()) { |
|
246 | + $title .= ', ' . $MEMBER->constituency(); |
|
247 | + } |
|
248 | + } |
|
222 | 249 | |
223 | 250 | // Enhance title if this is a member of Scottish Parliament |
224 | 251 | if ($MEMBER->house(HOUSE_TYPE_SCOTLAND)) { |
@@ -253,8 +280,9 @@ discard block |
||
253 | 280 | |
254 | 281 | // Build the RSS link and add it to page data. |
255 | 282 | $feedurl = $DATA->page_metadata('mp_rss', 'url') . $MEMBER->person_id() . '.rdf'; |
256 | -if (file_exists(BASEDIR . '/' . $feedurl)) |
|
283 | +if (file_exists(BASEDIR . '/' . $feedurl)) { |
|
257 | 284 | $DATA->set_page_metadata($this_page, 'rss', $feedurl); |
285 | +} |
|
258 | 286 | |
259 | 287 | // Prepare data for the template |
260 | 288 | $data['full_name'] = $MEMBER->full_name(); |
@@ -591,11 +619,13 @@ discard block |
||
591 | 619 | $url = $MEMBER->url(); |
592 | 620 | $params = array(); |
593 | 621 | foreach ($_GET as $key => $value) { |
594 | - if (substr($key, 0, 4) == 'utm_' || $key == 'gclid') |
|
595 | - $params[] = "$key=$value"; |
|
622 | + if (substr($key, 0, 4) == 'utm_' || $key == 'gclid') { |
|
623 | + $params[] = "$key=$value"; |
|
624 | + } |
|
625 | + } |
|
626 | + if (count($params)) { |
|
627 | + $url .= '?' . join('&', $params); |
|
596 | 628 | } |
597 | - if (count($params)) |
|
598 | - $url .= '?' . join('&', $params); |
|
599 | 629 | if ($pagetype) { |
600 | 630 | $pagetype = '/' . $pagetype; |
601 | 631 | } else { |
@@ -672,16 +702,21 @@ discard block |
||
672 | 702 | $current_member = $MEMBER->current_member(); |
673 | 703 | $left_house = $MEMBER->left_house(); |
674 | 704 | |
675 | - if (in_array(HOUSE_TYPE_ROYAL, $MEMBER->houses())) { # Royal short-circuit |
|
705 | + if (in_array(HOUSE_TYPE_ROYAL, $MEMBER->houses())) { |
|
706 | +# Royal short-circuit |
|
676 | 707 | return '<strong>Acceded on ' . $entered_house[HOUSE_TYPE_ROYAL]['date_pretty'] |
677 | 708 | . '<br>Coronated on 2 June 1953</strong></li>'; |
678 | 709 | } |
679 | 710 | $desc = ''; |
680 | 711 | foreach ($MEMBER->houses() as $house) { |
681 | - if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS])) |
|
682 | - continue; # Same info is printed further down |
|
712 | + if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS])) { |
|
713 | + continue; |
|
714 | + } |
|
715 | + # Same info is printed further down |
|
683 | 716 | |
684 | - if (!$current_member[$house]) $desc .= 'Former '; |
|
717 | + if (!$current_member[$house]) { |
|
718 | + $desc .= 'Former '; |
|
719 | + } |
|
685 | 720 | |
686 | 721 | $party = $left_house[$house]['party']; |
687 | 722 | $party_br = ''; |
@@ -689,8 +724,9 @@ discard block |
||
689 | 724 | $party_br = $m[2]; |
690 | 725 | $party = $m[1]; |
691 | 726 | } |
692 | - if ($party != 'unknown') |
|
693 | - $desc .= _htmlentities($party); |
|
727 | + if ($party != 'unknown') { |
|
728 | + $desc .= _htmlentities($party); |
|
729 | + } |
|
694 | 730 | if ($party == 'Speaker' || $party == 'Deputy Speaker') { |
695 | 731 | $desc .= ', and '; |
696 | 732 | # XXX: Might go horribly wrong if something odd happens |
@@ -701,15 +737,23 @@ discard block |
||
701 | 737 | } |
702 | 738 | if ($house==HOUSE_TYPE_COMMONS || $house==HOUSE_TYPE_NI || $house==HOUSE_TYPE_SCOTLAND) { |
703 | 739 | $desc .= ' '; |
704 | - if ($house==HOUSE_TYPE_COMMONS) $desc .= '<abbr title="Member of Parliament">MP</abbr>'; |
|
705 | - if ($house==HOUSE_TYPE_NI) $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>'; |
|
706 | - if ($house==HOUSE_TYPE_SCOTLAND) $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>'; |
|
740 | + if ($house==HOUSE_TYPE_COMMONS) { |
|
741 | + $desc .= '<abbr title="Member of Parliament">MP</abbr>'; |
|
742 | + } |
|
743 | + if ($house==HOUSE_TYPE_NI) { |
|
744 | + $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>'; |
|
745 | + } |
|
746 | + if ($house==HOUSE_TYPE_SCOTLAND) { |
|
747 | + $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>'; |
|
748 | + } |
|
707 | 749 | if ($party_br) { |
708 | 750 | $desc .= " ($party_br)"; |
709 | 751 | } |
710 | 752 | $desc .= ' for ' . $left_house[$house]['constituency']; |
711 | 753 | } |
712 | - if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') $desc .= ' Peer'; |
|
754 | + if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') { |
|
755 | + $desc .= ' Peer'; |
|
756 | + } |
|
713 | 757 | $desc .= ', '; |
714 | 758 | } |
715 | 759 | $desc = preg_replace('#, $#', '', $desc); |
@@ -971,10 +1015,13 @@ discard block |
||
971 | 1015 | # Find latest entered house |
972 | 1016 | $entered_house = null; |
973 | 1017 | foreach ($member->entered_house() as $h => $eh) { |
974 | - if (!$entered_house || $eh['date'] > $entered_house) $entered_house = $eh['date']; |
|
1018 | + if (!$entered_house || $eh['date'] > $entered_house) { |
|
1019 | + $entered_house = $eh['date']; |
|
1020 | + } |
|
1021 | + } |
|
1022 | + if ($entered_house > $year_ago) { |
|
1023 | + $since_text = 'since joining Parliament'; |
|
975 | 1024 | } |
976 | - if ($entered_house > $year_ago) |
|
977 | - $since_text = 'since joining Parliament'; |
|
978 | 1025 | |
979 | 1026 | $MOREURL = new \MySociety\TheyWorkForYou\Url('search'); |
980 | 1027 | $section = 'section:debates section:whall section:lords section:ni'; |
@@ -988,10 +1035,12 @@ discard block |
||
988 | 1035 | $MOREURL->insert(array('pid'=>$member->person_id(), 's'=>'section:wrans', 'pop'=>1)); |
989 | 1036 | // We assume that if they've answered a question, they're a minister |
990 | 1037 | $minister = 0; $Lminister = false; |
991 | - if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0) |
|
992 | - $minister = 1; |
|
993 | - if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0) |
|
994 | - $Lminister = true; |
|
1038 | + if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0) { |
|
1039 | + $minister = 1; |
|
1040 | + } |
|
1041 | + if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0) { |
|
1042 | + $Lminister = true; |
|
1043 | + } |
|
995 | 1044 | if ($member->party() == 'SPK' || $member->party() == 'CWM' || $member->party() == 'DCWM') { |
996 | 1045 | $minister = 2; |
997 | 1046 | } |
@@ -1039,11 +1088,17 @@ discard block |
||
1039 | 1088 | |
1040 | 1089 | if (isset($extra_info['number_of_alerts']) && ($extra_info['number_of_alerts']>0 || $has_email_alerts)) { |
1041 | 1090 | $line = '<strong>' . _htmlentities($extra_info['number_of_alerts']) . '</strong> ' . ($extra_info['number_of_alerts']==1?'person is':'people are') . ' tracking '; |
1042 | - if ($member->house_disp == HOUSE_TYPE_COMMONS) $line .= 'this MP'; |
|
1043 | - elseif ($member->house_disp == HOUSE_TYPE_LORDS) $line .= 'this peer'; |
|
1044 | - elseif ($member->house_disp == HOUSE_TYPE_NI) $line .= 'this MLA'; |
|
1045 | - elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) $line .= 'this MSP'; |
|
1046 | - elseif ($member->house_disp == HOUSE_TYPE_ROYAL) $line .= $member->full_name(); |
|
1091 | + if ($member->house_disp == HOUSE_TYPE_COMMONS) { |
|
1092 | + $line .= 'this MP'; |
|
1093 | + } elseif ($member->house_disp == HOUSE_TYPE_LORDS) { |
|
1094 | + $line .= 'this peer'; |
|
1095 | + } elseif ($member->house_disp == HOUSE_TYPE_NI) { |
|
1096 | + $line .= 'this MLA'; |
|
1097 | + } elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) { |
|
1098 | + $line .= 'this MSP'; |
|
1099 | + } elseif ($member->house_disp == HOUSE_TYPE_ROYAL) { |
|
1100 | + $line .= $member->full_name(); |
|
1101 | + } |
|
1047 | 1102 | if ($has_email_alerts) { |
1048 | 1103 | $line .= ' — <a href="' . WEBPATH . 'alert/?pid='.$member->person_id().'">email me updates on '. $member->full_name(). '’s activity</a>'; |
1049 | 1104 | } |
@@ -1067,10 +1122,12 @@ discard block |
||
1067 | 1122 | |
1068 | 1123 | function display_stats_line($category, $blurb, $type, $inwhat, $afterstuff, $extra_info, $minister = false, $Lminister = false) { |
1069 | 1124 | $return = false; |
1070 | - if (isset($extra_info[$category])) |
|
1071 | - $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff); |
|
1072 | - if (isset($extra_info["L$category"])) |
|
1073 | - $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff); |
|
1125 | + if (isset($extra_info[$category])) { |
|
1126 | + $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff); |
|
1127 | + } |
|
1128 | + if (isset($extra_info["L$category"])) { |
|
1129 | + $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff); |
|
1130 | + } |
|
1074 | 1131 | return $return; |
1075 | 1132 | } |
1076 | 1133 | |
@@ -1082,17 +1139,21 @@ discard block |
||
1082 | 1139 | $inwhat = preg_replace('#<\/a>#', '', $inwhat); |
1083 | 1140 | } |
1084 | 1141 | } |
1085 | - if ($house==HOUSE_TYPE_LORDS) $inwhat = str_replace('MP', 'Lord', $inwhat); |
|
1142 | + if ($house==HOUSE_TYPE_LORDS) { |
|
1143 | + $inwhat = str_replace('MP', 'Lord', $inwhat); |
|
1144 | + } |
|
1086 | 1145 | $line = $blurb; |
1087 | 1146 | $line .= '<strong>' . $extra_info[$category]; |
1088 | - if ($type) $line .= ' ' . make_plural($type, $extra_info[$category]); |
|
1147 | + if ($type) { |
|
1148 | + $line .= ' ' . make_plural($type, $extra_info[$category]); |
|
1149 | + } |
|
1089 | 1150 | $line .= '</strong>'; |
1090 | 1151 | $line .= $inwhat; |
1091 | 1152 | if ($minister===2) { |
1092 | 1153 | $line .= ' — Speakers/ deputy speakers do not ask written questions'; |
1093 | - } elseif ($minister) |
|
1094 | - $line .= ' — Ministers do not ask written questions'; |
|
1095 | - else { |
|
1154 | + } elseif ($minister) { |
|
1155 | + $line .= ' — Ministers do not ask written questions'; |
|
1156 | + } else { |
|
1096 | 1157 | $type = ($house==HOUSE_TYPE_COMMONS?'MP':($house==HOUSE_TYPE_LORDS?'Lord':'MLA')); |
1097 | 1158 | if (!get_http_var('rem') && isset($extra_info[$category . '_quintile'])) { |
1098 | 1159 | $line .= ' — '; |
@@ -1131,11 +1192,21 @@ discard block |
||
1131 | 1192 | $mean = $extra_info["writetothem_responsiveness_mean_$year"]; |
1132 | 1193 | |
1133 | 1194 | $a = $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"]; |
1134 | - if ($a == 'very low') $a = 'a very low'; |
|
1135 | - if ($a == 'low') $a = 'a low'; |
|
1136 | - if ($a == 'medium') $a = 'a medium'; |
|
1137 | - if ($a == 'high') $a = 'a high'; |
|
1138 | - if ($a == 'very high') $a = 'a very high'; |
|
1195 | + if ($a == 'very low') { |
|
1196 | + $a = 'a very low'; |
|
1197 | + } |
|
1198 | + if ($a == 'low') { |
|
1199 | + $a = 'a low'; |
|
1200 | + } |
|
1201 | + if ($a == 'medium') { |
|
1202 | + $a = 'a medium'; |
|
1203 | + } |
|
1204 | + if ($a == 'high') { |
|
1205 | + $a = 'a high'; |
|
1206 | + } |
|
1207 | + if ($a == 'very high') { |
|
1208 | + $a = 'a very high'; |
|
1209 | + } |
|
1139 | 1210 | $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"] = $a; |
1140 | 1211 | |
1141 | 1212 | 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); |
@@ -81,7 +81,9 @@ discard block |
||
81 | 81 | |
82 | 82 | $parent_page = $DATA->page_metadata($this_page, 'parent'); |
83 | 83 | if ($parent_title = $DATA->page_metadata($parent_page, 'title')) { |
84 | - if ($this->data['page_title']) $this->data['page_title'] .= ': '; |
|
84 | + if ($this->data['page_title']) { |
|
85 | + $this->data['page_title'] .= ': '; |
|
86 | + } |
|
85 | 87 | $this->data['page_title'] .= $parent_title; |
86 | 88 | } |
87 | 89 | |
@@ -103,7 +105,9 @@ discard block |
||
103 | 105 | // Meta keywords |
104 | 106 | if (!$this->data['meta_keywords'] = $DATA->page_metadata($this_page, "meta_keywords")) { |
105 | 107 | $this->data['meta_keywords'] = $this->keywords_title; |
106 | - if ($this->data['meta_keywords']) $this->data['meta_keywords'] .= ', '; |
|
108 | + if ($this->data['meta_keywords']) { |
|
109 | + $this->data['meta_keywords'] .= ', '; |
|
110 | + } |
|
107 | 111 | $this->data['meta_keywords'] .= 'Hansard, Official Report, Parliament, government, House of Commons, House of Lords, MP, Peer, Member of Parliament, MPs, Peers, Lords, Commons, Scottish Parliament, Northern Ireland Assembly, MSP, MLA, MSPs, MLAs, London Assembly Members'; |
108 | 112 | } |
109 | 113 | |
@@ -204,7 +208,9 @@ discard block |
||
204 | 208 | $p = $parent; |
205 | 209 | while ($p) { |
206 | 210 | $p = $DATA->page_metadata($p, 'parent'); |
207 | - if ($p) $parents[] = $p; |
|
211 | + if ($p) { |
|
212 | + $parents[] = $p; |
|
213 | + } |
|
208 | 214 | } |
209 | 215 | |
210 | 216 | $top_highlight = array_pop($parents); |
@@ -283,7 +289,9 @@ discard block |
||
283 | 289 | $menudata = $DATA->page_metadata($toppage, 'menu'); |
284 | 290 | $text = $menudata['text']; |
285 | 291 | $title = $menudata['title']; |
286 | - if (!$title) continue; |
|
292 | + if (!$title) { |
|
293 | + continue; |
|
294 | + } |
|
287 | 295 | |
288 | 296 | //get link and description for the menu ans add it to the array |
289 | 297 | $class = $toppage == $this->nav_highlights['top'] ? 'on' : ''; |