ILIAS  release_8 Revision v8.24
class.ilMDUtils.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
28{
34 public static function _LOMDurationToArray(string $a_string): array
35 {
36 $a_string = trim($a_string);
37 #$pattern = '/^(PT)?(\d{1,2}H)?(\d{1,2}M)?(\d{1,2}S)?$/i';
38 $pattern = '/^P(\d{1,2}M)?(\d{1,2}D)?(T(\d{1,2}H)?(\d{1,2}M)?(\d{1,2}S)?)?$/i';
39
40 $months = $days = $hours = $min = $sec = null;
41 if (!preg_match($pattern, $a_string, $matches)) {
42 return [];
43 }
44 // Month
45 if (preg_match('/^P(\d+)M/i', $a_string, $matches)) {
46 $months = $matches[1];
47 }
48 // Days
49 if (preg_match('/(\d+)+D/i', $a_string, $matches)) {
50 #var_dump("<pre>",$matches,"<pre>");
51 $days = $matches[1];
52 }
53
54 if (preg_match('/(\d+)+H/i', $a_string, $matches)) {
55 #var_dump("<pre>",$matches,"<pre>");
56 $hours = $matches[1];
57 }
58 if (preg_match('/T(\d{1,2}H)?(\d+)M/i', $a_string, $matches)) {
59 #var_dump("<pre>",$matches,"<pre>");
60 $min = $matches[2];
61 }
62 if (preg_match('/(\d+)S/i', $a_string, $matches)) {
63 #var_dump("<pre>",$matches,"<pre>");
64 $sec = $matches[1];
65 }
66
67 // Hack for zero values
68 if (!$months && !$days && !$hours && !$min && !$sec) {
69 return [];
70 }
71
72 return array((int) $months, (int) $days, (int) $hours, (int) $min, (int) $sec);
73 }
74
75 public static function _fillHTMLMetaTags(int $a_rbac_id, int $a_obj_id, string $a_type): bool
76 {
77 global $DIC;
78
79 // currently disabled due to mantis 0026864
80 return true;
81
82 $tpl = $DIC['tpl'];
83 $ilObjDataCache = $DIC['ilObjDataCache'];
84
86 $a_rbac_id,
87 $a_obj_id,
88 $a_type
89 ) as $lng_code => $key_string) {
90 $tpl->setCurrentBlock('mh_meta_item');
91 $tpl->setVariable('MH_META_NAME', 'keywords');
92 $tpl->setVariable('MH_META_LANG', $lng_code);
93 $tpl->setVariable('MH_META_CONTENT', $key_string);
94 $tpl->parseCurrentBlock();
95 }
96
97 foreach (ilMDContribute::_lookupAuthors($a_rbac_id, $a_obj_id, $a_type) as $author) {
98 $tpl->setCurrentBlock('mh_meta_item');
99 $tpl->setVariable('MH_META_NAME', 'author');
100 $tpl->setVariable('MH_META_CONTENT', $author);
101 $tpl->parseCurrentBlock();
102 }
103 return true;
104 }
105
106 public static function _parseCopyright(string $a_copyright): string
107 {
109 if (!$settings->isCopyrightSelectionActive()) {
110 return ilMDCopyrightSelectionEntry::isEntry($a_copyright) ? '' : $a_copyright;
111 }
112
114 }
115
116 public static function _getDefaultCopyright(): string
117 {
121 );
122 }
123}
static _lookupAuthors(int $a_rbac_id, int $a_obj_id, string $a_obj_type)
static _getKeywordsByLanguageAsString(int $a_rbac_id, int $a_obj_id, string $a_type)
static _LOMDurationToArray(string $a_string)
LOM datatype duration is a string like P2M4DT7H18M2S (2 months 4 days 7 hours 18 minutes 2 seconds) T...
static _parseCopyright(string $a_copyright)
static _fillHTMLMetaTags(int $a_rbac_id, int $a_obj_id, string $a_type)
static _getDefaultCopyright()
global $DIC
Definition: feed.php:28
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200