file_list.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2010 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: File listing
00029  *
00030  * $Id: file_list.php 8231 2010-07-18 20:07:39Z steffenk $
00031  * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
00032  *
00033  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *   77: class SC_file_list
00041  *  103:     function init()
00042  *  130:     function menuConfig()
00043  *  151:     function main()
00044  *  325:     function printContent()
00045  *
00046  * TOTAL FUNCTIONS: 4
00047  * (This index is automatically created/updated by the extension "extdeveval")
00048  *
00049  */
00050 
00051 
00052 unset($MCONF);
00053 require ('conf.php');
00054 require ($BACK_PATH . 'init.php');
00055 require ($BACK_PATH . 'template.php');
00056 $LANG->includeLLFile('EXT:lang/locallang_mod_file_list.xml');
00057 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00058 require_once ($BACK_PATH . 'class.file_list.inc');
00059 $BE_USER->modAccess($MCONF,1);
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 /**
00068  * Script Class for creating the list of files in the File > Filelist module
00069  *
00070  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00071  * @package TYPO3
00072  * @subpackage core
00073  */
00074 class SC_file_list {
00075     var $MCONF=array();         // Module configuration
00076     var $MOD_MENU=array();
00077     var $MOD_SETTINGS=array();
00078 
00079 
00080         // Internal:
00081     var $content;   // Accumulated HTML output
00082 
00083     /**
00084      * File processing object
00085      *
00086      * @var t3lib_basicFileFunctions
00087      */
00088     var $basicFF;
00089 
00090     /**
00091      * Document template object
00092      *
00093      * @var template
00094      */
00095     var $doc;
00096 
00097         // Internal, static: GPvars:
00098     var $id;        // "id" -> the path to list.
00099     var $pointer;   // Pointer to listing
00100     var $table;     // "Table"
00101     var $imagemode; // Thumbnail mode.
00102     var $cmd;
00103     var $overwriteExistingFiles;
00104 
00105 
00106     /**
00107      * Initialize variables, file object
00108      * Incoming GET vars include id, pointer, table, imagemode
00109      *
00110      * @return  void
00111      */
00112     function init() {
00113         global $TYPO3_CONF_VARS,$FILEMOUNTS;
00114 
00115             // Setting GPvars:
00116         $this->id = t3lib_div::_GP('id');
00117         $this->pointer = t3lib_div::_GP('pointer');
00118         $this->table = t3lib_div::_GP('table');
00119         $this->imagemode = t3lib_div::_GP('imagemode');
00120         $this->cmd = t3lib_div::_GP('cmd');
00121         $this->overwriteExistingFiles = t3lib_div::_GP('overwriteExistingFiles');
00122 
00123             // Setting module name:
00124         $this->MCONF = $GLOBALS['MCONF'];
00125 
00126             // File operation object:
00127         $this->basicFF = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00128         $this->basicFF->init($FILEMOUNTS,$TYPO3_CONF_VARS['BE']['fileExtensions']);
00129 
00130             // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc.
00131         $this->menuConfig();
00132     }
00133 
00134     /**
00135      * Setting the menu/session variables
00136      *
00137      * @return  void
00138      */
00139     function menuConfig()   {
00140             // MENU-ITEMS:
00141             // If array, then it's a selector box menu
00142             // If empty string it's just a variable, that'll be saved.
00143             // Values NOT in this array will not be saved in the settings-array for the module.
00144         $this->MOD_MENU = array(
00145             'sort' => '',
00146             'reverse' => '',
00147             'displayThumbs' => '',
00148             'clipBoard' => '',
00149             'bigControlPanel' => ''
00150         );
00151 
00152             // CLEANSE SETTINGS
00153         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00154     }
00155 
00156     /**
00157      * Main function, creating the listing
00158      *
00159      * @return  void
00160      */
00161     function main() {
00162         global $BE_USER,$LANG,$BACK_PATH,$TYPO3_CONF_VARS,$FILEMOUNTS;
00163 
00164             // Initialize the template object
00165         $this->doc = t3lib_div::makeInstance('template');
00166         $this->doc->backPath = $BACK_PATH;
00167         $this->doc->setModuleTemplate('templates/file_list.html');
00168         $this->doc->getPageRenderer()->loadPrototype();
00169 
00170             // Validating the input "id" (the path, directory!) and checking it against the mounts of the user.
00171         $this->id = $this->basicFF->is_directory($this->id);
00172         $access = $this->id && $this->basicFF->checkPathAgainstMounts($this->id.'/');
00173 
00174             // There there was access to this file path, continue, make the list
00175         if ($access)    {
00176                 // include the initialization for the flash uploader
00177             if ($GLOBALS['BE_USER']->uc['enableFlashUploader']) {
00178 
00179                 $this->doc->JScodeArray['flashUploader'] = '
00180                     if (top.TYPO3.FileUploadWindow.isFlashAvailable()) {
00181                         document.observe("dom:loaded", function() {
00182                                 // monitor the button
00183                             $("button-upload").observe("click", initFlashUploader);
00184 
00185                             function initFlashUploader(event) {
00186                                     // set the page specific options for the flashUploader
00187                                 var flashUploadOptions = {
00188                                     uploadURL:           top.TS.PATH_typo3 + "ajax.php",
00189                                     uploadFileSizeLimit: "' . t3lib_div::getMaxUploadFileSize() . '",
00190                                     uploadFileTypes: {
00191                                         allow:  "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow'] . '",
00192                                         deny: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny'] . '"
00193                                     },
00194                                     uploadFilePostName:  "upload_1",
00195                                     uploadPostParams: {
00196                                         "file[upload][1][target]": "' . $this->id . '",
00197                                         "file[upload][1][data]": 1,
00198                                         "file[upload][1][charset]": "utf-8",
00199                                         "ajaxID": "TYPO3_tcefile::process"
00200                                     }
00201                                 };
00202 
00203                                     // get the flashUploaderWindow instance from the parent frame
00204                                 var flashUploader = top.TYPO3.FileUploadWindow.getInstance(flashUploadOptions);
00205                                 // add an additional function inside the container to show the checkbox option
00206                                 var infoComponent = new top.Ext.Panel({
00207                                     autoEl: { tag: "div" },
00208                                     height: "auto",
00209                                     bodyBorder: false,
00210                                     border: false,
00211                                     hideBorders: true,
00212                                     cls: "t3-upload-window-infopanel",
00213                                     id: "t3-upload-window-infopanel-addition",
00214                                     html: \'<label for="overrideExistingFilesCheckbox"><input id="overrideExistingFilesCheckbox" type="checkbox" onclick="setFlashPostOptionOverwriteExistingFiles(this);" />\' + top.String.format(top.TYPO3.LLL.fileUpload.infoComponentOverrideFiles) + \'</label>\'
00215                                 });
00216                                 flashUploader.add(infoComponent);
00217 
00218                                     // do a reload of this frame once all uploads are done
00219                                 flashUploader.on("totalcomplete", function() {
00220                                     window.location.reload();
00221                                 });
00222 
00223                                     // this is the callback function that delivers the additional post parameter to the flash application
00224                                 top.setFlashPostOptionOverwriteExistingFiles = function(checkbox) {
00225                                     var uploader = top.TYPO3.getInstance("FileUploadWindow");
00226                                     if (uploader.isVisible()) {
00227                                         uploader.swf.addPostParam("overwriteExistingFiles", (checkbox.checked == true ? 1 : 0));
00228                                     }
00229                                 };
00230 
00231                                 event.stop();
00232                             };
00233                         });
00234                     }
00235                 ';
00236             }
00237                 // Create filelisting object
00238             $this->filelist = t3lib_div::makeInstance('fileList');
00239             $this->filelist->backPath = $BACK_PATH;
00240 
00241                 // if user never opened the list module, set the value for displayThumbs
00242             if (!isset($this->MOD_SETTINGS['displayThumbs'])) {
00243                 $this->MOD_SETTINGS['displayThumbs'] = $BE_USER->uc['thumbnailsByDefault'];
00244             }
00245             $this->filelist->thumbs = $this->MOD_SETTINGS['displayThumbs'];
00246 
00247                 // Create clipboard object and initialize that
00248             $this->filelist->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
00249             $this->filelist->clipObj->fileMode=1;
00250             $this->filelist->clipObj->initializeClipboard();
00251 
00252             $CB = t3lib_div::_GET('CB');
00253             if ($this->cmd=='setCB') $CB['el'] = $this->filelist->clipObj->cleanUpCBC(array_merge(t3lib_div::_POST('CBH'),t3lib_div::_POST('CBC')),'_FILE');
00254             if (!$this->MOD_SETTINGS['clipBoard'])  $CB['setP']='normal';
00255             $this->filelist->clipObj->setCmd($CB);
00256             $this->filelist->clipObj->cleanCurrent();
00257             $this->filelist->clipObj->endClipboard();   // Saves
00258 
00259                 // If the "cmd" was to delete files from the list (clipboard thing), do that:
00260             if ($this->cmd=='delete')   {
00261                 $items = $this->filelist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),'_FILE',1);
00262                 if (count($items))  {
00263                         // Make command array:
00264                     $FILE=array();
00265                     foreach ($items as $v) {
00266                         $FILE['delete'][]=array('data'=>$v);
00267                     }
00268 
00269                         // Init file processing object for deleting and pass the cmd array.
00270                     $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
00271                     $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
00272                     $fileProcessor->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions());
00273                     $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0;
00274                     $fileProcessor->start($FILE);
00275                     $fileProcessor->processData();
00276 
00277                     $fileProcessor->printLogErrorMessages();
00278                 }
00279             }
00280 
00281             if (!isset($this->MOD_SETTINGS['sort']))    {
00282                     // Set default sorting
00283                 $this->MOD_SETTINGS['sort'] = 'file';
00284                 $this->MOD_SETTINGS['reverse'] = 0;
00285             }
00286 
00287                 // Start up filelisting object, include settings.
00288             $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
00289             $this->filelist->start($this->id, $this->pointer, $this->MOD_SETTINGS['sort'], $this->MOD_SETTINGS['reverse'], $this->MOD_SETTINGS['clipBoard'], $this->MOD_SETTINGS['bigControlPanel']);
00290 
00291                 // Generate the list
00292             $this->filelist->generateList();
00293 
00294                 // Write the footer
00295             $this->filelist->writeBottom();
00296 
00297                 // Set top JavaScript:
00298             $this->doc->JScode=$this->doc->wrapScriptTags('
00299 
00300             if (top.fsMod) top.fsMod.recentIds["file"] = unescape("'.rawurlencode($this->id).'");
00301             function jumpToUrl(URL) {   //
00302                 window.location.href = URL;
00303             }
00304 
00305             '.$this->filelist->CBfunctions()    // ... and add clipboard JavaScript functions
00306             );
00307 
00308                 // This will return content necessary for the context sensitive clickmenus to work: bodytag events, JavaScript functions and DIV-layers.
00309             $this->doc->getContextMenuCode();
00310 
00311                 // Setting up the buttons and markers for docheader
00312             list($buttons, $otherMarkers) = $this->filelist->getButtonsAndOtherMarkers($this->id);
00313 
00314                 // add the folder info to the marker array
00315             $otherMarkers['FOLDER_INFO'] = $this->filelist->getFolderInfo();
00316 
00317             $docHeaderButtons = array_merge($this->getButtons(), $buttons);
00318 
00319                 // Build the <body> for the module
00320             $this->content = $this->doc->startPage($LANG->getLL('files'));
00321 
00322                 // Create output
00323             $pageContent='';
00324             $pageContent.= '<form action="'.htmlspecialchars($this->filelist->listURL()).'" method="post" name="dblistForm">';
00325             $pageContent.= $this->filelist->HTMLcode;
00326             $pageContent.= '<input type="hidden" name="cmd" /></form>';
00327 
00328 
00329             if ($this->filelist->HTMLcode)  {   // Making listing options:
00330 
00331                 $pageContent.='
00332 
00333                     <!--
00334                         Listing options for clipboard and thumbnails
00335                     -->
00336                     <div id="typo3-listOptions">
00337                 ';
00338 
00339                     // Add "display bigControlPanel" checkbox:
00340                 $pageContent.=t3lib_BEfunc::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], 'file_list.php', '', 'id="bigControlPanel"') . '<label for="bigControlPanel"> ' .$LANG->getLL('bigControlPanel', 1) . '</label><br />';
00341 
00342                     // Add "display thumbnails" checkbox:
00343                 $pageContent.=t3lib_BEfunc::getFuncCheck($this->id,'SET[displayThumbs]',$this->MOD_SETTINGS['displayThumbs'],'file_list.php','','id="checkDisplayThumbs"').' <label for="checkDisplayThumbs">'.$LANG->getLL('displayThumbs',1).'</label><br />';
00344 
00345                     // Add clipboard button
00346                 $pageContent.=t3lib_BEfunc::getFuncCheck($this->id,'SET[clipBoard]',$this->MOD_SETTINGS['clipBoard'],'file_list.php','','id="checkClipBoard"').' <label for="checkClipBoard">'.$LANG->getLL('clipBoard',1).'</label>';
00347 
00348                 $pageContent.='
00349                     </div>
00350                 ';
00351 
00352 
00353                     // Set clipboard:
00354                 if ($this->MOD_SETTINGS['clipBoard'])   {
00355                     $pageContent.=$this->filelist->clipObj->printClipboard();
00356                     $pageContent.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_clipboard', $GLOBALS['BACK_PATH']);
00357                 }
00358             }
00359 
00360             $markerArray = array(
00361                 'CSH' => $docHeaderButtons['csh'],
00362                 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
00363                 'CONTENT' => $pageContent
00364             );
00365 
00366             $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, array_merge($markerArray, $otherMarkers));
00367             $this->content.= $this->doc->endPage();
00368             $this->content = $this->doc->insertStylesAndJS($this->content);
00369 
00370         } else {
00371                 // Create output - no access (no warning though)
00372             $this->content = '';
00373             $this->content .= $this->doc->startPage($LANG->getLL('files'));
00374             $this->content .= $this->doc->endPage();
00375             $this->content = $this->doc->insertStylesAndJS($this->content);
00376         }
00377 
00378 
00379     }
00380 
00381     /**
00382      * Outputting the accumulated content to screen
00383      *
00384      * @return  void
00385      */
00386     function printContent() {
00387         echo $this->content;
00388     }
00389 
00390     /**
00391      * Create the panel of buttons for submitting the form or otherwise perform operations.
00392      *
00393      * @return  array   all available buttons as an assoc. array
00394      */
00395     function getButtons()   {
00396         global $TCA, $LANG, $BACK_PATH, $BE_USER;
00397 
00398         $buttons = array(
00399             'csh' => '',
00400             'shortcut' => '',
00401             'upload' => '',
00402             'new' => '',
00403         );
00404 
00405             // Add shortcut
00406         if ($BE_USER->mayMakeShortcut())    {
00407             $buttons['shortcut'] = $this->doc->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']);
00408         }
00409 
00410             // FileList Module CSH:
00411         $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_module', $GLOBALS['BACK_PATH'], '', TRUE);
00412 
00413             // upload button
00414         $buttons['upload'] = '<a href="' . $BACK_PATH . 'file_upload.php?target=' . rawurlencode($this->id) . '&amp;returnUrl=' . rawurlencode($this->filelist->listURL()) . '" id="button-upload" title="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.upload',1)).'">' .
00415             t3lib_iconWorks::getSpriteIcon('actions-edit-upload') .
00416         '</a>';
00417 
00418         $buttons['new'] = '<a href="' . $BACK_PATH . 'file_newfolder.php?target=' . rawurlencode($this->id) . '&amp;returnUrl=' . rawurlencode($this->filelist->listURL()) . '" title="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.new',1)).'">' .
00419             t3lib_iconWorks::getSpriteIcon('actions-document-new') .
00420         '</a>';
00421 
00422         return $buttons;
00423     }
00424 
00425 }
00426 
00427 
00428 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']) {
00429     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']);
00430 }
00431 
00432 
00433 
00434 // Make instance:
00435 $SOBE = t3lib_div::makeInstance('SC_file_list');
00436 $SOBE->init();
00437 $SOBE->main();
00438 $SOBE->printContent();
00439 
00440 ?>

Generated on Sat Jul 24 04:17:34 2010 for TYPO3 API by  doxygen 1.4.7