]> git.mjollnir.org Git - moodle.git/commitdiff
A few rearrangments in the new code for filtered external pages
authormoodler <moodler>
Fri, 28 Nov 2003 02:11:02 +0000 (02:11 +0000)
committermoodler <moodler>
Fri, 28 Nov 2003 02:11:02 +0000 (02:11 +0000)
lang/en/resource.php
mod/resource/config.html
mod/resource/fetch.php
mod/resource/lib.php
mod/resource/view.php

index a41815c8c11aa8937d8feccdb99a51175d747436..3518c4bb18d73be9fae6b245ba044e3b7f7d4786 100644 (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';
index 41b9234e7d0379f696bc8e65d5ad41db052fc3db..815a724ee401691f0d7ffc81a832f25d431f497d 100644 (file)
     <?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>
index a9667ede36892987ad2ba2ebd11e232d4596fc9b..e5722cffc79cc9a2ef9f2e7360b0473fa96e95d1 100644 (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);
-?>
\ No newline at end of file
+?>
index c17b19411a8dc0edbcad1a4eb4fd42b1d8d39987..d4ef05915bf2f7e9a2a798c034b88d2e828d1b93 100644 (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;
index 5f9264b2a2fa725ea56cd41226aacbf487978ddd..186425ccb8c30cf400015b8123a6e3c43d9b83c4 100644 (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 {
                     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");
                     $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\">";