@@ -38,13 +38,17 @@ discard block |
||
38 | 38 | |
39 | 39 | function api_getGeometry_name($name) { |
40 | 40 | $out = _api_getGeometry_name($name); |
41 | - if ($out) api_output($out); |
|
42 | - else api_error('Name not recognised'); |
|
43 | -} |
|
41 | + if ($out) { |
|
42 | + api_output($out); |
|
43 | + } else { |
|
44 | + api_error('Name not recognised'); |
|
45 | + } |
|
46 | + } |
|
44 | 47 | |
45 | 48 | function _api_getGeometry_name($name) { |
46 | - if (!defined('OPTION_MAPIT_URL') || !OPTION_MAPIT_URL) |
|
47 | - return null; |
|
49 | + if (!defined('OPTION_MAPIT_URL') || !OPTION_MAPIT_URL) { |
|
50 | + return null; |
|
51 | + } |
|
48 | 52 | |
49 | 53 | $name = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($name); |
50 | 54 | |
@@ -68,8 +72,9 @@ discard block |
||
68 | 72 | |
69 | 73 | function _api_cacheCheck($fn, $arg='') { |
70 | 74 | $cache = INCLUDESPATH . '../docs/api/cache/' . $fn; |
71 | - if (is_file($cache)) |
|
72 | - return unserialize(file_get_contents($cache)); |
|
75 | + if (is_file($cache)) { |
|
76 | + return unserialize(file_get_contents($cache)); |
|
77 | + } |
|
73 | 78 | $out = mapit_call($fn, $arg); |
74 | 79 | $fp = fopen($cache, 'w'); |
75 | 80 | if ($fp) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | return null; |
67 | 67 | } |
68 | 68 | |
69 | -function _api_cacheCheck($fn, $arg='') { |
|
69 | +function _api_cacheCheck($fn, $arg = '') { |
|
70 | 70 | $cache = INCLUDESPATH . '../docs/api/cache/' . $fn; |
71 | 71 | if (is_file($cache)) |
72 | 72 | return unserialize(file_get_contents($cache)); |
@@ -83,58 +83,58 @@ discard block |
||
83 | 83 | function _api_ni_centroids() { |
84 | 84 | return array( |
85 | 85 | # East Londonderry |
86 | - 66129 => array('centre_lat' => 54.980766, 'centre_lon' => -6.904907 ), |
|
87 | - 14276 => array('centre_lat' => 54.980766, 'centre_lon' => -6.904907 ), |
|
86 | + 66129 => array('centre_lat' => 54.980766, 'centre_lon' => -6.904907), |
|
87 | + 14276 => array('centre_lat' => 54.980766, 'centre_lon' => -6.904907), |
|
88 | 88 | # Foyle |
89 | - 66131 => array('centre_lat' => 54.933453, 'centre_lon' => -7.267456 ), |
|
90 | - 14273 => array('centre_lat' => 54.933453, 'centre_lon' => -7.267456 ), |
|
89 | + 66131 => array('centre_lat' => 54.933453, 'centre_lon' => -7.267456), |
|
90 | + 14273 => array('centre_lat' => 54.933453, 'centre_lon' => -7.267456), |
|
91 | 91 | # West Tyrone |
92 | - 66141 => array('centre_lat' => 54.619797, 'centre_lon' => -7.410278 ), |
|
93 | - 14292 => array('centre_lat' => 54.619797, 'centre_lon' => -7.410278 ), |
|
92 | + 66141 => array('centre_lat' => 54.619797, 'centre_lon' => -7.410278), |
|
93 | + 14292 => array('centre_lat' => 54.619797, 'centre_lon' => -7.410278), |
|
94 | 94 | # Fermanagh & South Tyrone |
95 | - 14296 => array('centre_lat' => 54.354958, 'centre_lon' => -7.443237 ), |
|
96 | - 66130 => array('centre_lat' => 54.354958, 'centre_lon' => -7.443237 ), |
|
95 | + 14296 => array('centre_lat' => 54.354958, 'centre_lon' => -7.443237), |
|
96 | + 66130 => array('centre_lat' => 54.354958, 'centre_lon' => -7.443237), |
|
97 | 97 | # Newry & Armagh |
98 | - 14303 => array('centre_lat' => 54.297295, 'centre_lon' => -6.613770 ), |
|
99 | - 66134 => array('centre_lat' => 54.297295, 'centre_lon' => -6.613770 ), |
|
98 | + 14303 => array('centre_lat' => 54.297295, 'centre_lon' => -6.613770), |
|
99 | + 66134 => array('centre_lat' => 54.297295, 'centre_lon' => -6.613770), |
|
100 | 100 | # Upper Bann |
101 | - 14300 => array('centre_lat' => 54.399750, 'centre_lon' => -6.350098 ), |
|
102 | - 66140 => array('centre_lat' => 54.399750, 'centre_lon' => -6.350098 ), |
|
101 | + 14300 => array('centre_lat' => 54.399750, 'centre_lon' => -6.350098), |
|
102 | + 66140 => array('centre_lat' => 54.399750, 'centre_lon' => -6.350098), |
|
103 | 103 | # South Down |
104 | - 14306 => array('centre_lat' => 54.213860, 'centre_lon' => -6.152344 ), |
|
105 | - 66138 => array('centre_lat' => 54.213860, 'centre_lon' => -6.152344 ), |
|
104 | + 14306 => array('centre_lat' => 54.213860, 'centre_lon' => -6.152344), |
|
105 | + 66138 => array('centre_lat' => 54.213860, 'centre_lon' => -6.152344), |
|
106 | 106 | # Lagan Valley |
107 | - 14309 => array('centre_lat' => 54.441296, 'centre_lon' => -6.108398 ), |
|
108 | - 66132 => array('centre_lat' => 54.441296, 'centre_lon' => -6.108398 ), |
|
107 | + 14309 => array('centre_lat' => 54.441296, 'centre_lon' => -6.108398), |
|
108 | + 66132 => array('centre_lat' => 54.441296, 'centre_lon' => -6.108398), |
|
109 | 109 | # Strangford |
110 | - 14312 => array('centre_lat' => 54.514706, 'centre_lon' => -5.751343 ), |
|
111 | - 66139 => array('centre_lat' => 54.514706, 'centre_lon' => -5.751343 ), |
|
110 | + 14312 => array('centre_lat' => 54.514706, 'centre_lon' => -5.751343), |
|
111 | + 66139 => array('centre_lat' => 54.514706, 'centre_lon' => -5.751343), |
|
112 | 112 | # North Down |
113 | - 14325 => array('centre_lat' => 54.651592, 'centre_lon' => -5.718384 ), |
|
114 | - 66136 => array('centre_lat' => 54.651592, 'centre_lon' => -5.718384 ), |
|
113 | + 14325 => array('centre_lat' => 54.651592, 'centre_lon' => -5.718384), |
|
114 | + 66136 => array('centre_lat' => 54.651592, 'centre_lon' => -5.718384), |
|
115 | 115 | # South Antrim |
116 | - 14318 => array('centre_lat' => 54.699234, 'centre_lon' => -6.102905 ), |
|
117 | - 66137 => array('centre_lat' => 54.699234, 'centre_lon' => -6.102905 ), |
|
116 | + 14318 => array('centre_lat' => 54.699234, 'centre_lon' => -6.102905), |
|
117 | + 66137 => array('centre_lat' => 54.699234, 'centre_lon' => -6.102905), |
|
118 | 118 | # East Antrim |
119 | - 66128 => array('centre_lat' => 54.832336, 'centre_lon' => -5.883179 ), |
|
120 | - 14284 => array('centre_lat' => 54.832336, 'centre_lon' => -5.883179 ), |
|
119 | + 66128 => array('centre_lat' => 54.832336, 'centre_lon' => -5.883179), |
|
120 | + 14284 => array('centre_lat' => 54.832336, 'centre_lon' => -5.883179), |
|
121 | 121 | # North Antrim |
122 | - 66135 => array('centre_lat' => 54.993374, 'centre_lon' => -6.328125 ), |
|
123 | - 14280 => array('centre_lat' => 54.993374, 'centre_lon' => -6.328125 ), |
|
122 | + 66135 => array('centre_lat' => 54.993374, 'centre_lon' => -6.328125), |
|
123 | + 14280 => array('centre_lat' => 54.993374, 'centre_lon' => -6.328125), |
|
124 | 124 | # Mid Ulster |
125 | - 66133 => array('centre_lat' => 54.721447, 'centre_lon' => -6.795044 ), |
|
126 | - 14288 => array('centre_lat' => 54.721447, 'centre_lon' => -6.795044 ), |
|
125 | + 66133 => array('centre_lat' => 54.721447, 'centre_lon' => -6.795044), |
|
126 | + 14288 => array('centre_lat' => 54.721447, 'centre_lon' => -6.795044), |
|
127 | 127 | # Belfast North |
128 | - 14321 => array('centre_lat' => 54.618607, 'centre_lon' => -5.917511 ), |
|
129 | - 66125 => array('centre_lat' => 54.618607, 'centre_lon' => -5.917511 ), |
|
128 | + 14321 => array('centre_lat' => 54.618607, 'centre_lon' => -5.917511), |
|
129 | + 66125 => array('centre_lat' => 54.618607, 'centre_lon' => -5.917511), |
|
130 | 130 | # Belfast East |
131 | - 14329 => array('centre_lat' => 54.598324, 'centre_lon' => -5.892792 ), |
|
132 | - 66124 => array('centre_lat' => 54.598324, 'centre_lon' => -5.892792 ), |
|
131 | + 14329 => array('centre_lat' => 54.598324, 'centre_lon' => -5.892792), |
|
132 | + 66124 => array('centre_lat' => 54.598324, 'centre_lon' => -5.892792), |
|
133 | 133 | # Belfast South |
134 | - 14331 => array('centre_lat' => 54.582409, 'centre_lon' => -5.925064 ), |
|
135 | - 66126 => array('centre_lat' => 54.582409, 'centre_lon' => -5.925064 ), |
|
134 | + 14331 => array('centre_lat' => 54.582409, 'centre_lon' => -5.925064), |
|
135 | + 66126 => array('centre_lat' => 54.582409, 'centre_lon' => -5.925064), |
|
136 | 136 | # Belfast West |
137 | - 14315 => array('centre_lat' => 54.606277, 'centre_lon' => -5.956650 ), |
|
138 | - 66127 => array('centre_lat' => 54.606277, 'centre_lon' => -5.956650 ), |
|
137 | + 14315 => array('centre_lat' => 54.606277, 'centre_lon' => -5.956650), |
|
138 | + 66127 => array('centre_lat' => 54.606277, 'centre_lon' => -5.956650), |
|
139 | 139 | ); |
140 | 140 | } |
@@ -57,8 +57,11 @@ discard block |
||
57 | 57 | $name = preg_replace('#\s+Committee#', '', $name); |
58 | 58 | |
59 | 59 | $date = parse_date(get_http_var('date')); |
60 | - if ($date) $date = '"' . $date['iso'] . '"'; |
|
61 | - else $date = 'date(now())'; |
|
60 | + if ($date) { |
|
61 | + $date = '"' . $date['iso'] . '"'; |
|
62 | + } else { |
|
63 | + $date = 'date(now())'; |
|
64 | + } |
|
62 | 65 | $q = $db->query("select distinct(dept) from moffice |
63 | 66 | where dept like :department |
64 | 67 | and from_date <= $date and $date <= to_date", array( |
@@ -108,8 +111,11 @@ discard block |
||
108 | 111 | $db = new ParlDB; |
109 | 112 | |
110 | 113 | $date = parse_date($date); |
111 | - if ($date) $date = '"' . $date['iso'] . '"'; |
|
112 | - else $date = 'date(now())'; |
|
114 | + if ($date) { |
|
115 | + $date = '"' . $date['iso'] . '"'; |
|
116 | + } else { |
|
117 | + $date = 'date(now())'; |
|
118 | + } |
|
113 | 119 | $q = $db->query("select distinct(dept) from moffice |
114 | 120 | where source = 'chgpages/selctee' |
115 | 121 | and from_date <= $date and $date <= to_date"); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | function api_getComments_start_date($start_date) { |
27 | - $args = array ( |
|
27 | + $args = array( |
|
28 | 28 | 'start_date' => $start_date, |
29 | 29 | 'end_date' => get_http_var('end_date') |
30 | 30 | ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | function api_getComments_search($s) { |
36 | - $args = array ( |
|
36 | + $args = array( |
|
37 | 37 | 's' => $s, |
38 | 38 | 'p' => get_http_var('page'), |
39 | 39 | 'num' => get_http_var('num'), |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | $match = 0; |
27 | 27 | foreach ($methods as $method => $data) { |
28 | 28 | if (strtolower($q_method) == strtolower($method)) { |
29 | - if (isset($data['superuser']) && $data['superuser']) { |
|
29 | + if (isset($data['superuser']) && $data['superuser']) { |
|
30 | 30 | $super_check = api_is_superuser_key($key); |
31 | 31 | if (!$super_check) { |
32 | 32 | if (get_http_var('docs')) { |
33 | - api_front_page(); |
|
33 | + api_front_page(); |
|
34 | 34 | } else { |
35 | - api_error('Invalid API key.'); |
|
36 | - exit; |
|
37 | - } |
|
35 | + api_error('Invalid API key.'); |
|
36 | + exit; |
|
37 | + } |
|
38 | 38 | } |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | api_log_call($key); |
42 | 42 | $match++; |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | '". Possible functions are: ' . |
74 | 74 | join(', ', array_keys($methods)); |
75 | 75 | if (get_http_var('output')) { |
76 | - api_error($msg); |
|
76 | + api_error($msg); |
|
77 | 77 | } else { |
78 | - api_front_page($msg); |
|
78 | + api_front_page($msg); |
|
79 | 79 | } |
80 | 80 | } else { |
81 | 81 | if (get_http_var('docs')) { |
@@ -103,13 +103,15 @@ discard block |
||
103 | 103 | <p> |
104 | 104 | <?php foreach ($methods[$method]['parameters'] as $parameter) { |
105 | 105 | print $parameter . ': <input type="text" name="'.$parameter.'" value="'; |
106 | - if ($val = get_http_var($parameter)) |
|
107 | - print _htmlspecialchars($val); |
|
106 | + if ($val = get_http_var($parameter)) { |
|
107 | + print _htmlspecialchars($val); |
|
108 | + } |
|
108 | 109 | print '" size="30"><br>'; |
109 | 110 | } |
110 | 111 | ?> |
111 | 112 | Output: |
112 | -<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output')=='js' || !get_http_var('output')) print ' checked'?>> |
|
113 | +<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output')=='js' || !get_http_var('output')) { |
|
114 | + print ' checked'?>> |
|
113 | 115 | <label for="output_js">JS</label> |
114 | 116 | <input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output')=='xml') print ' checked'?>> |
115 | 117 | <label for="output_xml">XML</label> |
@@ -124,9 +126,11 @@ discard block |
||
124 | 126 | <?php |
125 | 127 | if ($explorer) { |
126 | 128 | $qs = array(); |
129 | +} |
|
127 | 130 | foreach ($methods[$method]['parameters'] as $parameter) { |
128 | - if (get_http_var($parameter)) |
|
129 | - $qs[] = _htmlspecialchars(rawurlencode($parameter) . '=' . urlencode(get_http_var($parameter))); |
|
131 | + if (get_http_var($parameter)) { |
|
132 | + $qs[] = _htmlspecialchars(rawurlencode($parameter) . '=' . urlencode(get_http_var($parameter))); |
|
133 | + } |
|
130 | 134 | } |
131 | 135 | print '<h4><a name="output"></a>Output</h4>'; |
132 | 136 | print '<p>URL for this: <strong>https://www.theyworkforyou.com/api/'; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | foreach ($data['parameters'] as $parameter) { |
48 | 48 | if ($q_param = trim(get_http_var($parameter))) { |
49 | 49 | $match++; |
50 | - include_once 'api_'. $method . '.php'; |
|
50 | + include_once 'api_' . $method . '.php'; |
|
51 | 51 | api_call_user_func_or_error('api_' . $method . '_' . $parameter, array($q_param), 'API call not yet functional', 'api'); |
52 | 52 | break; |
53 | 53 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | api_error('No parameter provided to function "' . |
58 | 58 | _htmlspecialchars($q_method) . |
59 | 59 | '". Possible choices are: ' . |
60 | - join(', ', $data['parameters']) ); |
|
60 | + join(', ', $data['parameters'])); |
|
61 | 61 | } else { |
62 | - include_once 'api_'. $method . '.php'; |
|
62 | + include_once 'api_' . $method . '.php'; |
|
63 | 63 | api_call_user_func_or_error('api_' . $method, array(), 'API call not yet functional', 'api'); |
64 | 64 | break; |
65 | 65 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $DATA->set_page_metadata($this_page, 'title', "$method function"); |
94 | 94 | $PAGE->page_start(); |
95 | 95 | $PAGE->stripe_start(); |
96 | - include_once 'api_'. $method . '.php'; |
|
96 | + include_once 'api_' . $method . '.php'; |
|
97 | 97 | print '<p align="center"><strong>https://www.theyworkforyou.com/api/' . $method . '</strong></p>'; |
98 | 98 | api_call_user_func_or_error('api_' . $method . '_front', array(), 'No documentation yet', 'html'); |
99 | 99 | if ($method != 'getQuota') { |
@@ -112,20 +112,20 @@ discard block |
||
112 | 112 | <form method="get" action="?#output"> |
113 | 113 | <p> |
114 | 114 | <?php foreach ($methods[$method]['parameters'] as $parameter) { |
115 | - print $parameter . ': <input type="text" name="'.$parameter.'" value="'; |
|
115 | + print $parameter . ': <input type="text" name="' . $parameter . '" value="'; |
|
116 | 116 | if ($val = get_http_var($parameter)) |
117 | 117 | print _htmlspecialchars($val); |
118 | 118 | print '" size="30"><br>'; |
119 | 119 | } |
120 | 120 | ?> |
121 | 121 | Output: |
122 | -<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output')=='js' || !get_http_var('output')) print ' checked'?>> |
|
122 | +<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output') == 'js' || !get_http_var('output')) print ' checked'?>> |
|
123 | 123 | <label for="output_js">JS</label> |
124 | -<input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output')=='xml') print ' checked'?>> |
|
124 | +<input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output') == 'xml') print ' checked'?>> |
|
125 | 125 | <label for="output_xml">XML</label> |
126 | -<input id="output_php" type="radio" name="output" value="php"<?php if (get_http_var('output')=='php') print ' checked'?>> |
|
126 | +<input id="output_php" type="radio" name="output" value="php"<?php if (get_http_var('output') == 'php') print ' checked'?>> |
|
127 | 127 | <label for="output_php">Serialised PHP</label> |
128 | -<input id="output_rabx" type="radio" name="output" value="rabx"<?php if (get_http_var('output')=='rabx') print ' checked'?>> |
|
128 | +<input id="output_rabx" type="radio" name="output" value="rabx"<?php if (get_http_var('output') == 'rabx') print ' checked'?>> |
|
129 | 129 | <label for="output_rabx">RABX</label> |
130 | 130 | |
131 | 131 | <input type="submit" value="Go"> |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | print '<h4><a name="output"></a>Output</h4>'; |
142 | 142 | print '<p>URL for this: <strong>https://www.theyworkforyou.com/api/'; |
143 | - print $method . '?' . join('&', $qs) . '&output='._htmlspecialchars(get_http_var('output')).'</strong></p>'; |
|
143 | + print $method . '?' . join('&', $qs) . '&output=' . _htmlspecialchars(get_http_var('output')) . '</strong></p>'; |
|
144 | 144 | print '<pre>' . _htmlspecialchars($explorer) . '</pre>'; |
145 | 145 | } |
146 | 146 | } |
@@ -1,8 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (isset($term) && $term) { |
3 | 3 | $this_page = 'glossary_item'; |
4 | -} |
|
5 | -else { |
|
4 | +} else { |
|
6 | 5 | $this_page = "glossary"; |
7 | 6 | } |
8 | 7 | |
@@ -50,8 +49,7 @@ discard block |
||
50 | 49 | if ($term) { |
51 | 50 | $DATA->set_page_metadata($this_page, 'title', $term['title'].': Glossary item'); |
52 | 51 | $DATA->set_page_metadata($this_page, 'heading', $term['title']); |
53 | -} |
|
54 | -else { |
|
52 | +} else { |
|
55 | 53 | $DATA->set_page_metadata ($this_page, 'title', $GLOSSARY->current_letter.': Glossary index'); |
56 | 54 | $DATA->set_page_metadata ($this_page, 'heading', 'Glossary index'); |
57 | 55 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | } |
8 | 8 | |
9 | 9 | include_once '../../includes/easyparliament/init.php'; |
10 | -include_once INCLUDESPATH."easyparliament/glossary.php"; |
|
10 | +include_once INCLUDESPATH . "easyparliament/glossary.php"; |
|
11 | 11 | |
12 | 12 | $args = array( |
13 | 13 | 'sort' => "regexp_replace", |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | if ($term) { |
51 | - $DATA->set_page_metadata($this_page, 'title', $term['title'].': Glossary item'); |
|
51 | + $DATA->set_page_metadata($this_page, 'title', $term['title'] . ': Glossary item'); |
|
52 | 52 | $DATA->set_page_metadata($this_page, 'heading', $term['title']); |
53 | 53 | } |
54 | 54 | else { |
55 | - $DATA->set_page_metadata ($this_page, 'title', $GLOSSARY->current_letter.': Glossary index'); |
|
56 | - $DATA->set_page_metadata ($this_page, 'heading', 'Glossary index'); |
|
55 | + $DATA->set_page_metadata($this_page, 'title', $GLOSSARY->current_letter . ': Glossary index'); |
|
56 | + $DATA->set_page_metadata($this_page, 'heading', 'Glossary index'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | $PAGE->page_start(); |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | $URL->update(array("gl" => $GLOSSARY->next_term['glossary_id'])); |
73 | 73 | $next_link = $URL->generate('url'); |
74 | 74 | |
75 | - $nextprev = array ( |
|
76 | - 'next' => array ( |
|
75 | + $nextprev = array( |
|
76 | + 'next' => array( |
|
77 | 77 | 'url' => $next_link, |
78 | 78 | 'title' => 'Next term', |
79 | 79 | 'body' => $GLOSSARY->next_term['title'] |
80 | 80 | ), |
81 | - 'prev' => array ( |
|
81 | + 'prev' => array( |
|
82 | 82 | 'url' => $previous_link, |
83 | 83 | 'title' => 'Previous term', |
84 | 84 | 'body' => $GLOSSARY->previous_term['title'] |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | -$PAGE->stripe_end(array ( |
|
115 | - array ( |
|
114 | +$PAGE->stripe_end(array( |
|
115 | + array( |
|
116 | 116 | 'type' => 'nextprev', |
117 | 117 | 'content' => '' |
118 | 118 | ) |
@@ -96,7 +96,9 @@ discard block |
||
96 | 96 | } |
97 | 97 | continue; |
98 | 98 | } |
99 | - if (substr($r, 0, 8)=='Bill 141') continue; |
|
99 | + if (substr($r, 0, 8)=='Bill 141') { |
|
100 | + continue; |
|
101 | + } |
|
100 | 102 | if (preg_match('#\s+([1-4]?[05])$#', $r, $m)) { |
101 | 103 | if ($line != $m[1]) { |
102 | 104 | print "ERROR! $line $m[1] $r"; |
@@ -224,7 +226,9 @@ discard block |
||
224 | 226 | $insert = isset($m[4]) ? $m[4] : null; |
225 | 227 | unset($amendments[$num]); |
226 | 228 | $bill[$page][$line] = '<del title="'.$num.'">'.$bill[$page][$line].'</del>'; |
227 | - if ($insert) $bill[$page][$line] .= '<ins title="'.$num.'">'.$insert.'</ins>'; |
|
229 | + if ($insert) { |
|
230 | + $bill[$page][$line] .= '<ins title="'.$num.'">'.$insert.'</ins>'; |
|
231 | + } |
|
228 | 232 | } |
229 | 233 | # Page 8, line 24 [Clause 14], at end insert-- `...' |
230 | 234 | if (preg_match('#Page\s+(\d+), line (\d+) \[Clause (\d+)\], (?:at end|after subsection \(\d+\)) insert--\s+`(.*?)\'#s', $amendment, $m)) { |
@@ -302,8 +306,11 @@ discard block |
||
302 | 306 | } |
303 | 307 | if ($finished) { |
304 | 308 | for ($p = $subsubclause['startP']; $p<=$subsubclause['endP']; $p++) { |
305 | - if ($p>$subsubclause['startP']) $starti = 1; |
|
306 | - else $starti = $subsubclause['startL']; |
|
309 | + if ($p>$subsubclause['startP']) { |
|
310 | + $starti = 1; |
|
311 | + } else { |
|
312 | + $starti = $subsubclause['startL']; |
|
313 | + } |
|
307 | 314 | for ($i = $starti; $i<=$subsubclause['endL']; $i++) { # XXX Doesn't really work spanning pages |
308 | 315 | $bill[$p][$i] = '<del title="'.$num.'">' . $bill[$p][$i] . '</del>'; |
309 | 316 | } |
@@ -321,7 +328,9 @@ discard block |
||
321 | 328 | foreach ($clauses[$clause] as $subclause_num => $subclause) { |
322 | 329 | foreach ($subclause as $subsubclause_num => $subsubclause) { |
323 | 330 | if ($subsubclause['endP'] > $page) { $page = $subsubclause['endP']; $line = 0; } |
324 | - if ($subsubclause['endL'] > $line) $line = $subsubclause['endL']; |
|
331 | + if ($subsubclause['endL'] > $line) { |
|
332 | + $line = $subsubclause['endL']; |
|
333 | + } |
|
325 | 334 | } |
326 | 335 | } |
327 | 336 | $bill[$page][$line] .= "<ins title='$num'>$amendment</ins>\n\n"; |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | $this_page = 'bill_index'; |
4 | 4 | include_once '../../../../includes/easyparliament/init.php'; |
5 | -$DATA->set_page_metadata($this_page, 'heading','Legislative and Regulatory Reform Bill'); |
|
5 | +$DATA->set_page_metadata($this_page, 'heading', 'Legislative and Regulatory Reform Bill'); |
|
6 | 6 | $PAGE->page_start(); |
7 | 7 | $PAGE->stripe_start(); |
8 | -$PAGE->block_start(array ('title'=>'House of Commons - Normal Run')); |
|
8 | +$PAGE->block_start(array('title'=>'House of Commons - Normal Run')); |
|
9 | 9 | ?> |
10 | 10 | <ul> |
11 | 11 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | parse_bill('2006141.txt'); |
46 | 46 | $amendments = read_amendments('amendments.txt'); # The amendments, by number |
47 | 47 | parse_amendments(); |
48 | - $out = $title."\n\n"; |
|
48 | + $out = $title . "\n\n"; |
|
49 | 49 | $out .= "Page,Line\n"; |
50 | 50 | foreach ($bill as $page_num => $page) { |
51 | 51 | foreach ($page as $line_num => $line) { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | print '</ul>'; |
60 | 60 | $PAGE->block_end(); |
61 | 61 | $includes = array( |
62 | - array ( |
|
62 | + array( |
|
63 | 63 | 'type' => 'include', |
64 | 64 | 'content' => 'bills_intro' |
65 | 65 | ), |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $intitle = true; |
78 | 78 | $title = ''; |
79 | 79 | foreach ($f as $r) { |
80 | - if ($line<1) { |
|
80 | + if ($line < 1) { |
|
81 | 81 | $line++; |
82 | 82 | continue; |
83 | 83 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | continue; |
98 | 98 | } |
99 | - if (substr($r, 0, 8)=='Bill 141') continue; |
|
99 | + if (substr($r, 0, 8) == 'Bill 141') continue; |
|
100 | 100 | if (preg_match('#\s+([1-4]?[05])$#', $r, $m)) { |
101 | 101 | if ($line != $m[1]) { |
102 | 102 | print "ERROR! $line $m[1] $r"; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | if ($r == "\n") { |
142 | 142 | continue; |
143 | 143 | } |
144 | - if ($line<1) { |
|
144 | + if ($line < 1) { |
|
145 | 145 | $line++; |
146 | 146 | continue; |
147 | 147 | } |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | $number = $m[1]; |
156 | 156 | $amendments[$number] = ''; |
157 | 157 | } elseif (preg_match('#To move the following Clause#', $r)) { |
158 | - preg_match('#\n(.*?)$#', $amendments[$number-1], $m); |
|
159 | - $amendments[$number-1] = preg_replace('#\n(.*?)$#', '', $amendments[$number-1]); |
|
158 | + preg_match('#\n(.*?)$#', $amendments[$number - 1], $m); |
|
159 | + $amendments[$number - 1] = preg_replace('#\n(.*?)$#', '', $amendments[$number - 1]); |
|
160 | 160 | $amendments[$number] .= '*' . trim($m[1]) . "*\n$r"; |
161 | 161 | } else { |
162 | 162 | $amendments[$number] .= $r; |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | $page = $m[1]; $line = $m[2]; $clause = $m[3]; |
181 | 181 | $from_text = $m[4]; $end_line = $m[5]; $insert = $m[6]; |
182 | 182 | unset($amendments[$num]); |
183 | - $bill[$page][$line] = str_replace($from_text, "$from_text <del title='$num'>", $bill[$page][$line]) . '</del><ins title="'.$num.'">' . $insert . '</ins>'; |
|
184 | - for ($i=$line+1; $i<=$end_line; $i++) { |
|
185 | - $bill[$page][$i] = '<del title="'.$num.'">' . $bill[$page][$i] . '</del>'; |
|
183 | + $bill[$page][$line] = str_replace($from_text, "$from_text <del title='$num'>", $bill[$page][$line]) . '</del><ins title="' . $num . '">' . $insert . '</ins>'; |
|
184 | + for ($i = $line + 1; $i <= $end_line; $i++) { |
|
185 | + $bill[$page][$i] = '<del title="' . $num . '">' . $bill[$page][$i] . '</del>'; |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | # Page 4, line 9 [Clause 6], leave out from `under' to `creating' and insert `this Part making provision' |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | $insert = $m[7]; |
200 | 200 | unset($amendments[$num]); |
201 | 201 | $bill[$page][$from_line] = str_replace($from_text, "$from_text <del title='$num'>", $bill[$page][$from_line]) . '</del>'; |
202 | - for ($i=$from_line+1; $i<$to_line; $i++) { |
|
203 | - $bill[$page][$i] = '<del title="'.$num.'">' . $bill[$page][$i] . '</del>'; |
|
202 | + for ($i = $from_line + 1; $i < $to_line; $i++) { |
|
203 | + $bill[$page][$i] = '<del title="' . $num . '">' . $bill[$page][$i] . '</del>'; |
|
204 | 204 | } |
205 | - $bill[$page][$to_line] = '<del title="'.$num.'">' . str_replace($to_text, "</del><ins title='$num'>$insert</ins> $to_text", $bill[$page][$to_line]); |
|
205 | + $bill[$page][$to_line] = '<del title="' . $num . '">' . str_replace($to_text, "</del><ins title='$num'>$insert</ins> $to_text", $bill[$page][$to_line]); |
|
206 | 206 | } |
207 | 207 | # Page 3, line 13 [Clause 4], leave out from beginning to `confer' and insert `An order under this Part may not make provision to' |
208 | 208 | if (preg_match('#Page\s+(\d+), line (\d+) \[Clause (\d+)\], leave out from beginning to `(.*?)\' and insert `(.*?)\'#s', $amendment, $m)) { |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | $page = $m[1]; $line = $m[3]; $clause = $m[2]; |
224 | 224 | $insert = isset($m[4]) ? $m[4] : null; |
225 | 225 | unset($amendments[$num]); |
226 | - $bill[$page][$line] = '<del title="'.$num.'">'.$bill[$page][$line].'</del>'; |
|
227 | - if ($insert) $bill[$page][$line] .= '<ins title="'.$num.'">'.$insert.'</ins>'; |
|
226 | + $bill[$page][$line] = '<del title="' . $num . '">' . $bill[$page][$line] . '</del>'; |
|
227 | + if ($insert) $bill[$page][$line] .= '<ins title="' . $num . '">' . $insert . '</ins>'; |
|
228 | 228 | } |
229 | 229 | # Page 8, line 24 [Clause 14], at end insert-- `...' |
230 | 230 | if (preg_match('#Page\s+(\d+), line (\d+) \[Clause (\d+)\], (?:at end|after subsection \(\d+\)) insert--\s+`(.*?)\'#s', $amendment, $m)) { |
231 | 231 | $page = $m[1]; $line = $m[2]; $clause = $m[3]; |
232 | 232 | $insert = $m[4]; |
233 | 233 | unset($amendments[$num]); |
234 | - $bill[$page][$line] .= '<ins title="'.$num.'">'.$insert.'</ins>'; |
|
234 | + $bill[$page][$line] .= '<ins title="' . $num . '">' . $insert . '</ins>'; |
|
235 | 235 | } |
236 | 236 | # Title, line 1, leave out `reforming legislation' and insert `...' |
237 | 237 | if (preg_match('#Title, line.*?, leave out `(.*?)\' and insert `(.*?)\'#s', $amendment, $m)) { |
@@ -247,14 +247,14 @@ discard block |
||
247 | 247 | foreach ($clauses[$clause] as $subclause_num => $subclause) { |
248 | 248 | foreach ($subclause as $subsubclause_num => $subsubclause) { |
249 | 249 | $startP = $subsubclause['startP']; |
250 | - if ($startP==$page && $subsubclause['startL']==$line) { |
|
250 | + if ($startP == $page && $subsubclause['startL'] == $line) { |
|
251 | 251 | if ($startP == $subsubclause['endP']) { |
252 | 252 | unset($amendments[$num]); |
253 | - for ($i = $subsubclause['startL']; $i<=$subsubclause['endL']; $i++) { |
|
254 | - $bill[$page][$i] = '<del title="'.$num.'">' . $bill[$page][$i] . '</del>'; |
|
253 | + for ($i = $subsubclause['startL']; $i <= $subsubclause['endL']; $i++) { |
|
254 | + $bill[$page][$i] = '<del title="' . $num . '">' . $bill[$page][$i] . '</del>'; |
|
255 | 255 | } |
256 | 256 | if ($insert) { |
257 | - $bill[$page][$i-1] .= "<ins title='$num'>$insert</ins>"; |
|
257 | + $bill[$page][$i - 1] .= "<ins title='$num'>$insert</ins>"; |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
@@ -270,21 +270,21 @@ discard block |
||
270 | 270 | foreach ($clauses[$clause] as $subclause_num => $subclause) { |
271 | 271 | foreach ($subclause as $subsubclause_num => $subsubclause) { |
272 | 272 | $startP = $subsubclause['startP']; |
273 | - if ($startP==$page && $subsubclause['startL']==$line) { |
|
273 | + if ($startP == $page && $subsubclause['startL'] == $line) { |
|
274 | 274 | if ($startP == $subsubclause['endP']) { |
275 | 275 | unset($amendments[$num]); |
276 | 276 | $finished = true; |
277 | 277 | } |
278 | 278 | } |
279 | 279 | if ($finished) { |
280 | - for ($i = $subsubclause['startL']; $i<=$subsubclause['endL']; $i++) { |
|
281 | - $bill[$page][$i] = '<del title="'.$num.'">' . $bill[$page][$i] . '</del>'; |
|
280 | + for ($i = $subsubclause['startL']; $i <= $subsubclause['endL']; $i++) { |
|
281 | + $bill[$page][$i] = '<del title="' . $num . '">' . $bill[$page][$i] . '</del>'; |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | } |
285 | 285 | if ($finished) { |
286 | 286 | if ($insert) { |
287 | - $bill[$page][$i-1] .= "<ins title='$num'>$insert</ins>"; |
|
287 | + $bill[$page][$i - 1] .= "<ins title='$num'>$insert</ins>"; |
|
288 | 288 | } |
289 | 289 | break; |
290 | 290 | } |
@@ -296,16 +296,16 @@ discard block |
||
296 | 296 | $finished = false; |
297 | 297 | foreach ($clauses[$clause] as $subclause_num => $subclause) { |
298 | 298 | foreach ($subclause as $subsubclause_num => $subsubclause) { |
299 | - if ($subsubclause['startP']==$page && $subsubclause['startL']==$line) { |
|
299 | + if ($subsubclause['startP'] == $page && $subsubclause['startL'] == $line) { |
|
300 | 300 | unset($amendments[$num]); |
301 | 301 | $finished = true; |
302 | 302 | } |
303 | 303 | if ($finished) { |
304 | - for ($p = $subsubclause['startP']; $p<=$subsubclause['endP']; $p++) { |
|
305 | - if ($p>$subsubclause['startP']) $starti = 1; |
|
304 | + for ($p = $subsubclause['startP']; $p <= $subsubclause['endP']; $p++) { |
|
305 | + if ($p > $subsubclause['startP']) $starti = 1; |
|
306 | 306 | else $starti = $subsubclause['startL']; |
307 | - for ($i = $starti; $i<=$subsubclause['endL']; $i++) { # XXX Doesn't really work spanning pages |
|
308 | - $bill[$p][$i] = '<del title="'.$num.'">' . $bill[$p][$i] . '</del>'; |
|
307 | + for ($i = $starti; $i <= $subsubclause['endL']; $i++) { # XXX Doesn't really work spanning pages |
|
308 | + $bill[$p][$i] = '<del title="' . $num . '">' . $bill[$p][$i] . '</del>'; |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | } |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | |
3 | 3 | $this_page = 'bill_index'; |
4 | 4 | include_once '../../../../includes/easyparliament/init.php'; |
5 | -$DATA->set_page_metadata($this_page, 'heading','Identity Cards Act 2006'); |
|
5 | +$DATA->set_page_metadata($this_page, 'heading', 'Identity Cards Act 2006'); |
|
6 | 6 | |
7 | 7 | $PAGE->page_start(); |
8 | 8 | $PAGE->stripe_start(); |
9 | 9 | |
10 | -$PAGE->block_start(array ('title'=>'House of Commons - Normal Run')); |
|
10 | +$PAGE->block_start(array('title'=>'House of Commons - Normal Run')); |
|
11 | 11 | ?> |
12 | 12 | <ul> <li>Back on 25th May 2005, a bill was introduced: the <a |
13 | 13 | href="http://www.publications.parliament.uk/pa/cm200506/cmbills/009/2006009.htm">Identity |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | <?php |
34 | 34 | $PAGE->block_end(); |
35 | -$PAGE->block_start(array ('title'=>'House of Lords - Normal Run')); |
|
35 | +$PAGE->block_start(array('title'=>'House of Lords - Normal Run')); |
|
36 | 36 | ?> |
37 | 37 | |
38 | 38 | <ul> |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | <?php |
51 | 51 | $PAGE->block_end(); |
52 | -$PAGE->block_start(array ('title'=>'Ping Pong')); |
|
52 | +$PAGE->block_start(array('title'=>'Ping Pong')); |
|
53 | 53 | ?> |
54 | 54 | |
55 | 55 | <ul> |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $PAGE->block_end(); |
95 | 95 | |
96 | 96 | $includes = array( |
97 | - array ( |
|
97 | + array( |
|
98 | 98 | 'type' => 'include', |
99 | 99 | 'content' => 'bills_intro' |
100 | 100 | ), |
@@ -22,26 +22,26 @@ discard block |
||
22 | 22 | $toemail = ''; |
23 | 23 | $template = 'alert_new_mp'; |
24 | 24 | for ($k=1; $k<$argc; $k++) { |
25 | - if ($argv[$k] == '--nomail') |
|
26 | - $nomail = true; |
|
27 | - if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
|
28 | - $onlyemail = $m[1]; |
|
29 | - if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) |
|
30 | - $fromemail = $m[1]; |
|
31 | - if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) |
|
32 | - $toemail = $m[1]; |
|
25 | + if ($argv[$k] == '--nomail') |
|
26 | + $nomail = true; |
|
27 | + if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
|
28 | + $onlyemail = $m[1]; |
|
29 | + if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) |
|
30 | + $fromemail = $m[1]; |
|
31 | + if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) |
|
32 | + $toemail = $m[1]; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | if (DEVSITE) |
36 | - $nomail = true; |
|
36 | + $nomail = true; |
|
37 | 37 | |
38 | 38 | # Change this to the end date |
39 | 39 | $END_DATE = '2017-05-03'; |
40 | 40 | |
41 | 41 | if ($nomail) mlog("NOT SENDING EMAIL\n"); |
42 | 42 | if (($fromemail && $onlyemail) || ($toemail && $onlyemail)) { |
43 | - mlog("Can't have both from/to and only!\n"); |
|
44 | - exit; |
|
43 | + mlog("Can't have both from/to and only!\n"); |
|
44 | + exit; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $active = 0; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | $members = array(); |
67 | 67 | $start_time = time(); |
68 | 68 | foreach ($alertdata as $alertitem) { |
69 | - $active++; |
|
70 | - $email = $alertitem['email']; |
|
69 | + $active++; |
|
70 | + $email = $alertitem['email']; |
|
71 | 71 | if ($onlyemail && $email != $onlyemail) continue; |
72 | 72 | if ($fromemail && strtolower($email) == $fromemail) $fromflag = true; |
73 | 73 | if ($fromemail && !$fromflag) continue; |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | |
144 | 144 | $sss = "Active alerts: $active\nEmail lookups: $registered registered, $unregistered unregistered\nQuery lookups: $queries\nSent emails: $sentemails\n"; |
145 | 145 | if ($globalsuccess) { |
146 | - $sss .= 'Everything went swimmingly, in '; |
|
146 | + $sss .= 'Everything went swimmingly, in '; |
|
147 | 147 | } else { |
148 | - $sss .= 'Something went wrong! Total time: '; |
|
148 | + $sss .= 'Something went wrong! Total time: '; |
|
149 | 149 | } |
150 | 150 | $sss .= (getmicrotime()-$global_start)."\n\n"; |
151 | 151 | mlog($sss); |
@@ -155,7 +155,7 @@ |
||
155 | 155 | global $globalsuccess, $sentemails, $nomail, $start_time; |
156 | 156 | |
157 | 157 | $sentemails++; |
158 | - mlog("SEND $sentemails : Sending email to $current[email] ... "); |
|
158 | + mlog("send $sentemails : Sending email to $current[email] ... "); |
|
159 | 159 | $d = array('to' => $current['email'], 'template' => $template); |
160 | 160 | $m = array( |
161 | 161 | 'DATA' => join("\n", $data), |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $fromflag = false; |
22 | 22 | $toemail = ''; |
23 | 23 | $template = 'alert_new_mp'; |
24 | -for ($k=1; $k<$argc; $k++) { |
|
24 | +for ($k = 1; $k < $argc; $k++) { |
|
25 | 25 | if ($argv[$k] == '--nomail') |
26 | 26 | $nomail = true; |
27 | 27 | if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | // skip if they didn't lose their westminster seat in the most recent election |
92 | 92 | if ($member->left_house(1)['date'] != $END_DATE) continue; |
93 | 93 | |
94 | - if ( !isset($cons[$member->constituency]) ) { |
|
94 | + if (!isset($cons[$member->constituency])) { |
|
95 | 95 | $cons_member = new MEMBER(array('constituency' => $member->constituency, 'house' => 1)); |
96 | - if ( !$cons_member ) { |
|
96 | + if (!$cons_member) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | $cons[$member->constituency] = $cons_member; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | // these should never happen but let's just be sure |
105 | - if ( $cons_member->person_id == $member->person_id ) continue; |
|
105 | + if ($cons_member->person_id == $member->person_id) continue; |
|
106 | 106 | if (!$cons_member->current_member_anywhere()) continue; |
107 | 107 | |
108 | 108 | if ($email != $current['email']) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $user_id = 0; |
123 | 123 | $unregistered++; |
124 | 124 | } |
125 | - mlog("\nEMAIL: $email, uid $user_id; memory usage : ".memory_get_usage()."\n"); |
|
125 | + mlog("\nEMAIL: $email, uid $user_id; memory usage : " . memory_get_usage() . "\n"); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $lh = $member->left_house(); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } else { |
148 | 148 | $sss .= 'Something went wrong! Total time: '; |
149 | 149 | } |
150 | -$sss .= (getmicrotime()-$global_start)."\n\n"; |
|
150 | +$sss .= (getmicrotime() - $global_start) . "\n\n"; |
|
151 | 151 | mlog($sss); |
152 | 152 | mlog(date('r') . "\n"); |
153 | 153 | |
@@ -160,18 +160,18 @@ discard block |
||
160 | 160 | $m = array( |
161 | 161 | 'DATA' => join("\n", $data), |
162 | 162 | 'CHANGE' => join("\n", $change), |
163 | - 'ALERT_IS' => count($data)==1 ? 'alert is' : 'alerts are', |
|
164 | - 'MPS' => count($data)==1 ? 'This MP' : 'These MPs', |
|
165 | - 'MPS2' => count($data)==1 ? 'MP' : 'MPs', |
|
166 | - 'ALERTS' => count($data)==1 ? 'an alert' : 'some alerts', |
|
167 | - 'ALERTS2' => count($data)==1 ? 'alert' : 'alerts', |
|
168 | - 'LINKS' => count($data)==1 ? 'link' : 'links', |
|
163 | + 'ALERT_IS' => count($data) == 1 ? 'alert is' : 'alerts are', |
|
164 | + 'MPS' => count($data) == 1 ? 'This MP' : 'These MPs', |
|
165 | + 'MPS2' => count($data) == 1 ? 'MP' : 'MPs', |
|
166 | + 'ALERTS' => count($data) == 1 ? 'an alert' : 'some alerts', |
|
167 | + 'ALERTS2' => count($data) == 1 ? 'alert' : 'alerts', |
|
168 | + 'LINKS' => count($data) == 1 ? 'link' : 'links', |
|
169 | 169 | ); |
170 | 170 | if (!$nomail) { |
171 | 171 | $success = send_template_email($d, $m, true); |
172 | 172 | mlog("sent ... "); |
173 | 173 | # sleep if time between sending mails is less than a certain number of seconds on average |
174 | - if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than |
|
174 | + if (((time() - $start_time) / $sentemails) < 0.5) { # number of seconds per mail not to be quicker than |
|
175 | 175 | mlog("pausing ... "); |
176 | 176 | sleep(1); |
177 | 177 | } |
@@ -22,23 +22,30 @@ discard block |
||
22 | 22 | $toemail = ''; |
23 | 23 | $template = 'alert_new_mp'; |
24 | 24 | for ($k=1; $k<$argc; $k++) { |
25 | - if ($argv[$k] == '--nomail') |
|
26 | - $nomail = true; |
|
27 | - if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
|
28 | - $onlyemail = $m[1]; |
|
29 | - if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) |
|
30 | - $fromemail = $m[1]; |
|
31 | - if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) |
|
32 | - $toemail = $m[1]; |
|
33 | -} |
|
34 | - |
|
35 | -if (DEVSITE) |
|
25 | + if ($argv[$k] == '--nomail') { |
|
26 | + $nomail = true; |
|
27 | + } |
|
28 | + if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) { |
|
29 | + $onlyemail = $m[1]; |
|
30 | + } |
|
31 | + if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) { |
|
32 | + $fromemail = $m[1]; |
|
33 | + } |
|
34 | + if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) { |
|
35 | + $toemail = $m[1]; |
|
36 | + } |
|
37 | + } |
|
38 | + |
|
39 | +if (DEVSITE) { |
|
36 | 40 | $nomail = true; |
41 | +} |
|
37 | 42 | |
38 | 43 | # Change this to the end date |
39 | 44 | $END_DATE = '2017-05-03'; |
40 | 45 | |
41 | -if ($nomail) mlog("NOT SENDING EMAIL\n"); |
|
46 | +if ($nomail) { |
|
47 | + mlog("NOT SENDING EMAIL\n"); |
|
48 | +} |
|
42 | 49 | if (($fromemail && $onlyemail) || ($toemail && $onlyemail)) { |
43 | 50 | mlog("Can't have both from/to and only!\n"); |
44 | 51 | exit; |
@@ -68,14 +75,24 @@ discard block |
||
68 | 75 | foreach ($alertdata as $alertitem) { |
69 | 76 | $active++; |
70 | 77 | $email = $alertitem['email']; |
71 | - if ($onlyemail && $email != $onlyemail) continue; |
|
72 | - if ($fromemail && strtolower($email) == $fromemail) $fromflag = true; |
|
73 | - if ($fromemail && !$fromflag) continue; |
|
74 | - if ($toemail && strtolower($email) >= $toemail) continue; |
|
78 | + if ($onlyemail && $email != $onlyemail) { |
|
79 | + continue; |
|
80 | + } |
|
81 | + if ($fromemail && strtolower($email) == $fromemail) { |
|
82 | + $fromflag = true; |
|
83 | + } |
|
84 | + if ($fromemail && !$fromflag) { |
|
85 | + continue; |
|
86 | + } |
|
87 | + if ($toemail && strtolower($email) >= $toemail) { |
|
88 | + continue; |
|
89 | + } |
|
75 | 90 | $criteria_raw = $alertitem['criteria']; |
76 | 91 | |
77 | 92 | // we only care about alerts for people speaking |
78 | - if (!strstr($criteria_raw, 'speaker:')) continue; |
|
93 | + if (!strstr($criteria_raw, 'speaker:')) { |
|
94 | + continue; |
|
95 | + } |
|
79 | 96 | |
80 | 97 | preg_match('#speaker:(\d+)#', $criteria_raw, $m); |
81 | 98 | $person_id = $m[1]; |
@@ -86,10 +103,14 @@ discard block |
||
86 | 103 | $member = $members[$person_id]; |
87 | 104 | |
88 | 105 | // if they're still elected then don't send the email |
89 | - if ($member->current_member_anywhere()) continue; |
|
106 | + if ($member->current_member_anywhere()) { |
|
107 | + continue; |
|
108 | + } |
|
90 | 109 | |
91 | 110 | // skip if they didn't lose their westminster seat in the most recent election |
92 | - if ($member->left_house(1)['date'] != $END_DATE) continue; |
|
111 | + if ($member->left_house(1)['date'] != $END_DATE) { |
|
112 | + continue; |
|
113 | + } |
|
93 | 114 | |
94 | 115 | if ( !isset($cons[$member->constituency]) ) { |
95 | 116 | $cons_member = new MEMBER(array('constituency' => $member->constituency, 'house' => 1)); |
@@ -102,8 +123,12 @@ discard block |
||
102 | 123 | } |
103 | 124 | |
104 | 125 | // these should never happen but let's just be sure |
105 | - if ( $cons_member->person_id == $member->person_id ) continue; |
|
106 | - if (!$cons_member->current_member_anywhere()) continue; |
|
126 | + if ( $cons_member->person_id == $member->person_id ) { |
|
127 | + continue; |
|
128 | + } |
|
129 | + if (!$cons_member->current_member_anywhere()) { |
|
130 | + continue; |
|
131 | + } |
|
107 | 132 | |
108 | 133 | if ($email != $current['email']) { |
109 | 134 | if ($email_text && $change_text) { |
@@ -171,7 +196,8 @@ discard block |
||
171 | 196 | $success = send_template_email($d, $m, true); |
172 | 197 | mlog("sent ... "); |
173 | 198 | # sleep if time between sending mails is less than a certain number of seconds on average |
174 | - if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than |
|
199 | + if (((time() - $start_time) / $sentemails) < 0.5 ) { |
|
200 | +# number of seconds per mail not to be quicker than |
|
175 | 201 | mlog("pausing ... "); |
176 | 202 | sleep(1); |
177 | 203 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | # Done directly as storing everything in an array as $db->query() does runs out of memory, unsurprisingly |
12 | 12 | $q = mysql_query( |
13 | - 'select section.body, gid, yes_votes, no_votes |
|
13 | + 'select section.body, gid, yes_votes, no_votes |
|
14 | 14 | from hansard |
15 | 15 | inner join epobject as section on hansard.section_id = section.epobject_id |
16 | 16 | left join anonvotes on hansard.epobject_id = anonvotes.epobject_id |
@@ -24,34 +24,34 @@ discard block |
||
24 | 24 | |
25 | 25 | $votes = array(); |
26 | 26 | while ($row = mysql_fetch_assoc($q)) { |
27 | - $dept = $row['body']; |
|
28 | - if (!isset($votes[$dept])) $votes[$dept] = array( |
|
29 | - 'verymoreyes'=>0, 'moreyes'=>0, 'verymoreno'=>0, 'moreno'=>0, 'same'=>0, 'none'=>0 |
|
30 | - ); |
|
31 | - $yes = $row['yes_votes']; |
|
32 | - $no = $row['no_votes']; |
|
33 | - $gid = $row['gid']; |
|
34 | - if (is_null($yes)) { |
|
35 | - $votes[$dept]['none']++; |
|
36 | - } else { |
|
37 | - if ($no > $yes+10) { |
|
38 | - $votes[$dept]['verymoreno']++; |
|
39 | - } elseif ($no > $yes) { |
|
40 | - $votes[$dept]['moreno']++; |
|
41 | - } elseif ($no + 10 < $yes) { |
|
42 | - $votes[$dept]['verymoreyes']++; |
|
43 | - } elseif ($no < $yes) { |
|
44 | - $votes[$dept]['moreyes']++; |
|
45 | - } else { |
|
46 | - $votes[$dept]['same']++; |
|
47 | - } |
|
48 | - } |
|
27 | + $dept = $row['body']; |
|
28 | + if (!isset($votes[$dept])) $votes[$dept] = array( |
|
29 | + 'verymoreyes'=>0, 'moreyes'=>0, 'verymoreno'=>0, 'moreno'=>0, 'same'=>0, 'none'=>0 |
|
30 | + ); |
|
31 | + $yes = $row['yes_votes']; |
|
32 | + $no = $row['no_votes']; |
|
33 | + $gid = $row['gid']; |
|
34 | + if (is_null($yes)) { |
|
35 | + $votes[$dept]['none']++; |
|
36 | + } else { |
|
37 | + if ($no > $yes+10) { |
|
38 | + $votes[$dept]['verymoreno']++; |
|
39 | + } elseif ($no > $yes) { |
|
40 | + $votes[$dept]['moreno']++; |
|
41 | + } elseif ($no + 10 < $yes) { |
|
42 | + $votes[$dept]['verymoreyes']++; |
|
43 | + } elseif ($no < $yes) { |
|
44 | + $votes[$dept]['moreyes']++; |
|
45 | + } else { |
|
46 | + $votes[$dept]['same']++; |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | print "Department,11+ more yes votes than no,1-10 more yes votes than no,11+ more no votes than yes,1-10 more no votes than yes,Same votes yes/no,No votes\n"; |
52 | 52 | foreach ($votes as $dept => $v) { |
53 | - #if (!$v['moreyes'] && !$v['moreno'] && !$v['same']) continue; |
|
54 | - if (strstr($dept, ',')) |
|
55 | - $dept = "\"$dept\""; |
|
56 | - print "$dept,$v[verymoreyes],$v[moreyes],$v[verymoreno],$v[moreno],$v[same],$v[none]\n"; |
|
53 | + #if (!$v['moreyes'] && !$v['moreno'] && !$v['same']) continue; |
|
54 | + if (strstr($dept, ',')) |
|
55 | + $dept = "\"$dept\""; |
|
56 | + print "$dept,$v[verymoreyes],$v[moreyes],$v[verymoreno],$v[moreno],$v[same],$v[none]\n"; |
|
57 | 57 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | if (is_null($yes)) { |
35 | 35 | $votes[$dept]['none']++; |
36 | 36 | } else { |
37 | - if ($no > $yes+10) { |
|
37 | + if ($no > $yes + 10) { |
|
38 | 38 | $votes[$dept]['verymoreno']++; |
39 | 39 | } elseif ($no > $yes) { |
40 | 40 | $votes[$dept]['moreno']++; |
@@ -25,9 +25,11 @@ discard block |
||
25 | 25 | $votes = array(); |
26 | 26 | while ($row = mysql_fetch_assoc($q)) { |
27 | 27 | $dept = $row['body']; |
28 | - if (!isset($votes[$dept])) $votes[$dept] = array( |
|
28 | + if (!isset($votes[$dept])) { |
|
29 | + $votes[$dept] = array( |
|
29 | 30 | 'verymoreyes'=>0, 'moreyes'=>0, 'verymoreno'=>0, 'moreno'=>0, 'same'=>0, 'none'=>0 |
30 | 31 | ); |
32 | + } |
|
31 | 33 | $yes = $row['yes_votes']; |
32 | 34 | $no = $row['no_votes']; |
33 | 35 | $gid = $row['gid']; |
@@ -51,7 +53,8 @@ discard block |
||
51 | 53 | print "Department,11+ more yes votes than no,1-10 more yes votes than no,11+ more no votes than yes,1-10 more no votes than yes,Same votes yes/no,No votes\n"; |
52 | 54 | foreach ($votes as $dept => $v) { |
53 | 55 | #if (!$v['moreyes'] && !$v['moreno'] && !$v['same']) continue; |
54 | - if (strstr($dept, ',')) |
|
55 | - $dept = "\"$dept\""; |
|
56 | + if (strstr($dept, ',')) { |
|
57 | + $dept = "\"$dept\""; |
|
58 | + } |
|
56 | 59 | print "$dept,$v[verymoreyes],$v[moreyes],$v[verymoreno],$v[moreno],$v[same],$v[none]\n"; |
57 | 60 | } |