]> _ Git - cubeextranet.git/commitdiff
wip #5903 @0.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 2 May 2023 14:34:45 +0000 (14:34 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 2 May 2023 14:34:45 +0000 (14:34 +0000)
inc/ws/Util/class.ws.links.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index 89d90bf0810245e82404f22a2b546f46f731b56c..17bf87686744b9c2ddae9d6036dc7636dfe65886 100644 (file)
@@ -15,6 +15,9 @@ class wsLinks
     protected static $_testLinkCache = null;
     protected static $_linksKey = null;
 
+    protected static $_encryptedTypes = [14,15,35,39];
+    protected static $_encryptedAttributes = ['image_rollover'];
+
     public static function linksToExcel($links, $rulers, $pages = null)
     {
         set_time_limit(0);
@@ -319,54 +322,51 @@ class wsLinks
 
     public static function encryptLinkAttrs($link)
     {
-        if (is_array($link)) {
-            $link = CubeIT_Util_Object::asObject($link);
+        if (!is_array($link)) {
+            $link = CubeIT_Util_Array::asArray($link);
         }
 
-        $crypted = [13, 14, 35];
-
-        if (!in_array($link->type, $crypted)) {
-            return CubeIT_Util_Array::asArray($link);
+        if (!in_array($link->type, self::$_encryptedTypes)) {
+            return $link;
         }
 
-        $attrs = ['image_rollover'];
-        foreach ($attrs as $attr) {
+        foreach (self::$_encryptedAttributes as $attr) {
             if (!isset($link->$attr)) {
                 continue;
             }
-            $link->$attr = trim($link->$attr);
-            if (strpos($link->$attr, '///') === 0 || $link->$attr == '') {
+            $link->$attr = trim($link[$attr]);
+            if (strpos($link[$attr], '///') === 0 || $link[$attr] == '') {
                 continue;
             }
-            $link->$attr = '///' . CubeIT_Crypt::safeEncrypt($link->uid . '|||' . $link->$attr, self::_getLinkKey());
+            $link[$attr] = '///' . CubeIT_Crypt::safeEncrypt($link['uid'] . '|||' . $link[$attr], self::_getLinkKey());
         }
-        return CubeIT_Util_Array::asArray($link);
+        return $link;
     }
 
     public static function decryptLink($link)
     {
-        $array = false;
-        if (is_array($link)) {
-            $array = true;
-            $link = CubeIT_Util_Object::asObject($link);
+        if (!is_array($link)) {
+            $link = CubeIT_Util_Array::asArray($link);
+        }
+        if (!in_array($link['type'], self::$_encryptedTypes)) {
+            return $link;
         }
 
-        foreach ($link as $attr => $item) {
-            if (strpos($item, '///') !== 0) {
+        foreach (self::$_encryptedAttributes as $attr) {
+            $value=$link[$attr];
+            if (strpos($value, '///') !== 0) {
                 continue;
             }
-            $v = CubeIT_Crypt::safeDecrypt(substr($item, 3), self::_getLinkKey());
+            $v = CubeIT_Crypt::safeDecrypt(substr($value, 3), self::_getLinkKey());
             $e = explode('|||', $v);
-            if ($e[0] === $link->uid) {
-                $link->$attr = $e[1];
+            if ($e[0] === $link['uid']) {
+                $link[$attr] = $e[1];
             } else {
-                $link->$attr = '';
+                $link[$attr] = '';
             }
         }
-        if (!$array) {
-            return $link;
-        }
-        return CubeIT_Util_Array::asArray($link);
+
+        return $link;
     }
 
     public static function decryptLinks($links)
@@ -394,7 +394,7 @@ class wsLinks
 
     public static function getLinksDir($book_id)
     {
-        $dir = wsBook::getDir($book_id,'links');
+        $dir = wsBook::getDir($book_id, 'links');
         if (!file_exists($dir)) {
             mkdir($dir, 0777, true);
         }
index 436a5fc79439bb801be4f8b619c24e20b191cbff..d25fa138d6c1aeb3a30758fcd8a4016f12d8839d 100644 (file)
@@ -85,8 +85,6 @@ class wsHTML5Link
         $init = wsLinks::decryptLink($init);
         $init = CubeIT_Util_Array::asArray($init);
 
-        $wdir = wsBook::getDir($id, 'working');
-
         $init['scorm'] = self::isScorm($init);
         $init['to'] = self::replaceCustomURL($init['to']);
 
@@ -115,8 +113,6 @@ class wsHTML5Link
                 $init['video_controls'] = true;
                 copy($file, $compiler->wdir . $fname);
             }
-
-
         }
 
         switch ($init['type']) {