Exemplo n.º 1
0
 /**
  * @param string $text
  * @param boolean $trim
  * @param boolean $htmlentities
  * @throws Exception
  * @return string
  */
 public function render($text = null, $trim = true, $htmlentities = false)
 {
     if (null === $text) {
         $text = $this->renderChildren();
     }
     if (null === $text) {
         return null;
     }
     $cacheIdentifier = sha1($text);
     if (true === $this->cache->has($cacheIdentifier)) {
         return $this->cache->get($cacheIdentifier);
     }
     $this->markdownExecutablePath = CommandUtility::getCommand('markdown');
     if (false === is_executable($this->markdownExecutablePath)) {
         throw new Exception('Use of Markdown requires the "markdown" shell utility to be installed and accessible; this binary ' . 'could not be found in any of your configured paths available to this script', 1350511561);
     }
     if (true === (bool) $trim) {
         $text = trim($text);
     }
     if (true === (bool) $htmlentities) {
         $text = htmlentities($text);
     }
     $transformed = $this->transform($text);
     $this->cache->set($cacheIdentifier, $transformed);
     return $transformed;
 }
 /**
  * Flush the l10n cache
  *
  * @return void
  */
 public function clearCache()
 {
     if (isset($GLOBALS['BE_USER'])) {
         $GLOBALS['BE_USER']->writelog(3, 1, 0, 0, '[lang]: User %s has cleared the language cache', array($GLOBALS['BE_USER']->user['username']));
     }
     $this->cacheInstance->flush();
 }
Exemplo n.º 3
0
 /**
  * @param string $id
  * @return mixed
  */
 protected function retrieve($id)
 {
     if ($this->cache->has(self::ID_PREFIX . self::ID_SEPARATOR . $id)) {
         return $this->cache->get(self::ID_PREFIX . self::ID_SEPARATOR . $id);
     }
     return NULL;
 }
 /**
  * @param string $id
  * @return mixed
  */
 protected function retrieve($id)
 {
     if ($this->cache->has(get_class($this) . self::ID_SEPARATOR . $id)) {
         return $this->cache->get(get_class($this) . self::ID_SEPARATOR . $id);
     }
     return NULL;
 }
 /**
  * @param string $text
  * @param boolean $trim
  * @param boolean $htmlentities
  * @throws Exception
  * @return string
  */
 public function render($text = NULL, $trim = TRUE, $htmlentities = FALSE)
 {
     if (NULL === $text) {
         $text = $this->renderChildren();
     }
     if (NULL === $text) {
         return NULL;
     }
     $cacheIdentifier = sha1($text);
     if (TRUE === $this->cache->has($cacheIdentifier)) {
         return $this->cache->get($cacheIdentifier);
     }
     $this->markdownExecutablePath = \TYPO3\CMS\Core\Utility\CommandUtility::getCommand('markdown');
     if (FALSE === is_executable($this->markdownExecutablePath)) {
         throw new Exception('Use of Markdown requires the "markdown" shell utility to be installed ' . 'and accessible; this binary could not be found in any of your configured paths available to this script', 1350511561);
     }
     if (TRUE === (bool) $trim) {
         $text = trim($text);
     }
     if (TRUE === (bool) $htmlentities) {
         $text = htmlentities($text);
     }
     $transformed = $this->transform($text);
     $this->cache->set($cacheIdentifier, $transformed);
     return $transformed;
 }
Exemplo n.º 6
0
 /**
  * Transfers all entries from the early class information cache to
  * the classes cache in order to make them persistent
  *
  * @return void
  */
 protected function transferRuntimeClassInformationCacheEntriesToClassesCache()
 {
     foreach ($this->runtimeClassLoadingInformationCache as $classLoadingInformation) {
         $cacheEntryIdentifier = strtolower(str_replace('\\', '_', $classLoadingInformation[1]));
         if (!$this->classesCache->has($cacheEntryIdentifier)) {
             $this->classesCache->set($cacheEntryIdentifier, implode("ÿ", $classLoadingInformation));
         }
     }
 }
 /**
  * Returns parsed data from a given file and language key.
  *
  * @param string $fileReference Input is a file-reference (see \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName). That file is expected to be a supported locallang file format
  * @param string $languageKey Language key
  * @param string $charset Character set (option); if not set, determined by the language key
  * @param int $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception$
  * @param bool $isLocalizationOverride TRUE if $fileReference is a localization override
  * @return array|bool
  */
 public function getParsedData($fileReference, $languageKey, $charset = '', $errorMode = 0, $isLocalizationOverride = false)
 {
     $hash = md5($fileReference . $languageKey . $charset);
     $this->errorMode = $errorMode;
     // Check if the default language is processed before processing other language
     if (!$this->store->hasData($fileReference, 'default') && $languageKey !== 'default') {
         $this->getParsedData($fileReference, 'default', $charset, $this->errorMode);
     }
     // If the content is parsed (local cache), use it
     if ($this->store->hasData($fileReference, $languageKey)) {
         return $this->store->getData($fileReference);
     }
     // If the content is in cache (system cache), use it
     $data = $this->cacheInstance->get($hash);
     if ($data !== false) {
         $this->store->setData($fileReference, $languageKey, $data);
         return $this->store->getData($fileReference);
     }
     try {
         $this->store->setConfiguration($fileReference, $languageKey, $charset);
         /** @var $parser \TYPO3\CMS\Core\Localization\Parser\LocalizationParserInterface */
         $parser = $this->store->getParserInstance($fileReference);
         // Get parsed data
         $LOCAL_LANG = $parser->getParsedData($this->store->getAbsoluteFileReference($fileReference), $languageKey, $charset);
     } catch (Exception\FileNotFoundException $exception) {
         // Source localization file not found, set empty data as there could be an override
         $this->store->setData($fileReference, $languageKey, array());
         $LOCAL_LANG = $this->store->getData($fileReference);
     }
     // Override localization
     if (!$isLocalizationOverride && isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'])) {
         $this->localizationOverride($fileReference, $languageKey, $charset, $errorMode, $LOCAL_LANG);
     }
     // Save parsed data in cache
     $this->store->setData($fileReference, $languageKey, $LOCAL_LANG[$languageKey]);
     // Cache processed data
     $this->cacheInstance->set($hash, $this->store->getDataByLanguage($fileReference, $languageKey));
     return $this->store->getData($fileReference);
 }
Exemplo n.º 8
0
 /**
  * Returns parsed data from a given file and language key.
  *
  * @param string $fileReference Input is a file-reference (see \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName). That file is expected to be a supported locallang file format
  * @param string $languageKey Language key
  * @param string $charset Character set (option); if not set, determined by the language key
  * @param int $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception$
  * @param bool $isLocalizationOverride TRUE if $fileReference is a localization override
  * @return array|bool
  */
 public function getParsedData($fileReference, $languageKey, $charset = '', $errorMode = 0, $isLocalizationOverride = false)
 {
     // @deprecated since CMS 7, will be removed with CMS 8
     // this is a fallback to convert references to old 'cms' locallang files to the new location
     if (strpos($fileReference, 'EXT:cms') === 0) {
         $mapping = ['cms/web_info/loallang.xlf' => 'frontend/Resources/Private/Language/locallang_webinfo.xlf', 'cms/locallang_ttc.xlf' => 'frontend/Resources/Private/Language/locallang_ttc.xlf', 'cms/locallang_tca.xlf' => 'frontend/Resources/Private/Language/locallang_tca.xlf', 'cms/layout/locallang_db_new_content_el.xlf' => 'backend/Resources/Private/Language/locallang_db_new_content_el.xlf', 'cms/layout/locallang.xlf' => 'backend/Resources/Private/Language/locallang_layout.xlf', 'cms/layout/locallang_mod.xlf' => 'backend/Resources/Private/Language/locallang_mod.xlf', 'cms/locallang_csh_webinfo.xlf' => 'frontend/Resources/Private/Language/locallang_csh_webinfo.xlf', 'cms/locallang_csh_weblayout.xlf' => 'frontend/Resources/Private/Language/locallang_csh_weblayout.xlf'];
         $filePath = substr($fileReference, 4);
         GeneralUtility::deprecationLog('There is a reference to "' . $fileReference . '", which has been moved to "EXT:' . $mapping[$filePath] . '". This fallback will be removed with CMS 8.');
         $fileReference = 'EXT:' . $mapping[$filePath];
     }
     $hash = md5($fileReference . $languageKey . $charset);
     $this->errorMode = $errorMode;
     // Check if the default language is processed before processing other language
     if (!$this->store->hasData($fileReference, 'default') && $languageKey !== 'default') {
         $this->getParsedData($fileReference, 'default', $charset, $this->errorMode);
     }
     // If the content is parsed (local cache), use it
     if ($this->store->hasData($fileReference, $languageKey)) {
         return $this->store->getData($fileReference);
     }
     // If the content is in cache (system cache), use it
     $data = $this->cacheInstance->get($hash);
     if ($data !== false) {
         $this->store->setData($fileReference, $languageKey, $data);
         return $this->store->getData($fileReference);
     }
     try {
         $this->store->setConfiguration($fileReference, $languageKey, $charset);
         /** @var $parser \TYPO3\CMS\Core\Localization\Parser\LocalizationParserInterface */
         $parser = $this->store->getParserInstance($fileReference);
         // Get parsed data
         $LOCAL_LANG = $parser->getParsedData($this->store->getAbsoluteFileReference($fileReference), $languageKey, $charset);
     } catch (Exception\FileNotFoundException $exception) {
         // Source localization file not found, set empty data as there could be an override
         $this->store->setData($fileReference, $languageKey, array());
         $LOCAL_LANG = $this->store->getData($fileReference);
     }
     // Override localization
     if (!$isLocalizationOverride && isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'])) {
         $this->localizationOverride($fileReference, $languageKey, $charset, $errorMode, $LOCAL_LANG);
     }
     // Save parsed data in cache
     $this->store->setData($fileReference, $languageKey, $LOCAL_LANG[$languageKey]);
     // Cache processed data
     $this->cacheInstance->set($hash, $this->store->getDataByLanguage($fileReference, $languageKey));
     return $this->store->getData($fileReference);
 }
Exemplo n.º 9
0
 /**
  * Returns parsed data from a given file and language key.
  *
  * @param string $fileReference Input is a file-reference (see \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName). That file is expected to be a supported locallang file format
  * @param string $languageKey Language key
  * @param string $charset Character set (option); if not set, determined by the language key
  * @param int $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception$
  * @param bool $isLocalizationOverride TRUE if $fileReference is a localization override
  * @return array|bool
  */
 public function getParsedData($fileReference, $languageKey, $charset = '', $errorMode = 0, $isLocalizationOverride = false)
 {
     // @deprecated since TYPO3 v8, will be removed with TYPO3 v9
     // this is a fallback to convert references to old 'lang' locallang files to the new location
     if (strpos($fileReference, 'EXT:lang/locallang_') === 0) {
         $mapping = ['lang/locallang_alt_doc.xlf' => 'lang/Resources/Private/Language/locallang_alt_doc.xlf', 'lang/locallang_alt_intro.xlf' => 'lang/Resources/Private/Language/locallang_alt_intro.xlf', 'lang/locallang_browse_links.xlf' => 'lang/Resources/Private/Language/locallang_browse_links.xlf', 'lang/locallang_common.xlf' => 'lang/Resources/Private/Language/locallang_common.xlf', 'lang/locallang_core.xlf' => 'lang/Resources/Private/Language/locallang_core.xlf', 'lang/locallang_general.xlf' => 'lang/Resources/Private/Language/locallang_general.xlf', 'lang/locallang_login.xlf' => 'lang/Resources/Private/Language/locallang_login.xlf', 'lang/locallang_misc.xlf' => 'lang/Resources/Private/Language/locallang_misc.xlf', 'lang/locallang_mod_admintools.xlf' => 'lang/Resources/Private/Language/locallang_mod_admintools.xlf', 'lang/locallang_mod_file_list.xlf' => 'lang/Resources/Private/Language/locallang_mod_file_list.xlf', 'lang/locallang_mod_file.xlf' => 'lang/Resources/Private/Language/locallang_mod_file.xlf', 'lang/locallang_mod_help_about.xlf' => 'lang/Resources/Private/Language/locallang_mod_help_about.xlf', 'lang/locallang_mod_help_cshmanual.xlf' => 'lang/Resources/Private/Language/locallang_mod_help_cshmanual.xlf', 'lang/locallang_mod_help.xlf' => 'lang/Resources/Private/Language/locallang_mod_help.xlf', 'lang/locallang_mod_system.xlf' => 'lang/Resources/Private/Language/locallang_mod_system.xlf', 'lang/locallang_mod_usertools.xlf' => 'lang/Resources/Private/Language/locallang_mod_usertools.xlf', 'lang/locallang_mod_user_ws.xlf' => 'lang/Resources/Private/Language/locallang_mod_user_ws.xlf', 'lang/locallang_mod_web_func.xlf' => 'lang/Resources/Private/Language/locallang_mod_web_func.xlf', 'lang/locallang_mod_web_info.xlf' => 'lang/Resources/Private/Language/locallang_mod_web_info.xlf', 'lang/locallang_mod_web_list.xlf' => 'lang/Resources/Private/Language/locallang_mod_web_list.xlf', 'lang/locallang_mod_web.xlf' => 'lang/Resources/Private/Language/locallang_mod_web.xlf', 'lang/locallang_show_rechis.xlf' => 'lang/Resources/Private/Language/locallang_show_rechis.xlf', 'lang/locallang_t3lib_fullsearch.xlf' => 'lang/Resources/Private/Language/locallang_t3lib_fullsearch.xlf', 'lang/locallang_tca.xlf' => 'lang/Resources/Private/Language/locallang_tca.xlf', 'lang/locallang_tcemain.xlf' => 'lang/Resources/Private/Language/locallang_tcemain.xlf', 'lang/locallang_tsfe.xlf' => 'lang/Resources/Private/Language/locallang_tsfe.xlf', 'lang/locallang_tsparser.xlf' => 'lang/Resources/Private/Language/locallang_tsparser.xlf', 'lang/locallang_view_help.xlf' => 'lang/Resources/Private/Language/locallang_view_help.xlf', 'lang/locallang_wizards.xlf' => 'lang/Resources/Private/Language/locallang_wizards.xlf'];
         $filePath = substr($fileReference, 4);
         GeneralUtility::deprecationLog('There is a reference to "' . $fileReference . '", which has been moved to "EXT:' . $mapping[$filePath] . '". This fallback will be removed with TYPO3 v9.');
         $fileReference = 'EXT:' . $mapping[$filePath];
     }
     $hash = md5($fileReference . $languageKey . $charset);
     $this->errorMode = $errorMode;
     // Check if the default language is processed before processing other language
     if (!$this->store->hasData($fileReference, 'default') && $languageKey !== 'default') {
         $this->getParsedData($fileReference, 'default', $charset, $this->errorMode);
     }
     // If the content is parsed (local cache), use it
     if ($this->store->hasData($fileReference, $languageKey)) {
         return $this->store->getData($fileReference);
     }
     // If the content is in cache (system cache), use it
     $data = $this->cacheInstance->get($hash);
     if ($data !== false) {
         $this->store->setData($fileReference, $languageKey, $data);
         return $this->store->getData($fileReference);
     }
     try {
         $this->store->setConfiguration($fileReference, $languageKey, $charset);
         /** @var $parser \TYPO3\CMS\Core\Localization\Parser\LocalizationParserInterface */
         $parser = $this->store->getParserInstance($fileReference);
         // Get parsed data
         $LOCAL_LANG = $parser->getParsedData($this->store->getAbsoluteFileReference($fileReference), $languageKey, $charset);
     } catch (Exception\FileNotFoundException $exception) {
         // Source localization file not found, set empty data as there could be an override
         $this->store->setData($fileReference, $languageKey, []);
         $LOCAL_LANG = $this->store->getData($fileReference);
     }
     // Override localization
     if (!$isLocalizationOverride && isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'])) {
         $this->localizationOverride($fileReference, $languageKey, $charset, $errorMode, $LOCAL_LANG);
     }
     // Save parsed data in cache
     $this->store->setData($fileReference, $languageKey, $LOCAL_LANG[$languageKey]);
     // Cache processed data
     $this->cacheInstance->set($hash, $this->store->getDataByLanguage($fileReference, $languageKey));
     return $this->store->getData($fileReference);
 }
Exemplo n.º 10
0
 /**
  * Constructs the cache
  *
  * @param string $identifier A identifier which describes this cache
  * @param \TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface $backend Backend to be used for this cache
  */
 public function __construct($identifier, \TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface $backend)
 {
     parent::__construct($identifier, $backend);
 }
Exemplo n.º 11
0
 /**
  * Constructs the cache
  *
  * @param string $identifier A identifier which describes this cache
  * @param PhpCapableBackendInterface $backend Backend to be used for this cache
  */
 public function __construct($identifier, PhpCapableBackendInterface $backend)
 {
     parent::__construct($identifier, $backend);
 }
 /**
  * Cleares the complete cache for class loader.
  *
  * @return void
  */
 protected function clearClassesCache()
 {
     $this->coreCache->flush();
     $this->classesCache->flush();
 }