Commit c54a779a authored by Penny Leach's avatar Penny Leach
Browse files

artefact/file - allow highlighting of files in the browser

this needs a stylesheet change but is coming up in the dom.

can also be used for when you upload a new file, I guess
parent 80b1cf5e
......@@ -34,7 +34,12 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('myfiles', 'artefact.file'));
safe_require('artefact', 'file');
$javascript = ArtefactTypeFileBase::get_my_files_js(param_integer('folder', null));
$highlight = null;
if ($file = param_integer('file', 0)) {
$highlight = array($file); // todo convert to file1=1&file2=2 etc
}
$javascript = ArtefactTypeFileBase::get_my_files_js(param_integer('folder', null), $highlight);
$smarty = smarty(
array('tablerenderer', 'artefact/file/js/file.js'),
......
......@@ -200,6 +200,9 @@ function FileBrowser(element, source, statevars, changedircallback, actionname,
var row = TR({'class': 'r' + (n%2),'id':'row_' + r.id});
addElementClass(row, 'directory-item');
addElementClass(row, r.artefacttype);
if (highlightfiles[r.id]) {
addElementClass(row, 'highlight-file');
}
if (self.canmodify) {
self.makeRowDraggable(row);
}
......
......@@ -540,7 +540,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
}
public static function get_my_files_js($folder_id=null) {
public static function get_my_files_js($folder_id=null, $highlightfiles=null) {
global $USER;
......@@ -574,6 +574,12 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
$enc_folders = json_encode(array());
}
if ($highlightfiles) {
$enc_files = json_encode(array_fill_keys($highlightfiles, 1));
} else {
$enc_files = json_encode(array());
}
$copyright = get_field('site_content', 'content', 'name', 'uploadcopyright');
$javascript = <<<JAVASCRIPT
......@@ -581,7 +587,7 @@ var copyrightnotice = '{$copyright}';
var browser = new FileBrowser('filelist', 'myfiles.json.php', null, null, null, null, {$enc_folders});
var uploader = new FileUploader('uploader', 'upload.php', {}, null, null, browser.refresh, browser.fileexists);
browser.changedircallback = uploader.updatedestination;
var highlightfiles = {$enc_files};
JAVASCRIPT;
return $javascript;
......
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