/** * Creates language-overlay for records in general (where translation is found in records from the same table) * * @param string Table name * @param array Record to overlay. Must containt uid, pid and $table]['ctrl']['languageField'] * @param integer Pointer to the sys_language uid for content on the site. * @param string Overlay mode. If "hideNonTranslated" then records without translation will not be returned un-translated but unset (and return value is false) * @return mixed Returns the input record, possibly overlaid with a translation. But if $OLmode is "hideNonTranslated" then it will return false if no translation is found. */ function getRecordOverlay($table, $row, $sys_language_content, $OLmode = '') { //echo $table.'--'.$row['uid'].'--'.$sys_language_content.'--'.$OLmode; //echo '<hr>'; //return parent::getRecordOverlay($table,$row,$sys_language_content,$OLmode); global $TCA; //echo $row['uid'].'-'; //39348 //unset olmode $OLmode = ''; // die('���'); //call service to know if element is visible and which overlay language to use try { $element = tx_languagevisibility_feservices::getElement($row['uid'], $table); $overlayLanguage = tx_languagevisibility_feservices::getOverlayLanguageIdForElement($element, $sys_language_content); } catch (Exception $e) { //for any other tables: return parent::getRecordOverlay($table, $row, $sys_language_content, $OLmode); } //debug($overlayLanguage); if ($overlayLanguage === false) { //echo 'unset '.$table.' / '.$row['uid']; //not visible: unset($row); return $row; } else { //visible: if ($overlayLanguage != 0) { if ($element instanceof tx_languagevisibility_fceelement) { //for FCE the overlay processing is handled by templavoila module, so mark the row with additional infos: $languageRep = t3lib_div::makeInstance('tx_languagevisibility_languagerepository'); $overlayLanguageObj = $languageRep->getLanguageById($overlayLanguage); $row['_OVERLAYLANGUAGEISOCODE'] = $overlayLanguageObj->getIsoCode(); return $row; } elseif ($element instanceof tx_languagevisibility_fceoverlayelement) { //now its getting tricky: we need to return overlay record with merged XML $olrow = $this->_getDatabaseTranslationOverlayRecord('tt_content', $row, $overlayLanguage); if ($GLOBALS['TSFE']) { $GLOBALS['TSFE']->includeTCA('tt_content'); } //parse fce xml, and where a xml field is empty in olrow -> use default one $flexObj = t3lib_div::makeInstance('t3lib_flexformtools'); $this->_callbackVar_defaultXML = t3lib_div::xml2array($row['tx_templavoila_flex']); $this->_callbackVar_overlayXML = t3lib_div::xml2array($olrow['tx_templavoila_flex']); if (!is_array($this->_callbackVar_overlayXML)) { $this->_callbackVar_overlayXML = array(); } $return = $flexObj->traverseFlexFormXMLData('tt_content', 'tx_templavoila_flex', $row, $this, '_callback_checkXMLFieldsForFallback'); $row = parent::getRecordOverlay($table, $row, $overlayLanguage, $OLmode); $row['tx_templavoila_flex'] = t3lib_div::array2xml($this->_callbackVar_overlayXML); return $row; } else { //for default elements just do TYPO3 default overlay return parent::getRecordOverlay($table, $row, $overlayLanguage, $OLmode); } } else { return $row; } } }
/** * * @param unknown_type $table * @param unknown_type $row * @param unknown_type $sys_language_content * @param unknown_type $OLmode * @param t3lib_pageSelect $parent * @return void */ public function getRecordOverlay_postProcess($table, &$row, &$sys_language_content, $OLmode, t3lib_pageSelect $parent) { if (!is_array($row) || !isset($row['uid']) || $sys_language_content == 0) { return; } try { $element = tx_languagevisibility_feservices::getElement($row['uid'], $table); $overlayLanguage = tx_languagevisibility_feservices::getOverlayLanguageIdForElement($element, $sys_language_content); } catch (Exception $e) { return; } if ($element instanceof tx_languagevisibility_fceelement) { //for FCE the overlay processing is handled by templavoila module, so mark the row with additional infos: $languageRep = t3lib_div::makeInstance('tx_languagevisibility_languagerepository'); $overlayLanguageObj = $languageRep->getLanguageById($overlayLanguage); $row['_OVERLAYLANGUAGEISOCODE'] = $overlayLanguageObj->getIsoCode(); } elseif ($element instanceof tx_languagevisibility_fceoverlayelement) { //now its getting tricky: we need to return overlay record with merged XML $row['tx_templavoila_flex'] = $row['_ORIG_tx_templavoila_flex']; unset($row['_ORIG_tx_templavoila_flex']); $olrow = $this->_getDatabaseTranslationOverlayRecord('tt_content', $row, $overlayLanguage); if ($GLOBALS['TSFE']) { $GLOBALS['TSFE']->includeTCA('tt_content'); } //parse fce xml, and where a xml field is empty in olrow -> use default one $flexObj = t3lib_div::makeInstance('t3lib_flexformtools'); $this->_callbackVar_defaultXML = t3lib_div::xml2array($row['tx_templavoila_flex']); $this->_callbackVar_overlayXML = t3lib_div::xml2array($olrow['tx_templavoila_flex']); if (!is_array($this->_callbackVar_overlayXML)) { $this->_callbackVar_overlayXML = array(); } $return = $flexObj->traverseFlexFormXMLData('tt_content', 'tx_templavoila_flex', $row, $this, '_callback_checkXMLFieldsForFallback'); if ($sys_language_content != $overlayLanguage) { $row = $parent->getRecordOverlay($table, $row, $overlayLanguage, $OLmode); } $row['tx_templavoila_flex'] = t3lib_div::array2xml($this->_callbackVar_overlayXML); } }