From 518f01ce4f62854ce9cdc26a188c8a67128b4eb7 Mon Sep 17 00:00:00 2001
From: moodler
Date: Mon, 9 Aug 2004 15:45:22 +0000
Subject: [PATCH] Cleaned up some more things using some shortcut variables,
and also fixed bug 1711 that was preventing glossaries from working properly
---
mod/resource/details.php | 462 ------------------
.../type/directory/resource.class.php | 47 +-
mod/resource/type/file/resource.class.php | 68 +--
mod/resource/type/html/resource.class.php | 50 +-
mod/resource/type/text/resource.class.php | 52 +-
5 files changed, 113 insertions(+), 566 deletions(-)
delete mode 100644 mod/resource/details.php
diff --git a/mod/resource/details.php b/mod/resource/details.php
deleted file mode 100644
index f2e38e4e42..0000000000
--- a/mod/resource/details.php
+++ /dev/null
@@ -1,462 +0,0 @@
-course)) {
- error("This course doesn't exist");
- }
-
- require_login($course->id);
-
- if (!isteacher($course->id)) {
- error("You can't modify this course!");
- }
-
- $stredit = get_string("edit");
- $strediting = get_string("editingaresource", "resource");
- $strname = get_string("name");
- $strtypename = $RESOURCE_TYPE["$form->type"];
- $strexample = get_string("example", "resource");
- $strresources = get_string("modulenameplural", "resource");
-
- $form->name = stripslashes($form->name); // remove slashes
-
- print_header("$course->shortname: $strediting", "$course->shortname: $strediting",
- "wwwroot/course/view.php?id=$course->id\">$course->shortname ->
- id\">$strresources -> $form->name ($stredit)");
-
- if (!$form->name or !$form->type or !$form->summary) {
- error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]);
- }
-
- $form->alltext = "";
- if ($form->instance) {
- $form->alltext = get_field("resource", "alltext", "id", "$form->instance");
- }
-
- print_simple_box_start("center", "", "$THEME->cellheading");
-
- echo "
-type == HTML) {
- use_html_editor("alltext");
- }
- print_simple_box_end();
- print_footer($course);
-
- } else {
- error("This script was called incorrectly");
- }
-?>
diff --git a/mod/resource/type/directory/resource.class.php b/mod/resource/type/directory/resource.class.php
index eb644adc4b..379699a57e 100644
--- a/mod/resource/type/directory/resource.class.php
+++ b/mod/resource/type/directory/resource.class.php
@@ -14,23 +14,26 @@ function display() {
$strresources = get_string("modulenameplural", "resource");
$strlastmodified = get_string("lastmodified");
- if ($this->course->category) {
- require_login($this->course->id);
- $navigation = "framename}\" href=\"../../course/view.php?id={$this->course->id}\">{$this->course->shortname} ->
- framename}\" href=\"index.php?id={$this->course->id}\">$strresources ->";
+ $course = $this->course; // Shortcut
+ $resource = $this->resource; // Shortcut
+
+ if ($course->category) {
+ require_login($course->id);
+ $navigation = "framename}\" href=\"../../course/view.php?id={$course->id}\">{$course->shortname} ->
+ framename}\" href=\"index.php?id={$course->id}\">$strresources ->";
} else {
- $navigation = "framename}\" href=\"index.php?id={$this->course->id}\">$strresources ->"; }
+ $navigation = "framename}\" href=\"index.php?id={$course->id}\">$strresources ->"; }
require_once("../../files/mimetypes.php");
$subdir = isset($_GET['subdir']) ? $_GET['subdir'] : '';
- add_to_log($this->course->id, "resource", "view", "view.php?id={$this->cm->id}", $this->resource->id, $this->cm->id);
+ add_to_log($course->id, "resource", "view", "view.php?id={$this->cm->id}", $resource->id, $this->cm->id);
- if ($this->resource->reference) {
- $relativepath = "{$this->course->id}/{$this->resource->reference}";
+ if ($resource->reference) {
+ $relativepath = "{$course->id}/{$resource->reference}";
} else {
- $relativepath = "{$this->course->id}";
+ $relativepath = "{$course->id}";
}
if ($subdir) {
@@ -43,7 +46,7 @@ function display() {
array_shift($subs);
$countsubs = count($subs);
$count = 0;
- $subnav = "cm->id}\">{$this->resource->name}";
+ $subnav = "cm->id}\">{$resource->name}";
$backsub = '';
foreach ($subs as $sub) {
$count++;
@@ -55,24 +58,24 @@ function display() {
}
}
} else {
- $subnav = $this->resource->name;
+ $subnav = $resource->name;
}
- $pagetitle = strip_tags($this->course->shortname.': '.$this->resource->name);
+ $pagetitle = strip_tags($course->shortname.': '.$resource->name);
- print_header($pagetitle, $this->course->fullname, "$navigation $subnav",
- "", "", true, update_module_button($this->cm->id, $this->course->id, $strresource),
- navmenu($this->course, $this->cm));
+ print_header($pagetitle, $course->fullname, "$navigation $subnav",
+ "", "", true, update_module_button($this->cm->id, $course->id, $strresource),
+ navmenu($course, $this->cm));
- if (isteacheredit($this->course->id)) {
+ if (isteacheredit($course->id)) {
echo "";
}
- if (trim(strip_tags($this->resource->summary))) {
+ if (trim(strip_tags($resource->summary))) {
$formatoptions->noclean = true;
- print_simple_box(format_text($this->resource->summary, FORMAT_MOODLE, $formatoptions), "center");
+ print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
print_spacer(10,10);
}
@@ -81,7 +84,7 @@ function display() {
if (!$files) {
print_heading(get_string("nofilesyet"));
- print_footer($this->course);
+ print_footer($course);
exit;
}
@@ -122,7 +125,7 @@ function display() {
if ($icon == 'folder.gif') {
echo "cm->id}&subdir=$subdir/$file\">$file";
} else {
- link_to_popup_window($relativeurl, "resourcedirectory{$this->resource->id}", "$file", 450, 600, '');
+ link_to_popup_window($relativeurl, "resourcedirectory{$resource->id}", "$file", 450, 600, '');
}
echo '
';
echo ' | ';
@@ -138,7 +141,7 @@ function display() {
print_simple_box_end();
- print_footer($this->course);
+ print_footer($course);
}
diff --git a/mod/resource/type/file/resource.class.php b/mod/resource/type/file/resource.class.php
index 8266199848..57ee8ab711 100644
--- a/mod/resource/type/file/resource.class.php
+++ b/mod/resource/type/file/resource.class.php
@@ -178,17 +178,19 @@ function display() {
$this->set_parameters(); // set the parameters array
+ $course = $this->course; // shortcut
+ $resource = $this->resource; // shortcut
$strresource = get_string("modulename", "resource");
$strresources = get_string("modulenameplural", "resource");
$strlastmodified = get_string("lastmodified");
- if ($this->course->category) {
- require_login($this->course->id);
- $navigation = "framename}\" href=\"../../course/view.php?id={$this->course->id}\">{$this->course->shortname} ->
- framename}\" href=\"index.php?id={$this->course->id}\">$strresources ->";
+ if ($course->category) {
+ require_login($course->id);
+ $navigation = "framename}\" href=\"../../course/view.php?id={$course->id}\">{$course->shortname} ->
+ framename}\" href=\"index.php?id={$course->id}\">$strresources ->";
} else {
- $navigation = "framename}\" href=\"index.php?id={$this->course->id}\">$strresources ->";
+ $navigation = "framename}\" href=\"index.php?id={$course->id}\">$strresources ->";
}
@@ -208,10 +210,10 @@ function display() {
$querystring = '';
$resourcetype = '';
$embedded = false;
- $mimetype = mimeinfo("type", $this->resource->reference);
- $pagetitle = strip_tags($this->course->shortname.': '.$this->resource->name);
+ $mimetype = mimeinfo("type", $resource->reference);
+ $pagetitle = strip_tags($course->shortname.': '.$resource->name);
- if ($this->resource->options != "frame") {
+ if ($resource->options != "frame") {
if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // It's an image
$resourcetype = "image";
$embedded = true;
@@ -236,9 +238,9 @@ function display() {
/// Form the parse string
- if (!empty($this->resource->alltext)) {
+ if (!empty($resource->alltext)) {
$querys = array();
- $parray = explode(',', $this->resource->alltext);
+ $parray = explode(',', $resource->alltext);
foreach ($parray as $fieldstring) {
$field = explode('=', $fieldstring);
$querys[] = urlencode($field[1]).'='.urlencode($this->parameters[$field[0]]['value']);
@@ -251,10 +253,10 @@ function display() {
$inpopup = !empty($_GET["inpopup"]);
- if (resource_is_url($this->resource->reference)) {
- $fullurl = $this->resource->reference;
+ if (resource_is_url($resource->reference)) {
+ $fullurl = $resource->reference;
if (!empty($querystring)) {
- $urlpieces = parse_url($this->resource->reference);
+ $urlpieces = parse_url($resource->reference);
if (empty($urlpieces['query'])) {
$fullurl .= '?'.$querystring;
} else {
@@ -263,12 +265,12 @@ function display() {
}
} else {
if ($CFG->slasharguments) {
- $relativeurl = "/file.php/{$this->course->id}/{$this->resource->reference}";
+ $relativeurl = "/file.php/{$course->id}/{$resource->reference}";
if ($querystring) {
$relativeurl .= '?'.$querystring;
}
} else {
- $relativeurl = "/file.php?file=/{$this->course->id}/{$this->resource->reference}";
+ $relativeurl = "/file.php?file=/{$course->id}/{$resource->reference}";
if ($querystring) {
$relativeurl .= '&'.$querystring;
}
@@ -279,23 +281,23 @@ function display() {
/// Check whether this is supposed to be a popup, but was called directly
- if ($this->resource->popup and !$inpopup) { /// Make a page and a pop-up window
+ if ($resource->popup and !$inpopup) { /// Make a page and a pop-up window
- print_header($pagetitle, $this->course->fullname, "$navigation {$this->resource->name}", "", "", true, update_module_button($this->cm->id, $this->course->id, $strresource), navmenu($this->course, $this->cm));
+ print_header($pagetitle, $course->fullname, "$navigation {$resource->name}", "", "", true, update_module_button($this->cm->id, $course->id, $strresource), navmenu($course, $this->cm));
echo "\n';
- if (trim(strip_tags($this->resource->summary))) {
+ if (trim(strip_tags($resource->summary))) {
$formatoptions->noclean = true;
- print_simple_box(format_text($this->resource->summary, FORMAT_MOODLE, $formatoptions), "center");
+ print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
}
- $link = "wwwroot/mod/resource/view.php?inpopup=true&id={$this->cm->id}\" target=\"resource{$this->resource->id}\" onClick=\"return openpopup('/mod/resource/view.php?inpopup=true&id={$this->cm->id}', 'resource{$this->resource->id}','{$this->resource->popup}');\">{$this->resource->name}";
+ $link = "wwwroot/mod/resource/view.php?inpopup=true&id={$this->cm->id}\" target=\"resource{$resource->id}\" onClick=\"return openpopup('/mod/resource/view.php?inpopup=true&id={$this->cm->id}', 'resource{$resource->id}','{$resource->popup}');\">{$resource->name}";
echo " 
";
echo '';
@@ -304,17 +306,17 @@ function display() {
print_string('popupresourcelink', 'resource', $link);
echo "
";
- print_footer($this->course);
+ print_footer($course);
exit;
}
/// Now check whether we need to display a frameset
- if (empty($_GET['frameset']) and !$embedded and !$inpopup and $this->resource->options == "frame") {
- echo "{$this->course->shortname}: {$this->resource->name}\n";
+ if (empty($_GET['frameset']) and !$embedded and !$inpopup and $resource->options == "frame") {
+ echo "{$course->shortname}: {$resource->name}\n";
echo "";
exit;
@@ -323,15 +325,15 @@ function display() {
/// We can only get here once per resource, so add an entry to the log
- add_to_log($this->course->id, "resource", "view", "view.php?id={$this->cm->id}", $this->resource->id, $this->cm->id);
+ add_to_log($course->id, "resource", "view", "view.php?id={$this->cm->id}", $resource->id, $this->cm->id);
/// If we are in a frameset, just print the top of it
if (!empty($_GET['frameset']) and $_GET['frameset'] == "top") {
- print_header($pagetitle, $this->course->fullname, "$navigation framename\" href=\"$fullurl\">{$this->resource->name}", "", "", true, update_module_button($this->cm->id, $this->course->id, $strresource), navmenu($this->course, $this->cm, "parent"));
+ print_header($pagetitle, $course->fullname, "$navigation framename\" href=\"$fullurl\">{$resource->name}", "", "", true, update_module_button($this->cm->id, $course->id, $strresource), navmenu($course, $this->cm, "parent"));
- echo "".text_to_html($this->resource->summary, true, false)."";
+ echo "".text_to_html($resource->summary, true, false)."";
echo "