Cleaned up some more things using some shortcut variables, and also

fixed bug 1711 that was preventing glossaries from working properly
This commit is contained in:
moodler 2004-08-09 15:45:22 +00:00
parent ff1e2621f3
commit 518f01ce4f
5 changed files with 113 additions and 566 deletions

View File

@ -1,462 +0,0 @@
<?PHP // $Id$
require_once("../../config.php");
require_once("lib.php");
require_login();
$usehtmleditor = can_use_html_editor();
if ($form = data_submitted($destination)) {
if (! $course = get_record("course", "id", $form->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",
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
<a href=\"index.php?id=$course->id\">$strresources</a> -> $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 "<form name=theform method=post action=\"$form->destination\">";
echo "<table cellpadding=5 align=center>";
echo "<tr><td align=right nowrap><p><b>$strname:</b></p></td><td><p>$form->name</p></a></td></tr>";
switch ($form->type) {
case REFERENCE:
$strexamplereference = get_string("examplereference", "resource");
?>
<tr valign="top">
<td align="right" nowrap>
<p><b><?php echo $strtypename?>:</b></p>
</td>
<td>
<textarea name="reference" rows=3 cols=50 wrap="virtual"><?php p($form->reference) ?></textarea>
</td>
</tr>
<tr valign="top">
<td align="right" nowrap>
<p><b>(<?php echo $strexample?>)</b></p>
</td>
<td>
<p><?php echo $strexamplereference?></p>
</td>
</tr>
<?php
break;
case WEBPAGE:
$strexampleurl = get_string("exampleurl", "resource");
$strsearch = get_string("search");
if (empty($form->reference)) {
$form->reference = $CFG->resource_defaulturl;
}
?>
<tr valign="top">
<td align="right" nowrap>
<p><b><?php echo $strtypename?>:</b></p>
</td>
<td>
<input name="reference" size="80" value="<?php p($form->reference) ?>">
<?php
echo "<input type=button name=searchbutton value=\"$strsearch ...\" ".
"onClick=\"return window.open('$CFG->resource_websearch', 'websearch', 'menubar=1,location=1,directories=1,toolbar=1,scrollbars,resizable,width=800,height=600');\">\n";
?>
</td>
</tr>
<tr valign="top">
<td align="right" nowrap>&nbsp;
</td>
<td>
<p><?php echo "($strexample) $strexampleurl" ?></p>
</td>
</tr>
<?php
break;
case WEBLINK:
$strexampleurl = get_string("exampleurl", "resource");
$strnewwindow = get_string("newwindow", "resource");
$strnewwindowopen = get_string("newwindowopen", "resource");
$strsearch = get_string("search");
if (empty($form->reference)) {
$form->reference = $CFG->resource_defaulturl;
}
foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
$stringname = "str$optionname";
$$stringname = get_string("new$optionname", "resource");
$window->$optionname = "";
$jsoption[] = "\"$optionname\"";
}
$alljsoptions = implode(",", $jsoption);
if ($form->instance) { // Re-editing
if (!$form->alltext) {
$newwindow = ""; // Disable the new window
} else {
$newwindow = "checked";
$rawoptions = explode(',', $form->alltext);
foreach ($rawoptions as $rawoption) {
$option = explode('=', trim($rawoption));
$optionname = $option[0];
$optionvalue = $option[1];
if ($optionname == "height" or $optionname == "width") {
$window->$optionname = $optionvalue;
} else if ($optionvalue) {
$window->$optionname = "checked";
}
}
}
} else {
foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
$defaultvalue = "resource_popup$optionname";
$window->$optionname = $CFG->$defaultvalue;
}
$newwindow = $CFG->resource_popup;
}
?>
<tr valign="top">
<td align="right" nowrap>
<p><b><?php p($strtypename) ?>:</b></p>
</td>
<td>
<input name="reference" size="80" value="<?php p($form->reference) ?>">
<?php
echo "<input type=button name=searchbutton value=\"$strsearch ...\" ".
"onClick=\"return window.open('$CFG->resource_websearch', 'websearch', 'menubar=1,location=1,directories=1,toolbar=1,scrollbars,resizable,width=800,height=600');\">\n";
?>
</td>
</tr>
<tr valign="top">
<td align="right" nowrap>&nbsp;
</td>
<td>
<p><font size="-1"><?php echo "($strexample) $strexampleurl" ?></font></p>
</td>
</tr>
<tr valign="top">
<td align="right" nowrap>
<p><b><?php p($strnewwindow) ?></b></p>
</td>
<td>
<script>
var subitems = [<?php echo $alljsoptions; ?>];
</script>
<input name="setnewwindow" type=hidden value=1>
<input name="newwindow" type=checkbox value=1 <?php p($newwindow) ?>
onclick="return lockoptions('theform','newwindow', subitems)">
<?php p($strnewwindowopen) ?>
<ul>
<?php
foreach ($window as $name => $value) {
if ($name == "height" or $name == "width") {
continue;
}
echo "<input name=\"h$name\" type=hidden value=0>";
echo "<input name=\"$name\" type=checkbox value=1 ".$window->$name.">";
$stringname = "str$name";
echo $$stringname."<br />";
}
?>
<input name="hwidth" type=hidden value=0>
<input name="width" type=text size=4 value="<?php p($window->width) ?>">
<?php p($strwidth) ?><br />
<input name="hheight" type=hidden value=0>
<input name="height" type=text size=4 value="<?php p($window->height) ?>">
<?php p($strheight) ?><br />
<?php
if (!$newwindow) {
echo "<script>";
echo "lockoptions('theform','newwindow', subitems);";
echo "</script>";
}
?>
</ul>
</p>
</td>
</tr>
<?php
break;
case UPLOADEDFILE:
$strfilename = get_string("filename", "resource");
$strnote = get_string("note", "resource");
$strchooseafile = get_string("chooseafile", "resource");
$strnewwindow = get_string("newwindow", "resource");
$strnewwindowopen = get_string("newwindowopen", "resource");
foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
$stringname = "str$optionname";
$$stringname = get_string("new$optionname", "resource");
$window->$optionname = "";
$jsoption[] = "\"$optionname\"";
}
$alljsoptions = implode(",", $jsoption);
if ($form->instance) { // Re-editing
if (!$form->alltext) {
$newwindow = ""; // Disable the new window
} else {
$newwindow = "checked";
$rawoptions = explode(',', $form->alltext);
foreach ($rawoptions as $rawoption) {
$option = explode('=', trim($rawoption));
$optionname = $option[0];
$optionvalue = $option[1];
if ($optionname == "height" or $optionname == "width") {
$window->$optionname = $optionvalue;
} else if ($optionvalue) {
$window->$optionname = "checked";
}
}
}
} else {
foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
$defaultvalue = "resource_popup$optionname";
$window->$optionname = $CFG->$defaultvalue;
}
$newwindow = $CFG->resource_popup;
}
?>
<tr valign="top">
<td align="right" nowrap>
<p><b><?php echo $strfilename?>:</b></p>
</td>
<td>
<?php
echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\">&nbsp;";
button_to_popup_window ("/mod/resource/coursefiles.php?id=$course->id",
"coursefiles", $strchooseafile, 500, 750, $strchooseafile);
?>
</td>
</tr>
<tr valign="top">
<td align="right" nowrap>
<p><b><?php p($strnewwindow) ?></b></p>
</td>
<td>
<script>
var subitems = [<?php echo $alljsoptions; ?>];
</script>
<input name="setnewwindow" type=hidden value=1>
<input name="newwindow" type=checkbox value=1 <?php p($newwindow) ?>
onclick="return lockoptions('theform','newwindow', subitems)">
<?php p($strnewwindowopen) ?>
<ul>
<?php
foreach ($window as $name => $value) {
if ($name == "height" or $name == "width") {
continue;
}
echo "<input name=\"h$name\" type=hidden value=0>";
echo "<input name=\"$name\" type=checkbox value=1 ".$window->$name.">";
$stringname = "str$name";
echo $$stringname."<br />";
}
?>
<input name="hwidth" type=hidden value=0>
<input name="width" type=text size=4 value="<?php p($window->width) ?>">
<?php p($strwidth) ?><br />
<input name="hheight" type=hidden value=0>
<input name="height" type=text size=4 value="<?php p($window->height) ?>">
<?php p($strheight) ?><br />
<?php
if (!$newwindow) {
echo "<script>";
echo "lockoptions('theform','newwindow', subitems);";
echo "</script>";
}
?>
</ul>
</p>
</td>
</tr>
<?php
break;
case PROGRAM:
$strexampleurl = get_string("exampleurl", "resource");
?>
<tr valign="top">
<td align="right" nowrap>
<p><b><?php echo $strtypename?>:</b></p>
</td>
<td>
<input name="reference" size="100" value="<?php p($form->reference) ?>">
</td>
</tr>
<tr valign="top">
<td align="right" nowrap>&nbsp;
</td>
<td>
<p><?php echo "($strexample) $strexampleurl" ?></p>
</td>
</tr>
<?php
break;
case PLAINTEXT:
$strfulltext = get_string("fulltext", "resource");
?>
<tr valign="top">
<td align="right" nowrap>
<p><b><?php echo $strfulltext?>:</b></p><br />
<font size="1">
<?php helpbutton("writing", get_string("helpwriting"), "moodle", true, true) ?><br />
<?php helpbutton("text", get_string("helptext"), "moodle", true, true) ?> <br />
<?php emoticonhelpbutton("theform", "alltext") ?> <br />
</font>
</td>
<td>
<textarea name="alltext" rows=20 cols=50 wrap="virtual"><?php p($form->alltext) ?></textarea>
</td>
</tr>
<?php
break;
case WIKITEXT:
$strfulltext = get_string("fulltext", "resource");
?>
<tr valign="top">
<td align="right" nowrap="true">
<p><b><?php echo $strfulltext?>:</b></p><br />
<font size="1">
<?php helpbutton("writing", get_string("helpwriting"), "moodle", true, true) ?><br />
<?php helpbutton("wiki", get_string("helpwiki"), "moodle", true, true) ?> <br />
</font>
</td>
<td>
<textarea name="alltext" rows="20" cols="50" wrap="virtual"><?php p($form->alltext) ?></textarea>
</td>
</tr>
<?php
break;
case HTML:
$strhtmlfragment = get_string("htmlfragment", "resource");
?>
<tr valign="top">
<td align="right" nowrap>
<p><b><?php echo $strhtmlfragment?>:</b></p><br />
<font size="1">
<?php helpbutton("writing", get_string("helpwriting"), "moodle", true, true) ?><br />
<?php if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
helpbutton("html", get_string("helphtml"), "moodle", true, true);
} ?> <br />
</font>
</td>
<td>
<?php print_textarea($usehtmleditor, 20, 50, 680, 400, "alltext", $form->alltext); ?>
</td>
</tr>
<?php
break;
case DIRECTORY:
$rawdirs = get_directory_list("$CFG->dataroot/$course->id", 'moddata', true, true, false);
$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;
}
?>
</table>
<input type="hidden" name=summary value="<?php p($form->summary) ?>">
<input type="hidden" name=type value="<?php p($form->type) ?>">
<input type="hidden" name=name value="<?php p($form->name) ?>">
<input type="hidden" name=course value="<?php p($form->course) ?>">
<input type="hidden" name=coursemodule value="<?php p($form->coursemodule) ?>">
<input type="hidden" name=section value="<?php p($form->section) ?>">
<input type="hidden" name=module value="<?php p($form->module) ?>">
<input type="hidden" name=modulename value="<?php p($form->modulename) ?>">
<input type="hidden" name=instance value="<?php p($form->instance) ?>">
<input type="hidden" name=mode value="<?php p($form->mode) ?>">
<center>
<input type="submit" value="<?php print_string("savechanges") ?>">
<input type="submit" name=cancel value="<?php print_string("cancel") ?>">
</center>
</form>
<?php
if ($usehtmleditor and $form->type == HTML) {
use_html_editor("alltext");
}
print_simple_box_end();
print_footer($course);
} else {
error("This script was called incorrectly");
}
?>

View File

@ -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 = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id={$this->course->id}\">{$this->course->shortname}</a> ->
<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->";
$course = $this->course; // Shortcut
$resource = $this->resource; // Shortcut
if ($course->category) {
require_login($course->id);
$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> ->";
} else {
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->"; }
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$course->id}\">$strresources</a> ->"; }
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 = "<a href=\"view.php?id={$this->cm->id}\">{$this->resource->name}</a>";
$subnav = "<a href=\"view.php?id={$this->cm->id}\">{$resource->name}</a>";
$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 "<div align=\"right\"><img src=\"$CFG->pixpath/i/files.gif\" height=16 width=16 alt=\"\">&nbsp".
"<a href=\"$CFG->wwwroot/files/index.php?id={$this->course->id}&wdir=/{$this->resource->reference}$subdir\">".
"<a href=\"$CFG->wwwroot/files/index.php?id={$course->id}&wdir=/{$resource->reference}$subdir\">".
get_string("editfiles")."...</a></div>";
}
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 "<a href=\"view.php?id={$this->cm->id}&subdir=$subdir/$file\">$file</a>";
} 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 '</p></td>';
echo '<td>&nbsp;</td>';
@ -138,7 +141,7 @@ function display() {
print_simple_box_end();
print_footer($this->course);
print_footer($course);
}

View File

@ -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 = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id={$this->course->id}\">{$this->course->shortname}</a> ->
<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->";
if ($course->category) {
require_login($course->id);
$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> ->";
} else {
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->";
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$course->id}\">$strresources</a> ->";
}
@ -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<script language=\"Javascript\">";
echo "\n<!--\n";
echo "openpopup('/mod/resource/view.php?inpopup=true&id={$this->cm->id}','resource{$this->resource->id}','{$this->resource->popup}');\n";
echo "openpopup('/mod/resource/view.php?inpopup=true&id={$this->cm->id}','resource{$resource->id}','{$resource->popup}');\n";
echo "\n-->\n";
echo '</script>';
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 = "<a href=\"$CFG->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}</a>";
$link = "<a href=\"$CFG->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}</a>";
echo "<p>&nbsp</p>";
echo '<p align="center">';
@ -304,17 +306,17 @@ function display() {
print_string('popupresourcelink', 'resource', $link);
echo "</p>";
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 "<head><title>{$this->course->shortname}: {$this->resource->name}</title></head>\n";
if (empty($_GET['frameset']) and !$embedded and !$inpopup and $resource->options == "frame") {
echo "<head><title>{$course->shortname}: {$resource->name}</title></head>\n";
echo "<frameset rows=\"$CFG->resource_framesize,*\" border=\"2\">";
echo "<frame src=\"view.php?id={$this->cm->id}&type={$this->resource->type}&frameset=top\">";
echo "<frame src=\"view.php?id={$this->cm->id}&type={$resource->type}&frameset=top\">";
echo "<frame src=\"$fullurl\">";
echo "</frameset>";
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 <a target=\"$CFG->framename\" href=\"$fullurl\">{$this->resource->name}</a>", "", "", true, update_module_button($this->cm->id, $this->course->id, $strresource), navmenu($this->course, $this->cm, "parent"));
print_header($pagetitle, $course->fullname, "$navigation <a target=\"$CFG->framename\" href=\"$fullurl\">{$resource->name}</a>", "", "", true, update_module_button($this->cm->id, $course->id, $strresource), navmenu($course, $this->cm, "parent"));
echo "<center><font size=-1>".text_to_html($this->resource->summary, true, false)."</font></center>";
echo "<center><font size=-1>".text_to_html($resource->summary, true, false)."</font></center>";
echo "</body></html>";
exit;
}
@ -345,13 +347,13 @@ function display() {
if ($inpopup) {
print_header($pagetitle);
} else {
print_header($pagetitle, $this->course->fullname, "$navigation <a title=\"$strdirectlink\" target=\"$CFG->framename\" href=\"$fullurl\"> {$this->resource->name}</a>", "", "", true, update_module_button($this->cm->id, $this->course->id, $strresource), navmenu($this->course, $this->cm, "self"));
print_header($pagetitle, $course->fullname, "$navigation <a title=\"$strdirectlink\" target=\"$CFG->framename\" href=\"$fullurl\"> {$resource->name}</a>", "", "", true, update_module_button($this->cm->id, $course->id, $strresource), navmenu($course, $this->cm, "self"));
}
if ($resourcetype == "image") {
echo "<center><p>";
echo "<img title=\"{$this->resource->name}\" class=\"resourceimage\" src=\"$fullurl\">";
echo "<img title=\"{$resource->name}\" class=\"resourceimage\" src=\"$fullurl\">";
echo "</p></center>";
} else if ($resourcetype == "mp3") {
@ -415,16 +417,16 @@ function display() {
echo "</p></center>";
}
if (trim($this->resource->summary)) {
if (trim($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");
}
if ($inpopup) {
echo "<center><p>(<a href=\"$fullurl\">$strdirectlink</a>)</p></center>";
} else {
print_spacer(20,20);
print_footer($this->course);
print_footer($course);
}
} else { // Display the resource on it's own

View File

@ -65,46 +65,48 @@ function update_instance($resource) {
function display() {
global $CFG, $THEME;
$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 = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id={$this->course->id}\">{$this->course->shortname}</a> ->
<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->";
if ($course->category) {
require_login($course->id);
$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> ->";
} else {
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->";
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$course->id}\">$strresources</a> ->";
}
$pagetitle = strip_tags($this->course->shortname.': '.$this->resource->name);
$pagetitle = strip_tags($course->shortname.': '.$resource->name);
$formatoptions->noclean = true;
$inpopup = !empty($_GET["inpopup"]);
if ($this->resource->popup) {
if ($resource->popup) {
if ($inpopup) { /// Popup only
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);
print_header();
print_simple_box(format_text($this->resource->alltext, FORMAT_HTML, $formatoptions),
print_simple_box(format_text($resource->alltext, FORMAT_HTML, $formatoptions, $course->id),
"center", "", "$THEME->cellcontent", "20");
} else { /// 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<script language=\"Javascript\">";
echo "\n<!--\n";
echo "openpopup('/mod/resource/view.php?inpopup=true&id={$this->cm->id}','resource{$this->resource->id}','{$this->resource->popup}');\n";
echo "openpopup('/mod/resource/view.php?inpopup=true&id={$this->cm->id}','resource{$resource->id}','{$resource->popup}');\n";
echo "\n-->\n";
echo '</script>';
if (trim(strip_tags($this->resource->summary))) {
print_simple_box(format_text($this->resource->summary, FORMAT_MOODLE, $formatoptions), "center");
if (trim(strip_tags($resource->summary))) {
print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
}
$link = "<a href=\"$CFG->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}</a>";
$link = "<a href=\"$CFG->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}</a>";
echo "<p>&nbsp</p>";
echo '<p align="center">';
@ -113,20 +115,20 @@ function display() {
print_string('popupresourcelink', 'resource', $link);
echo "</p>";
print_footer($this->course);
print_footer($course);
}
} else { /// not a popup at all
add_to_log($this->course->id, "resource", "view", "view.php?id={$this->cm->id}", $this->resource->id, $this->cm->id);
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));
add_to_log($course->id, "resource", "view", "view.php?id={$this->cm->id}", $resource->id, $this->cm->id);
print_header($pagetitle, $course->fullname, "$navigation {$resource->name}",
"", "", true, update_module_button($this->cm->id, $course->id, $strresource),
navmenu($course, $this->cm));
print_simple_box(format_text($this->resource->alltext, FORMAT_HTML, $formatoptions), "center", "", "$THEME->cellcontent", "20");
print_simple_box(format_text($resource->alltext, FORMAT_HTML, $formatoptions, $course->id), "center", "", "$THEME->cellcontent", "20");
echo "<center><p><font size=1>$strlastmodified: ".userdate($this->resource->timemodified)."</p></center>";
echo "<center><p><font size=1>$strlastmodified: ".userdate($resource->timemodified)."</p></center>";
print_footer($this->course);
print_footer($course);
}
}

View File

@ -63,46 +63,48 @@ function update_instance($resource) {
function display() {
global $CFG, $THEME;
$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 = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id={$this->course->id}\">{$this->course->shortname}</a> ->
<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->";
if ($course->category) {
require_login($course->id);
$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> ->";
} else {
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->"; }
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$course->id}\">$strresources</a> ->"; }
$pagetitle = strip_tags($this->course->shortname.': '.$this->resource->name);
$pagetitle = strip_tags($course->shortname.': '.$resource->name);
$formatoptions->noclean = true;
$inpopup = !empty($_GET["inpopup"]);
if ($this->resource->popup) {
if ($resource->popup) {
if ($inpopup) { /// Popup only
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);
print_header();
print_simple_box(format_text($this->resource->alltext, $this->resource->options, $formatoptions),
print_simple_box(format_text($resource->alltext, $resource->options, $formatoptions, $course->id),
"center", "", "$THEME->cellcontent", "20");
} else { /// 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<script language=\"Javascript\">";
echo "\n<!--\n";
echo "openpopup('/mod/resource/view.php?inpopup=true&id={$this->cm->id}','resource{$this->resource->id}','{$this->resource->popup}');\n";
echo "openpopup('/mod/resource/view.php?inpopup=true&id={$this->cm->id}','resource{$resource->id}','{$resource->popup}');\n";
echo "\n-->\n";
echo '</script>';
if (trim(strip_tags($this->resource->summary))) {
print_simple_box(format_text($this->resource->summary, FORMAT_MOODLE, $formatoptions), "center");
if (trim(strip_tags($resource->summary))) {
print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
}
$link = "<a href=\"$CFG->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}</a>";
$link = "<a href=\"$CFG->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}</a>";
echo "<p>&nbsp</p>";
echo '<p align="center">';
@ -111,21 +113,21 @@ function display() {
print_string('popupresourcelink', 'resource', $link);
echo "</p>";
print_footer($this->course);
print_footer($course);
}
} else { /// not a popup at all
add_to_log($this->course->id, "resource", "view", "view.php?id={$this->cm->id}", $this->resource->id, $this->cm->id);
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));
add_to_log($course->id, "resource", "view", "view.php?id={$this->cm->id}", $resource->id, $this->cm->id);
print_header($pagetitle, $course->fullname, "$navigation {$resource->name}",
"", "", true, update_module_button($this->cm->id, $course->id, $strresource),
navmenu($course, $this->cm));
print_simple_box(format_text($this->resource->alltext, $this->resource->options, $formatoptions),
print_simple_box(format_text($resource->alltext, $resource->options, $formatoptions, $course->id),
"center", "", "$THEME->cellcontent", "20");
echo "<center><p><font size=1>$strlastmodified: ".userdate($this->resource->timemodified)."</p></center>";
echo "<center><p><font size=1>$strlastmodified: ".userdate($resource->timemodified)."</p></center>";
print_footer($this->course);
print_footer($course);
}
}