Refactor method pluginDIr

This commit is contained in:
joyqi 2021-09-02 17:55:41 +08:00
parent 4791cd978e
commit 7068b2bbe1
18 changed files with 226 additions and 209 deletions

View File

@ -1,4 +1,5 @@
<?php
include 'common.php';
$panel = $request->get('panel');
@ -10,4 +11,4 @@ if (!isset($panelTable['file']) || !in_array(urlencode($panel), $panelTable['fil
[$pluginName, $file] = explode('/', trim($panel, '/'), 2);
require_once $options->pluginDir($pluginName) . '/' . $panel;
require_once $options->pluginDir($pluginName) . '/' . $file;

View File

@ -1,16 +1,18 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<div class="col-mb-12 col-tb-8 col-tb-offset-2">
<div class="col-mb-12 col-tb-8 col-tb-offset-2">
<div class="error-page">
<h2 class="post-title">404 - <?php _e('页面没找到'); ?></h2>
<p><?php _e('你想查看的页面已被转移或删除了, 要不要搜索看看: '); ?></p>
<form method="post">
<p><input type="text" name="s" class="text" autofocus /></p>
<p><button type="submit" class="submit"><?php _e('搜索'); ?></button></p>
</form>
</div>
<div class="error-page">
<h2 class="post-title">404 - <?php _e('页面没找到'); ?></h2>
<p><?php _e('你想查看的页面已被转移或删除了, 要不要搜索看看: '); ?></p>
<form method="post">
<p><input type="text" name="s" class="text" autofocus/></p>
<p>
<button type="submit" class="submit"><?php _e('搜索'); ?></button>
</p>
</form>
</div>
</div><!-- end #content-->
<?php $this->need('footer.php'); ?>
</div><!-- end #content-->
<?php $this->need('footer.php'); ?>

View File

@ -1,36 +1,45 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<div class="col-mb-12 col-8" id="main" role="main">
<h3 class="archive-title"><?php $this->archiveTitle(array(
'category' => _t('分类 %s 下的文章'),
'search' => _t('包含关键字 %s 的文章'),
'tag' => _t('标签 %s 下的文章'),
'author' => _t('%s 发布的文章')
), '', ''); ?></h3>
<?php if ($this->have()): ?>
<?php while($this->next()): ?>
<div class="col-mb-12 col-8" id="main" role="main">
<h3 class="archive-title"><?php $this->archiveTitle([
'category' => _t('分类 %s 下的文章'),
'search' => _t('包含关键字 %s 的文章'),
'tag' => _t('标签 %s 下的文章'),
'author' => _t('%s 发布的文章')
], '', ''); ?></h3>
<?php if ($this->have()): ?>
<?php while ($this->next()): ?>
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<h2 class="post-title" itemprop="name headline"><a itemprop="url" href="<?php $this->permalink() ?>"><?php $this->title() ?></a></h2>
<ul class="post-meta">
<li itemprop="author" itemscope itemtype="http://schema.org/Person"><?php _e('作者: '); ?><a itemprop="name" href="<?php $this->author->permalink(); ?>" rel="author"><?php $this->author(); ?></a></li>
<li><?php _e('时间: '); ?><time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php $this->date(); ?></time></li>
<li><?php _e('分类: '); ?><?php $this->category(','); ?></li>
<li itemprop="interactionCount"><a href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 条评论', '%d 条评论'); ?></a></li>
</ul>
<h2 class="post-title" itemprop="name headline"><a itemprop="url"
href="<?php $this->permalink() ?>"><?php $this->title() ?></a>
</h2>
<ul class="post-meta">
<li itemprop="author" itemscope itemtype="http://schema.org/Person"><?php _e('作者: '); ?><a
itemprop="name" href="<?php $this->author->permalink(); ?>"
rel="author"><?php $this->author(); ?></a></li>
<li><?php _e('时间: '); ?>
<time datetime="<?php $this->date('c'); ?>"
itemprop="datePublished"><?php $this->date(); ?></time>
</li>
<li><?php _e('分类: '); ?><?php $this->category(','); ?></li>
<li itemprop="interactionCount"><a
href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 条评论', '%d 条评论'); ?></a>
</li>
</ul>
<div class="post-content" itemprop="articleBody">
<?php $this->content('- 阅读剩余部分 -'); ?>
<?php $this->content('- 阅读剩余部分 -'); ?>
</div>
</article>
<?php endwhile; ?>
<?php else: ?>
<article class="post">
<h2 class="post-title"><?php _e('没有找到内容'); ?></h2>
</article>
<?php endif; ?>
<?php endwhile; ?>
<?php else: ?>
<article class="post">
<h2 class="post-title"><?php _e('没有找到内容'); ?></h2>
</article>
<?php endif; ?>
<?php $this->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>
</div><!-- end #main -->
<?php $this->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>
</div><!-- end #main -->
<?php $this->need('sidebar.php'); ?>
<?php $this->need('footer.php'); ?>
<?php $this->need('sidebar.php'); ?>
<?php $this->need('footer.php'); ?>

View File

@ -2,48 +2,57 @@
<div id="comments">
<?php $this->comments()->to($comments); ?>
<?php if ($comments->have()): ?>
<h3><?php $this->commentsNum(_t('暂无评论'), _t('仅有一条评论'), _t('已有 %d 条评论')); ?></h3>
<?php $comments->listComments(); ?>
<h3><?php $this->commentsNum(_t('暂无评论'), _t('仅有一条评论'), _t('已有 %d 条评论')); ?></h3>
<?php $comments->listComments(); ?>
<?php $comments->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>
<?php $comments->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>
<?php endif; ?>
<?php if($this->allow('comment')): ?>
<div id="<?php $this->respondId(); ?>" class="respond">
<div class="cancel-comment-reply">
<?php $comments->cancelReply(); ?>
<?php if ($this->allow('comment')): ?>
<div id="<?php $this->respondId(); ?>" class="respond">
<div class="cancel-comment-reply">
<?php $comments->cancelReply(); ?>
</div>
<h3 id="response"><?php _e('添加新评论'); ?></h3>
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form">
<?php if ($this->user->hasLogin()): ?>
<p><?php _e('登录身份: '); ?><a
href="<?php $this->options->profileUrl(); ?>"><?php $this->user->screenName(); ?></a>. <a
href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> &raquo;</a>
</p>
<?php else: ?>
<p>
<label for="author" class="required"><?php _e('称呼'); ?></label>
<input type="text" name="author" id="author" class="text"
value="<?php $this->remember('author'); ?>" required/>
</p>
<p>
<label
for="mail"<?php if ($this->options->commentsRequireMail): ?> class="required"<?php endif; ?>><?php _e('Email'); ?></label>
<input type="email" name="mail" id="mail" class="text"
value="<?php $this->remember('mail'); ?>"<?php if ($this->options->commentsRequireMail): ?> required<?php endif; ?> />
</p>
<p>
<label
for="url"<?php if ($this->options->commentsRequireURL): ?> class="required"<?php endif; ?>><?php _e('网站'); ?></label>
<input type="url" name="url" id="url" class="text" placeholder="<?php _e('http://'); ?>"
value="<?php $this->remember('url'); ?>"<?php if ($this->options->commentsRequireURL): ?> required<?php endif; ?> />
</p>
<?php endif; ?>
<p>
<label for="textarea" class="required"><?php _e('内容'); ?></label>
<textarea rows="8" cols="50" name="text" id="textarea" class="textarea"
required><?php $this->remember('text'); ?></textarea>
</p>
<p>
<button type="submit" class="submit"><?php _e('提交评论'); ?></button>
</p>
</form>
</div>
<h3 id="response"><?php _e('添加新评论'); ?></h3>
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form">
<?php if($this->user->hasLogin()): ?>
<p><?php _e('登录身份: '); ?><a href="<?php $this->options->profileUrl(); ?>"><?php $this->user->screenName(); ?></a>. <a href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> &raquo;</a></p>
<?php else: ?>
<p>
<label for="author" class="required"><?php _e('称呼'); ?></label>
<input type="text" name="author" id="author" class="text" value="<?php $this->remember('author'); ?>" required />
</p>
<p>
<label for="mail"<?php if ($this->options->commentsRequireMail): ?> class="required"<?php endif; ?>><?php _e('Email'); ?></label>
<input type="email" name="mail" id="mail" class="text" value="<?php $this->remember('mail'); ?>"<?php if ($this->options->commentsRequireMail): ?> required<?php endif; ?> />
</p>
<p>
<label for="url"<?php if ($this->options->commentsRequireURL): ?> class="required"<?php endif; ?>><?php _e('网站'); ?></label>
<input type="url" name="url" id="url" class="text" placeholder="<?php _e('http://'); ?>" value="<?php $this->remember('url'); ?>"<?php if ($this->options->commentsRequireURL): ?> required<?php endif; ?> />
</p>
<?php endif; ?>
<p>
<label for="textarea" class="required"><?php _e('内容'); ?></label>
<textarea rows="8" cols="50" name="text" id="textarea" class="textarea" required ><?php $this->remember('text'); ?></textarea>
</p>
<p>
<button type="submit" class="submit"><?php _e('提交评论'); ?></button>
</p>
</form>
</div>
<?php else: ?>
<h3><?php _e('评论已关闭'); ?></h3>
<h3><?php _e('评论已关闭'); ?></h3>
<?php endif; ?>
</div>

View File

@ -3,26 +3,20 @@
<html>
<head>
<meta charset="<?php $this->options->charset(); ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><?php $this->archiveTitle(array(
'category' => _t('分类 %s 下的文章'),
'search' => _t('包含关键字 %s 的文章'),
'tag' => _t('标签 %s 下的文章'),
'author' => _t('%s 发布的文章')
), '', ' - '); ?><?php $this->options->title(); ?></title>
<title><?php $this->archiveTitle([
'category' => _t('分类 %s 下的文章'),
'search' => _t('包含关键字 %s 的文章'),
'tag' => _t('标签 %s 下的文章'),
'author' => _t('%s 发布的文章')
], '', ' - '); ?><?php $this->options->title(); ?></title>
<!-- 使用url函数转换相关路径 -->
<link rel="stylesheet" href="<?php $this->options->themeUrl('normalize.css'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('grid.css'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('style.css'); ?>">
<!--[if lt IE 9]>
<script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->
<!-- 通过自有函数输出HTML头部信息 -->
<?php $this->header(); ?>
</head>
@ -32,28 +26,31 @@
<div class="container">
<div class="row">
<div class="site-name col-mb-12 col-9">
<?php if ($this->options->logoUrl): ?>
<a id="logo" href="<?php $this->options->siteUrl(); ?>">
<img src="<?php $this->options->logoUrl() ?>" alt="<?php $this->options->title() ?>" />
</a>
<?php else: ?>
<a id="logo" href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title() ?></a>
<p class="description"><?php $this->options->description() ?></p>
<?php endif; ?>
<?php if ($this->options->logoUrl): ?>
<a id="logo" href="<?php $this->options->siteUrl(); ?>">
<img src="<?php $this->options->logoUrl() ?>" alt="<?php $this->options->title() ?>"/>
</a>
<?php else: ?>
<a id="logo" href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title() ?></a>
<p class="description"><?php $this->options->description() ?></p>
<?php endif; ?>
</div>
<div class="site-search col-3 kit-hidden-tb">
<form id="search" method="post" action="<?php $this->options->siteUrl(); ?>" role="search">
<label for="s" class="sr-only"><?php _e('搜索关键字'); ?></label>
<input type="text" id="s" name="s" class="text" placeholder="<?php _e('输入关键字搜索'); ?>" />
<input type="text" id="s" name="s" class="text" placeholder="<?php _e('输入关键字搜索'); ?>"/>
<button type="submit" class="submit"><?php _e('搜索'); ?></button>
</form>
</div>
<div class="col-mb-12">
<nav id="nav-menu" class="clearfix" role="navigation">
<a<?php if($this->is('index')): ?> class="current"<?php endif; ?> href="<?php $this->options->siteUrl(); ?>"><?php _e('首页'); ?></a>
<a<?php if ($this->is('index')): ?> class="current"<?php endif; ?>
href="<?php $this->options->siteUrl(); ?>"><?php _e('首页'); ?></a>
<?php \Widget\Contents\Page\Rows::alloc()->to($pages); ?>
<?php while($pages->next()): ?>
<a<?php if($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?> href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
<?php while ($pages->next()): ?>
<a<?php if ($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?>
href="<?php $pages->permalink(); ?>"
title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
<?php endwhile; ?>
</nav>
</div>

View File

@ -1,32 +1,42 @@
<?php
/**
* Default theme for Typecho
*
* @package Typecho Replica Theme
*
* @package Typecho Replica Theme
* @author Typecho Team
* @version 1.2
* @link http://typecho.org
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$this->need('header.php');
?>
$this->need('header.php');
?>
<div class="col-mb-12 col-8" id="main" role="main">
<?php while($this->next()): ?>
<?php while ($this->next()): ?>
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<h2 class="post-title" itemprop="name headline"><a itemprop="url" href="<?php $this->permalink() ?>"><?php $this->title() ?></a></h2>
<ul class="post-meta">
<li itemprop="author" itemscope itemtype="http://schema.org/Person"><?php _e('作者: '); ?><a itemprop="name" href="<?php $this->author->permalink(); ?>" rel="author"><?php $this->author(); ?></a></li>
<li><?php _e('时间: '); ?><time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php $this->date(); ?></time></li>
<li><?php _e('分类: '); ?><?php $this->category(','); ?></li>
<li itemprop="interactionCount"><a itemprop="discussionUrl" href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 条评论', '%d 条评论'); ?></a></li>
</ul>
<h2 class="post-title" itemprop="name headline">
<a itemprop="url"
href="<?php $this->permalink() ?>"><?php $this->title() ?></a>
</h2>
<ul class="post-meta">
<li itemprop="author" itemscope itemtype="http://schema.org/Person"><?php _e('作者: '); ?><a
itemprop="name" href="<?php $this->author->permalink(); ?>"
rel="author"><?php $this->author(); ?></a></li>
<li><?php _e('时间: '); ?>
<time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php $this->date(); ?></time>
</li>
<li><?php _e('分类: '); ?><?php $this->category(','); ?></li>
<li itemprop="interactionCount">
<a itemprop="discussionUrl"
href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 条评论', '%d 条评论'); ?></a>
</li>
</ul>
<div class="post-content" itemprop="articleBody">
<?php $this->content('- 阅读剩余部分 -'); ?>
<?php $this->content('- 阅读剩余部分 -'); ?>
</div>
</article>
<?php endwhile; ?>
<?php endwhile; ?>
<?php $this->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>
</div><!-- end #main-->

View File

@ -3,7 +3,10 @@
<div class="col-mb-12 col-8" id="main" role="main">
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<h1 class="post-title" itemprop="name headline"><a itemprop="url" href="<?php $this->permalink() ?>"><?php $this->title() ?></a></h1>
<h1 class="post-title" itemprop="name headline">
<a itemprop="url"
href="<?php $this->permalink() ?>"><?php $this->title() ?></a>
</h1>
<div class="post-content" itemprop="articleBody">
<?php $this->content(); ?>
</div>

View File

@ -3,10 +3,19 @@
<div class="col-mb-12 col-8" id="main" role="main">
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<h1 class="post-title" itemprop="name headline"><a itemprop="url" href="<?php $this->permalink() ?>"><?php $this->title() ?></a></h1>
<h1 class="post-title" itemprop="name headline">
<a itemprop="url"
href="<?php $this->permalink() ?>"><?php $this->title() ?></a>
</h1>
<ul class="post-meta">
<li itemprop="author" itemscope itemtype="http://schema.org/Person"><?php _e('作者: '); ?><a itemprop="name" href="<?php $this->author->permalink(); ?>" rel="author"><?php $this->author(); ?></a></li>
<li><?php _e('时间: '); ?><time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php $this->date(); ?></time></li>
<li itemprop="author" itemscope itemtype="http://schema.org/Person">
<?php _e('作者: '); ?><a itemprop="name"
href="<?php $this->author->permalink(); ?>"
rel="author"><?php $this->author(); ?></a>
</li>
<li><?php _e('时间: '); ?>
<time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php $this->date(); ?></time>
</li>
<li><?php _e('分类: '); ?><?php $this->category(','); ?></li>
</ul>
<div class="post-content" itemprop="articleBody">
@ -18,8 +27,8 @@
<?php $this->need('comments.php'); ?>
<ul class="post-near">
<li>上一篇: <?php $this->thePrev('%s','没有了'); ?></li>
<li>下一篇: <?php $this->theNext('%s','没有了'); ?></li>
<li>上一篇: <?php $this->thePrev('%s', '没有了'); ?></li>
<li>下一篇: <?php $this->theNext('%s', '没有了'); ?></li>
</ul>
</div><!-- end #main-->

View File

@ -1,59 +1,63 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<div class="col-mb-12 col-offset-1 col-3 kit-hidden-tb" id="secondary" role="complementary">
<?php if (!empty($this->options->sidebarBlock) && in_array('ShowRecentPosts', $this->options->sidebarBlock)): ?>
<section class="widget">
<h3 class="widget-title"><?php _e('最新文章'); ?></h3>
<ul class="widget-list">
<?php \Widget\Contents\Post\Recent::alloc()
->parse('<li><a href="{permalink}">{title}</a></li>'); ?>
</ul>
</section>
<section class="widget">
<h3 class="widget-title"><?php _e('最新文章'); ?></h3>
<ul class="widget-list">
<?php \Widget\Contents\Post\Recent::alloc()
->parse('<li><a href="{permalink}">{title}</a></li>'); ?>
</ul>
</section>
<?php endif; ?>
<?php if (!empty($this->options->sidebarBlock) && in_array('ShowRecentComments', $this->options->sidebarBlock)): ?>
<section class="widget">
<h3 class="widget-title"><?php _e('最近回复'); ?></h3>
<ul class="widget-list">
<?php \Widget\Comments\Recent::alloc()->to($comments); ?>
<?php while($comments->next()): ?>
<li><a href="<?php $comments->permalink(); ?>"><?php $comments->author(false); ?></a>: <?php $comments->excerpt(35, '...'); ?></li>
<?php endwhile; ?>
</ul>
</section>
<section class="widget">
<h3 class="widget-title"><?php _e('最近回复'); ?></h3>
<ul class="widget-list">
<?php \Widget\Comments\Recent::alloc()->to($comments); ?>
<?php while ($comments->next()): ?>
<li>
<a href="<?php $comments->permalink(); ?>"><?php $comments->author(false); ?></a>: <?php $comments->excerpt(35, '...'); ?>
</li>
<?php endwhile; ?>
</ul>
</section>
<?php endif; ?>
<?php if (!empty($this->options->sidebarBlock) && in_array('ShowCategory', $this->options->sidebarBlock)): ?>
<section class="widget">
<h3 class="widget-title"><?php _e('分类'); ?></h3>
<?php \Widget\Metas\Category\Rows::alloc()->listCategories('wrapClass=widget-list'); ?>
</section>
<section class="widget">
<h3 class="widget-title"><?php _e('分类'); ?></h3>
<?php \Widget\Metas\Category\Rows::alloc()->listCategories('wrapClass=widget-list'); ?>
</section>
<?php endif; ?>
<?php if (!empty($this->options->sidebarBlock) && in_array('ShowArchive', $this->options->sidebarBlock)): ?>
<section class="widget">
<h3 class="widget-title"><?php _e('归档'); ?></h3>
<ul class="widget-list">
<?php \Widget\Contents\Post\Date::alloc('type=month&format=F Y')
->parse('<li><a href="{permalink}">{date}</a></li>'); ?>
</ul>
</section>
<section class="widget">
<h3 class="widget-title"><?php _e('归档'); ?></h3>
<ul class="widget-list">
<?php \Widget\Contents\Post\Date::alloc('type=month&format=F Y')
->parse('<li><a href="{permalink}">{date}</a></li>'); ?>
</ul>
</section>
<?php endif; ?>
<?php if (!empty($this->options->sidebarBlock) && in_array('ShowOther', $this->options->sidebarBlock)): ?>
<section class="widget">
<h3 class="widget-title"><?php _e('其它'); ?></h3>
<ul class="widget-list">
<?php if($this->user->hasLogin()): ?>
<li class="last"><a href="<?php $this->options->adminUrl(); ?>"><?php _e('进入后台'); ?> (<?php $this->user->screenName(); ?>)</a></li>
<li><a href="<?php $this->options->logoutUrl(); ?>"><?php _e('退出'); ?></a></li>
<?php else: ?>
<li class="last"><a href="<?php $this->options->adminUrl('login.php'); ?>"><?php _e('登录'); ?></a></li>
<?php endif; ?>
<li><a href="<?php $this->options->feedUrl(); ?>"><?php _e('文章 RSS'); ?></a></li>
<li><a href="<?php $this->options->commentsFeedUrl(); ?>"><?php _e('评论 RSS'); ?></a></li>
<li><a href="http://www.typecho.org">Typecho</a></li>
</ul>
</section>
<section class="widget">
<h3 class="widget-title"><?php _e('其它'); ?></h3>
<ul class="widget-list">
<?php if ($this->user->hasLogin()): ?>
<li class="last"><a href="<?php $this->options->adminUrl(); ?>"><?php _e('进入后台'); ?>
(<?php $this->user->screenName(); ?>)</a></li>
<li><a href="<?php $this->options->logoutUrl(); ?>"><?php _e('退出'); ?></a></li>
<?php else: ?>
<li class="last"><a href="<?php $this->options->adminUrl('login.php'); ?>"><?php _e('登录'); ?></a>
</li>
<?php endif; ?>
<li><a href="<?php $this->options->feedUrl(); ?>"><?php _e('文章 RSS'); ?></a></li>
<li><a href="<?php $this->options->commentsFeedUrl(); ?>"><?php _e('评论 RSS'); ?></a></li>
<li><a href="http://www.typecho.org">Typecho</a></li>
</ul>
</section>
<?php endif; ?>
</div><!-- end #sidebar -->

View File

@ -101,7 +101,7 @@ namespace Typecho {
$aliasClass = str_replace('\\', '_', ltrim($className, '\\'));
class_alias($className, $aliasClass);
} elseif (
strpos($className, '_') !== false
(isset(__TYPECHO_CLASS_ALIASES__[$className]) || strpos($className, '_') !== false)
&& !class_exists($className, false)
&& !interface_exists($className, false)
&& !trait_exists($className, false)

View File

@ -105,7 +105,8 @@ class Db
public function __construct($adapterName, string $prefix = 'typecho_')
{
/** 获取适配器名称 */
$this->adapterName = $adapterName == 'Mysql' ? 'Mysqli' : $adapterName;
$adapterName = $adapterName == 'Mysql' ? 'Mysqli' : $adapterName;
$this->adapterName = $adapterName;
/** 数据库适配器 */
$adapterName = '\Typecho\Db\Adapter\\' . str_replace('_', '\\', $adapterName);

View File

@ -70,13 +70,6 @@ class Response
*/
private static $instance;
/**
* 结束前回调函数
*
* @var array
*/
private static $callback = [];
/**
* 字符编码
*
@ -139,7 +132,7 @@ class Response
/**
* @param bool $enable
*/
public function enableAutoSendHeaders($enable = true)
public function enableAutoSendHeaders(bool $enable = true)
{
$this->enableAutoSendHeaders = $enable;
}
@ -198,16 +191,6 @@ class Response
exit;
}
/**
* 新增回调
*
* @param $callback
*/
public static function addCallback($callback)
{
self::$callback[] = $callback;
}
/**
* 设置HTTP状态
*
@ -292,23 +275,6 @@ class Response
return $this;
}
/**
* 结束前的统一回调函数
*/
public static function callback()
{
static $called;
if ($called) {
return;
}
$called = true;
foreach (self::$callback as $callback) {
call_user_func($callback);
}
}
/**
* add responder
*

View File

@ -99,7 +99,6 @@ class Router
$widget->{$route['action']}();
}
Response::callback();
return;
} catch (\Exception $e) {

View File

@ -36,6 +36,7 @@ class Init extends Widget
define('__TYPECHO_CLASS_ALIASES__', [
'Typecho_Plugin_Interface' => '\Typecho\Plugin\PluginInterface',
'Typecho_Widget_Helper_Empty' => '\Typecho\Widget\Helper\EmptyClass',
'Typecho_Db_Adapter_Mysql' => '\Typecho\Db\Adapter\Mysqli',
'Widget_Abstract' => '\Widget\Base',
'Widget_Abstract_Contents' => '\Widget\Base\Contents',
'Widget_Abstract_Comments' => '\Widget\Base\Comments',

View File

@ -31,6 +31,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) {
* @property array $routingTable
* @property string $rootUrl
* @property string $pluginUrl
* @property string $pluginDir
* @property string $adminUrl
* @property string $loginUrl
* @property string $originalSiteUrl
@ -285,7 +286,7 @@ class Options extends Base
*/
public function pluginDir(?string $plugin = null): string
{
return __TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_PLUGIN_DIR__;
return Common::url($plugin, $this->pluginDir);
}
/**
@ -489,6 +490,14 @@ class Options extends Base
Common::url(__TYPECHO_PLUGIN_DIR__, $this->siteUrl);
}
/**
* @return string
*/
protected function ___pluginDir(): string
{
return Common::url(__TYPECHO_PLUGIN_DIR__, __TYPECHO_ROOT_DIR__);
}
/**
* 获取后台路径
*

View File

@ -58,7 +58,7 @@ class Config extends Options
}
/** 获取插件入口 */
[$this->pluginFileName, $this->className] = Plugin::portal($config, $this->options->pluginDir($config));
[$this->pluginFileName, $this->className] = Plugin::portal($config, $this->options->pluginDir);
$this->info = Plugin::parseInfo($this->pluginFileName);
}

View File

@ -40,7 +40,7 @@ class Edit extends Options implements ActionInterface
public function activate($pluginName)
{
/** 获取插件入口 */
[$pluginFileName, $className] = Plugin::portal($pluginName, $this->options->pluginDir($pluginName));
[$pluginFileName, $className] = Plugin::portal($pluginName, $this->options->pluginDir);
$info = Plugin::parseInfo($pluginFileName);
/** 检测依赖信息 */
@ -118,7 +118,7 @@ class Edit extends Options implements ActionInterface
public function configHandle(string $pluginName, array $settings, bool $isInit): bool
{
/** 获取插件入口 */
[$pluginFileName, $className] = Plugin::portal($pluginName, $this->options->pluginDir($pluginName));
[$pluginFileName, $className] = Plugin::portal($pluginName, $this->options->pluginDir);
if (!$isInit && method_exists($className, 'configCheck')) {
$result = call_user_func([$className, 'configCheck'], $settings);
@ -215,7 +215,7 @@ class Edit extends Options implements ActionInterface
try {
/** 获取插件入口 */
[$pluginFileName, $className] = Plugin::portal($pluginName, $this->options->pluginDir($pluginName));
[$pluginFileName, $className] = Plugin::portal($pluginName, $this->options->pluginDir);
} catch (Plugin\Exception $e) {
$pluginFileExist = false;

View File

@ -123,10 +123,7 @@ class Profile extends Edit implements ActionInterface
while ($plugins->next()) {
if ($plugins->personalConfig) {
[$pluginFileName, $className] = Plugin::portal(
$plugins->name,
$this->options->pluginDir($plugins->name)
);
[$pluginFileName, $className] = Plugin::portal($plugins->name, $this->options->pluginDir);
$form = $this->personalForm($plugins->name, $className, $pluginFileName, $group);
if ($this->user->pass($group, true)) {