Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

file_rename.php

Go to the documentation of this file.
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_rename {
00075 
00076       // Internal, static:
00077    var $doc;         // Template object.
00078    var $basicff;     // Instance of "t3lib_basicFileFunctions"
00079    var $icon;        // Will be set to the proper icon for the $target value.
00080    var $shortPath;      // Relative path to current found filemount
00081    var $title;       // Name of the filemount
00082 
00083       // Internal, static (GPVar):
00084    var $target;      // Set with the target path inputted in &target
00085    var $returnUrl;      // Return URL of list module.
00086 
00087       // Internal, dynamic:
00088    var $content;     // Accumulating content
00089 
00090 
00096    function init()   {
00097       global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
00098 
00099          // Initialize GPvars:
00100       $this->target = t3lib_div::_GP('target');
00101       $this->returnUrl = t3lib_div::_GP('returnUrl');
00102 
00103          // Init basic-file-functions object:
00104       $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00105       $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
00106 
00107          // Cleaning and checking target
00108       if (@file_exists($this->target)) {
00109          $this->target=$this->basicff->cleanDirectoryName($this->target);     // Cleaning and checking target (file or dir)
00110       } else {
00111          $this->target='';
00112       }
00113       $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
00114       if (!$this->target || !$key)  {
00115          t3lib_BEfunc::typo3PrintError ('Parameter Error','Target was not a directory!','');
00116          exit;
00117       }
00118 
00119          // Finding the icon
00120       switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
00121          case 'user':   $this->icon = 'gfx/i/_icon_ftp_user.gif'; break;
00122          case 'group':  $this->icon = 'gfx/i/_icon_ftp_group.gif';   break;
00123          default:    $this->icon = 'gfx/i/_icon_ftp.gif';   break;
00124       }
00125 
00126          // Relative path to filemount, $key:
00127       $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
00128 
00129          // Setting title:
00130       $this->title = $GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath;
00131 
00132          // Setting template object
00133       $this->doc = t3lib_div::makeInstance('smallDoc');
00134       $this->doc->docType = 'xhtml_trans';
00135       $this->doc->backPath = $BACK_PATH;
00136       $this->doc->form='<form action="tce_file.php" method="post" name="editform">';
00137       $this->doc->JScode=$this->doc->wrapScriptTags('
00138          function backToList()   {  //
00139             top.goToModule("file_list");
00140          }
00141       ');
00142    }
00143 
00149    function main()   {
00150       global $LANG;
00151 
00152          // Make page header:
00153       $this->content='';
00154       $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
00155       $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
00156       $this->content.=$this->doc->spacer(5);
00157       $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
00158       $this->content.=$this->doc->divider(5);
00159 
00160 
00161          // Making the formfields for renaming:
00162       $code='
00163 
00164          <div id="c-rename">
00165             <input type="text" name="file[rename][0][data]" value="'.htmlspecialchars(basename($this->shortPath)).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />
00166             <input type="hidden" name="file[rename][0][target]" value="'.htmlspecialchars($this->target).'" />
00167          </div>
00168       ';
00169 
00170          // Making submit button:
00171       $code.='
00172          <div id="c-submit">
00173             <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.submit',1).'" />
00174             <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
00175             <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
00176          </div>
00177       ';
00178 
00179          // CSH:
00180       $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_rename', $GLOBALS['BACK_PATH'],'<br/>');
00181 
00182          // Add the HTML as a section:
00183       $this->content.= $this->doc->section('',$code);
00184 
00185          // Ending page
00186       $this->content.= $this->doc->endPage();
00187    }
00188 
00194    function printContent() {
00195 
00196       echo $this->content;
00197    }
00198 }
00199 
00200 // Include extension?
00201 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_rename.php'])   {
00202    include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_rename.php']);
00203 }
00204 
00205 
00206 
00207 
00208 
00209 
00210 
00211 
00212 
00213 
00214 
00215 
00216 // Make instance:
00217 $SOBE = t3lib_div::makeInstance('SC_file_rename');
00218 $SOBE->init();
00219 $SOBE->main();
00220 $SOBE->printContent();
00221 ?>

Generated on Sun Oct 3 01:05:54 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913