Documentation TYPO3 par Ameos

file_list.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 ***************************************************************/
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 ('class.file_list.inc');
00062 $BE_USER->modAccess($MCONF,1);
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00077 class SC_file_list {
00078         var $MCONF=array();                     // Module configuration
00079         var $MOD_MENU=array();
00080         var $MOD_SETTINGS=array();
00081 
00082 
00083                 // Internal:
00084         var $content;   // Accumulated HTML output
00085         var $basicFF;   // File operation object (t3lib_basicFileFunctions)
00086         var $doc;               // Template object
00087 
00088                 // Internal, static: GPvars:
00089         var $id;                // "id" -> the path to list.
00090         var $pointer;   // Pointer to listing
00091         var $table;             // "Table"
00092         var $imagemode; // Thumbnail mode.
00093         var $cmd;
00094         var $overwriteExistingFiles;
00095 
00096 
00103         function init() {
00104                 global $TYPO3_CONF_VARS,$FILEMOUNTS;
00105 
00106                         // Setting GPvars:
00107                 $this->id = t3lib_div::_GP('id');
00108                 $this->pointer = t3lib_div::_GP('pointer');
00109                 $this->table = t3lib_div::_GP('table');
00110                 $this->imagemode = t3lib_div::_GP('imagemode');
00111                 $this->cmd = t3lib_div::_GP('cmd');
00112                 $this->overwriteExistingFiles = t3lib_div::_GP('overwriteExistingFiles');
00113 
00114                         // Setting module name:
00115                 $this->MCONF = $GLOBALS['MCONF'];
00116 
00117                         // File operation object:
00118                 $this->basicFF = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00119                 $this->basicFF->init($FILEMOUNTS,$TYPO3_CONF_VARS['BE']['fileExtensions']);
00120 
00121                         // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc.
00122                 $this->menuConfig();
00123         }
00124 
00130         function menuConfig()   {
00131                         // MENU-ITEMS:
00132                         // If array, then it's a selector box menu
00133                         // If empty string it's just a variable, that'll be saved.
00134                         // Values NOT in this array will not be saved in the settings-array for the module.
00135                 $this->MOD_MENU = array(
00136                         'sort' => '',
00137                         'reverse' => '',
00138                         'displayThumbs' => '',
00139                         'clipBoard' => ''
00140                 );
00141 
00142                         // CLEANSE SETTINGS
00143                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00144         }
00145 
00151         function main() {
00152                 global $BE_USER,$LANG,$BACK_PATH,$TYPO3_CONF_VARS,$FILEMOUNTS;
00153 
00154                         // Initialize the template object
00155                 $this->doc = t3lib_div::makeInstance('template');
00156                 $this->doc->backPath = $BACK_PATH;
00157                 $this->doc->docType = 'xhtml_trans';
00158 
00159                         // Validating the input "id" (the path, directory!) and checking it against the mounts of the user.
00160                 $this->id = $this->basicFF->is_directory($this->id);
00161                 $access = $this->id && $this->basicFF->checkPathAgainstMounts($this->id.'/');
00162 
00163                         // There there was access to this file path, continue, make the list
00164                 if ($access)    {
00165 
00166                                 // Create filelisting object
00167                         $filelist = t3lib_div::makeInstance('fileList');
00168                         $filelist->backPath = $BACK_PATH;
00169                         $filelist->thumbs = $this->MOD_SETTINGS['displayThumbs']?1:$BE_USER->uc['thumbnailsByDefault'];
00170 
00171                                 // Create clipboard object and initialize that
00172                         $filelist->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
00173                         $filelist->clipObj->fileMode=1;
00174                         $filelist->clipObj->initializeClipboard();
00175 
00176                         $CB = t3lib_div::_GET('CB');
00177                         if ($this->cmd=='setCB') $CB['el'] = $filelist->clipObj->cleanUpCBC(array_merge(t3lib_div::_POST('CBH'),t3lib_div::_POST('CBC')),'_FILE');
00178                         if (!$this->MOD_SETTINGS['clipBoard'])  $CB['setP']='normal';
00179                         $filelist->clipObj->setCmd($CB);
00180                         $filelist->clipObj->cleanCurrent();
00181                         $filelist->clipObj->endClipboard();     // Saves
00182 
00183                                 // If the "cmd" was to delete files from the list (clipboard thing), do that:
00184                         if ($this->cmd=='delete')       {
00185                                 $items = $filelist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),'_FILE',1);
00186                                 if (count($items))      {
00187                                                 // Make command array:
00188                                         $FILE=array();
00189                                         reset($items);
00190                                         while(list(,$v)=each($items))   {
00191                                                 $FILE['delete'][]=array('data'=>$v);
00192                                         }
00193 
00194                                                 // Init file processing object for deleting and pass the cmd array.
00195                                         $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
00196                                         $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
00197                                         $fileProcessor->init_actionPerms($BE_USER->user['fileoper_perms']);
00198                                         $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0;
00199                                         $fileProcessor->start($FILE);
00200                                         $fileProcessor->processData();
00201 
00202                                         $fileProcessor->printLogErrorMessages();
00203                                 }
00204                         }
00205 
00206                                 // Start up filelisting object, include settings.
00207                         $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
00208                         $filelist->start($this->id,$this->pointer,$this->MOD_SETTINGS['sort'],$this->MOD_SETTINGS['reverse'],$this->MOD_SETTINGS['clipBoard']);
00209 
00210                                 // Write the header
00211                         $filelist->writeTop($this->id);
00212 
00213                                 // Generate the list
00214                         $filelist->generateList($this->id,$this->table);
00215 
00216                                 // Write the footer
00217                         $filelist->writeBottom();
00218 
00219                                 // Set top JavaScript:
00220                         $this->doc->JScode=$this->doc->wrapScriptTags('
00221 
00222                         if (top.fsMod) top.fsMod.recentIds["file"] = unescape("'.rawurlencode($this->id).'");
00223                         function jumpToUrl(URL) {       //
00224                                 document.location = URL;
00225                         }
00226 
00227                         '.$filelist->CBfunctions()      // ... and add clipboard JavaScript functions
00228                         );
00229 
00230                                 // This will return content necessary for the context sensitive clickmenus to work: bodytag events, JavaScript functions and DIV-layers.
00231                         $CMparts=$this->doc->getContextMenuCode();
00232                         $this->doc->bodyTagAdditions = $CMparts[1];
00233                         $this->doc->JScode.=$CMparts[0];
00234                         $this->doc->postCode.= $CMparts[2];
00235 
00236 
00237                                 // Create output
00238                         $this->content='';
00239                         $this->content.=$this->doc->startPage($LANG->getLL('files'));
00240                         $this->content.= '<form action="'.htmlspecialchars($filelist->listURL()).'" method="post" name="dblistForm">';
00241                         $this->content.= $filelist->HTMLcode;
00242                         $this->content.= '<input type="hidden" name="cmd" /></form>';
00243 
00244                                 // FileList Module CSH:
00245                         $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_module', $GLOBALS['BACK_PATH'],'<br/>|');
00246 
00247                         if ($filelist->HTMLcode)        {       // Making listing options:
00248 
00249                                 $this->content.='
00250 
00251                                         <!--
00252                                                 Listing options for clipboard and thumbnails
00253                                         -->
00254                                         <div id="typo3-listOptions">
00255                                 ';
00256 
00257                                         // Add "display thumbnails" checkbox:
00258                                 $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[displayThumbs]',$this->MOD_SETTINGS['displayThumbs'],'file_list.php','').' '.$LANG->getLL('displayThumbs',1).'<br />';
00259 
00260                                         // Add clipboard button
00261                                 $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[clipBoard]',$this->MOD_SETTINGS['clipBoard'],'file_list.php','').' '.$LANG->getLL('clipBoard',1);
00262 
00263                                 $this->content.='
00264                                         </div>
00265                                 ';
00266                                 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_options', $GLOBALS['BACK_PATH']);
00267 
00268 
00269                                         // Set clipboard:
00270                                 if ($this->MOD_SETTINGS['clipBoard'])   {
00271                                         $this->content.=$filelist->clipObj->printClipboard();
00272                                         $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_clipboard', $GLOBALS['BACK_PATH']);
00273                                 }
00274                         }
00275 
00276                                 // Add shortcut
00277                         if ($BE_USER->mayMakeShortcut())        {
00278                                 $this->content.='<br /><br />'.$this->doc->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']);
00279                         }
00280                 } else {
00281                                 // Create output - no access (no warning though)
00282                         $this->content='';
00283                         $this->content.=$this->doc->startPage($LANG->getLL('files'));
00284                 }
00285 
00286                         // Ending page:
00287                 $this->content.= $this->doc->endPage();
00288         }
00289 
00295         function printContent() {
00296 
00297                 echo $this->content;
00298         }
00299 }
00300 
00301 // Include extension?
00302 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php'])     {
00303         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']);
00304 }
00305 
00306 
00307 
00308 
00309 
00310 
00311 
00312 
00313 
00314 
00315 
00316 
00317 // Make instance:
00318 $SOBE = t3lib_div::makeInstance('SC_file_list');
00319 $SOBE->init();
00320 $SOBE->main();
00321 $SOBE->printContent();
00322 
00323 
00324 if ($TYPO3_CONF_VARS['BE']['compressionLevel']) {
00325         new gzip_encode($TYPO3_CONF_VARS['BE']['compressionLevel']);
00326 }
00327 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6