TYPO3 CMS  TYPO3_7-6
MiscUtility.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
23 {
30  public static function getExtensionMetaData($extensionKey)
31  {
32  $_EXTKEY = $extensionKey;
33  $EM_CONF = [];
34  $extPath = ExtensionManagementUtility::extPath($extensionKey);
35  include($extPath . 'ext_emconf.php');
36 
37  $release = $EM_CONF[$_EXTKEY]['version'];
38  list($major, $minor, $_) = explode('.', $release, 3);
39  if (($pos = strpos($minor, '-')) !== false) {
40  // $minor ~ '2-dev'
41  $minor = substr($minor, 0, $pos);
42  }
43  $EM_CONF[$_EXTKEY]['version'] = $major . '.' . $minor;
44  $EM_CONF[$_EXTKEY]['release'] = $release;
45  $EM_CONF[$_EXTKEY]['extensionKey'] = $extensionKey;
46 
47  return $EM_CONF[$_EXTKEY];
48  }
49 
56  public static function getIcon($documentKey)
57  {
58  $basePath = 'typo3conf/Documentation/';
59  $documentPath = $basePath . $documentKey . '/';
60 
61  // Fallback icon
62  $icon = ExtensionManagementUtility::siteRelPath('documentation') . 'ext_icon.png';
63 
64  if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($documentKey, 'typo3cms.extensions.')) {
65  // Standard extension icon
66  $extensionKey = substr($documentKey, 20);
67  if (ExtensionManagementUtility::isLoaded($extensionKey)) {
68  $extensionPath = ExtensionManagementUtility::extPath($extensionKey);
69  $siteRelativePath = ExtensionManagementUtility::siteRelPath($extensionKey);
70  $icon = $siteRelativePath . ExtensionManagementUtility::getExtensionIcon($extensionPath);
71  }
72  } elseif (is_file(PATH_site . $documentPath . 'icon.png')) {
73  $icon = $documentPath . 'icon.png';
74  } elseif (is_file(PATH_site . $documentPath . 'icon.gif')) {
75  $icon = $documentPath . 'icon.gif';
76  }
77 
78  return $icon;
79  }
80 }
$EM_CONF[$_EXTKEY]
Definition: ext_emconf.php:2
static getExtensionIcon($extensionPath, $returnFullPath=false)