17 use \TYPO3\CMS\Core\Utility\GeneralUtility;
36 $documents = json_decode($json, TRUE);
37 foreach ($documents as &$document) {
56 foreach (
$GLOBALS[
'TYPO3_LOADED_EXT'] as $extensionKey => $extensionData) {
58 if (is_file($absoluteExtensionPath .
'README.rst') || is_file($absoluteExtensionPath .
'Documentation' . DIRECTORY_SEPARATOR .
'Index.rst')) {
60 if ($extensionData[
'type'] ===
'S') {
61 $version = TYPO3_branch;
63 $version = substr($metadata[
'release'], -4) ===
'-dev' ?
'latest' : $metadata[
'release'];
66 $documentKey =
'typo3cms.extensions.' . $extensionKey;
68 'title' => $metadata[
'title'],
69 'icon' => \
TYPO3\CMS\Documentation\Utility\MiscUtility::getIcon($documentKey),
70 'type' =>
'Extension',
71 'key' => $documentKey,
72 'shortcut' => $extensionKey,
73 'url' =>
'https://docs.typo3.org/typo3cms/extensions/' . $extensionKey .
'/',
74 'version' => $version,
103 if (count($packages) == 0) {
107 $languages = array($language);
108 if ($language !==
'default') {
109 $languages[] =
'default';
111 foreach ($languages as $language) {
113 if (isset($packages[$version][$language])) {
114 $success |= $this->
fetchDocument($url, $key, $version, $language);
118 foreach ($packages[$version] as $locale => $_) {
120 $success |= $this->
fetchDocument($url, $key, $version, $locale);
127 if (preg_match(
'/^(\d+\.\d+)\.\d+$/', $version, $matches)) {
129 $shortVersion = $matches[1];
130 if (isset($packages[$shortVersion][$language])) {
131 $success |= $this->
fetchDocument($url, $key, $shortVersion, $language);
137 if ($version !==
'latest' && isset($packages[
'latest'][$language])) {
138 $success |= $this->
fetchDocument($url, $key,
'latest', $language);
156 public function fetchDocument($url, $key, $version =
'latest', $language =
'default') {
158 $url = rtrim($url,
'/') .
'/';
160 $packagePrefix = substr($key, strrpos($key,
'.') + 1);
161 $languageSegment = str_replace(
'_',
'-', strtolower($language));
162 $packageName = sprintf(
'%s-%s-%s.zip', $packagePrefix, $version, $languageSegment);
163 $packageUrl = $url .
'packages/' . $packageName;
167 if (count($packages) == 0 || !isset($packages[$version][$language])) {
173 if (is_file($absolutePathToZipFile)) {
174 $localMd5 = md5_file($absolutePathToZipFile);
175 $remoteMd5 = $packages[$version][$language];
176 $hasArchive = $localMd5 === $remoteMd5;
181 if (!empty($content)) {
186 if (is_file($absolutePathToZipFile)) {
193 $documents = json_decode(file_get_contents($absoluteCacheFilename), TRUE);
194 foreach ($documents as $document) {
195 if ($document[
'key'] === $key) {
196 $composerData = array(
197 'name' => $document[
'title'],
198 'type' =>
'documentation',
199 'description' =>
'TYPO3 ' . $document[
'type'],
201 $relativeComposerFilename = $key .
'/' . $language .
'/composer.json';
221 $url = rtrim($url,
'/') .
'/';
222 $indexUrl = $url .
'packages/packages.xml';
241 $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
242 $data = json_decode(json_encode((array)simplexml_load_string($string)), TRUE);
243 libxml_disable_entity_loader($previousValueOfEntityLoader);
244 if (count($data) != 2) {
245 throw new \TYPO3\CMS\Documentation\Exception\XmlParser(
'Error in XML parser while decoding packages XML file.', 1374222437);
249 if ($data[
'languagePackIndex'][
'languagepack'][0] === NULL) {
250 $data[
'languagePackIndex'][
'languagepack'] = array($data[
'languagePackIndex'][
'languagepack']);
254 foreach ($data[
'languagePackIndex'][
'languagepack'] as $languagePack) {
255 $language = $languagePack[
'@attributes'][
'language'];
256 $version = $languagePack[
'@attributes'][
'version'];
257 $packages[$version][$language] = $languagePack[
'md5'];
272 $zip = zip_open($file);
273 if (is_resource($zip)) {
276 if (!is_dir($path)) {
280 while (($zipEntry = zip_read($zip)) !== FALSE) {
281 $zipEntryName = zip_entry_name($zipEntry);
282 if (strpos($zipEntryName,
'/') !== FALSE) {
283 $zipEntryPathSegments = explode(
'/', $zipEntryName);
284 $fileName = array_pop($zipEntryPathSegments);
286 if (empty($fileName)) {
290 if (strlen(trim($absoluteTargetPath)) > 0) {
292 $absoluteTargetPath, zip_entry_read($zipEntry, zip_entry_filesize($zipEntry))
294 if ($return === FALSE) {
295 throw new \TYPO3\CMS\Documentation\Exception\Document(
'Could not write file ' . $zipEntryName, 1374161546);
298 throw new \TYPO3\CMS\Documentation\Exception\Document(
'Could not write file ' . $zipEntryName, 1374161532);
302 throw new \TYPO3\CMS\Documentation\Exception\Document(
'Extension directory missing in zip file!', 1374161519);
306 throw new \TYPO3\CMS\Documentation\Exception\Document(
'Unable to open zip file ' . $file, 1374161508);
fetchDocument($url, $key, $version='latest', $language='default')
static mkdir_deep($directory, $deepDirectory='')
static writeFile($file, $content, $changePermissions=FALSE)
parsePackagesXML($string)
static isFirstPartOfStr($str, $partStr)
static getIcon($documentKey)
getAvailablePackages($url)
unzipDocumentPackage($file, $path)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
static getUrl($url, $includeHeader=0, $requestHeaders=FALSE, &$report=NULL)
fetchNearestDocument($url, $key, $version='latest', $language='default')
static getExtensionMetaData($extensionKey)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static getFileAbsFileName($filename, $onlyRelative=TRUE, $relToTYPO3_mainDir=FALSE)