Failed Conditions
Pull Request — master (#1327)
by Nick
69:15 queued 59:17
created
classes/Data.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -159,6 +159,9 @@
 block discarded – undo
159 159
         }
160 160
     }
161 161
 
162
+    /**
163
+     * @param string $type
164
+     */
162 165
     private function getMetadata($args="", $type) {
163 166
         // $type is either 'page' or 'section'
164 167
         global $this_page, $this_section;
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
     public function __construct() {
56 56
 
57
-        include_once METADATAPATH;	// defined in config.php
57
+        include_once METADATAPATH; // defined in config.php
58 58
 
59 59
     }
60 60
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
 
116 116
     public function set_page_metadata($page, $key, $value) {
117
-        $this->setMetadata(array("page"=>$page,"key"=>$key,"value"=>$value));
117
+        $this->setMetadata(array("page"=>$page, "key"=>$key, "value"=>$value));
118 118
     }
119 119
 
120 120
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
 
128 128
     public function set_section_metadata($section, $key, $value) {
129
-        $this->setMetadata(array("section"=>$section,"key"=>$key,"value"=>$value));
129
+        $this->setMetadata(array("section"=>$section, "key"=>$key, "value"=>$value));
130 130
     }
131 131
 
132 132
     /**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
 
152 152
     public function test_for_metadata($type, $item, $key) {
153
-        $dataarray =& $this->$type;
153
+        $dataarray = & $this->$type;
154 154
 
155 155
         if (isset($dataarray[$item][$key])) {
156 156
             return true;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         }
160 160
     }
161 161
 
162
-    private function getMetadata($args="", $type) {
162
+    private function getMetadata($args = "", $type) {
163 163
         // $type is either 'page' or 'section'
164 164
         global $this_page, $this_section;
165 165
 
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
             $item = $args[$type];
168 168
             $key = $args['key'];
169 169
         } else {
170
-            $var = "this_".$type;
170
+            $var = "this_" . $type;
171 171
             $item = $$var; // $this_page or $this_section.
172 172
             $key = $args;
173 173
         }
174 174
 
175 175
         twfy_debug("DATA", "$type: $item, $key");
176
-        $dataarray =& $this->$type;
176
+        $dataarray = & $this->$type;
177 177
 
178 178
         if ($this->test_for_metadata($type, $item, $key)) {
179 179
             $return = $dataarray[$item][$key];
180
-            $debugtext = "Key: ".$type."[".$item."][".$key."]";
180
+            $debugtext = "Key: " . $type . "[" . $item . "][" . $key . "]";
181 181
 
182 182
         } elseif ($this->test_for_metadata($type, "default", $key)) {
183 183
             $return = $dataarray["default"][$key];
184
-            $debugtext = "Key: ".$type."['default'][".$key."]";
184
+            $debugtext = "Key: " . $type . "['default'][" . $key . "]";
185 185
 
186 186
         } else {
187 187
             $return = false;
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
         $key = $args["key"];
207 207
         $value = $args["value"];
208 208
 
209
-        twfy_debug("DATA", "Setting: ".$type."[".$item."][".$key."] = '" . print_r($value, 1) . "'");
209
+        twfy_debug("DATA", "Setting: " . $type . "[" . $item . "][" . $key . "] = '" . print_r($value, 1) . "'");
210 210
 
211
-        $dataarray =& $this->$type;
211
+        $dataarray = & $this->$type;
212 212
         $dataarray[$item][$key] = $value;
213 213
     }
214 214
 
Please login to merge, or discard this patch.
classes/Db/Query.php 5 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -175,6 +175,11 @@  discard block
 block discarded – undo
175 175
     }
176 176
 
177 177
     // After SELECT.
178
+
179
+    /**
180
+     * @param integer $row_index
181
+     * @param string $column_name
182
+     */
178 183
     public function field($row_index, $column_name) {
179 184
         if ($this->rows > 0)
180 185
             return $this->data[$row_index][$column_name];
@@ -187,6 +192,10 @@  discard block
 block discarded – undo
187 192
     }
188 193
 
189 194
     // After SELECT.
195
+
196
+    /**
197
+     * @param integer $row_index
198
+     */
190 199
     public function row($row_index) {
191 200
         if ($this->success && $this->rows > 0)
192 201
             return $this->data[$row_index];
@@ -224,6 +233,9 @@  discard block
 block discarded – undo
224 233
         return $html;
225 234
     }
226 235
 
236
+    /**
237
+     * @param string $errormsg
238
+     */
227 239
     public function error($errormsg) {
228 240
         // When a query goes wrong...
229 241
         $this->success = false;
Please login to merge, or discard this patch.
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,6 @@
 block discarded – undo
72 72
  * - `$this->field(n,col)` returns an empty string.
73 73
  * - `$this->insert_id()` returns `null`.
74 74
  * - `$this->affected_rows()` returns `null`.
75
-
76 75
  */
77 76
 
78 77
 class Query {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
 class Query {
79 79
 
80 80
     public $success = true;
81
-    public $rows = NULL;
81
+    public $rows = null;
82 82
     public $data = array();
83
-    public $insert_id = NULL;
84
-    public $affected_rows = NULL;
83
+    public $insert_id = null;
84
+    public $affected_rows = null;
85 85
 
86 86
     public function __construct($conn) {
87 87
         $this->conn = $conn;
88 88
     }
89 89
 
90
-    public function query($sql="", $params = NULL) {
90
+    public function query($sql="", $params = null) {
91 91
 
92 92
         if (empty($sql)) {
93 93
             $this->success = false;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         twfy_debug ("SQL", $sql);
105 105
         twfy_debug ("SQL", print_r($params, 1));
106 106
 
107
-        if ($params !== NULL) {
107
+        if ($params !== null) {
108 108
             // Prepare and execute a statement
109 109
             $pdoStatement = $this->conn->prepare($sql);
110 110
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $this->conn = $conn;
88 88
     }
89 89
 
90
-    public function query($sql="", $params = NULL) {
90
+    public function query($sql = "", $params = NULL) {
91 91
 
92 92
         if (empty($sql)) {
93 93
             $this->success = false;
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
             return;
102 102
         }
103 103
 
104
-        twfy_debug ("SQL", $sql);
105
-        twfy_debug ("SQL", print_r($params, 1));
104
+        twfy_debug("SQL", $sql);
105
+        twfy_debug("SQL", print_r($params, 1));
106 106
 
107 107
         if ($params !== NULL) {
108 108
             // Prepare and execute a statement
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
         if (!$this->success) return;
135 135
 
136
-        if ( (!$pdoStatement) or (empty($pdoStatement)) ) {
136
+        if ((!$pdoStatement) or (empty($pdoStatement))) {
137 137
             // A failed query.
138 138
             $this->success = false;
139 139
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             }
156 156
             $this->affected_rows = $pdoStatement->rowCount();
157 157
 
158
-            twfy_debug ("SQLRESULT", array($this, 'displayResult'));
158
+            twfy_debug("SQLRESULT", array($this, 'displayResult'));
159 159
             // mysql_free_result($q);
160 160
         }
161 161
     }
Please login to merge, or discard this patch.
Braces   +19 added lines, -10 removed lines patch added patch discarded remove patch
@@ -112,7 +112,8 @@  discard block
 block discarded – undo
112 112
 
113 113
                 if (is_int($paramValue)) {
114 114
                     $paramType = \PDO::PARAM_INT;
115
-                } else {
115
+                }
116
+                else {
116 117
                     $paramType = \PDO::PARAM_STR;
117 118
                 }
118 119
 
@@ -121,7 +122,8 @@  discard block
 block discarded – undo
121 122
 
122 123
             $pdoStatement->execute();
123 124
 
124
-        } else {
125
+        }
126
+        else {
125 127
             // Execute the raw query
126 128
             $pdoStatement = $this->conn->query($sql);
127 129
         }
@@ -131,13 +133,16 @@  discard block
 block discarded – undo
131 133
             $this->error($this->conn->errorCode() . ': ' . $this->conn->errorInfo()[2]);
132 134
         }
133 135
 
134
-        if (!$this->success) return;
136
+        if (!$this->success) {
137
+            return;
138
+        }
135 139
 
136 140
         if ( (!$pdoStatement) or (empty($pdoStatement)) ) {
137 141
             // A failed query.
138 142
             $this->success = false;
139 143
 
140
-        } else {
144
+        }
145
+        else {
141 146
 
142 147
             // A successful SELECT, SHOW, EXPLAIN or DESCRIBE query.
143 148
             $this->success = true;
@@ -150,7 +155,8 @@  discard block
 block discarded – undo
150 155
             // Sanity check that lastInsertId() is actually a number, otherwise panic
151 156
             if (is_numeric($this->conn->lastInsertId())) {
152 157
                 $this->insert_id = (int) $this->conn->lastInsertId();
153
-            } else {
158
+            }
159
+            else {
154 160
                 throw new Exception('Last connection ID was not numeric!');
155 161
             }
156 162
             $this->affected_rows = $pdoStatement->rowCount();
@@ -176,8 +182,9 @@  discard block
 block discarded – undo
176 182
 
177 183
     // After SELECT.
178 184
     public function field($row_index, $column_name) {
179
-        if ($this->rows > 0)
180
-            return $this->data[$row_index][$column_name];
185
+        if ($this->rows > 0) {
186
+                    return $this->data[$row_index][$column_name];
187
+        }
181 188
         return "";
182 189
     }
183 190
 
@@ -188,8 +195,9 @@  discard block
 block discarded – undo
188 195
 
189 196
     // After SELECT.
190 197
     public function row($row_index) {
191
-        if ($this->success && $this->rows > 0)
192
-            return $this->data[$row_index];
198
+        if ($this->success && $this->rows > 0) {
199
+                    return $this->data[$row_index];
200
+        }
193 201
         return array();
194 202
     }
195 203
 
@@ -212,7 +220,8 @@  discard block
 block discarded – undo
212 220
                     if ($n == "email" || $n == "password" || $n == "postcode") {
213 221
                         // Don't want to risk this data being displayed on any page.
214 222
                         $html .= "<td>**MASKED**</td>";
215
-                    } else {
223
+                    }
224
+                    else {
216 225
                         $html .= "<td>" . _htmlentities($field) . "</td>";
217 226
                     }
218 227
                 }
Please login to merge, or discard this patch.
www/docs/api/api_getPerson.php 2 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -77,6 +77,9 @@  discard block
 block discarded – undo
77 77
     }
78 78
 }
79 79
 
80
+/**
81
+ * @param MySociety\TheyWorkForYou\Db\Query $q
82
+ */
80 83
 function _api_getPerson_output($q, $flatten=false) {
81 84
     $output = array();
82 85
     $last_mod = 0;
@@ -95,10 +98,16 @@  discard block
 block discarded – undo
95 98
     api_output($output, $last_mod);
96 99
 }
97 100
 
101
+/**
102
+ * @param integer $house
103
+ */
98 104
 function api_getPerson_constituency($constituency, $house) {
99 105
     _api_getPerson_constituency(array($constituency), $house);
100 106
 }
101 107
 
108
+/**
109
+ * @param integer $house
110
+ */
102 111
 function api_getPerson_postcode($pc, $house) {
103 112
     $pc = preg_replace('#[^a-z0-9 ]#i', '', $pc);
104 113
     $types = array();
Please login to merge, or discard this patch.
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
         $URL = new \MySociety\TheyWorkForYou\Url('mp');
29 29
         $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
30 30
     }
31
-    if ($has_party && isset($parties[$row['party']]))
32
-        $row['party'] = $parties[$row['party']];
31
+    if ($has_party && isset($parties[$row['party']])) {
32
+            $row['party'] = $parties[$row['party']];
33
+    }
33 34
     list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
34 35
     if ($image) {
35 36
         list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
@@ -49,7 +50,9 @@  discard block
 block discarded – undo
49 50
     }
50 51
 
51 52
     foreach ($row as $k => $r) {
52
-        if (is_string($r)) $row[$k] = html_entity_decode($r);
53
+        if (is_string($r)) {
54
+            $row[$k] = html_entity_decode($r);
55
+        }
53 56
     }
54 57
 
55 58
     return $row;
@@ -72,7 +75,8 @@  discard block
 block discarded – undo
72 75
         order by left_house desc", $params);
73 76
     if ($q->rows()) {
74 77
         _api_getPerson_output($q);
75
-    } else {
78
+    }
79
+    else {
76 80
         api_error('Unknown person ID');
77 81
     }
78 82
 }
@@ -85,8 +89,9 @@  discard block
 block discarded – undo
85 89
         $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true);
86 90
         $output[] = $out;
87 91
         $time = strtotime($q->field($i, 'lastupdate'));
88
-        if ($time > $last_mod)
89
-            $last_mod = $time;
92
+        if ($time > $last_mod) {
93
+                    $last_mod = $time;
94
+        }
90 95
     }
91 96
     # Only one MP, not an array
92 97
     if ($flatten && count($output) == 1 && $house == HOUSE_TYPE_COMMONS) {
@@ -104,24 +109,30 @@  discard block
 block discarded – undo
104 109
     $types = array();
105 110
     if ($house == HOUSE_TYPE_NI) {
106 111
         $types = array('NIE');
107
-    } elseif ($house == HOUSE_TYPE_SCOTLAND) {
112
+    }
113
+    elseif ($house == HOUSE_TYPE_SCOTLAND) {
108 114
         $types = array('SPC', 'SPE');
109 115
     }
110 116
     if (validate_postcode($pc)) {
111 117
         $constituencies = MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($pc);
112 118
         if ($constituencies == 'CONNECTION_TIMED_OUT') {
113 119
             api_error('Connection timed out');
114
-        } elseif ($types && isset($constituencies[$types[0]])) {
120
+        }
121
+        elseif ($types && isset($constituencies[$types[0]])) {
115 122
             $constituencies = array_map(function($c) use ($constituencies) { return $constituencies[$c]; }, $types);
116 123
             _api_getPerson_constituency($constituencies, $house);
117
-        } elseif ($types && isset($constituencies['WMC'])) {
124
+        }
125
+        elseif ($types && isset($constituencies['WMC'])) {
118 126
             api_error('Postcode not in correct region');
119
-        } elseif (isset($constituencies['WMC'])) {
127
+        }
128
+        elseif (isset($constituencies['WMC'])) {
120 129
             _api_getPerson_constituency(array($constituencies['WMC']), $house);
121
-        } else {
130
+        }
131
+        else {
122 132
             api_error('Unknown postcode');
123 133
         }
124
-    } else {
134
+    }
135
+    else {
125 136
         api_error('Invalid postcode');
126 137
     }
127 138
 }
@@ -134,13 +145,18 @@  discard block
 block discarded – undo
134 145
 
135 146
     $cons = array();
136 147
     foreach ($constituencies as $constituency) {
137
-        if ($constituency == '') continue;
138
-        if ($constituency == 'Orkney ')
139
-            $constituency = 'Orkney & Shetland';
148
+        if ($constituency == '') {
149
+            continue;
150
+        }
151
+        if ($constituency == 'Orkney ') {
152
+                    $constituency = 'Orkney & Shetland';
153
+        }
140 154
 
141 155
         if ($house == HOUSE_TYPE_COMMONS) {
142 156
             $normalised = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency);
143
-            if ($normalised) $constituency = $normalised;
157
+            if ($normalised) {
158
+                $constituency = $normalised;
159
+            }
144 160
         }
145 161
 
146 162
         $cons[] = $constituency;
@@ -167,7 +183,8 @@  discard block
 block discarded – undo
167 183
 
168 184
     if ($q->rows > 0) {
169 185
         _api_getPerson_output($q, true);
170
-    } else {
186
+    }
187
+    else {
171 188
         api_error('Unknown constituency, or no results for that constituency');
172 189
     }
173 190
 }
Please login to merge, or discard this patch.
classes/Db/Connection.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
      * @param string $db_pass The password for the database user
56 56
      * @param string $db_name The name of the database
57 57
      *
58
-     * @return true If the connection has been created successfully.
58
+     * @return boolean If the connection has been created successfully.
59 59
      */
60 60
 
61 61
     public function init($db_host, $db_user, $db_pass, $db_name) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
      * @return Query An object containing the results of the query.
103 103
      */
104 104
 
105
-    public function query($sql, $params = NULL) {
105
+    public function query($sql, $params = null) {
106 106
 
107 107
         $start = getmicrotime();
108 108
         $q = new \MySociety\TheyWorkForYou\Db\Query($this->conn);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         $duration = getmicrotime() - $start;
112 112
         global $mysqltotalduration;
113 113
         $mysqltotalduration += $duration;
114
-        twfy_debug ("SQL", "Complete after $duration seconds.");
114
+        twfy_debug("SQL", "Complete after $duration seconds.");
115 115
         // We could also output $q->mysql_info() here, but that's for
116 116
         // PHP >= 4.3.0.
117 117
         return $q;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function display_total_duration() {
128 128
         global $mysqltotalduration;
129
-        twfy_debug ("TIME", "Total time for MySQL queries on this page: " . $mysqltotalduration . " seconds.");
129
+        twfy_debug("TIME", "Total time for MySQL queries on this page: " . $mysqltotalduration . " seconds.");
130 130
     }
131 131
 
132 132
     /**
Please login to merge, or discard this patch.
www/includes/easyparliament/init.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@
 block discarded – undo
92 92
 include_once (INCLUDESPATH."easyparliament/user.php");
93 93
 
94 94
 // Test to see if this is a new-style template using the renderer class.
95
-if (! isset($new_style_template) OR $new_style_template !== TRUE) {
95
+if (! isset($new_style_template) or $new_style_template !== true) {
96 96
 
97 97
     // This is an old-style page. Use the old page classes.
98 98
     include_once (INCLUDESPATH."easyparliament/page.php");
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 First some things to help make our PHP nicer and betterer
5 5
 ********************************************************************************/
6 6
 
7
-error_reporting (E_ALL);
7
+error_reporting(E_ALL);
8 8
 
9 9
 /********************************************************************************
10 10
 Now some constants that are the same for live and dev versions
@@ -12,22 +12,22 @@  discard block
 block discarded – undo
12 12
 ********************************************************************************/
13 13
 
14 14
 // In case we need to switch these off globally at some point...
15
-define ("ALLOWCOMMENTS", true);
16
-define ("ALLOWTRACKBACKS", true);
15
+define("ALLOWCOMMENTS", true);
16
+define("ALLOWTRACKBACKS", true);
17 17
 
18 18
 // These variables are so we can keep date/time formats consistent across the site
19 19
 // and change them easily.
20 20
 // Formats here: http://www.php.net/manual/en/function.date.php
21
-define ("LONGERDATEFORMAT",		"l, j F Y");// Monday, 31 December 2003
22
-define ("LONGDATEFORMAT", 		"j F Y"); 	// 31 December 2003
23
-define ("SHORTDATEFORMAT", 		"j M Y");	// 31 Dec 2003
24
-define ("TIMEFORMAT", 			"g:i a");	// 11:59 pm
21
+define("LONGERDATEFORMAT", "l, j F Y"); // Monday, 31 December 2003
22
+define("LONGDATEFORMAT", "j F Y"); // 31 December 2003
23
+define("SHORTDATEFORMAT", "j M Y"); // 31 Dec 2003
24
+define("TIMEFORMAT", "g:i a"); // 11:59 pm
25 25
 
26
-define ("SHORTDATEFORMAT_SQL",	"%e %b %Y"); // 31 Dec 2003
27
-define ("TIMEFORMAT_SQL", 		"%l:%i %p"); // 11:59 PM
26
+define("SHORTDATEFORMAT_SQL", "%e %b %Y"); // 31 Dec 2003
27
+define("TIMEFORMAT_SQL", "%l:%i %p"); // 11:59 PM
28 28
 
29 29
 // Where we store the postcode of users if they search for an MP by postcode.
30
-define ('POSTCODE_COOKIE', 		'eppc');
30
+define('POSTCODE_COOKIE', 'eppc');
31 31
 
32 32
 /********************************************************************************
33 33
 And now all the files we'll include on every page.
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 twfy_debug_timestamp("after including utility.php");
42 42
 
43 43
 // Set the default timezone
44
-if(function_exists('date_default_timezone_set')) date_default_timezone_set(TIMEZONE);
44
+if (function_exists('date_default_timezone_set')) date_default_timezone_set(TIMEZONE);
45 45
 
46 46
 // Only do clever things with errors if we're not testing, otherwise show as default
47 47
 
@@ -70,40 +70,40 @@  discard block
 block discarded – undo
70 70
 
71 71
 // The time the page starts, so we can display the total at the end.
72 72
 // getmicrotime() is in utiltity.php.
73
-define ("STARTTIME", getmicrotime());
73
+define("STARTTIME", getmicrotime());
74 74
 if (!isset($_SERVER['WINDIR'])) {
75 75
     $rusage = getrusage();
76
-    define ('STARTTIMES', $rusage['ru_stime.tv_sec']*1000000 + $rusage['ru_stime.tv_usec']);
77
-    define ('STARTTIMEU', $rusage['ru_utime.tv_sec']*1000000 + $rusage['ru_utime.tv_usec']);
76
+    define('STARTTIMES', $rusage['ru_stime.tv_sec'] * 1000000 + $rusage['ru_stime.tv_usec']);
77
+    define('STARTTIMEU', $rusage['ru_utime.tv_sec'] * 1000000 + $rusage['ru_utime.tv_usec']);
78 78
 }
79 79
 
80 80
 $DATA = new \MySociety\TheyWorkForYou\Data;
81 81
 
82 82
 class ParlDB extends \MySociety\TheyWorkForYou\Db\Connection {
83 83
     public function __construct() {
84
-        $this->init (OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME);
84
+        $this->init(OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME);
85 85
     }
86 86
 }
87 87
 
88 88
 $filter = new \MySociety\TheyWorkForYou\Utility\LibFilter;
89 89
 
90
-include_once (INCLUDESPATH."easyparliament/user.php");
90
+include_once (INCLUDESPATH . "easyparliament/user.php");
91 91
 
92 92
 // Test to see if this is a new-style template using the renderer class.
93
-if (! isset($new_style_template) OR $new_style_template !== TRUE) {
93
+if (!isset($new_style_template) OR $new_style_template !== TRUE) {
94 94
 
95 95
     // This is an old-style page. Use the old page classes.
96
-    include_once (INCLUDESPATH."easyparliament/page.php");
96
+    include_once (INCLUDESPATH . "easyparliament/page.php");
97 97
 
98 98
 }
99 99
 
100
-include_once (INCLUDESPATH."easyparliament/hansardlist.php");
101
-include_once (INCLUDESPATH."dbtypes.php");
102
-include_once (INCLUDESPATH."easyparliament/commentlist.php");
103
-include_once (INCLUDESPATH."easyparliament/comment.php");
104
-include_once (INCLUDESPATH."easyparliament/trackback.php");
100
+include_once (INCLUDESPATH . "easyparliament/hansardlist.php");
101
+include_once (INCLUDESPATH . "dbtypes.php");
102
+include_once (INCLUDESPATH . "easyparliament/commentlist.php");
103
+include_once (INCLUDESPATH . "easyparliament/comment.php");
104
+include_once (INCLUDESPATH . "easyparliament/trackback.php");
105 105
 
106 106
 // Added in as new module by Richard Allan MP
107
-include_once (INCLUDESPATH."easyparliament/alert.php");
107
+include_once (INCLUDESPATH . "easyparliament/alert.php");
108 108
 
109 109
 twfy_debug_timestamp("at end of init.php");
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/calendar_date.php 2 patches
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,10 +18,13 @@
 block discarded – undo
18 18
 # Content goes here
19 19
 foreach ($data['dates'] as $date => $day_events) {
20 20
     foreach ($order as $i => $chamber) {
21
-        if (!array_key_exists($chamber, $day_events))
22
-            continue;
21
+        if (!array_key_exists($chamber, $day_events)) {
22
+                    continue;
23
+        }
23 24
         $events = $day_events[$chamber];
24
-        if ($plural[$i]) $chamber .= 's';
25
+        if ($plural[$i]) {
26
+            $chamber .= 's';
27
+        }
25 28
         print "<h2 class='calendar'>$chamber";
26 29
         if (in_array($major[$i], $data['majors'])) {
27 30
             $URL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$major[$i]]['page_all']);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         print "<h2 class='calendar'>$chamber";
26 26
         if (in_array($major[$i], $data['majors'])) {
27 27
             $URL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$major[$i]]['page_all']);
28
-            $URL->insert( array( 'd' => $date ) );
28
+            $URL->insert(array('d' => $date));
29 29
             print ' &nbsp; <a href="' . $URL->generate() . '">See this day &rarr;</a>';
30 30
         }
31 31
         print "</h2>\n";
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/comments_recent.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
     }
19 19
     $PAGE->block_start(array('id'=>'recentcomments', 'title'=>$title));
20 20
 
21
-    if ($this_page != 'home') $PAGE->page_links($data);
21
+    if ($this_page != 'home') {
22
+        $PAGE->page_links($data);
23
+    }
22 24
     $USERURL = new \MySociety\TheyWorkForYou\Url('userview');
23 25
     ?>
24 26
                         <ul>
@@ -50,7 +52,9 @@  discard block
 block discarded – undo
50 52
                         <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments'])+1; ?>">See more annotations posted recently</a></p>
51 53
 <?php
52 54
     }
53
-    if ($this_page != 'home') $PAGE->page_links($data);
55
+    if ($this_page != 'home') {
56
+        $PAGE->page_links($data);
57
+    }
54 58
     $PAGE->block_end();
55 59
 }
56 60
 ?>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $date = format_date($date, SHORTDATEFORMAT);
34 34
         $time = format_time($time, TIMEFORMAT);
35 35
 
36
-        $count = $n+1;
36
+        $count = $n + 1;
37 37
 
38 38
         $USERURL->insert(array('u'=>$comment['user_id']));
39 39
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     if ($this_page == 'home') {
48 48
         $MOREURL = new \MySociety\TheyWorkForYou\Url('comments_recent');
49 49
         ?>
50
-                        <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments'])+1; ?>">See more annotations posted recently</a></p>
50
+                        <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments']) + 1; ?>">See more annotations posted recently</a></p>
51 51
 <?php
52 52
     }
53 53
     if ($this_page != 'home') $PAGE->page_links($data);
Please login to merge, or discard this patch.
scripts/mprss.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -20,49 +20,49 @@  discard block
 block discarded – undo
20 20
 
21 21
 $starttime = time();
22 22
 for ($personrow=0; $personrow<$q->rows(); $personrow++) {
23
-	$person_id = $q->field($personrow, 'person_id');
23
+    $person_id = $q->field($personrow, 'person_id');
24 24
 
25
-	$args = array ( 'person_id' => $person_id );
26
-	$speeches = $HANSARDLIST->display('person', $args, 'none');
25
+    $args = array ( 'person_id' => $person_id );
26
+    $speeches = $HANSARDLIST->display('person', $args, 'none');
27 27
 
28
-	// Some data about this person that we'll need for the feed.
29
-	$MEMBER = new MEMBER(array('person_id' => $person_id));
30
-	$MPURL = new \MySociety\TheyWorkForYou\Url('mp');
31
-	$MPURL->insert(array('pid'=>$person_id));
32
-	$mpurl = $MPURL->generate();
28
+    // Some data about this person that we'll need for the feed.
29
+    $MEMBER = new MEMBER(array('person_id' => $person_id));
30
+    $MPURL = new \MySociety\TheyWorkForYou\Url('mp');
31
+    $MPURL->insert(array('pid'=>$person_id));
32
+    $mpurl = $MPURL->generate();
33 33
 
34
-	$date = gmdate('Y-m-d');
35
-	$time = gmdate('H:i:s');
36
-	$datenow = $date . 'T' . $time . '+00:00';
34
+    $date = gmdate('Y-m-d');
35
+    $time = gmdate('H:i:s');
36
+    $datenow = $date . 'T' . $time . '+00:00';
37 37
 
38
-	// Prepare the meat of the RSS file.
39
-	$items = '';
40
-	$entries = '';
41
-	if (isset ($speeches['rows']) && count($speeches['rows']) > 0) {
38
+    // Prepare the meat of the RSS file.
39
+    $items = '';
40
+    $entries = '';
41
+    if (isset ($speeches['rows']) && count($speeches['rows']) > 0) {
42 42
 
43
-		foreach ($speeches['rows'] as $n => $row) {
43
+        foreach ($speeches['rows'] as $n => $row) {
44 44
 
45
-			// While we're linking to individual speeches,
46
-			// the text is the body of the parent, ie (sub)section.
47
-			$title = _htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
45
+            // While we're linking to individual speeches,
46
+            // the text is the body of the parent, ie (sub)section.
47
+            $title = _htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
48 48
 
49
-			$link = isset($row['listurl']) ? $row['listurl'] : '';
50
-			$link = 'https://' . DOMAIN . $link;
49
+            $link = isset($row['listurl']) ? $row['listurl'] : '';
50
+            $link = 'https://' . DOMAIN . $link;
51 51
 
52
-			$description = _htmlentities(trim_characters($row['body'], 0, 200));
53
-			$contentencoded = $row['body'];
52
+            $description = _htmlentities(trim_characters($row['body'], 0, 200));
53
+            $contentencoded = $row['body'];
54 54
 
55
-			$hdate = format_date($row['hdate'], 'Y-m-d');
56
-			if ($row['htime'] != NULL) {
57
-				$htime = format_time($row['htime'], 'H:i:s');
58
-			} else {
59
-				$htime = '00:00:00';
60
-			}
55
+            $hdate = format_date($row['hdate'], 'Y-m-d');
56
+            if ($row['htime'] != NULL) {
57
+                $htime = format_time($row['htime'], 'H:i:s');
58
+            } else {
59
+                $htime = '00:00:00';
60
+            }
61 61
 
62
-			$date = $hdate . 'T' . $htime . '+00:00';
62
+            $date = $hdate . 'T' . $htime . '+00:00';
63 63
 
64
-			$items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
65
-			$entries .= "<item rdf:about=\"$link\">
64
+            $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
65
+            $entries .= "<item rdf:about=\"$link\">
66 66
 	<title>$title</title>
67 67
 	<link>$link</link>
68 68
 	<description>$description</description>
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 </item>
72 72
 ";
73 73
 
74
-		}
75
-	}
74
+        }
75
+    }
76 76
 
77
-	// Prepare the whole text of the RSS file.
78
-	$rsstext = '<?xml version="1.0" encoding="utf-8"?>
77
+    // Prepare the whole text of the RSS file.
78
+    $rsstext = '<?xml version="1.0" encoding="utf-8"?>
79 79
 <rdf:RDF
80 80
   xmlns:dc="http://purl.org/dc/elements/1.1/"
81 81
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 
102 102
 </rdf:RDF>';
103 103
 
104
-	// Write the text to the file...
105
-	$filename = $rsspath . $person_id . '.rdf';
106
-	$fh = @fopen($filename, "w");
107
-	if (!$fh) { # Problem writing, just carry on
108
-		echo "Could not write to file ($filename)\n";
109
-		continue;
110
-	}
111
-	fwrite($fh, $rsstext);
112
-	fclose ($fh);
104
+    // Write the text to the file...
105
+    $filename = $rsspath . $person_id . '.rdf';
106
+    $fh = @fopen($filename, "w");
107
+    if (!$fh) { # Problem writing, just carry on
108
+        echo "Could not write to file ($filename)\n";
109
+        continue;
110
+    }
111
+    fwrite($fh, $rsstext);
112
+    fclose ($fh);
113 113
 }
114 114
 
115 115
 #print "Took " . (time()-$starttime) . " seconds\n";
Please login to merge, or discard this patch.
classes/Search/Normal.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -188,6 +188,9 @@
 block discarded – undo
188 188
         return $items;
189 189
     }
190 190
 
191
+    /**
192
+     * @param \MySociety\TheyWorkForYou\Url $url
193
+     */
191 194
     private function generate_pagination_links($data, $url, $first, $last) {
192 195
         $links = array();
193 196
 
Please login to merge, or discard this patch.