From bfca8b177400bef95be56e42ad192a7c35cf07d7 Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 7 Jan 2007 13:49:31 +0000 Subject: [PATCH] MDL-7861 resource mod related xhtml strict fixes (student visible interface only) --- lib/weblib.php | 2 +- mod/resource/lib.php | 2 +- .../type/directory/resource.class.php | 37 +++++++++---------- mod/resource/type/file/resource.class.php | 35 ++++++++++-------- mod/resource/type/html/resource.class.php | 21 +++++------ mod/resource/type/text/resource.class.php | 21 +++++------ theme/standard/styles_fonts.css | 4 ++ theme/standard/styles_layout.css | 28 ++++++++++---- 8 files changed, 82 insertions(+), 68 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index caeb3e378c..958a50de13 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -3915,7 +3915,7 @@ function update_module_button($moduleid, $courseid, $string) { if (has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_MODULE, $moduleid))) { $string = get_string('updatethis', '', $string); - return "
frametarget method=\"get\" action=\"$CFG->wwwroot/course/mod.php\">". + return "frametarget method=\"get\" action=\"$CFG->wwwroot/course/mod.php\" onsubmit=\"this.target='{$CFG->framename}'; return true\">".//hack to allow edit on framed resources "
". "". "". diff --git a/mod/resource/lib.php b/mod/resource/lib.php index 7ad7334d23..381ab6c797 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -458,7 +458,7 @@ function resource_get_coursemodule_info($coursemodule) { if ($resource = get_record("resource", "id", $coursemodule->instance)) { if (!empty($resource->popup)) { - $info->extra = urlencode("target=\"resource$resource->id\" onclick=\"return ". + $info->extra = urlencode("onclick=\"this.target='resource$resource->id'; return ". "openpopup('/mod/resource/view.php?inpopup=true&id=". $coursemodule->id. "','resource$resource->id','$resource->popup');\""); diff --git a/mod/resource/type/directory/resource.class.php b/mod/resource/type/directory/resource.class.php index 1a0072f9f5..9be17062ad 100644 --- a/mod/resource/type/directory/resource.class.php +++ b/mod/resource/type/directory/resource.class.php @@ -20,24 +20,21 @@ function display() { require_once($CFG->libdir.'/filelib.php'); - $subdir = optional_param( 'subdir','' ); + $subdir = optional_param('subdir','', PARAM_PATH); + $resource->reference = clean_param($resource->reference, PARAM_PATH); - add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id); + $formatoptions = new object(); + $formatoptions->noclean = true; + add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id); if ($resource->reference) { - if (detect_munged_arguments($resource->reference, 0)) { - error("The filename contains illegal characters!"); - } $relativepath = "{$course->id}/{$resource->reference}"; } else { $relativepath = "{$course->id}"; } if ($subdir) { - if (detect_munged_arguments($subdir, 0)) { - error("The value for 'subdir' contains illegal characters!"); - } $relativepath = "$relativepath$subdir"; if (stripos($relativepath, 'backupdata') !== FALSE or stripos($relativepath, $CFG->moddata) !== FALSE) { error("Access not allowed!"); @@ -64,18 +61,18 @@ function display() { $pagetitle = strip_tags($course->shortname.': '.format_string($resource->name)); + $update = update_module_button($cm->id, $course->id, $this->strresource); + if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id))) { + $options = array('id'=>$course->id, 'wdir'=>'/'.$resource->reference.$subdir); + $editfiles = print_single_button("$CFG->wwwroot/files/index.php", $options, get_string("editfiles"), 'get', '', true); + $update = $editfiles.$update; + } print_header($pagetitle, $course->fullname, "$this->navigation $subnav", - "", "", true, update_module_button($cm->id, $course->id, $this->strresource), + "", "", true, $update, navmenu($course, $cm)); - if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id))) { - echo "
pixpath/i/files.gif\" height=\"16\" width=\"16\" alt=\"\" /> ". - "wwwroot/files/index.php?id={$course->id}&wdir=/{$resource->reference}$subdir\">". - get_string("editfiles")."...
"; - } if (trim(strip_tags($resource->summary))) { - $formatoptions->noclean = true; print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center"); print_spacer(10,10); } @@ -98,7 +95,7 @@ function display() { $strfolder = get_string("folder"); $strfile = get_string("file"); - echo ''; + echo '
'; echo "". "". "". @@ -122,20 +119,20 @@ function display() { if ($icon == 'folder.gif') { echo ''; - echo ''; - echo ''; echo ''; - echo ''; - echo ''; echo ''; diff --git a/mod/resource/type/file/resource.class.php b/mod/resource/type/file/resource.class.php index 254952927c..f119239e4d 100644 --- a/mod/resource/type/file/resource.class.php +++ b/mod/resource/type/file/resource.class.php @@ -217,6 +217,9 @@ function display() { $mimetype = mimeinfo("type", $resource->reference); $pagetitle = strip_tags($course->shortname.': '.format_string($resource->name)); + $formatoptions = new object(); + $formatoptions->noclean = true; + if ($resource->options != "frame") { if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // It's an image $resourcetype = "image"; @@ -328,18 +331,16 @@ function display() { echo ''; if (trim(strip_tags($resource->summary))) { - $formatoptions->noclean = true; print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "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->popup}');\">".format_string($resource->name,true).""; + $link = "wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true).""; - echo "

 

"; - echo '

'; + echo '

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

"; + echo '
'; print_footer($course); exit; @@ -348,7 +349,7 @@ function display() { /// Now check whether we need to display a frameset - $frameset = optional_param( '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 "\n"; @@ -379,6 +380,7 @@ function display() { if (!empty( $frameset ) and ($frameset == "top") ) { 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; echo '
'.format_text($resource->summary, FORMAT_HTML, $options).'
'; if (!empty($localpath)) { // Show some help @@ -386,7 +388,7 @@ function display() { 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 ''; } - echo ''; + echo ''; exit; } @@ -404,9 +406,9 @@ function display() { } if ($resourcetype == "image") { - echo "

"; + echo '

'; echo "name,true))."\" class=\"resourceimage\" src=\"$fullurl\" alt=\"\" />"; - echo "

"; + echo ''; } else if ($resourcetype == "mp3") { if (!empty($THEME->resource_mp3player_colors)) { @@ -418,6 +420,7 @@ function display() { } $c .= '&volText='.get_string('vol', 'resource').'&panText='.get_string('pan','resource'); $c = htmlentities($c); + echo '
'; echo '
'; echo ''; echo ''; echo '
'; + echo '
'; } else if ($resourcetype == "mediaplayer") { - echo "

"; + echo '

'; echo ''; echo ''; echo ''; - echo "

"; + echo ''; } else if ($resourcetype == "quicktime") { - echo "

"; + echo '

'; echo ''; echo ''; echo ''; - echo "

"; + echo ''; } if (trim($resource->summary)) { - $formatoptions->noclean = true; print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center"); } if ($inpopup) { - echo "

($strdirectlink)

"; + echo ""; } else { print_spacer(20,20); print_footer($course); @@ -498,7 +501,7 @@ function display() { echo ''; - echo "

($fullurl)

"; + echo ""; } redirect($fullurl); } diff --git a/mod/resource/type/html/resource.class.php b/mod/resource/type/html/resource.class.php index f1154178fa..d260beb077 100644 --- a/mod/resource/type/html/resource.class.php +++ b/mod/resource/type/html/resource.class.php @@ -90,13 +90,15 @@ function update_instance($resource) { function display() { global $CFG; + + $formatoptions = new object(); + $formatoptions->noclean = true; /// Are we displaying the course blocks? if ($this->resource->options == 'showblocks') { parent::display_course_blocks_start(); - $formatoptions->noclean = true; echo format_text($this->resource->alltext, FORMAT_HTML, $formatoptions, $this->course->id); parent::display_course_blocks_end(); @@ -112,9 +114,7 @@ function display() { $resource = $this->resource; $pagetitle = strip_tags($course->shortname.': '.format_string($resource->name)); - $formatoptions->noclean = true; - $inpopup_param = optional_param( 'inpopup','' ); - $inpopup = !empty($inpopup_param); + $inpopup = optional_param('inpopup', '', PARAM_BOOL); if ($resource->popup) { if ($inpopup) { /// Popup only @@ -130,23 +130,22 @@ function display() { navmenu($course, $cm)); echo "\n'; if (trim(strip_tags($resource->summary))) { print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "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->popup}');\">".format_string($resource->name,true).""; + $link = "wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true).""; - echo "

 

"; - echo '

'; + echo '

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

"; + echo '
'; print_footer($course); } @@ -160,7 +159,7 @@ function display() { print_simple_box(format_text($resource->alltext, FORMAT_HTML, $formatoptions, $course->id), "center", "", "", "20"); $strlastmodified = get_string("lastmodified"); - echo "

$strlastmodified: ".userdate($resource->timemodified)."

"; + echo "
$strlastmodified: ".userdate($resource->timemodified)."
"; print_footer($course); } diff --git a/mod/resource/type/text/resource.class.php b/mod/resource/type/text/resource.class.php index b4db05bc75..e9e2b9dc5f 100644 --- a/mod/resource/type/text/resource.class.php +++ b/mod/resource/type/text/resource.class.php @@ -85,14 +85,14 @@ function update_instance($resource) { function display() { global $CFG; + $formatoptions = new object(); + $formatoptions->noclean = true; /// Are we displaying the course blocks? if ($this->resource->options == 'showblocks') { parent::display_course_blocks_start(); - $formatoptions->noclean = true; - if (trim(strip_tags($this->resource->summary))) { echo format_text($this->resource->summary, FORMAT_MOODLE, $formatoptions, $this->course->id); } @@ -110,9 +110,7 @@ function display() { $resource = $this->resource; $pagetitle = strip_tags($course->shortname.': '.format_string($resource->name)); - $formatoptions->noclean = true; - $inpopup_param = optional_param( 'inpopup', '' ); - $inpopup = !empty($inpopup_param); + $inpopup = optional_param('inpopup', '', PARAM_BOOL); if ($resource->popup) { if ($inpopup) { /// Popup only @@ -129,23 +127,22 @@ function display() { navmenu($course, $cm)); echo "\n'; if (trim(strip_tags($resource->summary))) { print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "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->popup}');\">".format_string($resource->name,true).""; + $link = "wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true).""; - echo "

 

"; - echo '

'; + echo '

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

"; + echo '
'; print_footer($course); } @@ -160,7 +157,7 @@ function display() { "center", "", "", "20"); $strlastmodified = get_string("lastmodified"); - echo "

$strlastmodified: ".userdate($resource->timemodified)."

"; + echo "
$strlastmodified: ".userdate($resource->timemodified)."
"; print_footer($course); } diff --git a/theme/standard/styles_fonts.css b/theme/standard/styles_fonts.css index bd5a3b65a9..77706574e4 100644 --- a/theme/standard/styles_fonts.css +++ b/theme/standard/styles_fonts.css @@ -775,6 +775,10 @@ body#mod-forum-index .generalbox .cell { font-size:0.8em; } +.mod-resource .modified { + font-size:0.6em; +} + .ims-nav-dimmed, .ims-nav-button { font-size:0.8em; diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 023db96402..8e2bf83f11 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -449,12 +449,16 @@ table.navbar { width: 100%; } -.navbar .navbutton form { +.navbar .navbutton { + margin-top: 3px; float: left; } -.navbar .navbutton { - margin-top: 3px; +.navbar .navbutton div, +.navbar .navbutton form { + display:inline; + margin:0px; + padding:0px; } .navbar .breadcrumb { @@ -2369,14 +2373,24 @@ body#mod-quiz-report .controls { text-align: center; } -/* .navbutton form { - display: inline; - } */ - /*** *** Modules: Resource ***/ +#mod-resource-view .resourcecontent { + text-align:center; + margin:20px; +} + +.mod-resource .modified { + text-align:center; +} + +.mod-resource .popupnotice { + text-align:center; + margin:40px; +} + .ims-nav-bar { position: relative; padding:0.1em; -- 2.39.5
$strname$strsize$strmodified
'; + echo ''; echo "id}&subdir=$subdir/$file\">"; echo "pixpath/f/$icon\" width=\"16\" height=\"16\" alt=\"$strfolder\" /> $file"; } else { echo '
'; + echo ''; link_to_popup_window($relativeurl, "resourcedirectory{$resource->id}", "pixpath/f/$icon\" width=\"16\" height=\"16\" alt=\"$strfile\" /> $file", 450, 600, ''); } echo ' '; + echo ''; echo $filesize; echo ''; + echo ''; echo userdate(filemtime("$CFG->dataroot/$relativepath/$file"), $strftime); echo '