2002-10-17 14:03:59 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
2002-10-17 14:03:59 +00:00
|
|
|
|
|
|
|
require_variable($id); // Course Module ID
|
2003-04-29 13:31:47 +00:00
|
|
|
optional_variable($frameset, "");
|
2002-10-17 14:03:59 +00:00
|
|
|
|
|
|
|
if (! $cm = get_record("course_modules", "id", $id)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $cm->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $resource = get_record("resource", "id", $cm->instance)) {
|
|
|
|
error("Resource ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
$strresource = get_string("modulename", "resource");
|
|
|
|
$strresources = get_string("modulenameplural", "resource");
|
|
|
|
$strlastmodified = get_string("lastmodified");
|
|
|
|
|
|
|
|
if ($course->category) {
|
|
|
|
require_login($course->id);
|
2003-03-12 07:36:22 +00:00
|
|
|
$navigation = "<A TARGET=\"{$CFG->framename}\" HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->
|
|
|
|
<A TARGET=\"{$CFG->framename}\" HREF=\"index.php?id=$course->id\">$strresources</A> ->";
|
2002-10-17 14:03:59 +00:00
|
|
|
} else {
|
2003-03-12 07:36:22 +00:00
|
|
|
$navigation = "<A TARGET=\"{$CFG->framename}\" HREF=\"index.php?id=$course->id\">$strresources</A> ->";
|
2002-10-17 14:03:59 +00:00
|
|
|
}
|
|
|
|
|
2003-05-15 18:03:22 +00:00
|
|
|
if (!$cm->visible and !isteacher($course->id)) {
|
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
|
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
|
|
|
notice(get_string("activityiscurrentlyhidden"));
|
|
|
|
}
|
2002-11-10 14:03:25 +00:00
|
|
|
|
2002-10-17 14:03:59 +00:00
|
|
|
switch ($resource->type) {
|
2002-11-10 14:03:25 +00:00
|
|
|
case REFERENCE:
|
2002-10-17 14:03:59 +00:00
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
|
|
|
|
print_simple_box($resource->reference, "center");
|
|
|
|
echo "<CENTER><P>";
|
|
|
|
echo text_to_html($resource->summary);
|
|
|
|
echo "</P>";
|
|
|
|
echo "<P> </P>";
|
|
|
|
echo "<P><FONT SIZE=1>$strlastmodified: ".userdate($resource->timemodified)."</P>";
|
|
|
|
echo "</CENTER>";
|
|
|
|
print_footer($course);
|
|
|
|
break;
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
case WEBLINK:
|
2002-10-17 14:03:59 +00:00
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
redirect($resource->reference);
|
|
|
|
break;
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
case WEBPAGE:
|
2003-04-29 13:31:47 +00:00
|
|
|
if ($frameset == "top") {
|
2002-10-17 14:03:59 +00:00
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname",
|
2003-03-12 07:36:22 +00:00
|
|
|
"$navigation <A TARGET=\"{$CFG->framename}\" HREF=\"$resource->reference\" TITLE=\"$resource->reference\">$resource->name</A>",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
echo "<CENTER><FONT SIZE=-1>".text_to_html($resource->summary, true, false)."</FONT></CENTER>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
echo "<HEAD><TITLE>$course->shortname: $resource->name</TITLE></HEAD>\n";
|
2003-01-05 10:10:05 +00:00
|
|
|
echo "<FRAMESET ROWS=$RESOURCE_FRAME_SIZE,*>";
|
2003-04-29 13:31:47 +00:00
|
|
|
echo "<FRAME SRC=\"view.php?id=$cm->id&frameset=top\">";
|
2002-10-17 14:03:59 +00:00
|
|
|
echo "<FRAME SRC=\"$resource->reference\">";
|
|
|
|
echo "</FRAMESET>";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
case UPLOADEDFILE:
|
2003-04-29 13:31:47 +00:00
|
|
|
require_once("../../files/mimetypes.php");
|
|
|
|
|
2003-03-11 21:35:12 +00:00
|
|
|
if ($CFG->slasharguments) {
|
2003-03-12 08:02:05 +00:00
|
|
|
$fullurl = "$CFG->wwwroot/file.php/$course->id/$resource->reference";
|
2003-03-11 21:35:12 +00:00
|
|
|
} else {
|
2003-03-12 08:02:05 +00:00
|
|
|
$fullurl = "$CFG->wwwroot/file.php?file=/$course->id/$resource->reference";
|
2003-03-11 21:35:12 +00:00
|
|
|
}
|
|
|
|
|
2003-05-13 07:51:26 +00:00
|
|
|
$embedded = false;
|
2003-04-29 13:31:47 +00:00
|
|
|
|
2003-05-13 07:51:26 +00:00
|
|
|
if (mimeinfo("icon", $fullurl) == "image.gif") { // It's an image
|
|
|
|
$embedded = true;
|
|
|
|
$resourceimage = true;
|
|
|
|
} else {
|
|
|
|
$resourceimage = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// (could check for more embeddable media here...)
|
|
|
|
|
|
|
|
if ($frameset == "top" or $embedded) {
|
2003-03-12 08:02:05 +00:00
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname",
|
2003-04-29 13:31:47 +00:00
|
|
|
"$navigation <a target=\"$CFG->framename\" HREF=\"$fullurl\">$resource->name</A>",
|
2003-03-12 08:02:05 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource),
|
|
|
|
navmenu($course, $cm));
|
2003-04-29 13:31:47 +00:00
|
|
|
echo "<center><font size=-1>".text_to_html($resource->summary, true, false)."</font></center>";
|
2003-05-13 07:51:26 +00:00
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($embedded) { // Display resource embedded in page
|
|
|
|
if ($resourceimage) {
|
|
|
|
echo "<br />";
|
|
|
|
echo "<center><img class=\"resourceimage\" src=\"$fullurl\"></center>";
|
|
|
|
echo "<br />";
|
|
|
|
}
|
2003-04-29 13:51:28 +00:00
|
|
|
print_footer($course);
|
2003-04-29 13:31:47 +00:00
|
|
|
|
2003-05-13 07:51:26 +00:00
|
|
|
} else { // Display resource in a frame of it's own.
|
2003-04-29 13:31:47 +00:00
|
|
|
echo "<head><title>$course->shortname: $resource->name</title></head>\n";
|
|
|
|
echo "<frameset rows=$RESOURCE_FRAME_SIZE,*>";
|
|
|
|
echo "<frame src=\"view.php?id=$cm->id&frameset=top\">";
|
2003-05-13 07:51:26 +00:00
|
|
|
echo "<frame src=\"$fullurl\">";
|
2003-04-29 13:31:47 +00:00
|
|
|
echo "</frameset>";
|
2002-10-17 14:03:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
case PLAINTEXT:
|
2002-10-17 14:03:59 +00:00
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
|
|
|
|
print_simple_box(text_to_html($resource->alltext), "CENTER", "", "$THEME->cellcontent", "20");
|
|
|
|
|
|
|
|
echo "<CENTER><P><FONT SIZE=1>$strlastmodified: ".userdate($resource->timemodified)."</P></CENTER>";
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
break;
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
case HTML:
|
2002-10-17 14:03:59 +00:00
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
|
|
|
|
print_simple_box_start("CENTER", "", "$THEME->cellcontent", "20");
|
|
|
|
|
|
|
|
echo $resource->alltext;
|
|
|
|
|
|
|
|
print_simple_box_end();
|
|
|
|
|
|
|
|
echo "<CENTER><P><FONT SIZE=1>$strlastmodified: ".userdate($resource->timemodified)."</P></CENTER>";
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
break;
|
|
|
|
|
2002-12-24 07:01:03 +00:00
|
|
|
case PROGRAM: // Code provided by Mark Kimes <hectorp@buckfoodsvc.com>
|
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
|
|
|
|
$temptime = gmdate("YmdHis",time());
|
|
|
|
|
|
|
|
$temproot = $CFG->wwwroot . "/mod/resource/";
|
|
|
|
|
|
|
|
// I tried to get around this. I really did. But here we
|
|
|
|
// are, redefining the navigation resources specifically anyway.
|
|
|
|
// On the plus side, you can change the format of the navigation
|
|
|
|
// strings above without worrying what it'll do to this code. On
|
|
|
|
// the negative side, you'll have to update this code if you
|
|
|
|
// change the structure of the navigation completely. Bonus
|
|
|
|
// is that now we can have a chain of cooperative sites, each
|
|
|
|
// adding to the navigation string as it moves down the line,
|
|
|
|
// which could be quite cool. -- Mark
|
|
|
|
|
|
|
|
if ($course->category) {
|
|
|
|
$tempref = "<$course->shortname><" . $temproot . "../../course/view.php?id=$course->id>" .
|
|
|
|
"<$strresources><" . $temproot . "index.php?id=$course->id>";
|
|
|
|
} else {
|
|
|
|
$tempref = "<$strresources><index.php?id=$course->id>";
|
|
|
|
}
|
|
|
|
|
|
|
|
$tempurl = trim($resource->reference);
|
|
|
|
|
|
|
|
if ($tempquerystring = strstr($tempurl,'?')) {
|
|
|
|
$tempquerystring = substr($tempquerystring,1);
|
|
|
|
$tempurl = substr($tempurl,0,strlen($tempurl) - strlen($tempquerystring));
|
|
|
|
}
|
|
|
|
if (!empty($tempquerystring)) {
|
|
|
|
$tempquerystring = preg_replace("/(.*=)([^&]*)/e",
|
|
|
|
"'\\1' . urlencode('\\2')",
|
|
|
|
$tempquerystring);
|
|
|
|
}
|
|
|
|
$temp = $tempurl . $tempquerystring .
|
|
|
|
((strstr($tempurl,'?')) ? "&" : "?") .
|
|
|
|
"extern_nav=" . urlencode($tempref) .
|
|
|
|
"&extern_usr=" .
|
|
|
|
urlencode($USER->username) .
|
|
|
|
"&extern_nam=" . urlencode("$USER->firstname $USER->lastname") .
|
|
|
|
"&extern_tim=" . urlencode($temptime) .
|
|
|
|
"&extern_pwd=" .
|
|
|
|
urlencode(md5($temptime . $USER->password));
|
|
|
|
redirect($temp);
|
|
|
|
break;
|
|
|
|
|
2003-05-01 03:43:16 +00:00
|
|
|
case WIKITEXT:
|
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
|
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
|
|
|
|
|
|
|
print_simple_box(wiki_to_html($resource->alltext), "CENTER", "", "$THEME->cellcontent", "20" );
|
|
|
|
|
|
|
|
echo "<center><p><font size=\"1\">$strlastmodified: ".userdate($resource->timemodified)."</p></center>";
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2002-10-17 14:03:59 +00:00
|
|
|
default:
|
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
print_heading($resource->name);
|
|
|
|
|
|
|
|
print_simple_box("Error: unknown type of resource", "center");
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|