From: jerome Date: Thu, 8 Jan 2009 04:27:44 +0000 (+0000) Subject: resource: MDL-10021 upload file resource: change "keep navigation visible" into selec... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4d800fd210fe3143a57898426934d00cda96c44f;p=moodle.git resource: MDL-10021 upload file resource: change "keep navigation visible" into select box (No, yes with frame, yes without frame) --- diff --git a/lang/en_utf8/help/resource/frameifpossible.html b/lang/en_utf8/help/resource/frameifpossible.html index 05b1ee63be..8950478f19 100644 --- a/lang/en_utf8/help/resource/frameifpossible.html +++ b/lang/en_utf8/help/resource/frameifpossible.html @@ -1,6 +1,8 @@ -

Embedding files in a frame

-

This option will allow the file to be displayed in a frame, so that the Moodle navigation remains on the page in an upper frame.

+

Embedding files

+

This option will allow the file to be displayed in a frame or to be embedded within a navigable page, so that the Moodle navigation remains on the top of the page.

Note that this option is normally not necessary for media types such as movies, audio files and flash files, as without this option turned on they will be embedded within a navigable page.

-

Note also that the use of frames can break accessibility, and so this option will be completely ignored if the user has chosen the "Screenreader" option in their profile.

\ No newline at end of file +

Note also that the use of frame can break accessibility, and so this option will be completely ignored if the user has chosen the "Screenreader" option in their profile.

+ +

Note finally that the use of frame isn't XHTML strict. However the "without frame" option could break some Moodle themes. In conclusion, if the resource is well displayed without frame, prefer this option to the "with frame" option.

\ No newline at end of file diff --git a/lang/en_utf8/resource.php b/lang/en_utf8/resource.php index 50cffef0de..04ec1c0e31 100644 --- a/lang/en_utf8/resource.php +++ b/lang/en_utf8/resource.php @@ -59,6 +59,9 @@ $string['imspackageloaded'] = 'Package loaded'; $string['invalidassignment'] = 'incorrect assignment'; $string['invalidid'] = 'Resource ID was incorrect'; $string['keepnavigationvisible'] = 'Keep page navigation visible on the same page'; +$string['keepnavigationvisibleno'] = 'No'; +$string['keepnavigationvisibleyesframe'] = 'Yes, with frame'; +$string['keepnavigationvisibleyesobject'] = 'Yes, without frame'; $string['localfile'] = 'Local file'; $string['localfilechoose'] = 'Choose a local file (CD-ROM)'; $string['localfilehelp'] = 'Help displaying local files'; diff --git a/mod/resource/type/file/resource.class.php b/mod/resource/type/file/resource.class.php index 53385c79e9..cadd975e12 100644 --- a/mod/resource/type/file/resource.class.php +++ b/mod/resource/type/file/resource.class.php @@ -153,7 +153,17 @@ class resource_file extends resource_base { if (empty($resource->framepage)) { $resource->options = ''; } else { - $resource->options = 'frame'; + switch ($resource->framepage) { + case 1: + $resource->options = 'frame'; + break; + case 2: + $resource->options = 'objectframe'; + break; + default: + $resource->options = ''; + break; + } } unset($resource->framepage); $resource->popup = ''; @@ -376,73 +386,94 @@ class resource_file extends resource_base { /// 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)) { - ///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 - $navigation = build_navigation($this->navlinks, $cm); - print_header($pagetitle, $course->fullname, $navigation, "", "", 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 ''; - } - echo ''; - - ///embedded file into iframe if the resource is on another domain - /// - ///This case is not XHTML strict but there is no alternative - ///The object tag alternative is XHTML strict, however IE6-7 displays a blank object on accross domain by default, - ///so we decided to use iframe for accross domain MDL-10021 - if (!stristr($fullurl,$CFG->wwwroot)) { - echo '

'; - } - else { - ///embedded HTML file into an object tag - echo '

- alt : ' . $fullurl . ' -

'; - } - ///add some javascript in order to fit this object tag into the browser window - echo ' - '; - - ///print the summary - if (!empty($resource->summary)) { - print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center"); - } - echo ""; - exit; + resizeEmbeddedHtml(); + YAHOO.widget.Overlay.windowResizeEvent.subscribe(resizeEmbeddedHtml); + //]]> + + '; + + ///print the summary + if (!empty($resource->summary)) { + print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center"); + } + echo ""; + exit; + } else { + /// display the resource into a frame tag + @header('Content-Type: text/html; charset=utf-8'); + echo "\n"; + echo "\n"; + echo ''; + echo ''; + echo "" . format_string($course->shortname) . ": ".strip_tags(format_string($resource->name,true))."\n"; + echo "resource_framesize,*\">"; + echo "id}&type={$resource->type}&frameset=top\" title=\"".get_string('modulename','resource')."\"/>"; + if (!empty($localpath)) { // Show it like this so we interpose some HTML + echo "id}&type={$resource->type}&inpopup=true\" title=\"".get_string('modulename','resource')."\"/>"; + } else { + echo ""; + } + echo ""; + echo ""; + exit; + } } @@ -732,8 +763,15 @@ class resource_file extends resource_base { } } else { $defaults['windowpopup'] = 0; + /// set default value of 'keep navigation visible' if (array_key_exists('options', $defaults)) { - $defaults['framepage'] = ($defaults['options']=='frame'); + if ($defaults['options']=='frame') { + $defaults['framepage'] = 1; + } else if ($defaults['options']=='objectframe') { + $defaults['framepage'] = 2; + } else { + $defaults['framepage'] = 0; + } } } /// load up any stored parameters @@ -789,7 +827,8 @@ class resource_file extends resource_base { $mform->setDefault('windowpopup', !empty($CFG->resource_popup)); $mform->disabledIf('windowpopup', 'forcedownload', 'checked'); - $mform->addElement('checkbox', 'framepage', get_string('keepnavigationvisible', 'resource')); + $navoptions = array(0 => get_string('keepnavigationvisibleno','resource'), 1 => get_string('keepnavigationvisibleyesframe','resource'), 2 => get_string('keepnavigationvisibleyesobject','resource')); + $mform->addElement('select', 'framepage', get_string('keepnavigationvisible', 'resource'), $navoptions); $mform->setHelpButton('framepage', array('frameifpossible', get_string('keepnavigationvisible', 'resource'), 'resource')); $mform->setDefault('framepage', 0);