@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $parts = parse_url($url); |
16 | 16 | parse_str($parts['query'], $query); |
17 | 17 | |
18 | - if ( $query['id'] ) { |
|
18 | + if ($query['id']) { |
|
19 | 19 | if (strpos($parts['path'], 'lords') !== false) { |
20 | 20 | $gid = 'uk.org.publicwhip/lords/'; |
21 | 21 | } elseif (strpos($parts['path'], 'whall') !== false) { |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | |
31 | 31 | |
32 | 32 | public static function gid_to_url($gid) { |
33 | - if ( !$gid ) { |
|
33 | + if (!$gid) { |
|
34 | 34 | return ''; |
35 | 35 | } |
36 | 36 | global $hansardmajors; |
37 | 37 | $db = new \ParlDB(); |
38 | 38 | |
39 | - $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array( ':gid' => $gid )); |
|
39 | + $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid)); |
|
40 | 40 | $url_gid = fix_gid_from_db($gid); |
41 | 41 | $url = new \MySociety\TheyWorkForYou\Url($hansardmajors[$q->field(0, 'major')]['page']); |
42 | 42 | $url->insert(array('id' => $url_gid)); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | protected function getSearchSections() { |
34 | 34 | return array( |
35 | - array( 'section' => 'ni' ) |
|
35 | + array('section' => 'ni') |
|
36 | 36 | ); |
37 | 37 | } |
38 | 38 | |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | |
53 | 53 | $debates = $DEBATELIST->display('recent_debates', array('days' => 30, 'num' => 6), 'none'); |
54 | 54 | $MOREURL = new \MySociety\TheyWorkForYou\Url('nidebatesfront'); |
55 | - $MOREURL->insert( array( 'more' => 1 ) ); |
|
55 | + $MOREURL->insert(array('more' => 1)); |
|
56 | 56 | |
57 | 57 | // this makes sure that we don't repeat this debate in the list below |
58 | 58 | $random_debate = NULL; |
59 | - if ( isset($debates['data']) && count($debates['data']) ) { |
|
59 | + if (isset($debates['data']) && count($debates['data'])) { |
|
60 | 60 | $random_debate = $debates['data'][0]; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $recent = array(); |
64 | - if ( isset($debates['data']) && count($debates['data']) ) { |
|
64 | + if (isset($debates['data']) && count($debates['data'])) { |
|
65 | 65 | // at the start of a session there may be less than 6 |
66 | 66 | // debates |
67 | 67 | $max = 6; |
68 | - if ( count($debates['data']) < 6 ) { |
|
68 | + if (count($debates['data']) < 6) { |
|
69 | 69 | $max = count($debates['data']); |
70 | 70 | } |
71 | - for ( $i = 1; $i < $max; $i++ ) { |
|
71 | + for ($i = 1; $i < $max; $i++) { |
|
72 | 72 | $debate = $debates['data'][$i]; |
73 | 73 | $debate['desc'] = "Northern Ireland Assembly debates"; |
74 | 74 | $debate['more_url'] = $MOREURL->generate(); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | $featured = array(); |
80 | - if ( $random_debate ) { |
|
80 | + if ($random_debate) { |
|
81 | 81 | $featured = $random_debate; |
82 | 82 | $featured['more_url'] = $MOREURL->generate(); |
83 | 83 | $featured['desc'] = 'Northern Ireland Assembly debate'; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | $data['featured'] = $featured; |
89 | - $data['debates'] = array( 'recent' => $recent); |
|
89 | + $data['debates'] = array('recent' => $recent); |
|
90 | 90 | |
91 | 91 | $data['regional'] = $this->getMLAList(); |
92 | 92 | $data['template'] = 'ni/index'; |
@@ -114,7 +114,7 @@ |
||
114 | 114 | /** |
115 | 115 | * Remove Session Key/Value Pair |
116 | 116 | * |
117 | - * @param array $arr A list array of key names to remove |
|
117 | + * @param string[] $arr A list array of key names to remove |
|
118 | 118 | */ |
119 | 119 | |
120 | 120 | public function remove($arr) { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | // These stores an associative array of key/value pairs that |
44 | 44 | // we'll want passed on to other pages. |
45 | - $this->session_vars = array (); |
|
45 | + $this->session_vars = array(); |
|
46 | 46 | |
47 | 47 | // Prevent things using $DATA running if it hasn't been set, ie in testing |
48 | 48 | if (isset($DATA)) { |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | public function reset() { |
95 | 95 | // Call this to remove all the session_vars. |
96 | - $this->session_vars = array (); |
|
96 | + $this->session_vars = array(); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | * override just one or two of them. |
163 | 163 | */ |
164 | 164 | |
165 | - public function generate($encode = "html", $overrideVars=array()) { |
|
165 | + public function generate($encode = "html", $overrideVars = array()) { |
|
166 | 166 | |
167 | 167 | global $DATA; |
168 | 168 | |
169 | - $url_args = array (); |
|
169 | + $url_args = array(); |
|
170 | 170 | |
171 | 171 | foreach (array_merge($this->session_vars, $overrideVars) as $key => $var) { |
172 | 172 | if (is_array($var)) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | if (isset ($data['rows']) && count($data['rows']) > 0) { |
67 | 67 | |
68 | 68 | echo '<dl id="searchresults">'; |
69 | - for ($i=0; $i<count($data['rows']); $i++) { |
|
69 | + for ($i = 0; $i < count($data['rows']); $i++) { |
|
70 | 70 | |
71 | 71 | $row = $data['rows'][$i]; |
72 | 72 | echo '<dt><a href="', $row['listurl'], '">'; |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | } |
80 | 80 | if (isset($row['collapsed']) && $row['collapsed'] && $row['subsection_id']) { |
81 | 81 | $URL = new \MySociety\TheyWorkForYou\Url('search'); |
82 | - $URL->insert(array('s' => $info['s'] . " segment:$row[subsection_id]" )); |
|
82 | + $URL->insert(array('s' => $info['s'] . " segment:$row[subsection_id]")); |
|
83 | 83 | echo ' <a href="', $URL->generate(), '">See ', $row['collapsed'], |
84 | - ' other result', $row['collapsed']>1?'s':'', ' from this ', |
|
84 | + ' other result', $row['collapsed'] > 1 ? 's' : '', ' from this ', |
|
85 | 85 | $hansardmajors[$row['major']]['singular'], '</a>'; |
86 | 86 | } |
87 | 87 | echo '</small>'; |
88 | 88 | if ($match = get_http_var('match')) { |
89 | - echo ' – <a href="/search/record.php?result=', $row['gid'] , '&match=', _htmlspecialchars($match), '">This is the correct match</a>'; |
|
89 | + echo ' – <a href="/search/record.php?result=', $row['gid'], '&match=', _htmlspecialchars($match), '">This is the correct match</a>'; |
|
90 | 90 | } |
91 | 91 | echo '</dt> <dd><p>'; |
92 | 92 | if (isset($row['speaker']) && count($row['speaker'])) { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - public function display ($view, $args=array(), $format='html') { |
|
45 | + public function display($view, $args = array(), $format = 'html') { |
|
46 | 46 | // $view is what we're viewing by: |
47 | 47 | // 'ep' is all the comments attached to an epobject. |
48 | 48 | // 'user' is all the comments written by a user. |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | |
61 | 61 | if ($view == 'ep' || $view == 'user' || $view == 'recent' || $view == 'search' || $view == 'dates') { |
62 | 62 | // What function do we call for this view? |
63 | - $function = '_get_data_by_'.$view; |
|
63 | + $function = '_get_data_by_' . $view; |
|
64 | 64 | // Get all the dta that's to be rendered. |
65 | 65 | $data = $this->$function($args); |
66 | 66 | |
67 | 67 | } else { |
68 | 68 | // Don't have a valid $view; |
69 | - $PAGE->error_message ("You haven't specified a view type."); |
|
69 | + $PAGE->error_message("You haven't specified a view type."); |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
@@ -85,29 +85,29 @@ discard block |
||
85 | 85 | return true; |
86 | 86 | } |
87 | 87 | |
88 | - public function render($data, $format='html', $template='comments') { |
|
89 | - include (INCLUDESPATH."easyparliament/templates/$format/$template.php"); |
|
88 | + public function render($data, $format = 'html', $template = 'comments') { |
|
89 | + include (INCLUDESPATH . "easyparliament/templates/$format/$template.php"); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | public function _get_data_by_ep($args) { |
93 | 93 | // Get all the data attached to an epobject. |
94 | 94 | global $PAGE; |
95 | 95 | |
96 | - twfy_debug (get_class($this), "getting data by epobject"); |
|
96 | + twfy_debug(get_class($this), "getting data by epobject"); |
|
97 | 97 | |
98 | 98 | // What we return. |
99 | 99 | $data = array(); |
100 | 100 | if (!is_numeric($args['epobject_id'])) { |
101 | - $PAGE->error_message ("Sorry, we don't have a valid epobject id"); |
|
101 | + $PAGE->error_message("Sorry, we don't have a valid epobject id"); |
|
102 | 102 | return $data; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // For getting the data. |
106 | - $input = array ( |
|
107 | - 'amount' => array ( |
|
106 | + $input = array( |
|
107 | + 'amount' => array( |
|
108 | 108 | 'user' => true |
109 | 109 | ), |
110 | - 'where' => array ( |
|
110 | + 'where' => array( |
|
111 | 111 | 'comments.epobject_id=' => $args['epobject_id'], |
112 | 112 | #'visible=' => '1' |
113 | 113 | ), |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | // comments by things in $args? |
136 | 136 | global $PAGE; |
137 | 137 | |
138 | - twfy_debug (get_class($this), "getting data by user"); |
|
138 | + twfy_debug(get_class($this), "getting data by user"); |
|
139 | 139 | |
140 | 140 | // What we return. |
141 | 141 | $data = array(); |
142 | 142 | |
143 | 143 | if (!is_numeric($args['user_id'])) { |
144 | - $PAGE->error_message ("Sorry, we don't have a valid user id"); |
|
144 | + $PAGE->error_message("Sorry, we don't have a valid user id"); |
|
145 | 145 | return $data; |
146 | 146 | } |
147 | 147 | |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | $num = 10; |
152 | 152 | } |
153 | 153 | |
154 | - if (isset($args['page']) && is_numeric($args['page']) && $args['page']>1) { |
|
154 | + if (isset($args['page']) && is_numeric($args['page']) && $args['page'] > 1) { |
|
155 | 155 | $page = $args['page']; |
156 | 156 | } else { |
157 | 157 | $page = 1; |
158 | 158 | } |
159 | 159 | |
160 | - $limit = $num*($page-1) . ',' . $num; |
|
160 | + $limit = $num * ($page - 1) . ',' . $num; |
|
161 | 161 | |
162 | 162 | // We're getting the most recent comments posted to epobjects. |
163 | 163 | // We're grouping them by epobject so we can just link to each hansard thing once. |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | |
194 | 194 | if ($q->rows() > 0) { |
195 | 195 | |
196 | - for ($n=0; $n<$q->rows(); $n++) { |
|
196 | + for ($n = 0; $n < $q->rows(); $n++) { |
|
197 | 197 | |
198 | 198 | // All the basic stuff... |
199 | - $comments[$n] = array ( |
|
199 | + $comments[$n] = array( |
|
200 | 200 | 'comment_id' => $q->field($n, 'comment_id'), |
201 | 201 | 'posted' => $q->field($n, 'posted'), |
202 | 202 | 'total_comments' => $q->field($n, 'total_comments'), |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | ); |
209 | 209 | |
210 | 210 | // Add the URL... |
211 | - $urldata = array ( |
|
211 | + $urldata = array( |
|
212 | 212 | 'major' => $q->field($n, 'major'), |
213 | 213 | 'gid' => $q->field($n, 'gid'), |
214 | 214 | 'comment_id' => $q->field($n, 'comment_id'), |
@@ -234,14 +234,14 @@ discard block |
||
234 | 234 | |
235 | 235 | $commentbodies = array(); |
236 | 236 | |
237 | - for ($n=0; $n<$r->rows(); $n++) { |
|
238 | - $commentbodies[ $r->field($n, 'comment_id') ] = $r->field($n, 'body'); |
|
237 | + for ($n = 0; $n < $r->rows(); $n++) { |
|
238 | + $commentbodies[$r->field($n, 'comment_id')] = $r->field($n, 'body'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | // This does rely on both this and the previous query returning |
242 | 242 | // stuff in the same order... |
243 | 243 | foreach ($comments as $n => $commentdata) { |
244 | - $comments[$n]['body'] = $commentbodies[ $comments[$n]['comment_id'] ]; |
|
244 | + $comments[$n]['body'] = $commentbodies[$comments[$n]['comment_id']]; |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // $args should contain 'num', indicating how many to get. |
262 | 262 | // and perhaps pid too, for a particular person |
263 | 263 | |
264 | - twfy_debug (get_class($this), "getting data by recent"); |
|
264 | + twfy_debug(get_class($this), "getting data by recent"); |
|
265 | 265 | |
266 | 266 | // What we return. |
267 | 267 | $data = array(); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $page = 1; |
279 | 279 | } |
280 | 280 | |
281 | - $limit = $num*($page-1) . ',' . $num; |
|
281 | + $limit = $num * ($page - 1) . ',' . $num; |
|
282 | 282 | |
283 | 283 | $where = array( |
284 | 284 | 'visible=' => '1' |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | if (isset($args['pid']) && is_numeric($args['pid'])) { |
287 | 287 | $where['person_id='] = $args['pid']; |
288 | 288 | } |
289 | - $input = array ( |
|
290 | - 'amount' => array ( |
|
289 | + $input = array( |
|
290 | + 'amount' => array( |
|
291 | 291 | 'user' => true |
292 | 292 | ), |
293 | 293 | 'where' => $where, |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $data['pid'] = $args['pid']; |
306 | 306 | $q = 'SELECT title, given_name, family_name, lordofname, house FROM member m, person_names p WHERE m.person_id=p.person_id AND p.type="name" AND left_house="9999-12-31" AND m.person_id = :pid'; |
307 | 307 | $q = $this->db->query($q, array(':pid' => $args['pid'])); |
308 | - $data['full_name'] = member_full_name($q->field(0, 'house'), $q->field(0, 'title'), $q->field(0, 'given_name'), $q->field(0, 'family_name'), $q->field(0,'lordofname')); |
|
308 | + $data['full_name'] = member_full_name($q->field(0, 'house'), $q->field(0, 'title'), $q->field(0, 'given_name'), $q->field(0, 'family_name'), $q->field(0, 'lordofname')); |
|
309 | 309 | $q = 'SELECT COUNT(*) AS count FROM comments,hansard WHERE visible=1 AND comments.epobject_id = hansard.epobject_id and hansard.person_id = :pid'; |
310 | 310 | $params[':pid'] = $args['pid']; |
311 | 311 | } else { |
@@ -319,15 +319,15 @@ discard block |
||
319 | 319 | public function _get_data_by_dates($args) { |
320 | 320 | // $args should contain start_date and end_date |
321 | 321 | |
322 | - twfy_debug (get_class($this), "getting data by recent"); |
|
322 | + twfy_debug(get_class($this), "getting data by recent"); |
|
323 | 323 | $data = array(); |
324 | 324 | $where = array( |
325 | 325 | 'visible=' => '1', |
326 | 326 | 'date(posted)>=' => $args['start_date'], |
327 | 327 | 'date(posted)<=' => $args['end_date'] |
328 | 328 | ); |
329 | - $input = array ( |
|
330 | - 'amount' => array ( |
|
329 | + $input = array( |
|
330 | + 'amount' => array( |
|
331 | 331 | 'user' => true |
332 | 332 | ), |
333 | 333 | 'where' => $where, |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | public function _get_data_by_search($args) { |
342 | 342 | // $args should contain 'num', indicating how many to get. |
343 | 343 | |
344 | - twfy_debug (get_class($this), "getting data by search"); |
|
344 | + twfy_debug(get_class($this), "getting data by search"); |
|
345 | 345 | |
346 | 346 | // What we return. |
347 | 347 | $data = array(); |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | $page = 1; |
359 | 359 | } |
360 | 360 | |
361 | - $limit = $num*($page-1) . ',' . $num; |
|
361 | + $limit = $num * ($page - 1) . ',' . $num; |
|
362 | 362 | |
363 | - $input = array ( |
|
364 | - 'amount' => array ( |
|
363 | + $input = array( |
|
364 | + 'amount' => array( |
|
365 | 365 | 'user'=> true |
366 | 366 | ), |
367 | - 'where' => array ( |
|
367 | + 'where' => array( |
|
368 | 368 | 'comments.body LIKE' => "%$args[s]%" |
369 | 369 | ), |
370 | 370 | 'order' => 'posted DESC', |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | // It returns the URL for the comment. |
392 | 392 | |
393 | 393 | $major = $urldata['major']; |
394 | - $gid = $urldata['gid']; |
|
394 | + $gid = $urldata['gid']; |
|
395 | 395 | $comment_id = $urldata['comment_id']; |
396 | 396 | $user_id = isset($urldata['user_id']) ? $urldata['user_id'] : false; |
397 | 397 | |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $URL = new \MySociety\TheyWorkForYou\Url($page); |
406 | 406 | |
407 | 407 | $gid = fix_gid_from_db($gid); // In includes/utility.php |
408 | - $URL->insert(array('id' => $gid )); |
|
408 | + $URL->insert(array('id' => $gid)); |
|
409 | 409 | if ($user_id) { |
410 | 410 | $URL->insert(array('u' => $user_id)); |
411 | 411 | } |
@@ -483,9 +483,9 @@ discard block |
||
483 | 483 | $limit = isset($input['limit']) ? $input['limit'] : ''; |
484 | 484 | |
485 | 485 | // The fields to fetch from db. 'table' => array ('field1', 'field2'). |
486 | - $fieldsarr = array ( |
|
487 | - 'comments' => array ('comment_id', 'user_id', 'epobject_id', 'body', 'posted', 'modflagged', 'visible'), |
|
488 | - 'hansard' => array ('major', 'gid') |
|
486 | + $fieldsarr = array( |
|
487 | + 'comments' => array('comment_id', 'user_id', 'epobject_id', 'body', 'posted', 'modflagged', 'visible'), |
|
488 | + 'hansard' => array('major', 'gid') |
|
489 | 489 | ); |
490 | 490 | |
491 | 491 | // Yes, we need the gid of a comment's associated hansard object |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | |
497 | 497 | // Add on the stuff for getting a user's details. |
498 | 498 | if (isset($amount['user']) && $amount['user'] == true) { |
499 | - $fieldsarr['users'] = array ('firstname', 'lastname', 'user_id'); |
|
499 | + $fieldsarr['users'] = array('firstname', 'lastname', 'user_id'); |
|
500 | 500 | // Like doing "FROM comments, users" but it's easier to add |
501 | 501 | // an "INNER JOIN..." automatically to the query. |
502 | 502 | $join .= ' INNER JOIN users ON comments.user_id = users.user_id '; |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | $fieldsarr['epobject'] = array('body'); |
508 | 508 | } |
509 | 509 | |
510 | - $fieldsarr2 = array (); |
|
510 | + $fieldsarr2 = array(); |
|
511 | 511 | // Construct the $fields clause. |
512 | 512 | foreach ($fieldsarr as $table => $tablesfields) { |
513 | 513 | foreach ($tablesfields as $n => $field) { |
@@ -518,13 +518,13 @@ discard block |
||
518 | 518 | if ($table == 'epobject' && $field == 'body') { |
519 | 519 | $field .= ' AS hbody'; |
520 | 520 | } |
521 | - $fieldsarr2[] = $table.'.'.$field; |
|
521 | + $fieldsarr2[] = $table . '.' . $field; |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | $fields = implode(', ', $fieldsarr2); |
525 | 525 | |
526 | 526 | |
527 | - $wherearr2 = array (); |
|
527 | + $wherearr2 = array(); |
|
528 | 528 | $params = array(); |
529 | 529 | $i = 0; |
530 | 530 | // Construct the $where clause. |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $params[":where$i"] = $val; |
534 | 534 | $i++; |
535 | 535 | } |
536 | - $where = implode (" AND ", $wherearr2); |
|
536 | + $where = implode(" AND ", $wherearr2); |
|
537 | 537 | |
538 | 538 | if ($order != '') { |
539 | 539 | $order = "ORDER BY $order"; |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | } |
545 | 545 | |
546 | 546 | // Finally, do the query! |
547 | - $q = $this->db->query ("SELECT $fields |
|
547 | + $q = $this->db->query("SELECT $fields |
|
548 | 548 | FROM comments |
549 | 549 | $join |
550 | 550 | WHERE $where |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | ", $params); |
554 | 554 | |
555 | 555 | // Format the data into an array for returning. |
556 | - $data = array (); |
|
556 | + $data = array(); |
|
557 | 557 | |
558 | 558 | if ($q->rows() > 0) { |
559 | 559 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | // We'll generate permalinks for each comment. |
564 | 564 | // Assuming every comment is from the same major... |
565 | 565 | |
566 | - for ($n=0; $n<$q->rows(); $n++) { |
|
566 | + for ($n = 0; $n < $q->rows(); $n++) { |
|
567 | 567 | |
568 | 568 | // Put each row returned into its own array in $data. |
569 | 569 | foreach ($fieldsarr as $table => $tablesfields) { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include_once INCLUDESPATH."easyparliament/searchengine.php"; |
|
4 | -include_once INCLUDESPATH."easyparliament/searchlog.php"; |
|
3 | +include_once INCLUDESPATH . "easyparliament/searchengine.php"; |
|
4 | +include_once INCLUDESPATH . "easyparliament/searchlog.php"; |
|
5 | 5 | |
6 | 6 | /* |
7 | 7 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | class HANSARDLIST { |
54 | 54 | // This will be used to cache information about speakers on this page |
55 | 55 | // so we don't have to keep fetching the same data from the DB. |
56 | - public $speakers = array (); |
|
56 | + public $speakers = array(); |
|
57 | 57 | /* |
58 | 58 | $this->speakers[ $person_id ] = array ( |
59 | 59 | "name" => $name, |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | // This will be used to cache mappings from epobject_id to gid, |
68 | 68 | // so we don't have to continually fetch the same data in get_hansard_data(). |
69 | - public $epobjectid_to_gid = array (); |
|
69 | + public $epobjectid_to_gid = array(); |
|
70 | 70 | /* |
71 | 71 | $this->epobjectid_to_gid[ $epobject_id ] => $gid; |
72 | 72 | */ |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | |
116 | 116 | |
117 | - public function display ($view, $args=array(), $format='html') { |
|
117 | + public function display($view, $args = array(), $format = 'html') { |
|
118 | 118 | |
119 | 119 | // $view is what we're viewing by: |
120 | 120 | // 'gid' is the gid of a hansard object, |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | if ($view == 'search' && (!defined('FRONT_END_SEARCH') || !FRONT_END_SEARCH)) |
142 | 142 | return false; |
143 | 143 | |
144 | - $validviews = array ('calendar', 'date', 'gid', 'person', 'search', 'search_min', 'search_video', 'recent', 'recent_mostvotes', 'biggest_debates', 'recent_wrans', 'recent_wms', 'column', 'mp', 'bill', 'session', 'recent_debates', 'recent_pbc_debates', 'featured_gid'); |
|
144 | + $validviews = array('calendar', 'date', 'gid', 'person', 'search', 'search_min', 'search_video', 'recent', 'recent_mostvotes', 'biggest_debates', 'recent_wrans', 'recent_wms', 'column', 'mp', 'bill', 'session', 'recent_debates', 'recent_pbc_debates', 'featured_gid'); |
|
145 | 145 | if (in_array($view, $validviews)) { |
146 | 146 | |
147 | 147 | // What function do we call for this view? |
148 | - $function = '_get_data_by_'.$view; |
|
148 | + $function = '_get_data_by_' . $view; |
|
149 | 149 | // Get all the data that's to be rendered. |
150 | 150 | $data = $this->$function($args); |
151 | 151 | |
152 | 152 | } else { |
153 | 153 | // Don't have a valid $view. |
154 | - $PAGE->error_message ("You haven't specified a view type."); |
|
154 | + $PAGE->error_message("You haven't specified a view type."); |
|
155 | 155 | return false; |
156 | 156 | } |
157 | 157 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | |
174 | 174 | |
175 | - public function render($view, $data, $format='html') { |
|
175 | + public function render($view, $data, $format = 'html') { |
|
176 | 176 | // Once we have the data that's to be rendered, |
177 | 177 | // include the template. |
178 | 178 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | return $data; |
182 | 182 | } |
183 | 183 | |
184 | - include (INCLUDESPATH."easyparliament/templates/$format/hansard_$view" . ".php"); |
|
184 | + include (INCLUDESPATH . "easyparliament/templates/$format/hansard_$view" . ".php"); |
|
185 | 185 | return true; |
186 | 186 | |
187 | 187 | } |
@@ -226,13 +226,13 @@ discard block |
||
226 | 226 | $hdate = $q->field(0, 'hdate'); |
227 | 227 | if ($hdate) { |
228 | 228 | $URL = new \MySociety\TheyWorkForYou\Url($this->listpage); |
229 | - $URL->insert( array('d'=>$hdate) ); |
|
229 | + $URL->insert(array('d'=>$hdate)); |
|
230 | 230 | |
231 | 231 | // Work out a timestamp which is handy for comparing to now. |
232 | 232 | list($year, $month, $date) = explode('-', $hdate); |
233 | - $timestamp = gmmktime (0, 0, 0, $month, $date, $year); |
|
233 | + $timestamp = gmmktime(0, 0, 0, $month, $date, $year); |
|
234 | 234 | |
235 | - $data = array ( |
|
235 | + $data = array( |
|
236 | 236 | 'hdate' => $hdate, |
237 | 237 | 'timestamp' => $timestamp, |
238 | 238 | 'listurl' => $URL->generate() |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | // Pass it an array of data about an item and it will return an |
267 | 267 | // array of data about the item's section heading. |
268 | 268 | |
269 | - twfy_debug (get_class($this), "getting an item's section"); |
|
269 | + twfy_debug(get_class($this), "getting an item's section"); |
|
270 | 270 | |
271 | 271 | if ($itemdata['htype'] != '10') { |
272 | 272 | |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | // so get the section info above this item. |
276 | 276 | |
277 | 277 | // For getting hansard data. |
278 | - $input = array ( |
|
279 | - 'amount' => array ( |
|
278 | + $input = array( |
|
279 | + 'amount' => array( |
|
280 | 280 | 'body' => true |
281 | 281 | ), |
282 | - 'where' => array ( |
|
282 | + 'where' => array( |
|
283 | 283 | 'hansard.epobject_id=' => $itemdata['section_id'] |
284 | 284 | ) |
285 | 285 | ); |
@@ -306,21 +306,21 @@ discard block |
||
306 | 306 | // Pass it an array of data about an item and it will return an |
307 | 307 | // array of data about the item's subsection heading. |
308 | 308 | |
309 | - twfy_debug (get_class($this), "getting an item's subsection"); |
|
309 | + twfy_debug(get_class($this), "getting an item's subsection"); |
|
310 | 310 | |
311 | 311 | // What we return. |
312 | - $subsectiondata = array (); |
|
312 | + $subsectiondata = array(); |
|
313 | 313 | |
314 | 314 | if ($itemdata['htype'] == '12' || $itemdata['htype'] == '13') { |
315 | 315 | // This item is a speech or procedural, so get the |
316 | 316 | // subsection info above this item. |
317 | 317 | |
318 | 318 | // For getting hansard data. |
319 | - $input = array ( |
|
320 | - 'amount' => array ( |
|
319 | + $input = array( |
|
320 | + 'amount' => array( |
|
321 | 321 | 'body' => true |
322 | 322 | ), |
323 | - 'where' => array ( |
|
323 | + 'where' => array( |
|
324 | 324 | 'hansard.epobject_id=' => $itemdata['subsection_id'] |
325 | 325 | ) |
326 | 326 | ); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | // Pass it an array of item info, of a section/subsection, and this will return |
348 | 348 | // data for the next/prev items. |
349 | 349 | |
350 | - twfy_debug (get_class($this), "getting next/prev items"); |
|
350 | + twfy_debug(get_class($this), "getting next/prev items"); |
|
351 | 351 | |
352 | 352 | // What we return. |
353 | 353 | $nextprevdata = array(); |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | $wherearr['hansard.epobject_id='] = $prev_item_id; |
414 | 414 | |
415 | 415 | // For getting hansard data. |
416 | - $input = array ( |
|
417 | - 'amount' => array ( |
|
416 | + $input = array( |
|
417 | + 'amount' => array( |
|
418 | 418 | 'body' => true, |
419 | 419 | 'speaker' => true |
420 | 420 | ), |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | if ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') { |
430 | 430 | // Linking to the prev (sub)section. |
431 | 431 | $thing = $hansardmajors[$this->major]['singular']; |
432 | - $nextprevdata['prev'] = array ( |
|
432 | + $nextprevdata['prev'] = array( |
|
433 | 433 | 'body' => "Previous $thing", |
434 | 434 | 'url' => $prevdata[0]['listurl'], |
435 | 435 | 'title' => $prevdata[0]['body'] |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | } else { |
443 | 443 | $title = ''; |
444 | 444 | } |
445 | - $nextprevdata['prev'] = array ( |
|
445 | + $nextprevdata['prev'] = array( |
|
446 | 446 | 'body' => 'Previous speaker', |
447 | 447 | 'url' => $prevdata[0]['commentsurl'], |
448 | 448 | 'title' => $title |
@@ -458,8 +458,8 @@ discard block |
||
458 | 458 | $wherearr['hansard.epobject_id='] = $next_item_id; |
459 | 459 | |
460 | 460 | // For getting hansard data. |
461 | - $input = array ( |
|
462 | - 'amount' => array ( |
|
461 | + $input = array( |
|
462 | + 'amount' => array( |
|
463 | 463 | 'body' => true, |
464 | 464 | 'speaker' => true |
465 | 465 | ), |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | if ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') { |
474 | 474 | // Linking to the next (sub)section. |
475 | 475 | $thing = $hansardmajors[$this->major]['singular']; |
476 | - $nextprevdata['next'] = array ( |
|
476 | + $nextprevdata['next'] = array( |
|
477 | 477 | 'body' => "Next $thing", |
478 | 478 | 'url' => $nextdata[0]['listurl'], |
479 | 479 | 'title' => $nextdata[0]['body'] |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | } else { |
487 | 487 | $title = ''; |
488 | 488 | } |
489 | - $nextprevdata['next'] = array ( |
|
489 | + $nextprevdata['next'] = array( |
|
490 | 490 | 'body' => 'Next speaker', |
491 | 491 | 'url' => $nextdata[0]['commentsurl'], |
492 | 492 | 'title' => $title |
@@ -530,14 +530,14 @@ discard block |
||
530 | 530 | // containing the next/prev dates that contain items from |
531 | 531 | // $this->major of hansard object. |
532 | 532 | |
533 | - twfy_debug (get_class($this), "getting next/prev dates"); |
|
533 | + twfy_debug(get_class($this), "getting next/prev dates"); |
|
534 | 534 | |
535 | 535 | // What we return. |
536 | - $nextprevdata = array (); |
|
536 | + $nextprevdata = array(); |
|
537 | 537 | |
538 | 538 | $URL = new \MySociety\TheyWorkForYou\Url($this->listpage); |
539 | 539 | |
540 | - $looper = array ("next", "prev"); |
|
540 | + $looper = array("next", "prev"); |
|
541 | 541 | |
542 | 542 | foreach ($looper as $n => $nextorprev) { |
543 | 543 | |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | // when displaying the first day of debates. |
562 | 562 | if ($q->rows() > 0 && $q->field(0, 'hdate') != NULL) { |
563 | 563 | |
564 | - $URL->insert( array( 'd'=>$q->field(0, 'hdate') ) ); |
|
564 | + $URL->insert(array('d'=>$q->field(0, 'hdate'))); |
|
565 | 565 | |
566 | 566 | if ($nextorprev == 'next') { |
567 | 567 | $body = 'Next day'; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | |
572 | 572 | $title = format_date($q->field(0, 'hdate'), SHORTDATEFORMAT); |
573 | 573 | |
574 | - $nextprevdata[$nextorprev] = array ( |
|
574 | + $nextprevdata[$nextorprev] = array( |
|
575 | 575 | 'hdate' => $q->field(0, 'hdate'), |
576 | 576 | 'url' => $URL->generate(), |
577 | 577 | 'body' => $body, |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | $thing = $hansardmajors[$this->major]['plural']; |
586 | 586 | $URL->insert(array('y'=>$year)); |
587 | 587 | |
588 | - $nextprevdata['up'] = array ( |
|
588 | + $nextprevdata['up'] = array( |
|
589 | 589 | 'body' => "All of $year's $thing", |
590 | 590 | 'title' => '', |
591 | 591 | 'url' => $URL->generate() |
@@ -606,19 +606,19 @@ discard block |
||
606 | 606 | if (isset($args['date'])) { |
607 | 607 | $date = $args['date']; |
608 | 608 | } else { |
609 | - $PAGE->error_message ("Sorry, we don't have a date."); |
|
609 | + $PAGE->error_message("Sorry, we don't have a date."); |
|
610 | 610 | return false; |
611 | 611 | } |
612 | 612 | |
613 | 613 | if (!preg_match("/^(\d\d\d\d)-(\d{1,2})-(\d{1,2})$/", $date, $matches)) { |
614 | - $PAGE->error_message ("Sorry, '" . _htmlentities($date) . "' isn't of the right format (YYYY-MM-DD)."); |
|
614 | + $PAGE->error_message("Sorry, '" . _htmlentities($date) . "' isn't of the right format (YYYY-MM-DD)."); |
|
615 | 615 | return false; |
616 | 616 | } |
617 | 617 | |
618 | 618 | list(, $year, $month, $day) = $matches; |
619 | 619 | |
620 | 620 | if (!checkdate($month, $day, $year)) { |
621 | - $PAGE->error_message ("Sorry, '" . _htmlentities($date) . "' isn't a valid date."); |
|
621 | + $PAGE->error_message("Sorry, '" . _htmlentities($date) . "' isn't a valid date."); |
|
622 | 622 | return false; |
623 | 623 | } |
624 | 624 | |
@@ -636,29 +636,29 @@ discard block |
||
636 | 636 | global $PAGE; |
637 | 637 | |
638 | 638 | if (!isset($args['gid']) && $args['gid'] == '') { |
639 | - $PAGE->error_message ("Sorry, we don't have an item gid."); |
|
639 | + $PAGE->error_message("Sorry, we don't have an item gid."); |
|
640 | 640 | return false; |
641 | 641 | } |
642 | 642 | |
643 | 643 | |
644 | 644 | // Get all the data just for this epobject_id. |
645 | - $input = array ( |
|
646 | - 'amount' => array ( |
|
645 | + $input = array( |
|
646 | + 'amount' => array( |
|
647 | 647 | 'body' => true, |
648 | 648 | 'speaker' => true, |
649 | 649 | 'comment' => true, |
650 | 650 | 'votes' => true |
651 | 651 | ), |
652 | - 'where' => array ( |
|
652 | + 'where' => array( |
|
653 | 653 | // Need to add the 'uk.org.publicwhip/debate/' or whatever on before |
654 | 654 | // looking in the DB. |
655 | 655 | 'gid=' => $this->gidprefix . $args['gid'] |
656 | 656 | ) |
657 | 657 | ); |
658 | 658 | |
659 | - twfy_debug (get_class($this), "looking for redirected gid"); |
|
659 | + twfy_debug(get_class($this), "looking for redirected gid"); |
|
660 | 660 | $gid = $this->gidprefix . $args['gid']; |
661 | - $q = $this->db->query ("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid)); |
|
661 | + $q = $this->db->query("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid)); |
|
662 | 662 | if ($q->rows() == 0) { |
663 | 663 | $itemdata = $this->_get_hansard_data($input); |
664 | 664 | } else { |
@@ -666,10 +666,10 @@ discard block |
||
666 | 666 | $gid = $q->field(0, 'gid_to'); |
667 | 667 | $q = $this->db->query("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid)); |
668 | 668 | } while ($q->rows() > 0); |
669 | - twfy_debug (get_class($this), "found redirected gid $gid" ); |
|
669 | + twfy_debug(get_class($this), "found redirected gid $gid"); |
|
670 | 670 | $input['where'] = array('gid=' => $gid); |
671 | 671 | $itemdata = $this->_get_hansard_data($input); |
672 | - if (count($itemdata) > 0 ) { |
|
672 | + if (count($itemdata) > 0) { |
|
673 | 673 | throw new RedirectException(fix_gid_from_db($gid)); |
674 | 674 | } |
675 | 675 | } |
@@ -683,9 +683,9 @@ discard block |
||
683 | 683 | $this->check_gid_change($args['gid'], 'a', ''); |
684 | 684 | |
685 | 685 | if (substr($args['gid'], -1) == 'L') { |
686 | - $letts = array('a','b','c','d','e'); |
|
687 | - for ($i=0; $i<4; $i++) { |
|
688 | - $this->check_gid_change($args['gid'], $letts[$i], $letts[$i+1]); |
|
686 | + $letts = array('a', 'b', 'c', 'd', 'e'); |
|
687 | + for ($i = 0; $i < 4; $i++) { |
|
688 | + $this->check_gid_change($args['gid'], $letts[$i], $letts[$i + 1]); |
|
689 | 689 | } |
690 | 690 | } |
691 | 691 | |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | # $u = $q->field(0, 'source_url'); |
719 | 719 | # $u = '<br><a href="'. $u . '">' . $u . '</a>'; |
720 | 720 | #} |
721 | - $PAGE->error_message ("Sorry, there is no Hansard object with a gid of '" . _htmlentities($args['gid']) . "'."); |
|
721 | + $PAGE->error_message("Sorry, there is no Hansard object with a gid of '" . _htmlentities($args['gid']) . "'."); |
|
722 | 722 | return false; |
723 | 723 | } |
724 | 724 | |
@@ -727,8 +727,8 @@ discard block |
||
727 | 727 | } |
728 | 728 | |
729 | 729 | private function check_gid_change($gid, $from, $to) { |
730 | - $input = array ( |
|
731 | - 'amount' => array ( |
|
730 | + $input = array( |
|
731 | + 'amount' => array( |
|
732 | 732 | 'body' => true, |
733 | 733 | 'speaker' => true, |
734 | 734 | 'comment' => true, |
@@ -752,10 +752,10 @@ discard block |
||
752 | 752 | |
753 | 753 | global $DATA, $this_page; |
754 | 754 | |
755 | - twfy_debug (get_class($this), "getting data by date"); |
|
755 | + twfy_debug(get_class($this), "getting data by date"); |
|
756 | 756 | |
757 | 757 | // Where we'll put all the data we want to render. |
758 | - $data = array (); |
|
758 | + $data = array(); |
|
759 | 759 | |
760 | 760 | $date = $this->_validate_date($args); |
761 | 761 | |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | |
770 | 770 | // Get all the sections for this date. |
771 | 771 | // Then for each of those we'll get the subsections and rows. |
772 | - $input = array ( |
|
773 | - 'amount' => array ( |
|
772 | + $input = array( |
|
773 | + 'amount' => array( |
|
774 | 774 | 'body' => true, |
775 | 775 | 'comment' => true, |
776 | 776 | 'excerpt' => true |
777 | 777 | ), |
778 | - 'where' => array ( |
|
778 | + 'where' => array( |
|
779 | 779 | 'hdate=' => "$date", |
780 | 780 | 'htype=' => '10', |
781 | 781 | 'major=' => $this->major |
@@ -791,20 +791,20 @@ discard block |
||
791 | 791 | $data['rows'] = array(); |
792 | 792 | |
793 | 793 | $num_sections = count($sections); |
794 | - for ($n=0; $n<$num_sections; $n++) { |
|
794 | + for ($n = 0; $n < $num_sections; $n++) { |
|
795 | 795 | // For each section on this date, get the subsections within it. |
796 | 796 | |
797 | 797 | // Get all the section data. |
798 | 798 | $sectionrow = $this->_get_section($sections[$n]); |
799 | 799 | |
800 | 800 | // Get the subsections within the section. |
801 | - $input = array ( |
|
802 | - 'amount' => array ( |
|
801 | + $input = array( |
|
802 | + 'amount' => array( |
|
803 | 803 | 'body' => true, |
804 | 804 | 'comment' => true, |
805 | 805 | 'excerpt' => true |
806 | 806 | ), |
807 | - 'where' => array ( |
|
807 | + 'where' => array( |
|
808 | 808 | 'section_id=' => $sections[$n]['epobject_id'], |
809 | 809 | 'htype=' => '11', |
810 | 810 | 'major=' => $this->major |
@@ -815,10 +815,10 @@ discard block |
||
815 | 815 | $rows = $this->_get_hansard_data($input); |
816 | 816 | |
817 | 817 | // Put the section at the top of the rows array. |
818 | - array_unshift ($rows, $sectionrow); |
|
818 | + array_unshift($rows, $sectionrow); |
|
819 | 819 | |
820 | 820 | // Add the section heading and the subsections to the full list. |
821 | - $data['rows'] = array_merge ($data['rows'], $rows); |
|
821 | + $data['rows'] = array_merge($data['rows'], $rows); |
|
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
@@ -854,9 +854,9 @@ discard block |
||
854 | 854 | $major = ''; |
855 | 855 | } |
856 | 856 | |
857 | - $data = array (); |
|
857 | + $data = array(); |
|
858 | 858 | |
859 | - $q = $this->db->query ("SELECT DISTINCT(hdate) |
|
859 | + $q = $this->db->query("SELECT DISTINCT(hdate) |
|
860 | 860 | FROM hansard |
861 | 861 | $major |
862 | 862 | ORDER BY hdate DESC |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | |
868 | 868 | $URL = new \MySociety\TheyWorkForYou\Url($this->listpage); |
869 | 869 | |
870 | - for ($n=0; $n<$q->rows(); $n++) { |
|
870 | + for ($n = 0; $n < $q->rows(); $n++) { |
|
871 | 871 | $rowdata = array(); |
872 | 872 | |
873 | 873 | $rowdata['body'] = format_date($q->field($n, 'hdate'), SHORTDATEFORMAT); |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | $data = array(); |
897 | 897 | |
898 | 898 | if (!isset($args['person_id'])) { |
899 | - $PAGE->error_message ("Sorry, we need a valid person ID."); |
|
899 | + $PAGE->error_message("Sorry, we need a valid person ID."); |
|
900 | 900 | return $data; |
901 | 901 | } |
902 | 902 | |
@@ -936,8 +936,8 @@ discard block |
||
936 | 936 | |
937 | 937 | $speeches = array(); |
938 | 938 | if ($q->rows() > 0) { |
939 | - for ($n=0; $n<$q->rows(); $n++) { |
|
940 | - $speech = array ( |
|
939 | + for ($n = 0; $n < $q->rows(); $n++) { |
|
940 | + $speech = array( |
|
941 | 941 | 'subsection_id' => $q->field($n, 'subsection_id'), |
942 | 942 | 'section_id' => $q->field($n, 'section_id'), |
943 | 943 | 'htype' => $q->field($n, 'htype'), |
@@ -952,9 +952,9 @@ discard block |
||
952 | 952 | 'gid' => fix_gid_from_db($q->field($n, 'gid')), |
953 | 953 | ); |
954 | 954 | // Cache parent id to speed up _get_listurl |
955 | - $this->epobjectid_to_gid[$q->field($n, 'subsection_id') ] = fix_gid_from_db( $q->field($n, 'gid_subsection') ); |
|
955 | + $this->epobjectid_to_gid[$q->field($n, 'subsection_id')] = fix_gid_from_db($q->field($n, 'gid_subsection')); |
|
956 | 956 | |
957 | - $url_args = array ('p'=>$q->field($n, 'person_id')); |
|
957 | + $url_args = array('p'=>$q->field($n, 'person_id')); |
|
958 | 958 | $speech['listurl'] = $this->_get_listurl($speech, $url_args); |
959 | 959 | $speeches[] = $speech; |
960 | 960 | } |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | if (count($speeches) > 0) { |
964 | 964 | // Get the subsection texts. |
965 | 965 | $num_speeches = count($speeches); |
966 | - for ($n=0; $n<$num_speeches; $n++) { |
|
966 | + for ($n = 0; $n < $num_speeches; $n++) { |
|
967 | 967 | $thing = $hansardmajors[$speeches[$n]['major']]['title']; |
968 | 968 | // Add the parent's body on... |
969 | 969 | $speeches[$n]['parent']['body'] = $speeches[$n]['body_section'] . ' | ' . $thing; |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | // eg, by doing filter_user_input($s, 'strict'); |
1002 | 1002 | $searchstring = $args['s']; |
1003 | 1003 | } else { |
1004 | - if ( isset($args['exceptions']) ) { |
|
1004 | + if (isset($args['exceptions'])) { |
|
1005 | 1005 | throw new \Exception('No search string provided.'); |
1006 | 1006 | } else { |
1007 | 1007 | $PAGE->error_message("No search string"); |
@@ -1010,14 +1010,14 @@ discard block |
||
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | // What we'll return. |
1013 | - $data = array (); |
|
1013 | + $data = array(); |
|
1014 | 1014 | |
1015 | 1015 | $data['info']['s'] = $args['s']; |
1016 | 1016 | |
1017 | 1017 | // Allows us to specify how many results we want |
1018 | 1018 | // Mainly for glossary term adding |
1019 | 1019 | if (isset($args['num']) && $args['num']) { |
1020 | - $results_per_page = $args['num']+0; |
|
1020 | + $results_per_page = $args['num'] + 0; |
|
1021 | 1021 | } |
1022 | 1022 | else { |
1023 | 1023 | $results_per_page = 20; |
@@ -1045,16 +1045,16 @@ discard block |
||
1045 | 1045 | global $SEARCHENGINE; |
1046 | 1046 | |
1047 | 1047 | // For Xapian's equivalent of an SQL LIMIT clause. |
1048 | - $first_result = ($page-1) * $results_per_page; |
|
1048 | + $first_result = ($page - 1) * $results_per_page; |
|
1049 | 1049 | $data['info']['first_result'] = $first_result + 1; // Take account of LIMIT's 0 base. |
1050 | 1050 | |
1051 | 1051 | // Get the gids from Xapian |
1052 | 1052 | $sort_order = 'date'; |
1053 | 1053 | if (isset($args['o'])) { |
1054 | - if ($args['o']=='d') $sort_order = 'newest'; |
|
1055 | - if ($args['o']=='o') $sort_order = 'oldest'; |
|
1056 | - elseif ($args['o']=='c') $sort_order = 'created'; |
|
1057 | - elseif ($args['o']=='r') $sort_order = 'relevance'; |
|
1054 | + if ($args['o'] == 'd') $sort_order = 'newest'; |
|
1055 | + if ($args['o'] == 'o') $sort_order = 'oldest'; |
|
1056 | + elseif ($args['o'] == 'c') $sort_order = 'created'; |
|
1057 | + elseif ($args['o'] == 'r') $sort_order = 'relevance'; |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | $data['searchdescription'] = $SEARCHENGINE->query_description_long(); |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | |
1065 | 1065 | // Log this query so we can improve them - if it wasn't a "popular |
1066 | 1066 | // query" link |
1067 | - if (! isset($args['pop']) or $args['pop'] != 1) { |
|
1067 | + if (!isset($args['pop']) or $args['pop'] != 1) { |
|
1068 | 1068 | global $SEARCHLOG; |
1069 | 1069 | $SEARCHLOG->add( |
1070 | 1070 | array('query' => $searchstring, |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | |
1080 | 1080 | $SEARCHENGINE->run_search($first_result, $results_per_page, $sort_order); |
1081 | 1081 | $gids = $SEARCHENGINE->get_gids(); |
1082 | - if ($sort_order=='created') { |
|
1082 | + if ($sort_order == 'created') { |
|
1083 | 1083 | $createds = $SEARCHENGINE->get_createds(); |
1084 | 1084 | } |
1085 | 1085 | $relevances = $SEARCHENGINE->get_relevances(); |
@@ -1095,13 +1095,13 @@ discard block |
||
1095 | 1095 | |
1096 | 1096 | // Cycle through each result, munge the data, get more, and put it all in $data. |
1097 | 1097 | $num_gids = count($gids); |
1098 | - for ($n=0; $n<$num_gids; $n++) { |
|
1098 | + for ($n = 0; $n < $num_gids; $n++) { |
|
1099 | 1099 | $gid = $gids[$n]; |
1100 | 1100 | $relevancy = $relevances[$n]; |
1101 | 1101 | $collapsed = $SEARCHENGINE->collapsed[$n]; |
1102 | - if ($sort_order=='created') { |
|
1102 | + if ($sort_order == 'created') { |
|
1103 | 1103 | #$created = substr($createds[$n], 0, strpos($createds[$n], ':')); |
1104 | - if ($createds[$n]<$args['threshold']) { |
|
1104 | + if ($createds[$n] < $args['threshold']) { |
|
1105 | 1105 | $data['info']['total_results'] = $n; |
1106 | 1106 | break; |
1107 | 1107 | } |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | , array(':gid' => $gid)); |
1164 | 1164 | |
1165 | 1165 | if ($q->rows() > 1) { |
1166 | - if ( $isset($args['exceptions']) ) { |
|
1166 | + if ($isset($args['exceptions'])) { |
|
1167 | 1167 | throw new \Exception("Got more than one row getting data for $gid."); |
1168 | 1168 | } else { |
1169 | 1169 | $PAGE->error_message("Got more than one row getting data for $gid"); |
@@ -1177,14 +1177,14 @@ discard block |
||
1177 | 1177 | |
1178 | 1178 | $itemdata = $q->row(0); |
1179 | 1179 | $itemdata['collapsed'] = $collapsed; |
1180 | - $itemdata['gid'] = fix_gid_from_db( $q->field(0, 'gid') ); |
|
1180 | + $itemdata['gid'] = fix_gid_from_db($q->field(0, 'gid')); |
|
1181 | 1181 | $itemdata['relevance'] = $relevancy; |
1182 | 1182 | $itemdata['extract'] = $this->prepare_search_result_for_display($q->field(0, 'body')); |
1183 | 1183 | |
1184 | 1184 | ////////////////////////// |
1185 | 1185 | // 2. Create the URL to link to this bit of text. |
1186 | 1186 | |
1187 | - $id_data = array ( |
|
1187 | + $id_data = array( |
|
1188 | 1188 | 'major' => $itemdata['major'], |
1189 | 1189 | 'minor' => $itemdata['minor'], |
1190 | 1190 | 'htype' => $itemdata['htype'], |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | |
1196 | 1196 | // We append the query onto the end of the URL as variable 's' |
1197 | 1197 | // so we can highlight them on the debate/wrans list page. |
1198 | - $url_args = array ('s' => $searchstring); |
|
1198 | + $url_args = array('s' => $searchstring); |
|
1199 | 1199 | |
1200 | 1200 | $itemdata['listurl'] = $this->_get_listurl($id_data, $url_args, $encode); |
1201 | 1201 | |
@@ -1241,14 +1241,14 @@ discard block |
||
1241 | 1241 | if (isset($subsection['body'])) $body .= ': ' . $subsection['body']; |
1242 | 1242 | if (isset($subsection['listurl'])) $listurl = $subsection['listurl']; |
1243 | 1243 | else $listurl = ''; |
1244 | - $itemdata['parent'] = array ( |
|
1244 | + $itemdata['parent'] = array( |
|
1245 | 1245 | 'body' => $body, |
1246 | 1246 | 'listurl' => $listurl |
1247 | 1247 | ); |
1248 | 1248 | if ($itemdata['htype'] == 11) { |
1249 | 1249 | # Search result was a subsection heading; fetch the first entry |
1250 | 1250 | # from the wrans/wms to show under the heading |
1251 | - $input = array ( |
|
1251 | + $input = array( |
|
1252 | 1252 | 'amount' => array( |
1253 | 1253 | 'body' => true, |
1254 | 1254 | 'speaker' => true |
@@ -1303,7 +1303,7 @@ discard block |
||
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | // Trim it to length and position, adding ellipses. |
1306 | - $extract = trim_characters ($extract, $startpos, $length_of_extract); |
|
1306 | + $extract = trim_characters($extract, $startpos, $length_of_extract); |
|
1307 | 1307 | |
1308 | 1308 | // Highlight search words |
1309 | 1309 | $extract = $SEARCHENGINE->highlight($extract); |
@@ -1490,7 +1490,7 @@ discard block |
||
1490 | 1490 | |
1491 | 1491 | $params[':major'] = $this->major; |
1492 | 1492 | $params[':firstdate'] = $firstyear . '-' . $firstmonth . '-01'; |
1493 | - $q = $this->db->query("SELECT DISTINCT(hdate) AS hdate |
|
1493 | + $q = $this->db->query("SELECT DISTINCT(hdate) AS hdate |
|
1494 | 1494 | FROM hansard |
1495 | 1495 | WHERE major = :major |
1496 | 1496 | AND hdate >= :firstdate |
@@ -1503,7 +1503,7 @@ discard block |
||
1503 | 1503 | // We put the data in this array. See top of function for the structure. |
1504 | 1504 | $years = array(); |
1505 | 1505 | |
1506 | - for ($row=0; $row<$q->rows(); $row++) { |
|
1506 | + for ($row = 0; $row < $q->rows(); $row++) { |
|
1507 | 1507 | |
1508 | 1508 | list($year, $month, $day) = explode('-', $q->field($row, 'hdate')); |
1509 | 1509 | |
@@ -1557,9 +1557,9 @@ discard block |
||
1557 | 1557 | if ($action == 'recentyear') { |
1558 | 1558 | // Assuming there will be a previous year! |
1559 | 1559 | |
1560 | - $YEARURL->insert(array('y'=> $firstyear-1)); |
|
1560 | + $YEARURL->insert(array('y'=> $firstyear - 1)); |
|
1561 | 1561 | |
1562 | - $nextprev['prev'] = array ( |
|
1562 | + $nextprev['prev'] = array( |
|
1563 | 1563 | 'body' => 'Previous year', |
1564 | 1564 | 'title' => $firstyear - 1, |
1565 | 1565 | 'url' => $YEARURL->generate() |
@@ -1567,8 +1567,8 @@ discard block |
||
1567 | 1567 | |
1568 | 1568 | } else { // action is 'year'. |
1569 | 1569 | |
1570 | - $nextprev['prev'] = array ('body' => 'Previous year'); |
|
1571 | - $nextprev['next'] = array ('body' => 'Next year'); |
|
1570 | + $nextprev['prev'] = array('body' => 'Previous year'); |
|
1571 | + $nextprev['next'] = array('body' => 'Next year'); |
|
1572 | 1572 | |
1573 | 1573 | $q = $this->db->query("SELECT DATE_FORMAT(hdate, '%Y') AS year |
1574 | 1574 | FROM hansard WHERE major = :major |
@@ -1616,7 +1616,7 @@ discard block |
||
1616 | 1616 | from mentions where gid like 'uk.org.publicwhip/spq/$spid' |
1617 | 1617 | order by date, type"); |
1618 | 1618 | $nrows = $q->rows(); |
1619 | - for ($i=0; $i < $nrows; $i++) { |
|
1619 | + for ($i = 0; $i < $nrows; $i++) { |
|
1620 | 1620 | $result[$i] = $q->row($i); |
1621 | 1621 | } |
1622 | 1622 | return $result; |
@@ -1663,14 +1663,14 @@ discard block |
||
1663 | 1663 | // $input['limit'] as a string for the $limit clause, eg '21,20'. |
1664 | 1664 | |
1665 | 1665 | $amount = isset($input['amount']) ? $input['amount'] : array(); |
1666 | - $wherearr = isset($input['where']) ? $input['where'] : array(); |
|
1666 | + $wherearr = isset($input['where']) ? $input['where'] : array(); |
|
1667 | 1667 | $order = isset($input['order']) ? $input['order'] : ''; |
1668 | 1668 | $limit = isset($input['limit']) ? $input['limit'] : ''; |
1669 | 1669 | |
1670 | 1670 | |
1671 | 1671 | // The fields to fetch from db. 'table' => array ('field1', 'field2'). |
1672 | - $fieldsarr = array ( |
|
1673 | - 'hansard' => array ('epobject_id', 'htype', 'gid', 'hpos', 'section_id', 'subsection_id', 'hdate', 'htime', 'source_url', 'major', 'minor', 'video_status', 'colnum') |
|
1672 | + $fieldsarr = array( |
|
1673 | + 'hansard' => array('epobject_id', 'htype', 'gid', 'hpos', 'section_id', 'subsection_id', 'hdate', 'htime', 'source_url', 'major', 'minor', 'video_status', 'colnum') |
|
1674 | 1674 | ); |
1675 | 1675 | |
1676 | 1676 | $params = array(); |
@@ -1682,23 +1682,23 @@ discard block |
||
1682 | 1682 | if ((isset($amount['body']) && $amount['body'] == true) || |
1683 | 1683 | (isset($amount['comment']) && $amount['comment'] == true) |
1684 | 1684 | ) { |
1685 | - $fieldsarr['epobject'] = array ('body'); |
|
1685 | + $fieldsarr['epobject'] = array('body'); |
|
1686 | 1686 | $join = 'LEFT OUTER JOIN epobject ON hansard.epobject_id = epobject.epobject_id'; |
1687 | 1687 | } else { |
1688 | 1688 | $join = ''; |
1689 | 1689 | } |
1690 | 1690 | |
1691 | 1691 | |
1692 | - $fieldsarr2 = array (); |
|
1692 | + $fieldsarr2 = array(); |
|
1693 | 1693 | // Construct the $fields clause. |
1694 | 1694 | foreach ($fieldsarr as $table => $tablesfields) { |
1695 | 1695 | foreach ($tablesfields as $n => $field) { |
1696 | - $fieldsarr2[] = $table.'.'.$field; |
|
1696 | + $fieldsarr2[] = $table . '.' . $field; |
|
1697 | 1697 | } |
1698 | 1698 | } |
1699 | 1699 | $fields = implode(', ', $fieldsarr2); |
1700 | 1700 | |
1701 | - $wherearr2 = array (); |
|
1701 | + $wherearr2 = array(); |
|
1702 | 1702 | // Construct the $where clause. |
1703 | 1703 | $i = 0; |
1704 | 1704 | foreach ($wherearr as $key => $val) { |
@@ -1706,7 +1706,7 @@ discard block |
||
1706 | 1706 | $wherearr2[] = "$key :where$i"; |
1707 | 1707 | $i++; |
1708 | 1708 | } |
1709 | - $where = implode (" AND ", $wherearr2); |
|
1709 | + $where = implode(" AND ", $wherearr2); |
|
1710 | 1710 | |
1711 | 1711 | |
1712 | 1712 | if ($order != '') { |
@@ -1724,7 +1724,7 @@ discard block |
||
1724 | 1724 | } |
1725 | 1725 | |
1726 | 1726 | // Finally, do the query! |
1727 | - $q = $this->db->query ("SELECT $fields |
|
1727 | + $q = $this->db->query("SELECT $fields |
|
1728 | 1728 | FROM hansard |
1729 | 1729 | $join |
1730 | 1730 | WHERE $where |
@@ -1733,11 +1733,11 @@ discard block |
||
1733 | 1733 | ", $params); |
1734 | 1734 | |
1735 | 1735 | // Format the data into an array for returning. |
1736 | - $data = array (); |
|
1736 | + $data = array(); |
|
1737 | 1737 | |
1738 | 1738 | if ($q->rows() > 0) { |
1739 | 1739 | |
1740 | - for ($n=0; $n<$q->rows(); $n++) { |
|
1740 | + for ($n = 0; $n < $q->rows(); $n++) { |
|
1741 | 1741 | |
1742 | 1742 | // Where we'll store the data for this item before adding |
1743 | 1743 | // it to $data. |
@@ -1753,23 +1753,23 @@ discard block |
||
1753 | 1753 | if (isset($item['gid'])) { |
1754 | 1754 | // Remove the "uk.org.publicwhip/blah/" from the gid: |
1755 | 1755 | // (In includes/utility.php) |
1756 | - $item['gid'] = fix_gid_from_db( $item['gid'] ); |
|
1756 | + $item['gid'] = fix_gid_from_db($item['gid']); |
|
1757 | 1757 | } |
1758 | 1758 | |
1759 | 1759 | // Add mentions if (a) it's a question in the written |
1760 | 1760 | // answer section or (b) it's in the official reports |
1761 | 1761 | // and the body text ends in a bracketed SPID. |
1762 | - if (($this->major && $hansardmajors[$this->major]['page']=='spwrans') && ($item['htype'] == '12' && $item['minor'] == '1')) { |
|
1762 | + if (($this->major && $hansardmajors[$this->major]['page'] == 'spwrans') && ($item['htype'] == '12' && $item['minor'] == '1')) { |
|
1763 | 1763 | // Get out the SPID: |
1764 | - if ( preg_match('#\d{4}-\d\d-\d\d\.(.*?)\.q#', $item['gid'], $m) ) { |
|
1764 | + if (preg_match('#\d{4}-\d\d-\d\d\.(.*?)\.q#', $item['gid'], $m)) { |
|
1765 | 1765 | $item['mentions'] = $this->_get_mentions($m[1]); |
1766 | 1766 | } |
1767 | 1767 | } |
1768 | 1768 | |
1769 | 1769 | // The second case (b): |
1770 | - if (($this->major && $hansardmajors[$this->major]['page']=='spdebates') && isset($item['body'])) { |
|
1771 | - $stripped_body = preg_replace('/<[^>]+>/ms','',$item['body']); |
|
1772 | - if ( preg_match('/\((S\d+\w+-\d+)\)/ms',$stripped_body,$m) ) { |
|
1770 | + if (($this->major && $hansardmajors[$this->major]['page'] == 'spdebates') && isset($item['body'])) { |
|
1771 | + $stripped_body = preg_replace('/<[^>]+>/ms', '', $item['body']); |
|
1772 | + if (preg_match('/\((S\d+\w+-\d+)\)/ms', $stripped_body, $m)) { |
|
1773 | 1773 | $item['mentions'] = $this->_get_mentions($m[1]); |
1774 | 1774 | } |
1775 | 1775 | } |
@@ -1782,7 +1782,7 @@ discard block |
||
1782 | 1782 | // Get the number of items within a section or subsection. |
1783 | 1783 | // It could be that we can do this in the main query? |
1784 | 1784 | // Not sure. |
1785 | - if ( ($this->major && $hansardmajors[$this->major]['type']=='debate') && ($item['htype'] == '10' || $item['htype'] == '11') ) { |
|
1785 | + if (($this->major && $hansardmajors[$this->major]['type'] == 'debate') && ($item['htype'] == '10' || $item['htype'] == '11')) { |
|
1786 | 1786 | |
1787 | 1787 | if ($item['htype'] == '10') { |
1788 | 1788 | // Section - get a count of items within this section that |
@@ -1843,7 +1843,7 @@ discard block |
||
1843 | 1843 | // 'commentsurl' is the URL of the item on its own page, with comments. |
1844 | 1844 | |
1845 | 1845 | // All the things we need to work out a listurl! |
1846 | - $item_data = array ( |
|
1846 | + $item_data = array( |
|
1847 | 1847 | 'major' => $this->major, |
1848 | 1848 | 'minor' => $item['minor'], |
1849 | 1849 | 'htype' => $item['htype'], |
@@ -1876,11 +1876,11 @@ discard block |
||
1876 | 1876 | $item['htype'] == '12') { |
1877 | 1877 | // Debate speech or written answers (not questions). |
1878 | 1878 | |
1879 | - $item['votes'] = $this->_get_votes( $item['epobject_id'] ); |
|
1879 | + $item['votes'] = $this->_get_votes($item['epobject_id']); |
|
1880 | 1880 | } |
1881 | 1881 | |
1882 | 1882 | // Get the speaker for this item, if applicable. |
1883 | - if ( (isset($amount['speaker']) && $amount['speaker'] == true) && |
|
1883 | + if ((isset($amount['speaker']) && $amount['speaker'] == true) && |
|
1884 | 1884 | $item['person_id'] != '') { |
1885 | 1885 | |
1886 | 1886 | $item['speaker'] = $this->_get_speaker($item['person_id'], $item['hdate'], $item['htime'], $item['major']); |
@@ -1891,7 +1891,7 @@ discard block |
||
1891 | 1891 | if (isset($amount['comment']) && $amount['comment'] == true) { |
1892 | 1892 | |
1893 | 1893 | // All the things we need to get the comment data. |
1894 | - $item_data = array ( |
|
1894 | + $item_data = array( |
|
1895 | 1895 | 'htype' => $item['htype'], |
1896 | 1896 | 'epobject_id' => $item['epobject_id'] |
1897 | 1897 | ); |
@@ -1965,7 +1965,7 @@ discard block |
||
1965 | 1965 | } |
1966 | 1966 | |
1967 | 1967 | |
1968 | - public function _get_listurl ($id_data, $url_args=array(), $encode='html') { |
|
1968 | + public function _get_listurl($id_data, $url_args = array(), $encode = 'html') { |
|
1969 | 1969 | global $hansardmajors; |
1970 | 1970 | // Generates an item's listurl - this is the 'contextual' url |
1971 | 1971 | // for an item, in the full list view with an anchor (if appropriate). |
@@ -1994,7 +1994,7 @@ discard block |
||
1994 | 1994 | $DATA->set_page_metadata('pbc_clause', 'url', 'pbc/' . $this->url . $id); |
1995 | 1995 | $LISTURL->remove(array('id')); |
1996 | 1996 | } else { |
1997 | - $LISTURL->insert( array( 'id' => $id_data['gid'] ) ); |
|
1997 | + $LISTURL->insert(array('id' => $id_data['gid'])); |
|
1998 | 1998 | } |
1999 | 1999 | } else { |
2000 | 2000 | // A debate speech or question/answer, etc. |
@@ -2007,10 +2007,10 @@ discard block |
||
2007 | 2007 | // Find the gid of this item's (sub)section. |
2008 | 2008 | $parent_gid = ''; |
2009 | 2009 | |
2010 | - if (isset($this->epobjectid_to_gid[ $parent_epobject_id ])) { |
|
2010 | + if (isset($this->epobjectid_to_gid[$parent_epobject_id])) { |
|
2011 | 2011 | // We've previously cached the gid for this epobject_id, so use that. |
2012 | 2012 | |
2013 | - $parent_gid = $this->epobjectid_to_gid[ $parent_epobject_id ]; |
|
2013 | + $parent_gid = $this->epobjectid_to_gid[$parent_epobject_id]; |
|
2014 | 2014 | |
2015 | 2015 | } else { |
2016 | 2016 | // We haven't cached the gid, so fetch from db. |
@@ -2023,10 +2023,10 @@ discard block |
||
2023 | 2023 | if ($r->rows() > 0) { |
2024 | 2024 | // Remove the "uk.org.publicwhip/blah/" from the gid: |
2025 | 2025 | // (In includes/utility.php) |
2026 | - $parent_gid = fix_gid_from_db( $r->field(0, 'gid') ); |
|
2026 | + $parent_gid = fix_gid_from_db($r->field(0, 'gid')); |
|
2027 | 2027 | |
2028 | 2028 | // Cache it for if we need it again: |
2029 | - $this->epobjectid_to_gid[ $parent_epobject_id ] = $parent_gid; |
|
2029 | + $this->epobjectid_to_gid[$parent_epobject_id] = $parent_gid; |
|
2030 | 2030 | } |
2031 | 2031 | } |
2032 | 2032 | |
@@ -2036,18 +2036,18 @@ discard block |
||
2036 | 2036 | if (isset($this->bill_lookup[$minor])) { |
2037 | 2037 | list($title, $session) = $this->bill_lookup[$minor]; |
2038 | 2038 | } else { |
2039 | - $qq = $this->db->query('select title, session from bills where id='.$minor); |
|
2039 | + $qq = $this->db->query('select title, session from bills where id=' . $minor); |
|
2040 | 2040 | $title = $qq->field(0, 'title'); |
2041 | 2041 | $session = $qq->field(0, 'session'); |
2042 | 2042 | $this->bill_lookup[$minor] = array($title, $session); |
2043 | 2043 | } |
2044 | - $url = "$session/" . urlencode(str_replace(' ','_',$title)); |
|
2044 | + $url = "$session/" . urlencode(str_replace(' ', '_', $title)); |
|
2045 | 2045 | $parent_gid = preg_replace('#^.*?_.*?_#', '', $parent_gid); |
2046 | 2046 | global $DATA; |
2047 | 2047 | $DATA->set_page_metadata('pbc_clause', 'url', "pbc/$url/$parent_gid"); |
2048 | 2048 | $LISTURL->remove(array('id')); |
2049 | 2049 | } else { |
2050 | - $LISTURL->insert( array( 'id' => $parent_gid ) ); |
|
2050 | + $LISTURL->insert(array('id' => $parent_gid)); |
|
2051 | 2051 | } |
2052 | 2052 | // Use a truncated form of this item's gid for the anchor. |
2053 | 2053 | $fragment = '#g' . gid_to_anchor($id_data['gid']); |
@@ -2055,7 +2055,7 @@ discard block |
||
2055 | 2055 | } |
2056 | 2056 | |
2057 | 2057 | if (count($url_args) > 0) { |
2058 | - $LISTURL->insert( $url_args); |
|
2058 | + $LISTURL->insert($url_args); |
|
2059 | 2059 | } |
2060 | 2060 | |
2061 | 2061 | return $LISTURL->generate($encode) . $fragment; |
@@ -2118,10 +2118,10 @@ discard block |
||
2118 | 2118 | $member = $this->_get_speaker_alone($q->data, $person_id, $hdate, $htime, $major); |
2119 | 2119 | |
2120 | 2120 | $URL = $this->_get_speaker_url($member['house']); |
2121 | - $URL->insert( array ('p' => $person_id) ); |
|
2121 | + $URL->insert(array('p' => $person_id)); |
|
2122 | 2122 | |
2123 | 2123 | $name = member_full_name($member['house'], $member['title'], $member['given_name'], $member['family_name'], $member['lordofname']); |
2124 | - $speaker = array ( |
|
2124 | + $speaker = array( |
|
2125 | 2125 | 'member_id' => $member['member_id'], |
2126 | 2126 | "name" => $name, |
2127 | 2127 | 'house' => $member['house'], |
@@ -2168,13 +2168,13 @@ discard block |
||
2168 | 2168 | |
2169 | 2169 | private function _get_speaker_url($house) { |
2170 | 2170 | $URL = new \MySociety\TheyWorkForYou\Url('mp'); # Default, house=1 |
2171 | - if ($house==2) { |
|
2171 | + if ($house == 2) { |
|
2172 | 2172 | $URL = new \MySociety\TheyWorkForYou\Url('peer'); |
2173 | - } elseif ($house==3) { |
|
2173 | + } elseif ($house == 3) { |
|
2174 | 2174 | $URL = new \MySociety\TheyWorkForYou\Url('mla'); |
2175 | - } elseif ($house==4) { |
|
2175 | + } elseif ($house == 4) { |
|
2176 | 2176 | $URL = new \MySociety\TheyWorkForYou\Url('msp'); |
2177 | - } elseif ($house==0) { |
|
2177 | + } elseif ($house == 0) { |
|
2178 | 2178 | $URL = new \MySociety\TheyWorkForYou\Url('royal'); |
2179 | 2179 | } |
2180 | 2180 | return $URL; |
@@ -2190,7 +2190,7 @@ discard block |
||
2190 | 2190 | if (!$rows) { |
2191 | 2191 | return $offices; |
2192 | 2192 | } |
2193 | - for ($row=0; $row<$rows; $row++) { |
|
2193 | + for ($row = 0; $row < $rows; $row++) { |
|
2194 | 2194 | $dept = $q->field($row, 'dept'); |
2195 | 2195 | $pos = $q->field($row, 'position'); |
2196 | 2196 | $source = $q->field($row, 'source'); |
@@ -2249,12 +2249,12 @@ discard block |
||
2249 | 2249 | array(':epobject_id' => $item_data['epobject_id'])); |
2250 | 2250 | |
2251 | 2251 | // Add this comment to the data structure. |
2252 | - $comment = array ( |
|
2252 | + $comment = array( |
|
2253 | 2253 | 'comment_id' => $q->field(0, 'comment_id'), |
2254 | 2254 | 'user_id' => $q->field(0, 'user_id'), |
2255 | 2255 | 'body' => $q->field(0, 'body'), |
2256 | 2256 | 'posted' => $q->field(0, 'posted'), |
2257 | - 'username' => $q->field(0, 'firstname') .' '. $q->field(0, 'lastname') |
|
2257 | + 'username' => $q->field(0, 'firstname') . ' ' . $q->field(0, 'lastname') |
|
2258 | 2258 | ); |
2259 | 2259 | } |
2260 | 2260 | |
@@ -2264,7 +2264,7 @@ discard block |
||
2264 | 2264 | // or subsection itself, only the items within them. So |
2265 | 2265 | // we don't get the most recent comment. Because there isn't one. |
2266 | 2266 | |
2267 | - $return = array ( |
|
2267 | + $return = array( |
|
2268 | 2268 | 'totalcomments' => $totalcomments, |
2269 | 2269 | 'comment' => $comment |
2270 | 2270 | ); |
@@ -2278,7 +2278,7 @@ discard block |
||
2278 | 2278 | // What it says on the tin. |
2279 | 2279 | // $item_data must have 'htype' and 'epobject_id' elements. TODO: Check for major==4 |
2280 | 2280 | |
2281 | - if (($hansardmajors[$this->major]['type']=='debate') && |
|
2281 | + if (($hansardmajors[$this->major]['type'] == 'debate') && |
|
2282 | 2282 | ($item_data['htype'] == '10' || $item_data['htype'] == '11') |
2283 | 2283 | ) { |
2284 | 2284 | // We'll be getting a count of the comments on all items |
@@ -2362,7 +2362,7 @@ discard block |
||
2362 | 2362 | // Then depending on what htype it is, we get the data for other items too. |
2363 | 2363 | global $DATA, $this_page, $hansardmajors; |
2364 | 2364 | |
2365 | - twfy_debug (get_class($this), "getting data by gid"); |
|
2365 | + twfy_debug(get_class($this), "getting data by gid"); |
|
2366 | 2366 | |
2367 | 2367 | // Get the information about the item this URL refers to. |
2368 | 2368 | $itemdata = $this->_get_item($args); |
@@ -2371,25 +2371,25 @@ discard block |
||
2371 | 2371 | } |
2372 | 2372 | |
2373 | 2373 | // If part of a Written Answer (just question or just answer), select the whole thing |
2374 | - if (isset($itemdata['major']) && $hansardmajors[$itemdata['major']]['type']=='other' and ($itemdata['htype'] == '12' or $itemdata['htype'] == '13')) { |
|
2374 | + if (isset($itemdata['major']) && $hansardmajors[$itemdata['major']]['type'] == 'other' and ($itemdata['htype'] == '12' or $itemdata['htype'] == '13')) { |
|
2375 | 2375 | // find the gid of the subheading which holds this part |
2376 | - $input = array ( |
|
2376 | + $input = array( |
|
2377 | 2377 | 'amount' => array('gid' => true), |
2378 | - 'where' => array ( |
|
2378 | + 'where' => array( |
|
2379 | 2379 | 'epobject_id=' => $itemdata['subsection_id'], |
2380 | 2380 | ), |
2381 | 2381 | ); |
2382 | 2382 | $parent = $this->_get_hansard_data($input); |
2383 | 2383 | // display that item, i.e. the whole of the Written Answer |
2384 | - twfy_debug (get_class($this), "instead of " . $args['gid'] . " selecting subheading gid " . $parent[0]['gid'] . " to get whole wrans"); |
|
2384 | + twfy_debug(get_class($this), "instead of " . $args['gid'] . " selecting subheading gid " . $parent[0]['gid'] . " to get whole wrans"); |
|
2385 | 2385 | $args['gid'] = $parent[0]['gid']; |
2386 | 2386 | $this->_get_item($args); |
2387 | 2387 | throw new RedirectException($args['gid']); |
2388 | 2388 | } |
2389 | 2389 | |
2390 | 2390 | # If a WMS main heading, go to next gid |
2391 | - if (isset($itemdata['major']) && $itemdata['major']==4 && $itemdata['htype'] == '10') { |
|
2392 | - $input = array ( |
|
2391 | + if (isset($itemdata['major']) && $itemdata['major'] == 4 && $itemdata['htype'] == '10') { |
|
2392 | + $input = array( |
|
2393 | 2393 | 'amount' => array('gid' => true), |
2394 | 2394 | 'where' => array( |
2395 | 2395 | 'section_id=' => $itemdata['epobject_id'], |
@@ -2399,7 +2399,7 @@ discard block |
||
2399 | 2399 | ); |
2400 | 2400 | $next = $this->_get_hansard_data($input); |
2401 | 2401 | if (!empty($next)) { |
2402 | - twfy_debug (get_class($this), 'instead of ' . $args['gid'] . ' moving to ' . $next[0]['gid']); |
|
2402 | + twfy_debug(get_class($this), 'instead of ' . $args['gid'] . ' moving to ' . $next[0]['gid']); |
|
2403 | 2403 | $args['gid'] = $next[0]['gid']; |
2404 | 2404 | $this->_get_item($args); |
2405 | 2405 | throw new RedirectException($args['gid']); |
@@ -2451,16 +2451,16 @@ discard block |
||
2451 | 2451 | // Get the nextprev links for this item, to link to next/prev pages. |
2452 | 2452 | // Duh. |
2453 | 2453 | if ($itemdata['htype'] == '10') { |
2454 | - $nextprev = $this->_get_nextprev_items( $sectionrow ); |
|
2454 | + $nextprev = $this->_get_nextprev_items($sectionrow); |
|
2455 | 2455 | $data['info']['text_heading'] = $itemdata['body']; |
2456 | 2456 | |
2457 | 2457 | } elseif ($itemdata['htype'] == '11') { |
2458 | - $nextprev = $this->_get_nextprev_items( $subsectionrow ); |
|
2458 | + $nextprev = $this->_get_nextprev_items($subsectionrow); |
|
2459 | 2459 | $data['info']['text_heading'] = $itemdata['body']; |
2460 | 2460 | |
2461 | 2461 | } else { |
2462 | 2462 | // Ordinary lowly item. |
2463 | - $nextprev = $this->_get_nextprev_items( $itemdata ); |
|
2463 | + $nextprev = $this->_get_nextprev_items($itemdata); |
|
2464 | 2464 | |
2465 | 2465 | if (isset($subsectionrow['gid'])) { |
2466 | 2466 | $nextprev['up']['url'] = $subsectionrow['listurl']; |
@@ -2469,7 +2469,7 @@ discard block |
||
2469 | 2469 | $nextprev['up']['url'] = $sectionrow['listurl']; |
2470 | 2470 | $nextprev['up']['title'] = $sectionrow['body']; |
2471 | 2471 | } |
2472 | - $nextprev['up']['body'] = 'See the whole debate'; |
|
2472 | + $nextprev['up']['body'] = 'See the whole debate'; |
|
2473 | 2473 | } |
2474 | 2474 | |
2475 | 2475 | // We can then access this from $PAGE and the templates. |
@@ -2478,7 +2478,7 @@ discard block |
||
2478 | 2478 | // Now get all the non-heading rows. |
2479 | 2479 | |
2480 | 2480 | // What data do we want for each item? |
2481 | - $amount = array ( |
|
2481 | + $amount = array( |
|
2482 | 2482 | 'body' => true, |
2483 | 2483 | 'speaker' => true, |
2484 | 2484 | 'comment' => true, |
@@ -2491,9 +2491,9 @@ discard block |
||
2491 | 2491 | |
2492 | 2492 | # $sectionrow['trackback'] = $this->_get_trackback_data($sectionrow); |
2493 | 2493 | |
2494 | - $input = array ( |
|
2494 | + $input = array( |
|
2495 | 2495 | 'amount' => $amount, |
2496 | - 'where' => array ( |
|
2496 | + 'where' => array( |
|
2497 | 2497 | 'section_id=' => $itemdata['epobject_id'], |
2498 | 2498 | 'subsection_id=' => $itemdata['epobject_id'] |
2499 | 2499 | ), |
@@ -2501,15 +2501,15 @@ discard block |
||
2501 | 2501 | ); |
2502 | 2502 | |
2503 | 2503 | $data['rows'] = $this->_get_hansard_data($input); |
2504 | - if (!count($data['rows']) || (count($data['rows'])==1 && strstr($data['rows'][0]['body'], 'was asked'))) { |
|
2504 | + if (!count($data['rows']) || (count($data['rows']) == 1 && strstr($data['rows'][0]['body'], 'was asked'))) { |
|
2505 | 2505 | |
2506 | - $input = array ( |
|
2507 | - 'amount' => array ( |
|
2506 | + $input = array( |
|
2507 | + 'amount' => array( |
|
2508 | 2508 | 'body' => true, |
2509 | 2509 | 'comment' => true, |
2510 | 2510 | 'excerpt' => true |
2511 | 2511 | ), |
2512 | - 'where' => array ( |
|
2512 | + 'where' => array( |
|
2513 | 2513 | 'section_id=' => $sectionrow['epobject_id'], |
2514 | 2514 | 'htype=' => '11', |
2515 | 2515 | 'major=' => $this->major |
@@ -2527,9 +2527,9 @@ discard block |
||
2527 | 2527 | |
2528 | 2528 | # $subsectionrow['trackback'] = $this->_get_trackback_data($subsectionrow); |
2529 | 2529 | |
2530 | - $input = array ( |
|
2530 | + $input = array( |
|
2531 | 2531 | 'amount' => $amount, |
2532 | - 'where' => array ( |
|
2532 | + 'where' => array( |
|
2533 | 2533 | 'subsection_id=' => $itemdata['epobject_id'] |
2534 | 2534 | ), |
2535 | 2535 | 'order' => 'hpos ASC' |
@@ -2552,10 +2552,10 @@ discard block |
||
2552 | 2552 | $subsectionrow['gid'] != $sectionrow['gid']) { |
2553 | 2553 | // If we're looking at a section, there may not be a subsection. |
2554 | 2554 | // And if the subsectionrow and sectionrow aren't the same. |
2555 | - array_unshift ($data['rows'], $subsectionrow); |
|
2555 | + array_unshift($data['rows'], $subsectionrow); |
|
2556 | 2556 | } |
2557 | 2557 | |
2558 | - array_unshift ($data['rows'], $sectionrow); |
|
2558 | + array_unshift($data['rows'], $sectionrow); |
|
2559 | 2559 | |
2560 | 2560 | return $data; |
2561 | 2561 | |
@@ -2564,10 +2564,10 @@ discard block |
||
2564 | 2564 | public function _get_data_by_column($args) { |
2565 | 2565 | global $this_page; |
2566 | 2566 | |
2567 | - twfy_debug (get_class($this), "getting data by column"); |
|
2567 | + twfy_debug(get_class($this), "getting data by column"); |
|
2568 | 2568 | |
2569 | - $input = array( 'amount' => array('body'=>true, 'comment'=>true, 'speaker'=>true), |
|
2570 | - 'where' => array( 'hdate='=>$args['date'], 'major=' => $this->major, 'gid LIKE ' =>'%.'.$args['column'].'.%' ), |
|
2569 | + $input = array('amount' => array('body'=>true, 'comment'=>true, 'speaker'=>true), |
|
2570 | + 'where' => array('hdate='=>$args['date'], 'major=' => $this->major, 'gid LIKE ' =>'%.' . $args['column'] . '.%'), |
|
2571 | 2571 | 'order' => 'hpos' |
2572 | 2572 | ); |
2573 | 2573 | $data = $this->_get_hansard_data($input); |
@@ -2626,8 +2626,8 @@ discard block |
||
2626 | 2626 | public function get_gid_from_spid($spid) { |
2627 | 2627 | // Fix the common errors of S.0 instead of S.O and leading |
2628 | 2628 | // zeros in the numbers: |
2629 | - $fixed_spid = preg_replace('/(S[0-9]+)0-([0-9]+)/','${1}O-${2}',$spid); |
|
2630 | - $fixed_spid = preg_replace('/(S[0-9]+\w+)-0*([0-9]+)/','${1}-${2}',$fixed_spid); |
|
2629 | + $fixed_spid = preg_replace('/(S[0-9]+)0-([0-9]+)/', '${1}O-${2}', $spid); |
|
2630 | + $fixed_spid = preg_replace('/(S[0-9]+\w+)-0*([0-9]+)/', '${1}-${2}', $fixed_spid); |
|
2631 | 2631 | $q = $this->db->query( |
2632 | 2632 | "select mentioned_gid from mentions where gid = :gid_from_spid and (type = 4 or type = 6)", |
2633 | 2633 | array(':gid_from_spid' => 'uk.org.publicwhip/spq/' . $fixed_spid) |
@@ -2702,14 +2702,14 @@ discard block |
||
2702 | 2702 | ", array(':major' => $this->major)); |
2703 | 2703 | |
2704 | 2704 | // What we return. |
2705 | - $data = array (); |
|
2705 | + $data = array(); |
|
2706 | 2706 | $speeches = array(); |
2707 | 2707 | |
2708 | 2708 | if ($q->rows() > 0) { |
2709 | 2709 | |
2710 | - for ($n=0; $n<$q->rows(); $n++) { |
|
2710 | + for ($n = 0; $n < $q->rows(); $n++) { |
|
2711 | 2711 | |
2712 | - $speech = array ( |
|
2712 | + $speech = array( |
|
2713 | 2713 | 'subsection_id' => $q->field($n, 'subsection_id'), |
2714 | 2714 | 'section_id' => $q->field($n, 'section_id'), |
2715 | 2715 | 'htype' => $q->field($n, 'htype'), |
@@ -2722,11 +2722,11 @@ discard block |
||
2722 | 2722 | |
2723 | 2723 | // Remove the "uk.org.publicwhip/blah/" from the gid: |
2724 | 2724 | // (In includes/utility.php) |
2725 | - $speech['gid'] = fix_gid_from_db( $q->field($n, 'gid') ); |
|
2725 | + $speech['gid'] = fix_gid_from_db($q->field($n, 'gid')); |
|
2726 | 2726 | |
2727 | 2727 | $speech['listurl'] = $this->_get_listurl($speech); |
2728 | 2728 | |
2729 | - $speech['speaker'] = $this->_get_speaker($q->field($n, 'person_id'), $q->field($n, 'hdate'), $q->field($n, 'htime'), $this->major ); |
|
2729 | + $speech['speaker'] = $this->_get_speaker($q->field($n, 'person_id'), $q->field($n, 'hdate'), $q->field($n, 'htime'), $this->major); |
|
2730 | 2730 | |
2731 | 2731 | $speeches[] = $speech; |
2732 | 2732 | } |
@@ -2736,10 +2736,10 @@ discard block |
||
2736 | 2736 | // Get the subsection texts. |
2737 | 2737 | |
2738 | 2738 | $num_speeches = count($speeches); |
2739 | - for ($n=0; $n<$num_speeches; $n++) { |
|
2739 | + for ($n = 0; $n < $num_speeches; $n++) { |
|
2740 | 2740 | //if ($this->major == 1) { |
2741 | 2741 | // Debate. |
2742 | - $parent = $this->_get_subsection ($speeches[$n]); |
|
2742 | + $parent = $this->_get_subsection($speeches[$n]); |
|
2743 | 2743 | |
2744 | 2744 | //} elseif ($this->major == 3) { |
2745 | 2745 | // Wrans. |
@@ -2758,7 +2758,7 @@ discard block |
||
2758 | 2758 | $data['rows'] = $speeches; |
2759 | 2759 | |
2760 | 2760 | } else { |
2761 | - $data['rows'] = array (); |
|
2761 | + $data['rows'] = array(); |
|
2762 | 2762 | } |
2763 | 2763 | |
2764 | 2764 | $data['info']['days'] = $days; |
@@ -2775,13 +2775,13 @@ discard block |
||
2775 | 2775 | } |
2776 | 2776 | |
2777 | 2777 | |
2778 | - public function biggest_debates($args=array()) { |
|
2778 | + public function biggest_debates($args = array()) { |
|
2779 | 2779 | // So we can just get the data back for special formatting |
2780 | 2780 | // on the front page, without doing the whole display() thing. |
2781 | 2781 | return $this->_get_data_by_biggest_debates($args); |
2782 | 2782 | } |
2783 | 2783 | |
2784 | - public function _get_data_by_featured_gid($args=array()) { |
|
2784 | + public function _get_data_by_featured_gid($args = array()) { |
|
2785 | 2785 | $params = array(); |
2786 | 2786 | $data = array(); |
2787 | 2787 | |
@@ -2807,21 +2807,21 @@ discard block |
||
2807 | 2807 | |
2808 | 2808 | $q = $this->db->query($query, $params); |
2809 | 2809 | |
2810 | - if ( $q->rows ) { |
|
2810 | + if ($q->rows) { |
|
2811 | 2811 | |
2812 | 2812 | // This array just used for getting further data about this debate. |
2813 | - $item_data = array ( |
|
2813 | + $item_data = array( |
|
2814 | 2814 | 'major' => $this->major, |
2815 | 2815 | 'minor' => $q->field(0, 'minor'), |
2816 | - 'gid' => fix_gid_from_db( $q->field(0, 'gid') ), |
|
2816 | + 'gid' => fix_gid_from_db($q->field(0, 'gid')), |
|
2817 | 2817 | 'htype' => $q->field(0, 'htype'), |
2818 | 2818 | 'section_id' => $q->field(0, 'section_id'), |
2819 | 2819 | 'subsection_id' => $q->field(0, 'subsection_id'), |
2820 | 2820 | 'epobject_id' => $q->field(0, 'epobject_id') |
2821 | 2821 | ); |
2822 | 2822 | |
2823 | - $list_url = $this->_get_listurl( $item_data ); |
|
2824 | - $totalcomments = $this->_get_comment_count_for_epobject( $item_data ); |
|
2823 | + $list_url = $this->_get_listurl($item_data); |
|
2824 | + $totalcomments = $this->_get_comment_count_for_epobject($item_data); |
|
2825 | 2825 | |
2826 | 2826 | $body = $q->field(0, 'body'); |
2827 | 2827 | $hdate = $q->field(0, 'hdate'); |
@@ -2841,21 +2841,21 @@ discard block |
||
2841 | 2841 | ':subsection_id' => $item_data['subsection_id'], |
2842 | 2842 | ) |
2843 | 2843 | ); |
2844 | - $section_body = $r->field(0, 'sec_body'); |
|
2844 | + $section_body = $r->field(0, 'sec_body'); |
|
2845 | 2845 | $subsection_body = $r->field(0, 'sub_body'); |
2846 | - if ( $section_body && $subsection_body ) { |
|
2846 | + if ($section_body && $subsection_body) { |
|
2847 | 2847 | $parentbody = "$section_body : $subsection_body"; |
2848 | 2848 | } else { |
2849 | 2849 | $parentbody = "$section_body$subsection_body"; |
2850 | 2850 | } |
2851 | - } else if ( $item_data['htype'] == 10 ) { |
|
2851 | + } else if ($item_data['htype'] == 10) { |
|
2852 | 2852 | $parentbody = $body; |
2853 | 2853 | } |
2854 | 2854 | |
2855 | 2855 | // Get the question for this item. |
2856 | - if ( $item_data['htype'] == 12 ) { |
|
2856 | + if ($item_data['htype'] == 12) { |
|
2857 | 2857 | $childbody = $body; |
2858 | - $speaker = $this->_get_speaker($q->field(0, 'person_id'), $q->field(0, 'hdate'), $q->field(0, 'htime'), $this->major ); |
|
2858 | + $speaker = $this->_get_speaker($q->field(0, 'person_id'), $q->field(0, 'hdate'), $q->field(0, 'htime'), $this->major); |
|
2859 | 2859 | } else { |
2860 | 2860 | $r = $this->db->query("SELECT e.body, e.title, |
2861 | 2861 | h.person_id, h.hdate, h.htime |
@@ -2865,10 +2865,10 @@ discard block |
||
2865 | 2865 | ORDER BY hpos |
2866 | 2866 | LIMIT 1 |
2867 | 2867 | ", |
2868 | - array( ':object_id' => $item_data['epobject_id'] ) |
|
2868 | + array(':object_id' => $item_data['epobject_id']) |
|
2869 | 2869 | ); |
2870 | 2870 | $childbody = $r->field(0, 'body'); |
2871 | - $speaker = $this->_get_speaker($r->field(0, 'person_id'), $r->field(0, 'hdate'), $r->field(0, 'htime'), $this->major ); |
|
2871 | + $speaker = $this->_get_speaker($r->field(0, 'person_id'), $r->field(0, 'hdate'), $r->field(0, 'htime'), $this->major); |
|
2872 | 2872 | } |
2873 | 2873 | |
2874 | 2874 | $contentcount = 0; |
@@ -2884,7 +2884,7 @@ discard block |
||
2884 | 2884 | } |
2885 | 2885 | |
2886 | 2886 | global $hansardmajors; |
2887 | - $more_url = new \MySociety\TheyWorkForYou\Url( $hansardmajors[$this->major]['page_all'] ); |
|
2887 | + $more_url = new \MySociety\TheyWorkForYou\Url($hansardmajors[$this->major]['page_all']); |
|
2888 | 2888 | $details = array( |
2889 | 2889 | 'body' => $body, |
2890 | 2890 | 'contentcount' => $contentcount, |
@@ -2903,7 +2903,7 @@ discard block |
||
2903 | 2903 | 'more_url' => $more_url->generate() |
2904 | 2904 | ); |
2905 | 2905 | |
2906 | - $data = array ( |
|
2906 | + $data = array( |
|
2907 | 2907 | 'gid' => $args['gid'], |
2908 | 2908 | 'major' => $this->major, |
2909 | 2909 | 'info' => array(), |
@@ -2914,7 +2914,7 @@ discard block |
||
2914 | 2914 | return $data; |
2915 | 2915 | |
2916 | 2916 | } |
2917 | - public function _get_data_by_recent_debates($args=array()) { |
|
2917 | + public function _get_data_by_recent_debates($args = array()) { |
|
2918 | 2918 | // Returns an array of some random recent debates from a set number of |
2919 | 2919 | // recent days (that's recent days starting from the most recent day |
2920 | 2920 | // that had any debates on). |
@@ -2972,20 +2972,20 @@ discard block |
||
2972 | 2972 | |
2973 | 2973 | $q = $this->db->query($query, $params); |
2974 | 2974 | |
2975 | - for ($row=0; $row<$q->rows; $row++) { |
|
2975 | + for ($row = 0; $row < $q->rows; $row++) { |
|
2976 | 2976 | |
2977 | 2977 | // This array just used for getting further data about this debate. |
2978 | - $item_data = array ( |
|
2978 | + $item_data = array( |
|
2979 | 2979 | 'major' => $this->major, |
2980 | - 'gid' => fix_gid_from_db( $q->field($row, 'gid') ), |
|
2980 | + 'gid' => fix_gid_from_db($q->field($row, 'gid')), |
|
2981 | 2981 | 'htype' => $q->field($row, 'htype'), |
2982 | 2982 | 'section_id' => $q->field($row, 'section_id'), |
2983 | 2983 | 'subsection_id' => $q->field($row, 'subsection_id'), |
2984 | 2984 | 'epobject_id' => $q->field($row, 'epobject_id') |
2985 | 2985 | ); |
2986 | 2986 | |
2987 | - $list_url = $this->_get_listurl( $item_data ); |
|
2988 | - $totalcomments = $this->_get_comment_count_for_epobject( $item_data ); |
|
2987 | + $list_url = $this->_get_listurl($item_data); |
|
2988 | + $totalcomments = $this->_get_comment_count_for_epobject($item_data); |
|
2989 | 2989 | |
2990 | 2990 | $contentcount = $q->field($row, 'count'); |
2991 | 2991 | $body = $q->field($row, 'body'); |
@@ -3013,7 +3013,7 @@ discard block |
||
3013 | 3013 | LIMIT 1 |
3014 | 3014 | "); |
3015 | 3015 | $childbody = $r->field(0, 'body'); |
3016 | - $speaker = $this->_get_speaker($r->field(0, 'person_id'), $r->field(0, 'hdate'), $r->field(0, 'htime'), $this->major ); |
|
3016 | + $speaker = $this->_get_speaker($r->field(0, 'person_id'), $r->field(0, 'hdate'), $r->field(0, 'htime'), $this->major); |
|
3017 | 3017 | |
3018 | 3018 | $data[] = array( |
3019 | 3019 | 'contentcount' => $contentcount, |
@@ -3033,7 +3033,7 @@ discard block |
||
3033 | 3033 | |
3034 | 3034 | } |
3035 | 3035 | |
3036 | - $data = array ( |
|
3036 | + $data = array( |
|
3037 | 3037 | 'info' => array(), |
3038 | 3038 | 'data' => $data |
3039 | 3039 | ); |
@@ -3042,7 +3042,7 @@ discard block |
||
3042 | 3042 | |
3043 | 3043 | } |
3044 | 3044 | |
3045 | - public function _get_data_by_biggest_debates($args=array()) { |
|
3045 | + public function _get_data_by_biggest_debates($args = array()) { |
|
3046 | 3046 | // Returns an array of the debates with most speeches in from |
3047 | 3047 | // a set number of recent days (that's recent days starting from the |
3048 | 3048 | // most recent day that had any debates on). |
@@ -3094,28 +3094,28 @@ discard block |
||
3094 | 3094 | LIMIT :limit", $params); |
3095 | 3095 | |
3096 | 3096 | |
3097 | - for ($row=0; $row<$q->rows; $row++) { |
|
3097 | + for ($row = 0; $row < $q->rows; $row++) { |
|
3098 | 3098 | |
3099 | 3099 | // This array just used for getting further data about this debate. |
3100 | - $item_data = array ( |
|
3100 | + $item_data = array( |
|
3101 | 3101 | 'major' => $this->major, |
3102 | - 'gid' => fix_gid_from_db( $q->field($row, 'gid') ), |
|
3102 | + 'gid' => fix_gid_from_db($q->field($row, 'gid')), |
|
3103 | 3103 | 'htype' => $q->field($row, 'htype'), |
3104 | 3104 | 'section_id' => $q->field($row, 'section_id'), |
3105 | 3105 | 'subsection_id' => $q->field($row, 'subsection_id'), |
3106 | 3106 | 'epobject_id' => $q->field($row, 'epobject_id') |
3107 | 3107 | ); |
3108 | 3108 | |
3109 | - $list_url = $this->_get_listurl( $item_data ); |
|
3110 | - $totalcomments = $this->_get_comment_count_for_epobject( $item_data ); |
|
3109 | + $list_url = $this->_get_listurl($item_data); |
|
3110 | + $totalcomments = $this->_get_comment_count_for_epobject($item_data); |
|
3111 | 3111 | |
3112 | - $contentcount = $q->field($row, 'count'); |
|
3112 | + $contentcount = $q->field($row, 'count'); |
|
3113 | 3113 | $body = $q->field($row, 'body'); |
3114 | 3114 | $hdate = $q->field($row, 'hdate'); |
3115 | 3115 | |
3116 | 3116 | |
3117 | 3117 | // This array will be added to $data, which is what gets returned. |
3118 | - $debate = array ( |
|
3118 | + $debate = array( |
|
3119 | 3119 | 'contentcount' => $contentcount, |
3120 | 3120 | 'body' => $body, |
3121 | 3121 | 'hdate' => $hdate, |
@@ -3143,7 +3143,7 @@ discard block |
||
3143 | 3143 | LIMIT 1 |
3144 | 3144 | "); |
3145 | 3145 | $childbody = $r->field(0, 'body'); |
3146 | - $speaker = $this->_get_speaker($r->field(0, 'person_id'), $r->field(0, 'hdate'), $r->field(0, 'htime'), $this->major ); |
|
3146 | + $speaker = $this->_get_speaker($r->field(0, 'person_id'), $r->field(0, 'hdate'), $r->field(0, 'htime'), $this->major); |
|
3147 | 3147 | |
3148 | 3148 | $debate['child'] = array( |
3149 | 3149 | 'body' => $childbody, |
@@ -3153,7 +3153,7 @@ discard block |
||
3153 | 3153 | $data[] = $debate; |
3154 | 3154 | } |
3155 | 3155 | |
3156 | - $data = array ( |
|
3156 | + $data = array( |
|
3157 | 3157 | 'info' => array(), |
3158 | 3158 | 'data' => $data |
3159 | 3159 | ); |
@@ -3176,7 +3176,7 @@ discard block |
||
3176 | 3176 | return $q->field(0, 'count'); |
3177 | 3177 | } |
3178 | 3178 | |
3179 | - public function _get_data_by_recent_wrans ($args=array()) { |
|
3179 | + public function _get_data_by_recent_wrans($args = array()) { |
|
3180 | 3180 | global $hansardmajors; |
3181 | 3181 | |
3182 | 3182 | // $args['days'] is the number of days back to look for biggest debates. |
@@ -3238,19 +3238,19 @@ discard block |
||
3238 | 3238 | |
3239 | 3239 | $q = $this->db->query($query, $params); |
3240 | 3240 | |
3241 | - for ($row=0; $row<$q->rows; $row++) { |
|
3241 | + for ($row = 0; $row < $q->rows; $row++) { |
|
3242 | 3242 | // This array just used for getting further data about this debate. |
3243 | - $item_data = array ( |
|
3243 | + $item_data = array( |
|
3244 | 3244 | 'major' => $this->major, |
3245 | - 'gid' => fix_gid_from_db( $q->field($row, 'gid') ), |
|
3245 | + 'gid' => fix_gid_from_db($q->field($row, 'gid')), |
|
3246 | 3246 | 'htype' => $q->field($row, 'htype'), |
3247 | 3247 | 'section_id' => $q->field($row, 'section_id'), |
3248 | 3248 | 'subsection_id' => $q->field($row, 'subsection_id'), |
3249 | 3249 | 'epobject_id' => $q->field($row, 'epobject_id') |
3250 | 3250 | ); |
3251 | 3251 | |
3252 | - $list_url = $this->_get_listurl( $item_data ); |
|
3253 | - $totalcomments = $this->_get_comment_count_for_epobject( $item_data ); |
|
3252 | + $list_url = $this->_get_listurl($item_data); |
|
3253 | + $totalcomments = $this->_get_comment_count_for_epobject($item_data); |
|
3254 | 3254 | |
3255 | 3255 | $body = $q->field($row, 'body'); |
3256 | 3256 | $hdate = $q->field($row, 'hdate'); |
@@ -3276,25 +3276,25 @@ discard block |
||
3276 | 3276 | LIMIT 1 |
3277 | 3277 | "); |
3278 | 3278 | $childbody = $r->field(0, 'body'); |
3279 | - $speaker = $this->_get_speaker($r->field(0, 'person_id'), $r->field(0, 'hdate'), $r->field(0, 'htime'), $this->major ); |
|
3279 | + $speaker = $this->_get_speaker($r->field(0, 'person_id'), $r->field(0, 'hdate'), $r->field(0, 'htime'), $this->major); |
|
3280 | 3280 | |
3281 | - $data[] = array ( |
|
3281 | + $data[] = array( |
|
3282 | 3282 | 'body' => $body, |
3283 | 3283 | 'hdate' => $hdate, |
3284 | 3284 | 'list_url' => $list_url, |
3285 | 3285 | 'totalcomments' => $totalcomments, |
3286 | - 'child' => array ( |
|
3286 | + 'child' => array( |
|
3287 | 3287 | 'body' => $childbody, |
3288 | 3288 | 'speaker' => $speaker |
3289 | 3289 | ), |
3290 | - 'parent' => array ( |
|
3290 | + 'parent' => array( |
|
3291 | 3291 | 'body' => $parentbody |
3292 | 3292 | ) |
3293 | 3293 | ); |
3294 | 3294 | |
3295 | 3295 | } |
3296 | 3296 | |
3297 | - $data = array ( |
|
3297 | + $data = array( |
|
3298 | 3298 | 'info' => array(), |
3299 | 3299 | 'data' => $data |
3300 | 3300 | ); |
@@ -3311,7 +3311,7 @@ discard block |
||
3311 | 3311 | public $commentspage = 'pbc_speech'; |
3312 | 3312 | public $gidprefix = 'uk.org.publicwhip/standing/'; |
3313 | 3313 | |
3314 | - public function __construct($session='', $title='') { |
|
3314 | + public function __construct($session = '', $title = '') { |
|
3315 | 3315 | parent::__construct(); |
3316 | 3316 | $this->bill_title = $title; |
3317 | 3317 | $title = str_replace(' ', '_', $title); |
@@ -3319,7 +3319,7 @@ discard block |
||
3319 | 3319 | } |
3320 | 3320 | |
3321 | 3321 | public function _get_committee($bill_id) { |
3322 | - include_once INCLUDESPATH."easyparliament/member.php"; |
|
3322 | + include_once INCLUDESPATH . "easyparliament/member.php"; |
|
3323 | 3323 | $q = $this->db->query( |
3324 | 3324 | 'select count(*) as c from hansard |
3325 | 3325 | where major=6 and minor=:bill_id and htype=10', |
@@ -3332,7 +3332,7 @@ discard block |
||
3332 | 3332 | where bill_id = :bill_id group by person_id', |
3333 | 3333 | array(':bill_id' => $bill_id)); |
3334 | 3334 | $comm = array('sittings' => $sittings, 'chairmen' => array(), 'members' => array()); |
3335 | - for ($i=0; $i<$q->rows(); $i++) { |
|
3335 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
3336 | 3336 | $person_id = $q->field($i, 'person_id'); |
3337 | 3337 | $mp = new MEMBER(array('person_id'=>$person_id)); |
3338 | 3338 | $attending = $q->field($i, 'attending'); |
@@ -3353,13 +3353,13 @@ discard block |
||
3353 | 3353 | public function _get_data_by_bill($args) { |
3354 | 3354 | global $DATA, $this_page; |
3355 | 3355 | $data = array(); |
3356 | - $input = array ( |
|
3357 | - 'amount' => array ( |
|
3356 | + $input = array( |
|
3357 | + 'amount' => array( |
|
3358 | 3358 | 'body' => true, |
3359 | 3359 | 'comment' => true, |
3360 | 3360 | 'excerpt' => true |
3361 | 3361 | ), |
3362 | - 'where' => array ( |
|
3362 | + 'where' => array( |
|
3363 | 3363 | 'htype=' => '10', |
3364 | 3364 | 'major=' => $this->major, |
3365 | 3365 | 'minor=' => $args['id'], |
@@ -3370,18 +3370,18 @@ discard block |
||
3370 | 3370 | if (count($sections) > 0) { |
3371 | 3371 | $data['rows'] = array(); |
3372 | 3372 | $num_sections = count($sections); |
3373 | - for ($n=0; $n<$num_sections; $n++) { |
|
3373 | + for ($n = 0; $n < $num_sections; $n++) { |
|
3374 | 3374 | $sectionrow = $sections[$n]; |
3375 | 3375 | list($sitting, $part) = $this->_get_sitting($sectionrow['gid']); |
3376 | 3376 | $sectionrow['sitting'] = $sitting; |
3377 | 3377 | $sectionrow['part'] = $part; |
3378 | - $input = array ( |
|
3379 | - 'amount' => array ( |
|
3378 | + $input = array( |
|
3379 | + 'amount' => array( |
|
3380 | 3380 | 'body' => true, |
3381 | 3381 | 'comment' => true, |
3382 | 3382 | 'excerpt' => true |
3383 | 3383 | ), |
3384 | - 'where' => array ( |
|
3384 | + 'where' => array( |
|
3385 | 3385 | 'section_id=' => $sectionrow['epobject_id'], |
3386 | 3386 | 'htype=' => '11', |
3387 | 3387 | 'major=' => $this->major |
@@ -3389,8 +3389,8 @@ discard block |
||
3389 | 3389 | 'order' => 'hpos' |
3390 | 3390 | ); |
3391 | 3391 | $rows = $this->_get_hansard_data($input); |
3392 | - array_unshift ($rows, $sectionrow); |
|
3393 | - $data['rows'] = array_merge ($data['rows'], $rows); |
|
3392 | + array_unshift($rows, $sectionrow); |
|
3393 | + $data['rows'] = array_merge($data['rows'], $rows); |
|
3394 | 3394 | } |
3395 | 3395 | } |
3396 | 3396 | $data['info']['bill'] = $args['title']; |
@@ -3408,7 +3408,7 @@ discard block |
||
3408 | 3408 | array(':session' => $session) |
3409 | 3409 | ); |
3410 | 3410 | $bills = array(); |
3411 | - for ($i=0; $i<$q->rows(); $i++) { |
|
3411 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
3412 | 3412 | $bills[$q->field($i, 'id')] = $q->field($i, 'title'); |
3413 | 3413 | } |
3414 | 3414 | if (!count($bills)) { |
@@ -3419,7 +3419,7 @@ discard block |
||
3419 | 3419 | group by minor'); |
3420 | 3420 | $counts = array(); |
3421 | 3421 | # $comments = array(); |
3422 | - for ($i=0; $i<$q->rows(); $i++) { |
|
3422 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
3423 | 3423 | $minor = $q->field($i, 'minor'); |
3424 | 3424 | $counts[$minor] = $q->field($i, 'c'); |
3425 | 3425 | # $comments[$minor] = 0; |
@@ -3446,8 +3446,8 @@ discard block |
||
3446 | 3446 | |
3447 | 3447 | $YEARURL = new \MySociety\TheyWorkForYou\Url('pbc_session'); |
3448 | 3448 | $nextprev = array(); |
3449 | - $nextprev['prev'] = array ('body' => 'Previous session', 'title'=>''); |
|
3450 | - $nextprev['next'] = array ('body' => 'Next session', 'title'=>''); |
|
3449 | + $nextprev['prev'] = array('body' => 'Previous session', 'title'=>''); |
|
3450 | + $nextprev['next'] = array('body' => 'Next session', 'title'=>''); |
|
3451 | 3451 | $q = $this->db->query( |
3452 | 3452 | "SELECT session FROM bills WHERE session < :session ORDER BY session DESC LIMIT 1", |
3453 | 3453 | array(':session' => $session) |
@@ -3475,20 +3475,20 @@ discard block |
||
3475 | 3475 | where htype=10 and major=6 |
3476 | 3476 | order by hdate desc limit ' . $args['num']); |
3477 | 3477 | $data = array(); |
3478 | - for ($i=0; $i<$q->rows(); $i++) { |
|
3478 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
3479 | 3479 | $minor = $q->field($i, 'minor'); |
3480 | 3480 | $gid = $q->field($i, 'gid'); |
3481 | 3481 | $hdate = format_date($q->field($i, 'hdate'), LONGDATEFORMAT); |
3482 | - $qq = $this->db->query('select title, session from bills where id='.$minor); |
|
3482 | + $qq = $this->db->query('select title, session from bills where id=' . $minor); |
|
3483 | 3483 | $title = $qq->field(0, 'title'); |
3484 | 3484 | $session = $qq->field(0, 'session'); |
3485 | 3485 | list($sitting, $part) = $this->_get_sitting($gid); |
3486 | 3486 | $sitting_txt = make_ranking($sitting) . ' sitting'; |
3487 | - if ($part>0) $sitting .= ", part $part"; |
|
3487 | + if ($part > 0) $sitting .= ", part $part"; |
|
3488 | 3488 | $data[$hdate][] = array( |
3489 | 3489 | 'bill'=> $title, |
3490 | 3490 | 'sitting' => $sitting_txt, |
3491 | - 'url' => "/pbc/$session/" . urlencode(str_replace(' ','_',$title)) . '/#sitting' . $sitting, |
|
3491 | + 'url' => "/pbc/$session/" . urlencode(str_replace(' ', '_', $title)) . '/#sitting' . $sitting, |
|
3492 | 3492 | ); |
3493 | 3493 | } |
3494 | 3494 | return $data; |
@@ -3497,7 +3497,7 @@ discard block |
||
3497 | 3497 | # Given a GID, parse out the sitting number and optional part from it |
3498 | 3498 | public function _get_sitting($gid) { |
3499 | 3499 | if (preg_match('#_(\d\d)-(\d)_#', $gid, $m)) |
3500 | - return array($m[1]+0, $m[2]); |
|
3500 | + return array($m[1] + 0, $m[2]); |
|
3501 | 3501 | return array(0, 0); |
3502 | 3502 | } |
3503 | 3503 | } |
@@ -138,8 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | global $PAGE; |
140 | 140 | |
141 | - if ($view == 'search' && (!defined('FRONT_END_SEARCH') || !FRONT_END_SEARCH)) |
|
142 | - return false; |
|
141 | + if ($view == 'search' && (!defined('FRONT_END_SEARCH') || !FRONT_END_SEARCH)) { |
|
142 | + return false; |
|
143 | + } |
|
143 | 144 | |
144 | 145 | $validviews = array ('calendar', 'date', 'gid', 'person', 'search', 'search_min', 'search_video', 'recent', 'recent_mostvotes', 'biggest_debates', 'recent_wrans', 'recent_wms', 'column', 'mp', 'bill', 'session', 'recent_debates', 'recent_pbc_debates', 'featured_gid'); |
145 | 146 | if (in_array($view, $validviews)) { |
@@ -326,10 +327,11 @@ discard block |
||
326 | 327 | ); |
327 | 328 | |
328 | 329 | $subsectiondata = $this->_get_hansard_data($input); |
329 | - if (count($subsectiondata) == 0) |
|
330 | - $subsectiondata = null; |
|
331 | - else |
|
332 | - $subsectiondata = $subsectiondata[0]; |
|
330 | + if (count($subsectiondata) == 0) { |
|
331 | + $subsectiondata = null; |
|
332 | + } else { |
|
333 | + $subsectiondata = $subsectiondata[0]; |
|
334 | + } |
|
333 | 335 | |
334 | 336 | } elseif ($itemdata['htype'] == '11') { |
335 | 337 | // It's a subsection, so use the item itself. |
@@ -1018,12 +1020,12 @@ discard block |
||
1018 | 1020 | // Mainly for glossary term adding |
1019 | 1021 | if (isset($args['num']) && $args['num']) { |
1020 | 1022 | $results_per_page = $args['num']+0; |
1021 | - } |
|
1022 | - else { |
|
1023 | + } else { |
|
1023 | 1024 | $results_per_page = 20; |
1024 | 1025 | } |
1025 | - if ($results_per_page > 1000) |
|
1026 | - $results_per_page = 1000; |
|
1026 | + if ($results_per_page > 1000) { |
|
1027 | + $results_per_page = 1000; |
|
1028 | + } |
|
1027 | 1029 | |
1028 | 1030 | $data['info']['results_per_page'] = $results_per_page; |
1029 | 1031 | |
@@ -1051,10 +1053,16 @@ discard block |
||
1051 | 1053 | // Get the gids from Xapian |
1052 | 1054 | $sort_order = 'date'; |
1053 | 1055 | if (isset($args['o'])) { |
1054 | - if ($args['o']=='d') $sort_order = 'newest'; |
|
1055 | - if ($args['o']=='o') $sort_order = 'oldest'; |
|
1056 | - elseif ($args['o']=='c') $sort_order = 'created'; |
|
1057 | - elseif ($args['o']=='r') $sort_order = 'relevance'; |
|
1056 | + if ($args['o']=='d') { |
|
1057 | + $sort_order = 'newest'; |
|
1058 | + } |
|
1059 | + if ($args['o']=='o') { |
|
1060 | + $sort_order = 'oldest'; |
|
1061 | + } elseif ($args['o']=='c') { |
|
1062 | + $sort_order = 'created'; |
|
1063 | + } elseif ($args['o']=='r') { |
|
1064 | + $sort_order = 'relevance'; |
|
1065 | + } |
|
1058 | 1066 | } |
1059 | 1067 | |
1060 | 1068 | $data['searchdescription'] = $SEARCHENGINE->query_description_long(); |
@@ -1114,7 +1122,9 @@ discard block |
||
1114 | 1122 | FROM future |
1115 | 1123 | LEFT JOIN future_people ON id=calendar_id AND witness=0 |
1116 | 1124 | WHERE id = $id AND deleted=0"); |
1117 | - if ($q->rows() == 0) continue; |
|
1125 | + if ($q->rows() == 0) { |
|
1126 | + continue; |
|
1127 | + } |
|
1118 | 1128 | |
1119 | 1129 | $itemdata = $q->row(0); |
1120 | 1130 | |
@@ -1123,8 +1133,9 @@ discard block |
||
1123 | 1133 | in_array($itemdata['chamber'], array( |
1124 | 1134 | 'Commons: Main Chamber', 'Lords: Main Chamber', |
1125 | 1135 | 'Commons: Westminster Hall', |
1126 | - ))) |
|
1127 | - continue; |
|
1136 | + ))) { |
|
1137 | + continue; |
|
1138 | + } |
|
1128 | 1139 | |
1129 | 1140 | list($cal_item, $cal_meta) = \MySociety\TheyWorkForYou\Utility\Calendar::meta($itemdata); |
1130 | 1141 | $body = $this->prepare_search_result_for_display($cal_item) . '.'; |
@@ -1237,10 +1248,17 @@ discard block |
||
1237 | 1248 | $section = $this->_get_section($itemdata); |
1238 | 1249 | $subsection = $this->_get_subsection($itemdata); |
1239 | 1250 | $body = $hansardmajors[$itemdata['major']]['title'] . ' — '; |
1240 | - if (isset($section['body'])) $body .= $section['body']; |
|
1241 | - if (isset($subsection['body'])) $body .= ': ' . $subsection['body']; |
|
1242 | - if (isset($subsection['listurl'])) $listurl = $subsection['listurl']; |
|
1243 | - else $listurl = ''; |
|
1251 | + if (isset($section['body'])) { |
|
1252 | + $body .= $section['body']; |
|
1253 | + } |
|
1254 | + if (isset($subsection['body'])) { |
|
1255 | + $body .= ': ' . $subsection['body']; |
|
1256 | + } |
|
1257 | + if (isset($subsection['listurl'])) { |
|
1258 | + $listurl = $subsection['listurl']; |
|
1259 | + } else { |
|
1260 | + $listurl = ''; |
|
1261 | + } |
|
1244 | 1262 | $itemdata['parent'] = array ( |
1245 | 1263 | 'body' => $body, |
1246 | 1264 | 'listurl' => $listurl |
@@ -1565,7 +1583,8 @@ discard block |
||
1565 | 1583 | 'url' => $YEARURL->generate() |
1566 | 1584 | ); |
1567 | 1585 | |
1568 | - } else { // action is 'year'. |
|
1586 | + } else { |
|
1587 | +// action is 'year'. |
|
1569 | 1588 | |
1570 | 1589 | $nextprev['prev'] = array ('body' => 'Previous year'); |
1571 | 1590 | $nextprev['next'] = array ('body' => 'Next year'); |
@@ -1980,10 +1999,11 @@ discard block |
||
1980 | 1999 | // ); |
1981 | 2000 | |
1982 | 2001 | // $url_args is an array of other key/value pairs to be appended in the GET string. |
1983 | - if ($id_data['major']) |
|
1984 | - $LISTURL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$id_data['major']]['page_all']); |
|
1985 | - else |
|
1986 | - $LISTURL = new \MySociety\TheyWorkForYou\Url('wrans'); |
|
2002 | + if ($id_data['major']) { |
|
2003 | + $LISTURL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$id_data['major']]['page_all']); |
|
2004 | + } else { |
|
2005 | + $LISTURL = new \MySociety\TheyWorkForYou\Url('wrans'); |
|
2006 | + } |
|
1987 | 2007 | |
1988 | 2008 | $fragment = ''; |
1989 | 2009 | |
@@ -2633,7 +2653,9 @@ discard block |
||
2633 | 2653 | array(':gid_from_spid' => 'uk.org.publicwhip/spq/' . $fixed_spid) |
2634 | 2654 | ); |
2635 | 2655 | $gid = $q->field(0, 'mentioned_gid'); |
2636 | - if ($gid) return $gid; |
|
2656 | + if ($gid) { |
|
2657 | + return $gid; |
|
2658 | + } |
|
2637 | 2659 | return null; |
2638 | 2660 | } |
2639 | 2661 | public function old_get_gid_from_spid($spid) { |
@@ -2642,7 +2664,9 @@ discard block |
||
2642 | 2664 | array(':gid_like' => 'uk.org.publicwhip/spwa/%.' . $spid . '.h') |
2643 | 2665 | ); |
2644 | 2666 | $gid = $q->field(0, 'gid'); |
2645 | - if ($gid) return str_replace('uk.org.publicwhip/spwa/', '', $gid); |
|
2667 | + if ($gid) { |
|
2668 | + return str_replace('uk.org.publicwhip/spwa/', '', $gid); |
|
2669 | + } |
|
2646 | 2670 | return null; |
2647 | 2671 | } |
2648 | 2672 | } |
@@ -2928,7 +2952,9 @@ discard block |
||
2928 | 2952 | |
2929 | 2953 | // Get the most recent day on which we have a debate. |
2930 | 2954 | $recentday = $this->most_recent_day(); |
2931 | - if (!count($recentday)) return $data; |
|
2955 | + if (!count($recentday)) { |
|
2956 | + return $data; |
|
2957 | + } |
|
2932 | 2958 | |
2933 | 2959 | if (!isset($args['days']) || !is_numeric($args['days'])) { |
2934 | 2960 | $args['days'] = 1; |
@@ -3055,8 +3081,9 @@ discard block |
||
3055 | 3081 | |
3056 | 3082 | // Get the most recent day on which we have a debate. |
3057 | 3083 | $recentday = $this->most_recent_day(); |
3058 | - if (!count($recentday)) |
|
3059 | - return array(); |
|
3084 | + if (!count($recentday)) { |
|
3085 | + return array(); |
|
3086 | + } |
|
3060 | 3087 | |
3061 | 3088 | if (!isset($args['days']) || !is_numeric($args['days'])) { |
3062 | 3089 | $args['days'] = 1; |
@@ -3189,8 +3216,9 @@ discard block |
||
3189 | 3216 | |
3190 | 3217 | // Get the most recent day on which we have wrans. |
3191 | 3218 | $recentday = $this->most_recent_day(); |
3192 | - if (!count($recentday)) |
|
3193 | - return $data; |
|
3219 | + if (!count($recentday)) { |
|
3220 | + return $data; |
|
3221 | + } |
|
3194 | 3222 | |
3195 | 3223 | if (!isset($args['days']) || !is_numeric($args['days'])) { |
3196 | 3224 | $args['days'] = 1; |
@@ -3470,7 +3498,9 @@ discard block |
||
3470 | 3498 | } |
3471 | 3499 | |
3472 | 3500 | public function _get_data_by_recent_pbc_debates($args) { |
3473 | - if (!isset($args['num'])) $args['num'] = 20; |
|
3501 | + if (!isset($args['num'])) { |
|
3502 | + $args['num'] = 20; |
|
3503 | + } |
|
3474 | 3504 | $q = $this->db->query('select gid, minor, hdate from hansard |
3475 | 3505 | where htype=10 and major=6 |
3476 | 3506 | order by hdate desc limit ' . $args['num']); |
@@ -3484,7 +3514,9 @@ discard block |
||
3484 | 3514 | $session = $qq->field(0, 'session'); |
3485 | 3515 | list($sitting, $part) = $this->_get_sitting($gid); |
3486 | 3516 | $sitting_txt = make_ranking($sitting) . ' sitting'; |
3487 | - if ($part>0) $sitting .= ", part $part"; |
|
3517 | + if ($part>0) { |
|
3518 | + $sitting .= ", part $part"; |
|
3519 | + } |
|
3488 | 3520 | $data[$hdate][] = array( |
3489 | 3521 | 'bill'=> $title, |
3490 | 3522 | 'sitting' => $sitting_txt, |
@@ -3496,8 +3528,9 @@ discard block |
||
3496 | 3528 | |
3497 | 3529 | # Given a GID, parse out the sitting number and optional part from it |
3498 | 3530 | public function _get_sitting($gid) { |
3499 | - if (preg_match('#_(\d\d)-(\d)_#', $gid, $m)) |
|
3500 | - return array($m[1]+0, $m[2]); |
|
3531 | + if (preg_match('#_(\d\d)-(\d)_#', $gid, $m)) { |
|
3532 | + return array($m[1]+0, $m[2]); |
|
3533 | + } |
|
3501 | 3534 | return array(0, 0); |
3502 | 3535 | } |
3503 | 3536 | } |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | if ($hide_question) { |
34 | 34 | $always_ask = 0; |
35 | 35 | $show_survey_qn = $current_question; |
36 | - setcookie('survey', $current_question, time()+60*60*24*365, '/'); |
|
36 | + setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/'); |
|
37 | 37 | } elseif ($has_answered_question == $current_question && !$always_ask) { |
38 | 38 | $show_survey_qn = $current_question; |
39 | - setcookie('survey', $current_question, time()+60*60*24*365, '/'); |
|
39 | + setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/'); |
|
40 | 40 | } elseif (isset($_COOKIE['survey'])) { |
41 | 41 | $show_survey_qn = $_COOKIE['survey']; |
42 | 42 | } |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | if ($show_survey_qn < $current_question && !$has_answered_question) { |
50 | 50 | $page_url = ''; |
51 | 51 | $hide_url = ''; |
52 | - if ( in_array( $this_page, array('mp', 'peer', 'msp', 'mla', 'royal') ) ) { |
|
52 | + if (in_array($this_page, array('mp', 'peer', 'msp', 'mla', 'royal'))) { |
|
53 | 53 | global $MEMBER; |
54 | 54 | $page_url = $MEMBER->url(true) . "?answered_survey=$current_question"; |
55 | 55 | $hide_url = $MEMBER->url() . "?hide_survey=$current_question"; |
56 | 56 | } else { |
57 | 57 | $URL = new \MySociety\TheyWorkForYou\Url($this_page); |
58 | - $URL->insert(array('answered_survey' => $current_question )); |
|
58 | + $URL->insert(array('answered_survey' => $current_question)); |
|
59 | 59 | $page_url = 'https://' . DOMAIN . $URL->generate(); |
60 | 60 | $URL = new \MySociety\TheyWorkForYou\Url($this_page); |
61 | - $URL->insert(array('hide_survey' => $current_question )); |
|
61 | + $URL->insert(array('hide_survey' => $current_question)); |
|
62 | 62 | $hide_url = $URL->generate(); |
63 | 63 | } |
64 | 64 |
@@ -56,22 +56,22 @@ discard block |
||
56 | 56 | |
57 | 57 | class USER { |
58 | 58 | |
59 | - public $user_id = "0"; // So we have an ID for non-logged in users reporting comments etc. |
|
60 | - public $firstname = "Guest"; // So we have something to print for non-logged in users. |
|
59 | + public $user_id = "0"; // So we have an ID for non-logged in users reporting comments etc. |
|
60 | + public $firstname = "Guest"; // So we have something to print for non-logged in users. |
|
61 | 61 | public $lastname = ""; |
62 | - public $password = ""; // This will be a hashed version of a plaintext pw. |
|
62 | + public $password = ""; // This will be a hashed version of a plaintext pw. |
|
63 | 63 | public $email = ""; |
64 | - public $emailpublic = ""; // boolean - can other users see this user's email? |
|
64 | + public $emailpublic = ""; // boolean - can other users see this user's email? |
|
65 | 65 | public $postcode = ""; |
66 | 66 | public $url = ""; |
67 | - public $lastvisit = ""; // Last time the logged-in user loaded a page (GMT). |
|
67 | + public $lastvisit = ""; // Last time the logged-in user loaded a page (GMT). |
|
68 | 68 | public $registrationtime = ""; // When they registered (GMT). |
69 | - public $registrationip = ""; // Where they registered from. |
|
70 | - public $optin = ""; // boolean - Do they want emails from us? |
|
71 | - public $deleted = ""; // User can't log in or have their info displayed. |
|
72 | - public $confirmed = ''; // boolean - Has the user confirmed via email? |
|
73 | - public $facebook_id = ''; // Facebook ID for users who login with FB |
|
74 | - public $facebook_token = ''; // Facebook token for users who login with FB |
|
69 | + public $registrationip = ""; // Where they registered from. |
|
70 | + public $optin = ""; // boolean - Do they want emails from us? |
|
71 | + public $deleted = ""; // User can't log in or have their info displayed. |
|
72 | + public $confirmed = ''; // boolean - Has the user confirmed via email? |
|
73 | + public $facebook_id = ''; // Facebook ID for users who login with FB |
|
74 | + public $facebook_token = ''; // Facebook token for users who login with FB |
|
75 | 75 | // Don't use the status to check access privileges - use the is_able_to() function. |
76 | 76 | public $status = "Viewer"; |
77 | 77 | |
@@ -118,23 +118,23 @@ discard block |
||
118 | 118 | // We've got a user, so set them up. |
119 | 119 | |
120 | 120 | $this->user_id = $user_id; |
121 | - $this->firstname = $q->field(0,"firstname"); |
|
122 | - $this->lastname = $q->field(0,"lastname"); |
|
123 | - $this->password = $q->field(0,"password"); |
|
124 | - $this->email = $q->field(0,"email"); |
|
125 | - $this->emailpublic = $q->field(0,"emailpublic") == 1 ? true : false; |
|
126 | - $this->postcode = $q->field(0,"postcode"); |
|
127 | - $this->facebook_id = $q->field(0,"facebook_id"); |
|
128 | - $this->facebook_token = $q->field(0,"facebook_token"); |
|
129 | - $this->url = $q->field(0,"url"); |
|
130 | - $this->lastvisit = $q->field(0,"lastvisit"); |
|
121 | + $this->firstname = $q->field(0, "firstname"); |
|
122 | + $this->lastname = $q->field(0, "lastname"); |
|
123 | + $this->password = $q->field(0, "password"); |
|
124 | + $this->email = $q->field(0, "email"); |
|
125 | + $this->emailpublic = $q->field(0, "emailpublic") == 1 ? true : false; |
|
126 | + $this->postcode = $q->field(0, "postcode"); |
|
127 | + $this->facebook_id = $q->field(0, "facebook_id"); |
|
128 | + $this->facebook_token = $q->field(0, "facebook_token"); |
|
129 | + $this->url = $q->field(0, "url"); |
|
130 | + $this->lastvisit = $q->field(0, "lastvisit"); |
|
131 | 131 | $this->registrationtoken = $q->field(0, 'registrationtoken'); |
132 | - $this->registrationtime = $q->field(0,"registrationtime"); |
|
133 | - $this->registrationip = $q->field(0,"registrationip"); |
|
134 | - $this->optin = $q->field(0,"optin") == 1 ? true : false; |
|
135 | - $this->status = $q->field(0,"status"); |
|
136 | - $this->deleted = $q->field(0,"deleted") == 1 ? true : false; |
|
137 | - $this->confirmed = $q->field(0,"confirmed") == 1 ? true : false; |
|
132 | + $this->registrationtime = $q->field(0, "registrationtime"); |
|
133 | + $this->registrationip = $q->field(0, "registrationip"); |
|
134 | + $this->optin = $q->field(0, "optin") == 1 ? true : false; |
|
135 | + $this->status = $q->field(0, "status"); |
|
136 | + $this->deleted = $q->field(0, "deleted") == 1 ? true : false; |
|
137 | + $this->confirmed = $q->field(0, "confirmed") == 1 ? true : false; |
|
138 | 138 | |
139 | 139 | return true; |
140 | 140 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | } |
154 | 154 | |
155 | - public function add($details, $confirmation_required=true) { |
|
155 | + public function add($details, $confirmation_required = true) { |
|
156 | 156 | // Adds a new user's info into the db. |
157 | 157 | // Then optionally (and usually) calls another function to |
158 | 158 | // send them a confirmation email. |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | // This will be sent to them via email, so we can confirm they exist. |
240 | 240 | // The token will be the first 16 characters of a hash. |
241 | 241 | |
242 | - $token = substr( password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16 ); |
|
242 | + $token = substr(password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16); |
|
243 | 243 | |
244 | 244 | // Full stops don't work well at the end of URLs in emails, |
245 | 245 | // so replace them. We won't be doing anything clever with the hash |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $r = $this->db->query("UPDATE users |
252 | 252 | SET registrationtoken = :registrationtoken |
253 | 253 | WHERE user_id = :user_id |
254 | - ", array ( |
|
254 | + ", array( |
|
255 | 255 | ':registrationtoken' => $this->registrationtoken, |
256 | 256 | ':user_id' => $this->user_id |
257 | 257 | )); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | } |
299 | 299 | |
300 | 300 | public function add_facebook_id($facebook_id) { |
301 | - $q = $this->db->query ("UPDATE users SET facebook_id = :facebook_id WHERE email = :email", |
|
301 | + $q = $this->db->query("UPDATE users SET facebook_id = :facebook_id WHERE email = :email", |
|
302 | 302 | array( |
303 | 303 | ':facebook_id' => $facebook_id, |
304 | 304 | ':email' => $this->email |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | !isset($details['email']) || |
320 | 320 | $details['email'] == '' || |
321 | 321 | !isset($details['token']) || |
322 | - $details['token'] == '' ) { |
|
322 | + $details['token'] == '') { |
|
323 | 323 | return false; |
324 | 324 | } |
325 | 325 | |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | $confirmurl = 'https://' . DOMAIN . '/E/' . $urltoken; |
332 | 332 | |
333 | 333 | // Arrays we need to send a templated email. |
334 | - $data = array ( |
|
334 | + $data = array( |
|
335 | 335 | 'to' => $details['email'], |
336 | 336 | 'template' => 'email_confirmation' |
337 | 337 | ); |
338 | 338 | |
339 | - $merge = array ( |
|
339 | + $merge = array( |
|
340 | 340 | 'FIRSTNAME' => $details['firstname'], |
341 | 341 | 'LASTNAME' => $details['lastname'], |
342 | 342 | 'CONFIRMURL' => $confirmurl |
@@ -373,12 +373,12 @@ discard block |
||
373 | 373 | $confirmurl = 'https://' . DOMAIN . '/U/' . $urltoken; |
374 | 374 | |
375 | 375 | // Arrays we need to send a templated email. |
376 | - $data = array ( |
|
376 | + $data = array( |
|
377 | 377 | 'to' => $details['email'], |
378 | 378 | 'template' => 'join_confirmation' |
379 | 379 | ); |
380 | 380 | |
381 | - $merge = array ( |
|
381 | + $merge = array( |
|
382 | 382 | 'FIRSTNAME' => $details['firstname'], |
383 | 383 | 'LASTNAME' => $details['lastname'], |
384 | 384 | 'CONFIRMURL' => $confirmurl |
@@ -440,23 +440,23 @@ discard block |
||
440 | 440 | $this->email = $email; |
441 | 441 | for (;;) { |
442 | 442 | |
443 | - $pwd=null; |
|
444 | - $o=null; |
|
443 | + $pwd = null; |
|
444 | + $o = null; |
|
445 | 445 | |
446 | 446 | // Generates the password .... |
447 | - for ($x=0; $x < 6;) { |
|
448 | - $y = rand(1,1000); |
|
449 | - if($y>350 && $y<601) $d=chr(rand(48,57)); |
|
450 | - if($y<351) $d=chr(rand(65,90)); |
|
451 | - if($y>600) $d=chr(rand(97,122)); |
|
452 | - if ($d!=$o && !preg_match('#[O01lI]#', $d)) { |
|
453 | - $o=$d; $pwd.=$d; $x++; |
|
447 | + for ($x = 0; $x < 6;) { |
|
448 | + $y = rand(1, 1000); |
|
449 | + if ($y > 350 && $y < 601) $d = chr(rand(48, 57)); |
|
450 | + if ($y < 351) $d = chr(rand(65, 90)); |
|
451 | + if ($y > 600) $d = chr(rand(97, 122)); |
|
452 | + if ($d != $o && !preg_match('#[O01lI]#', $d)) { |
|
453 | + $o = $d; $pwd .= $d; $x++; |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
457 | 457 | // If the PW fits your purpose (e.g. this regexpression) return it, else make a new one |
458 | 458 | // (You can change this regular-expression how you want ....) |
459 | - if (preg_match("/^[a-zA-Z]{1}([a-zA-Z]+[0-9][a-zA-Z]+)+/",$pwd)) { |
|
459 | + if (preg_match("/^[a-zA-Z]{1}([a-zA-Z]+[0-9][a-zA-Z]+)+/", $pwd)) { |
|
460 | 460 | break; |
461 | 461 | } |
462 | 462 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | |
475 | 475 | $passwordforDB = password_hash($pwd, PASSWORD_BCRYPT); |
476 | 476 | |
477 | - $q = $this->db->query ("UPDATE users SET password = :password WHERE email = :email", |
|
477 | + $q = $this->db->query("UPDATE users SET password = :password WHERE email = :email", |
|
478 | 478 | array( |
479 | 479 | ':password' => $passwordforDB, |
480 | 480 | ':email' => $email |
@@ -502,14 +502,14 @@ discard block |
||
502 | 502 | return false; |
503 | 503 | } |
504 | 504 | |
505 | - $data = array ( |
|
505 | + $data = array( |
|
506 | 506 | 'to' => $this->email(), |
507 | 507 | 'template' => 'new_password' |
508 | 508 | ); |
509 | 509 | |
510 | 510 | $URL = new \MySociety\TheyWorkForYou\Url("userlogin"); |
511 | 511 | |
512 | - $merge = array ( |
|
512 | + $merge = array( |
|
513 | 513 | 'EMAIL' => $this->email(), |
514 | 514 | 'LOGINURL' => "https://" . DOMAIN . $URL->generate(), |
515 | 515 | 'PASSWORD' => $this->password() |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | public function facebook_id_exists($id, $return_id = false) { |
569 | 569 | // Returns true if there's a user with this facebook id. |
570 | 570 | |
571 | - if ($id!= "") { |
|
571 | + if ($id != "") { |
|
572 | 572 | $q = $this->db->query("SELECT user_id FROM users WHERE facebook_id = :id", array(':id' => $id)); |
573 | 573 | if ($q->rows() > 0) { |
574 | 574 | if ($return_id) { |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | /* Everyone */ return true; |
648 | 648 | |
649 | 649 | default: |
650 | - $PAGE->error_message ("You need to set permissions for '$action'!"); |
|
650 | + $PAGE->error_message("You need to set permissions for '$action'!"); |
|
651 | 651 | |
652 | 652 | return false; |
653 | 653 | |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | // Maybe there's a way of fetching these from the DB, |
666 | 666 | // so we don't duplicate them here...? |
667 | 667 | |
668 | - $statuses = array ("Viewer", "User", "Moderator", "Administrator", "Superuser"); |
|
668 | + $statuses = array("Viewer", "User", "Moderator", "Administrator", "Superuser"); |
|
669 | 669 | |
670 | 670 | return $statuses; |
671 | 671 | |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | return $details; |
825 | 825 | |
826 | 826 | } else { |
827 | - $PAGE->error_message ("Sorry, we were unable to update user id '" . _htmlentities($details["user_id"]) . "'"); |
|
827 | + $PAGE->error_message("Sorry, we were unable to update user id '" . _htmlentities($details["user_id"]) . "'"); |
|
828 | 828 | |
829 | 829 | return false; |
830 | 830 | } |
@@ -897,13 +897,13 @@ discard block |
||
897 | 897 | |
898 | 898 | if ($this->facebook_user) { |
899 | 899 | if (md5($this->facebook_token()) == $matches[2] && $this->deleted() == false) { |
900 | - twfy_debug ("THEUSER", "init SUCCESS: setting as logged in"); |
|
900 | + twfy_debug("THEUSER", "init SUCCESS: setting as logged in"); |
|
901 | 901 | $this->loggedin = true; |
902 | - } elseif (md5 ($this->facebook_token()) != $matches[2]) { |
|
903 | - twfy_debug ("THEUSER", "init FAILED: Facebook token doesn't match cookie"); |
|
902 | + } elseif (md5($this->facebook_token()) != $matches[2]) { |
|
903 | + twfy_debug("THEUSER", "init FAILED: Facebook token doesn't match cookie"); |
|
904 | 904 | $this->loggedin = false; |
905 | 905 | } else { |
906 | - twfy_debug ("THEUSER", "init FAILED: User is deleted"); |
|
906 | + twfy_debug("THEUSER", "init FAILED: User is deleted"); |
|
907 | 907 | $this->loggedin = false; |
908 | 908 | } |
909 | 909 | } else { |
@@ -916,30 +916,30 @@ discard block |
||
916 | 916 | // to need. Their preferences and saved things or something. |
917 | 917 | |
918 | 918 | |
919 | - twfy_debug ("THEUSER init SUCCEEDED", "setting as logged in"); |
|
919 | + twfy_debug("THEUSER init SUCCEEDED", "setting as logged in"); |
|
920 | 920 | $this->loggedin = true; |
921 | 921 | |
922 | - } elseif (md5 ($this->password()) != $matches[2]) { |
|
923 | - twfy_debug ("THEUSER init FAILED", "Password doesn't match cookie"); |
|
922 | + } elseif (md5($this->password()) != $matches[2]) { |
|
923 | + twfy_debug("THEUSER init FAILED", "Password doesn't match cookie"); |
|
924 | 924 | $this->loggedin = false; |
925 | 925 | } else { |
926 | - twfy_debug ("THEUSER init FAILED", "User is deleted"); |
|
926 | + twfy_debug("THEUSER init FAILED", "User is deleted"); |
|
927 | 927 | $this->loggedin = false; |
928 | 928 | } |
929 | 929 | } |
930 | 930 | |
931 | 931 | } else { |
932 | - twfy_debug ("THEUSER init FAILED", "didn't get 1 row from db"); |
|
932 | + twfy_debug("THEUSER init FAILED", "didn't get 1 row from db"); |
|
933 | 933 | $this->loggedin = false; |
934 | 934 | } |
935 | 935 | |
936 | 936 | } else { |
937 | - twfy_debug ("THEUSER init FAILED", "cookie's user_id is not numeric"); |
|
937 | + twfy_debug("THEUSER init FAILED", "cookie's user_id is not numeric"); |
|
938 | 938 | $this->loggedin = false; |
939 | 939 | } |
940 | 940 | |
941 | 941 | } else { |
942 | - twfy_debug ("THEUSER init FAILED", "cookie is not of the correct form"); |
|
942 | + twfy_debug("THEUSER init FAILED", "cookie is not of the correct form"); |
|
943 | 943 | $this->loggedin = false; |
944 | 944 | } |
945 | 945 | |
@@ -1010,67 +1010,67 @@ discard block |
||
1010 | 1010 | |
1011 | 1011 | if ($q->rows() == 1) { |
1012 | 1012 | // OK. |
1013 | - $dbpassword = $q->field(0,"password"); |
|
1013 | + $dbpassword = $q->field(0, "password"); |
|
1014 | 1014 | if (password_verify($userenteredpassword, $dbpassword)) { |
1015 | - $this->user_id = $q->field(0,"user_id"); |
|
1015 | + $this->user_id = $q->field(0, "user_id"); |
|
1016 | 1016 | $this->password = $dbpassword; |
1017 | 1017 | // We'll need these when we're going to log in. |
1018 | - $this->deleted = $q->field(0,"deleted") == 1 ? true : false; |
|
1019 | - $this->confirmed = $q->field(0,"confirmed") == 1 ? true : false; |
|
1018 | + $this->deleted = $q->field(0, "deleted") == 1 ? true : false; |
|
1019 | + $this->confirmed = $q->field(0, "confirmed") == 1 ? true : false; |
|
1020 | 1020 | |
1021 | 1021 | return true; |
1022 | 1022 | |
1023 | 1023 | } else { |
1024 | 1024 | // Failed. |
1025 | - return array ("invalidemail" => $error_string); |
|
1025 | + return array("invalidemail" => $error_string); |
|
1026 | 1026 | |
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | } else { |
1030 | 1030 | // Failed. |
1031 | - return array ("invalidemail" => $error_string); |
|
1031 | + return array("invalidemail" => $error_string); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | public function has_postcode() { |
1037 | 1037 | $has_postcode = false; |
1038 | - if ( $this->isloggedin() && $this->postcode() != '' || $this->postcode_is_set() ) { |
|
1038 | + if ($this->isloggedin() && $this->postcode() != '' || $this->postcode_is_set()) { |
|
1039 | 1039 | $has_postcode = true; |
1040 | 1040 | } |
1041 | 1041 | return $has_postcode; |
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | |
1045 | - public function facebook_login($returl="", $expire, $accessToken) { |
|
1045 | + public function facebook_login($returl = "", $expire, $accessToken) { |
|
1046 | 1046 | global $PAGE; |
1047 | 1047 | |
1048 | 1048 | twfy_debug("THEUSER", "Faceook login, user_id " . $this->user_id); |
1049 | 1049 | twfy_debug("THEUSER", "Faceook login, facebook_id " . $this->facebook_id); |
1050 | 1050 | twfy_debug("THEUSER", "Faceook login, email" . $this->email); |
1051 | 1051 | if ($this->facebook_id() == "") { |
1052 | - $PAGE->error_message ("We don't have a facebook id for this user.", true); |
|
1052 | + $PAGE->error_message("We don't have a facebook id for this user.", true); |
|
1053 | 1053 | |
1054 | 1054 | return; |
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | twfy_debug("THEUSER", "Faceook login, facebook_token: " . $accessToken); |
1058 | 1058 | |
1059 | - $q = $this->db->query ("UPDATE users SET facebook_token = :token WHERE email = :email", |
|
1059 | + $q = $this->db->query("UPDATE users SET facebook_token = :token WHERE email = :email", |
|
1060 | 1060 | array( |
1061 | 1061 | ':token' => $accessToken, |
1062 | 1062 | ':email' => $this->email |
1063 | 1063 | )); |
1064 | 1064 | |
1065 | 1065 | if (!$q->success()) { |
1066 | - $PAGE->error_message ("There was a problem logging you in", true); |
|
1066 | + $PAGE->error_message("There was a problem logging you in", true); |
|
1067 | 1067 | twfy_debug("THEUSER", "Faceook login, failed to set accessToken"); |
1068 | 1068 | |
1069 | 1069 | return false; |
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | // facebook login users probably don't have a password |
1073 | - $cookie = $this->user_id() . "." . md5 ($accessToken); |
|
1073 | + $cookie = $this->user_id() . "." . md5($accessToken); |
|
1074 | 1074 | twfy_debug("THEUSER", "Faceook login, cookie: " . $cookie); |
1075 | 1075 | |
1076 | 1076 | twfy_debug("USER", "logging in user from facebook " . $this->user_id); |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | return true; |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - public function login($returl="", $expire) { |
|
1083 | + public function login($returl = "", $expire) { |
|
1084 | 1084 | |
1085 | 1085 | // This is used to log the user in. Duh. |
1086 | 1086 | // You should already have checked the user's email and password using |
@@ -1102,21 +1102,21 @@ discard block |
||
1102 | 1102 | |
1103 | 1103 | // Various checks about the user - if they fail, we exit. |
1104 | 1104 | if ($this->user_id() == "" || $this->password == "") { |
1105 | - $PAGE->error_message ("We don't have the user_id or password to make the cookie.", true); |
|
1105 | + $PAGE->error_message("We don't have the user_id or password to make the cookie.", true); |
|
1106 | 1106 | |
1107 | 1107 | return; |
1108 | 1108 | } elseif ($this->deleted) { |
1109 | - $PAGE->error_message ("This user has been deleted.", true); |
|
1109 | + $PAGE->error_message("This user has been deleted.", true); |
|
1110 | 1110 | |
1111 | 1111 | return; |
1112 | 1112 | } elseif (!$this->confirmed) { |
1113 | - $PAGE->error_message ("You have not yet confirmed your account by clicking the link in the confirmation email we sent to you. If you don't have the email, you can <a href='/user/login/?resend=" . $this->user_id() . "'>have it resent</a>. If it still doesn't arrive, get in touch.", true); |
|
1113 | + $PAGE->error_message("You have not yet confirmed your account by clicking the link in the confirmation email we sent to you. If you don't have the email, you can <a href='/user/login/?resend=" . $this->user_id() . "'>have it resent</a>. If it still doesn't arrive, get in touch.", true); |
|
1114 | 1114 | |
1115 | 1115 | return; |
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | // Reminder: $this->password is actually a hashed version of the plaintext pw. |
1119 | - $cookie = $this->user_id() . "." . md5 ($this->password()); |
|
1119 | + $cookie = $this->user_id() . "." . md5($this->password()); |
|
1120 | 1120 | |
1121 | 1121 | $this->_login($returl, $expire, $cookie); |
1122 | 1122 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | $cookie_expires = 0; |
1133 | 1133 | if ($expire == 'never') { |
1134 | 1134 | twfy_debug("THEUSER", "cookie never expires"); |
1135 | - $cookie_expires = time()+86400*365*20; |
|
1135 | + $cookie_expires = time() + 86400 * 365 * 20; |
|
1136 | 1136 | } elseif (is_int($expire) && $expire > time()) { |
1137 | 1137 | twfy_debug("THEUSER", "cookie expires at " . $expire); |
1138 | 1138 | $cookie_expires = $expire; |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | } |
1171 | 1171 | } |
1172 | 1172 | |
1173 | - public function confirm_email($token, $redirect=true) { |
|
1173 | + public function confirm_email($token, $redirect = true) { |
|
1174 | 1174 | $arg = ''; |
1175 | 1175 | if (strstr($token, '::')) $arg = '::'; |
1176 | 1176 | if (strstr($token, '-')) $arg = '-'; |
@@ -1183,24 +1183,24 @@ discard block |
||
1183 | 1183 | FROM tokens |
1184 | 1184 | WHERE token = :token |
1185 | 1185 | AND type = 'E' |
1186 | - ", array (':token' => $registrationtoken)); |
|
1186 | + ", array(':token' => $registrationtoken)); |
|
1187 | 1187 | |
1188 | 1188 | if ($q->rows() == 1) { |
1189 | 1189 | $expires = $q->field(0, 'expires'); |
1190 | 1190 | $expire_time = strtotime($expires); |
1191 | - if ( $expire_time < time() ) { |
|
1191 | + if ($expire_time < time()) { |
|
1192 | 1192 | global $PAGE; |
1193 | 1193 | if ($PAGE && $redirect) { |
1194 | - $PAGE->error_message ("Sorry, that token seems to have expired"); |
|
1194 | + $PAGE->error_message("Sorry, that token seems to have expired"); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | return false; |
1198 | 1198 | } |
1199 | 1199 | |
1200 | - list( $user_id, $email ) = explode('::', $q->field(0, 'data')); |
|
1200 | + list($user_id, $email) = explode('::', $q->field(0, 'data')); |
|
1201 | 1201 | |
1202 | 1202 | // if we are logged in as someone else don't change the email |
1203 | - if ( $this->user_id() != 0 && $this->user_id() != $user_id ) { |
|
1203 | + if ($this->user_id() != 0 && $this->user_id() != $user_id) { |
|
1204 | 1204 | return false; |
1205 | 1205 | } |
1206 | 1206 | |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | |
1341 | 1341 | twfy_debug("THEUSER", "User with ID found to confirm: " . $this->user_id()); |
1342 | 1342 | // We'll need these to be set before logging the user in. |
1343 | - $this->email = $q->field(0, 'email'); |
|
1343 | + $this->email = $q->field(0, 'email'); |
|
1344 | 1344 | |
1345 | 1345 | // Set that they're confirmed in the DB. |
1346 | 1346 | $r = $this->db->query("UPDATE users |
@@ -1387,14 +1387,14 @@ discard block |
||
1387 | 1387 | |
1388 | 1388 | $this->postcode = $pc; |
1389 | 1389 | if (!headers_sent()) // if in debug mode |
1390 | - setcookie (POSTCODE_COOKIE, $pc, time()+7*86400, "/", COOKIEDOMAIN); |
|
1390 | + setcookie(POSTCODE_COOKIE, $pc, time() + 7 * 86400, "/", COOKIEDOMAIN); |
|
1391 | 1391 | |
1392 | 1392 | twfy_debug('USER', "Set the cookie named '" . POSTCODE_COOKIE . " to '$pc' for " . COOKIEDOMAIN . " domain"); |
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | public function unset_postcode_cookie() { |
1396 | 1396 | if (!headers_sent()) // if in debug mode |
1397 | - setcookie (POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN); |
|
1397 | + setcookie(POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN); |
|
1398 | 1398 | } |
1399 | 1399 | |
1400 | 1400 | // mostly here for updating from facebook where we do not need |
@@ -1407,8 +1407,8 @@ discard block |
||
1407 | 1407 | |
1408 | 1408 | // this is checked elsewhere but just in case we check here and |
1409 | 1409 | // bail out to be on the safe side |
1410 | - if ( isset($details['email'] ) ) { |
|
1411 | - if ( $details['email'] != $this->email() && $this->email_exists( $details['email'] ) ) { |
|
1410 | + if (isset($details['email'])) { |
|
1411 | + if ($details['email'] != $this->email() && $this->email_exists($details['email'])) { |
|
1412 | 1412 | return false; |
1413 | 1413 | } |
1414 | 1414 | } |
@@ -1457,8 +1457,8 @@ discard block |
||
1457 | 1457 | // this is checked elsewhere but just in case we check here and |
1458 | 1458 | // bail out to be on the safe side |
1459 | 1459 | $email = ''; |
1460 | - if ( isset($details['email'] ) ) { |
|
1461 | - if ( $details['email'] != $this->email() && $this->email_exists( $details['email'] ) ) { |
|
1460 | + if (isset($details['email'])) { |
|
1461 | + if ($details['email'] != $this->email() && $this->email_exists($details['email'])) { |
|
1462 | 1462 | return false; |
1463 | 1463 | } |
1464 | 1464 | $email = $details['email']; |
@@ -1486,7 +1486,7 @@ discard block |
||
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | if ($email && $email != $this->email) { |
1489 | - $token = substr( password_hash($email . microtime(), PASSWORD_BCRYPT), 29, 16 ); |
|
1489 | + $token = substr(password_hash($email . microtime(), PASSWORD_BCRYPT), 29, 16); |
|
1490 | 1490 | $data = $this->user_id() . '::' . $email; |
1491 | 1491 | $r = $this->db->query("INSERT INTO tokens |
1492 | 1492 | ( expires, token, type, data ) |
@@ -1503,7 +1503,7 @@ discard block |
||
1503 | 1503 | )); |
1504 | 1504 | |
1505 | 1505 | // send confirmation email here |
1506 | - if ( $r->success() ) { |
|
1506 | + if ($r->success()) { |
|
1507 | 1507 | $newdetails['email'] = $email; |
1508 | 1508 | $newdetails['token'] = $token; |
1509 | 1509 | if ($confirm_email) { |
@@ -21,21 +21,21 @@ discard block |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | // This handles basic insertion and approval functions for all epobjects |
24 | -include_once INCLUDESPATH."easyparliament/editqueue.php"; |
|
25 | -include_once INCLUDESPATH."easyparliament/searchengine.php"; |
|
24 | +include_once INCLUDESPATH . "easyparliament/editqueue.php"; |
|
25 | +include_once INCLUDESPATH . "easyparliament/searchengine.php"; |
|
26 | 26 | |
27 | 27 | class GLOSSARY { |
28 | 28 | |
29 | - public $num_terms; // how many glossary entries do we have |
|
29 | + public $num_terms; // how many glossary entries do we have |
|
30 | 30 | // (changes depending on how GLOSSARY is called |
31 | - public $hansard_count; // how many times does the phrase appear in hansard? |
|
32 | - public $query; // search term |
|
33 | - public $glossary_id; // if this is set then we only have 1 glossary term |
|
34 | - public $current_term; // will only be set if we have a valid epobject_id |
|
31 | + public $hansard_count; // how many times does the phrase appear in hansard? |
|
32 | + public $query; // search term |
|
33 | + public $glossary_id; // if this is set then we only have 1 glossary term |
|
34 | + public $current_term; // will only be set if we have a valid epobject_id |
|
35 | 35 | public $current_letter; |
36 | 36 | |
37 | 37 | // constructor... |
38 | - public function __construct($args=array()) { |
|
38 | + public function __construct($args = array()) { |
|
39 | 39 | // We can optionally start the glossary with one of several arguments |
40 | 40 | // 1. glossary_id - treat the glossary as a single term |
41 | 41 | // 2. glossary_term - search within glossary for a term |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | |
75 | 75 | // These stop stupid submissions. |
76 | 76 | // everything should be lowercase. |
77 | - $this->stopwords = array( "the", "of", "to", "and", "for", "in", "a", "on", "is", "that", "will", "secretary", "are", "ask", "state", "have", "be", "has", "by", "with", "i", "not", "what", "as", "it", "hon", "he", "which", "from", "if", "been", "this", "s", "we", "at", "government", "was", "my", "an", "department", "there", "make", "or", "made", "their", "all", "but", "they", "how", "debate" ); |
|
77 | + $this->stopwords = array("the", "of", "to", "and", "for", "in", "a", "on", "is", "that", "will", "secretary", "are", "ask", "state", "have", "be", "has", "by", "with", "i", "not", "what", "as", "it", "hon", "he", "which", "from", "if", "been", "this", "s", "we", "at", "government", "was", "my", "an", "department", "there", "make", "or", "made", "their", "all", "but", "they", "how", "debate"); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | - public function get_glossary_item($args=array()) { |
|
81 | + public function get_glossary_item($args = array()) { |
|
82 | 82 | // Search for and fetch glossary item with title or glossary_id |
83 | 83 | // We could also search glossary text that contains the title text, for cross references |
84 | 84 | |
85 | 85 | $this->alphabet = array(); |
86 | - foreach (range ("A", "Z") as $letter) { |
|
86 | + foreach (range("A", "Z") as $letter) { |
|
87 | 87 | $this->alphabet[$letter] = array(); |
88 | 88 | } |
89 | 89 | |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | WHERE g.glossary_id=eq.glossary_id AND u.user_id=eq.user_id AND g.visible=1 AND eq.approved=1 |
93 | 93 | ORDER by g.title"); |
94 | 94 | if ($q->success() && $q->rows()) { |
95 | - for ($i=0; $i < $q->rows(); $i++) { |
|
96 | - $this->terms[ $q->field($i,"glossary_id") ] = $q->row($i); |
|
95 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
96 | + $this->terms[$q->field($i, "glossary_id")] = $q->row($i); |
|
97 | 97 | // Now add the epobject to the alphabet navigation. |
98 | - $first_letter = strtoupper(substr($q->field($i,"title"),0,1)); |
|
99 | - $this->alphabet[$first_letter][] = $q->field($i,"glossary_id"); |
|
98 | + $first_letter = strtoupper(substr($q->field($i, "title"), 0, 1)); |
|
99 | + $this->alphabet[$first_letter][] = $q->field($i, "glossary_id"); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $this->num_terms = $q->rows(); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | - public function search_glossary($args=array()) { |
|
142 | + public function search_glossary($args = array()) { |
|
143 | 143 | // Search for and fetch glossary item with a title |
144 | 144 | // Useful for the search page, and nowhere else (so far) |
145 | 145 | |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | ORDER by g.title"; |
155 | 155 | $q = $this->db->query($query); |
156 | 156 | if ($q->success() && $q->rows()) { |
157 | - for ($i=0; $i < $q->rows(); $i++) { |
|
158 | - $this->search_matches[ $q->field($i,"glossary_id") ] = $q->row($i); |
|
157 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
158 | + $this->search_matches[$q->field($i, "glossary_id")] = $q->row($i); |
|
159 | 159 | } |
160 | 160 | $this->num_search_matches = $q->rows(); |
161 | 161 | } |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | global $THEUSER; |
192 | 192 | |
193 | 193 | if ($data['title'] == '') { |
194 | - error ("Sorry, you can't define a term without a title"); |
|
194 | + error("Sorry, you can't define a term without a title"); |
|
195 | 195 | return false; |
196 | 196 | } |
197 | 197 | |
198 | 198 | if ($data['body'] == '') { |
199 | - error ("You haven't entered a definition!"); |
|
199 | + error("You haven't entered a definition!"); |
|
200 | 200 | return false; |
201 | 201 | } |
202 | 202 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | - public function glossarise($body, $tokenize=0, $urlize=0) { |
|
252 | + public function glossarise($body, $tokenize = 0, $urlize = 0) { |
|
253 | 253 | // Turn a body of text into a link-up wonderland of glossary joy |
254 | 254 | |
255 | 255 | global $this_page; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | } |
293 | 293 | else { |
294 | 294 | if ($this_page == "admin_glossary") { |
295 | - $link_url = "#gl".$glossary_id; |
|
295 | + $link_url = "#gl" . $glossary_id; |
|
296 | 296 | } |
297 | 297 | else { |
298 | 298 | $link_url = $URL->generate('url'); |