]> git.mjollnir.org Git - moodle.git/commitdiff
A new resource type called Directory ... it simply lists all the
authormoodler <moodler>
Sun, 2 May 2004 15:10:04 +0000 (15:10 +0000)
committermoodler <moodler>
Sun, 2 May 2004 15:10:04 +0000 (15:10 +0000)
files in a directory to make them available to students.

lang/en/resource.php
mod/resource/details.php
mod/resource/lib.php
mod/resource/view.php

index c2786a448cfad63f4f0886f09c5d952b9dad76c4..6aca30f58126ccfabae6540006d5bc48bcacd889 100644 (file)
@@ -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';
 
 ?>
index c285376d240daab8ca0bd8335416209a9f8b6e81..618f4b9de9ac1868138667d266752731f49f92cf 100644 (file)
                 <?php
                 break;
 
+            case DIRECTORY:
+                $rawdirs = get_directory_list("$CFG->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");
+                ?>
+                <tr valign="top">
+                    <td align="right" nowrap>
+                        <p><b><?php echo $strtypename?>:</b></p>
+                    </td>
+                    <td>
+                        <?php choose_from_menu($dirs, "reference", $form->reference, $strmaindirectory, '', '') ?>
+                    </td>
+                </tr>
+                <tr valign="top">
+                    <td align="right" nowrap>&nbsp;
+                    </td>
+                    <td>
+                        <p><?php echo "$strdirectoryinfo" ?></p>
+                    </td>
+                </tr>
+
+                <?php
+                break;
+
             default:
                 error(get_string("notypechosen", "resource"), $_SERVER["HTTP_REFERER"]);
                 break;
index d2db6a4bcda1bb098fea1aed5b9a055cc3c74f89..d151b3191f90526cd34eb8f87f9f0d96f588bbd5 100644 (file)
@@ -8,6 +8,7 @@ define("WEBLINK",     "5");
 define("HTML",        "6");
 define("PROGRAM",     "7");
 define("WIKITEXT",    "8");
+define("DIRECTORY",   "9");
 
 $RESOURCE_TYPE = array (REFERENCE    => 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);
index a8bbb3f9eb3b390f9c97e988de20f9729e642127..6290cc425d996331fdd98aea9db8d18f9ef69cab 100644 (file)
 
             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 '<table cellpadding="4">';
+            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 '<tr>';
+                echo '<td>';
+                echo "<img src=\"$CFG->pixpath/f/$icon\" width=\"16\" height=\"16\">";
+                echo '</td>';
+                echo '<td nowrap="nowrap"><p>';
+                link_to_popup_window($relativeurl, "resourceedirectory$resource->id", "$file", 450, 600, '');
+                echo '</p></td>';
+                echo '<td>&nbsp;</td>';
+                echo '<td align="right" nowrap="nowrap"><p><font size="-1">';
+                echo userdate(filectime("$CFG->dataroot/$course->id/$resource->reference/$file"), $strftime);
+                echo '</font></p></td>';
+                echo '</tr>';
+            }
+            echo '</table>';
+
+            print_simple_box_end();
+
+            print_footer($course);
+            break;
 
         default:
             print_header($pagetitle, "$course->fullname", "$navigation $resource->name",