A few rearrangments in the new code for filtered external pages

This commit is contained in:
moodler 2003-11-28 02:11:02 +00:00
parent d31a78675b
commit 3bfe3922c2
5 changed files with 32 additions and 10 deletions

View File

@ -5,6 +5,7 @@
$string['addresource'] = 'Add resource';
$string['chooseafile'] = 'Choose or upload a file';
$string['configdefaulturl'] = 'This value is used to prefill the URL form when creating a new URL-based resource.';
$string['configfilterexternalpages'] = 'Enabling this setting will cause all external resources (web pages, uploaded HTML files) to be processed by the currently defined site filters (such as glossary autolinks, for example). Turning this option on may cause your course pages to slow down significantly - use with caution and only if you really need it.';
$string['configframesize'] = 'When a web page or an uploaded file is displayed within a frame, this value is the size (in pixels) of the top frame (which contains the navigation).';
$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['editingaresource'] = 'Editing a resource';

View File

@ -28,6 +28,20 @@
<?php print_string("configdefaulturl", "resource") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>resource_filterexternalpages:</td>
<td>
<?php
unset($choices);
$choices["0"] = get_string("no");
$choices["1"] = get_string("yes");
choose_from_menu ($choices, "resource_filterexternalpages", $CFG->resource_filterexternalpages, "");
?>
</td>
<td>
<?php print_string("configfilterexternalpages", "resource") ?>
</td>
</tr>
<tr>
<td colspan=3 align=center>
<input type="submit" value="<?php print_string("savechanges") ?>"></td>

View File

@ -2,7 +2,6 @@
require_once("../../config.php");
require_once("lib.php");
require_once("../../lib/snoopy/Snoopy.class.inc");
require_variable($id); // Course Module ID
require_variable($url); // url to fetch
@ -22,4 +21,4 @@
$content = resource_fetch_remote_file($cm, $url);
echo format_text($content->results,FORMAT_HTML);
?>
?>

View File

@ -28,7 +28,11 @@ if (!isset($CFG->resource_websearch)) {
if (!isset($CFG->resource_defaulturl)) {
set_config("resource_defaulturl", "http://");
}
}
if (!isset($CFG->resource_filterexternalpages)) {
set_config("resource_filterexternalpages", false);
}
$RESOURCE_WINDOW_OPTIONS = array("resizable", "scrollbars", "directories", "location",
"menubar", "toolbar", "status", "height", "width");
@ -162,7 +166,12 @@ function resource_get_coursemodule_info($coursemodule) {
}
function resource_fetch_remote_file ($cm, $url, $headers = "" ) {
// Snoopy is an HTTP client in PHP
/// Snoopy is an HTTP client in PHP
global $CFG;
require_once("$CFG->libdir/snoopy/Snoopy.class.inc");
$client = new Snoopy();
$client->agent = MAGPIE_USER_AGENT;
$client->read_timeout = MAGPIE_FETCH_TIME_OUT;

View File

@ -2,7 +2,6 @@
require_once("../../config.php");
require_once("lib.php");
require_once("../../lib/snoopy/Snoopy.class.inc");
require_variable($id); // Course Module ID
optional_variable($frameset, "");
@ -56,7 +55,7 @@
break;
case WEBLINK:
if ( $CFG->filterexternalpages ) {
if ($CFG->resource_filterexternalpages) {
$url = "fetch.php?id=$cm->id&url=$resource->reference";
} else {
$url = "$resource->reference";
@ -74,7 +73,7 @@
echo "<center><font size=-1>".text_to_html($resource->summary, true, false)."</font></center>";
} else {
if ( $CFG->filterexternalpages ) {
if ($CFG->resource_filterexternalpages) {
$url = "fetch.php?id=$cm->id&url=$resource->reference";
} else {
$url = "$resource->reference";
@ -92,7 +91,7 @@
require_once("../../files/mimetypes.php");
$inpopup = !empty($_GET["inpopup"]);
if ( $CFG->filterexternalpages ) {
if ($CFG->resource_filterexternalpages) {
if ($inpopup) {
$fetchingprefix = "$CFG->wwwroot/mod/resouce/fetch.php?id=$cm->id&url=";
} else {
@ -161,7 +160,7 @@
echo "<br />";
echo "<center><img class=\"resourceimage\" src=\"$fullurl\"></center>";
echo "<br />";
} elseif ( $resourcehtml and $CFG->filterexternalpages ) {
} else if ($resourcehtml and $CFG->resource_filterexternalpages) {
echo "<br />";
$content = resource_fetch_remote_file("$fetchingprefix$fullurl");
@ -184,7 +183,7 @@
$fullurl = "$CFG->wwwroot/file.php?file=/$course->id/$resource->reference";
}
if ( $resourcehtml and $CFG->filterexternalpages ) {
if ($resourcehtml and $CFG->resource_filterexternalpages) {
echo "<frame src=\"fetch.php?id=$cm->id&url=$fetchingprefix$fullurl\">";
} else {
echo "<frame src=\"$fullurl\">";