Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
2607fcb6
Commit
2607fcb6
authored
Oct 28, 2007
by
Nigel McNie
Browse files
Implemented the new artefactchooser API methods for blocktypes.
parent
afb7c30b
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/file/blocktype/filedownload/lib.php
View file @
2607fcb6
...
...
@@ -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
;
}
}
?>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment