]> git.mjollnir.org Git - moodle.git/commitdiff
Lots of little cleanups and these new things:
authormoodler <moodler>
Sun, 8 Aug 2004 14:33:23 +0000 (14:33 +0000)
committermoodler <moodler>
Sun, 8 Aug 2004 14:33:23 +0000 (14:33 +0000)
  - 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

13 files changed:
mod/resource/db/mysql.php
mod/resource/db/postgres7.php
mod/resource/lib.php
mod/resource/restorelib.php
mod/resource/type/directory/resource.class.php
mod/resource/type/file/resource.class.php
mod/resource/type/html/html.html
mod/resource/type/html/resource.class.php
mod/resource/type/reference/reference.html [deleted file]
mod/resource/type/reference/resource.class.php [deleted file]
mod/resource/type/text/resource.class.php
mod/resource/type/text/text.html
mod/resource/version.php

index f9de3de57abf081f7a34d5077f2769e1d2470c7c..be5020bbde92a2f9bcda908e31ef9eb8c5498b1b 100644 (file)
@@ -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();
     }
 
index 7162c4390277a6f614f4e9eaaab5369273c92317..1caea28dd5aa7d080ff14ed8aa6830ba481a803a 100644 (file)
@@ -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();
     }
 
index 2100411589214b4e98564949ef1cdf411443593f..99b9006e9509f55588b99cb3a9ae6ff1a64737c7 100644 (file)
@@ -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');
     }
index 1f8ce293abea10c397b052f0f92c006e0adbdd0d..15c2d1f5b3290ad2ad97cfeb843abea5c1352f3d 100644 (file)
                     $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','',
                 $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);
index 97865ab01ec0b8571c14d5e4808969cdb3c1ea81..97ff68d7babb4dc22f40152e4dfdb438fe7f476d 100644 (file)
@@ -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);
     }
index 5b52e83daafe3477a57840358215a39728081056..5933fb0b5cb4342bec4423e64d389b456eddcc2c 100644 (file)
@@ -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();
index 53a279ea895388dfbf3e1aebe755e30612d1665b..ce32d708ea099013b629181e0e265a6913ebcb43 100644 (file)
     </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>
+
index 2e532fc1af6ea59488978e69f94b17c19c5503f8..6c5b69fabed1c47e1af78b13fcbd033f2facc04b 100644 (file)
@@ -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"]);
+
+    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
 
-    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));
 
-    print_footer($this->course);
+            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>&nbsp</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();
diff --git a/mod/resource/type/reference/reference.html b/mod/resource/type/reference/reference.html
deleted file mode 100644 (file)
index d6e1971..0000000
+++ /dev/null
@@ -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>
-
diff --git a/mod/resource/type/reference/resource.class.php b/mod/resource/type/reference/resource.class.php
deleted file mode 100644 (file)
index 178d4dd..0000000
+++ /dev/null
@@ -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>&nbsp</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();
-}
-
-
-}
-
-?>
index 4177537599f77d6e49b9e6e6db22bb36ef28cd2e..dd845bae06ead8577d59c09c3b2258af5734d179 100644 (file)
@@ -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));
-
-    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>";
+    $inpopup = !empty($_GET["inpopup"]);
+
+    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
+
+            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>&nbsp</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");
index ae2334de125dc8d39ec8805620752afd7c57a7c1..a639aa50ccda6f09ec872d520de489ef322a91a5 100644 (file)
         <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>
+
index 33a1bb93c4b0840d8b5f9d1a827556fc95f0b416..2d3595a7c180babcba99184a641da6dbc05f43a6 100644 (file)
@@ -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;