ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilUIFilterService Class Reference

Filter service. More...

+ Collaboration diagram for ilUIFilterService:

Public Member Functions

 __construct (ilUIService $service, ilUIServiceDependencies $deps)
 Constructor. More...
 
 standard ( $filter_id, $base_action, array $inputs, array $is_input_initially_rendered, $is_activated=false, $is_expanded=false)
 Get standard filter instance. More...
 
 getData (Filter\Standard $filter)
 Get data. More...
 

Data Fields

const CMD_TOGGLE_ON = "toggleOn"
 
const CMD_TOGGLE_OFF = "toggleOff"
 
const CMD_EXPAND = "expand"
 
const CMD_COLLAPSE = "collapse"
 
const CMD_APPLY = "apply"
 
const CMD_RESET = "reset"
 

Protected Member Functions

 writeFilterStatusToSession ($filter_id, $inputs)
 Write filter status to session (filter activated/expanded, inputs being rendered or not) More...
 
 handleRendering ($filter_id, $inputs)
 Handle rendering of inputs to session. More...
 
 handleReset (string $filter_id)
 Handle reset command. More...
 
 handleApply (string $filter_id, Filter\Standard $filter)
 Handle apply command. More...
 

Protected Attributes

 $service
 
 $ui
 
 $session
 
 $request
 

Detailed Description

Filter service.

Wraps around KS filter container.

Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 15 of file class.ilUIFilterService.php.

Constructor & Destructor Documentation

◆ __construct()

ilUIFilterService::__construct ( ilUIService  $service,
ilUIServiceDependencies  $deps 
)

Constructor.

Parameters
ilUIService$service
ilUIServiceDependencies$deps

Definition at line 51 of file class.ilUIFilterService.php.

52 {
53 $this->service = $service;
54 $this->session = $deps->getSession();
55 $this->request = $deps->getRequest();
56 $this->ui = $deps->ui();
57 }
ui()
Definition: ui.php:5

References $service, ilUIServiceDependencies\getRequest(), ilUIServiceDependencies\getSession(), ilUIServiceDependencies\ui(), and ui().

+ Here is the call graph for this function:

Member Function Documentation

◆ getData()

ilUIFilterService::getData ( Filter\Standard  $filter)

Get data.

Parameters
Filter\Standard$filter
Returns
array|null

Definition at line 135 of file class.ilUIFilterService.php.

136 {
137 $result = null;
138 if ($filter->isActivated()) {
139 $filter = $this->request->getFilterWithRequest($filter);
140 $result = $filter->getData();
141 }
142 return $result;
143 }
$result

References $result.

◆ handleApply()

ilUIFilterService::handleApply ( string  $filter_id,
Filter\Standard  $filter 
)
protected

Handle apply command.

Parameters
string$filter_id
Filter\Standard$filter
Returns
Filter\Standard

Definition at line 211 of file class.ilUIFilterService.php.

211 : Filter\Standard
212 {
213 if ((in_array(
214 $this->request->getFilterCmd(),
215 [self::CMD_APPLY]
216 ))) {
217 $filter = $this->request->getFilterWithRequest($filter);
218 foreach ($filter->getInputs() as $input_id => $i) {
219 $this->session->writeValue($filter_id, $input_id, $i->getValue());
220 }
221 }
222 return $filter;
223 }
$i
Definition: metadata.php:24

References $i.

◆ handleRendering()

ilUIFilterService::handleRendering (   $filter_id,
  $inputs 
)
protected

Handle rendering of inputs to session.

Parameters
string$filter_id
array$inputs

Definition at line 179 of file class.ilUIFilterService.php.

180 {
181 foreach ($inputs as $input_id => $i) {
182 if ($this->request->isInputRendered($input_id)) {
183 $this->session->writeRendered($filter_id, $input_id, true);
184 } else {
185 $this->session->writeRendered($filter_id, $input_id, false);
186 }
187 }
188 }

References $i.

◆ handleReset()

ilUIFilterService::handleReset ( string  $filter_id)
protected

Handle reset command.

Parameters
string$filter_id

Definition at line 195 of file class.ilUIFilterService.php.

196 {
197 // clear session, if reset is pressed
198 if ($this->request->getFilterCmd() == self::CMD_RESET) {
199 $this->session->reset($filter_id);
200 }
201 }

◆ standard()

ilUIFilterService::standard (   $filter_id,
  $base_action,
array  $inputs,
array  $is_input_initially_rendered,
  $is_activated = false,
  $is_expanded = false 
)

Get standard filter instance.

Parameters
string$filter_id
string$base_action
FilterInput[]$inputs
bool[]$is_input_initially_rendered
bool$is_activated
bool$is_expanded
Returns
Filter\Standard

Definition at line 71 of file class.ilUIFilterService.php.

78 : Filter\Standard {
79 $ui = $this->ui->factory();
80
81 // write expand, activation, rendered inputs info to session
82 $this->writeFilterStatusToSession($filter_id, $inputs);
83
84 // handle the reset command
85 $this->handleReset($filter_id);
86
87 // determine activation/expand status
88 $is_activated = $this->session->isActivated($filter_id, $is_activated);
89 $is_expanded = $this->session->isExpanded($filter_id, $is_expanded);
90
91 // put data from session into filter
92 $inputs_with_session_data = [];
93 $is_input_initially_rendered_with_session = [];
94 foreach ($inputs as $input_id => $i) {
95 // rendering information
96 $rendered =
97 $this->session->isRendered($filter_id, $input_id, current($is_input_initially_rendered));
98 $is_input_initially_rendered_with_session[] = $rendered;
99 next($is_input_initially_rendered);
100
101 // values
102 $val = $this->session->getValue($filter_id, $input_id);
103 if ($rendered && !is_null($val)) {
104 $i = $i->withValue($val);
105 }
106 $inputs_with_session_data[$input_id] = $i;
107 }
108
109 // get the filter
110 $filter = $ui->input()->container()->filter()->standard(
111 $this->request->getAction($base_action, self::CMD_TOGGLE_ON),
112 $this->request->getAction($base_action, self::CMD_TOGGLE_OFF),
113 $this->request->getAction($base_action, self::CMD_EXPAND),
114 $this->request->getAction($base_action, self::CMD_COLLAPSE),
115 $this->request->getAction($base_action, self::CMD_APPLY, true),
116 $this->request->getAction($base_action, self::CMD_RESET, true),
117 $inputs_with_session_data,
118 $is_input_initially_rendered_with_session,
119 $is_activated,
120 $is_expanded
121 );
122
123 // handle apply command
124 $filter = $this->handleApply($filter_id, $filter);
125
126 return $filter;
127 }
writeFilterStatusToSession($filter_id, $inputs)
Write filter status to session (filter activated/expanded, inputs being rendered or not)
handleApply(string $filter_id, Filter\Standard $filter)
Handle apply command.
handleReset(string $filter_id)
Handle reset command.

◆ writeFilterStatusToSession()

ilUIFilterService::writeFilterStatusToSession (   $filter_id,
  $inputs 
)
protected

Write filter status to session (filter activated/expanded, inputs being rendered or not)

Parameters
string$filter_id
array$inputs

Definition at line 150 of file class.ilUIFilterService.php.

151 {
152 if ($this->request->getFilterCmd() == self::CMD_TOGGLE_ON) {
153 $this->session->writeActivated($filter_id, true);
154 }
155
156 if ($this->request->getFilterCmd() == self::CMD_TOGGLE_OFF) {
157 $this->session->writeActivated($filter_id, false);
158 }
159
160 if ($this->request->getFilterCmd() == self::CMD_EXPAND) {
161 $this->session->writeExpanded($filter_id, true);
162 }
163
164 if ($this->request->getFilterCmd() == self::CMD_COLLAPSE) {
165 $this->handleRendering($filter_id, $inputs);
166 $this->session->writeExpanded($filter_id, false);
167 }
168
169 if ($this->request->getFilterCmd() == self::CMD_APPLY) {
170 $this->handleRendering($filter_id, $inputs);
171 }
172 }
handleRendering($filter_id, $inputs)
Handle rendering of inputs to session.

Field Documentation

◆ $request

ilUIFilterService::$request
protected

Definition at line 44 of file class.ilUIFilterService.php.

◆ $service

ilUIFilterService::$service
protected

Definition at line 29 of file class.ilUIFilterService.php.

Referenced by __construct().

◆ $session

ilUIFilterService::$session
protected

Definition at line 39 of file class.ilUIFilterService.php.

◆ $ui

ilUIFilterService::$ui
protected

Definition at line 34 of file class.ilUIFilterService.php.

◆ CMD_APPLY

const ilUIFilterService::CMD_APPLY = "apply"

Definition at line 22 of file class.ilUIFilterService.php.

◆ CMD_COLLAPSE

const ilUIFilterService::CMD_COLLAPSE = "collapse"

Definition at line 21 of file class.ilUIFilterService.php.

◆ CMD_EXPAND

const ilUIFilterService::CMD_EXPAND = "expand"

Definition at line 20 of file class.ilUIFilterService.php.

◆ CMD_RESET

const ilUIFilterService::CMD_RESET = "reset"

Definition at line 23 of file class.ilUIFilterService.php.

◆ CMD_TOGGLE_OFF

const ilUIFilterService::CMD_TOGGLE_OFF = "toggleOff"

Definition at line 19 of file class.ilUIFilterService.php.

◆ CMD_TOGGLE_ON

const ilUIFilterService::CMD_TOGGLE_ON = "toggleOn"

Definition at line 18 of file class.ilUIFilterService.php.


The documentation for this class was generated from the following file: