Skip to content

Commit d6a31b3

Browse files
author
bnu
committed
Merge branch 'release/1.0.4'
2 parents bb53e84 + 2590fcf commit d6a31b3

6 files changed

Lines changed: 167 additions & 96 deletions

File tree

composer.json

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,53 @@
11
{
2-
"name": "xpressengine-plugin/banner",
3-
"description": "배너 기능 제공 플러그인 입니다.",
4-
"keywords": [
5-
"xpressengine",
6-
"plugin",
7-
"banner",
8-
"widget"
9-
],
10-
"license": "LGPL-3.0-or-later",
11-
"version": "1.0.3",
12-
"type": "xpressengine-plugin",
13-
"support": {
14-
"email": "developers@xpressengine.com"
15-
},
16-
"authors": [
17-
{
18-
"name": "XE Developers",
19-
"email": "developers@xpressengine.com",
20-
"homepage": "https://store.xehub.io/plugins/banner",
21-
"role": "Developer"
22-
}
23-
],
24-
"extra": {
25-
"xpressengine": {
26-
"title": "Banner",
27-
"component": {
28-
"widget/banner@widget": {
29-
"class": "\\Xpressengine\\Plugins\\Banner\\Widgets\\Widget",
30-
"name": "배너 위젯",
31-
"description": "편하고 자유롭게 배너를 편집할 수 있고, 편집한 배너를 위젯으로 어디든 출력할 수 있습니다. 또 원하는 시간을 지정하여 출력할 수 있습니다."
32-
},
33-
"widget/banner@widget/skin/banner@widgetskin": {
34-
"class": "Xpressengine\\Plugins\\Banner\\Skins\\WidgetSkin",
35-
"name": "Banner 기본 위젯 스킨",
36-
"description": "The Skin supported by Banner plugin."
37-
}
38-
}
39-
}
40-
},
41-
"require": {
42-
"xpressengine/xpressengine": "~3.0.2"
43-
},
44-
"autoload": {
45-
"psr-4": {
46-
"Xpressengine\\Plugins\\Banner\\": "src/"
2+
"name": "xpressengine-plugin/banner",
3+
"description": "배너 기능 제공 플러그인 입니다.",
4+
"keywords": [
5+
"xpressengine",
6+
"plugin",
7+
"banner",
8+
"widget"
9+
],
10+
"license": "LGPL-3.0-or-later",
11+
"version": "1.0.4",
12+
"type": "xpressengine-plugin",
13+
"support": {
14+
"email": "developers@xpressengine.com"
15+
},
16+
"authors": [
17+
{
18+
"name": "XE Developers",
19+
"email": "developers@xpressengine.com",
20+
"homepage": "https://store.xehub.io/plugins/banner",
21+
"role": "Developer"
22+
}
23+
],
24+
"extra": {
25+
"xpressengine": {
26+
"title": "Banner",
27+
"icon": "icon.png",
28+
"component": {
29+
"widget/banner@widget": {
30+
"class": "\\Xpressengine\\Plugins\\Banner\\Widgets\\Widget",
31+
"name": "배너 위젯",
32+
"description": "편하고 자유롭게 배너를 편집할 수 있고, 편집한 배너를 위젯으로 어디든 출력할 수 있습니다. 또 원하는 시간을 지정하여 출력할 수 있습니다."
4733
},
48-
"classmap": [
49-
"skins/widget/WidgetSkin.php"
50-
]
34+
"widget/banner@widget/skin/banner@widgetskin": {
35+
"class": "Xpressengine\\Plugins\\Banner\\Skins\\WidgetSkin",
36+
"name": "Banner 기본 위젯 스킨",
37+
"description": "The Skin supported by Banner plugin."
38+
}
39+
}
5140
}
41+
},
42+
"require": {
43+
"xpressengine/xpressengine": "~3.0.9"
44+
},
45+
"autoload": {
46+
"psr-4": {
47+
"Xpressengine\\Plugins\\Banner\\": "src/"
48+
},
49+
"classmap": [
50+
"skins/widget/WidgetSkin.php"
51+
]
52+
}
5253
}

plugin.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ function() {
8181
Route::get('/', [
8282
'as' => 'banner::group.index',
8383
'uses' => 'GroupController@index',
84+
'settings_menu' => 'contents.banner',
8485
]);
8586

8687
// 그룹 생성 페이지
@@ -160,6 +161,19 @@ function () {
160161
}
161162
);
162163
});
164+
165+
// settings menu 등록
166+
$menus = [
167+
'contents.banner' => [
168+
'title' => '배너',
169+
'display' => true,
170+
'description' => '',
171+
'ordering' => 6000
172+
],
173+
];
174+
foreach ($menus as $id => $menu) {
175+
app('xe.register')->push('settings/menu', $id, $menu);
176+
}
163177
}
164178

165179
/**

src/Handler.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ public function getGroups()
112112
return Group::get();
113113
}
114114

115+
/**
116+
* get groups by skin
117+
*
118+
* @return mixed
119+
*/
120+
public function getGroupsBySkin($skin)
121+
{
122+
return Group::where('skin', $skin)->get();
123+
}
124+
115125
/**
116126
* create item
117127
*

src/Widgets/Widget.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ class Widget extends AbstractWidget
3838
*/
3939
public function render()
4040
{
41+
$widgetConfig = $this->setting();
42+
4143
$setting = $this->setting();
44+
$title = $setting['@attributes']['title'];
4245
$group_id = array_get($setting, 'group_id');
4346

4447
$group = app('xe.banner')->getGroup($group_id);
45-
4648
if ($group == null) {
4749
return '';
4850
}
@@ -56,7 +58,8 @@ public function render()
5658
// 경우에 따라 버튼의 스타일이 다르게 표현되어 디자인이 깨지는 현상으로 인해 주석처리
5759
// $footer = '<div style="position:relative;top:-30px;text-align:right"><a class="xe-btn xe-btn-xs xe-btn-primary-outline" href="'.route('banner::group.edit',['group_id' => $group->id]).'" onclick="window.open(this.href, \'bannerEditor\', \'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no\');return false">배너편집</a></div>';
5860
}
59-
return $this->renderSkin(compact('group', 'items')) . $footer;
61+
62+
return $this->renderSkin(compact('title', 'group', 'items', 'widgetConfig')) . $footer;
6063
}
6164

6265
/**
@@ -68,7 +71,12 @@ public function render()
6871
*/
6972
public function renderSetting(array $args = [])
7073
{
71-
$groups = app('xe.banner')->getGroups();
74+
// $groups = app('xe.banner')->getGroups();
75+
$selectedSkinId = app('request')->get('skin');
76+
if ($selectedSkinId == '') {
77+
$selectedSkinId = array_get($args, '@attributes.skin-id');
78+
}
79+
$groups = app('xe.banner')->getGroupsBySkin($selectedSkinId);
7280
return view(Plugin::view('views.widget.setting'), compact('groups', 'args'));
7381
}
7482
}

views/settings/group/index.blade.php

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,54 @@
22
<h2><a href="{{ route('banner::group.index') }}"><i class="xi-arrow-left"></i>배너 목록</a></h2>
33
@stop
44

5-
<div class="row">
6-
<div class="col-sm-12">
7-
<div class="panel-group">
8-
<div class="panel">
9-
<div class="panel-heading">
10-
<div class="pull-left">
11-
<h3 class="panel-title">
12-
생성된 배너 목록
13-
</h3>
5+
<div class="container-fluid container-fluid--part">
6+
<div class="row">
7+
<div class="col-sm-12">
8+
<div class="panel-group">
9+
<div class="panel">
10+
<div class="panel-heading">
11+
<div class="pull-left">
12+
<h3 class="panel-title">
13+
생성된 배너 목록
14+
</h3>
15+
</div>
16+
<div class="pull-right">
17+
<a href="{{ route('banner::group.create') }}" class="xe-btn xe-btn-primary" data-toggle="xe-page-modal">새 배너 생성</a>
18+
</div>
1419
</div>
15-
<div class="pull-right">
16-
<a href="{{ route('banner::group.create') }}" class="xe-btn xe-btn-primary" data-toggle="xe-page-modal">새 배너 생성</a>
17-
</div>
18-
</div>
19-
<div class="table-responsive">
20-
<table class="table">
21-
<thead>
22-
<tr>
23-
<th scope="col">제목</th>
24-
<th scope="col">아이템수</th>
25-
<th scope="col">생성일</th>
26-
<th scope="col">관리</th>
27-
</tr>
28-
</thead>
29-
<tbody>
30-
@foreach($groups as $group)
20+
<div class="table-responsive">
21+
<table class="table">
22+
<thead>
3123
<tr>
32-
<td>{{ $group->title }}</td>
33-
<td>{{ $group->count }}</td>
34-
<td>{{ $group->created_at->format('Y.m.d H:i:s') }}</td>
35-
<td>
36-
<a class="xe-btn xe-btn-xs xe-btn-default" onclick="window.open(this.href, 'bannerEditor', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');return false" href="{{ route('banner::group.edit', ['group_id' => $group->id]) }}">편집</a>
37-
<a class="xe-btn xe-btn-default xe-btn-xs" role="button" data-toggle="collapse" href="#widget-code-{{ $group->id }}">
38-
위젯코드
39-
</a>
40-
<a class="xe-btn xe-btn-default xe-btn-xs" href="{{ route('banner::group.update', ['group_id' => $group->id]) }}" role="button" data-toggle="xe-page-modal">설정</a>
41-
</td>
24+
<th scope="col">제목</th>
25+
<th scope="col">아이템수</th>
26+
<th scope="col">생성일</th>
27+
<th scope="col">관리</th>
4228
</tr>
43-
<tr id="widget-code-{{ $group->id }}" class="collapse">
44-
<td colspan="4" class="">
45-
<div class="well">{{ $group->getWidgetCode() }}</div>
46-
</td>
47-
</tr>
48-
@endforeach
49-
</tbody>
50-
</table>
29+
</thead>
30+
<tbody>
31+
@foreach($groups as $group)
32+
<tr>
33+
<td>{{ $group->title }}</td>
34+
<td>{{ $group->count }}</td>
35+
<td>{{ $group->created_at->format('Y.m.d H:i:s') }}</td>
36+
<td>
37+
<a class="xe-btn xe-btn-xs xe-btn-default" onclick="window.open(this.href, 'bannerEditor', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');return false" href="{{ route('banner::group.edit', ['group_id' => $group->id]) }}">편집</a>
38+
<a class="xe-btn xe-btn-default xe-btn-xs" role="button" data-toggle="collapse" href="#widget-code-{{ $group->id }}">
39+
위젯코드
40+
</a>
41+
<a class="xe-btn xe-btn-default xe-btn-xs" href="{{ route('banner::group.update', ['group_id' => $group->id]) }}" role="button" data-toggle="xe-page-modal">설정</a>
42+
</td>
43+
</tr>
44+
<tr id="widget-code-{{ $group->id }}" class="collapse">
45+
<td colspan="4" class="">
46+
<div class="well">{{ $group->getWidgetCode() }}</div>
47+
</td>
48+
</tr>
49+
@endforeach
50+
</tbody>
51+
</table>
52+
</div>
5153
</div>
5254
</div>
5355
</div>

views/widget/setting.blade.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,46 @@
11
<div class="form-group">
22
<label class="">배너 선택</label>
3-
<select class="form-control __xe_select_group" name="group_id">
3+
<select class="form-control __xe_select_group __xe_widget_banner_select_group" name="group_id">
4+
<option value="">선택하세요</option>
45
@foreach($groups as $group)
56
<option @if($group->id === array_get($args, 'group_id')) selected="selected" @endif value="{{ $group->id }}" data-url="{{ route('banner::group.edit', ['group_id' => $group->id]) }}">{{ $group->title }}</option>
67
@endforeach
78
</select>
8-
</div>
99
<p class="help-block"></p>
10+
11+
<div>
12+
<a class="xe-btn xe-btn-secondary banner_group_setting" >배너 관리</a>
13+
<a class="xe-btn xe-btn-primary" href="{{ route('banner::group.index') }}" target="_blank">배너 관리 페이지 이동</a>
14+
{{--<a class="xe-btn xe-btn-primary" href="{{ route('banner::group.create') }}" data-toggle="xe-page-modal">배너 추가</a>--}}
15+
</div>
1016
</div>
17+
18+
<script>
19+
$(function () {
20+
$('.__xe_widget_banner_select_group').on('change', function (e) {
21+
var bannerGroupId = getSelectedBannerGroupId();
22+
});
23+
24+
$('.banner_group_setting').on('click', function (e) {
25+
var bannerGroupId = getSelectedBannerGroupId();
26+
if (bannerGroupId == '') {
27+
alert('선택된 배너가 없습니다.');
28+
} else {
29+
var href = $('.__xe_widget_banner_select_group').find('option[value="' + bannerGroupId + '"]').data('url');
30+
window.open(href, 'bannerEditor', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');
31+
return;
32+
}
33+
});
34+
35+
function getSelectedBannerGroupId()
36+
{
37+
var bannerGroupId = $('.__xe_widget_banner_select_group').find('option:selected').val();
38+
if (bannerGroupId == undefined) {
39+
bannerGroupId == '';
40+
}
41+
42+
return bannerGroupId;
43+
}
44+
45+
});
46+
</script>

0 commit comments

Comments
 (0)