/**
     * Prints the selector box form-field for the db/file/select elements (multiple)
     *
     * @param	string		Form element name
     * @param	string		Mode "db", "file" (internal_type for the "group" type) OR blank (then for the "select" type). Seperated with '|' a user defined mode can be set to be passed as param to the EB.
     * @param	string		Commalist of "allowed"
     * @param	array		The array of items. For "select" and "group"/"file" this is just a set of value. For "db" its an array of arrays with table/uid pairs.
     * @param	string		Alternative selector box.
     * @param	array		An array of additional parameters, eg: "size", "info", "headers" (array with "selector" and "items"), "noBrowser", "thumbnails"
     * @param	string		On focus attribute string
     * @param	string		$user_el_param Additional parameter for the EB
     * @return	string		The form fields for the selection.
     */
    function dbFileIcons($fName, $mode, $allowed, $itemArray, $selector = '', $params = array(), $onFocus = '', $userEBParam = '')
    {
        list($mode, $modeEB) = explode('|', $mode);
        $modeEB = $modeEB ? $modeEB : $mode;
        $disabled = '';
        if ($this->tceforms->renderReadonly || $params['readOnly']) {
            $disabled = ' disabled="disabled"';
        }
        // Sets a flag which means some JavaScript is included on the page to support this element.
        $this->tceforms->printNeededJS['dbFileIcons'] = 1;
        // INIT
        $uidList = array();
        $opt = array();
        $itemArrayC = 0;
        // Creating <option> elements:
        if (is_array($itemArray)) {
            $itemArrayC = count($itemArray);
            reset($itemArray);
            switch ($mode) {
                case 'db':
                    while (list(, $pp) = each($itemArray)) {
                        if ($pp['title']) {
                            $pTitle = $pp['title'];
                        } else {
                            if (function_exists('t3lib_BEfunc::getRecordWSOL')) {
                                $pRec = t3lib_BEfunc::getRecordWSOL($pp['table'], $pp['id']);
                            } else {
                                $pRec = t3lib_BEfunc::getRecord($pp['table'], $pp['id']);
                            }
                            $pTitle = is_array($pRec) ? $pRec[$GLOBALS['TCA'][$pp['table']]['ctrl']['label']] : NULL;
                        }
                        if ($pTitle) {
                            $pTitle = $pTitle ? t3lib_div::fixed_lgd_cs($pTitle, $this->tceforms->titleLen) : t3lib_BEfunc::getNoRecordTitle();
                            $pUid = $pp['table'] . '_' . $pp['id'];
                            $uidList[] = $pUid;
                            $opt[] = '<option value="' . htmlspecialchars($pUid) . '">' . htmlspecialchars($pTitle) . '</option>';
                        }
                    }
                    break;
                case 'folder':
                case 'file':
                    while (list(, $pp) = each($itemArray)) {
                        $pParts = explode('|', $pp);
                        $uidList[] = $pUid = $pTitle = $pParts[0];
                        $opt[] = '<option value="' . htmlspecialchars(rawurldecode($pParts[0])) . '">' . htmlspecialchars(rawurldecode($pParts[0])) . '</option>';
                    }
                    break;
                default:
                    while (list(, $pp) = each($itemArray)) {
                        $pParts = explode('|', $pp, 2);
                        $uidList[] = $pUid = $pParts[0];
                        $pTitle = $pParts[1] ? $pParts[1] : $pParts[0];
                        $opt[] = '<option value="' . htmlspecialchars(rawurldecode($pUid)) . '">' . htmlspecialchars(rawurldecode($pTitle)) . '</option>';
                    }
                    break;
            }
        }
        // Create selector box of the options
        $sSize = $params['autoSizeMax'] ? t3lib_div::intInRange($itemArrayC + 1, t3lib_div::intInRange($params['size'], 1), $params['autoSizeMax']) : $params['size'];
        if (!$selector) {
            $selector = '<select size="' . $sSize . '"' . $this->tceforms->insertDefStyle('group') . ' multiple="multiple" name="' . $fName . '_list" ' . $onFocus . $params['style'] . $disabled . '>' . implode('', $opt) . '</select>';
        }
        $icons = array('L' => array(), 'R' => array());
        if (!$params['readOnly']) {
            if (!$params['noBrowser']) {
                $aOnClick = 'setFormValueOpenBrowser(\'' . $modeEB . '\',\'' . ($fName . '|||' . $allowed . '|' . $userEBParam . '|') . '\'); return false;';
                $icons['R'][] = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/insert3.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_browse_' . ($mode === 'file' ? 'file' : 'db'))) . ' />' . '</a>';
            }
            if (!$params['dontShowMoveIcons']) {
                if ($sSize >= 5) {
                    $icons['L'][] = '<a href="#" onclick="setFormValueManipulate(\'' . $fName . '\',\'Top\'); return false;">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/group_totop.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_move_to_top')) . ' />' . '</a>';
                }
                $icons['L'][] = '<a href="#" onclick="setFormValueManipulate(\'' . $fName . '\',\'Up\'); return false;">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/up.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_move_up')) . ' />' . '</a>';
                $icons['L'][] = '<a href="#" onclick="setFormValueManipulate(\'' . $fName . '\',\'Down\'); return false;">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/down.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_move_down')) . ' />' . '</a>';
                if ($sSize >= 5) {
                    $icons['L'][] = '<a href="#" onclick="setFormValueManipulate(\'' . $fName . '\',\'Bottom\'); return false;">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/group_tobottom.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_move_to_bottom')) . ' />' . '</a>';
                }
            }
            // todo Clipboard
            $clipElements = $this->tceforms->getClipboardElements($allowed, $mode);
            if (count($clipElements)) {
                $aOnClick = '';
                #			$counter = 0;
                foreach ($clipElements as $elValue) {
                    if ($mode === 'file' or $mode === 'folder') {
                        $itemTitle = 'unescape(\'' . rawurlencode(tx_dam::file_basename($elValue)) . '\')';
                    } else {
                        // 'db' mode assumed
                        list($itemTable, $itemUid) = explode('|', $elValue);
                        if (function_exists('t3lib_BEfunc::getRecordWSOL')) {
                            $rec = t3lib_BEfunc::getRecordWSOL($itemTable, $itemUid);
                        } else {
                            $rec = t3lib_BEfunc::getRecord($itemTable, $itemUid);
                        }
                        $itemTitle = $GLOBALS['LANG']->JScharCode(t3lib_BEfunc::getRecordTitle($itemTable, $rec));
                        $elValue = $itemTable . '_' . $itemUid;
                    }
                    $aOnClick .= 'setFormValueFromBrowseWin(\'' . $fName . '\',\'' . t3lib_div::slashJS(t3lib_div::rawUrlEncodeJS($elValue)) . '\',' . t3lib_div::slashJS($itemTitle) . ');';
                    #$aOnClick .= 'setFormValueFromBrowseWin(\''.$fName.'\',unescape(\''.rawurlencode(str_replace('%20', ' ', $elValue)).'\'),'.$itemTitle.');';
                    #				$counter++;
                    #				if ($params['maxitems'] && $counter >= $params['maxitems'])	{	break;	}	// Makes sure that no more than the max items are inserted... for convenience.
                }
                $aOnClick .= 'return false;';
                $icons['R'][] = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/insert5.png', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib(sprintf($this->tceforms->getLL('l_clipInsert_' . ($mode === 'file' ? 'file' : 'db')), count($clipElements))) . ' />' . '</a>';
            }
            $icons['L'][] = '<a href="#" onclick="setFormValueManipulate(\'' . $fName . '\',\'Remove\'); return false;">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/group_clear.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_remove_selected')) . ' />' . '</a>';
        }
        $str = '<table border="0" cellpadding="0" cellspacing="0" width="1">
			' . ($params['headers'] ? '
				<tr>
					<td>' . $this->tceforms->wrapLabels($params['headers']['selector']) . '</td>
					<td></td>
					<td></td>
					<td></td>
					<td>' . ($params['thumbnails'] ? $this->tceforms->wrapLabels($params['headers']['items']) : '') . '</td>
				</tr>' : '') . '
			<tr>
				<td valign="top">' . $selector . '<br />' . $this->tceforms->wrapLabels($params['info']) . '</td>
				<td valign="top">' . implode('<br />', $icons['L']) . '</td>
				<td valign="top">' . implode('<br />', $icons['R']) . '</td>
				<td style="height:5px;"><span></span></td>
				<td valign="top">' . $this->tceforms->wrapLabels($params['thumbnails']) . '</td>
			</tr>
		</table>';
        // Creating the hidden field which contains the actual value as a comma list.
        $str .= '<input type="hidden" name="' . $fName . '" value="' . htmlspecialchars(implode(',', $uidList)) . '" />';
        return $str;
    }
 /**
  * Notifies the DAM about a deleted file or folder.
  * This will remove the file(s) from the index.
  *
  * @param	string		$filename Filename with path or a folder which have to have a trailing slash.
  * @param	string		$recyclerPath New path when item is moved to recycler.
  * @return	void
  */
 function notify_fileDeleted($filename, $recyclerPath = '')
 {
     if (is_array($row = tx_dam::meta_getDataForFile($filename, 'uid', true))) {
         $uid = $row['uid'];
     }
     if ($uid) {
         $fields_values = array();
         $fields_values['uid'] = $uid;
         $fields_values['deleted'] = '1';
         // file was moved to recycler
         if ($recyclerPath) {
             $org_filename = tx_dam::file_basename($filename);
             $path_parts = t3lib_div::split_fileref($recyclerPath);
             $new_filename = $path_parts['file'];
             $new_path = $path_parts['path'];
             if ($org_filename != $new_filename) {
                 $fields_values['file_name'] = $new_filename;
             }
             if ($new_path) {
                 $fields_values['file_path'] = tx_dam::path_makeRelative($new_path);
             }
         } else {
             // delete MM relations
             $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam_mm_ref', 'tx_dam_mm_ref.uid_local=' . $uid);
         }
         tx_dam_db::insertUpdateData($fields_values);
         // set language overlays deleted
         $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_dam', 'l18n_parent=' . $uid, array('deleted' => 1));
         # $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam', 'l18n_parent='.$uid);
         // todo: replace with full supported group concept --------------------
         // todo: delete child elements and their MM-relation
         // files stay at their physical storage position (usually uploads/tx_dam/storage/_uid_/)
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tx_dam', 'parent_id=' . intval($uid));
         while ($childRow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
             $childUid = $childRow[0];
             $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_dam', 'uid=' . $childUid, array('deleted' => 1));
             $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam_mm_ref', 'tx_dam_mm_ref.uid_local=' . $childUid);
         }
         // ------------------------------------
     } elseif (preg_match('#/$#', $filename)) {
         tx_dam_db::updateFilePathSetDeleted($filename);
     }
 }
 /**
  * Deleting files and folders (action=4)
  *
  * @param	array		$cmds['data'] is the the file/folder to delete
  * @return	boolean		Returns true upon success
  */
 function func_delete($cmds, $id)
 {
     if (!$this->isInit) {
         return FALSE;
     }
     // Checking path:
     $theFile = $cmds['data'];
     // main log entry
     $this->log['cmd']['delete'][$id] = array('errors' => array(), 'orig_filename' => $theFile, 'target_file' => '', 'target_path' => '');
     #		$theFile = preg_replace('#/$#', '', $theFile);
     if (!$this->isPathValid($theFile)) {
         $this->writelog(4, 2, 101, 'Target "%s" had invalid path (".." and "//" is not allowed in path).', array($theFile), 'delete', $id);
         return FALSE;
     }
     // Recycler moving or not?
     if ($this->useRecycler && ($recyclerPath = $this->findRecycler($theFile))) {
         // If a recycler is found, the deleted items is moved to the recycler and not just deleted.
         $newCmds = array();
         $newCmds['data'] = $theFile;
         $newCmds['target'] = $recyclerPath;
         $newCmds['altName'] = 1;
         $theDestFile = $this->func_move($newCmds);
         $this->writelog(4, 0, 4, 'Item "%s" moved to recycler at "%s"', array($theFile, $recyclerPath), 'delete', $id);
         // add file to log entry
         $this->log['cmd']['delete'][$id]['target_file'] = $theDestFile;
         $this->log['cmd']['delete'][$id]['target_path'] = $recyclerPath;
         // update meta data
         if ($this->processMetaUpdate) {
             tx_dam::notify_fileDeleted($theFile, $recyclerPath . '/' . tx_dam::file_basename($theFile));
         }
         return TRUE;
     } elseif ($this->useRecycler != 2) {
         // if $this->useRecycler==2 then we cannot delete for real!!
         if (@is_file($theFile)) {
             // If we are deleting a file...
             if ($this->actionPerms['deleteFile']) {
                 if ($this->checkPathAgainstMounts($theFile)) {
                     if (@unlink($theFile)) {
                         $this->writelog(4, 0, 1, 'File "%s" deleted', array($theFile), 'delete', $id);
                         // update meta data
                         if ($this->processMetaUpdate) {
                             tx_dam::notify_fileDeleted($theFile);
                         }
                         return TRUE;
                     } else {
                         $this->writelog(4, 1, 110, 'Could not delete file "%s". Write-permission problem?', array($theFile), 'delete', $id);
                     }
                 } else {
                     $this->writelog(4, 1, 111, 'Target was not within your mountpoints! T="%s"', array($theFile), 'delete', $id);
                 }
             } else {
                 $this->writelog(4, 1, 112, 'You are not allowed to delete files', '', 'delete', $id);
             }
             // FINISHED deleting file
         } elseif (@is_dir($theFile)) {
             // if we're deleting a folder
             if ($this->actionPerms['deleteFolder']) {
                 $theFile = $this->is_directory($theFile);
                 if ($theFile) {
                     if ($this->checkPathAgainstMounts($theFile)) {
                         // I choose not to append '/' to $theFile here as this will prevent us from deleting mounts!! (which makes sense to me...)
                         if ($this->actionPerms['deleteFolderRecursively'] && !$this->dont_use_exec_commands) {
                             // No way to do this under windows
                             $cmd = 'rm -Rf ' . escapeshellarg($theFile);
                             exec($cmd);
                             // This is a quite critical command...
                             clearstatcache();
                             if (!@file_exists($theFile)) {
                                 $this->writelog(4, 0, 2, 'Directory "%s" deleted recursively!', array($theFile), 'delete', $id);
                                 // update meta data
                                 if ($this->processMetaUpdate) {
                                     tx_dam::notify_fileDeleted($theFile);
                                 }
                                 return TRUE;
                             } else {
                                 $this->writelog(4, 2, 119, 'Directory "%s" WAS NOT deleted recursively! Write-permission problem?', array($theFile), 'delete', $id);
                             }
                         } else {
                             if (@rmdir($theFile)) {
                                 $this->writelog(4, 0, 3, 'Directory "%s" deleted', array($theFile), 'delete', $id);
                                 // update meta data
                                 if ($this->processMetaUpdate) {
                                     tx_dam::notify_fileDeleted($theFile);
                                 }
                                 return TRUE;
                             } else {
                                 $this->writelog(4, 1, 120, 'Could not delete directory! Write-permission problem? Is directory "%s" empty? (You are not allowed to delete directories recursively).', array($theFile), 'delete', $id);
                             }
                         }
                     } else {
                         $this->writelog(4, 1, 121, 'Target was not within your mountpoints! T="%s"', array($theFile), 'delete', $id);
                     }
                 } else {
                     $this->writelog(4, 2, 122, 'Target seemed not to be a directory! (Shouldn\'t happen here!)', '', 'delete', $id);
                 }
             } else {
                 $this->writelog(4, 1, 123, 'You are not allowed to delete directories', '', 'delete', $id);
             }
             // FINISHED copying directory
         } else {
             $this->writelog(4, 2, 130, 'The item was not a file or directory! "%s"', array($theFile), 'delete', $id);
         }
     } else {
         $this->writelog(4, 1, 131, 'No recycler found!', '', 'delete', $id);
     }
 }
 /**
  * tx_dam::path_compileInfo()
  */
 public function test_path_compileInfo()
 {
     $GLOBALS['T3_VAR']['ext']['dam']['pathInfoCache'] = array();
     $filepath = $this->getFixtureFilename();
     $filename = tx_dam::file_basename($filepath);
     $testpath = tx_dam::file_dirname($filepath);
     $pathInfo = tx_dam::path_compileInfo($testpath);
     self::assertTrue(is_array($pathInfo), 'Path not found: ' . $testpath);
     self::assertTrue((bool) $pathInfo['dir_readable'], 'Path not readable: ' . $testpath);
     self::assertFALSE((bool) $pathInfo['mount_id'], 'Impossible mount found: ' . $pathInfo['mount_path'] . ' (' . $testpath . ')');
     $pathInfo = tx_dam::path_compileInfo(PATH_site . 'fileadmin/');
     self::assertTrue(is_array($pathInfo), 'Path not found: ' . $testpath);
     self::assertTrue((bool) $pathInfo['dir_readable'], 'Path not readable: ' . $testpath);
     self::assertTrue((bool) $pathInfo['mount_id'], 'No mount found: ' . $pathInfo['mount_path'] . ' (' . $testpath . ')');
 }
 /**
  * get the mime type of a file with full path
  *
  * @param	string		$pathname absolute path to file
  * @return	array		file information
  */
 function getFileMimeType($pathname)
 {
     // this will be called from tx_dam therefore $pathname can be a fileInfo array
     $pathname = tx_dam::file_absolutePath($pathname);
     $TX_DAM = $GLOBALS['T3_VAR']['ext']['dam'];
     $mimeType = array();
     $mimeType['fulltype'] = '';
     $mimeType['file_mime_type'] = '';
     $mimeType['file_mime_subtype'] = '';
     $mimeType['file_type'] = '';
     $path_parts = t3lib_div::split_fileref($pathname);
     $mimeType['file_type'] = strtolower($path_parts['realFileext']);
     // cleanup bakup files extension
     $mimeType['file_type'] = preg_replace('#\\~$#', '', $mimeType['file_type']);
     $this->setup['useInternalMimeList'] = tx_dam::config_checkValueEnabled('setup.indexing.useInternalMimeList', true);
     $this->setup['useMimeContentType'] = tx_dam::config_checkValueEnabled('setup.indexing.useMimeContentType', true);
     $this->setup['useFileCommand'] = tx_dam::config_checkValueEnabled('setup.indexing.useFileCommand', true);
     // Get the mimetype info from the DB
     $file_type = tx_dam_db::getMediaExtension($mimeType['file_type']);
     // try first to get the mime type by extension with own array
     // I made the experience that it is a bit safer than with 'file'
     if ($this->setup['useInternalMimeList'] and $mimeType['file_type'] and isset($file_type['mime'])) {
         $mt = $file_type['mime'];
         if ($this->writeDevLog) {
             t3lib_div::devLog('getFileMimeType(): used builtin conversion table', 'tx_dam_indexing');
         }
         // next try
     } elseif ($this->setup['useMimeContentType'] and function_exists('mime_content_type')) {
         // available in PHP 4.3.0
         $mt = mime_content_type($pathname);
         if ($this->writeDevLog) {
             t3lib_div::devLog('getFileMimeType(): used mime_content_type()', 'tx_dam_indexing');
         }
     }
     // last chance
     if ($this->setup['useFileCommand'] and (!$mt or $mt === 'application/octet-stream')) {
         $osType = TYPO3_OS;
         if (!($osType === 'WIN')) {
             if ($cmd = t3lib_exec::getCommand('file')) {
                 $dummy = array();
                 $ret = false;
                 $mimeTypeTxt = trim(exec($cmd . ' --mime ' . escapeshellarg($pathname), $dummy, $ret));
                 if (!$ret and strstr($mimeTypeTxt, tx_dam::file_basename($pathname) . ':')) {
                     $a = explode(':', $mimeTypeTxt);
                     $a = explode(';', trim($a[1]));
                     //a[1]: text/plain, English; charset=iso-8859-1
                     $a = explode(',', trim($a[0]));
                     $a = explode(' ', trim($a[0]));
                     $mt = trim($a[0]);
                 }
             }
         }
         if ($this->writeDevLog) {
             t3lib_div::devLog('getFileMimeType(): used t3lib_exec::getCommand(\'file\')', 'tx_dam_indexing');
         }
     }
     $mtarr = explode('/', $mt);
     if (is_array($mtarr) && count($mtarr) == 2) {
         $mimeType['fulltype'] = $mt;
         $mimeType['file_mime_type'] = $mtarr[0];
         $mimeType['file_mime_subtype'] = $mtarr[1];
     }
     if ($mimeType['file_type'] == '') {
         $file_type = tx_dam_db::getMediaExtension('', $mimeType['fulltype']);
         $mimeType['file_type'] = $file_type['mime'];
     }
     if ($this->writeDevLog) {
         t3lib_div::devLog('getFileMimeType()', 'tx_dam_indexing', 0, $mimeType);
     }
     unset($mimeType['fulltype']);
     return $mimeType;
 }
 /**
  * 
  */
 protected function getFixtureTempFilename($type = 'txt')
 {
     $filename = $this->getFixtureFilename($type);
     $destFile = $this->getFixtureTempSrcPath() . tx_dam::file_basename($filename);
     copy($filename, $destFile);
     return $destFile;
 }
 /**
  * initialize the browsable trees
  *
  * @param	array		$TYPO3_CONF_VARS['EXTCONF']['dam']['selectionClasses']
  * @param	string		script name to link to
  * @param	boolean		Element browser mode
  * @return	void
  */
 function initSelectionClasses($selectionClassesArr, $thisScript, $mode = 'browse', $excludeReadOnlyMounts = false)
 {
     global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS;
     $this->selectionClasses = $selectionClassesArr;
     // configuration - default
     $default_modeSelIcons = tx_dam::config_checkValueEnabled('setup.selections.default.modeSelIcons', true);
     if (is_array($this->selectionClasses)) {
         foreach ($this->selectionClasses as $classKey => $classRef) {
             // configuration - class
             if (!tx_dam::config_checkValueEnabled('setup.selections.' . $classKey, true)) {
                 continue;
             }
             $config = tx_dam::config_getValue('setup.selections.' . $classKey, true);
             if (is_object($obj =& t3lib_div::getUserObj($classRef))) {
                 if (!$obj->isPureSelectionClass) {
                     if ($obj->isTreeViewClass) {
                         // object is a treeview class itself
                         $this->treeObjArr[$classKey] = $obj;
                         $this->treeObjArr[$classKey]->init('', '', $excludeReadOnlyMounts);
                     } else {
                         // object does not include treeview functionality. Therefore the standard browsetree is used with setup from the object
                         $this->treeObjArr[$classKey] =& t3lib_div::makeInstance('tx_dam_browseTree');
                         $this->treeObjArr[$classKey]->init();
                         $this->treeObjArr[$classKey]->title = $obj->getTreeTitle();
                         $this->treeObjArr[$classKey]->treeName = $obj->getTreeName();
                         $this->treeObjArr[$classKey]->domIdPrefix = $obj->domIdPrefix ? $obj->domIdPrefix : $obj->getTreeName();
                         $this->treeObjArr[$classKey]->rootIcon = PATH_txdam_rel . 'i/cat2folder.gif';
                         $this->treeObjArr[$classKey]->iconName = tx_dam::file_basename($obj->getDefaultIcon());
                         $this->treeObjArr[$classKey]->iconPath = tx_dam::file_dirname($obj->getDefaultIcon());
                         // workaround: Only variables can be passed by reference
                         $this->treeObjArr[$classKey]->_data = $obj->getTreeArray();
                         $this->treeObjArr[$classKey]->setDataFromArray($this->treeObjArr[$classKey]->_data);
                     }
                     $this->treeObjArr[$classKey]->thisScript = $thisScript;
                     $this->treeObjArr[$classKey]->BE_USER = $BE_USER;
                     $this->treeObjArr[$classKey]->mode = $mode;
                     $this->treeObjArr[$classKey]->ext_IconMode = '1';
                     // no context menu on icons
                     if (!$default_modeSelIcons or !tx_dam::config_isEnabledOption($config, 'modeSelIcons', true)) {
                         $this->treeObjArr[$classKey]->modeSelIcons = false;
                     }
                 }
                 if ($this->treeObjArr[$classKey]->supportMounts) {
                     $mounts = $this->getMountsForTreeClass($classKey, $this->treeObjArr[$classKey]->getTreeName());
                     if (count($mounts)) {
                         $this->treeObjArr[$classKey]->setMounts($mounts);
                     } else {
                         unset($this->treeObjArr[$classKey]);
                     }
                 }
             }
         }
     }
 }
 /**
  * tx_dam::process_renameFile()
  */
 public function test_process_renameFile()
 {
     $this->removeFixtureTempFiles();
     $this->removeIndexSetup();
     $this->removeFixturesFromIndex();
     $this->addFixturePathToFilemount();
     $filepath = $this->getFixtureTempFilename();
     $uid = tx_dam::file_isIndexed($filepath);
     self::assertNoUID($uid, 'File index found, but shouldn\'t');
     tx_dam::config_setValue('setup.indexing.auto', true);
     $indexed = tx_dam::index_autoProcess($filepath, $reindex = false);
     self::assertTrue(isset($indexed['isIndexed']), 'File not indexed');
     $uid = $indexed['fields']['uid'];
     $filepathNew = $filepath . '.doc';
     $error = tx_dam::process_renameFile($filepath, tx_dam::file_basename($filepathNew));
     if ($error) {
         debug($error);
     }
     self::assertTrue(is_file($filepathNew), 'File not renamed');
     $uid2 = tx_dam::file_isIndexed($filepathNew);
     self::assertUID($uid2, 'File index not found');
     self::assertEquals(intval($uid), intval($uid2), 'Wrong uid: ' . $uid . ' - ' . $uid2);
     $data = tx_dam::meta_getDataByUid($uid);
     self::assertEquals($data['file_name'], tx_dam::file_basename($filepathNew), 'Wrong file name ' . $indexed['fields']['file_name'] . ' != ' . tx_dam::file_basename($filepathNew));
     $this->removeFixturePathFromFilemount();
     $this->removeFixturesFromIndex();
     $this->removeIndexSetup();
     $this->removeFixtureTempFiles();
 }