Skip to content

Commit

Permalink
热修更新1.1.5版本
Browse files Browse the repository at this point in the history
  • Loading branch information
jzwalk committed Jun 14, 2020
1 parent aba159c commit 6aef14d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 45 deletions.
39 changes: 19 additions & 20 deletions Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private function getLocalInfos($name)
$pluginFile = is_dir($pluginDir) ? $pluginDir.'/Plugin.php' : $pluginDir.'.php';
if (is_file($pluginFile)) {
$parse = Typecho_Plugin::parseInfo($pluginFile);
$infos = array($parse['author'],$parse['version']);
$infos = array(strip_tags($parse['author']),strip_tags($parse['version'])); //兼容html混写
}
return $infos;
}
Expand All @@ -82,7 +82,7 @@ public function getPluginData()
} else {
$html = '';
$isRaw = false;
$pages = array_filter(preg_split("/(\r|\n|\r\n)/",strip_tags($this->settings->source)));
$pages = array_filter(preg_split('/(\r|\n|\r\n)/',strip_tags($this->settings->source)));
foreach ($pages as $page) {
$page = trim($page);
if ($page) {
Expand All @@ -104,10 +104,10 @@ public function getPluginData()

//解析表格内容
if ($html) {
$dom = new DOMDocument('1.0','UTF-8');
$dom = new DOMDocument('1.0','utf-8');
$html = function_exists('mb_convert_encoding') ? mb_convert_encoding($html,'HTML-ENTITIES','UTF-8') : $html;
@$dom->loadHTML($html);
$trs = $dom->getElementsByTagName("tr");
$trs = $dom->getElementsByTagName('tr');

$tdVal = '';
$texts = array();
Expand All @@ -117,27 +117,23 @@ public function getPluginData()
$urls = array();
foreach ($trs as $trKey=>$trVal) {
if ($trVal->parentNode->tagName=='tbody') {
//获取tr文本信息
foreach ($trVal->childNodes as $td) {
//获取td纯文本
foreach ($trVal->childNodes as $tdKey=>$td) {
$tdVal = $td->nodeValue;
if ($tdVal) {
$texts[$trKey][] = htmlspecialchars(trim(strip_tags($tdVal)));
$texts[$trKey][] = htmlspecialchars(trim($tdVal));
}
}
$tds = $trs->item($trKey)->getElementsByTagName("td");
//获取td链接地址
$tds = $trs->item($trKey)->getElementsByTagName('td');
//获取td元数据
foreach ($tds as $tdKey=>$tdVal) {
if ($tdKey!==1 && $tdKey!==2) {
$a = $tds->item($tdKey)->getElementsByTagName("a");
$href = $a->item(0) ? $a->item(0)->getAttribute("href") : '';
//处理多作者链接
$a = $tds->item($tdKey)->getElementsByTagName('a');
$href = $a->item(0) ? $a->item(0)->getAttribute('href') : '';
if ($tdKey==3) {
$href = '';
foreach ($a as $key=>$val) {
$href .= ($key==0 ? '' : ',').$val->getAttribute('href');
}
$href = str_replace(array('<td align="right">','</td>'),'',$dom->saveXML($tds->item($tdKey))); //全取作者栏html
}
$urls[] = htmlspecialchars($href);
$urls[] = trim($href);
}
}
}
Expand All @@ -146,12 +142,15 @@ public function getPluginData()
$urls = array_chunk($urls,3);

//合并关联键名
$keys = array('pluginName','desc','version','author','source','pluginUrl','site','zipFile');
$keys = array('pluginName','desc','version','mark','pluginUrl','authorHtml','zipFile');
$names = array();
$vals = array();
$datas = array();
foreach ($texts as $key=>$val) {
$names[] = isset($val[0]) ? $val[0] : $val[1]; //fix for PHP 7.0+
$datas[] = array_combine($keys,array_merge($val,$urls[$key]));
$vals = array_values(array_filter($val));
unset($vals[3]); //去除作者栏text
$datas[] = array_combine($keys,array_merge($vals,$urls[$key]));
}
//按插件名排序
array_multisort($names,SORT_ASC,$datas);
Expand Down Expand Up @@ -436,7 +435,7 @@ public function ZIP_CDN($name='',$author='')
*/
private function makedir($path)
{
$path = preg_replace("/\\\+/",'/',$path);
$path = preg_replace('/\\\+/','/',$path);
$current = rtrim($path,'/');
$last = $current;

Expand Down
2 changes: 1 addition & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @package TeStore
* @author 羽中, zhulin3141
* @version 1.1.4
* @version 1.1.5
* @dependence 13.12.12-*
* @link https://www.yzmb.me/archives/net/testore-for-typecho
* @copyright Copyright (c) 2014-2020 Yuzhong Zheng (jzwalk)
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
### 新GitHub表格解析版插件仓库TeStore v1.1.4
### 新GitHub表格解析版插件仓库TeStore v1.1.5

以免服务端思路复活这款插件,通过读取GitHub上的专用表格实现插件仓库的搜索、下载和安装删除功能
以免服务端思路复活这款插件,通过读取GitHub上的专用表格实现插件仓库的搜索、下载和安装删除等功能

- v1.1.4(20-5-17):
- v1.1.5(20-6-14):

1. 修正直接读取GitHub源无法正确解析列表的bug,作者信息全取html代码以兼容各种文档写法;

2. 获取本地插件meta信息时过滤html标签增强准确性,列表页搜索功能现已支持按作者名称筛选。

- v1.1.4(20-6-10):

1. 列表页面顶部增加点击标签,已安装插件可分页显示,列表附注图标更新为更清晰的SVG格式;

2. 操作按钮样式和反馈提示效果沿用系统风格,提交方式由ajax改为同步post,移除原sticky效果;

3. 安装过程增加目录检测和升级清理,移除pclzip使用PHP原生解压缩方法,data改为常规目录等。

- v1.1.3(20-5-15):
- v1.1.3(20-6-7):

1. 修正冗余代码增强可读性,修复非管理员用户可查看列表bug,修复同名插件只安装第一个bug;

Expand Down
38 changes: 18 additions & 20 deletions views/market.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
$pluginDatas = array();
//筛选关键词
foreach ($pluginData as $plugin) {
if (!$keywords || false!==stripos($plugin['pluginName'],$keywords) || false!==stripos($plugin['desc'],$keywords)) {
if (!$keywords || false!==stripos($plugin['pluginName'],$keywords) || false!==stripos($plugin['desc'],$keywords) || false!==stripos(htmlspecialchars_decode(strip_tags($plugin['authorHtml'])),$keywords)) {
$pluginDatas[] = $plugin;
}
}

$installed = $this->getLocalPlugins();
$infos = array();
$author = '';
$pluginIns = array();
//检测已安装
foreach ($pluginDatas as $key=>$plugin) {
if ($infos = $this->getLocalInfos($plugin['pluginName'])) {
if ($infos[0]==$plugin['author']) {
if ($infos[0]==htmlspecialchars_decode(strip_tags($plugin['authorHtml']))) {
$pluginIns[] = $plugin;
unset($pluginDatas[$key]);
}
Expand Down Expand Up @@ -91,54 +90,53 @@
</thead>
<tbody>
<?php if ($pluginData) :
$source = '';
$mark = '';
$tefans = false;
$url = '';
$version = '';
$authorHtml = '';
$author = '';
$authors = array();
$update = false;
$sites = array();
$uninstall = false;
foreach ($pluginData[$page] as $plugin) :
$name = $plugin['pluginName'];
$source = $plugin['source'];
$mark = $plugin['mark'];
$url = $plugin['pluginUrl'];
//社区维护版标记
$tefans = in_array($source,array('Download','N/A','Special'));
$tefans = in_array($mark,array('Download','N/A','Special'));
$url = $url ? ($tefans ? (strpos($url,'typecho-fans') ? 'https://github.com'.$url : 'https://github.com/typecho-fans/plugins/blob/master/'.$url) : $url) : '#'; ?>
<tr id="plugin-<?php echo $name; ?>">
<td><a rel="external noopener" href="<?php echo $url; ?>" title="<?php _e('点击查看插件文档'); ?>"<?php if ($url!=='#') echo ' target="_blank"'; ?>><?php echo $name; ?></a>
<?php if ($tefans) : ?>
<a href="http://typecho-fans.github.io" title="<?php _e('Typecho-Fans社区维护版'); ?>" target="_blank"><img src="<?php $this->options->pluginUrl('TeStore/views/tf.svg'); ?>" alt="typecho-fans"/></a><?php endif;
if ($source=='N/A' || $source=='不可用') : ?>
if ($mark=='N/A' || $mark=='不可用') : ?>
<img src="<?php $this->options->pluginUrl('TeStore/views/na.svg'); ?>" title="<?php _e('已失效或不适用于当前版本'); ?>" alt="n/a"/>
<?php elseif ($source=='Special' || $source=='特殊') : ?>
<?php elseif ($mark=='Special' || $mark=='特殊') : ?>
<img src="<?php $this->options->pluginUrl('TeStore/views/sp.svg'); ?>" title="<?php _e('安装用法特殊请先阅读文档'); ?>" alt="special"/>
<?php endif; ?></td>
<td><?php echo $plugin['desc']; ?></td>
<td><?php $version = $plugin['version'];
echo $version;
$author = $plugin['author'];
$authorHtml = $plugin['authorHtml'];
$author = htmlspecialchars_decode(strip_tags($authorHtml));
$infos = $this->getLocalInfos($name);
//已安装判断升级
$update = $infos && $infos[1]<$version;
$version = stripos($version,'v')===0 ? substr($version,1) : $version;
if ($infos && $infos[0]==$author && $update) : ?>
if ($update && $infos[0]==$author) : ?>
&#8672 <span class="error"><?php _e('有新版本!'); ?></span></td>
<?php endif; ?>
<td>
<?php $sites = explode(',',$plugin['site']);
$authors = explode(', ',$author);
//兼容多作者链接
foreach ($authors as $key=>$val) :
if (!empty($sites[$key])) : ?><a rel="external noopener" href="<?php echo $sites[$key]; ?>" title="<?php _e('点击访问作者主页'); ?>" target="_blank"><?php endif;
echo trim($val);
if (!empty($sites[$key])) : ?></a><?php endif;
if ($val!==end($authors)) : ?>, <?php endif;
endforeach; ?>
<?php echo $authorHtml; ?>
</td>
<td style="text-align:center;">
<?php $uninstall = $infos && $infos[0]==$author && !$update; ?>
<?php $uninstall = $infos && $infos[0]==$author && !$update;
$authors = preg_split('/(,|&)/',$author);
foreach ($authors as $key=>$val) :
$authors[$key] = trim($val);
endforeach; ?>
<form id="operation" action="<?php echo $storeUrl.($uninstall ? 'uninstall' : 'install').'?plugin='.$name.($uninstall ? '' : '&author='.implode('_',$authors).'&zip='.$plugin['zipFile']); ?>" method="post" enctype="application/x-www-form-urlencoded">
<button type="submit" class="btn btn-xs <?php echo $uninstall ? 'btn-warn' : 'primary'; ?>" data-name="<?php echo $name; ?>"><?php $uninstall ? _e('删除') : ($update ? _e('升级') : _e('安装')); ?></button>
</form>
Expand Down

0 comments on commit 6aef14d

Please sign in to comment.