This repository was archived by the owner on Mar 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.php
176 lines (142 loc) · 5.73 KB
/
plugin.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
namespace Xpressengine\Plugins\GoogleMapTool;
use XeFrontend;
use XePresenter;
use Route;
use Xpressengine\Http\Request;
use Xpressengine\Plugin\AbstractPlugin;
class Plugin extends AbstractPlugin
{
/**
* 이 메소드는 활성화(activate) 된 플러그인이 부트될 때 항상 실행됩니다.
*
* @return void
*/
public function boot()
{
// implement code
$this->route();
}
protected function route()
{
// implement code
Route::fixed(
$this->getId(),
function () {
Route::get(
'/popup/create',
[
'as' => 'google_map_tool::popup',
'uses' => function (Request $request) {
$title = 'google map tool for editor';
// set browser title
XeFrontend::title($title);
// load css file
// XeFrontend::css($this->asset('assets/style.css'))->load();
//header, footer 제거
\XeTheme::selectBlankTheme();
$config = \XeConfig::getOrNew('google_map_tool');
XeFrontend::js([
'http://maps.googleapis.com/maps/api/js?key=' . $config->get('key'),
$this->asset('assets/googleMapRenderer.js?key=' . $config->get('key'))
])->appendTo('head')->load();
// output
return XePresenter::make('google_map_tool::views.popup', ['config' => $config]);
}
]
);
Route::get(
'/popup/edit',
[
'as' => 'google_map_tool::popup.edit',
'uses' => function (Request $request) {
$title = 'google map tool for editor';
// set browser title
XeFrontend::title($title);
// load css file
XeFrontend::css($this->asset('assets/style.css'))->load();
//header, footer 제거
\XeTheme::selectBlankTheme();
$config = \XeConfig::getOrNew('google_map_tool');
XeFrontend::js([
'http://maps.googleapis.com/maps/api/js?key=' . $config->get('key'),
$this->asset('assets/googleMapRenderer.js?key=' . $config->get('key'))
])->appendTo('head')->load();
// output
return XePresenter::make('google_map_tool::views.popup-edit', ['config' => $config]);
}
]
);
}
);
Route::settings($this->getId(), function () {
Route::get('setting', ['as' => 'settings.plugin.google_map_tool.global', 'uses' => 'SettingsController@getGlobal']);
Route::post('setting', ['as' => 'settings.plugin.google_map_tool.global', 'uses' => 'SettingsController@postGlobal']);
Route::get('setting/{instanceId}', ['as' => 'settings.plugin.google_map_tool.setting', 'uses' => 'SettingsController@getSetting']);
Route::post('setting/{instanceId}', ['as' => 'settings.plugin.google_map_tool.setting', 'uses' => 'SettingsController@postSetting']);
}, ['namespace' => __NAMESPACE__]);
}
/**
* 플러그인이 활성화될 때 실행할 코드를 여기에 작성한다.
*
* @param string|null $installedVersion 현재 XpressEngine에 설치된 플러그인의 버전정보
*
* @return void
*/
public function activate($installedVersion = null)
{
// implement code
parent::activate($installedVersion);
}
/**
* 플러그인을 설치한다. 플러그인이 설치될 때 실행할 코드를 여기에 작성한다
*
* @return void
*/
public function install()
{
// implement code
parent::install();
}
/**
* 해당 플러그인이 설치된 상태라면 true, 설치되어있지 않다면 false를 반환한다.
* 이 메소드를 구현하지 않았다면 기본적으로 설치된 상태(true)를 반환한다.
*
* @param string $installedVersion 이 플러그인의 현재 설치된 버전정보
*
* @return boolean 플러그인의 설치 유무
*/
public function checkInstalled($installedVersion = null)
{
// implement code
return parent::checkInstalled($installedVersion);
}
/**
* 플러그인을 업데이트한다.
*
* @param string|null $installedVersion 현재 XpressEngine에 설치된 플러그인의 버전정보
*
* @return void
*/
public function update($installedVersion = null)
{
// implement code
parent::update($installedVersion);
}
/**
* 해당 플러그인이 최신 상태로 업데이트가 된 상태라면 true, 업데이트가 필요한 상태라면 false를 반환함.
* 이 메소드를 구현하지 않았다면 기본적으로 최신업데이트 상태임(true)을 반환함.
*
* @param string $currentVersion 현재 설치된 버전
*
* @return boolean 플러그인의 설치 유무,
*/
public function checkUpdated($currentVersion = null)
{
return true;
}
public function getSettingsURI()
{
return route('settings.plugin.google_map_tool.global');
}
}