file_newfolder.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Web>File: Create new folders in the filemounts
00029  *
00030  * $Id: file_newfolder.php 4567 2008-12-18 18:10:00Z dmitry $
00031  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
00032  *
00033  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *   74: class SC_file_newfolder
00041  *  101:     function init()
00042  *  161:     function main()
00043  *  255:     function printContent()
00044  *
00045  * TOTAL FUNCTIONS: 3
00046  * (This index is automatically created/updated by the extension "extdeveval")
00047  *
00048  */
00049 
00050 
00051 
00052 $BACK_PATH = '';
00053 require('init.php');
00054 require('template.php');
00055 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
00056 require_once(PATH_t3lib.'class.t3lib_parsehtml.php');
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 /**
00068  * Script Class for the create-new script; Displays a form for creating up to 10 folders or one new text file
00069  *
00070  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00071  * @package TYPO3
00072  * @subpackage core
00073  */
00074 class SC_file_newfolder {
00075 
00076         // External, static:
00077     var $folderNumber=10;
00078 
00079         // Internal, static:
00080     /**
00081      * document template object
00082      *
00083      * @var smallDoc
00084      */
00085     var $doc;
00086 
00087     /**
00088      * File processing object
00089      *
00090      * @var t3lib_basicFileFunctions
00091      */
00092     var $basicff;
00093     var $icon;          // Will be set to the proper icon for the $target value.
00094     var $shortPath;     // Relative path to current found filemount
00095     var $title;         // Name of the filemount
00096 
00097     /**
00098      * Charset processing object
00099      *
00100      * @var t3lib_cs
00101      */
00102     protected $charsetConversion;
00103 
00104         // Internal, static (GPVar):
00105     var $number;
00106     var $target;        // Set with the target path inputted in &target
00107     var $returnUrl;     // Return URL of list module.
00108 
00109         // Internal, dynamic:
00110     var $content;       // Accumulating content
00111 
00112 
00113 
00114     /**
00115      * Constructor function for class
00116      *
00117      * @return  void
00118      */
00119     function init() {
00120         global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
00121 
00122             // Initialize GPvars:
00123         $this->number = t3lib_div::_GP('number');
00124         $this->target = t3lib_div::_GP('target');
00125         $this->returnUrl = t3lib_div::_GP('returnUrl');
00126 
00127             // Init basic-file-functions object:
00128         $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00129         $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
00130 
00131             // Init basic-charset-functions object:
00132         $this->charsetConversion = t3lib_div::makeInstance('t3lib_cs');
00133 
00134             // Cleaning and checking target
00135         $this->target = $this->charsetConversion->conv($this->target, 'utf-8', $GLOBALS['LANG']->charSet);
00136         $this->target = $this->basicff->is_directory($this->target);
00137         $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
00138         if (!$this->target || !$key)    {
00139             t3lib_BEfunc::typo3PrintError ($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', true), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', true), '');
00140             exit;
00141         }
00142 
00143             // Finding the icon
00144         switch($GLOBALS['FILEMOUNTS'][$key]['type'])    {
00145             case 'user':    $this->icon = 'gfx/i/_icon_ftp_user.gif';   break;
00146             case 'group':   $this->icon = 'gfx/i/_icon_ftp_group.gif';  break;
00147             default:        $this->icon = 'gfx/i/_icon_ftp.gif';    break;
00148         }
00149 
00150         $this->icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$this->icon,'width="18" height="16"').' title="" alt="" />';
00151 
00152             // Relative path to filemount, $key:
00153         $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
00154 
00155             // Setting title:
00156         $this->title = $this->icon.$GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath;
00157 
00158             // Setting template object
00159         $this->doc = t3lib_div::makeInstance('template');
00160         $this->doc->setModuleTemplate('templates/file_newfolder.html');
00161         $this->doc->backPath = $BACK_PATH;
00162         $this->doc->JScode=$this->doc->wrapScriptTags('
00163             var path = "'.$this->target.'";
00164 
00165             function reload(a)  {   //
00166                 if (!changed || (changed && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).')))  {
00167                     var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl='
00168                             . urlencode($this->charsetConversion->conv($this->returnUrl, $GLOBALS['LANG']->charSet, 'utf-8'))
00169                             . '";
00170                     window.location.href = "file_newfolder.php?"+params;
00171                 }
00172             }
00173             function backToList()   {   //
00174                 top.goToModule("file_list");
00175             }
00176 
00177             var changed = 0;
00178         ');
00179     }
00180 
00181     /**
00182      * Main function, rendering the main module content
00183      *
00184      * @return  void
00185      */
00186     function main() {
00187         global $LANG;
00188 
00189             // start content compilation
00190         $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
00191 
00192 
00193             // Make page header:
00194         $pageContent='';
00195         $pageContent.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
00196         $pageContent.=$this->doc->spacer(5);
00197         $pageContent.=$this->doc->divider(5);
00198 
00199 
00200         $code = '<form action="tce_file.php" method="post" name="editform">';
00201             // Making the selector box for the number of concurrent folder-creations
00202         $this->number = t3lib_div::intInRange($this->number,1,10);
00203         $code .= '
00204             <div id="c-select">
00205                 <label for="number-of-new-folders">' .
00206                 $LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.number_of_folders') .
00207                 '</label>
00208                 <select name="number" id="number-of-new-folders" onchange="reload(this.options[this.selectedIndex].value);">';
00209         for ($a=1;$a<=$this->folderNumber;$a++) {
00210             $code .= '<option value="' . $a . '"' .
00211                     ($this->number == $a ? ' selected="selected"' : '') .
00212                     '>' . $a . '</option>';
00213         }
00214         $code.='
00215                 </select>
00216             </div>
00217             ';
00218 
00219             // Making the number of new-folder boxes needed:
00220         $code.='
00221             <div id="c-createFolders">
00222         ';
00223         for ($a=0;$a<$this->number;$a++)    {
00224             $code.='
00225                     <input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" onchange="changed=true;" />
00226                     <input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($this->target).'" />
00227                 ';
00228         }
00229         $code.='
00230             </div>
00231         ';
00232 
00233             // Making submit button for folder creation:
00234         $code.='
00235             <div id="c-submitFolders">
00236                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />
00237                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
00238                 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
00239             </div>
00240             ';
00241 
00242             // CSH:
00243         $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_newfolder', $GLOBALS['BACK_PATH'],'<br/>');
00244 
00245         $pageContent.= $code;
00246 
00247 
00248 
00249             // Add spacer:
00250         $pageContent.= $this->doc->spacer(10);
00251 
00252             // Switching form tags:
00253         $pageContent.= $this->doc->sectionEnd();
00254         $pageContent.= '</form><form action="tce_file.php" method="post" name="editform2">';
00255 
00256             // Add form fields for creation of a new, blank text file:
00257         $code='
00258             <div id="c-newFile">
00259                 <p>['.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']).']</p>
00260                 <input'.$this->doc->formWidth(20).' type="text" name="file[newfile][0][data]" onchange="changed=true;" />
00261                 <input type="hidden" name="file[newfile][0][target]" value="'.htmlspecialchars($this->target).'" />
00262             </div>
00263             ';
00264 
00265             // Submit button for creation of a new file:
00266         $code.='
00267             <div id="c-submitFiles">
00268                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile_submit',1).'" />
00269                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
00270                 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
00271             </div>
00272             ';
00273 
00274             // CSH:
00275         $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_newfile', $GLOBALS['BACK_PATH'],'<br/>');
00276         $pageContent.= $this->doc->section($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile'),$code);
00277 
00278         $docHeaderButtons = array();
00279 
00280             // Add the HTML as a section:
00281         $markerArray = array(
00282             'CSH' => $docHeaderButtons['csh'],
00283             'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
00284             'CONTENT' => $pageContent,
00285             'PATH' => $this->title,
00286         );
00287 
00288         $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
00289         $this->content.= $this->doc->endPage();
00290 
00291         $this->content = $this->doc->insertStylesAndJS($this->content);
00292     }
00293 
00294     /**
00295      * Outputting the accumulated content to screen
00296      *
00297      * @return  void
00298      */
00299     function printContent() {
00300         echo $this->content;
00301     }
00302 }
00303 
00304 
00305 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_newfolder.php'])    {
00306     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_newfolder.php']);
00307 }
00308 
00309 
00310 
00311 // Make instance:
00312 $SOBE = t3lib_div::makeInstance('SC_file_newfolder');
00313 $SOBE->init();
00314 $SOBE->main();
00315 $SOBE->printContent();
00316 
00317 ?>

Generated on Sat Jan 3 04:23:28 2009 for TYPO3 API by  doxygen 1.4.7