Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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';
?>
  • Loading branch information...
commit 19a9e4f2fa500de4b138ab21afaa15449232c9d1 1 parent abe1688
fmarier authored
Showing with 17 additions and 2 deletions.
  1. +16 −1 mod/resource/lib.php
  2. +1 −1  mod/resource/mod_form.php
View
17 mod/resource/lib.php
@@ -550,7 +550,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;
}
}
@@ -682,4 +682,19 @@ function resource_get_extra_capabilities() {
return array('moodle/site:accessallgroups');
}
+/**
+ * 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;
+}
+
?>
View
2  mod/resource/mod_form.php
@@ -44,7 +44,7 @@ function definition() {
// 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));
Please sign in to comment.
Something went wrong with that request. Please try again.