Commit 2607fcb6 authored by Nigel McNie's avatar Nigel McNie
Browse files

Implemented the new artefactchooser API methods for blocktypes.

parent afb7c30b
......@@ -103,19 +103,52 @@ class PluginBlocktypeFiledownload extends PluginBlocktype {
public static function instance_config_form($instance) {
$configdata = $instance->get('configdata');
return array(
'artefactids' => array(
'type' => 'artefactchooser',
'title' => get_string('Files', 'blocktype.file/filedownload'),
'defaultvalue' => (isset($configdata['artefactids'])) ? $configdata['artefactids'] : null,
'rules' => array(
'required' => true,
),
'limit' => 5,
'selectone' => false,
'artefacttypes' => array('file', 'image', 'profileicon'),
self::artefactchooser_element((isset($configdata['artefactids'])) ? $configdata['artefactids'] : null),
);
}
public static function artefactchooser_element($default=null) {
return array(
'name' => 'artefactids',
'type' => 'artefactchooser',
'title' => get_string('Files', 'blocktype.file/filedownload'),
'defaultvalue' => $default,
'rules' => array(
'required' => true,
),
'blocktype' => 'filedownload',
'limit' => 5,
'selectone' => false,
'artefacttypes' => array('file', 'image', 'profileicon'),
'template' => 'artefact:file:artefactchooser-element.tpl',
);
}
/**
* Optional method. If specified, allows the blocktype class to munge the
* artefactchooser element data before it's templated
*
* Note: same as the 'image' blocktype's version of this
*/
public static function artefactchooser_get_element_data($artefact) {
$artefact->icon = call_static_method(generate_artefact_class_name($artefact->artefacttype), 'get_icon', array('id' => $artefact->id));
if ($artefact->artefacttype == 'profileicon') {
$artefact->hovertitle = $artefact->note;
if ($artefact->title) {
$artefact->hovertitle .= ': ' . $artefact->title;
}
}
else {
$artefact->hovertitle = $artefact->title;
if ($artefact->description) {
$artefact->hovertitle .= ': ' . $artefact->description;
}
}
$artefact->title = str_shorten($artefact->title, 20);
$artefact->description = ($artefact->artefacttype == 'profileicon') ? $artefact->title : $artefact->description;
return $artefact;
}
}
?>
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