# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # # This patch gives resource types the option of including a # "get_icon.php" script inside their resource type module folder which # can dynamically determine the correct icon type to be used (i.e. # instead of using the "icon.gif" in the folder). For example, in the # case of a "repository" resource, the returned resource will likely # not be adequately described by a single icon (in once case a ppt file # could be returned, in another a jpeg and so on). # # Above lines and this line are ignored by the patching process. Index: course/lib.php --- course/lib.php Base (1.538.2.77) +++ course/lib.php Locally Modified (Based On 1.538.2.77) @@ -1395,17 +1395,23 @@ } else { // Normal activity $instancename = format_string($modinfo->cms[$modnumber]->name, true, $course->id); - if (!empty($modinfo->cms[$modnumber]->icon)) { - $icon = "$CFG->pixpath/".$modinfo->cms[$modnumber]->icon; + $customicon = $modinfo->cms[$modnumber]->icon; + if (!empty($customicon)) { + if (substr($customicon, 0, 4) === 'mod/') { + //this allows a custom icon.gif file for modules + $icon = "$CFG->modpixpath/".substr($customicon, 4); } else { + $icon = "$CFG->pixpath/".$customicon; + } + } else { $icon = "$CFG->modpixpath/$mod->modname/icon.gif"; } //Accessibility: for files get description via icon. $altname = ''; if ('resource'==$mod->modname) { - if (!empty($modinfo->cms[$modnumber]->icon)) { - $possaltname = $modinfo->cms[$modnumber]->icon; + if (!empty($customicon)) { + $possaltname = $customicon; $mimetype = mimeinfo_from_icon('type', $possaltname); $altname = get_mimetype_description($mimetype); Index: mod/resource/lib.php --- mod/resource/lib.php Base (1.70.2.15) +++ mod/resource/lib.php Locally Modified (Based On 1.70.2.15) @@ -361,6 +361,7 @@ require_once($CFG->libdir.'/filelib.php'); + $resourcepath = $CFG->dirroot.'/mod/resource/type/'.$resource->type.'/'; if ($resource->type == 'file') { $icon = mimeinfo("icon", $resource->reference); if ($icon != 'unknown.gif') { @@ -370,6 +371,19 @@ } } else if ($resource->type == 'directory') { $info->icon ="f/folder.gif"; + } else if(file_exists($resourcepath.'get_icon.php')) { + //dynamic icon + //lets custom resource type determine best choice + //e.g. when reosource is "repository" type + //used "get_icon.php" instead of lib.php cuz lib.php could be HUGE + require_once($resourcepath.'get_icon.php'); + $get_icon = "mod_resource_".$resource->type."_get_icon"; + $info->icon = $get_icon($resource); + } else if(file_exists($resourcepath.'icon.gif')) { + //static icon + //lets dev place static "icon.gif" in the resource type folder + //assuming 1 icon type adequately describes this resource + $info->icon = 'mod/resource/type/'.$resource->type.'/icon.gif'; } }