/**
  * The fallback order property is cached. This testcase
  * should ensure that it can be read multiple times.
  *
  * @test
  * @return void
  */
 public function getFallBackOrderMultipleTimes()
 {
     $el = $this->getMockForAbstractClass('tx_languagevisibility_element', array(), '', false);
     $languageRepository = new tx_languagevisibility_languagerepository();
     /* @var $language tx_languagevisibility_language */
     $language = $languageRepository->getLanguageById(1);
     $this->assertEquals(array(0 => 0), $language->getFallbackOrder($el));
     $this->assertEquals(count(array(0 => 0)), 1);
     $this->assertEquals(array(0 => 0), $language->getFallbackOrder($el));
     $this->assertFalse($language->isLanguageUidInFallbackOrder(22, $el));
     $this->assertTrue($language->isLanguageUidInFallbackOrder(0, $el));
 }
 function _hasOverlayRecordForLanguage($id)
 {
     $languageRep = tx_languagevisibility_languagerepository::makeInstance();
     $language = $languageRep->getLanguageById($id);
     $this->langIsoCodeForFlexFormCallback = strtoupper($language->getIsoCode());
     $this->_callBackFoundOverlay = FALSE;
     // Get data structure:
     if ($this->langDisabled == 1 && !$this->langDatabaseOverlay) {
         //the FCE has langDisabled: this means there is no overlay
         if ($this->disabledIsVisible == 1) {
             return true;
         } else {
             return false;
         }
     }
     if ($GLOBALS['TSFE']) {
         @$GLOBALS['TSFE']->includeTCA();
     }
     if ($this->langChildren == 1) {
         //the FCE has real overlay record
         $flexObj = t3lib_div::makeInstance('t3lib_flexformtools');
         if ($this->row['tx_templavoila_flex']) {
             $return = $flexObj->traverseFlexFormXMLData('tt_content', 'tx_templavoila_flex', $this->row, $this, '_hasOverlayRecordForLanguage_Inheritance_flexFormCallBack');
             if ($return !== TRUE && strlen($return) > 0) {
                 debug('FCE: _hasOverlayRecordForLanguage has error:' . $return);
             }
             return $this->_callBackFoundOverlay;
         } else {
             //in case no xml yet (new created?)
             return false;
         }
     } else {
         //the FCE has no real overlay record
         $flexObj = t3lib_div::makeInstance('t3lib_flexformtools');
         $flexObj->traverseFlexFormXMLData('tt_content', 'tx_templavoila_flex', $this->row, $this, '_hasOverlayRecordForLanguage_Seperate_flexFormCallBack');
         return $this->_callBackFoundOverlay;
     }
 }
 /**
  * returns an instance of the language repository as singleton.
  *
  * @param void
  * @return tx_languagevisibility_languagerepository
  */
 public static function makeInstance()
 {
     if (!self::$instance instanceof tx_languagevisibility_languagerepository) {
         self::$instance = t3lib_div::makeInstance('tx_languagevisibility_languagerepository');
     }
     return self::$instance;
 }
 /**
  * Helper function to check i an element with a given uid and tablename is visible for a languageid.
  *
  * @param int $uid
  * @param string $table
  * @param int $languageUid
  * @return boolean
  */
 public static function isVisible($uid, $table, $languageUid, $omitLocal = false)
 {
     $cacheKey = sprintf('%s:%d:%d:%d', $table, $uid, $languageUid, $omitLocal);
     if (!isset(self::$cache_isVisible[$cacheKey])) {
         $rep = tx_languagevisibility_languagerepository::makeInstance();
         $language = $rep->getLanguageById($languageUid);
         $dao = t3lib_div::makeInstance('tx_languagevisibility_daocommon');
         if (version_compare(TYPO3_version, '4.3.0', '<')) {
             $elementfactoryName = t3lib_div::makeInstanceClassName('tx_languagevisibility_elementFactory');
             $elementfactory = new $elementfactoryName($dao);
         } else {
             $elementfactory = t3lib_div::makeInstance('tx_languagevisibility_elementFactory', $dao);
         }
         try {
             $element = $elementfactory->getElementForTable($table, $uid);
         } catch (Exception $e) {
             return false;
         }
         $visibility = t3lib_div::makeInstance('tx_languagevisibility_visibilityService');
         self::$cache_isVisible[$cacheKey] = $visibility->isVisible($language, $element, $omitLocal);
     }
     return self::$cache_isVisible[$cacheKey];
 }