/** * 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 tslib_fe $ref * @return void */ public function settingLanguage_preProcess($params, &$ref) { // Get values from TypoScript: $lUid = intval($ref->config['config']['sys_language_uid']); //works only with "ignore" setting //need to check access for current page and show error: if (!tx_languagevisibility_feservices::checkVisiblityForElement($ref->page['uid'], 'pages', $lUid)) { $GLOBALS['TSFE']->pageNotFoundAndExit('Page is not visible in requested language [' . $lUid . '/' . $ref->page['uid'] . ']'); } }
/** * Setting the language key that'll be used by the current page. * In this function it should be checked, 1) that this language exists, 2) that a page_overlay_record exists, .. and if not the default language, 0 (zero), should be set. * * @return void * @access private */ function settingLanguage() { // Get values from TypoScript: $lUid = intval($this->config['config']['sys_language_uid']); //works only with "ignore" setting //need to check access for current page and show error: if (!tx_languagevisibility_feservices::checkVisiblityForElement($this->page['uid'], 'pages', $lUid)) { $GLOBALS['TSFE']->pageNotFoundAndExit('Page is not visible in requested language [' . $lUid . '/' . $this->page['uid'] . ']'); } //overlay of current page is handled in ux_t3lib_pageSelect::getPageOverlay parent::settingLanguage(); }
/** * Process the prepared crawler urls and check wether these pages have the chance to get crawled or not * * @param array $params the crawler result * @param object $ref the crawler_lib * @return void */ public function processUrls(&$params, &$ref) { foreach ($params['res'] as $cfg => $sub) { $list = array(); foreach ($params['res'][$cfg]['URLs'] as $key => $url) { list($id, $lang) = self::extractIdAndLangFromUrl($url); if (tx_languagevisibility_feservices::checkVisiblityForElement($id, 'pages', $lang)) { $list[] = $url; } else { // $url not visible therefore we drop it } } $params['res'][$cfg]['URLs'] = $list; } }
/** * * @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); } }