]> _ Git - cubist_util.git/commitdiff
wip #2602 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 20 Feb 2019 17:33:09 +0000 (18:33 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 20 Feb 2019 17:33:09 +0000 (18:33 +0100)
.gitignore
composer.json
src/Cubist/Util/Json.php [new file with mode: 0644]
src/Cubist/Util/WebVideo.php

index 723ef36f4e4f32c4560383aa5987c575a30c6535..89251957809632d53426e05f9f72ab5471fc8d8e 100644 (file)
@@ -1 +1,3 @@
-.idea
\ No newline at end of file
+.idea
+vendor
+composer.lock
\ No newline at end of file
index f3c69ef4223e87a3ace81c5ebcc8f1d8fbc4641e..a20fedce4cbe9c66fab3ba68a0a0cf4051ab9851 100644 (file)
@@ -21,6 +21,8 @@
     "ext-dom": "*",
     "ext-simplexml": "*",
     "ext-json": "*",
-    "ext-iconv": "*"
+    "ext-iconv": "*",
+    "zendframework/zend-filter": "^2.9@dev",
+    "zendframework/zend-json": "^3.1@dev"
   }
-}
\ No newline at end of file
+}
diff --git a/src/Cubist/Util/Json.php b/src/Cubist/Util/Json.php
new file mode 100644 (file)
index 0000000..644455a
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+namespace Cubist\Util;
+
+class Json extends \Zend\Json\Json
+{
+       /**
+        *
+        * @param mixed $v
+        * @return boolean
+        */
+       public static function isJson($v)
+       {
+               if (!is_string($v)) {
+                       return false;
+               }
+
+               $v = trim($v);
+
+               $firstchar = mb_substr($v, 0, 1);
+               $lastchar = mb_substr($v, -1);
+               return (($firstchar == '[' && $lastchar == ']') || ($firstchar == '{' && $lastchar == '}'));
+       }
+
+       public static function decode($encodedValue, $objectDecodeType = \Zend\Json\Json::TYPE_OBJECT)
+       {
+               if ((is_array($encodedValue) && $objectDecodeType == \Zend\Json\Json::TYPE_ARRAY) ||
+                       (is_object($encodedValue) && $objectDecodeType == \Zend\Json\Json::TYPE_OBJECT)
+               ) {
+                       return $encodedValue;
+               } else if (is_array($encodedValue) || is_object($encodedValue)) {
+                       $encodedValue = self::encode($encodedValue);
+               }
+               try {
+                       return parent::decode($encodedValue, $objectDecodeType);
+               } catch (\Exception $e) {
+                       return null;
+               }
+       }
+
+       public static function encode($valueToEncode, $cycleCheck = false, array $options = [])
+       {
+               return parent::encode($valueToEncode, $cycleCheck, $options);
+       }
+
+}
\ No newline at end of file
index 0f9c1e8640d48d1d77e7d38940f4a8266cc166c9..ae09523c8478b3b016c8e86b4b4718b23f1ffe4a 100644 (file)
@@ -29,7 +29,7 @@ class WebVideo {
 
                $s = CubeIT_Text::ucfirst($service, true);
                $f = '_get' . $s . 'Url';
-               $refl = new ReflectionClass(get_class());
+               $refl = new \ReflectionClass(get_class());
                if (!$refl->hasMethod($f)) {
                        return false;
                }
@@ -37,7 +37,7 @@ class WebVideo {
        }
 
        protected static function _getGenericUrl($url) {
-               $meta = CubeIT_Util_Html::getMicrodata($url);
+               $meta = Html::getMicrodata($url);
 
                $res = '';
                foreach ($meta->getElementsByTagName('*') as $m) {