ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilCronOerHarvester.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
16 const CRON_JOB_IDENTIFIER = 'meta_oer_harvester';
17
22
26 private $logger = null;
27
31 private $lng = null;
32
36 private $settings = null;
37
38
42 public function __construct()
43 {
44 global $DIC;
45
46 $this->logger = $DIC->logger()->meta();
47 $this->lng = $DIC->language();
48 $this->lng->loadLanguageModule('meta');
49
51 }
52
56 public function getTitle()
57 {
58 return $this->lng->txt('meta_oer_harvester');
59 }
60
64 public function getDescription()
65 {
66 return $this->lng->txt('meta_oer_harvester_desc');
67 }
68
72 public function getId()
73 {
75 }
76
77
81 public function hasAutoActivation()
82 {
83 return false;
84 }
85
89 public function hasFlexibleSchedule()
90 {
91 return true;
92 }
93
97 public function getDefaultScheduleType()
98 {
100 }
101
105 public function getDefaultScheduleValue()
106 {
108 }
109
110
114 public function hasCustomSettings()
115 {
116 return true;
117 }
118
123 {
124 // target selection
125 $target = new ilRepositorySelector2InputGUI(
126 $this->lng->txt('meta_oer_target'),
127 'target',
128 false
129 );
130
131 $explorer = $target->getExplorerGUI();
132 $explorer->setSelectMode('target', false);
133 $explorer->setRootId(ROOT_FOLDER_ID);
134 $explorer->setTypeWhiteList(['cat']);
135
136 if ($this->settings->getTarget()) {
137 $explorer->setPathOpen($this->settings->getTarget());
138 $target->setValue($this->settings->getTarget());
139 }
140
141 $target->setRequired(true);
142 $a_form->addItem($target);
143
144
145 // copyright selection
146 $checkbox_group = new ilCheckboxGroupInputGUI(
147 $this->lng->txt('meta_oer_copyright_selection'),
148 'copyright'
149 );
150 $checkbox_group->setRequired(true);
151 $checkbox_group->setValue($this->settings->getCopyrightTemplates());
152 $checkbox_group->setInfo(
153 $this->lng->txt('meta_oer_copyright_selection_info')
154 );
155
156 foreach (ilMDCopyrightSelectionEntry::_getEntries() as $copyright_entry) {
157 $copyright_checkox = new ilCheckboxOption(
158 $copyright_entry->getTitle(),
159 $copyright_entry->getEntryId(),
160 $copyright_entry->getDescription()
161 );
162 $checkbox_group->addOption($copyright_checkox);
163 }
164 $a_form->addItem($checkbox_group);
165 return $a_form;
166 }
167
168
173 public function saveCustomSettings(ilPropertyFormGUI $a_form)
174 {
175 $this->settings->setTarget($a_form->getInput('target'));
176 $this->settings->setCopyrightTemplates($a_form->getInput('copyright'));
177 $this->settings->save();
178
179 return true;
180 }
181
185 public function run()
186 {
187 $this->logger->info('Started cron oer harvester.');
188 $harvester = new ilOerHarvester(new ilCronJobResult());
189 $res = $harvester->run();
190 $this->logger->info('cron oer harvester finished');
191
192 return $res;
193 }
194
202 public function addToExternalSettingsForm($a_form_id, array &$a_fields, $a_is_active)
203 {
204 #23901
205 global $DIC;
206 $lng = $DIC->language();
207
208 switch ($a_form_id) {
210
211 $a_fields['meta_oer_harvester'] =
212 (
213 $a_is_active ?
214 $lng->txt('enabled') :
215 $lng->txt('disabled')
216 );
217 break;
218 }
219 }
220}
An exception for terminatinating execution or to throw for unit testing.
This class represents a property in a property form.
This class represents an option in a checkbox group.
Cron job result data container.
Cron job application base class.
const SCHEDULE_TYPE_DAILY
Cron job for definition for oer harvesting.
getDefaultScheduleValue()
Get schedule value.int|array
getDescription()
Get description.string
run()
Run job.ilCronJobResult
hasCustomSettings()
Has cron job any custom setting which can be edited?boolean
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
hasFlexibleSchedule()
Can the schedule be configured?boolean
__construct()
ilOerHarvester constructor.
addToExternalSettingsForm($a_form_id, array &$a_fields, $a_is_active)
Provide external settings for presentation in MD settings.
hasAutoActivation()
Is to be activated on "installation".boolean
saveCustomSettings(ilPropertyFormGUI $a_form)
getDefaultScheduleType()
Get schedule type.int
Cron job for definition for oer harvesting.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46