@@ -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 | } |
@@ -125,12 +147,19 @@ discard block |
||
| 125 | 147 | |
| 126 | 148 | ///////////////////////////////////////////////////////// |
| 127 | 149 | // DETERMINE TYPE OF REPRESENTITIVE |
| 128 | -if (get_http_var('peer')) $this_page = 'peer'; |
|
| 129 | -elseif (get_http_var('royal')) $this_page = 'royal'; |
|
| 130 | -elseif (get_http_var('mla')) $this_page = 'mla'; |
|
| 131 | -elseif (get_http_var('msp')) $this_page = 'msp'; |
|
| 132 | -elseif (get_http_var('london-assembly-member')) $this_page = 'london-assembly-member'; |
|
| 133 | -else $this_page = 'mp'; |
|
| 150 | +if (get_http_var('peer')) { |
|
| 151 | + $this_page = 'peer'; |
|
| 152 | +} elseif (get_http_var('royal')) { |
|
| 153 | + $this_page = 'royal'; |
|
| 154 | +} elseif (get_http_var('mla')) { |
|
| 155 | + $this_page = 'mla'; |
|
| 156 | +} elseif (get_http_var('msp')) { |
|
| 157 | + $this_page = 'msp'; |
|
| 158 | +} elseif (get_http_var('london-assembly-member')) { |
|
| 159 | + $this_page = 'london-assembly-member'; |
|
| 160 | +} else { |
|
| 161 | + $this_page = 'mp'; |
|
| 162 | +} |
|
| 134 | 163 | |
| 135 | 164 | try { |
| 136 | 165 | if (is_numeric($pid)) { |
@@ -179,8 +208,9 @@ discard block |
||
| 179 | 208 | $desc = "Read $member_name's contributions to Parliament, including speeches and questions"; |
| 180 | 209 | |
| 181 | 210 | // Enhance description if this is a current member |
| 182 | -if ($MEMBER->current_member_anywhere()) |
|
| 211 | +if ($MEMBER->current_member_anywhere()) { |
|
| 183 | 212 | $desc .= ', investigate their voting record, and get email alerts on their activity'; |
| 213 | +} |
|
| 184 | 214 | |
| 185 | 215 | // Enhance title if this is a member of the Commons |
| 186 | 216 | if ($MEMBER->house(HOUSE_TYPE_COMMONS)) { |
@@ -188,8 +218,10 @@ discard block |
||
| 188 | 218 | $title .= ', former'; |
| 189 | 219 | } |
| 190 | 220 | $title .= ' MP'; |
| 191 | - if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency(); |
|
| 192 | -} |
|
| 221 | + if ($MEMBER->constituency()) { |
|
| 222 | + $title .= ', ' . $MEMBER->constituency(); |
|
| 223 | + } |
|
| 224 | + } |
|
| 193 | 225 | |
| 194 | 226 | // Enhance title if this is a member of NIA |
| 195 | 227 | if ($MEMBER->house(HOUSE_TYPE_NI)) { |
@@ -202,8 +234,10 @@ discard block |
||
| 202 | 234 | $title .= ', former'; |
| 203 | 235 | } |
| 204 | 236 | $title .= ' MLA'; |
| 205 | - if ($MEMBER->constituency()) $title .= ', ' . $MEMBER->constituency(); |
|
| 206 | -} |
|
| 237 | + if ($MEMBER->constituency()) { |
|
| 238 | + $title .= ', ' . $MEMBER->constituency(); |
|
| 239 | + } |
|
| 240 | + } |
|
| 207 | 241 | |
| 208 | 242 | // Enhance title if this is a member of Scottish Parliament |
| 209 | 243 | if ($MEMBER->house(HOUSE_TYPE_SCOTLAND)) { |
@@ -238,8 +272,9 @@ discard block |
||
| 238 | 272 | |
| 239 | 273 | // Build the RSS link and add it to page data. |
| 240 | 274 | $feedurl = $DATA->page_metadata('mp_rss', 'url') . $MEMBER->person_id() . '.rdf'; |
| 241 | -if (file_exists(BASEDIR . '/' . $feedurl)) |
|
| 275 | +if (file_exists(BASEDIR . '/' . $feedurl)) { |
|
| 242 | 276 | $DATA->set_page_metadata($this_page, 'rss', $feedurl); |
| 277 | +} |
|
| 243 | 278 | |
| 244 | 279 | // Prepare data for the template |
| 245 | 280 | $data['full_name'] = $MEMBER->full_name(); |
@@ -576,11 +611,13 @@ discard block |
||
| 576 | 611 | $url = $MEMBER->url(); |
| 577 | 612 | $params = array(); |
| 578 | 613 | foreach ($_GET as $key => $value) { |
| 579 | - if (substr($key, 0, 4) == 'utm_' || $key == 'gclid') |
|
| 580 | - $params[] = "$key=$value"; |
|
| 614 | + if (substr($key, 0, 4) == 'utm_' || $key == 'gclid') { |
|
| 615 | + $params[] = "$key=$value"; |
|
| 616 | + } |
|
| 617 | + } |
|
| 618 | + if (count($params)) { |
|
| 619 | + $url .= '?' . join('&', $params); |
|
| 581 | 620 | } |
| 582 | - if (count($params)) |
|
| 583 | - $url .= '?' . join('&', $params); |
|
| 584 | 621 | if ($pagetype) { |
| 585 | 622 | $pagetype = '/' . $pagetype; |
| 586 | 623 | } else { |
@@ -657,16 +694,21 @@ discard block |
||
| 657 | 694 | $current_member = $MEMBER->current_member(); |
| 658 | 695 | $left_house = $MEMBER->left_house(); |
| 659 | 696 | |
| 660 | - if (in_array(HOUSE_TYPE_ROYAL, $MEMBER->houses())) { # Royal short-circuit |
|
| 697 | + if (in_array(HOUSE_TYPE_ROYAL, $MEMBER->houses())) { |
|
| 698 | +# Royal short-circuit |
|
| 661 | 699 | return '<strong>Acceded on ' . $entered_house[HOUSE_TYPE_ROYAL]['date_pretty'] |
| 662 | 700 | . '<br>Coronated on 2 June 1953</strong></li>'; |
| 663 | 701 | } |
| 664 | 702 | $desc = ''; |
| 665 | 703 | foreach ($MEMBER->houses() as $house) { |
| 666 | - if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS])) |
|
| 667 | - continue; # Same info is printed further down |
|
| 704 | + if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS])) { |
|
| 705 | + continue; |
|
| 706 | + } |
|
| 707 | + # Same info is printed further down |
|
| 668 | 708 | |
| 669 | - if (!$current_member[$house]) $desc .= 'Former '; |
|
| 709 | + if (!$current_member[$house]) { |
|
| 710 | + $desc .= 'Former '; |
|
| 711 | + } |
|
| 670 | 712 | |
| 671 | 713 | $party = $left_house[$house]['party']; |
| 672 | 714 | $party_br = ''; |
@@ -674,8 +716,9 @@ discard block |
||
| 674 | 716 | $party_br = $m[2]; |
| 675 | 717 | $party = $m[1]; |
| 676 | 718 | } |
| 677 | - if ($party != 'unknown') |
|
| 678 | - $desc .= _htmlentities($party); |
|
| 719 | + if ($party != 'unknown') { |
|
| 720 | + $desc .= _htmlentities($party); |
|
| 721 | + } |
|
| 679 | 722 | if ($party == 'Speaker' || $party == 'Deputy Speaker') { |
| 680 | 723 | $desc .= ', and '; |
| 681 | 724 | # XXX: Might go horribly wrong if something odd happens |
@@ -686,15 +729,23 @@ discard block |
||
| 686 | 729 | } |
| 687 | 730 | if ($house==HOUSE_TYPE_COMMONS || $house==HOUSE_TYPE_NI || $house==HOUSE_TYPE_SCOTLAND) { |
| 688 | 731 | $desc .= ' '; |
| 689 | - if ($house==HOUSE_TYPE_COMMONS) $desc .= '<abbr title="Member of Parliament">MP</abbr>'; |
|
| 690 | - if ($house==HOUSE_TYPE_NI) $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>'; |
|
| 691 | - if ($house==HOUSE_TYPE_SCOTLAND) $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>'; |
|
| 732 | + if ($house==HOUSE_TYPE_COMMONS) { |
|
| 733 | + $desc .= '<abbr title="Member of Parliament">MP</abbr>'; |
|
| 734 | + } |
|
| 735 | + if ($house==HOUSE_TYPE_NI) { |
|
| 736 | + $desc .= '<abbr title="Member of the Legislative Assembly">MLA</abbr>'; |
|
| 737 | + } |
|
| 738 | + if ($house==HOUSE_TYPE_SCOTLAND) { |
|
| 739 | + $desc .= '<abbr title="Member of the Scottish Parliament">MSP</abbr>'; |
|
| 740 | + } |
|
| 692 | 741 | if ($party_br) { |
| 693 | 742 | $desc .= " ($party_br)"; |
| 694 | 743 | } |
| 695 | 744 | $desc .= ' for ' . $left_house[$house]['constituency']; |
| 696 | 745 | } |
| 697 | - if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') $desc .= ' Peer'; |
|
| 746 | + if ($house==HOUSE_TYPE_LORDS && $party != 'Bishop') { |
|
| 747 | + $desc .= ' Peer'; |
|
| 748 | + } |
|
| 698 | 749 | $desc .= ', '; |
| 699 | 750 | } |
| 700 | 751 | $desc = preg_replace('#, $#', '', $desc); |
@@ -956,10 +1007,13 @@ discard block |
||
| 956 | 1007 | # Find latest entered house |
| 957 | 1008 | $entered_house = null; |
| 958 | 1009 | foreach ($member->entered_house() as $h => $eh) { |
| 959 | - if (!$entered_house || $eh['date'] > $entered_house) $entered_house = $eh['date']; |
|
| 1010 | + if (!$entered_house || $eh['date'] > $entered_house) { |
|
| 1011 | + $entered_house = $eh['date']; |
|
| 1012 | + } |
|
| 1013 | + } |
|
| 1014 | + if ($entered_house > $year_ago) { |
|
| 1015 | + $since_text = 'since joining Parliament'; |
|
| 960 | 1016 | } |
| 961 | - if ($entered_house > $year_ago) |
|
| 962 | - $since_text = 'since joining Parliament'; |
|
| 963 | 1017 | |
| 964 | 1018 | $MOREURL = new \MySociety\TheyWorkForYou\Url('search'); |
| 965 | 1019 | $section = 'section:debates section:whall section:lords section:ni'; |
@@ -973,10 +1027,12 @@ discard block |
||
| 973 | 1027 | $MOREURL->insert(array('pid'=>$member->person_id(), 's'=>'section:wrans', 'pop'=>1)); |
| 974 | 1028 | // We assume that if they've answered a question, they're a minister |
| 975 | 1029 | $minister = 0; $Lminister = false; |
| 976 | - if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0) |
|
| 977 | - $minister = 1; |
|
| 978 | - if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0) |
|
| 979 | - $Lminister = true; |
|
| 1030 | + if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0) { |
|
| 1031 | + $minister = 1; |
|
| 1032 | + } |
|
| 1033 | + if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0) { |
|
| 1034 | + $Lminister = true; |
|
| 1035 | + } |
|
| 980 | 1036 | if ($member->party() == 'SPK' || $member->party() == 'CWM' || $member->party() == 'DCWM') { |
| 981 | 1037 | $minister = 2; |
| 982 | 1038 | } |
@@ -1024,11 +1080,17 @@ discard block |
||
| 1024 | 1080 | |
| 1025 | 1081 | if (isset($extra_info['number_of_alerts']) && ($extra_info['number_of_alerts']>0 || $has_email_alerts)) { |
| 1026 | 1082 | $line = '<strong>' . _htmlentities($extra_info['number_of_alerts']) . '</strong> ' . ($extra_info['number_of_alerts']==1?'person is':'people are') . ' tracking '; |
| 1027 | - if ($member->house_disp == HOUSE_TYPE_COMMONS) $line .= 'this MP'; |
|
| 1028 | - elseif ($member->house_disp == HOUSE_TYPE_LORDS) $line .= 'this peer'; |
|
| 1029 | - elseif ($member->house_disp == HOUSE_TYPE_NI) $line .= 'this MLA'; |
|
| 1030 | - elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) $line .= 'this MSP'; |
|
| 1031 | - elseif ($member->house_disp == HOUSE_TYPE_ROYAL) $line .= $member->full_name(); |
|
| 1083 | + if ($member->house_disp == HOUSE_TYPE_COMMONS) { |
|
| 1084 | + $line .= 'this MP'; |
|
| 1085 | + } elseif ($member->house_disp == HOUSE_TYPE_LORDS) { |
|
| 1086 | + $line .= 'this peer'; |
|
| 1087 | + } elseif ($member->house_disp == HOUSE_TYPE_NI) { |
|
| 1088 | + $line .= 'this MLA'; |
|
| 1089 | + } elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) { |
|
| 1090 | + $line .= 'this MSP'; |
|
| 1091 | + } elseif ($member->house_disp == HOUSE_TYPE_ROYAL) { |
|
| 1092 | + $line .= $member->full_name(); |
|
| 1093 | + } |
|
| 1032 | 1094 | if ($has_email_alerts) { |
| 1033 | 1095 | $line .= ' — <a href="' . WEBPATH . 'alert/?pid='.$member->person_id().'">email me updates on '. $member->full_name(). '’s activity</a>'; |
| 1034 | 1096 | } |
@@ -1052,10 +1114,12 @@ discard block |
||
| 1052 | 1114 | |
| 1053 | 1115 | function display_stats_line($category, $blurb, $type, $inwhat, $afterstuff, $extra_info, $minister = false, $Lminister = false) { |
| 1054 | 1116 | $return = false; |
| 1055 | - if (isset($extra_info[$category])) |
|
| 1056 | - $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff); |
|
| 1057 | - if (isset($extra_info["L$category"])) |
|
| 1058 | - $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff); |
|
| 1117 | + if (isset($extra_info[$category])) { |
|
| 1118 | + $return = display_stats_line_house(HOUSE_TYPE_COMMONS, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff); |
|
| 1119 | + } |
|
| 1120 | + if (isset($extra_info["L$category"])) { |
|
| 1121 | + $return = display_stats_line_house(HOUSE_TYPE_LORDS, "L$category", $blurb, $type, $inwhat, $extra_info, $Lminister, $afterstuff); |
|
| 1122 | + } |
|
| 1059 | 1123 | return $return; |
| 1060 | 1124 | } |
| 1061 | 1125 | |
@@ -1067,17 +1131,21 @@ discard block |
||
| 1067 | 1131 | $inwhat = preg_replace('#<\/a>#', '', $inwhat); |
| 1068 | 1132 | } |
| 1069 | 1133 | } |
| 1070 | - if ($house==HOUSE_TYPE_LORDS) $inwhat = str_replace('MP', 'Lord', $inwhat); |
|
| 1134 | + if ($house==HOUSE_TYPE_LORDS) { |
|
| 1135 | + $inwhat = str_replace('MP', 'Lord', $inwhat); |
|
| 1136 | + } |
|
| 1071 | 1137 | $line = $blurb; |
| 1072 | 1138 | $line .= '<strong>' . $extra_info[$category]; |
| 1073 | - if ($type) $line .= ' ' . make_plural($type, $extra_info[$category]); |
|
| 1139 | + if ($type) { |
|
| 1140 | + $line .= ' ' . make_plural($type, $extra_info[$category]); |
|
| 1141 | + } |
|
| 1074 | 1142 | $line .= '</strong>'; |
| 1075 | 1143 | $line .= $inwhat; |
| 1076 | 1144 | if ($minister===2) { |
| 1077 | 1145 | $line .= ' — Speakers/ deputy speakers do not ask written questions'; |
| 1078 | - } elseif ($minister) |
|
| 1079 | - $line .= ' — Ministers do not ask written questions'; |
|
| 1080 | - else { |
|
| 1146 | + } elseif ($minister) { |
|
| 1147 | + $line .= ' — Ministers do not ask written questions'; |
|
| 1148 | + } else { |
|
| 1081 | 1149 | $type = ($house==HOUSE_TYPE_COMMONS?'MP':($house==HOUSE_TYPE_LORDS?'Lord':'MLA')); |
| 1082 | 1150 | if (!get_http_var('rem') && isset($extra_info[$category . '_quintile'])) { |
| 1083 | 1151 | $line .= ' — '; |
@@ -1116,11 +1184,21 @@ discard block |
||
| 1116 | 1184 | $mean = $extra_info["writetothem_responsiveness_mean_$year"]; |
| 1117 | 1185 | |
| 1118 | 1186 | $a = $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"]; |
| 1119 | - if ($a == 'very low') $a = 'a very low'; |
|
| 1120 | - if ($a == 'low') $a = 'a low'; |
|
| 1121 | - if ($a == 'medium') $a = 'a medium'; |
|
| 1122 | - if ($a == 'high') $a = 'a high'; |
|
| 1123 | - if ($a == 'very high') $a = 'a very high'; |
|
| 1187 | + if ($a == 'very low') { |
|
| 1188 | + $a = 'a very low'; |
|
| 1189 | + } |
|
| 1190 | + if ($a == 'low') { |
|
| 1191 | + $a = 'a low'; |
|
| 1192 | + } |
|
| 1193 | + if ($a == 'medium') { |
|
| 1194 | + $a = 'a medium'; |
|
| 1195 | + } |
|
| 1196 | + if ($a == 'high') { |
|
| 1197 | + $a = 'a high'; |
|
| 1198 | + } |
|
| 1199 | + if ($a == 'very high') { |
|
| 1200 | + $a = 'a very high'; |
|
| 1201 | + } |
|
| 1124 | 1202 | $extra_info["writetothem_responsiveness_fuzzy_response_description_$year"] = $a; |
| 1125 | 1203 | |
| 1126 | 1204 | 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); |