Skip to content

Commit

Permalink
Multibyte PagePath (URL) support
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-s committed Jul 3, 2014
1 parent 6b82fea commit 0d1b592
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion web/concrete/core/Http/Request.php
Expand Up @@ -51,7 +51,8 @@ public static function getInstance() {
* Returns the full path for a request
*/
public function getPath() {
$path = '/' . trim($this->getPathInfo(), '/');
$pathInfo = rawurldecode($this->getPathInfo());
$path = '/' . trim($pathInfo, '/');
return ($path == '/') ? '' : $path;
}

Expand Down
22 changes: 20 additions & 2 deletions web/concrete/core/Page/Page.php
Expand Up @@ -904,7 +904,7 @@ function getCollectionCheckedOutUserID() {
* @return string
*/
function getCollectionPath() {
return $this->cPath;
return self::getEncodePath($this->cPath);
}

/**
Expand All @@ -920,6 +920,24 @@ public function getCollectionPathObject()
return $path;
}

/**
* Returns the urlencode path for a page from path string
* @param string $path
* @return string $path
*/
public static function getEncodePath($path){
if(mb_strpos($path,"/") !== false){
$path = explode("/",$path);
$path = array_map("rawurlencode",$path);
$newPath = implode("/",$path);
}else if(is_null($path)){
$newPath = NULL;
}else{
$newPath = rawurlencode($path);
}
return str_replace('%21','!',$newPath);
}

/**
* Adds a non-canonical page path to the current page.
*/
Expand Down Expand Up @@ -995,7 +1013,7 @@ public function getCollectionLink($appendBaseURL = false, $ignoreUrlRewriting =
public static function getCollectionPathFromID($cID) {
$db = Loader::db();
$path = $db->GetOne("select cPath from PagePaths inner join CollectionVersions on (PagePaths.cID = CollectionVersions.cID and CollectionVersions.cvIsApproved = 1) where PagePaths.cID = ? order by PagePaths.ppIsCanonical desc", array($cID));
return $path;
return self::getEncodePath($path);
}

/**
Expand Down

0 comments on commit 0d1b592

Please sign in to comment.