• 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 
00089 
00090 }

Generated on Fri Dec 13 2013 13:52:12 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1