]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-7861 resource mod related xhtml strict fixes (student visible interface only)
authorskodak <skodak>
Sun, 7 Jan 2007 13:49:31 +0000 (13:49 +0000)
committerskodak <skodak>
Sun, 7 Jan 2007 13:49:31 +0000 (13:49 +0000)
lib/weblib.php
mod/resource/lib.php
mod/resource/type/directory/resource.class.php
mod/resource/type/file/resource.class.php
mod/resource/type/html/resource.class.php
mod/resource/type/text/resource.class.php
theme/standard/styles_fonts.css
theme/standard/styles_layout.css

index caeb3e378c2a360ec979239c5c751ec0489add88..958a50de1340adac173e3350049b504e034a9ffd 100644 (file)
@@ -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 "<form $CFG->frametarget method=\"get\" action=\"$CFG->wwwroot/course/mod.php\">".
+        return "<form $CFG->frametarget method=\"get\" action=\"$CFG->wwwroot/course/mod.php\" onsubmit=\"this.target='{$CFG->framename}'; return true\">".//hack to allow edit on framed resources
                "<fieldset class='invisiblefieldset'>".
                "<input type=\"hidden\" name=\"update\" value=\"$moduleid\" />".
                "<input type=\"hidden\" name=\"return\" value=\"true\" />".
index 7ad7334d237e5a7a726b35b08df6b774d9fb09d4..381ab6c79774168bae7bc5c60622cd9124cf5f03 100644 (file)
@@ -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&amp;id=".
                             $coursemodule->id.
                             "','resource$resource->id','$resource->popup');\"");
index 1a0072f9f5b8fab0eee7f92c21f4acb6c9a018c3..9be17062ad64b1d20c0cf0d8ed0c15b8e3df8531 100644 (file)
@@ -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 "<div align=\"right\"><img src=\"$CFG->pixpath/i/files.gif\" height=\"16\" width=\"16\" alt=\"\" />&nbsp;".
-            "<a href=\"$CFG->wwwroot/files/index.php?id={$course->id}&amp;wdir=/{$resource->reference}$subdir\">".
-            get_string("editfiles")."...</a></div>";
-    }
 
     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 '<table cellpadding="4" cellspacing="1" class="files">';
+    echo '<table cellpadding="4" cellspacing="1" class="files" summary="">';
     echo "<tr><th class=\"header name\" scope=\"col\">$strname</th>".
          "<th align=\"right\" colspan=\"2\" class=\"header size\" scope=\"col\">$strsize</th>".
          "<th align=\"right\" class=\"header date\" scope=\"col\">$strmodified</th>".
@@ -122,20 +119,20 @@ function display() {
 
         if ($icon == 'folder.gif') {
             echo '<tr class="folder">';
-            echo '<td nowrap="nowrap" class="name">';
+            echo '<td class="name">';
             echo "<a href=\"view.php?id={$cm->id}&amp;subdir=$subdir/$file\">";
             echo "<img src=\"$CFG->pixpath/f/$icon\" width=\"16\" height=\"16\" alt=\"$strfolder\" />&nbsp;$file</a>";
         } else {
             echo '<tr class="file">';
-            echo '<td nowrap="nowrap" class="name">';
+            echo '<td class="name">';
             link_to_popup_window($relativeurl, "resourcedirectory{$resource->id}", "<img src=\"$CFG->pixpath/f/$icon\" width=\"16\" height=\"16\" alt=\"$strfile\" />&nbsp;$file", 450, 600, '');
         }
         echo '</td>';
         echo '<td>&nbsp;</td>';
-        echo '<td align="right" nowrap="nowrap" class="size">';
+        echo '<td align="right" class="size">';
         echo $filesize;
         echo '</td>';
-        echo '<td align="right" nowrap="nowrap" class="date">';
+        echo '<td align="right" class="date">';
         echo userdate(filemtime("$CFG->dataroot/$relativepath/$file"), $strftime);
         echo '</td>';
         echo '</tr>';
index 254952927c120a48ae5135fd241c482577ac3a2b..f119239e4deaab158057df786271dfd2086d11c4 100644 (file)
@@ -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 '</script>';
 
         if (trim(strip_tags($resource->summary))) {
-            $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
         }
 
-        $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
+        $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
 
-        echo "<p>&nbsp;</p>";
-        echo '<p align="center">';
+        echo '<div class="popupnotice">';
         print_string('popupresource', 'resource');
         echo '<br />';
         print_string('popupresourcelink', 'resource', $link);
-        echo "</p>";
+        echo '</div>';
 
         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 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\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 '<div class="summary">'.format_text($resource->summary, FORMAT_HTML, $options).'</div>';
         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 '</div>';
         }
-        echo '</body></html>';
+        echo '</div></div></body></html>';
         exit;
     }
 
@@ -404,9 +406,9 @@ function display() {
         }
 
         if ($resourcetype == "image") {
-            echo "<center><p>";
+            echo '<div class="resourcecontent">';
             echo "<img title=\"".strip_tags(format_string($resource->name,true))."\" class=\"resourceimage\" src=\"$fullurl\" alt=\"\" />";
-            echo "</p></center>";
+            echo '</div>';
 
         } 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 '<div class="resourcecontent">';
             echo '<div class="mp3player" align="center">';
             echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
             echo '        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
@@ -434,10 +437,11 @@ function display() {
             echo '</embed>';
             echo '</object>';
             echo '</div>';
+            echo '</div>';
 
 
         } else if ($resourcetype == "mediaplayer") {
-            echo "<center><p>";
+            echo '<div class="resourcecontent">';
             echo '<object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"';
             echo '        codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
             echo '        standby="Loading Microsoft� Windows� Media Player components..." ';
@@ -458,11 +462,11 @@ function display() {
             echo ' pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/">';
             echo '</embed>';
             echo '</object>';
-            echo "</p></center>";
+            echo '</div>';
 
         } else if ($resourcetype == "quicktime") {
 
-            echo "<center><p>";
+            echo '<div class="resourcecontent">';
             echo '<object classid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
             echo '        codebase="http://www.apple.com/qtactivex/qtplugin.cab" ';
             echo '        height="450" width="600"';
@@ -478,16 +482,15 @@ function display() {
             echo ' pluginspage="http://quicktime.apple.com/">';
             echo '</embed>';
             echo '</object>';
-            echo "</p></center>";
+            echo '</div>';
         }
 
         if (trim($resource->summary)) {
-            $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
         }
 
         if ($inpopup) {
-            echo "<center><p>(<a href=\"$fullurl\">$strdirectlink</a>)</p></center>";
+            echo "<div class=\"popupnotice\">(<a href=\"$fullurl\">$strdirectlink</a>)</div>";
         } else {
             print_spacer(20,20);
             print_footer($course);
@@ -498,7 +501,7 @@ function display() {
             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 "<center><p>(<a href=\"$fullurl\">$fullurl</a>)</p></center>";
+            echo "<div class=\"popupnotice\">(<a href=\"$fullurl\">$fullurl</a>)</div>";
         }
         redirect($fullurl);
     }
index f1154178fa06b0f02a9da26b141dbeab28009dcc..d260beb077fe399ad60d9c31685dcafe059eee8b 100644 (file)
@@ -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<script type=\"text/javascript\">";
-                echo "\n<!--\n";
+                echo "\n//<![CDATA[\n";
                 echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
-                echo "\n-->\n";
+                echo "\n//]]>\n";
                 echo '</script>';
 
                 if (trim(strip_tags($resource->summary))) {
                     print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
                 }
 
-                $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
+                $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
 
-                echo "<p>&nbsp;</p>";
-                echo '<p align="center">';
+                echo '<div class="popupnotice">';
                 print_string('popupresource', 'resource');
                 echo '<br />';
                 print_string('popupresourcelink', 'resource', $link);
-                echo "</p>";
+                echo '</div>';
 
                 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 "<center><p><font size=\"1\">$strlastmodified: ".userdate($resource->timemodified)."</font></p></center>";
+            echo "<div class=\"modified\">$strlastmodified: ".userdate($resource->timemodified)."</div>";
 
             print_footer($course);
         }
index b4db05bc75cef69c851f448201226cb5aff37c27..e9e2b9dc5fe2bc131f52e8d50e80a7282a836102 100644 (file)
@@ -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<script type=\"text/javascript\">";
-                echo "\n<!--\n";
+                echo "\n//<![CDATA[\n";
                 echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
-                echo "\n-->\n";
+                echo "\n//]]>\n";
                 echo '</script>';
 
                 if (trim(strip_tags($resource->summary))) {
                     print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
                 }
 
-                $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
+                $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
 
-                echo "<p>&nbsp;</p>";
-                echo '<p align="center">';
+                echo '<div class="popupnotice">';
                 print_string('popupresource', 'resource');
                 echo '<br />';
                 print_string('popupresourcelink', 'resource', $link);
-                echo "</p>";
+                echo '</div>';
 
                 print_footer($course);
             }
@@ -160,7 +157,7 @@ function display() {
                     "center", "", "", "20");
 
             $strlastmodified = get_string("lastmodified");
-            echo "<center><p><font size=\"1\">$strlastmodified: ".userdate($resource->timemodified)."</font></p></center>";
+            echo "<div class=\"modified\">$strlastmodified: ".userdate($resource->timemodified)."</div>";
 
             print_footer($course);
         }
index bd5a3b65a938e8cb3e1235bef54fd3d35a4b15e5..77706574e4801fa7639f1728721f6b338948fa3f 100644 (file)
@@ -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;
index 023db96402b0738fc33aba388e69454565aa3337..8e2bf83f11cd45d25a1042711a5b55661514b06d 100644 (file)
@@ -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;