Lots of little cleanups and these new things:
- Reference resources are now history -> converted to HTML pages
(the backup/restore has been taken care of, Eloy)
- HTML pages and Text pages can now have popups!
- Summaries are not shown when they should be blank (eg if they
just contain a <br /> as the HTML editor usually inserts.
- Fixed some notices for PHP 5
This commit is contained in:
@@ -46,7 +46,10 @@ function resource_upgrade($oldversion) {
|
||||
modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='7';");
|
||||
modify_database("", "UPDATE prefix_resource SET type='text', options='3' WHERE type='8';");
|
||||
modify_database("", "UPDATE prefix_resource SET type='directory' WHERE type='9';");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004080801) {
|
||||
modify_database("", "UPDATE prefix_resource SET alltext=reference,type='html' WHERE type='reference';");
|
||||
rebuild_course_cache();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,10 @@ function resource_upgrade($oldversion) {
|
||||
modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='7';");
|
||||
modify_database("", "UPDATE prefix_resource SET type='text', options='3' WHERE type='8';");
|
||||
modify_database("", "UPDATE prefix_resource SET type='directory' WHERE type='9';");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004080801) {
|
||||
modify_database("", "UPDATE prefix_resource SET alltext=reference,type='html' WHERE type='reference';");
|
||||
rebuild_course_cache();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ if (!isset($CFG->resource_secretphrase)) {
|
||||
set_config("resource_secretphrase", random_string(20));
|
||||
}
|
||||
|
||||
$RESOURCE_WINDOW_OPTIONS = array("resizable", "scrollbars", "directories", "location",
|
||||
"menubar", "toolbar", "status", "height", "width");
|
||||
|
||||
if (!isset($CFG->resource_popup)) {
|
||||
set_config("resource_popup", "");
|
||||
}
|
||||
|
||||
$RESOURCE_WINDOW_OPTIONS = array("resizable", "scrollbars", "directories", "location",
|
||||
"menubar", "toolbar", "status", "height", "width");
|
||||
|
||||
foreach ($RESOURCE_WINDOW_OPTIONS as $popupoption) {
|
||||
$popupoption = "resource_popup$popupoption";
|
||||
if (!isset($CFG->$popupoption)) {
|
||||
@@ -484,7 +484,7 @@ function resource_get_resource_types() {
|
||||
$resources = array();
|
||||
|
||||
/// Standard resource types
|
||||
$standardresources = array('text','html','file','directory','reference');
|
||||
$standardresources = array('text','html','file','directory');
|
||||
foreach ($standardresources as $resourcetype) {
|
||||
$resources[$resourcetype] = get_string("resourcetype$resourcetype", 'resource');
|
||||
}
|
||||
|
||||
@@ -53,9 +53,15 @@
|
||||
$resource->popup = $resource->alltext;
|
||||
$resource->alltext = '';
|
||||
}
|
||||
//Move reference to alltext for references
|
||||
if ($resource->type == 1) {
|
||||
$resource->popup = '';
|
||||
$resource->alltext = $resource->reference;
|
||||
$resource->reference = '';
|
||||
}
|
||||
//Reencode the type field to its new values and fill the options field as needed
|
||||
//Array 1-9 of new types
|
||||
$types = array ('','reference','file','file','text','file',
|
||||
$types = array ('','html','file','file','text','file',
|
||||
'html','file','text','directory');
|
||||
//Array 1-9 of corresponding options
|
||||
$options = array ('','','frame','','0','',
|
||||
@@ -65,6 +71,12 @@
|
||||
$resource->type = $types[$oldtype];
|
||||
$resource->options = $options[$oldtype];
|
||||
}
|
||||
|
||||
if ($resource->type == 'reference') { // Obsolete type of resource
|
||||
$resource->type == 'html';
|
||||
$resource->alltext = $resource->reference;
|
||||
$resource->reference = '';
|
||||
}
|
||||
|
||||
//The structure is equal to the db, so insert the resource
|
||||
$newid = insert_record ("resource",$resource);
|
||||
|
||||
@@ -70,7 +70,7 @@ function display() {
|
||||
get_string("editfiles")."...</a></div>";
|
||||
}
|
||||
|
||||
if (trim($this->resource->summary)) {
|
||||
if (trim(strip_tags($this->resource->summary))) {
|
||||
print_simple_box(text_to_html($this->resource->summary), "center");
|
||||
print_spacer(10,10);
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ function display() {
|
||||
echo "\n-->\n";
|
||||
echo '</script>';
|
||||
|
||||
if (trim($this->resource->summary)) {
|
||||
if (trim(strip_tags($this->resource->summary))) {
|
||||
print_simple_box(text_to_html($this->resource->summary), "center");
|
||||
}
|
||||
|
||||
@@ -446,6 +446,8 @@ function display() {
|
||||
function setup($form) {
|
||||
global $CFG, $usehtmleditor, $RESOURCE_WINDOW_OPTIONS;
|
||||
|
||||
parent::setup($form);
|
||||
|
||||
$this->set_parameters(); // set the parameter array for the form
|
||||
|
||||
|
||||
@@ -518,8 +520,6 @@ function setup($form) {
|
||||
}
|
||||
|
||||
|
||||
parent::setup($form);
|
||||
|
||||
include("$CFG->dirroot/mod/resource/type/file/file.html");
|
||||
|
||||
parent::setup_end();
|
||||
|
||||
@@ -12,3 +12,67 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="2"><hr /></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right" nowrap>
|
||||
<p><b><?php print_string("pagewindow", "resource") ?>:</b></p>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<script>
|
||||
var popupitems = [<?php echo $popupoptions; ?>];
|
||||
var allitems = [<?php echo $alloptions; ?>];
|
||||
</script>
|
||||
<input type="checkbox" name="windowpage" value=1 <?php echo ($windowtype == "page") ? "checked" : "" ?> onClick="document.form.windowpopup.checked=false; return lockoptions('form', 'windowpopup', popupitems);">
|
||||
<?php print_string("pagedisplay", "resource") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right" nowrap>
|
||||
<p><b><?php p($strnewwindow) ?>:</b></p>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<input name="setnewwindow" type=hidden value=1>
|
||||
<input name="windowpopup" type=checkbox value=1 onclick="lockoptions('form','windowpopup', popupitems); document.form.windowpage.checked=false;">
|
||||
<?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 ($windowtype == "page") {
|
||||
echo "<script>";
|
||||
echo "lockoptions('form','windowpopup', popupitems);";
|
||||
echo "document.form.windowpage.checked=true;";
|
||||
echo "document.form.windowpopup.checked=false;";
|
||||
echo "</script>";
|
||||
} else {
|
||||
echo "<script>";
|
||||
echo "document.form.windowpopup.checked=true;";
|
||||
echo "document.form.windowpage.checked=false;";
|
||||
echo "</script>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -7,6 +7,60 @@ function resource_html($cmid=0) {
|
||||
parent::resource_base($cmid);
|
||||
}
|
||||
|
||||
function add_instance($resource) {
|
||||
// Given an object containing all the necessary data,
|
||||
// (defined by the form in mod.html) this function
|
||||
// will create a new instance and return the id number
|
||||
// of the new instance.
|
||||
|
||||
global $RESOURCE_WINDOW_OPTIONS;
|
||||
|
||||
$resource->timemodified = time();
|
||||
|
||||
if (isset($resource->windowpopup)) {
|
||||
$optionlist = array();
|
||||
foreach ($RESOURCE_WINDOW_OPTIONS as $option) {
|
||||
if (isset($resource->$option)) {
|
||||
$optionlist[] = $option."=".$resource->$option;
|
||||
}
|
||||
}
|
||||
$resource->popup = implode(',', $optionlist);
|
||||
|
||||
} else if (isset($resource->windowpage)) {
|
||||
$resource->popup = "";
|
||||
}
|
||||
|
||||
return insert_record("resource", $resource);
|
||||
}
|
||||
|
||||
|
||||
function update_instance($resource) {
|
||||
// Given an object containing all the necessary data,
|
||||
// (defined by the form in mod.html) this function
|
||||
// will update an existing instance with new data.
|
||||
|
||||
global $RESOURCE_WINDOW_OPTIONS;
|
||||
|
||||
$resource->id = $resource->instance;
|
||||
$resource->timemodified = time();
|
||||
|
||||
if (isset($resource->windowpopup)) {
|
||||
$optionlist = array();
|
||||
foreach ($RESOURCE_WINDOW_OPTIONS as $option) {
|
||||
if (isset($resource->$option)) {
|
||||
$optionlist[] = $option."=".$resource->$option;
|
||||
}
|
||||
}
|
||||
$resource->popup = implode(',', $optionlist);
|
||||
|
||||
} else if (isset($resource->windowpage)) {
|
||||
$resource->popup = "";
|
||||
}
|
||||
|
||||
return update_record("resource", $resource);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function display() {
|
||||
global $CFG, $THEME;
|
||||
@@ -21,28 +75,116 @@ function display() {
|
||||
$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> ->";
|
||||
} else {
|
||||
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->"; }
|
||||
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->";
|
||||
}
|
||||
|
||||
|
||||
add_to_log($this->course->id, "resource", "view", "view.php?id={$this->cm->id}", $this->resource->id, $this->cm->id);
|
||||
$pagetitle = strip_tags($this->course->shortname.': '.$this->resource->name);
|
||||
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_simple_box(format_text($this->resource->alltext, FORMAT_HTML), "center", "", "$THEME->cellcontent", "20");
|
||||
$inpopup = !empty($_GET["inpopup"]);
|
||||
|
||||
echo "<center><p><font size=1>$strlastmodified: ".userdate($this->resource->timemodified)."</p></center>";
|
||||
if ($this->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);
|
||||
print_header();
|
||||
print_simple_box(format_text($this->resource->alltext, FORMAT_HTML), "center", "", "$THEME->cellcontent", "20");
|
||||
} else { /// Make a page and a pop-up window
|
||||
|
||||
print_footer($this->course);
|
||||
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));
|
||||
|
||||
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 "\n-->\n";
|
||||
echo '</script>';
|
||||
|
||||
if (trim(strip_tags($this->resource->summary))) {
|
||||
print_simple_box(format_text($this->resource->summary, FORMAT_HTML), "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>";
|
||||
|
||||
echo "<p> </p>";
|
||||
echo '<p align="center">';
|
||||
print_string('popupresource', 'resource');
|
||||
echo '<br />';
|
||||
print_string('popupresourcelink', 'resource', $link);
|
||||
echo "</p>";
|
||||
|
||||
print_footer($this->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));
|
||||
|
||||
print_simple_box(format_text($this->resource->alltext, FORMAT_HTML), "center", "", "$THEME->cellcontent", "20");
|
||||
|
||||
echo "<center><p><font size=1>$strlastmodified: ".userdate($this->resource->timemodified)."</p></center>";
|
||||
|
||||
print_footer($this->course);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function setup($form) {
|
||||
global $CFG, $usehtmleditor;
|
||||
global $CFG, $usehtmleditor, $RESOURCE_WINDOW_OPTIONS;
|
||||
|
||||
parent::setup($form);
|
||||
|
||||
|
||||
$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");
|
||||
$strsearch = get_string("searchweb", "resource");
|
||||
|
||||
foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
|
||||
$stringname = "str$optionname";
|
||||
$$stringname = get_string("new$optionname", "resource");
|
||||
$window->$optionname = "";
|
||||
$jsoption[] = "\"$optionname\"";
|
||||
}
|
||||
|
||||
$frameoption = "\"framepage\"";
|
||||
$popupoptions = implode(",", $jsoption);
|
||||
$jsoption[] = $frameoption;
|
||||
$alloptions = implode(",", $jsoption);
|
||||
|
||||
if ($form->instance) { // Re-editing
|
||||
if (!$form->popup) {
|
||||
$windowtype = "page"; // No popup text => in page
|
||||
} else {
|
||||
$windowtype = "popup";
|
||||
$rawoptions = explode(',', $form->popup);
|
||||
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;
|
||||
}
|
||||
|
||||
$windowtype = ($CFG->resource_popup) ? 'popup' : 'page';
|
||||
if (!isset($form->options)) {
|
||||
$form->options = '';
|
||||
}
|
||||
}
|
||||
|
||||
include("$CFG->dirroot/mod/resource/type/html/html.html");
|
||||
|
||||
parent::setup_end();
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<tr valign="top">
|
||||
<td align="right" nowrap>
|
||||
<p><b><?php print_string("resourcetypereference", "resource") ?>:</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 print_string("example", "resource") ?>)</b></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><?php print_string("examplereference", "resource") ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
class resource_reference extends resource_base {
|
||||
|
||||
|
||||
function resource_reference($cmid=0) {
|
||||
parent::resource_base($cmid);
|
||||
}
|
||||
|
||||
|
||||
function display() {
|
||||
global $CFG, $THEME;
|
||||
|
||||
|
||||
$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> ->";
|
||||
} else {
|
||||
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->"; }
|
||||
|
||||
|
||||
add_to_log($this->course->id, "resource", "view", "view.php?id={$this->cm->id}", $this->resource->id, $this->cm->id);
|
||||
$pagetitle = strip_tags($this->course->shortname.': '.$this->resource->name);
|
||||
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_simple_box($this->resource->reference, "center");
|
||||
echo "<center><p>";
|
||||
echo text_to_html($this->resource->summary);
|
||||
echo "</p>";
|
||||
echo "<p> </p>";
|
||||
echo "<p><font size=1>$strlastmodified: ".userdate($this->resource->timemodified)."</p>";
|
||||
echo "</center>";
|
||||
print_footer($this->course);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function setup($form) {
|
||||
global $CFG;
|
||||
|
||||
global $editorfields;
|
||||
$editorfields = 'summary';
|
||||
|
||||
parent::setup($form);
|
||||
|
||||
include("$CFG->dirroot/mod/resource/type/reference/reference.html");
|
||||
|
||||
parent::setup_end();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -8,6 +8,58 @@ function resource_text($cmid=0) {
|
||||
}
|
||||
|
||||
|
||||
function add_instance($resource) {
|
||||
// Given an object containing all the necessary data,
|
||||
// (defined by the form in mod.html) this function
|
||||
// will create a new instance and return the id number
|
||||
// of the new instance.
|
||||
|
||||
global $RESOURCE_WINDOW_OPTIONS;
|
||||
|
||||
$resource->timemodified = time();
|
||||
|
||||
if (isset($resource->windowpopup)) {
|
||||
$optionlist = array();
|
||||
foreach ($RESOURCE_WINDOW_OPTIONS as $option) {
|
||||
if (isset($resource->$option)) {
|
||||
$optionlist[] = $option."=".$resource->$option;
|
||||
}
|
||||
}
|
||||
$resource->popup = implode(',', $optionlist);
|
||||
|
||||
} else if (isset($resource->windowpage)) {
|
||||
$resource->popup = "";
|
||||
}
|
||||
|
||||
return insert_record("resource", $resource);
|
||||
}
|
||||
|
||||
function update_instance($resource) {
|
||||
// Given an object containing all the necessary data,
|
||||
// (defined by the form in mod.html) this function
|
||||
// will update an existing instance with new data.
|
||||
|
||||
global $RESOURCE_WINDOW_OPTIONS;
|
||||
|
||||
$resource->id = $resource->instance;
|
||||
$resource->timemodified = time();
|
||||
|
||||
if (isset($resource->windowpopup)) {
|
||||
$optionlist = array();
|
||||
foreach ($RESOURCE_WINDOW_OPTIONS as $option) {
|
||||
if (isset($resource->$option)) {
|
||||
$optionlist[] = $option."=".$resource->$option;
|
||||
}
|
||||
}
|
||||
$resource->popup = implode(',', $optionlist);
|
||||
|
||||
} else if (isset($resource->windowpage)) {
|
||||
$resource->popup = "";
|
||||
}
|
||||
|
||||
return update_record("resource", $resource);
|
||||
}
|
||||
|
||||
function display() {
|
||||
global $CFG, $THEME;
|
||||
|
||||
@@ -23,30 +75,118 @@ function display() {
|
||||
} else {
|
||||
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$strresources</a> ->"; }
|
||||
|
||||
|
||||
add_to_log($this->course->id, "resource", "view", "view.php?id={$this->cm->id}", $this->resource->id, $this->cm->id);
|
||||
$pagetitle = strip_tags($this->course->shortname.': '.$this->resource->name);
|
||||
|
||||
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));
|
||||
$inpopup = !empty($_GET["inpopup"]);
|
||||
|
||||
print_simple_box(format_text($this->resource->alltext, $this->resource->options), "center", "", "$THEME->cellcontent", "20");
|
||||
if ($this->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);
|
||||
print_header();
|
||||
print_simple_box(format_text($this->resource->alltext, $this->resource->options),
|
||||
"center", "", "$THEME->cellcontent", "20");
|
||||
} else { /// Make a page and a pop-up window
|
||||
|
||||
echo "<center><p><font size=1>$strlastmodified: ".userdate($this->resource->timemodified)."</p></center>";
|
||||
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));
|
||||
|
||||
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 "\n-->\n";
|
||||
echo '</script>';
|
||||
|
||||
if (trim(strip_tags($this->resource->summary))) {
|
||||
print_simple_box(format_text($this->resource->summary, FORMAT_HTML), "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>";
|
||||
|
||||
echo "<p> </p>";
|
||||
echo '<p align="center">';
|
||||
print_string('popupresource', 'resource');
|
||||
echo '<br />';
|
||||
print_string('popupresourcelink', 'resource', $link);
|
||||
echo "</p>";
|
||||
|
||||
print_footer($this->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));
|
||||
|
||||
print_simple_box(format_text($this->resource->alltext, $this->resource->options),
|
||||
"center", "", "$THEME->cellcontent", "20");
|
||||
|
||||
echo "<center><p><font size=1>$strlastmodified: ".userdate($this->resource->timemodified)."</p></center>";
|
||||
|
||||
print_footer($this->course);
|
||||
}
|
||||
|
||||
print_footer($this->course);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function setup($form) {
|
||||
global $CFG;
|
||||
|
||||
global $editorfields;
|
||||
global $CFG, $editorfields, $RESOURCE_WINDOW_OPTIONS;
|
||||
|
||||
$editorfields = 'summary';
|
||||
|
||||
parent::setup($form);
|
||||
|
||||
$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");
|
||||
$strsearch = get_string("searchweb", "resource");
|
||||
|
||||
foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
|
||||
$stringname = "str$optionname";
|
||||
$$stringname = get_string("new$optionname", "resource");
|
||||
$window->$optionname = "";
|
||||
$jsoption[] = "\"$optionname\"";
|
||||
}
|
||||
|
||||
$frameoption = "\"framepage\"";
|
||||
$popupoptions = implode(",", $jsoption);
|
||||
$jsoption[] = $frameoption;
|
||||
$alloptions = implode(",", $jsoption);
|
||||
|
||||
if ($form->instance) { // Re-editing
|
||||
if (!$form->popup) {
|
||||
$windowtype = "page"; // No popup text => in page
|
||||
} else {
|
||||
$windowtype = "popup";
|
||||
$rawoptions = explode(',', $form->popup);
|
||||
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;
|
||||
}
|
||||
|
||||
$windowtype = ($CFG->resource_popup) ? 'popup' : 'page';
|
||||
if (!isset($form->options)) {
|
||||
$form->options = '';
|
||||
}
|
||||
}
|
||||
|
||||
$format_array = format_text_menu();
|
||||
unset($format_array[FORMAT_HTML]);
|
||||
include("$CFG->dirroot/mod/resource/type/text/text.html");
|
||||
|
||||
@@ -15,10 +15,74 @@
|
||||
<p><b><?php print_string("formattexttype") ?>:</b></p><br />
|
||||
</td>
|
||||
<td>
|
||||
<?php choose_from_menu($format_array, "options", $form->options, '') ?>
|
||||
<font size="1">
|
||||
<?php helpbutton("textformat", get_string("formattexttype")) ?><br />
|
||||
</font>
|
||||
<?php
|
||||
choose_from_menu($format_array, "options", $form->options, '');
|
||||
helpbutton("textformat", get_string("formattexttype"));
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="2"><hr /></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right" nowrap>
|
||||
<p><b><?php print_string("pagewindow", "resource") ?>:</b></p>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<script>
|
||||
var popupitems = [<?php echo $popupoptions; ?>];
|
||||
var allitems = [<?php echo $alloptions; ?>];
|
||||
</script>
|
||||
<input type="checkbox" name="windowpage" value=1 <?php echo ($windowtype == "page") ? "checked" : "" ?> onClick="document.form.windowpopup.checked=false; return lockoptions('form', 'windowpopup', popupitems);">
|
||||
<?php print_string("pagedisplay", "resource") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right" nowrap>
|
||||
<p><b><?php p($strnewwindow) ?>:</b></p>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<input name="setnewwindow" type=hidden value=1>
|
||||
<input name="windowpopup" type=checkbox value=1 onclick="lockoptions('form','windowpopup', popupitems); document.form.windowpage.checked=false;">
|
||||
<?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 ($windowtype == "page") {
|
||||
echo "<script>";
|
||||
echo "lockoptions('form','windowpopup', popupitems);";
|
||||
echo "document.form.windowpage.checked=true;";
|
||||
echo "document.form.windowpopup.checked=false;";
|
||||
echo "</script>";
|
||||
} else {
|
||||
echo "<script>";
|
||||
echo "document.form.windowpopup.checked=true;";
|
||||
echo "document.form.windowpage.checked=false;";
|
||||
echo "</script>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2004073000;
|
||||
$module->version = 2004080801;
|
||||
$module->requires = 2004073000; // Requires this Moodle version
|
||||
$module->cron = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user