Completed
Pull Request — master (#1322)
by Nick
11:36 queued 06:31
created
www/includes/easyparliament/people.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
         $this->db = new ParlDB;
15 15
     }
16 16
 
17
-    public function display ($view, $args=array(), $format='html') {
17
+    public function display($view, $args = array(), $format = 'html') {
18 18
         global $PAGE;
19 19
 
20 20
         $validviews = array('mps', 'peers', 'mlas', 'msps');
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
         if (in_array($view, $validviews)) {
23 23
 
24 24
             // What function do we call for this view?
25
-            $function = '_get_data_by_'.$view;
25
+            $function = '_get_data_by_' . $view;
26 26
 
27 27
             // Get all the data that's to be rendered.
28 28
             $data = $this->$function($args);
29 29
 
30 30
         } else {
31
-            $PAGE->error_message ("You haven't specified a view type.");
31
+            $PAGE->error_message("You haven't specified a view type.");
32 32
             return false;
33 33
         }
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 
41 41
 
42
-    public function render($view, $data, $format='html') {
42
+    public function render($view, $data, $format = 'html') {
43 43
         // Once we have the data that's to be rendered,
44 44
         // include the template.
45 45
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         }
50 50
 
51 51
         //This should really be a single template? (rjp)
52
-        include (INCLUDESPATH."easyparliament/templates/$format/people_$view" . ".php");
52
+        include (INCLUDESPATH . "easyparliament/templates/$format/people_$view" . ".php");
53 53
         return true;
54 54
 
55 55
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         $q = $this->db->query($query . "ORDER BY $sqlorder", $params);
132 132
 
133 133
         $data = array();
134
-        for ($row=0; $row<$q->rows(); $row++) {
134
+        for ($row = 0; $row < $q->rows(); $row++) {
135 135
             $p_id = $q->field($row, 'person_id');
136 136
             $dept = $q->field($row, 'dept');
137 137
             $pos = $q->field($row, 'position');
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                     $q->field($row, 'lordofname'));
145 145
                 $constituency = $q->field($row, 'constituency');
146 146
                 $url = make_member_url($name, $constituency, $args['house'], $p_id);
147
-                $narray = array (
147
+                $narray = array(
148 148
                     'person_id' 	=> $p_id,
149 149
                     'given_name' => $q->field($row, 'given_name'),
150 150
                     'family_name' => $q->field($row, 'family_name'),
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
         if ($args['house'] == 2 && ($order == 'name' || $order == 'constituency'))
178 178
             uasort($data, array($this, 'by_peer_name'));
179 179
 
180
-        $data = array (
181
-            'info' => array (
180
+        $data = array(
181
+            'info' => array(
182 182
                 'order' => $order
183 183
             ),
184 184
             'data' => $data
Please login to merge, or discard this patch.
Braces   +39 added lines, -24 removed lines patch added patch discarded remove patch
@@ -27,7 +27,8 @@  discard block
 block discarded – undo
27 27
             // Get all the data that's to be rendered.
28 28
             $data = $this->$function($args);
29 29
 
30
-        } else {
30
+        }
31
+        else {
31 32
             $PAGE->error_message ("You haven't specified a view type.");
32 33
             return false;
33 34
         }
@@ -100,30 +101,37 @@  discard block
 block discarded – undo
100 101
         if (isset($args['date'])) {
101 102
             $query .= 'AND from_date <= :date AND :date <= to_date ';
102 103
             $params[':date'] = $args['date'];
103
-        } else {
104
+        }
105
+        else {
104 106
             $query .= 'AND to_date="9999-12-31" ';
105 107
         }
106 108
         if ($use_personinfo) {
107 109
             $query .= 'LEFT OUTER JOIN personinfo ON member.person_id = personinfo.person_id AND data_key="' . $personinfo_key . '" ';
108 110
         }
109 111
         $query .= ' JOIN person_names p ON p.person_id = member.person_id AND p.type = "name" ';
110
-        if (isset($args['date']))
111
-            $query .= 'AND start_date <= :date AND :date <= end_date ';
112
-        else
113
-            $query .= 'AND end_date="9999-12-31" ';
112
+        if (isset($args['date'])) {
113
+                    $query .= 'AND start_date <= :date AND :date <= end_date ';
114
+        }
115
+        else {
116
+                    $query .= 'AND end_date="9999-12-31" ';
117
+        }
114 118
         $query .= 'WHERE house=' . $args['house'] . ' ';
115
-        if (isset($args['date']))
116
-            $query .= 'AND entered_house <= :date AND :date <= left_house ';
117
-        elseif (!isset($args['all']) || $args['house'] == 1)
118
-            $query .= 'AND left_house = (SELECT MAX(left_house) FROM member) ';
119
+        if (isset($args['date'])) {
120
+                    $query .= 'AND entered_house <= :date AND :date <= left_house ';
121
+        }
122
+        elseif (!isset($args['all']) || $args['house'] == 1) {
123
+                    $query .= 'AND left_house = (SELECT MAX(left_house) FROM member) ';
124
+        }
119 125
 
120 126
         if (isset($args['order'])) {
121 127
             $order = $args['order'];
122 128
             if ($args['order'] == 'given_name') {
123 129
                 $sqlorder = 'given_name, family_name';
124
-            } elseif ($args['order'] == 'constituency') {
130
+            }
131
+            elseif ($args['order'] == 'constituency') {
125 132
                 $sqlorder = 'constituency';
126
-            } elseif ($args['order'] == 'party') {
133
+            }
134
+            elseif ($args['order'] == 'party') {
127 135
                 $sqlorder = 'party, family_name, given_name, constituency';
128 136
             }
129 137
         }
@@ -138,7 +146,8 @@  discard block
 block discarded – undo
138 146
             if (isset($data[$p_id])) {
139 147
                 $data[$p_id]['dept'] = array_merge((array) $data[$p_id]['dept'], (array) $dept);
140 148
                 $data[$p_id]['pos'] = array_merge((array) $data[$p_id]['pos'], (array) $pos);
141
-            } else {
149
+            }
150
+            else {
142 151
                 $name = member_full_name($args['house'], $q->field($row, 'title'),
143 152
                     $q->field($row, 'given_name'), $q->field($row, 'family_name'),
144 153
                     $q->field($row, 'lordofname'));
@@ -165,7 +174,8 @@  discard block
 block discarded – undo
165 174
                     $narray['party'] = '-';
166 175
                     $narray['pos'] = 'Speaker';
167 176
                     $narray['dept'] = 'House of Commons';
168
-                } elseif ($narray['party'] == 'CWM' || $narray['party'] == 'DCWM') {
177
+                }
178
+                elseif ($narray['party'] == 'CWM' || $narray['party'] == 'DCWM') {
169 179
                     $narray['party'] = '-';
170 180
                     $narray['pos'] = 'Deputy Speaker';
171 181
                     $narray['dept'] = 'House of Commons';
@@ -174,8 +184,9 @@  discard block
 block discarded – undo
174 184
                 $data[$p_id] = $narray;
175 185
             }
176 186
         }
177
-        if ($args['house'] == 2 && ($order == 'name' || $order == 'constituency'))
178
-            uasort($data, array($this, 'by_peer_name'));
187
+        if ($args['house'] == 2 && ($order == 'name' || $order == 'constituency')) {
188
+                    uasort($data, array($this, 'by_peer_name'));
189
+        }
179 190
 
180 191
         $data = array (
181 192
             'info' => array (
@@ -188,14 +199,18 @@  discard block
 block discarded – undo
188 199
 
189 200
     }
190 201
     public function by_peer_name($a, $b) {
191
-        if (!$a['family_name'] && !$b['family_name'])
192
-            return strcmp($a['lordofname'], $b['lordofname']);
193
-        if (!$a['family_name'])
194
-            return strcmp($a['lordofname'], $b['family_name']);
195
-        if (!$b['family_name'])
196
-            return strcmp($a['family_name'], $b['lordofname']);
197
-        if (strcmp($a['family_name'], $b['family_name']))
198
-            return strcmp($a['family_name'], $b['family_name']);
202
+        if (!$a['family_name'] && !$b['family_name']) {
203
+                    return strcmp($a['lordofname'], $b['lordofname']);
204
+        }
205
+        if (!$a['family_name']) {
206
+                    return strcmp($a['lordofname'], $b['family_name']);
207
+        }
208
+        if (!$b['family_name']) {
209
+                    return strcmp($a['family_name'], $b['lordofname']);
210
+        }
211
+        if (strcmp($a['family_name'], $b['family_name'])) {
212
+                    return strcmp($a['family_name'], $b['family_name']);
213
+        }
199 214
         return strcmp($a['lordofname'], $b['lordofname']);
200 215
     }
201 216
 
Please login to merge, or discard this patch.
www/includes/easyparliament/recess.php 2 patches
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@  discard block
 block discarded – undo
12 12
     ),
13 13
     2001 => array(
14 14
         1=>array('less'=>8),
15
-        2=>array('between'=>array(15,26)),
16
-        4=>array('between'=>array(10,23)),
15
+        2=>array('between'=>array(15, 26)),
16
+        4=>array('between'=>array(10, 23)),
17 17
         5=>array('more'=>13),
18 18
         6=>array('less'=>13),
19 19
         7=>array('more'=>20),
20 20
         8=>array('all'=>1),
21 21
         9=>array('less'=>14, 'more'=>14),
22
-        10=>array('less'=>4, 'between'=>array(4,8, 8,15)),
22
+        10=>array('less'=>4, 'between'=>array(4, 8, 8, 15)),
23 23
         12=>array('more'=>19) ),
24 24
     2002 => array(
25 25
         1=>array('less'=>8),
26
-        2=>array('between'=>array(14,25)),
26
+        2=>array('between'=>array(14, 25)),
27 27
         3=>array('more'=>26),
28
-        4=>array('less'=>3, 'between'=>array(3,10)),
28
+        4=>array('less'=>3, 'between'=>array(3, 10)),
29 29
         5=>array('more'=>24),
30 30
         6=>array('less'=>10),
31 31
         7=>array('more'=>24),
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
         12=>array('more'=>19) ),
36 36
     2003 => array(
37 37
         1=>array('less'=>7),
38
-        2=>array('between'=>array(13,24)),
39
-        4=>array('between'=>array(14,28)),
38
+        2=>array('between'=>array(13, 24)),
39
+        4=>array('between'=>array(14, 28)),
40 40
         5=>array('more'=>22),
41 41
         6=>array('less'=>3),
42 42
         7=>array('more'=>17),
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
         12=>array('more'=>18)),
47 47
     2004 => array(
48 48
         1=>array('less'=>5),
49
-        2=>array('between'=>array(12,23)),
50
-        4=>array('between'=>array(1,19)),
49
+        2=>array('between'=>array(12, 23)),
50
+        4=>array('between'=>array(1, 19)),
51 51
         5=>array('more'=>27),
52 52
         6=>array('less'=>7),
53 53
         7=>array('more'=>22),
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         12=>array('more'=>21) ),
58 58
     2005 => array(
59 59
         1=>array('less'=>10),
60
-        2=>array('between'=>array(10,21)),
60
+        2=>array('between'=>array(10, 21)),
61 61
         3=>array('more'=>24),
62 62
         4=>array('less'=>4, 'more'=>10),
63 63
         5=>array('less'=>11, 'more'=>26),
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         12=>array('more'=>20) ),
70 70
     2006 => array(
71 71
         1=>array('less'=>9),
72
-        2=>array('between'=>array(16,27)),
72
+        2=>array('between'=>array(16, 27)),
73 73
         3=>array('more'=>30),
74 74
         4=>array('less'=>18),
75 75
         5=>array('more'=>25),
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     ),
83 83
     2007 => array(
84 84
         1=>array('less'=>8),
85
-        2=>array('between'=>array(8,19)),
85
+        2=>array('between'=>array(8, 19)),
86 86
         3=>array('more'=>29),
87 87
         4=>array('less'=>16),
88 88
         5=>array('more'=>24),
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
     ),
96 96
     2008 => array(
97 97
         1=>array('less'=>7),
98
-        2=>array('between'=>array(7,18)),
99
-        4=>array('between'=>array(3,21)),
98
+        2=>array('between'=>array(7, 18)),
99
+        4=>array('between'=>array(3, 21)),
100 100
         5=>array('more'=>22),
101 101
         6=>array('less'=>2),
102 102
         7=>array('more'=>22),
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
     ),
108 108
     2009 => array(
109 109
         1=>array('less'=>12),
110
-        2=>array('between'=>array(12,23)),
111
-        4=>array('between'=>array(2,20)),
110
+        2=>array('between'=>array(12, 23)),
111
+        4=>array('between'=>array(2, 20)),
112 112
         5=>array('more'=>21),
113 113
         6=>array('less'=>1),
114 114
         7=>array('more'=>21),
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     ),
120 120
     2010 => array(
121 121
         1=>array('less'=>5),
122
-        2=>array('between'=>array(10,22)),
122
+        2=>array('between'=>array(10, 22)),
123 123
         3=>array('more'=>30),
124 124
         4=>array('less'=>6, 'more'=>8),
125 125
         5=>array('less'=>18, 'more'=>27),
@@ -132,62 +132,62 @@  discard block
 block discarded – undo
132 132
     ),
133 133
     2011 => array(
134 134
         1=>array('less'=>10),
135
-        2=>array('between'=>array(17,28)),
136
-        4=>array('between'=>array(5,26)),
135
+        2=>array('between'=>array(17, 28)),
136
+        4=>array('between'=>array(5, 26)),
137 137
         5=>array('more'=>24),
138 138
         6=>array('less'=>7),
139 139
         7=>array('more'=>19),
140 140
         8=>array('all'=>1),
141 141
         9=>array('less'=>5, 'more'=>15),
142 142
         10=>array('less'=>10),
143
-        11=>array('between'=>array(15,21)),
143
+        11=>array('between'=>array(15, 21)),
144 144
         12=>array('more'=>20),
145 145
     ),
146 146
     2012 => array(
147 147
         1=>array('less'=>10),
148
-        2=>array('between'=>array(9,20)),
148
+        2=>array('between'=>array(9, 20)),
149 149
         3=>array('more'=>27),
150 150
         4=>array('less'=>16),
151 151
         5=>array('more'=>24),
152 152
         6=>array('less'=>11),
153 153
         7=>array('more'=>17),
154 154
         8=>array('all'=>1),
155
-        9=>array('less'=>3,'more'=>18),
155
+        9=>array('less'=>3, 'more'=>18),
156 156
         10=>array('less'=>15),
157
-        11=>array('between'=>array(13,19)),
157
+        11=>array('between'=>array(13, 19)),
158 158
         12=>array('more'=>20)
159 159
     ),
160 160
     2013 => array(
161 161
         1=>array('less'=>7),
162
-        2=>array('between'=>array(14,25)),
162
+        2=>array('between'=>array(14, 25)),
163 163
         3=>array('more'=>26),
164 164
         4=>array('less'=>15),
165 165
         5=>array('more'=>21),
166 166
         6=>array('less'=>3),
167 167
         7=>array('more'=>18),
168 168
         8=>array('all'=>1),
169
-        9=>array('less'=>2,'more'=>13),
169
+        9=>array('less'=>2, 'more'=>13),
170 170
         10=>array('less'=>8),
171
-        11=>array('between'=>array(12,18)),
171
+        11=>array('between'=>array(12, 18)),
172 172
         12=>array('more'=>19)
173 173
     ),
174 174
     2014 => array(
175 175
         1=>array('less'=>6),
176
-        2=>array('between'=>array(13,24)),
177
-        4=>array('between'=>array(10,28)),
178
-        5=>array('between'=>array(1,6))
176
+        2=>array('between'=>array(13, 24)),
177
+        4=>array('between'=>array(10, 28)),
178
+        5=>array('between'=>array(1, 6))
179 179
     ),
180 180
     2015 => array(
181 181
         7=>array('more'=>21),
182 182
         8=>array('all'=>1),
183 183
         9=>array('less'=>7, 'more'=>17),
184 184
         10=>array('less'=>12),
185
-        11=>array('between'=>array(10,16)),
185
+        11=>array('between'=>array(10, 16)),
186 186
         12=>array('more'=>17)
187 187
     ),
188 188
     2016 => array(
189 189
         1=>array('less'=>5),
190
-        2=>array('between'=>array(11,22))
190
+        2=>array('between'=>array(11, 22))
191 191
     )
192 192
 );
193 193
 # Lords differences
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
 $GLOBALS['recessdates'][101][2010][12]['more'] = 22;
200 200
 $GLOBALS['recessdates'][101][2011] = array(
201 201
     1 => array('less'=>10),
202
-    2 => array('between'=>array(16,28)),
203
-    4 => array('between'=>array(6,26)),
202
+    2 => array('between'=>array(16, 28)),
203
+    4 => array('between'=>array(6, 26)),
204 204
     5 => array('more'=>25),
205 205
     6 => array('less'=>6),
206 206
     7 => array('more'=>20),
207 207
     8 => array('all'=>1),
208 208
     9 => array('less'=>5, 'more'=>15),
209 209
     10 => array('less'=>3),
210
-    11=>array('between'=>array(16,21)),
210
+    11=>array('between'=>array(16, 21)),
211 211
     12 => array('more'=>21),
212 212
 );
213 213
 
@@ -216,74 +216,74 @@  discard block
 block discarded – undo
216 216
     1999 => array(
217 217
         7 => array('more' => 2),
218 218
         8 => array('less' => 31),
219
-        10 => array('between' => array(8,25)),
219
+        10 => array('between' => array(8, 25)),
220 220
         12 => array('more' => 17)
221 221
     ),
222 222
     2000 => array(
223 223
         1 => array('less' => 10),
224
-        4 => array('between' => array(7,25)),
224
+        4 => array('between' => array(7, 25)),
225 225
         7 => array('more' => 7),
226 226
         8 => array('all' => 1),
227 227
         9 => array('less' => 4),
228
-        10 => array('between' => array(6,23)),
228
+        10 => array('between' => array(6, 23)),
229 229
         12 => array('more' => 20)
230 230
     ),
231 231
     2001 => array(
232 232
         1=>array('less'=>8),
233
-        2=>array('between'=>array(16,26)),
234
-        4=>array('between'=>array(6,23)),
233
+        2=>array('between'=>array(16, 26)),
234
+        4=>array('between'=>array(6, 23)),
235 235
         6=>array('more'=>29),
236 236
         7=>array('all'=>1),
237 237
         8=>array('all'=>1),
238 238
         9=>array('less'=>3),
239
-        10=>array('between'=>array(5,22)),
239
+        10=>array('between'=>array(5, 22)),
240 240
         12=>array('more'=>21) ),
241 241
     2002 => array(
242 242
         1=>array('less'=>7),
243
-        2=>array('between'=>array(15,25)),
243
+        2=>array('between'=>array(15, 25)),
244 244
         3=>array('more'=>28),
245 245
         4=>array('less'=>15),
246 246
         7=>array('more'=>10),
247 247
         8=>array('all'=>1),
248 248
         9=>array('less'=>2),
249
-        10=>array('between'=>array(11,28)),
249
+        10=>array('between'=>array(11, 28)),
250 250
         12=>array('more'=>20) ),
251 251
     2003 => array(
252 252
         1=>array('less'=>6),
253
-        4=>array('between'=>array(0,31)),
253
+        4=>array('between'=>array(0, 31)),
254 254
         5=>array('less'=>2),
255 255
         6=>array('more'=>27),
256 256
         7=>array('all'=>1),
257 257
         8=>array('all'=>1),
258
-        10=>array('between'=>array(10,27)),
258
+        10=>array('between'=>array(10, 27)),
259 259
         12=>array('more'=>19)),
260 260
     2004 => array(
261 261
         1=>array('less'=>5),
262
-        2=>array('between'=>array(13,23)),
263
-        4=>array('between'=>array(2,19)),
262
+        2=>array('between'=>array(13, 23)),
263
+        4=>array('between'=>array(2, 19)),
264 264
         6=>array('more'=>25),
265 265
         7=>array('all'=>1),
266 266
         8=>array('less'=>30),
267
-        10=>array('between'=>array(10,23)),
267
+        10=>array('between'=>array(10, 23)),
268 268
         12=>array('more'=>26) ),
269 269
     2005 => array(
270 270
         1=>array('less'=>8),
271
-        2=>array('between'=>array(11,21)),
271
+        2=>array('between'=>array(11, 21)),
272 272
         3=>array('more'=>24),
273 273
         4=>array('less'=>11),
274 274
         7=>array('more'=>1),
275 275
         8=>array('all'=>1),
276 276
         9=>array('less'=>5),
277
-        10=>array('between'=>array(7,24)),
277
+        10=>array('between'=>array(7, 24)),
278 278
         12=>array('more'=>23) ),
279 279
     2006 => array(
280 280
         1=>array('less'=>9),
281
-        2=>array('between'=>array(10,20)),
281
+        2=>array('between'=>array(10, 20)),
282 282
         4=>array('less'=>18),
283 283
         7=>array('more'=>0),
284 284
         8=>array('all'=>1),
285 285
         9=>array('less'=>4),
286
-        10=>array('between'=>array(6,23)),
286
+        10=>array('between'=>array(6, 23)),
287 287
         12=>array('more'=>22),
288 288
     ),
289 289
     2007 => array(
@@ -293,18 +293,18 @@  discard block
 block discarded – undo
293 293
         7=>array('all'=>1),
294 294
         8=>array('all'=>1),
295 295
         9=>array('less'=>3),
296
-        10=>array('between'=>array(5,22)),
296
+        10=>array('between'=>array(5, 22)),
297 297
         12=>array('more'=>21),
298 298
     ),
299 299
     2008 => array(
300 300
         1=>array('less'=>5),
301
-        2=>array('between'=>array(8,18)),
301
+        2=>array('between'=>array(8, 18)),
302 302
         3=>array('more'=>28),
303 303
         4=>array('less'=>14),
304 304
         6=>array('more'=>27),
305 305
         7=>array('all'=>1),
306 306
         8=>array('all'=>1),
307
-        10=>array('between'=>array(10,27)),
307
+        10=>array('between'=>array(10, 27)),
308 308
     ),
309 309
 );
310 310
 
@@ -369,39 +369,39 @@  discard block
 block discarded – undo
369 369
         else
370 370
             $to = "$year-9-" . $dates[$year][9]['less'];
371 371
     }
372
-    if ( (isset($dates[$year][$month]['less']) && $day < $dates[$year][$month]['less'])
372
+    if ((isset($dates[$year][$month]['less']) && $day < $dates[$year][$month]['less'])
373 373
     || (isset($dates[$year][$month]['more']) && $day > $dates[$year][$month]['more'])
374 374
     || (isset($dates[$year][$month]['between']) && $day > $dates[$year][$month]['between'][0] && $day < $dates[$year][$month]['between'][1])
375
-    || (isset($dates[$year][$month]['between'][2]) && $day > $dates[$year][$month]['between'][2] && $day < $dates[$year][$month]['between'][3]) ) {
375
+    || (isset($dates[$year][$month]['between'][2]) && $day > $dates[$year][$month]['between'][2] && $day < $dates[$year][$month]['between'][3])) {
376 376
         switch ($month) {
377 377
             case 1: case 12: $recess = 'Christmas Recess'; break;
378
-            case 2: if ($body==1 || $body==101) $recess = 'Half Term Week';
379
-                elseif ($body==4) $recess = 'February Recess';
378
+            case 2: if ($body == 1 || $body == 101) $recess = 'Half Term Week';
379
+                elseif ($body == 4) $recess = 'February Recess';
380 380
                 break;
381
-            case 3: if ($body==1 || $body==101) $recess = 'Easter Recess';
382
-                elseif ($body==4) $recess = 'Spring Recess';
381
+            case 3: if ($body == 1 || $body == 101) $recess = 'Easter Recess';
382
+                elseif ($body == 4) $recess = 'Spring Recess';
383 383
                 break;
384 384
             case 4: if (isset($dates[$year][$month]['more']) && $day > $dates[$year][$month]['more']) {
385 385
                     $recess = 'Election Recess';
386
-                } elseif ($body==4 && $year==2003) {
386
+                } elseif ($body == 4 && $year == 2003) {
387 387
                     $recess = 'Election Recess';
388
-                } elseif ($body==1 || $body==101) {
388
+                } elseif ($body == 1 || $body == 101) {
389 389
                     $recess = 'Easter Recess';
390
-                } elseif ($body==4) {
390
+                } elseif ($body == 4) {
391 391
                     $recess = 'Spring Recess';
392 392
                 }
393 393
                 break;
394
-            case 5: if ($year==2001 || (isset($dates[$year][$month]['less']) && $day < $dates[$year][$month]['less'])) {
394
+            case 5: if ($year == 2001 || (isset($dates[$year][$month]['less']) && $day < $dates[$year][$month]['less'])) {
395 395
                     $recess = 'Election Recess';
396 396
                 } else {
397 397
                     $recess = 'Whit Recess';
398 398
                 }
399 399
                 break;
400
-            case 6: if ($year==2001) {
400
+            case 6: if ($year == 2001) {
401 401
                     $recess = 'Election Recess';
402
-                } elseif ($body==1 || $body==101) {
402
+                } elseif ($body == 1 || $body == 101) {
403 403
                     $recess = 'Whit Recess';
404
-                } elseif ($body==4) {
404
+                } elseif ($body == 4) {
405 405
                     $recess = 'Summer Recess';
406 406
                 } else {
407 407
                     trigger_error("Argh6");
@@ -411,15 +411,15 @@  discard block
 block discarded – undo
411 411
                 break;
412 412
             case 9: if (isset($dates[$year][$month]['less']) && $day < $dates[$year][$month]['less']) {
413 413
                     $recess = 'Summer Recess';
414
-                } elseif ($body==1 || $body==101) {
414
+                } elseif ($body == 1 || $body == 101) {
415 415
                     $recess = 'Conference Recess';
416 416
                 } else {
417 417
                     trigger_error("Argh9");
418 418
                 }
419 419
                 break;
420
-            case 10: if ($body==1 || $body==101) $recess = 'Conference Recess';
421
-                elseif ($body==4) $recess = 'Autumn Recess';
422
-                elseif ($body==5) $recess = 'Halloween Recess';
420
+            case 10: if ($body == 1 || $body == 101) $recess = 'Conference Recess';
421
+                elseif ($body == 4) $recess = 'Autumn Recess';
422
+                elseif ($body == 5) $recess = 'Halloween Recess';
423 423
                 break;
424 424
             case 11: $recess = 'Autumn Recess';
425 425
                 break;
@@ -427,12 +427,12 @@  discard block
 block discarded – undo
427 427
         }
428 428
         if (isset($dates[$year][$month]['less']) && $day < $dates[$year][$month]['less']) {
429 429
             $to = "$year-$month-" . $dates[$year][$month]['less'];
430
-            if ($month==1)
431
-                $from = ($year-1)."-12-" . $dates[$year-1][12]['more'];
430
+            if ($month == 1)
431
+                $from = ($year - 1) . "-12-" . $dates[$year - 1][12]['more'];
432 432
             else {
433
-                for ($newmonth = $month-1; $newmonth>=1; $newmonth--) {
433
+                for ($newmonth = $month - 1; $newmonth >= 1; $newmonth--) {
434 434
                     if (isset($dates[$year][$newmonth]['more'])) {
435
-                        $from = "$year-".($newmonth)."-" . $dates[$year][$newmonth]['more'];
435
+                        $from = "$year-" . ($newmonth) . "-" . $dates[$year][$newmonth]['more'];
436 436
                         break;
437 437
                     }
438 438
                 }
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
         }
441 441
         if (isset($dates[$year][$month]['more']) && $day > $dates[$year][$month]['more']) {
442 442
             $from = "$year-$month-" . $dates[$year][$month]['more'];
443
-            if ($month==12)
444
-                $to = ($year+1)."-01-" . $dates[$year+1][1]['less'];
443
+            if ($month == 12)
444
+                $to = ($year + 1) . "-01-" . $dates[$year + 1][1]['less'];
445 445
             else {
446
-                for ($newmonth = $month+1; $newmonth<=12; $newmonth++) {
446
+                for ($newmonth = $month + 1; $newmonth <= 12; $newmonth++) {
447 447
                     if (isset($dates[$year][$newmonth]['less'])) {
448
-                        $to = "$year-".($newmonth)."-" . $dates[$year][$newmonth]['less'];
448
+                        $to = "$year-" . ($newmonth) . "-" . $dates[$year][$newmonth]['less'];
449 449
                         break;
450 450
                     }
451 451
                 }
Please login to merge, or discard this patch.
Braces   +56 added lines, -27 removed lines patch added patch discarded remove patch
@@ -359,15 +359,19 @@  discard block
 block discarded – undo
359 359
         $recess = 'Summer Recess';
360 360
         if (isset($dates[$year][7]['all'])) {
361 361
             $from = "$year-6-" . $dates[$year][6]['more'];
362
-        } else {
362
+        }
363
+        else {
363 364
             $from = "$year-7-" . $dates[$year][7]['more'];
364 365
         }
365
-        if (!isset($dates[$year][9]))
366
-            $to = "$year-08-31";
367
-        elseif (isset($dates[$year][9]['all']))
368
-            $to = "$year-10-" . $dates[$year][10]['less'];
369
-        else
370
-            $to = "$year-9-" . $dates[$year][9]['less'];
366
+        if (!isset($dates[$year][9])) {
367
+                    $to = "$year-08-31";
368
+        }
369
+        elseif (isset($dates[$year][9]['all'])) {
370
+                    $to = "$year-10-" . $dates[$year][10]['less'];
371
+        }
372
+        else {
373
+                    $to = "$year-9-" . $dates[$year][9]['less'];
374
+        }
371 375
     }
372 376
     if ( (isset($dates[$year][$month]['less']) && $day < $dates[$year][$month]['less'])
373 377
     || (isset($dates[$year][$month]['more']) && $day > $dates[$year][$month]['more'])
@@ -375,35 +379,50 @@  discard block
 block discarded – undo
375 379
     || (isset($dates[$year][$month]['between'][2]) && $day > $dates[$year][$month]['between'][2] && $day < $dates[$year][$month]['between'][3]) ) {
376 380
         switch ($month) {
377 381
             case 1: case 12: $recess = 'Christmas Recess'; break;
378
-            case 2: if ($body==1 || $body==101) $recess = 'Half Term Week';
379
-                elseif ($body==4) $recess = 'February Recess';
382
+            case 2: if ($body==1 || $body==101) {
383
+                $recess = 'Half Term Week';
384
+            }
385
+                elseif ($body==4) {
386
+                    $recess = 'February Recess';
387
+                }
380 388
                 break;
381
-            case 3: if ($body==1 || $body==101) $recess = 'Easter Recess';
382
-                elseif ($body==4) $recess = 'Spring Recess';
389
+            case 3: if ($body==1 || $body==101) {
390
+                $recess = 'Easter Recess';
391
+            }
392
+                elseif ($body==4) {
393
+                    $recess = 'Spring Recess';
394
+                }
383 395
                 break;
384 396
             case 4: if (isset($dates[$year][$month]['more']) && $day > $dates[$year][$month]['more']) {
385 397
                     $recess = 'Election Recess';
386
-                } elseif ($body==4 && $year==2003) {
398
+                }
399
+                elseif ($body==4 && $year==2003) {
387 400
                     $recess = 'Election Recess';
388
-                } elseif ($body==1 || $body==101) {
401
+                }
402
+                elseif ($body==1 || $body==101) {
389 403
                     $recess = 'Easter Recess';
390
-                } elseif ($body==4) {
404
+                }
405
+                elseif ($body==4) {
391 406
                     $recess = 'Spring Recess';
392 407
                 }
393 408
                 break;
394 409
             case 5: if ($year==2001 || (isset($dates[$year][$month]['less']) && $day < $dates[$year][$month]['less'])) {
395 410
                     $recess = 'Election Recess';
396
-                } else {
411
+                }
412
+                else {
397 413
                     $recess = 'Whit Recess';
398 414
                 }
399 415
                 break;
400 416
             case 6: if ($year==2001) {
401 417
                     $recess = 'Election Recess';
402
-                } elseif ($body==1 || $body==101) {
418
+                }
419
+                elseif ($body==1 || $body==101) {
403 420
                     $recess = 'Whit Recess';
404
-                } elseif ($body==4) {
421
+                }
422
+                elseif ($body==4) {
405 423
                     $recess = 'Summer Recess';
406
-                } else {
424
+                }
425
+                else {
407 426
                     trigger_error("Argh6");
408 427
                 }
409 428
                 break;
@@ -411,15 +430,23 @@  discard block
 block discarded – undo
411 430
                 break;
412 431
             case 9: if (isset($dates[$year][$month]['less']) && $day < $dates[$year][$month]['less']) {
413 432
                     $recess = 'Summer Recess';
414
-                } elseif ($body==1 || $body==101) {
433
+                }
434
+                elseif ($body==1 || $body==101) {
415 435
                     $recess = 'Conference Recess';
416
-                } else {
436
+                }
437
+                else {
417 438
                     trigger_error("Argh9");
418 439
                 }
419 440
                 break;
420
-            case 10: if ($body==1 || $body==101) $recess = 'Conference Recess';
421
-                elseif ($body==4) $recess = 'Autumn Recess';
422
-                elseif ($body==5) $recess = 'Halloween Recess';
441
+            case 10: if ($body==1 || $body==101) {
442
+                $recess = 'Conference Recess';
443
+            }
444
+                elseif ($body==4) {
445
+                    $recess = 'Autumn Recess';
446
+                }
447
+                elseif ($body==5) {
448
+                    $recess = 'Halloween Recess';
449
+                }
423 450
                 break;
424 451
             case 11: $recess = 'Autumn Recess';
425 452
                 break;
@@ -427,8 +454,9 @@  discard block
 block discarded – undo
427 454
         }
428 455
         if (isset($dates[$year][$month]['less']) && $day < $dates[$year][$month]['less']) {
429 456
             $to = "$year-$month-" . $dates[$year][$month]['less'];
430
-            if ($month==1)
431
-                $from = ($year-1)."-12-" . $dates[$year-1][12]['more'];
457
+            if ($month==1) {
458
+                            $from = ($year-1)."-12-" . $dates[$year-1][12]['more'];
459
+            }
432 460
             else {
433 461
                 for ($newmonth = $month-1; $newmonth>=1; $newmonth--) {
434 462
                     if (isset($dates[$year][$newmonth]['more'])) {
@@ -440,8 +468,9 @@  discard block
 block discarded – undo
440 468
         }
441 469
         if (isset($dates[$year][$month]['more']) && $day > $dates[$year][$month]['more']) {
442 470
             $from = "$year-$month-" . $dates[$year][$month]['more'];
443
-            if ($month==12)
444
-                $to = ($year+1)."-01-" . $dates[$year+1][1]['less'];
471
+            if ($month==12) {
472
+                            $to = ($year+1)."-01-" . $dates[$year+1][1]['less'];
473
+            }
445 474
             else {
446 475
                 for ($newmonth = $month+1; $newmonth<=12; $newmonth++) {
447 476
                     if (isset($dates[$year][$newmonth]['less'])) {
Please login to merge, or discard this patch.
www/includes/easyparliament/glossary.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -21,22 +21,22 @@  discard block
 block discarded – undo
21 21
 */
22 22
 
23 23
 // This handles basic insertion and approval functions for all epobjects
24
-include_once INCLUDESPATH."easyparliament/editqueue.php";
25
-include_once INCLUDESPATH."easyparliament/searchengine.php";
26
-include_once INCLUDESPATH."url.php";
24
+include_once INCLUDESPATH . "easyparliament/editqueue.php";
25
+include_once INCLUDESPATH . "easyparliament/searchengine.php";
26
+include_once INCLUDESPATH . "url.php";
27 27
 
28 28
 class GLOSSARY {
29 29
 
30
-    public $num_terms;			// how many glossary entries do we have
30
+    public $num_terms; // how many glossary entries do we have
31 31
                             // (changes depending on how GLOSSARY is called
32
-    public $hansard_count;		// how many times does the phrase appear in hansard?
33
-    public $query;				// search term
34
-    public $glossary_id;		// if this is set then we only have 1 glossary term
35
-    public $current_term;		// will only be set if we have a valid epobject_id
32
+    public $hansard_count; // how many times does the phrase appear in hansard?
33
+    public $query; // search term
34
+    public $glossary_id; // if this is set then we only have 1 glossary term
35
+    public $current_term; // will only be set if we have a valid epobject_id
36 36
     public $current_letter;
37 37
 
38 38
     // constructor...
39
-    public function __construct($args=array()) {
39
+    public function __construct($args = array()) {
40 40
     // We can optionally start the glossary with one of several arguments
41 41
     //		1. glossary_id - treat the glossary as a single term
42 42
     //		2. glossary_term - search within glossary for a term
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
 
76 76
             // These stop stupid submissions.
77 77
             // everything should be lowercase.
78
-            $this->stopwords = array( "the", "of", "to", "and", "for", "in", "a", "on", "is", "that", "will", "secretary", "are", "ask", "state", "have", "be", "has", "by", "with", "i", "not", "what", "as", "it", "hon", "he", "which", "from", "if", "been", "this", "s", "we", "at", "government", "was", "my", "an", "department", "there", "make", "or", "made", "their", "all", "but", "they", "how", "debate" );
78
+            $this->stopwords = array("the", "of", "to", "and", "for", "in", "a", "on", "is", "that", "will", "secretary", "are", "ask", "state", "have", "be", "has", "by", "with", "i", "not", "what", "as", "it", "hon", "he", "which", "from", "if", "been", "this", "s", "we", "at", "government", "was", "my", "an", "department", "there", "make", "or", "made", "their", "all", "but", "they", "how", "debate");
79 79
 
80 80
     }
81 81
 
82
-    public function get_glossary_item($args=array()) {
82
+    public function get_glossary_item($args = array()) {
83 83
         // Search for and fetch glossary item with title or glossary_id
84 84
         // We could also search glossary text that contains the title text, for cross references
85 85
 
86 86
         $this->alphabet = array();
87
-        foreach (range ("A", "Z") as $letter) {
87
+        foreach (range("A", "Z") as $letter) {
88 88
             $this->alphabet[$letter] = array();
89 89
         }
90 90
 
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
             WHERE g.glossary_id=eq.glossary_id AND u.user_id=eq.user_id AND g.visible=1 AND eq.approved=1
94 94
             ORDER by g.title");
95 95
         if ($q->success() && $q->rows()) {
96
-            for ($i=0; $i < $q->rows(); $i++) {
97
-                $this->terms[ $q->field($i,"glossary_id") ] = $q->row($i);
96
+            for ($i = 0; $i < $q->rows(); $i++) {
97
+                $this->terms[$q->field($i, "glossary_id")] = $q->row($i);
98 98
                 // Now add the epobject to the alphabet navigation.
99
-                $first_letter = strtoupper(substr($q->field($i,"title"),0,1));
100
-                $this->alphabet[$first_letter][] = $q->field($i,"glossary_id");
99
+                $first_letter = strtoupper(substr($q->field($i, "title"), 0, 1));
100
+                $this->alphabet[$first_letter][] = $q->field($i, "glossary_id");
101 101
             }
102 102
 
103 103
             $this->num_terms = $q->rows();
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         }
141 141
     }
142 142
 
143
-    public function search_glossary($args=array()) {
143
+    public function search_glossary($args = array()) {
144 144
         // Search for and fetch glossary item with a title
145 145
         // Useful for the search page, and nowhere else (so far)
146 146
 
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
             ORDER by g.title";
156 156
         $q = $this->db->query($query);
157 157
         if ($q->success() && $q->rows()) {
158
-            for ($i=0; $i < $q->rows(); $i++) {
159
-                $this->search_matches[ $q->field($i,"glossary_id") ] = $q->row($i);
158
+            for ($i = 0; $i < $q->rows(); $i++) {
159
+                $this->search_matches[$q->field($i, "glossary_id")] = $q->row($i);
160 160
             }
161 161
             $this->num_search_matches = $q->rows();
162 162
         }
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
         global $THEUSER;
193 193
 
194 194
         if ($data['title'] == '') {
195
-            error ("Sorry, you can't define a term without a title");
195
+            error("Sorry, you can't define a term without a title");
196 196
             return false;
197 197
         }
198 198
 
199 199
         if ($data['body'] == '') {
200
-            error ("You haven't entered a definition!");
200
+            error("You haven't entered a definition!");
201 201
             return false;
202 202
         }
203 203
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         }
251 251
     }
252 252
 
253
-    public function glossarise($body, $tokenize=0, $urlize=0) {
253
+    public function glossarise($body, $tokenize = 0, $urlize = 0) {
254 254
     // Turn a body of text into a link-up wonderland of glossary joy
255 255
 
256 256
         global $this_page;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
             }
294 294
             else {
295 295
                 if ($this_page == "admin_glossary") {
296
-                    $link_url = "#gl".$glossary_id;
296
+                    $link_url = "#gl" . $glossary_id;
297 297
                 }
298 298
                 else {
299 299
                     $link_url = $URL->generate('url');
Please login to merge, or discard this patch.
Braces   +11 added lines, -6 removed lines patch added patch discarded remove patch
@@ -107,7 +107,9 @@  discard block
 block discarded – undo
107 107
             if (isset($args['glossary_id']) && ($args['glossary_id'] != "")) {
108 108
                 $next = 0; $first_term = null;
109 109
                 foreach ($this->terms as $term) {
110
-                    if (!$first_term) $first_term = $term;
110
+                    if (!$first_term) {
111
+                        $first_term = $term;
112
+                    }
111 113
                     $last_term = $term;
112 114
                     if ($next == 1) {
113 115
                         $this->next_term = $term;
@@ -234,7 +236,8 @@  discard block
 block discarded – undo
234 236
 
235 237
         if ($success) {
236 238
             return ($success);
237
-        } else {
239
+        }
240
+        else {
238 241
             return false;
239 242
         }
240 243
     }
@@ -278,8 +281,9 @@  discard block
 block discarded – undo
278 281
 
279 282
         // check for any glossary terms to replace
280 283
         foreach ($this->replace_order as $glossary_id => $count) {
281
-            if ($glossary_id == $this->glossary_id)
282
-                continue;
284
+            if ($glossary_id == $this->glossary_id) {
285
+                            continue;
286
+            }
283 287
 
284 288
             $term_body = $this->terms[$glossary_id]['body'];
285 289
             $term_title = $this->terms[$glossary_id]['title'];
@@ -304,8 +308,9 @@  discard block
 block discarded – undo
304 308
         }
305 309
         // Highlight all occurrences of another glossary term in the definition.
306 310
         $body = preg_replace($findwords, $replacewords, $body, 1);
307
-        if (isset($this->glossary_id))
308
-            $body = preg_replace("/(?<![>\.\'\/])\b(" . $this->terms[$this->glossary_id]['title'] . ")\b(?![<\'])/i", '<strong>\\1</strong>', $body, 1);
311
+        if (isset($this->glossary_id)) {
312
+                    $body = preg_replace("/(?<![>\.\'\/])\b(" . $this->terms[$this->glossary_id]['title'] . ")\b(?![<\'])/i", '<strong>\\1</strong>', $body, 1);
313
+        }
309 314
 
310 315
         // Replace any phrases in wikipedia
311 316
         // TODO: Merge this code into above, so our gloss and wikipedia
Please login to merge, or discard this patch.
tests/UserPageTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
      */
9 9
     public function getDataSet()
10 10
     {
11
-        return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/user.xml');
11
+        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/user.xml');
12 12
     }
13 13
 
14 14
     private function fetch_page($vars)
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
         return $this->base_fetch_page($vars, 'user');
17 17
     }
18 18
 
19
-    private function fetch_user_page( $vars = array(), $page = 'user' )
19
+    private function fetch_user_page($vars = array(), $page = 'user')
20 20
     {
21
-        return $this->base_fetch_page_user( $vars, '1.fbb689a0c092f5534b929d302db2c8a9', $page );
21
+        return $this->base_fetch_page_user($vars, '1.fbb689a0c092f5534b929d302db2c8a9', $page);
22 22
     }
23 23
 
24 24
     public function testLoginPageLoads()
25 25
     {
26
-        $page = $this->base_fetch_page( array(), 'user/login' );
26
+        $page = $this->base_fetch_page(array(), 'user/login');
27 27
         $this->assertContains('Sign in', $page);
28 28
     }
29 29
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             'password' => 'password',
35 35
             'submitted' => 'true',
36 36
         );
37
-        $page = $this->base_fetch_page( $vars, 'user/login' );
37
+        $page = $this->base_fetch_page($vars, 'user/login');
38 38
         # it's a redirect which means we should get nothing
39 39
         # as we're using the cli version of php :(
40 40
         $this->assertEquals('', $page);
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
     public function testEditUserInfo()
51 51
     {
52
-        $page = $this->fetch_user_page( array('pg' => 'edit' ) );
52
+        $page = $this->fetch_user_page(array('pg' => 'edit'));
53 53
         $this->assertContains('Your details', $page);
54 54
         $this->assertContains('name="pg" value="edit"', $page);
55 55
         $this->assertContains('value="Test"', $page);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             'email' => '[email protected]',
63 63
             'submitted' => 'true',
64 64
         );
65
-        $page = $this->fetch_user_page( $vars );
65
+        $page = $this->fetch_user_page($vars);
66 66
         $this->assertContains('Example User', $page);
67 67
     }
68 68
 }
Please login to merge, or discard this patch.
tests/FetchPageTestCase.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     protected function base_fetch_page($vars, $dir, $page = 'index.php', $req_uri = '')
10 10
     {
11 11
         foreach ($vars as $k => $v) {
12
-            $vars[$k] =  $k . '=' . urlencode($v);
12
+            $vars[$k] = $k . '=' . urlencode($v);
13 13
         }
14 14
 
15 15
         if (!$req_uri) {
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     protected function base_fetch_page_user($vars, $cookie, $dir, $page = 'index.php', $req_uri = '')
27 27
     {
28 28
         foreach ($vars as $k => $v) {
29
-            $vars[$k] =  $k . '=' . urlencode($v);
29
+            $vars[$k] = $k . '=' . urlencode($v);
30 30
         }
31 31
 
32 32
         if (!$req_uri) {
Please login to merge, or discard this patch.