file_newfolder.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2010 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 7974 2010-06-20 08:05:51Z benni $
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 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 /**
00066  * Script Class for the create-new script; Displays a form for creating up to 10 folders or one new text file
00067  *
00068  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00069  * @package TYPO3
00070  * @subpackage core
00071  */
00072 class SC_file_newfolder {
00073 
00074         // External, static:
00075     var $folderNumber=10;
00076 
00077         // Internal, static:
00078     /**
00079      * document template object
00080      *
00081      * @var smallDoc
00082      */
00083     var $doc;
00084 
00085     /**
00086      * File processing object
00087      *
00088      * @var t3lib_basicFileFunctions
00089      */
00090     var $basicff;
00091     var $icon;          // Will be set to the proper icon for the $target value.
00092     var $shortPath;     // Relative path to current found filemount
00093     var $title;         // Name of the filemount
00094 
00095     /**
00096      * Charset processing object
00097      *
00098      * @var t3lib_cs
00099      */
00100     protected $charsetConversion;
00101 
00102         // Internal, static (GPVar):
00103     var $number;
00104     var $target;        // Set with the target path inputted in &target
00105     var $returnUrl;     // Return URL of list module.
00106 
00107         // Internal, dynamic:
00108     var $content;       // Accumulating content
00109 
00110 
00111 
00112     /**
00113      * Constructor function for class
00114      *
00115      * @return  void
00116      */
00117     function init() {
00118         global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
00119 
00120             // Initialize GPvars:
00121         $this->number = t3lib_div::_GP('number');
00122         $this->target = t3lib_div::_GP('target');
00123         $this->returnUrl = t3lib_div::_GP('returnUrl');
00124 
00125             // Init basic-file-functions object:
00126         $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00127         $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
00128 
00129             // Init basic-charset-functions object:
00130         $this->charsetConversion = t3lib_div::makeInstance('t3lib_cs');
00131 
00132             // Cleaning and checking target
00133         $this->target = $this->charsetConversion->conv($this->target, 'utf-8', $GLOBALS['LANG']->charSet);
00134         $this->target = $this->basicff->is_directory($this->target);
00135         $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
00136         if (!$this->target || !$key)    {
00137             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), '');
00138             exit;
00139         }
00140 
00141             // Finding the icon
00142         switch($GLOBALS['FILEMOUNTS'][$key]['type'])    {
00143             case 'user':    $this->icon = 'gfx/i/_icon_ftp_user.gif';   break;
00144             case 'group':   $this->icon = 'gfx/i/_icon_ftp_group.gif';  break;
00145             default:        $this->icon = 'gfx/i/_icon_ftp.gif';    break;
00146         }
00147 
00148         $this->icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$this->icon,'width="18" height="16"').' title="" alt="" />';
00149 
00150             // Relative path to filemount, $key:
00151         $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
00152 
00153             // Setting title:
00154         $this->title = $this->icon . htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . $this->shortPath;
00155 
00156             // Setting template object
00157         $this->doc = t3lib_div::makeInstance('template');
00158         $this->doc->setModuleTemplate('templates/file_newfolder.html');
00159         $this->doc->backPath = $BACK_PATH;
00160         $this->doc->JScode=$this->doc->wrapScriptTags('
00161             var path = "'.$this->target.'";
00162 
00163             function reload(a)  {   //
00164                 if (!changed || (changed && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).')))  {
00165                     var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl='
00166                             . urlencode($this->charsetConversion->conv($this->returnUrl, $GLOBALS['LANG']->charSet, 'utf-8'))
00167                             . '";
00168                     window.location.href = "file_newfolder.php?"+params;
00169                 }
00170             }
00171             function backToList()   {   //
00172                 top.goToModule("file_list");
00173             }
00174 
00175             var changed = 0;
00176         ');
00177     }
00178 
00179     /**
00180      * Main function, rendering the main module content
00181      *
00182      * @return  void
00183      */
00184     function main() {
00185         global $LANG;
00186 
00187             // start content compilation
00188         $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
00189 
00190 
00191             // Make page header:
00192         $pageContent='';
00193         $pageContent.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
00194         $pageContent.=$this->doc->spacer(5);
00195         $pageContent.=$this->doc->divider(5);
00196 
00197 
00198         $code = '<form action="tce_file.php" method="post" name="editform">';
00199             // Making the selector box for the number of concurrent folder-creations
00200         $this->number = t3lib_div::intInRange($this->number,1,10);
00201         $code .= '
00202             <div id="c-select">
00203                 <label for="number-of-new-folders">' .
00204                 $LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.number_of_folders') .
00205                 '</label>
00206                 <select name="number" id="number-of-new-folders" onchange="reload(this.options[this.selectedIndex].value);">';
00207         for ($a=1;$a<=$this->folderNumber;$a++) {
00208             $code .= '<option value="' . $a . '"' .
00209                     ($this->number == $a ? ' selected="selected"' : '') .
00210                     '>' . $a . '</option>';
00211         }
00212         $code.='
00213                 </select>
00214             </div>
00215             ';
00216 
00217             // Making the number of new-folder boxes needed:
00218         $code.='
00219             <div id="c-createFolders">
00220         ';
00221         for ($a=0;$a<$this->number;$a++)    {
00222             $code.='
00223                     <input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" onchange="changed=true;" />
00224                     <input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($this->target) . '" /><br />
00225                 ';
00226         }
00227         $code.='
00228             </div>
00229         ';
00230 
00231             // Making submit button for folder creation:
00232         $code.='
00233             <div id="c-submitFolders">
00234                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />
00235                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
00236                 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
00237             </div>
00238             ';
00239 
00240             // CSH:
00241         $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_newfolder', $GLOBALS['BACK_PATH'], '<br />');
00242 
00243         $pageContent.= $code;
00244 
00245 
00246 
00247             // Add spacer:
00248         $pageContent.= $this->doc->spacer(10);
00249 
00250             // Switching form tags:
00251         $pageContent.= $this->doc->sectionEnd();
00252         $pageContent.= '</form><form action="tce_file.php" method="post" name="editform2">';
00253 
00254             // Create a list of allowed file extensions with the nice format "*.jpg, *.gif" etc.
00255         $fileExtList = array();
00256         $textfileExt = t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], TRUE);
00257         foreach ($textfileExt as $fileExt) {
00258             if (!preg_match('/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] . '/i', '.' . $fileExt)) {
00259                 $fileExtList[] = '*.' . $fileExt;
00260             }
00261         }
00262             // Add form fields for creation of a new, blank text file:
00263         $code='
00264             <div id="c-newFile">
00265                 <p>[' . htmlspecialchars(implode(', ', $fileExtList)) . ']</p>
00266                 <input'.$this->doc->formWidth(20).' type="text" name="file[newfile][0][data]" onchange="changed=true;" />
00267                 <input type="hidden" name="file[newfile][0][target]" value="'.htmlspecialchars($this->target).'" />
00268             </div>
00269             ';
00270 
00271             // Submit button for creation of a new file:
00272         $code.='
00273             <div id="c-submitFiles">
00274                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile_submit',1).'" />
00275                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
00276                 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
00277             </div>
00278             ';
00279 
00280             // CSH:
00281         $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_newfile', $GLOBALS['BACK_PATH'], '<br />');
00282         $pageContent.= $this->doc->section($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile'),$code);
00283         $pageContent .= $this->doc->sectionEnd();
00284         $pageContent .= '</form>';
00285 
00286         $docHeaderButtons = array();
00287 
00288             // Add the HTML as a section:
00289         $markerArray = array(
00290             'CSH' => $docHeaderButtons['csh'],
00291             'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
00292             'CONTENT' => $pageContent,
00293             'PATH' => $this->title,
00294         );
00295 
00296         $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
00297         $this->content.= $this->doc->endPage();
00298 
00299         $this->content = $this->doc->insertStylesAndJS($this->content);
00300     }
00301 
00302     /**
00303      * Outputting the accumulated content to screen
00304      *
00305      * @return  void
00306      */
00307     function printContent() {
00308         echo $this->content;
00309     }
00310 }
00311 
00312 
00313 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_newfolder.php'])    {
00314     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_newfolder.php']);
00315 }
00316 
00317 
00318 
00319 // Make instance:
00320 $SOBE = t3lib_div::makeInstance('SC_file_newfolder');
00321 $SOBE->init();
00322 $SOBE->main();
00323 $SOBE->printContent();
00324 
00325 ?>

Generated on Sat Jul 24 04:17:29 2010 for TYPO3 API by  doxygen 1.4.7