-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathServiceProvider.php
128 lines (113 loc) · 3.5 KB
/
ServiceProvider.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
namespace Acms\Plugins\Base;
use ACMS_App;
use App;
use Config;
use Acms\Services\Common\InjectTemplate;
class ServiceProvider extends ACMS_App
{
public $version = '1.0.1';
public $name = 'The BASE';
public $author = 'com.appleple';
public $module = false;
public $menu = 'base_index';
public $desc = 'The BASEと連携するためのモジュールを提供します。';
private $installTable = array(
'base_api',
);
/**
* サービスの起動処理
*/
public function init()
{
$inject = InjectTemplate::singleton();
if (ADMIN === 'app_base_index') {
$inject->add('admin-topicpath', PLUGIN_DIR . 'Base/theme/topicpath.html');
$inject->add('admin-main', PLUGIN_DIR . 'Base/theme/index.html');
}
$inject->add('admin-module-config-Base_Items', PLUGIN_DIR . 'Base/theme/items_body.html');
$inject->add('admin-module-config-Base_Detail', PLUGIN_DIR . 'Base/theme/detail_body.html');
$inject->add('admin-module-config-Base_Search', PLUGIN_DIR . 'Base/theme/search_body.html');
$inject->add('admin-module-select', PLUGIN_DIR . 'Base/theme/select.user.html');
App::singleton('app-the-base-config', function () {
$config = Config::loadDefaultField();
$config->overload(Config::loadBlogConfig(BID));
return $config;
});
}
/**
* インストールする前の環境チェック処理
*
* @return bool
*/
public function checkRequirements()
{
return true;
}
/**
* インストールするときの処理
* データベーステーブルの初期化など
*
* @return void
*/
public function install()
{
//------------
// テーブル削除
dbDropTables($this->installTable);
//---------------------
// テーブルデータ読み込み
$yamlTable = preg_replace('/%{PREFIX}/', DB_PREFIX, file_get_contents(dirname(__FILE__).'/db/schema.yaml'));
$tablesData = Config::yamlParse($yamlTable);
if ( !is_array($tablesData) ) $tablesData = array();
if ( !empty($tablesData[0]) ) unset($tablesData[0]);
$tableList = array_merge(array_diff(array_keys($tablesData), array('')));
$yamlIndex = preg_replace('/%{PREFIX}/', DB_PREFIX, file_get_contents(dirname(__FILE__).'/db/index.yaml'));
$indexData = Config::yamlParse($yamlIndex);
if ( !is_array($indexData) ) $indexData = array();
if ( !empty($indexData[0]) ) unset($indexData[0]);
//---------------
// テーブル作成
foreach ( $tableList as $tb ) {
$index = isset($indexData[$tb]) ? $indexData[$tb] : null;
dbCreateTables($tb, $tablesData[$tb], $index);
}
}
/**
* アンインストールするときの処理
* データベーステーブルの始末など
*
* @return void
*/
public function uninstall()
{
dbDropTables($this->installTable);
}
/**
* アップデートするときの処理
*
* @return bool
*/
public function update()
{
return true;
}
/**
* 有効化するときの処理
*
* @return bool
*/
public function activate()
{
return true;
}
/**
* 無効化するときの処理
*
* @return bool
*/
public function deactivate()
{
return true;
}
}