mod/resource: MDL-18691 allow custom resource types to specify their name in their own lang directory

Before this change, the full name of the resource type had to be stored in the "resource" namespace (for example in /mod/resource/lang/en_utf8/resource.php).

Now it can be put in the "resource_foo" namespace:

e.g. in /mod/resource/type/foo/lang/en_utf8/resource_foo.php:

<?php
  $string['resourcetypefoo'] = 'Link to a Foo Bar document';
?>
This commit is contained in:
fmarier
2009-03-27 03:21:10 +00:00
parent 66c7d3731f
commit 13ca1e06b8
2 changed files with 17 additions and 2 deletions
+16 -1
View File
@@ -526,7 +526,7 @@ function resource_get_types() {
$type->modclass = MOD_CLASS_RESOURCE;
$type->name = $resourcetype;
$type->type = "resource&amp;type=$resourcetype";
$type->typestr = get_string("resourcetype$resourcetype", 'resource');
$type->typestr = resource_get_name($resourcetype);
$types[] = $type;
}
}
@@ -763,4 +763,19 @@ function resource_supports($feature) {
}
}
/**
* Returns the full name of the given resource type. The name can
* either be set at the resource type level or at the resource module
* level.
*
* @param string $type shortname (or directory name) of the resource type
*/
function resource_get_name($type) {
$name = get_string("resourcetype$type", "resource_$type");
if (substr($name, 0, 2) === '[[') {
$name = get_string("resourcetype$type", 'resource');
}
return $name;
}
?>
+1 -1
View File
@@ -44,7 +44,7 @@ class mod_resource_mod_form extends moodleform_mod {
// summary should be optional again MDL-9485
//$mform->addRule('summary', get_string('required'), 'required', null, 'client');
$mform->addElement('header', 'typedesc', get_string('resourcetype'.$type,'resource'));
$mform->addElement('header', 'typedesc', resource_get_name($type));
$this->_resinstance->setup_elements($mform);
$this->standard_coursemodule_elements(array('groups'=>false, 'groupmembersonly'=>true, 'gradecat'=>false));