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
$documentationLink = '';
$oldManualsInformation = json_decode(@file_get_contents(PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . 'oldmanuals.json'), true);
if (isset($this->docsInformation[$extensionKey]['docs'][$versionString])) {
// link to extension to get the latest manual
$url = $this->docsInformation[$extensionKey]['docs'][$versionString]['url'];
} elseif (isset($oldManualsInformation[$extensionKey])) {
foreach ($this->getPossibleVersionStrings($versionString) as $possibleVersionString) {
if (isset($this->docsInformation[$extensionKey]['docs'][$possibleVersionString])) {
$url = $this->docsInformation[$extensionKey]['docs'][$possibleVersionString]['url'];
break;
}
}
if ($url === '' && isset($oldManualsInformation[$extensionKey])) {
$baseUrl = 'https://docs.typo3.org/typo3cms/extensions/';
$url = $baseUrl . $extensionKey . '/';
}
......@@ -78,4 +82,21 @@ class DocumentationService implements \TYPO3\CMS\Core\SingletonInterface
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