Commit 9496078b authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use function to process get_instance_config_javascript js (bug #845534)



Moving this code into its own function will allow it to be used for
block instance rendering javascript as well as the configuration form.

Change-Id: I42dba8425a8455aaa9faae19d50414e33c5988db
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent d513d730
......@@ -891,22 +891,7 @@ class BlockInstance {
$configjs = call_static_method($blocktypeclass, 'get_instance_config_javascript', $this);
if (is_array($configjs)) {
foreach ($configjs as &$jsfile) {
if (strpos($jsfile, 'http://') === false) {
if ($this->artefactplugin) {
$jsfile = 'artefact/' . $this->artefactplugin . '/blocktype/' .
$this->blocktype . '/' . $jsfile;
}
else {
$jsfile = 'blocktype/' . $this->blocktype . '/' . $jsfile;
}
$jsfile = '$j.getScript("' . get_config('wwwroot') . $jsfile . '");';
}
else {
$jsfile = '$j.getScript("' . $jsfile . '");';
}
}
$js .= implode('', $configjs);
$js = $this->get_get_javascript_javascript($configjs);
}
else if (is_string($configjs)) {
$js .= $configjs;
......@@ -1269,4 +1254,26 @@ class BlockInstance {
}
return $this->temp[$key][$id];
}
/**
* Returns javascript to grab & eval javascript from files on the web
*/
public function get_get_javascript_javascript($jsfiles) {
foreach ($jsfiles as &$jsfile) {
if (strpos($jsfile, 'http://') === false) {
if ($this->artefactplugin) {
$jsfile = 'artefact/' . $this->artefactplugin . '/blocktype/' .
$this->blocktype . '/' . $jsfile;
}
else {
$jsfile = 'blocktype/' . $this->blocktype . '/' . $jsfile;
}
$jsfile = '$j.getScript("' . get_config('wwwroot') . $jsfile . '");';
}
else {
$jsfile = '$j.getScript("' . $jsfile . '");';
}
}
return implode('', $jsfiles);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment