Skip to content

Commit

Permalink
검색에 대한 위젯 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
xharpenParksuhyeon committed Aug 23, 2021
1 parent 4728cd3 commit 0d6d8d3
Show file tree
Hide file tree
Showing 8 changed files with 418 additions and 243 deletions.
75 changes: 75 additions & 0 deletions components/Widgets/Searching/SearchingWidget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace Xpressengine\Plugins\Board\Components\Widgets\Searching;

use View;
use Illuminate\Support\Arr;
use Xpressengine\Menu\Models\MenuItem;
use Xpressengine\Plugin\SupportInfoTrait;;
use Xpressengine\Plugins\Board\ConfigHandler;
use Xpressengine\Plugins\Board\UrlHandler;
use Xpressengine\Widget\AbstractWidget;

class SearchingWidget extends AbstractWidget
{
use SupportInfoTrait;

protected static $path = 'board/components/Widgets/Searching';

/**
* 그려줄 내용 반환.
*
* @return string
*/
public function render()
{
/** @var UrlHandler $urlHandler */
$urlHandler = app(UrlHandler::class);
$widgetConfig = $this->setting();
$boardId = Arr::get($widgetConfig, 'board_id');
$boardMenuItem = MenuItem::where('type', 'board@board')->findOrFail($boardId);
$boardConfig = ConfigHandler::make()->get($boardMenuItem->id);

return $this->renderSkin([
'urlHandler' => $urlHandler,
'widgetConfig' => $widgetConfig,
'boardMenuItem' => $boardMenuItem,
'boardConfig' => $boardConfig
]);
}

/**
* render settings
*
* @param array $args
* @return string
*/
public function renderSetting(array $args = []): string
{
$boards = $this->getBoards();

return View::make('board::components.Widgets.Searching.views.settings', [
'args' => $args,
'boards' => $boards
]);
}

/**
* get boards
*
* @return array
*/
protected function getBoards(): array
{
return MenuItem::where('type', 'board@board')
->where('activated', true)
->get()
->map(function(MenuItem $menuItem) {
return [
'id' => $menuItem->id,
'text' => $menuItem->title,
];
})
->toArray();
}
}
15 changes: 15 additions & 0 deletions components/Widgets/Searching/Skins/Basic/BasicSearchingSkin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Xpressengine\Plugins\Board\Components\Widgets\Searching\Skins\Basic;

use Xpressengine\Skin\GenericSkin;

class BasicSearchingSkin extends GenericSkin
{
protected static $path = 'board/components/Widgets/Searching/Skins/Basic';

public function render()
{
return parent::render(); // TODO: Change the autogenerated stub
}
}
39 changes: 39 additions & 0 deletions components/Widgets/Searching/Skins/Basic/assets/css/skin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
body {
padding-top: 20px;
padding-bottom: 20px;
}

.header,
.footer {
padding-right: 15px;
padding-left: 15px;
}

.header {
padding-bottom: 20px;
margin-bottom: 30px;
border-bottom: 1px solid #e5e5e5;
}

.header h3 {
margin-top: 0;
margin-bottom: 0;
line-height: 40px;
font-size: 24px;
}

.footer {
padding-top: 19px;
color: #777;
border-top: 1px solid #e5e5e5;
}

.spot {
text-align: center;
color: inherit;
padding: 48px 30px;
border-radius: 6px;
border-bottom: 1px solid #e5e5e5;
margin-bottom: 30px;
background-color: #eee;
}
8 changes: 8 additions & 0 deletions components/Widgets/Searching/Skins/Basic/info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
return [
'setting' => [],
'support' => [
'mobile' => true,
'desktop' => true
]
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{-- implement it!! --}}
{{--{{ dd($widgetConfig) }}--}}
{{--{{ dd($moreUrl) }}--}}
13 changes: 13 additions & 0 deletions components/Widgets/Searching/info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

return [
'setting' => [
'sample_text2' => [
'_type' => 'text',
'_section' => '기본설정',
'label' => '샘플 문구',
'placeholder' => '샘플용 설정 필드입니다.',
'description' => '샘플용 설정 필드입니다.',
],
]
];
8 changes: 8 additions & 0 deletions components/Widgets/Searching/views/settings.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="form-group">
<label>게시판 선택</label>
<select name="board_id" class="form-control">
@foreach ($boards as $board)
<option value="{{ $board['id'] }}" @if(in_array($board['id'], (array)(\Illuminate\Support\Arr::get($args, 'board_id')))) selected="selected" @endif>{{ xe_trans($board['text']) }}</option>
@endforeach
</select>
</div>
Loading

0 comments on commit 0d6d8d3

Please sign in to comment.