ILIAS  release_8 Revision v8.24
class.ilMDUtilSelect.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
34 // BEGIN PATCH Lucene search
35 public static function _getLanguageSelect(
36 string $a_selected,
37 string $a_name,
38 array $prepend = array(),
39 bool $a_options_only = false
40 ) { // END PATCH Lucene Search
41 global $DIC;
42
43 $lng = $DIC['lng'];
44
46 $tmp_options[$code] = $lng->txt('meta_l_' . $code);
47 }
48 asort($tmp_options, SORT_STRING);
49
50 $options = [];
51 foreach ($prepend as $value => $translation) {
52 $options[$value] = $translation;
53 }
54 $options = array_merge($options, $tmp_options);
55 // BEGIN PATCH Lucene search
56 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
57 $a_selected,
58 $a_name,
59 $options,
60 false,
61 true
62 );
63 // END PATCH Lucene Search
64 }
65
71 // BEGIN PATCH Lucene search
72 public static function _getStructureSelect(
73 string $a_selected,
74 string $a_name,
75 array $prepend = array(),
76 bool $a_options_only = false
77 ) { // END PATCH Lucene Search
78 global $DIC;
79
80 $lng = $DIC['lng'];
81
82 $items = array('Atomic', 'Collection', 'Networked', 'Hierarchical', 'Linear');
83
84 foreach ($prepend as $value => $translation) {
85 $options[$value] = $translation;
86 }
87
88 foreach ($items as $item) {
89 $options[$item] = $lng->txt('meta_' . strtolower($item));
90 }
91 // BEGIN PATCH Lucene search
92 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
93 $a_selected,
94 $a_name,
95 $options,
96 false,
97 true
98 );
99 // END PATCH Lucene Search
100 }
101
107 // BEGIN PATCH Lucene search
108 public static function _getStatusSelect(
109 string $a_selected,
110 string $a_name,
111 array $prepend = array(),
112 bool $a_options_only = false
113 ) { // END PATCH Lucene Search
114 global $DIC;
115
116 $lng = $DIC['lng'];
117
118 $items = array('Draft', 'Final', 'Revised', 'Unavailable');
119
120 foreach ($prepend as $value => $translation) {
121 $options[$value] = $translation;
122 }
123
124 foreach ($items as $item) {
125 $options[$item] = $lng->txt('meta_' . strtolower($item));
126 }
127 // BEGIN PATCH Lucene search
128 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
129 $a_selected,
130 $a_name,
131 $options,
132 false,
133 true
134 );
135 // END PATCH Lucene Search
136 }
137
143 // BEGIN PATCH Lucene search
144 public static function _getRoleSelect(
145 string $a_selected,
146 string $a_name,
147 array $prepend = array(),
148 bool $a_options_only = false
149 ) { // END PATCH Lucene Search
150 global $DIC;
151
152 $lng = $DIC['lng'];
153
154 $items = array(
155 'Author',
156 'Publisher',
157 'Unknown',
158 'Initiator',
159 'Terminator',
160 'Editor',
161 'GraphicalDesigner',
162 'TechnicalImplementer',
163 'ContentProvider',
164 'TechnicalValidator',
165 'EducationalValidator',
166 'ScriptWriter',
167 'InstructionalDesigner',
168 'SubjectMatterExpert',
169 'Creator',
170 'Validator',
171 'PointOfContact'
172 );
173
174 foreach ($prepend as $value => $translation) {
175 $options[$value] = $translation;
176 }
177
178 foreach ($items as $item) {
179 $options[$item] = $lng->txt('meta_' . strtolower($item));
180 }
181 // BEGIN PATCH Lucene search
182 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
183 $a_selected,
184 $a_name,
185 $options,
186 false,
187 true
188 );
189 // END PATCH Lucene Search
190 }
191
197 // BEGIN PATCH Lucene search
198 public static function _getOperatingSystemSelect(
199 string $a_selected,
200 string $a_name,
201 array $prepend = array(),
202 bool $a_options_only = false
203 ) { // END PATCH Lucene Search
204 global $DIC;
205
206 $lng = $DIC['lng'];
207
208 $items = array('PC-DOS', 'MS-Windows', 'MAC-OS', 'Unix', 'Multi-OS', 'None');
209
210 foreach ($prepend as $value => $translation) {
211 $options[$value] = $translation;
212 }
213
214 foreach ($items as $item) {
215 $options[$item] = $item;
216 }
217 // BEGIN PATCH Lucene search
218 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
219 $a_selected,
220 $a_name,
221 $options,
222 false,
223 true
224 );
225 // END PATCH Lucene Search
226 }
227
233 // BEGIN PATCH Lucene search
234 public static function _getBrowserSelect(
235 string $a_selected,
236 string $a_name,
237 array $prepend = array(),
238 bool $a_options_only = false
239 ) { // END PATCH Lucene Search
240 global $DIC;
241
242 $lng = $DIC['lng'];
243
244 $items = array('Any', 'NetscapeCommunicator', 'MS-InternetExplorer', 'Opera', 'Amaya', 'Mozilla');
245
246 foreach ($prepend as $value => $translation) {
247 $options[$value] = $translation;
248 }
249
250 foreach ($items as $item) {
251 $options[$item] = $item;
252 }
253 // BEGIN PATCH Lucene search
254 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
255 $a_selected,
256 $a_name,
257 $options,
258 false,
259 true
260 );
261 // END PATCH Lucene Search
262 }
269 // BEGIN PATCH Lucene search
270 public static function _getFormatSelect(
271 string $a_selected,
272 string $a_name,
273 array $prepend = array(),
274 bool $a_options_only = false
275 ) { // END PATCH Lucene Search
276 global $DIC;
277
278 $lng = $DIC['lng'];
279 $ilDB = $DIC['ilDB'];
280
281 $options = [];
282 foreach ($prepend as $value => $translation) {
283 $options[$value] = $translation;
284 }
285
286 $ilDB->setLimit(200, 0);
287 // In case an index is defined on field il_meta_format, this group by
288 // statement takes advantage of it to improve the performance of the query.
289 $query = "SELECT format AS forma from il_meta_format GROUP BY format";
290 $res = $ilDB->query($query);
291 if (!$res->numRows()) {
292 return '';
293 }
294
295 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
296 if (is_string($row->forma) && $row->forma !== '') {
297 $options[$row->forma] = substr($row->forma, 0, 48);
298 }
299 }
300
301 // BEGIN PATCH Lucene search
302 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
303 $a_selected,
304 $a_name,
305 $options,
306 false,
307 true
308 );
309 // END PATCH Lucene Search
310 }
311
317 public static function _getDurationSelect(string $a_selected, string $a_name, array $prepend = array()): string
318 {
319 global $DIC;
320
321 $lng = $DIC['lng'];
322
323 foreach ($prepend as $value => $translation) {
324 $options[$value] = $translation;
325 }
326
327 $items = array(
328 15 => '15 ' . $lng->txt('minutes'),
329 30 => '30 ' . $lng->txt('minutes'),
330 45 => '45 ' . $lng->txt('minutes'),
331 60 => '1 ' . $lng->txt('hour'),
332 90 => '1 ' . $lng->txt('hour') . ' 30 ' . $lng->txt('minutes'),
333 120 => '2 ' . $lng->txt('hours'),
334 180 => '3 ' . $lng->txt('hours'),
335 240 => '4 ' . $lng->txt('hours')
336 );
337
338 foreach ($items as $key => $item) {
339 $options[$key] = $item;
340 }
341 return ilLegacyFormElementsUtil::formSelect($a_selected, $a_name, $options, false, true);
342 }
343
350 // BEGIN PATCH Lucene search
351 public static function _getInteractivityTypeSelect(
352 string $a_selected,
353 string $a_name,
354 array $prepend = array(),
355 bool $a_options_only = false
356 ) { // END PATCH Lucene Search
357 global $DIC;
358
359 $lng = $DIC['lng'];
360
361 $items = array('Actice', 'Expositive', 'Mixed');
362
363 foreach ($prepend as $value => $translation) {
364 $options[$value] = $translation;
365 }
366
367 foreach ($items as $item) {
368 $options[$item] = $item;
369 }
370 // BEGIN PATCH Lucene search
371 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
372 $a_selected,
373 $a_name,
374 $options,
375 false,
376 true
377 );
378 // END PATCH Lucene Search
379 }
380
387 // BEGIN PATCH Lucene search
388 public static function _getLearningResourceTypeSelect(
389 string $a_selected,
390 string $a_name,
391 array $prepend = array(),
392 bool $a_options_only = false
393 ) { // END PATCH Lucene Search
394 global $DIC;
395
396 $lng = $DIC['lng'];
397
398 $items = array(
399 'Exercise',
400 'Simulation',
401 'Questionnaire',
402 'Diagram',
403 'Figure',
404 'Graph',
405 'Index',
406 'Slide',
407 'Table',
408 'NarrativeText',
409 'Exam',
410 'Experiment',
411 'ProblemStatement',
412 'SelfAssessment',
413 'Lecture'
414 );
415
416 foreach ($prepend as $value => $translation) {
417 $options[$value] = $translation;
418 }
419
420 foreach ($items as $item) {
421 $options[$item] = $item;
422 }
423 // BEGIN PATCH Lucene search
424 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
425 $a_selected,
426 $a_name,
427 $options,
428 false,
429 true
430 );
431 // END PATCH Lucene Search
432 }
433
443 public static function _getInteractivityLevelSelect(
444 $a_selected,
445 string $a_name,
446 array $prepend = array(),
447 bool $a_options_only = false
448 ) {
449 global $DIC;
450
451 $lng = $DIC['lng'];
452
453 $items = array(1 => 'VeryLow', 2 => 'Low', 3 => 'Medium', 4 => 'High', 5 => 'VeryHigh');
454
455 foreach ($prepend as $value => $translation) {
456 $options[$value] = $translation;
457 }
458
459 foreach ($items as $key => $item) {
460 $options[$key] = $item;
461 }
462 // BEGIN PATCH Lucene search
463 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
464 $a_selected,
465 $a_name,
466 $options,
467 false,
468 true
469 );
470 // END PATCH Lucene Search
471 }
472
482 public static function _getSemanticDensitySelect(
483 $a_selected,
484 string $a_name,
485 array $prepend = array(),
486 bool $a_options_only = false
487 ) { // END PATCH Lucene Search
488 global $DIC;
489
490 $lng = $DIC['lng'];
491
492 $items = array(1 => 'VeryLow', 2 => 'Low', 3 => 'Medium', 4 => 'High', 5 => 'VeryHigh');
493
494 foreach ($prepend as $value => $translation) {
495 $options[$value] = $translation;
496 }
497
498 foreach ($items as $key => $item) {
499 $options[$key] = $item;
500 }
501 // BEGIN PATCH Lucene search
502 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
503 $a_selected,
504 $a_name,
505 $options,
506 false,
507 true
508 );
509 // END PATCH Lucene Search
510 }
511
518 // BEGIN PATCH Lucene search
519 public static function _getIntendedEndUserRoleSelect(
520 string $a_selected,
521 string $a_name,
522 array $prepend = array(),
523 bool $a_options_only = false
524 ) { // END PATCH Lucene Search
525 global $DIC;
526
527 $lng = $DIC['lng'];
528
529 $items = array('Teacher', 'Author', 'Learner', 'Manager');
530
531 foreach ($prepend as $value => $translation) {
532 $options[$value] = $translation;
533 }
534
535 foreach ($items as $item) {
536 $options[$item] = $item;
537 }
538 // BEGIN PATCH Lucene search
539 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
540 $a_selected,
541 $a_name,
542 $options,
543 false,
544 true
545 );
546 // END PATCH Lucene Search
547 }
548
554 // BEGIN PATCH Lucene search
555 public static function _getContextSelect(
556 string $a_selected,
557 string $a_name,
558 array $prepend = array(),
559 bool $a_options_only = false
560 ) { // END PATCH Lucene Search
561 global $DIC;
562
563 $lng = $DIC['lng'];
564
565 $items = array('School', 'HigherEducation', 'Training', 'Other');
566
567 foreach ($prepend as $value => $translation) {
568 $options[$value] = $translation;
569 }
570
571 foreach ($items as $item) {
572 $options[$item] = $item;
573 }
574 // BEGIN PATCH Lucene search
575 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
576 $a_selected,
577 $a_name,
578 $options,
579 false,
580 true
581 );
582 // END PATCH Lucene Search
583 }
584
589 public static function _getLocationTypeSelect(string $a_selected, string $a_name, array $prepend = array()): string
590 {
591 global $DIC;
592
593 $lng = $DIC['lng'];
594
595 $items = array('LocalFile', 'Reference');
596
597 foreach ($prepend as $value => $translation) {
598 $options[$value] = $translation;
599 }
600
601 foreach ($items as $item) {
602 $options[$item] = $item;
603 }
604 return ilLegacyFormElementsUtil::formSelect($a_selected, $a_name, $options, false, true);
605 }
606
616 public static function _getDifficultySelect(
617 $a_selected,
618 string $a_name,
619 array $prepend = array(),
620 bool $a_options_only = false
621 ) { // END PATCH Lucene Search
622 global $DIC;
623
624 $lng = $DIC['lng'];
625
626 $items = array(1 => 'VeryEasy', 2 => 'Easy', 3 => 'Medium', 4 => 'Difficult', 5 => 'VeryDifficult');
627
628 foreach ($prepend as $value => $translation) {
629 $options[$value] = $translation;
630 }
631
632 foreach ($items as $key => $item) {
633 $options[$key] = $item;
634 }
635 // BEGIN PATCH Lucene search
636 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
637 $a_selected,
638 $a_name,
639 $options,
640 false,
641 true
642 );
643 // END PATCH Lucene Search
644 }
645
651 public static function _getTypicalAgeRangeSelect(
652 string $a_selected,
653 string $a_name,
654 array $prepend = array()
655 ): string {
656 global $DIC;
657
658 $lng = $DIC['lng'];
659
660 $options = [];
661 foreach ($prepend as $value => $translation) {
662 $options[$value] = $translation;
663 }
664 $items = [];
665 for ($i = 1; $i < 100; $i++) {
666 $items[$i] = $i;
667 }
668 foreach ($items as $key => $item) {
669 $options[$key] = $item;
670 }
671 return ilLegacyFormElementsUtil::formSelect($a_selected, $a_name, $options, false, true);
672 }
673
679 public static function _getTypicalLearningTimeSelect(
680 string $a_selected,
681 string $a_name,
682 array $prepend = array()
683 ): string {
684 global $DIC;
685
686 $lng = $DIC['lng'];
687
688 foreach ($prepend as $value => $translation) {
689 $options[$value] = $translation;
690 }
691 $items = array(
692 15 => '15 ' . $lng->txt('minutes'),
693 30 => '30 ' . $lng->txt('minutes'),
694 45 => '45 ' . $lng->txt('minutes'),
695 60 => '1 ' . $lng->txt('hour'),
696 90 => '1 ' . $lng->txt('hour') . ' 30 ' . $lng->txt('minutes'),
697 120 => '2 ' . $lng->txt('hours'),
698 180 => '3 ' . $lng->txt('hours'),
699 240 => '4 ' . $lng->txt('hours')
700 );
701
702 foreach ($items as $key => $item) {
703 $options[$key] = $item;
704 }
705 return ilLegacyFormElementsUtil::formSelect($a_selected, $a_name, $options, false, true);
706 }
707
714 // BEGIN PATCH Lucene search
715 public static function _getCostsSelect(
716 string $a_selected,
717 string $a_name,
718 array $prepend = array(),
719 bool $a_options_only = false
720 ) { // END PATCH Lucene Search
721 global $DIC;
722
723 $lng = $DIC['lng'];
724
725 $items = array('Yes', 'No');
726
727 foreach ($prepend as $value => $translation) {
728 $options[$value] = $translation;
729 }
730
731 foreach ($items as $item) {
732 $options[$item] = $item;
733 }
734 // BEGIN PATCH Lucene search
735 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
736 $a_selected,
737 $a_name,
738 $options,
739 false,
740 true
741 );
742 // END PATCH Lucene Search
743 }
744
751 // BEGIN PATCH Lucene search
753 string $a_selected,
754 string $a_name,
755 array $prepend = array(),
756 bool $a_options_only = false
757 ) { // END PATCH Lucene Search
758 global $DIC;
759
760 $lng = $DIC['lng'];
761
762 $items = array('Yes', 'No');
763
764 foreach ($prepend as $value => $translation) {
765 $options[$value] = $translation;
766 }
767
768 foreach ($items as $item) {
769 $options[$item] = $item;
770 }
771 // BEGIN PATCH Lucene search
772 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
773 $a_selected,
774 $a_name,
775 $options,
776 false,
777 true
778 );
779 // END PATCH Lucene Search
780 }
781
788 // BEGIN PATCH Lucene search
789 public static function _getPurposeSelect(
790 string $a_selected,
791 string $a_name,
792 array $prepend = array(),
793 bool $a_options_only = false
794 ) { // END PATCH Lucene Search
795 global $DIC;
796
797 $lng = $DIC['lng'];
798
799 $items = array(
800 'Discipline',
801 'Idea',
802 'Prerequisite',
803 'EducationalObjective',
804 'AccessibilityRestrictions',
805 'EducationalLevel',
806 'SkillLevel',
807 'SecurityLevel',
808 'Competency'
809 );
810
811 foreach ($prepend as $value => $translation) {
812 $options[$value] = $translation;
813 }
814
815 foreach ($items as $item) {
816 $options[$item] = $item;
817 }
818 // BEGIN PATCH Lucene search
819 return $a_options_only ? $options : ilLegacyFormElementsUtil::formSelect(
820 $a_selected,
821 $a_name,
822 $options,
823 false,
824 true
825 );
826 // END PATCH Lucene Search
827 }
828}
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
static _getContextSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta context.
static _getOperatingSystemSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta technical os selector.
static _getLocationTypeSelect(string $a_selected, string $a_name, array $prepend=array())
Prepare a meta location type.
static _getLearningResourceTypeSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta educational learning resource type All possible entries in meta_format are shown.
static _getInteractivityLevelSelect( $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta educational interactivity level All possible entries in meta_format are shown.
static _getIntendedEndUserRoleSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta educational intended end user role All possible entries in meta_format are shown.
static _getStructureSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta general structure selector.
static _getCostsSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta rights costs All possible entries in meta_format are shown.
static _getInteractivityTypeSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta educational interactivity type All possible entries in meta_format are shown.
static _getTypicalAgeRangeSelect(string $a_selected, string $a_name, array $prepend=array())
Prepare a meta educational typical age range All possible entries in meta_format are shown.
static _getPurposeSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta rights copyright and other restrictions All possible entries in meta_format are shown.
static _getRoleSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta lifecycle status selector.
static _getSemanticDensitySelect( $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta educational semantic density All possible entries in meta_format are shown.
static _getDurationSelect(string $a_selected, string $a_name, array $prepend=array())
Prepare a meta technical duration selector All possible entries in meta_format are shown.
static _getLanguageSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta data language selector.
static _getBrowserSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta technical browser selector.
static _getCopyrightAndOtherRestrictionsSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta rights copyright and other restrictions All possible entries in meta_format are shown.
static _getStatusSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta lifecycle status selector.
static _getFormatSelect(string $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta technical format selector All possible entries in meta_format are shown.
static _getDifficultySelect( $a_selected, string $a_name, array $prepend=array(), bool $a_options_only=false)
Prepare a meta educational difficulty All possible entries in meta_format are shown.
static _getTypicalLearningTimeSelect(string $a_selected, string $a_name, array $prepend=array())
Prepare a meta educational typical learning time All possible entries in meta_format are shown.
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69
$i
Definition: metadata.php:41
string $key
Consumer key/client ID value.
Definition: System.php:193
$query
$lng