Skip to content
This repository has been archived by the owner on May 9, 2019. It is now read-only.

Commit

Permalink
Merge pull request #12 from chekun/develop
Browse files Browse the repository at this point in the history
[PR]云平台/或者没有权限的时候降级为手动下载上传模式
  • Loading branch information
Che Kun committed Feb 25, 2015
2 parents 7073de3 + 461d6e2 commit f23b0d3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
28 changes: 24 additions & 4 deletions Action.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<?php ! defined('__TYPECHO_ROOT_DIR__') and exit();

class AppStore_Action extends Typecho_Widget {
class AppStore_Action extends Typecho_Widget
{

/**
* 是否支持自动下载安装
*
* 如果在云平台上,则处理为手动下载模式。
*
* @var boolean
*/
private $installale = true;

/**
* 应用商店服务器
Expand All @@ -20,6 +30,14 @@ public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);

//检测是否可以自动下载安装
$tempDir = __TYPECHO_ROOT_DIR__.__TYPECHO_PLUGIN_DIR__.'/.app_store/';
if (! @touch($tempDir.'.installable'.time())) {
$this->installale = false;
} else {
unlink($tempDir.'.installable'.time());
}

//如果没有json库,加载兼容包
! extension_loaded('json') and include('libs/compat_json.php');

Expand Down Expand Up @@ -48,9 +66,11 @@ public function market()
//获取插件列表
$result = json_decode(http_get($this->server.'packages.json'));


if ($result) {

//导出已激活插件


//导出已激活插件
$activatedPlugins = Typecho_Plugin::export();

foreach ($result->packages as &$_package) {
Expand Down Expand Up @@ -202,4 +222,4 @@ public function install()
}
}

}
}
9 changes: 5 additions & 4 deletions Plugin.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
*
* @package AppStore
* @author chekun
* @version 1.1.1
* @version 1.2.0
* @link http://typecho.dilicms.com
*/
class AppStore_Plugin implements Typecho_Plugin_Interface
{

/**
* 插件下载临时目录
*
Expand All @@ -29,11 +30,11 @@ public static function activate()
if (! extension_loaded('curl')) {
throw new Typecho_Plugin_Exception('缺少curl扩展支持.');
}

//创建下载临时目录
$tempDir = __TYPECHO_ROOT_DIR__.__TYPECHO_PLUGIN_DIR__.self::$tempPath;
if (! file_exists($tempDir) and ! @mkdir($tempDir)) {
throw new Typecho_Plugin_Exception('无法创建插件下载临时目录.');
}

! file_exists($tempDir) and ! @mkdir($tempDir);

//创建菜单和路由
Helper::addPanel(1, 'AppStore/market.php', '应用商店', '应用商店', 'administrator');
Expand Down
1 change: 1 addition & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ The missing plugins store for Typecho!

- [@chekun](https://github.com/chekun)
- [@jzwalk](https://github.com/jzwalk)
- [@fengyunljp](https://github.com/fengyunljp)

### 欢迎一起完善该项目.
10 changes: 8 additions & 2 deletions views/list.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<p class="as-author">
<?php echo _t('作者'); ?>:
<cite><?php echo $plugin->versions[0]->author; ?></cite>

</p>
<p class="as-versions">
<?php echo _t('版本'); ?>:
Expand All @@ -18,12 +19,17 @@
<?php endforeach; ?>
</select>
</p>

<p class="as-require">
<?php echo _t('版本要求'); ?>:
<cite><?php echo $plugin->versions[0]->require; ?></cite>
</p>
<p class="as-operations">
<button class="btn-s as-install"><?php echo _t('安装'); ?></button>
<?php if ($this->installale): ?>
<button class="btn-s as-install"><?php echo _t("安装"); ?></button>
<?php else: ?>
<a class="btn-s" onclick="return confirm('没有写入权限或者运行在云平台中\n点击确认后将进行下载,请手动传到服务器上!');" href="<?php echo $this->server.'archive/'.$plugin->name.'/'.str_replace(' ', '%20', $version->version);?>"><?php echo _t('下载'); ?></a>
<?php endif; ?>
<span class="as-status" style="">
<?php if ($plugin->existed): ?>
<i class="fa fa-check-circle as-activated as-existed active" title="<?php echo _t('已安装'); ?>"></i>
Expand All @@ -40,4 +46,4 @@
<p><i class="fa fa-frown-o" style="font-size: 5em"></i></p>
<h3 style="font-size: 2em">没有找到任何插件</h3>
</div>
<?php endif; ?>
<?php endif; ?>

0 comments on commit f23b0d3

Please sign in to comment.