Documentation TYPO3 par Ameos

file_newfolder.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 ***************************************************************/
00052 $BACK_PATH = '';
00053 require('init.php');
00054 require('template.php');
00055 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00074 class SC_file_newfolder {
00075 
00076                 // External, static:
00077         var $folderNumber=10;
00078 
00079                 // Internal, static:
00080         var $doc;                       // Template object.
00081         var $basicff;           // Instance of "t3lib_basicFileFunctions"
00082         var $icon;                      // Will be set to the proper icon for the $target value.
00083         var $shortPath;         // Relative path to current found filemount
00084         var $title;                     // Name of the filemount
00085 
00086                 // Internal, static (GPVar):
00087         var $number;
00088         var $target;            // Set with the target path inputted in &target
00089         var $returnUrl;         // Return URL of list module.
00090 
00091                 // Internal, dynamic:
00092         var $content;           // Accumulating content
00093 
00094 
00095 
00101         function init() {
00102                 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
00103 
00104                         // Initialize GPvars:
00105                 $this->number = t3lib_div::_GP('number');
00106                 $this->target = t3lib_div::_GP('target');
00107                 $this->returnUrl = t3lib_div::_GP('returnUrl');
00108 
00109                         // Init basic-file-functions object:
00110                 $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00111                 $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
00112 
00113                         // Cleaning and checking target
00114                 $this->target=$this->basicff->is_directory($this->target);
00115                 $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
00116                 if (!$this->target || !$key)    {
00117                         t3lib_BEfunc::typo3PrintError ('Parameter Error','Target was not a directory!','');
00118                         exit;
00119                 }
00120 
00121                         // Finding the icon
00122                 switch($GLOBALS['FILEMOUNTS'][$key]['type'])    {
00123                         case 'user':    $this->icon = 'gfx/i/_icon_ftp_user.gif';       break;
00124                         case 'group':   $this->icon = 'gfx/i/_icon_ftp_group.gif';      break;
00125                         default:                $this->icon = 'gfx/i/_icon_ftp.gif';    break;
00126                 }
00127 
00128                         // Relative path to filemount, $key:
00129                 $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
00130 
00131                         // Setting title:
00132                 $this->title = $GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath;
00133 
00134                         // Setting template object
00135                 $this->doc = t3lib_div::makeInstance('smallDoc');
00136                 $this->doc->docType = 'xhtml_trans';
00137                 $this->doc->backPath = $BACK_PATH;
00138                 $this->doc->form='<form action="tce_file.php" method="post" name="editform">';
00139                 $this->doc->JScode=$this->doc->wrapScriptTags('
00140                         var path = "'.$this->target.'";
00141 
00142                         function reload(a)      {       //
00143                                 if (!changed || (changed && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).')))  {
00144                                         var params = "&target="+escape(path)+"&number="+a;
00145                                         document.location = "file_newfolder.php?"+params;
00146                                 }
00147                         }
00148                         function backToList()   {       //
00149                                 top.goToModule("file_list");
00150                         }
00151 
00152                         var changed = 0;
00153                 ');
00154         }
00155 
00161         function main() {
00162                 global $LANG;
00163 
00164                         // Make page header:
00165                 $this->content='';
00166                 $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
00167                 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
00168                 $this->content.=$this->doc->spacer(5);
00169                 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
00170                 $this->content.=$this->doc->divider(5);
00171 
00172 
00173                         // Making the selector box for the number of concurrent folder-creations
00174                 $this->number = t3lib_div::intInRange($this->number,1,10);
00175                 $code='
00176                         <div id="c-select">
00177                                 <select name="number" onchange="reload(this.options[this.selectedIndex].value);">';
00178                 for ($a=1;$a<=$this->folderNumber;$a++) {
00179                         $code.='
00180                                         <option value="'.$a.'"'.($this->number==$a?' selected="selected"':'').'>'.$a.' '.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.folders',1).'</option>';
00181                 }
00182                 $code.='
00183                                 </select>
00184                         </div>
00185                         ';
00186 
00187                         // Making the number of new-folder boxes needed:
00188                 $code.='
00189                         <div id="c-createFolders">
00190                 ';
00191                 for ($a=0;$a<$this->number;$a++)        {
00192                         $code.='
00193                                         <input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" onchange="changed=true;" />
00194                                         <input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($this->target).'" />
00195                                 ';
00196                 }
00197                 $code.='
00198                         </div>
00199                 ';
00200 
00201                         // Making submit button for folder creation:
00202                 $code.='
00203                         <div id="c-submitFolders">
00204                                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />
00205                                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
00206                                 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
00207                         </div>
00208                         ';
00209 
00210                         // CSH:
00211                 $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_newfolder', $GLOBALS['BACK_PATH'],'<br/>');
00212 
00213                 $this->content.= $this->doc->section('',$code);
00214 
00215 
00216 
00217                         // Add spacer:
00218                 $this->content.= $this->doc->spacer(10);
00219 
00220                         // Switching form tags:
00221                 $this->content.= $this->doc->sectionEnd();
00222                 $this->content.= '</form><form action="tce_file.php" method="post" name="editform2">';
00223 
00224                         // Add form fields for creation of a new, blank text file:
00225                 $code='
00226                         <div id="c-newFile">
00227                                 <p>['.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']).']</p>
00228                                 <input'.$this->doc->formWidth(20).' type="text" name="file[newfile][0][data]" onchange="changed=true;" />
00229                                 <input type="hidden" name="file[newfile][0][target]" value="'.htmlspecialchars($this->target).'" />
00230                         </div>
00231                         ';
00232 
00233                         // Submit button for creation of a new file:
00234                 $code.='
00235                         <div id="c-submitFiles">
00236                                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile_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_newfile', $GLOBALS['BACK_PATH'],'<br/>');
00244 
00245                         // Add the HTML as a section:
00246                 $this->content.= $this->doc->section($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile'),$code);
00247 
00248                         // Ending page
00249                 $this->content.= $this->doc->endPage();
00250         }
00251 
00257         function printContent() {
00258 
00259                 echo $this->content;
00260         }
00261 }
00262 
00263 // Include extension?
00264 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_newfolder.php'])        {
00265         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_newfolder.php']);
00266 }
00267 
00268 
00269 
00270 
00271 
00272 
00273 
00274 
00275 
00276 
00277 
00278 
00279 // Make instance:
00280 $SOBE = t3lib_div::makeInstance('SC_file_newfolder');
00281 $SOBE->init();
00282 $SOBE->main();
00283 $SOBE->printContent();
00284 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6