]> git.mjollnir.org Git - moodle.git/commitdiff
The resource types are now always displayed in a standard order
authormoodler <moodler>
Mon, 2 Aug 2004 19:11:15 +0000 (19:11 +0000)
committermoodler <moodler>
Mon, 2 Aug 2004 19:11:15 +0000 (19:11 +0000)
no matter what the language.

course/lib.php
help.php
mod/resource/lib.php

index ba418173cee26aee4d6f846e6991a3e4e8bb6c65..839761d24fa5fce6bbce5a296b4e83e603614c2b 100644 (file)
@@ -968,16 +968,19 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
 // Prints the menus to add activities and resources
 
     global $CFG;
-    static $straddactivity, $straddresource, $resources;
+    static $straddactivity, $stractivities, $straddresource, $resources;
 
     if (!isset($straddactivity)) {
         $straddactivity = get_string('addactivity');
         $straddresource = get_string('addresource');
-        $resourcetypes = get_list_of_plugins('mod/resource/type');
-        foreach ($resourcetypes as $resourcetype) {
-            $resources["resource&type=$resourcetype"] = get_string("resourcetype$resourcetype", 'resource');
+
+        /// Standard resource types
+        require_once("$CFG->dirroot/mod/resource/lib.php");
+        $resourceraw = resource_get_resource_types();
+
+        foreach ($resourceraw as $type => $name) {
+            $resources["resource&type=$type"] = $name;
         }
-        asort($resources);
         $resources['label'] = get_string('resourcetypelabel', 'resource');
     }
 
@@ -985,7 +988,7 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
 
     $output .= '<div align="right"><table align="right"><tr><td>';
     $output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$section&add=",
-                $resources, "ressection$section", "", $straddresource, '', '', true);
+                $resources, "ressection$section", "", $straddresource, 'resource/types', $straddresource, true);
     $output .= '</td>';
 
     if ($vertical) {
@@ -994,7 +997,7 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
 
     $output .= '<td>';
     $output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$section&add=",
-                $modnames, "section$section", "", $straddactivity, '', '', true);
+                $modnames, "section$section", "", $straddactivity, 'mods', $straddactivity, true);
     $output .= '</td></tr></table>';
     $output .= '</div>';
 
index fac83cd7229e536c3d25bec0e1e650fbca626871..49426df277c6f82eb0bbe7583ec89f640f5d284d 100644 (file)
--- a/help.php
+++ b/help.php
@@ -36,7 +36,7 @@
                 $helpfound = true;
                 include("$filepath");   // The actual helpfile
 
-                if ($module == "moodle" && ($file == "index.html" || $file == "mods.html")) {
+                if ($module == "moodle" and ($file == "index.html" or $file == "mods.html")) {
                     // include file for each module
 
                     if (!$modules = get_records("modules", "visible", 1)) {
                             $filepath = "$CFG->dirroot/lang/$lang/help/$mod->name/$file";
 
                             if (file_exists("$filepath")) {
+                                echo '<hr size="1" />';
+                                include("$filepath");   // The actual helpfile
+                                break;
+                            }
+                        }
+                    }
+                }
+
+                if ($module == "moodle" and ($file == "resource/types.html")) {  // RESOURCES
+                    require_once("$CFG->dirroot/mod/resource/lib.php");
+                    $typelist = resource_get_resource_types();
+                    $typelist['label'] = get_string('resourcetypelabel', 'resource');
+
+                    foreach ($typelist as $type => $name) {
+                        foreach ($langs as $lang) {
+                            if (empty($lang)) {
+                                continue;
+                            }
+                            $filepath = "$CFG->dirroot/lang/$lang/help/resource/type/$type.html";
+                            if (file_exists("$filepath")) {
+                                echo '<hr size="1" />';
                                 include("$filepath");   // The actual helpfile
                                 break;
                             }
index 72818924f24f0e6ec14f7f3d93308405a410cba0..2100411589214b4e98564949ef1cdf411443593f 100644 (file)
@@ -112,7 +112,7 @@ function setup(&$form) {
     }
     $nohtmleditorneeded = true;
 
-    print_heading_with_help(get_string("resourcetype$form->type", 'resource'), $form->type, 'resource');
+    print_heading_with_help(get_string("resourcetype$form->type", 'resource'), $form->type, 'resource/type');
 
     include("$CFG->dirroot/mod/resource/type/common.html");
 }
@@ -477,4 +477,25 @@ function resource_is_url($path) {
     return false;
 }
 
+function resource_get_resource_types() {
+/// Returns a menu of current resource types, in standard order
+    global $resource_standard_order;
+
+    $resources = array();
+
+    /// Standard resource types
+    $standardresources = array('text','html','file','directory','reference');
+    foreach ($standardresources as $resourcetype) {
+        $resources[$resourcetype] = get_string("resourcetype$resourcetype", 'resource');
+    }
+
+    /// Drop-in extra resource types
+    $resourcetypes = get_list_of_plugins('mod/resource/type');
+    foreach ($resourcetypes as $resourcetype) {
+        if (!in_array($resourcetype, $resources)) {
+            $resources[$resourcetype] = get_string("resourcetype$resourcetype", 'resource');
+        }
+    }
+    return $resources;
+}
 ?>