Issue Details (XML | Word | Printable)

Key: MDL-16926
Type: Bug Bug
Status: Open Open
Priority: Minor Minor
Assignee: Petr Škoda (skodak)
Reporter: Christian Deligant
Votes: 0
Watchers: 1
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Adding/creating a new resource type needs to name it in the global resource.php language file

Created: 18/Oct/08 06:26 PM   Updated: 20/Oct/08 02:34 PM
Component/s: Resource
Affects Version/s: 1.9
Fix Version/s: None

Environment: Linux Debian last release, Mysql5, php5
Issue Links:
Relates
 

Database: MySQL
Participants: Christian Deligant and Petr Škoda (skodak)
Security Level: None
Affected Branches: MOODLE_19_STABLE


 Description  « Hide
If you create/add a new resource type, you have to edit the global resource.php language file to assign a name, hence breaking the modularity of moodle.
I tried to create a lang folder structure (as for the activity modules) in the ROOT/mod/resource/type/newtypefolder but it didn't work...
I can't obviously put a lang folder structure directly in the mod/resource folder, as it will anyway break the modularity, even if in a lesser way.

I suggest this fix in the resource/lib.php file:
function resource_get_types() {
global $CFG;

$types = array();

$standardresources = array('text','html','file','directory');
foreach ($standardresources as $resourcetype) { $type = new object(); $type->modclass = MOD_CLASS_RESOURCE; $type->name = $resourcetype; $type->type = "resource&type=$resourcetype"; $type->typestr = get_string("resourcetype$resourcetype", 'resource'); $types[] = $type; }

/// Drop-in extra resource types
$resourcetypes = get_list_of_plugins('mod/resource/type');
foreach ($resourcetypes as $resourcetype) {
if (!empty($CFG->{'resource_hide_'.$resourcetype})) { // Not wanted continue; }
if (!in_array($resourcetype, $standardresources)) { $type = new object(); $type->modclass = MOD_CLASS_RESOURCE; $type->name = $resourcetype; $type->type = "resource&type=$resourcetype"; // this is the modified line to include extrapath directly in the new resource // NOTICE: the language file must be called "resource.php", thus breaking the habitual way of naming the language file by the name of the module $type->typestr = get_string("resourcetype$resourcetype", 'resource', NULL, "$CFG->dirroot/mod/resource/type/$resourcetype/lang/"); $types[] = $type; }
}

return $types;
}

a workaround for the NOTICE above could be changing the affected line with this block of code
===
$type->typestr = get_string("resourcetype$resourcetype", 'resource');
if ($type->typestr=="[[resourcetype$resourcetype]]") { $type->typestr = get_string("resourcetype$resourcetype", $resourcetype, NULL, "$CFG->dirroot/mod/resource/type/$resourcetype/lang/"); }
===

Hope this helps



 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Christian Deligant added a comment - 20/Oct/08 02:34 PM
Same kind of problem of "breaking" the modularity: the description/definition/localization of new "pieces" of moodle is hardcoded in the top level language files: if you edit them, you automatically break things when updating/upgrading moodle!