[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/typo3/ -> file_rename.php (source)

   1  <?php
   2  /***************************************************************
   3  *  Copyright notice
   4  *
   5  *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
   6  *  All rights reserved
   7  *
   8  *  This script is part of the TYPO3 project. The TYPO3 project is
   9  *  free software; you can redistribute it and/or modify
  10  *  it under the terms of the GNU General Public License as published by
  11  *  the Free Software Foundation; either version 2 of the License, or
  12  *  (at your option) any later version.
  13  *
  14  *  The GNU General Public License can be found at
  15  *  http://www.gnu.org/copyleft/gpl.html.
  16  *  A copy is found in the textfile GPL.txt and important notices to the license
  17  *  from the author is found in LICENSE.txt distributed with these scripts.
  18  *
  19  *
  20  *  This script is distributed in the hope that it will be useful,
  21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23  *  GNU General Public License for more details.
  24  *
  25  *  This copyright notice MUST APPEAR in all copies of the script!
  26  ***************************************************************/
  27  /**
  28   * Web>File: Renaming files and folders
  29   *
  30   * $Id: file_rename.php 1421 2006-04-10 09:27:15Z mundaun $
  31   * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
  32   *
  33   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
  34   */
  35  /**
  36   * [CLASS/FUNCTION INDEX of SCRIPT]
  37   *
  38   *
  39   *
  40   *   74: class SC_file_rename
  41   *   96:     function init()
  42   *  149:     function main()
  43   *  192:     function printContent()
  44   *
  45   * TOTAL FUNCTIONS: 3
  46   * (This index is automatically created/updated by the extension "extdeveval")
  47   *
  48   */
  49  
  50  
  51  
  52  $BACK_PATH = '';
  53  require ('init.php');
  54  require ('template.php');
  55  require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
  56  
  57  
  58  
  59  
  60  
  61  
  62  
  63  
  64  
  65  
  66  
  67  /**
  68   * Script Class for the rename-file form.
  69   *
  70   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
  71   * @package TYPO3
  72   * @subpackage core
  73   */
  74  class SC_file_rename {
  75  
  76          // Internal, static:
  77      var $doc;            // Template object.
  78      var $basicff;        // Instance of "t3lib_basicFileFunctions"
  79      var $icon;            // Will be set to the proper icon for the $target value.
  80      var $shortPath;        // Relative path to current found filemount
  81      var $title;            // Name of the filemount
  82  
  83          // Internal, static (GPVar):
  84      var $target;        // Set with the target path inputted in &target
  85      var $returnUrl;        // Return URL of list module.
  86  
  87          // Internal, dynamic:
  88      var $content;        // Accumulating content
  89  
  90  
  91      /**
  92       * Constructor function for class
  93       *
  94       * @return    void
  95       */
  96  	function init()    {
  97          global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
  98  
  99              // Initialize GPvars:
 100          $this->target = t3lib_div::_GP('target');
 101          $this->returnUrl = t3lib_div::_GP('returnUrl');
 102  
 103              // Init basic-file-functions object:
 104          $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
 105          $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
 106  
 107              // Cleaning and checking target
 108          if (@file_exists($this->target))    {
 109              $this->target=$this->basicff->cleanDirectoryName($this->target);        // Cleaning and checking target (file or dir)
 110          } else {
 111              $this->target='';
 112          }
 113          $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
 114          if (!$this->target || !$key)    {
 115              t3lib_BEfunc::typo3PrintError ('Parameter Error','Target was not a directory!','');
 116              exit;
 117          }
 118  
 119              // Finding the icon
 120          switch($GLOBALS['FILEMOUNTS'][$key]['type'])    {
 121              case 'user':    $this->icon = 'gfx/i/_icon_ftp_user.gif';    break;
 122              case 'group':    $this->icon = 'gfx/i/_icon_ftp_group.gif';    break;
 123              default:        $this->icon = 'gfx/i/_icon_ftp.gif';    break;
 124          }
 125  
 126              // Relative path to filemount, $key:
 127          $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
 128  
 129              // Setting title:
 130          $this->title = $GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath;
 131  
 132              // Setting template object
 133          $this->doc = t3lib_div::makeInstance('smallDoc');
 134          $this->doc->docType = 'xhtml_trans';
 135          $this->doc->backPath = $BACK_PATH;
 136          $this->doc->form='<form action="tce_file.php" method="post" name="editform">';
 137          $this->doc->JScode=$this->doc->wrapScriptTags('
 138  			function backToList()    {    //
 139                  top.goToModule("file_list");
 140              }
 141          ');
 142      }
 143  
 144      /**
 145       * Main function, rendering the content of the rename form
 146       *
 147       * @return    void
 148       */
 149  	function main()    {
 150          global $LANG;
 151  
 152              // Make page header:
 153          $this->content='';
 154          $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
 155          $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
 156          $this->content.=$this->doc->spacer(5);
 157          $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
 158          $this->content.=$this->doc->divider(5);
 159  
 160  
 161              // Making the formfields for renaming:
 162          $code='
 163  
 164              <div id="c-rename">
 165                  <input type="text" name="file[rename][0][data]" value="'.htmlspecialchars(basename($this->shortPath)).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />
 166                  <input type="hidden" name="file[rename][0][target]" value="'.htmlspecialchars($this->target).'" />
 167              </div>
 168          ';
 169  
 170              // Making submit button:
 171          $code.='
 172              <div id="c-submit">
 173                  <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.submit',1).'" />
 174                  <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
 175                  <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
 176              </div>
 177          ';
 178  
 179              // CSH:
 180          $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_rename', $GLOBALS['BACK_PATH'],'<br/>');
 181  
 182              // Add the HTML as a section:
 183          $this->content.= $this->doc->section('',$code);
 184  
 185      }
 186  
 187      /**
 188       * Outputting the accumulated content to screen
 189       *
 190       * @return    void
 191       */
 192  	function printContent()    {
 193          $this->content.= $this->doc->endPage();
 194          $this->content = $this->doc->insertStylesAndJS($this->content);
 195          echo $this->content;
 196      }
 197  }
 198  
 199  // Include extension?
 200  if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_rename.php'])    {
 201      include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_rename.php']);
 202  }
 203  
 204  
 205  
 206  
 207  
 208  
 209  
 210  
 211  
 212  
 213  
 214  
 215  // Make instance:
 216  $SOBE = t3lib_div::makeInstance('SC_file_rename');
 217  $SOBE->init();
 218  $SOBE->main();
 219  $SOBE->printContent();
 220  ?>


Généré le : Sun Nov 25 17:13:16 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics