mirror of
https://github.com/typecho/typecho.git
synced 2025-04-14 06:41:53 +02:00
Merge branch 'master' of github.com:typecho/typecho
This commit is contained in:
commit
4ad930a31d
@ -75,11 +75,11 @@ namespace {
|
||||
|
||||
namespace Typecho {
|
||||
spl_autoload_register(function (string $className) {
|
||||
$isAlias = defined('__TYPECHO_CLASS_ALIASES__') && isset(__TYPECHO_CLASS_ALIASES__[$className]);
|
||||
$path = str_replace(
|
||||
['_', '\\'],
|
||||
'/',
|
||||
(defined('__TYPECHO_CLASS_ALIASES__') && isset(__TYPECHO_CLASS_ALIASES__[$className]))
|
||||
? __TYPECHO_CLASS_ALIASES__[$className] : $className
|
||||
$isAlias ? __TYPECHO_CLASS_ALIASES__[$className] : $className
|
||||
) . '.php';
|
||||
|
||||
$defaultFile = __TYPECHO_ROOT_DIR__ . '/var/' . $path;
|
||||
@ -101,7 +101,7 @@ namespace Typecho {
|
||||
$aliasClass = str_replace('\\', '_', ltrim($className, '\\'));
|
||||
class_alias($className, $aliasClass);
|
||||
} elseif (
|
||||
(isset(__TYPECHO_CLASS_ALIASES__[$className]) || strpos($className, '_') !== false)
|
||||
($isAlias || strpos($className, '_') !== false)
|
||||
&& !class_exists($className, false)
|
||||
&& !interface_exists($className, false)
|
||||
&& !trait_exists($className, false)
|
||||
|
@ -91,7 +91,7 @@ trait SQLiteTrait
|
||||
*/
|
||||
public function parseSelect(array $sql): string
|
||||
{
|
||||
$query = $this->filterCountQuery($this->buildQuery($sql));
|
||||
$query = $this->buildQuery($sql);
|
||||
|
||||
if ($this->isSQLite2) {
|
||||
$query = $this->filterCountQuery($query);
|
||||
|
@ -128,12 +128,9 @@ class Request
|
||||
/**
|
||||
* 获取实际传递参数
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $key 指定参数
|
||||
* @param mixed $default 默认参数 (default: NULL)
|
||||
* @param bool|null $exists detect exists
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $key, $default = null, ?bool &$exists = true)
|
||||
@ -176,7 +173,6 @@ class Request
|
||||
* 获取一个数组
|
||||
*
|
||||
* @param $key
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArray($key): array
|
||||
@ -189,10 +185,7 @@ class Request
|
||||
/**
|
||||
* 从参数列表指定的值中获取http传递参数
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param mixed $params 指定的参数
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function from($params): array
|
||||
@ -210,7 +203,6 @@ class Request
|
||||
/**
|
||||
* getRequestRoot
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestRoot(): string
|
||||
@ -232,7 +224,6 @@ class Request
|
||||
/**
|
||||
* 获取当前请求url
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestUrl(): string
|
||||
@ -244,7 +235,6 @@ class Request
|
||||
* 根据当前uri构造指定参数的uri
|
||||
*
|
||||
* @param mixed $parameter 指定的参数
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function makeUriByRequest($parameter = null): string
|
||||
@ -334,7 +324,6 @@ class Request
|
||||
/**
|
||||
* 获取ip地址
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getIp(): string
|
||||
@ -363,7 +352,6 @@ class Request
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $default
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getHeader(string $key, ?string $default = null): ?string
|
||||
@ -375,7 +363,6 @@ class Request
|
||||
/**
|
||||
* 获取客户端
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getAgent(): ?string
|
||||
@ -386,7 +373,6 @@ class Request
|
||||
/**
|
||||
* 获取客户端
|
||||
*
|
||||
* @access public
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReferer(): ?string
|
||||
@ -490,32 +476,11 @@ class Request
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取url前缀
|
||||
* 获取请求资源地址
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
private function getUrlPrefix(): string
|
||||
{
|
||||
if (empty($this->urlPrefix)) {
|
||||
if (defined('__TYPECHO_URL_PREFIX__')) {
|
||||
$this->urlPrefix = __TYPECHO_URL_PREFIX__;
|
||||
} elseif (php_sapi_name() != 'cli') {
|
||||
$this->urlPrefix = ($this->isSecure() ? 'https' : 'http') . '://'
|
||||
. ($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->urlPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求地址
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
private function getRequestUri(): ?string
|
||||
public function getRequestUri(): ?string
|
||||
{
|
||||
if (!empty($this->requestUri)) {
|
||||
return $this->requestUri;
|
||||
@ -557,10 +522,28 @@ class Request
|
||||
return $this->requestUri = $requestUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取url前缀
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getUrlPrefix(): string
|
||||
{
|
||||
if (empty($this->urlPrefix)) {
|
||||
if (defined('__TYPECHO_URL_PREFIX__')) {
|
||||
$this->urlPrefix = __TYPECHO_URL_PREFIX__;
|
||||
} elseif (php_sapi_name() != 'cli') {
|
||||
$this->urlPrefix = ($this->isSecure() ? 'https' : 'http') . '://'
|
||||
. ($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->urlPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* getBaseUrl
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
private function getBaseUrl(): ?string
|
||||
|
@ -168,6 +168,16 @@ class Request
|
||||
return $this->request->getRequestUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求资源地址
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestUri(): string
|
||||
{
|
||||
return $this->request->getRequestUri();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前pathinfo
|
||||
*
|
||||
|
@ -186,8 +186,8 @@ class Backup extends BaseOptions implements ActionInterface
|
||||
{
|
||||
$path = null;
|
||||
|
||||
if (!empty($FILES)) {
|
||||
$file = array_pop($FILES);
|
||||
if (!empty($_FILES)) {
|
||||
$file = array_pop($_FILES);
|
||||
|
||||
if (0 == $file['error'] && is_uploaded_file($file['tmp_name'])) {
|
||||
$path = $file['tmp_name'];
|
||||
|
@ -66,7 +66,7 @@ class Rows extends Metas
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $children = [];
|
||||
private $childNodes = [];
|
||||
|
||||
/**
|
||||
* 所有父节点列表
|
||||
@ -116,11 +116,11 @@ class Rows extends Metas
|
||||
private function levelWalkCallback(array $categories, array $parents = [])
|
||||
{
|
||||
foreach ($parents as $parent) {
|
||||
if (!isset($this->children[$parent])) {
|
||||
$this->children[$parent] = [];
|
||||
if (!isset($this->childNodes[$parent])) {
|
||||
$this->childNodes[$parent] = [];
|
||||
}
|
||||
|
||||
$this->children[$parent] = array_merge($this->children[$parent], $categories);
|
||||
$this->childNodes[$parent] = array_merge($this->childNodes[$parent], $categories);
|
||||
}
|
||||
|
||||
foreach ($categories as $mid) {
|
||||
@ -223,7 +223,7 @@ class Rows extends Metas
|
||||
if ($this->mid == $this->parameter->current) {
|
||||
echo ' category-active';
|
||||
} elseif (
|
||||
isset($this->children[$this->mid]) && in_array($this->parameter->current, $this->children[$this->mid])
|
||||
isset($this->childNodes[$this->mid]) && in_array($this->parameter->current, $this->childNodes[$this->mid])
|
||||
) {
|
||||
echo ' category-parent-active';
|
||||
}
|
||||
@ -269,7 +269,7 @@ class Rows extends Metas
|
||||
if ($children) {
|
||||
//缓存变量便于还原
|
||||
$tmp = $this->row;
|
||||
$this->sequence ++;
|
||||
$this->sequence++;
|
||||
|
||||
//在子评论之前输出
|
||||
echo '<' . $this->categoryOptions->wrapTag . (empty($this->categoryOptions->wrapClass)
|
||||
@ -284,7 +284,7 @@ class Rows extends Metas
|
||||
//在子评论之后输出
|
||||
echo '</' . $this->categoryOptions->wrapTag . '>';
|
||||
|
||||
$this->sequence --;
|
||||
$this->sequence--;
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ class Rows extends Metas
|
||||
*/
|
||||
public function getAllChildren($mid): array
|
||||
{
|
||||
return $this->children[$mid] ?? [];
|
||||
return $this->childNodes[$mid] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user