--- /dev/null
+<?php
+
+namespace Cubist\Util;
+
+class CSS
+{
+ protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', '');
+
+ public static function writeCSSUA($property, $value)
+ {
+ $res = array();
+ foreach (self::$uaPrefixes as $prefix) {
+ $res[] = $prefix . $property . ':' . $value;
+ }
+ return implode(';', $res) . ';';
+ }
+}
\ No newline at end of file
class Url
{
- public static function isLocal($url, $site_url)
+ public static function isLocal($url, $site_url=null)
{
- if (strpos($url, $site_url) === 0) {
+ if (null!==$site_url && strpos($url, $site_url) === 0) {
return true;
}
- if (substr($url, 0, 2) == "//") {
+ if (strpos($url, "//") === 0) {
return false;
}
$u = parse_url($url);
- if (isset($u['scheme']) && $u['scheme'] != '') {
- return false;
- }
- return true;
- }
+ return !(isset($u['scheme']) && $u['scheme'] != '');
+ }
public static function extractPathComponents($path)
{
$path = urldecode($path);
$path = trim($path, '/');
if ($path == '') {
- return array();
- } else {
- return explode('/', $path);
+ return [];
}
- }
- public static function isDistant($url, $site_url)
+ return explode('/', $path);
+ }
+
+ public static function isDistant($url, $site_url=null)
{
return !self::isLocal($url, $site_url);
}
- public static function toAbsolute($url, $site_url)
+ public static function toAbsolute($url, $site_url=null)
{
- if (substr($url, 0, 1) == '/') {
+ if (strpos($url, '/') === 0) {
$url = $site_url . $url;
}
return $url;
$host = parse_url($url, PHP_URL_HOST);
if (!$acceptSubdomain) {
- return $host == $domain;
+ return $host === $domain;
}
return preg_match("/" . $domain . "$/", $host);
}