file_rename.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: Renaming files and folders
00029  *
00030  * $Id: file_rename.php 7905 2010-06-13 14:42:33Z ohader $
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_rename
00041  *   96:     function init()
00042  *  149:     function main()
00043  *  192:     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 rename-file form.
00067  *
00068  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00069  * @package TYPO3
00070  * @subpackage core
00071  */
00072 class SC_file_rename {
00073 
00074         // Internal, static:
00075     /**
00076      * Document template object
00077      *
00078      * @var smallDoc
00079      */
00080     var $doc;
00081 
00082     /**
00083      * File processing object
00084      *
00085      * @var t3lib_basicFileFunctions
00086      */
00087     var $basicff;
00088     var $icon;          // Will be set to the proper icon for the $target value.
00089     var $shortPath;     // Relative path to current found filemount
00090     var $title;         // Name of the filemount
00091 
00092         // Internal, static (GPVar):
00093     var $target;        // Set with the target path inputted in &target
00094     var $returnUrl;     // Return URL of list module.
00095 
00096         // Internal, dynamic:
00097     var $content;       // Accumulating content
00098 
00099 
00100     /**
00101      * Constructor function for class
00102      *
00103      * @return  void
00104      */
00105     function init() {
00106         //TODO remove global
00107         global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
00108 
00109             // Initialize GPvars:
00110         $this->target = t3lib_div::_GP('target');
00111         $this->returnUrl = t3lib_div::_GP('returnUrl');
00112 
00113             // Init basic-file-functions object:
00114         $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00115         $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
00116 
00117             // Cleaning and checking target
00118         if (file_exists($this->target)) {
00119             $this->target=$this->basicff->cleanDirectoryName($this->target);        // Cleaning and checking target (file or dir)
00120         } else {
00121             $this->target='';
00122         }
00123         $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
00124         if (!$this->target || !$key)    {
00125             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), '');
00126             exit;
00127         }
00128 
00129             // Finding the icon
00130         switch($GLOBALS['FILEMOUNTS'][$key]['type'])    {
00131             case 'user':    $this->icon = 'gfx/i/_icon_ftp_user.gif';   break;
00132             case 'group':   $this->icon = 'gfx/i/_icon_ftp_group.gif';  break;
00133             default:        $this->icon = 'gfx/i/_icon_ftp.gif';    break;
00134         }
00135 
00136         $this->icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$this->icon,'width="18" height="16"').' title="" alt="" />';
00137 
00138             // Relative path to filemount, $key:
00139         $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
00140 
00141             // Setting title:
00142         $this->title = $this->icon . htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . $this->shortPath;
00143 
00144             // Setting template object
00145         $this->doc = t3lib_div::makeInstance('template');
00146         $this->doc->setModuleTemplate('templates/file_rename.html');
00147         $this->doc->backPath = $BACK_PATH;
00148         $this->doc->JScode=$this->doc->wrapScriptTags('
00149             function backToList()   {   //
00150                 top.goToModule("file_list");
00151             }
00152         ');
00153     }
00154 
00155     /**
00156      * Main function, rendering the content of the rename form
00157      *
00158      * @return  void
00159      */
00160     function main() {
00161         //TODO remove global, change $LANG into $GLOBALS['LANG'], change locallang*.php to locallang*.xml
00162 
00163         global $LANG;
00164 
00165             // Make page header:
00166         $this->content = $this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
00167 
00168         $pageContent = $this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
00169         $pageContent .= $this->doc->spacer(5);
00170         $pageContent .= $this->doc->divider(5);
00171 
00172 
00173         $code = '<form action="tce_file.php" method="post" name="editform">';
00174             // Making the formfields for renaming:
00175         $code .= '
00176 
00177             <div id="c-rename">
00178                 <input type="text" name="file[rename][0][data]" value="'.htmlspecialchars(basename($this->shortPath)).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />
00179                 <input type="hidden" name="file[rename][0][target]" value="'.htmlspecialchars($this->target).'" />
00180             </div>
00181         ';
00182 
00183             // Making submit button:
00184         $code.='
00185             <div id="c-submit">
00186                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.submit',1).'" />
00187                 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
00188                 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
00189             </div>
00190         ';
00191 
00192         $code .= '</form>';
00193 
00194             // Add the HTML as a section:
00195         $pageContent .= $code;
00196 
00197         $docHeaderButtons = array();
00198         $docHeaderButtons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_rename', $GLOBALS['BACK_PATH']);
00199 
00200             // Add the HTML as a section:
00201         $markerArray = array(
00202             'CSH' => $docHeaderButtons['csh'],
00203             'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
00204             'CONTENT' => $pageContent,
00205             'PATH' => $this->title,
00206         );
00207 
00208         $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
00209         $this->content.= $this->doc->endPage();
00210         $this->content = $this->doc->insertStylesAndJS($this->content);
00211     }
00212 
00213     /**
00214      * Outputting the accumulated content to screen
00215      *
00216      * @return  void
00217      */
00218     function printContent() {
00219         echo $this->content;
00220     }
00221 }
00222 
00223 
00224 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_rename.php'])   {
00225     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_rename.php']);
00226 }
00227 
00228 
00229 
00230 // Make instance:
00231 $SOBE = t3lib_div::makeInstance('SC_file_rename');
00232 $SOBE->init();
00233 $SOBE->main();
00234 $SOBE->printContent();
00235 
00236 ?>

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