diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89b99b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/tmp/**/* +/tmp/* diff --git a/bin/update.php b/bin/update.php new file mode 100644 index 0000000..e33dcaa --- /dev/null +++ b/bin/update.php @@ -0,0 +1,7 @@ +update(); diff --git a/build/service/CalendarExtractor.php b/build/service/CalendarExtractor.php index 1ab71c2..cb075f9 100644 --- a/build/service/CalendarExtractor.php +++ b/build/service/CalendarExtractor.php @@ -177,8 +177,6 @@ } - - die(1); } @@ -257,7 +255,38 @@ * @return ics ICS Representation of the events * ---------------------------------------------------------*/ - // public function toIcs(); + public function toIcs(){ + $RAW = ""; + + /* [1] Manage types + =========================================================*/ + $type_name = []; + + foreach($this->event_t as $color=>$uid) + $type_name[$uid] = $color; + + + /* [2] For each event + =========================================================*/ + foreach($this->event as $event_t=>$events){ + + $type = "Event of type '".$type_name[$event_t]."'"; + + /* (2) For each event of each type + ---------------------------------------------------------*/ + foreach($events as $start_t=>$stop_t){ + $RAW .= "BEGIN:VEVENT\n"; + $RAW .= "DTSTART:$start_t\n"; + $RAW .= "DTSTOP:$stop_t\n"; + $RAW .= "SUMMARY:$type\n"; + $RAW .= "END:VEVENT\n\n"; + } + + } + + return $RAW; + + } } \ No newline at end of file diff --git a/build/service/Updater.php b/build/service/Updater.php index cdd26e8..56b4e19 100644 --- a/build/service/Updater.php +++ b/build/service/Updater.php @@ -48,12 +48,19 @@ foreach($this->config->getPeriods() as $p_id=>$p_date){ /* (1) Load image in the extractor */ - var_dump("http://sciences.univ-pau.fr/edt/diplomes/${d_id}${p_id}.png"); $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); + + + } } diff --git a/public_html/index.php b/public_html/index.php index 38d88f9..043f30e 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -1,13 +1,3 @@ update(); - - // var_dump( imagecreatefrompng("http://sciences.univ-pau.fr/edt/diplomes/T0000000378S0000000000002.png") ); - echo "bla"; diff --git a/tmp/cursus.json b/tmp/cursus.json deleted file mode 100644 index e5933cd..0000000 --- a/tmp/cursus.json +++ /dev/null @@ -1 +0,0 @@ -{"CMI- CBE 1\u00e8re Ann\u00e9e> CMI-CBE Bio 1\u00e8re Ann\u00e9e":"T0005396693","CMI- CBE 1\u00e8re Ann\u00e9e> CMI-CBE Chimie 1\u00e8re Ann\u00e9e":"T0005396692","CMI- CBE 2\u00e8me Ann\u00e9e> CMI-CBE Bio 2\u00e8me Ann\u00e9e":"T0005396892","CMI- CBE 2\u00e8me Ann\u00e9e> CMI-CBE Chimie 2\u00e8me Ann\u00e9e":"T0005396893","CMI- GP 1\u00e8re Ann\u00e9e> CMI-GP G\u00e9osciences 1\u00e8re Ann\u00e9e":"T0005396862","CMI- GP 1\u00e8re Ann\u00e9e> CMI-GP R\u00e9serv et Product 1\u00e8re Ann\u00e9e":"T0005396863","L1 Biologie> L1 BIO groupe 1":"T0000000491","L1 Biologie> L1 BIO groupe 2":"T0000000494","L1 Biologie> L1 BIO groupe 3":"T0005395984","L1 Biologie> L1 BIO groupe 4":"T0005396527","L1 Informatique> L1 Info Gr1":"T0005396004","L1 Informatique> L1 Info Gr2":"T0005396003","L1 Informatique> L1 Info Gr3":"T0005396450","L1 Maths> L1 MATH Gr1":"T0005396556","L1 Maths> L1 MATH Gr2":"T0005396557","L1 Maths> L1 MATH Gr3":"T0005396715","L1 MIASHS> L1 MIASHS Gr1":"T0005396232","L1 MIASHS> L1 MIASHS Gr2":"T0005396233","L1 Phys. et Chim.> L1 PC groupe 1":"T0000000488","L1 Phys. et Chim.> L1 PC groupe 2":"T0000000489","L1 Phys. et Chim.> L1 PC groupe 3":"T0005396633","L1 Sciences de la Terre> L1 SDT GR 1":"T0005396887","L1 Sciences de la Terre> L1 SDT GR 2":"T0005396888","L2 Biologie> L2 BIO GR1":"T0005396244","L2 Biologie> L2 BIO GR2":"T0005396245","L2 Biologie> L2 BIO GR3":"T0005396246","L2 Biologie> L2 BIO GR4":"T0005396690","L2 Informatique> L2 Info Gr1":"T0005395091","L2 Informatique> L2 Info Gr2":"T0005395092","L2 Informatique> L2 Info Gr3":"T0005396870","L2 Math\u00e9matiques> L2 MATH Gr 1":"T0005394768","L2 Math\u00e9matiques> L2 MATH Gr 2":"T0005396687","L3 Biologie> L3 BIO G1":"T0000000219","L3 Biologie> L3 BIO G2":"T0000000218","L3 Biologie> L3 BIO G3":"T0005396782","L3 informatique> L3 info groupe 1":"T0000000246","L3 informatique> L3 info groupe 2":"T0000000247","L3 Math\u00e9matiques> L3 Math G 1":"T0005396879","L3 Math\u00e9matiques> L3 Math G 2":"T0005396880","M1 G\u00e9nie p\u00e9trolier> M1 GP G\u00e9osciences":"T0005394886","M1 G\u00e9nie p\u00e9trolier> M1 GP Production et trait":"T0005394888","M1 G\u00e9nie p\u00e9trolier> M1 GP R\u00e9servoirs":"T0005394887","M1 Technologie de l'Internet> M1 Tech Inter groupe 1":"T0000000377","M1 Technologie de l'Internet> M1 Tech Inter groupe 2":"T0000000378","M2 G\u00e9nie p\u00e9trolier> M2 GP G\u00e9osciences":"T0005394889","M2 G\u00e9nie p\u00e9trolier> M2 GP Production et trait":"T0005394891","M2 G\u00e9nie p\u00e9trolier> M2 GP R\u00e9servoirs":"T0005394890"} \ No newline at end of file diff --git a/tmp/period.json b/tmp/period.json deleted file mode 100644 index 8627949..0000000 --- a/tmp/period.json +++ /dev/null @@ -1 +0,0 @@ -{"S0000000000002":"11-09-2017","S0000000000004":"18-09-2017","S0000000000008":"25-09-2017","S0000000000010":"02-10-2017","S0000000000020":"09-10-2017","S0000000000040":"16-10-2017","S0000000000080":"23-10-2017","S0000000000200":"06-11-2017","S0000000000400":"13-11-2017","S0000000000800":"20-11-2017"} \ No newline at end of file