Commit 9eafd5e4 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add multiple files area browser to image,internalmedia block types

parent 6970f052
......@@ -91,8 +91,7 @@ class PluginBlocktypeImage extends PluginBlocktype {
safe_require('artefact', 'file');
$instance->set('artefactplugin', 'file');
return array(
// self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null, $istemplate),
'filebrowser' => self::filebrowser_element($instance, (isset($configdata['artefactid'])) ? $configdata['artefactid'] : null, $istemplate),
'filebrowser' => self::filebrowser_element($instance, (isset($configdata['artefactid'])) ? array($configdata['artefactid']) : null, $istemplate),
'showdescription' => array(
'type' => 'checkbox',
'title' => get_string('showdescription', 'blocktype.file/image'),
......@@ -120,38 +119,13 @@ class PluginBlocktypeImage extends PluginBlocktype {
return $values;
}
public static function filebrowser_element(&$instance, $default=null, $istemplate=false) {
$element = array(
'name' => 'filebrowser',
'type' => 'filebrowser',
'title' => get_string('image'),
'folder' => param_integer('folder', 0),
'highlight' => null,
'browse' => true,
'page' => View::make_base_url(),
'config' => array(
'upload' => true,
'uploadagreement' => get_config_plugin('artefact', 'file', 'uploadagreement'),
'createfolder' => false,
'edit' => false,
'select' => true,
'selectone' => true,
'alwaysopen' => true,
),
'filters' => array(
'artefacttype' => array('image'),
),
'selectlistcallback' => array(
'name' => 'artefact_get_records_by_id',
'args' => array(empty($default) ? array() : array($default)),
),
public static function filebrowser_element(&$instance, $default=array(), $istemplate=false) {
$element = ArtefactTypeFileBase::blockconfig_filebrowser_element($instance, $default, $istemplate);
$element['title'] = get_string('image');
$element['config']['selectone'] = true;
$element['filters'] = array(
'artefacttype' => array('image'),
);
if (!$istemplate) {
// You don't have to choose a file if this view is a template
$element['rules'] = array(
'required' => true,
);
}
return $element;
}
......
......@@ -84,7 +84,7 @@ class PluginBlocktypeInternalmedia extends PluginBlocktype {
safe_require('artefact', 'file');
$instance->set('artefactplugin', 'file');
return array(
'filebrowser' => self::filebrowser_element($instance, (isset($configdata['artefactid'])) ? $configdata['artefactid'] : null, $istemplate),
'filebrowser' => self::filebrowser_element($instance, (isset($configdata['artefactid'])) ? array($configdata['artefactid']) : null, $istemplate),
'width' => array(
'type' => 'text',
'title' => get_string('width'),
......@@ -116,39 +116,14 @@ class PluginBlocktypeInternalmedia extends PluginBlocktype {
return false;
}
public static function filebrowser_element(&$instance, $default=null, $istemplate=false) {
$element = array(
'name' => 'filebrowser',
'type' => 'filebrowser',
'title' => get_string('media', 'blocktype.file/internalmedia'),
'folder' => param_integer('folder', 0),
'highlight' => null,
'browse' => true,
'page' => View::make_base_url(),
'config' => array(
'upload' => true,
'uploadagreement' => get_config_plugin('artefact', 'file', 'uploadagreement'),
'createfolder' => false,
'edit' => false,
'select' => true,
'selectone' => true,
'alwaysopen' => true,
),
'filters' => array(
'artefacttype' => array('file'),
'filetype' => self::get_allowed_mimetypes(),
),
'selectlistcallback' => array(
'name' => 'artefact_get_records_by_id',
'args' => array(empty($default) ? array() : array($default)),
),
public static function filebrowser_element(&$instance, $default=array(), $istemplate=false) {
$element = ArtefactTypeFileBase::blockconfig_filebrowser_element($instance, $default, $istemplate);
$element['title'] = get_string('media', 'blocktype.file/internalmedia');
$element['config']['selectone'] = true;
$element['filters'] = array(
'artefacttype' => array('file'),
'filetype' => self::get_allowed_mimetypes(),
);
if (!$istemplate) {
// You don't have to choose a file if this view is a template
$element['rules'] = array(
'required' => true,
);
}
return $element;
}
......
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