use Cubist\Util\Xml;
use Fluidbook\Tools\Compiler\Compiler;
use Fluidbook\Tools\Compiler\CompilerInterface;
+use SodiumException;
use stdClass;
class Link {
}
+ public static function encryptLinks($links)
+ {
+ $res = [];
+ foreach ($links as $key => $link) {
+ $res[$key] = self::encryptLinkAttrs($link);
+ }
+ return $res;
+ }
+
+ /**
+ * @throws SodiumException
+ */
+ public static function encryptLinkAttrs($link)
+ {
+ if (is_array($link)) {
+ $link = ObjectUtil::asObject($link);
+ }
+
+ $crypted = [13, 14, 35];
+
+ if (!isset($link->type) || !in_array($link->type, $crypted)) {
+ return $link;
+ }
+
+ $attrs = ['image_rollover'];
+ foreach ($attrs as $attr) {
+ if (!isset($link->$attr)) {
+ continue;
+ }
+ $link->$attr = trim($link->$attr);
+ if (str_starts_with($link->$attr, '///') || $link->$attr == '') {
+ continue;
+ }
+ $link->$attr = '///' . Crypt::safeEncrypt($link->uid . '|||' . $link->$attr, self::_getLinkKey());
+ }
+ return $link;
+ }
+
+
}