ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCronManagerTableFilterMediator Class Reference

Class ilCronManagerTableFilterMediator. More...

+ Collaboration diagram for ilCronManagerTableFilterMediator:

Public Member Functions

 __construct (ilCronJobCollection $repository, Factory $uiFactory, ilUIService $uiService, ilLanguage $lng)
 ilCronManagerTableFilterMediator constructor. More...
 
 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
 
 $items
 
 $uiFactory
 
 $uiService
 
 $lng
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilCronManagerTableFilterMediator constructor.

Parameters
ilCronJobCollection$repository
Factory$uiFactory
ilUIService$uiService
ilLanguage$lng

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

References $lng, $uiFactory, and $uiService.

Member Function Documentation

◆ filter()

ilCronManagerTableFilterMediator::filter ( string  $action)
Parameters
string$action
Returns
Standard

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

References $result, ilCronJobEntity\getComponent(), ilCronJobEntity\isPlugin(), 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.

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

◆ filteredJobs()

ilCronManagerTableFilterMediator::filteredJobs ( Standard  $filter)
Parameters
Standard$filter
Returns
ilCronJobCollection

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

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

140  {
141  $filterValues = $this->uiService->filter()->getData($filter);
142 
143  return $this->items->filter(function (ilCronJobEntity $entity) use ($filterValues) : bool {
144  if (
145  isset($filterValues[self::FILTER_PROPERTY_NAME_TITLE]) &&
146  is_string($filterValues[self::FILTER_PROPERTY_NAME_TITLE]) &&
147  strlen($filterValues[self::FILTER_PROPERTY_NAME_TITLE]) > 0
148  ) {
149  $titleFilterValue = $filterValues[self::FILTER_PROPERTY_NAME_TITLE];
150  if (ilStr::strIPos($entity->getEffectiveTitle(), $titleFilterValue) === false) {
151  return false;
152  }
153  }
154 
155  if (
156  isset($filterValues[self::FILTER_PROPERTY_NAME_COMPONENT]) &&
157  is_string($filterValues[self::FILTER_PROPERTY_NAME_COMPONENT]) &&
158  strlen($filterValues[self::FILTER_PROPERTY_NAME_COMPONENT]) > 0
159  ) {
160  $component = $entity->getComponent();
161  if ($entity->isPlugin()) {
162  $component = $this->lng->txt('cmps_plugin') . '/' . $component;
163  }
164 
165  if ($filterValues[self::FILTER_PROPERTY_NAME_COMPONENT] !== $component) {
166  return false;
167  }
168  }
169 
170  if (
171  isset($filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE]) &&
172  is_string($filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE]) &&
173  strlen($filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE]) > 0
174  ) {
175  if ((int) $filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE] !== $entity->getEffectiveScheduleType()) {
176  return false;
177  }
178  }
179 
180  if (
181  isset($filterValues[self::FILTER_PROPERTY_NAME_STATUS]) &&
182  is_string($filterValues[self::FILTER_PROPERTY_NAME_STATUS]) &&
183  strlen($filterValues[self::FILTER_PROPERTY_NAME_STATUS]) > 0
184  ) {
185  if (
186  (int) $filterValues[self::FILTER_PROPERTY_NAME_STATUS] === self::FILTER_STATUS_ACTIVE &&
187  !$entity->getJobStatus()
188  ) {
189  return false;
190  } elseif (
191  (int) $filterValues[self::FILTER_PROPERTY_NAME_STATUS] === self::FILTER_STATUS_INACTIVE &&
192  $entity->getJobStatus()
193  ) {
194  return false;
195  }
196  }
197 
198  if (
199  isset($filterValues[self::FILTER_PROPERTY_NAME_RESULT]) &&
200  is_string($filterValues[self::FILTER_PROPERTY_NAME_RESULT]) &&
201  strlen($filterValues[self::FILTER_PROPERTY_NAME_RESULT]) > 0
202  ) {
203  if ((int) $filterValues[self::FILTER_PROPERTY_NAME_RESULT] !== $entity->getJobResultStatus()) {
204  return false;
205  }
206  }
207 
208  return true;
209  });
210  }
filter(callable $callable)
Returns all the elements of this collection that satisfy the predicate $callable. ...
static strIPos($a_haystack, $a_needle, $a_offset=null)
Definition: class.ilStr.php:48
Class ilCronJobEntity.
Class ilCronJobCollection.
+ Here is the call graph for this function:

Field Documentation

◆ $items

ilCronManagerTableFilterMediator::$items
private

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

◆ $lng

ilCronManagerTableFilterMediator::$lng
private

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

Referenced by __construct().

◆ $uiFactory

ilCronManagerTableFilterMediator::$uiFactory
private

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

Referenced by __construct().

◆ $uiService

ilCronManagerTableFilterMediator::$uiService
private

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

Referenced by __construct().

◆ FILTER_PROPERTY_NAME_COMPONENT

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_COMPONENT = 'component'
private

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

◆ FILTER_PROPERTY_NAME_RESULT

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_RESULT = 'result'
private

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

◆ FILTER_PROPERTY_NAME_SCHEDULE

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_SCHEDULE = 'schedule'
private

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

◆ FILTER_PROPERTY_NAME_STATUS

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_STATUS = 'status'
private

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

◆ FILTER_PROPERTY_NAME_TITLE

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_TITLE = 'title'
private

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

◆ FILTER_STATUS_ACTIVE

const ilCronManagerTableFilterMediator::FILTER_STATUS_ACTIVE = 1
private

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

◆ FILTER_STATUS_INACTIVE

const ilCronManagerTableFilterMediator::FILTER_STATUS_INACTIVE = 2
private

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


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