This commit was manufactured by cvs2svn to create tag
[Packages/TYPO3.CMS.git] / typo3 / file_list.php
index 1ed3feb..a9fe245 100755 (executable)
@@ -1,22 +1,22 @@
 <?php
 /***************************************************************
 *  Copyright notice
-*  
-*  (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
+*
+*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  All rights reserved
 *
-*  This script is part of the TYPO3 project. The TYPO3 project is 
+*  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
-* 
+*
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license 
+*  A copy is found in the textfile GPL.txt and important notices to the license
 *  from the author is found in LICENSE.txt distributed with these scripts.
 *
-* 
+*
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
-/** 
+/**
  * Web>File: File listing
  *
- * @author     Kasper Skårhøj <kasper@typo3.com>
- * @package TYPO3
- * @subpackage core
- * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
+ * $Id$
+ * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *   77: class SC_file_list
+ *  103:     function init()
+ *  130:     function menuConfig()
+ *  151:     function main()
+ *  288:     function printContent()
+ *
+ * TOTAL FUNCTIONS: 4
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
  */
 
+
 unset($MCONF);
 require ('mod/file/list/conf.php');
 require ('init.php');
@@ -47,57 +63,74 @@ $BE_USER->modAccess($MCONF,1);
 
 
 
-// ***************************
-// Script Classes
-// ***************************
+
+
+
+
+/**
+ * Script Class for creating the list of files in the File > Filelist module
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage core
+ */
 class SC_file_list {
        var $MCONF=array();                     // Module configuration
-       var $MOD_MENU=array();          
+       var $MOD_MENU=array();
        var $MOD_SETTINGS=array();
 
-               // GET vars set:
+
+               // Internal:
+       var $content;   // Accumulated HTML output
+       var $basicFF;   // File operation object (t3lib_basicFileFunctions)
+       var $doc;               // Template object
+
+               // Internal, static: GPvars:
        var $id;                // "id" -> the path to list.
        var $pointer;   // Pointer to listing
        var $table;             // "Table"
        var $imagemode; // Thumbnail mode.
+       var $cmd;
+       var $overwriteExistingFiles;
 
-       var $content;   // Accumulated HTML output
-       var $basicFF;   // File operation object (t3lib_basicFileFunctions)
-       var $doc;               // Template object
 
-       
-       
        /**
         * Initialize variables, file object
         * Incoming GET vars include id, pointer, table, imagemode
         *
         * @return      void
-        */     
+        */
        function init() {
                global $TYPO3_CONF_VARS,$FILEMOUNTS;
-                       
+
+                       // Setting GPvars:
+               $this->id = t3lib_div::_GP('id');
+               $this->pointer = t3lib_div::_GP('pointer');
+               $this->table = t3lib_div::_GP('table');
+               $this->imagemode = t3lib_div::_GP('imagemode');
+               $this->cmd = t3lib_div::_GP('cmd');
+               $this->overwriteExistingFiles = t3lib_div::_GP('overwriteExistingFiles');
+
+                       // Setting module name:
                $this->MCONF = $GLOBALS['MCONF'];
 
-               $this->id = t3lib_div::GPvar('id');
-               $this->pointer = t3lib_div::GPvar('pointer');
-               $this->table = t3lib_div::GPvar('table');
-               $this->imagemode = t3lib_div::GPvar('imagemode');
+                       // File operation object:
                $this->basicFF = t3lib_div::makeInstance('t3lib_basicFileFunctions');
                $this->basicFF->init($FILEMOUNTS,$TYPO3_CONF_VARS['BE']['fileExtensions']);
-               
+
                        // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc.
                $this->menuConfig();
        }
 
        /**
         * Setting the menu/session variables
-        * 
+        *
         * @return      void
-        */     
+        */
        function menuConfig()   {
                        // MENU-ITEMS:
                        // If array, then it's a selector box menu
-                       // If empty string it's just a variable, that'll be saved. 
+                       // If empty string it's just a variable, that'll be saved.
                        // Values NOT in this array will not be saved in the settings-array for the module.
                $this->MOD_MENU = array(
                        'sort' => '',
@@ -105,29 +138,28 @@ class SC_file_list {
                        'displayThumbs' => '',
                        'clipBoard' => ''
                );
-                       
+
                        // CLEANSE SETTINGS
-               $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::GPvar('SET'), $this->MCONF['name']);
+               $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
        }
 
        /**
         * Main function, creating the listing
         *
-        * @param       
-        * @return      
-        */     
+        * @return      void
+        */
        function main() {
-               global $BE_USER,$LANG,$BACK_PATH,$HTTP_GET_VARS,$HTTP_POST_VARS,$TYPO3_CONF_VARS,$FILEMOUNTS;
-               
+               global $BE_USER,$LANG,$BACK_PATH,$TYPO3_CONF_VARS,$FILEMOUNTS;
+
                        // Initialize the template object
                $this->doc = t3lib_div::makeInstance('template');
                $this->doc->backPath = $BACK_PATH;
                $this->doc->docType = 'xhtml_trans';
-               
+
                        // Validating the input "id" (the path, directory!) and checking it against the mounts of the user.
                $this->id = $this->basicFF->is_directory($this->id);
                $access = $this->id && $this->basicFF->checkPathAgainstMounts($this->id.'/');
-               
+
                        // There there was access to this file path, continue, make the list
                if ($access)    {
 
@@ -135,22 +167,22 @@ class SC_file_list {
                        $filelist = t3lib_div::makeInstance('fileList');
                        $filelist->backPath = $BACK_PATH;
                        $filelist->thumbs = $this->MOD_SETTINGS['displayThumbs']?1:$BE_USER->uc['thumbnailsByDefault'];
-                       
+
                                // Create clipboard object and initialize that
                        $filelist->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
                        $filelist->clipObj->fileMode=1;
                        $filelist->clipObj->initializeClipboard();
-       
-                       $CB = $HTTP_GET_VARS['CB'];
-                       if (t3lib_div::GPvar('cmd')=='setCB') $CB['el'] = $filelist->clipObj->cleanUpCBC(array_merge($HTTP_POST_VARS['CBH'],$HTTP_POST_VARS['CBC']),'_FILE');
+
+                       $CB = t3lib_div::_GET('CB');
+                       if ($this->cmd=='setCB') $CB['el'] = $filelist->clipObj->cleanUpCBC(array_merge(t3lib_div::_POST('CBH'),t3lib_div::_POST('CBC')),'_FILE');
                        if (!$this->MOD_SETTINGS['clipBoard'])  $CB['setP']='normal';
                        $filelist->clipObj->setCmd($CB);
                        $filelist->clipObj->cleanCurrent();
                        $filelist->clipObj->endClipboard();     // Saves
-                       
+
                                // If the "cmd" was to delete files from the list (clipboard thing), do that:
-                       if (t3lib_div::GPvar('cmd')=='delete')  {
-                               $items = $filelist->clipObj->cleanUpCBC($HTTP_POST_VARS['CBC'],'_FILE',1);
+                       if ($this->cmd=='delete')       {
+                               $items = $filelist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),'_FILE',1);
                                if (count($items))      {
                                                // Make command array:
                                        $FILE=array();
@@ -163,16 +195,14 @@ class SC_file_list {
                                        $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
                                        $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
                                        $fileProcessor->init_actionPerms($BE_USER->user['fileoper_perms']);
-                                       $fileProcessor->dontCheckForUnique = t3lib_div::GPvar('overwriteExistingFiles') ? 1 : 0;
+                                       $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0;
                                        $fileProcessor->start($FILE);
                                        $fileProcessor->processData();
-                                       
-                                               // Redirect to the status file.
-                                       Header('Location: '.t3lib_div::locationHeaderUrl('status_file.php'));
-                                       exit;
+
+                                       $fileProcessor->printLogErrorMessages();
                                }
                        }
-               
+
                                // Start up filelisting object, include settings.
                        $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
                        $filelist->start($this->id,$this->pointer,$this->MOD_SETTINGS['sort'],$this->MOD_SETTINGS['reverse'],$this->MOD_SETTINGS['clipBoard']);
@@ -185,12 +215,12 @@ class SC_file_list {
 
                                // Write the footer
                        $filelist->writeBottom();
-               
+
                                // Set top JavaScript:
                        $this->doc->JScode=$this->doc->wrapScriptTags('
 
                        if (top.fsMod) top.fsMod.recentIds["file"] = unescape("'.rawurlencode($this->id).'");
-                       function jumpToUrl(URL) {
+                       function jumpToUrl(URL) {       //
                                document.location = URL;
                        }
 
@@ -202,44 +232,61 @@ class SC_file_list {
                        $this->doc->bodyTagAdditions = $CMparts[1];
                        $this->doc->JScode.=$CMparts[0];
                        $this->doc->postCode.= $CMparts[2];
-               
-                                               
+
+
                                // Create output
                        $this->content='';
                        $this->content.=$this->doc->startPage($LANG->getLL('files'));
-                       $this->content.= '<form action="'.$filelist->listURL().'" method="post" name="dblistForm">';
+                       $this->content.= '<form action="'.htmlspecialchars($filelist->listURL()).'" method="post" name="dblistForm">';
                        $this->content.= $filelist->HTMLcode;
-                       $this->content.= '<input type="hidden" name="cmd"></form>';
-                       
-                       if ($filelist->HTMLcode)        {       // Making search form:
+                       $this->content.= '<input type="hidden" name="cmd" /></form>';
+
+                       if ($filelist->HTMLcode)        {       // Making listing options:
+
+                               $this->content.='
+
+                                       <!--
+                                               Listing options for clipboard and thumbnails
+                                       -->
+                                       <div id="typo3-listOptions">
+                               ';
+
                                        // Add "display thumbnails" checkbox:
                                $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[displayThumbs]',$this->MOD_SETTINGS['displayThumbs'],'file_list.php','').' '.$LANG->getLL('displayThumbs',1).'<br />';
-       
+
                                        // Add clipboard button
                                $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[clipBoard]',$this->MOD_SETTINGS['clipBoard'],'file_list.php','').' '.$LANG->getLL('clipBoard',1);
-                                       
+
+                               $this->content.='
+                                       </div>
+                               ';
+
+
                                        // Set clipboard:
                                if ($this->MOD_SETTINGS['clipBoard'])   $this->content.=$filelist->clipObj->printClipboard();
                        }
 
                                // Add shortcut
                        if ($BE_USER->mayMakeShortcut())        {
-                               $this->content.=$this->doc->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']);
+                               $this->content.='<br /><br />'.$this->doc->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']);
                        }
                } else {
                                // Create output - no access (no warning though)
                        $this->content='';
                        $this->content.=$this->doc->startPage($LANG->getLL('files'));
                }
+
+                       // Ending page:
+               $this->content.= $this->doc->endPage();
        }
 
        /**
-        * Ending page and outputting content from ->content
-        */     
+        * Outputting the accumulated content to screen
+        *
+        * @return      void
+        */
        function printContent() {
-               global $SOBE;
 
-               $this->content.= $this->doc->endPage();
                echo $this->content;
        }
 }