[TASK] Rename GeneralUtility in Documentation sysext 55/28655/4
authorMarkus Klein <klein.t3@mfc-linz.at>
Sun, 23 Mar 2014 00:41:04 +0000 (01:41 +0100)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Sun, 23 Mar 2014 16:12:34 +0000 (17:12 +0100)
Rename the GeneralUtility class in the Documentation sysext to avoid
confusion with GeneralUtility used in the Core sysext.

Resolves: #57197
Releases: 6.2
Change-Id: Iff44c713307c86840d60bc9ef5aee67ae9741fa9
Reviewed-on: https://review.typo3.org/28655
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
typo3/sysext/documentation/Classes/Controller/DocumentController.php
typo3/sysext/documentation/Classes/Domain/Repository/DocumentRepository.php
typo3/sysext/documentation/Classes/Service/DocumentationService.php
typo3/sysext/documentation/Classes/Utility/GeneralUtility.php [deleted file]
typo3/sysext/documentation/Classes/Utility/MiscUtility.php [new file with mode: 0644]

index dce45dc..0a40fb6 100644 (file)
@@ -149,7 +149,7 @@ class DocumentController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
 
                        if ($result) {
                                $this->controllerContext->getFlashMessageQueue()->enqueue(
-                                       \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+                                       GeneralUtility::makeInstance(
                                                'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
                                                \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
                                                        'downloadSucceeded',
@@ -162,7 +162,7 @@ class DocumentController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
                                );
                        } else {
                                $this->controllerContext->getFlashMessageQueue()->enqueue(
-                                       \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+                                       GeneralUtility::makeInstance(
                                                'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
                                                \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
                                                        'downloadFailedNoArchive',
@@ -179,7 +179,7 @@ class DocumentController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
                        }
                } catch (\Exception $e) {
                        $this->controllerContext->getFlashMessageQueue()->enqueue(
-                               \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+                               GeneralUtility::makeInstance(
                                        'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
                                        \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
                                                'downloadFailedDetails',
index 103d012..42451bf 100644 (file)
@@ -4,7 +4,7 @@ namespace TYPO3\CMS\Documentation\Domain\Repository;
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 2013 Xavier Perseguers <xavier@typo3.org>
+ *  (c) 2013-2014 Xavier Perseguers <xavier@typo3.org>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -24,6 +24,8 @@ namespace TYPO3\CMS\Documentation\Domain\Repository;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * An extension helper repository to be used in ext:documentation context
  *
@@ -68,7 +70,7 @@ class DocumentRepository {
                // Initialize the dependency of languages
                $languageDependencies = array();
                /** @var $locales \TYPO3\CMS\Core\Localization\Locales */
-               $locales = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Localization\\Locales');
+               $locales = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Localization\\Locales');
                // Language is found. Configure it:
                $shortLanguage = $language;
                if (!in_array($shortLanguage, $locales->getLocales()) && strpos($shortLanguage, '_') !== FALSE) {
@@ -134,14 +136,14 @@ class DocumentRepository {
                $basePath = 'typo3conf/Documentation/';
 
                $documents = array();
-               $documentKeys = \TYPO3\CMS\Core\Utility\GeneralUtility::get_dirs(PATH_site . $basePath);
+               $documentKeys = GeneralUtility::get_dirs(PATH_site . $basePath);
                // Early return in case no document keys were found
                if (!is_array($documentKeys)) {
                        return $documents;
                }
 
                foreach ($documentKeys as $documentKey) {
-                       $icon = \TYPO3\CMS\Documentation\Utility\GeneralUtility::getIcon($documentKey);
+                       $icon = \TYPO3\CMS\Documentation\Utility\MiscUtility::getIcon($documentKey);
 
                        /** @var \TYPO3\CMS\Documentation\Domain\Model\Document $document */
                        $document = $this->objectManager->get('TYPO3\\CMS\\Documentation\\Domain\\Model\\Document')
@@ -149,7 +151,7 @@ class DocumentRepository {
                                ->setIcon($icon);
 
                        $languagePath = $basePath . $documentKey . '/';
-                       $languages = \TYPO3\CMS\Core\Utility\GeneralUtility::get_dirs(PATH_site . $languagePath);
+                       $languages = GeneralUtility::get_dirs(PATH_site . $languagePath);
                        foreach ($languages as $language) {
                                $metadata = $this->getMetadata($documentKey, $language);
                                if (!empty($metadata['extensionKey'])) {
@@ -163,7 +165,7 @@ class DocumentRepository {
                                        ->setDescription($metadata['description']);
 
                                $formatPath = $languagePath . $language . '/';
-                               $formats = \TYPO3\CMS\Core\Utility\GeneralUtility::get_dirs(PATH_site . $formatPath);
+                               $formats = GeneralUtility::get_dirs(PATH_site . $formatPath);
                                foreach ($formats as $format) {
                                        $documentFile = '';
                                        switch ($format) {
@@ -179,7 +181,7 @@ class DocumentRepository {
                                                        break;
                                                case 'pdf':
                                                        // Retrieve first PDF
-                                                       $files = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir(PATH_site . $formatPath . $format, 'pdf');
+                                                       $files = GeneralUtility::getFilesInDir(PATH_site . $formatPath . $format, 'pdf');
                                                        if (count($files) > 0) {
                                                                $documentFile = current($files);
                                                        }
@@ -218,7 +220,7 @@ class DocumentRepository {
                        $path = $extensionData['siteRelPath'] . 'doc/';
                        if (is_file(PATH_site . $path . 'manual.sxw')) {
                                $documentKey = 'typo3cms.extensions.' . $extensionKey;
-                               $icon = \TYPO3\CMS\Documentation\Utility\GeneralUtility::getIcon($documentKey);
+                               $icon = \TYPO3\CMS\Documentation\Utility\MiscUtility::getIcon($documentKey);
 
                                /** @var \TYPO3\CMS\Documentation\Domain\Model\Document $document */
                                $document = $this->objectManager->get('TYPO3\\CMS\\Documentation\\Domain\\Model\\Document')
@@ -260,10 +262,10 @@ class DocumentRepository {
                        'title' => $documentKey,
                        'description' => '',
                );
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($documentKey, 'typo3cms.extensions.')) {
+               if (GeneralUtility::isFirstPartOfStr($documentKey, 'typo3cms.extensions.')) {
                        $extensionKey = substr($documentKey, 20);
                        if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extensionKey)) {
-                               $metadata = \TYPO3\CMS\Documentation\Utility\GeneralUtility::getExtensionMetaData($extensionKey);
+                               $metadata = \TYPO3\CMS\Documentation\Utility\MiscUtility::getExtensionMetaData($extensionKey);
                        }
                } elseif (is_file($documentPath . 'composer.json')) {
                        $info = json_decode(file_get_contents($documentPath . 'composer.json'), TRUE);
index 2fb9d5e..c36c71e 100644 (file)
@@ -4,7 +4,7 @@ namespace TYPO3\CMS\Documentation\Service;
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 2013 Xavier Perseguers <xavier@typo3.org>
+ *  (c) 2013-2014 Xavier Perseguers <xavier@typo3.org>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -45,7 +45,7 @@ class DocumentationService {
                if ($json) {
                        $documents = json_decode($json, TRUE);
                        foreach ($documents as &$document) {
-                               $document['icon'] = \TYPO3\CMS\Documentation\Utility\GeneralUtility::getIcon($document['key']);
+                               $document['icon'] = \TYPO3\CMS\Documentation\Utility\MiscUtility::getIcon($document['key']);
                        }
 
                        // Cache file locally to be able to create a composer.json file when fetching a document
@@ -66,7 +66,7 @@ class DocumentationService {
                foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extensionKey => $extensionData) {
                        $absoluteExtensionPath = GeneralUtility::getFileAbsFileName($extensionData['siteRelPath']);
                        if (is_file($absoluteExtensionPath . 'README.rst') || is_file($absoluteExtensionPath . 'Documentation' . DIRECTORY_SEPARATOR . 'Index.rst')) {
-                               $metadata = \TYPO3\CMS\Documentation\Utility\GeneralUtility::getExtensionMetaData($extensionKey);
+                               $metadata = \TYPO3\CMS\Documentation\Utility\MiscUtility::getExtensionMetaData($extensionKey);
                                if ($extensionData['type'] === 'S') {
                                        $version = TYPO3_branch;
                                } else {
@@ -76,7 +76,7 @@ class DocumentationService {
                                $documentKey = 'typo3cms.extensions.' . $extensionKey;
                                $documents[] = array(
                                        'title'   => $metadata['title'],
-                                       'icon'    => \TYPO3\CMS\Documentation\Utility\GeneralUtility::getIcon($documentKey),
+                                       'icon'    => \TYPO3\CMS\Documentation\Utility\MiscUtility::getIcon($documentKey),
                                        'type'    => 'Extension',
                                        'key'     => $documentKey,
                                        'shortcut' => $extensionKey,
@@ -126,7 +126,7 @@ class DocumentationService {
                                continue;
                        } else {
                                foreach ($packages[$version] as $locale => $_) {
-                                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($locale, $language)) {
+                                       if (GeneralUtility::isFirstPartOfStr($locale, $language)) {
                                                $success |= $this->fetchDocument($url, $key, $version, $locale);
                                                // Fetch next language (jump current foreach up to the loop of $languages)
                                                continue 2;
diff --git a/typo3/sysext/documentation/Classes/Utility/GeneralUtility.php b/typo3/sysext/documentation/Classes/Utility/GeneralUtility.php
deleted file mode 100644 (file)
index c6dd2b4..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-namespace TYPO3\CMS\Documentation\Utility;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2013 Xavier Perseguers <xavier@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
-
-/**
- * General utility.
- *
- * @author Xavier Perseguers <xavier@typo3.org>
- */
-class GeneralUtility {
-
-       /**
-        * Returns meta-data for a given extension.
-        *
-        * @param string $extensionKey
-        * @return array
-        */
-       static public function getExtensionMetaData($extensionKey) {
-               $_EXTKEY = $extensionKey;
-               $EM_CONF = array();
-               $extPath = ExtensionManagementUtility::extPath($extensionKey);
-               include($extPath . 'ext_emconf.php');
-
-               $release = $EM_CONF[$_EXTKEY]['version'];
-               list($major, $minor, $_) = explode('.', $release, 3);
-               if (($pos = strpos($minor, '-')) !== FALSE) {
-                       // $minor ~ '2-dev'
-                       $minor = substr($minor, 0, $pos);
-               }
-               $EM_CONF[$_EXTKEY]['version'] = $major . '.' . $minor;
-               $EM_CONF[$_EXTKEY]['release'] = $release;
-               $EM_CONF[$_EXTKEY]['extensionKey'] = $extensionKey;
-
-               return $EM_CONF[$_EXTKEY];
-       }
-
-       /**
-        * Returns the icon associated to a given document key.
-        *
-        * @param string $documentKey
-        * @return string
-        */
-       static public function getIcon($documentKey) {
-               $basePath = 'typo3conf/Documentation/';
-               $documentPath = $basePath . $documentKey . '/';
-
-               // Fallback icon
-               $icon = ExtensionManagementUtility::siteRelPath('documentation') . 'ext_icon.gif';
-
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($documentKey, 'typo3cms.extensions.')) {
-                       // Standard extension icon
-                       $extensionKey = substr($documentKey, 20);
-                       if (ExtensionManagementUtility::isLoaded($extensionKey)) {
-                               $extensionPath = ExtensionManagementUtility::extPath($extensionKey);
-                               $siteRelativePath = ExtensionManagementUtility::siteRelPath($extensionKey);
-                               $icon = $siteRelativePath . ExtensionManagementUtility::getExtensionIcon($extensionPath);
-                       }
-               } elseif (is_file(PATH_site . $documentPath . 'icon.png')) {
-                       $icon = $documentPath . 'icon.png';
-               } elseif (is_file(PATH_site . $documentPath . 'icon.gif')) {
-                       $icon = $documentPath . 'icon.gif';
-               }
-
-               return $icon;
-       }
-
-}
\ No newline at end of file
diff --git a/typo3/sysext/documentation/Classes/Utility/MiscUtility.php b/typo3/sysext/documentation/Classes/Utility/MiscUtility.php
new file mode 100644 (file)
index 0000000..43aae82
--- /dev/null
@@ -0,0 +1,91 @@
+<?php
+namespace TYPO3\CMS\Documentation\Utility;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Xavier Perseguers <xavier@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+
+/**
+ * Misc utility.
+ *
+ * @author Xavier Perseguers <xavier@typo3.org>
+ */
+class MiscUtility {
+
+       /**
+        * Returns meta-data for a given extension.
+        *
+        * @param string $extensionKey
+        * @return array
+        */
+       static public function getExtensionMetaData($extensionKey) {
+               $_EXTKEY = $extensionKey;
+               $EM_CONF = array();
+               $extPath = ExtensionManagementUtility::extPath($extensionKey);
+               include($extPath . 'ext_emconf.php');
+
+               $release = $EM_CONF[$_EXTKEY]['version'];
+               list($major, $minor, $_) = explode('.', $release, 3);
+               if (($pos = strpos($minor, '-')) !== FALSE) {
+                       // $minor ~ '2-dev'
+                       $minor = substr($minor, 0, $pos);
+               }
+               $EM_CONF[$_EXTKEY]['version'] = $major . '.' . $minor;
+               $EM_CONF[$_EXTKEY]['release'] = $release;
+               $EM_CONF[$_EXTKEY]['extensionKey'] = $extensionKey;
+
+               return $EM_CONF[$_EXTKEY];
+       }
+
+       /**
+        * Returns the icon associated to a given document key.
+        *
+        * @param string $documentKey
+        * @return string
+        */
+       static public function getIcon($documentKey) {
+               $basePath = 'typo3conf/Documentation/';
+               $documentPath = $basePath . $documentKey . '/';
+
+               // Fallback icon
+               $icon = ExtensionManagementUtility::siteRelPath('documentation') . 'ext_icon.gif';
+
+               if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($documentKey, 'typo3cms.extensions.')) {
+                       // Standard extension icon
+                       $extensionKey = substr($documentKey, 20);
+                       if (ExtensionManagementUtility::isLoaded($extensionKey)) {
+                               $extensionPath = ExtensionManagementUtility::extPath($extensionKey);
+                               $siteRelativePath = ExtensionManagementUtility::siteRelPath($extensionKey);
+                               $icon = $siteRelativePath . ExtensionManagementUtility::getExtensionIcon($extensionPath);
+                       }
+               } elseif (is_file(PATH_site . $documentPath . 'icon.png')) {
+                       $icon = $documentPath . 'icon.png';
+               } elseif (is_file(PATH_site . $documentPath . 'icon.gif')) {
+                       $icon = $documentPath . 'icon.gif';
+               }
+
+               return $icon;
+       }
+
+}