Initial commit
Some checks failed
定时更新GitHub源插件 / 自动更新GitHub插件 (push) Has been cancelled

This commit is contained in:
chorblack
2026-03-07 11:19:25 +08:00
commit e75f275ef4
4484 changed files with 645480 additions and 0 deletions

62
DevTool/Action.php Normal file
View File

@@ -0,0 +1,62 @@
<?php ! defined('__TYPECHO_ROOT_DIR__') and exit();
class DevTool_Action extends Typecho_Widget {
public function __construct($request, $response, $params = NULL){
parent::__construct($request, $response, $params);
$this->db = Typecho_Db::get();
define('TYPEHO_ADMIN_PATH', __TYPECHO_ROOT_DIR__ . __TYPECHO_ADMIN_DIR__ );
}
public function index(){
include_once 'views/index.php';
}
public function options(){
$options = Helper::options();
$optData = $this->db->fetchAll($this->db->select('name', 'user', 'value')
->from('table.options'));
include_once 'views/options.php';
}
public function post(){
$rssfile = array(
"http://rss.news.sohu.com/rss/pfocus.xml",
"http://rss.news.sohu.com/rss/focus.xml",
"http://rss.news.sohu.com/rss/guonei.xml",
"http://rss.news.sohu.com/rss/guoji.xml",
"http://rss.news.sohu.com/rss/junshi.xml",
"http://rss.news.sohu.com/rss/sports.xml",
"http://rss.news.sohu.com/rss/business.xml",
"http://rss.news.sohu.com/rss/it.xml",
"http://rss.news.sohu.com/rss/learning.xml",
"http://rss.news.sohu.com/rss/yule.xml"
);
$rssfile = $rssfile[rand(0, count($rssfile) - 1)];
$xml = simplexml_load_file($rssfile);
$postObj = new Widget_Abstract_Contents($this->request, $this->response);
$insertId = array();
$posts = array();
foreach ($xml->channel->item as $item) {
$post = array();
$post['title'] = (string)$item->title[0];
$post['text'] = (string)$item->description[0];
$posts[] = $post;
}
if( ! empty($posts) ){
foreach ($posts as $post) {
$insertId[] = $postObj->insert($post);
}
}
include_once 'views/post.php';
}
}

78
DevTool/Plugin.php Normal file
View File

@@ -0,0 +1,78 @@
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
/**
* 开发者工具
*
* @package DevTool
* @author zhulin3141
* @version 1.0.0
* @link http://zhulin31410.blog.163.com/
*/
class DevTool_Plugin implements Typecho_Plugin_Interface
{
const NAME = '开发者工具';
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function activate()
{
Typecho_Plugin::factory('admin/menu.php')->navBar = array('DevTool_Plugin', 'render');
Helper::addPanel(1, 'DevTool/index.php', self::NAME, self::NAME, 'administrator');
Helper::addRoute('dev-tool_index', __TYPECHO_ADMIN_DIR__ . 'dev-tool/index', 'DevTool_Action', 'index');
Helper::addRoute('dev-tool_options', __TYPECHO_ADMIN_DIR__ . 'dev-tool/options', 'DevTool_Action', 'options');
Helper::addRoute('dev-tool_post', __TYPECHO_ADMIN_DIR__ . 'dev-tool/post', 'DevTool_Action', 'post');
}
/**
* 禁用插件方法,如果禁用失败,直接抛出异常
*
* @static
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function deactivate(){
Helper::removePanel(1, 'DevTool/index.php');
Helper::removeRoute('dev-tool_index');
Helper::removeRoute('dev-tool_options');
Helper::removeRoute('dev-tool_post');
}
/**
* 获取插件配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form 配置面板
* @return void
*/
public static function config(Typecho_Widget_Helper_Form $form)
{}
/**
* 个人用户的配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form
* @return void
*/
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
/**
* 插件实现方法
*
* @access public
* @return void
*/
public static function render()
{
$options = Helper::options();
echo '<a href="';
$options->adminUrl('extending.php?panel=DevTool%2Findex.php');
echo '">' .self::NAME .'</a>';
}
}

5
DevTool/README.md Normal file
View File

@@ -0,0 +1,5 @@
### Typecho开发者测试插件DevTool v1.0.0
启用后可在“控制台”-“开发者工具”中分类查看Option数据(插件、路由和面板相关)或自动生成30条文章内容用于主题测试。
> RSS源更换为搜狐新闻修正路径兼容Typecho1.0+。

8
DevTool/index.php Normal file
View File

@@ -0,0 +1,8 @@
<?php !defined('__TYPECHO_ROOT_DIR__') and exit();
$options = Helper::options();
$siteUrl = $options->siteUrl;
$isRewrite = $options->rewrite;
$absUrl = ($isRewrite ? rtrim($siteUrl, '/') : $siteUrl . "index.php");
Typecho_Response::getInstance()->redirect($absUrl . __TYPECHO_ADMIN_DIR__ . 'dev-tool/index');

42
DevTool/views/index.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
include TYPEHO_ADMIN_PATH . 'common.php';
$menu->title = _t(DevTool_Plugin::NAME);
include TYPEHO_ADMIN_PATH . 'header.php';
include TYPEHO_ADMIN_PATH . 'menu.php';
?>
<div class="main">
<div class="body container">
<div class="colgroup">
<div class="typecho-page-title col-mb-12">
<h2><?php echo $menu->title; ?></h2>
</div>
</div>
<div class="row typecho-page-main" role="form">
<div class="col-mb-12 col-tb-8 col-tb-offset-2">
<ul class="typecho-option" id="typecho-option-item-title-0">
<li>
<a href="<?php $options->index(__TYPECHO_ADMIN_DIR__ .'dev-tool/options'); ?>">查看Option数据</a>
</li>
<li>
<a href="<?php $options->index(__TYPECHO_ADMIN_DIR__ .'dev-tool/post'); ?>">生成文章</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<?php
include TYPEHO_ADMIN_PATH.'copyright.php';
include TYPEHO_ADMIN_PATH.'common-js.php';
include TYPEHO_ADMIN_PATH.'footer.php';
?>
<script type="text/javascript">
$(function(){
$('a').attr('target', '_self');
});
</script>

94
DevTool/views/options.php Normal file
View File

@@ -0,0 +1,94 @@
<?php
include TYPEHO_ADMIN_PATH . 'common.php';
$menu->title = _t(DevTool_Plugin::NAME);
include TYPEHO_ADMIN_PATH . 'header.php';
include TYPEHO_ADMIN_PATH . 'menu.php';
?>
<style type="text/css">
.serialize{color: blue; cursor: pointer;}
.org-value{display: none;}
</style>
<div class="main">
<div class="body container">
<div class="colgroup">
<div class="typecho-page-title col-mb-12">
<h2><?php echo $menu->title; ?></h2>
</div>
</div>
<div class="row typecho-page-main" role="form">
<div class="col-mb-12 typecho-list">
<div class="typecho-list-operate clearfix">
<form method="get">
<a target="_self" href="<?php $options->index(__TYPECHO_ADMIN_DIR__ .'dev-tool/options'); ?>?keywords=plugin"><?php _e('插件相关'); ?></a>
<a target="_self" href="<?php $options->index(__TYPECHO_ADMIN_DIR__ .'dev-tool/options'); ?>?keywords=routingTable"><?php _e('路由'); ?></a>
<a target="_self" href="<?php $options->index(__TYPECHO_ADMIN_DIR__ .'dev-tool/options'); ?>?keywords=panel"><?php _e('Panel'); ?></a>
<div class="search" role="search">
<?php if ('' != $request->keywords): ?>
<a href="<?php $options->index(__TYPECHO_ADMIN_DIR__ .'dev-tool/options'); ?>"><?php _e('&laquo; 取消筛选'); ?></a>
<?php endif; ?>
<input type="text" class="text-s" placeholder="<?php _e('请输入关键字'); ?>" value="<?php echo htmlspecialchars($request->keywords); ?>" name="keywords" />
<button type="submit" class="btn btn-s"><?php _e('筛选'); ?></button>
</div>
</form>
</div>
<div class="typecho-table-wrap">
<table class="typecho-list-table">
<colgroup>
<col width="25%">
<col width="45%">
</colgroup>
<thead>
<tr>
<th>名称</th>
<th>值</th>
</tr>
</thead>
<tbody>
<?php if( $optData ): ?>
<?php foreach ($optData as $opt): ?>
<?php $opt = (object)$opt; ?>
<?php if( $request->keywords == '' || false !== stripos($opt->name, $request->keywords )): ?>
<tr>
<td><?php echo $opt->name; ?></td>
<td>
<?php if(preg_match('/(.+)\:(.+)\:\{(.+)\}/', $opt->value) > 0): ?>
<span class="serialize">serialize value</span>
<span class="org-value"><pre><?php print_r(unserialize($opt->value)); ?></pre></span>
<?php else: ?>
<?php echo $opt->value; ?>
<?php endif; ?>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<?php
include TYPEHO_ADMIN_PATH.'copyright.php';
include TYPEHO_ADMIN_PATH.'common-js.php';
include TYPEHO_ADMIN_PATH.'footer.php';
?>
<script type="text/javascript">
$(function(){
$('.serialize').on('click', function(){
$(this).hide().parent().find('.org-value').show();
});
$('.org-value').on('click', function(){
$(this).hide().parent().find('.serialize').show();
});
$('a').attr('target', '_self');
});
</script>

19
DevTool/views/post.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
include TYPEHO_ADMIN_PATH . 'common.php';
$menu->title = _t(DevTool_Plugin::NAME);
include TYPEHO_ADMIN_PATH . 'header.php';
include TYPEHO_ADMIN_PATH . 'menu.php';
?>
<div class="main">
<div class="body container">
<p>成功生成 <?php echo count($insertId); ?>条文章</p>
</div>
</div>
<?php
include TYPEHO_ADMIN_PATH.'copyright.php';
include TYPEHO_ADMIN_PATH.'common-js.php';
include TYPEHO_ADMIN_PATH.'footer.php';
?>