Commit 450f708e authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Browse my files list in new blog posts

parent 625d16e9
......@@ -114,32 +114,48 @@ $form = pieform(array(
$getstring = quotestrings(array(
'mahara' => array(
'cancel',
),
'artefact.blog' => array(
'attach',
'blogpost',
'browsemyfiles',
'nofilesattachedtothispost',
'remove',
)));
// Insert this automatically sometime.
$copyright = get_field('site_content', 'content', 'name', 'uploadcopyright');
$wwwroot = get_config('wwwroot');
$javascript = <<< EOF
// The file uploader uploads files to the list of blog post attachments
var copyrightnotice = '{$copyright}';
var uploader = new FileUploader('uploader', 'upload.php', {$getstring['blogpost']}, false,
attachtopost, fileexists);
uploader.createid = {$createid};
// List of attachments to the blog post
// File browser instance allows users to attach files from the my files area
var browser = null;
var browsebutton = INPUT({'id':'browsebutton', 'type':'button', 'value':{$getstring['browsemyfiles']},
'onclick':browsemyfiles});
function browsemyfiles() {
hideElement('browsebutton');
browser = new FileBrowser('filebrowser', '{$wwwroot}artefact/file/myfiles.json.php',
function () {}, {$getstring['attach']}, attachtopost);
browser.init();
}
addLoadEvent(function () {insertSiblingNodesBefore('filebrowser', browsebutton);});
// List of attachments to the blog post
var attached = new TableRenderer(
'attachedfiles',
'attachedfiles.json.php',
......@@ -202,7 +218,7 @@ function fileexists(name) {
EOF;
$smarty = smarty(array('tablerenderer', 'artefact/file/js/uploader.js'));
$smarty = smarty(array('tablerenderer', 'artefact/file/js/uploader.js', 'artefact/file/js/filebrowser.js'));
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign_by_ref('textinputform', $form);
$smarty->assign('pagetitle', $pagetitle);
......
......@@ -32,9 +32,11 @@ $string['description'] = 'description';
$string['addblog'] = 'Add Blog';
$string['newblog'] = 'New Blog';
$string['attach'] = 'Attach';
$string['attachedfiles'] = 'Attached files';
$string['nofilesattachedtothispost'] = 'No attached files';
$string['blogpost'] = 'post';
$string['browsemyfiles'] = 'Browse my files';
$string['remove'] = 'Remove';
$string['blogtitle'] = 'Title';
......
......@@ -18,6 +18,7 @@
<h2>{str section="artefact.blog" tag=$pagetitle}</h2>
{$textinputform}
<div id='uploader'></div>
<table id='filebrowser'><tbody><tr><td></td></tr></tbody></table>
<h3>{str section=artefact.blog tag=attachedfiles}</h3>
<table id='attachedfiles'><tbody><tr><td></td></tr></tbody></table>
</div>
......
......@@ -14,9 +14,12 @@ function FileBrowser(element, source, changedircallback, actionname, actioncallb
if (this.actionname) {
this.lastcolumnfunc = function(r) {
var button = INPUT({'type':'button', 'value':get_string(self.actionname)});
button.onclick = function () { self.actioncallback(r) };
return TD(null, button);
if (r.artefacttype != 'folder') {
var button = INPUT({'type':'button', 'value':self.actionname});
button.onclick = function () { self.actioncallback(r) };
return TD(null, button);
}
return TD(null);
}
}
else {
......@@ -52,8 +55,6 @@ function FileBrowser(element, source, changedircallback, actionname, actioncallb
// Folder navigation links
insertSiblingNodesBefore(self.element, DIV({'id':'foldernav'}));
//self.lastcolumnfunc = self.actionname ? self.getfileinfo : self.editdelete;
self.filelist = new TableRenderer(
self.element,
self.source,
......@@ -78,7 +79,6 @@ function FileBrowser(element, source, changedircallback, actionname, actioncallb
this.refresh = function () { self.changedir(self.cwd); };
this.savemetadata = function (fileid, formid, replacefile, originalname) {
var name = $(formid).name.value;
if (isEmpty(name)) {
......
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