protected function _getLangNavigation() { global $REX; // ul id if ($this->langUlId == '') { $ulIdAttribute = ''; } else { $ulIdAttribute = ' id="' . $this->langUlId . '"'; } $out = '<ul' . $ulIdAttribute . '>'; foreach ($REX['CLANG'] as $clangId => $clangName) { $article = OOArticle::getArticleById($REX['ARTICLE_ID'], $clangId); // new article id if (OOArticle::isValid($article) && $article->isOnline()) { $newArticleId = $article->getId(); $articleStatus = true; } else { $newArticleId = $REX['START_ARTICLE_ID']; $articleStatus = false; } if (!$articleStatus && $this->langHideLiIfOfflineArticle) { // do nothing } else { if (class_exists('seo42')) { $langCode = seo42::getLangCode($clangId); $originalName = seo42::getOriginalLangName($clangId); $langSlug = seo42::getLangSlug($clangId); } else { $langCode = $clangName; $originalName = $clangName; $langSlug = $clangName; } // link text if ($this->langUseLangCodeAsLinkText) { $linkText = $langCode; } else { $linkText = $originalName; } if ($this->langUpperCaseLinkText) { $linkText = strtoupper($linkText); } // li attribute if ($this->langShowLiIds) { $liIdAttribute = ' id="' . $langSlug . '"'; } else { $liIdAttribute = ''; } // class attribute if ($REX['CUR_CLANG'] == $clangId) { $liClassAttribute = ' class="' . $this->langSelectedClass . '"'; } else { $liClassAttribute = ''; } // li out $out .= '<li' . $liIdAttribute . $liClassAttribute . '><a href="' . rex_getUrl($newArticleId, $clangId) . '">' . $linkText . '</a></li>'; } } $out .= '</ul>'; return $out; }
/** * RESOLVE() * * resolve url to ARTICLE_ID & CLANG, * resolve rewritten params back to GET/REQUEST */ function resolve() { global $REX, $SEO42_URLS, $SEO42_IDS; if (!file_exists(SEO42_PATHLIST)) { seo42_generate_pathlist(array()); } require_once SEO42_PATHLIST; if (!$REX['REDAXO']) { $article_id = -1; $clang = $REX['CUR_CLANG']; $start_id = $REX['START_ARTICLE_ID']; $notfound_id = $REX['NOTFOUND_ARTICLE_ID']; $install_subdir = seo42::getServerSubDir(); // 42 $homelang = $REX['ADDON']['seo42']['settings']['homelang']; // TRY IMMEDIATE MATCH OF REQUEST_URI AGAINST PATHLIST.. if (self::resolve_from_pathlist(ltrim($_SERVER['REQUEST_URI'], '/'))) { return; } // allow_article_id ? if ($REX['ADDON']['seo42']['settings']['allow_article_id'] && rex_get('article_id', 'int') > 0) { return self::setArticleId(rex_request('article_id', 'int'), rex_request('clang', 'int', $clang)); } // IF NON_REWRITTEN URLS ALLOWED -> USE ARTICLE_ID FROM REQUEST if ($REX['ADDON']['seo42']['settings']['auto_redirects'] != SEO42_AUTO_REDIRECT_NONE && rex_get('article_id', 'int') > 0) { if ($REX['ADDON']['seo42']['settings']['auto_redirects'] == SEO42_AUTO_REDIRECT_ARTICLE_ID) { $artId = rex_request('article_id', 'int'); $clangId = rex_request('clang', 'int', $clang); $article = OOArticle::getArticleById($artId, $clangId); if (OOArticle::isValid($article)) { $redirect = array('id' => $artId, 'clang' => $clangId, 'status' => 301); return self::redirect($redirect); /*todo: include params*/ } } } // GET PATH RELATIVE TO INTALL_SUBDIR ---------------> 42 $path = ltrim($_SERVER['REQUEST_URI'], '/'); if (seo42::isSubDirInstall()) { $path = substr($path, strlen($install_subdir)); $path = ltrim($path, '/'); } // TRIM STANDARD PARAMS if (($pos = strpos($path, '?')) !== false) { $path = substr($path, 0, $pos); } // TRIM ANCHORS if (($pos = strpos($path, '#')) !== false) { $path = substr($path, 0, $pos); } // RETRY RESOLVE VIA PATHLIST if (self::resolve_from_pathlist($path)) { return; } // smart redirects option if ($REX['ADDON']['seo42']['settings']['smart_redirects']) { $trimmedReuqestUri = trim($_SERVER['REQUEST_URI'], '/'); $trimmedReuqestUri = str_replace('.html', '', $trimmedReuqestUri); $requestUriWithCorrectUrlEnding = $trimmedReuqestUri . $REX['ADDON']['seo42']['settings']['url_ending']; if (isset($SEO42_URLS[$requestUriWithCorrectUrlEnding])) { $redirect = array('id' => $SEO42_URLS[$requestUriWithCorrectUrlEnding]['id'], 'clang' => $SEO42_URLS[$requestUriWithCorrectUrlEnding]['clang'], 'status' => 301); return self::redirect($redirect); } } // auto redirects if ($REX['ADDON']['seo42']['settings']['auto_redirects'] == SEO42_AUTO_REDIRECT_URL_REWRITE || $REX['ADDON']['seo42']['settings']['auto_redirects'] == SEO42_AUTO_REDIRECT_URL_REWRITE_R3) { // smart redirects for old fashioned standard redaxo rewrite methods if ($REX['ADDON']['seo42']['settings']['auto_redirects'] == SEO42_AUTO_REDIRECT_URL_REWRITE_R3) { preg_match('/\\/(.*(\\.))?((?P<clang>[0-9]+)(.*)\\-(?P<id>[0-9]+))((\\-|\\.).*)/', $_SERVER['REQUEST_URI'], $url_params); } else { preg_match('/\\/(.*(\\.))?((?P<id>[0-9]+)\\-(?P<clang>[0-9]+))((\\-|\\.).*)/', $_SERVER['REQUEST_URI'], $url_params); } if ($url_params !== false && isset($url_params['id']) && isset($url_params['clang'])) { $article = OOArticle::getArticleById($url_params['id'], $url_params['clang']); if (OOArticle::isValid($article)) { $redirect = array('id' => $url_params['id'], 'clang' => $url_params['clang'], 'status' => 301); return self::redirect($redirect); } } } // check for possible lang slug to load up correct language for 404 article $firstSlashPos = strpos($path, '/'); if ($firstSlashPos !== false) { $possibleLangSlug = substr($path, 0, $firstSlashPos); $langSlugs = array(); foreach ($REX['CLANG'] as $clangId => $clangName) { $langSlugs[$clangId] = seo42::getLangSlug($clangId); } $clangId = array_search($possibleLangSlug, $langSlugs); if ($clangId !== false) { $clang = $clangId; $REX['CUR_CLANG'] = $clang; } } // GET ID FROM EXTENSION POINT $ep = rex_register_extension_point('SEO42_ARTICLE_ID_NOT_FOUND', ''); if (isset($ep['article_id']) && $ep['article_id'] > 0) { if (isset($ep['clang']) && $ep['clang'] > -1) { $clang = $ep['clang']; } return self::setArticleId($ep['article_id'], $clang); } // STILL NO MATCH -> 404 seo42::set404ResponseFlag(); self::setArticleId($notfound_id, $clang); } }