Merge branch 'M28_MDL46116_IMSCP_container_items' of https://github.com/Dave-B/moodle into MOODLE_28_STABLE
This commit is contained in:
+11
-7
@@ -60,15 +60,19 @@ function imscp_print_content($imscp, $cm, $course) {
|
||||
function imscp_htmllize_item($item, $imscp, $cm) {
|
||||
global $CFG;
|
||||
|
||||
if (preg_match('|^https?://|', $item['href'])) {
|
||||
$url = $item['href'];
|
||||
if ($item['href']) {
|
||||
if (preg_match('|^https?://|', $item['href'])) {
|
||||
$url = $item['href'];
|
||||
} else {
|
||||
$context = context_module::instance($cm->id);
|
||||
$urlbase = "$CFG->wwwroot/pluginfile.php";
|
||||
$path = '/'.$context->id.'/mod_imscp/content/'.$imscp->revision.'/'.$item['href'];
|
||||
$url = file_encode_url($urlbase, $path, false);
|
||||
}
|
||||
$result = "<li><a href=\"$url\">".$item['title'].'</a>';
|
||||
} else {
|
||||
$context = context_module::instance($cm->id);
|
||||
$urlbase = "$CFG->wwwroot/pluginfile.php";
|
||||
$path = '/'.$context->id.'/mod_imscp/content/'.$imscp->revision.'/'.$item['href'];
|
||||
$url = file_encode_url($urlbase, $path, false);
|
||||
$result = '<li>'.$item['title'];
|
||||
}
|
||||
$result = "<li><a href=\"$url\">".$item['title'].'</a>';
|
||||
if ($item['subitems']) {
|
||||
$result .= '<ul>';
|
||||
foreach ($item['subitems'] as $subitem) {
|
||||
|
||||
+30
-11
@@ -41,21 +41,29 @@ M.mod_imscp.init = function(Y) {
|
||||
imscp_current_node.highlight();
|
||||
|
||||
var content = new Y.YUI2.util.Element('imscp_content');
|
||||
try {
|
||||
// first try IE way - it can not set name attribute later
|
||||
// and also it has some restrictions on DOM access from object tag
|
||||
var obj = document.createElement('<iframe id="imscp_object" src="'+node.href+'">');
|
||||
} catch (e) {
|
||||
var obj = document.createElement('object');
|
||||
obj.setAttribute('id', 'imscp_object');
|
||||
obj.setAttribute('type', 'text/html');
|
||||
obj.setAttribute('data', node.href);
|
||||
var obj;
|
||||
if (node.href) {
|
||||
try {
|
||||
// First try IE way - it can not set name attribute later
|
||||
// and also it has some restrictions on DOM access from object tag.
|
||||
obj = document.createElement('<iframe id="imscp_object" src="' + node.href + '">');
|
||||
} catch (e) {
|
||||
obj = document.createElement('object');
|
||||
obj.setAttribute('id', 'imscp_object');
|
||||
obj.setAttribute('type', 'text/html');
|
||||
obj.setAttribute('data', node.href);
|
||||
}
|
||||
}
|
||||
var old = Y.YUI2.util.Dom.get('imscp_object');
|
||||
if (old) {
|
||||
content.replaceChild(obj, old);
|
||||
} else {
|
||||
content.appendChild(obj);
|
||||
old = Y.YUI2.util.Dom.get('imscp_child_list');
|
||||
if (old) {
|
||||
content.replaceChild(obj, old);
|
||||
} else {
|
||||
content.appendChild(obj);
|
||||
}
|
||||
}
|
||||
imscp_resize_frame();
|
||||
|
||||
@@ -139,6 +147,17 @@ M.mod_imscp.init = function(Y) {
|
||||
}
|
||||
};
|
||||
|
||||
var imscp_firstlinked = function(node) {
|
||||
// Return first item with an href
|
||||
if (node.href) {
|
||||
return node;
|
||||
} else if (node.children) {
|
||||
return imscp_firstlinked(node.children[0]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
var imscp_up = function(node) {
|
||||
if (node.depth > 0) {
|
||||
return node.parent;
|
||||
@@ -271,7 +290,7 @@ M.mod_imscp.init = function(Y) {
|
||||
});
|
||||
|
||||
// finally activate the first item
|
||||
imscp_activate_item(tree.getRoot().children[0]);
|
||||
imscp_activate_item(imscp_firstlinked(tree.getRoot().children[0]));
|
||||
|
||||
// resizing
|
||||
imscp_resize_layout(false);
|
||||
|
||||
Reference in New Issue
Block a user