ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ActionsImpl.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Search\GUI;
22
26use ILIAS\Data\Factory as DataFactory;
27use ilSearchGUI;
28
29class ActionsImpl implements Actions
30{
31 protected const string SEARCH_CMD = 'search';
32 protected const string REMOTE_SEARCH_CMD = 'remoteSearch';
33 protected const string SHOW_SAVED_RESULTS_CMD = 'showSavedResults';
34 protected const string APPLY_FILTER_CMD = 'applyFilter';
35 protected const string SWITCH_RESULT_PAGE_CMD = 'switchResultPage';
36 protected const string SORT_RESULT_PAGE_CMD = 'sortResultPage';
37 protected const string AUTO_COMPLETE_CMD = 'autoComplete';
38
39 public function __construct(
40 protected ilCtrlInterface $ctrl,
41 protected DataFactory $data_factory
42 ) {
43 }
44
45 public function search(): URI
46 {
47 $ctrl_target = $this->ctrl->getLinkTargetByClass(
48 ilSearchGUI::class,
49 self::SEARCH_CMD
50 );
51 return $this->ctrlToURI($ctrl_target);
52 }
53
54 public function remoteSearch(): URI
55 {
56 $ctrl_target = $this->ctrl->getLinkTargetByClass(
57 ilSearchGUI::class,
58 self::REMOTE_SEARCH_CMD
59 );
60 return $this->ctrlToURI($ctrl_target);
61 }
62
63 public function showSavedResults(): URI
64 {
65 $ctrl_target = $this->ctrl->getLinkTargetByClass(
66 ilSearchGUI::class,
67 self::SHOW_SAVED_RESULTS_CMD
68 );
69 return $this->ctrlToURI($ctrl_target);
70 }
71
72 public function applyFilter(): URI
73 {
74 $ctrl_target = $this->ctrl->getLinkTargetByClass(
75 ilSearchGUI::class,
76 self::APPLY_FILTER_CMD
77 );
78 return $this->ctrlToURI($ctrl_target);
79 }
80
81 public function switchResultPage(Sortation $sortation): URI
82 {
83 $this->ctrl->setParameterByClass(ilSearchGUI::class, Param::SORTATION->value, $sortation->value);
84 $ctrl_target = $this->ctrl->getLinkTargetByClass(
85 ilSearchGUI::class,
86 self::SWITCH_RESULT_PAGE_CMD
87 );
88 $this->ctrl->clearParameterByClass(ilSearchGUI::class, Param::SORTATION->value);
89 return $this->ctrlToURI($ctrl_target);
90 }
91
92 public function sortResultPage(): URI
93 {
94 $ctrl_target = $this->ctrl->getLinkTargetByClass(
95 ilSearchGUI::class,
96 self::SORT_RESULT_PAGE_CMD
97 );
98 return $this->ctrlToURI($ctrl_target);
99 }
100
101 public function autoComplete(): URI
102 {
103 $ctrl_target = $this->ctrl->getLinkTargetByClass(
104 ilSearchGUI::class,
105 self::AUTO_COMPLETE_CMD,
106 null,
107 true
108 );
109 return $this->ctrlToURI($ctrl_target);
110 }
111
112 public function isValidCommand(string $cmd): bool
113 {
114 return in_array($cmd, [
115 self::SEARCH_CMD,
116 self::REMOTE_SEARCH_CMD,
117 self::SHOW_SAVED_RESULTS_CMD,
118 self::APPLY_FILTER_CMD,
119 self::SWITCH_RESULT_PAGE_CMD,
120 self::SORT_RESULT_PAGE_CMD,
121 self::AUTO_COMPLETE_CMD
122 ]);
123 }
124
125 protected function ctrlToURI(string $ctrl_target): URI
126 {
127 return $this->data_factory->uri(
128 rtrim(ILIAS_HTTP_PATH, '/') . '/' . $ctrl_target
129 );
130 }
131}
Builds data types.
Definition: Factory.php:36
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
const string SORT_RESULT_PAGE_CMD
Definition: ActionsImpl.php:36
switchResultPage(Sortation $sortation)
Definition: ActionsImpl.php:81
ctrlToURI(string $ctrl_target)
const string SHOW_SAVED_RESULTS_CMD
Definition: ActionsImpl.php:33
__construct(protected ilCtrlInterface $ctrl, protected DataFactory $data_factory)
Definition: ActionsImpl.php:39
const string SWITCH_RESULT_PAGE_CMD
Definition: ActionsImpl.php:35
@ilCtrl_IsCalledBy ilSearchGUI: ilSearchControllerGUI
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...