ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDidacticTemplateSettingsTableFilter Class Reference
+ Collaboration diagram for ilDidacticTemplateSettingsTableFilter:

Public Member Functions

 __construct (string $target_url)
 
 init ()
 Init Filter. More...
 
 render ()
 
 filter (array $settings)
 

Protected Member Functions

 isFiltered (ilDidacticTemplateSetting $setting)
 
 getFilterValue (string $name)
 
 loadFilterValues ()
 

Protected Attributes

const FILTER_ID = 'otpl_templates_table'
 
const FILTER_NAME_ICON = 'icon'
 
const FILTER_NAME_TITLE = 'title'
 
const FILTER_NAME_TYPE = 'type'
 
const FILTER_NAME_SCOPE = 'scope'
 
const FILTER_NAME_ACTIVE = 'active'
 
const FILTER_ON = 1
 
const FILTER_OFF = 2
 
const FILTER_GLOBAL = 1
 
const FILTER_LOCAL = 2
 

Private Attributes

array $input_activation_config
 
ilLanguage $lng
 
Factory $ui_factory
 
Renderer $ui_renderer
 
ilUIService $ui_service
 
string $target_url
 
ILIAS UI Component Input Container Filter Filter $filter = null
 
array $filter_values = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateSettingsTableFilter::__construct ( string  $target_url)

Definition at line 59 of file class.ilDidacticTemplateSettingsTableFilter.php.

60 {
61 global $DIC;
62
63 $this->lng = $DIC->language();
64 $this->ui_factory = $DIC->ui()->factory();
65 $this->ui_renderer = $DIC->ui()->renderer();
66 $this->ui_service = $DIC->uiService();
67
68 $this->target_url = $target_url;
69 }
global $DIC
Definition: shib_login.php:26

References $DIC, $target_url, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ filter()

ilDidacticTemplateSettingsTableFilter::filter ( array  $settings)
Parameters
ilDidacticTemplateSetting[]$settings
Returns
ilDidacticTemplateSetting[]

Definition at line 137 of file class.ilDidacticTemplateSettingsTableFilter.php.

137 : array
138 {
139 $this->loadFilterValues();
140
141 $filtered = [];
142 foreach ($settings as $setting) {
143 if ($this->isFiltered($setting)) {
144 continue;
145 }
146 $filtered[] = $setting;
147 }
148
149 return $filtered;
150 }

References isFiltered(), and loadFilterValues().

Referenced by init(), isFiltered(), loadFilterValues(), and render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilterValue()

ilDidacticTemplateSettingsTableFilter::getFilterValue ( string  $name)
protected

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

212 {
213 return $this->filter_values[$name] ?? null;
214 }

Referenced by isFiltered().

+ Here is the caller graph for this function:

◆ init()

ilDidacticTemplateSettingsTableFilter::init ( )

Init Filter.

Definition at line 74 of file class.ilDidacticTemplateSettingsTableFilter.php.

74 : void
75 {
76 $inputs[self::FILTER_NAME_ICON] = $this->ui_factory->input()->field()->select(
77 $this->lng->txt('icon'),
78 [
79 self::FILTER_ON => $this->lng->txt('didactic_filter_with_icon'),
80 self::FILTER_OFF => $this->lng->txt('didactic_filter_without_icon')
81 ]
82 );
83
84 $inputs[self::FILTER_NAME_TITLE] = $this->ui_factory->input()->field()->text(
85 $this->lng->txt('title')
86 );
87
88 $options = [];
90 $options[$type] = $this->lng->txt('objs_' . $type);
91 }
92 asort($options);
93 $inputs[self::FILTER_NAME_TYPE] = $this->ui_factory->input()->field()->select(
94 $this->lng->txt('type'),
95 $options
96 );
97
98 $inputs[self::FILTER_NAME_SCOPE] = $this->ui_factory->input()->field()->select(
99 $this->lng->txt('didactic_scope'),
100 [
101 self::FILTER_GLOBAL => $this->lng->txt('didactic_global'),
102 self::FILTER_LOCAL => $this->lng->txt('didactic_local')
103 ]
104 );
105
106 $inputs[self::FILTER_NAME_ACTIVE] = $this->ui_factory->input()->field()->select(
107 $this->lng->txt('status'),
108 [
109 self::FILTER_ON => $this->lng->txt('active'),
110 self::FILTER_OFF => $this->lng->txt('inactive')
111 ]
112 );
113
114 $this->filter = $this->ui_service->filter()->standard(
115 self::FILTER_ID,
116 $this->target_url,
117 $inputs,
118 $this->input_activation_config,
119 true,
120 true
121 );
122 }

References ILIAS\UI\Implementation\Component\Input\$inputs, filter(), FILTER_NAME_ACTIVE, FILTER_NAME_ICON, FILTER_NAME_SCOPE, FILTER_NAME_TITLE, FILTER_NAME_TYPE, ILIAS\Repository\lng(), and ilDidacticTemplateSettings\lookupAssignedObjectTypes().

+ Here is the call graph for this function:

◆ isFiltered()

ilDidacticTemplateSettingsTableFilter::isFiltered ( ilDidacticTemplateSetting  $setting)
protected

Definition at line 152 of file class.ilDidacticTemplateSettingsTableFilter.php.

152 : bool
153 {
154 if (!$this->filter->isActivated()) {
155 return false;
156 }
157
158 $value = (string) $this->getFilterValue(self::FILTER_NAME_ICON);
159 if ($value) {
160 if ($value === (string) self::FILTER_ON && $setting->getIconHandler()->getAbsolutePath() === '') {
161 return true;
162 }
163 if ($value === (string) self::FILTER_OFF && $setting->getIconHandler()->getAbsolutePath() !== '') {
164 return true;
165 }
166 }
167
168 $value = (string) $this->getFilterValue(self::FILTER_NAME_TITLE);
169 if ($value !== '') {
170 $title_string = ($setting->getPresentationTitle() . ' ' . $setting->getPresentationDescription());
171 $title_string .= (' ' . $setting->getInfo());
172 if (ilStr::strIPos($title_string, $value) === false) {
173 return true;
174 }
175 }
176
177 $value = (string) $this->getFilterValue(self::FILTER_NAME_TYPE);
178 if ($value !== '') {
179 $assigned = $setting->getAssignments();
180 if (!in_array($value, $assigned)) {
181 return true;
182 }
183 }
184
185 $value = (string) $this->getFilterValue(self::FILTER_NAME_SCOPE);
186 if ($value) {
187 $is_local = (bool) count($setting->getEffectiveFrom());
188
189 print_r($setting->getEffectiveFrom());
190 if ($value === (string) self::FILTER_GLOBAL && $is_local) {
191 return true;
192 }
193 if ($value === (string) self::FILTER_LOCAL && !$is_local) {
194 return true;
195 }
196 }
197
198 $value = (string) $this->getFilterValue(self::FILTER_NAME_ACTIVE);
199 if ($value) {
200 if ($value === (string) self::FILTER_ON && !$setting->isEnabled()) {
201 return true;
202 }
203 if ($value === (string) self::FILTER_OFF && $setting->isEnabled()) {
204 return true;
205 }
206 }
207
208 return false;
209 }
getInfo()
Get installation info text.
static strIPos(string $a_haystack, string $a_needle, int $a_offset=0)
Definition: class.ilStr.php:51

References filter(), ilDidacticTemplateSetting\getAssignments(), ilDidacticTemplateSetting\getEffectiveFrom(), getFilterValue(), ilDidacticTemplateSetting\getIconHandler(), ilDidacticTemplateSetting\getInfo(), ilDidacticTemplateSetting\getPresentationDescription(), ilDidacticTemplateSetting\getPresentationTitle(), ilDidacticTemplateSetting\isEnabled(), and ilStr\strIPos().

Referenced by filter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadFilterValues()

ilDidacticTemplateSettingsTableFilter::loadFilterValues ( )
protected

Definition at line 216 of file class.ilDidacticTemplateSettingsTableFilter.php.

216 : void
217 {
218 foreach ($this->filter->getInputs() as $name => $input) {
219 $this->filter_values[$name] = $input->getValue();
220 }
221 }

References filter().

Referenced by filter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilDidacticTemplateSettingsTableFilter::render ( )

Definition at line 124 of file class.ilDidacticTemplateSettingsTableFilter.php.

124 : string
125 {
126 return $this->ui_renderer->render(
127 [
128 $this->filter
129 ]
130 );
131 }

References filter().

+ Here is the call graph for this function:

Field Documentation

◆ $filter

ILIAS UI Component Input Container Filter Filter ilDidacticTemplateSettingsTableFilter::$filter = null
private

◆ $filter_values

array ilDidacticTemplateSettingsTableFilter::$filter_values = []
private

◆ $input_activation_config

array ilDidacticTemplateSettingsTableFilter::$input_activation_config
private
Initial value:
= [
self::FILTER_NAME_ICON => false,
self::FILTER_NAME_TITLE => true,
self::FILTER_NAME_TYPE => true,
self::FILTER_NAME_SCOPE => false,
self::FILTER_NAME_ACTIVE => true
]
return true

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

◆ $lng

ilLanguage ilDidacticTemplateSettingsTableFilter::$lng
private

◆ $target_url

string ilDidacticTemplateSettingsTableFilter::$target_url
private

◆ $ui_factory

Factory ilDidacticTemplateSettingsTableFilter::$ui_factory
private

◆ $ui_renderer

Renderer ilDidacticTemplateSettingsTableFilter::$ui_renderer
private

◆ $ui_service

ilUIService ilDidacticTemplateSettingsTableFilter::$ui_service
private

◆ FILTER_GLOBAL

const ilDidacticTemplateSettingsTableFilter::FILTER_GLOBAL = 1
protected

◆ FILTER_ID

const ilDidacticTemplateSettingsTableFilter::FILTER_ID = 'otpl_templates_table'
protected

◆ FILTER_LOCAL

const ilDidacticTemplateSettingsTableFilter::FILTER_LOCAL = 2
protected

◆ FILTER_NAME_ACTIVE

const ilDidacticTemplateSettingsTableFilter::FILTER_NAME_ACTIVE = 'active'
protected

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

Referenced by init().

◆ FILTER_NAME_ICON

const ilDidacticTemplateSettingsTableFilter::FILTER_NAME_ICON = 'icon'
protected

Definition at line 28 of file class.ilDidacticTemplateSettingsTableFilter.php.

Referenced by init().

◆ FILTER_NAME_SCOPE

const ilDidacticTemplateSettingsTableFilter::FILTER_NAME_SCOPE = 'scope'
protected

Definition at line 31 of file class.ilDidacticTemplateSettingsTableFilter.php.

Referenced by init().

◆ FILTER_NAME_TITLE

const ilDidacticTemplateSettingsTableFilter::FILTER_NAME_TITLE = 'title'
protected

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

Referenced by init().

◆ FILTER_NAME_TYPE

const ilDidacticTemplateSettingsTableFilter::FILTER_NAME_TYPE = 'type'
protected

Definition at line 30 of file class.ilDidacticTemplateSettingsTableFilter.php.

Referenced by init().

◆ FILTER_OFF

const ilDidacticTemplateSettingsTableFilter::FILTER_OFF = 2
protected

◆ FILTER_ON

const ilDidacticTemplateSettingsTableFilter::FILTER_ON = 1
protected

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