/**
  * Returns the maps template from $confId.'template'
  *
  * @param tx_rnbase_configurations $configurations
  * @param string $confId
  * @return string empty string if template was not found
  */
 public static function getMapTemplate($configurations, $confId)
 {
     $file = $configurations->get($confId . 'template');
     if (!$file) {
         return '';
     }
     $subpartName = $configurations->get($confId . 'subpart');
     if (!$subpartName) {
         return '';
     }
     $ret = '';
     try {
         $subpart = tx_rnbase_util_Templates::getSubpartFromFile($file, $subpartName);
         $ret = str_replace(array("\r\n", "\n", "\r"), '', $subpart);
     } catch (Exception $e) {
         $ret = '';
     }
     return $ret;
 }
 /**
  *
  * @param tx_rnbase_IParameters $parameters
  * @param tx_rnbase_configurations $configurations
  * @param ArrayObject $viewData
  * @return string error msg or null
  */
 public function handleRequest(&$parameters, &$configurations, &$viewData)
 {
     // confIdExtended setzen
     $this->confIdExtended = $configurations->get($this->getConfId() . 'extendedConfId');
     $this->confIdExtended = $this->confIdExtended ? $this->confIdExtended : 'default';
     $confId = $this->getExtendedConfId();
     // Filter erstellen.
     /* @var $filter tx_rnbase_filter_BaseFilter */
     $filter = tx_rnbase_filter_BaseFilter::createFilter($parameters, $configurations, $viewData, $confId . 'filter.');
     $fields = $options = array();
     // Searcher instanzieren. Konfiguriert wird er über die options['searchdef']
     /* @var $searcher tx_rnbase_util_SearchGeneric */
     tx_rnbase::load('tx_rnbase_util_SearchBase');
     $searcher = tx_rnbase_util_SearchBase::getInstance('tx_rnbase_util_SearchGeneric');
     // Dem Filter den Searcher übergeben, fall er diese Möglichkeit bietet.
     if (method_exists($filter, 'setSearcher')) {
         $filter->setSearcher($searcher);
     }
     // Suche initialisieren und nur ausführen wenn der Filter es erlaubt.
     if ($doSearch = $filter->init($fields, $options)) {
         // Soll ein PageBrowser verwendet werden?
         if ($configurations->get($confId . 'pagebrowser')) {
             $pbOptions = array('searchcallback' => array($searcher, 'search'));
             $cbOptions['pbid'] = ($var = $configurations->get($confId . 'pagebrowser.cbid')) ? $var : 'pb' . $this->confIdExtended;
             $filter->handlePageBrowser($configurations, $confId . 'pagebrowser', $viewData, $fields, $options, $pbOptions);
         }
         // Soll ein CharBrowser verwendet werden?
         if ($configurations->get($confId . 'charbrowser')) {
             // optionen sammeln
             $cbOptions = array('searchcallback' => array($searcher, 'search'));
             $cbOptions['colname'] = ($var = $configurations->get($confId . 'charbrowser.colname')) ? $var : 'title';
             $cbOptions['specials'] = ($var = $configurations->get($confId . 'charbrowser.specials')) ? $var : 'last';
             $cbOptions['cbid'] = ($var = $configurations->get($confId . 'charbrowser.cbid')) ? $var : 'cb' . $this->confIdExtended;
             $filter->handleCharBrowser($configurations, $confId . 'charbrowser', $viewData, $fields, $options, $cbOptions);
         }
         // items besorgen.
         $items = $searcher->search($fields, $options);
     } else {
         $items = array();
     }
     $viewData->offsetSet('items', $items);
     $viewData->offsetSet('searched', $doSearch);
     return null;
 }
 public function init(tx_rnbase_configurations $conf, $confId)
 {
     $this->conf = $conf;
     $this->confId = $confId;
     $apiKey = $conf->get($confId . 'google.apikey');
     $apiKey = $apiKey ? $apiKey : NULL;
     $width = $conf->get($confId . 'width');
     $height = $conf->get($confId . 'height');
     $this->map = tx_rnbase::makeInstance('tx_wecmap_map_google', $apiKey, $width, $height);
     // Der MapType
     $mapType = $conf->get($confId . 'maptype') ? constant($conf->get($confId . 'maptype')) : NULL;
     $types = array_flip(tx_rnbase_maps_TypeRegistry::getMapTypes());
     if ($mapType && array_key_exists($mapType, $types)) {
         $this->setMapType(tx_rnbase_maps_TypeRegistry::getInstance()->getType($this, $mapType));
     }
     // Controls
     $controls = $conf->get($confId . 'google.controls');
     if ($controls) {
         $controls = tx_rnbase_util_Strings::trimExplode(',', $controls);
         foreach ($controls as $control) {
             $this->addControl(tx_rnbase::makeInstance('tx_rnbase_maps_google_Control', $control));
         }
     }
 }
 /**
  * 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;
 }
 /**
  * Gets an ordered list of language label suffixes that should be tried to
  * get localizations in the preferred order of formality.
  *
  * Method copied from Tx_Oelib_SalutationSwitcher of Oliver Klee
  *
  * @param tx_rnbase_configurations $configurations
  * @return array ordered list of suffixes from "", "_formal" and "_informal", will not be empty
  */
 private static function getSuffixesToTry($configurations)
 {
     $suffixesToTry = array();
     $salutation = $configurations->get('salutation');
     if ($salutation && $salutation == 'informal') {
         $suffixesToTry[] = '_informal';
     }
     $suffixesToTry[] = '_formal';
     $suffixesToTry[] = '';
     return $suffixesToTry;
 }
 /**
  * This method is taken from TYPO3\CMS\Frontend\ContentObject\FileContentObject.
  * It is a good tradition in TYPO3 that code can not be re-used. TYPO3 6.x makes
  * no difference...
  *
  * @param tx_rnbase_configurations $conf
  * @param $cObj
  * @param string $confId
  * @return array
  */
 public static function fetchFilesByTS($conf, $cObj, $confId = '')
 {
     /* @var $fileRepository \TYPO3\CMS\Core\Resource\FileRepository */
     $fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
     $fileObjects = array();
     $pics = array();
     tx_rnbase::load('tx_rnbase_util_Strings');
     // Getting the files
     // Try DAM style
     if ($conf->get($confId . 'refTable')) {
         $referencesForeignTable = $conf->getCObj()->stdWrap($conf->get($confId . 'refTable'), $conf->get($confId . 'refTable.'));
         $referencesFieldName = $conf->getCObj()->stdWrap($conf->get($confId . 'refField'), $conf->get($confId . 'refField.'));
         $referencesForeignUid = $conf->getCObj()->stdWrap($conf->get($confId . 'refUid'), $conf->get($confId . 'refUid.'));
         if (!$referencesForeignUid) {
             $referencesForeignUid = isset($cObj->data['_LOCALIZED_UID']) ? $cObj->data['_LOCALIZED_UID'] : $cObj->data['uid'];
         }
         $pics = $fileRepository->findByRelation($referencesForeignTable, $referencesFieldName, $referencesForeignUid);
     } elseif (is_array($conf->get($confId . 'references.'))) {
         $refConfId = $confId . 'references.';
         /*
         			The TypoScript could look like this:# all items related to the page.media field:
         			references {
         			table = pages
         			uid.data = page:uid
         			fieldName = media
         			}# or: sys_file_references with uid 27:
         			references = 27
         */
         // It's important that this always stays "fieldName" and not be renamed to "field" as it would otherwise collide with the stdWrap key of that name
         $referencesFieldName = $conf->getCObj()->stdWrap($conf->get($refConfId . 'fieldName'), $conf->get($refConfId . 'fieldName.'));
         if ($referencesFieldName) {
             $table = $cObj->getCurrentTable();
             if ($table === 'pages' && isset($cObj->data['_LOCALIZED_UID']) && intval($cObj->data['sys_language_uid']) > 0) {
                 $table = 'pages_language_overlay';
             }
             $referencesForeignTable = $conf->getCObj()->stdWrap($conf->get($refConfId . 'table'), $conf->get($refConfId . 'table.'));
             $referencesForeignTable = $referencesForeignTable ? $referencesForeignTable : $table;
             $referencesForeignUid = $conf->getCObj()->stdWrap($conf->get($refConfId . 'uid'), $conf->get($refConfId . 'uid.'));
             $referencesForeignUid = $referencesForeignUid ? $referencesForeignUid : (isset($cObj->data['_LOCALIZED_UID']) ? $cObj->data['_LOCALIZED_UID'] : $cObj->data['uid']);
             // Vermutlich kann hier auch nur ein Objekt geliefert werden...
             $pics = array();
             $referencesForeignUid = tx_rnbase_util_Strings::intExplode(',', $referencesForeignUid);
             foreach ($referencesForeignUid as $refForUid) {
                 if (!$conf->get($refConfId . 'treatIdAsReference')) {
                     $pics[] = $fileRepository->findFileReferenceByUid($refForUid);
                 } else {
                     $pics[] = $fileRepository->findByRelation($referencesForeignTable, $referencesFieldName, $refForUid);
                 }
             }
         } elseif ($refUids = $conf->getCObj()->stdWrap($conf->get($refConfId . 'uid'), $conf->get($refConfId . 'uid.'))) {
             if (!empty($refUids)) {
                 $refUids = tx_rnbase_util_Strings::intExplode(',', $refUids);
                 foreach ($refUids as $refUid) {
                     $pics[] = $fileRepository->findFileReferenceByUid($refUid);
                 }
             }
         }
     }
     // TODO: Hook
     tx_rnbase_util_Misc::callHook('rn_base', 'util_TSFal_fetchFilesByTS_appendMedia_hook', array('conf' => $conf, '$confId' => $confId, 'media' => &$pics), null);
     // gibt es ein Limit/offset
     $offset = intval($conf->get($confId . 'offset'));
     $limit = intval($conf->get($confId . 'limit'));
     if (!empty($pics) && $limit) {
         $pics = array_slice($pics, $offset, $limit);
     } elseif (!empty($pics) && $offset) {
         $pics = array_slice($pics, $offset);
     }
     // Die Bilder sollten jetzt noch in ein
     $fileObjects = self::convertRef2Media($pics);
     return $fileObjects;
 }
 /**
  * Prüft, ob per Parameter oder Konfiguration der Debug für die Labels aktiv ist.
  *
  * @param tx_rnbase_configurations $configurations
  * @return boolean or string with debug type (plain, html)
  */
 public static function isLabelDebugEnabled(tx_rnbase_configurations $configurations = NULL)
 {
     static $status = array();
     // check global debug params
     if (!isset($status['global'])) {
         $status['global'] = !empty($_GET['labeldebug']) && self::isDebugEnabled() ? $_GET['labeldebug'] : self::isDebugEnabled();
     }
     if ($status['global']) {
         return $status['global'];
     }
     // check plugin debug config
     if ($configurations instanceof tx_rnbase_configurations) {
         $pluginId = $configurations->getPluginId();
         if (!isset($status[$pluginId])) {
             $status[$pluginId] = $configurations->get('labeldebug');
         }
         return empty($status[$pluginId]) ? FALSE : $status[$pluginId];
     }
     // no debug!
     return FALSE;
 }
예제 #8
0
 /**
  * Find a configured cache handler.
  *
  * @param tx_rnbase_configurations $configurations
  * @param string $confId
  * @return tx_rnbase_action_ICacheHandler
  */
 protected function getCacheHandler($configurations, $confId)
 {
     $clazz = $configurations->get($confId . 'class');
     if (!$clazz) {
         return FALSE;
     }
     $handler = tx_rnbase::makeInstance($clazz, $configurations, $confId);
     return $handler;
 }
 /**
  * Get a message string for empty list. This is an language string. The key is
  * taken from ts-config: [item].listinfo.llkeyEmpty
  *
  * @param array_object $viewData
  * @param tx_rnbase_configurations $configurations
  * @return string
  */
 function getEmptyListMessage($confId, &$viewData, &$configurations)
 {
     return $configurations->getLL($configurations->get($confId . 'listinfo.llkeyEmpty'));
 }
 /**
  * Bindet einen Buchstaben-Browser ein
  *
  * @param tx_rnbase_configurations $configurations
  * @param string $confid
  * @param ArrayObject $viewData
  * @param array $fields
  * @param array $options
  * @param array $cfg You have to set 'colname'. The database column used for character browsing.
  */
 public static function handleCharBrowser(&$configurations, $confid, &$viewData, &$fields, &$options, $cfg = array())
 {
     if ($configurations->get($confid)) {
         $colName = $cfg['colname'];
         if (!$colName) {
             throw new Exception('No column name for charbrowser defined');
         }
         $pagerData = self::findPagerData($fields, $options, $cfg);
         $firstChar = $configurations->getParameters()->offsetGet($pagerData['pointername']);
         $firstChar = strlen(trim($firstChar)) > 0 ? substr($firstChar, 0, $firstChar[0] == '0' ? 3 : 1) : $pagerData['default'];
         // Existiert der Point in den aktuellen Daten
         $firstChar = array_key_exists($firstChar, $pagerData['list']) ? $firstChar : $pagerData['default'];
         $viewData->offsetSet('pagerData', $pagerData);
         $viewData->offsetSet('charpointer', $firstChar);
     }
     $filter = $viewData->offsetGet('filter');
     // Der CharBrowser beachten wir nur, wenn keine Suche aktiv ist
     // TODO: Der Filter sollte eine Methode haben, die sagt, ob ein Formular aktiv ist
     if ($firstChar != '' && !$filter->isSpecialSearch()) {
         $specials = tx_rnbase_util_SearchBase::getSpecialChars();
         $firsts = $specials[$firstChar];
         if ($firsts) {
             $firsts = implode('\',\'', $firsts);
         } else {
             $firsts = $firstChar;
         }
         if ($fields[SEARCH_FIELD_CUSTOM]) {
             $fields[SEARCH_FIELD_CUSTOM] .= ' AND ';
         }
         $fields[SEARCH_FIELD_CUSTOM] .= 'LEFT(UCASE(' . $colName . "),1) IN ('{$firsts}') ";
     }
 }
 /**
  *
  * @param tx_rnbase_configurations $configurations
  *
  * @return void
  */
 protected function send503HeaderOnException(tx_rnbase_configurations $configurations)
 {
     //sending a 503 header?
     return intval(tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'send503HeaderOnException')) && (!array_key_exists('send503HeaderOnException', $configurations->getConfigArray()) || $configurations->get('send503HeaderOnException') != 0) || $configurations->get('send503HeaderOnException') == 1;
 }
 /**
  * Vergleichsfelder aus der TS-Config setzen
  *
  * @param array $fields
  * @param tx_rnbase_configurations $configurations
  * @param string $confId Id der TS-Config z.B. myview.fields.
  */
 static function setConfigFields(&$fields, $configurations, $confId)
 {
     $cfgFields = $configurations->get($confId);
     self::setConfigFieldsByArray($fields, $cfgFields);
 }
 /**
  * Init this link by typoscript setup
  *
  * @param tx_rnbase_configurations $configurations
  * @param string $confId
  *
  * @return tx_rnbase_util_Link
  */
 public function initByTS($configurations, $confId, $parameterArr)
 {
     $parameterArr = is_array($parameterArr) ? $parameterArr : array();
     $pid = $configurations->getCObj()->stdWrap($configurations->get($confId . 'pid'), $configurations->get($confId . 'pid.'));
     $qualifier = $configurations->get($confId . 'qualifier');
     if ($qualifier) {
         $this->designator($qualifier);
     }
     $target = $configurations->get($confId . 'target');
     if ($target) {
         $this->target($target);
     }
     // feste URL für externen Link
     if ($fixed = $configurations->get($confId . 'fixedUrl', TRUE)) {
         $this->destination($fixed);
     } else {
         $this->destination($pid ? $pid : $GLOBALS['TSFE']->id);
         // absolute und ggf. schema url erzeugen
         if ($absUrl = $configurations->get($confId . 'absurl')) {
             $this->setAbsUrl(TRUE, $absUrl == 1 || strtolower($absUrl) == 'true' ? '' : $absUrl);
         }
     }
     if (array_key_exists('SECTION', $parameterArr)) {
         $this->anchor(htmlspecialchars($parameterArr['SECTION']));
         unset($parameterArr['SECTION']);
     } else {
         $this->anchor((string) $configurations->get($confId . 'section', TRUE));
     }
     $this->parameters($parameterArr);
     // eigene Parameter für typolink, die einfach weitergegeben werden
     $typolinkCfg = $configurations->get($confId . 'typolink.');
     if (is_array($typolinkCfg)) {
         foreach ($typolinkCfg as $cfgName => $cfgValue) {
             $this->addTypolinkParam($cfgName, $cfgValue);
         }
     }
     // Zusätzliche Parameter für den Link
     $atagParams = $configurations->get($confId . 'atagparams.', TRUE);
     if (is_array($atagParams)) {
         // Die Parameter werden jetzt nochmal per TS validiert und können somit dynamisch gesetzt werden
         $attributes = array();
         foreach ($atagParams as $aParam => $lvalue) {
             if (substr($aParam, strlen($aParam) - 1, 1) == '.') {
                 $aParam = substr($aParam, 0, strlen($aParam) - 1);
                 if (array_key_exists($aParam, $atagParams)) {
                     continue;
                 }
             }
             $attributes[$aParam] = $configurations->getCObj()->stdWrap($atagParams[$aParam], $atagParams[$aParam . '.']);
         }
         $this->attributes($attributes);
     }
     // KeepVars prüfen
     // Per Default sind die KeepVars nicht aktiviert. Mit useKeepVars == 1 können sie hinzugefügt werden
     if (!$configurations->get($confId . 'useKeepVars')) {
         $this->overruled();
     } elseif ($keepVarConf = $configurations->get($confId . 'useKeepVars.')) {
         // Sonderoptionen für KeepVars gesetzt
         $newKeepVars = array();
         // skip empty values? default false!
         $skipEmpty = !empty($keepVarConf['skipEmpty']);
         $keepVars = $configurations->getKeepVars();
         $allow = $keepVarConf['allow'];
         $deny = $keepVarConf['deny'];
         if ($allow) {
             $allow = tx_rnbase_util_Strings::trimExplode(',', $allow);
             foreach ($allow as $allowed) {
                 $value = $keepVars->offsetGet($allowed);
                 if ($skipEmpty && empty($value)) {
                     continue;
                 }
                 $newKeepVars[$allowed] = $keepVars->offsetGet($allowed);
             }
         } elseif ($deny) {
             $deny = array_flip(tx_rnbase_util_Strings::trimExplode(',', $deny));
             $keepVarsArr = $keepVars->getArrayCopy();
             foreach ($keepVarsArr as $key => $value) {
                 if ($skipEmpty && empty($value)) {
                     continue;
                 }
                 if (!array_key_exists($key, $deny)) {
                     $newKeepVars[$key] = $value;
                 }
             }
         }
         $add = $keepVarConf['add'];
         if ($add) {
             $add = tx_rnbase_util_Strings::trimExplode(',', $add);
             foreach ($add as $linkvar) {
                 $linkvar = tx_rnbase_util_Strings::trimExplode('=', $linkvar);
                 if (count($linkvar) < 2) {
                     // tt_news::* or ttnews::id
                     list($qualifier, $name) = tx_rnbase_util_Strings::trimExplode('::', $linkvar[0]);
                     if ($value = tx_rnbase_parameters::getPostOrGetParameter($qualifier)) {
                         if ($name == '*' && is_array($value)) {
                             foreach ($value as $paramName => $paramValue) {
                                 if ($skipEmpty && empty($paramValue)) {
                                     continue;
                                 }
                                 if (strpos($paramName, 'NK_') === FALSE) {
                                     $newKeepVars[$qualifier . '::' . $paramName] = $paramValue;
                                 }
                             }
                         } else {
                             $newKeepVars[$linkvar[0]] = $value[$name];
                         }
                     }
                 } else {
                     $newKeepVars[$linkvar[0]] = $linkvar[1];
                 }
             }
         }
         $this->overruled($newKeepVars);
     }
     if ($configurations->get($confId . 'noCache')) {
         $this->noCache();
     }
     // Bei der Linkerzeugung wir normalerweise immer ein cHash angelegt. Bei Plugins, die als USER_INT
     // ausgeführt werden, ist dies nicht notwendig und geht auf die Performance. Daher wird hier
     // automatisch der cHash für USER_INT deaktiviert. Per Typocript kann man es aber bei Bedarf manuell
     // wieder aktivieren
     if ($configurations->get($confId . 'noHash') || $configurations->get($confId . 'noHash') !== '0' && $configurations->isPluginUserInt()) {
         $this->noHash();
     }
     return $this;
 }