@@ -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 | } |
@@ -41,7 +41,8 @@ discard block |
||
41 | 41 | $fragment = ''; |
42 | 42 | if ($id_data['htype'] == '11' || $id_data['htype'] == '10') { |
43 | 43 | $LISTURL->insert( array( 'id' => $id_data['gid'] ) ); |
44 | - } else { |
|
44 | + } |
|
45 | + else { |
|
45 | 46 | $parent_epobject_id = $id_data['subsection_id']; |
46 | 47 | $parent_gid = ''; |
47 | 48 | $r = $db->query("SELECT gid |
@@ -75,22 +76,25 @@ discard block |
||
75 | 76 | $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url = :url order by gid limit 1', array( |
76 | 77 | ':url' => $url |
77 | 78 | )); |
78 | - if ($q->rows()) |
|
79 | - return api_converturl_url_output($q); |
|
79 | + if ($q->rows()) { |
|
80 | + return api_converturl_url_output($q); |
|
81 | + } |
|
80 | 82 | |
81 | 83 | $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array( |
82 | 84 | ':url' => $url_nohash . '%' |
83 | 85 | )); |
84 | - if ($q->rows()) |
|
85 | - return api_converturl_url_output($q); |
|
86 | + if ($q->rows()) { |
|
87 | + return api_converturl_url_output($q); |
|
88 | + } |
|
86 | 89 | |
87 | 90 | $url_bound = str_replace('cmhansrd/cm', 'cmhansrd/vo', $url_nohash); |
88 | 91 | if ($url_bound != $url_nohash) { |
89 | 92 | $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array( |
90 | 93 | ':url' => $url_bound . '%' |
91 | 94 | )); |
92 | - if ($q->rows()) |
|
93 | - return api_converturl_url_output($q); |
|
95 | + if ($q->rows()) { |
|
96 | + return api_converturl_url_output($q); |
|
97 | + } |
|
94 | 98 | } |
95 | 99 | api_error('Sorry, URL could not be converted'); |
96 | 100 | } |
@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | $q = $db->query($sql, $params); |
9 | 9 | $output = array(); |
10 | 10 | $last_mod = 0; |
11 | - for ($i=0; $i<$q->rows(); $i++) { |
|
11 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
12 | 12 | $pid = $q->field($i, 'person_id'); |
13 | 13 | $row = array( |
14 | 14 | 'member_id' => $q->field($i, 'member_id'), |
15 | 15 | 'person_id' => $pid, |
16 | 16 | 'name' => html_entity_decode(member_full_name($q->field($i, 'house'), $q->field($i, 'title'), |
17 | 17 | $q->field($i, 'given_name'), $q->field($i, 'family_name'), |
18 | - $q->field($i, 'lordofname') )), |
|
18 | + $q->field($i, 'lordofname'))), |
|
19 | 19 | 'party' => isset($parties[$q->field($i, 'party')]) ? $parties[$q->field($i, 'party')] : $q->field($i, 'party'), |
20 | 20 | ); |
21 | 21 | if ($q->field($i, 'house') != 2) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | if (count($pids)) { |
33 | 33 | $q = $db->query('SELECT person, dept, position, from_date, to_date FROM moffice |
34 | 34 | WHERE to_date="9999-12-31" AND person IN (' . join(',', $pids) . ')'); |
35 | - for ($i=0; $i<$q->rows(); $i++) { |
|
35 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
36 | 36 | $row = $q->row($i); |
37 | 37 | $pid = $row['person']; |
38 | 38 | unset($row['person']); |
@@ -81,7 +81,8 @@ |
||
81 | 81 | function api_getMembers_date($house, $date) { |
82 | 82 | if ($date = parse_date($date)) { |
83 | 83 | api_getMembers($house, '"' . $date['iso'] . '"'); |
84 | - } else { |
|
84 | + } |
|
85 | + else { |
|
85 | 86 | api_error('Invalid date format'); |
86 | 87 | } |
87 | 88 | } |
@@ -27,10 +27,12 @@ |
||
27 | 27 | if ($output) { |
28 | 28 | if ($output[0]) { |
29 | 29 | api_output($output[0][$id], $output[1]); |
30 | - } else { |
|
30 | + } |
|
31 | + else { |
|
31 | 32 | api_error('Unknown field'); |
32 | 33 | } |
33 | - } else { |
|
34 | + } |
|
35 | + else { |
|
34 | 36 | api_error('Unknown person ID'); |
35 | 37 | } |
36 | 38 | } |
@@ -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,13 +38,18 @@ 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 | + } |
|
44 | + else { |
|
45 | + api_error('Name not recognised'); |
|
46 | + } |
|
47 | + } |
|
44 | 48 | |
45 | 49 | function _api_getGeometry_name($name) { |
46 | - if (!defined('OPTION_MAPIT_URL') || !OPTION_MAPIT_URL) |
|
47 | - return null; |
|
50 | + if (!defined('OPTION_MAPIT_URL') || !OPTION_MAPIT_URL) { |
|
51 | + return null; |
|
52 | + } |
|
48 | 53 | |
49 | 54 | $name = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($name); |
50 | 55 | |
@@ -54,7 +59,8 @@ discard block |
||
54 | 59 | if ($name == $area['name']) { |
55 | 60 | if (isset($ni_geometry[$area_id])) { |
56 | 61 | $out = $ni_geometry[$area_id]; |
57 | - } else { |
|
62 | + } |
|
63 | + else { |
|
58 | 64 | $out = mapit_call('area/geometry', $area_id); |
59 | 65 | } |
60 | 66 | $out['name'] = $name; |
@@ -68,8 +74,9 @@ discard block |
||
68 | 74 | |
69 | 75 | function _api_cacheCheck($fn, $arg='') { |
70 | 76 | $cache = INCLUDESPATH . '../docs/api/cache/' . $fn; |
71 | - if (is_file($cache)) |
|
72 | - return unserialize(file_get_contents($cache)); |
|
77 | + if (is_file($cache)) { |
|
78 | + return unserialize(file_get_contents($cache)); |
|
79 | + } |
|
73 | 80 | $out = mapit_call($fn, $arg); |
74 | 81 | $fp = fopen($cache, 'w'); |
75 | 82 | if ($fp) { |
@@ -60,7 +60,7 @@ |
||
60 | 60 | $q = $db->query("select constituency, data_key, data_value from consinfo |
61 | 61 | where constituency = :constituency", array(':constituency' => $constituency)); |
62 | 62 | if ($q->rows()) { |
63 | - for ($i=0; $i<$q->rows(); $i++) { |
|
63 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
64 | 64 | $data_key = $q->field($i, 'data_key'); |
65 | 65 | $output[$data_key] = $q->field($i, 'data_value'); |
66 | 66 | } |
@@ -106,25 +106,31 @@ discard block |
||
106 | 106 | if ($t == 'commons') { |
107 | 107 | $list = 'DEBATE'; |
108 | 108 | $type = 'debates'; |
109 | - } elseif ($t == 'lords') { |
|
109 | + } |
|
110 | + elseif ($t == 'lords') { |
|
110 | 111 | $list = 'LORDSDEBATE'; |
111 | 112 | $type = 'lords'; |
112 | - } elseif ($t == 'westminsterhall') { |
|
113 | + } |
|
114 | + elseif ($t == 'westminsterhall') { |
|
113 | 115 | $list = 'WHALL'; |
114 | 116 | $type = 'whall'; |
115 | - } elseif ($t == 'scotland') { |
|
117 | + } |
|
118 | + elseif ($t == 'scotland') { |
|
116 | 119 | $list = 'SP'; |
117 | 120 | $type = 'sp'; |
118 | - } elseif ($t == 'northernireland') { |
|
121 | + } |
|
122 | + elseif ($t == 'northernireland') { |
|
119 | 123 | $list = 'NI'; |
120 | 124 | $type = 'ni'; |
121 | - } else { |
|
125 | + } |
|
126 | + else { |
|
122 | 127 | api_error('Unknown type'); |
123 | 128 | return; |
124 | 129 | } |
125 | 130 | if ($d = get_http_var('date')) { |
126 | 131 | _api_getHansard_date($list, $d); |
127 | - } elseif (get_http_var('search') || get_http_var('person')) { |
|
132 | + } |
|
133 | + elseif (get_http_var('search') || get_http_var('person')) { |
|
128 | 134 | $s = get_http_var('search'); |
129 | 135 | $pid = get_http_var('person'); |
130 | 136 | _api_getHansard_search(array( |
@@ -132,11 +138,14 @@ discard block |
||
132 | 138 | 'pid' => $pid, |
133 | 139 | 'type' => $type, |
134 | 140 | )); |
135 | - } elseif ($gid = get_http_var('gid')) { |
|
141 | + } |
|
142 | + elseif ($gid = get_http_var('gid')) { |
|
136 | 143 | _api_getHansard_gid($list, $gid); |
137 | - } elseif ($y = get_http_var('year')) { |
|
144 | + } |
|
145 | + elseif ($y = get_http_var('year')) { |
|
138 | 146 | _api_getHansard_year($list, $y); |
139 | - } else { |
|
147 | + } |
|
148 | + else { |
|
140 | 149 | api_error('That is not a valid search.'); |
141 | 150 | } |
142 | 151 | } |
@@ -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; |
@@ -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,21 +50,28 @@ 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); |
62 | 72 | return array($output, $last_mod); |
63 | - } else { |
|
73 | + } |
|
74 | + else { |
|
64 | 75 | return null; |
65 | 76 | } |
66 | 77 | } |
@@ -70,10 +81,12 @@ discard block |
||
70 | 81 | if ($output) { |
71 | 82 | if ($output[0]) { |
72 | 83 | api_output($output[0], $output[1]); |
73 | - } else { |
|
84 | + } |
|
85 | + else { |
|
74 | 86 | api_error('Unknown field'); |
75 | 87 | } |
76 | - } else { |
|
88 | + } |
|
89 | + else { |
|
77 | 90 | api_error('Unknown person ID'); |
78 | 91 | } |
79 | 92 | } |
@@ -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 | ); |
@@ -57,8 +57,12 @@ 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 | + } |
|
63 | + else { |
|
64 | + $date = 'date(now())'; |
|
65 | + } |
|
62 | 66 | $q = $db->query("select distinct(dept) from moffice |
63 | 67 | where dept like :department |
64 | 68 | and from_date <= $date and $date <= to_date", array( |
@@ -72,7 +76,8 @@ discard block |
||
72 | 76 | ); |
73 | 77 | } |
74 | 78 | api_output($output); |
75 | - } elseif ($q->rows()) { |
|
79 | + } |
|
80 | + elseif ($q->rows()) { |
|
76 | 81 | # One committee |
77 | 82 | $q = $db->query("select * from moffice, member, person_names pn |
78 | 83 | where moffice.person = member.person_id |
@@ -96,10 +101,12 @@ discard block |
||
96 | 101 | $output['members'][] = $member; |
97 | 102 | } |
98 | 103 | api_output($output); |
99 | - } else { |
|
104 | + } |
|
105 | + else { |
|
100 | 106 | api_error('That committee has no members...?'); |
101 | 107 | } |
102 | - } else { |
|
108 | + } |
|
109 | + else { |
|
103 | 110 | api_error('That name was not recognised'); |
104 | 111 | } |
105 | 112 | } |
@@ -108,8 +115,12 @@ discard block |
||
108 | 115 | $db = new ParlDB; |
109 | 116 | |
110 | 117 | $date = parse_date($date); |
111 | - if ($date) $date = '"' . $date['iso'] . '"'; |
|
112 | - else $date = 'date(now())'; |
|
118 | + if ($date) { |
|
119 | + $date = '"' . $date['iso'] . '"'; |
|
120 | + } |
|
121 | + else { |
|
122 | + $date = 'date(now())'; |
|
123 | + } |
|
113 | 124 | $q = $db->query("select distinct(dept) from moffice |
114 | 125 | where source = 'chgpages/selctee' |
115 | 126 | and from_date <= $date and $date <= to_date"); |
@@ -120,7 +131,8 @@ discard block |
||
120 | 131 | ); |
121 | 132 | } |
122 | 133 | api_output($output); |
123 | - } else { |
|
134 | + } |
|
135 | + else { |
|
124 | 136 | api_error('No committees found'); |
125 | 137 | } |
126 | 138 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | include_once '../../includes/easyparliament/init.php'; |
4 | -include_once INCLUDESPATH."easyparliament/people.php"; |
|
4 | +include_once INCLUDESPATH . "easyparliament/people.php"; |
|
5 | 5 | |
6 | 6 | if (get_http_var('msp')) { |
7 | 7 | $type = 'MSPs'; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $args = $people->getArgs(); |
19 | 19 | $people->setMetaData($args); |
20 | 20 | $data = $people->getData($args); |
21 | -if ( isset($args['f']) && $args['f'] == 'csv' ) { |
|
21 | +if (isset($args['f']) && $args['f'] == 'csv') { |
|
22 | 22 | $people->sendAsCSV($data); |
23 | 23 | } else { |
24 | 24 | MySociety\TheyWorkForYou\Renderer::output("people/index", $data); |
@@ -5,11 +5,14 @@ discard block |
||
5 | 5 | |
6 | 6 | if (get_http_var('msp')) { |
7 | 7 | $type = 'MSPs'; |
8 | -} elseif (get_http_var('mla')) { |
|
8 | +} |
|
9 | +elseif (get_http_var('mla')) { |
|
9 | 10 | $type = 'MLAs'; |
10 | -} elseif (get_http_var('peer')) { |
|
11 | +} |
|
12 | +elseif (get_http_var('peer')) { |
|
11 | 13 | $type = 'Peers'; |
12 | -} else { |
|
14 | +} |
|
15 | +else { |
|
13 | 16 | $type = 'MPs'; |
14 | 17 | } |
15 | 18 | |
@@ -20,6 +23,7 @@ discard block |
||
20 | 23 | $data = $people->getData($args); |
21 | 24 | if ( isset($args['f']) && $args['f'] == 'csv' ) { |
22 | 25 | $people->sendAsCSV($data); |
23 | -} else { |
|
26 | +} |
|
27 | +else { |
|
24 | 28 | MySociety\TheyWorkForYou\Renderer::output("people/index", $data); |
25 | 29 | } |