mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-08 07:40:17 +08:00
Refactored search-based code to its own folder
Also applied StyleCI changes
This commit is contained in:
parent
2b06e86d53
commit
837fd74bf6
@ -74,9 +74,8 @@ class PermissionApplicator
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($chain as $currentEntity) {
|
foreach ($chain as $currentEntity) {
|
||||||
|
|
||||||
if (is_null($currentEntity->restricted)) {
|
if (is_null($currentEntity->restricted)) {
|
||||||
throw new InvalidArgumentException("Entity restricted field used but has not been loaded");
|
throw new InvalidArgumentException('Entity restricted field used but has not been loaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($currentEntity->restricted) {
|
if ($currentEntity->restricted) {
|
||||||
|
@ -249,6 +249,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->avatarUrl = $avatar;
|
$this->avatarUrl = $avatar;
|
||||||
|
|
||||||
return $avatar;
|
return $avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace BookStack\Console\Commands;
|
namespace BookStack\Console\Commands;
|
||||||
|
|
||||||
use BookStack\Entities\Models\Entity;
|
use BookStack\Entities\Models\Entity;
|
||||||
use BookStack\Entities\Tools\SearchIndex;
|
use BookStack\Search\SearchIndex;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ use BookStack\Auth\Permissions\EntityPermission;
|
|||||||
use BookStack\Auth\Permissions\JointPermission;
|
use BookStack\Auth\Permissions\JointPermission;
|
||||||
use BookStack\Auth\Permissions\JointPermissionBuilder;
|
use BookStack\Auth\Permissions\JointPermissionBuilder;
|
||||||
use BookStack\Auth\Permissions\PermissionApplicator;
|
use BookStack\Auth\Permissions\PermissionApplicator;
|
||||||
use BookStack\Entities\Tools\SearchIndex;
|
|
||||||
use BookStack\Entities\Tools\SlugGenerator;
|
use BookStack\Entities\Tools\SlugGenerator;
|
||||||
use BookStack\Interfaces\Deletable;
|
use BookStack\Interfaces\Deletable;
|
||||||
use BookStack\Interfaces\Favouritable;
|
use BookStack\Interfaces\Favouritable;
|
||||||
@ -19,6 +18,8 @@ use BookStack\Interfaces\Loggable;
|
|||||||
use BookStack\Interfaces\Sluggable;
|
use BookStack\Interfaces\Sluggable;
|
||||||
use BookStack\Interfaces\Viewable;
|
use BookStack\Interfaces\Viewable;
|
||||||
use BookStack\Model;
|
use BookStack\Model;
|
||||||
|
use BookStack\Search\SearchIndex;
|
||||||
|
use BookStack\Search\SearchTerm;
|
||||||
use BookStack\Traits\HasCreatorAndUpdater;
|
use BookStack\Traits\HasCreatorAndUpdater;
|
||||||
use BookStack\Traits\HasOwner;
|
use BookStack\Traits\HasOwner;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
namespace BookStack\Http\Controllers\Api;
|
namespace BookStack\Http\Controllers\Api;
|
||||||
|
|
||||||
use BookStack\Entities\Models\Entity;
|
use BookStack\Entities\Models\Entity;
|
||||||
use BookStack\Entities\Tools\SearchOptions;
|
use BookStack\Search\SearchOptions;
|
||||||
use BookStack\Entities\Tools\SearchResultsFormatter;
|
use BookStack\Search\SearchResultsFormatter;
|
||||||
use BookStack\Entities\Tools\SearchRunner;
|
use BookStack\Search\SearchRunner;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class SearchApiController extends ApiController
|
class SearchApiController extends ApiController
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
namespace BookStack\Http\Controllers;
|
namespace BookStack\Http\Controllers;
|
||||||
|
|
||||||
use BookStack\Entities\Queries\Popular;
|
use BookStack\Entities\Queries\Popular;
|
||||||
use BookStack\Entities\Tools\SearchOptions;
|
|
||||||
use BookStack\Entities\Tools\SearchResultsFormatter;
|
|
||||||
use BookStack\Entities\Tools\SearchRunner;
|
|
||||||
use BookStack\Entities\Tools\SiblingFetcher;
|
use BookStack\Entities\Tools\SiblingFetcher;
|
||||||
|
use BookStack\Search\SearchOptions;
|
||||||
|
use BookStack\Search\SearchResultsFormatter;
|
||||||
|
use BookStack\Search\SearchRunner;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class SearchController extends Controller
|
class SearchController extends Controller
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace BookStack\Entities\Tools;
|
namespace BookStack\Search;
|
||||||
|
|
||||||
use BookStack\Actions\Tag;
|
use BookStack\Actions\Tag;
|
||||||
use BookStack\Entities\EntityProvider;
|
use BookStack\Entities\EntityProvider;
|
||||||
use BookStack\Entities\Models\Entity;
|
use BookStack\Entities\Models\Entity;
|
||||||
use BookStack\Entities\Models\Page;
|
use BookStack\Entities\Models\Page;
|
||||||
use BookStack\Entities\Models\SearchTerm;
|
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use DOMNode;
|
use DOMNode;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
@ -1,30 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace BookStack\Entities\Tools;
|
namespace BookStack\Search;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class SearchOptions
|
class SearchOptions
|
||||||
{
|
{
|
||||||
/**
|
public array $searches = [];
|
||||||
* @var array
|
public array $exacts = [];
|
||||||
*/
|
public array $tags = [];
|
||||||
public $searches = [];
|
public array $filters = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $exacts = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $tags = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $filters = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance from a search string.
|
* Create a new instance from a search string.
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace BookStack\Entities\Tools;
|
namespace BookStack\Search;
|
||||||
|
|
||||||
use BookStack\Actions\Tag;
|
use BookStack\Actions\Tag;
|
||||||
use BookStack\Entities\Models\Entity;
|
use BookStack\Entities\Models\Entity;
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace BookStack\Entities\Tools;
|
namespace BookStack\Search;
|
||||||
|
|
||||||
use BookStack\Auth\Permissions\PermissionApplicator;
|
use BookStack\Auth\Permissions\PermissionApplicator;
|
||||||
use BookStack\Auth\User;
|
use BookStack\Auth\User;
|
||||||
@ -8,7 +8,6 @@ use BookStack\Entities\EntityProvider;
|
|||||||
use BookStack\Entities\Models\BookChild;
|
use BookStack\Entities\Models\BookChild;
|
||||||
use BookStack\Entities\Models\Entity;
|
use BookStack\Entities\Models\Entity;
|
||||||
use BookStack\Entities\Models\Page;
|
use BookStack\Entities\Models\Page;
|
||||||
use BookStack\Entities\Models\SearchTerm;
|
|
||||||
use Illuminate\Database\Connection;
|
use Illuminate\Database\Connection;
|
||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||||
@ -29,7 +28,7 @@ class SearchRunner
|
|||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $queryOperators = ['<=', '>=', '=', '<', '>', 'like', '!='];
|
protected array $queryOperators = ['<=', '>=', '=', '<', '>', 'like', '!='];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retain a cache of score adjusted terms for specific search options.
|
* Retain a cache of score adjusted terms for specific search options.
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace BookStack\Entities\Models;
|
namespace BookStack\Search;
|
||||||
|
|
||||||
use BookStack\Model;
|
use BookStack\Model;
|
||||||
|
|
@ -10,7 +10,7 @@ use BookStack\Auth\User;
|
|||||||
use BookStack\Entities\Models\Bookshelf;
|
use BookStack\Entities\Models\Bookshelf;
|
||||||
use BookStack\Entities\Models\Chapter;
|
use BookStack\Entities\Models\Chapter;
|
||||||
use BookStack\Entities\Models\Page;
|
use BookStack\Entities\Models\Page;
|
||||||
use BookStack\Entities\Tools\SearchIndex;
|
use BookStack\Search\SearchIndex;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
@ -8,7 +8,7 @@ use BookStack\Auth\User;
|
|||||||
use BookStack\Entities\Models\Book;
|
use BookStack\Entities\Models\Book;
|
||||||
use BookStack\Entities\Models\Chapter;
|
use BookStack\Entities\Models\Chapter;
|
||||||
use BookStack\Entities\Models\Page;
|
use BookStack\Entities\Models\Page;
|
||||||
use BookStack\Entities\Tools\SearchIndex;
|
use BookStack\Search\SearchIndex;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Entity;
|
namespace Tests\Entity;
|
||||||
|
|
||||||
use BookStack\Entities\Tools\SearchOptions;
|
use BookStack\Search\SearchOptions;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class SearchOptionsTest extends TestCase
|
class SearchOptionsTest extends TestCase
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace Tests;
|
<?php
|
||||||
|
|
||||||
|
namespace Tests;
|
||||||
|
|
||||||
use BookStack\Actions\Favourite;
|
use BookStack\Actions\Favourite;
|
||||||
use BookStack\Auth\User;
|
use BookStack\Auth\User;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user