/**
  * Render statistics about indexed media types
  *
  * @return	string		HTML output
  */
 function statisticsMediaType($addFileTypes = true)
 {
     global $LANG;
     $content = '';
     // init table layout
     $tableLayout = array('table' => array('<table border="0" cellspacing="1" cellpadding="2" style="width:auto;">', '</table>'), '0' => array('tr' => array('<tr class="bgColor2">', '</tr>'), 'defCol' => array('<td align="center">', '</td>')), 'defRow' => array('tr' => array('<tr class="bgColor3-20">', '</tr>'), '1' => array('<td align="center">', '</td>'), '4' => array('<td align="right" style="padding-right:0.5em;">', '</td>'), '5' => array('<td align="right" style="padding-right:0.5em;">', '</td>'), 'defCol' => array('<td>', '</td>')));
     $table = array();
     $tr = 0;
     // add header row
     $table[$tr][] = '&nbsp';
     $table[$tr][] = $LANG->getLL('mediaTypes', 1);
     $table[$tr][] = '&nbsp';
     $table[$tr][] = '&nbsp';
     $table[$tr][] = 'Count';
     $table[$tr][] = 'Total';
     $totalCount = 0;
     foreach ($GLOBALS['T3_VAR']['ext']['dam']['media2code'] as $media_type) {
         $whereClauses = array();
         $whereClauses['media_type'] = 'media_type=' . $media_type;
         $rows = tx_dam_db::getDataWhere('COUNT(uid) as count', $whereClauses);
         reset($rows);
         $row = current($rows);
         $count = $row['count'];
         $totalCount += $count;
         $icon = tx_dam_guiFunc::icon_getMediaTypeImgTag(array('media_type' => $media_type), '', false);
         $mediaTypeName = tx_dam_guiFunc::convert_mediaType($media_type);
         // add row to table
         $tr++;
         $table[$tr][] = $icon;
         $table[$tr][] = '<strong>' . htmlspecialchars($mediaTypeName) . '</strong>';
         $table[$tr][] = '&nbsp;';
         $table[$tr][] = '&nbsp;';
         $table[$tr][] = '&nbsp;';
         $table[$tr][] = '<strong>' . $count . '</strong>';
         $tableLayout[$tr]['tr'] = array('<tr class="bgColor4">', '</tr>');
         if ($addFileTypes) {
             if ($contentFileTypes = $this->statisticsFileType($media_type)) {
                 foreach ($contentFileTypes as $fileTypeRow) {
                     // add row to table
                     $tr++;
                     $table[$tr][] = '&nbsp';
                     $table[$tr][] = '&nbsp';
                     $table[$tr][] = $fileTypeRow[0];
                     $table[$tr][] = $fileTypeRow[1];
                     $table[$tr][] = $fileTypeRow[2];
                     $table[$tr][] = '&nbsp';
                 }
             }
         }
         // add row to table
         $tr++;
         $table[$tr][] = '<span></span>';
         $table[$tr][] = '<span></span>';
         $table[$tr][] = '<span></span>';
         $table[$tr][] = '<span></span>';
         $table[$tr][] = '<span></span>';
         $table[$tr][] = '<span></span>';
         $tableLayout[$tr]['tr'] = array('<tr class="bgColor" style="height:0.5em;">', '</tr>');
     }
     // add row to table
     $tr++;
     $table[$tr][] = '&nbsp;';
     $table[$tr][] = '&nbsp;';
     $table[$tr][] = '&nbsp;';
     $table[$tr][] = '&nbsp;';
     $table[$tr][] = '&nbsp;';
     $table[$tr][] = '<strong>' . $totalCount . '</strong>';
     $tableLayout[$tr]['tr'] = array('<tr class="bgColor4-20">', '</tr>');
     $content .= $this->pObj->doc->table($table, $tableLayout);
     return $content;
 }
 /**
  * Compiles from a meta data array human readable content.
  *
  * @param	array		$row Meta data record array
  * @param	string		$displayItems Item names as comma list which are array keys or special names like "_dimensions". Format and option can be added (separated with ":") to call tx_dam::tools_formatValue().
  * @param	string		$formatData If set the array wll be formatted as "paragraph" or "table".
  * @return	array		Info data array
  */
 function meta_compileInfoData($row, $displayItems = '', $formatData = '')
 {
     $infoData = array();
     $displayItems = $displayItems ? $displayItems : 'title, file_name, file_size:filesize, _dimensions, description:truncate:50';
     $displayItems = t3lib_div::trimExplode(',', $displayItems, true);
     foreach ($displayItems as $item) {
         list($item, $format, $config) = t3lib_div::trimExplode(':', $item, true);
         $label = '';
         switch ($item) {
             case '_media_type':
                 $infoData[$item]['value'] = tx_dam_guiFunc::convert_mediaType($row['media_type']);
                 t3lib_div::loadTCA('tx_dam');
                 $label = $GLOBALS['TCA']['tx_dam']['columns']['media_type']['label'];
                 break;
             case '_dimensions':
                 if ($row['media_type'] == TXDAM_mtype_image and $row['hpixels']) {
                     $infoData[$item]['value'] = $row['hpixels'] . 'x' . $row['vpixels'] . ' px';
                     $label = 'LLL:EXT:dam/locallang_db.xml:tx_dam_item.metrics';
                 } elseif ($row['height_unit']) {
                     $infoData[$item]['value'] = $row['width'] . 'x' . $row['height'] . ' ' . $row['height_unit'];
                     $label = 'LLL:EXT:dam/locallang_db.xml:tx_dam_item.metrics';
                 }
                 break;
                 // todo _techinfo
                 //				case '_techinfo':
                 //					if ($row['media_type'] == TXDAM_mtype_image AND $row['color_space']) {
                 //						$value = tx_dam_guifunc::getLabelFromItemlist('tx_dam', 'color_space', $row['color_space']);
                 //						if (is_object($GLOBALS['LANG'])) {
                 //							$value = $LANG->sL($value);
                 //						}
                 //						$infoData[$item]['value'] = $value;
                 //					}
                 //				break;
             // todo _techinfo
             //				case '_techinfo':
             //					if ($row['media_type'] == TXDAM_mtype_image AND $row['color_space']) {
             //						$value = tx_dam_guifunc::getLabelFromItemlist('tx_dam', 'color_space', $row['color_space']);
             //						if (is_object($GLOBALS['LANG'])) {
             //							$value = $LANG->sL($value);
             //						}
             //						$infoData[$item]['value'] = $value;
             //					}
             //				break;
             case '_caption':
                 $infoData[$item]['value'] = $row['caption'] ? $row['caption'] : $row['description'];
                 break;
             default:
                 if (isset($row[$item])) {
                     $infoData[$item]['value'] = $row[$item];
                 }
                 break;
         }
         if ($format and isset($infoData[$item])) {
             $infoData[$item]['value'] = tx_dam_guiFunc::tools_formatValue($infoData[$item]['value'], $format, $config);
         }
         if ($label and is_object($GLOBALS['LANG'])) {
             $infoData[$item]['label'] = $GLOBALS['LANG']->sL($label);
         }
         if (isset($infoData[$item]) and !isset($infoData[$item]['label']) and is_object($GLOBALS['LANG'])) {
             t3lib_div::loadTCA('tx_dam');
             $infoData[$item]['label'] = $GLOBALS['LANG']->sL($GLOBALS['TCA']['tx_dam']['columns'][$item]['label']);
         }
     }
     switch ($formatData) {
         case 'p':
         case 'paragraph':
             $infoText = '';
             foreach ($infoData as $val) {
                 $infoText .= '<p><strong>' . htmlspecialchars($val['label']) . '</strong> ' . htmlspecialchars($val['value']) . '</p>';
             }
             $infoData = $infoText;
             break;
         case 'table':
             $infoText = '';
             foreach ($infoData as $val) {
                 $infoText .= '<tr><td><strong>' . htmlspecialchars($val['label']) . '</strong>&nbsp;</td><td>' . htmlspecialchars($val['value']) . '</td></tr>';
             }
             $infoData = '<table>' . $infoText . '</table>';
             break;
         case 'value-array':
             $infoArr = array();
             foreach ($infoData as $item => $val) {
                 $infoArr[$item] = $val['value'];
             }
             $infoData = $infoArr;
             break;
         case 'value-string':
             $infoArr = array();
             foreach ($infoData as $item => $val) {
                 $infoArr[$item] = $val['value'];
             }
             $infoData = implode("\n", $infoArr);
             break;
         default:
             break;
     }
     return $infoData;
 }