@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * Returns false if $base is not absolute, otherwise an IRI. |
| 266 | 266 | * |
| 267 | - * @param IRI|string $base (Absolute) Base IRI |
|
| 267 | + * @param SimplePie_IRI $base (Absolute) Base IRI |
|
| 268 | 268 | * @param IRI|string $relative Relative IRI |
| 269 | 269 | * @return IRI|false |
| 270 | 270 | */ |
@@ -1119,6 +1119,7 @@ discard block |
||
| 1119 | 1119 | /** |
| 1120 | 1120 | * Convert an IRI to a URI (or parts thereof) |
| 1121 | 1121 | * |
| 1122 | + * @param false|string $string |
|
| 1122 | 1123 | * @return string |
| 1123 | 1124 | */ |
| 1124 | 1125 | public function to_uri($string) |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function __set($name, $value) |
| 150 | 150 | { |
| 151 | - if (method_exists($this, 'set_' . $name)) |
|
| 151 | + if (method_exists($this, 'set_'.$name)) |
|
| 152 | 152 | { |
| 153 | - call_user_func(array($this, 'set_' . $name), $value); |
|
| 153 | + call_user_func(array($this, 'set_'.$name), $value); |
|
| 154 | 154 | } |
| 155 | 155 | elseif ( |
| 156 | 156 | $name === 'iauthority' |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | || $name === 'ifragment' |
| 162 | 162 | ) |
| 163 | 163 | { |
| 164 | - call_user_func(array($this, 'set_' . substr($name, 1)), $value); |
|
| 164 | + call_user_func(array($this, 'set_'.substr($name, 1)), $value); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | $return = $this->$name; |
| 192 | 192 | } |
| 193 | 193 | // host -> ihost |
| 194 | - elseif (($prop = 'i' . $name) && array_key_exists($prop, $props)) |
|
| 194 | + elseif (($prop = 'i'.$name) && array_key_exists($prop, $props)) |
|
| 195 | 195 | { |
| 196 | 196 | $name = $prop; |
| 197 | 197 | $return = $this->$prop; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | else |
| 206 | 206 | { |
| 207 | - trigger_error('Undefined property: ' . get_class($this) . '::' . $name, E_USER_NOTICE); |
|
| 207 | + trigger_error('Undefined property: '.get_class($this).'::'.$name, E_USER_NOTICE); |
|
| 208 | 208 | $return = null; |
| 209 | 209 | } |
| 210 | 210 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function __isset($name) |
| 228 | 228 | { |
| 229 | - if (method_exists($this, 'get_' . $name) || isset($this->$name)) |
|
| 229 | + if (method_exists($this, 'get_'.$name) || isset($this->$name)) |
|
| 230 | 230 | { |
| 231 | 231 | return true; |
| 232 | 232 | } |
@@ -243,9 +243,9 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | public function __unset($name) |
| 245 | 245 | { |
| 246 | - if (method_exists($this, 'set_' . $name)) |
|
| 246 | + if (method_exists($this, 'set_'.$name)) |
|
| 247 | 247 | { |
| 248 | - call_user_func(array($this, 'set_' . $name), ''); |
|
| 248 | + call_user_func(array($this, 'set_'.$name), ''); |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
@@ -270,11 +270,11 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | public static function absolutize($base, $relative) |
| 272 | 272 | { |
| 273 | - if (!($relative instanceof SimplePie_IRI)) |
|
| 273 | + if ( ! ($relative instanceof SimplePie_IRI)) |
|
| 274 | 274 | { |
| 275 | 275 | $relative = new SimplePie_IRI($relative); |
| 276 | 276 | } |
| 277 | - if (!$relative->is_valid()) |
|
| 277 | + if ( ! $relative->is_valid()) |
|
| 278 | 278 | { |
| 279 | 279 | return false; |
| 280 | 280 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | else |
| 286 | 286 | { |
| 287 | - if (!($base instanceof SimplePie_IRI)) |
|
| 287 | + if ( ! ($base instanceof SimplePie_IRI)) |
|
| 288 | 288 | { |
| 289 | 289 | $base = new SimplePie_IRI($base); |
| 290 | 290 | } |
@@ -312,11 +312,11 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '') |
| 314 | 314 | { |
| 315 | - $target->ipath = '/' . $relative->ipath; |
|
| 315 | + $target->ipath = '/'.$relative->ipath; |
|
| 316 | 316 | } |
| 317 | 317 | elseif (($last_segment = strrpos($base->ipath, '/')) !== false) |
| 318 | 318 | { |
| 319 | - $target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath; |
|
| 319 | + $target->ipath = substr($base->ipath, 0, $last_segment + 1).$relative->ipath; |
|
| 320 | 320 | } |
| 321 | 321 | else |
| 322 | 322 | { |
@@ -370,19 +370,19 @@ discard block |
||
| 370 | 370 | { |
| 371 | 371 | $match['scheme'] = null; |
| 372 | 372 | } |
| 373 | - if (!isset($match[3]) || $match[3] === '') |
|
| 373 | + if ( ! isset($match[3]) || $match[3] === '') |
|
| 374 | 374 | { |
| 375 | 375 | $match['authority'] = null; |
| 376 | 376 | } |
| 377 | - if (!isset($match[5])) |
|
| 377 | + if ( ! isset($match[5])) |
|
| 378 | 378 | { |
| 379 | 379 | $match['path'] = ''; |
| 380 | 380 | } |
| 381 | - if (!isset($match[6]) || $match[6] === '') |
|
| 381 | + if ( ! isset($match[6]) || $match[6] === '') |
|
| 382 | 382 | { |
| 383 | 383 | $match['query'] = null; |
| 384 | 384 | } |
| 385 | - if (!isset($match[8]) || $match[8] === '') |
|
| 385 | + if ( ! isset($match[8]) || $match[8] === '') |
|
| 386 | 386 | { |
| 387 | 387 | $match['fragment'] = null; |
| 388 | 388 | } |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $input = ''; |
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | - return $output . $input; |
|
| 455 | + return $output.$input; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | // Percent encode anything invalid or not in ucschar |
| 552 | 552 | if ( |
| 553 | 553 | // Invalid sequences |
| 554 | - !$valid |
|
| 554 | + ! $valid |
|
| 555 | 555 | // Non-shortest form sequences are invalid |
| 556 | 556 | || $length > 1 && $character <= 0x7F |
| 557 | 557 | || $length > 2 && $character <= 0x7FF |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | ) |
| 569 | 569 | && ( |
| 570 | 570 | // Everything not in iprivate, if it applies |
| 571 | - !$iprivate |
|
| 571 | + ! $iprivate |
|
| 572 | 572 | || $character < 0xE000 |
| 573 | 573 | || $character > 0x10FFFD |
| 574 | 574 | ) |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | $value = hexdec($bytes[$i]); |
| 619 | 619 | |
| 620 | 620 | // If we're the first byte of sequence: |
| 621 | - if (!$remaining) |
|
| 621 | + if ( ! $remaining) |
|
| 622 | 622 | { |
| 623 | 623 | // Start position |
| 624 | 624 | $start = $i; |
@@ -679,12 +679,12 @@ discard block |
||
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | // If we've reached the end of the current byte sequence, append it to Unicode::$data |
| 682 | - if (!$remaining) |
|
| 682 | + if ( ! $remaining) |
|
| 683 | 683 | { |
| 684 | 684 | // Percent encode anything invalid or not in iunreserved |
| 685 | 685 | if ( |
| 686 | 686 | // Invalid sequences |
| 687 | - !$valid |
|
| 687 | + ! $valid |
|
| 688 | 688 | // Non-shortest form sequences are invalid |
| 689 | 689 | || $length > 1 && $character <= 0x7F |
| 690 | 690 | || $length > 2 && $character <= 0x7FF |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | { |
| 707 | 707 | for ($j = $start; $j <= $i; $j++) |
| 708 | 708 | { |
| 709 | - $string .= '%' . strtoupper($bytes[$j]); |
|
| 709 | + $string .= '%'.strtoupper($bytes[$j]); |
|
| 710 | 710 | } |
| 711 | 711 | } |
| 712 | 712 | else |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | { |
| 726 | 726 | for ($j = $start; $j < $len; $j++) |
| 727 | 727 | { |
| 728 | - $string .= '%' . strtoupper($bytes[$j]); |
|
| 728 | + $string .= '%'.strtoupper($bytes[$j]); |
|
| 729 | 729 | } |
| 730 | 730 | } |
| 731 | 731 | |
@@ -777,7 +777,7 @@ discard block |
||
| 777 | 777 | ) || |
| 778 | 778 | ( |
| 779 | 779 | $this->scheme === null && |
| 780 | - !$isauthority && |
|
| 780 | + ! $isauthority && |
|
| 781 | 781 | strpos($this->ipath, ':') !== false && |
| 782 | 782 | (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) |
| 783 | 783 | ) |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | public function set_iri($iri) |
| 801 | 801 | { |
| 802 | 802 | static $cache; |
| 803 | - if (!$cache) |
|
| 803 | + if ( ! $cache) |
|
| 804 | 804 | { |
| 805 | 805 | $cache = array(); |
| 806 | 806 | } |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | else |
| 825 | 825 | { |
| 826 | 826 | $parsed = $this->parse_iri((string) $iri); |
| 827 | - if (!$parsed) |
|
| 827 | + if ( ! $parsed) |
|
| 828 | 828 | { |
| 829 | 829 | return false; |
| 830 | 830 | } |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | { |
| 861 | 861 | $this->scheme = null; |
| 862 | 862 | } |
| 863 | - elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) |
|
| 863 | + elseif ( ! preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) |
|
| 864 | 864 | { |
| 865 | 865 | $this->scheme = null; |
| 866 | 866 | return false; |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | public function set_authority($authority) |
| 883 | 883 | { |
| 884 | 884 | static $cache; |
| 885 | - if (!$cache) |
|
| 885 | + if ( ! $cache) |
|
| 886 | 886 | $cache = array(); |
| 887 | 887 | |
| 888 | 888 | if ($authority === null) |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | { |
| 979 | 979 | if (SimplePie_Net_IPv6::check_ipv6(substr($ihost, 1, -1))) |
| 980 | 980 | { |
| 981 | - $this->ihost = '[' . SimplePie_Net_IPv6::compress(substr($ihost, 1, -1)) . ']'; |
|
| 981 | + $this->ihost = '['.SimplePie_Net_IPv6::compress(substr($ihost, 1, -1)).']'; |
|
| 982 | 982 | } |
| 983 | 983 | else |
| 984 | 984 | { |
@@ -1052,7 +1052,7 @@ discard block |
||
| 1052 | 1052 | public function set_path($ipath) |
| 1053 | 1053 | { |
| 1054 | 1054 | static $cache; |
| 1055 | - if (!$cache) |
|
| 1055 | + if ( ! $cache) |
|
| 1056 | 1056 | { |
| 1057 | 1057 | $cache = array(); |
| 1058 | 1058 | } |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | $removed = $this->remove_dot_segments($valid); |
| 1070 | 1070 | |
| 1071 | 1071 | $cache[$ipath] = array($valid, $removed); |
| 1072 | - $this->ipath = ($this->scheme !== null) ? $removed : $valid; |
|
| 1072 | + $this->ipath = ($this->scheme !== null) ? $removed : $valid; |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | $this->scheme_normalization(); |
@@ -1124,7 +1124,7 @@ discard block |
||
| 1124 | 1124 | public function to_uri($string) |
| 1125 | 1125 | { |
| 1126 | 1126 | static $non_ascii; |
| 1127 | - if (!$non_ascii) |
|
| 1127 | + if ( ! $non_ascii) |
|
| 1128 | 1128 | { |
| 1129 | 1129 | $non_ascii = implode('', range("\x80", "\xFF")); |
| 1130 | 1130 | } |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | */ |
| 1149 | 1149 | public function get_iri() |
| 1150 | 1150 | { |
| 1151 | - if (!$this->is_valid()) |
|
| 1151 | + if ( ! $this->is_valid()) |
|
| 1152 | 1152 | { |
| 1153 | 1153 | return false; |
| 1154 | 1154 | } |
@@ -1156,27 +1156,27 @@ discard block |
||
| 1156 | 1156 | $iri = ''; |
| 1157 | 1157 | if ($this->scheme !== null) |
| 1158 | 1158 | { |
| 1159 | - $iri .= $this->scheme . ':'; |
|
| 1159 | + $iri .= $this->scheme.':'; |
|
| 1160 | 1160 | } |
| 1161 | 1161 | if (($iauthority = $this->get_iauthority()) !== null) |
| 1162 | 1162 | { |
| 1163 | - $iri .= '//' . $iauthority; |
|
| 1163 | + $iri .= '//'.$iauthority; |
|
| 1164 | 1164 | } |
| 1165 | 1165 | if ($this->ipath !== '') |
| 1166 | 1166 | { |
| 1167 | 1167 | $iri .= $this->ipath; |
| 1168 | 1168 | } |
| 1169 | - elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') |
|
| 1169 | + elseif ( ! empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') |
|
| 1170 | 1170 | { |
| 1171 | 1171 | $iri .= $this->normalization[$this->scheme]['ipath']; |
| 1172 | 1172 | } |
| 1173 | 1173 | if ($this->iquery !== null) |
| 1174 | 1174 | { |
| 1175 | - $iri .= '?' . $this->iquery; |
|
| 1175 | + $iri .= '?'.$this->iquery; |
|
| 1176 | 1176 | } |
| 1177 | 1177 | if ($this->ifragment !== null) |
| 1178 | 1178 | { |
| 1179 | - $iri .= '#' . $this->ifragment; |
|
| 1179 | + $iri .= '#'.$this->ifragment; |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | return $iri; |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | $iauthority = ''; |
| 1205 | 1205 | if ($this->iuserinfo !== null) |
| 1206 | 1206 | { |
| 1207 | - $iauthority .= $this->iuserinfo . '@'; |
|
| 1207 | + $iauthority .= $this->iuserinfo.'@'; |
|
| 1208 | 1208 | } |
| 1209 | 1209 | if ($this->ihost !== null) |
| 1210 | 1210 | { |
@@ -1212,7 +1212,7 @@ discard block |
||
| 1212 | 1212 | } |
| 1213 | 1213 | if ($this->port !== null) |
| 1214 | 1214 | { |
| 1215 | - $iauthority .= ':' . $this->port; |
|
| 1215 | + $iauthority .= ':'.$this->port; |
|
| 1216 | 1216 | } |
| 1217 | 1217 | return $iauthority; |
| 1218 | 1218 | } |
@@ -151,8 +151,7 @@ discard block |
||
| 151 | 151 | if (method_exists($this, 'set_' . $name)) |
| 152 | 152 | { |
| 153 | 153 | call_user_func(array($this, 'set_' . $name), $value); |
| 154 | - } |
|
| 155 | - elseif ( |
|
| 154 | + } elseif ( |
|
| 156 | 155 | $name === 'iauthority' |
| 157 | 156 | || $name === 'iuserinfo' |
| 158 | 157 | || $name === 'ihost' |
@@ -185,8 +184,7 @@ discard block |
||
| 185 | 184 | ) |
| 186 | 185 | { |
| 187 | 186 | $return = $this->{"get_$name"}(); |
| 188 | - } |
|
| 189 | - elseif (array_key_exists($name, $props)) |
|
| 187 | + } elseif (array_key_exists($name, $props)) |
|
| 190 | 188 | { |
| 191 | 189 | $return = $this->$name; |
| 192 | 190 | } |
@@ -201,8 +199,7 @@ discard block |
||
| 201 | 199 | { |
| 202 | 200 | $name = $prop; |
| 203 | 201 | $return = $this->$prop; |
| 204 | - } |
|
| 205 | - else |
|
| 202 | + } else |
|
| 206 | 203 | { |
| 207 | 204 | trigger_error('Undefined property: ' . get_class($this) . '::' . $name, E_USER_NOTICE); |
| 208 | 205 | $return = null; |
@@ -211,8 +208,7 @@ discard block |
||
| 211 | 208 | if ($return === null && isset($this->normalization[$this->scheme][$name])) |
| 212 | 209 | { |
| 213 | 210 | return $this->normalization[$this->scheme][$name]; |
| 214 | - } |
|
| 215 | - else |
|
| 211 | + } else |
|
| 216 | 212 | { |
| 217 | 213 | return $return; |
| 218 | 214 | } |
@@ -229,8 +225,7 @@ discard block |
||
| 229 | 225 | if (method_exists($this, 'get_' . $name) || isset($this->$name)) |
| 230 | 226 | { |
| 231 | 227 | return true; |
| 232 | - } |
|
| 233 | - else |
|
| 228 | + } else |
|
| 234 | 229 | { |
| 235 | 230 | return false; |
| 236 | 231 | } |
@@ -277,12 +272,10 @@ discard block |
||
| 277 | 272 | if (!$relative->is_valid()) |
| 278 | 273 | { |
| 279 | 274 | return false; |
| 280 | - } |
|
| 281 | - elseif ($relative->scheme !== null) |
|
| 275 | + } elseif ($relative->scheme !== null) |
|
| 282 | 276 | { |
| 283 | 277 | return clone $relative; |
| 284 | - } |
|
| 285 | - else |
|
| 278 | + } else |
|
| 286 | 279 | { |
| 287 | 280 | if (!($base instanceof SimplePie_IRI)) |
| 288 | 281 | { |
@@ -296,8 +289,7 @@ discard block |
||
| 296 | 289 | { |
| 297 | 290 | $target = clone $relative; |
| 298 | 291 | $target->scheme = $base->scheme; |
| 299 | - } |
|
| 300 | - else |
|
| 292 | + } else |
|
| 301 | 293 | { |
| 302 | 294 | $target = new SimplePie_IRI; |
| 303 | 295 | $target->scheme = $base->scheme; |
@@ -309,46 +301,39 @@ discard block |
||
| 309 | 301 | if ($relative->ipath[0] === '/') |
| 310 | 302 | { |
| 311 | 303 | $target->ipath = $relative->ipath; |
| 312 | - } |
|
| 313 | - elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '') |
|
| 304 | + } elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '') |
|
| 314 | 305 | { |
| 315 | 306 | $target->ipath = '/' . $relative->ipath; |
| 316 | - } |
|
| 317 | - elseif (($last_segment = strrpos($base->ipath, '/')) !== false) |
|
| 307 | + } elseif (($last_segment = strrpos($base->ipath, '/')) !== false) |
|
| 318 | 308 | { |
| 319 | 309 | $target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath; |
| 320 | - } |
|
| 321 | - else |
|
| 310 | + } else |
|
| 322 | 311 | { |
| 323 | 312 | $target->ipath = $relative->ipath; |
| 324 | 313 | } |
| 325 | 314 | $target->ipath = $target->remove_dot_segments($target->ipath); |
| 326 | 315 | $target->iquery = $relative->iquery; |
| 327 | - } |
|
| 328 | - else |
|
| 316 | + } else |
|
| 329 | 317 | { |
| 330 | 318 | $target->ipath = $base->ipath; |
| 331 | 319 | if ($relative->iquery !== null) |
| 332 | 320 | { |
| 333 | 321 | $target->iquery = $relative->iquery; |
| 334 | - } |
|
| 335 | - elseif ($base->iquery !== null) |
|
| 322 | + } elseif ($base->iquery !== null) |
|
| 336 | 323 | { |
| 337 | 324 | $target->iquery = $base->iquery; |
| 338 | 325 | } |
| 339 | 326 | } |
| 340 | 327 | $target->ifragment = $relative->ifragment; |
| 341 | 328 | } |
| 342 | - } |
|
| 343 | - else |
|
| 329 | + } else |
|
| 344 | 330 | { |
| 345 | 331 | $target = clone $base; |
| 346 | 332 | $target->ifragment = null; |
| 347 | 333 | } |
| 348 | 334 | $target->scheme_normalization(); |
| 349 | 335 | return $target; |
| 350 | - } |
|
| 351 | - else |
|
| 336 | + } else |
|
| 352 | 337 | { |
| 353 | 338 | return false; |
| 354 | 339 | } |
@@ -387,8 +372,7 @@ discard block |
||
| 387 | 372 | $match['fragment'] = null; |
| 388 | 373 | } |
| 389 | 374 | return $match; |
| 390 | - } |
|
| 391 | - else |
|
| 375 | + } else |
|
| 392 | 376 | { |
| 393 | 377 | // This can occur when a paragraph is accidentally parsed as a URI |
| 394 | 378 | return false; |
@@ -410,8 +394,7 @@ discard block |
||
| 410 | 394 | if (strpos($input, '../') === 0) |
| 411 | 395 | { |
| 412 | 396 | $input = substr($input, 3); |
| 413 | - } |
|
| 414 | - elseif (strpos($input, './') === 0) |
|
| 397 | + } elseif (strpos($input, './') === 0) |
|
| 415 | 398 | { |
| 416 | 399 | $input = substr($input, 2); |
| 417 | 400 | } |
@@ -419,8 +402,7 @@ discard block |
||
| 419 | 402 | elseif (strpos($input, '/./') === 0) |
| 420 | 403 | { |
| 421 | 404 | $input = substr($input, 2); |
| 422 | - } |
|
| 423 | - elseif ($input === '/.') |
|
| 405 | + } elseif ($input === '/.') |
|
| 424 | 406 | { |
| 425 | 407 | $input = '/'; |
| 426 | 408 | } |
@@ -429,8 +411,7 @@ discard block |
||
| 429 | 411 | { |
| 430 | 412 | $input = substr($input, 3); |
| 431 | 413 | $output = substr_replace($output, '', strrpos($output, '/')); |
| 432 | - } |
|
| 433 | - elseif ($input === '/..') |
|
| 414 | + } elseif ($input === '/..') |
|
| 434 | 415 | { |
| 435 | 416 | $input = '/'; |
| 436 | 417 | $output = substr_replace($output, '', strrpos($output, '/')); |
@@ -445,8 +426,7 @@ discard block |
||
| 445 | 426 | { |
| 446 | 427 | $output .= substr($input, 0, $pos); |
| 447 | 428 | $input = substr_replace($input, '', 0, $pos); |
| 448 | - } |
|
| 449 | - else |
|
| 429 | + } else |
|
| 450 | 430 | { |
| 451 | 431 | $output .= $input; |
| 452 | 432 | $input = ''; |
@@ -540,8 +520,7 @@ discard block |
||
| 540 | 520 | break; |
| 541 | 521 | } |
| 542 | 522 | } |
| 543 | - } |
|
| 544 | - else |
|
| 523 | + } else |
|
| 545 | 524 | { |
| 546 | 525 | $position = $strlen - 1; |
| 547 | 526 | $valid = false; |
@@ -575,8 +554,9 @@ discard block |
||
| 575 | 554 | ) |
| 576 | 555 | { |
| 577 | 556 | // If we were a character, pretend we weren't, but rather an error. |
| 578 | - if ($valid) |
|
| 579 | - $position--; |
|
| 557 | + if ($valid) { |
|
| 558 | + $position--; |
|
| 559 | + } |
|
| 580 | 560 | |
| 581 | 561 | for ($j = $start; $j <= $position; $j++) |
| 582 | 562 | { |
@@ -708,8 +688,7 @@ discard block |
||
| 708 | 688 | { |
| 709 | 689 | $string .= '%' . strtoupper($bytes[$j]); |
| 710 | 690 | } |
| 711 | - } |
|
| 712 | - else |
|
| 691 | + } else |
|
| 713 | 692 | { |
| 714 | 693 | for ($j = $start; $j <= $i; $j++) |
| 715 | 694 | { |
@@ -808,8 +787,7 @@ discard block |
||
| 808 | 787 | if ($iri === null) |
| 809 | 788 | { |
| 810 | 789 | return true; |
| 811 | - } |
|
| 812 | - elseif (isset($cache[$iri])) |
|
| 790 | + } elseif (isset($cache[$iri])) |
|
| 813 | 791 | { |
| 814 | 792 | list($this->scheme, |
| 815 | 793 | $this->iuserinfo, |
@@ -820,8 +798,7 @@ discard block |
||
| 820 | 798 | $this->ifragment, |
| 821 | 799 | $return) = $cache[$iri]; |
| 822 | 800 | return $return; |
| 823 | - } |
|
| 824 | - else |
|
| 801 | + } else |
|
| 825 | 802 | { |
| 826 | 803 | $parsed = $this->parse_iri((string) $iri); |
| 827 | 804 | if (!$parsed) |
@@ -859,13 +836,11 @@ discard block |
||
| 859 | 836 | if ($scheme === null) |
| 860 | 837 | { |
| 861 | 838 | $this->scheme = null; |
| 862 | - } |
|
| 863 | - elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) |
|
| 839 | + } elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) |
|
| 864 | 840 | { |
| 865 | 841 | $this->scheme = null; |
| 866 | 842 | return false; |
| 867 | - } |
|
| 868 | - else |
|
| 843 | + } else |
|
| 869 | 844 | { |
| 870 | 845 | $this->scheme = strtolower($scheme); |
| 871 | 846 | } |
@@ -882,8 +857,9 @@ discard block |
||
| 882 | 857 | public function set_authority($authority) |
| 883 | 858 | { |
| 884 | 859 | static $cache; |
| 885 | - if (!$cache) |
|
| 886 | - $cache = array(); |
|
| 860 | + if (!$cache) { |
|
| 861 | + $cache = array(); |
|
| 862 | + } |
|
| 887 | 863 | |
| 888 | 864 | if ($authority === null) |
| 889 | 865 | { |
@@ -891,8 +867,7 @@ discard block |
||
| 891 | 867 | $this->ihost = null; |
| 892 | 868 | $this->port = null; |
| 893 | 869 | return true; |
| 894 | - } |
|
| 895 | - elseif (isset($cache[$authority])) |
|
| 870 | + } elseif (isset($cache[$authority])) |
|
| 896 | 871 | { |
| 897 | 872 | list($this->iuserinfo, |
| 898 | 873 | $this->ihost, |
@@ -900,16 +875,14 @@ discard block |
||
| 900 | 875 | $return) = $cache[$authority]; |
| 901 | 876 | |
| 902 | 877 | return $return; |
| 903 | - } |
|
| 904 | - else |
|
| 878 | + } else |
|
| 905 | 879 | { |
| 906 | 880 | $remaining = $authority; |
| 907 | 881 | if (($iuserinfo_end = strrpos($remaining, '@')) !== false) |
| 908 | 882 | { |
| 909 | 883 | $iuserinfo = substr($remaining, 0, $iuserinfo_end); |
| 910 | 884 | $remaining = substr($remaining, $iuserinfo_end + 1); |
| 911 | - } |
|
| 912 | - else |
|
| 885 | + } else |
|
| 913 | 886 | { |
| 914 | 887 | $iuserinfo = null; |
| 915 | 888 | } |
@@ -920,8 +893,7 @@ discard block |
||
| 920 | 893 | $port = null; |
| 921 | 894 | } |
| 922 | 895 | $remaining = substr($remaining, 0, $port_start); |
| 923 | - } |
|
| 924 | - else |
|
| 896 | + } else |
|
| 925 | 897 | { |
| 926 | 898 | $port = null; |
| 927 | 899 | } |
@@ -950,8 +922,7 @@ discard block |
||
| 950 | 922 | if ($iuserinfo === null) |
| 951 | 923 | { |
| 952 | 924 | $this->iuserinfo = null; |
| 953 | - } |
|
| 954 | - else |
|
| 925 | + } else |
|
| 955 | 926 | { |
| 956 | 927 | $this->iuserinfo = $this->replace_invalid_with_pct_encoding($iuserinfo, '!$&\'()*+,;=:'); |
| 957 | 928 | $this->scheme_normalization(); |
@@ -973,20 +944,17 @@ discard block |
||
| 973 | 944 | { |
| 974 | 945 | $this->ihost = null; |
| 975 | 946 | return true; |
| 976 | - } |
|
| 977 | - elseif (substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']') |
|
| 947 | + } elseif (substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']') |
|
| 978 | 948 | { |
| 979 | 949 | if (SimplePie_Net_IPv6::check_ipv6(substr($ihost, 1, -1))) |
| 980 | 950 | { |
| 981 | 951 | $this->ihost = '[' . SimplePie_Net_IPv6::compress(substr($ihost, 1, -1)) . ']'; |
| 982 | - } |
|
| 983 | - else |
|
| 952 | + } else |
|
| 984 | 953 | { |
| 985 | 954 | $this->ihost = null; |
| 986 | 955 | return false; |
| 987 | 956 | } |
| 988 | - } |
|
| 989 | - else |
|
| 957 | + } else |
|
| 990 | 958 | { |
| 991 | 959 | $ihost = $this->replace_invalid_with_pct_encoding($ihost, '!$&\'()*+,;='); |
| 992 | 960 | |
@@ -1000,8 +968,7 @@ discard block |
||
| 1000 | 968 | if ($ihost[$position] === '%') |
| 1001 | 969 | { |
| 1002 | 970 | $position += 3; |
| 1003 | - } |
|
| 1004 | - else |
|
| 971 | + } else |
|
| 1005 | 972 | { |
| 1006 | 973 | $ihost[$position] = strtolower($ihost[$position]); |
| 1007 | 974 | $position++; |
@@ -1029,14 +996,12 @@ discard block |
||
| 1029 | 996 | { |
| 1030 | 997 | $this->port = null; |
| 1031 | 998 | return true; |
| 1032 | - } |
|
| 1033 | - elseif (strspn($port, '0123456789') === strlen($port)) |
|
| 999 | + } elseif (strspn($port, '0123456789') === strlen($port)) |
|
| 1034 | 1000 | { |
| 1035 | 1001 | $this->port = (int) $port; |
| 1036 | 1002 | $this->scheme_normalization(); |
| 1037 | 1003 | return true; |
| 1038 | - } |
|
| 1039 | - else |
|
| 1004 | + } else |
|
| 1040 | 1005 | { |
| 1041 | 1006 | $this->port = null; |
| 1042 | 1007 | return false; |
@@ -1062,8 +1027,7 @@ discard block |
||
| 1062 | 1027 | if (isset($cache[$ipath])) |
| 1063 | 1028 | { |
| 1064 | 1029 | $this->ipath = $cache[$ipath][(int) ($this->scheme !== null)]; |
| 1065 | - } |
|
| 1066 | - else |
|
| 1030 | + } else |
|
| 1067 | 1031 | { |
| 1068 | 1032 | $valid = $this->replace_invalid_with_pct_encoding($ipath, '!$&\'()*+,;=@:/'); |
| 1069 | 1033 | $removed = $this->remove_dot_segments($valid); |
@@ -1087,8 +1051,7 @@ discard block |
||
| 1087 | 1051 | if ($iquery === null) |
| 1088 | 1052 | { |
| 1089 | 1053 | $this->iquery = null; |
| 1090 | - } |
|
| 1091 | - else |
|
| 1054 | + } else |
|
| 1092 | 1055 | { |
| 1093 | 1056 | $this->iquery = $this->replace_invalid_with_pct_encoding($iquery, '!$&\'()*+,;=:@/?', true); |
| 1094 | 1057 | $this->scheme_normalization(); |
@@ -1107,8 +1070,7 @@ discard block |
||
| 1107 | 1070 | if ($ifragment === null) |
| 1108 | 1071 | { |
| 1109 | 1072 | $this->ifragment = null; |
| 1110 | - } |
|
| 1111 | - else |
|
| 1073 | + } else |
|
| 1112 | 1074 | { |
| 1113 | 1075 | $this->ifragment = $this->replace_invalid_with_pct_encoding($ifragment, '!$&\'()*+,;=:@/?'); |
| 1114 | 1076 | $this->scheme_normalization(); |
@@ -1165,8 +1127,7 @@ discard block |
||
| 1165 | 1127 | if ($this->ipath !== '') |
| 1166 | 1128 | { |
| 1167 | 1129 | $iri .= $this->ipath; |
| 1168 | - } |
|
| 1169 | - elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') |
|
| 1130 | + } elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') |
|
| 1170 | 1131 | { |
| 1171 | 1132 | $iri .= $this->normalization[$this->scheme]['ipath']; |
| 1172 | 1133 | } |
@@ -1215,8 +1176,7 @@ discard block |
||
| 1215 | 1176 | $iauthority .= ':' . $this->port; |
| 1216 | 1177 | } |
| 1217 | 1178 | return $iauthority; |
| 1218 | - } |
|
| 1219 | - else |
|
| 1179 | + } else |
|
| 1220 | 1180 | { |
| 1221 | 1181 | return null; |
| 1222 | 1182 | } |
@@ -1230,9 +1190,10 @@ discard block |
||
| 1230 | 1190 | protected function get_authority() |
| 1231 | 1191 | { |
| 1232 | 1192 | $iauthority = $this->get_iauthority(); |
| 1233 | - if (is_string($iauthority)) |
|
| 1234 | - return $this->to_uri($iauthority); |
|
| 1235 | - else |
|
| 1236 | - return $iauthority; |
|
| 1193 | + if (is_string($iauthority)) { |
|
| 1194 | + return $this->to_uri($iauthority); |
|
| 1195 | + } else { |
|
| 1196 | + return $iauthority; |
|
| 1197 | + } |
|
| 1237 | 1198 | } |
| 1238 | 1199 | } |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | * @since 1.0 |
| 861 | 861 | * |
| 862 | 862 | * @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data) |
| 863 | - * @return int|string|null |
|
| 863 | + * @return string|null |
|
| 864 | 864 | */ |
| 865 | 865 | public function get_local_date($date_format = '%c') |
| 866 | 866 | { |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | * |
| 884 | 884 | * @see get_date |
| 885 | 885 | * @param string $date_format Supports any PHP date format from {@see http://php.net/date} |
| 886 | - * @return int|string|null |
|
| 886 | + * @return null|string |
|
| 887 | 887 | */ |
| 888 | 888 | public function get_gmdate($date_format = 'j F Y, g:i a') |
| 889 | 889 | { |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | * |
| 902 | 902 | * @see get_updated_date |
| 903 | 903 | * @param string $date_format Supports any PHP date format from {@see http://php.net/date} |
| 904 | - * @return int|string|null |
|
| 904 | + * @return null|string |
|
| 905 | 905 | */ |
| 906 | 906 | public function get_updated_gmdate($date_format = 'j F Y, g:i a') |
| 907 | 907 | { |
@@ -2893,7 +2893,7 @@ discard block |
||
| 2893 | 2893 | * @since 1.0 |
| 2894 | 2894 | * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo |
| 2895 | 2895 | * @link http://www.georss.org/ GeoRSS |
| 2896 | - * @return string|null |
|
| 2896 | + * @return double|null |
|
| 2897 | 2897 | */ |
| 2898 | 2898 | public function get_latitude() |
| 2899 | 2899 | { |
@@ -2921,7 +2921,7 @@ discard block |
||
| 2921 | 2921 | * @since 1.0 |
| 2922 | 2922 | * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo |
| 2923 | 2923 | * @link http://www.georss.org/ GeoRSS |
| 2924 | - * @return string|null |
|
| 2924 | + * @return double|null |
|
| 2925 | 2925 | */ |
| 2926 | 2926 | public function get_longitude() |
| 2927 | 2927 | { |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function __destruct() |
| 124 | 124 | { |
| 125 | - if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) |
|
| 125 | + if ((version_compare(PHP_VERSION, '5.3', '<') || ! gc_enabled()) && ! ini_get('zend.ze1_compatibility_mode')) |
|
| 126 | 126 | { |
| 127 | 127 | unset($this->feed); |
| 128 | 128 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function get_id($hash = false) |
| 214 | 214 | { |
| 215 | - if (!$hash) |
|
| 215 | + if ( ! $hash) |
|
| 216 | 216 | { |
| 217 | 217 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) |
| 218 | 218 | { |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | if ($this->get_permalink() !== null || $this->get_title() !== null) |
| 251 | 251 | { |
| 252 | - return md5($this->get_permalink() . $this->get_title()); |
|
| 252 | + return md5($this->get_permalink().$this->get_title()); |
|
| 253 | 253 | } |
| 254 | 254 | else |
| 255 | 255 | { |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | public function get_title() |
| 269 | 269 | { |
| 270 | - if (!isset($this->data['title'])) |
|
| 270 | + if ( ! isset($this->data['title'])) |
|
| 271 | 271 | { |
| 272 | 272 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) |
| 273 | 273 | { |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - elseif (!$description_only) |
|
| 362 | + elseif ( ! $description_only) |
|
| 363 | 363 | { |
| 364 | 364 | return $this->get_content(true); |
| 365 | 365 | } |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | { |
| 398 | 398 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
| 399 | 399 | } |
| 400 | - elseif (!$content_only) |
|
| 400 | + elseif ( ! $content_only) |
|
| 401 | 401 | { |
| 402 | 402 | return $this->get_description(true); |
| 403 | 403 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - if (!empty($categories)) |
|
| 485 | + if ( ! empty($categories)) |
|
| 486 | 486 | { |
| 487 | 487 | return array_unique($categories); |
| 488 | 488 | } |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - if (!empty($contributors)) |
|
| 591 | + if ( ! empty($contributors)) |
|
| 592 | 592 | { |
| 593 | 593 | return array_unique($contributors); |
| 594 | 594 | } |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - if (!empty($authors)) |
|
| 673 | + if ( ! empty($authors)) |
|
| 674 | 674 | { |
| 675 | 675 | return array_unique($authors); |
| 676 | 676 | } |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | */ |
| 733 | 733 | public function get_date($date_format = 'j F Y, g:i a') |
| 734 | 734 | { |
| 735 | - if (!isset($this->data['date'])) |
|
| 735 | + if ( ! isset($this->data['date'])) |
|
| 736 | 736 | { |
| 737 | 737 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published')) |
| 738 | 738 | { |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | $this->data['date']['raw'] = $return[0]['data']; |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | - if (!empty($this->data['date']['raw'])) |
|
| 770 | + if ( ! empty($this->data['date']['raw'])) |
|
| 771 | 771 | { |
| 772 | 772 | $parser = $this->registry->call('Parse_Date', 'get'); |
| 773 | 773 | $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']); |
@@ -811,14 +811,14 @@ discard block |
||
| 811 | 811 | */ |
| 812 | 812 | public function get_updated_date($date_format = 'j F Y, g:i a') |
| 813 | 813 | { |
| 814 | - if (!isset($this->data['updated'])) |
|
| 814 | + if ( ! isset($this->data['updated'])) |
|
| 815 | 815 | { |
| 816 | 816 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) |
| 817 | 817 | { |
| 818 | 818 | $this->data['updated']['raw'] = $return[0]['data']; |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - if (!empty($this->data['updated']['raw'])) |
|
| 821 | + if ( ! empty($this->data['updated']['raw'])) |
|
| 822 | 822 | { |
| 823 | 823 | $parser = $this->registry->call('Parse_Date', 'get'); |
| 824 | 824 | $this->data['updated']['parsed'] = $parser->parse($this->data['date']['raw']); |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | */ |
| 865 | 865 | public function get_local_date($date_format = '%c') |
| 866 | 866 | { |
| 867 | - if (!$date_format) |
|
| 867 | + if ( ! $date_format) |
|
| 868 | 868 | { |
| 869 | 869 | return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT); |
| 870 | 870 | } |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | */ |
| 975 | 975 | public function get_links($rel = 'alternate') |
| 976 | 976 | { |
| 977 | - if (!isset($this->data['links'])) |
|
| 977 | + if ( ! isset($this->data['links'])) |
|
| 978 | 978 | { |
| 979 | 979 | $this->data['links'] = array(); |
| 980 | 980 | foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | } |
| 1009 | 1009 | if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) |
| 1010 | 1010 | { |
| 1011 | - if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') |
|
| 1011 | + if ( ! isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') |
|
| 1012 | 1012 | { |
| 1013 | 1013 | $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
| 1014 | 1014 | } |
@@ -1019,19 +1019,19 @@ discard block |
||
| 1019 | 1019 | { |
| 1020 | 1020 | if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key))) |
| 1021 | 1021 | { |
| 1022 | - if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) |
|
| 1022 | + if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key])) |
|
| 1023 | 1023 | { |
| 1024 | - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); |
|
| 1025 | - $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; |
|
| 1024 | + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]); |
|
| 1025 | + $this->data['links'][$key] = & $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]; |
|
| 1026 | 1026 | } |
| 1027 | 1027 | else |
| 1028 | 1028 | { |
| 1029 | - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; |
|
| 1029 | + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = & $this->data['links'][$key]; |
|
| 1030 | 1030 | } |
| 1031 | 1031 | } |
| 1032 | 1032 | elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) |
| 1033 | 1033 | { |
| 1034 | - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; |
|
| 1034 | + $this->data['links'][substr($key, 41)] = & $this->data['links'][$key]; |
|
| 1035 | 1035 | } |
| 1036 | 1036 | $this->data['links'][$key] = array_unique($this->data['links'][$key]); |
| 1037 | 1037 | } |
@@ -1085,7 +1085,7 @@ discard block |
||
| 1085 | 1085 | */ |
| 1086 | 1086 | public function get_enclosures() |
| 1087 | 1087 | { |
| 1088 | - if (!isset($this->data['enclosures'])) |
|
| 1088 | + if ( ! isset($this->data['enclosures'])) |
|
| 1089 | 1089 | { |
| 1090 | 1090 | $this->data['enclosures'] = array(); |
| 1091 | 1091 | |
@@ -1732,7 +1732,7 @@ discard block |
||
| 1732 | 1732 | // If we have media:group tags, loop through them. |
| 1733 | 1733 | foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) |
| 1734 | 1734 | { |
| 1735 | - if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) |
|
| 1735 | + if (isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) |
|
| 1736 | 1736 | { |
| 1737 | 1737 | // If we have media:content tags, loop through them. |
| 1738 | 1738 | foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) |
@@ -2762,7 +2762,7 @@ discard block |
||
| 2762 | 2762 | |
| 2763 | 2763 | foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) |
| 2764 | 2764 | { |
| 2765 | - if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') |
|
| 2765 | + if (isset($link['attribs']['']['href']) && ! empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') |
|
| 2766 | 2766 | { |
| 2767 | 2767 | // Attributes |
| 2768 | 2768 | $bitrate = null; |
@@ -2797,7 +2797,7 @@ discard block |
||
| 2797 | 2797 | |
| 2798 | 2798 | foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) |
| 2799 | 2799 | { |
| 2800 | - if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') |
|
| 2800 | + if (isset($link['attribs']['']['href']) && ! empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') |
|
| 2801 | 2801 | { |
| 2802 | 2802 | // Attributes |
| 2803 | 2803 | $bitrate = null; |
@@ -2873,7 +2873,7 @@ discard block |
||
| 2873 | 2873 | |
| 2874 | 2874 | $this->data['enclosures'] = array_values(array_unique($this->data['enclosures'])); |
| 2875 | 2875 | } |
| 2876 | - if (!empty($this->data['enclosures'])) |
|
| 2876 | + if ( ! empty($this->data['enclosures'])) |
|
| 2877 | 2877 | { |
| 2878 | 2878 | return $this->data['enclosures']; |
| 2879 | 2879 | } |
@@ -147,8 +147,7 @@ discard block |
||
| 147 | 147 | if (isset($this->data['child'][$namespace][$tag])) |
| 148 | 148 | { |
| 149 | 149 | return $this->data['child'][$namespace][$tag]; |
| 150 | - } |
|
| 151 | - else |
|
| 150 | + } else |
|
| 152 | 151 | { |
| 153 | 152 | return null; |
| 154 | 153 | } |
@@ -217,32 +216,25 @@ discard block |
||
| 217 | 216 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) |
| 218 | 217 | { |
| 219 | 218 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 220 | - } |
|
| 221 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) |
|
| 219 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) |
|
| 222 | 220 | { |
| 223 | 221 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 224 | - } |
|
| 225 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) |
|
| 222 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) |
|
| 226 | 223 | { |
| 227 | 224 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 228 | - } |
|
| 229 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) |
|
| 225 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) |
|
| 230 | 226 | { |
| 231 | 227 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 232 | - } |
|
| 233 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) |
|
| 228 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) |
|
| 234 | 229 | { |
| 235 | 230 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 236 | - } |
|
| 237 | - elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'])) |
|
| 231 | + } elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'])) |
|
| 238 | 232 | { |
| 239 | 233 | return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 240 | - } |
|
| 241 | - elseif (($return = $this->get_permalink()) !== null) |
|
| 234 | + } elseif (($return = $this->get_permalink()) !== null) |
|
| 242 | 235 | { |
| 243 | 236 | return $return; |
| 244 | - } |
|
| 245 | - elseif (($return = $this->get_title()) !== null) |
|
| 237 | + } elseif (($return = $this->get_title()) !== null) |
|
| 246 | 238 | { |
| 247 | 239 | return $return; |
| 248 | 240 | } |
@@ -250,8 +242,7 @@ discard block |
||
| 250 | 242 | if ($this->get_permalink() !== null || $this->get_title() !== null) |
| 251 | 243 | { |
| 252 | 244 | return md5($this->get_permalink() . $this->get_title()); |
| 253 | - } |
|
| 254 | - else |
|
| 245 | + } else |
|
| 255 | 246 | { |
| 256 | 247 | return md5(serialize($this->data)); |
| 257 | 248 | } |
@@ -272,32 +263,25 @@ discard block |
||
| 272 | 263 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) |
| 273 | 264 | { |
| 274 | 265 | $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
| 275 | - } |
|
| 276 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) |
|
| 266 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) |
|
| 277 | 267 | { |
| 278 | 268 | $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
| 279 | - } |
|
| 280 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) |
|
| 269 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) |
|
| 281 | 270 | { |
| 282 | 271 | $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
| 283 | - } |
|
| 284 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) |
|
| 272 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) |
|
| 285 | 273 | { |
| 286 | 274 | $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
| 287 | - } |
|
| 288 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) |
|
| 275 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) |
|
| 289 | 276 | { |
| 290 | 277 | $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
| 291 | - } |
|
| 292 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) |
|
| 278 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) |
|
| 293 | 279 | { |
| 294 | 280 | $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 295 | - } |
|
| 296 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
|
| 281 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
|
| 297 | 282 | { |
| 298 | 283 | $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 299 | - } |
|
| 300 | - else |
|
| 284 | + } else |
|
| 301 | 285 | { |
| 302 | 286 | $this->data['title'] = null; |
| 303 | 287 | } |
@@ -325,45 +309,34 @@ discard block |
||
| 325 | 309 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) |
| 326 | 310 | { |
| 327 | 311 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
| 328 | - } |
|
| 329 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) |
|
| 312 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) |
|
| 330 | 313 | { |
| 331 | 314 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
| 332 | - } |
|
| 333 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) |
|
| 315 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) |
|
| 334 | 316 | { |
| 335 | 317 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
| 336 | - } |
|
| 337 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) |
|
| 318 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) |
|
| 338 | 319 | { |
| 339 | 320 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
| 340 | - } |
|
| 341 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) |
|
| 321 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) |
|
| 342 | 322 | { |
| 343 | 323 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 344 | - } |
|
| 345 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) |
|
| 324 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) |
|
| 346 | 325 | { |
| 347 | 326 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 348 | - } |
|
| 349 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) |
|
| 327 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) |
|
| 350 | 328 | { |
| 351 | 329 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
| 352 | - } |
|
| 353 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) |
|
| 330 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) |
|
| 354 | 331 | { |
| 355 | 332 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 356 | - } |
|
| 357 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) |
|
| 333 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) |
|
| 358 | 334 | { |
| 359 | 335 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML); |
| 360 | - } |
|
| 361 | - |
|
| 362 | - elseif (!$description_only) |
|
| 336 | + } elseif (!$description_only) |
|
| 363 | 337 | { |
| 364 | 338 | return $this->get_content(true); |
| 365 | - } |
|
| 366 | - else |
|
| 339 | + } else |
|
| 367 | 340 | { |
| 368 | 341 | return null; |
| 369 | 342 | } |
@@ -388,20 +361,16 @@ discard block |
||
| 388 | 361 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) |
| 389 | 362 | { |
| 390 | 363 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
| 391 | - } |
|
| 392 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) |
|
| 364 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) |
|
| 393 | 365 | { |
| 394 | 366 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
| 395 | - } |
|
| 396 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) |
|
| 367 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) |
|
| 397 | 368 | { |
| 398 | 369 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
| 399 | - } |
|
| 400 | - elseif (!$content_only) |
|
| 370 | + } elseif (!$content_only) |
|
| 401 | 371 | { |
| 402 | 372 | return $this->get_description(true); |
| 403 | - } |
|
| 404 | - else |
|
| 373 | + } else |
|
| 405 | 374 | { |
| 406 | 375 | return null; |
| 407 | 376 | } |
@@ -420,8 +389,7 @@ discard block |
||
| 420 | 389 | if (isset($categories[$key])) |
| 421 | 390 | { |
| 422 | 391 | return $categories[$key]; |
| 423 | - } |
|
| 424 | - else |
|
| 392 | + } else |
|
| 425 | 393 | { |
| 426 | 394 | return null; |
| 427 | 395 | } |
@@ -466,8 +434,7 @@ discard block |
||
| 466 | 434 | if (isset($category['attribs']['']['domain'])) |
| 467 | 435 | { |
| 468 | 436 | $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 469 | - } |
|
| 470 | - else |
|
| 437 | + } else |
|
| 471 | 438 | { |
| 472 | 439 | $scheme = null; |
| 473 | 440 | } |
@@ -485,8 +452,7 @@ discard block |
||
| 485 | 452 | if (!empty($categories)) |
| 486 | 453 | { |
| 487 | 454 | return array_unique($categories); |
| 488 | - } |
|
| 489 | - else |
|
| 455 | + } else |
|
| 490 | 456 | { |
| 491 | 457 | return null; |
| 492 | 458 | } |
@@ -505,8 +471,7 @@ discard block |
||
| 505 | 471 | if (isset($authors[$key])) |
| 506 | 472 | { |
| 507 | 473 | return $authors[$key]; |
| 508 | - } |
|
| 509 | - else |
|
| 474 | + } else |
|
| 510 | 475 | { |
| 511 | 476 | return null; |
| 512 | 477 | } |
@@ -525,8 +490,7 @@ discard block |
||
| 525 | 490 | if (isset($contributors[$key])) |
| 526 | 491 | { |
| 527 | 492 | return $contributors[$key]; |
| 528 | - } |
|
| 529 | - else |
|
| 493 | + } else |
|
| 530 | 494 | { |
| 531 | 495 | return null; |
| 532 | 496 | } |
@@ -591,8 +555,7 @@ discard block |
||
| 591 | 555 | if (!empty($contributors)) |
| 592 | 556 | { |
| 593 | 557 | return array_unique($contributors); |
| 594 | - } |
|
| 595 | - else |
|
| 558 | + } else |
|
| 596 | 559 | { |
| 597 | 560 | return null; |
| 598 | 561 | } |
@@ -673,16 +636,13 @@ discard block |
||
| 673 | 636 | if (!empty($authors)) |
| 674 | 637 | { |
| 675 | 638 | return array_unique($authors); |
| 676 | - } |
|
| 677 | - elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) |
|
| 639 | + } elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) |
|
| 678 | 640 | { |
| 679 | 641 | return $authors; |
| 680 | - } |
|
| 681 | - elseif ($authors = $this->feed->get_authors()) |
|
| 642 | + } elseif ($authors = $this->feed->get_authors()) |
|
| 682 | 643 | { |
| 683 | 644 | return $authors; |
| 684 | - } |
|
| 685 | - else |
|
| 645 | + } else |
|
| 686 | 646 | { |
| 687 | 647 | return null; |
| 688 | 648 | } |
@@ -701,16 +661,13 @@ discard block |
||
| 701 | 661 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) |
| 702 | 662 | { |
| 703 | 663 | return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
| 704 | - } |
|
| 705 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) |
|
| 664 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) |
|
| 706 | 665 | { |
| 707 | 666 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 708 | - } |
|
| 709 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) |
|
| 667 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) |
|
| 710 | 668 | { |
| 711 | 669 | return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 712 | - } |
|
| 713 | - else |
|
| 670 | + } else |
|
| 714 | 671 | { |
| 715 | 672 | return null; |
| 716 | 673 | } |
@@ -737,32 +694,25 @@ discard block |
||
| 737 | 694 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published')) |
| 738 | 695 | { |
| 739 | 696 | $this->data['date']['raw'] = $return[0]['data']; |
| 740 | - } |
|
| 741 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) |
|
| 697 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) |
|
| 742 | 698 | { |
| 743 | 699 | $this->data['date']['raw'] = $return[0]['data']; |
| 744 | - } |
|
| 745 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued')) |
|
| 700 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued')) |
|
| 746 | 701 | { |
| 747 | 702 | $this->data['date']['raw'] = $return[0]['data']; |
| 748 | - } |
|
| 749 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created')) |
|
| 703 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created')) |
|
| 750 | 704 | { |
| 751 | 705 | $this->data['date']['raw'] = $return[0]['data']; |
| 752 | - } |
|
| 753 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) |
|
| 706 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) |
|
| 754 | 707 | { |
| 755 | 708 | $this->data['date']['raw'] = $return[0]['data']; |
| 756 | - } |
|
| 757 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) |
|
| 709 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) |
|
| 758 | 710 | { |
| 759 | 711 | $this->data['date']['raw'] = $return[0]['data']; |
| 760 | - } |
|
| 761 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) |
|
| 712 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) |
|
| 762 | 713 | { |
| 763 | 714 | $this->data['date']['raw'] = $return[0]['data']; |
| 764 | - } |
|
| 765 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) |
|
| 715 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) |
|
| 766 | 716 | { |
| 767 | 717 | $this->data['date']['raw'] = $return[0]['data']; |
| 768 | 718 | } |
@@ -771,8 +721,7 @@ discard block |
||
| 771 | 721 | { |
| 772 | 722 | $parser = $this->registry->call('Parse_Date', 'get'); |
| 773 | 723 | $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']); |
| 774 | - } |
|
| 775 | - else |
|
| 724 | + } else |
|
| 776 | 725 | { |
| 777 | 726 | $this->data['date'] = null; |
| 778 | 727 | } |
@@ -791,8 +740,7 @@ discard block |
||
| 791 | 740 | default: |
| 792 | 741 | return date($date_format, $this->data['date']['parsed']); |
| 793 | 742 | } |
| 794 | - } |
|
| 795 | - else |
|
| 743 | + } else |
|
| 796 | 744 | { |
| 797 | 745 | return null; |
| 798 | 746 | } |
@@ -822,8 +770,7 @@ discard block |
||
| 822 | 770 | { |
| 823 | 771 | $parser = $this->registry->call('Parse_Date', 'get'); |
| 824 | 772 | $this->data['updated']['parsed'] = $parser->parse($this->data['date']['raw']); |
| 825 | - } |
|
| 826 | - else |
|
| 773 | + } else |
|
| 827 | 774 | { |
| 828 | 775 | $this->data['updated'] = null; |
| 829 | 776 | } |
@@ -842,8 +789,7 @@ discard block |
||
| 842 | 789 | default: |
| 843 | 790 | return date($date_format, $this->data['updated']['parsed']); |
| 844 | 791 | } |
| 845 | - } |
|
| 846 | - else |
|
| 792 | + } else |
|
| 847 | 793 | { |
| 848 | 794 | return null; |
| 849 | 795 | } |
@@ -867,12 +813,10 @@ discard block |
||
| 867 | 813 | if (!$date_format) |
| 868 | 814 | { |
| 869 | 815 | return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT); |
| 870 | - } |
|
| 871 | - elseif (($date = $this->get_date('U')) !== null && $date !== false) |
|
| 816 | + } elseif (($date = $this->get_date('U')) !== null && $date !== false) |
|
| 872 | 817 | { |
| 873 | 818 | return strftime($date_format, $date); |
| 874 | - } |
|
| 875 | - else |
|
| 819 | + } else |
|
| 876 | 820 | { |
| 877 | 821 | return null; |
| 878 | 822 | } |
@@ -931,12 +875,10 @@ discard block |
||
| 931 | 875 | if ($link !== null) |
| 932 | 876 | { |
| 933 | 877 | return $link; |
| 934 | - } |
|
| 935 | - elseif ($enclosure !== null) |
|
| 878 | + } elseif ($enclosure !== null) |
|
| 936 | 879 | { |
| 937 | 880 | return $enclosure->get_link(); |
| 938 | - } |
|
| 939 | - else |
|
| 881 | + } else |
|
| 940 | 882 | { |
| 941 | 883 | return null; |
| 942 | 884 | } |
@@ -956,8 +898,7 @@ discard block |
||
| 956 | 898 | if ($links[$key] !== null) |
| 957 | 899 | { |
| 958 | 900 | return $links[$key]; |
| 959 | - } |
|
| 960 | - else |
|
| 901 | + } else |
|
| 961 | 902 | { |
| 962 | 903 | return null; |
| 963 | 904 | } |
@@ -1023,13 +964,11 @@ discard block |
||
| 1023 | 964 | { |
| 1024 | 965 | $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); |
| 1025 | 966 | $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; |
| 1026 | - } |
|
| 1027 | - else |
|
| 967 | + } else |
|
| 1028 | 968 | { |
| 1029 | 969 | $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; |
| 1030 | 970 | } |
| 1031 | - } |
|
| 1032 | - elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) |
|
| 971 | + } elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) |
|
| 1033 | 972 | { |
| 1034 | 973 | $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; |
| 1035 | 974 | } |
@@ -1039,8 +978,7 @@ discard block |
||
| 1039 | 978 | if (isset($this->data['links'][$rel])) |
| 1040 | 979 | { |
| 1041 | 980 | return $this->data['links'][$rel]; |
| 1042 | - } |
|
| 1043 | - else |
|
| 981 | + } else |
|
| 1044 | 982 | { |
| 1045 | 983 | return null; |
| 1046 | 984 | } |
@@ -1062,8 +1000,7 @@ discard block |
||
| 1062 | 1000 | if (isset($enclosures[$key])) |
| 1063 | 1001 | { |
| 1064 | 1002 | return $enclosures[$key]; |
| 1065 | - } |
|
| 1066 | - else |
|
| 1003 | + } else |
|
| 1067 | 1004 | { |
| 1068 | 1005 | return null; |
| 1069 | 1006 | } |
@@ -1139,8 +1076,7 @@ discard block |
||
| 1139 | 1076 | } |
| 1140 | 1077 | $captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
| 1141 | 1078 | } |
| 1142 | - } |
|
| 1143 | - elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) |
|
| 1079 | + } elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) |
|
| 1144 | 1080 | { |
| 1145 | 1081 | foreach ($captions as $caption) |
| 1146 | 1082 | { |
@@ -1190,8 +1126,7 @@ discard block |
||
| 1190 | 1126 | if (isset($category['attribs']['']['scheme'])) |
| 1191 | 1127 | { |
| 1192 | 1128 | $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1193 | - } |
|
| 1194 | - else |
|
| 1129 | + } else |
|
| 1195 | 1130 | { |
| 1196 | 1131 | $scheme = 'http://search.yahoo.com/mrss/category_schema'; |
| 1197 | 1132 | } |
@@ -1213,8 +1148,7 @@ discard block |
||
| 1213 | 1148 | if (isset($category['attribs']['']['scheme'])) |
| 1214 | 1149 | { |
| 1215 | 1150 | $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1216 | - } |
|
| 1217 | - else |
|
| 1151 | + } else |
|
| 1218 | 1152 | { |
| 1219 | 1153 | $scheme = 'http://search.yahoo.com/mrss/category_schema'; |
| 1220 | 1154 | } |
@@ -1266,8 +1200,7 @@ discard block |
||
| 1266 | 1200 | $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1267 | 1201 | } |
| 1268 | 1202 | $copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
| 1269 | - } |
|
| 1270 | - elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) |
|
| 1203 | + } elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) |
|
| 1271 | 1204 | { |
| 1272 | 1205 | $copyright_url = null; |
| 1273 | 1206 | $copyright_label = null; |
@@ -1297,8 +1230,7 @@ discard block |
||
| 1297 | 1230 | if (isset($credit['attribs']['']['scheme'])) |
| 1298 | 1231 | { |
| 1299 | 1232 | $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1300 | - } |
|
| 1301 | - else |
|
| 1233 | + } else |
|
| 1302 | 1234 | { |
| 1303 | 1235 | $credit_scheme = 'urn:ebu'; |
| 1304 | 1236 | } |
@@ -1308,8 +1240,7 @@ discard block |
||
| 1308 | 1240 | } |
| 1309 | 1241 | $credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
| 1310 | 1242 | } |
| 1311 | - } |
|
| 1312 | - elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) |
|
| 1243 | + } elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) |
|
| 1313 | 1244 | { |
| 1314 | 1245 | foreach ($credits as $credit) |
| 1315 | 1246 | { |
@@ -1323,8 +1254,7 @@ discard block |
||
| 1323 | 1254 | if (isset($credit['attribs']['']['scheme'])) |
| 1324 | 1255 | { |
| 1325 | 1256 | $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1326 | - } |
|
| 1327 | - else |
|
| 1257 | + } else |
|
| 1328 | 1258 | { |
| 1329 | 1259 | $credit_scheme = 'urn:ebu'; |
| 1330 | 1260 | } |
@@ -1347,8 +1277,7 @@ discard block |
||
| 1347 | 1277 | { |
| 1348 | 1278 | $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1349 | 1279 | } |
| 1350 | - } |
|
| 1351 | - elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) |
|
| 1280 | + } elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) |
|
| 1352 | 1281 | { |
| 1353 | 1282 | if (isset($description_parent[0]['data'])) |
| 1354 | 1283 | { |
@@ -1398,15 +1327,13 @@ discard block |
||
| 1398 | 1327 | if (isset($hash['attribs']['']['algo'])) |
| 1399 | 1328 | { |
| 1400 | 1329 | $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1401 | - } |
|
| 1402 | - else |
|
| 1330 | + } else |
|
| 1403 | 1331 | { |
| 1404 | 1332 | $algo = 'md5'; |
| 1405 | 1333 | } |
| 1406 | 1334 | $hashes_parent[] = $algo.':'.$value; |
| 1407 | 1335 | } |
| 1408 | - } |
|
| 1409 | - elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) |
|
| 1336 | + } elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) |
|
| 1410 | 1337 | { |
| 1411 | 1338 | foreach ($hashes_iterator as $hash) |
| 1412 | 1339 | { |
@@ -1419,8 +1346,7 @@ discard block |
||
| 1419 | 1346 | if (isset($hash['attribs']['']['algo'])) |
| 1420 | 1347 | { |
| 1421 | 1348 | $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1422 | - } |
|
| 1423 | - else |
|
| 1349 | + } else |
|
| 1424 | 1350 | { |
| 1425 | 1351 | $algo = 'md5'; |
| 1426 | 1352 | } |
@@ -1444,8 +1370,7 @@ discard block |
||
| 1444 | 1370 | } |
| 1445 | 1371 | } |
| 1446 | 1372 | unset($temp); |
| 1447 | - } |
|
| 1448 | - elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) |
|
| 1373 | + } elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) |
|
| 1449 | 1374 | { |
| 1450 | 1375 | if (isset($keywords[0]['data'])) |
| 1451 | 1376 | { |
@@ -1456,8 +1381,7 @@ discard block |
||
| 1456 | 1381 | } |
| 1457 | 1382 | } |
| 1458 | 1383 | unset($temp); |
| 1459 | - } |
|
| 1460 | - elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) |
|
| 1384 | + } elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) |
|
| 1461 | 1385 | { |
| 1462 | 1386 | if (isset($keywords[0]['data'])) |
| 1463 | 1387 | { |
@@ -1468,8 +1392,7 @@ discard block |
||
| 1468 | 1392 | } |
| 1469 | 1393 | } |
| 1470 | 1394 | unset($temp); |
| 1471 | - } |
|
| 1472 | - elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) |
|
| 1395 | + } elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) |
|
| 1473 | 1396 | { |
| 1474 | 1397 | if (isset($keywords[0]['data'])) |
| 1475 | 1398 | { |
@@ -1493,8 +1416,7 @@ discard block |
||
| 1493 | 1416 | { |
| 1494 | 1417 | $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
| 1495 | 1418 | } |
| 1496 | - } |
|
| 1497 | - elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) |
|
| 1419 | + } elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) |
|
| 1498 | 1420 | { |
| 1499 | 1421 | if (isset($player_parent[0]['attribs']['']['url'])) |
| 1500 | 1422 | { |
@@ -1512,8 +1434,7 @@ discard block |
||
| 1512 | 1434 | if (isset($rating['attribs']['']['scheme'])) |
| 1513 | 1435 | { |
| 1514 | 1436 | $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1515 | - } |
|
| 1516 | - else |
|
| 1437 | + } else |
|
| 1517 | 1438 | { |
| 1518 | 1439 | $rating_scheme = 'urn:simple'; |
| 1519 | 1440 | } |
@@ -1523,8 +1444,7 @@ discard block |
||
| 1523 | 1444 | } |
| 1524 | 1445 | $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
| 1525 | 1446 | } |
| 1526 | - } |
|
| 1527 | - elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) |
|
| 1447 | + } elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) |
|
| 1528 | 1448 | { |
| 1529 | 1449 | foreach ($ratings as $rating) |
| 1530 | 1450 | { |
@@ -1536,8 +1456,7 @@ discard block |
||
| 1536 | 1456 | } |
| 1537 | 1457 | $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
| 1538 | 1458 | } |
| 1539 | - } |
|
| 1540 | - elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) |
|
| 1459 | + } elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) |
|
| 1541 | 1460 | { |
| 1542 | 1461 | foreach ($ratings as $rating) |
| 1543 | 1462 | { |
@@ -1546,8 +1465,7 @@ discard block |
||
| 1546 | 1465 | if (isset($rating['attribs']['']['scheme'])) |
| 1547 | 1466 | { |
| 1548 | 1467 | $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1549 | - } |
|
| 1550 | - else |
|
| 1468 | + } else |
|
| 1551 | 1469 | { |
| 1552 | 1470 | $rating_scheme = 'urn:simple'; |
| 1553 | 1471 | } |
@@ -1557,8 +1475,7 @@ discard block |
||
| 1557 | 1475 | } |
| 1558 | 1476 | $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
| 1559 | 1477 | } |
| 1560 | - } |
|
| 1561 | - elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) |
|
| 1478 | + } elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) |
|
| 1562 | 1479 | { |
| 1563 | 1480 | foreach ($ratings as $rating) |
| 1564 | 1481 | { |
@@ -1598,8 +1515,7 @@ discard block |
||
| 1598 | 1515 | } |
| 1599 | 1516 | $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
| 1600 | 1517 | } |
| 1601 | - } |
|
| 1602 | - elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) |
|
| 1518 | + } elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) |
|
| 1603 | 1519 | { |
| 1604 | 1520 | foreach ($restrictions as $restriction) |
| 1605 | 1521 | { |
@@ -1612,8 +1528,7 @@ discard block |
||
| 1612 | 1528 | } |
| 1613 | 1529 | $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
| 1614 | 1530 | } |
| 1615 | - } |
|
| 1616 | - elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) |
|
| 1531 | + } elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) |
|
| 1617 | 1532 | { |
| 1618 | 1533 | foreach ($restrictions as $restriction) |
| 1619 | 1534 | { |
@@ -1634,8 +1549,7 @@ discard block |
||
| 1634 | 1549 | } |
| 1635 | 1550 | $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
| 1636 | 1551 | } |
| 1637 | - } |
|
| 1638 | - elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) |
|
| 1552 | + } elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) |
|
| 1639 | 1553 | { |
| 1640 | 1554 | foreach ($restrictions as $restriction) |
| 1641 | 1555 | { |
@@ -1652,8 +1566,7 @@ discard block |
||
| 1652 | 1566 | if (is_array($restrictions_parent)) |
| 1653 | 1567 | { |
| 1654 | 1568 | $restrictions_parent = array_values(array_unique($restrictions_parent)); |
| 1655 | - } |
|
| 1656 | - else |
|
| 1569 | + } else |
|
| 1657 | 1570 | { |
| 1658 | 1571 | $restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default')); |
| 1659 | 1572 | } |
@@ -1668,8 +1581,7 @@ discard block |
||
| 1668 | 1581 | $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
| 1669 | 1582 | } |
| 1670 | 1583 | } |
| 1671 | - } |
|
| 1672 | - elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) |
|
| 1584 | + } elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) |
|
| 1673 | 1585 | { |
| 1674 | 1586 | foreach ($thumbnails as $thumbnail) |
| 1675 | 1587 | { |
@@ -1687,8 +1599,7 @@ discard block |
||
| 1687 | 1599 | { |
| 1688 | 1600 | $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1689 | 1601 | } |
| 1690 | - } |
|
| 1691 | - elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) |
|
| 1602 | + } elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) |
|
| 1692 | 1603 | { |
| 1693 | 1604 | if (isset($title_parent[0]['data'])) |
| 1694 | 1605 | { |
@@ -1781,8 +1692,7 @@ discard block |
||
| 1781 | 1692 | if (isset($content['attribs']['']['duration'])) |
| 1782 | 1693 | { |
| 1783 | 1694 | $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1784 | - } |
|
| 1785 | - else |
|
| 1695 | + } else |
|
| 1786 | 1696 | { |
| 1787 | 1697 | $duration = $duration_parent; |
| 1788 | 1698 | } |
@@ -1862,8 +1772,7 @@ discard block |
||
| 1862 | 1772 | { |
| 1863 | 1773 | $captions = array_values(array_unique($captions)); |
| 1864 | 1774 | } |
| 1865 | - } |
|
| 1866 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) |
|
| 1775 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) |
|
| 1867 | 1776 | { |
| 1868 | 1777 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) |
| 1869 | 1778 | { |
@@ -1898,8 +1807,7 @@ discard block |
||
| 1898 | 1807 | { |
| 1899 | 1808 | $captions = array_values(array_unique($captions)); |
| 1900 | 1809 | } |
| 1901 | - } |
|
| 1902 | - else |
|
| 1810 | + } else |
|
| 1903 | 1811 | { |
| 1904 | 1812 | $captions = $captions_parent; |
| 1905 | 1813 | } |
@@ -1919,8 +1827,7 @@ discard block |
||
| 1919 | 1827 | if (isset($category['attribs']['']['scheme'])) |
| 1920 | 1828 | { |
| 1921 | 1829 | $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1922 | - } |
|
| 1923 | - else |
|
| 1830 | + } else |
|
| 1924 | 1831 | { |
| 1925 | 1832 | $scheme = 'http://search.yahoo.com/mrss/category_schema'; |
| 1926 | 1833 | } |
@@ -1945,8 +1852,7 @@ discard block |
||
| 1945 | 1852 | if (isset($category['attribs']['']['scheme'])) |
| 1946 | 1853 | { |
| 1947 | 1854 | $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1948 | - } |
|
| 1949 | - else |
|
| 1855 | + } else |
|
| 1950 | 1856 | { |
| 1951 | 1857 | $scheme = 'http://search.yahoo.com/mrss/category_schema'; |
| 1952 | 1858 | } |
@@ -1960,12 +1866,10 @@ discard block |
||
| 1960 | 1866 | if (is_array($categories) && is_array($categories_parent)) |
| 1961 | 1867 | { |
| 1962 | 1868 | $categories = array_values(array_unique(array_merge($categories, $categories_parent))); |
| 1963 | - } |
|
| 1964 | - elseif (is_array($categories)) |
|
| 1869 | + } elseif (is_array($categories)) |
|
| 1965 | 1870 | { |
| 1966 | 1871 | $categories = array_values(array_unique($categories)); |
| 1967 | - } |
|
| 1968 | - elseif (is_array($categories_parent)) |
|
| 1872 | + } elseif (is_array($categories_parent)) |
|
| 1969 | 1873 | { |
| 1970 | 1874 | $categories = array_values(array_unique($categories_parent)); |
| 1971 | 1875 | } |
@@ -1984,8 +1888,7 @@ discard block |
||
| 1984 | 1888 | $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1985 | 1889 | } |
| 1986 | 1890 | $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
| 1987 | - } |
|
| 1988 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) |
|
| 1891 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) |
|
| 1989 | 1892 | { |
| 1990 | 1893 | $copyright_url = null; |
| 1991 | 1894 | $copyright_label = null; |
@@ -1998,8 +1901,7 @@ discard block |
||
| 1998 | 1901 | $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 1999 | 1902 | } |
| 2000 | 1903 | $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
| 2001 | - } |
|
| 2002 | - else |
|
| 1904 | + } else |
|
| 2003 | 1905 | { |
| 2004 | 1906 | $copyrights = $copyrights_parent; |
| 2005 | 1907 | } |
@@ -2019,8 +1921,7 @@ discard block |
||
| 2019 | 1921 | if (isset($credit['attribs']['']['scheme'])) |
| 2020 | 1922 | { |
| 2021 | 1923 | $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2022 | - } |
|
| 2023 | - else |
|
| 1924 | + } else |
|
| 2024 | 1925 | { |
| 2025 | 1926 | $credit_scheme = 'urn:ebu'; |
| 2026 | 1927 | } |
@@ -2034,8 +1935,7 @@ discard block |
||
| 2034 | 1935 | { |
| 2035 | 1936 | $credits = array_values(array_unique($credits)); |
| 2036 | 1937 | } |
| 2037 | - } |
|
| 2038 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) |
|
| 1938 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) |
|
| 2039 | 1939 | { |
| 2040 | 1940 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) |
| 2041 | 1941 | { |
@@ -2049,8 +1949,7 @@ discard block |
||
| 2049 | 1949 | if (isset($credit['attribs']['']['scheme'])) |
| 2050 | 1950 | { |
| 2051 | 1951 | $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2052 | - } |
|
| 2053 | - else |
|
| 1952 | + } else |
|
| 2054 | 1953 | { |
| 2055 | 1954 | $credit_scheme = 'urn:ebu'; |
| 2056 | 1955 | } |
@@ -2064,8 +1963,7 @@ discard block |
||
| 2064 | 1963 | { |
| 2065 | 1964 | $credits = array_values(array_unique($credits)); |
| 2066 | 1965 | } |
| 2067 | - } |
|
| 2068 | - else |
|
| 1966 | + } else |
|
| 2069 | 1967 | { |
| 2070 | 1968 | $credits = $credits_parent; |
| 2071 | 1969 | } |
@@ -2074,12 +1972,10 @@ discard block |
||
| 2074 | 1972 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) |
| 2075 | 1973 | { |
| 2076 | 1974 | $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2077 | - } |
|
| 2078 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) |
|
| 1975 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) |
|
| 2079 | 1976 | { |
| 2080 | 1977 | $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2081 | - } |
|
| 2082 | - else |
|
| 1978 | + } else |
|
| 2083 | 1979 | { |
| 2084 | 1980 | $description = $description_parent; |
| 2085 | 1981 | } |
@@ -2098,8 +1994,7 @@ discard block |
||
| 2098 | 1994 | if (isset($hash['attribs']['']['algo'])) |
| 2099 | 1995 | { |
| 2100 | 1996 | $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2101 | - } |
|
| 2102 | - else |
|
| 1997 | + } else |
|
| 2103 | 1998 | { |
| 2104 | 1999 | $algo = 'md5'; |
| 2105 | 2000 | } |
@@ -2109,8 +2004,7 @@ discard block |
||
| 2109 | 2004 | { |
| 2110 | 2005 | $hashes = array_values(array_unique($hashes)); |
| 2111 | 2006 | } |
| 2112 | - } |
|
| 2113 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) |
|
| 2007 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) |
|
| 2114 | 2008 | { |
| 2115 | 2009 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) |
| 2116 | 2010 | { |
@@ -2123,8 +2017,7 @@ discard block |
||
| 2123 | 2017 | if (isset($hash['attribs']['']['algo'])) |
| 2124 | 2018 | { |
| 2125 | 2019 | $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2126 | - } |
|
| 2127 | - else |
|
| 2020 | + } else |
|
| 2128 | 2021 | { |
| 2129 | 2022 | $algo = 'md5'; |
| 2130 | 2023 | } |
@@ -2134,8 +2027,7 @@ discard block |
||
| 2134 | 2027 | { |
| 2135 | 2028 | $hashes = array_values(array_unique($hashes)); |
| 2136 | 2029 | } |
| 2137 | - } |
|
| 2138 | - else |
|
| 2030 | + } else |
|
| 2139 | 2031 | { |
| 2140 | 2032 | $hashes = $hashes_parent; |
| 2141 | 2033 | } |
@@ -2156,8 +2048,7 @@ discard block |
||
| 2156 | 2048 | { |
| 2157 | 2049 | $keywords = array_values(array_unique($keywords)); |
| 2158 | 2050 | } |
| 2159 | - } |
|
| 2160 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) |
|
| 2051 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) |
|
| 2161 | 2052 | { |
| 2162 | 2053 | if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) |
| 2163 | 2054 | { |
@@ -2172,8 +2063,7 @@ discard block |
||
| 2172 | 2063 | { |
| 2173 | 2064 | $keywords = array_values(array_unique($keywords)); |
| 2174 | 2065 | } |
| 2175 | - } |
|
| 2176 | - else |
|
| 2066 | + } else |
|
| 2177 | 2067 | { |
| 2178 | 2068 | $keywords = $keywords_parent; |
| 2179 | 2069 | } |
@@ -2182,12 +2072,10 @@ discard block |
||
| 2182 | 2072 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
| 2183 | 2073 | { |
| 2184 | 2074 | $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
| 2185 | - } |
|
| 2186 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
|
| 2075 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
|
| 2187 | 2076 | { |
| 2188 | 2077 | $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
| 2189 | - } |
|
| 2190 | - else |
|
| 2078 | + } else |
|
| 2191 | 2079 | { |
| 2192 | 2080 | $player = $player_parent; |
| 2193 | 2081 | } |
@@ -2202,8 +2090,7 @@ discard block |
||
| 2202 | 2090 | if (isset($rating['attribs']['']['scheme'])) |
| 2203 | 2091 | { |
| 2204 | 2092 | $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2205 | - } |
|
| 2206 | - else |
|
| 2093 | + } else |
|
| 2207 | 2094 | { |
| 2208 | 2095 | $rating_scheme = 'urn:simple'; |
| 2209 | 2096 | } |
@@ -2217,8 +2104,7 @@ discard block |
||
| 2217 | 2104 | { |
| 2218 | 2105 | $ratings = array_values(array_unique($ratings)); |
| 2219 | 2106 | } |
| 2220 | - } |
|
| 2221 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) |
|
| 2107 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) |
|
| 2222 | 2108 | { |
| 2223 | 2109 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) |
| 2224 | 2110 | { |
@@ -2227,8 +2113,7 @@ discard block |
||
| 2227 | 2113 | if (isset($rating['attribs']['']['scheme'])) |
| 2228 | 2114 | { |
| 2229 | 2115 | $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2230 | - } |
|
| 2231 | - else |
|
| 2116 | + } else |
|
| 2232 | 2117 | { |
| 2233 | 2118 | $rating_scheme = 'urn:simple'; |
| 2234 | 2119 | } |
@@ -2242,8 +2127,7 @@ discard block |
||
| 2242 | 2127 | { |
| 2243 | 2128 | $ratings = array_values(array_unique($ratings)); |
| 2244 | 2129 | } |
| 2245 | - } |
|
| 2246 | - else |
|
| 2130 | + } else |
|
| 2247 | 2131 | { |
| 2248 | 2132 | $ratings = $ratings_parent; |
| 2249 | 2133 | } |
@@ -2274,8 +2158,7 @@ discard block |
||
| 2274 | 2158 | { |
| 2275 | 2159 | $restrictions = array_values(array_unique($restrictions)); |
| 2276 | 2160 | } |
| 2277 | - } |
|
| 2278 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) |
|
| 2161 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) |
|
| 2279 | 2162 | { |
| 2280 | 2163 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) |
| 2281 | 2164 | { |
@@ -2300,8 +2183,7 @@ discard block |
||
| 2300 | 2183 | { |
| 2301 | 2184 | $restrictions = array_values(array_unique($restrictions)); |
| 2302 | 2185 | } |
| 2303 | - } |
|
| 2304 | - else |
|
| 2186 | + } else |
|
| 2305 | 2187 | { |
| 2306 | 2188 | $restrictions = $restrictions_parent; |
| 2307 | 2189 | } |
@@ -2317,8 +2199,7 @@ discard block |
||
| 2317 | 2199 | { |
| 2318 | 2200 | $thumbnails = array_values(array_unique($thumbnails)); |
| 2319 | 2201 | } |
| 2320 | - } |
|
| 2321 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) |
|
| 2202 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) |
|
| 2322 | 2203 | { |
| 2323 | 2204 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) |
| 2324 | 2205 | { |
@@ -2328,8 +2209,7 @@ discard block |
||
| 2328 | 2209 | { |
| 2329 | 2210 | $thumbnails = array_values(array_unique($thumbnails)); |
| 2330 | 2211 | } |
| 2331 | - } |
|
| 2332 | - else |
|
| 2212 | + } else |
|
| 2333 | 2213 | { |
| 2334 | 2214 | $thumbnails = $thumbnails_parent; |
| 2335 | 2215 | } |
@@ -2338,12 +2218,10 @@ discard block |
||
| 2338 | 2218 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) |
| 2339 | 2219 | { |
| 2340 | 2220 | $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2341 | - } |
|
| 2342 | - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) |
|
| 2221 | + } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) |
|
| 2343 | 2222 | { |
| 2344 | 2223 | $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2345 | - } |
|
| 2346 | - else |
|
| 2224 | + } else |
|
| 2347 | 2225 | { |
| 2348 | 2226 | $title = $title_parent; |
| 2349 | 2227 | } |
@@ -2403,8 +2281,7 @@ discard block |
||
| 2403 | 2281 | if (isset($content['attribs']['']['duration'])) |
| 2404 | 2282 | { |
| 2405 | 2283 | $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2406 | - } |
|
| 2407 | - else |
|
| 2284 | + } else |
|
| 2408 | 2285 | { |
| 2409 | 2286 | $duration = $duration_parent; |
| 2410 | 2287 | } |
@@ -2486,8 +2363,7 @@ discard block |
||
| 2486 | 2363 | { |
| 2487 | 2364 | $captions = array_values(array_unique($captions)); |
| 2488 | 2365 | } |
| 2489 | - } |
|
| 2490 | - else |
|
| 2366 | + } else |
|
| 2491 | 2367 | { |
| 2492 | 2368 | $captions = $captions_parent; |
| 2493 | 2369 | } |
@@ -2507,8 +2383,7 @@ discard block |
||
| 2507 | 2383 | if (isset($category['attribs']['']['scheme'])) |
| 2508 | 2384 | { |
| 2509 | 2385 | $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2510 | - } |
|
| 2511 | - else |
|
| 2386 | + } else |
|
| 2512 | 2387 | { |
| 2513 | 2388 | $scheme = 'http://search.yahoo.com/mrss/category_schema'; |
| 2514 | 2389 | } |
@@ -2522,16 +2397,13 @@ discard block |
||
| 2522 | 2397 | if (is_array($categories) && is_array($categories_parent)) |
| 2523 | 2398 | { |
| 2524 | 2399 | $categories = array_values(array_unique(array_merge($categories, $categories_parent))); |
| 2525 | - } |
|
| 2526 | - elseif (is_array($categories)) |
|
| 2400 | + } elseif (is_array($categories)) |
|
| 2527 | 2401 | { |
| 2528 | 2402 | $categories = array_values(array_unique($categories)); |
| 2529 | - } |
|
| 2530 | - elseif (is_array($categories_parent)) |
|
| 2403 | + } elseif (is_array($categories_parent)) |
|
| 2531 | 2404 | { |
| 2532 | 2405 | $categories = array_values(array_unique($categories_parent)); |
| 2533 | - } |
|
| 2534 | - else |
|
| 2406 | + } else |
|
| 2535 | 2407 | { |
| 2536 | 2408 | $categories = null; |
| 2537 | 2409 | } |
@@ -2550,8 +2422,7 @@ discard block |
||
| 2550 | 2422 | $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2551 | 2423 | } |
| 2552 | 2424 | $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
| 2553 | - } |
|
| 2554 | - else |
|
| 2425 | + } else |
|
| 2555 | 2426 | { |
| 2556 | 2427 | $copyrights = $copyrights_parent; |
| 2557 | 2428 | } |
@@ -2571,8 +2442,7 @@ discard block |
||
| 2571 | 2442 | if (isset($credit['attribs']['']['scheme'])) |
| 2572 | 2443 | { |
| 2573 | 2444 | $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2574 | - } |
|
| 2575 | - else |
|
| 2445 | + } else |
|
| 2576 | 2446 | { |
| 2577 | 2447 | $credit_scheme = 'urn:ebu'; |
| 2578 | 2448 | } |
@@ -2586,8 +2456,7 @@ discard block |
||
| 2586 | 2456 | { |
| 2587 | 2457 | $credits = array_values(array_unique($credits)); |
| 2588 | 2458 | } |
| 2589 | - } |
|
| 2590 | - else |
|
| 2459 | + } else |
|
| 2591 | 2460 | { |
| 2592 | 2461 | $credits = $credits_parent; |
| 2593 | 2462 | } |
@@ -2596,8 +2465,7 @@ discard block |
||
| 2596 | 2465 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) |
| 2597 | 2466 | { |
| 2598 | 2467 | $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2599 | - } |
|
| 2600 | - else |
|
| 2468 | + } else |
|
| 2601 | 2469 | { |
| 2602 | 2470 | $description = $description_parent; |
| 2603 | 2471 | } |
@@ -2616,8 +2484,7 @@ discard block |
||
| 2616 | 2484 | if (isset($hash['attribs']['']['algo'])) |
| 2617 | 2485 | { |
| 2618 | 2486 | $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2619 | - } |
|
| 2620 | - else |
|
| 2487 | + } else |
|
| 2621 | 2488 | { |
| 2622 | 2489 | $algo = 'md5'; |
| 2623 | 2490 | } |
@@ -2627,8 +2494,7 @@ discard block |
||
| 2627 | 2494 | { |
| 2628 | 2495 | $hashes = array_values(array_unique($hashes)); |
| 2629 | 2496 | } |
| 2630 | - } |
|
| 2631 | - else |
|
| 2497 | + } else |
|
| 2632 | 2498 | { |
| 2633 | 2499 | $hashes = $hashes_parent; |
| 2634 | 2500 | } |
@@ -2649,8 +2515,7 @@ discard block |
||
| 2649 | 2515 | { |
| 2650 | 2516 | $keywords = array_values(array_unique($keywords)); |
| 2651 | 2517 | } |
| 2652 | - } |
|
| 2653 | - else |
|
| 2518 | + } else |
|
| 2654 | 2519 | { |
| 2655 | 2520 | $keywords = $keywords_parent; |
| 2656 | 2521 | } |
@@ -2659,8 +2524,7 @@ discard block |
||
| 2659 | 2524 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
| 2660 | 2525 | { |
| 2661 | 2526 | $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
| 2662 | - } |
|
| 2663 | - else |
|
| 2527 | + } else |
|
| 2664 | 2528 | { |
| 2665 | 2529 | $player = $player_parent; |
| 2666 | 2530 | } |
@@ -2675,8 +2539,7 @@ discard block |
||
| 2675 | 2539 | if (isset($rating['attribs']['']['scheme'])) |
| 2676 | 2540 | { |
| 2677 | 2541 | $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2678 | - } |
|
| 2679 | - else |
|
| 2542 | + } else |
|
| 2680 | 2543 | { |
| 2681 | 2544 | $rating_scheme = 'urn:simple'; |
| 2682 | 2545 | } |
@@ -2690,8 +2553,7 @@ discard block |
||
| 2690 | 2553 | { |
| 2691 | 2554 | $ratings = array_values(array_unique($ratings)); |
| 2692 | 2555 | } |
| 2693 | - } |
|
| 2694 | - else |
|
| 2556 | + } else |
|
| 2695 | 2557 | { |
| 2696 | 2558 | $ratings = $ratings_parent; |
| 2697 | 2559 | } |
@@ -2722,8 +2584,7 @@ discard block |
||
| 2722 | 2584 | { |
| 2723 | 2585 | $restrictions = array_values(array_unique($restrictions)); |
| 2724 | 2586 | } |
| 2725 | - } |
|
| 2726 | - else |
|
| 2587 | + } else |
|
| 2727 | 2588 | { |
| 2728 | 2589 | $restrictions = $restrictions_parent; |
| 2729 | 2590 | } |
@@ -2739,8 +2600,7 @@ discard block |
||
| 2739 | 2600 | { |
| 2740 | 2601 | $thumbnails = array_values(array_unique($thumbnails)); |
| 2741 | 2602 | } |
| 2742 | - } |
|
| 2743 | - else |
|
| 2603 | + } else |
|
| 2744 | 2604 | { |
| 2745 | 2605 | $thumbnails = $thumbnails_parent; |
| 2746 | 2606 | } |
@@ -2749,8 +2609,7 @@ discard block |
||
| 2749 | 2609 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) |
| 2750 | 2610 | { |
| 2751 | 2611 | $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
| 2752 | - } |
|
| 2753 | - else |
|
| 2612 | + } else |
|
| 2754 | 2613 | { |
| 2755 | 2614 | $title = $title_parent; |
| 2756 | 2615 | } |
@@ -2876,8 +2735,7 @@ discard block |
||
| 2876 | 2735 | if (!empty($this->data['enclosures'])) |
| 2877 | 2736 | { |
| 2878 | 2737 | return $this->data['enclosures']; |
| 2879 | - } |
|
| 2880 | - else |
|
| 2738 | + } else |
|
| 2881 | 2739 | { |
| 2882 | 2740 | return null; |
| 2883 | 2741 | } |
@@ -2900,12 +2758,10 @@ discard block |
||
| 2900 | 2758 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) |
| 2901 | 2759 | { |
| 2902 | 2760 | return (float) $return[0]['data']; |
| 2903 | - } |
|
| 2904 | - elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
|
| 2761 | + } elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
|
| 2905 | 2762 | { |
| 2906 | 2763 | return (float) $match[1]; |
| 2907 | - } |
|
| 2908 | - else |
|
| 2764 | + } else |
|
| 2909 | 2765 | { |
| 2910 | 2766 | return null; |
| 2911 | 2767 | } |
@@ -2928,16 +2784,13 @@ discard block |
||
| 2928 | 2784 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) |
| 2929 | 2785 | { |
| 2930 | 2786 | return (float) $return[0]['data']; |
| 2931 | - } |
|
| 2932 | - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) |
|
| 2787 | + } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) |
|
| 2933 | 2788 | { |
| 2934 | 2789 | return (float) $return[0]['data']; |
| 2935 | - } |
|
| 2936 | - elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
|
| 2790 | + } elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
|
| 2937 | 2791 | { |
| 2938 | 2792 | return (float) $match[2]; |
| 2939 | - } |
|
| 2940 | - else |
|
| 2793 | + } else |
|
| 2941 | 2794 | { |
| 2942 | 2795 | return null; |
| 2943 | 2796 | } |
@@ -2954,8 +2807,7 @@ discard block |
||
| 2954 | 2807 | if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) |
| 2955 | 2808 | { |
| 2956 | 2809 | return $this->registry->create('Source', array($this, $return[0])); |
| 2957 | - } |
|
| 2958 | - else |
|
| 2810 | + } else |
|
| 2959 | 2811 | { |
| 2960 | 2812 | return null; |
| 2961 | 2813 | } |
@@ -210,6 +210,9 @@ |
||
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | + /** |
|
| 214 | + * @param string $name |
|
| 215 | + */ |
|
| 213 | 216 | protected function search_elements_by_tag($name, &$done, $feeds) |
| 214 | 217 | { |
| 215 | 218 | if ($this->dom === null) |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $feeds = array_merge($feeds, $this->search_elements_by_tag('a', $done, $feeds)); |
| 201 | 201 | $feeds = array_merge($feeds, $this->search_elements_by_tag('area', $done, $feeds)); |
| 202 | 202 | |
| 203 | - if (!empty($feeds)) |
|
| 203 | + if ( ! empty($feeds)) |
|
| 204 | 204 | { |
| 205 | 205 | return array_values($feeds); |
| 206 | 206 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | continue; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) |
|
| 245 | + if ( ! in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && ! in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('application/rss+xml', 'application/atom+xml'))) && ! isset($feeds[$href])) |
|
| 246 | 246 | { |
| 247 | 247 | $this->checked_feeds++; |
| 248 | 248 | $headers = array( |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | $this->local = array_unique($this->local); |
| 307 | 307 | $this->elsewhere = array_unique($this->elsewhere); |
| 308 | - if (!empty($this->local) || !empty($this->elsewhere)) |
|
| 308 | + if ( ! empty($this->local) || ! empty($this->elsewhere)) |
|
| 309 | 309 | { |
| 310 | 310 | return true; |
| 311 | 311 | } |
@@ -79,8 +79,7 @@ discard block |
||
| 79 | 79 | set_error_handler(array('SimplePie_Misc', 'silence_errors')); |
| 80 | 80 | $this->dom->loadHTML($this->file->body); |
| 81 | 81 | restore_error_handler(); |
| 82 | - } |
|
| 83 | - else |
|
| 82 | + } else |
|
| 84 | 83 | { |
| 85 | 84 | $this->dom = null; |
| 86 | 85 | } |
@@ -151,17 +150,14 @@ discard block |
||
| 151 | 150 | if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml'))) |
| 152 | 151 | { |
| 153 | 152 | return true; |
| 154 | - } |
|
| 155 | - else |
|
| 153 | + } else |
|
| 156 | 154 | { |
| 157 | 155 | return false; |
| 158 | 156 | } |
| 159 | - } |
|
| 160 | - elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) |
|
| 157 | + } elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) |
|
| 161 | 158 | { |
| 162 | 159 | return true; |
| 163 | - } |
|
| 164 | - else |
|
| 160 | + } else |
|
| 165 | 161 | { |
| 166 | 162 | return false; |
| 167 | 163 | } |
@@ -203,8 +199,7 @@ discard block |
||
| 203 | 199 | if (!empty($feeds)) |
| 204 | 200 | { |
| 205 | 201 | return array_values($feeds); |
| 206 | - } |
|
| 207 | - else |
|
| 202 | + } else |
|
| 208 | 203 | { |
| 209 | 204 | return null; |
| 210 | 205 | } |
@@ -232,8 +227,7 @@ discard block |
||
| 232 | 227 | if ($this->base_location < $line) |
| 233 | 228 | { |
| 234 | 229 | $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base)); |
| 235 | - } |
|
| 236 | - else |
|
| 230 | + } else |
|
| 237 | 231 | { |
| 238 | 232 | $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); |
| 239 | 233 | } |
@@ -280,8 +274,7 @@ discard block |
||
| 280 | 274 | if (method_exists($link, 'getLineNo') && $this->base_location < $link->getLineNo()) |
| 281 | 275 | { |
| 282 | 276 | $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base)); |
| 283 | - } |
|
| 284 | - else |
|
| 277 | + } else |
|
| 285 | 278 | { |
| 286 | 279 | $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); |
| 287 | 280 | } |
@@ -295,8 +288,7 @@ discard block |
||
| 295 | 288 | if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) |
| 296 | 289 | { |
| 297 | 290 | $this->local[] = $href; |
| 298 | - } |
|
| 299 | - else |
|
| 291 | + } else |
|
| 300 | 292 | { |
| 301 | 293 | $this->elsewhere[] = $href; |
| 302 | 294 | } |
@@ -331,8 +323,7 @@ discard block |
||
| 331 | 323 | if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) |
| 332 | 324 | { |
| 333 | 325 | return $feed; |
| 334 | - } |
|
| 335 | - else |
|
| 326 | + } else |
|
| 336 | 327 | { |
| 337 | 328 | unset($array[$key]); |
| 338 | 329 | } |
@@ -359,8 +350,7 @@ discard block |
||
| 359 | 350 | if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) |
| 360 | 351 | { |
| 361 | 352 | return $feed; |
| 362 | - } |
|
| 363 | - else |
|
| 353 | + } else |
|
| 364 | 354 | { |
| 365 | 355 | unset($array[$key]); |
| 366 | 356 | } |
@@ -49,6 +49,9 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | class SimplePie_Misc |
| 51 | 51 | { |
| 52 | + /** |
|
| 53 | + * @param integer $seconds |
|
| 54 | + */ |
|
| 52 | 55 | public static function time_hms($seconds) |
| 53 | 56 | { |
| 54 | 57 | $time = ''; |
@@ -329,6 +332,11 @@ discard block |
||
| 329 | 332 | } |
| 330 | 333 | } |
| 331 | 334 | |
| 335 | + /** |
|
| 336 | + * @param string $data |
|
| 337 | + * @param string $input |
|
| 338 | + * @param string $output |
|
| 339 | + */ |
|
| 332 | 340 | protected static function change_encoding_mbstring($data, $input, $output) |
| 333 | 341 | { |
| 334 | 342 | if ($input === 'windows-949') |
@@ -367,6 +375,11 @@ discard block |
||
| 367 | 375 | return false; |
| 368 | 376 | } |
| 369 | 377 | |
| 378 | + /** |
|
| 379 | + * @param string $data |
|
| 380 | + * @param string $input |
|
| 381 | + * @param string $output |
|
| 382 | + */ |
|
| 370 | 383 | protected static function change_encoding_iconv($data, $input, $output) |
| 371 | 384 | { |
| 372 | 385 | return @iconv($input, $output, $data); |
@@ -1696,6 +1709,9 @@ discard block |
||
| 1696 | 1709 | } |
| 1697 | 1710 | } |
| 1698 | 1711 | |
| 1712 | + /** |
|
| 1713 | + * @return string |
|
| 1714 | + */ |
|
| 1699 | 1715 | public static function get_curl_version() |
| 1700 | 1716 | { |
| 1701 | 1717 | if (is_array($curl = curl_version())) |
@@ -1763,7 +1779,6 @@ discard block |
||
| 1763 | 1779 | /** |
| 1764 | 1780 | * Remove RFC822 comments |
| 1765 | 1781 | * |
| 1766 | - * @param string $data Data to strip comments from |
|
| 1767 | 1782 | * @return string Comment stripped string |
| 1768 | 1783 | */ |
| 1769 | 1784 | public static function uncomment_rfc822($string) |
@@ -2019,7 +2034,7 @@ discard block |
||
| 2019 | 2034 | * @todo Add support for EBCDIC |
| 2020 | 2035 | * @param string $data XML data |
| 2021 | 2036 | * @param SimplePie_Registry $registry Class registry |
| 2022 | - * @return array Possible encodings |
|
| 2037 | + * @return string[] Possible encodings |
|
| 2023 | 2038 | */ |
| 2024 | 2039 | public static function xml_encoding($data, $registry) |
| 2025 | 2040 | { |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | $seconds = $remainder % 60; |
| 65 | 65 | if ($minutes < 10 && $hours > 0) |
| 66 | 66 | { |
| 67 | - $minutes = '0' . $minutes; |
|
| 67 | + $minutes = '0'.$minutes; |
|
| 68 | 68 | } |
| 69 | 69 | if ($seconds < 10) |
| 70 | 70 | { |
| 71 | - $seconds = '0' . $seconds; |
|
| 71 | + $seconds = '0'.$seconds; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $time .= $minutes.':'; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $return = array(); |
| 101 | 101 | $name = preg_quote($realname, '/'); |
| 102 | - if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) |
|
| 102 | + if (preg_match_all("/<($name)".SIMPLEPIE_PCRE_HTML_ATTRIBUTE."(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) |
|
| 103 | 103 | { |
| 104 | 104 | for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) |
| 105 | 105 | { |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $return[$i]['content'] = $matches[$i][4][0]; |
| 117 | 117 | } |
| 118 | 118 | $return[$i]['attribs'] = array(); |
| 119 | - if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) |
|
| 119 | + if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' '.$matches[$i][2][0].' ', $attribs, PREG_SET_ORDER)) |
|
| 120 | 120 | { |
| 121 | 121 | for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) |
| 122 | 122 | { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | foreach ($element['attribs'] as $key => $value) |
| 139 | 139 | { |
| 140 | 140 | $key = strtolower($key); |
| 141 | - $full .= " $key=\"" . htmlspecialchars($value['data']) . '"'; |
|
| 141 | + $full .= " $key=\"".htmlspecialchars($value['data']).'"'; |
|
| 142 | 142 | } |
| 143 | 143 | if ($element['self_closing']) |
| 144 | 144 | { |
@@ -172,13 +172,13 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $log_error = true; |
| 175 | - if (!function_exists('error_log')) |
|
| 175 | + if ( ! function_exists('error_log')) |
|
| 176 | 176 | { |
| 177 | 177 | $log_error = false; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $log_file = @ini_get('error_log'); |
| 181 | - if (!empty($log_file) && ('syslog' !== $log_file) && !@is_writable($log_file)) |
|
| 181 | + if ( ! empty($log_file) && ('syslog' !== $log_file) && ! @is_writable($log_file)) |
|
| 182 | 182 | { |
| 183 | 183 | $log_error = false; |
| 184 | 184 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) |
|
| 204 | + if ($parsed['scheme'] === '' && $parsed['authority'] === '' && ! file_exists($url)) |
|
| 205 | 205 | { |
| 206 | 206 | return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); |
| 207 | 207 | } |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | if ($input === 'US-ASCII') |
| 298 | 298 | { |
| 299 | 299 | static $non_ascii_octects = ''; |
| 300 | - if (!$non_ascii_octects) |
|
| 300 | + if ( ! $non_ascii_octects) |
|
| 301 | 301 | { |
| 302 | 302 | for ($i = 0x80; $i <= 0xFF; $i++) |
| 303 | 303 | { |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | { |
| 354 | 354 | return false; |
| 355 | 355 | } |
| 356 | - if (!in_array($input, mb_list_encodings())) |
|
| 356 | + if ( ! in_array($input, mb_list_encodings())) |
|
| 357 | 357 | { |
| 358 | 358 | return false; |
| 359 | 359 | } |
@@ -1738,7 +1738,7 @@ discard block |
||
| 1738 | 1738 | $data = ''; |
| 1739 | 1739 | } |
| 1740 | 1740 | } |
| 1741 | - return $output . $data; |
|
| 1741 | + return $output.$data; |
|
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | 1744 | public static function parse_date($dt) |
@@ -1965,15 +1965,15 @@ discard block |
||
| 1965 | 1965 | } |
| 1966 | 1966 | else if ($codepoint <= 0x7ff) |
| 1967 | 1967 | { |
| 1968 | - return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); |
|
| 1968 | + return chr(0xc0 | ($codepoint >> 6)).chr(0x80 | ($codepoint & 0x3f)); |
|
| 1969 | 1969 | } |
| 1970 | 1970 | else if ($codepoint <= 0xffff) |
| 1971 | 1971 | { |
| 1972 | - return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); |
|
| 1972 | + return chr(0xe0 | ($codepoint >> 12)).chr(0x80 | (($codepoint >> 6) & 0x3f)).chr(0x80 | ($codepoint & 0x3f)); |
|
| 1973 | 1973 | } |
| 1974 | 1974 | else if ($codepoint <= 0x10ffff) |
| 1975 | 1975 | { |
| 1976 | - return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); |
|
| 1976 | + return chr(0xf0 | ($codepoint >> 18)).chr(0x80 | (($codepoint >> 12) & 0x3f)).chr(0x80 | (($codepoint >> 6) & 0x3f)).chr(0x80 | ($codepoint & 0x3f)); |
|
| 1977 | 1977 | } |
| 1978 | 1978 | else |
| 1979 | 1979 | { |
@@ -2129,7 +2129,7 @@ discard block |
||
| 2129 | 2129 | } |
| 2130 | 2130 | header('Content-type: text/javascript; charset: UTF-8'); |
| 2131 | 2131 | header('Cache-Control: must-revalidate'); |
| 2132 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days |
|
| 2132 | + header('Expires: '.gmdate('D, d M Y H:i:s', time() + 604800).' GMT'); // 7 days |
|
| 2133 | 2133 | ?> |
| 2134 | 2134 | function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { |
| 2135 | 2135 | if (placeholder != '') { |
@@ -2163,14 +2163,14 @@ discard block |
||
| 2163 | 2163 | public static function get_build() |
| 2164 | 2164 | { |
| 2165 | 2165 | $root = dirname(dirname(__FILE__)); |
| 2166 | - if (file_exists($root . '/.git/index')) |
|
| 2166 | + if (file_exists($root.'/.git/index')) |
|
| 2167 | 2167 | { |
| 2168 | - return filemtime($root . '/.git/index'); |
|
| 2168 | + return filemtime($root.'/.git/index'); |
|
| 2169 | 2169 | } |
| 2170 | - elseif (file_exists($root . '/SimplePie')) |
|
| 2170 | + elseif (file_exists($root.'/SimplePie')) |
|
| 2171 | 2171 | { |
| 2172 | 2172 | $time = 0; |
| 2173 | - foreach (glob($root . '/SimplePie/*.php') as $file) |
|
| 2173 | + foreach (glob($root.'/SimplePie/*.php') as $file) |
|
| 2174 | 2174 | { |
| 2175 | 2175 | if (($mtime = filemtime($file)) > $time) |
| 2176 | 2176 | { |
@@ -2179,9 +2179,9 @@ discard block |
||
| 2179 | 2179 | } |
| 2180 | 2180 | return $time; |
| 2181 | 2181 | } |
| 2182 | - elseif (file_exists(dirname(__FILE__) . '/Core.php')) |
|
| 2182 | + elseif (file_exists(dirname(__FILE__).'/Core.php')) |
|
| 2183 | 2183 | { |
| 2184 | - return filemtime(dirname(__FILE__) . '/Core.php'); |
|
| 2184 | + return filemtime(dirname(__FILE__).'/Core.php'); |
|
| 2185 | 2185 | } |
| 2186 | 2186 | else |
| 2187 | 2187 | { |
@@ -2194,11 +2194,11 @@ discard block |
||
| 2194 | 2194 | */ |
| 2195 | 2195 | public static function debug(&$sp) |
| 2196 | 2196 | { |
| 2197 | - $info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n"; |
|
| 2198 | - $info .= 'PHP ' . PHP_VERSION . "\n"; |
|
| 2197 | + $info = 'SimplePie '.SIMPLEPIE_VERSION.' Build '.SIMPLEPIE_BUILD."\n"; |
|
| 2198 | + $info .= 'PHP '.PHP_VERSION."\n"; |
|
| 2199 | 2199 | if ($sp->error() !== null) |
| 2200 | 2200 | { |
| 2201 | - $info .= 'Error occurred: ' . $sp->error() . "\n"; |
|
| 2201 | + $info .= 'Error occurred: '.$sp->error()."\n"; |
|
| 2202 | 2202 | } |
| 2203 | 2203 | else |
| 2204 | 2204 | { |
@@ -2214,20 +2214,20 @@ discard block |
||
| 2214 | 2214 | switch ($ext) |
| 2215 | 2215 | { |
| 2216 | 2216 | case 'pcre': |
| 2217 | - $info .= ' Version ' . PCRE_VERSION . "\n"; |
|
| 2217 | + $info .= ' Version '.PCRE_VERSION."\n"; |
|
| 2218 | 2218 | break; |
| 2219 | 2219 | case 'curl': |
| 2220 | 2220 | $version = curl_version(); |
| 2221 | - $info .= ' Version ' . $version['version'] . "\n"; |
|
| 2221 | + $info .= ' Version '.$version['version']."\n"; |
|
| 2222 | 2222 | break; |
| 2223 | 2223 | case 'mbstring': |
| 2224 | - $info .= ' Overloading: ' . mb_get_info('func_overload') . "\n"; |
|
| 2224 | + $info .= ' Overloading: '.mb_get_info('func_overload')."\n"; |
|
| 2225 | 2225 | break; |
| 2226 | 2226 | case 'iconv': |
| 2227 | - $info .= ' Version ' . ICONV_VERSION . "\n"; |
|
| 2227 | + $info .= ' Version '.ICONV_VERSION."\n"; |
|
| 2228 | 2228 | break; |
| 2229 | 2229 | case 'xml': |
| 2230 | - $info .= ' Version ' . LIBXML_DOTTED_VERSION . "\n"; |
|
| 2230 | + $info .= ' Version '.LIBXML_DOTTED_VERSION."\n"; |
|
| 2231 | 2231 | break; |
| 2232 | 2232 | } |
| 2233 | 2233 | } |
@@ -109,8 +109,7 @@ discard block |
||
| 109 | 109 | if (strlen($matches[$i][3][0]) <= 2) |
| 110 | 110 | { |
| 111 | 111 | $return[$i]['self_closing'] = true; |
| 112 | - } |
|
| 113 | - else |
|
| 112 | + } else |
|
| 114 | 113 | { |
| 115 | 114 | $return[$i]['self_closing'] = false; |
| 116 | 115 | $return[$i]['content'] = $matches[$i][4][0]; |
@@ -143,8 +142,7 @@ discard block |
||
| 143 | 142 | if ($element['self_closing']) |
| 144 | 143 | { |
| 145 | 144 | $full .= ' />'; |
| 146 | - } |
|
| 147 | - else |
|
| 145 | + } else |
|
| 148 | 146 | { |
| 149 | 147 | $full .= ">$element[content]</$element[tag]>"; |
| 150 | 148 | } |
@@ -209,16 +207,13 @@ discard block |
||
| 209 | 207 | if ($http === 2 && $parsed['scheme'] !== '') |
| 210 | 208 | { |
| 211 | 209 | return "feed:$url"; |
| 212 | - } |
|
| 213 | - elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') |
|
| 210 | + } elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') |
|
| 214 | 211 | { |
| 215 | 212 | return substr_replace($url, 'podcast', 0, 4); |
| 216 | - } |
|
| 217 | - elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') |
|
| 213 | + } elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') |
|
| 218 | 214 | { |
| 219 | 215 | return substr_replace($url, 'itpc', 0, 4); |
| 220 | - } |
|
| 221 | - else |
|
| 216 | + } else |
|
| 222 | 217 | { |
| 223 | 218 | return $url; |
| 224 | 219 | } |
@@ -259,8 +254,7 @@ discard block |
||
| 259 | 254 | if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) |
| 260 | 255 | { |
| 261 | 256 | return chr($integer); |
| 262 | - } |
|
| 263 | - else |
|
| 257 | + } else |
|
| 264 | 258 | { |
| 265 | 259 | return strtoupper($match[0]); |
| 266 | 260 | } |
@@ -1701,16 +1695,13 @@ discard block |
||
| 1701 | 1695 | if (is_array($curl = curl_version())) |
| 1702 | 1696 | { |
| 1703 | 1697 | $curl = $curl['version']; |
| 1704 | - } |
|
| 1705 | - elseif (substr($curl, 0, 5) === 'curl/') |
|
| 1698 | + } elseif (substr($curl, 0, 5) === 'curl/') |
|
| 1706 | 1699 | { |
| 1707 | 1700 | $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5)); |
| 1708 | - } |
|
| 1709 | - elseif (substr($curl, 0, 8) === 'libcurl/') |
|
| 1701 | + } elseif (substr($curl, 0, 8) === 'libcurl/') |
|
| 1710 | 1702 | { |
| 1711 | 1703 | $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8)); |
| 1712 | - } |
|
| 1713 | - else |
|
| 1704 | + } else |
|
| 1714 | 1705 | { |
| 1715 | 1706 | $curl = 0; |
| 1716 | 1707 | } |
@@ -1732,8 +1723,7 @@ discard block |
||
| 1732 | 1723 | if (($end = strpos($data, '-->', $start)) !== false) |
| 1733 | 1724 | { |
| 1734 | 1725 | $data = substr_replace($data, '', 0, $end + 3); |
| 1735 | - } |
|
| 1736 | - else |
|
| 1726 | + } else |
|
| 1737 | 1727 | { |
| 1738 | 1728 | $data = ''; |
| 1739 | 1729 | } |
@@ -1789,8 +1779,7 @@ discard block |
||
| 1789 | 1779 | { |
| 1790 | 1780 | $position++; |
| 1791 | 1781 | continue; |
| 1792 | - } |
|
| 1793 | - elseif (isset($string[$position])) |
|
| 1782 | + } elseif (isset($string[$position])) |
|
| 1794 | 1783 | { |
| 1795 | 1784 | switch ($string[$position]) |
| 1796 | 1785 | { |
@@ -1803,14 +1792,12 @@ discard block |
||
| 1803 | 1792 | break; |
| 1804 | 1793 | } |
| 1805 | 1794 | $position++; |
| 1806 | - } |
|
| 1807 | - else |
|
| 1795 | + } else |
|
| 1808 | 1796 | { |
| 1809 | 1797 | break; |
| 1810 | 1798 | } |
| 1811 | 1799 | } |
| 1812 | - } |
|
| 1813 | - else |
|
| 1800 | + } else |
|
| 1814 | 1801 | { |
| 1815 | 1802 | $output .= '('; |
| 1816 | 1803 | } |
@@ -1825,8 +1812,7 @@ discard block |
||
| 1825 | 1812 | if (($pos = strpos($mime, ';')) === false) |
| 1826 | 1813 | { |
| 1827 | 1814 | return trim($mime); |
| 1828 | - } |
|
| 1829 | - else |
|
| 1815 | + } else |
|
| 1830 | 1816 | { |
| 1831 | 1817 | return trim(substr($mime, 0, $pos)); |
| 1832 | 1818 | } |
@@ -1837,8 +1823,7 @@ discard block |
||
| 1837 | 1823 | if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64')) |
| 1838 | 1824 | { |
| 1839 | 1825 | $mode = SIMPLEPIE_CONSTRUCT_BASE64; |
| 1840 | - } |
|
| 1841 | - else |
|
| 1826 | + } else |
|
| 1842 | 1827 | { |
| 1843 | 1828 | $mode = SIMPLEPIE_CONSTRUCT_NONE; |
| 1844 | 1829 | } |
@@ -1861,8 +1846,7 @@ discard block |
||
| 1861 | 1846 | default: |
| 1862 | 1847 | return SIMPLEPIE_CONSTRUCT_NONE | $mode; |
| 1863 | 1848 | } |
| 1864 | - } |
|
| 1865 | - else |
|
| 1849 | + } else |
|
| 1866 | 1850 | { |
| 1867 | 1851 | return SIMPLEPIE_CONSTRUCT_TEXT | $mode; |
| 1868 | 1852 | } |
@@ -1909,13 +1893,11 @@ discard block |
||
| 1909 | 1893 | if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/') |
| 1910 | 1894 | { |
| 1911 | 1895 | return SIMPLEPIE_CONSTRUCT_NONE; |
| 1912 | - } |
|
| 1913 | - else |
|
| 1896 | + } else |
|
| 1914 | 1897 | { |
| 1915 | 1898 | return SIMPLEPIE_CONSTRUCT_BASE64; |
| 1916 | 1899 | } |
| 1917 | - } |
|
| 1918 | - else |
|
| 1900 | + } else |
|
| 1919 | 1901 | { |
| 1920 | 1902 | return SIMPLEPIE_CONSTRUCT_TEXT; |
| 1921 | 1903 | } |
@@ -1958,24 +1940,19 @@ discard block |
||
| 1958 | 1940 | if ($codepoint < 0) |
| 1959 | 1941 | { |
| 1960 | 1942 | return false; |
| 1961 | - } |
|
| 1962 | - else if ($codepoint <= 0x7f) |
|
| 1943 | + } else if ($codepoint <= 0x7f) |
|
| 1963 | 1944 | { |
| 1964 | 1945 | return chr($codepoint); |
| 1965 | - } |
|
| 1966 | - else if ($codepoint <= 0x7ff) |
|
| 1946 | + } else if ($codepoint <= 0x7ff) |
|
| 1967 | 1947 | { |
| 1968 | 1948 | return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); |
| 1969 | - } |
|
| 1970 | - else if ($codepoint <= 0xffff) |
|
| 1949 | + } else if ($codepoint <= 0xffff) |
|
| 1971 | 1950 | { |
| 1972 | 1951 | return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); |
| 1973 | - } |
|
| 1974 | - else if ($codepoint <= 0x10ffff) |
|
| 1952 | + } else if ($codepoint <= 0x10ffff) |
|
| 1975 | 1953 | { |
| 1976 | 1954 | return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); |
| 1977 | - } |
|
| 1978 | - else |
|
| 1955 | + } else |
|
| 1979 | 1956 | { |
| 1980 | 1957 | // U+FFFD REPLACEMENT CHARACTER |
| 1981 | 1958 | return "\xEF\xBF\xBD"; |
@@ -2003,8 +1980,7 @@ discard block |
||
| 2003 | 1980 | { |
| 2004 | 1981 | list($name, $value) = explode('=', $section, 2); |
| 2005 | 1982 | $return[urldecode($name)][] = urldecode($value); |
| 2006 | - } |
|
| 2007 | - else |
|
| 1983 | + } else |
|
| 2008 | 1984 | { |
| 2009 | 1985 | $return[urldecode($section)][] = null; |
| 2010 | 1986 | } |
@@ -2166,8 +2142,7 @@ discard block |
||
| 2166 | 2142 | if (file_exists($root . '/.git/index')) |
| 2167 | 2143 | { |
| 2168 | 2144 | return filemtime($root . '/.git/index'); |
| 2169 | - } |
|
| 2170 | - elseif (file_exists($root . '/SimplePie')) |
|
| 2145 | + } elseif (file_exists($root . '/SimplePie')) |
|
| 2171 | 2146 | { |
| 2172 | 2147 | $time = 0; |
| 2173 | 2148 | foreach (glob($root . '/SimplePie/*.php') as $file) |
@@ -2178,12 +2153,10 @@ discard block |
||
| 2178 | 2153 | } |
| 2179 | 2154 | } |
| 2180 | 2155 | return $time; |
| 2181 | - } |
|
| 2182 | - elseif (file_exists(dirname(__FILE__) . '/Core.php')) |
|
| 2156 | + } elseif (file_exists(dirname(__FILE__) . '/Core.php')) |
|
| 2183 | 2157 | { |
| 2184 | 2158 | return filemtime(dirname(__FILE__) . '/Core.php'); |
| 2185 | - } |
|
| 2186 | - else |
|
| 2159 | + } else |
|
| 2187 | 2160 | { |
| 2188 | 2161 | return filemtime(__FILE__); |
| 2189 | 2162 | } |
@@ -2199,8 +2172,7 @@ discard block |
||
| 2199 | 2172 | if ($sp->error() !== null) |
| 2200 | 2173 | { |
| 2201 | 2174 | $info .= 'Error occurred: ' . $sp->error() . "\n"; |
| 2202 | - } |
|
| 2203 | - else |
|
| 2175 | + } else |
|
| 2204 | 2176 | { |
| 2205 | 2177 | $info .= "No error found.\n"; |
| 2206 | 2178 | } |
@@ -2230,8 +2202,7 @@ discard block |
||
| 2230 | 2202 | $info .= ' Version ' . LIBXML_DOTTED_VERSION . "\n"; |
| 2231 | 2203 | break; |
| 2232 | 2204 | } |
| 2233 | - } |
|
| 2234 | - else |
|
| 2205 | + } else |
|
| 2235 | 2206 | { |
| 2236 | 2207 | $info .= " $ext not loaded\n"; |
| 2237 | 2208 | } |
@@ -190,7 +190,7 @@ |
||
| 190 | 190 | * 0:0:0:0:0:FFFF:129.144.52.38 |
| 191 | 191 | * |
| 192 | 192 | * @param string $ip An IPv6 address |
| 193 | - * @return array [0] contains the IPv6 represented part, and [1] the IPv4 represented part |
|
| 193 | + * @return string[] [0] contains the IPv6 represented part, and [1] the IPv4 represented part |
|
| 194 | 194 | */ |
| 195 | 195 | private static function split_v6_v4($ip) |
| 196 | 196 | { |
@@ -123,7 +123,7 @@ |
||
| 123 | 123 | // xxx::xxx |
| 124 | 124 | else |
| 125 | 125 | { |
| 126 | - $fill = ':' . str_repeat('0:', 6 - $c2 - $c1); |
|
| 126 | + $fill = ':'.str_repeat('0:', 6 - $c2 - $c1); |
|
| 127 | 127 | $ip = str_replace('::', $fill, $ip); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -86,16 +86,14 @@ discard block |
||
| 86 | 86 | if ($ip1 === '') |
| 87 | 87 | { |
| 88 | 88 | $c1 = -1; |
| 89 | - } |
|
| 90 | - else |
|
| 89 | + } else |
|
| 91 | 90 | { |
| 92 | 91 | $c1 = substr_count($ip1, ':'); |
| 93 | 92 | } |
| 94 | 93 | if ($ip2 === '') |
| 95 | 94 | { |
| 96 | 95 | $c2 = -1; |
| 97 | - } |
|
| 98 | - else |
|
| 96 | + } else |
|
| 99 | 97 | { |
| 100 | 98 | $c2 = substr_count($ip2, ':'); |
| 101 | 99 | } |
@@ -173,8 +171,7 @@ discard block |
||
| 173 | 171 | if ($ip_parts[1] !== '') |
| 174 | 172 | { |
| 175 | 173 | return implode(':', $ip_parts); |
| 176 | - } |
|
| 177 | - else |
|
| 174 | + } else |
|
| 178 | 175 | { |
| 179 | 176 | return $ip_parts[0]; |
| 180 | 177 | } |
@@ -200,8 +197,7 @@ discard block |
||
| 200 | 197 | $ipv6_part = substr($ip, 0, $pos); |
| 201 | 198 | $ipv4_part = substr($ip, $pos + 1); |
| 202 | 199 | return array($ipv6_part, $ipv4_part); |
| 203 | - } |
|
| 204 | - else |
|
| 200 | + } else |
|
| 205 | 201 | { |
| 206 | 202 | return array($ip, ''); |
| 207 | 203 | } |
@@ -226,35 +222,39 @@ discard block |
||
| 226 | 222 | foreach ($ipv6 as $ipv6_part) |
| 227 | 223 | { |
| 228 | 224 | // The section can't be empty |
| 229 | - if ($ipv6_part === '') |
|
| 230 | - return false; |
|
| 225 | + if ($ipv6_part === '') { |
|
| 226 | + return false; |
|
| 227 | + } |
|
| 231 | 228 | |
| 232 | 229 | // Nor can it be over four characters |
| 233 | - if (strlen($ipv6_part) > 4) |
|
| 234 | - return false; |
|
| 230 | + if (strlen($ipv6_part) > 4) { |
|
| 231 | + return false; |
|
| 232 | + } |
|
| 235 | 233 | |
| 236 | 234 | // Remove leading zeros (this is safe because of the above) |
| 237 | 235 | $ipv6_part = ltrim($ipv6_part, '0'); |
| 238 | - if ($ipv6_part === '') |
|
| 239 | - $ipv6_part = '0'; |
|
| 236 | + if ($ipv6_part === '') { |
|
| 237 | + $ipv6_part = '0'; |
|
| 238 | + } |
|
| 240 | 239 | |
| 241 | 240 | // Check the value is valid |
| 242 | 241 | $value = hexdec($ipv6_part); |
| 243 | - if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) |
|
| 244 | - return false; |
|
| 242 | + if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) { |
|
| 243 | + return false; |
|
| 244 | + } |
|
| 245 | 245 | } |
| 246 | 246 | if (count($ipv4) === 4) |
| 247 | 247 | { |
| 248 | 248 | foreach ($ipv4 as $ipv4_part) |
| 249 | 249 | { |
| 250 | 250 | $value = (int) $ipv4_part; |
| 251 | - if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) |
|
| 252 | - return false; |
|
| 251 | + if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) { |
|
| 252 | + return false; |
|
| 253 | + } |
|
| 253 | 254 | } |
| 254 | 255 | } |
| 255 | 256 | return true; |
| 256 | - } |
|
| 257 | - else |
|
| 257 | + } else |
|
| 258 | 258 | { |
| 259 | 259 | return false; |
| 260 | 260 | } |
@@ -704,7 +704,6 @@ |
||
| 704 | 704 | * Remove RFC822 comments |
| 705 | 705 | * |
| 706 | 706 | * @access protected |
| 707 | - * @param string $data Data to strip comments from |
|
| 708 | 707 | * @return string Comment stripped string |
| 709 | 708 | */ |
| 710 | 709 | public function remove_rfc2822_comments($string) |
@@ -541,11 +541,11 @@ discard block |
||
| 541 | 541 | */ |
| 542 | 542 | public function __construct() |
| 543 | 543 | { |
| 544 | - $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')'; |
|
| 545 | - $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')'; |
|
| 544 | + $this->day_pcre = '('.implode(array_keys($this->day), '|').')'; |
|
| 545 | + $this->month_pcre = '('.implode(array_keys($this->month), '|').')'; |
|
| 546 | 546 | |
| 547 | 547 | static $cache; |
| 548 | - if (!isset($cache[get_class($this)])) |
|
| 548 | + if ( ! isset($cache[get_class($this)])) |
|
| 549 | 549 | { |
| 550 | 550 | $all_methods = get_class_methods($this); |
| 551 | 551 | |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | public static function get() |
| 573 | 573 | { |
| 574 | 574 | static $object; |
| 575 | - if (!$object) |
|
| 575 | + if ( ! $object) |
|
| 576 | 576 | { |
| 577 | 577 | $object = new SimplePie_Parse_Date; |
| 578 | 578 | } |
@@ -638,13 +638,13 @@ discard block |
||
| 638 | 638 | public function date_w3cdtf($date) |
| 639 | 639 | { |
| 640 | 640 | static $pcre; |
| 641 | - if (!$pcre) |
|
| 641 | + if ( ! $pcre) |
|
| 642 | 642 | { |
| 643 | 643 | $year = '([0-9]{4})'; |
| 644 | 644 | $month = $day = $hour = $minute = $second = '([0-9]{2})'; |
| 645 | 645 | $decimal = '([0-9]*)'; |
| 646 | 646 | $zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))'; |
| 647 | - $pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/'; |
|
| 647 | + $pcre = '/^'.$year.'(?:-?'.$month.'(?:-?'.$day.'(?:[Tt\x09\x20]+'.$hour.'(?::?'.$minute.'(?::?'.$second.'(?:.'.$decimal.')?)?)?'.$zone.')?)?)?$/'; |
|
| 648 | 648 | } |
| 649 | 649 | if (preg_match($pcre, $date, $match)) |
| 650 | 650 | { |
@@ -770,11 +770,11 @@ discard block |
||
| 770 | 770 | public function date_rfc2822($date) |
| 771 | 771 | { |
| 772 | 772 | static $pcre; |
| 773 | - if (!$pcre) |
|
| 773 | + if ( ! $pcre) |
|
| 774 | 774 | { |
| 775 | 775 | $wsp = '[\x09\x20]'; |
| 776 | - $fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)'; |
|
| 777 | - $optional_fws = $fws . '?'; |
|
| 776 | + $fws = '(?:'.$wsp.'+|'.$wsp.'*(?:\x0D\x0A'.$wsp.'+)+)'; |
|
| 777 | + $optional_fws = $fws.'?'; |
|
| 778 | 778 | $day_name = $this->day_pcre; |
| 779 | 779 | $month = $this->month_pcre; |
| 780 | 780 | $day = '([0-9]{1,2})'; |
@@ -782,8 +782,8 @@ discard block |
||
| 782 | 782 | $year = '([0-9]{2,4})'; |
| 783 | 783 | $num_zone = '([+\-])([0-9]{2})([0-9]{2})'; |
| 784 | 784 | $character_zone = '([A-Z]{1,5})'; |
| 785 | - $zone = '(?:' . $num_zone . '|' . $character_zone . ')'; |
|
| 786 | - $pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i'; |
|
| 785 | + $zone = '(?:'.$num_zone.'|'.$character_zone.')'; |
|
| 786 | + $pcre = '/(?:'.$optional_fws.$day_name.$optional_fws.',)?'.$optional_fws.$day.$fws.$month.$fws.$year.$fws.$hour.$optional_fws.':'.$optional_fws.$minute.'(?:'.$optional_fws.':'.$optional_fws.$second.')?'.$fws.$zone.'/i'; |
|
| 787 | 787 | } |
| 788 | 788 | if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match)) |
| 789 | 789 | { |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | public function date_rfc850($date) |
| 864 | 864 | { |
| 865 | 865 | static $pcre; |
| 866 | - if (!$pcre) |
|
| 866 | + if ( ! $pcre) |
|
| 867 | 867 | { |
| 868 | 868 | $space = '[\x09\x20]+'; |
| 869 | 869 | $day_name = $this->day_pcre; |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | $day = '([0-9]{1,2})'; |
| 872 | 872 | $year = $hour = $minute = $second = '([0-9]{2})'; |
| 873 | 873 | $zone = '([A-Z]{1,5})'; |
| 874 | - $pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i'; |
|
| 874 | + $pcre = '/^'.$day_name.','.$space.$day.'-'.$month.'-'.$year.$space.$hour.':'.$minute.':'.$second.$space.$zone.'$/i'; |
|
| 875 | 875 | } |
| 876 | 876 | if (preg_match($pcre, $date, $match)) |
| 877 | 877 | { |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | public function date_asctime($date) |
| 929 | 929 | { |
| 930 | 930 | static $pcre; |
| 931 | - if (!$pcre) |
|
| 931 | + if ( ! $pcre) |
|
| 932 | 932 | { |
| 933 | 933 | $space = '[\x09\x20]+'; |
| 934 | 934 | $wday_name = $this->day_pcre; |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | $hour = $sec = $min = '([0-9]{2})'; |
| 938 | 938 | $year = '([0-9]{4})'; |
| 939 | 939 | $terminator = '\x0A?\x00?'; |
| 940 | - $pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i'; |
|
| 940 | + $pcre = '/^'.$wday_name.$space.$mon_name.$space.$day.$space.$hour.':'.$min.':'.$sec.$space.$year.$terminator.'$/i'; |
|
| 941 | 941 | } |
| 942 | 942 | if (preg_match($pcre, $date, $match)) |
| 943 | 943 | { |
@@ -620,8 +620,7 @@ discard block |
||
| 620 | 620 | if (is_callable($callback)) |
| 621 | 621 | { |
| 622 | 622 | $this->user[] = $callback; |
| 623 | - } |
|
| 624 | - else |
|
| 623 | + } else |
|
| 625 | 624 | { |
| 626 | 625 | trigger_error('User-supplied function must be a valid callback', E_USER_WARNING); |
| 627 | 626 | } |
@@ -683,8 +682,7 @@ discard block |
||
| 683 | 682 | { |
| 684 | 683 | $timezone = 0 - $timezone; |
| 685 | 684 | } |
| 686 | - } |
|
| 687 | - else |
|
| 685 | + } else |
|
| 688 | 686 | { |
| 689 | 687 | $timezone = 0; |
| 690 | 688 | } |
@@ -693,8 +691,7 @@ discard block |
||
| 693 | 691 | $second = round($match[6] + $match[7] / pow(10, strlen($match[7]))); |
| 694 | 692 | |
| 695 | 693 | return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone; |
| 696 | - } |
|
| 697 | - else |
|
| 694 | + } else |
|
| 698 | 695 | { |
| 699 | 696 | return false; |
| 700 | 697 | } |
@@ -730,8 +727,7 @@ discard block |
||
| 730 | 727 | { |
| 731 | 728 | $position++; |
| 732 | 729 | continue; |
| 733 | - } |
|
| 734 | - elseif (isset($string[$position])) |
|
| 730 | + } elseif (isset($string[$position])) |
|
| 735 | 731 | { |
| 736 | 732 | switch ($string[$position]) |
| 737 | 733 | { |
@@ -744,14 +740,12 @@ discard block |
||
| 744 | 740 | break; |
| 745 | 741 | } |
| 746 | 742 | $position++; |
| 747 | - } |
|
| 748 | - else |
|
| 743 | + } else |
|
| 749 | 744 | { |
| 750 | 745 | break; |
| 751 | 746 | } |
| 752 | 747 | } |
| 753 | - } |
|
| 754 | - else |
|
| 748 | + } else |
|
| 755 | 749 | { |
| 756 | 750 | $output .= '('; |
| 757 | 751 | } |
@@ -830,8 +824,7 @@ discard block |
||
| 830 | 824 | if ($match[4] < 50) |
| 831 | 825 | { |
| 832 | 826 | $match[4] += 2000; |
| 833 | - } |
|
| 834 | - elseif ($match[4] < 1000) |
|
| 827 | + } elseif ($match[4] < 1000) |
|
| 835 | 828 | { |
| 836 | 829 | $match[4] += 1900; |
| 837 | 830 | } |
@@ -840,15 +833,13 @@ discard block |
||
| 840 | 833 | if ($match[7] !== '') |
| 841 | 834 | { |
| 842 | 835 | $second = $match[7]; |
| 843 | - } |
|
| 844 | - else |
|
| 836 | + } else |
|
| 845 | 837 | { |
| 846 | 838 | $second = 0; |
| 847 | 839 | } |
| 848 | 840 | |
| 849 | 841 | return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone; |
| 850 | - } |
|
| 851 | - else |
|
| 842 | + } else |
|
| 852 | 843 | { |
| 853 | 844 | return false; |
| 854 | 845 | } |
@@ -905,15 +896,13 @@ discard block |
||
| 905 | 896 | if ($match[4] < 50) |
| 906 | 897 | { |
| 907 | 898 | $match[4] += 2000; |
| 908 | - } |
|
| 909 | - else |
|
| 899 | + } else |
|
| 910 | 900 | { |
| 911 | 901 | $match[4] += 1900; |
| 912 | 902 | } |
| 913 | 903 | |
| 914 | 904 | return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone; |
| 915 | - } |
|
| 916 | - else |
|
| 905 | + } else |
|
| 917 | 906 | { |
| 918 | 907 | return false; |
| 919 | 908 | } |
@@ -954,8 +943,7 @@ discard block |
||
| 954 | 943 | |
| 955 | 944 | $month = $this->month[strtolower($match[2])]; |
| 956 | 945 | return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); |
| 957 | - } |
|
| 958 | - else |
|
| 946 | + } else |
|
| 959 | 947 | { |
| 960 | 948 | return false; |
| 961 | 949 | } |
@@ -973,8 +961,7 @@ discard block |
||
| 973 | 961 | if ($strtotime === -1 || $strtotime === false) |
| 974 | 962 | { |
| 975 | 963 | return false; |
| 976 | - } |
|
| 977 | - else |
|
| 964 | + } else |
|
| 978 | 965 | { |
| 979 | 966 | return $strtotime; |
| 980 | 967 | } |
@@ -265,6 +265,9 @@ discard block |
||
| 265 | 265 | return $this->data; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | + /** |
|
| 269 | + * @param string $tag |
|
| 270 | + */ |
|
| 268 | 271 | public function tag_open($parser, $tag, $attributes) |
| 269 | 272 | { |
| 270 | 273 | list($this->namespace[], $this->element[]) = $this->split_ns($tag); |
@@ -332,6 +335,9 @@ discard block |
||
| 332 | 335 | } |
| 333 | 336 | } |
| 334 | 337 | |
| 338 | + /** |
|
| 339 | + * @param string $cdata |
|
| 340 | + */ |
|
| 335 | 341 | public function cdata($parser, $cdata) |
| 336 | 342 | { |
| 337 | 343 | if ($this->current_xhtml_construct >= 0) |
@@ -344,6 +350,9 @@ discard block |
||
| 344 | 350 | } |
| 345 | 351 | } |
| 346 | 352 | |
| 353 | + /** |
|
| 354 | + * @param string $tag |
|
| 355 | + */ |
|
| 347 | 356 | public function tag_close($parser, $tag) |
| 348 | 357 | { |
| 349 | 358 | if ($this->current_xhtml_construct >= 0) |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | if ($declaration->parse()) |
| 121 | 121 | { |
| 122 | 122 | $data = substr($data, $pos + 2); |
| 123 | - $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data; |
|
| 123 | + $data = '<?xml version="'.$declaration->version.'" encoding="'.$encoding.'" standalone="'.(($declaration->standalone) ? 'yes' : 'no').'"?>'.$data; |
|
| 124 | 124 | } |
| 125 | 125 | else |
| 126 | 126 | { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | xml_set_element_handler($xml, 'tag_open', 'tag_close'); |
| 152 | 152 | |
| 153 | 153 | // Parse! |
| 154 | - if (!xml_parse($xml, $data, true)) |
|
| 154 | + if ( ! xml_parse($xml, $data, true)) |
|
| 155 | 155 | { |
| 156 | 156 | $this->error_code = xml_get_error_code($xml); |
| 157 | 157 | $this->error_string = xml_error_string($this->error_code); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | case constant('XMLReader::END_ELEMENT'): |
| 177 | 177 | if ($xml->namespaceURI !== '') |
| 178 | 178 | { |
| 179 | - $tagName = $xml->namespaceURI . $this->separator . $xml->localName; |
|
| 179 | + $tagName = $xml->namespaceURI.$this->separator.$xml->localName; |
|
| 180 | 180 | } |
| 181 | 181 | else |
| 182 | 182 | { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $empty = $xml->isEmptyElement; |
| 189 | 189 | if ($xml->namespaceURI !== '') |
| 190 | 190 | { |
| 191 | - $tagName = $xml->namespaceURI . $this->separator . $xml->localName; |
|
| 191 | + $tagName = $xml->namespaceURI.$this->separator.$xml->localName; |
|
| 192 | 192 | } |
| 193 | 193 | else |
| 194 | 194 | { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | if ($xml->namespaceURI !== '') |
| 201 | 201 | { |
| 202 | - $attrName = $xml->namespaceURI . $this->separator . $xml->localName; |
|
| 202 | + $attrName = $xml->namespaceURI.$this->separator.$xml->localName; |
|
| 203 | 203 | } |
| 204 | 204 | else |
| 205 | 205 | { |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | $this->current_xhtml_construct++; |
| 306 | 306 | if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML) |
| 307 | 307 | { |
| 308 | - $this->data['data'] .= '<' . end($this->element); |
|
| 308 | + $this->data['data'] .= '<'.end($this->element); |
|
| 309 | 309 | if (isset($attribs[''])) |
| 310 | 310 | { |
| 311 | 311 | foreach ($attribs[''] as $name => $value) |
| 312 | 312 | { |
| 313 | - $this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"'; |
|
| 313 | + $this->data['data'] .= ' '.$name.'="'.htmlspecialchars($value, ENT_COMPAT, $this->encoding).'"'; |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | $this->data['data'] .= '>'; |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | else |
| 320 | 320 | { |
| 321 | - $this->datas[] =& $this->data; |
|
| 322 | - $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; |
|
| 321 | + $this->datas[] = & $this->data; |
|
| 322 | + $this->data = & $this->data['child'][end($this->namespace)][end($this->element)][]; |
|
| 323 | 323 | $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)); |
| 324 | 324 | if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml') |
| 325 | 325 | || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml') |
@@ -349,14 +349,14 @@ discard block |
||
| 349 | 349 | if ($this->current_xhtml_construct >= 0) |
| 350 | 350 | { |
| 351 | 351 | $this->current_xhtml_construct--; |
| 352 | - if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'))) |
|
| 352 | + if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && ! in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'))) |
|
| 353 | 353 | { |
| 354 | - $this->data['data'] .= '</' . end($this->element) . '>'; |
|
| 354 | + $this->data['data'] .= '</'.end($this->element).'>'; |
|
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | if ($this->current_xhtml_construct === -1) |
| 358 | 358 | { |
| 359 | - $this->data =& $this->datas[count($this->datas) - 1]; |
|
| 359 | + $this->data = & $this->datas[count($this->datas) - 1]; |
|
| 360 | 360 | array_pop($this->datas); |
| 361 | 361 | } |
| 362 | 362 | |
@@ -370,12 +370,12 @@ discard block |
||
| 370 | 370 | public function split_ns($string) |
| 371 | 371 | { |
| 372 | 372 | static $cache = array(); |
| 373 | - if (!isset($cache[$string])) |
|
| 373 | + if ( ! isset($cache[$string])) |
|
| 374 | 374 | { |
| 375 | 375 | if ($pos = strpos($string, $this->separator)) |
| 376 | 376 | { |
| 377 | 377 | static $separator_length; |
| 378 | - if (!$separator_length) |
|
| 378 | + if ( ! $separator_length) |
|
| 379 | 379 | { |
| 380 | 380 | $separator_length = strlen($this->separator); |
| 381 | 381 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | $namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2 || |
| 392 | 392 | $namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG3 || |
| 393 | 393 | $namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG4 || |
| 394 | - $namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5 ) |
|
| 394 | + $namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5) |
|
| 395 | 395 | { |
| 396 | 396 | $namespace = SIMPLEPIE_NAMESPACE_MEDIARSS; |
| 397 | 397 | } |
@@ -81,8 +81,7 @@ discard block |
||
| 81 | 81 | if (strtoupper($encoding) === 'US-ASCII') |
| 82 | 82 | { |
| 83 | 83 | $this->encoding = 'UTF-8'; |
| 84 | - } |
|
| 85 | - else |
|
| 84 | + } else |
|
| 86 | 85 | { |
| 87 | 86 | $this->encoding = $encoding; |
| 88 | 87 | } |
@@ -121,8 +120,7 @@ discard block |
||
| 121 | 120 | { |
| 122 | 121 | $data = substr($data, $pos + 2); |
| 123 | 122 | $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data; |
| 124 | - } |
|
| 125 | - else |
|
| 123 | + } else |
|
| 126 | 124 | { |
| 127 | 125 | $this->error_string = 'SimplePie bug! Please report this!'; |
| 128 | 126 | return false; |
@@ -162,8 +160,7 @@ discard block |
||
| 162 | 160 | $this->current_byte = xml_get_current_byte_index($xml); |
| 163 | 161 | xml_parser_free($xml); |
| 164 | 162 | return $return; |
| 165 | - } |
|
| 166 | - else |
|
| 163 | + } else |
|
| 167 | 164 | { |
| 168 | 165 | libxml_clear_errors(); |
| 169 | 166 | $xml = new XMLReader(); |
@@ -177,8 +174,7 @@ discard block |
||
| 177 | 174 | if ($xml->namespaceURI !== '') |
| 178 | 175 | { |
| 179 | 176 | $tagName = $xml->namespaceURI . $this->separator . $xml->localName; |
| 180 | - } |
|
| 181 | - else |
|
| 177 | + } else |
|
| 182 | 178 | { |
| 183 | 179 | $tagName = $xml->localName; |
| 184 | 180 | } |
@@ -189,8 +185,7 @@ discard block |
||
| 189 | 185 | if ($xml->namespaceURI !== '') |
| 190 | 186 | { |
| 191 | 187 | $tagName = $xml->namespaceURI . $this->separator . $xml->localName; |
| 192 | - } |
|
| 193 | - else |
|
| 188 | + } else |
|
| 194 | 189 | { |
| 195 | 190 | $tagName = $xml->localName; |
| 196 | 191 | } |
@@ -200,8 +195,7 @@ discard block |
||
| 200 | 195 | if ($xml->namespaceURI !== '') |
| 201 | 196 | { |
| 202 | 197 | $attrName = $xml->namespaceURI . $this->separator . $xml->localName; |
| 203 | - } |
|
| 204 | - else |
|
| 198 | + } else |
|
| 205 | 199 | { |
| 206 | 200 | $attrName = $xml->localName; |
| 207 | 201 | } |
@@ -227,8 +221,7 @@ discard block |
||
| 227 | 221 | $this->current_line = $error->line; |
| 228 | 222 | $this->current_column = $error->column; |
| 229 | 223 | return false; |
| 230 | - } |
|
| 231 | - else |
|
| 224 | + } else |
|
| 232 | 225 | { |
| 233 | 226 | return true; |
| 234 | 227 | } |
@@ -284,8 +277,7 @@ discard block |
||
| 284 | 277 | $this->xml_base[] = $base; |
| 285 | 278 | $this->xml_base_explicit[] = true; |
| 286 | 279 | } |
| 287 | - } |
|
| 288 | - else |
|
| 280 | + } else |
|
| 289 | 281 | { |
| 290 | 282 | $this->xml_base[] = end($this->xml_base); |
| 291 | 283 | $this->xml_base_explicit[] = end($this->xml_base_explicit); |
@@ -294,8 +286,7 @@ discard block |
||
| 294 | 286 | if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang'])) |
| 295 | 287 | { |
| 296 | 288 | $this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang']; |
| 297 | - } |
|
| 298 | - else |
|
| 289 | + } else |
|
| 299 | 290 | { |
| 300 | 291 | $this->xml_lang[] = end($this->xml_lang); |
| 301 | 292 | } |
@@ -315,8 +306,7 @@ discard block |
||
| 315 | 306 | } |
| 316 | 307 | $this->data['data'] .= '>'; |
| 317 | 308 | } |
| 318 | - } |
|
| 319 | - else |
|
| 309 | + } else |
|
| 320 | 310 | { |
| 321 | 311 | $this->datas[] =& $this->data; |
| 322 | 312 | $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; |
@@ -337,8 +327,7 @@ discard block |
||
| 337 | 327 | if ($this->current_xhtml_construct >= 0) |
| 338 | 328 | { |
| 339 | 329 | $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding); |
| 340 | - } |
|
| 341 | - else |
|
| 330 | + } else |
|
| 342 | 331 | { |
| 343 | 332 | $this->data['data'] .= $cdata; |
| 344 | 333 | } |
@@ -396,8 +385,7 @@ discard block |
||
| 396 | 385 | $namespace = SIMPLEPIE_NAMESPACE_MEDIARSS; |
| 397 | 386 | } |
| 398 | 387 | $cache[$string] = array($namespace, $local_name); |
| 399 | - } |
|
| 400 | - else |
|
| 388 | + } else |
|
| 401 | 389 | { |
| 402 | 390 | $cache[$string] = array('', $string); |
| 403 | 391 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | * @since 1.5.0 |
| 18 | 18 | * |
| 19 | 19 | * @param string $type Filename without extension. |
| 20 | - * @param array $templates An optional list of template candidates |
|
| 20 | + * @param string[] $templates An optional list of template candidates |
|
| 21 | 21 | * @return string Full path to template file. |
| 22 | 22 | */ |
| 23 | 23 | function get_query_template( $type, $templates = array() ) { |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | * @param array $templates An optional list of template candidates |
| 21 | 21 | * @return string Full path to template file. |
| 22 | 22 | */ |
| 23 | -function get_query_template( $type, $templates = array() ) { |
|
| 24 | - $type = preg_replace( '|[^a-z0-9-]+|', '', $type ); |
|
| 23 | +function get_query_template($type, $templates = array()) { |
|
| 24 | + $type = preg_replace('|[^a-z0-9-]+|', '', $type); |
|
| 25 | 25 | |
| 26 | - if ( empty( $templates ) ) |
|
| 26 | + if (empty($templates)) |
|
| 27 | 27 | $templates = array("{$type}.php"); |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param array $templates A list of template candidates, in descending order of priority. |
| 40 | 40 | */ |
| 41 | - $templates = apply_filters( "{$type}_template_hierarchy", $templates ); |
|
| 41 | + $templates = apply_filters("{$type}_template_hierarchy", $templates); |
|
| 42 | 42 | |
| 43 | - $template = locate_template( $templates ); |
|
| 43 | + $template = locate_template($templates); |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Filters the path of the queried template by type. |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param string $type Filename without extension. |
| 60 | 60 | * @param array $templates A list of template candidates, in descending order of priority. |
| 61 | 61 | */ |
| 62 | - return apply_filters( "{$type}_template", $template, $type, $templates ); |
|
| 62 | + return apply_filters("{$type}_template", $template, $type, $templates); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -107,17 +107,17 @@ discard block |
||
| 107 | 107 | * @return string Full path to archive template file. |
| 108 | 108 | */ |
| 109 | 109 | function get_archive_template() { |
| 110 | - $post_types = array_filter( (array) get_query_var( 'post_type' ) ); |
|
| 110 | + $post_types = array_filter((array) get_query_var('post_type')); |
|
| 111 | 111 | |
| 112 | 112 | $templates = array(); |
| 113 | 113 | |
| 114 | - if ( count( $post_types ) == 1 ) { |
|
| 115 | - $post_type = reset( $post_types ); |
|
| 114 | + if (count($post_types) == 1) { |
|
| 115 | + $post_type = reset($post_types); |
|
| 116 | 116 | $templates[] = "archive-{$post_type}.php"; |
| 117 | 117 | } |
| 118 | 118 | $templates[] = 'archive.php'; |
| 119 | 119 | |
| 120 | - return get_query_template( 'archive', $templates ); |
|
| 120 | + return get_query_template('archive', $templates); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | * @return string Full path to archive template file. |
| 134 | 134 | */ |
| 135 | 135 | function get_post_type_archive_template() { |
| 136 | - $post_type = get_query_var( 'post_type' ); |
|
| 137 | - if ( is_array( $post_type ) ) |
|
| 138 | - $post_type = reset( $post_type ); |
|
| 136 | + $post_type = get_query_var('post_type'); |
|
| 137 | + if (is_array($post_type)) |
|
| 138 | + $post_type = reset($post_type); |
|
| 139 | 139 | |
| 140 | - $obj = get_post_type_object( $post_type ); |
|
| 141 | - if ( ! ( $obj instanceof WP_Post_Type ) || ! $obj->has_archive ) { |
|
| 140 | + $obj = get_post_type_object($post_type); |
|
| 141 | + if ( ! ($obj instanceof WP_Post_Type) || ! $obj->has_archive) { |
|
| 142 | 142 | return ''; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $templates = array(); |
| 176 | 176 | |
| 177 | - if ( $author instanceof WP_User ) { |
|
| 177 | + if ($author instanceof WP_User) { |
|
| 178 | 178 | $templates[] = "author-{$author->user_nicename}.php"; |
| 179 | 179 | $templates[] = "author-{$author->ID}.php"; |
| 180 | 180 | } |
| 181 | 181 | $templates[] = 'author.php'; |
| 182 | 182 | |
| 183 | - return get_query_template( 'author', $templates ); |
|
| 183 | + return get_query_template('author', $templates); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | $templates = array(); |
| 216 | 216 | |
| 217 | - if ( ! empty( $category->slug ) ) { |
|
| 217 | + if ( ! empty($category->slug)) { |
|
| 218 | 218 | |
| 219 | - $slug_decoded = urldecode( $category->slug ); |
|
| 220 | - if ( $slug_decoded !== $category->slug ) { |
|
| 219 | + $slug_decoded = urldecode($category->slug); |
|
| 220 | + if ($slug_decoded !== $category->slug) { |
|
| 221 | 221 | $templates[] = "category-{$slug_decoded}.php"; |
| 222 | 222 | } |
| 223 | 223 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | } |
| 227 | 227 | $templates[] = 'category.php'; |
| 228 | 228 | |
| 229 | - return get_query_template( 'category', $templates ); |
|
| 229 | + return get_query_template('category', $templates); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | $templates = array(); |
| 262 | 262 | |
| 263 | - if ( ! empty( $tag->slug ) ) { |
|
| 263 | + if ( ! empty($tag->slug)) { |
|
| 264 | 264 | |
| 265 | - $slug_decoded = urldecode( $tag->slug ); |
|
| 266 | - if ( $slug_decoded !== $tag->slug ) { |
|
| 265 | + $slug_decoded = urldecode($tag->slug); |
|
| 266 | + if ($slug_decoded !== $tag->slug) { |
|
| 267 | 267 | $templates[] = "tag-{$slug_decoded}.php"; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | $templates[] = 'tag.php'; |
| 274 | 274 | |
| 275 | - return get_query_template( 'tag', $templates ); |
|
| 275 | + return get_query_template('tag', $templates); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -306,11 +306,11 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | $templates = array(); |
| 308 | 308 | |
| 309 | - if ( ! empty( $term->slug ) ) { |
|
| 309 | + if ( ! empty($term->slug)) { |
|
| 310 | 310 | $taxonomy = $term->taxonomy; |
| 311 | 311 | |
| 312 | - $slug_decoded = urldecode( $term->slug ); |
|
| 313 | - if ( $slug_decoded !== $term->slug ) { |
|
| 312 | + $slug_decoded = urldecode($term->slug); |
|
| 313 | + if ($slug_decoded !== $term->slug) { |
|
| 314 | 314 | $templates[] = "taxonomy-$taxonomy-{$slug_decoded}.php"; |
| 315 | 315 | } |
| 316 | 316 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | } |
| 320 | 320 | $templates[] = 'taxonomy.php'; |
| 321 | 321 | |
| 322 | - return get_query_template( 'taxonomy', $templates ); |
|
| 322 | + return get_query_template('taxonomy', $templates); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -351,9 +351,9 @@ discard block |
||
| 351 | 351 | * @return string Full path to home template file. |
| 352 | 352 | */ |
| 353 | 353 | function get_home_template() { |
| 354 | - $templates = array( 'home.php', 'index.php' ); |
|
| 354 | + $templates = array('home.php', 'index.php'); |
|
| 355 | 355 | |
| 356 | - return get_query_template( 'home', $templates ); |
|
| 356 | + return get_query_template('home', $templates); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | function get_front_page_template() { |
| 372 | 372 | $templates = array('front-page.php'); |
| 373 | 373 | |
| 374 | - return get_query_template( 'front_page', $templates ); |
|
| 374 | + return get_query_template('front_page', $templates); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
@@ -407,28 +407,28 @@ discard block |
||
| 407 | 407 | $template = get_page_template_slug(); |
| 408 | 408 | $pagename = get_query_var('pagename'); |
| 409 | 409 | |
| 410 | - if ( ! $pagename && $id ) { |
|
| 410 | + if ( ! $pagename && $id) { |
|
| 411 | 411 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object |
| 412 | 412 | $post = get_queried_object(); |
| 413 | - if ( $post ) |
|
| 413 | + if ($post) |
|
| 414 | 414 | $pagename = $post->post_name; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | $templates = array(); |
| 418 | - if ( $template && 0 === validate_file( $template ) ) |
|
| 418 | + if ($template && 0 === validate_file($template)) |
|
| 419 | 419 | $templates[] = $template; |
| 420 | - if ( $pagename ) { |
|
| 421 | - $pagename_decoded = urldecode( $pagename ); |
|
| 422 | - if ( $pagename_decoded !== $pagename ) { |
|
| 420 | + if ($pagename) { |
|
| 421 | + $pagename_decoded = urldecode($pagename); |
|
| 422 | + if ($pagename_decoded !== $pagename) { |
|
| 423 | 423 | $templates[] = "page-{$pagename_decoded}.php"; |
| 424 | 424 | } |
| 425 | 425 | $templates[] = "page-{$pagename}.php"; |
| 426 | 426 | } |
| 427 | - if ( $id ) |
|
| 427 | + if ($id) |
|
| 428 | 428 | $templates[] = "page-{$id}.php"; |
| 429 | 429 | $templates[] = 'page.php'; |
| 430 | 430 | |
| 431 | - return get_query_template( 'page', $templates ); |
|
| 431 | + return get_query_template('page', $templates); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
@@ -483,14 +483,14 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | $templates = array(); |
| 485 | 485 | |
| 486 | - if ( ! empty( $object->post_type ) ) { |
|
| 487 | - $template = get_page_template_slug( $object ); |
|
| 488 | - if ( $template && 0 === validate_file( $template ) ) { |
|
| 486 | + if ( ! empty($object->post_type)) { |
|
| 487 | + $template = get_page_template_slug($object); |
|
| 488 | + if ($template && 0 === validate_file($template)) { |
|
| 489 | 489 | $templates[] = $template; |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - $name_decoded = urldecode( $object->post_name ); |
|
| 493 | - if ( $name_decoded !== $object->post_name ) { |
|
| 492 | + $name_decoded = urldecode($object->post_name); |
|
| 493 | + if ($name_decoded !== $object->post_name) { |
|
| 494 | 494 | $templates[] = "single-{$object->post_type}-{$name_decoded}.php"; |
| 495 | 495 | } |
| 496 | 496 | |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | |
| 501 | 501 | $templates[] = "single.php"; |
| 502 | 502 | |
| 503 | - return get_query_template( 'single', $templates ); |
|
| 503 | + return get_query_template('single', $templates); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
@@ -532,9 +532,9 @@ discard block |
||
| 532 | 532 | |
| 533 | 533 | $templates = array(); |
| 534 | 534 | |
| 535 | - if ( ! empty( $object->post_type ) ) { |
|
| 536 | - $post_format = get_post_format( $object ); |
|
| 537 | - if ( $post_format ) { |
|
| 535 | + if ( ! empty($object->post_type)) { |
|
| 536 | + $post_format = get_post_format($object); |
|
| 537 | + if ($post_format) { |
|
| 538 | 538 | $templates[] = "embed-{$object->post_type}-{$post_format}.php"; |
| 539 | 539 | } |
| 540 | 540 | $templates[] = "embed-{$object->post_type}.php"; |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | |
| 543 | 543 | $templates[] = "embed.php"; |
| 544 | 544 | |
| 545 | - return get_query_template( 'embed', $templates ); |
|
| 545 | + return get_query_template('embed', $templates); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | /** |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | * @return string Full path to singular template file |
| 559 | 559 | */ |
| 560 | 560 | function get_singular_template() { |
| 561 | - return get_query_template( 'singular' ); |
|
| 561 | + return get_query_template('singular'); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | /** |
@@ -595,14 +595,14 @@ discard block |
||
| 595 | 595 | |
| 596 | 596 | $templates = array(); |
| 597 | 597 | |
| 598 | - if ( $attachment ) { |
|
| 599 | - if ( false !== strpos( $attachment->post_mime_type, '/' ) ) { |
|
| 600 | - list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
|
| 598 | + if ($attachment) { |
|
| 599 | + if (false !== strpos($attachment->post_mime_type, '/')) { |
|
| 600 | + list($type, $subtype) = explode('/', $attachment->post_mime_type); |
|
| 601 | 601 | } else { |
| 602 | - list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
|
| 602 | + list($type, $subtype) = array($attachment->post_mime_type, ''); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - if ( ! empty( $subtype ) ) { |
|
| 605 | + if ( ! empty($subtype)) { |
|
| 606 | 606 | $templates[] = "{$type}-{$subtype}.php"; |
| 607 | 607 | $templates[] = "{$subtype}.php"; |
| 608 | 608 | } |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | } |
| 611 | 611 | $templates[] = 'attachment.php'; |
| 612 | 612 | |
| 613 | - return get_query_template( 'attachment', $templates ); |
|
| 613 | + return get_query_template('attachment', $templates); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | /** |
@@ -626,25 +626,25 @@ discard block |
||
| 626 | 626 | * @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false. |
| 627 | 627 | * @return string The template filename if one is located. |
| 628 | 628 | */ |
| 629 | -function locate_template($template_names, $load = false, $require_once = true ) { |
|
| 629 | +function locate_template($template_names, $load = false, $require_once = true) { |
|
| 630 | 630 | $located = ''; |
| 631 | - foreach ( (array) $template_names as $template_name ) { |
|
| 632 | - if ( !$template_name ) |
|
| 631 | + foreach ((array) $template_names as $template_name) { |
|
| 632 | + if ( ! $template_name) |
|
| 633 | 633 | continue; |
| 634 | - if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { |
|
| 635 | - $located = STYLESHEETPATH . '/' . $template_name; |
|
| 634 | + if (file_exists(STYLESHEETPATH.'/'.$template_name)) { |
|
| 635 | + $located = STYLESHEETPATH.'/'.$template_name; |
|
| 636 | 636 | break; |
| 637 | - } elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) { |
|
| 638 | - $located = TEMPLATEPATH . '/' . $template_name; |
|
| 637 | + } elseif (file_exists(TEMPLATEPATH.'/'.$template_name)) { |
|
| 638 | + $located = TEMPLATEPATH.'/'.$template_name; |
|
| 639 | 639 | break; |
| 640 | - } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) { |
|
| 641 | - $located = ABSPATH . WPINC . '/theme-compat/' . $template_name; |
|
| 640 | + } elseif (file_exists(ABSPATH.WPINC.'/theme-compat/'.$template_name)) { |
|
| 641 | + $located = ABSPATH.WPINC.'/theme-compat/'.$template_name; |
|
| 642 | 642 | break; |
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - if ( $load && '' != $located ) |
|
| 647 | - load_template( $located, $require_once ); |
|
| 646 | + if ($load && '' != $located) |
|
| 647 | + load_template($located, $require_once); |
|
| 648 | 648 | |
| 649 | 649 | return $located; |
| 650 | 650 | } |
@@ -673,20 +673,20 @@ discard block |
||
| 673 | 673 | * @param string $_template_file Path to template file. |
| 674 | 674 | * @param bool $require_once Whether to require_once or require. Default true. |
| 675 | 675 | */ |
| 676 | -function load_template( $_template_file, $require_once = true ) { |
|
| 676 | +function load_template($_template_file, $require_once = true) { |
|
| 677 | 677 | global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; |
| 678 | 678 | |
| 679 | - if ( is_array( $wp_query->query_vars ) ) { |
|
| 680 | - extract( $wp_query->query_vars, EXTR_SKIP ); |
|
| 679 | + if (is_array($wp_query->query_vars)) { |
|
| 680 | + extract($wp_query->query_vars, EXTR_SKIP); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - if ( isset( $s ) ) { |
|
| 684 | - $s = esc_attr( $s ); |
|
| 683 | + if (isset($s)) { |
|
| 684 | + $s = esc_attr($s); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - if ( $require_once ) { |
|
| 688 | - require_once( $_template_file ); |
|
| 687 | + if ($require_once) { |
|
| 688 | + require_once($_template_file); |
|
| 689 | 689 | } else { |
| 690 | - require( $_template_file ); |
|
| 690 | + require($_template_file); |
|
| 691 | 691 | } |
| 692 | 692 | } |
@@ -23,8 +23,9 @@ discard block |
||
| 23 | 23 | function get_query_template( $type, $templates = array() ) { |
| 24 | 24 | $type = preg_replace( '|[^a-z0-9-]+|', '', $type ); |
| 25 | 25 | |
| 26 | - if ( empty( $templates ) ) |
|
| 27 | - $templates = array("{$type}.php"); |
|
| 26 | + if ( empty( $templates ) ) { |
|
| 27 | + $templates = array("{$type}.php"); |
|
| 28 | + } |
|
| 28 | 29 | |
| 29 | 30 | /** |
| 30 | 31 | * Filters the list of template filenames that are searched for when retrieving a template to use. |
@@ -134,8 +135,9 @@ discard block |
||
| 134 | 135 | */ |
| 135 | 136 | function get_post_type_archive_template() { |
| 136 | 137 | $post_type = get_query_var( 'post_type' ); |
| 137 | - if ( is_array( $post_type ) ) |
|
| 138 | - $post_type = reset( $post_type ); |
|
| 138 | + if ( is_array( $post_type ) ) { |
|
| 139 | + $post_type = reset( $post_type ); |
|
| 140 | + } |
|
| 139 | 141 | |
| 140 | 142 | $obj = get_post_type_object( $post_type ); |
| 141 | 143 | if ( ! ( $obj instanceof WP_Post_Type ) || ! $obj->has_archive ) { |
@@ -410,13 +412,15 @@ discard block |
||
| 410 | 412 | if ( ! $pagename && $id ) { |
| 411 | 413 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object |
| 412 | 414 | $post = get_queried_object(); |
| 413 | - if ( $post ) |
|
| 414 | - $pagename = $post->post_name; |
|
| 415 | + if ( $post ) { |
|
| 416 | + $pagename = $post->post_name; |
|
| 417 | + } |
|
| 415 | 418 | } |
| 416 | 419 | |
| 417 | 420 | $templates = array(); |
| 418 | - if ( $template && 0 === validate_file( $template ) ) |
|
| 419 | - $templates[] = $template; |
|
| 421 | + if ( $template && 0 === validate_file( $template ) ) { |
|
| 422 | + $templates[] = $template; |
|
| 423 | + } |
|
| 420 | 424 | if ( $pagename ) { |
| 421 | 425 | $pagename_decoded = urldecode( $pagename ); |
| 422 | 426 | if ( $pagename_decoded !== $pagename ) { |
@@ -424,8 +428,9 @@ discard block |
||
| 424 | 428 | } |
| 425 | 429 | $templates[] = "page-{$pagename}.php"; |
| 426 | 430 | } |
| 427 | - if ( $id ) |
|
| 428 | - $templates[] = "page-{$id}.php"; |
|
| 431 | + if ( $id ) { |
|
| 432 | + $templates[] = "page-{$id}.php"; |
|
| 433 | + } |
|
| 429 | 434 | $templates[] = 'page.php'; |
| 430 | 435 | |
| 431 | 436 | return get_query_template( 'page', $templates ); |
@@ -629,8 +634,9 @@ discard block |
||
| 629 | 634 | function locate_template($template_names, $load = false, $require_once = true ) { |
| 630 | 635 | $located = ''; |
| 631 | 636 | foreach ( (array) $template_names as $template_name ) { |
| 632 | - if ( !$template_name ) |
|
| 633 | - continue; |
|
| 637 | + if ( !$template_name ) { |
|
| 638 | + continue; |
|
| 639 | + } |
|
| 634 | 640 | if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { |
| 635 | 641 | $located = STYLESHEETPATH . '/' . $template_name; |
| 636 | 642 | break; |
@@ -643,8 +649,9 @@ discard block |
||
| 643 | 649 | } |
| 644 | 650 | } |
| 645 | 651 | |
| 646 | - if ( $load && '' != $located ) |
|
| 647 | - load_template( $located, $require_once ); |
|
| 652 | + if ( $load && '' != $located ) { |
|
| 653 | + load_template( $located, $require_once ); |
|
| 654 | + } |
|
| 648 | 655 | |
| 649 | 656 | return $located; |
| 650 | 657 | } |
@@ -145,6 +145,7 @@ discard block |
||
| 145 | 145 | * the two files do not match, and likewise that the last lines do not |
| 146 | 146 | * match. The caller must trim matching lines from the beginning and end |
| 147 | 147 | * of the portions it is going to specify. |
| 148 | + * @param double $nchunks |
|
| 148 | 149 | */ |
| 149 | 150 | function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks) |
| 150 | 151 | { |
@@ -265,6 +266,10 @@ discard block |
||
| 265 | 266 | * |
| 266 | 267 | * Note that XLIM, YLIM are exclusive bounds. All line numbers are |
| 267 | 268 | * origin-0 and discarded lines are not counted. |
| 269 | + * @param integer $xoff |
|
| 270 | + * @param integer $xlim |
|
| 271 | + * @param integer $yoff |
|
| 272 | + * @param integer $ylim |
|
| 268 | 273 | */ |
| 269 | 274 | function _compareseq ($xoff, $xlim, $yoff, $ylim) |
| 270 | 275 | { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | // Skip matching "snake". |
| 100 | 100 | $copy = array(); |
| 101 | 101 | while ($xi < $n_from && $yi < $n_to |
| 102 | - && !$this->xchanged[$xi] && !$this->ychanged[$yi]) { |
|
| 102 | + && ! $this->xchanged[$xi] && ! $this->ychanged[$yi]) { |
|
| 103 | 103 | $copy[] = $from_lines[$xi++]; |
| 104 | 104 | ++$yi; |
| 105 | 105 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * match. The caller must trim matching lines from the beginning and end |
| 147 | 147 | * of the portions it is going to specify. |
| 148 | 148 | */ |
| 149 | - function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks) |
|
| 149 | + function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) |
|
| 150 | 150 | { |
| 151 | 151 | $flip = false; |
| 152 | 152 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $this->lcs = 0; |
| 172 | - $this->seq[0]= $yoff - 1; |
|
| 172 | + $this->seq[0] = $yoff - 1; |
|
| 173 | 173 | $this->in_seq = array(); |
| 174 | 174 | $ymids[0] = array(); |
| 175 | 175 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks); |
|
| 185 | + $x1 = $xoff + (int) (($numer + ($xlim - $xoff) * $chunk) / $nchunks); |
|
| 186 | 186 | for (; $x < $x1; $x++) { |
| 187 | 187 | $line = $flip ? $this->yv[$x] : $this->xv[$x]; |
| 188 | 188 | if (empty($ymatches[$line])) { |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff); |
| 219 | 219 | $ymid = $ymids[$this->lcs]; |
| 220 | 220 | for ($n = 0; $n < $nchunks - 1; $n++) { |
| 221 | - $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks); |
|
| 221 | + $x1 = $xoff + (int) (($numer + ($xlim - $xoff) * $n) / $nchunks); |
|
| 222 | 222 | $y1 = $ymid[$n] + 1; |
| 223 | 223 | $seps[] = $flip ? array($y1, $x1) : array($x1, $y1); |
| 224 | 224 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | $beg = 1; |
| 240 | 240 | while ($beg < $end) { |
| 241 | - $mid = (int)(($beg + $end) / 2); |
|
| 241 | + $mid = (int) (($beg + $end) / 2); |
|
| 242 | 242 | if ($ypos > $this->seq[$mid]) { |
| 243 | 243 | $beg = $mid + 1; |
| 244 | 244 | } else { |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * Note that XLIM, YLIM are exclusive bounds. All line numbers are |
| 267 | 267 | * origin-0 and discarded lines are not counted. |
| 268 | 268 | */ |
| 269 | - function _compareseq ($xoff, $xlim, $yoff, $ylim) |
|
| 269 | + function _compareseq($xoff, $xlim, $yoff, $ylim) |
|
| 270 | 270 | { |
| 271 | 271 | /* Slide down the bottom initial diagonal. */ |
| 272 | 272 | while ($xoff < $xlim && $yoff < $ylim |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | reset($seps); |
| 308 | 308 | $pt1 = $seps[0]; |
| 309 | 309 | while ($pt2 = next($seps)) { |
| 310 | - $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]); |
|
| 310 | + $this->_compareseq($pt1[0], $pt2[0], $pt1[1], $pt2[1]); |
|
| 311 | 311 | $pt1 = $pt2; |
| 312 | 312 | } |
| 313 | 313 | } |
@@ -28,314 +28,314 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | class Text_Diff_Engine_native { |
| 30 | 30 | |
| 31 | - function diff($from_lines, $to_lines) |
|
| 32 | - { |
|
| 33 | - array_walk($from_lines, array('Text_Diff', 'trimNewlines')); |
|
| 34 | - array_walk($to_lines, array('Text_Diff', 'trimNewlines')); |
|
| 35 | - |
|
| 36 | - $n_from = count($from_lines); |
|
| 37 | - $n_to = count($to_lines); |
|
| 38 | - |
|
| 39 | - $this->xchanged = $this->ychanged = array(); |
|
| 40 | - $this->xv = $this->yv = array(); |
|
| 41 | - $this->xind = $this->yind = array(); |
|
| 42 | - unset($this->seq); |
|
| 43 | - unset($this->in_seq); |
|
| 44 | - unset($this->lcs); |
|
| 45 | - |
|
| 46 | - // Skip leading common lines. |
|
| 47 | - for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) { |
|
| 48 | - if ($from_lines[$skip] !== $to_lines[$skip]) { |
|
| 49 | - break; |
|
| 50 | - } |
|
| 51 | - $this->xchanged[$skip] = $this->ychanged[$skip] = false; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // Skip trailing common lines. |
|
| 55 | - $xi = $n_from; $yi = $n_to; |
|
| 56 | - for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) { |
|
| 57 | - if ($from_lines[$xi] !== $to_lines[$yi]) { |
|
| 58 | - break; |
|
| 59 | - } |
|
| 60 | - $this->xchanged[$xi] = $this->ychanged[$yi] = false; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // Ignore lines which do not exist in both files. |
|
| 64 | - for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { |
|
| 65 | - $xhash[$from_lines[$xi]] = 1; |
|
| 66 | - } |
|
| 67 | - for ($yi = $skip; $yi < $n_to - $endskip; $yi++) { |
|
| 68 | - $line = $to_lines[$yi]; |
|
| 69 | - if (($this->ychanged[$yi] = empty($xhash[$line]))) { |
|
| 70 | - continue; |
|
| 71 | - } |
|
| 72 | - $yhash[$line] = 1; |
|
| 73 | - $this->yv[] = $line; |
|
| 74 | - $this->yind[] = $yi; |
|
| 75 | - } |
|
| 76 | - for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { |
|
| 77 | - $line = $from_lines[$xi]; |
|
| 78 | - if (($this->xchanged[$xi] = empty($yhash[$line]))) { |
|
| 79 | - continue; |
|
| 80 | - } |
|
| 81 | - $this->xv[] = $line; |
|
| 82 | - $this->xind[] = $xi; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - // Find the LCS. |
|
| 86 | - $this->_compareseq(0, count($this->xv), 0, count($this->yv)); |
|
| 87 | - |
|
| 88 | - // Merge edits when possible. |
|
| 89 | - $this->_shiftBoundaries($from_lines, $this->xchanged, $this->ychanged); |
|
| 90 | - $this->_shiftBoundaries($to_lines, $this->ychanged, $this->xchanged); |
|
| 91 | - |
|
| 92 | - // Compute the edit operations. |
|
| 93 | - $edits = array(); |
|
| 94 | - $xi = $yi = 0; |
|
| 95 | - while ($xi < $n_from || $yi < $n_to) { |
|
| 96 | - assert($yi < $n_to || $this->xchanged[$xi]); |
|
| 97 | - assert($xi < $n_from || $this->ychanged[$yi]); |
|
| 98 | - |
|
| 99 | - // Skip matching "snake". |
|
| 100 | - $copy = array(); |
|
| 101 | - while ($xi < $n_from && $yi < $n_to |
|
| 102 | - && !$this->xchanged[$xi] && !$this->ychanged[$yi]) { |
|
| 103 | - $copy[] = $from_lines[$xi++]; |
|
| 104 | - ++$yi; |
|
| 105 | - } |
|
| 106 | - if ($copy) { |
|
| 107 | - $edits[] = new Text_Diff_Op_copy($copy); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - // Find deletes & adds. |
|
| 111 | - $delete = array(); |
|
| 112 | - while ($xi < $n_from && $this->xchanged[$xi]) { |
|
| 113 | - $delete[] = $from_lines[$xi++]; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $add = array(); |
|
| 117 | - while ($yi < $n_to && $this->ychanged[$yi]) { |
|
| 118 | - $add[] = $to_lines[$yi++]; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - if ($delete && $add) { |
|
| 122 | - $edits[] = new Text_Diff_Op_change($delete, $add); |
|
| 123 | - } elseif ($delete) { |
|
| 124 | - $edits[] = new Text_Diff_Op_delete($delete); |
|
| 125 | - } elseif ($add) { |
|
| 126 | - $edits[] = new Text_Diff_Op_add($add); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - return $edits; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF, |
|
| 135 | - * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized |
|
| 136 | - * segments. |
|
| 137 | - * |
|
| 138 | - * Returns (LCS, PTS). LCS is the length of the LCS. PTS is an array of |
|
| 139 | - * NCHUNKS+1 (X, Y) indexes giving the diving points between sub |
|
| 140 | - * sequences. The first sub-sequence is contained in (X0, X1), (Y0, Y1), |
|
| 141 | - * the second in (X1, X2), (Y1, Y2) and so on. Note that (X0, Y0) == |
|
| 142 | - * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM). |
|
| 143 | - * |
|
| 144 | - * This function assumes that the first lines of the specified portions of |
|
| 145 | - * the two files do not match, and likewise that the last lines do not |
|
| 146 | - * match. The caller must trim matching lines from the beginning and end |
|
| 147 | - * of the portions it is going to specify. |
|
| 148 | - */ |
|
| 149 | - function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks) |
|
| 150 | - { |
|
| 151 | - $flip = false; |
|
| 152 | - |
|
| 153 | - if ($xlim - $xoff > $ylim - $yoff) { |
|
| 154 | - /* Things seems faster (I'm not sure I understand why) when the |
|
| 31 | + function diff($from_lines, $to_lines) |
|
| 32 | + { |
|
| 33 | + array_walk($from_lines, array('Text_Diff', 'trimNewlines')); |
|
| 34 | + array_walk($to_lines, array('Text_Diff', 'trimNewlines')); |
|
| 35 | + |
|
| 36 | + $n_from = count($from_lines); |
|
| 37 | + $n_to = count($to_lines); |
|
| 38 | + |
|
| 39 | + $this->xchanged = $this->ychanged = array(); |
|
| 40 | + $this->xv = $this->yv = array(); |
|
| 41 | + $this->xind = $this->yind = array(); |
|
| 42 | + unset($this->seq); |
|
| 43 | + unset($this->in_seq); |
|
| 44 | + unset($this->lcs); |
|
| 45 | + |
|
| 46 | + // Skip leading common lines. |
|
| 47 | + for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) { |
|
| 48 | + if ($from_lines[$skip] !== $to_lines[$skip]) { |
|
| 49 | + break; |
|
| 50 | + } |
|
| 51 | + $this->xchanged[$skip] = $this->ychanged[$skip] = false; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // Skip trailing common lines. |
|
| 55 | + $xi = $n_from; $yi = $n_to; |
|
| 56 | + for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) { |
|
| 57 | + if ($from_lines[$xi] !== $to_lines[$yi]) { |
|
| 58 | + break; |
|
| 59 | + } |
|
| 60 | + $this->xchanged[$xi] = $this->ychanged[$yi] = false; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // Ignore lines which do not exist in both files. |
|
| 64 | + for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { |
|
| 65 | + $xhash[$from_lines[$xi]] = 1; |
|
| 66 | + } |
|
| 67 | + for ($yi = $skip; $yi < $n_to - $endskip; $yi++) { |
|
| 68 | + $line = $to_lines[$yi]; |
|
| 69 | + if (($this->ychanged[$yi] = empty($xhash[$line]))) { |
|
| 70 | + continue; |
|
| 71 | + } |
|
| 72 | + $yhash[$line] = 1; |
|
| 73 | + $this->yv[] = $line; |
|
| 74 | + $this->yind[] = $yi; |
|
| 75 | + } |
|
| 76 | + for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { |
|
| 77 | + $line = $from_lines[$xi]; |
|
| 78 | + if (($this->xchanged[$xi] = empty($yhash[$line]))) { |
|
| 79 | + continue; |
|
| 80 | + } |
|
| 81 | + $this->xv[] = $line; |
|
| 82 | + $this->xind[] = $xi; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + // Find the LCS. |
|
| 86 | + $this->_compareseq(0, count($this->xv), 0, count($this->yv)); |
|
| 87 | + |
|
| 88 | + // Merge edits when possible. |
|
| 89 | + $this->_shiftBoundaries($from_lines, $this->xchanged, $this->ychanged); |
|
| 90 | + $this->_shiftBoundaries($to_lines, $this->ychanged, $this->xchanged); |
|
| 91 | + |
|
| 92 | + // Compute the edit operations. |
|
| 93 | + $edits = array(); |
|
| 94 | + $xi = $yi = 0; |
|
| 95 | + while ($xi < $n_from || $yi < $n_to) { |
|
| 96 | + assert($yi < $n_to || $this->xchanged[$xi]); |
|
| 97 | + assert($xi < $n_from || $this->ychanged[$yi]); |
|
| 98 | + |
|
| 99 | + // Skip matching "snake". |
|
| 100 | + $copy = array(); |
|
| 101 | + while ($xi < $n_from && $yi < $n_to |
|
| 102 | + && !$this->xchanged[$xi] && !$this->ychanged[$yi]) { |
|
| 103 | + $copy[] = $from_lines[$xi++]; |
|
| 104 | + ++$yi; |
|
| 105 | + } |
|
| 106 | + if ($copy) { |
|
| 107 | + $edits[] = new Text_Diff_Op_copy($copy); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + // Find deletes & adds. |
|
| 111 | + $delete = array(); |
|
| 112 | + while ($xi < $n_from && $this->xchanged[$xi]) { |
|
| 113 | + $delete[] = $from_lines[$xi++]; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $add = array(); |
|
| 117 | + while ($yi < $n_to && $this->ychanged[$yi]) { |
|
| 118 | + $add[] = $to_lines[$yi++]; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + if ($delete && $add) { |
|
| 122 | + $edits[] = new Text_Diff_Op_change($delete, $add); |
|
| 123 | + } elseif ($delete) { |
|
| 124 | + $edits[] = new Text_Diff_Op_delete($delete); |
|
| 125 | + } elseif ($add) { |
|
| 126 | + $edits[] = new Text_Diff_Op_add($add); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + return $edits; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF, |
|
| 135 | + * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized |
|
| 136 | + * segments. |
|
| 137 | + * |
|
| 138 | + * Returns (LCS, PTS). LCS is the length of the LCS. PTS is an array of |
|
| 139 | + * NCHUNKS+1 (X, Y) indexes giving the diving points between sub |
|
| 140 | + * sequences. The first sub-sequence is contained in (X0, X1), (Y0, Y1), |
|
| 141 | + * the second in (X1, X2), (Y1, Y2) and so on. Note that (X0, Y0) == |
|
| 142 | + * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM). |
|
| 143 | + * |
|
| 144 | + * This function assumes that the first lines of the specified portions of |
|
| 145 | + * the two files do not match, and likewise that the last lines do not |
|
| 146 | + * match. The caller must trim matching lines from the beginning and end |
|
| 147 | + * of the portions it is going to specify. |
|
| 148 | + */ |
|
| 149 | + function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks) |
|
| 150 | + { |
|
| 151 | + $flip = false; |
|
| 152 | + |
|
| 153 | + if ($xlim - $xoff > $ylim - $yoff) { |
|
| 154 | + /* Things seems faster (I'm not sure I understand why) when the |
|
| 155 | 155 | * shortest sequence is in X. */ |
| 156 | - $flip = true; |
|
| 157 | - list ($xoff, $xlim, $yoff, $ylim) |
|
| 158 | - = array($yoff, $ylim, $xoff, $xlim); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - if ($flip) { |
|
| 162 | - for ($i = $ylim - 1; $i >= $yoff; $i--) { |
|
| 163 | - $ymatches[$this->xv[$i]][] = $i; |
|
| 164 | - } |
|
| 165 | - } else { |
|
| 166 | - for ($i = $ylim - 1; $i >= $yoff; $i--) { |
|
| 167 | - $ymatches[$this->yv[$i]][] = $i; |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - $this->lcs = 0; |
|
| 172 | - $this->seq[0]= $yoff - 1; |
|
| 173 | - $this->in_seq = array(); |
|
| 174 | - $ymids[0] = array(); |
|
| 175 | - |
|
| 176 | - $numer = $xlim - $xoff + $nchunks - 1; |
|
| 177 | - $x = $xoff; |
|
| 178 | - for ($chunk = 0; $chunk < $nchunks; $chunk++) { |
|
| 179 | - if ($chunk > 0) { |
|
| 180 | - for ($i = 0; $i <= $this->lcs; $i++) { |
|
| 181 | - $ymids[$i][$chunk - 1] = $this->seq[$i]; |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks); |
|
| 186 | - for (; $x < $x1; $x++) { |
|
| 187 | - $line = $flip ? $this->yv[$x] : $this->xv[$x]; |
|
| 188 | - if (empty($ymatches[$line])) { |
|
| 189 | - continue; |
|
| 190 | - } |
|
| 191 | - $matches = $ymatches[$line]; |
|
| 192 | - reset($matches); |
|
| 193 | - while (list(, $y) = each($matches)) { |
|
| 194 | - if (empty($this->in_seq[$y])) { |
|
| 195 | - $k = $this->_lcsPos($y); |
|
| 196 | - assert($k > 0); |
|
| 197 | - $ymids[$k] = $ymids[$k - 1]; |
|
| 198 | - break; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - while (list(, $y) = each($matches)) { |
|
| 202 | - if ($y > $this->seq[$k - 1]) { |
|
| 203 | - assert($y <= $this->seq[$k]); |
|
| 204 | - /* Optimization: this is a common case: next match is |
|
| 156 | + $flip = true; |
|
| 157 | + list ($xoff, $xlim, $yoff, $ylim) |
|
| 158 | + = array($yoff, $ylim, $xoff, $xlim); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + if ($flip) { |
|
| 162 | + for ($i = $ylim - 1; $i >= $yoff; $i--) { |
|
| 163 | + $ymatches[$this->xv[$i]][] = $i; |
|
| 164 | + } |
|
| 165 | + } else { |
|
| 166 | + for ($i = $ylim - 1; $i >= $yoff; $i--) { |
|
| 167 | + $ymatches[$this->yv[$i]][] = $i; |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + $this->lcs = 0; |
|
| 172 | + $this->seq[0]= $yoff - 1; |
|
| 173 | + $this->in_seq = array(); |
|
| 174 | + $ymids[0] = array(); |
|
| 175 | + |
|
| 176 | + $numer = $xlim - $xoff + $nchunks - 1; |
|
| 177 | + $x = $xoff; |
|
| 178 | + for ($chunk = 0; $chunk < $nchunks; $chunk++) { |
|
| 179 | + if ($chunk > 0) { |
|
| 180 | + for ($i = 0; $i <= $this->lcs; $i++) { |
|
| 181 | + $ymids[$i][$chunk - 1] = $this->seq[$i]; |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks); |
|
| 186 | + for (; $x < $x1; $x++) { |
|
| 187 | + $line = $flip ? $this->yv[$x] : $this->xv[$x]; |
|
| 188 | + if (empty($ymatches[$line])) { |
|
| 189 | + continue; |
|
| 190 | + } |
|
| 191 | + $matches = $ymatches[$line]; |
|
| 192 | + reset($matches); |
|
| 193 | + while (list(, $y) = each($matches)) { |
|
| 194 | + if (empty($this->in_seq[$y])) { |
|
| 195 | + $k = $this->_lcsPos($y); |
|
| 196 | + assert($k > 0); |
|
| 197 | + $ymids[$k] = $ymids[$k - 1]; |
|
| 198 | + break; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + while (list(, $y) = each($matches)) { |
|
| 202 | + if ($y > $this->seq[$k - 1]) { |
|
| 203 | + assert($y <= $this->seq[$k]); |
|
| 204 | + /* Optimization: this is a common case: next match is |
|
| 205 | 205 | * just replacing previous match. */ |
| 206 | - $this->in_seq[$this->seq[$k]] = false; |
|
| 207 | - $this->seq[$k] = $y; |
|
| 208 | - $this->in_seq[$y] = 1; |
|
| 209 | - } elseif (empty($this->in_seq[$y])) { |
|
| 210 | - $k = $this->_lcsPos($y); |
|
| 211 | - assert($k > 0); |
|
| 212 | - $ymids[$k] = $ymids[$k - 1]; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff); |
|
| 219 | - $ymid = $ymids[$this->lcs]; |
|
| 220 | - for ($n = 0; $n < $nchunks - 1; $n++) { |
|
| 221 | - $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks); |
|
| 222 | - $y1 = $ymid[$n] + 1; |
|
| 223 | - $seps[] = $flip ? array($y1, $x1) : array($x1, $y1); |
|
| 224 | - } |
|
| 225 | - $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim); |
|
| 226 | - |
|
| 227 | - return array($this->lcs, $seps); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - function _lcsPos($ypos) |
|
| 231 | - { |
|
| 232 | - $end = $this->lcs; |
|
| 233 | - if ($end == 0 || $ypos > $this->seq[$end]) { |
|
| 234 | - $this->seq[++$this->lcs] = $ypos; |
|
| 235 | - $this->in_seq[$ypos] = 1; |
|
| 236 | - return $this->lcs; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - $beg = 1; |
|
| 240 | - while ($beg < $end) { |
|
| 241 | - $mid = (int)(($beg + $end) / 2); |
|
| 242 | - if ($ypos > $this->seq[$mid]) { |
|
| 243 | - $beg = $mid + 1; |
|
| 244 | - } else { |
|
| 245 | - $end = $mid; |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - assert($ypos != $this->seq[$end]); |
|
| 250 | - |
|
| 251 | - $this->in_seq[$this->seq[$end]] = false; |
|
| 252 | - $this->seq[$end] = $ypos; |
|
| 253 | - $this->in_seq[$ypos] = 1; |
|
| 254 | - return $end; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * Finds LCS of two sequences. |
|
| 259 | - * |
|
| 260 | - * The results are recorded in the vectors $this->{x,y}changed[], by |
|
| 261 | - * storing a 1 in the element for each line that is an insertion or |
|
| 262 | - * deletion (ie. is not in the LCS). |
|
| 263 | - * |
|
| 264 | - * The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1. |
|
| 265 | - * |
|
| 266 | - * Note that XLIM, YLIM are exclusive bounds. All line numbers are |
|
| 267 | - * origin-0 and discarded lines are not counted. |
|
| 268 | - */ |
|
| 269 | - function _compareseq ($xoff, $xlim, $yoff, $ylim) |
|
| 270 | - { |
|
| 271 | - /* Slide down the bottom initial diagonal. */ |
|
| 272 | - while ($xoff < $xlim && $yoff < $ylim |
|
| 273 | - && $this->xv[$xoff] == $this->yv[$yoff]) { |
|
| 274 | - ++$xoff; |
|
| 275 | - ++$yoff; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /* Slide up the top initial diagonal. */ |
|
| 279 | - while ($xlim > $xoff && $ylim > $yoff |
|
| 280 | - && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) { |
|
| 281 | - --$xlim; |
|
| 282 | - --$ylim; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - if ($xoff == $xlim || $yoff == $ylim) { |
|
| 286 | - $lcs = 0; |
|
| 287 | - } else { |
|
| 288 | - /* This is ad hoc but seems to work well. $nchunks = |
|
| 206 | + $this->in_seq[$this->seq[$k]] = false; |
|
| 207 | + $this->seq[$k] = $y; |
|
| 208 | + $this->in_seq[$y] = 1; |
|
| 209 | + } elseif (empty($this->in_seq[$y])) { |
|
| 210 | + $k = $this->_lcsPos($y); |
|
| 211 | + assert($k > 0); |
|
| 212 | + $ymids[$k] = $ymids[$k - 1]; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff); |
|
| 219 | + $ymid = $ymids[$this->lcs]; |
|
| 220 | + for ($n = 0; $n < $nchunks - 1; $n++) { |
|
| 221 | + $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks); |
|
| 222 | + $y1 = $ymid[$n] + 1; |
|
| 223 | + $seps[] = $flip ? array($y1, $x1) : array($x1, $y1); |
|
| 224 | + } |
|
| 225 | + $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim); |
|
| 226 | + |
|
| 227 | + return array($this->lcs, $seps); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + function _lcsPos($ypos) |
|
| 231 | + { |
|
| 232 | + $end = $this->lcs; |
|
| 233 | + if ($end == 0 || $ypos > $this->seq[$end]) { |
|
| 234 | + $this->seq[++$this->lcs] = $ypos; |
|
| 235 | + $this->in_seq[$ypos] = 1; |
|
| 236 | + return $this->lcs; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + $beg = 1; |
|
| 240 | + while ($beg < $end) { |
|
| 241 | + $mid = (int)(($beg + $end) / 2); |
|
| 242 | + if ($ypos > $this->seq[$mid]) { |
|
| 243 | + $beg = $mid + 1; |
|
| 244 | + } else { |
|
| 245 | + $end = $mid; |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + assert($ypos != $this->seq[$end]); |
|
| 250 | + |
|
| 251 | + $this->in_seq[$this->seq[$end]] = false; |
|
| 252 | + $this->seq[$end] = $ypos; |
|
| 253 | + $this->in_seq[$ypos] = 1; |
|
| 254 | + return $end; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * Finds LCS of two sequences. |
|
| 259 | + * |
|
| 260 | + * The results are recorded in the vectors $this->{x,y}changed[], by |
|
| 261 | + * storing a 1 in the element for each line that is an insertion or |
|
| 262 | + * deletion (ie. is not in the LCS). |
|
| 263 | + * |
|
| 264 | + * The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1. |
|
| 265 | + * |
|
| 266 | + * Note that XLIM, YLIM are exclusive bounds. All line numbers are |
|
| 267 | + * origin-0 and discarded lines are not counted. |
|
| 268 | + */ |
|
| 269 | + function _compareseq ($xoff, $xlim, $yoff, $ylim) |
|
| 270 | + { |
|
| 271 | + /* Slide down the bottom initial diagonal. */ |
|
| 272 | + while ($xoff < $xlim && $yoff < $ylim |
|
| 273 | + && $this->xv[$xoff] == $this->yv[$yoff]) { |
|
| 274 | + ++$xoff; |
|
| 275 | + ++$yoff; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /* Slide up the top initial diagonal. */ |
|
| 279 | + while ($xlim > $xoff && $ylim > $yoff |
|
| 280 | + && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) { |
|
| 281 | + --$xlim; |
|
| 282 | + --$ylim; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + if ($xoff == $xlim || $yoff == $ylim) { |
|
| 286 | + $lcs = 0; |
|
| 287 | + } else { |
|
| 288 | + /* This is ad hoc but seems to work well. $nchunks = |
|
| 289 | 289 | * sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); $nchunks = |
| 290 | 290 | * max(2,min(8,(int)$nchunks)); */ |
| 291 | - $nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1; |
|
| 292 | - list($lcs, $seps) |
|
| 293 | - = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks); |
|
| 294 | - } |
|
| 291 | + $nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1; |
|
| 292 | + list($lcs, $seps) |
|
| 293 | + = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks); |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - if ($lcs == 0) { |
|
| 297 | - /* X and Y sequences have no common subsequence: mark all |
|
| 296 | + if ($lcs == 0) { |
|
| 297 | + /* X and Y sequences have no common subsequence: mark all |
|
| 298 | 298 | * changed. */ |
| 299 | - while ($yoff < $ylim) { |
|
| 300 | - $this->ychanged[$this->yind[$yoff++]] = 1; |
|
| 301 | - } |
|
| 302 | - while ($xoff < $xlim) { |
|
| 303 | - $this->xchanged[$this->xind[$xoff++]] = 1; |
|
| 304 | - } |
|
| 305 | - } else { |
|
| 306 | - /* Use the partitions to split this problem into subproblems. */ |
|
| 307 | - reset($seps); |
|
| 308 | - $pt1 = $seps[0]; |
|
| 309 | - while ($pt2 = next($seps)) { |
|
| 310 | - $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]); |
|
| 311 | - $pt1 = $pt2; |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * Adjusts inserts/deletes of identical lines to join changes as much as |
|
| 318 | - * possible. |
|
| 319 | - * |
|
| 320 | - * We do something when a run of changed lines include a line at one end |
|
| 321 | - * and has an excluded, identical line at the other. We are free to |
|
| 322 | - * choose which identical line is included. `compareseq' usually chooses |
|
| 323 | - * the one at the beginning, but usually it is cleaner to consider the |
|
| 324 | - * following identical line to be the "change". |
|
| 325 | - * |
|
| 326 | - * This is extracted verbatim from analyze.c (GNU diffutils-2.7). |
|
| 327 | - */ |
|
| 328 | - function _shiftBoundaries($lines, &$changed, $other_changed) |
|
| 329 | - { |
|
| 330 | - $i = 0; |
|
| 331 | - $j = 0; |
|
| 332 | - |
|
| 333 | - assert('count($lines) == count($changed)'); |
|
| 334 | - $len = count($lines); |
|
| 335 | - $other_len = count($other_changed); |
|
| 336 | - |
|
| 337 | - while (1) { |
|
| 338 | - /* Scan forward to find the beginning of another run of |
|
| 299 | + while ($yoff < $ylim) { |
|
| 300 | + $this->ychanged[$this->yind[$yoff++]] = 1; |
|
| 301 | + } |
|
| 302 | + while ($xoff < $xlim) { |
|
| 303 | + $this->xchanged[$this->xind[$xoff++]] = 1; |
|
| 304 | + } |
|
| 305 | + } else { |
|
| 306 | + /* Use the partitions to split this problem into subproblems. */ |
|
| 307 | + reset($seps); |
|
| 308 | + $pt1 = $seps[0]; |
|
| 309 | + while ($pt2 = next($seps)) { |
|
| 310 | + $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]); |
|
| 311 | + $pt1 = $pt2; |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * Adjusts inserts/deletes of identical lines to join changes as much as |
|
| 318 | + * possible. |
|
| 319 | + * |
|
| 320 | + * We do something when a run of changed lines include a line at one end |
|
| 321 | + * and has an excluded, identical line at the other. We are free to |
|
| 322 | + * choose which identical line is included. `compareseq' usually chooses |
|
| 323 | + * the one at the beginning, but usually it is cleaner to consider the |
|
| 324 | + * following identical line to be the "change". |
|
| 325 | + * |
|
| 326 | + * This is extracted verbatim from analyze.c (GNU diffutils-2.7). |
|
| 327 | + */ |
|
| 328 | + function _shiftBoundaries($lines, &$changed, $other_changed) |
|
| 329 | + { |
|
| 330 | + $i = 0; |
|
| 331 | + $j = 0; |
|
| 332 | + |
|
| 333 | + assert('count($lines) == count($changed)'); |
|
| 334 | + $len = count($lines); |
|
| 335 | + $other_len = count($other_changed); |
|
| 336 | + |
|
| 337 | + while (1) { |
|
| 338 | + /* Scan forward to find the beginning of another run of |
|
| 339 | 339 | * changes. Also keep track of the corresponding point in the |
| 340 | 340 | * other file. |
| 341 | 341 | * |
@@ -346,91 +346,91 @@ discard block |
||
| 346 | 346 | * |
| 347 | 347 | * Furthermore, $j is always kept so that $j == $other_len or |
| 348 | 348 | * $other_changed[$j] == false. */ |
| 349 | - while ($j < $other_len && $other_changed[$j]) { |
|
| 350 | - $j++; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - while ($i < $len && ! $changed[$i]) { |
|
| 354 | - assert('$j < $other_len && ! $other_changed[$j]'); |
|
| 355 | - $i++; $j++; |
|
| 356 | - while ($j < $other_len && $other_changed[$j]) { |
|
| 357 | - $j++; |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - if ($i == $len) { |
|
| 362 | - break; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - $start = $i; |
|
| 366 | - |
|
| 367 | - /* Find the end of this run of changes. */ |
|
| 368 | - while (++$i < $len && $changed[$i]) { |
|
| 369 | - continue; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - do { |
|
| 373 | - /* Record the length of this run of changes, so that we can |
|
| 349 | + while ($j < $other_len && $other_changed[$j]) { |
|
| 350 | + $j++; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + while ($i < $len && ! $changed[$i]) { |
|
| 354 | + assert('$j < $other_len && ! $other_changed[$j]'); |
|
| 355 | + $i++; $j++; |
|
| 356 | + while ($j < $other_len && $other_changed[$j]) { |
|
| 357 | + $j++; |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + if ($i == $len) { |
|
| 362 | + break; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + $start = $i; |
|
| 366 | + |
|
| 367 | + /* Find the end of this run of changes. */ |
|
| 368 | + while (++$i < $len && $changed[$i]) { |
|
| 369 | + continue; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + do { |
|
| 373 | + /* Record the length of this run of changes, so that we can |
|
| 374 | 374 | * later determine whether the run has grown. */ |
| 375 | - $runlength = $i - $start; |
|
| 375 | + $runlength = $i - $start; |
|
| 376 | 376 | |
| 377 | - /* Move the changed region back, so long as the previous |
|
| 377 | + /* Move the changed region back, so long as the previous |
|
| 378 | 378 | * unchanged line matches the last changed one. This merges |
| 379 | 379 | * with previous changed regions. */ |
| 380 | - while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) { |
|
| 381 | - $changed[--$start] = 1; |
|
| 382 | - $changed[--$i] = false; |
|
| 383 | - while ($start > 0 && $changed[$start - 1]) { |
|
| 384 | - $start--; |
|
| 385 | - } |
|
| 386 | - assert('$j > 0'); |
|
| 387 | - while ($other_changed[--$j]) { |
|
| 388 | - continue; |
|
| 389 | - } |
|
| 390 | - assert('$j >= 0 && !$other_changed[$j]'); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - /* Set CORRESPONDING to the end of the changed run, at the |
|
| 380 | + while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) { |
|
| 381 | + $changed[--$start] = 1; |
|
| 382 | + $changed[--$i] = false; |
|
| 383 | + while ($start > 0 && $changed[$start - 1]) { |
|
| 384 | + $start--; |
|
| 385 | + } |
|
| 386 | + assert('$j > 0'); |
|
| 387 | + while ($other_changed[--$j]) { |
|
| 388 | + continue; |
|
| 389 | + } |
|
| 390 | + assert('$j >= 0 && !$other_changed[$j]'); |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + /* Set CORRESPONDING to the end of the changed run, at the |
|
| 394 | 394 | * last point where it corresponds to a changed run in the |
| 395 | 395 | * other file. CORRESPONDING == LEN means no such point has |
| 396 | 396 | * been found. */ |
| 397 | - $corresponding = $j < $other_len ? $i : $len; |
|
| 397 | + $corresponding = $j < $other_len ? $i : $len; |
|
| 398 | 398 | |
| 399 | - /* Move the changed region forward, so long as the first |
|
| 399 | + /* Move the changed region forward, so long as the first |
|
| 400 | 400 | * changed line matches the following unchanged one. This |
| 401 | 401 | * merges with following changed regions. Do this second, so |
| 402 | 402 | * that if there are no merges, the changed region is moved |
| 403 | 403 | * forward as far as possible. */ |
| 404 | - while ($i < $len && $lines[$start] == $lines[$i]) { |
|
| 405 | - $changed[$start++] = false; |
|
| 406 | - $changed[$i++] = 1; |
|
| 407 | - while ($i < $len && $changed[$i]) { |
|
| 408 | - $i++; |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - assert('$j < $other_len && ! $other_changed[$j]'); |
|
| 412 | - $j++; |
|
| 413 | - if ($j < $other_len && $other_changed[$j]) { |
|
| 414 | - $corresponding = $i; |
|
| 415 | - while ($j < $other_len && $other_changed[$j]) { |
|
| 416 | - $j++; |
|
| 417 | - } |
|
| 418 | - } |
|
| 419 | - } |
|
| 420 | - } while ($runlength != $i - $start); |
|
| 421 | - |
|
| 422 | - /* If possible, move the fully-merged run of changes back to a |
|
| 404 | + while ($i < $len && $lines[$start] == $lines[$i]) { |
|
| 405 | + $changed[$start++] = false; |
|
| 406 | + $changed[$i++] = 1; |
|
| 407 | + while ($i < $len && $changed[$i]) { |
|
| 408 | + $i++; |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + assert('$j < $other_len && ! $other_changed[$j]'); |
|
| 412 | + $j++; |
|
| 413 | + if ($j < $other_len && $other_changed[$j]) { |
|
| 414 | + $corresponding = $i; |
|
| 415 | + while ($j < $other_len && $other_changed[$j]) { |
|
| 416 | + $j++; |
|
| 417 | + } |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | + } while ($runlength != $i - $start); |
|
| 421 | + |
|
| 422 | + /* If possible, move the fully-merged run of changes back to a |
|
| 423 | 423 | * corresponding run in the other file. */ |
| 424 | - while ($corresponding < $i) { |
|
| 425 | - $changed[--$start] = 1; |
|
| 426 | - $changed[--$i] = 0; |
|
| 427 | - assert('$j > 0'); |
|
| 428 | - while ($other_changed[--$j]) { |
|
| 429 | - continue; |
|
| 430 | - } |
|
| 431 | - assert('$j >= 0 && !$other_changed[$j]'); |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - } |
|
| 424 | + while ($corresponding < $i) { |
|
| 425 | + $changed[--$start] = 1; |
|
| 426 | + $changed[--$i] = 0; |
|
| 427 | + assert('$j > 0'); |
|
| 428 | + while ($other_changed[--$j]) { |
|
| 429 | + continue; |
|
| 430 | + } |
|
| 431 | + assert('$j >= 0 && !$other_changed[$j]'); |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | 436 | } |