committed #8507 - added alt to img tags and changed reference to locallang file to...
[Packages/TYPO3.CMS.git] / typo3 / file_list.php
old mode 100755 (executable)
new mode 100644 (file)
index 6ab271d..c0fccda
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -41,7 +41,7 @@
  *  103:     function init()
  *  130:     function menuConfig()
  *  151:     function main()
- *  295:     function printContent()
+ *  325:     function printContent()
  *
  * TOTAL FUNCTIONS: 4
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -58,6 +58,7 @@ require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
 require_once (PATH_t3lib.'class.t3lib_extfilefunc.php');
 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
+require_once (PATH_t3lib.'class.t3lib_parsehtml.php');
 require_once ('class.file_list.inc');
 $BE_USER->modAccess($MCONF,1);
 
@@ -82,8 +83,20 @@ class SC_file_list {
 
                // Internal:
        var $content;   // Accumulated HTML output
-       var $basicFF;   // File operation object (t3lib_basicFileFunctions)
-       var $doc;               // Template object
+
+       /**
+        * File processing object
+        *
+        * @var t3lib_basicFileFunctions
+        */
+       var $basicFF;
+
+       /**
+        * Document template object
+        *
+        * @var template
+        */
+       var $doc;
 
                // Internal, static: GPvars:
        var $id;                // "id" -> the path to list.
@@ -154,7 +167,7 @@ class SC_file_list {
                        // Initialize the template object
                $this->doc = t3lib_div::makeInstance('template');
                $this->doc->backPath = $BACK_PATH;
-               $this->doc->docType = 'xhtml_trans';
+               $this->doc->setModuleTemplate('templates/file_list.html');
 
                        // Validating the input "id" (the path, directory!) and checking it against the mounts of the user.
                $this->id = $this->basicFF->is_directory($this->id);
@@ -164,25 +177,25 @@ class SC_file_list {
                if ($access)    {
 
                                // Create filelisting object
-                       $filelist = t3lib_div::makeInstance('fileList');
-                       $filelist->backPath = $BACK_PATH;
-                       $filelist->thumbs = $this->MOD_SETTINGS['displayThumbs']?1:$BE_USER->uc['thumbnailsByDefault'];
+                       $this->filelist = t3lib_div::makeInstance('fileList');
+                       $this->filelist->backPath = $BACK_PATH;
+                       $this->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();
+                       $this->filelist->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
+                       $this->filelist->clipObj->fileMode=1;
+                       $this->filelist->clipObj->initializeClipboard();
 
                        $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->cmd=='setCB') $CB['el'] = $this->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
+                       $this->filelist->clipObj->setCmd($CB);
+                       $this->filelist->clipObj->cleanCurrent();
+                       $this->filelist->clipObj->endClipboard();       // Saves
 
                                // If the "cmd" was to delete files from the list (clipboard thing), do that:
                        if ($this->cmd=='delete')       {
-                               $items = $filelist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),'_FILE',1);
+                               $items = $this->filelist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),'_FILE',1);
                                if (count($items))      {
                                                // Make command array:
                                        $FILE=array();
@@ -194,7 +207,7 @@ class SC_file_list {
                                                // Init file processing object for deleting and pass the cmd array.
                                        $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
                                        $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
-                                       $fileProcessor->init_actionPerms($BE_USER->user['fileoper_perms']);
+                                       $fileProcessor->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions());
                                        $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0;
                                        $fileProcessor->start($FILE);
                                        $fileProcessor->processData();
@@ -203,50 +216,57 @@ class SC_file_list {
                                }
                        }
 
+                       if (!isset($this->MOD_SETTINGS['sort']))        {
+                                       // Set default sorting
+                               $this->MOD_SETTINGS['sort'] = 'file';
+                               $this->MOD_SETTINGS['reverse'] = 0;
+                       }
+
                                // 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']);
-
-                               // Write the header
-                       $filelist->writeTop($this->id);
+                       $this->filelist->start($this->id,$this->pointer,$this->MOD_SETTINGS['sort'],$this->MOD_SETTINGS['reverse'],$this->MOD_SETTINGS['clipBoard']);
 
                                // Generate the list
-                       $filelist->generateList();
+                       $this->filelist->generateList();
 
                                // Write the footer
-                       $filelist->writeBottom();
+                       $this->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) {       //
-                               document.location = URL;
+                               window.location.href = URL;
                        }
 
-                       '.$filelist->CBfunctions()      // ... and add clipboard JavaScript functions
+                       '.$this->filelist->CBfunctions()        // ... and add clipboard JavaScript functions
                        );
 
                                // This will return content necessary for the context sensitive clickmenus to work: bodytag events, JavaScript functions and DIV-layers.
-                       $CMparts=$this->doc->getContextMenuCode();
-                       $this->doc->bodyTagAdditions = $CMparts[1];
-                       $this->doc->JScode.=$CMparts[0];
-                       $this->doc->postCode.= $CMparts[2];
+                       $this->doc->getContextMenuCode();
+
+                               // Setting up the buttons and markers for docheader
+                       list($buttons, $otherMarkers) = $this->filelist->getButtonsAndOtherMarkers($this->id);
+
+                               // add the folder info to the marker array
+                       $otherMarkers['FOLDER_INFO'] = $this->filelist->getFolderInfo();
 
+                       $docHeaderButtons = array_merge($this->getButtons(), $buttons);
+
+                               // Build the <body> for the module
+                       $this->content = $this->doc->startPage($LANG->getLL('files'));
 
                                // Create output
-                       $this->content='';
-                       $this->content.=$this->doc->startPage($LANG->getLL('files'));
-                       $this->content.= '<form action="'.htmlspecialchars($filelist->listURL()).'" method="post" name="dblistForm">';
-                       $this->content.= $filelist->HTMLcode;
-                       $this->content.= '<input type="hidden" name="cmd" /></form>';
+                       $pageContent='';
+                       $pageContent.= '<form action="'.htmlspecialchars($this->filelist->listURL()).'" method="post" name="dblistForm">';
+                       $pageContent.= $this->filelist->HTMLcode;
+                       $pageContent.= '<input type="hidden" name="cmd" /></form>';
 
-                               // FileList Module CSH:
-                       $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_module', $GLOBALS['BACK_PATH'],'<br/>|');
 
-                       if ($filelist->HTMLcode)        {       // Making listing options:
+                       if ($this->filelist->HTMLcode)  {       // Making listing options:
 
-                               $this->content.='
+                               $pageContent.='
 
                                        <!--
                                                Listing options for clipboard and thumbnails
@@ -255,36 +275,42 @@ class SC_file_list {
                                ';
 
                                        // 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 />';
+                               $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 />';
 
                                        // Add clipboard button
-                               $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[clipBoard]',$this->MOD_SETTINGS['clipBoard'],'file_list.php','').' '.$LANG->getLL('clipBoard',1);
+                               $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>';
 
-                               $this->content.='
+                               $pageContent.='
                                        </div>
                                ';
-                               $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_options', $GLOBALS['BACK_PATH']);
 
 
                                        // Set clipboard:
                                if ($this->MOD_SETTINGS['clipBoard'])   {
-                                       $this->content.=$filelist->clipObj->printClipboard();
-                                       $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_clipboard', $GLOBALS['BACK_PATH']);
+                                       $pageContent.=$this->filelist->clipObj->printClipboard();
+                                       $pageContent.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_clipboard', $GLOBALS['BACK_PATH']);
                                }
                        }
 
-                               // Add shortcut
-                       if ($BE_USER->mayMakeShortcut())        {
-                               $this->content.='<br /><br />'.$this->doc->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']);
-                       }
+                       $markerArray = array(
+                               'CSH' => $docHeaderButtons['csh'],
+                               'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
+                               'CONTENT' => $pageContent
+                       );
+
+                       $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, array_merge($markerArray, $otherMarkers));
+                       $this->content.= $this->doc->endPage();
+                       $this->content = $this->doc->insertStylesAndJS($this->content);
+
                } else {
                                // Create output - no access (no warning though)
-                       $this->content='';
-                       $this->content.=$this->doc->startPage($LANG->getLL('files'));
+                       $this->content = '';
+                       $this->content .= $this->doc->startPage($LANG->getLL('files'));
+                       $this->content .= $this->doc->endPage();
+                       $this->content = $this->doc->insertStylesAndJS($this->content);
                }
 
-                       // Ending page:
-               $this->content.= $this->doc->endPage();
+
        }
 
        /**
@@ -293,24 +319,48 @@ class SC_file_list {
         * @return      void
         */
        function printContent() {
-
                echo $this->content;
        }
-}
-
-// Include extension?
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php'])    {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']);
-}
 
+       /**
+        * Create the panel of buttons for submitting the form or otherwise perform operations.
+        *
+        * @return      array   all available buttons as an assoc. array
+        */
+       function getButtons()   {
+               global $TCA, $LANG, $BACK_PATH, $BE_USER;
+
+               $buttons = array(
+                       'csh' => '',
+                       'shortcut' => '',
+                       'upload' => '',
+                       'new' => '',
+               );
 
+                       // Add shortcut
+               if ($BE_USER->mayMakeShortcut())        {
+                       $buttons['shortcut'] = $this->doc->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']);
+               }
 
+                       // FileList Module CSH:
+               $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_module', $GLOBALS['BACK_PATH'], '', TRUE);
 
+                       // upload button
+               $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.xml:cm.upload',1)).'" alt="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.upload',1)).'" />';
+               $buttons['upload'] = '<a href="' . $BACK_PATH . 'file_upload.php?target=' . rawurlencode($this->id) . '&amp;returnUrl=' . rawurlencode($this->filelist->listURL()) . '">' . $theIcon . '</a>';
 
+               $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.xml:cm.new',1)).'" alt="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.new',1)).'" />';
+               $buttons['new'] = '<a href="' . $BACK_PATH . 'file_newfolder.php?target=' . rawurlencode($this->id) . '&amp;returnUrl=' . rawurlencode($this->filelist->listURL()) . '">' . $theIcon . '</a>';
 
+               return $buttons;
+       }
 
+}
 
 
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php'])    {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']);
+}
 
 
 
@@ -320,8 +370,4 @@ $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
 
-
-if ($TYPO3_CONF_VARS['BE']['compressionLevel'])        {
-       new gzip_encode($TYPO3_CONF_VARS['BE']['compressionLevel']);
-}
-?>
\ No newline at end of file
+?>