@@ -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 | } |
@@ -38,9 +38,13 @@ discard block |
||
38 | 38 | foreach ($keys as $keyarr) { |
39 | 39 | list($key, $commercial, $created, $reason, $estimated_usage) = $keyarr; |
40 | 40 | echo '<li><span style="font-size:200%">' . $key . '</span><br><span style="color: #666666;">'; |
41 | - if ($commercial==1) echo 'Commercial key,'; |
|
42 | - elseif ($commercial==-1) echo 'Key'; |
|
43 | - else echo 'Non-commercial key,'; |
|
41 | + if ($commercial==1) { |
|
42 | + echo 'Commercial key,'; |
|
43 | + } elseif ($commercial==-1) { |
|
44 | + echo 'Key'; |
|
45 | + } else { |
|
46 | + echo 'Non-commercial key,'; |
|
47 | + } |
|
44 | 48 | echo ' created ', $created, '; ', $reason, '; estimated usage ', $estimated_usage; |
45 | 49 | echo '</span><br><em>Usage statistics</em>: '; |
46 | 50 | $q = $db->query('SELECT count(*) as count FROM api_stats WHERE api_key="' . $key . '" AND query_time > NOW() - interval 1 day'); |
@@ -75,7 +79,9 @@ discard block |
||
75 | 79 | global $THEUSER; |
76 | 80 | $key = auth_ab64_encode(urandom_bytes(16)); |
77 | 81 | $db = new ParlDB; |
78 | - if ($commercial=='') $commercial = 0; |
|
82 | + if ($commercial=='') { |
|
83 | + $commercial = 0; |
|
84 | + } |
|
79 | 85 | $db->query('INSERT INTO api_key (user_id, api_key, commercial, created, reason, estimated_usage) VALUES |
80 | 86 | (:user_id, :key, :commercial, NOW(), :reason, :estimated_usage)', array( |
81 | 87 | ':user_id' => $THEUSER->user_id(), |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | if (get_http_var('create_key') && get_http_var('reason')) { |
22 | 22 | $estimated_usage = (int) get_http_var('estimated_usage'); |
23 | 23 | $commercial = get_http_var('commercial'); |
24 | - create_key($commercial, get_http_var('reason'), $estimated_usage); |
|
24 | + create_key($commercial, get_http_var('reason'), $estimated_usage); |
|
25 | 25 | if ($commercial == '1' || $estimated_usage > 50000) { |
26 | 26 | echo '<p><strong>It looks like your usage may fall outside of our free-of-charge bracket: if that\'s the case, this key might get blocked, so we\'d advise you to email us at <a href="[email protected]">[email protected]</a> to discuss licensing options.</strong></p>'; |
27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $db = new ParlDB; |
30 | 30 | $q = $db->query('SELECT api_key, commercial, created, reason, estimated_usage FROM api_key WHERE user_id=' . $THEUSER->user_id()); |
31 | 31 | $keys = array(); |
32 | - for ($i=0; $i<$q->rows(); $i++) { |
|
32 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
33 | 33 | $keys[] = array($q->field($i, 'api_key'), $q->field($i, 'commercial'), $q->field($i, 'created'), $q->field($i, 'reason'), $q->field($i, 'estimated_usage')); |
34 | 34 | } |
35 | 35 | if ($keys) { |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | foreach ($keys as $keyarr) { |
39 | 39 | list($key, $commercial, $created, $reason, $estimated_usage) = $keyarr; |
40 | 40 | echo '<li><span style="font-size:200%">' . $key . '</span><br><span style="color: #666666;">'; |
41 | - if ($commercial==1) echo 'Commercial key,'; |
|
42 | - elseif ($commercial==-1) echo 'Key'; |
|
41 | + if ($commercial == 1) echo 'Commercial key,'; |
|
42 | + elseif ($commercial == -1) echo 'Key'; |
|
43 | 43 | else echo 'Non-commercial key,'; |
44 | 44 | echo ' created ', $created, '; ', $reason, '; estimated usage ', $estimated_usage; |
45 | 45 | echo '</span><br><em>Usage statistics</em>: '; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | global $THEUSER; |
76 | 76 | $key = auth_ab64_encode(urandom_bytes(16)); |
77 | 77 | $db = new ParlDB; |
78 | - if ($commercial=='') $commercial = 0; |
|
78 | + if ($commercial == '') $commercial = 0; |
|
79 | 79 | $db->query('INSERT INTO api_key (user_id, api_key, commercial, created, reason, estimated_usage) VALUES |
80 | 80 | (:user_id, :key, :commercial, NOW(), :reason, :estimated_usage)', array( |
81 | 81 | ':user_id' => $THEUSER->user_id(), |
@@ -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"); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | )); |
67 | 67 | if ($q->rows() > 1) { |
68 | 68 | # More than one committee matches |
69 | - for ($i=0; $i<$q->rows(); $i++) { |
|
69 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
70 | 70 | $output['committees'][] = array( |
71 | 71 | 'name' => $q->field($i, 'dept') |
72 | 72 | ); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | if ($q->rows()) { |
86 | 86 | $output = array(); |
87 | 87 | $output['committee'] = $q->field(0, 'dept'); |
88 | - for ($i=0; $i<$q->rows(); $i++) { |
|
88 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
89 | 89 | $member = array( |
90 | 90 | 'person_id' => $q->field($i, 'person'), |
91 | 91 | 'name' => $q->field($i, 'given_name') . ' ' . $q->field($i, 'family_name'), |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | where source = 'chgpages/selctee' |
115 | 115 | and from_date <= $date and $date <= to_date"); |
116 | 116 | if ($q->rows()) { |
117 | - for ($i=0; $i<$q->rows(); $i++) { |
|
117 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
118 | 118 | $output['committees'][] = array( |
119 | 119 | 'name' => $q->field($i, 'dept') |
120 | 120 | ); |
@@ -75,22 +75,25 @@ |
||
75 | 75 | $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url = :url order by gid limit 1', array( |
76 | 76 | ':url' => $url |
77 | 77 | )); |
78 | - if ($q->rows()) |
|
79 | - return api_converturl_url_output($q); |
|
78 | + if ($q->rows()) { |
|
79 | + return api_converturl_url_output($q); |
|
80 | + } |
|
80 | 81 | |
81 | 82 | $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array( |
82 | 83 | ':url' => $url_nohash . '%' |
83 | 84 | )); |
84 | - if ($q->rows()) |
|
85 | - return api_converturl_url_output($q); |
|
85 | + if ($q->rows()) { |
|
86 | + return api_converturl_url_output($q); |
|
87 | + } |
|
86 | 88 | |
87 | 89 | $url_bound = str_replace('cmhansrd/cm', 'cmhansrd/vo', $url_nohash); |
88 | 90 | if ($url_bound != $url_nohash) { |
89 | 91 | $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array( |
90 | 92 | ':url' => $url_bound . '%' |
91 | 93 | )); |
92 | - if ($q->rows()) |
|
93 | - return api_converturl_url_output($q); |
|
94 | + if ($q->rows()) { |
|
95 | + return api_converturl_url_output($q); |
|
96 | + } |
|
94 | 97 | } |
95 | 98 | api_error('Sorry, URL could not be converted'); |
96 | 99 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $LISTURL = new URL($hansardmajors[$id_data['major']]['page_all']); |
41 | 41 | $fragment = ''; |
42 | 42 | if ($id_data['htype'] == '11' || $id_data['htype'] == '10') { |
43 | - $LISTURL->insert( array( 'id' => $id_data['gid'] ) ); |
|
43 | + $LISTURL->insert(array('id' => $id_data['gid'])); |
|
44 | 44 | } else { |
45 | 45 | $parent_epobject_id = $id_data['subsection_id']; |
46 | 46 | $parent_gid = ''; |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | ':epobject_id' => $parent_epobject_id |
51 | 51 | )); |
52 | 52 | if ($r->rows() > 0) { |
53 | - $parent_gid = fix_gid_from_db( $r->field(0, 'gid') ); |
|
53 | + $parent_gid = fix_gid_from_db($r->field(0, 'gid')); |
|
54 | 54 | } |
55 | 55 | if ($parent_gid != '') { |
56 | - $LISTURL->insert( array( 'id' => $parent_gid ) ); |
|
56 | + $LISTURL->insert(array('id' => $parent_gid)); |
|
57 | 57 | $fragment = '#g' . gid_to_anchor($id_data['gid']); |
58 | 58 | } |
59 | 59 | } |
@@ -28,8 +28,9 @@ discard block |
||
28 | 28 | $URL = new URL('mp'); |
29 | 29 | $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']); |
30 | 30 | } |
31 | - if ($has_party && isset($parties[$row['party']])) |
|
32 | - $row['party'] = $parties[$row['party']]; |
|
31 | + if ($has_party && isset($parties[$row['party']])) { |
|
32 | + $row['party'] = $parties[$row['party']]; |
|
33 | + } |
|
33 | 34 | list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']); |
34 | 35 | if ($image) { |
35 | 36 | list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image)); |
@@ -49,7 +50,9 @@ discard block |
||
49 | 50 | } |
50 | 51 | |
51 | 52 | foreach ($row as $k => $r) { |
52 | - if (is_string($r)) $row[$k] = html_entity_decode($r); |
|
53 | + if (is_string($r)) { |
|
54 | + $row[$k] = html_entity_decode($r); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | |
55 | 58 | return $row; |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true); |
86 | 89 | $output[] = $out; |
87 | 90 | $time = strtotime($q->field($i, 'lastupdate')); |
88 | - if ($time > $last_mod) |
|
89 | - $last_mod = $time; |
|
91 | + if ($time > $last_mod) { |
|
92 | + $last_mod = $time; |
|
93 | + } |
|
90 | 94 | } |
91 | 95 | # Only one MP, not an array |
92 | 96 | if ($flatten && count($output) == 1 && $house == HOUSE_TYPE_COMMONS) { |
@@ -134,13 +138,18 @@ discard block |
||
134 | 138 | |
135 | 139 | $cons = array(); |
136 | 140 | foreach ($constituencies as $constituency) { |
137 | - if ($constituency == '') continue; |
|
138 | - if ($constituency == 'Orkney ') |
|
139 | - $constituency = 'Orkney & Shetland'; |
|
141 | + if ($constituency == '') { |
|
142 | + continue; |
|
143 | + } |
|
144 | + if ($constituency == 'Orkney ') { |
|
145 | + $constituency = 'Orkney & Shetland'; |
|
146 | + } |
|
140 | 147 | |
141 | 148 | if ($house == HOUSE_TYPE_COMMONS) { |
142 | 149 | $normalised = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency); |
143 | - if ($normalised) $constituency = $normalised; |
|
150 | + if ($normalised) { |
|
151 | + $constituency = $normalised; |
|
152 | + } |
|
144 | 153 | } |
145 | 154 | |
146 | 155 | $cons[] = $constituency; |
@@ -17,7 +17,7 @@ |
||
17 | 17 | <?php |
18 | 18 | } |
19 | 19 | |
20 | -function _api_getPerson_row($row, $has_party=FALSE) { |
|
20 | +function _api_getPerson_row($row, $has_party=false) { |
|
21 | 21 | global $parties; |
22 | 22 | $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'], |
23 | 23 | $row['family_name'], $row['lordofname']); |
@@ -77,6 +77,9 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | +/** |
|
81 | + * @param MySociety\TheyWorkForYou\Db\Query $q |
|
82 | + */ |
|
80 | 83 | function _api_getPerson_output($q, $flatten=false) { |
81 | 84 | $output = array(); |
82 | 85 | $last_mod = 0; |
@@ -95,10 +98,16 @@ discard block |
||
95 | 98 | api_output($output, $last_mod); |
96 | 99 | } |
97 | 100 | |
101 | +/** |
|
102 | + * @param integer $house |
|
103 | + */ |
|
98 | 104 | function api_getPerson_constituency($constituency, $house) { |
99 | 105 | _api_getPerson_constituency(array($constituency), $house); |
100 | 106 | } |
101 | 107 | |
108 | +/** |
|
109 | + * @param integer $house |
|
110 | + */ |
|
102 | 111 | function api_getPerson_postcode($pc, $house) { |
103 | 112 | $pc = preg_replace('#[^a-z0-9 ]#i', '', $pc); |
104 | 113 | $types = array(); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <?php |
18 | 18 | } |
19 | 19 | |
20 | -function _api_getPerson_row($row, $has_party=FALSE) { |
|
20 | +function _api_getPerson_row($row, $has_party = FALSE) { |
|
21 | 21 | global $parties; |
22 | 22 | $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'], |
23 | 23 | $row['family_name'], $row['lordofname']); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | } |
31 | 31 | if ($has_party && isset($parties[$row['party']])) |
32 | 32 | $row['party'] = $parties[$row['party']]; |
33 | - list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']); |
|
33 | + list($image, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']); |
|
34 | 34 | if ($image) { |
35 | 35 | list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image)); |
36 | 36 | $row['image'] = $image; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | # Ministerialships and Select Committees |
44 | 44 | $db = new ParlDB; |
45 | 45 | $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC'); |
46 | - for ($i=0; $i<$q->rows(); $i++) { |
|
46 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
47 | 47 | $row['office'][] = $q->row($i); |
48 | 48 | } |
49 | 49 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | return $row; |
56 | 56 | } |
57 | 57 | |
58 | -function api_getPerson_id($id, $house='') { |
|
58 | +function api_getPerson_id($id, $house = '') { |
|
59 | 59 | $db = new ParlDB; |
60 | 60 | $params = array( |
61 | 61 | ':person_id' => $id |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | -function _api_getPerson_output($q, $flatten=false) { |
|
80 | +function _api_getPerson_output($q, $flatten = false) { |
|
81 | 81 | $output = array(); |
82 | 82 | $last_mod = 0; |
83 | - for ($i=0; $i<$q->rows(); $i++) { |
|
83 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
84 | 84 | $house = $q->field($i, 'house'); |
85 | 85 | $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true); |
86 | 86 | $output[] = $out; |
@@ -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'), |
@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | $ids = preg_split('#\s*,\s*#', $ids, -1, PREG_SPLIT_NO_EMPTY); |
21 | 21 | $safe_ids = array(0); |
22 | 22 | foreach ($ids as $id) { |
23 | - if (ctype_digit($id)) $safe_ids[] = $id; |
|
23 | + if (ctype_digit($id)) { |
|
24 | + $safe_ids[] = $id; |
|
25 | + } |
|
24 | 26 | } |
25 | 27 | $ids = join(',', $safe_ids); |
26 | 28 | |
@@ -32,13 +34,15 @@ discard block |
||
32 | 34 | $output = array(); |
33 | 35 | for ($i=0; $i<$q->rows(); $i++) { |
34 | 36 | $data_key = $q->field($i, 'data_key'); |
35 | - if (count($fields) && !in_array($data_key, $fields)) |
|
36 | - continue; |
|
37 | + if (count($fields) && !in_array($data_key, $fields)) { |
|
38 | + continue; |
|
39 | + } |
|
37 | 40 | $pid = $q->field($i, 'person_id'); |
38 | 41 | $output[$pid][$data_key] = $q->field($i, 'data_value'); |
39 | 42 | $time = strtotime($q->field($i, 'lastupdate')); |
40 | - if ($time > $last_mod) |
|
41 | - $last_mod = $time; |
|
43 | + if ($time > $last_mod) { |
|
44 | + $last_mod = $time; |
|
45 | + } |
|
42 | 46 | } |
43 | 47 | $q = $db->query("select memberinfo.*, person_id from memberinfo, member |
44 | 48 | where memberinfo.member_id=member.member_id and person_id in (" . $ids . ") |
@@ -46,16 +50,22 @@ discard block |
||
46 | 50 | if ($q->rows()) { |
47 | 51 | for ($i=0; $i<$q->rows(); $i++) { |
48 | 52 | $data_key = $q->field($i, 'data_key'); |
49 | - if (count($fields) && !in_array($data_key, $fields)) |
|
50 | - continue; |
|
53 | + if (count($fields) && !in_array($data_key, $fields)) { |
|
54 | + continue; |
|
55 | + } |
|
51 | 56 | $mid = $q->field($i, 'member_id'); |
52 | 57 | $pid = $q->field($i, 'person_id'); |
53 | - if (!isset($output[$pid]['by_member_id'])) $output[$pid]['by_member_id'] = array(); |
|
54 | - if (!isset($output[$pid]['by_member_id'][$mid])) $output[$pid]['by_member_id'][$mid] = array(); |
|
58 | + if (!isset($output[$pid]['by_member_id'])) { |
|
59 | + $output[$pid]['by_member_id'] = array(); |
|
60 | + } |
|
61 | + if (!isset($output[$pid]['by_member_id'][$mid])) { |
|
62 | + $output[$pid]['by_member_id'][$mid] = array(); |
|
63 | + } |
|
55 | 64 | $output[$pid]['by_member_id'][$mid][$data_key] = $q->field($i, 'data_value'); |
56 | 65 | $time = strtotime($q->field($i, 'lastupdate')); |
57 | - if ($time > $last_mod) |
|
58 | - $last_mod = $time; |
|
66 | + if ($time > $last_mod) { |
|
67 | + $last_mod = $time; |
|
68 | + } |
|
59 | 69 | } |
60 | 70 | } |
61 | 71 | ksort($output); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | where person_id in (" . $ids . ")"); |
31 | 31 | if ($q->rows()) { |
32 | 32 | $output = array(); |
33 | - for ($i=0; $i<$q->rows(); $i++) { |
|
33 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
34 | 34 | $data_key = $q->field($i, 'data_key'); |
35 | 35 | if (count($fields) && !in_array($data_key, $fields)) |
36 | 36 | continue; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | where memberinfo.member_id=member.member_id and person_id in (" . $ids . ") |
45 | 45 | order by person_id,member_id"); |
46 | 46 | if ($q->rows()) { |
47 | - for ($i=0; $i<$q->rows(); $i++) { |
|
47 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
48 | 48 | $data_key = $q->field($i, 'data_key'); |
49 | 49 | if (count($fields) && !in_array($data_key, $fields)) |
50 | 50 | continue; |
@@ -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 | ?> |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | <form method="get" action="?#output"> |
103 | 103 | <p> |
104 | 104 | <?php foreach ($methods[$method]['parameters'] as $parameter) { |
105 | - print $parameter . ': <input type="text" name="'.$parameter.'" value="'; |
|
105 | + print $parameter . ': <input type="text" name="' . $parameter . '" value="'; |
|
106 | 106 | if ($val = get_http_var($parameter)) |
107 | 107 | print _htmlspecialchars($val); |
108 | 108 | print '" size="30"><br>'; |
109 | 109 | } |
110 | 110 | ?> |
111 | 111 | 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'?>> |
|
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 | 113 | <label for="output_js">JS</label> |
114 | -<input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output')=='xml') print ' checked'?>> |
|
114 | +<input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output') == 'xml') print ' checked'?>> |
|
115 | 115 | <label for="output_xml">XML</label> |
116 | -<input id="output_php" type="radio" name="output" value="php"<?php if (get_http_var('output')=='php') print ' checked'?>> |
|
116 | +<input id="output_php" type="radio" name="output" value="php"<?php if (get_http_var('output') == 'php') print ' checked'?>> |
|
117 | 117 | <label for="output_php">Serialised PHP</label> |
118 | -<input id="output_rabx" type="radio" name="output" value="rabx"<?php if (get_http_var('output')=='rabx') print ' checked'?>> |
|
118 | +<input id="output_rabx" type="radio" name="output" value="rabx"<?php if (get_http_var('output') == 'rabx') print ' checked'?>> |
|
119 | 119 | <label for="output_rabx">RABX</label> |
120 | 120 | |
121 | 121 | <input type="submit" value="Go"> |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | print '<h4><a name="output"></a>Output</h4>'; |
132 | 132 | print '<p>URL for this: <strong>https://www.theyworkforyou.com/api/'; |
133 | - print $method . '?' . join('&', $qs) . '&output='._htmlspecialchars(get_http_var('output')).'</strong></p>'; |
|
133 | + print $method . '?' . join('&', $qs) . '&output=' . _htmlspecialchars(get_http_var('output')) . '</strong></p>'; |
|
134 | 134 | print '<pre>' . _htmlspecialchars($explorer) . '</pre>'; |
135 | 135 | } |
136 | 136 | $sidebar = api_sidebar(); |
@@ -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 | ) |