Implement shortcode URL resolver

Fix URL for 360 content view
This commit is contained in:
Kumi 2021-08-19 11:37:47 +02:00
parent 75743e7c4d
commit 3cd8a30a4a
4 changed files with 32 additions and 1 deletions

22
classes/shortcodes.php Normal file
View file

@ -0,0 +1,22 @@
<?php
namespace mod_expcontent;
defined('MOODLE_INTERNAL') || die();
require('../../config.php');
require_once('lib.php');
class shortcodes {
public static function expcontent($shortcode, $args) {
$expconfig = get_config('mod_expcontent');
$baseurl = $expconfig->baseurl;
if ($baseurl[-1] != "/") $baseurl += "/";
$ext = array_key_exists("ext", $args) ? "." . $args["ext"] : "";
return $baseurl . "meta_media/high/" . $args["id"] . $ext;
}
}

8
db/shortcodes.php Normal file
View file

@ -0,0 +1,8 @@
<?php
defined('MOODLE_INTERNAL') || die();
$shortcodes = [
'expcontent' => [
'callback' => 'mod_expcontent\shortcodes::expcontent'
]
];

View file

@ -3,6 +3,7 @@
defined('MOODLE_INTERNAL') || die();
$string['modulename'] = 'EXP360 Content';
$string['modulename'] = 'EXP360 Contents';
$string['settings'] = 'Settings';

View file

@ -78,6 +78,6 @@ img {
<li><span><?php echo($expcontent->name); ?></span></li>
<li class="right"><a class="hover" href="javascript:history.back();"><i class="fas fa-times"></i></a></li>
</ul>
<iframe src='<?php echo($baseurl . "/view-content/" . $expcontent->contentid . "?autoplay=true"); ?>' allow="autoplay; fullscreen"></iframe>
<iframe src='<?php echo($baseurl . "view-content/" . $expcontent->contentid . "?autoplay=true"); ?>' allow="autoplay; fullscreen"></iframe>
</body>
</html>