[svn r10839] Replace the old document upload form by a formvalidator

skala
Julian Prud'homme 18 years ago
parent 06e558ec91
commit 416b733e95
  1. 34
      main/document/document.inc.php
  2. 4
      main/document/document.php
  3. 4
      main/document/slideshow.php
  4. 65
      main/document/upload.php

@ -1,4 +1,4 @@
<?php // $Id: document.inc.php 10195 2006-11-25 15:26:00Z pcool $
<?php // $Id: document.inc.php 10839 2007-01-23 09:35:28Z elixir_julian $
/*
==============================================================================
@ -19,7 +19,7 @@
* @param string $group_dir
* @return string html form
*/
function build_directory_selector($folders,$curdirpath,$group_dir='')
function build_directory_selector($folders,$curdirpath,$group_dir='',$changeRenderer)
{
$folder_titles = array();
if(get_setting('use_document_title') == 'true')
@ -43,13 +43,21 @@ function build_directory_selector($folders,$curdirpath,$group_dir='')
$folder_titles[$folder] = basename($folder);
}
}
$form = '<form name="selector" action="'.$_SERVER['PHP_SELF'].'" method="post">'."\n";
$form .= get_lang('CurrentDirectory').' <select name="curdirpath" onchange="javascript:document.selector.submit()">'."\n";
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
$form = new FormValidator('selector','POST',$_SERVER['PHP_SELF']);
$parent_select = $form->addElement('select', 'curdirpath', get_lang('CurrentDirectory'),'','onchange="javascript:document.selector.submit()"');
if($changeRenderer==true){
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('<span>{label} : {element}</span> ','curdirpath');
}
//group documents cannot be uploaded in the root
if($group_dir=='')
if($group_dir=='')
{
$form .= '<option value="/">/ ('.get_lang('Root').')</option>';
$parent_select -> addOption(get_lang('Root'),'/');
if(is_array($folders))
{
foreach ($folders AS $folder)
@ -57,7 +65,8 @@ function build_directory_selector($folders,$curdirpath,$group_dir='')
$selected = ($curdirpath==$folder)?' selected="selected"':'';
$path_parts = explode('/',$folder);
$label = str_repeat('&nbsp;&nbsp;&nbsp;',count($path_parts)-2).' &mdash; '.$folder_titles[$folder];
$form .= '<option'.$selected.' value="'.$folder.'">'.$label.'</option>'."\n";
$parent_select -> addOption($label,$folder);
if($selected!='') $parent_select->setSelected($folder);
}
}
}
@ -76,13 +85,12 @@ function build_directory_selector($folders,$curdirpath,$group_dir='')
$path_parts = explode('/',str_replace($group_dir,'',$folder));
$label = str_repeat('&nbsp;&nbsp;&nbsp;',count($path_parts)-2).' &mdash; '.$label;
}
$form .= '<option'.$selected.' value="'.$folder.'">'.$label.'</option>'."\n";
$parent_select -> addOption($label,$folder);
if($selected!='') $parent_select->setSelected($folder);
}
}
$form .= '</select>'."\n";
$form .= '<noscript><input type="submit" name="change_path" value="'.get_lang('Ok').'" /></noscript>'."\n";
$form .= '</form>';
$form=$form->toHtml();
return $form;
}

@ -1,4 +1,4 @@
<?php // $Id: document.php 10539 2006-12-20 14:11:07Z pcool $
<?php // $Id: document.php 10839 2007-01-23 09:35:28Z elixir_julian $
/*
==============================================================================
Dokeos - elearning and course management software
@ -461,7 +461,7 @@ $docs_and_folders = DocumentManager::get_all_document_data($_course,$curdirpath,
<div id="folderselector" style="float:left;margin-right:10px;margin-top:5px;">
<?php
$folders = DocumentManager::get_all_document_folders($_course,$to_group_id,$is_allowed_to_edit || $group_member_with_upload_rights);
echo(build_directory_selector($folders,$curdirpath,$group_properties['directory']));
echo(build_directory_selector($folders,$curdirpath,$group_properties['directory'],true));
?>
</div>

@ -1,5 +1,5 @@
<?php
// $Id: slideshow.php 10204 2006-11-26 20:46:53Z pcool $
// $Id: slideshow.php 10839 2007-01-23 09:35:28Z elixir_julian $
/*
==============================================================================
Dokeos - elearning and course management software
@ -89,7 +89,7 @@ $interbreadcrumb[] = array ("url" => $url, "name" => $originaltoolname);
// because $nametools uses $_SERVER['PHP_SELF'] for the breadcrumbs instead of $_SERVER['REQUEST_URI'], I had to
// bypass the $nametools thing and use <b></b> tags in the $interbreadcrump array
$url = "slideshow.php?curdirpath=".$pathurl;
$originaltoolname = get_lang('Slideshow');
$originaltoolname = get_lang('_slideshow');
//$interbreadcrumb[]= array ("url"=>$url, "name"=>$originaltoolname );
Display :: display_header($originaltoolname, "Doc");

@ -1,4 +1,4 @@
<?php // $Id: upload.php 10204 2006-11-26 20:46:53Z pcool $
<?php // $Id: upload.php 10839 2007-01-23 09:35:28Z elixir_julian $
/*
==============================================================================
Dokeos - elearning and course management software
@ -314,50 +314,35 @@ echo(build_directory_selector($folders,$path,$group_properties['directory']));
</div>
<!-- start upload form -->
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" name="upload" enctype="multipart/form-data">
<!-- <input type="hidden" name="MAX_FILE_SIZE" value="5400"> -->
<input type="hidden" name="curdirpath" value="<?php echo $path; ?>">
<table>
<tr>
<td valign="top">
<?php echo get_lang('File'); ?>
</td>
<td>
<input type="file" name="user_upload"/>
</td>
</tr>
<?php
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
$form = new FormValidator('upload','POST',$_SERVER['PHP_SELF'],'','enctype="multipart/form-data"');
$form->addElement('hidden','curdirpath',$path);
$form->addElement('file','user_upload',get_lang('File'),'');
if(get_setting('use_document_title')=='true')
{
?>
<tr>
<td><?php echo get_lang('Title');?></td>
<td><input type="text" size="20" name="title" style="width:300px;"></td>
</tr>
<?php
$form->addElement('text','title',get_lang('Title'),'size="20" style="width:300px;"');
$form->addElement('textarea','comment',get_lang('Comment'),'wrap="virtual" style="width:300px;"');
}
$form->addElement('checkbox','unzip',get_lang('Options'),get_lang('Uncompress'),'onclick="check_unzip()" value="1"');
$form->addElement('radio', 'if_exists', get_lang('UplWhatIfFileExists'), get_lang('UplDoNothing'), 'value="nothing"');
$form->addElement('radio', 'if_exists', '', get_lang('UplOverwriteLong'), 'value="overwrite"');
$form->addElement('radio', 'if_exists', '', get_lang('UplRenameLong'), 'value="rename"');
$form->addElement('submit', null, get_lang('Ok'));
$form->display();
?>
<tr>
<td valign="top"><?php echo get_lang('Comment');?></td>
<td><textarea rows="3" cols="20" name="comment" wrap="virtual" style="width:300px;"></textarea></td>
</tr>
<tr>
<td valign="top">
<?php echo get_lang('Options'); ?>
</td>
<td>
- <input type="checkbox" name="unzip" value="1" onclick="check_unzip()"/> <?php echo(get_lang('Uncompress'));?><br/>
- <?php echo (get_lang('UplWhatIfFileExists'));?><br/>
&nbsp;&nbsp;&nbsp;<input type="radio" name="if_exists" value="nothing" title="<?php echo (get_lang('UplDoNothingLong'));?>" checked="checked"/> <?php echo (get_lang('UplDoNothing'));?><br/>
&nbsp;&nbsp;&nbsp;<input type="radio" name="if_exists" value="overwrite" title="<?php echo (get_lang('UplOverwriteLong'));?>"/> <?php echo (get_lang('UplOverwrite'));?><br/>
&nbsp;&nbsp;&nbsp;<input type="radio" name="if_exists" value="rename" title="<?php echo (get_lang('UplRenameLong'));?>"/> <?php echo (get_lang('UplRename'));?>
</td>
</tr>
</table>
<input type="submit" value="<?php echo(get_lang('Ok'));?>">
</form>
<!-- end upload form -->
<!-- so they can get back to the documents -->

Loading…
Cancel
Save