]> _ Git - cubist_util.git/commitdiff
wip #4697 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 Sep 2021 07:43:32 +0000 (09:43 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 Sep 2021 07:43:32 +0000 (09:43 +0200)
src/CSS.php [new file with mode: 0644]
src/Url.php

diff --git a/src/CSS.php b/src/CSS.php
new file mode 100644 (file)
index 0000000..f453c00
--- /dev/null
@@ -0,0 +1,17 @@
+<?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
index 53eee9bc0651ce658c4fbef710dda4117de2c3b2..1a83c0ffc7ddbce831fe528a0e87ed69cf30cfd5 100644 (file)
@@ -4,41 +4,38 @@ namespace Cubist\Util;
 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;
@@ -65,7 +62,7 @@ class Url
 
                $host = parse_url($url, PHP_URL_HOST);
                if (!$acceptSubdomain) {
-                       return $host == $domain;
+                       return $host === $domain;
                }
                return preg_match("/" . $domain . "$/", $host);
        }