Skip to content

Commit

Permalink
A new resource type called Directory ... it simply lists all the
Browse files Browse the repository at this point in the history
files in a directory to make them available to students.
  • Loading branch information
moodler committed May 2, 2004
1 parent fb9ec10 commit 7ba54e1
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lang/en/resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$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.';
Expand All @@ -29,6 +30,7 @@
$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';
Expand Down Expand Up @@ -58,5 +60,6 @@
$string['resourcetype6'] = 'HTML text';
$string['resourcetype7'] = 'Program';
$string['resourcetype8'] = 'Wiki text';
$string['resourcetype9'] = 'Directory';

?>
28 changes: 28 additions & 0 deletions mod/resource/details.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,34 @@
<?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;
Expand Down
4 changes: 3 additions & 1 deletion mod/resource/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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"),
Expand All @@ -16,7 +17,8 @@
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);
Expand Down
54 changes: 53 additions & 1 deletion mod/resource/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<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",
Expand Down

0 comments on commit 7ba54e1

Please sign in to comment.