ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilUIFilterService Class Reference

Filter service. More...

+ Collaboration diagram for ilUIFilterService:

Public Member Functions

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

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 (string $filter_id, array $inputs)
 Write filter status to session (filter activated/expanded, inputs being rendered or not) More...
 
 handleRendering (string $filter_id, array $inputs)
 Handle rendering of inputs to session. More...
 
 handleReset (string $filter_id)
 
 handleApplyAndToggle (string $filter_id, Filter\Standard $filter)
 

Protected Attributes

ilUIService $service
 
UIServices $ui
 
ilUIFilterServiceSessionGateway $session
 
ilUIFilterRequestAdapter $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 29 of file class.ilUIFilterService.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

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

45  {
46  $this->service = $service;
47  $this->session = $deps->getSession();
48  $this->request = $deps->getRequest();
49  $this->ui = $deps->ui();
50  }
+ Here is the call graph for this function:

Member Function Documentation

◆ getData()

ilUIFilterService::getData ( Filter\Standard  $filter)

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

References null.

132  : ?array
133  {
134  $filter_data = null;
135  if ($filter->isActivated()) {
136  foreach ($filter->getInputs() as $k => $i) {
137  $filter_data[$k] = $i->getValue();
138  }
139  }
140 
141  return $filter_data;
142  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ handleApplyAndToggle()

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

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

References ILIAS\UI\Component\Input\Container\Filter\Filter\getData().

Referenced by standard().

202  : Filter\Standard
203  {
204  if ((in_array(
205  $this->request->getFilterCmd(),
206  [self::CMD_APPLY, self::CMD_TOGGLE_ON, self::CMD_TOGGLE_OFF]
207  ))) {
208  $filter = $this->request->getFilterWithRequest($filter);
209 
210  // always expand the filter, when it is activated with empty input values
211  if ($this->request->getFilterCmd() == self::CMD_TOGGLE_ON) {
212  $result = $filter->getData();
213  $expand = true;
214  foreach ($result as $k => $v) {
215  if (!empty($v) || $v === 0 || $v === "0") {
216  $expand = false;
217  }
218  }
219  if ($expand) {
220  $this->session->writeExpanded($filter_id, true);
221  $filter = $filter->withExpanded();
222  }
223  }
224 
225  foreach ($filter->getInputs() as $input_id => $i) {
226  $this->session->writeValue($filter_id, $input_id, $i->getValue());
227  }
228  }
229 
230  return $filter;
231  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleRendering()

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

Handle rendering of inputs to session.

Parameters
string$filter_id
FilterInput[]$inputs

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

Referenced by writeFilterStatusToSession().

183  : void
184  {
185  foreach ($inputs as $input_id => $i) {
186  if ($this->request->isInputRendered($input_id)) {
187  $this->session->writeRendered($filter_id, $input_id, true);
188  } else {
189  $this->session->writeRendered($filter_id, $input_id, false);
190  }
191  }
192  }
+ Here is the caller graph for this function:

◆ handleReset()

ilUIFilterService::handleReset ( string  $filter_id)
protected

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

Referenced by standard().

194  : void
195  {
196  // clear session, if reset is pressed
197  if ($this->request->getFilterCmd() == self::CMD_RESET) {
198  $this->session->reset($filter_id);
199  }
200  }
+ Here is the caller graph for this function:

◆ standard()

ilUIFilterService::standard ( string  $filter_id,
string  $base_action,
array  $inputs,
array  $is_input_initially_rendered,
bool  $is_activated = false,
bool  $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

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

References Vendor\Package\$e, handleApplyAndToggle(), handleReset(), ILIAS\User\Profile\next, ILIAS\Repository\ui(), and writeFilterStatusToSession().

71  : Filter\Standard {
72  $ui = $this->ui->factory();
73 
74  // write expand, activation, rendered inputs info to session
75  $this->writeFilterStatusToSession($filter_id, $inputs);
76 
77  // handle the reset command
78  $this->handleReset($filter_id);
79 
80  // determine activation/expand status
81  $is_activated = $this->session->isActivated($filter_id, $is_activated);
82  $is_expanded = $this->session->isExpanded($filter_id, $is_expanded);
83 
84  // put data from session into filter
85  $inputs_with_session_data = [];
86  $is_input_initially_rendered_with_session = [];
87 
88  if (count($inputs) != count($is_input_initially_rendered)) {
89  throw new \ArgumentCountError(
90  "Inputs and boolean values for initial rendering must be arrays of same size."
91  );
92  }
93 
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 (!is_null($val)) {
104  try {
105  $i = $i->withValue($val);
106  } catch (InvalidArgumentException $e) {
107  }
108  }
109  $inputs_with_session_data[$input_id] = $i;
110  }
111 
112  // get the filter
113  $filter = $ui->input()->container()->filter()->standard(
114  $this->request->getAction($base_action, self::CMD_TOGGLE_ON, true),
115  $this->request->getAction($base_action, self::CMD_TOGGLE_OFF, true),
116  $this->request->getAction($base_action, self::CMD_EXPAND),
117  $this->request->getAction($base_action, self::CMD_COLLAPSE),
118  $this->request->getAction($base_action, self::CMD_APPLY, true),
119  $this->request->getAction($base_action, self::CMD_RESET, true),
120  $inputs_with_session_data,
121  $is_input_initially_rendered_with_session,
122  $is_activated,
123  $is_expanded
124  );
125 
126  // handle apply and toggle commands
127  $filter = $this->handleApplyAndToggle($filter_id, $filter);
128 
129  return $filter;
130  }
handleApplyAndToggle(string $filter_id, Filter\Standard $filter)
writeFilterStatusToSession(string $filter_id, array $inputs)
Write filter status to session (filter activated/expanded, inputs being rendered or not) ...
handleReset(string $filter_id)
+ Here is the call graph for this function:

◆ writeFilterStatusToSession()

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

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

Parameters
string$filter_id
FilterInput[]$inputs

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

References handleRendering().

Referenced by standard().

150  : void
151  {
152  if ($this->request->getFilterCmd() == self::CMD_TOGGLE_ON) {
153  $this->handleRendering($filter_id, $inputs);
154  $this->session->writeActivated($filter_id, true);
155  }
156 
157  if ($this->request->getFilterCmd() == self::CMD_TOGGLE_OFF) {
158  $this->handleRendering($filter_id, $inputs);
159  $this->session->writeActivated($filter_id, false);
160  }
161 
162  if ($this->request->getFilterCmd() == self::CMD_EXPAND) {
163  $this->session->writeExpanded($filter_id, true);
164  }
165 
166  if ($this->request->getFilterCmd() == self::CMD_COLLAPSE) {
167  $this->session->writeExpanded($filter_id, false);
168  }
169 
170  if ($this->request->getFilterCmd() == self::CMD_APPLY) {
171  $this->handleRendering($filter_id, $inputs);
172  // always activate the filter when it is applied
173  $this->session->writeActivated($filter_id, true);
174  }
175  }
handleRendering(string $filter_id, array $inputs)
Handle rendering of inputs to session.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $request

ilUIFilterRequestAdapter ilUIFilterService::$request
protected

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

◆ $service

ilUIService ilUIFilterService::$service
protected

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

Referenced by __construct().

◆ $session

ilUIFilterServiceSessionGateway ilUIFilterService::$session
protected

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

◆ $ui

UIServices ilUIFilterService::$ui
protected

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

◆ CMD_APPLY

const ilUIFilterService::CMD_APPLY = "apply"

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

◆ CMD_COLLAPSE

const ilUIFilterService::CMD_COLLAPSE = "collapse"

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

◆ CMD_EXPAND

const ilUIFilterService::CMD_EXPAND = "expand"

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

◆ CMD_RESET

const ilUIFilterService::CMD_RESET = "reset"

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

◆ CMD_TOGGLE_OFF

const ilUIFilterService::CMD_TOGGLE_OFF = "toggleOff"

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

◆ CMD_TOGGLE_ON

const ilUIFilterService::CMD_TOGGLE_ON = "toggleOn"

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


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