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

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