-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatesetup.php.tpl
More file actions
54 lines (47 loc) · 2 KB
/
createsetup.php.tpl
File metadata and controls
54 lines (47 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace {=$namespace}\setup;
use org\jecat\framework\db\DB ;
use org\jecat\framework\message\Message;
use org\jecat\framework\message\MessageQueue;
use org\opencomb\platform\ext\Extension;
use org\opencomb\platform\ext\ExtensionMetainfo ;
use org\opencomb\platform\ext\IExtensionDataInstaller ;
class DataInstaller implements IExtensionDataInstaller
{
public function install(MessageQueue $aMessageQueue,ExtensionMetainfo $aMetainfo)
{
$aExtension = new Extension($aMetainfo);
// 1 . create data table
<foreach for="$arrTableInfoList" item="tableinfo">
DB::singleton()->execute( "{=$tableinfo['Create Table']}" );
$aMessageQueue->create(Message::success,'新建数据表: %s',"{=$tableinfo['Table']}");
</foreach>
// 2. insert table data<clear />
<foreach for="$arrTableInfoList" item="tableinfo"><clear />
<if "!empty($tableinfo['keys'])"><clear />
$nDataRows = 0 ;<clear />
<foreach for="$tableinfo['data']" item='arrRowData'>
$nDataRows+= DB::singleton()->execute( "REPLACE INTO `{=$tableinfo['Table']}` ({=implode(',',$tableinfo['keys'])}) VALUES ({=implode(',',$tableinfo['factors'])}) ", array({=implode(',',$arrRowData)}) ) ;<clear />
</foreach>
$aMessageQueue->create(Message::success,'向数据表%s插入了%d行记录。',array("{=$tableinfo['Table']}",$nDataRows));
</if>
</foreach>
// 3. settings
<if '!empty($setting)' >
$aSetting = $aExtension->setting() ;
<foreach for="$setting" key='path' item="items">
<foreach for="$items" key='item' item='value'>
$aSetting->setItem('{=$path}','{=$item}',{=var_export($value,true)});
</foreach>
$aMessageQueue->create(Message::success,'保存配置:%s',"{=$path}");
</foreach>
</if>
// 4. files
<if '!empty($dataFolder)' >
// $sDataFolder = '{=$dataFolder}';
// $sToFolder = $aExtension ->filesFolder()->path();
// Folder::singleton()->copy($sDataFolder,$sToFolder);
// $aMessageQueue->create(Message::success,'复制文件夹: `%s` to `%s`',array($sDataFolder,$sToFolder));
</if>
}
}