From: julmis Date: Fri, 26 Mar 2004 09:29:44 +0000 (+0000) Subject: Cleaning up javascript and trying to make code less X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=cfa3f2622ea8fec034fd83fc9700f4e229c581d8;p=moodle.git Cleaning up javascript and trying to make code less memory consuming. --- diff --git a/lib/editor/coursefiles.php b/lib/editor/coursefiles.php index e78909852c..ba572a2d49 100644 --- a/lib/editor/coursefiles.php +++ b/lib/editor/coursefiles.php @@ -4,7 +4,7 @@ // This file is a hack to files/index.php that removes // the headers and adds some controls so that images -// can be selected within the Richtext editor. +// can be selected within the Richtext editor. // All the Moodle-specific stuff is in this top section // Configuration and access control occurs here. @@ -33,7 +33,7 @@ function html_footer() { echo ""; } - + function html_header($course, $wdir, $formfield=""){ global $CFG; @@ -41,7 +41,7 @@ if (! $site = get_site()) { error("Invalid site!"); } - + ?> @@ -49,28 +49,26 @@ - + filelist); print_simple_box_end(); echo "
"; - notice_yesno (get_string("deletecheckfiles"), + notice_yesno (get_string("deletecheckfiles"), "".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&action=delete&confirm=1", "".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&action=cancel"); } else { @@ -324,7 +322,7 @@ echo "Error: could not rename $oldname to $name"; } displaydir($wdir); - + } else { $strrename = get_string("rename"); $strcancel = get_string("cancel"); @@ -362,7 +360,7 @@ echo "Error: could not create $name"; } displaydir($wdir); - + } else { $strcreate = get_string("create"); $strcancel = get_string("cancel"); @@ -396,7 +394,7 @@ fputs($fileptr, stripslashes($text)); fclose($fileptr); displaydir($wdir); - + } else { $streditfile = get_string("edit", "", "$file"); $fileptr = fopen($basedir.$file, "r"); @@ -435,7 +433,7 @@ echo ""; echo ""; - if ($usehtmleditor) { + if ($usehtmleditor) { print_richedit_javascript("form", "text", "yes"); } @@ -469,7 +467,7 @@ } clearfilelist(); displaydir($wdir); - + } else { html_header($course, $wdir, "form.name"); @@ -545,7 +543,7 @@ } echo ""; } - + } else { // Use external unzip program print_simple_box_start("center"); echo "
";
@@ -614,7 +612,7 @@
             }
             html_footer();
             break;
-            
+
         case "cancel";
             clearfilelist();
 
@@ -629,13 +627,13 @@
 /// FILE FUNCTIONS ///////////////////////////////////////////////////////////
 
 
-function fulldelete($location) { 
+function fulldelete($location) {
     if (is_dir($location)) {
         $currdir = opendir($location);
-        while ($file = readdir($currdir)) { 
+        while ($file = readdir($currdir)) {
             if ($file <> ".." && $file <> ".") {
                 $fullfile = $location."/".$file;
-                if (is_dir($fullfile)) { 
+                if (is_dir($fullfile)) {
                     if (!fulldelete($fullfile)) {
                         return false;
                     }
@@ -643,9 +641,9 @@ function fulldelete($location) {
                     if (!unlink($fullfile)) {
                         return false;
                     }
-                } 
+                }
             }
-        } 
+        }
         closedir($currdir);
         if (! rmdir($location)) {
             return false;
@@ -693,14 +691,14 @@ function printfilelist($filelist) {
             echo "pixpath/f/folder.gif\" height=\"16\" width=\"16\"> $file
"; $subfilelist = array(); $currdir = opendir($basedir.$file); - while ($subfile = readdir($currdir)) { + while ($subfile = readdir($currdir)) { if ($subfile <> ".." && $subfile <> ".") { $subfilelist[] = $file."/".$subfile; } } printfilelist($subfilelist); - } else { + } else { $icon = mimeinfo("icon", $file); echo "pixpath/f/$icon\" height=\"16\" width=\"16\"> $file
"; } @@ -747,7 +745,7 @@ function displaydir ($wdir) { if ($file == "." || $file == "..") { continue; } - + if (is_dir($fullpath."/".$file)) { $dirlist[] = $file; } else { @@ -776,7 +774,7 @@ function displaydir ($wdir) { echo "
"; - echo ""; + echo "
"; if ($wdir == "/") { $wdir = ""; @@ -790,7 +788,7 @@ function displaydir ($wdir) { print "wwwroot/lib/editor/images/folderup.gif\" height=\"14\" width=\"24\" border=\"0\" ALT=\"Move up\">"; print "\n"; } - + $count = 0; if (!empty($dirlist)) { @@ -803,7 +801,7 @@ function displaydir ($wdir) { $fileurl = rawurlencode($wdir."/".$dir); $filesafe = rawurlencode($dir); $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); - + echo ""; if ($usecheckboxes) { @@ -812,7 +810,7 @@ function displaydir ($wdir) { print_cell("left", "pixpath/f/folder.gif\" height=16 width=16 border=0 alt=\"folder\">".htmlspecialchars($dir).""); print_cell("right", " "); print_cell("right", $filedate); - + echo ""; } } @@ -831,7 +829,7 @@ function displaydir ($wdir) { $filesafe = rawurlencode($file); $fileurlsafe = rawurlencode($fileurl); $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); - + $dimensions = get_image_size($filename); if($dimensions) { $imgwidth = $dimensions[0]; @@ -852,25 +850,14 @@ function displaydir ($wdir) { } else { $ffurl = "/file.php?file=/$id$fileurl"; } - link_to_popup_window ($ffurl, "display", - "pixpath/f/$icon\" height=16 width=16 border=0 align=\"absmiddle\" alt=\"$strfile\">", + link_to_popup_window ($ffurl, "display", + "pixpath/f/$icon\" height=16 width=16 border=0 align=\"absmiddle\" alt=\"$strfile\">", 480, 640); $file_size = filesize($filename); - ?> - - $file"; + + echo "wwwroot.$ffurl."',"; + echo " isize: '".$file_size."', itype: '".$imgtype."', iwidth: '".$imgwidth."',"; + echo " iheight: '".$imgheight."', imodified: '".$filedate."' })\" href=\"#\">$file"; echo ""; if ($icon == "zip.gif") { @@ -881,7 +868,7 @@ function displaydir ($wdir) { } print_cell("right", "$edittext "); print_cell("right", $filedate); - + echo ""; } } @@ -891,7 +878,7 @@ function displaydir ($wdir) { $wdir = "/"; } - echo "
"; + echo "
"; echo "
"; echo ""; echo " ";