コード例 #1
0
    /**
     * 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;
    }