-
-
Save hissy/8fc198d4d196b8d1d584 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('C5_EXECUTE') or die("Access Denied."); | |
class Page extends Concrete5_Model_Page { | |
//URLエンコード対応 | |
function getCollectionPath() { | |
return self::getEncodePath($this->cPath); | |
} | |
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 = ?", array($cID)); | |
$path .= '/'; | |
return self::getEncodePath($path); | |
} | |
//PagePathのエンコード処理 | |
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); | |
} | |
function getEscapePath($path){ | |
return htmlentities($path,ENT_QUOTES, APP_CHARSET); | |
} | |
// ここから追加 | |
function getCollectionAction() { | |
$cID = $this->cID; | |
$valt = Loader::helper('validation/token'); | |
$token = $valt->getParameter(); | |
if( (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' && defined('BASE_URL_SSL')) || | |
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' && defined('BASE_URL_SSL')) ) { | |
$str = BASE_URL_SSL . DIR_REL . "/" . DISPATCHER_FILENAME . "?cID={$cID}&" . $token; | |
} else { | |
$str = BASE_URL . DIR_REL . "/" . DISPATCHER_FILENAME . "?cID={$cID}&" . $token; | |
} | |
return $str; | |
} | |
// ここまで追加 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment