registerArgument('extension', 'array', 'Extension key', true); } /** * Renders a link to re-import the static SQL data of an extension * * @return string The rendered a tag */ public function render() { $extension = $this->arguments['extension']; $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $staticSqlDataFile = $extension['siteRelPath'] . 'ext_tables_static+adt.sql'; if (!file_exists(Environment::getPublicPath() . '/' . $staticSqlDataFile)) { return '' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . ''; } $registry = GeneralUtility::makeInstance(Registry::class); $oldMd5Hash = $registry->get(static::$registryNamespace, $staticSqlDataFile); $md5HashIsEqual = true; // We used to only store "1" in the database when data was imported // No need to compare file content here and just show the reload icon if (!empty($oldMd5Hash) && $oldMd5Hash !== 1) { $currentMd5Hash = md5_file(Environment::getPublicPath() . '/' . $staticSqlDataFile); $md5HashIsEqual = $oldMd5Hash === $currentMd5Hash; } if ($md5HashIsEqual) { $iconIdentifier = 'actions-database-reload'; $languageKey = 'extensionList.databaseReload'; } else { $iconIdentifier = 'actions-database-import'; $languageKey = 'extensionList.databaseImport'; } $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder(); $uriBuilder->reset(); $uri = $uriBuilder->uriFor('reloadExtensionData', ['extension' => $extension['key']], 'Action'); $this->tag->addAttribute('href', $uri); $this->tag->addAttribute('title', LocalizationUtility::translate($languageKey, 'extensionmanager')); $this->tag->setContent($iconFactory->getIcon($iconIdentifier, Icon::SIZE_SMALL)->render()); return $this->tag->render(); } }