diff --git a/lib/filelib.php b/lib/filelib.php index 37806b97542..a41c57615f3 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -566,7 +566,7 @@ function file_get_draft_area_files($draftitemid, $filepath = '/') { $icon = mimeinfo_from_type('icon', $file->get_mimetype()); $icon = str_replace('.gif', '', $icon); - $item->icon = $OUTPUT->pix_url('f/' . $icon); + $item->icon = $OUTPUT->pix_url('f/' . $icon)->out(); if ($icon == 'zip') { $item->type = 'zip'; @@ -576,7 +576,7 @@ function file_get_draft_area_files($draftitemid, $filepath = '/') { if ($file->is_directory()) { $item->filesize = 0; - $item->icon = $OUTPUT->pix_url('f/folder'); + $item->icon = $OUTPUT->pix_url('f/folder')->out(); $item->type = 'folder'; $foldername = explode('/', trim($item->filepath, '/')); $item->fullname = trim(array_pop($foldername), '/'); diff --git a/lib/javascript-static.js b/lib/javascript-static.js index d7233affa25..9ef86076688 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -5,8 +5,17 @@ var Y = null; // Global M object, this helps with solving of namespace and scope issues -var M = {}; +var M = M || {}; +function launch_filemanager(options) { + Y.use('core_filemanager', function() { + var client_id = options.client_id; + // filemangers defined in lib/form/filemanager.js + if (!filemanagers[client_id]) { + filemanagers[client_id] = new M.core_filemanager(options); + } + }); +} // === old legacy JS code, hopefully to be replaced soon by M.xx.yy and YUI3 code === @@ -1206,21 +1215,11 @@ function stripHTML(str) { } function json_decode(json) { - try { - var obj = YAHOO.lang.JSON.parse(json); - } catch (e) { - alert(e.toString() + "\n" + stripHTML(json)); - } - return obj; + return Y.JSON.parse(json); } function json_encode(data) { - try { - var json = YAHOO.lang.JSON.stringify(data); - } catch (e) { - alert(e.toString()); - } - return json; + return Y.JSON.stringify(data); } /** @@ -1317,8 +1316,17 @@ function confirm_dialog(event, args) { if (target.args.callback) { // args comes from PHP, so callback will be a string, needs to be evaluated by JS - var callback = eval('('+target.args.callback+')'); - callback.apply(this); + var callback = null; + if (Y.Lang.isFunction(target.args.callback)) { + callback = target.args.callback; + } else { + callback = eval('('+target.args.callback+')'); + } + if (Y.Lang.isObject(target.args.scope)) { + callback.apply(target.args.scope); + } else { + callback(); + } } if (target.tagName.toLowerCase() == 'a') { diff --git a/repository/lib.php b/repository/lib.php index 5f649d3c292..db51d898cde 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -836,7 +836,7 @@ abstract class repository { 'url'=>$fileinfo->get_url(), 'id'=>$file->get_itemid(), 'file'=>$file->get_filename(), - 'icon' => $OUTPUT->pix_url(file_extension_icon($thefile, 32)) + 'icon' => $OUTPUT->pix_url(file_extension_icon($thefile, 32))->out() ); } else { return null;