/**
  * Initializes the backend module by setting internal variables
  *
  * @return	void
  */
 function init()
 {
     global $TYPO3_CONF_VARS, $FILEMOUNTS;
     // name might be set from outside
     if (!$this->MCONF['name']) {
         $this->MCONF = $GLOBALS['MCONF'];
     }
     tx_dam::config_init();
     # tx_dam::config_setValue('setup.devel', '1');
     $this->defaultPid = tx_dam_db::getPid();
     $this->id = $this->defaultPid;
     // from parent::init();
     $this->CMD = t3lib_div::_GP('CMD');
     $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
     $this->menuConfig();
     $this->handleExternalFunctionValue();
     // include the default language file
     $GLOBALS['LANG']->includeLLFile('EXT:dam/lib/locallang.xml');
     //
     // Get current folder
     //
     // tx_dam_folder could be set by GP or stored in module conf
     $SET = t3lib_div::_GP('SET');
     $this->path = $this->MOD_SETTINGS['tx_dam_folder'];
     // check if tx_dam_folder was set by GP which takes precedence, if not use command sent by navframe
     // order: GP (script), SLCMD (navframe), MOD_SETTINGS (stored)
     $SLCMD = t3lib_div::_GPmerged('SLCMD');
     if (!$SET['tx_dam_folder'] and is_array($SLCMD['SELECT']) and is_array($SLCMD['SELECT']['txdamFolder'])) {
         $this->path = tx_dam::path_makeRelative(key($SLCMD['SELECT']['txdamFolder']));
     }
     $this->checkOrSetPath();
     $this->pageinfo = t3lib_BEfunc::readPageAccess($this->defaultPid, $this->perms_clause);
     $this->calcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
     //
     // Detect and set forced single function and set params
     //
     // remove selection command from any params
     $this->addParams['SLCMD'] = '';
     $this->addParams['SET'] = '';
     // forced a module function?
     $forcedFunction = t3lib_div::_GP('forcedFunction');
     if ($this->MOD_MENU['function'][$forcedFunction]) {
         $this->forcedFunction = $forcedFunction;
         $this->addParams['forcedFunction'] = $this->forcedFunction;
         $this->handleExternalFunctionValue('function', $this->forcedFunction);
     }
     //
     // Init selection
     //
     $this->selection = t3lib_div::makeInstance('tx_dam_selectionQuery');
     $maxPages = $this->config_checkValueEnabled('browserMaxPages', 20);
     $this->MOD_SETTINGS['tx_dam_resultPointer'] = $this->selection->initPointer($this->MOD_SETTINGS['tx_dam_resultPointer'], $this->MOD_SETTINGS['tx_dam_resultsPerPage'], $maxPages);
     $this->selection->initSelection($this, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['selectionClasses'], 'tx_dam', 'tx_dam_select');
     $this->selection->initQueryGen();
     $this->selection->qg->initBESelect('tx_dam', tx_dam_db::getPidList());
     $this->selection->addFilemountsToQuerygen();
     // debug output
     if (tx_dam::config_getValue('setup.devel')) {
         $this->debugContent['MOD_SETTINGS'] = '<h4>MOD_SETTINGS</h4>' . t3lib_div::view_array($this->MOD_SETTINGS);
     }
     // BE Info output
     if (tx_dam::config_getValue('setup.devel') and t3lib_extMgm::isLoaded('cc_beinfo')) {
         require_once t3lib_extMgm::extPath('cc_beinfo') . 'class.tx_ccbeinfo.php';
         $beinfo = t3lib_div::makeInstance('tx_ccbeinfo');
         $beinfoContent = $beinfo->makeInfo($this);
         $this->debugContent['beinfo'] = '<h4>BE Info</h4>' . $beinfoContent;
     }
 }
    /**
     * Rendering the copy file form for a multiple items
     *
     * @return	string		HTML content
     */
    function renderFormMulti($items, $targetFolder)
    {
        global $BACK_PATH, $LANG, $TCA;
        $content = '';
        $references = 0;
        // FOLDER_INFO is missing due to missing param in current function - so we set it to nothing
        $this->pObj->markers['FOLDER_INFO'] = '';
        $titleNotExists = 'title="' . $GLOBALS['LANG']->getLL('fileNotExists', true) . '"';
        $iconNotExists = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], PATH_txdam_rel . 'i/error_h.gif', 'width="10" height="10"') . ' ' . $titleNotExists . ' valign="top" alt="" />';
        $referencedIcon = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], PATH_txdam_rel . 'i/is_referenced.gif', 'width="15" height="12"') . ' title="' . $LANG->getLL($this->langPrefix . 'messageReferencesUsed', 1) . '" alt="" />';
        // init table layout
        $tableLayout = array('table' => array('<table cellpadding="2" cellspacing="1" border="0" width="100%">', '</table>'), '0' => array('defCol' => array('<th nowrap="nowrap" class="bgColor5">', '</th>'), '0' => array('<th width="1%" class="bgColor5">', '</th>'), '1' => array('<th width="1%" class="bgColor5">', '</th>'), '3' => array('<th width="1%" class="bgColor5">', '</th>'), '4' => array('<th width="1%" class="bgColor5">', '</th>'), '5' => array('<th width="1%" class="bgColor5">', '</th>')), 'defRow' => array('defCol' => array('<td nowrap="nowrap" class="bgColor4">', '</td>'), '2' => array('<td class="bgColor4">', '</td>'), '3' => array('<td style="text-align:center" class="bgColor4">', '</td>'), '4' => array('<td style="padding:0 5px 0 5px" class="bgColor4">', '</td>'), '5' => array('<td style="text-align:center" class="bgColor4">', '</td>')));
        $cTable = array();
        $tr = 0;
        $td = 0;
        $cTable[$tr][$td++] = '&nbsp;';
        $cTable[$tr][$td++] = '&nbsp;';
        $cTable[$tr][$td++] = $LANG->sL($TCA['tx_dam']['columns']['title']['label'], 1);
        $cTable[$tr][$td++] = '&nbsp;';
        $cTable[$tr][$td++] = '&nbsp;';
        $cTable[$tr][$td++] = $LANG->sL($TCA['tx_dam']['columns']['file_path']['label'], 1);
        $tr++;
        foreach ($items as $id => $meta) {
            $filepath = tx_dam::file_absolutePath($meta);
            if ($meta['file_accessable']) {
                $checkbox = '<input type="checkbox" name="data[' . $this->copyOrMove . '][' . $id . '][data]" value="' . htmlspecialchars($filepath) . '"  checked="checked" />';
            } else {
                $checkbox = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], PATH_txdam_rel . 'i/error_h.gif', 'width="10" height="10"') . ' title="' . $LANG->getLL('accessDenied', true) . '" alt="" />';
            }
            $title = $meta['title'] ? $meta['title'] : $meta['file_name'];
            $title = t3lib_div::fixed_lgd_cs($title, 50);
            $icon = tx_dam_guiFunc::icon_getFileTypeImgTag($meta, 'class="c-recicon"', false);
            if (!@file_exists($filepath)) {
                $icon .= $iconNotExists;
                $info = '';
            } else {
                $info = $GLOBALS['SOBE']->btn_infoFile($meta);
            }
            // Add row to table
            $td = 0;
            $cTable[$tr][$td++] = $checkbox;
            $cTable[$tr][$td++] = $icon;
            $cTable[$tr][$td++] = htmlspecialchars($title);
            $cTable[$tr][$td++] = htmlspecialchars(strtoupper($meta['file_type']));
            $cTable[$tr][$td++] = $info;
            $cTable[$tr][$td++] = htmlspecialchars(t3lib_div::fixed_lgd_cs($meta['file_path'], -15));
            $tr++;
        }
        $itemTable = $this->pObj->doc->table($cTable, $tableLayout);
        $targetFolderRel = tx_dam::path_makeRelative($targetFolder);
        $msg = array();
        $msg[] = '&nbsp;';
        $msg[] = $LANG->getLL('labelTargetFolder', 1) . ' <strong>' . htmlspecialchars($targetFolderRel) . '</strong>';
        $msg[] = '&nbsp;';
        $msg[] = htmlspecialchars(sprintf($LANG->getLL($this->langPrefix . 'message'), $targetFolderRel));
        $msg[] = '&nbsp;';
        $msg[] = $itemTable;
        $buttons = '
			<input type="hidden" name="data[' . $this->copyOrMove . '][' . $id . '][data]" value="' . htmlspecialchars($filepath) . '" />
			<input type="hidden" name="data[' . $this->copyOrMove . '][' . $id . '][target]" value="' . htmlspecialchars($targetFolder) . '" />';
        if (tx_dam::config_checkValueEnabled('mod.txdamM1_SHARED.displayExtraButtons', 1)) {
            if ($this->copyOrMove == 'copy') {
                $buttons .= '
					<input type="submit" value="' . $LANG->getLL('tx_dam_cmd_filecopy.submit', 1) . '" />
					<input type="submit" value="' . $LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.cancel', 1) . '" onclick="jumpBack(); return false;" />';
            } else {
                $buttons .= '
					<input type="submit" value="' . $LANG->getLL('tx_dam_cmd_filemove.submit', 1) . '" />
					<input type="submit" value="' . $LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.cancel', 1) . '" onclick="jumpBack(); return false;" />';
            }
        }
        $this->pObj->docHeaderButtons['SAVE'] = '<input class="c-inputButton" name="_savedok"' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/clip_copy.gif') . ' title="' . $LANG->getLL($this->langPrefix . 'submit', 1) . '" height="16" type="image" width="16">';
        $this->pObj->docHeaderButtons['CLOSE'] = '<a href="#" onclick="jumpBack(); return false;"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/closedok.gif') . ' class="c-inputButton" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.cancel', 1) . '" alt="" height="16" width="16"></a>';
        $content .= $GLOBALS['SOBE']->getMessageBox($GLOBALS['SOBE']->pageTitle, $msg, $buttons, 1);
        return $content;
    }
 /**
  * Function, processing the query part for selecting/filtering records in DAM
  * Called from DAM
  *
  * @param	string		Query type: AND, OR, ...
  * @param	string		Operator, eg. '!=' - see DAM Documentation
  * @param	string		Category - corresponds to the "treename" used for the category tree in the nav. frame
  * @param	string		The select value/id
  * @param	string		The select value (true/false,...)
  * @param	object		Reference to the parent DAM object.
  * @return	string
  * @see tx_dam_selection::getWhereClausePart()
  */
 function selection_getQueryPart($queryType, $operator, $cat, $id, $value, &$damObj)
 {
     $query = $damObj->sl->getFieldMapping('tx_dam', 'file_path');
     if ($queryType === 'NOT') {
         $query .= ' NOT';
     }
     $likeStr = $GLOBALS['TYPO3_DB']->escapeStrForLike(tx_dam::path_makeRelative($id), 'tx_dam');
     $query .= ' LIKE BINARY ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($likeStr . '%', 'tx_dam');
     return array($queryType, $query);
 }
    /**
     * Renders the EB for rte mode
     *
     * @return	string HTML
     */
    function main_rte()
    {
        global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
        // Excluding items based on Page TSConfig
        $this->allowedItems = array_diff($this->allowedItems, t3lib_div::trimExplode(',', $this->modPageConfig['properties']['removeTabs'], 1));
        // Excluding upload into readOnly folders
        $path = tx_dam::path_makeAbsolute($this->damSC->path);
        if ($this->isReadOnlyFolder($path)) {
            $this->allowedItems = array_diff($this->allowedItems, array('upload'));
        }
        if (!$path or !@is_dir($path)) {
            $path = $this->fileProcessor->findTempFolder() . '/';
            // The closest TEMP-path is found
        }
        $this->damSC->path = tx_dam::path_makeRelative($path);
        // mabe not needed
        // Starting content:
        $content = $this->doc->startPage($LANG->getLL('Insert Image', 1));
        $this->reinitParams();
        // Making menu in top:
        $menuDef = array();
        if (in_array('image', $this->allowedItems) && ($this->act == 'image' || t3lib_div::_GP('cWidth'))) {
            $menuDef['page']['isActive'] = $this->act == 'image';
            $menuDef['page']['label'] = $LANG->getLL('currentImage', 1);
            $menuDef['page']['url'] = '#';
            $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'' . htmlspecialchars($this->thisScript . '?act=image&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('magic', $this->allowedItems)) {
            $menuDef['file']['isActive'] = $this->act == 'magic';
            $menuDef['file']['label'] = $LANG->getLL('magicImage', 1);
            $menuDef['file']['url'] = '#';
            $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'' . htmlspecialchars($this->thisScript . '?act=magic&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('plain', $this->allowedItems)) {
            $menuDef['url']['isActive'] = $this->act == 'plain';
            $menuDef['url']['label'] = $LANG->getLL('plainImage', 1);
            $menuDef['url']['url'] = '#';
            $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'' . htmlspecialchars($this->thisScript . '?act=plain&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('dragdrop', $this->allowedItems)) {
            $menuDef['mail']['isActive'] = $this->act == 'dragdrop';
            $menuDef['mail']['label'] = $LANG->getLL('dragDropImage', 1);
            $menuDef['mail']['url'] = '#';
            $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\'' . htmlspecialchars($this->thisScript . '?act=dragdrop&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('upload', $this->allowedItems)) {
            $menuDef['upload']['isActive'] = $this->act == 'upload';
            $menuDef['upload']['label'] = $LANG->getLL('tx_dam_file_upload.title', 1);
            $menuDef['upload']['url'] = '#';
            $menuDef['upload']['addParams'] = 'onclick="jumpToUrl(\'' . htmlspecialchars($this->thisScript . '?act=upload&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        $content .= $this->doc->getTabMenuRaw($menuDef);
        $pArr = explode('|', $this->bparams);
        switch ($this->act) {
            case 'image':
                $JScode = '
				document.write(printCurrentImageOptions());
				insertImagePropertiesInForm();';
                $content .= '<br />' . $this->doc->wrapScriptTags($JScode);
                break;
            case 'upload':
                $content .= $this->dam_upload($this->allowedFileTypes, $this->disallowedFileTypes);
                $content .= $this->damSC->getOptions();
                $content .= '<br /><br />';
                if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
                    $content .= $this->createFolder($path);
                    $content .= '<br />';
                }
                break;
            case 'dragdrop':
                $this->allowedFileTypes = t3lib_div::trimExplode(',', $pArr[3], true);
                $this->addDisplayOptions();
                $content .= $this->dam_select($this->allowedFileTypes, $this->disallowedFileTypes);
                $content .= $this->damSC->getOptions();
                break;
            case 'plain':
                $this->allowedFileTypes = t3lib_div::trimExplode(',', $pArr[3], true);
                $this->addDisplayOptions();
                $content .= $this->dam_select($this->allowedFileTypes, $this->disallowedFileTypes);
                $content .= $this->damSC->getOptions();
                $content .= $this->getMsgBox($this->RTESelectImageObj->getHelpMessage($this->act));
                break;
            case 'magic':
                $this->addDisplayOptions();
                $content .= $this->dam_select($this->allowedFileTypes, $this->disallowedFileTypes);
                $content .= $this->damSC->getOptions();
                $content .= $this->getMsgBox($this->RTESelectImageObj->getHelpMessage($this->act));
                break;
            default:
                break;
        }
        // Ending page, returning content:
        $content .= $this->doc->endPage();
        $this->doc->JScodeArray['rtehtmlarea'] = $this->RTESelectImageObj->getJSCode($this->act, $this->editorNo, $this->sys_language_content);
        $this->doc->JScodeArray['rtehtmlarea-dam'] = $this->getAdditionalJSCode();
        $content = $this->damSC->doc->insertStylesAndJS($content);
        return $content;
    }
 /**
  * tx_dam::path_makeXXX()
  */
 public function test_path_makeXXX()
 {
     $GLOBALS['T3_VAR']['ext']['dam']['pathInfoCache'] = array();
     $filepath = $this->getFixtureFilename();
     $filename = tx_dam::file_basename($filepath);
     $testpath = tx_dam::file_dirname($filepath);
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     self::assertEquals($path, $testpath, 'File path differs: ' . $path . ' (' . $testpath . ')');
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     self::assertEquals($path, $testpath, 'Path differs: ' . $path . ' (' . $testpath . ')');
     $testpath = '/aaa/../bbb/./ccc//ddd';
     $testpathClean = '/bbb/ccc/ddd/';
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     self::assertEquals($path, $testpathClean, 'Path differs: ' . $path . ' (' . $testpathClean . ')');
     $testpath = PATH_site . '/aaa/../bbb/./ccc//ddd';
     $testpathClean = 'bbb/ccc/ddd/';
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     self::assertEquals($path, $testpathClean, 'Path differs: ' . $path . ' (' . $testpathClean . ')');
 }
예제 #6
0
 /**
  * Search for a file and walk up the path if not found in current dir.
  *
  * @param 	string 		$fileName File name to search for
  * @param 	string 		$path Path to search for file
  * @param 	boolean 	$walkUp If set it will be searched for the file in folders above the given
  * @param 	string 		$basePath This absolute path is the limit for searching with $walkUp
  * @return	string 		file content
  */
 function tools_findFileInPath($fileName, $path, $walkUp = true, $basePath = '')
 {
     $basePath = $basePath ? $basePath : PATH_site;
     $path = tx_dam::path_makeAbsolute($path);
     if (is_file($path . $fileName) and is_readable($path . $fileName)) {
         $setup = t3lib_div::getUrl($path . $fileName);
         return $setup;
     }
     if (!$walkUp or $path == $basePath) {
         return false;
     }
     if (tx_dam::path_makeRelative($path) == '') {
         return false;
     }
     if (!($path = dirname($path))) {
         return false;
     }
     return tx_dam::tools_findFileInPath($fileName, $path, $walkUp, $basePath);
 }
예제 #7
0
 /**
  * Set all records deleted that matches/begins with the given path.
  *
  * @param	string		$path path
  * @return	void
  */
 function updateFilePathSetDeleted($path)
 {
     $path = tx_dam::path_makeRelative($path);
     // this way db trigger will not work
     // $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_dam', 'tx_dam.file_path LIKE BINARY '.$GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['TYPO3_DB']->escapeStrForLike($path, 'tx_dam').'%', 'tx_dam'), array('deleted'=>'1'));
     $where = array();
     $where['enableFields'] = '';
     $where['pidList'] = '';
     $likeStr = $GLOBALS['TYPO3_DB']->escapeStrForLike($path, 'tx_dam');
     $where['file_path'] = 'tx_dam.file_path LIKE BINARY ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($likeStr . '%', 'tx_dam');
     $rows = tx_dam_db::getDataWhere('tx_dam.uid', $where);
     foreach ($rows as $row) {
         $row['deleted'] = '1';
         tx_dam_db::insertUpdateData($row);
     }
 }
 /**
  * Initializes the query with file mounts to limit access
  *
  * @return	void
  */
 function addFilemountsToQuerygen()
 {
     // init filemounts
     if (is_object($GLOBALS['BE_USER']) and !$GLOBALS['BE_USER']->isAdmin()) {
         if (count($GLOBALS['FILEMOUNTS'])) {
             $whereArr = array();
             foreach ($GLOBALS['FILEMOUNTS'] as $mount) {
                 $likeStr = $GLOBALS['TYPO3_DB']->escapeStrForLike(tx_dam::path_makeRelative($mount['path']), 'tx_dam');
                 $whereArr[] = 'tx_dam.file_path LIKE BINARY ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($likeStr . '%', 'tx_dam');
             }
             $where = implode(' OR ', $whereArr);
             $where = $where ? '(' . $where . ')' : '';
             $this->qg->addWhere($where, 'AND', 'tx_dam.FILEMOUNTS');
         } else {
             // no filemounts - no access at all
             $this->qg->addWhere('1=0', 'AND', 'tx_dam.FILEMOUNTS');
         }
     }
 }
 /**
  * Removes testfiles from index
  */
 protected function removeFixturesFromIndex()
 {
     $path = tx_dam::path_makeRelative(PATH_txdam . 'tests/fixtures/');
     $likeStr = $GLOBALS['TYPO3_DB']->escapeStrForLike($path, 'tx_dam');
     $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam', 'file_path LIKE BINARY ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($likeStr . '%', 'tx_dam'));
 }
예제 #10
0
    /**
     * Main function of the module. Write the content to $this->content
     *
     * @return	void
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS;
        $this->extObjCmdInit();
        //
        // Initialize the template object
        //
        if (!is_object($this->doc)) {
            $this->doc = t3lib_div::makeInstance('template');
            $this->doc->backPath = $BACK_PATH;
            $this->doc->setModuleTemplate(t3lib_extMgm::extRelPath('dam') . 'res/templates/mod_cmd.html');
            $this->doc->styleSheetFile2 = t3lib_extMgm::extRelPath('dam') . 'res/css/stylesheet.css';
            $this->doc->docType = 'xhtml_trans';
        }
        //
        // check access
        //
        $access = false;
        $this->actionAccess = $this->extObjAccess();
        if ($this->actionAccess) {
            $this->accessDenied = array();
            if ($this->file) {
                foreach ($this->file as $key => $filename) {
                    if (!tx_dam::access_checkFile($filename, $this->extObj->passthroughMissingFiles)) {
                        $this->accessDenied['file'][] = tx_dam::file_normalizePath($filename);
                        unset($this->file[$key]);
                    }
                }
                if ($this->file) {
                    $access = true;
                }
            } elseif ($this->folder) {
                foreach ($this->folder as $key => $path) {
                    if (!tx_dam::access_checkPath($path)) {
                        $this->accessDenied['folder'][] = tx_dam::path_makeRelative($path);
                        unset($this->folder[$key]);
                    }
                }
                if ($this->folder) {
                    $access = true;
                }
            } elseif ($this->record and $this->defaultPid) {
                foreach ($this->record as $table => $uidList) {
                    $where = array();
                    $where['enableFields'] = tx_dam_db::deleteClause($table);
                    $where['pidList'] = $table . '.pid IN (' . $this->defaultPid . ')';
                    $where['uid'] = $table . '.uid IN (' . implode(',', $uidList) . ')';
                    $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $table, implode(' AND ', $where), '', '', '', 'uid');
                    if ($rows) {
                        $this->record[$table] = array_keys($rows);
                    } else {
                        $this->accessDenied['record'][$table] = $uidList;
                        unset($this->record[$table]);
                    }
                }
                if ($this->record) {
                    $access = true;
                }
            }
        }
        //
        // Main
        //
        if ($access) {
            //
            // Output page header
            //
            $this->actionTarget = $this->actionTarget ? $this->actionTarget : t3lib_div::linkThisScript(array('returnUrl' => $this->returnUrl, 'redirect' => $this->redirect));
            if ($this->CMD == 'tx_dam_cmd_foldernew') {
                $this->actionTarget = $BACK_PATH . 'tce_file.php';
            }
            $this->doc->form = '<form action="' . htmlspecialchars($this->actionTarget) . '" method="post" name="editform" enctype="' . $TYPO3_CONF_VARS['SYS']['form_enctype'] . '">';
            // JavaScript
            $this->doc->JScodeArray['jumpToUrl'] = '
				var script_ended = 0;
				var changed = 0;

				function jumpToUrl(URL)	{
					document.location.href = URL;
				}

				function jumpBack()	{
					document.location.href = "' . htmlspecialchars($this->redirect) . '";
				}

				function navFrameReload() {
					if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav)	{
						// top.content.nav_frame.refresh_nav();
					}
				}
				';
            $this->doc->postCode .= $this->doc->wrapScriptTags('
				script_ended = 1;');
            $this->makePageHeader();
            //
            // Call submodule function
            //
            $this->extObjContent();
            $this->markers['CONTENT'] = $this->content;
        } else {
            // If no access
            $this->makePageHeader();
            $accessDeniedInfo = array();
            if ($this->actionAccess) {
                foreach ($this->accessDenied as $type => $items) {
                    if ($items) {
                        $accessDeniedInfo[] = '<h4>' . $LANG->getLL($type, 1) . '</h4>';
                        foreach ($items as $item) {
                            $accessDeniedInfo[] = '<p>' . htmlspecialchars($item) . '</p>';
                        }
                    }
                }
            } else {
                $accessDeniedInfo[] = '<p>' . sprintf($LANG->getLL('messageCmdDenied', 1), $this->pageTitle) . '</p>';
            }
            // file do not exist ...
            $this->content .= $this->accessDeniedMessageBox(implode('', $accessDeniedInfo));
        }
    }
    /**
     * Display uploads module
     *
     * @param	array		$allowedFileTypes Array list of allowed file types
     * @param	array		$disallowedFileTypes Array list of disallowed file types
     * @return	string		HTML content for the module
     * @todo make use of $allowedFileTypes, $disallowedFileTypes ?
     */
    function dam_upload($allowedFileTypes = array(), $disallowedFileTypes = array())
    {
        global $BE_USER, $FILEMOUNTS, $TYPO3_CONF_VARS;
        $content = '';
        $path = tx_dam::path_makeAbsolute($this->damSC->path);
        if (!$path or !@is_dir($path) or !$this->fileProcessor->checkPathAgainstMounts($path) or $this->isReadOnlyFolder($path)) {
            $path = $this->fileProcessor->findTempFolder() . '/';
            // The closest TEMP-path is found
        }
        $this->damSC->path = tx_dam::path_makeRelative($path);
        // maybe not needed
        if (@is_dir($path)) {
            $content .= '<form action="' . htmlspecialchars(t3lib_div::linkThisScript()) . '" method="post" name="editform" enctype="' . $TYPO3_CONF_VARS['SYS']['form_enctype'] . '">';
            // Upload form
            if ($objRef = $TYPO3_CONF_VARS['SC_OPTIONS']['ext/dam/class.tx_dam_browse_media.php']['upload_modfunc']) {
                $damUploadExtObj = t3lib_div::getUserObj($objRef);
            } else {
                require_once PATH_txdam . 'modfunc_file_upload/class.tx_dam_file_upload.php';
                $damUploadExtObj = t3lib_div::makeInstance('tx_dam_file_upload');
            }
            // it may be needed
            require_once PATH_txdam . 'lib/class.tx_dam_guirenderlist.php';
            $this->damSC->guiItems = t3lib_div::makeInstance('tx_dam_guiRenderList');
            // init the upload module function
            $this->damSC->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->damSC->MOD_MENU, t3lib_div::_GP('SET'), $this->damSC->MCONF['name'], 'ses');
            $damUploadExtObj->init($this->damSC, array('path' => PATH_thisScript));
            $damUploadExtObj->setEBmode($this);
            // call it
            if (is_callable(array($damUploadExtObj, 'head'))) {
                $damUploadExtObj->head();
            }
            $form = $damUploadExtObj->main();
            // Create folder tree:
            $browseTrees = t3lib_div::makeInstance('tx_dam_browseTrees');
            $browseTrees->init($this->thisScript, 'elbrowser', true, true);
            $trees = $browseTrees->getTrees();
            // fix for MSIE 80 breaking the table-layout due to nested forms
            $content .= '<form action="#" method="post" id="nested-form-bug"></form>';
            // Putting the parts together, side by side:
            $content .= '

				<!--
					Wrapper table for folder tree / file list:
				-->
				<table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
					<tr>
						<td class="c-wCell" valign="top" width="31%">' . $this->barheader($GLOBALS['LANG']->getLL('folderTree', 1) . ':') . $trees . '</td>
						<td valign="top" style="padding-right:5px;">' . $form . '</td>
					</tr>
				</table>
				';
            $content .= '</form>';
        }
        return $content;
    }