/**
  * Main function, returning the HTML content
  *
  * @return string HTML
  */
 function main()
 {
     $content = '';
     $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->installTool = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility');
     $databaseUpdateUtility = $this->objectManager->get('SJBR\\StaticInfoTables\\Utility\\DatabaseUpdateUtility');
     // Clear the class cache
     $classCacheManager = $this->objectManager->get('SJBR\\StaticInfoTables\\Cache\\ClassCacheManager');
     $classCacheManager->reBuild();
     // Process the database updates of this base extension (we want to re-process these updates every time the update script is invoked)
     $extensionSitePath = ExtensionManagementUtility::extPath(GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName));
     $content .= '<p>' . nl2br(LocalizationUtility::translate('updateTables', $this->extensionName)) . '</p>';
     $this->importStaticSqlFile($extensionSitePath);
     // Get the extensions which want to extend static_info_tables
     $loadedExtensions = array_unique(ExtensionManagementUtility::getLoadedExtensionListArray());
     foreach ($loadedExtensions as $extensionKey) {
         $extensionInfoFile = ExtensionManagementUtility::extPath($extensionKey) . 'Configuration/DomainModelExtension/StaticInfoTables.txt';
         if (file_exists($extensionInfoFile)) {
             // We need to reprocess the database structure update sql statements (ext_tables)
             $this->processDatabaseUpdates($extensionKey);
             // Now we process the static data updates (ext_tables_static+adt)
             // Note: The Install Tool Utility does not handle sql update statements
             $databaseUpdateUtility->doUpdate($extensionKey);
             $content .= '<p>' . nl2br(LocalizationUtility::translate('updateLanguageLabels', $this->extensionName)) . ' ' . $extensionKey . '</p>';
         }
     }
     if (!$content) {
         // Nothing to do
         $content .= '<p>' . nl2br(LocalizationUtility::translate('nothingToDo', $this->extensionName)) . '</p>';
     }
     // Notice for old language packs
     $content .= '<p>' . nl2br(LocalizationUtility::translate('update.oldLanguagePacks', $this->extensionName)) . '</p>';
     return $content;
 }
 /**
  * hook function
  *
  * @param $params
  * @param $pObj
  *
  * @return void
  * @todo add a more explaining description why this hook is required
  */
 public function init(&$params, $pObj)
 {
     // exclude extensions, which are not worth to check them
     $extensionsToCheck = array_diff(ExtensionManagementUtility::getLoadedExtensionListArray(), $this->ignoredExtensions, scandir(PATH_typo3 . 'sysext'));
     // check extensions, which are worth to check
     foreach ($extensionsToCheck as $extensionName) {
         $extPath = ExtensionManagementUtility::extPath($extensionName);
         if (file_exists($extPath . 'Meta/theme.yaml') && file_exists($extPath . 'Configuration/TypoScript/setup.txt')) {
             $pObj->add(new Theme($extensionName));
         }
     }
 }
 /**
  * Toggle extension installation state action
  *
  * @param string $extension
  */
 protected function toggleExtensionInstallationStateAction($extension)
 {
     $installedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
     if (in_array($extension, $installedExtensions)) {
         // uninstall
         $this->installUtility->uninstall($extension);
     } else {
         // install
         $this->managementService->resolveDependenciesAndInstall($this->installUtility->enrichExtensionWithDetails($extension));
     }
     $this->redirect('index', 'List', NULL, array(self::TRIGGER_RefreshModuleMenu => TRUE));
 }
Example #4
0
 /**
  * @param boolean $includeCoreExtensions
  * @return array
  */
 public static function getAllInstalledFluidEnabledExtensions($includeCoreExtensions = false)
 {
     if (true === is_array(self::$cache)) {
         return self::$cache;
     }
     $allExtensions = ExtensionManagementUtility::getLoadedExtensionListArray();
     $fluidExtensions = [];
     foreach ($allExtensions as $extensionKey) {
         $fluidTemplateFolderPath = ExtensionManagementUtility::extPath($extensionKey, 'Resources/Private/Templates');
         $isCore = strpos($fluidTemplateFolderPath, 'sysext');
         $hasTemplates = file_exists($fluidTemplateFolderPath);
         if (true === $hasTemplates) {
             if (false === $isCore || true === $includeCoreExtensions && true === $isCore) {
                 array_push($fluidExtensions, $extensionKey);
             }
         }
     }
     self::$cache = $fluidExtensions;
     return self::$cache;
 }
Example #5
0
 /**
  * Toggle extension installation state action
  *
  * @param string $extensionKey
  */
 protected function toggleExtensionInstallationStateAction($extensionKey)
 {
     $installedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
     try {
         if (in_array($extensionKey, $installedExtensions)) {
             // uninstall
             $this->installUtility->uninstall($extensionKey);
         } else {
             // install
             $extension = $this->extensionModelUtility->mapExtensionArrayToModel($this->installUtility->enrichExtensionWithDetails($extensionKey));
             if ($this->managementService->installExtension($extension) === FALSE) {
                 $this->redirect('unresolvedDependencies', 'List', NULL, array('extensionKey' => $extensionKey));
             }
         }
     } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
         $this->addFlashMessage(htmlspecialchars($e->getMessage()), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
     } catch (\TYPO3\Flow\Package\Exception\PackageStatesFileNotWritableException $e) {
         $this->addFlashMessage(htmlspecialchars($e->getMessage()), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
     }
     $this->redirect('index', 'List', NULL, array(self::TRIGGER_RefreshModuleMenu => TRUE));
 }
 /**
  * Get all loaded extensions which try to extend EXT:news
  *
  * @return array
  */
 protected function getExtensibleExtensions()
 {
     $loadedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
     // Get the extensions which want to extend news
     $extensibleExtensions = array();
     foreach ($loadedExtensions as $extensionKey) {
         try {
             $extensionInfoFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey, 'Resources/Private/extend-news.txt');
             if (file_exists($extensionInfoFile)) {
                 $info = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($extensionInfoFile);
                 $classes = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $info, TRUE);
                 foreach ($classes as $class) {
                     $extensibleExtensions[$class][$extensionKey] = 1;
                 }
             }
         } catch (Exception $e) {
             $message = sprintf('Class cache could not been been build. Error "%s" with extension "%s"!', $e->getMessage(), $extensionKey);
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($message, 'news');
         }
     }
     return $extensibleExtensions;
 }
Example #7
0
 /**
  * Call function if you need the requireJS library
  * this automatically adds the JavaScript path of all loaded extensions in the requireJS path option
  * so it resolves names like TYPO3/CMS/MyExtension/MyJsFile to EXT:MyExtension/Resources/Public/JavaScript/MyJsFile.js
  * when using requireJS
  *
  * @return void
  */
 public function loadRequireJs()
 {
     // load all paths to map to package names / namespaces
     if (count($this->requireJsConfig) === 0) {
         // first, load all paths for the namespaces, and configure contrib libs.
         $this->requireJsConfig['paths'] = array('jquery-ui' => 'contrib/jqueryui', 'jquery' => 'contrib/jquery');
         // get all extensions that are loaded
         $loadedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
         foreach ($loadedExtensions as $packageName) {
             $fullJsPath = 'EXT:' . $packageName . '/Resources/Public/JavaScript/';
             $fullJsPath = GeneralUtility::getFileAbsFileName($fullJsPath);
             $fullJsPath = \TYPO3\CMS\Core\Utility\PathUtility::getRelativePath(PATH_typo3, $fullJsPath);
             $fullJsPath = rtrim($fullJsPath, '/');
             if ($fullJsPath) {
                 $this->requireJsConfig['paths']['TYPO3/CMS/' . GeneralUtility::underscoredToUpperCamelCase($packageName)] = $this->backPath . $fullJsPath;
             }
         }
         // check if additional AMD modules need to be loaded if a single AMD module is initialized
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules'])) {
             $this->addInlineSettingArray('RequireJS.PostInitializationModules', $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules']);
         }
     }
     $this->addRequireJs = TRUE;
 }
Example #8
0
 /**
  * Call function if you need the requireJS library
  * this automatically adds the JavaScript path of all loaded extensions in the requireJS path option
  * so it resolves names like TYPO3/CMS/MyExtension/MyJsFile to EXT:MyExtension/Resources/Public/JavaScript/MyJsFile.js
  * when using requireJS
  *
  * @return void
  */
 public function loadRequireJs()
 {
     // load all paths to map to package names / namespaces
     if (empty($this->requireJsConfig)) {
         // In order to avoid browser caching of JS files, adding a GET parameter to the files loaded via requireJS
         if (GeneralUtility::getApplicationContext()->isDevelopment()) {
             $this->requireJsConfig['urlArgs'] = 'bust=' . $GLOBALS['EXEC_TIME'];
         } else {
             $this->requireJsConfig['urlArgs'] = 'bust=' . GeneralUtility::hmac(TYPO3_version . PATH_site);
         }
         // first, load all paths for the namespaces, and configure contrib libs.
         $this->requireJsConfig['paths'] = array('jquery-ui' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/jquery-ui', 'datatables' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/jquery.dataTables', 'nprogress' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/nprogress', 'moment' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/moment', 'cropper' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/cropper.min', 'imagesloaded' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/imagesloaded.pkgd.min', 'bootstrap' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap/bootstrap', 'twbs/bootstrap-datetimepicker' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap-datetimepicker', 'autosize' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/autosize', 'taboverride' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/taboverride.min', 'twbs/bootstrap-slider' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap-slider.min', 'jquery/autocomplete' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/jquery.autocomplete');
         // get all extensions that are loaded
         $loadedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
         foreach ($loadedExtensions as $packageName) {
             $fullJsPath = 'EXT:' . $packageName . '/Resources/Public/JavaScript/';
             $fullJsPath = GeneralUtility::getFileAbsFileName($fullJsPath);
             $fullJsPath = \TYPO3\CMS\Core\Utility\PathUtility::getRelativePath(PATH_typo3, $fullJsPath);
             $fullJsPath = rtrim($fullJsPath, '/');
             if ($fullJsPath) {
                 $this->requireJsConfig['paths']['TYPO3/CMS/' . GeneralUtility::underscoredToUpperCamelCase($packageName)] = $this->backPath . $fullJsPath;
             }
         }
         // check if additional AMD modules need to be loaded if a single AMD module is initialized
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules'])) {
             $this->addInlineSettingArray('RequireJS.PostInitializationModules', $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules']);
         }
     }
     $this->addRequireJs = true;
 }
 /**
  * @test
  */
 public function getRequiredExtensionListArrayReturnsUniqueList()
 {
     $GLOBALS['TYPO3_CONF_VARS']['EXT']['requiredExt'] = 'foo,bar,foo';
     $this->assertEquals(array('foo', 'bar'), array_intersect(array('foo', 'bar'), \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray()));
 }
Example #10
0
 /**
  * Call function if you need the requireJS library
  * this automatically adds the JavaScript path of all loaded extensions in the requireJS path option
  * so it resolves names like TYPO3/CMS/MyExtension/MyJsFile to EXT:MyExtension/Resources/Public/JavaScript/MyJsFile.js
  * when using requireJS
  *
  * @return void
  */
 public function loadRequireJs()
 {
     if (!empty($this->requireJsConfig)) {
         return;
     }
     $this->addRequireJs = true;
     $loadedExtensions = ExtensionManagementUtility::getLoadedExtensionListArray();
     $isDevelopment = GeneralUtility::getApplicationContext()->isDevelopment();
     $cacheIdentifier = 'requireJS_' . md5(implode(',', $loadedExtensions) . ($isDevelopment ? ':dev' : ''));
     /** @var VariableFrontend $cache */
     $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('assets');
     $this->requireJsConfig = $cache->get($cacheIdentifier);
     // if we did not get a configuration from the cache, compute and store it in the cache
     if (empty($this->requireJsConfig)) {
         $this->requireJsConfig = $this->computeRequireJsConfig($isDevelopment, $loadedExtensions);
         $cache->set($cacheIdentifier, $this->requireJsConfig);
     }
 }
 /**
  * Returns a selector-box with loaded extension keys
  *
  * @param string $prefix Form element name prefix
  * @param array $value The current values selected
  * @return string HTML select element
  */
 public function extensionSelector($prefix, $value)
 {
     $loadedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
     // make box:
     $opt = array();
     $opt[] = '<option value=""></option>';
     foreach ($loadedExtensions as $extensionKey) {
         $sel = '';
         if (is_array($value)) {
             $sel = in_array($extensionKey, $value) ? ' selected="selected"' : '';
         }
         $opt[] = '<option value="' . htmlspecialchars($extensionKey) . '"' . $sel . '>' . htmlspecialchars($extensionKey) . '</option>';
     }
     return '<select name="' . $prefix . '[]" multiple="multiple" size="' . MathUtility::forceIntegerInRange(count($opt), 5, 10) . '">' . implode('', $opt) . '</select>';
 }
Example #12
0
 /**
  * Create advanced options form
  * Sets content in $this->content
  *
  * @param array $inData Form configurat data
  * @return void
  */
 public function makeAdvancedOptionsForm($inData)
 {
     $loadedExtensions = ExtensionManagementUtility::getLoadedExtensionListArray();
     $loadedExtensions = array_combine($loadedExtensions, $loadedExtensions);
     $this->standaloneView->assign('extensions', $loadedExtensions);
     $this->standaloneView->assign('inData', $inData);
 }
 /**
  * Get all loaded extensions which try to extend EXT:static_info_tables
  *
  * @return array
  */
 protected function getExtensibleExtensions()
 {
     $loadedExtensions = array_unique(ExtensionManagementUtility::getLoadedExtensionListArray());
     // Get the extensions which want to extend static_info_tables
     $extensibleExtensions = array();
     foreach ($loadedExtensions as $extensionKey) {
         $extensionInfoFile = ExtensionManagementUtility::extPath($extensionKey) . 'Configuration/DomainModelExtension/StaticInfoTables.txt';
         if (file_exists($extensionInfoFile)) {
             $info = GeneralUtility::getUrl($extensionInfoFile);
             $classes = GeneralUtility::trimExplode(LF, $info, TRUE);
             foreach ($classes as $class) {
                 $extensibleExtensions[$class][$extensionKey] = 1;
             }
         }
     }
     return $extensibleExtensions;
 }
 /**
  * @return array
  */
 protected function detectExtensionsContainingViewHelpers()
 {
     $detected = array();
     foreach (ExtensionManagementUtility::getLoadedExtensionListArray() as $extensionKey) {
         if (!in_array($extensionKey, $this->blackistedSystemExtensionKeys)) {
             if (is_dir(GeneralUtility::getFileAbsFileName('EXT:' . $extensionKey . '/Classes/ViewHelpers'))) {
                 $detected[] = isset($this->systemExtensionKeyMap[$extensionKey]) ? $this->systemExtensionKeyMap[$extensionKey] : $extensionKey;
             }
         }
     }
     return $detected;
 }
 /**
  * Get a list of installed extensions
  *
  * @return array of installed extensions
  */
 public static function getInstalledExtensions()
 {
     if (self::$installedExtensions !== NULL) {
         return self::$installedExtensions;
     }
     if (t3lib_div::int_from_ver(TYPO3_version) < 6001000) {
         /** @var $extensionList tx_em_Extensions_List */
         $extensionList = t3lib_div::makeInstance('tx_em_Extensions_List');
         list($list, ) = $extensionList->getInstalledExtensions();
         $list = array_keys($list);
     } else {
         $list = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
     }
     self::$installedExtensions = $list;
     return $list;
 }
 /**
  * Returns the list of composer.json files
  *
  * @return array<string>
  */
 public function getComposerFiles()
 {
     $composerFiles = array();
     if (is_callable(array('t3lib_extMgm', 'getEnabledExtensionList'))) {
         $extensions = explode(',', t3lib_extMgm::getEnabledExtensionList());
     } else {
         $extensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
     }
     foreach ($extensions as $extension) {
         $composerFilePath = t3lib_extMgm::extPath($extension) . '/composer.json';
         if (file_exists($composerFilePath)) {
             $composerFiles[$extension] = $composerFilePath;
         }
     }
     return $composerFiles;
 }
Example #17
0
 /**
  * Returns the keys of the loaded extensions.
  *
  * @return string[] the keys of the loaded extensions, might be empty
  */
 protected function getLoadedExtensionKeys()
 {
     return ExtensionManagementUtility::getLoadedExtensionListArray();
 }
 /**
  * Update an extension. Makes no sanity check but directly searches highest
  * available version from TER and updates. Update check is done by the list
  * already. This method should only be called if we are sure that there is
  * an update.
  *
  * @return string
  */
 protected function updateExtensionAction()
 {
     $extensionKey = $this->request->getArgument('extension');
     $version = $this->request->getArgument('version');
     $extension = $this->extensionRepository->findOneByExtensionKeyAndVersion($extensionKey, $version);
     if (!$extension instanceof Extension) {
         $extension = $this->extensionRepository->findHighestAvailableVersion($extensionKey);
     }
     $installedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
     try {
         if (in_array($extensionKey, $installedExtensions, TRUE)) {
             // To resolve new dependencies the extension is installed again
             $this->managementService->installExtension($extension);
         } else {
             $this->managementService->downloadMainExtension($extension);
         }
         $this->addFlashMessage(htmlspecialchars($this->translate('extensionList.updateFlashMessage.body', array($extensionKey))), $this->translate('extensionList.updateFlashMessage.title'));
     } catch (\Exception $e) {
         $this->addFlashMessage(htmlspecialchars($e->getMessage()), '', FlashMessage::ERROR);
     }
     return '';
 }
Example #19
0
 /**
  * Find all ext_autoload files and merge with core_autoload.
  *
  * @return array
  */
 protected static function createCoreAndExtensionRegistry()
 {
     $classRegistry = array();
     // At this point during bootstrap the local configuration is initialized,
     // ExtensionManagementUtility is ready to get the list of enabled extensions
     foreach (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray() as $extensionKey) {
         try {
             $extensionAutoloadFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey, 'ext_autoload.php');
             if (@file_exists($extensionAutoloadFile)) {
                 $classRegistry = array_merge($classRegistry, require $extensionAutoloadFile);
             }
         } catch (\BadFunctionCallException $e) {
         }
     }
     return $classRegistry;
 }