From 7ba54e1b781ab3c64b72f05652cd32e9f7d717bb Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 2 May 2004 15:10:04 +0000 Subject: [PATCH] A new resource type called Directory ... it simply lists all the files in a directory to make them available to students. --- lang/en/resource.php | 3 +++ mod/resource/details.php | 28 +++++++++++++++++++++ mod/resource/lib.php | 4 ++- mod/resource/view.php | 54 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 87 insertions(+), 2 deletions(-) diff --git a/lang/en/resource.php b/lang/en/resource.php index c2786a448c..6aca30f581 100644 --- a/lang/en/resource.php +++ b/lang/en/resource.php @@ -19,6 +19,7 @@ $string['configpopuptoolbar'] = 'Should popup windows show the tool bar by defau $string['configpopupwidth'] = 'What width should be the default width for new popup windows?'; $string['configwebsearch'] = 'When adding a URL as a webpage or weblink, this location is offered as a site to help the user search for the URL they want.'; $string['directlink'] = 'Direct link to this file'; +$string['directoryinfo'] = 'All the files in the chosen directory will be displayed.'; $string['editingaresource'] = 'Editing a resource'; $string['example'] = 'Example'; $string['examplereference'] = 'Tobin, K. & Tippins, D (1993) Constructivism as a Referent for Teaching and Learning. In: K. Tobin (Ed) The Practice of Constructivism in Science Education, pp 3-21, Lawrence-Erlbaum, Hillsdale, NJ.'; @@ -29,6 +30,7 @@ $string['fetchservererror'] = 'An error was found with the remote server while t $string['filename'] = 'File name'; $string['fulltext'] = 'Full text'; $string['htmlfragment'] = 'HTML fragment'; +$string['maindirectory'] = 'Main files directory'; $string['modulename'] = 'Resource'; $string['modulenameplural'] = 'Resources'; $string['neverseen'] = 'Never seen'; @@ -58,5 +60,6 @@ $string['resourcetype5'] = 'Web Link'; $string['resourcetype6'] = 'HTML text'; $string['resourcetype7'] = 'Program'; $string['resourcetype8'] = 'Wiki text'; +$string['resourcetype9'] = 'Directory'; ?> diff --git a/mod/resource/details.php b/mod/resource/details.php index c285376d24..618f4b9de9 100644 --- a/mod/resource/details.php +++ b/mod/resource/details.php @@ -396,6 +396,34 @@ dataroot/$course->id", 'moddata', true, true); + $dirs = array(); + foreach ($rawdirs as $rawdir) { + $dirs[$rawdir] = $rawdir; + } + $strdirectoryinfo = get_string("directoryinfo", "resource"); + $strmaindirectory = get_string("maindirectory", "resource"); + ?> + + +

:

+ + + reference, $strmaindirectory, '', '') ?> + + + +   + + +

+ + + + get_string("resourcetype1", "resource"), WEBPAGE => get_string("resourcetype2", "resource"), @@ -16,7 +17,8 @@ $RESOURCE_TYPE = array (REFERENCE => get_string("resourcetype1", "resource"), WEBLINK => get_string("resourcetype5", "resource"), HTML => get_string("resourcetype6", "resource"), PROGRAM => get_string("resourcetype7", "resource"), - WIKITEXT => get_string("resourcetype8", "resource") ); + WIKITEXT => get_string("resourcetype8", "resource"), + DIRECTORY => get_string("resourcetype9", "resource") ); if (!isset($CFG->resource_framesize)) { set_config("resource_framesize", 130); diff --git a/mod/resource/view.php b/mod/resource/view.php index a8bbb3f9eb..6290cc425d 100644 --- a/mod/resource/view.php +++ b/mod/resource/view.php @@ -410,7 +410,59 @@ print_footer($course); break; - + + case DIRECTORY: + require_once("../../files/mimetypes.php"); + + add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", $resource->id, $cm->id); + print_header($pagetitle, "$course->fullname", "$navigation $resource->name", + "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm)); + + if (trim($resource->summary)) { + print_simple_box(text_to_html($resource->summary), "center"); + print_spacer(10,10); + } + + print_simple_box_start("center", "", "$THEME->cellcontent", "20" ); + + if ($resource->reference) { + $relativepath = "$course->id/$resource->reference"; + } else { + $relativepath = "$course->id"; + } + + $files = get_directory_list("$CFG->dataroot/$relativepath", 'moddata', false); + $strftime = get_string('strftimedatetime'); + + echo ''; + foreach ($files as $file) { + $icon = mimeinfo("icon", $file); + + if ($CFG->slasharguments) { + $relativeurl = "/file.php/$course->id/$resource->reference/$file"; + } else { + $relativeurl = "/file.php?file=/$course->id/$resource->reference/$file"; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
'; + echo "pixpath/f/$icon\" width=\"16\" height=\"16\">"; + echo '

'; + link_to_popup_window($relativeurl, "resourceedirectory$resource->id", "$file", 450, 600, ''); + echo '

 

'; + echo userdate(filectime("$CFG->dataroot/$course->id/$resource->reference/$file"), $strftime); + echo '

'; + + print_simple_box_end(); + + print_footer($course); + break; default: print_header($pagetitle, "$course->fullname", "$navigation $resource->name", -- 2.39.5