@@ -159,6 +159,9 @@ |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | + /** |
|
163 | + * @param string $type |
|
164 | + */ |
|
162 | 165 | private function getMetadata($args="", $type) { |
163 | 166 | // $type is either 'page' or 'section' |
164 | 167 | global $this_page, $this_section; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function __construct() { |
56 | 56 | |
57 | - include_once METADATAPATH; // defined in config.php |
|
57 | + include_once METADATAPATH; // defined in config.php |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | |
116 | 116 | public function set_page_metadata($page, $key, $value) { |
117 | - $this->setMetadata(array("page"=>$page,"key"=>$key,"value"=>$value)); |
|
117 | + $this->setMetadata(array("page"=>$page, "key"=>$key, "value"=>$value)); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | |
128 | 128 | public function set_section_metadata($section, $key, $value) { |
129 | - $this->setMetadata(array("section"=>$section,"key"=>$key,"value"=>$value)); |
|
129 | + $this->setMetadata(array("section"=>$section, "key"=>$key, "value"=>$value)); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | |
152 | 152 | public function test_for_metadata($type, $item, $key) { |
153 | - $dataarray =& $this->$type; |
|
153 | + $dataarray = & $this->$type; |
|
154 | 154 | |
155 | 155 | if (isset($dataarray[$item][$key])) { |
156 | 156 | return true; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - private function getMetadata($args="", $type) { |
|
162 | + private function getMetadata($args = "", $type) { |
|
163 | 163 | // $type is either 'page' or 'section' |
164 | 164 | global $this_page, $this_section; |
165 | 165 | |
@@ -167,21 +167,21 @@ discard block |
||
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 |
||
206 | 206 | $key = $args["key"]; |
207 | 207 | $value = $args["value"]; |
208 | 208 | |
209 | - twfy_debug("DATA", "Setting: ".$type."[".$item."][".$key."] = '" . print_r($value, 1) . "'"); |
|
209 | + twfy_debug("DATA", "Setting: " . $type . "[" . $item . "][" . $key . "] = '" . print_r($value, 1) . "'"); |
|
210 | 210 | |
211 | - $dataarray =& $this->$type; |
|
211 | + $dataarray = & $this->$type; |
|
212 | 212 | $dataarray[$item][$key] = $value; |
213 | 213 | } |
214 | 214 |
@@ -175,6 +175,11 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | // After SELECT. |
178 | + |
|
179 | + /** |
|
180 | + * @param integer $row_index |
|
181 | + * @param string $column_name |
|
182 | + */ |
|
178 | 183 | public function field($row_index, $column_name) { |
179 | 184 | if ($this->rows > 0) |
180 | 185 | return $this->data[$row_index][$column_name]; |
@@ -187,6 +192,10 @@ discard block |
||
187 | 192 | } |
188 | 193 | |
189 | 194 | // After SELECT. |
195 | + |
|
196 | + /** |
|
197 | + * @param integer $row_index |
|
198 | + */ |
|
190 | 199 | public function row($row_index) { |
191 | 200 | if ($this->success && $this->rows > 0) |
192 | 201 | return $this->data[$row_index]; |
@@ -224,6 +233,9 @@ discard block |
||
224 | 233 | return $html; |
225 | 234 | } |
226 | 235 | |
236 | + /** |
|
237 | + * @param string $errormsg |
|
238 | + */ |
|
227 | 239 | public function error($errormsg) { |
228 | 240 | // When a query goes wrong... |
229 | 241 | $this->success = false; |
@@ -72,7 +72,6 @@ |
||
72 | 72 | * - `$this->field(n,col)` returns an empty string. |
73 | 73 | * - `$this->insert_id()` returns `null`. |
74 | 74 | * - `$this->affected_rows()` returns `null`. |
75 | - |
|
76 | 75 | */ |
77 | 76 | |
78 | 77 | class Query { |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | class Query { |
79 | 79 | |
80 | 80 | public $success = true; |
81 | - public $rows = NULL; |
|
81 | + public $rows = null; |
|
82 | 82 | public $data = array(); |
83 | - public $insert_id = NULL; |
|
84 | - public $affected_rows = NULL; |
|
83 | + public $insert_id = null; |
|
84 | + public $affected_rows = null; |
|
85 | 85 | |
86 | 86 | public function __construct($conn) { |
87 | 87 | $this->conn = $conn; |
88 | 88 | } |
89 | 89 | |
90 | - public function query($sql="", $params = NULL) { |
|
90 | + public function query($sql="", $params = null) { |
|
91 | 91 | |
92 | 92 | if (empty($sql)) { |
93 | 93 | $this->success = false; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | twfy_debug ("SQL", $sql); |
105 | 105 | twfy_debug ("SQL", print_r($params, 1)); |
106 | 106 | |
107 | - if ($params !== NULL) { |
|
107 | + if ($params !== null) { |
|
108 | 108 | // Prepare and execute a statement |
109 | 109 | $pdoStatement = $this->conn->prepare($sql); |
110 | 110 |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $this->conn = $conn; |
88 | 88 | } |
89 | 89 | |
90 | - public function query($sql="", $params = NULL) { |
|
90 | + public function query($sql = "", $params = NULL) { |
|
91 | 91 | |
92 | 92 | if (empty($sql)) { |
93 | 93 | $this->success = false; |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
104 | - twfy_debug ("SQL", $sql); |
|
105 | - twfy_debug ("SQL", print_r($params, 1)); |
|
104 | + twfy_debug("SQL", $sql); |
|
105 | + twfy_debug("SQL", print_r($params, 1)); |
|
106 | 106 | |
107 | 107 | if ($params !== NULL) { |
108 | 108 | // Prepare and execute a statement |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | if (!$this->success) return; |
135 | 135 | |
136 | - if ( (!$pdoStatement) or (empty($pdoStatement)) ) { |
|
136 | + if ((!$pdoStatement) or (empty($pdoStatement))) { |
|
137 | 137 | // A failed query. |
138 | 138 | $this->success = false; |
139 | 139 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | $this->affected_rows = $pdoStatement->rowCount(); |
157 | 157 | |
158 | - twfy_debug ("SQLRESULT", array($this, 'displayResult')); |
|
158 | + twfy_debug("SQLRESULT", array($this, 'displayResult')); |
|
159 | 159 | // mysql_free_result($q); |
160 | 160 | } |
161 | 161 | } |
@@ -112,7 +112,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | * @param string $db_pass The password for the database user |
56 | 56 | * @param string $db_name The name of the database |
57 | 57 | * |
58 | - * @return true If the connection has been created successfully. |
|
58 | + * @return boolean If the connection has been created successfully. |
|
59 | 59 | */ |
60 | 60 | |
61 | 61 | public function init($db_host, $db_user, $db_pass, $db_name) { |
@@ -102,7 +102,7 @@ |
||
102 | 102 | * @return Query An object containing the results of the query. |
103 | 103 | */ |
104 | 104 | |
105 | - public function query($sql, $params = NULL) { |
|
105 | + public function query($sql, $params = null) { |
|
106 | 106 | |
107 | 107 | $start = getmicrotime(); |
108 | 108 | $q = new \MySociety\TheyWorkForYou\Db\Query($this->conn); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $duration = getmicrotime() - $start; |
112 | 112 | global $mysqltotalduration; |
113 | 113 | $mysqltotalduration += $duration; |
114 | - twfy_debug ("SQL", "Complete after $duration seconds."); |
|
114 | + twfy_debug("SQL", "Complete after $duration seconds."); |
|
115 | 115 | // We could also output $q->mysql_info() here, but that's for |
116 | 116 | // PHP >= 4.3.0. |
117 | 117 | return $q; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | public function display_total_duration() { |
128 | 128 | global $mysqltotalduration; |
129 | - twfy_debug ("TIME", "Total time for MySQL queries on this page: " . $mysqltotalduration . " seconds."); |
|
129 | + twfy_debug("TIME", "Total time for MySQL queries on this page: " . $mysqltotalduration . " seconds."); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -92,7 +92,7 @@ |
||
92 | 92 | include_once (INCLUDESPATH."easyparliament/user.php"); |
93 | 93 | |
94 | 94 | // Test to see if this is a new-style template using the renderer class. |
95 | -if (! isset($new_style_template) OR $new_style_template !== TRUE) { |
|
95 | +if (! isset($new_style_template) or $new_style_template !== true) { |
|
96 | 96 | |
97 | 97 | // This is an old-style page. Use the old page classes. |
98 | 98 | include_once (INCLUDESPATH."easyparliament/page.php"); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | First some things to help make our PHP nicer and betterer |
5 | 5 | ********************************************************************************/ |
6 | 6 | |
7 | -error_reporting (E_ALL); |
|
7 | +error_reporting(E_ALL); |
|
8 | 8 | |
9 | 9 | /******************************************************************************** |
10 | 10 | Now some constants that are the same for live and dev versions |
@@ -12,22 +12,22 @@ discard block |
||
12 | 12 | ********************************************************************************/ |
13 | 13 | |
14 | 14 | // In case we need to switch these off globally at some point... |
15 | -define ("ALLOWCOMMENTS", true); |
|
16 | -define ("ALLOWTRACKBACKS", true); |
|
15 | +define("ALLOWCOMMENTS", true); |
|
16 | +define("ALLOWTRACKBACKS", true); |
|
17 | 17 | |
18 | 18 | // These variables are so we can keep date/time formats consistent across the site |
19 | 19 | // and change them easily. |
20 | 20 | // Formats here: http://www.php.net/manual/en/function.date.php |
21 | -define ("LONGERDATEFORMAT", "l, j F Y");// Monday, 31 December 2003 |
|
22 | -define ("LONGDATEFORMAT", "j F Y"); // 31 December 2003 |
|
23 | -define ("SHORTDATEFORMAT", "j M Y"); // 31 Dec 2003 |
|
24 | -define ("TIMEFORMAT", "g:i a"); // 11:59 pm |
|
21 | +define("LONGERDATEFORMAT", "l, j F Y"); // Monday, 31 December 2003 |
|
22 | +define("LONGDATEFORMAT", "j F Y"); // 31 December 2003 |
|
23 | +define("SHORTDATEFORMAT", "j M Y"); // 31 Dec 2003 |
|
24 | +define("TIMEFORMAT", "g:i a"); // 11:59 pm |
|
25 | 25 | |
26 | -define ("SHORTDATEFORMAT_SQL", "%e %b %Y"); // 31 Dec 2003 |
|
27 | -define ("TIMEFORMAT_SQL", "%l:%i %p"); // 11:59 PM |
|
26 | +define("SHORTDATEFORMAT_SQL", "%e %b %Y"); // 31 Dec 2003 |
|
27 | +define("TIMEFORMAT_SQL", "%l:%i %p"); // 11:59 PM |
|
28 | 28 | |
29 | 29 | // Where we store the postcode of users if they search for an MP by postcode. |
30 | -define ('POSTCODE_COOKIE', 'eppc'); |
|
30 | +define('POSTCODE_COOKIE', 'eppc'); |
|
31 | 31 | |
32 | 32 | /******************************************************************************** |
33 | 33 | And now all the files we'll include on every page. |
@@ -41,7 +41,7 @@ discard block |
||
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,42 +70,42 @@ discard block |
||
70 | 70 | |
71 | 71 | // The time the page starts, so we can display the total at the end. |
72 | 72 | // getmicrotime() is in utiltity.php. |
73 | -define ("STARTTIME", getmicrotime()); |
|
73 | +define("STARTTIME", getmicrotime()); |
|
74 | 74 | if (!isset($_SERVER['WINDIR'])) { |
75 | 75 | $rusage = getrusage(); |
76 | - define ('STARTTIMES', $rusage['ru_stime.tv_sec']*1000000 + $rusage['ru_stime.tv_usec']); |
|
77 | - define ('STARTTIMEU', $rusage['ru_utime.tv_sec']*1000000 + $rusage['ru_utime.tv_usec']); |
|
76 | + define('STARTTIMES', $rusage['ru_stime.tv_sec'] * 1000000 + $rusage['ru_stime.tv_usec']); |
|
77 | + define('STARTTIMEU', $rusage['ru_utime.tv_sec'] * 1000000 + $rusage['ru_utime.tv_usec']); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $DATA = new \MySociety\TheyWorkForYou\Data; |
81 | 81 | |
82 | 82 | class ParlDB extends \MySociety\TheyWorkForYou\Db\Connection { |
83 | 83 | public function __construct() { |
84 | - $this->init (OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME); |
|
84 | + $this->init(OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | -include_once (INCLUDESPATH."url.php"); |
|
88 | +include_once (INCLUDESPATH . "url.php"); |
|
89 | 89 | |
90 | 90 | $filter = new \MySociety\TheyWorkForYou\Utility\LibFilter; |
91 | 91 | |
92 | -include_once (INCLUDESPATH."easyparliament/user.php"); |
|
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 | - include_once (INCLUDESPATH."easyparliament/page.php"); |
|
98 | + include_once (INCLUDESPATH . "easyparliament/page.php"); |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
102 | -include_once (INCLUDESPATH."easyparliament/hansardlist.php"); |
|
103 | -include_once (INCLUDESPATH."dbtypes.php"); |
|
104 | -include_once (INCLUDESPATH."easyparliament/commentlist.php"); |
|
105 | -include_once (INCLUDESPATH."easyparliament/comment.php"); |
|
106 | -include_once (INCLUDESPATH."easyparliament/trackback.php"); |
|
102 | +include_once (INCLUDESPATH . "easyparliament/hansardlist.php"); |
|
103 | +include_once (INCLUDESPATH . "dbtypes.php"); |
|
104 | +include_once (INCLUDESPATH . "easyparliament/commentlist.php"); |
|
105 | +include_once (INCLUDESPATH . "easyparliament/comment.php"); |
|
106 | +include_once (INCLUDESPATH . "easyparliament/trackback.php"); |
|
107 | 107 | |
108 | 108 | // Added in as new module by Richard Allan MP |
109 | -include_once (INCLUDESPATH."easyparliament/alert.php"); |
|
109 | +include_once (INCLUDESPATH . "easyparliament/alert.php"); |
|
110 | 110 | |
111 | 111 | twfy_debug_timestamp("at end of init.php"); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | }, $data); |
210 | 210 | |
211 | 211 | foreach (array_keys($this->tag_counts) as $tag) { |
212 | - for ($i=0; $i<$this->tag_counts[$tag]; $i++) { |
|
212 | + for ($i = 0; $i < $this->tag_counts[$tag]; $i++) { |
|
213 | 213 | $data .= "</$tag>"; |
214 | 214 | } |
215 | 215 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | if (!in_array($name, $this->no_close)) { |
229 | 229 | if (isset($this->tag_counts[$name])) { |
230 | 230 | $this->tag_counts[$name]--; |
231 | - return '</'.$name.'>'; |
|
231 | + return '</' . $name . '>'; |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | } else { |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | $ending = $matches[3]; |
245 | 245 | if (in_array($name, array_keys($this->allowed))) { |
246 | 246 | $params = ""; |
247 | - preg_match_all("/([a-z0-9]+)=([\"'])(.*?)\\2/si", $body, $matches_2, PREG_SET_ORDER); # <foo a="b" /> |
|
248 | - preg_match_all("/([a-z0-9]+)(=)([^\"\s']+)/si", $body, $matches_1, PREG_SET_ORDER); # <foo a=b /> |
|
249 | - preg_match_all("/([a-z0-9]+)=([\"'])([^\"']*?)\s*$/si", $body, $matches_3, PREG_SET_ORDER); # <foo a="b /> |
|
247 | + preg_match_all("/([a-z0-9]+)=([\"'])(.*?)\\2/si", $body, $matches_2, PREG_SET_ORDER); # <foo a="b" /> |
|
248 | + preg_match_all("/([a-z0-9]+)(=)([^\"\s']+)/si", $body, $matches_1, PREG_SET_ORDER); # <foo a=b /> |
|
249 | + preg_match_all("/([a-z0-9]+)=([\"'])([^\"']*?)\s*$/si", $body, $matches_3, PREG_SET_ORDER); # <foo a="b /> |
|
250 | 250 | $matches = array_merge($matches_1, $matches_2, $matches_3); |
251 | 251 | |
252 | 252 | foreach ($matches as $match) { |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | if ($ending) { |
276 | 276 | $ending = ' /'; |
277 | 277 | } |
278 | - return '<'.$name.$params.$ending.'>'; |
|
278 | + return '<' . $name . $params . $ending . '>'; |
|
279 | 279 | } else { |
280 | 280 | return ''; |
281 | 281 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | if ($this->strip_comments) { |
287 | 287 | return ''; |
288 | 288 | } else { |
289 | - return '<'.$data.'>'; |
|
289 | + return '<' . $data . '>'; |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | if (preg_match("/^([^:]+)\:/si", $data, $matches)) { |
304 | 304 | if (!in_array($matches[1], $this->allowed_protocols)) { |
305 | - $data = '#'.substr($data, strlen($matches[1])+1); |
|
305 | + $data = '#' . substr($data, strlen($matches[1]) + 1); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | # if there are less than 5, just allow it as-is |
353 | 353 | # |
354 | 354 | |
355 | - if (strlen($data_notags)<5) { |
|
355 | + if (strlen($data_notags) < 5) { |
|
356 | 356 | return $data; |
357 | 357 | } |
358 | 358 | |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | $data |
398 | 398 | ); |
399 | 399 | |
400 | - return $m[1].$data.$m[3]; |
|
400 | + return $m[1] . $data . $m[3]; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | ##################################################################################### |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | |
475 | 475 | |
476 | 476 | |
477 | - return $m[1].$m[2].$m[3]; |
|
477 | + return $m[1] . $m[2] . $m[3]; |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | |
497 | 497 | if ($term != ';') { |
498 | 498 | |
499 | - return '&'.$preamble; |
|
499 | + return '&' . $preamble; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | # |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | if ($this->is_valid_entity($preamble)) { |
507 | 507 | |
508 | - return '&'.$preamble; |
|
508 | + return '&' . $preamble; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | # not an allowed antity, so escape the ampersand |
514 | 514 | # |
515 | 515 | |
516 | - return '&'.$preamble; |
|
516 | + return '&' . $preamble; |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | # inside strings. within general text, we decode hex/dec entities. |
563 | 563 | # |
564 | 564 | |
565 | - public function decode_entities($data, $in_attribute=1) { |
|
565 | + public function decode_entities($data, $in_attribute = 1) { |
|
566 | 566 | |
567 | 567 | $data = preg_replace_callback('!(&)#(\d+);?!', array($this, 'decode_dec_entity'), $data); |
568 | 568 | $data = preg_replace_callback('!(&)#x([0-9a-f]+);?!i', array($this, 'decode_hex_entity'), $data); |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | # |
604 | 604 | |
605 | 605 | if ($d > 127) { |
606 | - if ($orig_type == '%') { return '%'.dechex($d); } |
|
606 | + if ($orig_type == '%') { return '%' . dechex($d); } |
|
607 | 607 | if ($orig_type == '&') { return "&#$d;"; } |
608 | 608 | } |
609 | 609 |
@@ -177,7 +177,8 @@ discard block |
||
177 | 177 | $data = preg_replace("/<([^>]*?)(?=<|$)/", "<$1>", $data); |
178 | 178 | $data = preg_replace("/(^|>)([^<]*?)(?=>)/", "$1<$2", $data); |
179 | 179 | |
180 | - } else { |
|
180 | + } |
|
181 | + else { |
|
181 | 182 | |
182 | 183 | # |
183 | 184 | # escape stray brackets |
@@ -231,7 +232,8 @@ discard block |
||
231 | 232 | return '</'.$name.'>'; |
232 | 233 | } |
233 | 234 | } |
234 | - } else { |
|
235 | + } |
|
236 | + else { |
|
235 | 237 | return ''; |
236 | 238 | } |
237 | 239 | } |
@@ -268,7 +270,8 @@ discard block |
||
268 | 270 | if (!$ending) { |
269 | 271 | if (isset($this->tag_counts[$name])) { |
270 | 272 | $this->tag_counts[$name]++; |
271 | - } else { |
|
273 | + } |
|
274 | + else { |
|
272 | 275 | $this->tag_counts[$name] = 1; |
273 | 276 | } |
274 | 277 | } |
@@ -276,7 +279,8 @@ discard block |
||
276 | 279 | $ending = ' /'; |
277 | 280 | } |
278 | 281 | return '<'.$name.$params.$ending.'>'; |
279 | - } else { |
|
282 | + } |
|
283 | + else { |
|
280 | 284 | return ''; |
281 | 285 | } |
282 | 286 | } |
@@ -285,7 +289,8 @@ discard block |
||
285 | 289 | if (preg_match("/^!--(.*)--$/si", $data)) { |
286 | 290 | if ($this->strip_comments) { |
287 | 291 | return ''; |
288 | - } else { |
|
292 | + } |
|
293 | + else { |
|
289 | 294 | return '<'.$data.'>'; |
290 | 295 | } |
291 | 296 | } |
@@ -324,7 +329,9 @@ discard block |
||
324 | 329 | while (1) { |
325 | 330 | $len = strlen($data); |
326 | 331 | $data = preg_replace("/<({$tags})(\s[^>]*)?(><\\/\\1>|\\/>)/", '', $data); |
327 | - if ($len == strlen($data)) break; |
|
332 | + if ($len == strlen($data)) { |
|
333 | + break; |
|
334 | + } |
|
328 | 335 | } |
329 | 336 | } |
330 | 337 |