1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Firesphere\SolrSearch\Admins; |
4
|
|
|
|
5
|
|
|
use Firesphere\SolrSearch\Models\DirtyClass; |
6
|
|
|
use Firesphere\SolrSearch\Models\ElevatedItem; |
7
|
|
|
use Firesphere\SolrSearch\Models\Elevation; |
8
|
|
|
use Firesphere\SolrSearch\Models\SolrLog; |
9
|
|
|
use SilverStripe\Admin\ModelAdmin; |
10
|
|
|
use SilverStripe\Forms\GridField\GridField; |
11
|
|
|
use SilverStripe\View\Requirements; |
12
|
|
|
use Symbiote\GridFieldExtensions\GridFieldOrderableRows; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class \Firesphere\SolrSearch\Admins\SearchAdmin |
16
|
|
|
* Manage or see the Solr configuration. Default implementation of SilverStripe ModelAdmin |
17
|
|
|
* Nothing to see here |
18
|
|
|
* |
19
|
|
|
* @package Firesphere\SolrSearch\Admins |
20
|
|
|
*/ |
21
|
|
|
class SearchAdmin extends ModelAdmin |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Models managed by this admin |
25
|
|
|
* |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
private static $managed_models = [ |
29
|
|
|
SolrLog::class, |
30
|
|
|
DirtyClass::class, |
31
|
|
|
Elevation::class, |
32
|
|
|
ElevatedItem::class, |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Add a pretty magnifying glass to the sidebar menu |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private static $menu_icon_class = 'font-icon-search'; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Where to find me |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
private static $url_segment = 'searchadmin'; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* My name |
51
|
|
|
* |
52
|
|
|
* @var string |
53
|
1 |
|
*/ |
54
|
|
|
private static $menu_title = 'Search'; |
55
|
1 |
|
|
56
|
|
|
/** |
57
|
1 |
|
* Make sure the custom CSS for highlighting in the GridField is loaded |
58
|
1 |
|
*/ |
59
|
|
|
public function init() |
60
|
|
|
{ |
61
|
|
|
parent::init(); |
62
|
|
|
|
63
|
|
|
//Requirements::css('firesphere/solr-search:client/dist/main.css'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getEditForm($id = null, $fields = null) |
67
|
|
|
{ |
68
|
|
|
$oldImportFrom = $this->showImportForm; |
69
|
|
|
$this->showImportForm = false; |
70
|
|
|
/** @var GridField $gridField */ |
71
|
|
|
$form = parent::getEditForm($id, $fields); |
72
|
|
|
$this->showImportForm = $oldImportFrom; |
73
|
|
|
|
74
|
|
|
if ($this->modelClass === ElevatedItem::class) { |
75
|
|
|
$gridField = $form->Fields()->dataFieldByName($this->sanitiseClassName($this->modelClass)); |
76
|
|
|
|
77
|
|
|
$gridField |
78
|
|
|
->getConfig() |
79
|
|
|
->addComponent(new GridFieldOrderableRows('Rank')); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $form; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|