Moodle

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

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.9
  • Fix Version/s: None
  • Component/s: Resource
  • Labels:
    None
  • Environment:
    Linux Debian last release, Mysql5, php5
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_19_STABLE

Description

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

Issue Links

Activity

Hide
Christian Deligant added a comment -

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!

Show
Christian Deligant added a comment - 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!
Hide
Petr Škoda (skodak) added a comment -

mod/resource was split into separate modules in 2.0, no changes except security fixes are planned for 1.9, sorry.
Thank you for the report.

Petr Skoda

Show
Petr Škoda (skodak) added a comment - mod/resource was split into separate modules in 2.0, no changes except security fixes are planned for 1.9, sorry. Thank you for the report. Petr Skoda

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: