00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 final class t3lib_iconWorks {
00086
00087 public static $fileSpriteIconNames = array(
00088 'htm' => 'mimetypes-text-html',
00089 'html' => 'mimetypes-text-html',
00090 'css' => 'mimetypes-text-css',
00091 'js' => 'mimetypes-text-js',
00092 'csv' => 'mimetypes-text-csv',
00093 'php' => 'mimetypes-text-php',
00094 'php6' => 'mimetypes-text-php',
00095 'php5' => 'mimetypes-text-php',
00096 'php4' => 'mimetypes-text-php',
00097 'php3' => 'mimetypes-text-php',
00098 'inc' => 'mimetypes-text-php',
00099 'ts' => 'mimetypes-text-ts',
00100 'txt' => 'mimetypes-text-text',
00101 'class' => 'mimetypes-text-text',
00102 'tmpl' => 'mimetypes-text-text',
00103 'jpg' => 'mimetypes-media-image',
00104 'jpeg' => 'mimetypes-media-image',
00105 'gif' => 'mimetypes-media-image',
00106 'png' => 'mimetypes-media-image',
00107 'bmp' => 'mimetypes-media-image',
00108 'tif' => 'mimetypes-media-image',
00109 'tga' => 'mimetypes-media-image',
00110 'psd' => 'mimetypes-media-image',
00111 'eps' => 'mimetypes-media-image',
00112 'avi' => 'mimetypes-media-video',
00113 'mpg' => 'mimetypes-media-video',
00114 'mpeg' => 'mimetypes-media-video',
00115 'mov' => 'mimetypes-media-video',
00116 'wav' => 'mimetypes-media-audio',
00117 'mp3' => 'mimetypes-media-audio',
00118 'mid' => 'mimetypes-media-audio',
00119 'swf' => 'mimetypes-media-flash',
00120 'swa' => 'mimetypes-media-flash',
00121 'exe' => 'mimetypes-executable-executable',
00122 'com' => 'mimetypes-executable-executable',
00123 't3x' => 'mimetypes-compressed',
00124 't3d' => 'mimetypes-compressed',
00125 'zip' => 'mimetypes-compressed',
00126 'tgz' => 'mimetypes-compressed',
00127 'gz' => 'mimetypes-compressed',
00128 'pdf' => 'mimetypes-pdf',
00129 'doc' => 'mimetypes-word',
00130 'sxw' => 'mimetypes-word',
00131 'rtf' => 'mimetypes-word',
00132 'xls' => 'mimetypes-excel',
00133 'sxc' => 'mimetypes-excel',
00134 'ppt' => 'mimetypes-powerpoint',
00135 'mount' => 'apps-filetree-mount',
00136 'folder' => 'apps-filetree-folder-default',
00137 'default' => 'mimetypes-other-other'
00138 );
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 public static function getIconImage($table, $row = array(), $backPath, $params = '', $shaded = FALSE) {
00154 $str = '<img' .
00155 self::skinImg($backPath, self::getIcon($table, $row, $shaded), 'width="18" height="16"') .
00156 (trim($params) ? ' ' . trim($params) : '');
00157 if (!stristr($str, 'alt="')) {
00158 $str.=' alt=""';
00159 }
00160 $str.=' />';
00161 return $str;
00162 }
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 public static function getIcon($table, $row = array(), $shaded = FALSE) {
00176 global $TCA, $PAGES_TYPES, $ICON_TYPES;
00177
00178 // Flags:
00179 $doNotGenerateIcon = $GLOBALS['TYPO3_CONF_VARS']['GFX']['noIconProc']; // If set, the icon will NOT be generated with GDlib. Rather the icon will be looked for as [iconfilename]_X.[extension]
00180 $doNotRenderUserGroupNumber = TRUE; // If set, then the usergroup number will NOT be printed unto the icon. NOTICE. the icon is generated only if a default icon for groups is not found... So effectively this is ineffective...
00181
00182 // Shadow:
00183 if ($TCA[$table]['ctrl']['versioningWS']) {
00184 switch((int)$row['t3ver_state']) {
00185 case 1:
00186 return 'gfx/i/shadow_hide.png';
00187 break;
00188 case 2:
00189 return 'gfx/i/shadow_delete.png';
00190 break;
00191 case 3:
00192 return 'gfx/i/shadow_moveto_plh.png';
00193 break;
00194 case 4:
00195 return 'gfx/i/shadow_moveto_pointer.png';
00196 break;
00197 }
00198 }
00199
00200 // First, find the icon file name. This can depend on configuration in TCA, field values and more:
00201 if ($table=='pages') {
00202 // @TODO: RFC #7370: doktype 2&5 are deprecated since TYPO3 4.2-beta1
00203 if ($row['nav_hide'] && ($row['doktype']==1||$row['doktype']==2)) $row['doktype'] = 5; // Workaround to change the icon if "Hide in menu" was set
00204
00205 if (!$iconfile = $PAGES_TYPES[$row['doktype']]['icon']) {
00206 $iconfile = $PAGES_TYPES['default']['icon'];
00207 }
00208 if ($row['module'] && $ICON_TYPES[$row['module']]['icon']) {
00209 $iconfile = $ICON_TYPES[$row['module']]['icon'];
00210 }
00211 } else {
00212 if (!$iconfile = $TCA[$table]['ctrl']['typeicons'][$row[$TCA[$table]['ctrl']['typeicon_column']]]) {
00213 $iconfile = (($TCA[$table]['ctrl']['iconfile']) ? $TCA[$table]['ctrl']['iconfile'] : $table.'.gif');
00214 }
00215 }
00216
00217 // Setting path of iconfile if not already set. Default is "gfx/i/"
00218 if (!strstr($iconfile, '/')) {
00219 $iconfile = 'gfx/i/'.$iconfile;
00220 }
00221
00222 // Setting the absolute path where the icon should be found as a file:
00223 if (substr($iconfile, 0, 3)=='../') {
00224 $absfile = PATH_site.substr($iconfile, 3);
00225 } else {
00226 $absfile = PATH_typo3.$iconfile;
00227 }
00228
00229 // Initializing variables, all booleans except otherwise stated:
00230 $hidden = FALSE;
00231 $timing = FALSE;
00232 $futuretiming = FALSE;
00233 $user = FALSE; // In fact an integer value...
00234 $deleted = FALSE;
00235 $protectSection = FALSE; // Set, if a page-record (only pages!) has the extend-to-subpages flag set.
00236 $noIconFound = $row['_NO_ICON_FOUND'] ? TRUE : FALSE;
00237 // + $shaded which is also boolean!
00238
00239 // Icon state based on "enableFields":
00240 if (is_array($TCA[$table]['ctrl']['enablecolumns'])) {
00241 $enCols = $TCA[$table]['ctrl']['enablecolumns'];
00242 // If "hidden" is enabled:
00243 if ($enCols['disabled']) { if ($row[$enCols['disabled']]) { $hidden = TRUE; }}
00244 // If a "starttime" is set and higher than current time:
00245 if ($enCols['starttime']) {
00246 if ($GLOBALS['EXEC_TIME'] < intval($row[$enCols['starttime']])) {
00247 $timing = TRUE;
00248 // ...And if "endtime" is NOT set:
00249 if (intval($row[$enCols['endtime']]) == 0) {
00250 $futuretiming = TRUE;
00251 }
00252 }
00253 }
00254 // If an "endtime" is set:
00255 if ($enCols['endtime']) {
00256 if (intval($row[$enCols['endtime']]) > 0) {
00257 if (intval($row[$enCols['endtime']]) < $GLOBALS['EXEC_TIME']) {
00258 $timing = TRUE; // End-timing applies at this point.
00259 } else {
00260 $futuretiming = TRUE; // End-timing WILL apply in the future for this element.
00261 }
00262 }
00263 }
00264 // If a user-group field is set:
00265 if ($enCols['fe_group']) {
00266 $user = $row[$enCols['fe_group']];
00267 if ($user && $doNotRenderUserGroupNumber) $user = 100; // Limit for user number rendering!
00268 }
00269 }
00270
00271 // If "deleted" flag is set (only when listing records which are also deleted!)
00272 if ($col = $row[$TCA[$table]['ctrl']['delete']]) {
00273 $deleted = TRUE;
00274 }
00275 // Detecting extendToSubpages (for pages only)
00276 if ($table=='pages' && $row['extendToSubpages'] && ($hidden || $timing || $futuretiming || $user)) {
00277 $protectSection = TRUE;
00278 }
00279
00280 // If ANY of the booleans are set it means we have to alter the icon:
00281 if ($hidden || $timing || $futuretiming || $user || $deleted || $shaded || $noIconFound) {
00282 $flags = '';
00283 $string = '';
00284 if ($deleted) {
00285 $string = 'deleted';
00286 $flags = 'd';
00287 } elseif ($noIconFound) { // This is ONLY for creating icons with "?" on easily...
00288 $string = 'no_icon_found';
00289 $flags = 'x';
00290 } else {
00291 if ($hidden) $string.='hidden';
00292 if ($timing) $string.='timing';
00293 if (!$string && $futuretiming) {
00294 $string = 'futuretiming';
00295 }
00296
00297 $flags.=
00298 ($hidden ? 'h' : '').
00299 ($timing ? 't' : '').
00300 ($futuretiming ? 'f' : '').
00301 ($user ? 'u' : '').
00302 ($protectSection ? 'p' : '').
00303 ($shaded ? 's' : '');
00304 }
00305
00306 // Create tagged icon file name:
00307 $iconFileName_stateTagged = preg_replace('/.([[:alnum:]]+)$/', '__'.$flags.'.\1', basename($iconfile));
00308
00309 // Check if tagged icon file name exists (a tagget icon means the icon base name with the flags added between body and extension of the filename, prefixed with underscore)
00310 if (@is_file(dirname($absfile) . '/' . $iconFileName_stateTagged) || @is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . '/' . dirname($iconfile) . '/' . $iconFileName_stateTagged)) { // Look for [iconname]_xxxx.[ext]
00311 return dirname($iconfile).'/'.$iconFileName_stateTagged;
00312 } elseif ($doNotGenerateIcon) { // If no icon generation can be done, try to look for the _X icon:
00313 $iconFileName_X = preg_replace('/.([[:alnum:]]+)$/', '__x.\1', basename($iconfile));
00314 if (@is_file(dirname($absfile).'/'.$iconFileName_X)) {
00315 return dirname($iconfile).'/'.$iconFileName_X;
00316 } else {
00317 return 'gfx/i/no_icon_found.gif';
00318 }
00319 } else { // Otherwise, create the icon:
00320 $theRes = self::makeIcon($GLOBALS['BACK_PATH'] . $iconfile, $string, $user, $protectSection, $absfile, $iconFileName_stateTagged);
00321 return $theRes;
00322 }
00323 } else {
00324 return $iconfile;
00325 }
00326 }
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340 public static function skinImg($backPath, $src, $wHattribs = '', $outputMode = 0) {
00341
00342 static $cachedSkinImages = array();
00343
00344 $imageId = md5($backPath . $src . $wHattribs . $outputMode);
00345
00346 if (isset($cachedSkinImages[$imageId])) {
00347 return $cachedSkinImages[$imageId];
00348 }
00349 // Setting source key. If the icon is refered to inside an extension, we homogenize the prefix to "ext/":
00350 $srcKey = preg_replace('/^(\.\.\/typo3conf\/ext|sysext|ext)\//', 'ext/', $src);
00351 #if ($src!=$srcKey)debug(array($src, $srcKey));
00352
00353 // LOOKING for alternative icons:
00354 if ($GLOBALS['TBE_STYLES']['skinImg'][$srcKey]) { // Slower or faster with is_array()? Could be used.
00355 list($src, $wHattribs) = $GLOBALS['TBE_STYLES']['skinImg'][$srcKey];
00356 } elseif ($GLOBALS['TBE_STYLES']['skinImgAutoCfg']) { // Otherwise, test if auto-detection is enabled:
00357
00358 // Search for alternative icon automatically:
00359 $fExt = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['forceFileExtension'];
00360 $scaleFactor = ($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] ? $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] : 1); // Scaling factor
00361 $lookUpName = ($fExt ? preg_replace('/\.[[:alnum:]]+$/', '', $srcKey) . '.' . $fExt : $srcKey); // Set filename to look for
00362
00363 if ($fExt && !@is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . $lookUpName)) {
00364 // fallback to original filename if icon with forced extension doesn't exists
00365 $lookUpName = $srcKey;
00366 }
00367 // If file is found:
00368 if (@is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'].$lookUpName)) { // If there is a file...
00369 $iInfo = @getimagesize($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . $lookUpName); // Get width/height:
00370
00371 // Set $src and $wHattribs:
00372 $src = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['relDir'] . $lookUpName;
00373 $wHattribs = 'width="' . round($iInfo[0] * $scaleFactor) . '" height="' . round($iInfo[1] * $scaleFactor) . '"';
00374 }
00375
00376
00377
00378 $GLOBALS['TBE_STYLES']['skinImg'][$srcKey] = array($src, $wHattribs);
00379 }
00380
00381
00382 # if (preg_match('/^width="([0-9]+)" height="([0-9]+)"$/', $wHattribs, $reg)) $wHattribs='width="'.($reg[1]*2).'" height="'.($reg[2]*2).'"';
00383
00384
00385
00386 $matches = array();
00387 $srcBasename = basename($src);
00388 if (preg_match('/(.*)_i(\....)$/', $srcBasename, $matches)) {
00389 $temp_path = dirname(PATH_thisScript) . '/';
00390 if (!@is_file($temp_path . $backPath . $src)) {
00391 $srcOrg = preg_replace('/_i' . preg_quote($matches[2]) . '$/', $matches[2], $src);
00392 $src = self::makeIcon($backPath . $srcOrg, 'disabled', 0, false, $temp_path . $backPath . $srcOrg, $srcBasename);
00393 }
00394 }
00395
00396
00397
00398 $output = '';
00399 switch($outputMode) {
00400 case 0:
00401 $output = ' src="' . $backPath . $src . '" ' . $wHattribs;
00402 break;
00403 case 1:
00404 $output = $backPath . $src;
00405 break;
00406 case 2:
00407 $output = $wHattribs;
00408 break;
00409 }
00410
00411 $cachedSkinImages[$imageId] = $output;
00412 return $output;
00413 }
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443 public static function makeIcon($iconfile, $mode, $user, $protectSection, $absFile, $iconFileName_stateTagged) {
00444 $iconFileName = 'icon_'.t3lib_div::shortMD5($iconfile.'|'.$mode.'|-'.$user.'|'.$protectSection).'_'.$iconFileName_stateTagged.'.'.($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']?'png':'gif');
00445 $mainpath = '../typo3temp/'.$iconFileName;
00446 $path = PATH_site.'typo3temp/'.$iconFileName;
00447
00448
00449 if (file_exists(PATH_typo3.'icons/'.$iconFileName)) {
00450 return 'icons/'.$iconFileName;
00451 } elseif (file_exists($path)) {
00452 return $mainpath;
00453 } else {
00454 if (file_exists($absFile)) {
00455 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
00456
00457
00458 $im = self::imagecreatefrom($absFile);
00459 if ($im<0) return $iconfile;
00460
00461
00462 if (($mode=='disabled') OR ($mode!='futuretiming' && $mode!='no_icon_found' && !(!$mode && $user))) {
00463 for ($c = 0; $c<ImageColorsTotal($im); $c++) {
00464 $cols = ImageColorsForIndex($im, $c);
00465 $newcol = round(($cols['red']+$cols['green']+$cols['blue'])/3);
00466 $lighten = ($mode=='disabled') ? 2.5 : 2;
00467 $newcol = round(255-((255-$newcol)/$lighten));
00468 ImageColorSet($im, $c, $newcol, $newcol, $newcol);
00469 }
00470 }
00471
00472 if ($user) {
00473 if ($user < 100) {
00474 $black = ImageColorAllocate($im, 0, 0, 0);
00475 imagefilledrectangle($im, 0, 0, (($user>10)?9:5), 8, $black);
00476
00477 $white = ImageColorAllocate($im, 255, 255, 255);
00478 imagestring($im, 1, 1, 1, $user, $white);
00479 }
00480
00481 $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_group.gif');
00482 if ($ol_im<0) return $iconfile;
00483
00484 self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
00485 }
00486
00487 if ($mode) {
00488 unset($ol_im);
00489 switch($mode) {
00490 case 'deleted':
00491 $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_deleted.gif');
00492 break;
00493 case 'futuretiming':
00494 $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_timing.gif');
00495 break;
00496 case 'timing':
00497 $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_timing.gif');
00498 break;
00499 case 'hiddentiming':
00500 $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_hidden_timing.gif');
00501 break;
00502 case 'no_icon_found':
00503 $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_no_icon_found.gif');
00504 break;
00505 case 'disabled':
00506
00507 $ol_im = 0;
00508 break;
00509 case 'hidden':
00510 default:
00511 $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_hidden.gif');
00512 break;
00513 }
00514 if ($ol_im<0) return $iconfile;
00515 if ($ol_im) {
00516 self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
00517 }
00518 }
00519
00520 if ($protectSection) {
00521 $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_sub5.gif');
00522 if ($ol_im<0) return $iconfile;
00523 self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
00524 }
00525
00526
00527 @self::imagemake($im, $path);
00528 t3lib_div::gif_compress($path, 'IM');
00529 ImageDestroy($im);
00530 return $mainpath;
00531 } else {
00532 return $iconfile;
00533 }
00534 } else {
00535 return $GLOBALS['BACK_PATH'].'gfx/fileicons/default.gif';
00536 }
00537 }
00538 }
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565 public static function imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h) {
00566 imagecopyresized($im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h);
00567 }
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577 public static function imagecreatefrom($file) {
00578 $file = t3lib_div::read_png_gif($file, $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']);
00579 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
00580 return $file ? imagecreatefrompng($file) : -1;
00581 } else {
00582 return $file ? imagecreatefromgif($file) : -1;
00583 }
00584 }
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594 public static function imagemake($im, $path) {
00595 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
00596 @ImagePng($im, $path);
00597 } else {
00598 @ImageGif($im, $path);
00599 }
00600 }
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637 public static function getSpriteIcon($iconName, array $options = array(), array $overlays = array()) {
00638 $innerHtml = (isset($options['html']) ? $options['html'] : '');
00639 $tagName = (isset($options['tagName']) ? $options['tagName'] : 'span');
00640
00641
00642 if (count($overlays)) {
00643 foreach ($overlays as $overlayIconName => $overlayOptions) {
00644 $overlayOptions['html'] = $innerHtml;
00645 $overlayOptions['class'] = (isset($overlayOptions['class']) ? $overlayOptions['class'] . ' ': '') . 't3-icon-overlay';
00646 $innerHtml = self::getSpriteIcon($overlayIconName, $overlayOptions);
00647 }
00648 }
00649
00650
00651 $iconName = (in_array($iconName, $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable']) || $iconName == 'empty-empty' ? $iconName : 'status-status-icon-missing');
00652
00653
00654 $options['class'] = self::getSpriteIconClasses($iconName) . (isset($options['class']) ? ' ' . $options['class'] : '');
00655
00656 unset($options['html']);
00657 unset($options['tagName']);
00658 return self::buildSpriteHtmlIconTag($options, $innerHtml, $tagName);
00659 }
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674 public static function getSpriteIconForFile($fileExtension, array $options = array()) {
00675 $innerHtml = (isset($options['html']) ? $options['html'] : '');
00676 $tagName = (isset($options['tagName']) ? $options['tagName'] : 'span');
00677
00678
00679 $options['class'] = self::mapFileExtensionToSpriteIconClass($fileExtension) . (isset($options['class']) ? ' ' . $options['class'] : '');
00680
00681 unset($options['html']);
00682 unset($options['tagName']);
00683 return self::buildSpriteHtmlIconTag($options, $innerHtml, $tagName);
00684 }
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694 public static function mapFileExtensionToSpriteIconClass($fileExtension) {
00695
00696
00697
00698 if (strpos($fileExtension, '.') !== FALSE || strpos($fileExtension, '/') !== FALSE) {
00699
00700
00701 $filePath = dirname(t3lib_div::getIndpEnv('SCRIPT_FILENAME')) . '/' . $GLOBALS['BACK_PATH'] . $fileExtension;
00702 $path = t3lib_div::resolveBackPath($filePath);
00703 if (is_dir($path) || substr($fileExtension, -1) === '/' || substr($fileExtension, -1) === '\\') {
00704 $fileExtension = 'folder';
00705 } else if (($pos = strrpos($fileExtension, '.')) !== FALSE) {
00706 $fileExtension = strtolower(substr($fileExtension, $pos + 1));
00707 } else {
00708 $fileExtension = 'default';
00709 }
00710 }
00711
00712
00713
00714 if (!isset(self::$fileSpriteIconNames[$fileExtension])) {
00715 $fileExtension = 'default';
00716 }
00717 $iconName = self::$fileSpriteIconNames[$fileExtension];
00718 return self::getSpriteIconClasses($iconName);
00719 }
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735 public static function getSpriteIconForRecord($table, array $row, array $options = array()) {
00736 $innerHtml = (isset($options['html']) ? $options['html'] : '');
00737 $tagName = (isset($options['tagName']) ? $options['tagName'] : 'span');
00738
00739
00740 $overlaySpriteIconName = self::mapRecordOverlayToSpriteIconName($table, $row);
00741 if ($overlaySpriteIconName) {
00742 $overlayOptions = array(
00743 'html' => $innerHtml,
00744 'class' => 't3-icon-overlay'
00745 );
00746 $innerHtml = self::getSpriteIcon($overlaySpriteIconName, $overlayOptions);
00747 }
00748
00749
00750 $options['class'] = self::mapRecordTypeToSpriteIconClass($table, $row) . (isset($options['class']) ? ' ' . $options['class'] : '');
00751
00752 unset($options['html']);
00753 unset($options['tagName']);
00754 return self::buildSpriteHtmlIconTag($options, $innerHtml, $tagName);
00755 }
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775 protected static function mapRecordTypeToSpriteIconClass($table, array $row) {
00776 $iconName = '';
00777 $recordType = array();
00778 if (isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_column'])) {
00779 $column = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column'];
00780
00781 if (isset($row[$column])) {
00782 $recordType[1] = $row[$column];
00783 } else {
00784 $recordType[1] = 'default';
00785 }
00786
00787
00788
00789
00790 if ($table === 'pages') {
00791 if ($row['nav_hide']) {
00792 $recordType[2] = $recordType[1] . '-hideinmenu';
00793 }
00794 if ($row['is_siteroot']) {
00795 $recordType[3] = $recordType[1] . '-root';
00796 }
00797 if ($row['module']) {
00798 $recordType[4] = 'contains-' . $row['module'];
00799 }
00800 }
00801
00802 if (is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])) {
00803 foreach ($recordType AS $key => $type) {
00804 if (isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$type])) {
00805 $recordType[$key] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$type];
00806 } else {
00807 unset($recordType[$key]);
00808 }
00809 }
00810 $recordType[0] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['default'];
00811 } else {
00812 foreach ($recordType AS $key => $type) {
00813 $recordType[$key] = 'tcarecords-' . $table . '-' . $type;
00814 }
00815 $recordType[0] = 'tcarecords-' . $table . '-default';
00816 }
00817 } else {
00818 if (is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])) {
00819 $recordType[0] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['default'];
00820 } else {
00821 $recordType[0] = 'tcarecords-' . $table . '-default';
00822 }
00823 }
00824 krsort($recordType);
00825 foreach ($recordType as $record) {
00826 if (in_array($record, $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'])) {
00827 return self::getSpriteIconClasses($record);
00828 }
00829 }
00830 return self::getSpriteIconClasses('status-status-icon-missing');
00831 }
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854 protected static function mapRecordOverlayToSpriteIconName($table, array $row) {
00855 $tcaCtrl = $GLOBALS['TCA'][$table]['ctrl'];
00856
00857
00858 $status = array(
00859 'hidden' => FALSE,
00860 'starttime' => FALSE,
00861 'endtime' => FALSE,
00862 'futureendtime' => FALSE,
00863 'fe_group' => FALSE,
00864 'deleted' => FALSE,
00865 'protectedSection' => FALSE,
00866 'nav_hide' => ($row['nav_hide'] ? TRUE : FALSE),
00867 'noIconFound' => ($row['_NO_ICON_FOUND'] ? TRUE : FALSE),
00868 );
00869
00870
00871 if (is_array($tcaCtrl['enablecolumns'])) {
00872 $enCols = $tcaCtrl['enablecolumns'];
00873
00874 if ($tcaCtrl['enablecolumns']['disabled'] && $row[$tcaCtrl['enablecolumns']['disabled']]) {
00875 $status['hidden'] = TRUE;
00876 }
00877
00878 if ($tcaCtrl['enablecolumns']['starttime'] && $GLOBALS['EXEC_TIME'] < intval($row[$tcaCtrl['enablecolumns']['starttime']])) {
00879 $status['starttime'] = TRUE;
00880 }
00881
00882
00883 if ($tcaCtrl['enablecolumns']['endtime']) {
00884 if (intval($row[$tcaCtrl['enablecolumns']['endtime']]) > 0) {
00885 if (intval($row[$tcaCtrl['enablecolumns']['endtime']]) < $GLOBALS['EXEC_TIME']) {
00886
00887 $status['endtime'] = TRUE;
00888 } else {
00889
00890 $status['futureendtime'] = TRUE;
00891 }
00892 }
00893 }
00894
00895 if ($tcaCtrl['enablecolumns']['fe_group'] && $row[$tcaCtrl['enablecolumns']['fe_group']]) {
00896 $status['fe_group'] = TRUE;
00897 }
00898 }
00899
00900
00901 if ($row[$tcaCtrl['delete']]) {
00902 $status['deleted'] = TRUE;
00903 }
00904
00905
00906 if ($table == 'pages' && $row['extendToSubpages']) {
00907 $status['protectedSection'] = TRUE;
00908 }
00909
00910
00911
00912 $priorities = $GLOBALS['TBE_STYLES']['spriteIconApi']['spriteIconRecordOverlayPriorities'];
00913
00914 $iconName = '';
00915 foreach ($priorities as $priority) {
00916 if ($status[$priority]) {
00917 $iconName = $GLOBALS['TBE_STYLES']['spriteIconApi']['spriteIconRecordOverlayNames'][$priority];
00918 break;
00919 }
00920 }
00921
00922 return $iconName;
00923 }
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937 public static function getSpriteIconClasses($iconName) {
00938 $cssClasses = $baseCssClass = 't3-icon';
00939 $parts = explode('-', $iconName);
00940
00941 if (count($parts) > 1) {
00942
00943 $cssClasses .= ' ' . ($baseCssClass . '-' . $parts[0]);
00944
00945 $cssClasses .= ' ' . ($baseCssClass . '-' . $parts[0] . '-' . $parts[1]);
00946
00947 $cssClasses .= ' ' . ($baseCssClass . '-' . substr($iconName, strlen($parts[0]) + 1));
00948 }
00949 return $cssClasses;
00950 }
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962 protected static function buildSpriteHtmlIconTag(array $tagAttributes, $innerHtml = ' ', $tagName = 'span') {
00963 $attributes = '';
00964 foreach ($tagAttributes as $attribute => $value) {
00965 $attributes .= ' ' . htmlspecialchars($attribute) . '="' . htmlspecialchars($value) . '"';
00966 }
00967 return '<' . $tagName . $attributes . '>' . $innerHtml . '</' . $tagName . '>';
00968 }
00969
00970 }
00971
00972 ?>