From 5f6503a8aa017f86cdb8090f3a9f891302a299aa Mon Sep 17 00:00:00 2001 From: Julian Prud'homme Date: Thu, 1 Feb 2007 11:46:48 +0100 Subject: [PATCH] [svn r11045] new upload form (with formvalidator) with upload progress bar --- main/work/work.php | 141 +++++++++++++-------------------------------- 1 file changed, 41 insertions(+), 100 deletions(-) diff --git a/main/work/work.php b/main/work/work.php index 56e13ea2de..10e4d2c894 100644 --- a/main/work/work.php +++ b/main/work/work.php @@ -23,7 +23,7 @@ * @author Patrick Cool , Ghent University - ability for course admins to specify wether uploaded documents are visible or invisible by default. * @author Roan Embrechts, code refactoring and virtual course support * @author Frederic Vauthier, directories management -* @version $Id: work.php 11011 2007-01-30 11:51:14Z elixir_julian $ +* @version $Id: work.php 11045 2007-02-01 10:46:48Z elixir_julian $ * * @todo refactor more code into functions, use quickforms, coding standards, ... */ @@ -795,125 +795,66 @@ if ($_POST['submitWork'] && $succeed &&!$id) //last value is to check this is no } } - echo "
\n", - "\n"; - + require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); + require_once (api_get_path(LIBRARY_PATH).'fileDisplay.lib.php'); + + $form = new FormValidator('form','POST',$_SERVER['PHP_SELF']."?curdirpath=$cur_dir_path&origin=$origin",'','enctype="multipart/form-data"'); + if(!empty($error_message)) Display::display_error_message($error_message); if ($submitGroupWorkUrl) // For user comming from group space to publish his work { $realUrl = str_replace ($_configuration['root_sys'], $_configuration['root_web'], str_replace("\\", "/", realpath($submitGroupWorkUrl) ) ) ; - - echo "\n", - - "\n", - "\n", - - "\n"; + $form->addElement('hidden', 'newWorkUrl', $submitGroupWorkUrl); + $text_document = &$form->addElement('text', 'document', get_lang("Document")); + $defaults["document"] = ''.$realUrl.''; + $text_document->freeze(); } + elseif ($edit && ($is_allowed_to_edit or $is_author)) { $workUrl = $currentCourseRepositoryWeb.$workUrl; - - echo "\n", - - "\n", - - "\n", - - "\n"; + $form->addElement('hidden', 'id', $edit); + $text_document=$form->addElement('text', 'document', get_lang("Document")); + $defaults["document"] = ''.$workUrl.''; + $form->applyFilter('document','strtoupper'); + $text_document->freeze(); } + else // else standard upload option { - echo "\n", - - "\n", - - "\n", - - "\n"; + $form->addElement('file','file',get_lang('DownloadFile')); } - + + $titleWork=$form->addElement('text', 'title', get_lang("TitleWork")); + $defaults["title"] = ($edit?stripslashes($workTitle):stripslashes($title)); + + $titleAuthors=$form->addElement('text', 'authors', get_lang("Authors")); + $defaults["authors"] = ($edit?stripslashes($workAuthor):stripslashes($authors)); + + $titleAuthors=$form->addElement('textarea', 'description', get_lang("Description")); + $defaults["description"] = ($edit?stripslashes($workDescription):stripslashes($description)); + + $form->addElement('hidden', 'active', 1); + $form->addElement('hidden', 'accepted', 1); + + $form->addElement('submit', 'submitWork', get_lang('Ok')); + if(empty($authors)) { $authors=$_user['lastName']." ".$_user['firstName']; } - - echo "\n", - - "\n", - - "\n", - - "\n", - - "\n", - - "\n", - - "\n", - - "\n", - - "\n", - - "\n", - - "\n", - - "\n", - - "\n", - - "", - - "\n", - - "\n", - - "
", - "", - get_lang("Document")," : ", - "", - "",$realUrl,"", - "
", - "\n", - get_lang('Document')," : ", - "", - "",$workUrl,"", - "
", - get_lang("DownloadFile"),"  ", - "", - "", - "
", - get_lang("TitleWork"),"  ", - "", - "", - "
", - get_lang("Authors")."  ", - "", - "\n", - "
", - get_lang("Description"),"  ", - "", - "", - "", - "", - "
", - ""; - + if($_POST['submitWork'] || $edit) { - echo "  "; + $form->addElement('submit', 'cancelForm', get_lang('Cancel')); } - - echo "
\n", - - "
\n", - - "

 

"; + + $form->add_real_progress_bar('uploadWork','DownloadFile'); + + $form->setDefaults($defaults); + $form->display(); + } //show them the form for the directory name if(isset($_REQUEST['createdir']) && $is_allowed_to_edit)