00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00032 class ilMDUtils
00033 {
00042 function _LOMDurationToArray($a_string)
00043 {
00044 $a_string = trim($a_string);
00045 #$pattern = '/^(PT)?(\d{1,2}H)?(\d{1,2}M)?(\d{1,2}S)?$/i';
00046 $pattern = '/^P(\d{1,2}M)?(\d{1,2}D)?(T(\d{1,2}H)?(\d{1,2}M)?(\d{1,2}S)?)?$/i';
00047
00048 if(!preg_match($pattern,$a_string,$matches))
00049 {
00050 return false;
00051 }
00052
00053 if(preg_match('/^P(\d+)M/i',$a_string,$matches))
00054 {
00055 $months = $matches[1];
00056 }
00057
00058 if(preg_match('/(\d+)+D/i',$a_string,$matches))
00059 {
00060 #var_dump("<pre>",$matches,"<pre>");
00061 $days = $matches[1];
00062 }
00063
00064 if(preg_match('/(\d+)+H/i',$a_string,$matches))
00065 {
00066 #var_dump("<pre>",$matches,"<pre>");
00067 $hours = $matches[1];
00068 }
00069 if(preg_match('/T(\d{1,2}H)?(\d+)M/i',$a_string,$matches))
00070 {
00071 #var_dump("<pre>",$matches,"<pre>");
00072 $min = $matches[2];
00073 }
00074 if(preg_match('/(\d+)S/i',$a_string,$matches))
00075 {
00076 #var_dump("<pre>",$matches,"<pre>");
00077 $sec = $matches[1];
00078 }
00079
00080
00081 if(!$months and !$days and !$hours and !$min and !$sec)
00082 {
00083 return false;
00084 }
00085
00086 return array($months,$days,$hours,$min,$sec);
00087 }
00088
00099 public static function _fillHTMLMetaTags($a_rbac_id,$a_obj_id,$a_type)
00100 {
00101 global $tpl,$ilObjDataCache;
00102
00103 include_once('Services/MetaData/classes/class.ilMDKeyword.php');
00104 foreach(ilMDKeyword::_getKeywordsByLanguageAsString($a_rbac_id,$a_obj_id,$a_type) as $lng_code => $key_string)
00105 {
00106 $tpl->setCurrentBlock('mh_meta_item');
00107 $tpl->setVariable('MH_META_NAME','keywords');
00108 $tpl->setVariable('MH_META_LANG',$lng_code);
00109 $tpl->setVariable('MH_META_CONTENT',$key_string);
00110 $tpl->parseCurrentBlock();
00111 }
00112 include_once('Services/MetaData/classes/class.ilMDContribute.php');
00113 foreach(ilMDContribute::_lookupAuthors($a_rbac_id,$a_obj_id,$a_type) as $author)
00114 {
00115 $tpl->setCurrentBlock('mh_meta_item');
00116 $tpl->setVariable('MH_META_NAME','author');
00117 $tpl->setVariable('MH_META_CONTENT',$author);
00118 $tpl->parseCurrentBlock();
00119 }
00120
00121 }
00122
00132 public static function _parseCopyright($a_copyright)
00133 {
00134 include_once('Services/MetaData/classes/class.ilMDSettings.php');
00135 $settings = ilMDSettings::_getInstance();
00136 if(!$settings->isCopyrightSelectionActive())
00137 {
00138 return $a_copyright;
00139 }
00140 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
00141 return ilMDCopyrightSelectionEntry::_lookupCopyright($a_copyright);
00142 }
00143
00144
00145 }