Esempio n. 1
0
 function EDT($sel_ICS = "g91", $sel_name = "I1")
 {
     require_once $this->SG_lib . 'SG_iCal.php';
     $this->sel_ICS = $sel_ICS;
     $this->sel_name = $sel_name;
     $ICS = $this->getICS($this->sel_ICS);
     if (file_exists($ICS)) {
         $ical = new SG_iCalReader($ICS);
         $query = new SG_iCal_Query();
         $this->events = $ical->getEvents();
         $this->events_parsed = $this->parseEvents($this->events);
     } else {
         $this->erreur = TRUE;
         //ICS n'existe pas.
     }
 }
Esempio n. 2
0
 /**
  * Find and add new test in BD
  * @param int $id id of classroom
  * @param \DateTime $beginAt
  * @param \DateTime $endAt
  */
 public function findTests($id, \DateTime $beginAt, \DateTime $endAt)
 {
     // Find event in id classes at today
     $url = sprintf($this->urlADE, $id, $beginAt->format("Y-m-d"), $endAt->format("Y-m-d"));
     $ical = new \SG_iCalReader($url);
     $evts = $ical->getEvents();
     $tests = array();
     if (count($evts) > 0) {
         foreach ($evts as $event) {
             // Begin by EX -> is an exam
             if (strpos($event->getSummary(), "Examen") === 0) {
                 $tests[] = $event;
             }
         }
     }
     return $tests;
 }
Esempio n. 3
0
<?php

require_once '../SG_iCal.php';
function dump_t($x)
{
    echo "<pre>" . print_r($x, true) . "</pre>";
}
$ICS = "exdate.ics";
//echo dump_t(file_get_contents($ICS));
$ical = new SG_iCalReader($ICS);
$query = new SG_iCal_Query();
$evts = $ical->getEvents();
//$evts = $query->Between($ical,strtotime('20100901'),strtotime('20101131'));
$data = array();
foreach ($evts as $id => $ev) {
    $jsEvt = array("id" => $id + 1, "title" => $ev->getProperty('summary'), "start" => $ev->getStart(), "end" => $ev->getEnd() - 1, "allDay" => $ev->isWholeDay());
    if (isset($ev->recurrence)) {
        $count = 0;
        $start = $ev->getStart();
        $freq = $ev->getFrequency();
        if ($freq->firstOccurrence() == $start) {
            $data[] = $jsEvt;
        }
        while (($next = $freq->nextOccurrence($start)) > 0) {
            if (!$next or $count >= 1000) {
                break;
            }
            $count++;
            $start = $next;
            $jsEvt["start"] = $start;
            $jsEvt["end"] = $start + $ev->getDuration() - 1;
  private function _getRawEventData($ics_file)
  {

    // if(!is_file($ics_file.'_fixed')){
    //   $fixer = new google_ics_fix();
    //   $fixer->fixFile($ics_file);
    // }
    // $ics_calendar = new SG_iCalReader($ics_file.'_fixed');
    $ics_calendar = new SG_iCalReader($ics_file);
    return $ics_calendar->getEvents();
  }
Esempio n. 5
0
 /** Fonction qui remplis un tableau de cours.
  *  Utilise icalendar.
  */
 public function getCours()
 {
     /* Parse l'ics*/
     $nb = 0;
     $tab = array();
     $ical = new SG_iCalReader($this->ICS);
     $query = new SG_iCal_Query();
     $evts = $ical->getEvents();
     $data = array();
     if (!is_array($evts)) {
         echo "ERREUR, d'initialisation des evenements.";
         echo '<br>$evts= ' . $evts;
     }
     foreach ($evts as $id => $ev) {
         $jsEvt = array("id" => $id + 1, "title" => $ev->getProperty('summary'), "start" => $ev->getStart(), "end" => $ev->getEnd(), "allDay" => $ev->isWholeDay(), "location" => $ev->getProperty('location'), "description" => $ev->getProperty('description'));
         if (isset($ev->recurrence)) {
             $count = 0;
             $start = $ev->getStart();
             $freq = $ev->getFrequency();
             if ($freq->firstOccurrence() == $start) {
                 $data[] = $jsEvt;
             }
             while (($next = $freq->nextOccurrence($start)) > 0) {
                 if (!$next or $count >= 1000) {
                     break;
                 }
                 $count++;
                 $start = $next;
                 $jsEvt["start"] = $start;
                 $jsEvt["end"] = $start + $ev->getDuration();
                 $data[] = $jsEvt;
             }
         } else {
             $data[] = $jsEvt;
         }
         $String2 = htmlentities($jsEvt["description"], ENT_QUOTES, "UTF-8");
         $String = nl2br($String2);
         $sum = htmlentities($jsEvt["title"], ENT_QUOTES, "UTF-8");
         $sum2 = nl2br($sum);
         $Matiere = between('Mati&egrave;re : ', '<br />', $String);
         $prof = between('Personnel : ', '<br />', $String);
         $promo = between('Groupe : ', 'Groupe ', $String);
         $tmp = between('Groupe :', 'Salle ', $String);
         $sous_groupe = rtrim(trim(stripslashes(after('-', $tmp))));
         if ($sous_groupe == "") {
             $sous_groupe = "0";
         }
         $tabGroupe = array();
         $promo = trim($promo);
         $tmp_groupe = between('Groupe :', 'Salle', $String2);
         //--> 'INFO 2 Groupe 2\, INFO 2 Groupe 3'
         // echo $tmp.'<br/>';
         $tmp_tab = explode(",", $tmp_groupe);
         foreach ($tmp_tab as $g) {
             if (strpos($g, 'TP') !== FALSE) {
                 $tmp = between("TP ", "-", $String2);
             } else {
                 $tmp = after($promo . ' Groupe ', $g);
                 $tmp = trim(stripslashes($tmp));
                 // Enlève antislash et les espaces
                 if ($tmp == "") {
                     $tmp = "0";
                 }
             }
             array_push($tabGroupe, $tmp);
         }
         $type = before(' -', $sum2);
         $salle = between('Salle : ', '<br />', $String);
         $date_debut = $jsEvt['start'];
         $date_fin = $jsEvt['end'];
         $date = new DateTime('@' . $date_debut);
         /* Instancie les BEANs*/
         $cours = new Cours();
         $cours->setDateDebut($date_debut);
         $cours->setMatiere($Matiere);
         $cours->setDateFin($date_fin);
         $cours->setType($type);
         $cours->setProf($prof);
         $cours->setSalle($salle);
         foreach ($tabGroupe as $g) {
             $Groupe = new Groupe();
             $Groupe->setSousGroupe($sous_groupe[0]);
             $Groupe->setNumero($g);
             $Groupe->setPromo($promo);
             $cours->setGroupe($Groupe);
         }
         $cours->setId();
         $tab[$nb++] = $cours;
         sort($tab);
         // Noé
         array_push($this->tab_cours, $cours);
     }
 }
Esempio n. 6
0
         } else {
             // try without curl
             // works for public source and basic authentication only
             $copy_result = get_copy($ICS, $filename, $verify_peer);
             if (!($copy_result === TRUE)) {
                 echo $copy_result;
                 break;
             }
         }
     }
     if ($enable_cache) {
         copy($filename, $cachefile);
     }
 }
 $ICS = $filename;
 $ical = new SG_iCalReader($ICS);
 $query = new SG_iCal_Query();
 $evts = $ical->getEvents();
 $tzinfo = $ical->getTimeZoneInfo();
 if (is_array($evts) && !empty($evts)) {
     foreach ($evts as $id => $ev) {
         $curr_Evt = array("id" => $id + 1, "title" => $ev->getProperty('summary'), "start" => $ev->getStart(), "end" => $ev->getEnd(), "allDay" => $ev->isWholeDay(), "location" => $ev->getLocation(), "description" => $ev->getDescription(), "data" => $ev->data);
         if (isset($ev->recurrence)) {
             $count = 0;
             $next = -1;
             $start = $ev->getStart();
             $freq = $ev->getFrequency();
             if ($freq->firstOccurrence() == $start) {
                 if ($start < strtotime($endtime) && $endtime != 0 && $curr_Evt['end'] > strtotime($starttime)) {
                     $data[] = $curr_Evt;
                 }
Esempio n. 7
0
		<title>Online iCal Parser</title>
	</head>
	<body>
		<h1>Online iCal Parser</h1>
		
		<form action="#" method="POST">
			<label for="ical_url">URL</label>
			<input type="text" id="ical_url" name="ical_url" value="<?=$ical_url;?>" />
			
			<input type="submit" name="submit_ical" value="Parse!" />
		</form>
		
		<?php
			if($ical_url)
			{
				$ical = new SG_iCalReader($ical_url);
				if(!$ical->getCalendarInfo())
				{
					echo '<p class="error">Failed to load '.$ical_url.'!</p>';
				}
				
				$information = $ical->getCalendarInfo();
				if($information)
				{
					?>
					
					<h2>Calendar: <?=$information->getTitle();?></h2>
					<p>Description: <?=$information->getDescription();?></h2>
					<p>Found <?=count($ical->getEvents());?> events:</p>
					
					<dl>