From cf15f3af1e07c0bf8d2b1d899ee923010a1a2188 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 15 Sep 2017 20:21:52 +0200 Subject: [PATCH] update lessons + correct_lessons [todo] update location + correct_location --- build/router/controller/ics.php | 22 +++++++++++++++------- build/router/controller/page.php | 21 ++++++++++++++++----- config/routes.json | 24 ++++++++++++++++++++---- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/build/router/controller/ics.php b/build/router/controller/ics.php index 33b0145..fb0dfab 100644 --- a/build/router/controller/ics.php +++ b/build/router/controller/ics.php @@ -50,7 +50,7 @@ - public function info(){ + public function lessons(){ /* [1] Get database data =========================================================*/ @@ -65,7 +65,8 @@ - echo "
"; + echo ""; + echo ""; foreach($d_cols as $data){ @@ -74,18 +75,22 @@ $color = $data['color']; $name = $data['name']; - echo "$basename
"; + echo ""; } + echo "
Read nameCorrection
$basename
"; echo ""; + echo "
"; } + // todo + public function location(){} - public function correct(){ + public function correct_lessons(){ /* [1] Update data @@ -114,7 +119,7 @@ /* [2] Update file one the fly =========================================================*/ /* (1) Get corrections */ - $sqlr = DatabaseDriver::getPDO()->prepare("SELECT CONCAT(basename, color) as uid, name FROM event WHERE id_diplome = :idd"); + $sqlr = DatabaseDriver::getPDO()->prepare("SELECT id_event, name FROM event WHERE id_diplome = :idd"); $sqlr->execute([ ':idd' => $this->diplome_id ]); /* (2) Manage error */ @@ -125,7 +130,7 @@ $corrections = []; foreach($fetched as $c) - $corrections[$c['uid']] = $c['name']; + $corrections[$c['id_event']] = $c['name']; /* (3) Get file pointer */ @@ -142,7 +147,7 @@ for( $l = 0 ; $l < count($line)-1 ; $l++ ){ // {1} If got the right pointer // - if( preg_match('@^DESCRIPTION:(.+#[\da-f]{6})$@', $line[$l], $m) ){ + if( preg_match('@^DESCRIPTION:event\@(\d+)$@', $line[$l], $m) ){ // {2} If is in the list of correction // if( !isset($corrections[$m[1]]) ) @@ -162,6 +167,9 @@ header('Location: /'); } + // todo + public function correct_location(){} + /* POST-CALL * */ diff --git a/build/router/controller/page.php b/build/router/controller/page.php index 32937b8..2d3d90c 100644 --- a/build/router/controller/page.php +++ b/build/router/controller/page.php @@ -41,24 +41,35 @@ /* [2] Display the links =========================================================*/ - echo ""; + echo "
DiplomeConfigLinkLast Update
"; foreach($diplomes as $id=>$data){ $name = $data[0]; $upda = $data[1]; - - echo ""; - $URI = $_SERVER['REQUEST_URI']; $url = $_SERVER['HTTP_HOST'].$URI."ics/$id.ics"; $link = __ROOT__."/tmp/$id.ics"; - echo ""; + + // name + echo ""; + + // link to correct lessons + echo ""; echo ""; + echo ""; + + // update date echo ""; echo ""; } diff --git a/config/routes.json b/config/routes.json index 9c7a4b2..25d7000 100644 --- a/config/routes.json +++ b/config/routes.json @@ -20,17 +20,33 @@ } }, - "/info/{diplome_id}": { + "/location/{diplome_id}": { "methods": ["GET"], - "controller": "ics:info", + "controller": "ics:location", "arguments": { "diplome_id": "T\\d+" } }, - "/correct/{diplome_id}": { + "/lessons/{diplome_id}": { + "methods": ["GET"], + "controller": "ics:lessons", + "arguments": { + "diplome_id": "T\\d+" + } + }, + + "/xlessons/{diplome_id}": { "methods": ["POST"], - "controller": "ics:correct", + "controller": "ics:correct_lessons", + "arguments": { + "diplome_id": "T\\d+" + } + }, + + "/xlocation/{diplome_id}": { + "methods": ["POST"], + "controller": "ics:correct_location", "arguments": { "diplome_id": "T\\d+" }
DiplomeLessons' nameLocationLinkLast Update
$nameCorrect
$nameCorrectCorrecthttps://$url$upda