ILIAS  release_8 Revision v8.24
ilCronManagerTableFilterMediator Class Reference
+ Collaboration diagram for ilCronManagerTableFilterMediator:

Public Member Functions

 __construct (ilCronJobCollection $repository, Factory $uiFactory, ilUIService $uiService, ilLanguage $lng)
 
 filter (string $action)
 
 filteredJobs (Standard $filter)
 

Private Attributes

const FILTER_PROPERTY_NAME_TITLE = 'title'
 
const FILTER_PROPERTY_NAME_COMPONENT = 'component'
 
const FILTER_PROPERTY_NAME_SCHEDULE = 'schedule'
 
const FILTER_PROPERTY_NAME_STATUS = 'status'
 
const FILTER_PROPERTY_NAME_RESULT = 'result'
 
const FILTER_STATUS_ACTIVE = 1
 
const FILTER_STATUS_INACTIVE = 2
 
ilCronJobCollection $items
 
Factory $uiFactory
 
ilUIService $uiService
 
ilLanguage $lng
 

Detailed Description

Definition at line 24 of file class.ilCronManagerTableFilterMediator.php.

Constructor & Destructor Documentation

◆ __construct()

ilCronManagerTableFilterMediator::__construct ( ilCronJobCollection  $repository,
Factory  $uiFactory,
ilUIService  $uiService,
ilLanguage  $lng 
)

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

References $lng, $uiFactory, $uiService, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ filter()

ilCronManagerTableFilterMediator::filter ( string  $action)

Definition at line 52 of file class.ilCronManagerTableFilterMediator.php.

52 : Standard
53 {
54 $componentOptions = array_unique(array_map(function (ilCronJobEntity $entity): string {
55 if ($entity->isPlugin()) {
56 return $this->lng->txt('cmps_plugin') . '/' . $entity->getComponent();
57 }
58
59 return $entity->getComponent();
60 }, $this->items->toArray()));
61 asort($componentOptions);
62
63 $title = $this->uiFactory->input()->field()->text($this->lng->txt('title'));
64 $components = $this->uiFactory->input()->field()->select(
65 $this->lng->txt('cron_component'),
66 array_combine($componentOptions, $componentOptions)
67 );
68 $schedule = $this->uiFactory->input()->field()->select(
69 $this->lng->txt('cron_schedule'),
70 [
71 ilCronJob::SCHEDULE_TYPE_DAILY => $this->lng->txt('cron_schedule_daily'),
72 ilCronJob::SCHEDULE_TYPE_WEEKLY => $this->lng->txt('cron_schedule_weekly'),
73 ilCronJob::SCHEDULE_TYPE_MONTHLY => $this->lng->txt('cron_schedule_monthly'),
74 ilCronJob::SCHEDULE_TYPE_QUARTERLY => $this->lng->txt('cron_schedule_quarterly'),
75 ilCronJob::SCHEDULE_TYPE_YEARLY => $this->lng->txt('cron_schedule_yearly'),
76 ilCronJob::SCHEDULE_TYPE_IN_MINUTES => sprintf($this->lng->txt('cron_schedule_in_minutes'), 'x'),
77 ilCronJob::SCHEDULE_TYPE_IN_HOURS => sprintf($this->lng->txt('cron_schedule_in_hours'), 'x'),
78 ilCronJob::SCHEDULE_TYPE_IN_DAYS => sprintf($this->lng->txt('cron_schedule_in_days'), 'x')
79 ]
80 );
81 $status = $this->uiFactory->input()->field()->select(
82 $this->lng->txt('cron_status'),
83 [
84 self::FILTER_STATUS_ACTIVE => $this->lng->txt('cron_status_active'),
85 self::FILTER_STATUS_INACTIVE => $this->lng->txt('cron_status_inactive'),
86 ]
87 );
88 $result = $this->uiFactory->input()->field()->select(
89 $this->lng->txt('cron_result'),
90 [
92 'cron_result_status_invalid_configuration'
93 ),
94 ilCronJobResult::STATUS_NO_ACTION => $this->lng->txt(
95 'cron_result_status_no_action'
96 ),
97 ilCronJobResult::STATUS_OK => $this->lng->txt(
98 'cron_result_status_ok'
99 ),
100 ilCronJobResult::STATUS_CRASHED => $this->lng->txt(
101 'cron_result_status_crashed'
102 ),
103 ilCronJobResult::STATUS_RESET => $this->lng->txt(
104 'cron_result_status_reset'
105 ),
106 ilCronJobResult::STATUS_FAIL => $this->lng->txt(
107 'cron_result_status_fail'
108 ),
109 ]
110 );
111
112 $fields = [
113 self::FILTER_PROPERTY_NAME_TITLE => $title,
114 self::FILTER_PROPERTY_NAME_COMPONENT => $components,
115 self::FILTER_PROPERTY_NAME_SCHEDULE => $schedule,
116 self::FILTER_PROPERTY_NAME_STATUS => $status,
117 self::FILTER_PROPERTY_NAME_RESULT => $result,
118 ];
119
120 return $this->uiService->filter()->standard(
121 'cron_job_adm_table',
122 $action,
123 $fields,
124 array_fill(0, count($fields), true),
125 true,
126 true
127 );
128 }
const SCHEDULE_TYPE_IN_DAYS
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_IN_HOURS
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_IN_MINUTES
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_WEEKLY
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_YEARLY
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_QUARTERLY
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_MONTHLY
@depracated This will be replaced with an ENUM in ILIAS 9
This describes a standard filter.
Definition: Standard.php:27

References ilCronJobEntity\getComponent(), ilCronJobEntity\isPlugin(), ILIAS\Repository\lng(), ilCronJob\SCHEDULE_TYPE_DAILY, ilCronJob\SCHEDULE_TYPE_IN_DAYS, ilCronJob\SCHEDULE_TYPE_IN_HOURS, ilCronJob\SCHEDULE_TYPE_IN_MINUTES, ilCronJob\SCHEDULE_TYPE_MONTHLY, ilCronJob\SCHEDULE_TYPE_QUARTERLY, ilCronJob\SCHEDULE_TYPE_WEEKLY, ilCronJob\SCHEDULE_TYPE_YEARLY, ilCronJobResult\STATUS_CRASHED, ilCronJobResult\STATUS_FAIL, ilCronJobResult\STATUS_INVALID_CONFIGURATION, ilCronJobResult\STATUS_NO_ACTION, ilCronJobResult\STATUS_OK, and ilCronJobResult\STATUS_RESET.

+ Here is the call graph for this function:

◆ filteredJobs()

ilCronManagerTableFilterMediator::filteredJobs ( Standard  $filter)

Definition at line 130 of file class.ilCronManagerTableFilterMediator.php.

131 {
132 $filterValues = $this->uiService->filter()->getData($filter);
133
134 return $this->items->filter(function (ilCronJobEntity $entity) use ($filterValues): bool {
135 if (
136 isset($filterValues[self::FILTER_PROPERTY_NAME_TITLE]) &&
137 is_string($filterValues[self::FILTER_PROPERTY_NAME_TITLE]) &&
138 $filterValues[self::FILTER_PROPERTY_NAME_TITLE] !== ''
139 ) {
140 $titleFilterValue = $filterValues[self::FILTER_PROPERTY_NAME_TITLE];
141 if (ilStr::strIPos($entity->getEffectiveTitle(), $titleFilterValue) === false) {
142 return false;
143 }
144 }
145
146 if (
147 isset($filterValues[self::FILTER_PROPERTY_NAME_COMPONENT]) &&
148 is_string($filterValues[self::FILTER_PROPERTY_NAME_COMPONENT]) &&
149 $filterValues[self::FILTER_PROPERTY_NAME_COMPONENT] !== ''
150 ) {
151 $component = $entity->getComponent();
152 if ($entity->isPlugin()) {
153 $component = $this->lng->txt('cmps_plugin') . '/' . $component;
154 }
155
156 if ($filterValues[self::FILTER_PROPERTY_NAME_COMPONENT] !== $component) {
157 return false;
158 }
159 }
160
161 if (
162 isset($filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE]) &&
163 is_string($filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE]) &&
164 $filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE] !== ''
165 ) {
166 if ((int) $filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE] !== $entity->getEffectiveScheduleType()) {
167 return false;
168 }
169 }
170
171 if (
172 isset($filterValues[self::FILTER_PROPERTY_NAME_STATUS]) &&
173 is_string($filterValues[self::FILTER_PROPERTY_NAME_STATUS]) &&
174 $filterValues[self::FILTER_PROPERTY_NAME_STATUS] !== ''
175 ) {
176 if (
177 (int) $filterValues[self::FILTER_PROPERTY_NAME_STATUS] === self::FILTER_STATUS_ACTIVE &&
178 !$entity->getJobStatus()
179 ) {
180 return false;
181 } elseif (
182 (int) $filterValues[self::FILTER_PROPERTY_NAME_STATUS] === self::FILTER_STATUS_INACTIVE &&
183 $entity->getJobStatus()
184 ) {
185 return false;
186 }
187 }
188
189 if (
190 isset($filterValues[self::FILTER_PROPERTY_NAME_RESULT]) &&
191 is_string($filterValues[self::FILTER_PROPERTY_NAME_RESULT]) &&
192 $filterValues[self::FILTER_PROPERTY_NAME_RESULT] !== ''
193 ) {
194 if ((int) $filterValues[self::FILTER_PROPERTY_NAME_RESULT] !== $entity->getJobResultStatus()) {
195 return false;
196 }
197 }
198
199 return true;
200 });
201 }
static strIPos(string $a_haystack, string $a_needle, ?int $a_offset=null)
Definition: class.ilStr.php:54
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
filter(callable $callable)
Returns all the elements of this collection that satisfy the predicate $callable.

References ilCronJobCollection\filter(), FILTER_PROPERTY_NAME_TITLE, ilCronJobEntity\getComponent(), ilCronJobEntity\getEffectiveScheduleType(), ilCronJobEntity\getEffectiveTitle(), ilCronJobEntity\getJobResultStatus(), ilCronJobEntity\getJobStatus(), if, ilCronJobEntity\isPlugin(), and ilStr\strIPos().

+ Here is the call graph for this function:

Field Documentation

◆ $items

ilCronJobCollection ilCronManagerTableFilterMediator::$items
private

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

◆ $lng

ilLanguage ilCronManagerTableFilterMediator::$lng
private

Definition at line 38 of file class.ilCronManagerTableFilterMediator.php.

Referenced by __construct().

◆ $uiFactory

Factory ilCronManagerTableFilterMediator::$uiFactory
private

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

Referenced by __construct().

◆ $uiService

ilUIService ilCronManagerTableFilterMediator::$uiService
private

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

Referenced by __construct().

◆ FILTER_PROPERTY_NAME_COMPONENT

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_COMPONENT = 'component'
private

Definition at line 27 of file class.ilCronManagerTableFilterMediator.php.

◆ FILTER_PROPERTY_NAME_RESULT

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_RESULT = 'result'
private

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

◆ FILTER_PROPERTY_NAME_SCHEDULE

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_SCHEDULE = 'schedule'
private

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

◆ FILTER_PROPERTY_NAME_STATUS

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_STATUS = 'status'
private

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

◆ FILTER_PROPERTY_NAME_TITLE

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_TITLE = 'title'
private

Definition at line 26 of file class.ilCronManagerTableFilterMediator.php.

Referenced by filteredJobs().

◆ FILTER_STATUS_ACTIVE

const ilCronManagerTableFilterMediator::FILTER_STATUS_ACTIVE = 1
private

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

◆ FILTER_STATUS_INACTIVE

const ilCronManagerTableFilterMediator::FILTER_STATUS_INACTIVE = 2
private

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


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