Commit 4732373f authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use filebrowser element to select folders in folder blocktype


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent ebf29cfa
......@@ -80,8 +80,10 @@ class PluginBlocktypeFolder extends PluginBlocktype {
public static function instance_config_form($instance, $istemplate) {
$configdata = $instance->get('configdata');
safe_require('artefact', 'file');
$instance->set('artefactplugin', 'file');
return array(
self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null),
'artefactid' => self::filebrowser_element($instance, (isset($configdata['artefactid'])) ? array($configdata['artefactid']) : null),
);
}
......@@ -118,6 +120,18 @@ class PluginBlocktypeFolder extends PluginBlocktype {
return 'parent, title';
}
public static function filebrowser_element(&$instance, $default=array()) {
$element = ArtefactTypeFileBase::blockconfig_filebrowser_element($instance, $default);
$element['title'] = get_string('file', 'artefact.file');
$element['name'] = 'artefactid';
$element['config']['selectone'] = true;
$element['config']['selectfolders'] = true;
$element['filters'] = array(
'artefacttype' => array('folder'),
);
return $element;
}
public static function default_copy_type() {
return 'full';
}
......
......@@ -216,6 +216,7 @@ function pieform_element_filebrowser_build_filelist($form, $element, $folder, $h
$userid = ($group || $institution) ? null : $USER->get('id');
$editable = (int) $element['config']['edit'];
$selectable = (int) $element['config']['select'];
$selectfolders = (int) $element['config']['selectfolders'];
$publishing = (int) !empty($element['config']['publishing']);
$querybase = $element['page'] . (strpos($element['page'], '?') === false ? '?' : '&');
$prefix = $form->get_name() . '_' . $element['name'];
......@@ -227,6 +228,7 @@ function pieform_element_filebrowser_build_filelist($form, $element, $folder, $h
$smarty->assign('highlight', $highlight);
$smarty->assign('editable', $editable);
$smarty->assign('selectable', $selectable);
$smarty->assign('selectfolders', $selectfolders);
$smarty->assign('publishing', $publishing);
$smarty->assign('filelist', $filedata);
$smarty->assign('querybase', $querybase);
......
......@@ -92,7 +92,7 @@
</div>
<div id="{$prefix}_filelist_container">
{include file="artefact:file:form/filelist.tpl" prefix=$prefix filelist=$filelist editable=$config.edit selectable=$config.select highlight=$highlight edit=$edit querybase=$querybase groupinfo=$groupinfo owner=$tabs.owner ownerid=$tabs.ownerid}
{include file="artefact:file:form/filelist.tpl" prefix=$prefix filelist=$filelist editable=$config.edit selectable=$config.select highlight=$highlight edit=$edit querybase=$querybase groupinfo=$groupinfo owner=$tabs.owner ownerid=$tabs.ownerid selectfolders=$config.selectfolders}
</div>
{* Edit form used when js is available *}
......
......@@ -44,7 +44,7 @@
{if !isset($file->can_edit) || $file->can_edit !== 0}<input type="submit" class="submit btn-edit s" name="{$prefix}_edit[{$file->id}]" value="{str tag=edit}" />
<input type="submit" class="submit btn-del s" name="{$prefix}_delete[{$file->id}]" value="{str tag=delete}" />{/if}
{/if}
{if $selectable && $file->artefacttype != 'folder' && $publishable}
{if $selectable && ($file->artefacttype != 'folder' || $selectfolders) && $publishable && !$file->isparent}
<input type="submit" class="select small" name="{$prefix}_select[{$file->id}]" id="{$prefix}_select_{$file->id}" value="{str tag=select}" />
{/if}
</td>
......
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