ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMDUtils.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
33{
42 public static function _LOMDurationToArray($a_string)
43 {
44 $a_string = trim($a_string);
45 #$pattern = '/^(PT)?(\d{1,2}H)?(\d{1,2}M)?(\d{1,2}S)?$/i';
46 $pattern = '/^P(\d{1,2}M)?(\d{1,2}D)?(T(\d{1,2}H)?(\d{1,2}M)?(\d{1,2}S)?)?$/i';
47
48 if (!preg_match($pattern, $a_string, $matches)) {
49 return false;
50 }
51 // Month
52 if (preg_match('/^P(\d+)M/i', $a_string, $matches)) {
53 $months = $matches[1];
54 }
55 // Days
56 if (preg_match('/(\d+)+D/i', $a_string, $matches)) {
57 #var_dump("<pre>",$matches,"<pre>");
58 $days = $matches[1];
59 }
60
61 if (preg_match('/(\d+)+H/i', $a_string, $matches)) {
62 #var_dump("<pre>",$matches,"<pre>");
63 $hours = $matches[1];
64 }
65 if (preg_match('/T(\d{1,2}H)?(\d+)M/i', $a_string, $matches)) {
66 #var_dump("<pre>",$matches,"<pre>");
67 $min = $matches[2];
68 }
69 if (preg_match('/(\d+)S/i', $a_string, $matches)) {
70 #var_dump("<pre>",$matches,"<pre>");
71 $sec = $matches[1];
72 }
73
74 // Hack for zero values
75 if (!$months and !$days and !$hours and !$min and !$sec) {
76 return false;
77 }
78
79 return array($months,$days,$hours,$min,$sec);
80 }
81
92 public static function _fillHTMLMetaTags($a_rbac_id, $a_obj_id, $a_type)
93 {
94 global $DIC;
95
96 // currently disabled due to mantis 0026864
97 return true;
98
99 $tpl = $DIC['tpl'];
100 $ilObjDataCache = $DIC['ilObjDataCache'];
101
102 include_once('Services/MetaData/classes/class.ilMDKeyword.php');
103 foreach (ilMDKeyword::_getKeywordsByLanguageAsString($a_rbac_id, $a_obj_id, $a_type) as $lng_code => $key_string) {
104 $tpl->setCurrentBlock('mh_meta_item');
105 $tpl->setVariable('MH_META_NAME', 'keywords');
106 $tpl->setVariable('MH_META_LANG', $lng_code);
107 $tpl->setVariable('MH_META_CONTENT', $key_string);
108 $tpl->parseCurrentBlock();
109 }
110 include_once('Services/MetaData/classes/class.ilMDContribute.php');
111 foreach (ilMDContribute::_lookupAuthors($a_rbac_id, $a_obj_id, $a_type) as $author) {
112 $tpl->setCurrentBlock('mh_meta_item');
113 $tpl->setVariable('MH_META_NAME', 'author');
114 $tpl->setVariable('MH_META_CONTENT', $author);
115 $tpl->parseCurrentBlock();
116 }
117 }
118
128 public static function _parseCopyright($a_copyright)
129 {
130 include_once('Services/MetaData/classes/class.ilMDSettings.php');
131 $settings = ilMDSettings::_getInstance();
132 if (!$settings->isCopyrightSelectionActive()) {
133 return $a_copyright;
134 }
135 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
137 }
138}
An exception for terminatinating execution or to throw for unit testing.
static _lookupAuthors($a_rbac_id, $a_obj_id, $a_obj_type)
Lookup authors.
static _lookupCopyright($a_cp_string)
lookup copyright by entry id
static _getKeywordsByLanguageAsString($a_rbac_id, $a_obj_id, $a_type)
Get keywords by language as string.
static _getInstance()
get instance
static _fillHTMLMetaTags($a_rbac_id, $a_obj_id, $a_type)
Fill html meta tags.
static _parseCopyright($a_copyright)
Parse copyright.
static _LOMDurationToArray($a_string)
LOM datatype duration is a string like P2M4DT7H18M2S (2 months 4 days 7 hours 18 minutes 2 seconds) T...
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46