Exemplo n.º 1
0
 public static function goForRedirect($params, $ref)
 {
     if (empty($_GET['eID']) && empty($_GET['ADMCMD_prev']) && empty($_GET['ADMCMD_cooluri']) && $GLOBALS['TSFE']->config['config']['tx_cooluri_enable'] == 1 && $GLOBALS['TSFE']->config['config']['redirectOldLinksToNew'] == 1 && \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI') && (substr(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'), 1, 9) == 'index.php' || substr(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'), 1, 1) == '?')) {
         $ourl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI');
         $ss = explode('?', $ourl);
         if ($ss[1]) {
             $ss[1] = strtr($ss[1], array('%5B' => '[', '%5D' => ']'));
             $pars = \Bednarik\Cooluri\Core\Functions::convertQuerystringToArray($ss[1]);
         }
         $pageid = $pars['id'];
         if (is_null($pageid)) {
             // No page id given, so no need to redirect
             return;
         } else {
             if (!ctype_digit($pageid)) {
                 $pageid = $GLOBALS['TYPO3_DB']->fullQuoteStr($pageid, 'pages');
                 $q = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'alias=' . $pageid);
                 $page = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($q);
                 $pars['id'] = (int) $page['uid'];
             } else {
                 $q = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid=' . (int) $pageid);
                 $page = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($q);
                 $pars['id'] = (int) $page['uid'];
             }
         }
         // if a page is hidden, there won't be any redirect, because it would
         // redirect to the root
         if (!$page || $page['hidden'] == 1 || $page['deleted'] == 1) {
             return;
         }
         if ($pars) {
             $lt = self::getTranslateInstance();
             if (!$lt) {
                 return;
             }
             if (self::$confArray['MULTIDOMAIN']) {
                 if (empty(\Bednarik\Cooluri\Core\Translate::$conf->cache->prefix)) {
                     self::simplexml_addChild(\Bednarik\Cooluri\Core\Translate::$conf->cache, 'prefix', self::getDomain((int) $pars['id']) . '@');
                 } else {
                     \Bednarik\Cooluri\Core\Translate::$conf->cache->prefix = self::getDomain((int) $pars['id']) . '@';
                 }
             }
             $url = $lt->params2coolForRedirect($pars);
             $parts = explode('?', $url);
             if (empty($parts[0])) {
                 return;
             }
             if (self::$confArray['MULTIDOMAIN'] || \Bednarik\Cooluri\Core\Translate::$conf->domainlanguages) {
                 $url = explode('@', $url);
                 $url = 'http://' . $url[0] . '/' . $url[1];
             }
             \Bednarik\Cooluri\Core\Functions::redirect($url, 301);
         }
     }
 }