/**
     * Render list of files.
     *
     * @param	array		$filesArray List of files. See tx_dam_db::getReferencedFiles
     * @param	boolean		$displayThumbs
     * @param	boolean		$disabled
     * @return	string		HTML output
     */
    function renderFileList($filesArray, $displayThumbs = true, $disabled = false)
    {
        global $LANG;
        $out = '';
        // Listing the files:
        if (is_array($filesArray) && count($filesArray)) {
            $lines = array();
            foreach ($filesArray['rows'] as $row) {
                $absFilePath = tx_dam::file_absolutePath($row);
                $fileExists = @file_exists($absFilePath);
                $addAttrib = 'class="absmiddle"';
                $addAttrib .= tx_dam_guiFunc::icon_getTitleAttribute($row);
                $iconTag = tx_dam::icon_getFileTypeImgTag($row, $addAttrib);
                // add clickmenu
                if ($fileExists && !$disabled) {
                    #							$fileIcon = $this->tceforms->getClickMenu($fileIcon, $absFilePath);
                    $iconTag = $this->tceforms->getClickMenu($iconTag, 'tx_dam', $row['uid']);
                }
                $title = $row['title'] ? t3lib_div::fixed_lgd_cs($row['title'], $this->tceforms->titleLen) : t3lib_BEfunc::getNoRecordTitle();
                // Create link to showing details about the file in a window:
                if ($fileExists) {
                    #$Ahref = $GLOBALS['BACK_PATH'].'show_item.php?table='.rawurlencode($absFilePath).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
                    $onClick = 'top.launchView(\'tx_dam\', \'' . $row['uid'] . '\');';
                    $onClick = 'top.launchView(\'' . $absFilePath . '\');';
                    $ATag_info = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">';
                    $info = $ATag_info . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $LANG->getLL('info', 1) . '" alt="" /> ' . $LANG->getLL('info', 1) . '</a>';
                } else {
                    $info = '&nbsp;';
                }
                // Thumbnail/size generation:
                $clickThumb = '';
                if ($displayThumbs && $fileExists && tx_dam_image::isPreviewPossible($row)) {
                    $clickThumb = tx_dam_image::previewImgTag($row);
                    $clickThumb = '<div class="clickThumb">' . $clickThumb . '</div>';
                } elseif ($displayThumbs) {
                    $clickThumb = '<div style="width:68px"></div>';
                }
                // Show element:
                $lines[] = '
					<tr class="bgColor4">
						<td valign="top" nowrap="nowrap" style="min-width:20em">' . $iconTag . htmlspecialchars($title) . '&nbsp;</td>
						<td valign="top" nowrap="nowrap" width="1%">' . $info . '</td>
					</tr>';
                $infoText = tx_dam_guiFunc::meta_compileInfoData($row, 'file_name, file_size:filesize, _dimensions, caption:truncate:50', 'table');
                $infoText = str_replace('<table>', '<table border="0" cellpadding="0" cellspacing="1">', $infoText);
                $infoText = str_replace('<strong>', '<strong style="font-weight:normal;">', $infoText);
                $infoText = str_replace('</td><td>', '</td><td class="bgColor-10">', $infoText);
                if ($displayThumbs) {
                    $lines[] = '
						<tr class="bgColor">
							<td valign="top" colspan="2">
							<table border="0" cellpadding="0" cellspacing="0"><tr>
								<td valign="top">' . $clickThumb . '</td>
								<td valign="top" style="padding-left:1em">' . $infoText . '</td></tr>
							</table>
							<div style="height:0.5em;"></div>
							</td>
						</tr>';
                } else {
                    $lines[] = '
						<tr class="bgColor">
							<td valign="top" colspan="2" style="padding-left:22px">
							' . $infoText . '
							<div style="height:0.5em;"></div>
							</td>
						</tr>';
                }
                $lines[] = '
						<tr>
							<td colspan="2"><div style="height:0.5em;"></div></td>
						</tr>';
            }
            // Wrap all the rows in table tags:
            $out .= '

		<!--
			File listing
		-->
				<table border="0" cellpadding="1" cellspacing="1">
					' . implode('', $lines) . '
				</table>';
        }
        // Return accumulated content for filelisting:
        return $out;
    }
 /**
  * Fetches the data for the tree
  *
  * @param	string		Abs file path
  * @param	integer		Max depth (recursivity limit)
  * @param	string		HTML-code prefix for recursive calls.
  * @return	integer		The count of items on the level
  * @see getBrowsableTree()
  */
 function getFolderTree($files_path, $depth = 999, $depthData = '')
 {
     // This generates the directory tree
     $dirs = t3lib_div::get_dirs($files_path);
     $c = 0;
     if (is_array($dirs)) {
         $depth = intval($depth);
         $HTML = '';
         $a = 0;
         $c = count($dirs);
         natcasesort($dirs);
         foreach ($dirs as $key => $val) {
             $a++;
             $this->tree[] = array();
             // Reserve space.
             end($this->tree);
             $treeKey = key($this->tree);
             // Get the key for this space
             $LN = $a == $c ? 'blank' : 'line';
             $val = preg_replace('/^\\.\\//', '', $val);
             $title = $val;
             $path = $files_path . $val . '/';
             $md5_uid = md5($path);
             $specUID = hexdec(substr($md5_uid, 0, 6));
             $this->specUIDmap[$specUID] = $path;
             $row = array();
             $row['path'] = $path;
             $row['uid'] = $specUID;
             $row['title'] = $title;
             if ($depth > 1 && $this->expandNext($specUID)) {
                 $nextCount = $this->getFolderTree($path, $depth - 1, $this->makeHTML ? $depthData . '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/' . $LN . '.gif', 'width="18" height="16"') . ' alt="" />' : '');
                 $exp = 1;
                 // Set "did expand" flag
             } else {
                 $nextCount = $this->getCount($path);
                 $exp = 0;
                 // Clear "did expand" flag
             }
             // Set HTML-icons, if any:
             if ($this->makeHTML) {
                 $HTML = $depthData . $this->PMicon($row, $a, $c, $nextCount, $exp);
                 $pathInfo = tx_dam::path_compileInfo($path);
                 $HTML .= $this->wrapIcon(tx_dam::icon_getFileTypeImgTag($pathInfo), $row);
             }
             // Finally, add the row/HTML content to the ->tree array in the reserved key.
             $this->tree[$treeKey] = array('row' => $row, 'HTML' => $HTML, 'bank' => $this->bank);
         }
     }
     return $c;
 }
    /**
     * Do the file indexing
     * Read files from a directory index them and output a result table
     *
     * @return	string		HTML content
     */
    function checkUploads($indexSessionID)
    {
        global $LANG, $TYPO3_CONF_VARS;
        // makes sense? Was a hint on php.net
        ob_end_flush();
        // get session data - which might have left files stored
        $indexSession = $this->indexSessionFetch();
        $where = array();
        if ($age = intval($this->pObj->MOD_SETTINGS['tx_dam_tools_indexupdate.age'])) {
            $where['tstamp'] = 'tstamp<' . (time() - $age);
        }
        if ($indexSessionID == '' or !isset($indexSession['ID']) or !($indexSession['ID'] == $indexSessionID) or $indexSession['currentCount'] == 0) {
            $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam_file_tracking', '');
            $files = array();
            $files = $this->getFilesInDir(PATH_site . 'uploads/', true, $files);
            $countTotal = count($files);
            $indexSession = $this->indexSessionNew($countTotal, $files);
        }
        if (is_array($indexSession['data'])) {
            $damIndexing = t3lib_div::makeInstance('tx_dam_indexing');
            $damIndexing->init();
            $damIndexing->dryRun = TRUE;
            foreach ($indexSession['data'] as $key => $file) {
                // increase progress bar
                $indexSession['currentCount']++;
                $fileHash = tx_dam::file_calcHash($file);
                $fileInfo = tx_dam::file_compileInfo($file);
                $fields_values = array('tstamp' => time(), 'file_name' => $fileInfo['file_name'], 'file_path' => $fileInfo['file_path'], 'file_size' => $fileInfo['file_size'], 'file_ctime' => min($fileInfo['file_ctime'], $fileInfo['file_mtime']), 'file_hash' => $fileHash);
                $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_dam_file_tracking', $fields_values);
                $fileInfo = array_merge($fileInfo, $damIndexing->getFileMimeType($file));
                $fileInfo['media_type'] = tx_dam::convert_mediaType($fileInfo['file_mime_type']);
                $ctable = array();
                $ctable[] = '&nbsp;';
                $ctable[] = tx_dam::icon_getFileTypeImgTag($fileInfo, 'align="top"') . '&nbsp;' . htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['file_name'], 30));
                $ctable[] = htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['file_path'], -30));
                $this->indexing_addTableRow($ctable);
                $msg = $LANG->getLL('tx_dam_tools_indexupdate.updatedMessage', 1);
                $code = sprintf($msg, $indexSession['currentCount'], $indexSession['totalFilesCount']);
                $this->indexing_setMessage($code);
                $this->indexing_progressBar($indexSession['currentCount'], $indexSession['totalFilesCount']);
                $this->indexing_flushNow();
                $this->indexSessionWrite($indexSession);
                if ($this->indexEndtime < time() and $indexSession['currentCount'] < $indexSession['totalFilesCount']) {
                    $params = $this->pObj->addParams;
                    $params['indexSessionID'] = $indexSession['ID'];
                    echo '
						<script type="text/javascript">  window.location.href = unescape("' . t3lib_div::rawUrlEncodeJS(tx_dam_SCbase::linkThisScriptStraight($params)) . '"); </script>';
                    exit;
                }
            }
        } elseif ($indexSession['totalFilesCount'] == 0) {
            $code = $LANG->getLL('tx_dam_tools_indexupdate.no_files');
            $this->indexing_setMessage($code);
        }
        $this->indexing_finished();
        // finished - clear session
        $this->indexSessionClear();
    }
 /**
  * Renders the item icon
  *
  * @param	array		$item item array
  * @return	string
  */
 function getItemIcon(&$item)
 {
     static $iconNotExists;
     if (!$iconNotExists) {
         $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 . ' alt="" />';
     }
     $titletext = t3lib_BEfunc::getRecordIconAltText($item, $this->table);
     $itemIcon = tx_dam::icon_getFileTypeImgTag($item, 'title="' . $titletext . '"');
     if ($this->enableContextMenus) {
         $itemIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($itemIcon, $this->table, $item['uid']);
     }
     if (!is_file(tx_dam::file_absolutePath($item))) {
         $item['file_status'] = TXDAM_status_file_missing;
         $itemIcon .= $iconNotExists;
     }
     return $itemIcon;
 }
 /**
  * Renders the item icon
  *
  * @param	array		$item item array
  * @return	string
  */
 function getItemIcon($item)
 {
     static $titleNotIndexed;
     static $iconNotIndexed;
     if (!$iconNotIndexed) {
         $titleNotIndexed = 'title="' . $GLOBALS['LANG']->getLL('fileNotIndexed') . '"';
         $iconNotIndexed = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/required_h.gif', 'width="10" height="10"') . ' ' . $titleNotIndexed . ' alt="" />';
     }
     $type = $item['__type'];
     if ($type == 'file') {
         $titleAttr = '';
         $attachToIcon = '';
         if (!$item['__isIndexed'] and !($uid = tx_dam::file_isIndexed($item))) {
             $attachToIcon = $iconNotIndexed;
             $titleAttr = $titleNotIndexed;
         }
         $iconTag = tx_dam::icon_getFileTypeImgTag($item, $titleAttr);
         if ($this->enableContextMenus) {
             $iconTag = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconTag, tx_dam::file_absolutePath($item));
         }
         $iconTag .= $attachToIcon;
     } else {
         $titleAttr = 'title="' . htmlspecialchars($item[$type . '_title']) . '"';
         $iconTag = tx_dam::icon_getFileTypeImgTag($item, $titleAttr);
         if ($this->enableContextMenus) {
             $iconTag = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconTag, tx_dam::path_makeAbsolute($item));
         }
     }
     return $iconTag;
 }
 /**
  * Creates a list of uploaded files
  *
  * @param	array		$log: ...
  * @return	string		HTML content
  */
 function getUploadedFileList($files)
 {
     global $BACK_PATH, $LANG;
     $content = '';
     // init table layout
     $tableLayout = array('table' => array('<table border="0" cellpadding="1" cellspacing="1" id="typo3-filelist">', '</table>'), 'defRow' => array('tr' => array('<tr>', '</tr>'), 'defCol' => array('<td valign="middle" class="bgColor4">', '</td>'), '990' => array('<td valign="middle" class="bgColor4">', '</td>'), '996' => array('<td valign="middle" class="bgColor5">', '</td>')), '0' => array('tr' => array('<tr class="c-headLine">', '</tr>'), 'defCol' => array('<td valign="middle" class="c-headLine">', '</td>'), '2' => array('<td valign="middle" class="c-headLine" style="width:165px;">', '</td>')));
     $table = array();
     $tr = 0;
     // header
     $td = 0;
     $table[$tr][$td++] = '&nbsp;';
     $table[$tr][$td++] = '&nbsp;';
     $table[$tr][$td++] = $LANG->getLL('c_file');
     $table[$tr][$td++] = $LANG->getLL('c_fileext');
     $table[$tr][$td++] = $LANG->getLL('c_tstamp');
     $table[$tr][$td++] = $LANG->getLL('c_size');
     # $table[$tr][$td++] = $LANG->getLL('c_rw');
     $table[$tr][$td++] = '&nbsp;';
     if (is_object($this->ebObj) && !$this->rteMode) {
         $table[$tr][$td++] = '&nbsp;';
     }
     $addAllJS = '';
     foreach ($files as $item) {
         $tr++;
         $row = $item['meta'];
         $fileIcon = tx_dam::icon_getFileTypeImgTag($row, 'title="' . htmlspecialchars($row['file_type']) . '"');
         // Add row to table
         $td = 0;
         if ($row['uid']) {
             #$table[$tr][$td++] = $this->pObj->doc->icons(-1); // Ok;
             $table[$tr][$td++] = $this->enableBatchProcessing ? '<input type="checkbox" name="process_recs[]" value="' . $row['uid'] . '" />' : '';
             $table[$tr][$td++] = $fileIcon;
             // if upload is called from RTE, allow direct linking by a click on file name
             if ($this->rteMode && is_object($this->ebObj)) {
                 $row = $this->ebObj->enhanceItemArray($row, $this->ebObj->mode);
                 $onClick = 'return link_folder(' . t3lib_div::quoteJSvalue(t3lib_div::rawUrlEncodeFP(tx_dam::file_relativeSitePath($row['_ref_file_path']))) . ');';
                 $ATag_insert = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
                 $table[$tr][$td++] = $ATag_insert . htmlspecialchars(t3lib_div::fixed_lgd_cs($row['file_name'], 30)) . '</a>';
             } else {
                 $table[$tr][$td++] = htmlspecialchars(t3lib_div::fixed_lgd_cs($row['file_name'], 30));
             }
             $table[$tr][$td++] = htmlspecialchars(strtoupper($row['file_type']));
             $table[$tr][$td++] = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $row['file_ctime']);
             $table[$tr][$td++] = htmlspecialchars(t3lib_div::formatSize($row['file_size']));
             $table[$tr][$td++] = $this->pObj->btn_editRec_inNewWindow('tx_dam', $item['uid']);
             if (is_object($this->ebObj)) {
                 if (intval($row['uid']) && !$this->rteMode) {
                     $row = $this->ebObj->enhanceItemArray($row, $this->ebObj->mode);
                     $iconFile = tx_dam::icon_getFileType($row);
                     $titleAttrib = tx_dam_guiFunc::icon_getTitleAttribute($row);
                     // JS: insertElement(table, uid, type, filename, fpath, filetype, imagefile ,action, close)
                     $onClick_params = implode(', ', array("'" . $row['_ref_table'] . "'", "'" . $row['_ref_id'] . "'", "'" . $this->ebObj->mode . "'", t3lib_div::quoteJSvalue($row['file_name']), t3lib_div::quoteJSvalue($row['_ref_file_path']), "'" . $row['file_type'] . "'", "'" . $iconFile . "'"));
                     $onClick = 'return insertElement(' . $onClick_params . ');';
                     $ATag_add = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
                     $onClick = 'return insertElement(' . $onClick_params . ', \'\', 1);';
                     $ATag_insert = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
                     $addAllJS .= 'insertElement(' . $onClick_params . '); ';
                     $table[$tr][$td++] = $ATag_add . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $LANG->getLL('addToList', 1) . '" alt="" /></a>';
                 } elseif ($this->rteMode) {
                     continue;
                 } else {
                     $table[$tr][$td++] = '';
                 }
             }
         } else {
             // failure
             $table[$tr][$td++] = $this->pObj->doc->icons(2);
             // warning
             $table[$tr][$td++] = $fileIcon;
             $table[$tr][$td++] = htmlspecialchars(t3lib_div::fixed_lgd_cs($row['file_name'], 30));
             $table[$tr][$td++] = htmlspecialchars(strtoupper($row['file_type']));
             $table[$tr][$td++] = '';
             $table[$tr][$td++] = '';
             $table[$tr][$td++] = htmlspecialchars($this->getErrorMsgFromItem($item));
         }
     }
     // render table
     if ($tr) {
         $code = '';
         // folder_link expects a form named ltargetform to look for link settings, so we need this if it's called from RTE
         if ($this->rteMode) {
             $code .= '<form action="" name="ltargetform" id="ltargetform"></form>';
         }
         $code .= $this->pObj->doc->table($table, $tableLayout);
         if ($addAllJS) {
             $label = $LANG->getLL('eb_addAllToList', true);
             $titleAttrib = ' title="' . $label . '"';
             $onClick = $addAllJS . 'return true;';
             $ATag_add = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $titleAttrib . '>';
             $addIcon = $ATag_add . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />';
             $addAllButton = '<div style="margin:1em 0 1em 1em;"><span class="button"' . $titleAttrib . '>' . $ATag_add . $addIcon . $label . '</a></span></div>';
             $code = $code . $addAllButton;
         }
     } else {
         $code = false;
     }
     return $code;
 }
    /**
     *
     */
    function doIndexingCallback($type, $meta, $absFile, $fileArrKey, $pObj)
    {
        global $LANG, $TYPO3_CONF_VARS;
        // get session data
        $indexSession = $this->indexSessionFetch();
        // increase progress bar
        $indexSession['currentCount']++;
        if (is_array($meta) and is_array($meta['fields'])) {
            if (tx_dam::config_getValue('setup.devel')) {
                t3lib_div::print_array(array('file_name' => $meta['fields']['file_name'], 'indexExist' => $meta['indexExist'], 'reindexed' => $meta['reindexed'], 'isIndexed' => $meta['isIndexed']));
            }
            if ($meta['isIndexed']) {
                $failure = '';
                $openRecPopup = '';
                if ($meta['failure']) {
                    $failure .= '<br /><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/icon_fatalerror.gif', 'width="18" height="16"') . ' class="absmiddle" alt="" />';
                    $failure .= ' ' . htmlspecialchars($meta['failure']);
                } else {
                    $openRecPopup = $GLOBALS['SOBE']->btn_editRec_inNewWindow('tx_dam', $meta['fields']['uid']);
                }
                $ctable = array();
                $ctable[] = $openRecPopup;
                $ctable[] = '<span style="white-space:nowrap;">' . tx_dam::icon_getFileTypeImgTag($meta['fields'], 'align="top"') . '&nbsp;' . htmlspecialchars(t3lib_div::fixed_lgd_cs($meta['fields']['file_name'], 23)) . '</span>' . $failure;
                $ctable[] = strtoupper($meta['fields']['file_type']);
                $ctable[] = '<span style="white-space:nowrap;">' . htmlspecialchars(str_replace("\n", ' ', t3lib_div::fixed_lgd_cs($meta['fields']['abstract'], 14))) . '</span>';
                $ctable[] = htmlspecialchars(t3lib_div::fixed_lgd_cs($meta['fields']['file_path'], -15));
                $this->indexing_addTableRow($ctable);
                $msg = $LANG->getLL('tx_damindex_index.indexed_message', 1);
                $code = sprintf($msg, $this->index->stat['totalCount'], max(1, ceil($this->index->stat['totalTime'] / 1000)));
                $this->indexing_setMessage($code);
            }
        }
        $this->indexing_progressBar($indexSession['currentCount'], $indexSession['totalFilesCount']);
        $this->indexing_flushNow();
        // one step further - save session data
        unset($indexSession['filesTodo'][$fileArrKey]);
        $indexSession['indexStat'] = $this->index->stat;
        $indexSession['infoList'] = $this->index->infoList;
        $this->indexSessionWrite($indexSession);
        if ($this->indexEndtime < time() and $indexSession['currentCount'] < $indexSession['totalFilesCount']) {
            $params = $this->pObj->addParams;
            $params['indexSessionID'] = $indexSession['ID'];
            echo '
				<script type="text/javascript">  window.location.href = unescape("' . t3lib_div::rawUrlEncodeJS(tx_dam_SCbase::linkThisScriptStraight($params)) . '"); </script>';
            exit;
        }
    }
 /**
  * Returns meta data which might be processed.
  * That means some fields are known and will be substituted by other fields values if the requested field is empty.
  * Example if you request a caption but the field is empty you will get the description field value.
  * This function will be improved by time and the processing will be configurable.
  *
  * @param	string		$field Field name to get meta data from. These are database fields.
  * @param	array		$conf Additional configuration options for the field rendering (if supported for field)
  * @return	mixed		Meta data value.
  * @todo getContent(): more fields and user fields
  */
 function getContent($field, $conf = array())
 {
     global $TYPO3_CONF_VARS;
     require_once PATH_txdam . 'lib/class.tx_dam_guifunc.php';
     $content = '';
     $hsc = true;
     switch ($field) {
         case 'file_size':
             if (!$conf['format']) {
                 $conf['format'] = 'filesize';
             }
             $content = $this->getMetaInfo($field);
             break;
         case '__image_thumbnailImgTag':
             $content = tx_dam_image::previewImgTag($this->getMetaInfoArray(), $conf['size'], $conf['imgAttributes']);
             $hsc = false;
             break;
         case '__image_thumbnailImgUrl':
             $content = tx_dam_image::previewImgUrl($this->getMetaInfoArray(), $conf['size'], $conf['imgAttributes']);
             $hsc = false;
             break;
         case '__image_thumbnailImg':
             $content = tx_dam_image::preview($this->getMetaInfoArray(), $conf['size'], $conf['imgAttributes']);
             // This is an array - return directly
             return $content;
             break;
         case '__icon_fileTypeImgTag':
             $addAttrib = $conf['imgAttributes'];
             if ($conf['createTitleAttribute'] and strpos($addAttrib, 'title=') === false) {
                 $addAttrib .= tx_dam_guiFunc::icon_getTitleAttribute($this->getMetaInfoArray());
             }
             $content = tx_dam::icon_getFileTypeImgTag($this->getMetaInfoArray(), $conf['imgAttributes']);
             $hsc = false;
             break;
         case 'caption':
             $caption = $this->getMeta('caption');
             if (!$caption) {
                 $caption = $this->getMeta('description');
             }
             $content = $caption;
             break;
         case 'alt_text':
             $alt_text = $this->getMeta('alt_text');
             if (!$alt_text) {
                 $alt_text = $this->getMeta('title');
             }
             $content = $alt_text;
             break;
         case 'media_type':
             $content = tx_dam_guifunc::convert_mediaType($this->getMeta($field));
             break;
             // TODO set substitution rules externally
             // TODO allow user functions
         // TODO set substitution rules externally
         // TODO allow user functions
         default:
             $content = $this->getMetaInfo($field);
             break;
     }
     if ($conf['format'] and $content) {
         $content = tx_dam_guifunc::tools_formatValue($content, $conf['format'], $conf['formatConf']);
     }
     if ($conf['stdWrap.']) {
         $lcObj = t3lib_div::makeInstance('tslib_cObj');
         $lcObj->start($this->getMetaArray(), 'tx_dam');
         $content = $lcObj->stdWrap($content, $conf['stdWrap.']);
         $hsc = false;
     } else {
     }
     if (isset($conf['htmlSpecialChars']) and !$conf['htmlSpecialChars']) {
         $hsc = false;
     }
     if ($hsc or $conf['htmlSpecialChars']) {
         $content = htmlspecialchars($content);
     }
     return $content;
 }
 /**
  * Returns the icon of an item
  *
  * @param	string		The select value/id
  * @param	string		The select value (true/false,...)
  * @return	string
  */
 function selection_getItemIcon($id, $value)
 {
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',', $this->fieldArray), $this->table, 'uid=' . intval($id));
     if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         $icon = tx_dam::icon_getFileTypeImgTag($row);
     }
     return $icon;
 }
 /**
  * Returns a file or folder icon for a given (file)path as HTML img tag.
  * A title attribute will be added by default.
  *
  * @param	array		$infoArr Record/info array: eg. $pathInfo = tx_dam::path_getInfo($path)
  * @param	mixed		$addAttrib Additional attributes for the image tag.
  * @return	string		Icon img tag
  * @see tx_dam::path_getInfo()
  */
 function icon_getFileTypeImgTag($infoArr, $addAttrib = '')
 {
     if (is_array($addAttrib)) {
         $addAttrib = tx_dam_guifunc::tools_implodeAttributes($addAttrib);
     }
     if (strpos($addAttrib, 'title=') === false) {
         $addAttrib .= tx_dam_guiFunc::icon_getTitleAttribute($infoArr);
     }
     return tx_dam::icon_getFileTypeImgTag($infoArr, $addAttrib);
 }