From: moodler Date: Tue, 2 Nov 2004 12:45:04 +0000 (+0000) Subject: Copied from STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8e73aa97055a342951553953682f1729ccb68731;p=moodle.git Copied from STABLE --- diff --git a/files/index.php b/files/index.php index 35c5de5c53..3ba59a1f6d 100644 --- a/files/index.php +++ b/files/index.php @@ -8,6 +8,7 @@ // USER is a persistent variable using sessions require("../config.php"); + require("mimetypes.php"); $id = required_param('id', PARAM_INT); $file = optional_param('file', '', PARAM_PATH); @@ -15,6 +16,15 @@ $action = optional_param('action', '', PARAM_ACTION); $name = optional_param('name', '', PARAM_FILE); $oldname = optional_param('oldname', '', PARAM_FILE); + $choose = optional_param('choose', '', PARAM_CLEAN); + + + if ($choose) { + if (count(explode('.', $choose)) != 2) { + error('Incorrect format for choose parameter'); + } + } + if (! $course = get_record("course", "id", $id) ) { error("That's an invalid course id"); @@ -27,21 +37,30 @@ } function html_footer() { - global $course; - echo ""; - print_footer($course); + + global $course, $choose; + + if ($choose) { + echo ""; + } else { + echo ""; + print_footer($course); + } } function html_header($course, $wdir, $formfield=""){ + global $CFG, $THEME, $ME, $choose; - global $CFG; + if (! $site = get_site()) { + error("Invalid site!"); + } - if ($course->id == SITEID) { + if ($course->id == $site->id) { $strfiles = get_string("sitefiles"); } else { $strfiles = get_string("files"); } - + if ($wdir == "/") { $fullnav = "$strfiles"; } else { @@ -52,29 +71,65 @@ for ($i=1; $i<$numdirs-1; $i++) { $navigation .= " -> "; $link .= "/".urlencode($dirs[$i]); - $navigation .= "id&wdir=$link\">".$dirs[$i].""; + $navigation .= "id&wdir=$link&choose=$choose\">".$dirs[$i].""; } - $fullnav = "id&wdir=/\">$strfiles $navigation -> ".$dirs[$numdirs-1]; + $fullnav = "id&wdir=/&choose=$choose\">$strfiles $navigation -> ".$dirs[$numdirs-1]; } - if ($course->id == SITEID) { - print_header("$course->shortname: $strfiles", "$course->fullname", - "admin/index.php\">".get_string("administration"). - " -> $fullnav", $formfield); - print_heading(get_string("publicsitefileswarning"), "center", 2); + if ($choose) { + print_header(); + + $chooseparts = explode('.', $choose); + + ?> + + + ', '»', "$course->shortname -> $fullnav"); + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'; + + if ($course->id == $site->id) { + print_heading(get_string("publicsitefileswarning"), "center", 2); + } } else { - print_header("$course->shortname: $strfiles", "$course->fullname", - "id\">$course->shortname". - " -> $fullnav", $formfield); + + if ($course->id == $site->id) { + print_header("$course->shortname: $strfiles", "$course->fullname", + "admin/index.php\">".get_string("administration"). + " -> $fullnav", $formfield); + + print_heading(get_string("publicsitefileswarning"), "center", 2); + + } else { + print_header("$course->shortname: $strfiles", "$course->fullname", + "id\">$course->shortname". + " -> $fullnav", $formfield); + } } - echo ""; + + echo "
"; echo ""; echo "
"; + } + if (! $basedir = make_upload_directory("$course->id")) { error("The site administrator needs to fix the file permissions"); } @@ -83,7 +138,6 @@ // End of configuration and access control - require("mimetypes.php"); if (!$wdir) { $wdir="/"; @@ -129,6 +183,7 @@ echo "

$struploadafile ($strmaxsize) --> $wdir"; echo "
"; echo "
"; + echo ' '; echo " "; echo " "; echo " "; @@ -139,6 +194,7 @@ echo "
"; echo "
"; echo "
"; + echo ' '; echo " "; echo " "; echo " "; @@ -229,6 +285,7 @@ echo "

$strrenamefileto:"; echo "
"; echo ""; + echo ' '; echo " "; echo " "; echo " "; @@ -239,6 +296,7 @@ echo ""; echo ""; echo "
"; + echo ' '; echo " "; echo " "; echo " "; @@ -268,6 +326,7 @@ echo "

$strcreatefolder:"; echo "
"; echo ""; + echo ' '; echo " "; echo " "; echo " "; @@ -277,6 +336,7 @@ echo ""; echo ""; echo "
"; + echo ' '; echo " "; echo " "; echo " "; @@ -312,6 +372,7 @@ echo "
"; echo ""; + echo ' '; echo " "; echo " "; echo " "; @@ -323,6 +384,7 @@ echo ""; echo ""; echo "
"; + echo ' '; echo " "; echo " "; echo " "; @@ -368,6 +430,7 @@ echo "

".get_string("whattocallzip"); echo "
"; echo ""; + echo ' '; echo " "; echo " "; echo " "; @@ -377,6 +440,7 @@ echo ""; echo ""; echo "
"; + echo ' '; echo " "; echo " "; echo " "; @@ -406,6 +470,7 @@ } echo "
"; + echo ' '; echo " "; echo " "; echo " "; @@ -453,6 +518,7 @@ echo "
"; } echo "

"; + echo ' '; echo " "; echo " "; echo " "; @@ -593,6 +659,7 @@ function displaydir ($wdir) { global $basedir; global $id; global $USER, $CFG; + global $choose; $fullpath = $basedir.$wdir; @@ -626,9 +693,11 @@ function displaydir ($wdir) { $strunzip = get_string("unzip"); $strlist = get_string("list"); $strrestore= get_string("restore"); + $strchoose = get_string("choose"); echo ""; + echo ''; echo "
"; echo ""; echo ""; @@ -660,10 +729,10 @@ function displaydir ($wdir) { echo ""; print_cell("center", ""); - print_cell("left", "pixpath/f/folder.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"Folder\" />".htmlspecialchars($dir).""); + print_cell("left", "pixpath/f/folder.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"Folder\" />".htmlspecialchars($dir).""); print_cell("right", "$filesize"); print_cell("right", $filedate); - print_cell("right", "$strrename"); + print_cell("right", "$strrename"); echo ""; } @@ -683,6 +752,12 @@ function displaydir ($wdir) { $fileurlsafe = rawurlencode($fileurl); $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); + if (substr($fileurl,0,1) == '/') { + $selectfile = substr($fileurl,1); + } else { + $selectfile = $fileurl; + } + echo ""; print_cell("center", ""); @@ -704,18 +779,25 @@ function displaydir ($wdir) { $file_size = filesize($filename); print_cell("right", display_size($file_size)); print_cell("right", $filedate); + + if ($choose) { + $edittext = "$strchoose "; + } else { + $edittext = ''; + } + + if ($icon == "text.gif" || $icon == "html.gif") { - $edittext = "$stredit"; + $edittext .= "$stredit"; } else if ($icon == "zip.gif") { - $edittext = "sesskey\">$strunzip "; - $edittext .= "sesskey\">$strlist "; + $edittext .= "sesskey&choose=$choose\">$strunzip "; + $edittext .= "sesskey&choose=$choose\">$strlist "; if (!empty($CFG->backup_version) and isteacheredit($id)) { - $edittext .= "sesskey\">$strrestore "; + $edittext .= "sesskey&choose=$choose\">$strrestore "; } - } else { - $edittext = ""; } - print_cell("right", "$edittext $strrename"); + + print_cell("right", "$edittext $strrename"); echo ""; } @@ -745,6 +827,7 @@ function displaydir ($wdir) { echo "
"; if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) { echo ""; + echo ' '; echo " "; echo " "; echo " "; @@ -754,6 +837,7 @@ function displaydir ($wdir) { } echo ""; echo ""; + echo ' '; echo " "; echo " "; echo " ";