예제 #1
0
 private function RedirectToCanonicalURL($docId, $langId, $status = 301)
 {
     if (!$this->itsMODx->config['friendly_urls']) {
         return FALSE;
     }
     // Returns true if a redirection has taken place,
     // else false
     // Get the alias path...
     $aliasDecoded = YamsUtils::UrlDecode($_GET['q']);
     // split the path into subdirectories...
     $aliasArray = preg_split('/' . preg_quote('/', '/') . '/' . $this->itsUTF8Modifier, $aliasDecoded);
     // Encode each subdirectory part
     foreach ($aliasArray as $key => $value) {
         $aliasArray[$key] = YamsUtils::UrlEncode($value);
     }
     // Reform the encoded url and preg quote it.
     $aliasEscaped = implode('/', $aliasArray);
     $targetAliasEscaped = $this->GetDocumentAlias($docId, $langId, $this->itsShowSiteStartAlias, TRUE, FALSE, FALSE);
     if ($aliasEscaped != $targetAliasEscaped || !$this->IsMultilingualDocument($docId) && preg_match('/^' . preg_quote($this->GetMODxSubdirectory(FALSE, TRUE, FALSE) . '/' . $aliasDecoded, '/') . '/' . $this->itsUTF8Modifier, $_SERVER['REQUEST_URI']) != 1) {
         $url = $this->ConstructURL($langId, $docId, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE);
         if ($url != '') {
             // error_log( 'url 2: ' . $url );
             header('Location: ' . $url, TRUE, $status);
             exit;
             return TRUE;
         }
     }
     return FALSE;
 }
예제 #2
0
             $docId = NULL;
             $langId = NULL;
         }
     }
     //    // If a valid docId has not been found, it will have been set to null
     //    // which will trigger MODx to generate a page not found event.
     //    $modx->documentMethod = 'id';
     //    if ( ! is_null( $docId ) )
     //    {
     //      $modx->documentIdentifier = $docId;
     //    }
 } else {
     if ($yams->ActiveURLsAreIdentical() && $yams->GetUseMultilingualAliases() && $yams->GetMultilingualAliasesAreUnique()) {
         // Determine the docId and langId from the alias...
         // The currentLangId is set if a valid document is found.
         $aliasDecoded = YamsUtils::UrlDecode($_GET['q']);
         $docId = $yams->GetDocumentIdentifierUnique($aliasDecoded, $langId);
     } else {
         // Determine the langId from the server and root name
         $langId = $yams->DetermineCurrentLangId();
         // Determine the docId from the alias, given the language
         $docId = $yams->GetDocumentIdentifier($_GET['q'], $langId);
     }
 }
 if (is_null($docId)) {
     // If no docId was found...
     // but a standard MODx url matches... then use that.
     // This is for compatibility with standard MODx resources
     if (YamsUtils::IsValidId($modx->documentIdentifier)) {
         $docIdFoundByYAMS = FALSE;
         $docId = $modx->documentIdentifier;