]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed long-standing problem with popup windows.
authormoodler <moodler>
Thu, 8 Jan 2004 12:20:11 +0000 (12:20 +0000)
committermoodler <moodler>
Thu, 8 Jan 2004 12:20:11 +0000 (12:20 +0000)
Now when you go to the using the navbar, they popup and leave
some navigation behind.

Also fixed a recent bug with embedded images

lang/en/resource.php
mod/resource/view.php

index bf7f7fc080ddb479876981fd104156193b03954c..858e35ea5cfc878cabf9724b9071ffff45734d7c 100644 (file)
@@ -46,6 +46,8 @@ $string['newwindowopen'] = 'Display this resource in a new popup window';
 $string['note'] = 'Note';
 $string['notefile'] = 'To upload more files into the course (so they appear in this list) use the <a href=\"$a\">File Manager</a>.';
 $string['notypechosen'] = 'You need to choose a type.  Use your back button to go back and retry.';
+$string['popupresource'] = 'This resource should appear in a popup window.';
+$string['popupresourcelink'] = 'If it didn\'t, click here: $a';
 $string['resourcetype'] = 'Type of resource';
 $string['resourcetype1'] = 'Reference';
 $string['resourcetype2'] = 'Web Page';
index 9297c34cbd5d854d8363d363e5dea6fa588306d0..145c64b21626ecca1552d5e84777baf9b6577695 100644 (file)
             break;
 
         case WEBLINK:
+            add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
+
+            $inpopup = !empty($_GET["inpopup"]);
+
+            if ($resource->alltext and !$inpopup) {    /// Make a page and a pop-up window
+                print_header($pagetitle, "$course->fullname", "$navigation $resource->name", "", "", true, 
+                             update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
+
+                echo "\n<script language=\"Javascript\">";
+                echo "\n<!--\n";
+                echo "openpopup('/mod/resource/view.php?inpopup=true&id=$cm->id',".
+                     "'resource$resource->id','$resource->alltext');\n";
+                echo "\n-->\n";
+                echo '</script>';
+
+                if (trim($resource->summary)) {
+                    print_simple_box(text_to_html($resource->summary), "center");
+                }
+
+                $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&id=$cm->id\" target=\"resource$resource->id\" onClick=\"return openpopup('/mod/resource/view.php?inpopup=true&id=$cm->id', 'resource$resource->id','$resource->alltext');\">$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($course);
+                die;
+            }
+
             if ($CFG->resource_filterexternalpages) {
                 $url = "fetch.php?id=$cm->id&url=$resource->reference";
             } else {
                 $url = "$resource->reference";
             }
-            add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
             redirect($url, "", 0);
             break;
 
             $resourcetype = "";
             $embedded = false;
 
-            $imagetypes = array('image/gif','image/jpg','image/png');
-            if (in_array(mimeinfo("type", $fullurl), $imagetypes)) {  // It's an image
+            $imagetypes = array('image/gif','image/jpeg','image/png');
+            if (in_array(mimeinfo("type", $resource->reference), $imagetypes)) {  // It's an image
                 $embedded = true;
                 $resourcetype = "image";
 
-            } else if (mimeinfo("icon", $fullurl) == "html.gif") {    // It's a web page
+            } else if (mimeinfo("icon", $resource->reference) == "html.gif") {    // It's a web page
                 $resourcetype = "html";
             }
 
             $inpopup = !empty($_GET["inpopup"]);
 
             if ($CFG->slasharguments) {
-                $fullurl = "$CFG->wwwroot/file.php/$course->id/$resource->reference";
+                $relativeurl = "/file.php/$course->id/$resource->reference";
             } else {
-                $fullurl = "$CFG->wwwroot/file.php?file=/$course->id/$resource->reference";
+                $relativeurl = "/file.php?file=/$course->id/$resource->reference";
             }
+            $fullurl = "$CFG->wwwroot$relativeurl";
 
             if ($CFG->resource_filterexternalpages and $resourcetype == "html") {
                 $fullurl = "$CFG->wwwroot/mod/resource/fetch.php?id=$cm->id&url=$fullurl";
             }
 
 
+            /// Check whether this is supposed to be a popup, but was called directly
+
+            if ($resource->alltext and !$inpopup) {    /// Make a page and a pop-up window
+                add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
+
+                print_header($pagetitle, "$course->fullname", "$navigation $resource->name", "", "", true, 
+                             update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
+
+                echo "\n<script language=\"Javascript\">";
+                echo "\n<!--\n";
+                echo "openpopup('$relativeurl','resource$resource->id','$resource->alltext');\n";
+                echo "\n-->\n";
+                echo '</script>';
+
+                if (trim($resource->summary)) {
+                    print_simple_box(text_to_html($resource->summary), "center");
+                }
+
+                $link = "<a href=\"$fullurl\" target=\"resource$resource->id\" onClick=\"return openpopup('$relativeurl', 'resource$resource->id','$resource->alltext');\">$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($course);
+                exit;
+            }
+
+
             /// Now check whether we need to display a frameset
 
             if (empty($frameset) and !$embedded and !$inpopup) { 
                 if (!$inpopup) {
                     print_footer($course);
                 }
+
             } else {              // Display the resource on it's own
                 redirect($fullurl);
             }