Compare commits
No commits in common. "0017693c81f648779a609a8cc042eb486c1b5b15" and "b416e585966b8cc06b66573c5294e22d822c121d" have entirely different histories.
0017693c81
...
b416e58596
|
@ -65,5 +65,4 @@
|
|||
- 1.2.2
|
||||
|
||||
- 增加侧边栏显示的全局开关
|
||||
- 修复代码块中的短代码解析问题
|
||||
- 新增一个随机文章阅读的独立页面
|
||||
- 修复代码块中的短代码解析问题
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* 随机阅读
|
||||
*
|
||||
* @package custom
|
||||
*/
|
||||
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||
|
||||
$db = Typecho_Db::get();
|
||||
|
||||
// 统计符合条件的文章总数
|
||||
$countSql = $db->select('COUNT(*) AS count')
|
||||
->from('table.contents')
|
||||
->where('status = ?', 'publish')
|
||||
->where('type = ?', 'post')
|
||||
->where('created <= ?', time());
|
||||
$countResult = $db->fetchRow($countSql);
|
||||
$total = $countResult['count'];
|
||||
|
||||
if ($total > 0) {
|
||||
// 随机选择一个偏移量
|
||||
$offset = mt_rand(0, $total - 1);
|
||||
|
||||
// 根据偏移量获取一篇文章
|
||||
$sql = $db->select()
|
||||
->from('table.contents')
|
||||
->where('status = ?', 'publish')
|
||||
->where('type = ?', 'post')
|
||||
->where('created <= ?', time())
|
||||
->limit(1)
|
||||
->offset($offset);
|
||||
|
||||
$result = $db->fetchRow($sql);
|
||||
|
||||
if (!empty($result)) {
|
||||
$target = Typecho_Widget::widget('Widget_Abstract_Contents')->filter($result);
|
||||
$this->response->redirect($target['permalink'], 307);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有找到文章,重定向到首页
|
||||
$this->response->redirect($this->options->siteUrl, 307);
|
||||
?>
|
|
@ -16,21 +16,20 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||
</div>
|
||||
<div id="page-tags">
|
||||
<div id="page" class="row row-cols-1">
|
||||
<?php if ($this->options->showsidebar): ?>
|
||||
<div id="posts" class="col-lg-8 col-md-12 animated fadeInLeft">
|
||||
<?php else: ?>
|
||||
<div id="posts" class="col-lg-12 col-md-12">
|
||||
<?php endif; ?>
|
||||
<div class="puock-text p-block no-style pb-2">
|
||||
<?php
|
||||
// 获取所有标签
|
||||
$tags = Typecho_Widget::widget('Widget_Metas_Tag_Cloud');
|
||||
|
||||
// 准备字母数组
|
||||
$letters = range('A', 'Z');
|
||||
$letters[] = '0';
|
||||
$letters[] = '0';
|
||||
|
||||
// 获取所有存在的首字母
|
||||
$existingLetters = array();
|
||||
$tagsArray = array();
|
||||
$tagsArray = array();
|
||||
|
||||
while ($tags->next()) {
|
||||
$firstChar = getFirstChar($tags->name);
|
||||
if (!in_array($firstChar, $existingLetters)) {
|
||||
|
@ -42,6 +41,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||
'count' => $tags->count
|
||||
);
|
||||
}
|
||||
|
||||
// 对每个字母下的标签按名称排序
|
||||
foreach ($tagsArray as &$letterTags) {
|
||||
usort($letterTags, function($a, $b) {
|
||||
|
@ -49,6 +49,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||
});
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- 字母导航 -->
|
||||
<ul class='pl-0' id='tags-main-index'>
|
||||
<?php foreach ($letters as $letter): ?>
|
||||
|
@ -62,11 +63,13 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||
<li class='t'><?php echo $i; ?></li>
|
||||
<?php endfor; ?>
|
||||
</ul>
|
||||
|
||||
<!-- 标签列表 -->
|
||||
<ul id='tags-main-box' class='pl-0'>
|
||||
<?php
|
||||
// 按字母顺序排序
|
||||
ksort($tagsArray);
|
||||
|
||||
foreach ($tagsArray as $letter => $tags): ?>
|
||||
<li class='n' id='<?php echo $letter; ?>'>
|
||||
<h4 class='tag-name'><span class='t-lg c-sub'>#</span><?php echo $letter; ?></h4>
|
||||
|
@ -78,7 +81,9 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($this->options->showsidebar): ?>
|
||||
<?php
|
||||
|
||||
?>
|
||||
|
||||
<?php $this->need('sidebar.php'); ?>
|
||||
<?php endif; ?>
|
||||
<?php $this->need('footer.php'); ?>
|
||||
<?php $this->need('footer.php'); ?>
|
||||
|
|
Loading…
Reference in New Issue