@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public function __construct($name) { |
21 | 21 | // treat Labour and Labour/Co-operative the same as that's how |
22 | 22 | // people view them and it'll confuse the results otherwise |
23 | - if ( $name == 'Labour/Co-operative' ) { |
|
23 | + if ($name == 'Labour/Co-operative') { |
|
24 | 24 | $name = 'Labour'; |
25 | 25 | } |
26 | 26 | $this->name = $name; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | ':date' => date('Y-m-d'), |
43 | 43 | ) |
44 | 44 | ); |
45 | - if ( $member_count->rows ) { |
|
45 | + if ($member_count->rows) { |
|
46 | 46 | $num_members = $member_count->field(0, 'num_members'); |
47 | 47 | return $num_members; |
48 | 48 | } else { |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | ) |
71 | 71 | ); |
72 | 72 | |
73 | - if ( $position->rows ) { |
|
73 | + if ($position->rows) { |
|
74 | 74 | $score = $position->field(0, 'score'); |
75 | 75 | $score_desc = score_to_strongly($score); |
76 | 76 | |
77 | - if ( $want_score ) { |
|
78 | - return array( $score_desc, $score); |
|
77 | + if ($want_score) { |
|
78 | + return array($score_desc, $score); |
|
79 | 79 | } else { |
80 | 80 | return $score_desc; |
81 | 81 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ':party' => $this->name |
115 | 115 | ); |
116 | 116 | |
117 | - if ( $this->name == 'Labour' ) { |
|
117 | + if ($this->name == 'Labour') { |
|
118 | 118 | $party_where = '( party = :party OR party = :party2 )'; |
119 | 119 | $params = array( |
120 | 120 | ':party' => $this->name, |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
125 | - for ( $i = 0; $i < $num_divs; $i++ ) { |
|
125 | + for ($i = 0; $i < $num_divs; $i++) { |
|
126 | 126 | $division_id = $divisions->field($i, 'division_id'); |
127 | 127 | $weights = $this->get_vote_scores($divisions->field($i, 'policy_vote')); |
128 | 128 | |
@@ -142,42 +142,42 @@ discard block |
||
142 | 142 | ); |
143 | 143 | |
144 | 144 | $num_votes = 0; |
145 | - for ( $j = 0; $j < $votes->rows(); $j++ ) { |
|
145 | + for ($j = 0; $j < $votes->rows(); $j++) { |
|
146 | 146 | $vote_dir = $votes->field($j, 'vote'); |
147 | - if ( $vote_dir == '' ) continue; |
|
148 | - if ( $vote_dir == 'tellno' ) $vote_dir = 'no'; |
|
149 | - if ( $vote_dir == 'tellaye' ) $vote_dir = 'aye'; |
|
147 | + if ($vote_dir == '') continue; |
|
148 | + if ($vote_dir == 'tellno') $vote_dir = 'no'; |
|
149 | + if ($vote_dir == 'tellaye') $vote_dir = 'aye'; |
|
150 | 150 | |
151 | 151 | $num_votes += $votes->field($j, 'num_votes'); |
152 | 152 | $score += ($votes->field($j, 'num_votes') * $weights[$vote_dir]); |
153 | 153 | } |
154 | 154 | |
155 | 155 | $total_votes += $num_votes; |
156 | - $max_score += $num_votes * max( array_values( $weights ) ); |
|
156 | + $max_score += $num_votes * max(array_values($weights)); |
|
157 | 157 | } |
158 | 158 | |
159 | - if ( $total_votes == 0 ) { |
|
159 | + if ($total_votes == 0) { |
|
160 | 160 | return null; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // this implies that all the divisions in the policy have a policy |
164 | 164 | // position of absent so we set weight to -1 to indicate we can't |
165 | 165 | // really say what the parties position is. |
166 | - if ( $max_score == 0 ) { |
|
166 | + if ($max_score == 0) { |
|
167 | 167 | $weight = -1; |
168 | 168 | } else { |
169 | - $weight = 1 - ( $score/$max_score ); |
|
169 | + $weight = 1 - ($score / $max_score); |
|
170 | 170 | } |
171 | 171 | $score_desc = score_to_strongly($weight); |
172 | 172 | |
173 | - if ( $want_score ) { |
|
174 | - return array( $score_desc, $weight); |
|
173 | + if ($want_score) { |
|
174 | + return array($score_desc, $weight); |
|
175 | 175 | } else { |
176 | 176 | return $score_desc; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - public function cache_position( $position ) { |
|
180 | + public function cache_position($position) { |
|
181 | 181 | $this->db->query( |
182 | 182 | "REPLACE INTO partypolicy |
183 | 183 | (party, house, policy_id, score) |
@@ -197,9 +197,9 @@ discard block |
||
197 | 197 | return $positions; |
198 | 198 | } |
199 | 199 | |
200 | - foreach ( $policies->getPolicies() as $policy_id => $policy_text ) { |
|
201 | - list( $position, $score ) = $this->$method($policy_id, true); |
|
202 | - if ( $position === null ) { |
|
200 | + foreach ($policies->getPolicies() as $policy_id => $policy_text) { |
|
201 | + list($position, $score) = $this->$method($policy_id, true); |
|
202 | + if ($position === null) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $both = 1; |
220 | 220 | $agree = 10; |
221 | 221 | |
222 | - if ( stripos($vote, '3') !== FALSE ) { |
|
222 | + if (stripos($vote, '3') !== FALSE) { |
|
223 | 223 | $agree = 50; |
224 | 224 | $absent = 25; |
225 | 225 | $both = 25; |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | 'both' => $both |
231 | 231 | ); |
232 | 232 | |
233 | - if ( stripos($vote, 'aye') !== FALSE ) { |
|
233 | + if (stripos($vote, 'aye') !== FALSE) { |
|
234 | 234 | $scores['aye'] = $agree; |
235 | 235 | $scores['no'] = 0; |
236 | - } else if ( stripos($vote, 'no') !== FALSE ) { |
|
236 | + } else if (stripos($vote, 'no') !== FALSE) { |
|
237 | 237 | $scores['no'] = $agree; |
238 | 238 | $scores['aye'] = 0; |
239 | 239 | } else { |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $parties = array(); |
257 | 257 | $party_count = $party_list->rows; |
258 | 258 | |
259 | - for ( $i = 0; $i < $party_count; $i++ ) { |
|
259 | + for ($i = 0; $i < $party_count; $i++) { |
|
260 | 260 | $party = $party_list->field($i, 'party'); |
261 | 261 | if ( |
262 | 262 | !$party |
@@ -144,9 +144,15 @@ |
||
144 | 144 | $num_votes = 0; |
145 | 145 | for ( $j = 0; $j < $votes->rows(); $j++ ) { |
146 | 146 | $vote_dir = $votes->field($j, 'vote'); |
147 | - if ( $vote_dir == '' ) continue; |
|
148 | - if ( $vote_dir == 'tellno' ) $vote_dir = 'no'; |
|
149 | - if ( $vote_dir == 'tellaye' ) $vote_dir = 'aye'; |
|
147 | + if ( $vote_dir == '' ) { |
|
148 | + continue; |
|
149 | + } |
|
150 | + if ( $vote_dir == 'tellno' ) { |
|
151 | + $vote_dir = 'no'; |
|
152 | + } |
|
153 | + if ( $vote_dir == 'tellaye' ) { |
|
154 | + $vote_dir = 'aye'; |
|
155 | + } |
|
150 | 156 | |
151 | 157 | $num_votes += $votes->field($j, 'num_votes'); |
152 | 158 | $score += ($votes->field($j, 'num_votes') * $weights[$vote_dir]); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $both = 1; |
220 | 220 | $agree = 10; |
221 | 221 | |
222 | - if ( stripos($vote, '3') !== FALSE ) { |
|
222 | + if ( stripos($vote, '3') !== false ) { |
|
223 | 223 | $agree = 50; |
224 | 224 | $absent = 25; |
225 | 225 | $both = 25; |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | 'both' => $both |
231 | 231 | ); |
232 | 232 | |
233 | - if ( stripos($vote, 'aye') !== FALSE ) { |
|
233 | + if ( stripos($vote, 'aye') !== false ) { |
|
234 | 234 | $scores['aye'] = $agree; |
235 | 235 | $scores['no'] = 0; |
236 | - } else if ( stripos($vote, 'no') !== FALSE ) { |
|
236 | + } else if ( stripos($vote, 'no') !== false ) { |
|
237 | 237 | $scores['no'] = $agree; |
238 | 238 | $scores['aye'] = 0; |
239 | 239 | } else { |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | public $source; |
20 | 20 | |
21 | 21 | /** |
22 | - * To String |
|
23 | - * |
|
24 | - * Return the office title as a string. |
|
25 | - * |
|
26 | - * @return string The title of the office, or "Unnamed Office" |
|
27 | - */ |
|
22 | + * To String |
|
23 | + * |
|
24 | + * Return the office title as a string. |
|
25 | + * |
|
26 | + * @return string The title of the office, or "Unnamed Office" |
|
27 | + */ |
|
28 | 28 | |
29 | 29 | public function __toString() { |
30 | 30 | if (isset ($this->title)){ |
@@ -35,25 +35,25 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Pretty Dates |
|
39 | - * |
|
40 | - * Return a string containing prettified dates of this office. |
|
41 | - * |
|
42 | - * 2004-05-28 and 2004-05-13 are the first dates for data scraped from the |
|
43 | - * old selctee/privsec pages on parliament.uk (you can see this in |
|
44 | - * cmpages/chgpages' privsec0001_2004-06-08.html and |
|
45 | - * selctee0001_2004-06-08.html). So if the date is those dates for those two |
|
46 | - * things, you don't want to display it because it's not a known start date, |
|
47 | - * it could have been before that date. 2005-11-10 is because the PPS changes |
|
48 | - * did not all happen on that date but the website did not update until that |
|
49 | - * date so it outputs "before" in either from/to date in that case. |
|
50 | - * 2009-01-16 is the last date before the page disappeared off parliament.uk |
|
51 | - * entirely so that displays that fact that after then we don't know. |
|
52 | - * |
|
53 | - * @todo https://github.com/mysociety/theyworkforyou/issues/632 |
|
54 | - * |
|
55 | - * @return string The dates of this office in a readable form. |
|
56 | - */ |
|
38 | + * Pretty Dates |
|
39 | + * |
|
40 | + * Return a string containing prettified dates of this office. |
|
41 | + * |
|
42 | + * 2004-05-28 and 2004-05-13 are the first dates for data scraped from the |
|
43 | + * old selctee/privsec pages on parliament.uk (you can see this in |
|
44 | + * cmpages/chgpages' privsec0001_2004-06-08.html and |
|
45 | + * selctee0001_2004-06-08.html). So if the date is those dates for those two |
|
46 | + * things, you don't want to display it because it's not a known start date, |
|
47 | + * it could have been before that date. 2005-11-10 is because the PPS changes |
|
48 | + * did not all happen on that date but the website did not update until that |
|
49 | + * date so it outputs "before" in either from/to date in that case. |
|
50 | + * 2009-01-16 is the last date before the page disappeared off parliament.uk |
|
51 | + * entirely so that displays that fact that after then we don't know. |
|
52 | + * |
|
53 | + * @todo https://github.com/mysociety/theyworkforyou/issues/632 |
|
54 | + * |
|
55 | + * @return string The dates of this office in a readable form. |
|
56 | + */ |
|
57 | 57 | |
58 | 58 | public function pretty_dates() { |
59 | 59 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | |
29 | 29 | public function __toString() { |
30 | - if (isset ($this->title)){ |
|
30 | + if (isset ($this->title)) { |
|
31 | 31 | return (string) $this->title; |
32 | 32 | } else { |
33 | 33 | return 'Unnamed Office'; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function pretty_dates() { |
59 | 59 | |
60 | 60 | if ($this->to_date == '9999-12-31') { |
61 | - return 'since ' . format_date($this->from_date, SHORTDATEFORMAT); |
|
61 | + return 'since '.format_date($this->from_date, SHORTDATEFORMAT); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $output = ''; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if ($this->source == 'chgpages/privsec' && $this->from_date == '2005-11-10') { |
71 | 71 | $output .= 'before '; |
72 | 72 | } |
73 | - $output .= format_date($this->from_date,SHORTDATEFORMAT) . ' '; |
|
73 | + $output .= format_date($this->from_date, SHORTDATEFORMAT).' '; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $output .= 'to '; |
@@ -64,7 +64,7 @@ |
||
64 | 64 | $output = ''; |
65 | 65 | |
66 | 66 | if ( |
67 | - !($this->source == 'chgpages/selctee' && $this->from_date == '2004-05-28') AND |
|
67 | + !($this->source == 'chgpages/selctee' && $this->from_date == '2004-05-28') and |
|
68 | 68 | !($this->source == 'chgpages/privsec' && $this->from_date == '2004-05-13') |
69 | 69 | ) { |
70 | 70 | if ($this->source == 'chgpages/privsec' && $this->from_date == '2005-11-10') { |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace MySociety\TheyWorkForYou; |
4 | 4 | |
5 | -require_once INCLUDESPATH . "../../commonlib/phplib/random.php"; |
|
6 | -require_once INCLUDESPATH . "../../commonlib/phplib/auth.php"; |
|
5 | +require_once INCLUDESPATH."../../commonlib/phplib/random.php"; |
|
6 | +require_once INCLUDESPATH."../../commonlib/phplib/auth.php"; |
|
7 | 7 | |
8 | 8 | class MiniSurvey { |
9 | 9 | |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | if ($hide_question) { |
26 | 26 | $always_ask = 0; |
27 | 27 | $show_survey_qn = $current_question; |
28 | - setcookie('survey', $current_question, time()+60*60*24*365, '/'); |
|
28 | + setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/'); |
|
29 | 29 | } elseif ($has_answered_question == $current_question && !$always_ask) { |
30 | 30 | $show_survey_qn = $current_question; |
31 | - setcookie('survey', $current_question, time()+60*60*24*365, '/'); |
|
31 | + setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/'); |
|
32 | 32 | } elseif (isset($_COOKIE['survey'])) { |
33 | 33 | $show_survey_qn = $_COOKIE['survey']; |
34 | 34 | } |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | |
39 | 39 | $page_url = ''; |
40 | 40 | $hide_url = ''; |
41 | - if ( in_array( $this_page, array('mp', 'peer', 'msp', 'mla', 'royal') ) ) { |
|
41 | + if (in_array($this_page, array('mp', 'peer', 'msp', 'mla', 'royal'))) { |
|
42 | 42 | global $MEMBER; |
43 | - if ( $MEMBER ) { |
|
44 | - $page_url = $MEMBER->url(true) . "?answered_survey=$current_question"; |
|
45 | - $hide_url = $MEMBER->url() . "?hide_survey=$current_question"; |
|
43 | + if ($MEMBER) { |
|
44 | + $page_url = $MEMBER->url(true)."?answered_survey=$current_question"; |
|
45 | + $hide_url = $MEMBER->url()."?hide_survey=$current_question"; |
|
46 | 46 | } |
47 | 47 | } else { |
48 | 48 | $URL = new \URL($this_page); |
49 | - $URL->insert(array('answered_survey' => $current_question )); |
|
50 | - $page_url = 'https://' . DOMAIN . $URL->generate(); |
|
49 | + $URL->insert(array('answered_survey' => $current_question)); |
|
50 | + $page_url = 'https://'.DOMAIN.$URL->generate(); |
|
51 | 51 | $URL = new \URL($this_page); |
52 | - $URL->insert(array('hide_survey' => $current_question )); |
|
52 | + $URL->insert(array('hide_survey' => $current_question)); |
|
53 | 53 | $hide_url = $URL->generate(); |
54 | 54 | } |
55 | 55 |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | $searchstring = ''; |
14 | 14 | |
15 | 15 | if ($advphrase = get_http_var('phrase')) { |
16 | - $searchstring .= ' "' . $advphrase . '"'; |
|
16 | + $searchstring .= ' "'.$advphrase.'"'; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | if ($advexclude = get_http_var('exclude')) { |
20 | - $searchstring .= ' -' . join(' -', preg_split('/\s+/', $advexclude)); |
|
20 | + $searchstring .= ' -'.join(' -', preg_split('/\s+/', $advexclude)); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | return $searchstring; |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | $q = \MySociety\TheyWorkForYou\Utility\Search::searchMemberDbLookup($searchspeaker); |
82 | 82 | $pids = array(); |
83 | 83 | $row_count = $q->rows(); |
84 | - for ($i=0; $i<$row_count; $i++) { |
|
84 | + for ($i = 0; $i < $row_count; $i++) { |
|
85 | 85 | $pids[$q->field($i, 'person_id')] = true; |
86 | 86 | } |
87 | 87 | $pids = array_keys($pids); |
88 | 88 | if (count($pids) > 0) { |
89 | - $searchstring .= ' speaker:' . join(' speaker:', $pids); |
|
89 | + $searchstring .= ' speaker:'.join(' speaker:', $pids); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | $searchstring = ''; |
98 | 98 | |
99 | 99 | if ($advdept = get_http_var('department')) { |
100 | - $searchstring .= ' department:' . preg_replace('#[^a-z]#i', '', $advdept); |
|
100 | + $searchstring .= ' department:'.preg_replace('#[^a-z]#i', '', $advdept); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | if ($advparty = get_http_var('party')) { |
104 | - $searchstring .= ' party:' . join(' party:', explode(',', $advparty)); |
|
104 | + $searchstring .= ' party:'.join(' party:', explode(',', $advparty)); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $advsection = get_http_var('section'); |
108 | 108 | if (!$advsection) |
109 | 109 | $advsection = get_http_var('maj'); # Old URLs had this |
110 | 110 | if (is_array($advsection)) { |
111 | - $searchstring .= ' section:' . join(' section:', $advsection); |
|
111 | + $searchstring .= ' section:'.join(' section:', $advsection); |
|
112 | 112 | } elseif ($advsection) { |
113 | 113 | $searchstring .= " section:$advsection"; |
114 | 114 | } |
@@ -28,11 +28,17 @@ discard block |
||
28 | 28 | |
29 | 29 | if (get_http_var('from') || get_http_var('to')) { |
30 | 30 | $from = parse_date(get_http_var('from')); |
31 | - if ($from) $from = $from['iso']; |
|
32 | - else $from = '1935-10-01'; |
|
31 | + if ($from) { |
|
32 | + $from = $from['iso']; |
|
33 | + } else { |
|
34 | + $from = '1935-10-01'; |
|
35 | + } |
|
33 | 36 | $to = parse_date(get_http_var('to')); |
34 | - if ($to) $to = $to['iso']; |
|
35 | - else $to = date('Y-m-d'); |
|
37 | + if ($to) { |
|
38 | + $to = $to['iso']; |
|
39 | + } else { |
|
40 | + $to = date('Y-m-d'); |
|
41 | + } |
|
36 | 42 | $searchstring .= " $from..$to"; |
37 | 43 | } |
38 | 44 | |
@@ -105,8 +111,10 @@ discard block |
||
105 | 111 | } |
106 | 112 | |
107 | 113 | $advsection = get_http_var('section'); |
108 | - if (!$advsection) |
|
109 | - $advsection = get_http_var('maj'); # Old URLs had this |
|
114 | + if (!$advsection) { |
|
115 | + $advsection = get_http_var('maj'); |
|
116 | + } |
|
117 | + # Old URLs had this |
|
110 | 118 | if (is_array($advsection)) { |
111 | 119 | $searchstring .= ' section:' . join(' section:', $advsection); |
112 | 120 | } elseif ($advsection) { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $this->db = new \ParlDB; |
34 | 34 | |
35 | 35 | if (is_null($data)) { |
36 | - return; |
|
36 | + return; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | $this->id = $data['id']; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | private function _getContentIDs() { |
126 | 126 | $q = $this->db->query( |
127 | - "SELECT body, gid, ep.epobject_id FROM epobject ep |
|
127 | + "SELECT body, gid, ep.epobject_id FROM epobject ep |
|
128 | 128 | JOIN hansard h on ep.epobject_id = h.epobject_id |
129 | 129 | JOIN topic_epobjects te on te.epobject_id = ep.epobject_id |
130 | 130 | WHERE topic_key = :topic_key", |
@@ -180,24 +180,24 @@ discard block |
||
180 | 180 | |
181 | 181 | function addContent($gid) { |
182 | 182 | $q = $this->db->query( |
183 | - "SELECT epobject_id FROM hansard WHERE gid = :gid", |
|
184 | - array( |
|
183 | + "SELECT epobject_id FROM hansard WHERE gid = :gid", |
|
184 | + array( |
|
185 | 185 | ":gid" => $gid |
186 | - ) |
|
186 | + ) |
|
187 | 187 | ); |
188 | 188 | |
189 | 189 | if (!$q->success() || $q->rows == 0) { |
190 | - return false; |
|
190 | + return false; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | $epobject_id = $q->field(0, 'epobject_id'); |
194 | 194 | |
195 | 195 | $q = $this->db->query( |
196 | - "INSERT INTO topic_epobjects (topic_key, epobject_id) VALUES (:topic, :ep_id)", |
|
197 | - array( |
|
196 | + "INSERT INTO topic_epobjects (topic_key, epobject_id) VALUES (:topic, :ep_id)", |
|
197 | + array( |
|
198 | 198 | ":topic" => $this->id, |
199 | 199 | ":ep_id" => $epobject_id |
200 | - ) |
|
200 | + ) |
|
201 | 201 | ); |
202 | 202 | |
203 | 203 | return $q->success(); |
@@ -205,31 +205,31 @@ discard block |
||
205 | 205 | |
206 | 206 | function deleteContent($id) { |
207 | 207 | $q = $this->db->query( |
208 | - "DELETE FROM topic_epobjects WHERE topic_key = :topic AND epobject_id = :ep_id", |
|
209 | - array( |
|
208 | + "DELETE FROM topic_epobjects WHERE topic_key = :topic AND epobject_id = :ep_id", |
|
209 | + array( |
|
210 | 210 | ":topic" => $this->id, |
211 | 211 | ":ep_id" => $id |
212 | - ) |
|
212 | + ) |
|
213 | 213 | ); |
214 | 214 | |
215 | 215 | return $q->success(); |
216 | 216 | } |
217 | 217 | |
218 | 218 | function getPolicySets() { |
219 | - $q = $this->db->query( |
|
219 | + $q = $this->db->query( |
|
220 | 220 | "SELECT policyset FROM topic_policysets WHERE topic_key = :key", |
221 | 221 | array( |
222 | - ':key' => $this->id |
|
222 | + ':key' => $this->id |
|
223 | 223 | ) |
224 | - ); |
|
224 | + ); |
|
225 | 225 | |
226 | - $sets = array(); |
|
227 | - $count = $q->rows; |
|
228 | - for ($i = 0; $i < $count; $i++) { |
|
226 | + $sets = array(); |
|
227 | + $count = $q->rows; |
|
228 | + for ($i = 0; $i < $count; $i++) { |
|
229 | 229 | $sets[] = $q->field($i, 'policyset'); |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | - return $sets; |
|
232 | + return $sets; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | function addPolicySets($sets) { |
@@ -259,20 +259,20 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | function getPolicies() { |
262 | - $q = $this->db->query( |
|
262 | + $q = $this->db->query( |
|
263 | 263 | 'SELECT policy_id FROM topic_policies WHERE topic_key = :key', |
264 | 264 | array( |
265 | - ':key' => $this->id |
|
265 | + ':key' => $this->id |
|
266 | 266 | ) |
267 | - ); |
|
267 | + ); |
|
268 | 268 | |
269 | - $policies = array(); |
|
270 | - $count = $q->rows; |
|
271 | - for ($i = 0; $i < $count; $i++) { |
|
269 | + $policies = array(); |
|
270 | + $count = $q->rows; |
|
271 | + for ($i = 0; $i < $count; $i++) { |
|
272 | 272 | $policies[] = $q->field($i, 'policy_id'); |
273 | - } |
|
273 | + } |
|
274 | 274 | |
275 | - return $policies; |
|
275 | + return $policies; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | function addPolicies($policies) { |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | |
317 | 317 | function save() { |
318 | 318 | $q = $this->db->query( |
319 | - "REPLACE INTO topics |
|
319 | + "REPLACE INTO topics |
|
320 | 320 | (id, title, slug, description, search_string, front_page, image) |
321 | 321 | VALUES |
322 | 322 | (:id, :title, :slug, :description, :search_string, :front_page, :image)", |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | function sctitle() { |
55 | 55 | $title = $this->title; |
56 | - if (strpos($title, 'The ') === 0 ) { |
|
56 | + if (strpos($title, 'The ') === 0) { |
|
57 | 57 | $title = lcfirst($title); |
58 | 58 | } |
59 | 59 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | function url() { |
76 | 76 | $url = new \URL('topic'); |
77 | - return $url->generate() . $this->slug; |
|
77 | + return $url->generate().$this->slug; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | function image() { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | function image_url() { |
85 | - return "/topic/image.php?id=" . $this->slug(); |
|
85 | + return "/topic/image.php?id=".$this->slug(); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | function image_path() { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | ); |
243 | 243 | } else { |
244 | 244 | foreach ($sets as $set) { |
245 | - if ($set == '' ) { |
|
245 | + if ($set == '') { |
|
246 | 246 | continue; |
247 | 247 | } |
248 | 248 | $q = $this->db->query( |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | ); |
286 | 286 | } else { |
287 | 287 | foreach ($policies as $policy) { |
288 | - if ($policy == '' ) { |
|
288 | + if ($policy == '') { |
|
289 | 289 | continue; |
290 | 290 | } |
291 | 291 | $q = $this->db->query( |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * |
29 | 29 | */ |
30 | 30 | |
31 | - public function __construct($data = NULL) |
|
31 | + public function __construct($data = null) |
|
32 | 32 | { |
33 | 33 | $this->db = new \ParlDB; |
34 | 34 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $this_page = 'spwransfront'; |
22 | 22 | $data = array(); |
23 | 23 | |
24 | - $args = array( 'months' => 1 ); |
|
24 | + $args = array('months' => 1); |
|
25 | 25 | $WRANSLIST = new \SPWRANSLIST; |
26 | 26 | |
27 | 27 | $wrans = array(); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | protected function getSearchSections() { |
45 | 45 | return array( |
46 | - array( 'section' => 'spwrans' ) |
|
46 | + array('section' => 'spwrans') |
|
47 | 47 | ); |
48 | 48 | } |
49 | 49 | |
@@ -54,29 +54,29 @@ discard block |
||
54 | 54 | $SPWRANSLIST = new \SPWRANSLIST; |
55 | 55 | $gid = $SPWRANSLIST->get_gid_from_spid($spid); |
56 | 56 | if ($gid) { |
57 | - if (preg_match('/uk\.org\.publicwhip\/spwa\/(\d{4}-\d\d-\d\d\.(.*))/',$gid,$m)) { |
|
57 | + if (preg_match('/uk\.org\.publicwhip\/spwa\/(\d{4}-\d\d-\d\d\.(.*))/', $gid, $m)) { |
|
58 | 58 | $URL = new \URL('spwrans'); |
59 | 59 | $URL->reset(); |
60 | - $URL->insert( array('id' => $m[1]) ); |
|
61 | - $fragment_identifier = '#g' . $m[2]; |
|
62 | - header('Location: ' . $URL->generate('none') . $fragment_identifier, true, 303); |
|
60 | + $URL->insert(array('id' => $m[1])); |
|
61 | + $fragment_identifier = '#g'.$m[2]; |
|
62 | + header('Location: '.$URL->generate('none').$fragment_identifier, true, 303); |
|
63 | 63 | exit; |
64 | - } elseif (preg_match('/uk\.org\.publicwhip\/spor\/(\d{4}-\d\d-\d\d\.(.*))/',$gid,$m)) { |
|
64 | + } elseif (preg_match('/uk\.org\.publicwhip\/spor\/(\d{4}-\d\d-\d\d\.(.*))/', $gid, $m)) { |
|
65 | 65 | $URL = new \URL('spdebates'); |
66 | 66 | $URL->reset(); |
67 | - $URL->insert( array('id' => $m[1]) ); |
|
68 | - $fragment_identifier = '#g' . $m[2]; |
|
69 | - header('Location: ' . $URL->generate('none') . $fragment_identifier, true, 303); |
|
67 | + $URL->insert(array('id' => $m[1])); |
|
68 | + $fragment_identifier = '#g'.$m[2]; |
|
69 | + header('Location: '.$URL->generate('none').$fragment_identifier, true, 303); |
|
70 | 70 | exit; |
71 | 71 | } else { |
72 | - $PAGE->error_message ("Strange GID ($gid) for that Scottish Parliament ID."); |
|
72 | + $PAGE->error_message("Strange GID ($gid) for that Scottish Parliament ID."); |
|
73 | 73 | } |
74 | 74 | } |
75 | - $PAGE->error_message ("Couldn't match that Scottish Parliament ID to a GID."); |
|
75 | + $PAGE->error_message("Couldn't match that Scottish Parliament ID to a GID."); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | protected function get_question_mentions_html($row_data) { |
79 | - if( count($row_data) == 0 ) { |
|
79 | + if (count($row_data) == 0) { |
|
80 | 80 | return ''; |
81 | 81 | } |
82 | 82 | $result = ''; |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | $first_difference_output = TRUE; |
86 | 86 | // Keep the references until after the history that's in a timeline: |
87 | 87 | $references = array(); |
88 | - for( $i = 0; $i < $nrows; $i++ ) { |
|
88 | + for ($i = 0; $i < $nrows; $i++) { |
|
89 | 89 | $row = $row_data[$i]; |
90 | - if( ! $row["date"] ) { |
|
90 | + if (!$row["date"]) { |
|
91 | 91 | // If this mention isn't associated with a date, the difference won't be interesting. |
92 | 92 | $last_date = NULL; |
93 | 93 | } |
94 | 94 | $description = ''; |
95 | 95 | if ($last_date && ($last_date != $row["date"])) { |
96 | 96 | // Calculate how long the gap was in days: |
97 | - $daysdiff = (integer)((strtotime($row["date"]) - strtotime($last_date)) / 86400); |
|
97 | + $daysdiff = (integer) ((strtotime($row["date"]) - strtotime($last_date)) / 86400); |
|
98 | 98 | $daysstring = ($daysdiff == 1) ? "day" : "days"; |
99 | 99 | $further = ""; |
100 | - if( $first_difference_output ) { |
|
100 | + if ($first_difference_output) { |
|
101 | 101 | $first_difference_output = FALSE; |
102 | 102 | } else { |
103 | 103 | $further = " a further"; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $inner = "BUG: Unknown mention type $row[type]"; |
109 | 109 | $date = format_date($row['date'], SHORTDATEFORMAT); |
110 | 110 | $url = $row['url']; |
111 | - if ( strpos($url, 'business/businessBulletin') !== FALSE ) { |
|
111 | + if (strpos($url, 'business/businessBulletin') !== FALSE) { |
|
112 | 112 | $url = str_replace('www.scottish', 'archive.scottish', $url); |
113 | 113 | } |
114 | 114 | switch ($row["type"]) { |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | $inner = "Mentioned in <a class=\"debate-speech__meta__link\" href=\"$url\">tabled written questions on $date</a>"; |
123 | 123 | break; |
124 | 124 | case 4: |
125 | - if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['gid'],$m) ) { |
|
125 | + if (preg_match('/^uk.org.publicwhip\/spq\/(.*)$/', $row['gid'], $m)) { |
|
126 | 126 | $URL = new \URL("spwrans"); |
127 | - $URL->insert( array('spid' => $m[1]) ); |
|
127 | + $URL->insert(array('spid' => $m[1])); |
|
128 | 128 | $relative_url = $URL->generate("none"); |
129 | 129 | $inner = "Given a <a class=\"debate-speech__meta__link\" href=\"$relative_url\">written answer on $date</a>"; |
130 | 130 | } |
@@ -133,25 +133,25 @@ discard block |
||
133 | 133 | $inner = "Given a holding answer on $date"; |
134 | 134 | break; |
135 | 135 | case 6: |
136 | - if( preg_match('/^uk.org.publicwhip\/spor\/(.*)$/',$row['mentioned_gid'],$m) ) { |
|
136 | + if (preg_match('/^uk.org.publicwhip\/spor\/(.*)$/', $row['mentioned_gid'], $m)) { |
|
137 | 137 | $URL = new \URL("spdebates"); |
138 | - $URL->insert( array('id' => $m[1]) ); |
|
138 | + $URL->insert(array('id' => $m[1])); |
|
139 | 139 | $relative_url = $URL->generate("none"); |
140 | 140 | $inner = "<a href=\"$relative_url\">Asked in parliament on $date</a>"; |
141 | 141 | } |
142 | 142 | break; |
143 | 143 | case 7: |
144 | - if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['mentioned_gid'],$m) ) { |
|
144 | + if (preg_match('/^uk.org.publicwhip\/spq\/(.*)$/', $row['mentioned_gid'], $m)) { |
|
145 | 145 | $referencing_spid = $m[1]; |
146 | 146 | $URL = new \URL("spwrans"); |
147 | - $URL->insert( array('spid' => $referencing_spid) ); |
|
147 | + $URL->insert(array('spid' => $referencing_spid)); |
|
148 | 148 | $relative_url = $URL->generate("none"); |
149 | 149 | $inner = "Referenced in <a href=\"$relative_url\">question $referencing_spid</a>"; |
150 | 150 | $reference = TRUE; |
151 | 151 | } |
152 | 152 | break; |
153 | 153 | } |
154 | - if( $reference ) { |
|
154 | + if ($reference) { |
|
155 | 155 | $references[] = "\n<li>$inner."; |
156 | 156 | } else { |
157 | 157 | $result .= "\n<li class=\"link-to-hansard\">$description$inner</span>"; |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | } |
82 | 82 | $result = ''; |
83 | 83 | $nrows = count($row_data); |
84 | - $last_date = NULL; |
|
85 | - $first_difference_output = TRUE; |
|
84 | + $last_date = null; |
|
85 | + $first_difference_output = true; |
|
86 | 86 | // Keep the references until after the history that's in a timeline: |
87 | 87 | $references = array(); |
88 | 88 | for( $i = 0; $i < $nrows; $i++ ) { |
89 | 89 | $row = $row_data[$i]; |
90 | 90 | if( ! $row["date"] ) { |
91 | 91 | // If this mention isn't associated with a date, the difference won't be interesting. |
92 | - $last_date = NULL; |
|
92 | + $last_date = null; |
|
93 | 93 | } |
94 | 94 | $description = ''; |
95 | 95 | if ($last_date && ($last_date != $row["date"])) { |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | $daysstring = ($daysdiff == 1) ? "day" : "days"; |
99 | 99 | $further = ""; |
100 | 100 | if( $first_difference_output ) { |
101 | - $first_difference_output = FALSE; |
|
101 | + $first_difference_output = false; |
|
102 | 102 | } else { |
103 | 103 | $further = " a further"; |
104 | 104 | } |
105 | 105 | $description = "\n<span class=\"question-mention-gap\">After$further $daysdiff $daysstring,</span> "; |
106 | 106 | } |
107 | - $reference = FALSE; |
|
107 | + $reference = false; |
|
108 | 108 | $inner = "BUG: Unknown mention type $row[type]"; |
109 | 109 | $date = format_date($row['date'], SHORTDATEFORMAT); |
110 | 110 | $url = $row['url']; |
111 | - if ( strpos($url, 'business/businessBulletin') !== FALSE ) { |
|
111 | + if ( strpos($url, 'business/businessBulletin') !== false ) { |
|
112 | 112 | $url = str_replace('www.scottish', 'archive.scottish', $url); |
113 | 113 | } |
114 | 114 | switch ($row["type"]) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $URL->insert( array('spid' => $referencing_spid) ); |
148 | 148 | $relative_url = $URL->generate("none"); |
149 | 149 | $inner = "Referenced in <a href=\"$relative_url\">question $referencing_spid</a>"; |
150 | - $reference = TRUE; |
|
150 | + $reference = true; |
|
151 | 151 | } |
152 | 152 | break; |
153 | 153 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | protected function getSearchSections() { |
26 | 26 | return array( |
27 | - array( 'section' => 'sp' ) |
|
27 | + array('section' => 'sp') |
|
28 | 28 | ); |
29 | 29 | } |
30 | 30 | } |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | |
13 | 13 | protected function display_front() { |
14 | 14 | global $DATA, $this_page; |
15 | - if ( get_http_var('type') == 'wrans') { |
|
15 | + if (get_http_var('type') == 'wrans') { |
|
16 | 16 | return parent::display_front(); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $data = array(); |
20 | 20 | |
21 | - $args = array( 'months' => 1 ); |
|
21 | + $args = array('months' => 1); |
|
22 | 22 | $WRANSLIST = new \WRANSLIST; |
23 | 23 | |
24 | 24 | $wrans = array(); |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | |
51 | 51 | protected function getSearchSections() { |
52 | 52 | $sections = array( |
53 | - array( 'section' => 'wrans', 'title' => 'Written Answers' ), |
|
53 | + array('section' => 'wrans', 'title' => 'Written Answers'), |
|
54 | 54 | ); |
55 | - if ( get_http_var('type') == '') { |
|
56 | - $sections[] = array( 'section' => 'wms', 'title' => 'Written Ministerial Statements' ); |
|
55 | + if (get_http_var('type') == '') { |
|
56 | + $sections[] = array('section' => 'wms', 'title' => 'Written Ministerial Statements'); |
|
57 | 57 | } |
58 | 58 | return $sections; |
59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | # speech bar the first (assuming that's the question) |
63 | 63 | private $votelinks_so_far = 0; |
64 | 64 | |
65 | - protected function generate_votes ($votes, $id, $gid) { |
|
65 | + protected function generate_votes($votes, $id, $gid) { |
|
66 | 66 | /* |
67 | 67 | Returns HTML for the 'Does this answer the question?' links (wrans) in the sidebar. |
68 | 68 | $votes = => array ( |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | |
43 | 43 | if ($bill_id && $id) { |
44 | 44 | return $this->display_section_or_speech(array( |
45 | - 'gid' => $standingprefix . $id, |
|
45 | + 'gid' => $standingprefix.$id, |
|
46 | 46 | )); |
47 | 47 | } elseif ($bill_id) { |
48 | 48 | # Display the page for a particular bill |
49 | 49 | $this_page = 'pbc_bill'; |
50 | - $args = array ( |
|
50 | + $args = array( |
|
51 | 51 | 'id' => $bill_id, |
52 | 52 | 'title' => $this->bill, |
53 | 53 | 'session' => $this->session, |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | } elseif ($this->session && $this->bill) { |
61 | 61 | # Illegal bill title, redirect to session page |
62 | 62 | $URL = new \URL('pbc_session'); |
63 | - header('Location: ' . $URL->generate() . urlencode($this->session)); |
|
63 | + header('Location: '.$URL->generate().urlencode($this->session)); |
|
64 | 64 | exit; |
65 | 65 | } elseif ($this->session) { |
66 | 66 | # Display the bills for a particular session |
67 | 67 | $this_page = 'pbc_session'; |
68 | 68 | $DATA->set_page_metadata($this_page, 'title', "Session $this->session"); |
69 | - $args = array ( |
|
69 | + $args = array( |
|
70 | 70 | 'session' => $this->session, |
71 | 71 | ); |
72 | 72 | $data = array(); |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | |
89 | 89 | protected function getSearchSections() { |
90 | 90 | return array( |
91 | - array( 'section' => 'pbc' ) |
|
91 | + array('section' => 'pbc') |
|
92 | 92 | ); |
93 | 93 | } |
94 | 94 | |
95 | 95 | protected function front_content() { |
96 | - return $this->list->display( 'recent_pbc_debates', array( 'num' => 50 ), 'none' ); |
|
96 | + return $this->list->display('recent_pbc_debates', array('num' => 50), 'none'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | protected function display_front() { |
@@ -65,7 +65,7 @@ |
||
65 | 65 | } elseif ($this->session) { |
66 | 66 | # Display the bills for a particular session |
67 | 67 | $this_page = 'pbc_session'; |
68 | - $DATA->set_page_metadata($this_page, 'title', "Session $this->session"); |
|
68 | + $DATA->set_page_metadata($this_page, 'title', "session $this->session"); |
|
69 | 69 | $args = array ( |
70 | 70 | 'session' => $this->session, |
71 | 71 | ); |