2 namespace TYPO3\CMS\Lang\Service;
37 $mirrorUrl .= $extPath[0] .
'/' . $extPath[1] .
'/' . $extPath .
'-l10n/' . $extPath .
'-l10n.xml';
38 $remote = GeneralUtility::getURL($mirrorUrl, 0, array(TYPO3_user_agent));
39 if ($remote !==
false) {
41 $result = $parsed[
'languagePackIndex'];
56 $parser = xml_parser_create();
59 xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
60 xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
62 xml_parse_into_struct($parser, $string, $values, $index);
64 if (xml_get_error_code($parser)) {
65 $line = xml_get_current_line_number($parser);
66 $error = xml_error_string(xml_get_error_code($parser));
67 xml_parser_free($parser);
68 throw new \TYPO3\CMS\Lang\Exception\XmlParser(
'Error in XML parser while decoding l10n XML file. Line ' . $line .
': ' . $error, 1345736517);
71 $stack = array(array());
77 foreach ($values as $val) {
79 $tagName = ($val[
'tag'] ==
'languagepack' && $val[
'type'] ==
'open') ? $val[
'attributes'][
'language'] : $val[
'tag'];
81 $documentTag = $tagName;
84 switch ($val[
'type']) {
89 $current[$tagName] = array();
90 $stack[$stacktop++] = $current;
95 $oldCurrent = $current;
96 $current = $stack[--$stacktop];
99 $current[key($current)] = $oldCurrent;
104 $trimmedValue = trim((
string)$val[
'value']);
105 if ($trimmedValue !==
'') {
106 $current[$tagName] = $trimmedValue;
111 $result = $current[$tagName];
129 if (is_array($l10n)) {
131 $relativeLanguagePath =
'l10n' .
'/' . $language .
'/';
134 if (empty($absolutePathToZipFile) || empty($absoluteLanguagePath) || empty($absoluteExtensionLanguagePath)) {
135 throw new \TYPO3\CMS\Lang\Exception\Language(
'Given path is invalid.', 1352565336);
137 if (!is_dir($absoluteLanguagePath)) {
141 if (is_dir($absoluteExtensionLanguagePath)) {
148 }
catch (\TYPO3\CMS\Core\Exception $exception) {
168 $packageUrl = $extensionPath[0] .
'/' . $extensionPath[1] .
'/' . $extensionPath .
169 '-l10n/' . $extensionPath .
'-l10n-' . $language .
'.zip';
173 if (strpos($path,
'/sysext/') !==
false) {
175 list($majorVersion, ) = explode(
'.', TYPO3_branch);
178 $packageUrl = $extensionPath[0] .
'/' . $extensionPath[1] .
'/' . $extensionPath .
179 '-l10n/' . $extensionPath .
'-l10n-' . $language .
'.v' . $majorVersion .
'.zip';
181 }
catch (\BadFunctionCallException $e) {
185 $l10nResponse = GeneralUtility::getURL($mirrorUrl . $packageUrl, 0, array(TYPO3_user_agent));
186 if ($l10nResponse ===
false) {
187 throw new \TYPO3\CMS\Lang\Exception\XmlParser(
'Error: Translation could not be fetched.', 1345736785);
189 return array($l10nResponse);
203 $zip = zip_open($file);
204 if (is_resource($zip)) {
206 if (!is_dir($path)) {
209 while (($zipEntry = zip_read($zip)) !==
false) {
210 $zipEntryName = zip_entry_name($zipEntry);
211 if (strpos($zipEntryName,
'/') !==
false) {
212 $zipEntryPathSegments = explode(
'/', $zipEntryName);
213 $fileName = array_pop($zipEntryPathSegments);
215 if (empty($fileName)) {
219 if (trim($absoluteTargetPath) !==
'') {
221 $absoluteTargetPath, zip_entry_read($zipEntry, zip_entry_filesize($zipEntry))
223 if ($return ===
false) {
224 throw new \TYPO3\CMS\Lang\Exception\Language(
'Could not write file ' . $zipEntryName, 1345304560);
227 throw new \TYPO3\CMS\Lang\Exception\Language(
'Could not write file ' . $zipEntryName, 1352566904);
231 throw new \TYPO3\CMS\Lang\Exception\Language(
'Extension directory missing in zip file!', 1352566905);
235 throw new \TYPO3\CMS\Lang\Exception\Language(
'Unable to open zip file ' . $file, 1345304561);