@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | $gid = $featured->get_gid(); |
58 | 58 | $gidCheck = new Gid($gid); |
59 | 59 | $gid = $gidCheck->checkForRedirect(); |
60 | - if ( $gid ) { |
|
60 | + if ($gid) { |
|
61 | 61 | $title = $featured->get_title(); |
62 | 62 | $context = $featured->get_context(); |
63 | 63 | $related = $featured->get_related(); |
64 | 64 | $item = $this->getFeaturedDebate($gid, $title, $context, $related); |
65 | 65 | } else { |
66 | 66 | $item = $debatelist->display('recent_debates', array('days' => 7, 'num' => 1), 'none'); |
67 | - if ( isset($item['data']) && count($item['data']) ) { |
|
67 | + if (isset($item['data']) && count($item['data'])) { |
|
68 | 68 | $item = $item['data'][0]; |
69 | 69 | $more_url = new Url('debates'); |
70 | 70 | $item['more_url'] = $more_url->generate(); |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | $item['featured'] = true; |
96 | 96 | |
97 | 97 | $related_debates = array(); |
98 | - foreach ( $related as $related_gid ) { |
|
99 | - if ( $related_gid ) { |
|
98 | + foreach ($related as $related_gid) { |
|
99 | + if ($related_gid) { |
|
100 | 100 | $related_item = $debatelist->display('featured_gid', array('gid' => $related_gid), 'none'); |
101 | 101 | $related_debates[] = $related_item['data']; |
102 | 102 | } |
@@ -121,21 +121,21 @@ discard block |
||
121 | 121 | |
122 | 122 | $recent_content = array(); |
123 | 123 | |
124 | - foreach ( $this->recent_types as $class => $recent ) { |
|
124 | + foreach ($this->recent_types as $class => $recent) { |
|
125 | 125 | $class = "\\$class"; |
126 | 126 | $instance = new $class(); |
127 | 127 | $more_url = new Url($recent[1]); |
128 | - if ( $recent[0] == 'recent_pbc_debates' ) { |
|
129 | - $content = array( 'data' => $instance->display($recent[0], array('num' => 5), 'none') ); |
|
128 | + if ($recent[0] == 'recent_pbc_debates') { |
|
129 | + $content = array('data' => $instance->display($recent[0], array('num' => 5), 'none')); |
|
130 | 130 | } else { |
131 | 131 | $content = $instance->display($recent[0], array('days' => 7, 'num' => 1), 'none'); |
132 | - if ( isset($content['data']) && count($content['data']) ) { |
|
132 | + if (isset($content['data']) && count($content['data'])) { |
|
133 | 133 | $content = $content['data'][0]; |
134 | 134 | } else { |
135 | 135 | $content = array(); |
136 | 136 | } |
137 | 137 | } |
138 | - if ( $content ) { |
|
138 | + if ($content) { |
|
139 | 139 | $content['more_url'] = $more_url->generate(); |
140 | 140 | $content['desc'] = $recent[2]; |
141 | 141 | $recent_content[] = $content; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | WHERE event_date >= :date |
155 | 155 | AND deleted = 0 |
156 | 156 | ORDER BY event_date, chamber, pos", |
157 | - array( ':date' => $date ) |
|
157 | + array(':date' => $date) |
|
158 | 158 | ); |
159 | 159 | |
160 | 160 | if (!$q->rows()) { |
@@ -62,7 +62,8 @@ discard block |
||
62 | 62 | $context = $featured->get_context(); |
63 | 63 | $related = $featured->get_related(); |
64 | 64 | $item = $this->getFeaturedDebate($gid, $title, $context, $related); |
65 | - } else { |
|
65 | + } |
|
66 | + else { |
|
66 | 67 | $item = $debatelist->display('recent_debates', array('days' => 7, 'num' => 1), 'none'); |
67 | 68 | if ( isset($item['data']) && count($item['data']) ) { |
68 | 69 | $item = $item['data'][0]; |
@@ -71,7 +72,8 @@ discard block |
||
71 | 72 | $item['desc'] = 'Commons Debates'; |
72 | 73 | $item['related'] = array(); |
73 | 74 | $item['featured'] = false; |
74 | - } else { |
|
75 | + } |
|
76 | + else { |
|
75 | 77 | $item = array(); |
76 | 78 | } |
77 | 79 | } |
@@ -82,9 +84,11 @@ discard block |
||
82 | 84 | public function getFeaturedDebate($gid, $title, $context, $related) { |
83 | 85 | if (strpos($gid, 'lords') !== false) { |
84 | 86 | $debatelist = new \LORDSDEBATELIST; |
85 | - } elseif (strpos($gid, 'westminhall') !== false) { |
|
87 | + } |
|
88 | + elseif (strpos($gid, 'westminhall') !== false) { |
|
86 | 89 | $debatelist = new \WHALLLIST; |
87 | - } else { |
|
90 | + } |
|
91 | + else { |
|
88 | 92 | $debatelist = new \DEBATELIST; |
89 | 93 | } |
90 | 94 | |
@@ -127,11 +131,13 @@ discard block |
||
127 | 131 | $more_url = new Url($recent[1]); |
128 | 132 | if ( $recent[0] == 'recent_pbc_debates' ) { |
129 | 133 | $content = array( 'data' => $instance->display($recent[0], array('num' => 5), 'none') ); |
130 | - } else { |
|
134 | + } |
|
135 | + else { |
|
131 | 136 | $content = $instance->display($recent[0], array('days' => 7, 'num' => 1), 'none'); |
132 | 137 | if ( isset($content['data']) && count($content['data']) ) { |
133 | 138 | $content = $content['data'][0]; |
134 | - } else { |
|
139 | + } |
|
140 | + else { |
|
135 | 141 | $content = array(); |
136 | 142 | } |
137 | 143 | } |
@@ -318,6 +318,9 @@ discard block |
||
318 | 318 | $format_date_months = array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); |
319 | 319 | $format_date_months_short = array('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
320 | 320 | |
321 | +/** |
|
322 | + * @param string $format |
|
323 | + */ |
|
321 | 324 | function format_date($date, $format) { |
322 | 325 | global $format_date_months, $format_date_months_short; |
323 | 326 | // Pass it a date (YYYY-MM-DD) and a |
@@ -342,6 +345,9 @@ discard block |
||
342 | 345 | } |
343 | 346 | |
344 | 347 | |
348 | +/** |
|
349 | + * @param string $format |
|
350 | + */ |
|
345 | 351 | function format_time($time, $format) { |
346 | 352 | // Pass it a time (HH:MM:SS) and a |
347 | 353 | // PHP date format string (eg, "H:i") |
@@ -486,6 +492,7 @@ discard block |
||
486 | 492 | |
487 | 493 | /** |
488 | 494 | * Filters user input to remove unwanted HTML tags etc |
495 | + * @param string $filter_type |
|
489 | 496 | */ |
490 | 497 | function filter_user_input($text, $filter_type) { |
491 | 498 | // We use this to filter any major user input, especially comments. |
@@ -750,12 +757,18 @@ discard block |
||
750 | 757 | /* verp_envelope_sender RECIPIENT |
751 | 758 | * Construct a VERP envelope sender for an email to RECIPIENT |
752 | 759 | */ |
760 | +/** |
|
761 | + * @return string|null |
|
762 | + */ |
|
753 | 763 | function twfy_verp_envelope_sender($recipient) { |
754 | 764 | $envelope_sender = verp_envelope_sender($recipient, 'twfy', EMAILDOMAIN); |
755 | 765 | |
756 | 766 | return $envelope_sender; |
757 | 767 | } |
758 | 768 | |
769 | +/** |
|
770 | + * @param string $message |
|
771 | + */ |
|
759 | 772 | function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false) { |
760 | 773 | // Use this rather than PHP's mail() direct, so we can make alterations |
761 | 774 | // easily to all the emails we send out from the site. |
@@ -814,6 +827,9 @@ discard block |
||
814 | 827 | } |
815 | 828 | |
816 | 829 | // Call this with a key name to get a COOKIE variable. |
830 | +/** |
|
831 | + * @param string $name |
|
832 | + */ |
|
817 | 833 | function get_cookie_var($name, $default='') { |
818 | 834 | if (array_key_exists($name, $_COOKIE)) { |
819 | 835 | return clean_var($_COOKIE[$name]); |
@@ -1058,6 +1074,10 @@ discard block |
||
1058 | 1074 | } |
1059 | 1075 | } |
1060 | 1076 | |
1077 | +/** |
|
1078 | + * @param integer $major |
|
1079 | + * @param MySociety\TheyWorkForYou\Url $LISTURL |
|
1080 | + */ |
|
1061 | 1081 | function _major_summary_title($major, $data, $LISTURL, $daytext) { |
1062 | 1082 | global $hansardmajors; |
1063 | 1083 | |
@@ -1107,6 +1127,9 @@ discard block |
||
1107 | 1127 | return $return; |
1108 | 1128 | } |
1109 | 1129 | |
1130 | +/** |
|
1131 | + * @param string|null $url |
|
1132 | + */ |
|
1110 | 1133 | function redirect($url) { |
1111 | 1134 | if (defined('TESTING')) { |
1112 | 1135 | print "Location: $url"; |
@@ -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)) { |
@@ -173,18 +173,22 @@ |
||
173 | 173 | foreach ($var as $v) { |
174 | 174 | $url_args[] = "$key=" . urlencode(stripslashes($v)); |
175 | 175 | } |
176 | - } elseif ($var != null) |
|
177 | - $url_args[] = "$key=" . urlencode(stripslashes($var)); |
|
176 | + } |
|
177 | + elseif ($var != null) { |
|
178 | + $url_args[] = "$key=" . urlencode(stripslashes($var)); |
|
179 | + } |
|
178 | 180 | } |
179 | 181 | |
180 | 182 | $page_url = WEBPATH . $DATA->page_metadata($this->destinationpage, "url"); |
181 | 183 | |
182 | 184 | if (sizeof($url_args) == 0) { |
183 | 185 | return $page_url; |
184 | - } else { |
|
186 | + } |
|
187 | + else { |
|
185 | 188 | if ($encode == "html") { |
186 | 189 | return $page_url . "?" . implode("&", $url_args); |
187 | - } elseif ($encode == "none" || $encode == "url") { |
|
190 | + } |
|
191 | + elseif ($encode == "none" || $encode == "url") { |
|
188 | 192 | return $page_url . "?" . implode("&", $url_args); |
189 | 193 | } |
190 | 194 | } |
@@ -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 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | if (!in_array($name, $this->no_close)) { |
229 | 229 | if (isset($this->tag_counts[$name])) { |
230 | 230 | $this->tag_counts[$name]--; |
231 | - return '</'.$name.'>'; |
|
231 | + return '</' . $name . '>'; |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | } else { |
@@ -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) { |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | if ($ending) { |
276 | 276 | $ending = ' /'; |
277 | 277 | } |
278 | - return '<'.$name.$params.$ending.'>'; |
|
278 | + return '<' . $name . $params . $ending . '>'; |
|
279 | 279 | } else { |
280 | 280 | return ''; |
281 | 281 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | if ($this->strip_comments) { |
287 | 287 | return ''; |
288 | 288 | } else { |
289 | - return '<'.$data.'>'; |
|
289 | + return '<' . $data . '>'; |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
@@ -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 | |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | $data |
398 | 398 | ); |
399 | 399 | |
400 | - return $m[1].$data.$m[3]; |
|
400 | + return $m[1] . $data . $m[3]; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | ##################################################################################### |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | |
475 | 475 | |
476 | 476 | |
477 | - return $m[1].$m[2].$m[3]; |
|
477 | + return $m[1] . $m[2] . $m[3]; |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | |
497 | 497 | if ($term != ';') { |
498 | 498 | |
499 | - return '&'.$preamble; |
|
499 | + return '&' . $preamble; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | # |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | if ($this->is_valid_entity($preamble)) { |
507 | 507 | |
508 | - return '&'.$preamble; |
|
508 | + return '&' . $preamble; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | # not an allowed antity, so escape the ampersand |
514 | 514 | # |
515 | 515 | |
516 | - return '&'.$preamble; |
|
516 | + return '&' . $preamble; |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | |
@@ -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); |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | # |
604 | 604 | |
605 | 605 | if ($d > 127) { |
606 | - if ($orig_type == '%') { return '%'.dechex($d); } |
|
606 | + if ($orig_type == '%') { return '%' . dechex($d); } |
|
607 | 607 | if ($orig_type == '&') { return "&#$d;"; } |
608 | 608 | } |
609 | 609 |
@@ -177,7 +177,8 @@ discard block |
||
177 | 177 | $data = preg_replace("/<([^>]*?)(?=<|$)/", "<$1>", $data); |
178 | 178 | $data = preg_replace("/(^|>)([^<]*?)(?=>)/", "$1<$2", $data); |
179 | 179 | |
180 | - } else { |
|
180 | + } |
|
181 | + else { |
|
181 | 182 | |
182 | 183 | # |
183 | 184 | # escape stray brackets |
@@ -231,7 +232,8 @@ discard block |
||
231 | 232 | return '</'.$name.'>'; |
232 | 233 | } |
233 | 234 | } |
234 | - } else { |
|
235 | + } |
|
236 | + else { |
|
235 | 237 | return ''; |
236 | 238 | } |
237 | 239 | } |
@@ -268,7 +270,8 @@ discard block |
||
268 | 270 | if (!$ending) { |
269 | 271 | if (isset($this->tag_counts[$name])) { |
270 | 272 | $this->tag_counts[$name]++; |
271 | - } else { |
|
273 | + } |
|
274 | + else { |
|
272 | 275 | $this->tag_counts[$name] = 1; |
273 | 276 | } |
274 | 277 | } |
@@ -276,7 +279,8 @@ discard block |
||
276 | 279 | $ending = ' /'; |
277 | 280 | } |
278 | 281 | return '<'.$name.$params.$ending.'>'; |
279 | - } else { |
|
282 | + } |
|
283 | + else { |
|
280 | 284 | return ''; |
281 | 285 | } |
282 | 286 | } |
@@ -285,7 +289,8 @@ discard block |
||
285 | 289 | if (preg_match("/^!--(.*)--$/si", $data)) { |
286 | 290 | if ($this->strip_comments) { |
287 | 291 | return ''; |
288 | - } else { |
|
292 | + } |
|
293 | + else { |
|
289 | 294 | return '<'.$data.'>'; |
290 | 295 | } |
291 | 296 | } |
@@ -324,7 +329,9 @@ discard block |
||
324 | 329 | while (1) { |
325 | 330 | $len = strlen($data); |
326 | 331 | $data = preg_replace("/<({$tags})(\s[^>]*)?(><\\/\\1>|\\/>)/", '', $data); |
327 | - if ($len == strlen($data)) break; |
|
332 | + if ($len == strlen($data)) { |
|
333 | + break; |
|
334 | + } |
|
328 | 335 | } |
329 | 336 | } |
330 | 337 |
@@ -32,7 +32,8 @@ |
||
32 | 32 | $URL = new \MySociety\TheyWorkForYou\Url('member'); |
33 | 33 | $URL->insert(array('id'=>$row['speaker']['member_id'])); |
34 | 34 | $member = '<a href="' . $URL->generate() . '">' . $row['speaker']['name'] . '</a>: '; |
35 | - } else { |
|
35 | + } |
|
36 | + else { |
|
36 | 37 | $member = ''; |
37 | 38 | } |
38 | 39 | ?> |
@@ -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'])) { |
@@ -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,7 +32,7 @@ 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'] = ''; |
@@ -52,7 +52,7 @@ 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 | 57 | $text = "<a href=\"" . $LOGINURL->generate() . "\">You'd better sign in!</a>"; |
58 | 58 | } else { |
@@ -67,7 +67,7 @@ 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 | |
@@ -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. |
@@ -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: |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | public function include_sidebar_template($sidebarname) { |
235 | 235 | global $this_page, $DATA; |
236 | 236 | |
237 | - $sidebarpath = INCLUDESPATH.'easyparliament/sidebars/'.$sidebarname.'.php'; |
|
237 | + $sidebarpath = INCLUDESPATH . 'easyparliament/sidebars/' . $sidebarname . '.php'; |
|
238 | 238 | |
239 | 239 | if (file_exists($sidebarpath)) { |
240 | 240 | include $sidebarpath; |
@@ -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: |
@@ -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. |
@@ -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 != '') { |
@@ -553,7 +553,7 @@ 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 | 559 | $uplink .= '<br><a href="' . $URL->generate() . '">Remove highlighting</a>'; |
@@ -568,7 +568,7 @@ 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 | 573 | $nextlink = $next['body'] . ' »'; |
574 | 574 | } |
@@ -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,7 +624,7 @@ 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 | 630 | echo ' <a href="' . $URL->generate() . '">More options</a>'; |
@@ -646,16 +646,16 @@ 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') { |
|
656 | + if ($ordering == 'd') { |
|
657 | 657 | print '<strong>Sorted by date: newest</strong> / <a href="' . $orderUrl->generate('html', array('o'=>'o')) . '">oldest</a>'; |
658 | - } elseif ($ordering=='o') { |
|
658 | + } elseif ($ordering == 'o') { |
|
659 | 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>", |
@@ -663,7 +663,7 @@ discard block |
||
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'))); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 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) |
@@ -824,14 +824,14 @@ discard block |
||
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 | ?> |
@@ -850,12 +850,12 @@ discard block |
||
850 | 850 | |
851 | 851 | // add some extra controls for the administrators |
852 | 852 | if ($this_page == "admin_glossary") { |
853 | - print "<a id=\"gl".$term['glossary_id']."\"></a>"; |
|
853 | + print "<a id=\"gl" . $term['glossary_id'] . "\"></a>"; |
|
854 | 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(); |
858 | - $admin_links = "<br><small><a href=\"".$delete_url."\">delete</a></small>"; |
|
858 | + $admin_links = "<br><small><a href=\"" . $delete_url . "\">delete</a></small>"; |
|
859 | 859 | } |
860 | 860 | else { |
861 | 861 | $admin_links = ""; |
@@ -878,9 +878,9 @@ discard block |
||
878 | 878 | // Add a direct search link for current glossary item |
879 | 879 | $URL = new \MySociety\TheyWorkForYou\Url('search'); |
880 | 880 | // remember to quote the term for phrase matching in search |
881 | - $URL->insert(array('s' => '"'.$term['title'].'"')); |
|
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 | |
@@ -955,7 +955,7 @@ 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']; |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | |
1094 | 1094 | $body = trim_characters($report['body'], 0, 40); |
1095 | 1095 | |
1096 | - $tabledata['rows'][] = array ( |
|
1096 | + $tabledata['rows'][] = array( |
|
1097 | 1097 | _htmlentities($report['firstname'] . ' ' . $report['lastname']), |
1098 | 1098 | _htmlentities($body), |
1099 | 1099 | $report['reported'], |
@@ -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,7 +1211,7 @@ 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 | |
@@ -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' |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | $LOGINURL->insert(array('ret' => $THISPAGE->generate('none') )); |
56 | 56 | |
57 | 57 | $text = "<a href=\"" . $LOGINURL->generate() . "\">You'd better sign in!</a>"; |
58 | - } else { |
|
58 | + } |
|
59 | + else { |
|
59 | 60 | $text = "That's all folks!"; |
60 | 61 | } |
61 | 62 | $this_page = 'home'; |
@@ -88,7 +89,8 @@ discard block |
||
88 | 89 | public function within_stripe() { |
89 | 90 | if ($this->within_stripe_main == true || $this->within_stripe_sidebar == true) { |
90 | 91 | return true; |
91 | - } else { |
|
92 | + } |
|
93 | + else { |
|
92 | 94 | return false; |
93 | 95 | } |
94 | 96 | } |
@@ -96,7 +98,8 @@ discard block |
||
96 | 98 | public function within_stripe_sidebar() { |
97 | 99 | if ($this->within_stripe_sidebar == true) { |
98 | 100 | return true; |
99 | - } else { |
|
101 | + } |
|
102 | + else { |
|
100 | 103 | return false; |
101 | 104 | } |
102 | 105 | } |
@@ -114,7 +117,10 @@ discard block |
||
114 | 117 | // 'foot' - For the bottom stripe on hansard debates/wrans listings. |
115 | 118 | // $id is the value of an id for this div (if blank, not used). |
116 | 119 | ?> |
117 | - <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') echo ' ' . $extra_class; ?>"<?php |
|
120 | + <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') { |
|
121 | + echo ' ' . $extra_class; |
|
122 | +} |
|
123 | +?>"<?php |
|
118 | 124 | if ($id != '') { |
119 | 125 | print ' id="' . $id . '"'; |
120 | 126 | } |
@@ -192,20 +198,24 @@ discard block |
||
192 | 198 | |
193 | 199 | if (count($contents) == 0) { |
194 | 200 | print "\t\t\t \n"; |
195 | - } else { |
|
201 | + } |
|
202 | + else { |
|
196 | 203 | #print '<div class="sidebar">'; |
197 | 204 | foreach ($contents as $hash) { |
198 | 205 | if (isset($hash['type'])) { |
199 | 206 | if ($hash['type'] == 'include') { |
200 | 207 | $this->include_sidebar_template($hash['content']); |
201 | 208 | |
202 | - } elseif ($hash['type'] == 'nextprev') { |
|
209 | + } |
|
210 | + elseif ($hash['type'] == 'nextprev') { |
|
203 | 211 | $this->nextprevlinks(); |
204 | 212 | |
205 | - } elseif ($hash['type'] == 'html') { |
|
213 | + } |
|
214 | + elseif ($hash['type'] == 'html') { |
|
206 | 215 | print $hash['content']; |
207 | 216 | |
208 | - } elseif ($hash['type'] == 'extrahtml') { |
|
217 | + } |
|
218 | + elseif ($hash['type'] == 'extrahtml') { |
|
209 | 219 | $extrahtml .= $hash['content']; |
210 | 220 | } |
211 | 221 | } |
@@ -256,7 +266,8 @@ discard block |
||
256 | 266 | |
257 | 267 | if (isset($data['id']) && $data['id'] != '') { |
258 | 268 | $id = ' id="' . $data['id'] . '"'; |
259 | - } else { |
|
269 | + } |
|
270 | + else { |
|
260 | 271 | $id = ''; |
261 | 272 | } |
262 | 273 | |
@@ -304,7 +315,8 @@ discard block |
||
304 | 315 | // This is the page title of the parent. |
305 | 316 | $section_text = $DATA->page_metadata($parent_page, 'title'); |
306 | 317 | |
307 | - } else { |
|
318 | + } |
|
319 | + else { |
|
308 | 320 | // Top level page - no parent, hence no parental title. |
309 | 321 | $section_text = ''; |
310 | 322 | } |
@@ -318,7 +330,8 @@ discard block |
||
318 | 330 | |
319 | 331 | if ($page_text == '' && !is_bool($page_text)) { |
320 | 332 | // If the metadata 'heading' is set, but empty, we display nothing. |
321 | - } elseif ($page_text == false) { |
|
333 | + } |
|
334 | + elseif ($page_text == false) { |
|
322 | 335 | // But if it just hasn't been set, we use the 'title'. |
323 | 336 | $page_text = $DATA->page_metadata($this_page, "title"); |
324 | 337 | } |
@@ -326,7 +339,8 @@ discard block |
||
326 | 339 | if ($page_text == $section_text) { |
327 | 340 | // We don't want to print both. |
328 | 341 | $section_text = ''; |
329 | - } elseif (!$page_text && $section_text) { |
|
342 | + } |
|
343 | + elseif (!$page_text && $section_text) { |
|
330 | 344 | // Bodge for if we have a section_text but no page_text. |
331 | 345 | $page_text = $section_text; |
332 | 346 | $section_text = ''; |
@@ -340,7 +354,8 @@ discard block |
||
340 | 354 | print "\n\t\t\t\t<br><span>$page_text</span>\n"; |
341 | 355 | } |
342 | 356 | print "</h1>\n"; |
343 | - } elseif ($page_text) { |
|
357 | + } |
|
358 | + elseif ($page_text) { |
|
344 | 359 | print "\t\t\t\t<h1>$page_text</h1>\n"; |
345 | 360 | } |
346 | 361 | } |
@@ -399,7 +414,8 @@ discard block |
||
399 | 414 | // global which will then be displayed by the header template |
400 | 415 | if ( $this->page_started() ) { |
401 | 416 | $this->message($message, 'error'); |
402 | - } else { |
|
417 | + } |
|
418 | + else { |
|
403 | 419 | if ( !isset($page_errors) ) { |
404 | 420 | $page_errors = array(); |
405 | 421 | } |
@@ -479,7 +495,9 @@ discard block |
||
479 | 495 | |
480 | 496 | global $DATA, $this_page; |
481 | 497 | |
482 | - if ($this->page_started()) return; |
|
498 | + if ($this->page_started()) { |
|
499 | + return; |
|
500 | + } |
|
483 | 501 | // The page's HTML hasn't been started yet, so we'd better do it. |
484 | 502 | |
485 | 503 | // Set the page title (in the <title></title>). |
@@ -487,7 +505,8 @@ discard block |
||
487 | 505 | |
488 | 506 | if (isset($info['text_heading'])) { |
489 | 507 | $page_title = $info['text_heading']; |
490 | - } elseif (isset($info['text'])) { |
|
508 | + } |
|
509 | + elseif (isset($info['text'])) { |
|
491 | 510 | // Use a truncated version of the page's main item's body text. |
492 | 511 | // trim_words() is in utility.php. Trim to 40 chars. |
493 | 512 | $page_title = trim_characters($info['text'], 0, 40); |
@@ -539,7 +558,8 @@ discard block |
||
539 | 558 | if (isset($prev['url'])) { |
540 | 559 | $prevlink = '<a href="' . $prev['url'] . '" title="' . $prev['title'] . '" class="linkbutton">« ' . $prev['body'] . '</a>'; |
541 | 560 | |
542 | - } else { |
|
561 | + } |
|
562 | + else { |
|
543 | 563 | $prevlink = '« ' . $prev['body']; |
544 | 564 | } |
545 | 565 | } |
@@ -569,7 +589,8 @@ discard block |
||
569 | 589 | |
570 | 590 | if (isset($next['url'])) { |
571 | 591 | $nextlink = '<a href="' . $next['url'] . '" title="' . $next['title'] . '" class="linkbutton">' . $next['body'] . ' »</a>'; |
572 | - } else { |
|
592 | + } |
|
593 | + else { |
|
573 | 594 | $nextlink = $next['body'] . ' »'; |
574 | 595 | } |
575 | 596 | } |
@@ -599,7 +620,8 @@ discard block |
||
599 | 620 | if ($value == '') { |
600 | 621 | if (get_http_var('q') !== '') { |
601 | 622 | $value = get_http_var('q'); |
602 | - } else { |
|
623 | + } |
|
624 | + else { |
|
603 | 625 | $value = get_http_var('s'); |
604 | 626 | } |
605 | 627 | } |
@@ -629,8 +651,11 @@ discard block |
||
629 | 651 | $URL->insert(array('adv' => 1)); |
630 | 652 | echo ' <a href="' . $URL->generate() . '">More options</a>'; |
631 | 653 | echo '<br>'; |
632 | - if ($wtt) print '<input type="hidden" name="wtt" value="1">'; |
|
633 | - } else { ?> |
|
654 | + if ($wtt) { |
|
655 | + print '<input type="hidden" name="wtt" value="1">'; |
|
656 | + } |
|
657 | + } |
|
658 | + else { ?> |
|
634 | 659 | <form action="http://www.writetothem.com/lords" method="get"> |
635 | 660 | <input type="hidden" name="pid" value="<?=_htmlentities(get_http_var('pid')) ?>"> |
636 | 661 | <input type="submit" style="font-size: 150%" value=" I want to write to this Lord "><br> |
@@ -648,16 +673,19 @@ discard block |
||
648 | 673 | |
649 | 674 | if ($ordering=='r') { |
650 | 675 | print '<strong>Sorted by relevance</strong>'; |
651 | - } else { |
|
676 | + } |
|
677 | + else { |
|
652 | 678 | printf("<a href='%s'>Sort by relevance</a>", $orderUrl->generate('html', array('o'=>'r'))); |
653 | 679 | } |
654 | 680 | |
655 | 681 | print " | "; |
656 | 682 | if ($ordering=='d') { |
657 | 683 | print '<strong>Sorted by date: newest</strong> / <a href="' . $orderUrl->generate('html', array('o'=>'o')) . '">oldest</a>'; |
658 | - } elseif ($ordering=='o') { |
|
684 | + } |
|
685 | + elseif ($ordering=='o') { |
|
659 | 686 | print '<strong>Sorted by date:</strong> <a href="' . $orderUrl->generate('html', array('o'=>'d')) . '">newest</a> / <strong>oldest</strong>'; |
660 | - } else { |
|
687 | + } |
|
688 | + else { |
|
661 | 689 | printf("Sort by date: <a href='%s'>newest</a> / <a href='%s'>oldest</a>", |
662 | 690 | $orderUrl->generate('html', array('o'=>'d')), $orderUrl->generate('html', array('o'=>'o'))); |
663 | 691 | } |
@@ -665,7 +693,8 @@ discard block |
||
665 | 693 | print " | "; |
666 | 694 | if ($ordering=='p') { |
667 | 695 | print '<strong>Use by person</strong>'; |
668 | - } else { |
|
696 | + } |
|
697 | + else { |
|
669 | 698 | printf('<a href="%s">Show use by person</a>', $orderUrl->generate('html', array('o'=>'p'))); |
670 | 699 | } |
671 | 700 | echo '</div>'; |
@@ -888,7 +917,8 @@ discard block |
||
888 | 917 | if ($GLOSSARY->num_search_matches > 1) { |
889 | 918 | $plural = "them"; |
890 | 919 | $definition = "some definitions"; |
891 | - } else { |
|
920 | + } |
|
921 | + else { |
|
892 | 922 | $plural = "it"; |
893 | 923 | $definition = "a definition"; |
894 | 924 | } |
@@ -941,7 +971,8 @@ discard block |
||
941 | 971 | if ($page < 10) { |
942 | 972 | $firstpage = 1; |
943 | 973 | $lastpage = 10; |
944 | - } else { |
|
974 | + } |
|
975 | + else { |
|
945 | 976 | $firstpage = $page - 10; |
946 | 977 | $lastpage = $page + 9; |
947 | 978 | } |
@@ -971,7 +1002,8 @@ discard block |
||
971 | 1002 | |
972 | 1003 | if ($n > 1) { |
973 | 1004 | $URL->insert(array('p'=>$n)); |
974 | - } else { |
|
1005 | + } |
|
1006 | + else { |
|
975 | 1007 | // No page number for the first page. |
976 | 1008 | $URL->remove(array('p')); |
977 | 1009 | } |
@@ -981,7 +1013,8 @@ discard block |
||
981 | 1013 | |
982 | 1014 | if ($n != $page) { |
983 | 1015 | $pagelinks[] = '<a href="' . $URL->generate() . '">' . $n . '</a>'; |
984 | - } else { |
|
1016 | + } |
|
1017 | + else { |
|
985 | 1018 | $pagelinks[] = "<strong>$n</strong>"; |
986 | 1019 | } |
987 | 1020 | } |
@@ -1028,7 +1061,8 @@ discard block |
||
1028 | 1061 | $USERURL = new \MySociety\TheyWorkForYou\Url('userview'); |
1029 | 1062 | $USERURL->insert(array('id'=>$data['user_id'])); |
1030 | 1063 | $username = '<a href="' . $USERURL->generate() . '">' . _htmlentities($data['user_name']) . '</a>'; |
1031 | - } else { |
|
1064 | + } |
|
1065 | + else { |
|
1032 | 1066 | $username = _htmlentities($data['user_name']); |
1033 | 1067 | } |
1034 | 1068 | ?> |
@@ -1043,7 +1077,8 @@ discard block |
||
1043 | 1077 | ?> |
1044 | 1078 | <p> <br><em>This report has not been resolved.</em></p> |
1045 | 1079 | <?php |
1046 | - } else { |
|
1080 | + } |
|
1081 | + else { |
|
1047 | 1082 | ?> |
1048 | 1083 | <p><em>This report was resolved on <?php echo $data['resolved']; ?></em></p> |
1049 | 1084 | <?php |
@@ -1087,7 +1122,8 @@ discard block |
||
1087 | 1122 | 'cid' => $report['comment_id'], |
1088 | 1123 | )); |
1089 | 1124 | $editlink = '<a href="' . $EDITURL->generate() . '">View</a>'; |
1090 | - } else { |
|
1125 | + } |
|
1126 | + else { |
|
1091 | 1127 | $editlink = 'Locked'; |
1092 | 1128 | } |
1093 | 1129 | |
@@ -1104,7 +1140,8 @@ discard block |
||
1104 | 1140 | |
1105 | 1141 | $this->display_table($tabledata); |
1106 | 1142 | |
1107 | - } else { |
|
1143 | + } |
|
1144 | + else { |
|
1108 | 1145 | |
1109 | 1146 | print "<p>There are no outstanding annotation reports.</p>\n"; |
1110 | 1147 | } |
@@ -1144,7 +1181,8 @@ discard block |
||
1144 | 1181 | $nowDateComponents = getdate(); |
1145 | 1182 | if ($nowDateComponents['mon'] == $month && $nowDateComponents['year'] == $year) { |
1146 | 1183 | $toDay = $nowDateComponents['mday']; |
1147 | - } else { |
|
1184 | + } |
|
1185 | + else { |
|
1148 | 1186 | $toDay = ''; |
1149 | 1187 | } |
1150 | 1188 | |
@@ -1205,7 +1243,8 @@ discard block |
||
1205 | 1243 | // If so, higlight it. |
1206 | 1244 | if ($currentDay == $toDay) { |
1207 | 1245 | $calendar .= '<td class="on">'; |
1208 | - } else { |
|
1246 | + } |
|
1247 | + else { |
|
1209 | 1248 | $calendar .= '<td>'; |
1210 | 1249 | } |
1211 | 1250 | |
@@ -1221,7 +1260,8 @@ discard block |
||
1221 | 1260 | |
1222 | 1261 | // $currentDay is not a member of $dateArray. |
1223 | 1262 | |
1224 | - } else { |
|
1263 | + } |
|
1264 | + else { |
|
1225 | 1265 | |
1226 | 1266 | $calendar .= "$currentDay</td>"; |
1227 | 1267 | } |
@@ -1327,7 +1367,8 @@ discard block |
||
1327 | 1367 | if ($page != $this_page) { |
1328 | 1368 | $URL = new \MySociety\TheyWorkForYou\Url($page); |
1329 | 1369 | $title = '<a href="' . $URL->generate() . '">' . $title . '</a>'; |
1330 | - } else { |
|
1370 | + } |
|
1371 | + else { |
|
1331 | 1372 | $title = '<strong>' . $title . '</strong>'; |
1332 | 1373 | } |
1333 | 1374 |