"ext-json": "*",
"ext-iconv": "*",
"ext-gd": "*",
+ "ext-sodium": "*",
"laravel/framework": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0",
"cubist/util": "dev-master",
"cubist/pdf": "dev-master",
"barryvdh/laravel-debugbar": "*",
- "spatie/laravel-medialibrary": "^9.12.4|^10.7.16"
+ "spatie/laravel-medialibrary": "^9.12.4|^10.7.16",
+ "chillerlan/php-qrcode": "dev-main"
}
}
namespace Fluidbook\Tools\Links;
+use chillerlan\QRCode\QRCode;
use Cubist\Util\ArrayUtil;
use Cubist\Util\Crypt;
use Cubist\Util\CSS;
use Cubist\Util\ObjectUtil;
use Cubist\Util\Text;
use Cubist\Util\Xml;
-use Fluidbook\Tools\Compiler\Compiler;
use Fluidbook\Tools\Compiler\CompilerInterface;
use SodiumException;
use stdClass;
$init['scorm'] = self::isScorm($init);
$init['to'] = self::replaceCustomURL($init['to']);
+ if ($init['to'] === 'auto:qrcode') {
+ $init['to'] = self::scanQRCode($init, $compiler);
+ }
+
switch ($init['type']) {
case static::WEB:
case static::WEB_INFOS:
return $link;
}
+ /**
+ * @throws \Exception
+ */
+ public static function scanQRCode($link, $compiler)
+ {
+ $image = ZoomLink::generateImage([
+ 'id' => $link['uid'],
+ 'page' => $link['page'],
+ 'maxzoom' => 2,
+ 'group' => '',
+ 'group-count' => 0,
+ 'width' => round($link['width']),
+ 'height' => round($link['height']),
+ 'x' => round($link['left']),
+ 'y' => round($link['top']),
+ 'border' => 0,
+ 'borderColor' => '',
+ ], $compiler, 'qrcodereader', 'qrcode', false, false);
+
+ return ':)';
+ try {
+ $result = (new QRCode)->readFromFile($image);
+ return (string)$result;
+ } catch (\Exception $e) {
+
+ }
+ return '';
+ }
+
}
/**
* @param $attributes
- * @param $compiler CompilerInterface
+ * @param $compiler CompilerInterface|null
* @param $cachedir
* @param $save
- * @return void
+ * @return string
*/
- public static function generateImage($attributes, $compiler, $cachedir, $save, $trim = false) {
+ public static function generateImage($attributes, $compiler, $cachedir, $save, $trim = false,$copy=true) {
$maxzoom = $attributes['maxzoom']; // Max zoom level might not always be set in the link editor
$maxzoom = max(0, min($maxzoom, 20));
Log::error('Failed generate image ' . json_encode($attributes));
}
$dest = 'data/links/' . $save . '_' . $attributes['id'] . '.' . $ext;
- $compiler->simpleCopyLinkFile($both, $dest);
+ if($copy) {
+ $compiler->simpleCopyLinkFile($both, $dest);
+ }
+ return $both;
}