/** * 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; }