Commit 11503817 authored by Robert Lyon's avatar Robert Lyon Committed by Son Nguyen
Browse files

Allowing the pdf block file upload field to filter by pdf



Bug 1422480

Also added a filter to the image block to filter by image files

Change-Id: If5665396894f5f9114cca4b449d383efbfc5f94f
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 56cb08dd
......@@ -104,6 +104,7 @@ class PluginBlocktypeImage extends PluginBlocktype {
$element = ArtefactTypeFileBase::blockconfig_filebrowser_element($instance, $default);
$element['title'] = get_string('image');
$element['name'] = 'artefactid';
$element['accept'] = 'image/*';
$element['config']['selectone'] = true;
$element['filters'] = array(
'artefacttype' => array('image', 'profileicon'),
......
......@@ -98,6 +98,7 @@ class PluginBlocktypePdf extends PluginBlocktype {
$element = ArtefactTypeFileBase::blockconfig_filebrowser_element($instance, $default);
$element['title'] = get_string('file', 'artefact.file');
$element['name'] = 'artefactid';
$element['accept'] = 'application/pdf';
$element['config']['selectone'] = true;
$element['filters'] = array(
'artefacttype' => array('file'),
......
......@@ -152,6 +152,8 @@ function pieform_element_filebrowser(Pieform $form, $element) {
$fileliststr = json_encode($filedata);
$smarty->assign('prefix', $prefix);
$accepts = isset($element['accept']) ? 'accept="' . Pieform::hsc($element['accept']) . '"' : '';
$smarty->assign('accepts', $accepts);
$initjs = "{$prefix} = new FileBrowser('{$prefix}', {$folder}, {$configstr}, config);
{$prefix}.filedata = {$fileliststr};";
......
......@@ -54,7 +54,7 @@
{$licenseform|safe}
<div class="uploadform">
<label for="{$prefix}_userfile">{if $config.simpleupload}{str tag='uploadfile' section='artefact.file'}{else}{str tag='File' section='artefact.file'}{/if}</label>
<span id="{$prefix}_userfile_container"><input type="file" class="file" id="{$prefix}_userfile" name="userfile[]" multiple size="20" /></span>
<span id="{$prefix}_userfile_container"><input type="file" class="file" {$accepts|safe} id="{$prefix}_userfile" name="userfile[]" multiple size="20" /></span>
<span id="{$prefix}_userfile_maxuploadsize">({str tag=maxuploadsize section=artefact.file} {$maxuploadsize})</span>
{if $config.uploadagreement}<script>setNodeAttribute('{$prefix}_userfile', 'disabled', true);</script>{/if}
</div>
......
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