Skip to content

Commit

Permalink
MDL-20065 new implementation of File module, modules sub-types are be…
Browse files Browse the repository at this point in the history
…ing migrated to separate modules; remaining issues to be listed as sub-tasks in tracker
  • Loading branch information
skodak committed Aug 13, 2009
1 parent 3b804d2 commit aa54ed7
Show file tree
Hide file tree
Showing 58 changed files with 2,614 additions and 6,709 deletions.
23 changes: 20 additions & 3 deletions blocks/activity_modules/block_activity_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,34 @@ function get_content() {
$modinfo = get_fast_modinfo($course);
$modfullnames = array();

$archetypes = array();

foreach($modinfo->cms as $cm) {
if (!$cm->uservisible) {
if (!$cm->uservisible or $cm->modname === 'label') {
continue;
}
if (array_key_exists($cm->modname, $modfullnames)) {
continue;
}
$modfullnames[$cm->modname] = $cm->modplural;
if (!array_key_exists($cm->modname, $archetypes)) {
$archetypes[$cm->modname] = plugin_supports('mod', $cm->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
}
if ($archetypes[$cm->modname] == MOD_ARCHETYPE_RESOURCE) {
if (!array_key_exists('resources', $modfullnames)) {
$modfullnames['resources'] = get_string('resources');
}
} else {
$modfullnames[$cm->modname] = $cm->modplural;
}
}

asort($modfullnames, SORT_LOCALE_STRING);

foreach ($modfullnames as $modname => $modfullname) {
if ($modname != 'label') {
if ($modname === 'resources') {
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/resources.php?id='.$course->id.'">'.$modfullname.'</a>';
$this->content->icons[] = '<img src="'.$OUTPUT->old_icon_url('f/html') . '" class="icon" alt="" />';
} else {
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$course->id.'">'.$modfullname.'</a>';
$this->content->icons[] = '<img src="'.$OUTPUT->mod_icon_url('icon', $modname) . '" class="icon" alt="" />';
}
Expand Down
29 changes: 15 additions & 14 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1343,25 +1343,23 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
$icon = $OUTPUT->old_icon_url(str_replace(array('.gif', '.png'), '', $customicon));
}
} else {
$icon = "" . $OUTPUT->mod_icon_url('icon', $mod->modname) . "";
$icon = $OUTPUT->mod_icon_url('icon', $mod->modname);
}

//Accessibility: for files get description via icon.
//Accessibility: for files get description via icon, this is very ugly hack!
$altname = '';
if ('resource'==$mod->modname) {
if (!empty($customicon)) {
$possaltname = $customicon;
$altname = $mod->modfullname;
if (!empty($customicon)) {
$archetype = plugin_supports('mod', $mod->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
if ($archetype == MOD_ARCHETYPE_RESOURCE) {
$possaltname = str_replace(array('.gif', '.png'), '', $customicon).'.gif';

$mimetype = mimeinfo_from_icon('type', $possaltname);
$altname = get_mimetype_description($mimetype);
} else {
$altname = $mod->modfullname;
}
} else {
$altname = $mod->modfullname;
}
// Avoid unnecessary duplication.
if (false!==stripos($instancename, $altname)) {
if (false !== stripos($instancename, $altname)) {
$altname = '';
}
// File type after name, for alphabetic lists (screen reader).
Expand Down Expand Up @@ -1587,8 +1585,13 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
}
}
} else {
// all mods without type are considered activity
$activities[$modname] = $modnamestr;
$archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
if ($archetype == MOD_ARCHETYPE_RESOURCE) {
$resources[$modname] = $modnamestr;
} else {
// all other archetypes are considered activity
$activities[$modname] = $modnamestr;
}
}
}
}
Expand Down Expand Up @@ -3535,5 +3538,3 @@ function get_course_by_idnumber ($idnumber) {
global $DB;
return $DB->get_record('course', array('idnumber' => $idnumber));
}

?>
Loading

0 comments on commit aa54ed7

Please sign in to comment.