Commit d5dd8bed authored by Thomas Löffler's avatar Thomas Löffler

Merge branch 'develop' into task/update-solr

parents f9196ffa 85af25fd
Pipeline #7813 passed with stages
in 3 minutes
...@@ -64,10 +64,14 @@ class DocumentationService implements \TYPO3\CMS\Core\SingletonInterface ...@@ -64,10 +64,14 @@ class DocumentationService implements \TYPO3\CMS\Core\SingletonInterface
$documentationLink = ''; $documentationLink = '';
$oldManualsInformation = json_decode(@file_get_contents(PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . 'oldmanuals.json'), true); $oldManualsInformation = json_decode(@file_get_contents(PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . 'oldmanuals.json'), true);
if (isset($this->docsInformation[$extensionKey]['docs'][$versionString])) { foreach ($this->getPossibleVersionStrings($versionString) as $possibleVersionString) {
// link to extension to get the latest manual if (isset($this->docsInformation[$extensionKey]['docs'][$possibleVersionString])) {
$url = $this->docsInformation[$extensionKey]['docs'][$versionString]['url']; $url = $this->docsInformation[$extensionKey]['docs'][$possibleVersionString]['url'];
} elseif (isset($oldManualsInformation[$extensionKey])) { break;
}
}
if ($url === '' && isset($oldManualsInformation[$extensionKey])) {
$baseUrl = 'https://docs.typo3.org/typo3cms/extensions/'; $baseUrl = 'https://docs.typo3.org/typo3cms/extensions/';
$url = $baseUrl . $extensionKey . '/'; $url = $baseUrl . $extensionKey . '/';
} }
...@@ -78,4 +82,21 @@ class DocumentationService implements \TYPO3\CMS\Core\SingletonInterface ...@@ -78,4 +82,21 @@ class DocumentationService implements \TYPO3\CMS\Core\SingletonInterface
return $returnUrlOnly ? $url : $documentationLink; return $returnUrlOnly ? $url : $documentationLink;
} }
private function getPossibleVersionStrings(string $defaultVersion): array
{
$possibleVersionStrings = [
$defaultVersion,
// just 2 points without v
];
$versionParts = explode('.', $defaultVersion);
if (count($versionParts) === 3) {
$possibleVersionStrings[] = implode('.', array_slice($versionParts, 0, 2));
}
$possibleVersionStrings[] = ltrim($defaultVersion, 'v');
$possibleVersionStrings[] = ltrim(implode('.', array_slice($versionParts, 0, 2)), 'v');
return $possibleVersionStrings;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment