Commit 51c77585 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add newly uploaded files to the list of attachments

parent 4b49af72
......@@ -61,6 +61,7 @@ else {
$pagetitle = 'editblogpost';
}
// This form just has the main text inputs and no submit button. The
// submit and cancel buttons are in their own form at the bottom of
// the page.
......@@ -107,6 +108,10 @@ $form = pieform(array(
)
));
// Strings used in the javascript
$getstring = quotestrings(array(
'mahara' => array(
),
......@@ -118,13 +123,21 @@ $getstring = quotestrings(array(
// Insert this automatically sometime.
$copyright = get_field('site_content', 'content', 'name', 'uploadcopyright');
$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
var attached = new TableRenderer(
'attachedfiles',
'attachedfiles.json.php',
......@@ -139,18 +152,29 @@ attached.paginate = false;
attached.blogpost = {$blogpost};
attached.statevars.push('blogpost');
attached.rowfunction = function (r) { return TR({'id':'attached_old_' + r.id}); };
attached.updateOnLoad();
// This function adds a newly uploaded file to the attached files list.
// Add a newly uploaded file to the attached files list.
function attachtopost(data) {
return true;
alert(data.title);
alert(attached.tbody);
appendChildNodes(attached.tbody,
TR({'id':'attached_new:' + data.uploadnumber},
map(partial(TD,null), [data.title, data.description])));
hideElement(attached.table.previousSibling);
showElement(attached.table);
}
// This function checks if there's a file attached to the post with the given name
// Check if there's already a file attached to the post with the given name
function fileexists(name) {
return false;
}
attached.updateOnLoad();
EOF;
......@@ -160,6 +184,8 @@ $smarty->assign_by_ref('textinputform', $form);
$smarty->assign('pagetitle', $pagetitle);
$smarty->display('artefact:blog:editpost.tpl');
/**
* This function gets called to create a new blog post, and publish it
* simultaneously.
......@@ -179,6 +205,8 @@ function editpost_submit(array $values) {
redirect(get_config('wwwroot') . 'artefact/blog/list/');
}
/**
* This function get called to cancel the form submission. It returns to the
* blog list.
......
......@@ -17,8 +17,8 @@
<div class="maincontent">
<h2>{str section="artefact.blog" tag=$pagetitle}</h2>
{$textinputform}
<h3>{str section=artefact.blog tag=attachedfiles}</h3>
<div id='uploader'></div>
<h3>{str section=artefact.blog tag=attachedfiles}</h3>
<table id='attachedfiles'><tbody><tr><td></td></tr></tbody></table>
</div>
</span></span></span></span>
......
Supports Markdown
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