/**
     * Renders header table row with media type and previewer
     *
     * @param	array		$PA An array with additional configuration options.
     * @param	object		$fobj TCEForms object reference
     * @return	string		The HTML code for the TCEform field
     */
    function tx_dam_mediaType($PA, &$fobj)
    {
        global $TCA;
        $this->tceforms =& $PA['pObj'];
        $config = $PA['fieldConf']['config'];
        $row = $PA['row'];
        $table = $PA['table'];
        // TODO overlay all fields to be safe
        foreach (array('media_type', 'file_name', 'file_path', 'file_size', 'hpixels', 'vpixels') as $field) {
            $row[$field] = $this->tceforms->getLanguageOverlayRawValue($table, $row, $field, $TCA[$table]['columns'][$field]);
        }
        $itemMediaInfo = '';
        $itemMediaInfo .= '<div class="tableRow">' . $this->tceforms->sL('LLL:EXT:lang/locallang_general.xml:LGL.title', true) . '<br />' . '<strong>' . htmlspecialchars($row['title']) . '</strong></div>';
        $itemMediaInfo .= '<div class="tableRow">' . $this->tceforms->sL('LLL:EXT:dam/locallang_db.xml:tx_dam_item.file_name', true) . '<br />' . '<strong>' . htmlspecialchars($row['file_name']) . '</strong></div>';
        $itemMediaInfo .= '<div class="tableRow">' . $this->tceforms->sL('LLL:EXT:dam/locallang_db.xml:tx_dam_item.file_path', true) . '<br />' . '<strong>' . htmlspecialchars($row['file_path']) . '</strong></div>';
        if ($row['media_type'] == TXDAM_mtype_image) {
            $out = '';
            $out .= $row['hpixels'] ? $row['hpixels'] . 'x' . $row['vpixels'] . ' px, ' : '';
            $out .= t3lib_div::formatSize($row['file_size']);
            $out .= $row['color_space'] ? ', ' . $this->tceforms->sL(t3lib_befunc::getLabelFromItemlist($PA['table'], 'color_space', $row['color_space']), true) : '';
            $itemMediaInfo .= '<div class="tableRow"><nobr>' . htmlspecialchars($out) . '</nobr></div>';
        }
        $itemMediaTypeIcon = tx_dam_guiFunc::getMediaTypeIconBox($row);
        $itemMediaInfoTable = '
			<table border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td valign="top">' . $itemMediaTypeIcon . '</td>
					<td valign="top" align="left" style="padding-left:25px;">' . $itemMediaInfo . '
					</td>
				</tr>
			</table>';
        $fieldTemplate = '
			<tr>
				<td colspan="2"><img src="clear.gif" width="1" height="5" alt="" /></td>
			</tr>
			<tr>
				<td nowrap="nowrap"><img name="req_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="10" height="10" alt="" /><img name="cm_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="7" height="10" alt="" /></td>
				<td valign="top">###FIELD_ITEM######FIELD_PAL_LINK_ICON###</td>
			</tr>
			<tr>
				<td colspan="2"><img src="clear.gif" width="1" height="15" alt="" /></td>
			</tr>
			';
        $itemMediaInfoTable = $this->tceforms->intoTemplate(array('NAME' => '', 'ID' => $row['uid'], 'FIELD' => $PA['field'], 'TABLE' => $PA['table'], 'ITEM' => $itemMediaInfoTable, 'HELP_ICON' => ''), $fieldTemplate);
        //
        // previewer
        //
        $itemPreviewer = '';
        $headerCode = '';
        $previewer = NULL;
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['previewerClasses'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['previewerClasses'] as $idName => $classRessource) {
                if (is_object($previewer = t3lib_div::getUserObj($classRessource))) {
                    if ($previewer->isValid($row, '200', 'topright')) {
                        $outArr = $previewer->render($row, '200', 'topright');
                        $itemPreviewer = $outArr['htmlCode'];
                        $headerCode = $outArr['headerCode'];
                        break;
                    }
                }
            }
            unset($previewer);
            $previewer = NULL;
        }
        // todo: header code should go into header - really - but how
        //
        // all together now
        //
        $out = '
			<tr>
				<td colspan="2">
					<table border="0" cellpadding="0" cellspacing="0" width="100%">
						<tr>
							<td valign="top">
								<table border="0" cellpadding="0" cellspacing="0">' . $itemMediaInfoTable . '
								</table>
							</td>
							<td width="1%" valign="top" align="center" style="padding: 0px 10px 0px 10px">' . $headerCode . $itemPreviewer . '</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="2"><img src="clear.gif" width="1" height="5" alt="" /></td>
			</tr>';
        return $out;
    }
    /**
     * Returns a dia like thumbnail
     *
     * @param	array		$row tx_dam record
     * @param	integer		$diaSize dia size
     * @param	integer		$diaMargin dia margin
     * @param	array		$showElements Extra elements to show: "title,info,icons"
     * @param	string		$onClick: ...
     * @param	boolean		$makeIcon: ...
     * @param	string		$actions action content to be displayed
     * @return	string		HTML output
     */
    function getDia($row, $diaSize = 115, $diaMargin = 10, $showElements = '', $onClick = NULL, $makeIcon = TRUE, $actions = '')
    {
        if (!is_array($showElements)) {
            $showElements = t3lib_div::trimExplode(',', $showElements, 1);
        }
        // extra CSS code for HTML header
        if (is_object($GLOBALS['SOBE']) and !isset($GLOBALS['SOBE']->doc->inDocStylesArray['tx_dam_SCbase_dia'])) {
            $GLOBALS['SOBE']->doc->inDocStylesArray['tx_dam_SCbase_dia'] = tx_dam_guiFunc::getDiaStyles($diaSize, $diaMargin);
        }
        // use css/stylesheet
        $iconBgColor = t3lib_div::modifyHTMLcolor($GLOBALS['SOBE']->doc->bgColor, -10, -10, -10);
        $titleLen = ceil(30 * ($diaSize - $diaMargin) / (200 - $diaMargin));
        $hpixels = $row['hpixels'];
        $vpixels = $row['vpixels'];
        if ($hpixels and $vpixels) {
            list($hpixels, $vpixels) = tx_dam_image::calcSize($hpixels, $vpixels, $diaSize, $diaSize);
        } else {
            if ($hpixels > $diaSize) {
                $hpixels = $diaSize;
            }
            if ($vpixels > $diaSize) {
                $vpixels = $diaSize;
            }
        }
        $uid = $row['uid'];
        $imgAttributes = array();
        $imgAttributes['title'] = str_replace("\n", '', t3lib_div::fixed_lgd_cs($row['description'], 50));
        if ($hpixels) {
            $imgAttributes['style'] = 'margin-top:' . (ceil(($diaSize - $vpixels) / 2) + $diaMargin) . 'px;';
        } else {
            $imgAttributes['style'] = 'margin-top:' . $diaMargin . 'px;';
        }
        $imgAttributes['onclick'] = $onClick;
        $thumb = tx_dam_image::previewImgTag($row, $diaSize, $imgAttributes);
        if (!$makeIcon and empty($thumb)) {
            return '';
        }
        if (empty($thumb)) {
            $thumb = tx_dam_guiFunc::getMediaTypeIconBox($row);
            if ($onClick) {
                $thumb = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $thumb . '</a>';
            }
        }
        $descr = '';
        if (in_array('title', $showElements)) {
            $descr .= htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'], $titleLen)) . '<br />';
        }
        if (in_array('info', $showElements)) {
            $code = strtoupper($row['file_type']) . ', ';
            $code .= $row['hpixels'] ? $row['hpixels'] . 'x' . $row['vpixels'] . ', ' : '';
            $code .= t3lib_div::formatSize($row['file_size']);
            $descr .= '<span class="txdam-descr">' . htmlspecialchars($code) . '</span>';
        }
        if ($descr) {
            $descr = '<div class="txdam-title">' . $descr . '</div>';
        }
        $icons = '';
        $iconArr = array();
        if (in_array('icons', $showElements)) {
            // deprecated
            $iconArr[] = tx_dam_SCbase::icon_editRec('tx_dam', $row['uid'], 'style="margin-left:3px;margin-right:3px;"');
            $iconArr[] = tx_dam_SCbase::btn_editRec_inNewWindow('tx_dam', $row['uid'], 'style="margin-left:3px;margin-right:3px;"');
            $iconArr[] = tx_dam_SCbase::icon_infoRec('tx_dam', $row['uid'], 'style="margin-left:3px;margin-right:3px;"');
            $iconArr[] = tx_dam_SCbase::btn_removeRecFromSel('tx_dam', $row['uid'], 'style="margin-left:3px;margin-right:3px;"');
        }
        if (in_array('actions', $showElements)) {
            $actions;
        }
        $icons = $icons ? '<div style="margin:3px;">' . implode('<span style="width:40px;"></span>', $iconArr) . '</div>' : '';
        $actions = $actions ? '<div style="margin:3px;">' . $actions . '</div>' : '';
        $diaCode = '
		<table class="txdam-dia" cellspacing="0" cellpadding="0" border="0">
		<tr><td><span class="txdam-dia">' . $thumb . '</span></td></tr>
		' . ($descr . $icons . $actions ? '<tr><td align="center" bgcolor="' . $iconBgColor . '">' . $descr . $icons . $actions . '</td></tr>' : '') . '
		</table> ';
        return $diaCode;
    }