/
search.php
79 lines (67 loc) · 1.89 KB
/
search.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
<?php
namespace Concrete\Controller\Element\Express\Search;
use Concrete\Core\Controller\ElementController;
use Concrete\Core\Entity\Express\Entity;
use Concrete\Core\Entity\Search\Query;
use Concrete\Core\File\Search\SearchProvider;
use Concrete\Core\Foundation\Serializer\JsonSerializer;
class Search extends ElementController
{
/**
* This is where the header search bar in the page should point. This search bar allows keyword searching in
* different contexts.
*
* @var string
*/
protected $headerSearchAction;
/**
* @var Entity
*/
protected $entity;
/**
* @var Query
*/
protected $query;
public function getElement()
{
return 'express/search/search';
}
/**
* @param Query $query
*/
public function setQuery(Query $query = null): void
{
$this->query = $query;
}
/**
* @param string $headerSearchAction
*/
public function setHeaderSearchAction(string $headerSearchAction): void
{
$this->headerSearchAction = $headerSearchAction;
}
/**
* @param Entity $entity
*/
public function setEntity(Entity $entity): void
{
$this->entity = $entity;
}
public function view()
{
$this->set('entity', $this->entity);
$this->set('form', $this->app->make('helper/form'));
$this->set('token', $this->app->make('token'));
if (isset($this->headerSearchAction)) {
$this->set('headerSearchAction', $this->headerSearchAction);
} else {
$this->set(
'headerSearchAction',
$this->app->make('url')->to('/dashboard/express/entries/', 'view', $this->entity->getId())
);
}
if (isset($this->query)) {
$this->set('query', $this->app->make(JsonSerializer::class)->serialize($this->query, 'json'));
}
}
}