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

modules/dateplaner/includes/inc.parse.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                                                                                       |
00005         |       Dateplaner Modul                                                                                                                  |                                                                                                     
00006         +-----------------------------------------------------------------------------+
00007         | Copyright (c) 2004 ILIAS open source & University of Applied Sciences Bremen|
00008         |                                                                             |
00009         | This program is free software; you can redistribute it and/or               |
00010         | modify it under the terms of the GNU General Public License                 |
00011         | as published by the Free Software Foundation; either version 2              |
00012         | of the License, or (at your option) any later version.                      |
00013         |                                                                             |
00014         | This program is distributed in the hope that it will be useful,             |
00015         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00016         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00017         | GNU General Public License for more details.                                |
00018         |                                                                             |
00019         | You should have received a copy of the GNU General Public License           |
00020         | along with this program; if not, write to the Free Software                 |
00021         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00022         +-----------------------------------------------------------------------------+
00023 */
00024 
00049 function getCSV($file){
00050         $handle = fopen ($file,"r"); 
00051         while ($data = fgetcsv ($handle, 1000, ",")) { // Daten werden aus der Datei
00052             $array[] = $data;                           // in ein Array $data gelesen
00053         }
00054         fclose ($handle);
00055         return $array;
00056 }
00057 
00065 function showArray($array){
00066         global $DP_language;
00067         $format = $DP_language[date_format];
00068         $parsedata.= "<b>$DP_language[insertImportDates]</b> <br><hr>";
00069         foreach($array as $date){
00070                 $parsedata.= "<table><tr><td><b>$DP_language[timeslice]</b></td><td>".date($format, $date[begin])." - ".date($format, $date[end])."</td></tr>";
00071                 $parsedata.= "<tr><td valign='top'><b>$DP_language[shorttext]:</b></td><td>".$date[short]."</td></tr>";
00072                 $parsedata.= "<tr><td valign='top'><b>$DP_language[Text]:</b></td><td>".$date[text]."</td></tr></table>";
00073                 
00074                 $parsedata.= "<hr>";
00075         }
00076         return $parsedata;
00077 }
00078 
00079 
00087 function convertToDateFormat($a){
00088         global $DP_UId;
00089         for($i=1; $i<count($a); $i++){
00090                 $j = $i-1;
00091                 if($a[$i][5]=="Aus"){//ganztagestermin?
00092                         $dates[$j][begin]       = makeTimestamp($a[$i][1], $a[$i][2]);
00093                         $dates[$j][end]         = makeTimestamp($a[$i][3], $a[$i][4]);
00094                         $dates[$j][user_ID]     = $DP_UId;
00095                         $dates[$j][short]       = $a[$i][0];
00096                         if($a[$i][16]!="") {$dates[$j][short].= " (".$a[$i][16].")";}//Ort?
00097                         $dates[$j][text]        = $a[$i][14];
00098                 }else{
00099                         $dates[$j][begin]       = makeTimestamp($a[$i][1], "00:00:00");
00100                         $dates[$j][end]         = makeTimestamp($a[$i][3], "23:59:59");
00101                         $dates[$j][user_ID]     = $DP_UId;
00102                         $dates[$j][short]       = $a[$i][0];
00103                         if($a[$i][16]!="") {$dates[$j][short].= " (".$a[$i][16].")";}//Ort?
00104                         $dates[$j][text]        = $a[$i][14];
00105                 }
00106                 
00107         }
00108         return $dates;          
00109 }
00110 
00118 function makeTimestamp($day, $time){
00119         $d = explode(".", $day );
00120         $t = explode(":", $time);
00121         $timestamp = mktime($t[0],$t[1],$t[2],$d[1],$d[0],$d[2]);
00122         return  $timestamp;
00123 }
00124 
00133 function parse($db, $_FILES){
00134         global $DP_language;
00135         $file = $_FILES['Datei'];
00136         if($file[tmp_name]){            
00137                 $array = getCSV($file[tmp_name]);
00138                 $dates = convertToDateFormat($array);
00139                 for($j=0; $j<count($dates);$j++){
00140                         $return = $db->addDate (        $dates[$j][begin],
00141                                                                                 $dates[$j][end], 
00142                                                                                 0, 
00143                                                                                 $dates[$j][user_ID], 
00144                                                                                 mktime(),
00145                                                                                 0, 
00146                                                                                 0, 
00147                                                                                 $dates[$j][short], 
00148                                                                                 $dates[$j][text], 
00149                                                                                 0, 
00150                                                                                 $dates[$j][user_ID]);
00151                 }
00152                 return showArray($dates);
00153         }
00154         else{
00155                 return $DP_language[ERROR_FILE_CSV_MSG];
00156         }
00157 
00158 }
00159 ?>

Generated on Fri Dec 13 2013 09:06:37 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1