From ffaaf096a5e1b6319a7b4c3ec5beec06eee4af20 Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 8 Jan 2004 12:20:11 +0000 Subject: [PATCH] Fixed long-standing problem with popup windows. 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 | 2 ++ mod/resource/view.php | 77 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/lang/en/resource.php b/lang/en/resource.php index bf7f7fc080..858e35ea5c 100644 --- a/lang/en/resource.php +++ b/lang/en/resource.php @@ -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 File Manager.'; $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'; diff --git a/mod/resource/view.php b/mod/resource/view.php index 9297c34cbd..145c64b216 100644 --- a/mod/resource/view.php +++ b/mod/resource/view.php @@ -55,12 +55,43 @@ 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'; + + if (trim($resource->summary)) { + print_simple_box(text_to_html($resource->summary), "center"); + } + + $link = "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"; + + echo "

 

"; + echo '

'; + print_string('popupresource', 'resource'); + echo '
'; + print_string('popupresourcelink', 'resource', $link); + echo "

"; + + 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; @@ -101,12 +132,12 @@ $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"; } @@ -116,16 +147,49 @@ $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'; + + if (trim($resource->summary)) { + print_simple_box(text_to_html($resource->summary), "center"); + } + + $link = "id\" onClick=\"return openpopup('$relativeurl', 'resource$resource->id','$resource->alltext');\">$resource->name"; + + echo "

 

"; + echo '

'; + print_string('popupresource', 'resource'); + echo '
'; + print_string('popupresourcelink', 'resource', $link); + echo "

"; + + print_footer($course); + exit; + } + + /// Now check whether we need to display a frameset if (empty($frameset) and !$embedded and !$inpopup) { @@ -177,6 +241,7 @@ if (!$inpopup) { print_footer($course); } + } else { // Display the resource on it's own redirect($fullurl); } -- 2.39.5