@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | if (strstr(XAPIANDB, ":")) { |
47 | 47 | //ini_set('display_errors', 'On'); |
48 | 48 | list ($xapian_host, $xapian_port) = explode(":", XAPIANDB); |
49 | - twfy_debug("SEARCH", "Using Xapian remote backend: " . $xapian_host . " port " . $xapian_port); |
|
49 | + twfy_debug("SEARCH", "Using Xapian remote backend: ".$xapian_host." port ".$xapian_port); |
|
50 | 50 | $xapiandb_remote = remote_open($xapian_host, intval($xapian_port)); |
51 | 51 | $xapiandb = new XapianDatabase($xapiandb_remote); |
52 | 52 | } else { |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | $this->prefixed = array(); |
93 | 93 | |
94 | 94 | // Split words up into individual words, and quoted phrases |
95 | - preg_match_all('/(' . |
|
96 | - '"|' . # match either a quote, or... |
|
97 | - '(?:(?<![' .$this->wordchars. '])-)?' . # optionally a - (exclude) |
|
95 | + preg_match_all('/('. |
|
96 | + '"|'.# match either a quote, or... |
|
97 | + '(?:(?<!['.$this->wordchars.'])-)?'.# optionally a - (exclude) |
|
98 | 98 | # if at start of word (i.e. not preceded by a word character, in |
99 | 99 | # which case it is probably a hyphenated-word) |
100 | - '['.$this->wordchars.']+' . # followed by a string of word-characters |
|
100 | + '['.$this->wordchars.']+'.# followed by a string of word-characters |
|
101 | 101 | ')/', $this->query, $all_words); |
102 | 102 | if ($all_words) { |
103 | 103 | $all_words = $all_words[0]; |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | if (strpos($word, ':') !== false) { |
123 | 123 | $items = explode(":", strtolower($word)); |
124 | 124 | $type = $items[0]; |
125 | - if (substr($type, 0, 1)=='-') $type = substr($type, 1); |
|
126 | - $value = strtolower(join(":", array_slice($items,1))); |
|
125 | + if (substr($type, 0, 1) == '-') $type = substr($type, 1); |
|
126 | + $value = strtolower(join(":", array_slice($items, 1))); |
|
127 | 127 | if ($type == 'section') { |
128 | 128 | $newv = $value; |
129 | 129 | if ($value == 'debates' || $value == 'debate') $newv = 1; |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | elseif ($value == 'pbc' || $value == 'standing') $newv = 6; |
136 | 136 | elseif ($value == 'sp') $newv = 7; |
137 | 137 | elseif ($value == 'spwrans' || $value == 'spwran') $newv = 8; |
138 | - elseif ($value == 'uk') $newv = array(1,2,3,4,6,101); |
|
139 | - elseif ($value == 'scotland') $newv = array(7,8); |
|
138 | + elseif ($value == 'uk') $newv = array(1, 2, 3, 4, 6, 101); |
|
139 | + elseif ($value == 'scotland') $newv = array(7, 8); |
|
140 | 140 | elseif ($value == 'future') $newv = 'F'; |
141 | 141 | if (is_array($newv)) { |
142 | - $newv = 'major:' . join(' major:', $newv); |
|
142 | + $newv = 'major:'.join(' major:', $newv); |
|
143 | 143 | } else { |
144 | 144 | $newv = "major:$newv"; |
145 | 145 | } |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | # Merged people |
180 | 180 | $db = new ParlDB; |
181 | 181 | $merged = $db->query('SELECT * FROM gidredirect WHERE gid_from LIKE :gid_from', array(':gid_from' => "uk.org.publicwhip/person/%")); |
182 | - for ($n=0; $n<$merged->rows(); $n++) { |
|
182 | + for ($n = 0; $n < $merged->rows(); $n++) { |
|
183 | 183 | $from_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_from')); |
184 | 184 | $to_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_to')); |
185 | 185 | $this->query = preg_replace("#speaker:($from_id|$to_id)#i", "(speaker:$from_id OR speaker:$to_id)", $this->query); |
186 | 186 | } |
187 | 187 | |
188 | - twfy_debug("SEARCH", "prefixed: " . var_export($this->prefixed, true)); |
|
188 | + twfy_debug("SEARCH", "prefixed: ".var_export($this->prefixed, true)); |
|
189 | 189 | |
190 | - twfy_debug("SEARCH", "query -- ". $this->query); |
|
190 | + twfy_debug("SEARCH", "query -- ".$this->query); |
|
191 | 191 | $flags = XapianQueryParser::FLAG_BOOLEAN | XapianQueryParser::FLAG_LOVEHATE | |
192 | 192 | XapianQueryParser::FLAG_WILDCARD | XapianQueryParser::FLAG_SPELLING_CORRECTION; |
193 | 193 | $flags = $flags | XapianQueryParser::FLAG_PHRASE; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | # Now parse the parsed query back into a query string, yummy |
206 | 206 | |
207 | 207 | $qd = $query->get_description(); |
208 | - twfy_debug("SEARCH", "queryparser original description -- " . $qd); |
|
208 | + twfy_debug("SEARCH", "queryparser original description -- ".$qd); |
|
209 | 209 | $qd = substr($qd, 14, -1); # Strip Xapian::Query() |
210 | 210 | $qd = preg_replace('#:\(.*?\)#', '', $qd); # Don't need pos or weight |
211 | 211 | # Date range |
@@ -256,11 +256,11 @@ discard block |
||
256 | 256 | $iter->next(); |
257 | 257 | } |
258 | 258 | $used[] = $tt; |
259 | - $qd = preg_replace('#' . preg_quote($mm, '#') . '#', $tt, $qd, 1); |
|
259 | + $qd = preg_replace('#'.preg_quote($mm, '#').'#', $tt, $qd, 1); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | # Speakers |
263 | - for ($n=0; $n<$merged->rows(); $n++) { |
|
263 | + for ($n = 0; $n < $merged->rows(); $n++) { |
|
264 | 264 | $from_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_from')); |
265 | 265 | $to_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_to')); |
266 | 266 | $qd = str_replace("(S$from_id OR S$to_id)", "S$to_id", $qd); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $qd = preg_replace('#AND_NOT ([a-z0-9"]+)#', '-$1', $qd); |
279 | 279 | preg_match_all('#AND_NOT \((.*?)\)#', $qd, $m); |
280 | 280 | foreach ($m[1] as $mm) { |
281 | - $mmn = '-' . join(' -', explode(' OR ', $mm)); |
|
281 | + $mmn = '-'.join(' -', explode(' OR ', $mm)); |
|
282 | 282 | $qd = str_replace("AND_NOT ($mm)", $mmn, $qd); |
283 | 283 | } |
284 | 284 | |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | $this->query_desc = trim($qd); |
298 | 298 | |
299 | 299 | #print 'DEBUG: ' . $query->get_description(); |
300 | - twfy_debug("SEARCH", "words: " . var_export($this->words, true)); |
|
301 | - twfy_debug("SEARCH", "phrases: " . var_export($this->phrases, true)); |
|
302 | - twfy_debug("SEARCH", "queryparser description -- " . $this->query_desc); |
|
300 | + twfy_debug("SEARCH", "words: ".var_export($this->words, true)); |
|
301 | + twfy_debug("SEARCH", "phrases: ".var_export($this->phrases, true)); |
|
302 | + twfy_debug("SEARCH", "queryparser description -- ".$this->query_desc); |
|
303 | 303 | |
304 | 304 | $this->valid = true; |
305 | 305 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | } |
340 | 340 | |
341 | 341 | // Perform partial query to get a count of number of matches |
342 | - public function run_count($first_result, $results_per_page, $sort_order='relevance') { |
|
342 | + public function run_count($first_result, $results_per_page, $sort_order = 'relevance') { |
|
343 | 343 | if (!defined('XAPIANDB') || !XAPIANDB) |
344 | 344 | return null; |
345 | 345 | |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | #} |
413 | 413 | |
414 | 414 | $duration = getmicrotime() - $start; |
415 | - twfy_debug ("SEARCH", "Search count took $duration seconds."); |
|
415 | + twfy_debug("SEARCH", "Search count took $duration seconds."); |
|
416 | 416 | |
417 | 417 | return $count; |
418 | 418 | } |
419 | 419 | |
420 | 420 | // Perform the full search... |
421 | - public function run_search($first_result, $results_per_page, $sort_order='relevance') { |
|
421 | + public function run_search($first_result, $results_per_page, $sort_order = 'relevance') { |
|
422 | 422 | $start = getmicrotime(); |
423 | 423 | |
424 | 424 | #$matches = $this->enquire->get_mset($first_result, $results_per_page); |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | $iter->next(); |
446 | 446 | } |
447 | 447 | $duration = getmicrotime() - $start; |
448 | - twfy_debug ("SEARCH", "Run search took $duration seconds."); |
|
448 | + twfy_debug("SEARCH", "Run search took $duration seconds."); |
|
449 | 449 | } |
450 | 450 | // ... use these to get the results |
451 | 451 | public function get_gids() { |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | if ($hl) { |
511 | 511 | $hlextract .= "<span class=\"hi\">$extractword</span>$endswithamp"; |
512 | 512 | } else { |
513 | - $hlextract .= $extractword . $endswithamp; |
|
513 | + $hlextract .= $extractword.$endswithamp; |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | $body = preg_replace("#</span>\s+<span class=\"hi\">#", " ", $hlextract); |
@@ -547,17 +547,17 @@ discard block |
||
547 | 547 | |
548 | 548 | // Find the position of the first of the search words/phrases in $body. |
549 | 549 | public function position_of_first_word($body) { |
550 | - $lcbody = ' ' . html_entity_decode(strtolower($body)) . ' '; // spaces to make regexp mapping easier |
|
550 | + $lcbody = ' '.html_entity_decode(strtolower($body)).' '; // spaces to make regexp mapping easier |
|
551 | 551 | $pos = -1; |
552 | 552 | |
553 | 553 | // look for phrases |
554 | 554 | foreach ($this->phrases as $phrase) { |
555 | 555 | $phrasematch = join($phrase, '[^'.$this->wordchars.']+'); |
556 | - if (preg_match('/([^'.$this->wordchars.']' . $phrasematch . '[^A-Za-z0-9])/', $lcbody, $matches)) |
|
556 | + if (preg_match('/([^'.$this->wordchars.']'.$phrasematch.'[^A-Za-z0-9])/', $lcbody, $matches)) |
|
557 | 557 | { |
558 | - $wordpos = strpos( $lcbody, $matches[0] ); |
|
558 | + $wordpos = strpos($lcbody, $matches[0]); |
|
559 | 559 | if ($wordpos) { |
560 | - if ( ($wordpos < $pos) || ($pos==-1) ) { |
|
560 | + if (($wordpos < $pos) || ($pos == -1)) { |
|
561 | 561 | $pos = $wordpos; |
562 | 562 | } |
563 | 563 | } |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | foreach ($stemmed_words as $word) { |
576 | 576 | if ($word == '') continue; |
577 | 577 | $matchword = $this->stem($extractword); |
578 | - if ($matchword == $word && ($wordpos < $pos || $pos==-1)) { |
|
578 | + if ($matchword == $word && ($wordpos < $pos || $pos == -1)) { |
|
579 | 579 | $pos = $wordpos; |
580 | 580 | } |
581 | 581 | } |
@@ -585,10 +585,10 @@ discard block |
||
585 | 585 | |
586 | 586 | foreach ($this->words as $word) { |
587 | 587 | if (ctype_digit($word)) $word = '(?:'.$word.'|'.number_format($word).')'; |
588 | - if (preg_match('/([^'.$this->wordchars.']' . $word . '[^'.$this->wordchars. '])/', $lcbody, $matches)) { |
|
589 | - $wordpos = strpos( $lcbody, $matches[0] ); |
|
588 | + if (preg_match('/([^'.$this->wordchars.']'.$word.'[^'.$this->wordchars.'])/', $lcbody, $matches)) { |
|
589 | + $wordpos = strpos($lcbody, $matches[0]); |
|
590 | 590 | if ($wordpos) { |
591 | - if ( ($wordpos < $pos) || ($pos==-1) ) { |
|
591 | + if (($wordpos < $pos) || ($pos == -1)) { |
|
592 | 592 | $pos = $wordpos; |
593 | 593 | } |
594 | 594 | } |
@@ -599,10 +599,10 @@ discard block |
||
599 | 599 | |
600 | 600 | foreach ($this->words as $word) { |
601 | 601 | if (ctype_digit($word)) $word = '(?:'.$word.'|'.number_format($word).')'; |
602 | - if (preg_match('/(' . $word . ')/', $lcbody, $matches)) { |
|
603 | - $wordpos = strpos( $lcbody, $matches[0] ); |
|
602 | + if (preg_match('/('.$word.')/', $lcbody, $matches)) { |
|
603 | + $wordpos = strpos($lcbody, $matches[0]); |
|
604 | 604 | if ($wordpos) { |
605 | - if ( ($wordpos < $pos) || ($pos==-1) ) { |
|
605 | + if (($wordpos < $pos) || ($pos == -1)) { |
|
606 | 606 | $pos = $wordpos; |
607 | 607 | } |
608 | 608 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | */ |
27 | 27 | |
28 | -if (defined('XAPIANDB') AND XAPIANDB != '') { |
|
28 | +if (defined('XAPIANDB') and XAPIANDB != '') { |
|
29 | 29 | if (file_exists('/usr/share/php/xapian.php')) { |
30 | 30 | include_once '/usr/share/php/xapian.php'; |
31 | 31 | } else { |
@@ -263,15 +263,15 @@ discard block |
||
263 | 263 | for ($n=0; $n<$merged->rows(); $n++) { |
264 | 264 | $from_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_from')); |
265 | 265 | $to_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_to')); |
266 | - $qd = str_replace("(S$from_id OR S$to_id)", "S$to_id", $qd); |
|
267 | - $qd = str_replace("S$from_id OR S$to_id", "S$to_id", $qd); |
|
266 | + $qd = str_replace("(S$from_id OR S$to_id)", "s$to_id", $qd); |
|
267 | + $qd = str_replace("s$from_id OR S$to_id", "s$to_id", $qd); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | preg_match_all('#S(\d+)#', $qd, $m); |
271 | 271 | foreach ($m[1] as $mm) { |
272 | 272 | $member = new MEMBER(array('person_id' => $mm)); |
273 | 273 | $name = $member->full_name(); |
274 | - $qd = str_replace("S$mm", "speaker:$name", $qd); |
|
274 | + $qd = str_replace("s$mm", "speaker:$name", $qd); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | # Simplify display of excluded words |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * Test that the Royal edge-case house is correctly defined. |
11 | 11 | */ |
12 | - public function testRoyalHouseDefined() |
|
12 | + public function testRoyalHouseDefined() |
|
13 | 13 | { |
14 | 14 | $this->assertEquals(0, HOUSE_TYPE_ROYAL); |
15 | 15 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Test that the House of Commons is correctly defined. |
19 | 19 | */ |
20 | - public function testCommonsHouseDefined() |
|
20 | + public function testCommonsHouseDefined() |
|
21 | 21 | { |
22 | 22 | $this->assertEquals(1, HOUSE_TYPE_COMMONS); |
23 | 23 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * Test that the House of Lords is correctly defined. |
27 | 27 | */ |
28 | - public function testLordsHouseDefined() |
|
28 | + public function testLordsHouseDefined() |
|
29 | 29 | { |
30 | 30 | $this->assertEquals(2, HOUSE_TYPE_LORDS); |
31 | 31 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * Test that the Northern Ireland Assembly is correctly defined. |
35 | 35 | */ |
36 | - public function testNIHouseDefined() |
|
36 | + public function testNIHouseDefined() |
|
37 | 37 | { |
38 | 38 | $this->assertEquals(3, HOUSE_TYPE_NI); |
39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * Test that the Scottish Parliament is correctly defined. |
43 | 43 | */ |
44 | - public function testScotlandHouseDefined() |
|
44 | + public function testScotlandHouseDefined() |
|
45 | 45 | { |
46 | 46 | $this->assertEquals(4, HOUSE_TYPE_SCOTLAND); |
47 | 47 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Test that the Assembly for Wales is correctly defined. |
51 | 51 | */ |
52 | - public function testWalesHouseDefined() |
|
52 | + public function testWalesHouseDefined() |
|
53 | 53 | { |
54 | 54 | $this->assertEquals(5, HOUSE_TYPE_WALES); |
55 | 55 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | public function escape_comments($data) { |
156 | 156 | |
157 | 157 | $data = preg_replace_callback("/<!--(.*?)-->/s", function($matches) { |
158 | - return '<!--' . HtmlSpecialChars($this->StripSingle($matches[1])) . '-->'; |
|
158 | + return '<!--'.HtmlSpecialChars($this->StripSingle($matches[1])).'-->'; |
|
159 | 159 | }, $data); |
160 | 160 | |
161 | 161 | return $data; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | }, $data); |
210 | 210 | |
211 | 211 | foreach (array_keys($this->tag_counts) as $tag) { |
212 | - for ($i=0; $i<$this->tag_counts[$tag]; $i++) { |
|
212 | + for ($i = 0; $i < $this->tag_counts[$tag]; $i++) { |
|
213 | 213 | $data .= "</$tag>"; |
214 | 214 | } |
215 | 215 | } |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | $ending = $matches[3]; |
245 | 245 | if (in_array($name, array_keys($this->allowed))) { |
246 | 246 | $params = ""; |
247 | - preg_match_all("/([a-z0-9]+)=([\"'])(.*?)\\2/si", $body, $matches_2, PREG_SET_ORDER); # <foo a="b" /> |
|
248 | - preg_match_all("/([a-z0-9]+)(=)([^\"\s']+)/si", $body, $matches_1, PREG_SET_ORDER); # <foo a=b /> |
|
249 | - preg_match_all("/([a-z0-9]+)=([\"'])([^\"']*?)\s*$/si", $body, $matches_3, PREG_SET_ORDER); # <foo a="b /> |
|
247 | + preg_match_all("/([a-z0-9]+)=([\"'])(.*?)\\2/si", $body, $matches_2, PREG_SET_ORDER); # <foo a="b" /> |
|
248 | + preg_match_all("/([a-z0-9]+)(=)([^\"\s']+)/si", $body, $matches_1, PREG_SET_ORDER); # <foo a=b /> |
|
249 | + preg_match_all("/([a-z0-9]+)=([\"'])([^\"']*?)\s*$/si", $body, $matches_3, PREG_SET_ORDER); # <foo a="b /> |
|
250 | 250 | $matches = array_merge($matches_1, $matches_2, $matches_3); |
251 | 251 | |
252 | 252 | foreach ($matches as $match) { |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | if (preg_match("/^([^:]+)\:/si", $data, $matches)) { |
304 | 304 | if (!in_array($matches[1], $this->allowed_protocols)) { |
305 | - $data = '#'.substr($data, strlen($matches[1])+1); |
|
305 | + $data = '#'.substr($data, strlen($matches[1]) + 1); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | # if there are less than 5, just allow it as-is |
353 | 353 | # |
354 | 354 | |
355 | - if (strlen($data_notags)<5) { |
|
355 | + if (strlen($data_notags) < 5) { |
|
356 | 356 | return $data; |
357 | 357 | } |
358 | 358 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | # inside strings. within general text, we decode hex/dec entities. |
563 | 563 | # |
564 | 564 | |
565 | - public function decode_entities($data, $in_attribute=1) { |
|
565 | + public function decode_entities($data, $in_attribute = 1) { |
|
566 | 566 | |
567 | 567 | $data = preg_replace_callback('!(&)#(\d+);?!', array($this, 'decode_dec_entity'), $data); |
568 | 568 | $data = preg_replace_callback('!(&)#x([0-9a-f]+);?!i', array($this, 'decode_hex_entity'), $data); |
@@ -324,7 +324,9 @@ |
||
324 | 324 | while (1) { |
325 | 325 | $len = strlen($data); |
326 | 326 | $data = preg_replace("/<({$tags})(\s[^>]*)?(><\\/\\1>|\\/>)/", '', $data); |
327 | - if ($len == strlen($data)) break; |
|
327 | + if ($len == strlen($data)) { |
|
328 | + break; |
|
329 | + } |
|
328 | 330 | } |
329 | 331 | } |
330 | 332 |
@@ -159,6 +159,9 @@ |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | + /** |
|
163 | + * @param string $type |
|
164 | + */ |
|
162 | 165 | private function getMetadata($args="", $type) { |
163 | 166 | // $type is either 'page' or 'section' |
164 | 167 | global $this_page, $this_section; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function __construct() { |
56 | 56 | |
57 | - include_once METADATAPATH; // defined in config.php |
|
57 | + include_once METADATAPATH; // defined in config.php |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | |
116 | 116 | public function set_page_metadata($page, $key, $value) { |
117 | - $this->setMetadata(array("page"=>$page,"key"=>$key,"value"=>$value)); |
|
117 | + $this->setMetadata(array("page"=>$page, "key"=>$key, "value"=>$value)); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | |
128 | 128 | public function set_section_metadata($section, $key, $value) { |
129 | - $this->setMetadata(array("section"=>$section,"key"=>$key,"value"=>$value)); |
|
129 | + $this->setMetadata(array("section"=>$section, "key"=>$key, "value"=>$value)); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | |
152 | 152 | public function test_for_metadata($type, $item, $key) { |
153 | - $dataarray =& $this->$type; |
|
153 | + $dataarray = & $this->$type; |
|
154 | 154 | |
155 | 155 | if (isset($dataarray[$item][$key])) { |
156 | 156 | return true; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - private function getMetadata($args="", $type) { |
|
162 | + private function getMetadata($args = "", $type) { |
|
163 | 163 | // $type is either 'page' or 'section' |
164 | 164 | global $this_page, $this_section; |
165 | 165 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | twfy_debug("DATA", "$type: $item, $key"); |
176 | - $dataarray =& $this->$type; |
|
176 | + $dataarray = & $this->$type; |
|
177 | 177 | |
178 | 178 | if ($this->test_for_metadata($type, $item, $key)) { |
179 | 179 | $return = $dataarray[$item][$key]; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $debugtext = "No metadata found for key '$key'"; |
189 | 189 | } |
190 | 190 | |
191 | - twfy_debug("DATA", "$debugtext, returning '" . (is_scalar($return) ? $return : gettype($return)) . "'."); |
|
191 | + twfy_debug("DATA", "$debugtext, returning '".(is_scalar($return) ? $return : gettype($return))."'."); |
|
192 | 192 | |
193 | 193 | return $return; |
194 | 194 | } |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | $key = $args["key"]; |
207 | 207 | $value = $args["value"]; |
208 | 208 | |
209 | - twfy_debug("DATA", "Setting: ".$type."[".$item."][".$key."] = '" . print_r($value, 1) . "'"); |
|
209 | + twfy_debug("DATA", "Setting: ".$type."[".$item."][".$key."] = '".print_r($value, 1)."'"); |
|
210 | 210 | |
211 | - $dataarray =& $this->$type; |
|
211 | + $dataarray = & $this->$type; |
|
212 | 212 | $dataarray[$item][$key] = $value; |
213 | 213 | } |
214 | 214 |
@@ -175,6 +175,11 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | // After SELECT. |
178 | + |
|
179 | + /** |
|
180 | + * @param integer $row_index |
|
181 | + * @param string $column_name |
|
182 | + */ |
|
178 | 183 | public function field($row_index, $column_name) { |
179 | 184 | if ($this->rows > 0) |
180 | 185 | return $this->data[$row_index][$column_name]; |
@@ -187,6 +192,10 @@ discard block |
||
187 | 192 | } |
188 | 193 | |
189 | 194 | // After SELECT. |
195 | + |
|
196 | + /** |
|
197 | + * @param integer $row_index |
|
198 | + */ |
|
190 | 199 | public function row($row_index) { |
191 | 200 | if ($this->success && $this->rows > 0) |
192 | 201 | return $this->data[$row_index]; |
@@ -224,6 +233,9 @@ discard block |
||
224 | 233 | return $html; |
225 | 234 | } |
226 | 235 | |
236 | + /** |
|
237 | + * @param string $errormsg |
|
238 | + */ |
|
227 | 239 | public function error($errormsg) { |
228 | 240 | // When a query goes wrong... |
229 | 241 | $this->success = false; |
@@ -72,7 +72,6 @@ |
||
72 | 72 | * - `$this->field(n,col)` returns an empty string. |
73 | 73 | * - `$this->insert_id()` returns `null`. |
74 | 74 | * - `$this->affected_rows()` returns `null`. |
75 | - |
|
76 | 75 | */ |
77 | 76 | |
78 | 77 | class Query { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $this->conn = $conn; |
88 | 88 | } |
89 | 89 | |
90 | - public function query($sql="", $params = NULL) { |
|
90 | + public function query($sql = "", $params = NULL) { |
|
91 | 91 | |
92 | 92 | if (empty($sql)) { |
93 | 93 | $this->success = false; |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
104 | - twfy_debug ("SQL", $sql); |
|
105 | - twfy_debug ("SQL", print_r($params, 1)); |
|
104 | + twfy_debug("SQL", $sql); |
|
105 | + twfy_debug("SQL", print_r($params, 1)); |
|
106 | 106 | |
107 | 107 | if ($params !== NULL) { |
108 | 108 | // Prepare and execute a statement |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | |
129 | 129 | // Test the query actually worked |
130 | 130 | if (!$pdoStatement) { |
131 | - $this->error($this->conn->errorCode() . ': ' . $this->conn->errorInfo()[2]); |
|
131 | + $this->error($this->conn->errorCode().': '.$this->conn->errorInfo()[2]); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | if (!$this->success) return; |
135 | 135 | |
136 | - if ( (!$pdoStatement) or (empty($pdoStatement)) ) { |
|
136 | + if ((!$pdoStatement) or (empty($pdoStatement))) { |
|
137 | 137 | // A failed query. |
138 | 138 | $this->success = false; |
139 | 139 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | $this->affected_rows = $pdoStatement->rowCount(); |
157 | 157 | |
158 | - twfy_debug ("SQLRESULT", array($this, 'displayResult')); |
|
158 | + twfy_debug("SQLRESULT", array($this, 'displayResult')); |
|
159 | 159 | // mysql_free_result($q); |
160 | 160 | } |
161 | 161 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $html .= "<table border=\"1\">\n<tr>\n"; |
203 | 203 | |
204 | 204 | foreach (array_keys($this->data[0]) as $fieldname) { |
205 | - $html .= "<th>" . _htmlentities($fieldname) . "</th>"; |
|
205 | + $html .= "<th>"._htmlentities($fieldname)."</th>"; |
|
206 | 206 | } |
207 | 207 | $html .= "</tr>\n"; |
208 | 208 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | // Don't want to risk this data being displayed on any page. |
214 | 214 | $html .= "<td>**MASKED**</td>"; |
215 | 215 | } else { |
216 | - $html .= "<td>" . _htmlentities($field) . "</td>"; |
|
216 | + $html .= "<td>"._htmlentities($field)."</td>"; |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | $html .= "</tr>\n"; |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | class Query { |
79 | 79 | |
80 | 80 | public $success = true; |
81 | - public $rows = NULL; |
|
81 | + public $rows = null; |
|
82 | 82 | public $data = array(); |
83 | - public $insert_id = NULL; |
|
84 | - public $affected_rows = NULL; |
|
83 | + public $insert_id = null; |
|
84 | + public $affected_rows = null; |
|
85 | 85 | |
86 | 86 | public function __construct($conn) { |
87 | 87 | $this->conn = $conn; |
88 | 88 | } |
89 | 89 | |
90 | - public function query($sql="", $params = NULL) { |
|
90 | + public function query($sql="", $params = null) { |
|
91 | 91 | |
92 | 92 | if (empty($sql)) { |
93 | 93 | $this->success = false; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | twfy_debug ("SQL", $sql); |
105 | 105 | twfy_debug ("SQL", print_r($params, 1)); |
106 | 106 | |
107 | - if ($params !== NULL) { |
|
107 | + if ($params !== null) { |
|
108 | 108 | // Prepare and execute a statement |
109 | 109 | $pdoStatement = $this->conn->prepare($sql); |
110 | 110 |
@@ -77,6 +77,9 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | +/** |
|
81 | + * @param MySociety\TheyWorkForYou\Db\Query $q |
|
82 | + */ |
|
80 | 83 | function _api_getPerson_output($q, $flatten=false) { |
81 | 84 | $output = array(); |
82 | 85 | $last_mod = 0; |
@@ -95,10 +98,16 @@ discard block |
||
95 | 98 | api_output($output, $last_mod); |
96 | 99 | } |
97 | 100 | |
101 | +/** |
|
102 | + * @param integer $house |
|
103 | + */ |
|
98 | 104 | function api_getPerson_constituency($constituency, $house) { |
99 | 105 | _api_getPerson_constituency(array($constituency), $house); |
100 | 106 | } |
101 | 107 | |
108 | +/** |
|
109 | + * @param integer $house |
|
110 | + */ |
|
102 | 111 | function api_getPerson_postcode($pc, $house) { |
103 | 112 | $pc = preg_replace('#[^a-z0-9 ]#i', '', $pc); |
104 | 113 | $types = array(); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include_once INCLUDESPATH . 'easyparliament/member.php'; |
|
3 | +include_once INCLUDESPATH.'easyparliament/member.php'; |
|
4 | 4 | |
5 | 5 | function api_getPerson_front() { |
6 | 6 | ?> |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <?php |
18 | 18 | } |
19 | 19 | |
20 | -function _api_getPerson_row($row, $has_party=FALSE) { |
|
20 | +function _api_getPerson_row($row, $has_party = FALSE) { |
|
21 | 21 | global $parties; |
22 | 22 | $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'], |
23 | 23 | $row['family_name'], $row['lordofname']); |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | } |
27 | 27 | if ($row['house'] == 1) { |
28 | 28 | $URL = new \MySociety\TheyWorkForYou\Url('mp'); |
29 | - $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']); |
|
29 | + $row['url'] = $URL->generate('none').make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']); |
|
30 | 30 | } |
31 | 31 | if ($has_party && isset($parties[$row['party']])) |
32 | 32 | $row['party'] = $parties[$row['party']]; |
33 | - list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']); |
|
33 | + list($image, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']); |
|
34 | 34 | if ($image) { |
35 | - list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image)); |
|
35 | + list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR.'/images/', $image)); |
|
36 | 36 | $row['image'] = $image; |
37 | 37 | $row['image_height'] = $height; |
38 | 38 | $row['image_width'] = $width; |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | if ($row['house'] == 1 && ($row['left_house'] == '9999-12-31' || (isset($dissolution[1]) && $row['left_house'] == $dissolution[1]))) { |
43 | 43 | # Ministerialships and Select Committees |
44 | 44 | $db = new ParlDB; |
45 | - $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC'); |
|
46 | - for ($i=0; $i<$q->rows(); $i++) { |
|
45 | + $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person='.$row['person_id'].' ORDER BY from_date DESC'); |
|
46 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
47 | 47 | $row['office'][] = $q->row($i); |
48 | 48 | } |
49 | 49 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | return $row; |
56 | 56 | } |
57 | 57 | |
58 | -function api_getPerson_id($id, $house='') { |
|
58 | +function api_getPerson_id($id, $house = '') { |
|
59 | 59 | $db = new ParlDB; |
60 | 60 | $params = array( |
61 | 61 | ':person_id' => $id |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | -function _api_getPerson_output($q, $flatten=false) { |
|
80 | +function _api_getPerson_output($q, $flatten = false) { |
|
81 | 81 | $output = array(); |
82 | 82 | $last_mod = 0; |
83 | - for ($i=0; $i<$q->rows(); $i++) { |
|
83 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
84 | 84 | $house = $q->field($i, 'house'); |
85 | 85 | $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true); |
86 | 86 | $output[] = $out; |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | $cons_params = array(); |
150 | 150 | $params = array(':house' => $house); |
151 | 151 | foreach ($cons as $key => $constituency) { |
152 | - $cons_params[] = ':constituency' . $key; |
|
153 | - $params[':constituency' . $key] = $constituency; |
|
152 | + $cons_params[] = ':constituency'.$key; |
|
153 | + $params[':constituency'.$key] = $constituency; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | $query_base = "SELECT member.*, p.title, p.given_name, p.family_name, p.lordofname |
157 | 157 | FROM member, person_names p |
158 | - WHERE constituency in (" . join(",", $cons_params) . ") |
|
158 | + WHERE constituency in (" . join(",", $cons_params).") |
|
159 | 159 | AND member.person_id = p.person_id AND p.type = 'name' |
160 | 160 | AND p.start_date <= left_house AND left_house <= p.end_date |
161 | 161 | AND house = :house"; |
@@ -28,8 +28,9 @@ discard block |
||
28 | 28 | $URL = new \MySociety\TheyWorkForYou\Url('mp'); |
29 | 29 | $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']); |
30 | 30 | } |
31 | - if ($has_party && isset($parties[$row['party']])) |
|
32 | - $row['party'] = $parties[$row['party']]; |
|
31 | + if ($has_party && isset($parties[$row['party']])) { |
|
32 | + $row['party'] = $parties[$row['party']]; |
|
33 | + } |
|
33 | 34 | list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']); |
34 | 35 | if ($image) { |
35 | 36 | list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image)); |
@@ -49,7 +50,9 @@ discard block |
||
49 | 50 | } |
50 | 51 | |
51 | 52 | foreach ($row as $k => $r) { |
52 | - if (is_string($r)) $row[$k] = html_entity_decode($r); |
|
53 | + if (is_string($r)) { |
|
54 | + $row[$k] = html_entity_decode($r); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | |
55 | 58 | return $row; |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true); |
86 | 89 | $output[] = $out; |
87 | 90 | $time = strtotime($q->field($i, 'lastupdate')); |
88 | - if ($time > $last_mod) |
|
89 | - $last_mod = $time; |
|
91 | + if ($time > $last_mod) { |
|
92 | + $last_mod = $time; |
|
93 | + } |
|
90 | 94 | } |
91 | 95 | # Only one MP, not an array |
92 | 96 | if ($flatten && count($output) == 1 && $house == HOUSE_TYPE_COMMONS) { |
@@ -134,13 +138,18 @@ discard block |
||
134 | 138 | |
135 | 139 | $cons = array(); |
136 | 140 | foreach ($constituencies as $constituency) { |
137 | - if ($constituency == '') continue; |
|
138 | - if ($constituency == 'Orkney ') |
|
139 | - $constituency = 'Orkney & Shetland'; |
|
141 | + if ($constituency == '') { |
|
142 | + continue; |
|
143 | + } |
|
144 | + if ($constituency == 'Orkney ') { |
|
145 | + $constituency = 'Orkney & Shetland'; |
|
146 | + } |
|
140 | 147 | |
141 | 148 | if ($house == HOUSE_TYPE_COMMONS) { |
142 | 149 | $normalised = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency); |
143 | - if ($normalised) $constituency = $normalised; |
|
150 | + if ($normalised) { |
|
151 | + $constituency = $normalised; |
|
152 | + } |
|
144 | 153 | } |
145 | 154 | |
146 | 155 | $cons[] = $constituency; |
@@ -55,7 +55,7 @@ |
||
55 | 55 | * @param string $db_pass The password for the database user |
56 | 56 | * @param string $db_name The name of the database |
57 | 57 | * |
58 | - * @return true If the connection has been created successfully. |
|
58 | + * @return boolean If the connection has been created successfully. |
|
59 | 59 | */ |
60 | 60 | |
61 | 61 | public function init($db_host, $db_user, $db_pass, $db_name) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | // These vars come from config.php. |
64 | 64 | |
65 | 65 | if (!$global_connection) { |
66 | - $dsn = 'mysql:charset=utf8;dbname=' . $db_name . ';host=' . $db_host; |
|
66 | + $dsn = 'mysql:charset=utf8;dbname='.$db_name.';host='.$db_host; |
|
67 | 67 | |
68 | 68 | try { |
69 | 69 | $conn = new \PDO($dsn, $db_user, $db_pass); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $duration = getmicrotime() - $start; |
112 | 112 | global $mysqltotalduration; |
113 | 113 | $mysqltotalduration += $duration; |
114 | - twfy_debug ("SQL", "Complete after $duration seconds."); |
|
114 | + twfy_debug("SQL", "Complete after $duration seconds."); |
|
115 | 115 | // We could also output $q->mysql_info() here, but that's for |
116 | 116 | // PHP >= 4.3.0. |
117 | 117 | return $q; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | public function display_total_duration() { |
128 | 128 | global $mysqltotalduration; |
129 | - twfy_debug ("TIME", "Total time for MySQL queries on this page: " . $mysqltotalduration . " seconds."); |
|
129 | + twfy_debug("TIME", "Total time for MySQL queries on this page: ".$mysqltotalduration." seconds."); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -102,7 +102,7 @@ |
||
102 | 102 | * @return Query An object containing the results of the query. |
103 | 103 | */ |
104 | 104 | |
105 | - public function query($sql, $params = NULL) { |
|
105 | + public function query($sql, $params = null) { |
|
106 | 106 | |
107 | 107 | $start = getmicrotime(); |
108 | 108 | $q = new \MySociety\TheyWorkForYou\Db\Query($this->conn); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | First some things to help make our PHP nicer and betterer |
5 | 5 | ********************************************************************************/ |
6 | 6 | |
7 | -error_reporting (E_ALL); |
|
7 | +error_reporting(E_ALL); |
|
8 | 8 | |
9 | 9 | /******************************************************************************** |
10 | 10 | Now some constants that are the same for live and dev versions |
@@ -12,36 +12,36 @@ discard block |
||
12 | 12 | ********************************************************************************/ |
13 | 13 | |
14 | 14 | // In case we need to switch these off globally at some point... |
15 | -define ("ALLOWCOMMENTS", true); |
|
16 | -define ("ALLOWTRACKBACKS", true); |
|
15 | +define("ALLOWCOMMENTS", true); |
|
16 | +define("ALLOWTRACKBACKS", true); |
|
17 | 17 | |
18 | 18 | // These variables are so we can keep date/time formats consistent across the site |
19 | 19 | // and change them easily. |
20 | 20 | // Formats here: http://www.php.net/manual/en/function.date.php |
21 | -define ("LONGERDATEFORMAT", "l, j F Y");// Monday, 31 December 2003 |
|
22 | -define ("LONGDATEFORMAT", "j F Y"); // 31 December 2003 |
|
23 | -define ("SHORTDATEFORMAT", "j M Y"); // 31 Dec 2003 |
|
24 | -define ("TIMEFORMAT", "g:i a"); // 11:59 pm |
|
21 | +define("LONGERDATEFORMAT", "l, j F Y"); // Monday, 31 December 2003 |
|
22 | +define("LONGDATEFORMAT", "j F Y"); // 31 December 2003 |
|
23 | +define("SHORTDATEFORMAT", "j M Y"); // 31 Dec 2003 |
|
24 | +define("TIMEFORMAT", "g:i a"); // 11:59 pm |
|
25 | 25 | |
26 | -define ("SHORTDATEFORMAT_SQL", "%e %b %Y"); // 31 Dec 2003 |
|
27 | -define ("TIMEFORMAT_SQL", "%l:%i %p"); // 11:59 PM |
|
26 | +define("SHORTDATEFORMAT_SQL", "%e %b %Y"); // 31 Dec 2003 |
|
27 | +define("TIMEFORMAT_SQL", "%l:%i %p"); // 11:59 PM |
|
28 | 28 | |
29 | 29 | // Where we store the postcode of users if they search for an MP by postcode. |
30 | -define ('POSTCODE_COOKIE', 'eppc'); |
|
30 | +define('POSTCODE_COOKIE', 'eppc'); |
|
31 | 31 | |
32 | 32 | /******************************************************************************** |
33 | 33 | And now all the files we'll include on every page. |
34 | 34 | ********************************************************************************/ |
35 | 35 | |
36 | 36 | // The Composer autoloader, which also handles our internal autoloading magic. |
37 | -require_once dirname(__FILE__) . '/../../../vendor/autoload.php'; |
|
37 | +require_once dirname(__FILE__).'/../../../vendor/autoload.php'; |
|
38 | 38 | |
39 | -include_once dirname(__FILE__) . '/../../../conf/general'; |
|
40 | -include_once INCLUDESPATH . 'utility.php'; |
|
39 | +include_once dirname(__FILE__).'/../../../conf/general'; |
|
40 | +include_once INCLUDESPATH.'utility.php'; |
|
41 | 41 | twfy_debug_timestamp("after including utility.php"); |
42 | 42 | |
43 | 43 | // Set the default timezone |
44 | -if(function_exists('date_default_timezone_set')) date_default_timezone_set(TIMEZONE); |
|
44 | +if (function_exists('date_default_timezone_set')) date_default_timezone_set(TIMEZONE); |
|
45 | 45 | |
46 | 46 | // Only do clever things with errors if we're not testing, otherwise show as default |
47 | 47 | |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | |
71 | 71 | // The time the page starts, so we can display the total at the end. |
72 | 72 | // getmicrotime() is in utiltity.php. |
73 | -define ("STARTTIME", getmicrotime()); |
|
73 | +define("STARTTIME", getmicrotime()); |
|
74 | 74 | if (!isset($_SERVER['WINDIR'])) { |
75 | 75 | $rusage = getrusage(); |
76 | - define ('STARTTIMES', $rusage['ru_stime.tv_sec']*1000000 + $rusage['ru_stime.tv_usec']); |
|
77 | - define ('STARTTIMEU', $rusage['ru_utime.tv_sec']*1000000 + $rusage['ru_utime.tv_usec']); |
|
76 | + define('STARTTIMES', $rusage['ru_stime.tv_sec'] * 1000000 + $rusage['ru_stime.tv_usec']); |
|
77 | + define('STARTTIMEU', $rusage['ru_utime.tv_sec'] * 1000000 + $rusage['ru_utime.tv_usec']); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $DATA = new \MySociety\TheyWorkForYou\Data; |
81 | 81 | |
82 | 82 | class ParlDB extends \MySociety\TheyWorkForYou\Db\Connection { |
83 | 83 | public function __construct() { |
84 | - $this->init (OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME); |
|
84 | + $this->init(OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | include_once (INCLUDESPATH."easyparliament/user.php"); |
93 | 93 | |
94 | 94 | // Test to see if this is a new-style template using the renderer class. |
95 | -if (! isset($new_style_template) OR $new_style_template !== TRUE) { |
|
95 | +if (!isset($new_style_template) OR $new_style_template !== TRUE) { |
|
96 | 96 | |
97 | 97 | // This is an old-style page. Use the old page classes. |
98 | 98 | include_once (INCLUDESPATH."easyparliament/page.php"); |
@@ -92,7 +92,7 @@ |
||
92 | 92 | include_once (INCLUDESPATH."easyparliament/user.php"); |
93 | 93 | |
94 | 94 | // Test to see if this is a new-style template using the renderer class. |
95 | -if (! isset($new_style_template) OR $new_style_template !== TRUE) { |
|
95 | +if (! isset($new_style_template) or $new_style_template !== true) { |
|
96 | 96 | |
97 | 97 | // This is an old-style page. Use the old page classes. |
98 | 98 | include_once (INCLUDESPATH."easyparliament/page.php"); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include_once INCLUDESPATH . '../../commonlib/phplib/gaze.php'; |
|
4 | -include_once INCLUDESPATH . 'easyparliament/member.php'; |
|
3 | +include_once INCLUDESPATH.'../../commonlib/phplib/gaze.php'; |
|
4 | +include_once INCLUDESPATH.'easyparliament/member.php'; |
|
5 | 5 | |
6 | 6 | class PAGE { |
7 | 7 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public $within_stripe_sidebar = false; |
20 | 20 | |
21 | 21 | public function page_start() { |
22 | - if ( !$this->page_started() ) { |
|
22 | + if (!$this->page_started()) { |
|
23 | 23 | $this->checkForAdmin(); |
24 | 24 | $this->displayHeader(); |
25 | 25 | } |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | |
33 | 33 | $data = $h->data; |
34 | 34 | $data = array_merge($u->data, $data); |
35 | - if ( isset($page_errors) ) { |
|
35 | + if (isset($page_errors)) { |
|
36 | 36 | $data['page_errors'] = $page_errors; |
37 | 37 | } |
38 | 38 | $data['banner_text'] = ''; |
39 | 39 | extract($data); |
40 | - require_once INCLUDESPATH . 'easyparliament/templates/html/header.php'; |
|
40 | + require_once INCLUDESPATH.'easyparliament/templates/html/header.php'; |
|
41 | 41 | |
42 | 42 | echo '<div class="full-page legacy-page static-page"> <div class="full-page__row"> <div class="panel">'; |
43 | 43 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | $THISPAGE = new \MySociety\TheyWorkForYou\Url($this_page); |
53 | 53 | |
54 | 54 | $LOGINURL = new \MySociety\TheyWorkForYou\Url('userlogin'); |
55 | - $LOGINURL->insert(array('ret' => $THISPAGE->generate('none') )); |
|
55 | + $LOGINURL->insert(array('ret' => $THISPAGE->generate('none'))); |
|
56 | 56 | |
57 | - $text = "<a href=\"" . $LOGINURL->generate() . "\">You'd better sign in!</a>"; |
|
57 | + $text = "<a href=\"".$LOGINURL->generate()."\">You'd better sign in!</a>"; |
|
58 | 58 | } else { |
59 | 59 | $text = "That's all folks!"; |
60 | 60 | } |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | public function page_end() { |
70 | - if ( !$this->page_started() ) { |
|
70 | + if (!$this->page_started()) { |
|
71 | 71 | $this->page_start(); |
72 | 72 | } |
73 | 73 | |
74 | 74 | echo '</div></div></div>'; |
75 | 75 | $footer = new MySociety\TheyWorkForYou\Renderer\Footer(); |
76 | 76 | $footer_links = $footer->data; |
77 | - require_once INCLUDESPATH . 'easyparliament/templates/html/footer.php'; |
|
77 | + require_once INCLUDESPATH.'easyparliament/templates/html/footer.php'; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public function page_started() { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - public function stripe_start($type='side', $id='', $extra_class = '') { |
|
104 | + public function stripe_start($type = 'side', $id = '', $extra_class = '') { |
|
105 | 105 | // $type is one of: |
106 | 106 | // 'full' - a full width div |
107 | 107 | // 'side' - a white stripe with a coloured sidebar. |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | // 'foot' - For the bottom stripe on hansard debates/wrans listings. |
115 | 115 | // $id is the value of an id for this div (if blank, not used). |
116 | 116 | ?> |
117 | - <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') echo ' ' . $extra_class; ?>"<?php |
|
117 | + <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') echo ' '.$extra_class; ?>"<?php |
|
118 | 118 | if ($id != '') { |
119 | - print ' id="' . $id . '"'; |
|
119 | + print ' id="'.$id.'"'; |
|
120 | 120 | } |
121 | 121 | ?>> |
122 | 122 | <div class="main"> |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | - public function stripe_end ($contents = array(), $extra = '') { |
|
134 | + public function stripe_end($contents = array(), $extra = '') { |
|
135 | 135 | // $contents is an array containing 0 or more hashes. |
136 | 136 | // Each hash has two values, 'type' and 'content'. |
137 | 137 | // 'Type' could be one of these: |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | |
244 | 244 | |
245 | - public function block_start($data=array()) { |
|
245 | + public function block_start($data = array()) { |
|
246 | 246 | // Starts a 'block' div, used mostly on the home page, |
247 | 247 | // on the MP page, and in the sidebars. |
248 | 248 | // $data is a hash like this: |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $this->blockbody_open = false; |
256 | 256 | |
257 | 257 | if (isset($data['id']) && $data['id'] != '') { |
258 | - $id = ' id="' . $data['id'] . '"'; |
|
258 | + $id = ' id="'.$data['id'].'"'; |
|
259 | 259 | } else { |
260 | 260 | $id = ''; |
261 | 261 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $title = isset($data['title']) ? $data['title'] : ''; |
264 | 264 | |
265 | 265 | if (isset($data['url'])) { |
266 | - $title = '<a href="' . $data['url'] . '">' . $title . '</a>'; |
|
266 | + $title = '<a href="'.$data['url'].'">'.$title.'</a>'; |
|
267 | 267 | } |
268 | 268 | ?> |
269 | 269 | <div class="block"<?php echo $id; ?>> |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | if (is_string($message)) { |
390 | 390 | // Sometimes we're just sending a single line to this function |
391 | 391 | // rather like the bigger array... |
392 | - $message = array ( |
|
392 | + $message = array( |
|
393 | 393 | 'text' => $message |
394 | 394 | ); |
395 | 395 | } |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | // if the page has started then we're most likely in an old school page |
398 | 398 | // so we should just print out the error, otherwise stick it in the error |
399 | 399 | // global which will then be displayed by the header template |
400 | - if ( $this->page_started() ) { |
|
400 | + if ($this->page_started()) { |
|
401 | 401 | $this->message($message, 'error'); |
402 | 402 | } else { |
403 | - if ( !isset($page_errors) ) { |
|
403 | + if (!isset($page_errors)) { |
|
404 | 404 | $page_errors = array(); |
405 | 405 | } |
406 | - $page_errors[] = $message; |
|
406 | + $page_errors[] = $message; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if ($fatal) { |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | |
423 | - public function message($message, $class='') { |
|
423 | + public function message($message, $class = '') { |
|
424 | 424 | // Generates a very simple but common page content. |
425 | 425 | // Used for when a user logs out, or votes, or any simple thing |
426 | 426 | // where there's a little message and probably a link elsewhere. |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | // $class is a class name that will be applied to the message's HTML elements. |
435 | 435 | |
436 | 436 | if ($class != '') { |
437 | - $class = ' class="' . $class . '"'; |
|
437 | + $class = ' class="'.$class.'"'; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | $need_to_close_stripe = false; |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | public function informational($text) { |
471 | - print '<div class="informational left">' . $text . '</div>'; |
|
471 | + print '<div class="informational left">'.$text.'</div>'; |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | public function set_hansard_headings($info) { |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | if ($page_title != '') { |
499 | 499 | $page_title .= ': '; |
500 | 500 | } |
501 | - $page_title .= format_date ($info['date'], SHORTDATEFORMAT); |
|
501 | + $page_title .= format_date($info['date'], SHORTDATEFORMAT); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | if ($page_title != '') { |
@@ -537,15 +537,15 @@ discard block |
||
537 | 537 | $prev = $nextprev['prev']; |
538 | 538 | |
539 | 539 | if (isset($prev['url'])) { |
540 | - $prevlink = '<a href="' . $prev['url'] . '" title="' . $prev['title'] . '" class="linkbutton">« ' . $prev['body'] . '</a>'; |
|
540 | + $prevlink = '<a href="'.$prev['url'].'" title="'.$prev['title'].'" class="linkbutton">« '.$prev['body'].'</a>'; |
|
541 | 541 | |
542 | 542 | } else { |
543 | - $prevlink = '« ' . $prev['body']; |
|
543 | + $prevlink = '« '.$prev['body']; |
|
544 | 544 | } |
545 | 545 | } |
546 | 546 | |
547 | 547 | if ($prevlink != '') { |
548 | - $prevlink = '<span class="prev">' . $prevlink . '</span>'; |
|
548 | + $prevlink = '<span class="prev">'.$prevlink.'</span>'; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -553,10 +553,10 @@ discard block |
||
553 | 553 | |
554 | 554 | if (isset($nextprev['up'])) { |
555 | 555 | |
556 | - $uplink = '<span class="up"><a href="' . $nextprev['up']['url'] . '" title="' . $nextprev['up']['title'] . '">' . $nextprev['up']['body'] . '</a>'; |
|
556 | + $uplink = '<span class="up"><a href="'.$nextprev['up']['url'].'" title="'.$nextprev['up']['title'].'">'.$nextprev['up']['body'].'</a>'; |
|
557 | 557 | if (get_http_var('s')) { |
558 | 558 | $URL = new \MySociety\TheyWorkForYou\Url($this_page); |
559 | - $uplink .= '<br><a href="' . $URL->generate() . '">Remove highlighting</a>'; |
|
559 | + $uplink .= '<br><a href="'.$URL->generate().'">Remove highlighting</a>'; |
|
560 | 560 | } |
561 | 561 | $uplink .= '</span>'; |
562 | 562 | } |
@@ -568,14 +568,14 @@ discard block |
||
568 | 568 | $next = $nextprev['next']; |
569 | 569 | |
570 | 570 | if (isset($next['url'])) { |
571 | - $nextlink = '<a href="' . $next['url'] . '" title="' . $next['title'] . '" class="linkbutton">' . $next['body'] . ' »</a>'; |
|
571 | + $nextlink = '<a href="'.$next['url'].'" title="'.$next['title'].'" class="linkbutton">'.$next['body'].' »</a>'; |
|
572 | 572 | } else { |
573 | - $nextlink = $next['body'] . ' »'; |
|
573 | + $nextlink = $next['body'].' »'; |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | |
577 | 577 | if ($nextlink != '') { |
578 | - $nextlink = '<span class="next">' . $nextlink . '</span>'; |
|
578 | + $nextlink = '<span class="next">'.$nextlink.'</span>'; |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | } |
586 | 586 | |
587 | 587 | |
588 | - public function search_form($value='') { |
|
588 | + public function search_form($value = '') { |
|
589 | 589 | global $SEARCHENGINE; |
590 | 590 | // Search box on the search page. |
591 | 591 | // If $value is set then it will be displayed in the form. |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | } |
616 | 616 | |
617 | 617 | echo '<div class="mainsearchbox">'; |
618 | - if ($wtt<2) { |
|
618 | + if ($wtt < 2) { |
|
619 | 619 | echo '<form action="', $URL->generate(), '" method="get">'; |
620 | 620 | if (get_http_var('o')) { |
621 | 621 | echo '<input type="hidden" name="o" value="', _htmlentities(get_http_var('o')), '">'; |
@@ -624,10 +624,10 @@ discard block |
||
624 | 624 | echo '<input type="hidden" name="house" value="', _htmlentities(get_http_var('house')), '">'; |
625 | 625 | } |
626 | 626 | echo '<input type="text" name="q" value="', _htmlentities($value), '" size="50"> '; |
627 | - echo '<input type="submit" value=" ', ($wtt?'Modify search':'Search'), ' ">'; |
|
627 | + echo '<input type="submit" value=" ', ($wtt ? 'Modify search' : 'Search'), ' ">'; |
|
628 | 628 | $URL = new \MySociety\TheyWorkForYou\Url('search'); |
629 | 629 | $URL->insert(array('adv' => 1)); |
630 | - echo ' <a href="' . $URL->generate() . '">More options</a>'; |
|
630 | + echo ' <a href="'.$URL->generate().'">More options</a>'; |
|
631 | 631 | echo '<br>'; |
632 | 632 | if ($wtt) print '<input type="hidden" name="wtt" value="1">'; |
633 | 633 | } else { ?> |
@@ -646,24 +646,24 @@ discard block |
||
646 | 646 | $ordering = 'd'; |
647 | 647 | } |
648 | 648 | |
649 | - if ($ordering=='r') { |
|
649 | + if ($ordering == 'r') { |
|
650 | 650 | print '<strong>Sorted by relevance</strong>'; |
651 | 651 | } else { |
652 | 652 | printf("<a href='%s'>Sort by relevance</a>", $orderUrl->generate('html', array('o'=>'r'))); |
653 | 653 | } |
654 | 654 | |
655 | 655 | print " | "; |
656 | - if ($ordering=='d') { |
|
657 | - print '<strong>Sorted by date: newest</strong> / <a href="' . $orderUrl->generate('html', array('o'=>'o')) . '">oldest</a>'; |
|
658 | - } elseif ($ordering=='o') { |
|
659 | - print '<strong>Sorted by date:</strong> <a href="' . $orderUrl->generate('html', array('o'=>'d')) . '">newest</a> / <strong>oldest</strong>'; |
|
656 | + if ($ordering == 'd') { |
|
657 | + print '<strong>Sorted by date: newest</strong> / <a href="'.$orderUrl->generate('html', array('o'=>'o')).'">oldest</a>'; |
|
658 | + } elseif ($ordering == 'o') { |
|
659 | + print '<strong>Sorted by date:</strong> <a href="'.$orderUrl->generate('html', array('o'=>'d')).'">newest</a> / <strong>oldest</strong>'; |
|
660 | 660 | } else { |
661 | 661 | printf("Sort by date: <a href='%s'>newest</a> / <a href='%s'>oldest</a>", |
662 | 662 | $orderUrl->generate('html', array('o'=>'d')), $orderUrl->generate('html', array('o'=>'o'))); |
663 | 663 | } |
664 | 664 | |
665 | 665 | print " | "; |
666 | - if ($ordering=='p') { |
|
666 | + if ($ordering == 'p') { |
|
667 | 667 | print '<strong>Use by person</strong>'; |
668 | 668 | } else { |
669 | 669 | printf('<a href="%s">Show use by person</a>', $orderUrl->generate('html', array('o'=>'p'))); |
@@ -684,10 +684,10 @@ discard block |
||
684 | 684 | } |
685 | 685 | |
686 | 686 | public function advanced_search_form() { |
687 | - include_once INCLUDESPATH . 'easyparliament/templates/html/search_advanced.php'; |
|
687 | + include_once INCLUDESPATH.'easyparliament/templates/html/search_advanced.php'; |
|
688 | 688 | } |
689 | 689 | |
690 | - public function login_form ($errors = array()) { |
|
690 | + public function login_form($errors = array()) { |
|
691 | 691 | // Used for /user/login/ and /user/prompt/ |
692 | 692 | // $errors is a hash of potential errors from a previous log in attempt. |
693 | 693 | ?> |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | public function glossary_atoz(&$GLOSSARY) { |
792 | 792 | // Print out a nice list of lettered links to glossary pages |
793 | 793 | |
794 | - $letters = array (); |
|
794 | + $letters = array(); |
|
795 | 795 | |
796 | 796 | foreach ($GLOSSARY->alphabet as $letter => $eps) { |
797 | 797 | // if we're writing out the current letter (list or item) |
@@ -802,11 +802,11 @@ discard block |
||
802 | 802 | $URL->insert(array('az' => $letter)); |
803 | 803 | $letter_link = $URL->generate('url'); |
804 | 804 | |
805 | - $letters[] = "<li class=\"on\"><a href=\"" . $letter_link . "\">" . $letter . "</a></li>"; |
|
805 | + $letters[] = "<li class=\"on\"><a href=\"".$letter_link."\">".$letter."</a></li>"; |
|
806 | 806 | } |
807 | 807 | // otherwise in list view show no link |
808 | 808 | else { |
809 | - $letters[] = "<li class=\"on\">" . $letter . "</li>"; |
|
809 | + $letters[] = "<li class=\"on\">".$letter."</li>"; |
|
810 | 810 | } |
811 | 811 | } |
812 | 812 | elseif (!empty($GLOSSARY->alphabet[$letter])) { |
@@ -814,24 +814,24 @@ discard block |
||
814 | 814 | $URL->insert(array('az' => $letter)); |
815 | 815 | $letter_link = $URL->generate('url'); |
816 | 816 | |
817 | - $letters[] = "<li><a href=\"" . $letter_link . "\">" . $letter . "</a></li>"; |
|
817 | + $letters[] = "<li><a href=\"".$letter_link."\">".$letter."</a></li>"; |
|
818 | 818 | } |
819 | 819 | else { |
820 | - $letters[] = '<li>' . $letter . '</li>'; |
|
820 | + $letters[] = '<li>'.$letter.'</li>'; |
|
821 | 821 | } |
822 | 822 | } |
823 | 823 | ?> |
824 | 824 | <div class="letters"> |
825 | 825 | <ul> |
826 | 826 | <?php |
827 | - for ($n=0; $n<13; $n++) { |
|
827 | + for ($n = 0; $n < 13; $n++) { |
|
828 | 828 | print $letters[$n]; |
829 | 829 | } |
830 | 830 | ?> |
831 | 831 | </ul> |
832 | 832 | <ul> |
833 | 833 | <?php |
834 | - for ($n=13; $n<26; $n++) { |
|
834 | + for ($n = 13; $n < 26; $n++) { |
|
835 | 835 | print $letters[$n]; |
836 | 836 | } |
837 | 837 | ?> |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | // add some extra controls for the administrators |
852 | 852 | if ($this_page == "admin_glossary") { |
853 | 853 | print "<a id=\"gl".$term['glossary_id']."\"></a>"; |
854 | - print "<h3>" . $term['title'] . "</h3>"; |
|
854 | + print "<h3>".$term['title']."</h3>"; |
|
855 | 855 | $URL = new \MySociety\TheyWorkForYou\Url('admin_glossary'); |
856 | 856 | $URL->insert(array("delete_confirm" => $term['glossary_id'])); |
857 | 857 | $delete_url = $URL->generate(); |
@@ -866,13 +866,13 @@ discard block |
||
866 | 866 | $URL->insert(array('u' => $term['user_id'])); |
867 | 867 | $user_link = $URL->generate('url'); |
868 | 868 | |
869 | - $user_details = "\t\t\t\t<p><small>contributed by user <a href=\"" . $user_link . "\">" . $term['firstname'] . " " . $term['lastname'] . "</a></small>" . $admin_links . "</p>\n"; |
|
869 | + $user_details = "\t\t\t\t<p><small>contributed by user <a href=\"".$user_link."\">".$term['firstname']." ".$term['lastname']."</a></small>".$admin_links."</p>\n"; |
|
870 | 870 | } |
871 | 871 | else { |
872 | 872 | $user_details = ""; |
873 | 873 | } |
874 | 874 | |
875 | - print "\t\t\t\t<p class=\"glossary-body\">" . $term['body'] . "</p>\n" . $user_details; |
|
875 | + print "\t\t\t\t<p class=\"glossary-body\">".$term['body']."</p>\n".$user_details; |
|
876 | 876 | |
877 | 877 | if ($this_page == "glossary_item") { |
878 | 878 | // Add a direct search link for current glossary item |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | // remember to quote the term for phrase matching in search |
881 | 881 | $URL->insert(array('s' => '"'.$term['title'].'"')); |
882 | 882 | $search_url = $URL->generate(); |
883 | - printf ("\t\t\t\t<p>Search hansard for \"<a href=\"%s\" title=\"View search results for this glossary item\">%s</a>\"</p>", $search_url, $term['title']); |
|
883 | + printf("\t\t\t\t<p>Search hansard for \"<a href=\"%s\" title=\"View search results for this glossary item\">%s</a>\"</p>", $search_url, $term['title']); |
|
884 | 884 | } |
885 | 885 | } |
886 | 886 | |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | $URL = new \MySociety\TheyWorkForYou\Url('glossary'); |
913 | 913 | $URL->remove(array("g")); |
914 | 914 | $glossary_link = $URL->generate('url'); |
915 | - print "<small><a href=\"" . $glossary_link . "\">Browse the glossary</a></small>"; |
|
915 | + print "<small><a href=\"".$glossary_link."\">Browse the glossary</a></small>"; |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | public function glossary_links() { |
@@ -955,13 +955,13 @@ discard block |
||
955 | 955 | |
956 | 956 | // Generate all the page links. |
957 | 957 | $URL = new \MySociety\TheyWorkForYou\Url($this_page); |
958 | - $URL->insert( array('wtt' => get_http_var('wtt')) ); |
|
958 | + $URL->insert(array('wtt' => get_http_var('wtt'))); |
|
959 | 959 | if (isset($pagedata['s'])) { |
960 | 960 | # XXX: Should be taken out in *one* place, not here + search_form etc. |
961 | 961 | $value = $pagedata['s']; |
962 | 962 | if (preg_match_all('#speaker:(\d+)#', $value, $m) == 1) { |
963 | 963 | $person_id = $m[1][0]; |
964 | - $value = str_replace('speaker:' . $person_id, '', $value); |
|
964 | + $value = str_replace('speaker:'.$person_id, '', $value); |
|
965 | 965 | $URL->insert(array('pid' => $person_id)); |
966 | 966 | } |
967 | 967 | $URL->insert(array('s' => $value)); |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | } |
981 | 981 | |
982 | 982 | if ($n != $page) { |
983 | - $pagelinks[] = '<a href="' . $URL->generate() . '">' . $n . '</a>'; |
|
983 | + $pagelinks[] = '<a href="'.$URL->generate().'">'.$n.'</a>'; |
|
984 | 984 | } else { |
985 | 985 | $pagelinks[] = "<strong>$n</strong>"; |
986 | 986 | } |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | <?php |
1002 | 1002 | } |
1003 | 1003 | |
1004 | - echo "\t\t\t\t" . implode(' ', $pagelinks); |
|
1004 | + echo "\t\t\t\t".implode(' ', $pagelinks); |
|
1005 | 1005 | |
1006 | 1006 | if ($page != $numpages) { |
1007 | 1007 | $nextpage = $page + 1; |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | if ($data['user_id'] > 0) { |
1028 | 1028 | $USERURL = new \MySociety\TheyWorkForYou\Url('userview'); |
1029 | 1029 | $USERURL->insert(array('id'=>$data['user_id'])); |
1030 | - $username = '<a href="' . $USERURL->generate() . '">' . _htmlentities($data['user_name']) . '</a>'; |
|
1030 | + $username = '<a href="'.$USERURL->generate().'">'._htmlentities($data['user_name']).'</a>'; |
|
1031 | 1031 | } else { |
1032 | 1032 | $username = _htmlentities($data['user_name']); |
1033 | 1033 | } |
@@ -1086,15 +1086,15 @@ discard block |
||
1086 | 1086 | 'rid' => $report['report_id'], |
1087 | 1087 | 'cid' => $report['comment_id'], |
1088 | 1088 | )); |
1089 | - $editlink = '<a href="' . $EDITURL->generate() . '">View</a>'; |
|
1089 | + $editlink = '<a href="'.$EDITURL->generate().'">View</a>'; |
|
1090 | 1090 | } else { |
1091 | 1091 | $editlink = 'Locked'; |
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | $body = trim_characters($report['body'], 0, 40); |
1095 | 1095 | |
1096 | - $tabledata['rows'][] = array ( |
|
1097 | - _htmlentities($report['firstname'] . ' ' . $report['lastname']), |
|
1096 | + $tabledata['rows'][] = array( |
|
1097 | + _htmlentities($report['firstname'].' '.$report['lastname']), |
|
1098 | 1098 | _htmlentities($body), |
1099 | 1099 | $report['reported'], |
1100 | 1100 | $editlink |
@@ -1124,13 +1124,13 @@ discard block |
||
1124 | 1124 | // $page is the name of the page the dates should link to. |
1125 | 1125 | |
1126 | 1126 | // Create array containing abbreviations of days of week. |
1127 | - $daysOfWeek = array('Mon','Tue','Wed','Thu','Fri','Sat','Sun'); |
|
1127 | + $daysOfWeek = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'); |
|
1128 | 1128 | |
1129 | 1129 | // What is the first day of the month in question? |
1130 | - $firstDayOfMonth = mktime(0,0,0,$month,1,$year); |
|
1130 | + $firstDayOfMonth = mktime(0, 0, 0, $month, 1, $year); |
|
1131 | 1131 | |
1132 | 1132 | // How many days does this month contain? |
1133 | - $numberDays = date('t',$firstDayOfMonth); |
|
1133 | + $numberDays = date('t', $firstDayOfMonth); |
|
1134 | 1134 | |
1135 | 1135 | // Retrieve some information about the first day of the |
1136 | 1136 | // month in question. |
@@ -1211,13 +1211,13 @@ discard block |
||
1211 | 1211 | |
1212 | 1212 | // Is the $currentDay a member of $dateArray? If so, |
1213 | 1213 | // the day should be linked. |
1214 | - if (in_array($currentDay,$dateArray)) { |
|
1214 | + if (in_array($currentDay, $dateArray)) { |
|
1215 | 1215 | |
1216 | 1216 | $date = sprintf("%04d-%02d-%02d", $year, $month, $currentDay); |
1217 | 1217 | |
1218 | 1218 | $DAYURL->insert(array('d'=>$date)); |
1219 | 1219 | |
1220 | - $calendar .= "<a href=\"" . $DAYURL->generate() . "\">$currentDay</a></td>"; |
|
1220 | + $calendar .= "<a href=\"".$DAYURL->generate()."\">$currentDay</a></td>"; |
|
1221 | 1221 | |
1222 | 1222 | // $currentDay is not a member of $dateArray. |
1223 | 1223 | |
@@ -1312,8 +1312,8 @@ discard block |
||
1312 | 1312 | // Returns HTML suitable for putting in the sidebar on Admin pages. |
1313 | 1313 | global $this_page, $DATA; |
1314 | 1314 | |
1315 | - $pages = array ('admin_home', |
|
1316 | - 'admin_comments','admin_trackbacks', 'admin_searchlogs', 'admin_popularsearches', 'admin_failedsearches', |
|
1315 | + $pages = array('admin_home', |
|
1316 | + 'admin_comments', 'admin_trackbacks', 'admin_searchlogs', 'admin_popularsearches', 'admin_failedsearches', |
|
1317 | 1317 | 'alert_stats', 'admin_statistics', 'admin_reportstats', |
1318 | 1318 | 'admin_commentreports', 'admin_glossary', 'admin_glossary_pending', 'admin_badusers', |
1319 | 1319 | 'admin_photos', 'admin_mpurls', 'admin_policies', 'admin_banner', 'admin_featured', 'admin_topics' |
@@ -1326,9 +1326,9 @@ discard block |
||
1326 | 1326 | |
1327 | 1327 | if ($page != $this_page) { |
1328 | 1328 | $URL = new \MySociety\TheyWorkForYou\Url($page); |
1329 | - $title = '<a href="' . $URL->generate() . '">' . $title . '</a>'; |
|
1329 | + $title = '<a href="'.$URL->generate().'">'.$title.'</a>'; |
|
1330 | 1330 | } else { |
1331 | - $title = '<strong>' . $title . '</strong>'; |
|
1331 | + $title = '<strong>'.$title.'</strong>'; |
|
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | $links[] = $title; |
@@ -1336,7 +1336,7 @@ discard block |
||
1336 | 1336 | |
1337 | 1337 | $html = "<ul>\n"; |
1338 | 1338 | |
1339 | - $html .= "<li>" . implode("</li>\n<li>", $links) . "</li>\n"; |
|
1339 | + $html .= "<li>".implode("</li>\n<li>", $links)."</li>\n"; |
|
1340 | 1340 | |
1341 | 1341 | $html .= "</ul>\n"; |
1342 | 1342 |
@@ -114,7 +114,10 @@ discard block |
||
114 | 114 | // 'foot' - For the bottom stripe on hansard debates/wrans listings. |
115 | 115 | // $id is the value of an id for this div (if blank, not used). |
116 | 116 | ?> |
117 | - <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') echo ' ' . $extra_class; ?>"<?php |
|
117 | + <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') { |
|
118 | + echo ' ' . $extra_class; |
|
119 | +} |
|
120 | +?>"<?php |
|
118 | 121 | if ($id != '') { |
119 | 122 | print ' id="' . $id . '"'; |
120 | 123 | } |
@@ -479,7 +482,9 @@ discard block |
||
479 | 482 | |
480 | 483 | global $DATA, $this_page; |
481 | 484 | |
482 | - if ($this->page_started()) return; |
|
485 | + if ($this->page_started()) { |
|
486 | + return; |
|
487 | + } |
|
483 | 488 | // The page's HTML hasn't been started yet, so we'd better do it. |
484 | 489 | |
485 | 490 | // Set the page title (in the <title></title>). |
@@ -629,7 +634,9 @@ discard block |
||
629 | 634 | $URL->insert(array('adv' => 1)); |
630 | 635 | echo ' <a href="' . $URL->generate() . '">More options</a>'; |
631 | 636 | echo '<br>'; |
632 | - if ($wtt) print '<input type="hidden" name="wtt" value="1">'; |
|
637 | + if ($wtt) { |
|
638 | + print '<input type="hidden" name="wtt" value="1">'; |
|
639 | + } |
|
633 | 640 | } else { ?> |
634 | 641 | <form action="http://www.writetothem.com/lords" method="get"> |
635 | 642 | <input type="hidden" name="pid" value="<?=_htmlentities(get_http_var('pid')) ?>"> |
@@ -743,8 +750,7 @@ discard block |
||
743 | 750 | // The return url for after the user has logged in. |
744 | 751 | if (get_http_var("ret") != "") { |
745 | 752 | $returl = get_http_var("ret"); |
746 | - } |
|
747 | - else { |
|
753 | + } else { |
|
748 | 754 | $returl = $glossary_returl; |
749 | 755 | } |
750 | 756 | ?> |
@@ -808,15 +814,13 @@ discard block |
||
808 | 814 | else { |
809 | 815 | $letters[] = "<li class=\"on\">" . $letter . "</li>"; |
810 | 816 | } |
811 | - } |
|
812 | - elseif (!empty($GLOSSARY->alphabet[$letter])) { |
|
817 | + } elseif (!empty($GLOSSARY->alphabet[$letter])) { |
|
813 | 818 | $URL = new \MySociety\TheyWorkForYou\Url('glossary'); |
814 | 819 | $URL->insert(array('az' => $letter)); |
815 | 820 | $letter_link = $URL->generate('url'); |
816 | 821 | |
817 | 822 | $letters[] = "<li><a href=\"" . $letter_link . "\">" . $letter . "</a></li>"; |
818 | - } |
|
819 | - else { |
|
823 | + } else { |
|
820 | 824 | $letters[] = '<li>' . $letter . '</li>'; |
821 | 825 | } |
822 | 826 | } |
@@ -856,8 +860,7 @@ discard block |
||
856 | 860 | $URL->insert(array("delete_confirm" => $term['glossary_id'])); |
857 | 861 | $delete_url = $URL->generate(); |
858 | 862 | $admin_links = "<br><small><a href=\"".$delete_url."\">delete</a></small>"; |
859 | - } |
|
860 | - else { |
|
863 | + } else { |
|
861 | 864 | $admin_links = ""; |
862 | 865 | } |
863 | 866 | |
@@ -867,8 +870,7 @@ discard block |
||
867 | 870 | $user_link = $URL->generate('url'); |
868 | 871 | |
869 | 872 | $user_details = "\t\t\t\t<p><small>contributed by user <a href=\"" . $user_link . "\">" . $term['firstname'] . " " . $term['lastname'] . "</a></small>" . $admin_links . "</p>\n"; |
870 | - } |
|
871 | - else { |
|
873 | + } else { |
|
872 | 874 | $user_details = ""; |
873 | 875 | } |
874 | 876 |