[BUGFIX] Hide the field "Selected Pages" for menu type "Sitemap"
[Packages/TYPO3.CMS.git] / typo3 / file_rename.php
old mode 100755 (executable)
new mode 100644 (file)
index 3b8f014..f469e99
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -28,9 +28,9 @@
  * Web>File: Renaming files and folders
  *
  * $Id$
- * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
@@ -52,8 +52,6 @@
 $BACK_PATH = '';
 require('init.php');
 require('template.php');
-require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
-require_once(PATH_t3lib.'class.t3lib_parsehtml.php');
 
 
 
@@ -67,7 +65,7 @@ require_once(PATH_t3lib.'class.t3lib_parsehtml.php');
 /**
  * Script Class for the rename-file form.
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -105,26 +103,28 @@ class SC_file_rename {
         * @return      void
         */
        function init() {
+               //TODO remove global
                global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
 
                        // Initialize GPvars:
                $this->target = t3lib_div::_GP('target');
-               $this->returnUrl = t3lib_div::_GP('returnUrl');
+               $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
 
                        // Init basic-file-functions object:
                $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
                $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
 
                        // Cleaning and checking target
-               if (@file_exists($this->target))        {
+               if (file_exists($this->target)) {
                        $this->target=$this->basicff->cleanDirectoryName($this->target);                // Cleaning and checking target (file or dir)
                } else {
                        $this->target='';
                }
                $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
-               if (!$this->target || !$key)    {
-                       t3lib_BEfunc::typo3PrintError ('Parameter Error','Target was not a directory!','');
-                       exit;
+               if (!$this->target || !$key) {
+                       $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
+                       $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
+                       throw new RuntimeException($title . ': ' . $message);
                }
 
                        // Finding the icon
@@ -140,11 +140,10 @@ class SC_file_rename {
                $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
 
                        // Setting title:
-               $this->title = $this->icon.$GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath;
+               $this->title = $this->icon . htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . htmlspecialchars($this->shortPath);
 
                        // Setting template object
                $this->doc = t3lib_div::makeInstance('template');
-               $this->doc->docType = 'xhtml_trans';
                $this->doc->setModuleTemplate('templates/file_rename.html');
                $this->doc->backPath = $BACK_PATH;
                $this->doc->JScode=$this->doc->wrapScriptTags('
@@ -160,6 +159,8 @@ class SC_file_rename {
         * @return      void
         */
        function main() {
+               //TODO remove global, change $LANG into $GLOBALS['LANG'], change locallang*.php to locallang*.xml
+
                global $LANG;
 
                        // Make page header:
@@ -189,6 +190,7 @@ class SC_file_rename {
                        </div>
                ';
 
+               $code .= '</form>';
 
                        // Add the HTML as a section:
                $pageContent .= $code;
@@ -203,7 +205,7 @@ class SC_file_rename {
                        'CONTENT' => $pageContent,
                        'PATH' => $this->title,
                );
-               
+
                $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
                $this->content.= $this->doc->endPage();
                $this->content = $this->doc->insertStylesAndJS($this->content);
@@ -219,19 +221,10 @@ class SC_file_rename {
        }
 }
 
-// Include extension?
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_rename.php'])  {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_rename.php']);
-}
-
-
-
-
-
-
-
-
 
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/file_rename.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/file_rename.php']);
+}
 
 
 
@@ -240,4 +233,5 @@ $SOBE = t3lib_div::makeInstance('SC_file_rename');
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
-?>
\ No newline at end of file
+
+?>