Commit 7b6c3498 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files
parents 68c05960 aa943f14
......@@ -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,50 +108,97 @@ $form = pieform(array(
)
));
// Strings used in the javascript
$getstring = quotestrings(array(
'mahara' => array(
'cancel',
),
'artefact.blog' => array(
'blogpost',
'nofilesattachedtothispost',
'remove',
)));
// 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',
[
'title',
'description',
function () { return TD(null); }
function (r) {
return TD(null, INPUT({'type':'button', 'value':{$getstring['remove']},
'onclick':"removefrompost('attached_old:"+r.id+"')"}));
}
]
);
attached.emptycontent = {$getstring['nofilesattachedtothispost']};
attached.paginate = false;
attached.blogpost = {$blogpost};
attached.statevars.push('blogpost');
attached.rowfunction = function (r) { return TR({'id':'attached_old_' + r.id}); };
attached.rowfunction = function (r) { return TR({'id':'attached_old:' + r.id}); };
attached.updateOnLoad();
// Show/hide the 'no attachments' message if there are no/some attachments
function checknoattachments() {
if (attached.tbody.hasChildNodes()) {
hideElement(attached.table.previousSibling);
showElement(attached.table);
}
else {
showElement(attached.table.previousSibling);
hideElement(attached.table);
}
}
// 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;
appendChildNodes(attached.tbody,
TR({'id':'attached_new:' + data.uploadnumber},
map(partial(TD,null),
[data.title, data.description,
INPUT({'type':'button', 'value':{$getstring['remove']},
'onclick':"removefrompost('attached_new:"+data.uploadnumber+"')"})])));
checknoattachments();
}
// This function checks if there's a file attached to the post with the given name
// Remove a row from the attached files list.
function removefrompost(rowid) {
removeElement(rowid);
checknoattachments();
}
// 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 +208,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 +229,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.
......
......@@ -35,6 +35,7 @@ $string['newblog'] = 'New Blog';
$string['attachedfiles'] = 'Attached files';
$string['nofilesattachedtothispost'] = 'No attached files';
$string['blogpost'] = 'post';
$string['remove'] = 'Remove';
$string['blogtitle'] = 'Title';
$string['blogtitledesc'] = 'e.g., ‘Jill’s Travel Blog’.';
......
......@@ -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>
......
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