[svn r19677] refactoring: removing duplicate code for create folder form

actions bar in upload.php
skala
Patrick Cool 16 years ago
parent 189fa71e3f
commit 9476ce8655
  1. 25
      main/document/document.inc.php
  2. 22
      main/document/document.php
  3. 114
      main/document/upload.php

@ -1,4 +1,4 @@
<?php // $Id: document.inc.php 19471 2009-03-31 23:28:53Z cvargas1 $
<?php // $Id: document.inc.php 19677 2009-04-09 09:49:45Z pcool $
/*
==============================================================================
@ -487,4 +487,27 @@ function display_user_link_document($user_id, $name)
}
}
function create_dir_form()
{
//create the form that asks for the directory name
$new_folder_text = '<form action="'.api_get_self().'" method="post">';
$new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$curdirpath.'" />';
// form title
$new_folder_text .= '<div class="row"><div class="form_header">'.get_lang('CreateDir').'</div></div>';
// folder field
$new_folder_text .= '<div class="row">';
$new_folder_text .= '<div class="label"><span class="form_required">*</span>'.get_lang('NewDir').'</div>';
$new_folder_text .= '<div class="formw"><input type="text" name="dirname" /></div>';
$new_folder_text .= '</div>';
// submit button
$new_folder_text .= '<div class="row">';
$new_folder_text .= '<div class="label">&nbsp;</div>';
$new_folder_text .= '<div class="formw"><button type="submit" name="create_dir">'.get_lang('CreateFolder').'</button></div>';
$new_folder_text .= '</div>';
$new_folder_text .= '</form>';
$new_folder_text .= '<div style="clear: both; margin-bottom: 10px;"></div>';
return $new_folder_text;
}
?>

@ -1,4 +1,4 @@
<?php // $Id: document.php 19676 2009-04-09 09:14:37Z pcool $
<?php // $Id: document.php 19677 2009-04-09 09:49:45Z pcool $
/*
==============================================================================
Dokeos - elearning and course management software
@ -542,26 +542,8 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY
//show them the form for the directory name
if(isset($_GET['createdir']))
{
//create the form that asks for the directory name
$new_folder_text = '<form action="'.api_get_self().'" method="post">';
$new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$curdirpath.'" />';
// form title
$new_folder_text .= '<div class="row"><div class="form_header">'.get_lang('CreateDir').'</div></div>';
// folder field
$new_folder_text .= '<div class="row">';
$new_folder_text .= '<div class="label"><span class="form_required">*</span>'.get_lang('NewDir').'</div>';
$new_folder_text .= '<div class="formw"><input type="text" name="dirname" /></div>';
$new_folder_text .= '</div>';
// submit button
$new_folder_text .= '<div class="row">';
$new_folder_text .= '<div class="label">&nbsp;</div>';
$new_folder_text .= '<div class="formw"><button type="submit" name="create_dir">'.get_lang('CreateFolder').'</button></div>';
$new_folder_text .= '</div>';
$new_folder_text .= '</form>';
$new_folder_text .= '<div style="clear: both; margin-bottom: 10px;"></div>';
//show the form
echo $new_folder_text;
echo create_dir_form();
}

@ -1,4 +1,4 @@
<?php // $Id: upload.php 19397 2009-03-27 22:02:19Z iflorespaz $
<?php // $Id: upload.php 19677 2009-04-09 09:49:45Z pcool $
/*
==============================================================================
Dokeos - elearning and course management software
@ -55,21 +55,21 @@
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// name of the language file that needs to be included
$language_file = 'document';
// global settings initialisation
// also provides access to main api (inc/lib/main_api.lib.php)
// including the global Dokeos file
include("../inc/global.inc.php");
// including additional libraries
include_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
include_once(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php');
include_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
include('document.inc.php');
// adding extra javascript to the form
$htmlHeadXtra[] =
"<script type=\"text/javascript\">
<!-- //
@ -167,12 +167,8 @@ function get_text_content($doc_path, $doc_mime) {
return FALSE;
}
}
/*
-----------------------------------------------------------
Variables
- some need defining before inclusion of libraries
-----------------------------------------------------------
*/
// variables
$is_allowed_to_edit = api_is_allowed_to_edit();
$courseDir = $_course['path']."/document";
@ -224,21 +220,7 @@ else
$path = '/';
}
/*
-----------------------------------------------------------
Libraries
-----------------------------------------------------------
*/
//many useful functions in main_api.lib.php, by default included
include_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
include_once(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php');
include_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
//check the path
//if the path is not found (no document id), set the path to /
//check the path: if the path is not found (no document id), set the path to /
if(!DocumentManager::get_document_id($_course,$path))
{
$path = '/';
@ -254,31 +236,25 @@ if (isset($_POST['unzip']) && $_POST['unzip'] == 1)
{
include(api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php');
}
/*
-----------------------------------------------------------
Variables
-----------------------------------------------------------
*/
$max_filled_space = DocumentManager::get_course_quota();
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
$nameTools = get_lang('UplUploadDocument');
$interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($path).$req_gid, "name"=> $langDocuments);
Display::display_header($nameTools,"Doc");
// variables
$max_filled_space = DocumentManager::get_course_quota();
// title of the tool
if($to_group_id !=0) //add group name after for group documents
{
$add_group_to_title = ' ('.$group_properties['name'].')';
}
//show the title
echo '<div class="actions-title">';
echo $nameTools.$add_group_to_title;
echo '</div>';
$nameTools = get_lang('UplUploadDocument').$add_group_to_title;
// breadcrumbs
$interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($path).$req_gid, "name"=> $langDocuments);
// display the header
Display::display_header($nameTools,"Doc");
/*
-----------------------------------------------------------
Here we do all the work
@ -520,31 +496,40 @@ if(isset($_GET['createdir']))
$new_folder_text .= '<button type="submit" class="save" name="create_dir">'.get_lang('CreateFolder').'</button>';
$new_folder_text .= '</form>';
//show the form
Display::display_normal_message($new_folder_text, false);
//Display::display_normal_message($new_folder_text, false);
echo create_dir_form();
}
else { //give them a link to create a directory
?>
<p><a href="<?php echo api_get_self(); ?>?path=<?php echo $path; ?>&amp;createdir=1"><img src="../img/folder_new.gif" border="0" align="absmiddle" alt ="" /> <?php echo(get_lang('CreateDir'));?></a></p>
<?php
// actions
echo '<div class="actions">';
// link back to the documents overview
echo '<a href="document.php?curdirpath='.$path.'">'.Display::return_icon('back.png').get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview').'</a>';
// link to create a folder
if(!isset($_GET['createdir']))
{
echo '<a href="'.api_get_self().'?path='.$path.'&amp;createdir=1">'.Display::return_icon('folder_new.gif', get_lang('CreateDir')).get_lang('CreateDir').'</a>';
}
?>
echo '</div>';
<div id="folderselector">
<?php
//form to select directory
$folders = DocumentManager::get_all_document_folders($_course,$to_group_id,$is_allowed_to_edit);
echo(build_directory_selector($folders,$path,$group_properties['directory']));
?>
</div>
<!-- start upload form -->
<?php
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
$form = new FormValidator('upload','POST',api_get_self(),'','enctype="multipart/form-data"');
// form title
$form->addElement('header', '', $nameTools);
$form->addElement('hidden','curdirpath',$path);
$form->addElement('file','user_upload',get_lang('File'),'id="user_upload" size="45"');
@ -590,14 +575,7 @@ $form->display();
<!-- end upload form -->
<!-- so they can get back to the documents -->
<p><?php echo (get_lang('Back'));?> <?php echo (get_lang('To'));?> <a href="document.php?curdirpath=<?php echo $path; ?>"><?php echo (get_lang('DocumentsOverview'));?></a></p>
<?php
/*
==============================================================================
FOOTER
==============================================================================
*/
// footer
Display::display_footer();
?>

Loading…
Cancel
Save