/**
  * Convert a title to something that can be used in an page path:
  * - Convert spaces to underscores
  * - Convert non A-Z characters to ASCII equivalents
  * - Convert some special things like the 'ae'-character
  * - Strip off all other symbols
  * Works with the character set defined as "forceCharset"
  *
  * WARNING!!! The signature or visibility of this function may change at any moment!
  *
  * @param string $title Input title to clean
  * @return string Encoded title, passed through rawurlencode() = ready to put in the URL.
  * @see rootLineToPath()
  */
 public function encodeTitle($title)
 {
     // Fetch character set
     $charset = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] : $GLOBALS['TSFE']->defaultCharSet;
     // Convert to lowercase
     $processedTitle = $GLOBALS['TSFE']->csConvObj->conv_case($charset, $title, 'toLower');
     // Strip tags
     $processedTitle = strip_tags($processedTitle);
     // Convert some special tokens to the space character
     $space = isset($this->conf['spaceCharacter']) ? $this->conf['spaceCharacter'] : '_';
     $processedTitle = preg_replace('/[ \\-+_]+/', $space, $processedTitle);
     // convert spaces
     // Convert extended letters to ascii equivalents
     $processedTitle = $GLOBALS['TSFE']->csConvObj->specCharsToASCII($charset, $processedTitle);
     // Strip the rest
     if ($this->extConf['init']['enableAllUnicodeLetters']) {
         // Warning: slow!!!
         $processedTitle = preg_replace('/[^\\p{L}0-9' . ($space ? preg_quote($space) : '') . ']/u', '', $processedTitle);
     } else {
         $processedTitle = preg_replace('/[^a-zA-Z0-9' . ($space ? preg_quote($space) : '') . ']/', '', $processedTitle);
     }
     $processedTitle = preg_replace('/\\' . $space . '{2,}/', $space, $processedTitle);
     // Convert multiple 'spaces' to a single one
     $processedTitle = trim($processedTitle, $space);
     if ($this->conf['encodeTitle_userProc']) {
         $encodingConfiguration = array('strtolower' => true, 'spaceCharacter' => $this->conf['spaceCharacter']);
         $params = array('pObj' => &$this, 'title' => $title, 'processedTitle' => $processedTitle, 'encodingConfiguration' => $encodingConfiguration);
         $processedTitle = $this->apiWrapper->callUserFunction($this->conf['encodeTitle_userProc'], $params, $this);
     }
     // Return encoded URL
     return rawurlencode(strtolower($processedTitle));
 }
Esempio n. 2
0
 /**
  * Determines the current host. Sometimes it is not possible to determine
  * that from the environment, so the hook is used to get the host from the
  * third-party scripts.
  *
  * @return string
  */
 protected function getHost()
 {
     $host = strtolower((string) $this->apiWrapper->getIndpEnv('HTTP_HOST'));
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['getHost'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['getHost'] as $userFunc) {
             $hookParams = array('host' => $host);
             $newHost = $this->apiWrapper->callUserFunction($userFunc, $hookParams, $this);
             if (!empty($newHost) && is_string($newHost)) {
                 $host = $newHost;
             }
         }
     }
     return $host;
 }
 /**
  * Creates common configuration template.
  *
  * @return	array		Template
  */
 protected function getTemplate()
 {
     $confTemplate = array('init' => array('enableCHashCache' => true, 'appendMissingSlash' => 'ifNotFile,redirect', 'adminJumpToBackend' => true, 'enableUrlDecodeCache' => true, 'enableUrlEncodeCache' => true, 'emptyUrlReturnValue' => $this->apiWrapper->getIndpEnv('TYPO3_SITE_PATH')), 'pagePath' => array('type' => 'user', 'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main', 'spaceCharacter' => '-', 'languageGetVar' => 'L'), 'fileName' => array('defaultToHTMLsuffixOnPrev' => 0, 'acceptHTMLsuffix' => 1));
     // Add print feature if TemplaVoila is not loaded
     if (!$this->apiWrapper->isExtLoaded('templavoila')) {
         $confTemplate['fileName']['index']['print'] = array('keyValues' => array('type' => 98));
     }
     // Add respectSimulateStaticURLs if SimulateStatic is loaded
     if ($this->apiWrapper->isExtLoaded('simulatestatic')) {
         $confTemplate['init']['respectSimulateStaticURLs'] = true;
     }
     $this->addLanguages($confTemplate);
     // Add from extensions
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration'] as $extKey => $userFunc) {
             $params = array('config' => $confTemplate, 'extKey' => $extKey);
             $var = $this->apiWrapper->callUserFunction($userFunc, $params, $this);
             if ($var) {
                 $confTemplate = $var;
             }
         }
     }
     return $confTemplate;
 }