file_list.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 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 4579 2008-12-20 17:32:31Z ohader $
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 ('mod/file/list/conf.php');
00054 require ('init.php');
00055 require ('template.php');
00056 $LANG->includeLLFile('EXT:lang/locallang_mod_file_list.xml');
00057 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
00058 require_once (PATH_t3lib.'class.t3lib_extfilefunc.php');
00059 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
00060 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
00061 require_once (PATH_t3lib.'class.t3lib_parsehtml.php');
00062 require_once ('class.file_list.inc');
00063 $BE_USER->modAccess($MCONF,1);
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 /**
00072  * Script Class for creating the list of files in the File > Filelist module
00073  *
00074  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00075  * @package TYPO3
00076  * @subpackage core
00077  */
00078 class SC_file_list {
00079     var $MCONF=array();         // Module configuration
00080     var $MOD_MENU=array();
00081     var $MOD_SETTINGS=array();
00082 
00083 
00084         // Internal:
00085     var $content;   // Accumulated HTML output
00086 
00087     /**
00088      * File processing object
00089      *
00090      * @var t3lib_basicFileFunctions
00091      */
00092     var $basicFF;
00093 
00094     /**
00095      * Document template object
00096      *
00097      * @var template
00098      */
00099     var $doc;
00100 
00101         // Internal, static: GPvars:
00102     var $id;        // "id" -> the path to list.
00103     var $pointer;   // Pointer to listing
00104     var $table;     // "Table"
00105     var $imagemode; // Thumbnail mode.
00106     var $cmd;
00107     var $overwriteExistingFiles;
00108 
00109 
00110     /**
00111      * Initialize variables, file object
00112      * Incoming GET vars include id, pointer, table, imagemode
00113      *
00114      * @return  void
00115      */
00116     function init() {
00117         global $TYPO3_CONF_VARS,$FILEMOUNTS;
00118 
00119             // Setting GPvars:
00120         $this->id = t3lib_div::_GP('id');
00121         $this->pointer = t3lib_div::_GP('pointer');
00122         $this->table = t3lib_div::_GP('table');
00123         $this->imagemode = t3lib_div::_GP('imagemode');
00124         $this->cmd = t3lib_div::_GP('cmd');
00125         $this->overwriteExistingFiles = t3lib_div::_GP('overwriteExistingFiles');
00126 
00127             // Setting module name:
00128         $this->MCONF = $GLOBALS['MCONF'];
00129 
00130             // File operation object:
00131         $this->basicFF = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00132         $this->basicFF->init($FILEMOUNTS,$TYPO3_CONF_VARS['BE']['fileExtensions']);
00133 
00134             // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc.
00135         $this->menuConfig();
00136     }
00137 
00138     /**
00139      * Setting the menu/session variables
00140      *
00141      * @return  void
00142      */
00143     function menuConfig()   {
00144             // MENU-ITEMS:
00145             // If array, then it's a selector box menu
00146             // If empty string it's just a variable, that'll be saved.
00147             // Values NOT in this array will not be saved in the settings-array for the module.
00148         $this->MOD_MENU = array(
00149             'sort' => '',
00150             'reverse' => '',
00151             'displayThumbs' => '',
00152             'clipBoard' => ''
00153         );
00154 
00155             // CLEANSE SETTINGS
00156         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00157     }
00158 
00159     /**
00160      * Main function, creating the listing
00161      *
00162      * @return  void
00163      */
00164     function main() {
00165         global $BE_USER,$LANG,$BACK_PATH,$TYPO3_CONF_VARS,$FILEMOUNTS;
00166 
00167             // Initialize the template object
00168         $this->doc = t3lib_div::makeInstance('template');
00169         $this->doc->backPath = $BACK_PATH;
00170         $this->doc->setModuleTemplate('templates/file_list.html');
00171 
00172             // Validating the input "id" (the path, directory!) and checking it against the mounts of the user.
00173         $this->id = $this->basicFF->is_directory($this->id);
00174         $access = $this->id && $this->basicFF->checkPathAgainstMounts($this->id.'/');
00175 
00176             // There there was access to this file path, continue, make the list
00177         if ($access)    {
00178 
00179                 // Create filelisting object
00180             $this->filelist = t3lib_div::makeInstance('fileList');
00181             $this->filelist->backPath = $BACK_PATH;
00182             $this->filelist->thumbs = $this->MOD_SETTINGS['displayThumbs']?1:$BE_USER->uc['thumbnailsByDefault'];
00183 
00184                 // Create clipboard object and initialize that
00185             $this->filelist->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
00186             $this->filelist->clipObj->fileMode=1;
00187             $this->filelist->clipObj->initializeClipboard();
00188 
00189             $CB = t3lib_div::_GET('CB');
00190             if ($this->cmd=='setCB') $CB['el'] = $this->filelist->clipObj->cleanUpCBC(array_merge(t3lib_div::_POST('CBH'),t3lib_div::_POST('CBC')),'_FILE');
00191             if (!$this->MOD_SETTINGS['clipBoard'])  $CB['setP']='normal';
00192             $this->filelist->clipObj->setCmd($CB);
00193             $this->filelist->clipObj->cleanCurrent();
00194             $this->filelist->clipObj->endClipboard();   // Saves
00195 
00196                 // If the "cmd" was to delete files from the list (clipboard thing), do that:
00197             if ($this->cmd=='delete')   {
00198                 $items = $this->filelist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),'_FILE',1);
00199                 if (count($items))  {
00200                         // Make command array:
00201                     $FILE=array();
00202                     reset($items);
00203                     while(list(,$v)=each($items))   {
00204                         $FILE['delete'][]=array('data'=>$v);
00205                     }
00206 
00207                         // Init file processing object for deleting and pass the cmd array.
00208                     $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
00209                     $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
00210                     $fileProcessor->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions());
00211                     $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0;
00212                     $fileProcessor->start($FILE);
00213                     $fileProcessor->processData();
00214 
00215                     $fileProcessor->printLogErrorMessages();
00216                 }
00217             }
00218 
00219             if (!isset($this->MOD_SETTINGS['sort']))    {
00220                     // Set default sorting
00221                 $this->MOD_SETTINGS['sort'] = 'file';
00222                 $this->MOD_SETTINGS['reverse'] = 0;
00223             }
00224 
00225                 // Start up filelisting object, include settings.
00226             $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
00227             $this->filelist->start($this->id,$this->pointer,$this->MOD_SETTINGS['sort'],$this->MOD_SETTINGS['reverse'],$this->MOD_SETTINGS['clipBoard']);
00228 
00229                 // Generate the list
00230             $this->filelist->generateList();
00231 
00232                 // Write the footer
00233             $this->filelist->writeBottom();
00234 
00235                 // Set top JavaScript:
00236             $this->doc->JScode=$this->doc->wrapScriptTags('
00237 
00238             if (top.fsMod) top.fsMod.recentIds["file"] = unescape("'.rawurlencode($this->id).'");
00239             function jumpToUrl(URL) {   //
00240                 window.location.href = URL;
00241             }
00242 
00243             '.$this->filelist->CBfunctions()    // ... and add clipboard JavaScript functions
00244             );
00245 
00246                 // This will return content necessary for the context sensitive clickmenus to work: bodytag events, JavaScript functions and DIV-layers.
00247             $this->doc->getContextMenuCode();
00248 
00249                 // Setting up the buttons and markers for docheader
00250             list($buttons, $otherMarkers) = $this->filelist->getButtonsAndOtherMarkers($this->id);
00251 
00252                 // add the folder info to the marker array
00253             $otherMarkers['FOLDER_INFO'] = $this->filelist->getFolderInfo();
00254 
00255             $docHeaderButtons = array_merge($this->getButtons(), $buttons);
00256 
00257                 // Build the <body> for the module
00258             $this->content = $this->doc->startPage($LANG->getLL('files'));
00259 
00260                 // Create output
00261             $pageContent='';
00262             $pageContent.= '<form action="'.htmlspecialchars($this->filelist->listURL()).'" method="post" name="dblistForm">';
00263             $pageContent.= $this->filelist->HTMLcode;
00264             $pageContent.= '<input type="hidden" name="cmd" /></form>';
00265 
00266 
00267             if ($this->filelist->HTMLcode)  {   // Making listing options:
00268 
00269                 $pageContent.='
00270 
00271                     <!--
00272                         Listing options for clipboard and thumbnails
00273                     -->
00274                     <div id="typo3-listOptions">
00275                 ';
00276 
00277                     // Add "display thumbnails" checkbox:
00278                 $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 />';
00279 
00280                     // Add clipboard button
00281                 $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>';
00282 
00283                 $pageContent.='
00284                     </div>
00285                 ';
00286 
00287 
00288                     // Set clipboard:
00289                 if ($this->MOD_SETTINGS['clipBoard'])   {
00290                     $pageContent.=$this->filelist->clipObj->printClipboard();
00291                     $pageContent.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_clipboard', $GLOBALS['BACK_PATH']);
00292                 }
00293             }
00294 
00295             $markerArray = array(
00296                 'CSH' => $docHeaderButtons['csh'],
00297                 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
00298                 'CONTENT' => $pageContent
00299             );
00300 
00301             $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, array_merge($markerArray, $otherMarkers));
00302             $this->content.= $this->doc->endPage();
00303             $this->content = $this->doc->insertStylesAndJS($this->content);
00304 
00305         } else {
00306                 // Create output - no access (no warning though)
00307             $this->content = '';
00308             $this->content .= $this->doc->startPage($LANG->getLL('files'));
00309             $this->content .= $this->doc->endPage();
00310             $this->content = $this->doc->insertStylesAndJS($this->content);
00311         }
00312 
00313 
00314     }
00315 
00316     /**
00317      * Outputting the accumulated content to screen
00318      *
00319      * @return  void
00320      */
00321     function printContent() {
00322         echo $this->content;
00323     }
00324 
00325     /**
00326      * Create the panel of buttons for submitting the form or otherwise perform operations.
00327      *
00328      * @return  array   all available buttons as an assoc. array
00329      */
00330     function getButtons()   {
00331         global $TCA, $LANG, $BACK_PATH, $BE_USER;
00332 
00333         $buttons = array(
00334             'csh' => '',
00335             'shortcut' => '',
00336             'upload' => '',
00337             'new' => '',
00338         );
00339 
00340             // Add shortcut
00341         if ($BE_USER->mayMakeShortcut())    {
00342             $buttons['shortcut'] = $this->doc->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']);
00343         }
00344 
00345             // FileList Module CSH:
00346         $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_module', $GLOBALS['BACK_PATH'], '', TRUE);
00347 
00348             // upload button
00349         $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/upload.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.upload',1)).'" alt="" />';
00350         $buttons['upload'] = '<a href="'.$BACK_PATH.'file_upload.php?target='.rawurlencode($this->id).'&returnUrl='.rawurlencode($this->filelist->listURL()).'">'.$theIcon.'</a>';
00351 
00352         $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_file.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.new',1)).'" alt="" />';
00353         $buttons['new'] = '<a href="'.$BACK_PATH.'file_newfolder.php?target='.rawurlencode($this->id).'&returnUrl='.rawurlencode($this->filelist->listURL()).'">'.$theIcon.'</a>';
00354 
00355         return $buttons;
00356     }
00357 
00358 }
00359 
00360 
00361 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']) {
00362     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']);
00363 }
00364 
00365 
00366 
00367 // Make instance:
00368 $SOBE = t3lib_div::makeInstance('SC_file_list');
00369 $SOBE->init();
00370 $SOBE->main();
00371 $SOBE->printContent();
00372 
00373 ?>

Generated on Sat Jan 3 04:23:28 2009 for TYPO3 API by  doxygen 1.4.7