/** * Render the simple XML export * * @param array Translation data for configuration * @return string Filename */ function render() { global $LANG, $BE_USER; $sysLang = $this->sysLang; $accumObj = $this->l10ncfgObj->getL10nAccumulatedInformationsObjectForLanguage($sysLang); if ($this->forcedSourceLanguage) { $accumObj->setForcedPreviewLanguage($this->forcedSourceLanguage); } $accum = $accumObj->getInfoArray(); $errorMessage = array(); /** @var $xmlTool tx_l10nmgr_xmltools */ $xmlTool = t3lib_div::makeInstance('tx_l10nmgr_xmltools'); $output = array(); // Traverse the structure and generate XML output: foreach ($accum as $pId => $page) { $output[] = "\t" . '<pageGrp id="' . $pId . '" sourceUrl="' . t3lib_div::getIndpEnv("TYPO3_SITE_URL") . 'index.php?id=' . $pId . '">' . "\n"; foreach ($accum[$pId]['items'] as $table => $elements) { foreach ($elements as $elementUid => $data) { if (!empty($data['ISOcode'])) { $targetIso = $data['ISOcode']; } if (is_array($data['fields'])) { $fieldsForRecord = array(); foreach ($data['fields'] as $key => $tData) { if (is_array($tData)) { list(, $uidString, $fieldName) = explode(':', $key); list($uidValue) = explode('/', $uidString); $noChangeFlag = !strcmp(trim($tData['diffDefaultValue']), trim($tData['defaultValue'])); if (!$this->modeOnlyChanged || !$noChangeFlag) { // @DP: Why this check? if ($this->forcedSourceLanguage && isset($tData['previewLanguageValues'][$this->forcedSourceLanguage]) || $this->forcedSourceLanguage === FALSE) { if ($this->forcedSourceLanguage) { $dataForTranslation = $tData['previewLanguageValues'][$this->forcedSourceLanguage]; } else { $dataForTranslation = $tData['defaultValue']; } $_isTranformedXML = FALSE; // Following checks are not enough! Fields that could be transformed to be XML conform are not transformed! textpic fields are not isRTE=1!!! No idea why... //DZ 2010-09-08 // > if > else loop instead of || // Test re-import of XML! RTE-Back transformation //echo $tData['fieldType']; //if (preg_match('/templavoila_flex/',$key)) { echo "1 -"; } //echo $key."\n"; if ($tData['fieldType'] == 'text' && $tData['isRTE'] || preg_match('/templavoila_flex/', $key)) { $dataForTranslationTranformed = $xmlTool->RTE2XML($dataForTranslation); if ($dataForTranslationTranformed !== FALSE) { $_isTranformedXML = TRUE; $dataForTranslation = $dataForTranslationTranformed; } } if ($_isTranformedXML) { $output[] = "\t\t" . '<data table="' . $table . '" elementUid="' . $elementUid . '" key="' . $key . '" transformations="1">' . $dataForTranslation . '</data>' . "\n"; } else { //Substitute & with & in non-RTE fields $dataForTranslation = str_replace('&', '&', $dataForTranslation); $dataForTranslation = str_replace('<', '<', $dataForTranslation); //$dataForTranslation = t3lib_div::deHSCentities($dataForTranslation); $params = $BE_USER->getModuleData('l10nmgr/cm1/prefs', 'prefs'); if ($params['utf8'] == '1') { $dataForTranslation = tx_l10nmgr_utf8tools::utf8_bad_strip($dataForTranslation); } if ($xmlTool->isValidXMLString($dataForTranslation)) { $output[] = "\t\t" . '<data table="' . $table . '" elementUid="' . $elementUid . '" key="' . $key . '">' . $dataForTranslation . '</data>' . "\n"; } else { if ($params['noxmlcheck'] == '1') { $output[] = "\t\t" . '<data table="' . $table . '" elementUid="' . $elementUid . '" key="' . $key . '"><![CDATA[' . $dataForTranslation . ']]></data>' . "\n"; } else { $this->setInternalMessage($LANG->getLL('export.process.error.invalid.message'), $elementUid . '/' . $table . '/' . $key); } } } } else { $this->setInternalMessage($LANG->getLL('export.process.error.empty.message'), $elementUid . '/' . $table . '/' . $key); } } } } } } } $output[] = "\t" . '</pageGrp>' . "\r"; } // Provide a hook for specific manipulations before building the actual XML if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['l10nmgr']['exportCatXmlPreProcess'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['l10nmgr']['exportCatXmlPreProcess'] as $classReference) { $processingObject = t3lib_div::getUserObj($classReference); $output = $processingObject->processBeforeExportingCatXml($output, $this); } } // get ISO2L code for source language if ($this->l10ncfgObj->getData('sourceLangStaticId') && t3lib_extMgm::isLoaded('static_info_tables')) { $sourceIso2L = ''; $staticLangArr = t3lib_BEfunc::getRecord('static_languages', $this->l10ncfgObj->getData('sourceLangStaticId'), 'lg_iso_2'); $sourceIso2L = ' sourceLang="' . $staticLangArr['lg_iso_2'] . '"'; } $XML = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $XML .= '<!DOCTYPE TYPO3L10N [ <!ENTITY nbsp " "> ]>' . "\n" . '<TYPO3L10N>' . "\n"; $XML .= "\t" . '<head>' . "\n"; $XML .= "\t\t" . '<t3_l10ncfg>' . $this->l10ncfgObj->getData('uid') . '</t3_l10ncfg>' . "\n"; $XML .= "\t\t" . '<t3_sysLang>' . $sysLang . '</t3_sysLang>' . "\n"; $XML .= "\t\t" . '<t3_sourceLang>' . $staticLangArr['lg_iso_2'] . '</t3_sourceLang>' . "\n"; $XML .= "\t\t" . '<t3_targetLang>' . $targetIso . '</t3_targetLang>' . "\n"; $XML .= "\t\t" . '<t3_baseURL>' . t3lib_div::getIndpEnv("TYPO3_SITE_URL") . '</t3_baseURL>' . "\n"; $XML .= "\t\t" . '<t3_workspaceId>' . $GLOBALS['BE_USER']->workspace . '</t3_workspaceId>' . "\n"; $XML .= "\t\t" . '<t3_count>' . $accumObj->getFieldCount() . '</t3_count>' . "\n"; $XML .= "\t\t" . '<t3_wordCount>' . $accumObj->getWordCount() . '</t3_wordCount>' . "\n"; $XML .= "\t\t" . '<t3_internal>' . "\r\t" . $this->renderInternalMessage() . "\t\t" . '</t3_internal>' . "\n"; $XML .= "\t\t" . '<t3_formatVersion>' . L10NMGR_FILEVERSION . '</t3_formatVersion>' . "\n"; $XML .= "\t\t" . '<t3_l10nmgrVersion>' . L10NMGR_VERSION . '</t3_l10nmgrVersion>' . "\n"; $XML .= "\t" . '</head>' . "\n"; $XML .= implode('', $output) . "\n"; $XML .= "</TYPO3L10N>"; return $this->saveExportFile($XML); }
/** * Transforms a RTE Field to valid XML * * * @param string HTML String which should be transformed * @return mixed false if transformation failed, string with XML if all fine */ function RTE2XML($content, $withStripBadUTF8 = 0) { //function RTE2XML($content,$withStripBadUTF8=$GLOBALS['BE_USER']->getModuleData('l10nmgr/cm1/checkUTF8', '')) { //if (!$withStripBadUTF8) { // $withStripBadUTF8 = $GLOBALS['BE_USER']->getModuleData('l10nmgr/cm1/checkUTF8', ''); //} //echo '###'.$withStripBadUTF8; $content_org = $content; // First call special transformations (registered using hooks) if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['l10nmgr']['transformation'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['l10nmgr']['transformation'] as $classReference) { $processingObject = t3lib_div::getUserObj($classReference); $content = $processingObject->transform_rte($content, $this->parseHTML); } } $content = $this->parseHTML->TS_images_rte($content); $content = $this->parseHTML->TS_links_rte($content); $content = $this->parseHTML->TS_transform_rte($content, 1); //substitute & with & //$content=str_replace('&','&',$content); Changed by DZ 2011-05-11 $content = str_replace('<hr>', '<hr />', $content); $content = str_replace('<br>', '<br />', $content); $content = t3lib_div::deHSCentities($content); if ($withStripBadUTF8 == 1) { $content = tx_l10nmgr_utf8tools::utf8_bad_strip($content); } if ($this->isValidXMLString($content)) { return $content; } else { return false; } }