• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/MetaData/classes/class.ilMDUtils.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 // Month
00053                 if(preg_match('/^P(\d+)M/i',$a_string,$matches))
00054                 {
00055                         $months = $matches[1];
00056                 }
00057                 // Days
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                 // Hack for zero values
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 }

Generated on Fri Dec 13 2013 17:57:00 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1