/**
  * Setzt eventuelle Sprachparameter,
  * damit nur valide Daten für die aktuelle Sprache ausgelesen werden.
  *
  * @param array &$fields
  * @param array &$options
  * @return void
  */
 protected function handleLanguageOptions(&$fields, &$options)
 {
     if (!isset($options['i18n']) && !isset($options['ignorei18n']) && !isset($options['enablefieldsoff'])) {
         $tableName = $this->getEmptyModel()->getTableName();
         $languageField = tx_rnbase_util_TCA::getLanguageFieldForTable($tableName);
         // Die Sprache prüfen wir nur, wenn ein Sprachfeld gesetzt ist.
         if (!empty($languageField)) {
             $tsfe = tx_rnbase_util_TYPO3::getTSFE();
             $languages = array();
             if (isset($options['additionali18n'])) {
                 $languages = tx_rnbase_util_Strings::trimExplode(',', $options['additionali18n'], TRUE);
             }
             // for all languages
             $languages[] = '-1';
             // Wenn eine bestimmte Sprache gesetzt ist,
             // laden wir diese ebenfalls.
             if (is_object($tsfe) && $tsfe->sys_language_content) {
                 $languages[] = $tsfe->sys_language_content;
             } else {
                 // default language
                 $languages[] = '0';
             }
             $options['i18n'] = implode(',', array_unique($languages, SORT_NUMERIC));
         }
     }
 }
 /**
  * @group unit
  */
 public function testHandleRequestSubstitutesPageTitleIfConfigured()
 {
     tx_rnbase_util_TYPO3::getTSFE()->getPageAndRootline();
     $repository = $this->getMockForAbstractClass('tx_mklib_repository_Abstract', array(), '', FALSE, FALSE, FALSE, array('findByUid'));
     $model = tx_rnbase::makeInstance('tx_mklib_model_Page', array('uid' => 987654321));
     $repository->expects($this->once())->method('findByUid')->will($this->returnValue($model));
     $action = $this->getMockForAbstractClass('tx_mklib_action_ShowSingeItem', array(), '', TRUE, TRUE, TRUE, array('getSingleItemRepository', 'getConfId'));
     $action->expects($this->once())->method('getSingleItemRepository')->will($this->returnValue($repository));
     $action->expects($this->any())->method('getConfId')->will($this->returnValue('myAction.'));
     $parameters = tx_rnbase::makeInstance('tx_rnbase_parameters', array('uid' => 987654321));
     $configurations = $this->createConfigurations(array('myAction.' => array('substitutePageTitle' => TRUE)), 'mklib', 'mklib', $parameters);
     $viewData = $configurations->getViewData();
     $action->setConfigurations($configurations);
     $this->callInaccessibleMethod($action, 'handleRequest', $parameters, $configurations, $viewData);
     $this->assertEquals($this->defaultSubstitutedPageTitle, tx_rnbase_util_TYPO3::getTSFE()->page['title'], 'tx_rnbase_util_TYPO3::getTSFE()->page[\'title\'] falsch ersetzt');
     $this->assertEquals($this->defaultSubstitutedPageTitle, tx_rnbase_util_TYPO3::getTSFE()->indexedDocTitle, 'tx_rnbase_util_TYPO3::getTSFE()->indexedDocTitle falsch ersetzt');
 }
 /**
  * Find a configured cache handler.
  *
  * @param tx_rnbase_configurations $configurations
  * @param string $confId
  * @return tx_rnbase_action_ICacheHandler
  */
 protected function getCacheHandler($configurations, $confId)
 {
     // no caching if disabled!
     if (tx_rnbase_util_TYPO3::getTSFE()->no_cache) {
         return NULL;
     }
     $class = $configurations->get($confId . 'class');
     if (!$class) {
         return FALSE;
     }
     /* @var $handler tx_rnbase_action_ICacheHandler */
     $handler = tx_rnbase::makeInstance($class);
     if (!$handler instanceof tx_rnbase_action_ICacheHandler) {
         throw new Exception('"' . $class . '" has to implement "tx_rnbase_action_ICacheHandler".');
     }
     $handler->init($this, $confId);
     return $handler;
 }
Beispiel #4
0
 /**
  * Autotranslate a record to fe language
  * @param array $row
  * @param string $tableName
  * @param array $options
  */
 private function lookupLanguage(&$row, $tableName, $options)
 {
     // ACHTUNG: Bei Aufruf im BE führt das zu einem Fehler in TCE-Formularen. Die
     // Initialisierung der TSFE ändert den backPath im PageRender auf einen falschen
     // Wert. Dadurch werden JS-Dateien nicht mehr geladen.
     // Ist dieser Aufruf im BE überhaupt sinnvoll?
     if (!(defined('TYPO3_MODE') && TYPO3_MODE === 'FE')) {
         return;
     }
     // Then get localization of record:
     // (if the content language is not the default language)
     $tsfe = tx_rnbase_util_TYPO3::getTSFE();
     $sysPage = tx_rnbase_util_TYPO3::getSysPage();
     if (!is_object($tsfe) || !$tsfe->sys_language_content || $options['enablefieldsoff'] || $options['ignorei18n']) {
         return;
     }
     $OLmode = isset($options['i18nolmode']) ? $options['i18nolmode'] : '';
     $row = $sysPage->getRecordOverlay($tableName, $row, $tsfe->sys_language_content, $OLmode);
 }
 /**
  * Same method as tslib_pibase::pi_getPidList()
  * @return string commaseparated list of pids
  */
 public static function getPidList($pid_list, $recursive = 0)
 {
     tx_rnbase::load('tx_rnbase_util_Math');
     tx_rnbase::load('tx_rnbase_util_Typo3Classes');
     if (!strcmp($pid_list, '')) {
         $pid_list = tx_rnbase_util_TYPO3::getTSFE()->id;
     }
     $recursive = tx_rnbase_util_Math::intInRange($recursive, 0);
     $pid_list_arr = array_unique(tx_rnbase_util_Strings::trimExplode(',', $pid_list, 1));
     $pid_list = array();
     foreach ($pid_list_arr as $val) {
         $val = tx_rnbase_util_Math::intInRange($val, 0);
         if ($val) {
             /* @var $cObj \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */
             $cObj = tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getContentObjectRendererClass());
             $_list = $cObj->getTreeList(-1 * $val, $recursive);
             if ($_list) {
                 $pid_list[] = $_list;
             }
         }
     }
     return implode(',', $pid_list);
 }
 /**
  * Returns the localized label of the LOCAL_LANG key.
  * This is a reimplementation from tslib_pibase::pi_getLL().
  *
  * @param string $key
  * @param string $alt
  * @param string $hsc
  *
  * @return string
  */
 private function getLL40($key, $alt = '', $hsc = FALSE)
 {
     if (!strcmp(substr($key, 0, 4), 'LLL:')) {
         return self::sL($key);
     }
     if (isset($this->LOCAL_LANG[$this->getLLKey()][$key])) {
         $tsfe = tx_rnbase_util_TYPO3::getTSFE();
         // The "from" charset is normally empty and thus it will convert from the charset of the system language, but if it is set (see ->pi_loadLL()) it will be used.
         $word = $tsfe->csConv($this->LOCAL_LANG[$this->getLLKey()][$key], $this->LOCAL_LANG_charset[$this->getLLKey()][$key]);
     } elseif ($this->getLLKey(TRUE) && isset($this->LOCAL_LANG[$this->getLLKey(TRUE)][$key])) {
         $tsfe = tx_rnbase_util_TYPO3::getTSFE();
         // The "from" charset is normally empty and thus it will convert from the charset of the system language, but if it is set (see ->pi_loadLL()) it will be used.
         $word = $GLOBALS['TSFE']->csConv($this->LOCAL_LANG[$this->getLLKey(TRUE)][$key], $this->LOCAL_LANG_charset[$this->getLLKey(TRUE)][$key]);
     } elseif (isset($this->LOCAL_LANG['default'][$key])) {
         // No charset conversion because default is english and thereby ASCII
         $word = $this->LOCAL_LANG['default'][$key];
     } else {
         // Im BE die LANG fragen...
         $word = is_object($GLOBALS['LANG']) ? $GLOBALS['LANG']->getLL($key) : '';
         if (!$word) {
             $word = $this->LLtestPrefixAlt . $alt;
         }
     }
     $output = $this->LLtestPrefix . $word;
     if ($hsc) {
         $output = htmlspecialchars($output);
     }
     return $output;
 }
 /**
  * @return TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
  */
 protected function getTsfe()
 {
     return tx_rnbase_util_TYPO3::getTSFE();
 }
 /**
  * @return void
  */
 protected function substitutePageTitle()
 {
     if ($this->getConfigurations()->get($this->getConfId() . 'substitutePageTitle')) {
         $pageTitle = $this->getPageTitle();
         tx_rnbase_util_TYPO3::getTSFE()->page['title'] = $pageTitle;
         tx_rnbase_util_TYPO3::getTSFE()->indexedDocTitle = $pageTitle;
     }
 }
 /**
  * check the template for includes
  *
  * Examples: (the @ seperates the file from the subpart)
  *     <!--
  *         Subtemplate fuer dam einbinden
  *         ###INCLUDE_TEMPLATE typo3conf/ext/rn_base/res/simplegallery.html@DAM_IMAGES###
  *         und eingebunden
  *     -->
  *     or
  *     <!-- ### INCLUDE_TEMPLATE EXT:rn_base/res/simplegallery.html@DAM_IMAGES ### -->
  *
  * @param string $template
  * @return string
  */
 public static function includeSubTemplates($template)
 {
     // nothing to do, if we dont have a template
     if (empty($template)) {
         return $template;
     }
     $cache = $included = FALSE;
     tx_rnbase::load('tx_rnbase_util_TYPO3');
     if (!tx_rnbase_util_TYPO3::getTSFE()->no_cache) {
         tx_rnbase::load('tx_rnbase_cache_Manager');
         $cache = tx_rnbase_cache_Manager::getCache('rnbase');
         $cacheKey = 'includeSubTemplateFor_' . md5($template);
         $included = $cache->get($cacheKey);
     }
     // search and replace the subparts
     if (empty($included)) {
         $included = preg_replace_callback('!\\<\\!--[a-zA-Z0-9_ \\s]*###[ ]*INCLUDE_TEMPLATE([^###]*)\\###[a-zA-Z0-9_ \\s]*-->!is', array(self, 'cbIncludeSubTemplates'), $template);
         // store the template in the cache
         if ($cache) {
             $cache->set($cacheKey, $included);
         }
     }
     return $included;
 }
 /**
  * @return array
  */
 protected function getCacheKeyParts()
 {
     $keys = array();
     // TSFE hash, contains page id, domain, etc.
     $keys[] = tx_rnbase_util_TYPO3::getTSFE()->getHash();
     // the plugin ID (tt_content:uid or random md3, whenn rendered as USER in TS)
     $keys[] = $this->getConfigurations()->getPluginId();
     // the conf id of the current action (without trailing dot)
     $keys[] = trim($this->getConfId(), '.');
     // aditionaly a optional key set by ts
     $keys[] = $this->getSalt();
     // include params to the cache key usage = qualifier|uid,tt_news|tt_news
     $params = $this->getIcludeParams();
     if (!empty($params)) {
         // all get and post vars
         tx_rnbase::load('tx_rnbase_util_Arrays');
         $gp = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule(tx_rnbase_parameters::getGetParameters(), tx_rnbase_parameters::getPostParameters());
         // the cobj to get the parameter value
         $cObj = $this->getConfigurations()->getCObj();
         foreach ($params as $param) {
             $keys[] = 'P-' . $param . '-' . $cObj->getGlobal($param, $gp);
         }
     }
     return $keys;
 }