本文整理汇总了PHP中ConfService::getContextCharset方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfService::getContextCharset方法的具体用法?PHP ConfService::getContextCharset怎么用?PHP ConfService::getContextCharset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfService
的用法示例。
在下文中一共展示了ConfService::getContextCharset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseUrl
protected function parseUrl($url, $forceLogin = false)
{
// URL MAY BE ajxp.ftp://username:password@host/path
$urlParts = AJXP_Utils::safeParseUrl($url);
$this->repositoryId = $urlParts["host"];
$repository = ConfService::getRepositoryById($this->repositoryId);
if ($repository == null) {
throw new Exception("Cannot find repository for dynamic ftp authentification.");
}
$credentials = AJXP_Safe::tryLoadingCredentialsFromSources($urlParts, $repository);
$this->user = $credentials["user"];
$this->password = $credentials["password"];
if ($this->user == "") {
throw new AJXP_Exception("Cannot find user/pass for FTP access!");
}
if ($repository->getOption("DYNAMIC_FTP") == "TRUE" && isset($_SESSION["AJXP_DYNAMIC_FTP_DATA"])) {
$data = $_SESSION["AJXP_DYNAMIC_FTP_DATA"];
$this->host = $data["FTP_HOST"];
$this->path = $data["PATH"];
$this->secure = $data["FTP_SECURE"] == "TRUE" ? true : false;
$this->port = $data["FTP_PORT"] != "" ? intval($data["FTP_PORT"]) : ($this->secure ? 22 : 21);
$this->ftpActive = $data["FTP_DIRECT"] == "TRUE" ? true : false;
$this->repoCharset = $data["CHARSET"];
} else {
$this->host = $repository->getOption("FTP_HOST");
$this->path = $repository->getOption("PATH");
$this->secure = $repository->getOption("FTP_SECURE") == "TRUE" ? true : false;
$this->port = $repository->getOption("FTP_PORT") != "" ? intval($repository->getOption("FTP_PORT")) : ($this->secure ? 22 : 21);
$this->ftpActive = $repository->getOption("FTP_DIRECT") == "TRUE" ? true : false;
$this->repoCharset = $repository->getOption("CHARSET");
}
// Test Connexion and server features
global $_SESSION;
$cacheKey = $repository->getId() . "_ftpCharset";
if (!isset($_SESSION[$cacheKey]) || !strlen($_SESSION[$cacheKey]) || $forceLogin) {
$features = $this->getServerFeatures();
$ctxCharset = ConfService::getContextCharset();
if (empty($ctxCharset)) {
ConfService::setContextCharset($features["charset"]);
$_SESSION[$cacheKey] = $features["charset"];
} else {
$_SESSION[$cacheKey] = $ctxCharset;
}
}
return $urlParts;
}
示例2: getEncoding
/**
* Try to detect the current encoding (cached in session)
* @static
* @return string
*/
public static function getEncoding()
{
if (self::$currentCharsetValue == null) {
$charset = ConfService::getContextCharset();
if (!empty($charset)) {
// Check if the session get an assigned charset encoding (it's the case for remote SSH for example)
self::$currentCharsetValue = $charset;
} else {
// Get the current locale (expecting the filesystem is in the same locale, as the standard says)
self::$currentCharsetValue = self::parseCharset(setlocale(LC_CTYPE, 0));
}
}
return self::$currentCharsetValue;
}