<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php83" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-uuid" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/uid" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/chillerlan/php-qrcode" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/chillerlan/php-settings-container" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<path value="$PROJECT_DIR$/vendor/guzzlehttp/uri-template" />
<path value="$PROJECT_DIR$/vendor/laravel/prompts" />
<path value="$PROJECT_DIR$/vendor/psr/clock" />
+ <path value="$PROJECT_DIR$/vendor/chillerlan/php-settings-container" />
+ <path value="$PROJECT_DIR$/vendor/chillerlan/php-qrcode" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.0">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>
+ <component name="PhpUnit">
+ <phpunit_settings>
+ <PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
+ </phpunit_settings>
+ </component>
</project>
\ No newline at end of file
namespace Fluidbook\Tools\Links;
+use Illuminate\Support\Facades\DB;
+
class CustomLink extends NormalLink
{
protected $role = 'link';
return static::_getURL($this->to);
}
- protected static function _getURLOfType($type, $ref, $default = null)
- {
- global $core;
- $e = explode(':', $ref, 2);
- if (count($e) == 2 && $e[0] == $type) {
- $ref = $e[1];
- }
- $nospaceref = str_replace(' ', '', $ref);
- $r = $core->con->select("SELECT * FROM wsref WHERE (ref='" . $core->con->escape($ref) . "' OR ref='" . $core->con->escape($nospaceref) . "') AND type='" . $core->con->escape($type) . "'");
- if ($r->count()) {
- return $r->url;
- }
- if (null === $default) {
- return 'https://workshop.fluidbook.com/services/wsref?ref=' . urlencode($type . '|' . $ref);
- }
- return $default;
- }
-
-
public function getTarget()
{
return '_blank';
return new CustomLink($id, $init, $compiler);
}
- public static function _getURL($to)
+ protected static function _getURL($ref, $type = '', $default = null)
{
- $e = explode(':', $to, 2);
- if (!count($e) == 1) {
- return 'https://workshop.fluidbook.com/services/wsref?ref=' . urlencode($to);
+ $ref = str_replace('custom:', '', $ref);
+ $e = explode(':', $ref, 2);
+ if (count($e) == 2 && $e[0] == $type) {
+ $ref = $e[1];
+ $type = $e[0];
}
- $type = trim($e[0]);
- $ref = trim($e[1]);
- return self::_getURLOfType($type, $ref);
+ $nospaceref = str_replace(' ', '', $ref);
+
+ $res = DB::table('fluidbook_reference_url')->where('type', $type)->whereIn('ref', [$ref, $nospaceref])->get();
+ if ($res->count() > 0) {
+ $url = $res->get('url');
+ if (!$url || $url === '-') {
+ return $default;
+ }
+ return $url;
+ }
+ return $default;
}
}