New Updater * ---------------------------------------------------------*/ public function __construct(){ /* [1] Fetch config =========================================================*/ { /* (1) Try to load the configuration */ $this->config = Config::load("http://sciences.univ-pau.fr/edt/_ressource.js", "http://sciences.univ-pau.fr/edt/_periode.js"); /* (2) If cannot fetch config */ if( !($this->config instanceof Config) ) throw new \Exception("Cannot fetch configuration"); } } /* (2) Update the ICS files * * @return error FALSE on error * ---------------------------------------------------------*/ public function update(){ /* [1] Browse ech diplome =========================================================*/ foreach($this->config->getDiplomes() as $d_id=>$d_name){ file_put_contents(__ROOT__."/tmp/$d_id.ics", "BEGIN:VCALENDAR\nVERSION:2.0\nMETHOD:PUBLISH\nX-WR-CALNAME: UPPA $d_name"); /* (1) Browse each date ---------------------------------------------------------*/ foreach($this->config->getPeriods() as $p_id=>$p_date){ /* (1) Load image in the extractor */ $calext = new CalendarExtractor("http://sciences.univ-pau.fr/edt/diplomes/${d_id}${p_id}.png", $p_date); /* (2) Extract calendar data */ $calext->process(); /* (3) Get ICS events representation */ $EVENTS = $calext->toIcs(); /* (4) Add to file */ file_put_contents(__ROOT__."/tmp/$d_id.ics", $EVENTS, FILE_APPEND); } file_put_contents(__ROOT__."/tmp/$d_id.ics", "END:VCALENDAR", FILE_APPEND); } } }