/
SearchProvider.php
149 lines (132 loc) · 3.58 KB
/
SearchProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
namespace Concrete\Core\File\Search;
use Concrete\Core\Attribute\Category\FileCategory;
use Concrete\Core\Entity\Search\SavedFileSearch;
use Concrete\Core\File\FileList;
use Concrete\Core\File\Filesystem;
use Concrete\Core\File\FolderItemList;
use Concrete\Core\File\Search\ColumnSet\DefaultSet;
use Concrete\Core\File\Search\Result\Result;
use Concrete\Core\File\Search\ColumnSet\Available;
use Concrete\Core\File\Search\ColumnSet\ColumnSet;
use Concrete\Core\Search\AbstractSearchProvider;
use Concrete\Core\Search\Field\ManagerFactory;
use Concrete\Core\Search\StickyRequest;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Tree\Node\Node;
use Concrete\Core\Tree\Node\Type\SearchPreset;
use Symfony\Component\HttpFoundation\Session\Session;
class SearchProvider extends AbstractSearchProvider
{
public function getFieldManager()
{
return ManagerFactory::get('file');
}
/**
* @var \Concrete\Core\Attribute\Category\FileCategory
*/
protected $category;
/**
* @var Filesystem
*/
protected $filesystem;
/**
* @return string
*/
public function getSessionNamespace()
{
return 'file';
}
public function __construct(Filesystem $filesystem, FileCategory $category, Session $session)
{
$this->category = $category;
$this->filesystem = $filesystem;
parent::__construct($session);
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Attribute\Category\AbstractCategory::getCustomAttributeKeys()
*/
public function getCustomAttributeKeys()
{
return $this->category->getSearchableList();
}
/**
* @return \Concrete\Core\File\Search\ColumnSet\Available
*/
public function getAvailableColumnSet()
{
return new Available();
}
/**
* @return string
*/
public function getCurrentColumnSet()
{
return ColumnSet::getCurrent();
}
/**
* @return \Concrete\Core\File\Search\ColumnSet\ColumnSet
*/
public function getBaseColumnSet()
{
return new ColumnSet();
}
/**
* @return \Concrete\Core\File\Search\ColumnSet\DefaultSet
*/
public function getDefaultColumnSet()
{
return new DefaultSet();
}
/**
* @return \Concrete\Core\File\FileList
*/
public function getItemList()
{
$list = new FolderItemList();
$list->setupAutomaticSorting();
return $list;
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Search\AbstractSearchProvider::getItemsPerPage()
*/
public function getItemsPerPage()
{
$app = Application::getFacadeApplication();
$config = $app->make('config');
return $config->get('concrete.file_manager.results');
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Search\AbstractSearchProvider::getItemsPerPageOptions()
*/
public function getItemsPerPageOptions()
{
$app = Application::getFacadeApplication();
$config = $app->make('config');
$options = $config->get('concrete.file_manager.items_per_page_options');
if (!empty($options)) {
return $options;
}
return parent::getItemsPerPageOptions();
}
/**
* @return \Concrete\Core\File\Search\Result\Result
*/
public function createSearchResultObject($columns, $list)
{
return new Result($columns, $list);
}
/**
* @return \Concrete\Core\Entity\Search\SavedFileSearch
*/
public function getSavedSearch()
{
return new SavedFileSearch();
}
}