Skip to content

Commit

Permalink
bug
Browse files Browse the repository at this point in the history
  • Loading branch information
刘俊涛 committed Mar 1, 2017
1 parent 30603c9 commit 79d0fba
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 22 deletions.
2 changes: 1 addition & 1 deletion backend/views/module/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$this->title = '插件设置:' .' '.$model->name;
$this->title = '模块配置:' .' '.$model->name;
$this->params['breadcrumbs'][] = ['label' => '插件', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
Expand Down
12 changes: 5 additions & 7 deletions common/components/LoadModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,24 @@
use Yii;
use yii\base\BootstrapInterface;
use yii\base\Component;
use yii\web\Application;
use yii\helpers\ArrayHelper;

class LoadModule extends Component implements BootstrapInterface
{
public function bootstrap($app)
{
if ($app instanceof Application) {
// 先判断是否安装,没安装不操作~
if (!file_exists(Yii::getAlias('@root/web/storage/install.txt'))) {
return;
}
// 先判断是否安装,没安装不操作~
if (!file_exists(Yii::getAlias('@root/web/storage/install.txt'))) {
return;
}

$models = Module::findOpenModules(Module::TYPE_CORE);
$bootstrapType = $app->id;
foreach ($models as $model) {
$modulePackage = Yii::$app->moduleManager->findOne($model->id);
$class = [
'class' => $modulePackage->getModuleClass()
'class' => $modulePackage->getModuleClass(),
'params' => $modulePackage->getConfig()
];
$this->setModule($model->id, $class);
$bootstraps = explode("|", $model->bootstrap);
Expand Down
37 changes: 24 additions & 13 deletions common/modules/attachment/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,31 @@ class Module extends \yii\base\Module implements BootstrapInterface
{
public function bootstrap($app)
{
$app->set('storage', [
'class' => 'common\\modules\\attachment\\components\\Storage',
$storage = [
'class' => 'common\modules\attachment\components\Storage',
'fs' => [
// 'class' => 'creocoder\flysystem\LocalFilesystem',
// 'path' => '@storagePath/upload',
'class' => 'common\\modules\\attachment\\components\\flysystem\\QiniuFilesystem',
'access' => 'EMBSLKU4SR4O8bHVteOY4F4Od2fYaty4aYY3PsR9',
'secret' => 'L2DdJkn3A8scKa3wbaktz6vU-tj8H9oLnZhU7yCn',
'bucket' => 'siyuan',
'class' => 'creocoder\flysystem\LocalFilesystem',
'path' => '@storagePath/upload',
],
'baseUrl' => 'http:https://image.51siyuan.cn',
'imageProcessor' => [
'class' => 'common\\modules\\attachment\\components\\image\\Qiniu',
]
]);
'baseUrl' => '@storagePath/upload',
'imageProcessor' => 'common\modules\attachment\components\image\Local'
];
if (isset($this->params['filesystem_type'])) {
switch ($this->params['filesystem_type']) {
case 'qiniu':
$storage['fs'] = [
'class' => 'common\\modules\\attachment\\components\\flysystem\\QiniuFilesystem',
'access' => $this->params['qiniu_access_key'],
'secret' => $this->params['qiniu_access_secret'],
'bucket' => $this->params['qiniu_bucket'],
];
$storage['baseUrl'] = 'http:https://image.51siyuan.cn';
$storage['imageProcessor'] = [
'class' => 'common\\modules\\attachment\\components\\image\\Qiniu'
];
break;
}
}
$app->set('storage', $storage);
}
}
38 changes: 38 additions & 0 deletions common/modules/attachment/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
return [
[
'name' => 'filesystem_type',
'type' => 'radio',
'value' => 'local',
'desc' => '文件系统',
'extra' => [
'local' => '本地',
'qiniu' => '七牛',
// 'aliyuncs' => '阿里云oss',
]
],
[
'name' => 'qiniu_access_key',
'type' => 'text',
'value' => '',
'desc' => '七牛access_key',
],
[
'name' => 'qiniu_access_secret',
'type' => 'text',
'value' => '',
'desc' => '七牛access_secret',
],
[
'name' => 'qiniu_bucket',
'type' => 'text',
'value' => '',
'desc' => '七牛bucket',
],
[
'name' => 'qiniu_domain',
'type' => 'text',
'value' => '',
'desc' => '七牛域名',
],
];
2 changes: 1 addition & 1 deletion database/migrations/m160728_025305_create_config_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function up()
LOCK TABLES {{%config}} WRITE;
/*!40000 ALTER TABLE {{%config}} DISABLE KEYS */;
INSERT INTO {{%config}} VALUES (1,'CONFIG_TYPE_LIST','text=>字符\r\narray=>数组\r\npassword=>密码\r\nimage=>图片\r\ntextarea=>多行字符\r\nselect=>下拉框\r\nradio=>单选框\r\ncheckbox=>多选框\r\neditor=>富文本编辑器','','配置类型列表','array',0,1461937892,'system'),
(2,'CONFIG_GROUP','site=>网站\r\nsystem=>系统\r\nemail=>邮箱\r\nwechat=>微信','','配置分组','array',1468405444,1468421137,'system'),
(2,'CONFIG_GROUP','site=>网站\r\nsystem=>系统\r\nwechat=>微信','','配置分组','array',1468405444,1468421137,'system'),
(3,'SITE_NAME','yii2cmf','','网站名称','text',0,1461937892,'site'),
(4,'SITE_ICP','','','域名备案号','text',0,1461937892,'site'),
(5,'SITE_LOGO','','','网站LOGO','image',0,1461937892,'site'),
Expand Down

0 comments on commit 79d0fba

Please sign in to comment.