Skip to content

Commit 95d2d61

Browse files
fecmall界面安装appinstall入口
1 parent ec3a6e0 commit 95d2d61

File tree

8 files changed

+160
-85
lines changed

8 files changed

+160
-85
lines changed

app/appinstall/config/appinstall.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22
/**
3-
* FecShop file.
3+
* FecMall file.
44
*
5-
* @link http://www.fecshop.com/
6-
* @copyright Copyright (c) 2016 FecShop Software LLC
7-
* @license http://www.fecshop.com/license/
5+
* @link http://www.fecmall.com/
6+
* @copyright Copyright (c) 2016 FecMall Software LLC
7+
* @license http://www.fecmall.com/license/
88
*/
99
/**
1010
* 本文件在@appfront/web/index.php 处,会被引入。
@@ -25,7 +25,7 @@
2525
'components' => [
2626
// 404页面对应的url key
2727
'errorHandler' => [
28-
'errorAction' => 'site/helper/error',
28+
'errorAction' => 'database/error/index',
2929
],
3030
// 首页对应的url key
3131
'urlManager' => [

app/appinstall/config/modules/Database.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?php
22
/**
3-
* FecShop file.
3+
* FecMall file.
44
*
5-
* @link http://www.fecshop.com/
6-
* @copyright Copyright (c) 2016 FecShop Software LLC
7-
* @license http://www.fecshop.com/license/
5+
* @link http://www.fecmall.com/
6+
* @copyright Copyright (c) 2016 FecMall Software LLC
7+
* @license http://www.fecmall.com/license/
8+
*/
9+
/**
10+
* @author Terry Zhao <2358269014@qq.com>
11+
* @since 1.0
812
*/
913
return [
1014
/**

app/appinstall/config/params.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<?php
22
/**
3-
* FecShop file.
3+
* FecMall file.
44
*
5-
* @link http://www.fecshop.com/
6-
* @copyright Copyright (c) 2016 FecShop Software LLC
7-
* @license http://www.fecshop.com/license/
5+
* @link http://www.fecmall.com/
6+
* @copyright Copyright (c) 2016 FecMall Software LLC
7+
* @license http://www.fecmall.com/license/
88
*/
99
return [
1010
/**
1111
* 模板路径配置部分
1212
*/
13-
'appinstallBaseTheme' => '@fecshop/app/appinstall/theme',
13+
//'appinstallBaseTheme' => '@fecshop/app/appinstall/theme',
1414
/**
1515
* 模板默认的layout文件,也就是模板路径下面的layout文件夹下的文件,
1616
* 对于上面的模板路径的配置,也就是文件:@fecshop/app/appfront/theme/base/front/layouts/main.php
1717
*/
18-
'appfrontBaseLayoutName'=> 'main.php',
18+
//'appfrontBaseLayoutName'=> 'main.php',
1919
/**
2020
* 入口的名字,这个对应入口的文件夹命名。
2121
*/
22-
'appName' => 'appinstall',
22+
//'appName' => 'appinstall',
2323

2424
];

app/appinstall/modules/Database/Module.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22
/**
3-
* FecShop file.
3+
* FecMall file.
44
*
5-
* @link http://www.fecshop.com/
6-
* @copyright Copyright (c) 2016 FecShop Software LLC
7-
* @license http://www.fecshop.com/license/
5+
* @link http://www.fecmall.com/
6+
* @copyright Copyright (c) 2016 FecMall Software LLC
7+
* @license http://www.fecmall.com/license/
88
*/
99

1010
namespace fecshop\app\appinstall\modules\Database;
@@ -14,7 +14,6 @@
1414
/**
1515
* @author Terry Zhao <2358269014@qq.com>
1616
* @since 1.0
17-
* Catalog Module 模块
1817
*/
1918
class Module extends \yii\base\Module
2019
{

app/appinstall/modules/Database/controllers/ConfigController.php

+64-62
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
<?php
2-
2+
/**
3+
* FecMall file.
4+
*
5+
* @link http://www.fecmall.com/
6+
* @copyright Copyright (c) 2016 FecMall Software LLC
7+
* @license http://www.fecmall.com/license/
8+
*/
39
namespace fecshop\app\appinstall\modules\Database\controllers;
410

511
use Yii;
6-
12+
/**
13+
* @author Terry Zhao <2358269014@qq.com>
14+
* @since 1.0
15+
*/
716
class ConfigController extends \yii\web\Controller
817
{
918
public function init()
@@ -13,12 +22,30 @@ public function init()
1322

1423
public $_migrateLog = '';
1524

16-
// 数据库管理
25+
// 安装默认第一步页面
26+
public function actionIndex()
27+
{
28+
$editForm = Yii::$app->request->post('editForm');
29+
if ($editForm && $this->checkDatabaseData($editForm)
30+
&& $this->updateDatabase($editForm)) {
31+
Yii::$app->session->setFlash('database-success', 'mysql config set success, mysql config file path: @common/config/main-local.php');
32+
// 进行跳转
33+
$homeUrl = Yii::$app->homeUrl;
34+
return $this->redirect($homeUrl.'/database/config/migrate');
35+
}
36+
$errorInfo = Yii::$app->session->getFlash('database-errors');
37+
$errorInfo = $this->getErrorHtml($errorInfo);
38+
return $this->render($this->action->id, [
39+
'errorInfo' => $errorInfo,
40+
'editForm' => $editForm,
41+
]);
42+
}
43+
44+
// 数据库migrate页面
1745
public function actionMigrate()
1846
{
1947
$successInfo = Yii::$app->session->getFlash('database-success');
2048
$successInfo = $this->getSuccessHtml($successInfo);
21-
2249
$errorInfo = Yii::$app->session->getFlash('migrate-errors');
2350
$errorInfo = $this->getErrorHtml($errorInfo);
2451

@@ -31,17 +58,6 @@ public function actionMigrate()
3158
]);
3259
}
3360

34-
public function actionComplete()
35-
{
36-
// 执行 chmod 644 @common/config/main-local
37-
38-
// 删除掉install.php文件
39-
return $this->render($this->action->id, [
40-
]);
41-
42-
}
43-
44-
// 进行测试数据sql的安装和测试图片的复制
4561
public function actionAddtestdata()
4662
{
4763
$errorInfo = Yii::$app->session->getFlash('add-test-errors');
@@ -55,15 +71,14 @@ public function actionAddtestdata()
5571
]);
5672

5773
}
58-
74+
// 进行sql migrate ,产品图片的复制
5975
public function actionAddtestdatainit()
6076
{
6177
// 1. 图片的复制
6278
$sourcePath = dirname(Yii::getAlias('@common')) . '/environments/test_data/appimage';
6379
//$sourcePath = Yii::getAlias('@fectmelani/app/appimage');
6480
$targetPath = Yii::getAlias('@appimage');
6581
$this->copyDir($sourcePath, $targetPath);
66-
6782
// 2. sql文件的执行
6883
$sqlFile = dirname(Yii::getAlias('@common')) . '/environments/test_data/fecshop.sql';
6984
$sqlStr = file_get_contents($sqlFile);
@@ -74,56 +89,40 @@ public function actionAddtestdatainit()
7489
$innerTransaction->commit();
7590
echo json_encode([
7691
'status' => 'success',
77-
]);exit;
92+
]);
7893

94+
exit;
7995
} catch (\Exception $e) {
8096
$innerTransaction->rollBack();
8197
$message = $e->getMessage();
8298
echo json_encode([
8399
'status' => 'fail',
84100
'info' => $message ,
85-
]);exit;
101+
]);
86102

103+
exit;
87104
}
88-
89105
echo json_encode([
90-
'status' => 'fail',
91-
'info' => 'error' ,
92-
]);
106+
'status' => 'fail',
107+
'info' => 'error' ,
108+
]);
109+
93110
exit;
94111
}
95112

96-
97-
98-
// 进行数据库的migrate操作
113+
// 进行数据库的migrate操作(ajax)
99114
public function actionMigrateprocess()
100115
{
101116
$this->runMigrate();
102117
exit;
103118
}
104119

105-
106-
// 安装默认第一步页面
107-
public function actionIndex()
120+
// 完成页面
121+
public function actionComplete()
108122
{
109-
110-
$editForm = Yii::$app->request->post('editForm');
111-
112-
if ($editForm && $this->checkDatabaseData($editForm)
113-
&& $this->updateDatabase($editForm)) {
114-
115-
Yii::$app->session->setFlash('database-success', 'mysql config set success, mysql config file path: @common/config/main-local.php');
116-
// 进行跳转
117-
$homeUrl = Yii::$app->homeUrl;
118-
return $this->redirect($homeUrl.'/database/config/migrate');
119-
}
120-
$errorInfo = Yii::$app->session->getFlash('database-errors');
121-
$errorInfo = $this->getErrorHtml($errorInfo);
122-
return $this->render($this->action->id, [
123-
'errorInfo' => $errorInfo,
124-
'editForm' => $editForm,
125-
]);
123+
return $this->render($this->action->id, []);
126124
}
125+
127126
// 进行数据库的信息的检查,以及将数据库信息写入文件
128127
public function updateDatabase($editForm)
129128
{
@@ -156,13 +155,15 @@ public function updateDatabase($editForm)
156155

157156
return false;
158157
}
158+
// 得到文件的内容
159159
$mainLocalInfo = file_get_contents($mainLocalFile);
160160
//$mainLocalInfo = require($mainLocalFile);
161+
// 进行文件替换
161162
$mainLocalInfo = str_replace('{mysql_host}', $host, $mainLocalInfo);
162163
$mainLocalInfo = str_replace('{mysql_database}', $database, $mainLocalInfo);
163164
$mainLocalInfo = str_replace('{mysql_user}', $user, $mainLocalInfo);
164165
$mainLocalInfo = str_replace('{mysql_password}', $password, $mainLocalInfo);
165-
//var_dump($mainLocalInfo);exit;
166+
// 写入配置文件
166167
if (@file_put_contents($mainLocalFile, $mainLocalInfo) === false) {
167168
$errors = 'Unable to write the file '.$mainLocalFile;
168169
Yii::$app->session->setFlash('database-errors', $errors);
@@ -218,24 +219,27 @@ public function getSuccessHtml($successInfo){
218219
</div>
219220
';
220221
}
222+
221223
return '';
222224
}
223225

224226
public function getErrorHtml($errorInfo){
225227
if ($errorInfo) {
226228
return '
227-
<div class="fecshop_message">
228-
<div class="error-msg">
229-
<div>'. $errorInfo .'</div>
230-
</div>
231-
</div>
229+
<div class="fecshop_message">
230+
<div class="error-msg">
231+
<div>'. $errorInfo .'</div>
232+
</div>
233+
</div>
232234
';
233235
}
234236

235237
return '';
236-
237238
}
238-
239+
/**
240+
* 在yii web环境,执行console中的命令,
241+
* 该函数,相当于执行console命令行 `./yii migrate --interactive=0 --migrationPath=@fecshop/migrations/mysqldb`
242+
*/
239243
public function runMigrate()
240244
{
241245
$oldApp = \Yii::$app;
@@ -246,10 +250,10 @@ public function runMigrate()
246250
'db' => $oldApp->db,
247251
],
248252
]);
249-
$dd = \Yii::$app->runAction('migrate/up', ['migrationPath' => '@fecshop/migrations/mysqldb', 'interactive' => false]);
253+
$runResult = \Yii::$app->runAction('migrate/up', ['migrationPath' => '@fecshop/migrations/mysqldb', 'interactive' => false]);
250254
\Yii::$app = $oldApp;
251255

252-
return $dd ;
256+
return $runResult ;
253257
}
254258

255259
/*
@@ -275,9 +279,8 @@ public function runMigrate()
275279
}
276280
*/
277281

278-
279-
280-
public function dir_mkdir($path = '', $mode = 0777, $recursive = true)
282+
// 创建文件夹,在图片文件复制的过程中使用。
283+
public function dirMkdir($path = '', $mode = 0777, $recursive = true)
281284
{
282285
clearstatcache();
283286
if (!is_dir($path))
@@ -289,7 +292,7 @@ public function dir_mkdir($path = '', $mode = 0777, $recursive = true)
289292
return true;
290293
}
291294
/**
292-
* 文件夹文件拷贝
295+
* 文件夹文件拷贝(递归)
293296
*
294297
* @param string $sourcePath 来源文件夹
295298
* @param string $targetPath 目的地文件夹
@@ -302,9 +305,8 @@ public function copyDir($sourcePath, $targetPath, $isForce = true)
302305
{
303306
return false;
304307
}
305-
306308
$dir = opendir($sourcePath);
307-
$this->dir_mkdir($targetPath);
309+
$this->dirMkdir($targetPath);
308310
while (false !== ($file = readdir($dir)))
309311
{
310312
if (($file != '.') && ($file != '..')) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* FecMall file.
4+
*
5+
* @link http://www.fecmall.com/
6+
* @copyright Copyright (c) 2016 FecMall Software LLC
7+
* @license http://www.fecmall.com/license/
8+
*/
9+
namespace fecshop\app\appinstall\modules\Database\controllers;
10+
11+
use fecshop\app\appfront\modules\AppfrontController;
12+
use Yii;
13+
/**
14+
* @author Terry Zhao <2358269014@qq.com>
15+
* @since 1.0
16+
*/
17+
class ErrorController extends \yii\web\Controller
18+
{
19+
public function actions()
20+
{
21+
return [
22+
'index' => [
23+
'class' => 'yii\web\ErrorAction',
24+
],
25+
//'captcha' => [
26+
// 'class' => 'yii\captcha\CaptchaAction',
27+
// 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
28+
//],
29+
];
30+
}
31+
32+
}

0 commit comments

Comments
 (0)