-
-
Notifications
You must be signed in to change notification settings - Fork 8
[サイト内検索] 隠しページ(ページ管理>メニュー非表示のページ)は検索に含めない設定を追加 #2386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,7 +163,7 @@ private function searchContents($request, $searchs_frame, $method = null, $narro | |
|
|
||
| // 各プラグインのSQL をUNION | ||
| // 公開されているページ、フレームを検索対象とする | ||
| $searchable_page_ids = $this->fetchSearchablePageIds($request); | ||
| $searchable_page_ids = $this->fetchSearchablePageIds($request, $searchs_frame); | ||
| $searchable_frame_ids = Frame::visible()->get()->pluck('id'); | ||
|
|
||
| foreach ($union_sqls as $union_sql) { | ||
|
|
@@ -427,6 +427,7 @@ public function saveBuckets($request, $page_id, $frame_id, $id = null) | |
| $searchs->frame_select = intval($request->frame_select); | ||
| $searchs->target_frame_ids = empty($request->target_frame_ids) ? "": implode(',', $request->target_frame_ids); | ||
| $searchs->recieve_keyword = intval($request->recieve_keyword); | ||
| $searchs->page_select = intval($request->page_select); | ||
|
|
||
| // データ保存 | ||
| $searchs->save(); | ||
|
|
@@ -474,9 +475,28 @@ public function changeBuckets($request, $page_id = null, $frame_id = null, $id = | |
| /** | ||
| * 検索対象のページIDを取得する | ||
| */ | ||
| private function fetchSearchablePageIds($request) | ||
| private function fetchSearchablePageIds($request, $searchs_frame) | ||
| { | ||
| $pages = Page::get(); | ||
|
|
||
| // ページの選択「ページ管理のメニュー表示条件に従う」 | ||
| if ($searchs_frame->page_select == 1) { | ||
|
|
||
| // 表示ページのみに絞る | ||
| $pages = $pages->filter(function ($page) { | ||
| return $page->base_display_flag == 1; | ||
| }); | ||
|
|
||
| // フレームの選択「選択したものだけ表示する」 | ||
| if ($searchs_frame->frame_select == 1) { | ||
| // 選択したフレームに紐づくページ を追加取得してマージ | ||
| $frame_page_ids = Frame::whereIn('frames.id', explode(',', $searchs_frame->target_frame_ids))->get()->pluck('page_id')->toArray(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. イコール演算子の右側にスペースが2つ続いています。 |
||
| $pages_frame = Page::whereIn('pages.id', $frame_page_ids)->get(); | ||
|
Comment on lines
+493
to
+494
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2回のDBクエリを1回に統合できそうです。 |
||
|
|
||
| $pages = $pages->merge($pages_frame)->unique('id'); | ||
| } | ||
| } | ||
|
Comment on lines
480
to
+498
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 下記部分はSQLにした方が走査処理としては効率的かと思いましたが、いかがでしょう? 全体を示すと下記のようなコードを想定しています。 |
||
|
|
||
| // 見れないページ除外 | ||
| $visible_page_ids = []; | ||
| foreach ($pages as $page) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| class AddSelectPageFromSearchs extends Migration | ||
| { | ||
| /** | ||
| * Run the migrations. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function up() | ||
| { | ||
| Schema::table('searchs', function (Blueprint $table) { | ||
| $table->integer('page_select')->default(0)->comment('ページの選択フラグ')->after('recieve_keyword'); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Reverse the migrations. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function down() | ||
| { | ||
| Schema::table('searchs', function (Blueprint $table) { | ||
| $table->dropColumn('page_select'); | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
マジックナンバーがコントローラ/viewに散在してしまっているので、enum定数化をお願いすること可能でしょうか?