Permalink
Browse files

MDL-10021: change frame into object tag when display a Link Resource …

…with navigation bar, merged from 19
  • Loading branch information...
1 parent f95efc3 commit 58208f55119a44380c8bdc92f82a9868a5b303a4 jerome committed Oct 31, 2008
Showing with 57 additions and 17 deletions.
  1. +57 −17 mod/resource/type/file/resource.class.php
@@ -1,5 +1,6 @@
<?php // $Id$
+
/**
* Extend the base resource class for file resources
*
@@ -370,23 +371,62 @@ function display() {
/// Now check whether we need to display a frameset
$frameset = optional_param('frameset', '', PARAM_ALPHA);
- if (empty($frameset) and !$embedded and !$inpopup and ($resource->options == "frame") and empty($USER->screenreader)) {
- @header('Content-Type: text/html; charset=utf-8');
- echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
- echo "<html dir=\"ltr\">\n";
- echo '<head>';
- echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
- echo "<title>" . format_string($course->shortname) . ": ".strip_tags(format_string($resource->name,true))."</title></head>\n";
- echo "<frameset rows=\"$CFG->resource_framesize,*\">";
- echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;frameset=top\" title=\"".get_string('modulename','resource')."\"/>";
- if (!empty($localpath)) { // Show it like this so we interpose some HTML
- echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;inpopup=true\" title=\"".get_string('modulename','resource')."\"/>";
- } else {
- echo "<frame src=\"$fullurl\" title=\"".get_string('modulename','resource')."\"/>";
- }
- echo "</frameset>";
- echo "</html>";
- exit;
+ if (empty($frameset) and !$embedded and !$inpopup and ($resource->options == "frame") and empty($USER->screenreader)) {
+ ///Yahoo javascript libaries for updating embedded object size
+ require_js(array('yui_utilities'));
+ require_js(array('yui_container'));
+ require_js(array('yui_dom-event'));
+ require_js(array('yui_dom'));
+
+ ///Moodle Header and navigation bar
+ print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
+ $options = new object();
+ $options->para = false;
+ if (!empty($localpath)) { // Show some help
+ echo '<div align="right" class="helplink">';
+ link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
+ echo '</div>';
+ }
+ echo '</div></div>';
+
+ ///embedded HTML file into an object tag
+ echo '<p><object id="embeddedhtml" data="' . $fullurl . '" type="'.$mimetype.'" width="800" height="600">
+ alt : <a href="' . $fullurl . '">' . $fullurl . '</a>
+ </object></p>';
+
+ ///add some javascript in order to fit this object tag into the browser window
+ echo '<script type="text/javascript">
+ function resizeEmbeddedHtml() {
+ //calculate new embedded html height size
+ ';
+ if (!empty($resource->summary)) {
+ echo' objectheight = YAHOO.util.Dom.getViewportHeight() - 230;
+ ';
+ }
+ else {
+ echo' objectheight = YAHOO.util.Dom.getViewportHeight() - 120;
+ ';
+ }
+ echo ' //the object tag cannot be smaller than a human readable size
+ if (objectheight<200){
+ objectheight = 200;
+ }
+ //resize the embedded html object
+ YAHOO.util.Dom.setStyle("embeddedhtml", "height", objectheight+"px");
+ YAHOO.util.Dom.setStyle("embeddedhtml", "width", "100%");
+ }
+ resizeEmbeddedHtml();
+ YAHOO.widget.Overlay.windowResizeEvent.subscribe(resizeEmbeddedHtml);
+ </script>
+ ';
+
+ ///print the summary
+ if (!empty($resource->summary)) {
+ print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
+ }
+ echo "</body></html>";
+ exit;
+
}

0 comments on commit 58208f5

Please sign in to comment.