From fde947e9995c57a56e1ebde08cdefdea00675744 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 16 Jun 2013 14:23:14 +0200 Subject: [PATCH 001/143] Added a markup for the Debug-Version. --- templates/partials/menu.phtml | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/partials/menu.phtml b/templates/partials/menu.phtml index 50ac141..d851e50 100644 --- a/templates/partials/menu.phtml +++ b/templates/partials/menu.phtml @@ -9,6 +9,7 @@ username ?> + Debud-Version. From e86e8dc4f0253abc543898d0bd28743bd190a6fe Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 16 Jun 2013 15:51:44 +0200 Subject: [PATCH 002/143] Changed place of Debug-Hint --- templates/partials/menu.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/partials/menu.phtml b/templates/partials/menu.phtml index d851e50..40481bd 100644 --- a/templates/partials/menu.phtml +++ b/templates/partials/menu.phtml @@ -9,8 +9,8 @@ username ?> - Debud-Version. + Debug-Version. - Debug-Version. +Debug-Version. + + From b9f4983bb6f2f1a652b357cfd1296a5100d9ea9f Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:10:50 +0200 Subject: [PATCH 026/143] [i] Oooops --- templates/partials/menu.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/partials/menu.phtml b/templates/partials/menu.phtml index b703c97..c86bc91 100644 --- a/templates/partials/menu.phtml +++ b/templates/partials/menu.phtml @@ -19,9 +19,9 @@
  • List All Profiles
  • From 410011ad550c1492a6102adbf1c73d90c0244eb6 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:12:17 +0200 Subject: [PATCH 027/143] [i] PersonController.php --- classes/Xodx/PersonController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index ee9d79a..f249356 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -297,8 +297,6 @@ public function editAction($template) echo ("Test"); } - - public function profileeditorAction ($template) { $bootstrap = $this->_app->getBootstrap(); From 540523d6f698dccf3b60fdfec5d79b9a6303136c Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:13:26 +0200 Subject: [PATCH 028/143] [i] ApplicationController.php --- classes/Xodx/ApplicationController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/Xodx/ApplicationController.php b/classes/Xodx/ApplicationController.php index 976300e..a225923 100644 --- a/classes/Xodx/ApplicationController.php +++ b/classes/Xodx/ApplicationController.php @@ -290,3 +290,4 @@ public function getUser () return $this->_user; } } + From a3e11ca679b2a3e29f52d27926eda70ff0e940ac Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:16:23 +0200 Subject: [PATCH 029/143] [i] For Testing --- classes/Xodx/PersonController.php | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index f249356..485cf29 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -299,27 +299,30 @@ public function editAction($template) public function profileeditorAction ($template) { - $bootstrap = $this->_app->getBootstrap(); - $request = $bootstrap->getResource('request'); + echo ("Test"); - $username = $request->getValue('username', 'post'); - $password = $request->getValue('password', 'post'); + //$bootstrap = $this->_app->getBootstrap(); + //$request = $bootstrap->getResource('request'); - if ($this->login($username, $password)) { - $template->disableLayout(); - $template->setRawContent(''); + //$username = $request->getValue('username', 'post'); + //$password = $request->getValue('password', 'post'); - $location = new Saft_Url($this->_app->getBaseUri()); - $location->setParameter('c', 'user'); - $location->setParameter('a', 'home'); + //if ($this->login($username, $password)) { + //$template->disableLayout(); + //$template->setRawContent(''); - $template->redirect($location); - } else { - $template->addContent('templates/login.phtml'); - } + //$location = new Saft_Url($this->_app->getBaseUri()); + //$location->setParameter('c', 'user'); + //$location->setParameter('a', 'home'); + +// $template->redirect($location); + //} else { + // $template->addContent('templates/login.phtml'); + //} $template->addContent('templates/profileeditor.phtml'); return $template; + } /** From e8a4fd43cd76b229d2c517c566b33745e3cd30fc Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:18:05 +0200 Subject: [PATCH 030/143] [i] persontest -> person --- classes/Xodx/PersonController.php | 22 ---------------------- classes/Xodx/PersontestController.php | 10 ---------- templates/person/profileeditor.phtml | 2 +- 3 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 classes/Xodx/PersontestController.php diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 485cf29..9edbea5 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -299,30 +299,8 @@ public function editAction($template) public function profileeditorAction ($template) { - echo ("Test"); - - //$bootstrap = $this->_app->getBootstrap(); - //$request = $bootstrap->getResource('request'); - - //$username = $request->getValue('username', 'post'); - //$password = $request->getValue('password', 'post'); - - //if ($this->login($username, $password)) { - //$template->disableLayout(); - //$template->setRawContent(''); - - //$location = new Saft_Url($this->_app->getBaseUri()); - //$location->setParameter('c', 'user'); - //$location->setParameter('a', 'home'); - -// $template->redirect($location); - //} else { - // $template->addContent('templates/login.phtml'); - //} - $template->addContent('templates/profileeditor.phtml'); return $template; - } /** diff --git a/classes/Xodx/PersontestController.php b/classes/Xodx/PersontestController.php deleted file mode 100644 index 03d4adb..0000000 --- a/classes/Xodx/PersontestController.php +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 1ea7307..90dd281 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -1,5 +1,5 @@

    Profil Editor

    - +
    From ae13b326ed565e5e9196bade67f1c8658116ae0f Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:19:24 +0200 Subject: [PATCH 031/143] [i] Let us see if this works --- classes/Xodx/PersonController.php | 2 +- templates/person/profileeditor.phtml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 9edbea5..480e945 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -292,7 +292,7 @@ public function getNotifications ($personUri) return $pingResult; } - public function editAction($template) + public function editAction($a, $b, $c) { echo ("Test"); } diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 90dd281..f772ced 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -8,13 +8,13 @@
    - +

    - +

    From ce02bc9c80b0add7d563592e7cc3979d0c56248d Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:36:27 +0200 Subject: [PATCH 032/143] [i] Test if it works --- templates/person/profileeditor.phtml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index f772ced..90d7b25 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -2,12 +2,12 @@
    - +
    - +
    -
    +

    Dies ist die Seite für den Profileditor.

    From b98dbb32fc8225661e07bb60214ba919dac669b3 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:37:20 +0200 Subject: [PATCH 033/143] [i] uncommented Button --- templates/person/profileeditor.phtml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 90d7b25..3ce14ab 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -19,10 +19,11 @@
    +-->
    ---> +

    Dies ist die Seite für den Profileditor.

    From 2f4c30a634e351e065a907583e0da11af5bf6e10 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:41:13 +0200 Subject: [PATCH 034/143] [i] If this will work? --- templates/person/profileeditor.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 3ce14ab..9e7a442 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -2,9 +2,9 @@
    - +
    - +
    +
    From de7fa9f3ddc055799fe165f20ecf6d035af432c5 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:56:57 +0200 Subject: [PATCH 041/143] [i] Next Try --- templates/person/profileeditor.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 703c62e..17b57c3 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -4,7 +4,7 @@
    - +
    +

    Ein paar Tests:

    From 640a892fc19269ae26b78a90266602b961d52542 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:57:41 +0200 Subject: [PATCH 042/143] [i] Next Test --- templates/person/profileeditor.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 17b57c3..0914bae 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -26,7 +26,7 @@

    Dies ist die Seite für den Profileditor.

    -

    Ein paar Tests:

    +

    Ein paar Tests:

    From 3f9ed673d7f6332839566f11065aab1b457dd798 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 23 Jun 2013 22:58:15 +0200 Subject: [PATCH 043/143] [i] With () --- templates/person/profileeditor.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 0914bae..d2cc54d 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -26,7 +26,7 @@

    Dies ist die Seite für den Profileditor.

    -

    Ein paar Tests:

    +

    Ein paar Tests:

    From a514939ddc5c3e5f756729ccc3af9267dcf981fe Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Mon, 8 Jul 2013 19:18:30 +0200 Subject: [PATCH 044/143] [i] Test for This --- templates/person/profileeditor.phtml | 29 ++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index d2cc54d..f641b36 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -4,9 +4,32 @@
    - +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + + + - - - -
    From be99008acbf3d11739a931d368a58f27cd8989ea Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Tue, 3 Sep 2013 17:09:54 +0200 Subject: [PATCH 088/143] Todos und Query --- classes/Xodx/PersonController.php | 2 +- templates/person/profileeditor.phtml | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 605512b..ff79b00 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -363,7 +363,7 @@ public function profileeditorAction ($template) echo ("Name: "); echo ($name); - $query = "PREFIX foaf: SELECT * WHERE { ?person a foaf:Person. ?person foaf:nick '$name' }"; + $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; $profiles = $model->sparqlQuery( $query); $template->profile = $profiles[0]; diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index d21eeb3..4d22914 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -1,4 +1,4 @@ -

    Profil Editor

    +

    Profil Editor

    @@ -10,6 +10,18 @@ if (isset($this->profile)) foreach ($this->profile as $key => $element) { + //TODO: Filtern von z.B. foaf:knows + //Ressourcen gar nicht zeigen. + //Array für erwünschte Prädikate definieren --> Was darf editiert werden? + //und danach filtern. + //Unterscheidung zwischen Single und Multiple-Prädikaten + //Diff: Alte Werte löschen! + + //if (!$allowedfields.contains($key)) + //{ + // break; + //} + //var_dump($element); //echo ("
    "); From 584d8dc226ee35f39d7aea4598d5b90e6f2dcf11 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 15 Sep 2013 15:30:01 +0200 Subject: [PATCH 089/143] Correct Properties in Profile Editor --- classes/Xodx/PersonController.php | 5 +++- templates/person/profileeditor.phtml | 37 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index ff79b00..a3c7843 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -366,7 +366,10 @@ public function profileeditorAction ($template) $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; $profiles = $model->sparqlQuery( $query); - $template->profile = $profiles[0]; + //echo("Result:
    "); + //var_dump($profiles); + //echo("
    "); + $template->profile = $profiles; $template->addContent('templates/profileeditor.phtml'); diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 4d22914..e6a859c 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -6,30 +6,29 @@ if (isset($this->profile)) { - var_dump($this->profile); +// var_dump($this->profile); foreach ($this->profile as $key => $element) { - //TODO: Filtern von z.B. foaf:knows - //Ressourcen gar nicht zeigen. - //Array für erwünschte Prädikate definieren --> Was darf editiert werden? - //und danach filtern. - //Unterscheidung zwischen Single und Multiple-Prädikaten - //Diff: Alte Werte löschen! - - //if (!$allowedfields.contains($key)) - //{ - // break; - //} - - //var_dump($element); - //echo ("
    "); - + //TODO: Filtern von z.B. foaf:knows + //Ressourcen gar nicht zeigen. + //Array für erwünschte Prädikate definieren --> Was darf editiert werden? + //und danach filtern. + //Unterscheidung zwischen Single und Multiple-Prädikaten + //Diff: Alte Werte löschen! + + //if (!$allowedfields.contains($key)) + //{ + // break; + //} + + $keyX = $element["p"]; + $elementX = $element["o"]; echo ("
    - +
    - - + +
    "); } From 82e5ca4ee6cdeaaec85c3cfe4ddf4230567a6193 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 15 Sep 2013 20:11:01 +0200 Subject: [PATCH 090/143] Filter for Prefixes --- classes/Xodx/PersonController.php | 14 +++++--- templates/person/profileeditor.phtml | 48 +++++++++++++++------------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index a3c7843..4446a8f 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -314,7 +314,8 @@ public function editAction() $old = false; $newKey; $newValue; - $changed = array(); + $changedADD = array(); + $changedDELETE = array(); foreach ($_POST as $key => $value) { if (!$old) @@ -327,16 +328,19 @@ public function editAction() { if ($value != $newValue) { - $changed[$newKey] = $newValue; + $changedADD[$newKey] = $newValue; + $changedDELETE[$newKey] = $value; } $old = false; } } - echo("Debug: "); - var_dump($changed); + echo("Debug Add: "); + var_dump($changedADD); + echo("
    Debug Delete: "); + var_dump($changedDELETE); $nsFoaf = 'http://xmlns.com/foaf/0.1/'; - foreach ($changed as $key => $value) + foreach ($changedADD as $key => $value) { echo ("
    Writing $key --- $value"); $model->addStatement($key, $nsFoaf . 'Account', $value); diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index e6a859c..af4afa0 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -6,31 +6,35 @@ if (isset($this->profile)) { -// var_dump($this->profile); + $allowedPrefixes = array(); + $allowedPrefixes[] = "http://xmlns.com/foaf/0.1/nick"; foreach ($this->profile as $key => $element) { - //TODO: Filtern von z.B. foaf:knows - //Ressourcen gar nicht zeigen. - //Array für erwünschte Prädikate definieren --> Was darf editiert werden? - //und danach filtern. - //Unterscheidung zwischen Single und Multiple-Prädikaten - //Diff: Alte Werte löschen! - - //if (!$allowedfields.contains($key)) - //{ - // break; - //} - - $keyX = $element["p"]; - $elementX = $element["o"]; -echo ("
    - -
    - - -
    -
    "); + //DONE: Filtern von z.B. foaf:knows + //DONE: Ressourcen gar nicht zeigen. + //DONE: Array für erwünschte Prädikate definieren --> Was darf editiert werden? + //DONE: und danach filtern. + //TODO: Unterscheidung zwischen Single und Multiple-Prädikaten + //PARTLY DONE: Diff: Alte Werte löschen! + + //if (!$allowedfields.contains($key)) + //{ + // break; + //} + + $keyX = $element["p"]; + $elementX = $element["o"]; + if (in_array($keyX, $allowedPrefixes)) + { + echo ("
    + +
    + + +
    +
    "); + } } } else From ffd8bcd1c40a12aa82cd54d814e23df3a2d35337 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Mon, 16 Sep 2013 20:54:58 +0200 Subject: [PATCH 091/143] It does _something_ --- classes/Xodx/PersonController.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 4446a8f..7d87050 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -311,6 +311,9 @@ public function editAction() echo ("
    "); //This is real sourcecode! $model = $this->_app->getBootstrap()->getResource('model'); + $applicationController = $this->_app->getController('Xodx_ApplicationController'); + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; $old = false; $newKey; $newValue; @@ -340,10 +343,19 @@ public function editAction() var_dump($changedDELETE); $nsFoaf = 'http://xmlns.com/foaf/0.1/'; + foreach ($changedDELETE as $key => $value) + { + //$keyArray = array('value' => ); + $valueArray = array('type' => $value); + echo ("
    Writing $key --- $value"); + $model->deleteStatement($userUri, $key, $valueArray); + } foreach ($changedADD as $key => $value) { + //$keyArray = array('value' => ); + $valueArray = array('type' => $value); echo ("
    Writing $key --- $value"); - $model->addStatement($key, $nsFoaf . 'Account', $value); + $model->addStatement($userUri, $key, $valueArray); } } @@ -368,6 +380,7 @@ public function profileeditorAction ($template) echo ($name); $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; + //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; $profiles = $model->sparqlQuery( $query); //echo("Result:
    "); From a127d9b81153202406ce1f371333200b8f7645b9 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Mon, 16 Sep 2013 21:43:05 +0200 Subject: [PATCH 092/143] Pass allowedPrefixes --- classes/Xodx/PersonController.php | 5 +++++ templates/person/profileeditor.phtml | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 7d87050..17d696a 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -363,6 +363,9 @@ public function profileeditorAction ($template) { $model = $this->_app->getBootstrap()->getResource('Model'); + $allowedPrefixes = array(); + $allowedPrefixes[] = "http://xmlns.com/foaf/0.1/nick"; + //TODO: Make this of course dynamic... $name = "test1"; @@ -386,7 +389,9 @@ public function profileeditorAction ($template) //echo("Result:
    "); //var_dump($profiles); //echo("
    "); + $template->allowedPrefixes = $allowedPrefixes; $template->profile = $profiles; + //var_dump($allowedPrefixes); $template->addContent('templates/profileeditor.phtml'); diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index af4afa0..e69381d 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -6,9 +6,6 @@ if (isset($this->profile)) { - $allowedPrefixes = array(); - $allowedPrefixes[] = "http://xmlns.com/foaf/0.1/nick"; - foreach ($this->profile as $key => $element) { //DONE: Filtern von z.B. foaf:knows @@ -25,7 +22,7 @@ if (isset($this->profile)) $keyX = $element["p"]; $elementX = $element["o"]; - if (in_array($keyX, $allowedPrefixes)) + if (in_array($keyX, $this->allowedPrefixes)) { echo ("
    From ec3cbf975a2d5d3d93d8e51944a65b6561b79d1c Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Mon, 16 Sep 2013 22:04:32 +0200 Subject: [PATCH 093/143] Multiple (prepared) --- classes/Xodx/PersonController.php | 3 +++ templates/person/profileeditor.phtml | 31 ++++++++++++++++------------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 17d696a..0b3b73c 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -363,8 +363,10 @@ public function profileeditorAction ($template) { $model = $this->_app->getBootstrap()->getResource('Model'); + //The following Stuff has to be passed through somehow. $allowedPrefixes = array(); $allowedPrefixes[] = "http://xmlns.com/foaf/0.1/nick"; + $multiple = false; //TODO: Make this of course dynamic... @@ -391,6 +393,7 @@ public function profileeditorAction ($template) //echo("
    "); $template->allowedPrefixes = $allowedPrefixes; $template->profile = $profiles; + $template->multiple = $multiple; //var_dump($allowedPrefixes); $template->addContent('templates/profileeditor.phtml'); diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index e69381d..66100b3 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -6,31 +6,36 @@ if (isset($this->profile)) { + $multiple = $this->multiple; + //var_dump($multiple); + echo ("
    "); foreach ($this->profile as $key => $element) { //DONE: Filtern von z.B. foaf:knows //DONE: Ressourcen gar nicht zeigen. //DONE: Array für erwünschte Prädikate definieren --> Was darf editiert werden? //DONE: und danach filtern. - //TODO: Unterscheidung zwischen Single und Multiple-Prädikaten + //PARTLY DONE: Unterscheidung zwischen Single und Multiple-Prädikaten //PARTLY DONE: Diff: Alte Werte löschen! - //if (!$allowedfields.contains($key)) - //{ - // break; - //} - $keyX = $element["p"]; $elementX = $element["o"]; if (in_array($keyX, $this->allowedPrefixes)) { - echo ("
    - -
    - - -
    -
    "); + if ($multiple) + { + echo ("Multiple Stuff not supperted. Yet."); + } + else + { + echo ("
    + +
    + + +
    +
    "); + } } } } From 481efc552adfa38c95d7ae38e4c1586b57afd58d Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Mon, 16 Sep 2013 22:44:23 +0200 Subject: [PATCH 094/143] Multiple --- classes/Xodx/PersonController.php | 80 ++++++++++++++++------------ templates/person/profileeditor.phtml | 3 +- 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 0b3b73c..ce0fb5f 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -319,44 +319,56 @@ public function editAction() $newValue; $changedADD = array(); $changedDELETE = array(); - foreach ($_POST as $key => $value) + $multiple = $_POST["multiple"]; + unset($_POST["multiple"]); + + if ($multiple) { - if (!$old) - { - $newKey = $key; - $newValue = $value; - $old = true; - } - else + //Multiple Stuff + echo ("Multiple."); + } + else + { + echo ("Single."); + foreach ($_POST as $key => $value) { - if ($value != $newValue) + if (!$old) + { + $newKey = $key; + $newValue = $value; + $old = true; + } + else { - $changedADD[$newKey] = $newValue; - $changedDELETE[$newKey] = $value; + if ($value != $newValue) + { + $changedADD[$newKey] = $newValue; + $changedDELETE[$newKey] = $value; + } + $old = false; } - $old = false; } - } - echo("Debug Add: "); - var_dump($changedADD); - echo("
    Debug Delete: "); - var_dump($changedDELETE); + echo("Debug Add: "); + var_dump($changedADD); + echo("
    Debug Delete: "); + var_dump($changedDELETE); - $nsFoaf = 'http://xmlns.com/foaf/0.1/'; - foreach ($changedDELETE as $key => $value) - { - //$keyArray = array('value' => ); - $valueArray = array('type' => $value); - echo ("
    Writing $key --- $value"); - $model->deleteStatement($userUri, $key, $valueArray); - } - foreach ($changedADD as $key => $value) - { - //$keyArray = array('value' => ); - $valueArray = array('type' => $value); - echo ("
    Writing $key --- $value"); - $model->addStatement($userUri, $key, $valueArray); - } + $nsFoaf = 'http://xmlns.com/foaf/0.1/'; + foreach ($changedDELETE as $key => $value) + { + //$keyArray = array('value' => ); + $valueArray = array('type' => $value); + echo ("
    Writing $key --- $value"); + $model->deleteStatement($userUri, $key, $valueArray); + } + foreach ($changedADD as $key => $value) + { + //$keyArray = array('value' => ); + $valueArray = array('type' => $value); + echo ("
    Writing $key --- $value"); + $model->addStatement($userUri, $key, $valueArray); + } + } } public function profileeditorAction ($template) @@ -381,8 +393,8 @@ public function profileeditorAction ($template) $stringArray = explode("id=", $userUri); //var_dump($stringArray); $name = $stringArray[1]; - echo ("Name: "); - echo ($name); + //echo ("Name: "); + //echo ($name); $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 66100b3..a4e1c85 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -8,7 +8,8 @@ if (isset($this->profile)) { $multiple = $this->multiple; //var_dump($multiple); - echo ("
    "); + $stringMultiple=(string)$multiple; + echo ("
    "); foreach ($this->profile as $key => $element) { //DONE: Filtern von z.B. foaf:knows From 2dca61fd590b50053ba645229884ffe485281866 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 21 Sep 2013 11:22:19 +0200 Subject: [PATCH 095/143] Go over all allowedPrefixes --- classes/Xodx/PersonController.php | 9 +++--- templates/partials/menu.phtml | 2 -- templates/person/profileeditor.phtml | 46 +++++++++++++--------------- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index ce0fb5f..f5d723a 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -374,16 +374,14 @@ public function editAction() public function profileeditorAction ($template) { $model = $this->_app->getBootstrap()->getResource('Model'); + $config = $this->_app->getBootstrap()->getResource('Config'); - //The following Stuff has to be passed through somehow. + //TODO: Pass this. $allowedPrefixes = array(); $allowedPrefixes[] = "http://xmlns.com/foaf/0.1/nick"; + $allowedPrefixes[] = "http://xmlns.com/foaf/0.1/depiction"; $multiple = false; - //TODO: Make this of course dynamic... - - $name = "test1"; - $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; @@ -406,6 +404,7 @@ public function profileeditorAction ($template) $template->allowedPrefixes = $allowedPrefixes; $template->profile = $profiles; $template->multiple = $multiple; + $template->config = $config; //var_dump($allowedPrefixes); $template->addContent('templates/profileeditor.phtml'); diff --git a/templates/partials/menu.phtml b/templates/partials/menu.phtml index c86bc91..d7e7fba 100644 --- a/templates/partials/menu.phtml +++ b/templates/partials/menu.phtml @@ -1,5 +1,3 @@ -Debug-Version. -
    @@ -56,3 +47,10 @@ else
    + +"); +var_dump($this -> config); + +?> From 4858e763027f0af81c7846c6b10c33e1056c7723 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 21 Sep 2013 15:51:03 +0200 Subject: [PATCH 096/143] Pass Prefixes correctly. --- classes/Xodx/PersonController.php | 113 ++++++++++++++++++--------- templates/partials/menu.phtml | 7 +- templates/person/profileeditor.phtml | 13 ++- 3 files changed, 90 insertions(+), 43 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index f5d723a..6fbefb2 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -314,61 +314,98 @@ public function editAction() $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; - $old = false; + $stringArray = explode("id=", $userUri); + $name = $stringArray[1]; + + $prefixesPrepare = array(); + $valuesPrepare = array(); + $valuesNew = array(); $newKey; $newValue; + $oldValue; $changedADD = array(); $changedDELETE = array(); $multiple = $_POST["multiple"]; unset($_POST["multiple"]); - if ($multiple) + //TODO: GET NAME + + $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; + $databaseValues = $model->sparqlQuery($query); + + //prepare $_POST into prefix --> value + foreach ($_POST as $key => $value) { - //Multiple Stuff - echo ("Multiple."); + $keyArray = explode("_", $key); + $number = (int)$keyArray[0]; + if ($keyArray[1] == "value") + { + $valuesPrepare[$number] = $value; + } + + if ($keyArray[1] == "prefix") + { + $prefixesPrepare[$number] = $value; + } } - else + + foreach ($prefixesPrepare as $key => $value) { - echo ("Single."); - foreach ($_POST as $key => $value) + $valuesNew[$value] = $valuesPrepare[(int)$key]; + } + + echo("Debug valuesNew: "); + var_dump($valuesNew); + //echo("
    Debug prefixesPrepare: "); + //var_dump($prefixesPrepare); + echo("
    "); + + foreach ($valuesNew as $key => $value) + { + //Reset old values + $oldValue = ""; + $newKey = $key; + + //find corresponding value in query + //Searches for equivalent of $newKey + foreach ($databaseValues as $key => $element) { - if (!$old) - { - $newKey = $key; - $newValue = $value; - $old = true; - } - else + $p = $element["p"]; + $o = $element["o"]; + //echo "
    $p -- $o"; + if (strcmp ($element["p"], $newKey) == 0) { - if ($value != $newValue) - { - $changedADD[$newKey] = $newValue; - $changedDELETE[$newKey] = $value; - } - $old = false; + $oldValue = $element["o"]; } } - echo("Debug Add: "); - var_dump($changedADD); - echo("
    Debug Delete: "); - var_dump($changedDELETE); - $nsFoaf = 'http://xmlns.com/foaf/0.1/'; - foreach ($changedDELETE as $key => $value) + if ($value != $oldValue) { - //$keyArray = array('value' => ); - $valueArray = array('type' => $value); - echo ("
    Writing $key --- $value"); - $model->deleteStatement($userUri, $key, $valueArray); + $changedADD[$newKey] = $value; + $changedDELETE[$newKey] = $oldValue; } - foreach ($changedADD as $key => $value) - { - //$keyArray = array('value' => ); - $valueArray = array('type' => $value); - echo ("
    Writing $key --- $value"); - $model->addStatement($userUri, $key, $valueArray); - } - } + } + + echo("Debug Delete: "); + var_dump($changedDELETE); + echo("
    Debug Add: "); + var_dump($changedADD); + + foreach ($changedDELETE as $key => $value) + { + //$keyArray = array('value' => ); + $valueArray = array('type' => $value); + echo ("
    Delete $key --- $value"); + //$model->deleteStatement($userUri, $key, $valueArray); + } + foreach ($changedADD as $key => $value) + { + //$keyArray = array('value' => ); + $valueArray = array('type' => $value); + echo ("
    Writing $key --- $value"); + //$model->addStatement($userUri, $key, $valueArray); + } + } public function profileeditorAction ($template) diff --git a/templates/partials/menu.phtml b/templates/partials/menu.phtml index d7e7fba..d0ffaf0 100644 --- a/templates/partials/menu.phtml +++ b/templates/partials/menu.phtml @@ -17,7 +17,12 @@
  • List All Profiles
  • diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index a4cc44d..e8eae3d 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -9,8 +9,9 @@ if (isset($this->profile)) $multiple = $this->multiple; //var_dump($multiple); $stringMultiple=(string)$multiple; - var_dump($this->profile); - echo ("
    "); + //var_dump($this->profile); + //echo ("
    "); + $counter = 0; foreach ($this->allowedPrefixes as $prefix) { $elementX = ""; @@ -22,13 +23,17 @@ if (isset($this->profile)) $elementX = $element["o"]; } } - + $counterText = (string)$counter; + $prefixText = $counterText ."_prefix"; + $valueText = $counterText . "_value"; echo ("
    - + +
    "); + $counter = $counter + 1; } } else From 2903e96599a49103a9d2e54fcf5e00dcc1d767ba Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 21 Sep 2013 17:33:27 +0200 Subject: [PATCH 097/143] configuration for ProfileEditor --- README.md | 9 +++++++ classes/Xodx/PersonController.php | 41 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/README.md b/README.md index 0094164..63c4ee9 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,15 @@ In order to get the JavaScript dependencies [twitter bootstrap](http://twitter.g in the xodx root directory (should be the same directory where you found this file). +Configuration +------------- +### Profile Editor +Here is described the configuration of the Profile Editor + +There are single and multiple Properties. They are stored in editor.single and editor.multiple respectivly. For every configured Property a corresponding RegEx has to be given. The RegEx can be given any Name, they are afterwards configured via regex.NameOfTheRegEx. Property and Regex are seperated by a comma, without space after the comma. editor.single and editor.multiple are composed with as many Property-RegEx Literals as needed, also seperated with a comma, without spaces. +Example: + + Code Conventions ---------------- Currently, this project is developed using [OntoWiki's coding standard](https://github.com/AKSW/OntoWiki/wiki/Coding-Standards). diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 6fbefb2..1a59c80 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -406,6 +406,8 @@ public function editAction() //$model->addStatement($userUri, $key, $valueArray); } + $this->loadPropertyRegex(); + } public function profileeditorAction ($template) @@ -462,4 +464,43 @@ private static function _issueE24fix ($date) return $date; } } + + public function loadPropertyRegex() + { + $properties = array(); + $config = $this->_app->getBootstrap()->getResource('Config'); + $bothConfigs = explode(",",$config["editor.single"].",".$config["editor.multiple"]); + //$multiple = explode(",",$config["editor.multiple"]); + $skip = false; + + foreach($bothConfigs as $key => $element) + { + if (!$skip) + { + $property = $element; + $skip = true; + } + else + { + $skip = false; + $properties[$property] = $this->propertyRegex($element); + } + } + + //echo("Dump:
    "); + //var_dump($properties); + //var_dump($single); + //var_dump($multiple); + //var_dump($config["editor.single"]); + //var_dump($config["editor.multiple"]); + + return $properties; + } + + public function propertyRegex($regexName) + { + $config = $this->_app->getBootstrap()->getResource('Config'); + $regexString = "regex.".$regexName; + return $config[$regexString]; + } } From ae10c8bf2f5745a56b9c0ae05d04a09c42c57285 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 21 Sep 2013 17:51:30 +0200 Subject: [PATCH 098/143] Load (single) Properties from config --- classes/Xodx/PersonController.php | 47 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 1a59c80..59e6940 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -405,50 +405,32 @@ public function editAction() echo ("
    Writing $key --- $value"); //$model->addStatement($userUri, $key, $valueArray); } - - $this->loadPropertyRegex(); - } public function profileeditorAction ($template) { $model = $this->_app->getBootstrap()->getResource('Model'); - $config = $this->_app->getBootstrap()->getResource('Config'); + $allowedPrefixes = $this->loadPropertiesSingle(); - //TODO: Pass this. - $allowedPrefixes = array(); - $allowedPrefixes[] = "http://xmlns.com/foaf/0.1/nick"; - $allowedPrefixes[] = "http://xmlns.com/foaf/0.1/depiction"; $multiple = false; $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; - //echo ($userUri); - //(getPerson($userUri)); - //$name = $userUri; $stringArray = explode("id=", $userUri); - //var_dump($stringArray); $name = $stringArray[1]; - //echo ("Name: "); - //echo ($name); $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; $profiles = $model->sparqlQuery( $query); - //echo("Result:
    "); - //var_dump($profiles); - //echo("
    "); $template->allowedPrefixes = $allowedPrefixes; $template->profile = $profiles; $template->multiple = $multiple; $template->config = $config; - //var_dump($allowedPrefixes); $template->addContent('templates/profileeditor.phtml'); - //$this$_GET["url"]; return $template; } @@ -470,7 +452,6 @@ public function loadPropertyRegex() $properties = array(); $config = $this->_app->getBootstrap()->getResource('Config'); $bothConfigs = explode(",",$config["editor.single"].",".$config["editor.multiple"]); - //$multiple = explode(",",$config["editor.multiple"]); $skip = false; foreach($bothConfigs as $key => $element) @@ -487,8 +468,8 @@ public function loadPropertyRegex() } } - //echo("Dump:
    "); - //var_dump($properties); + echo("Dump:
    "); + var_dump($properties); //var_dump($single); //var_dump($multiple); //var_dump($config["editor.single"]); @@ -503,4 +484,26 @@ public function propertyRegex($regexName) $regexString = "regex.".$regexName; return $config[$regexString]; } + + public function loadPropertiesSingle() + { + $properties = array(); + $config = $this->_app->getBootstrap()->getResource('Config'); + $single = explode(",",$config["editor.single"]); + $skip = false; + + foreach($single as $key => $element) + { + if (!$skip) + { + $properties[] = $element; + $skip = true; + } + else + { + $skip = false; + } + } + return $properties; + } } From 9a7225830277236d5dbbac872d78d7dbcd702686 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 21 Sep 2013 17:55:21 +0200 Subject: [PATCH 099/143] Config for Profile Editor in config.ini-dist --- config.ini-dist | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config.ini-dist b/config.ini-dist index 995cee8..062ff75 100644 --- a/config.ini-dist +++ b/config.ini-dist @@ -8,6 +8,16 @@ push.hub = "http://pubsubhubbub.appspot.com" ;push.hub = "http://localhost:8123/" ;push.hub = "http://localhost/OntoWiki/pubsub/hubbub" +;Parameters for Profile Editor +editor.single = http://xmlns.com/foaf/0.1/depiction,URL +editor.multiple = http://xmlns.com/foaf/0.1/schoolHomepage,URL,http://xmlns.com/foaf/0.1/jabberID,Email + +regex.URL = "_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/[^\s]*)?$_iuS" +; by http://mathiasbynens.be/demo/url-regex +regex.Email = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@ +(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" +; by http://www.regular-expressions.info/email.html + [erfurt] ; In this section you can configure the Erfurt framework From 2527603c3d343a9449236e96ba4b0ffefb265171 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 22 Sep 2013 17:06:53 +0200 Subject: [PATCH 100/143] Saving apparently works. --- classes/Xodx/PersonController.php | 13 +++++++------ templates/person/profileeditor.phtml | 8 -------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 59e6940..59ad55c 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -394,16 +394,17 @@ public function editAction() foreach ($changedDELETE as $key => $value) { //$keyArray = array('value' => ); - $valueArray = array('type' => $value); - echo ("
    Delete $key --- $value"); - //$model->deleteStatement($userUri, $key, $valueArray); + $valueArray = array('type' => 'uri', 'value' => $value); + echo ("
    Delete: $userUri, $key, $value"); + $model->deleteStatement($userUri, $key, $valueArray); } foreach ($changedADD as $key => $value) { //$keyArray = array('value' => ); - $valueArray = array('type' => $value); - echo ("
    Writing $key --- $value"); - //$model->addStatement($userUri, $key, $valueArray); + //array('type' => 'uri', 'value' => $newPersonUri) + $valueArray = array('type' => 'uri', 'value' => $value); + echo ("
    Writing: $userUri, $key, $value"); + $model->addStatement($userUri, $key, $valueArray); } } diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index e8eae3d..010d7b2 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -51,11 +51,3 @@ else - - -"); -var_dump($this -> config); - -?> From 5f293dcc0a0b5bd526f1d616306131f8e12a5a63 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Tue, 24 Sep 2013 18:13:26 +0200 Subject: [PATCH 101/143] RegEx is executed, but only debugged. --- classes/Xodx/PersonController.php | 30 ++++++++++++++++++++++++------ templates/partials/menu.phtml | 7 +++++-- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 59ad55c..e0fe75b 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -316,6 +316,7 @@ public function editAction() $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; $stringArray = explode("id=", $userUri); $name = $stringArray[1]; + $propertyRegex = $this -> loadPropertyRegex(); $prefixesPrepare = array(); $valuesPrepare = array(); @@ -325,6 +326,7 @@ public function editAction() $oldValue; $changedADD = array(); $changedDELETE = array(); + $wrong = array(); $multiple = $_POST["multiple"]; unset($_POST["multiple"]); @@ -381,8 +383,23 @@ public function editAction() if ($value != $oldValue) { - $changedADD[$newKey] = $value; - $changedDELETE[$newKey] = $oldValue; + //echo ("$value != $oldValue
    "); + + $rString = $propertyRegex[$newKey]; + //echo ("Regex for $newKey: $rString
    "); + //$fooo = preg_match($String, $value); + //var_dump($fooo); + if (preg_match($String, $value) === true) + { + echo ("Match: $value for $newKey"); + $changedADD[$newKey] = $value; + $changedDELETE[$newKey] = $oldValue; + } + else + { + echo ("Wrong Format: $value for $newKey
    "); + $wrong[$newKey] == $value; + } } } @@ -394,7 +411,7 @@ public function editAction() foreach ($changedDELETE as $key => $value) { //$keyArray = array('value' => ); - $valueArray = array('type' => 'uri', 'value' => $value); + $valueArray = array('type' => 'literal', 'value' => $value); echo ("
    Delete: $userUri, $key, $value"); $model->deleteStatement($userUri, $key, $valueArray); } @@ -402,7 +419,7 @@ public function editAction() { //$keyArray = array('value' => ); //array('type' => 'uri', 'value' => $newPersonUri) - $valueArray = array('type' => 'uri', 'value' => $value); + $valueArray = array('type' => 'literal', 'value' => $value); echo ("
    Writing: $userUri, $key, $value"); $model->addStatement($userUri, $key, $valueArray); } @@ -469,8 +486,8 @@ public function loadPropertyRegex() } } - echo("Dump:
    "); - var_dump($properties); + //echo("Dump:
    "); + //var_dump($properties); //var_dump($single); //var_dump($multiple); //var_dump($config["editor.single"]); @@ -481,6 +498,7 @@ public function loadPropertyRegex() public function propertyRegex($regexName) { + //echo "propertyRegex: $regexName
    "; $config = $this->_app->getBootstrap()->getResource('Config'); $regexString = "regex.".$regexName; return $config[$regexString]; diff --git a/templates/partials/menu.phtml b/templates/partials/menu.phtml index d0ffaf0..4416b13 100644 --- a/templates/partials/menu.phtml +++ b/templates/partials/menu.phtml @@ -21,10 +21,13 @@ if ($this->username != "guest") { echo ("
  • Profile Editor
  • "); + echo ("
  • Logout
  • "); + } + else + { + echo ("
  • Login
  • "); } ?> -
  • Login
  • -
  • Logout
  • From a6786f69adef99c01b4cca61e67220c7d5d65691 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 29 Sep 2013 15:19:01 +0200 Subject: [PATCH 102/143] editAction -> profileeditorAction --- classes/Xodx/PersonController.php | 89 +++++++++++++++++----------- templates/person/profileeditor.phtml | 40 ++++++++++--- 2 files changed, 86 insertions(+), 43 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index e0fe75b..37d76f3 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -292,9 +292,39 @@ public function getNotifications ($personUri) return $pingResult; } - public function editAction() + public function profileeditorAction ($template) { -//This is stuff for Debugging + $model = $this->_app->getBootstrap()->getResource('Model'); + + if (count ($_POST) == 0) + { + + $allowedSinglePrefixes = $this->loadPropertiesSingle(); + $allowedMultiplePrefixes = $this->loadPropertiesMultiple(); + + $applicationController = $this->_app->getController('Xodx_ApplicationController'); + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; + $stringArray = explode("id=", $userUri); + $name = $stringArray[1]; + + $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; + //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; + + $profiles = $model->sparqlQuery( $query); + $template->allowedSinglePrefixes = $allowedSinglePrefixes; + $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; + $template->profile = $profiles; + $template->config = $config; + + $template->addContent('templates/profileeditor.phtml'); + + return $template; + + } + else + { + //This is stuff for Debugging echo ("You sent me this:
    "); var_dump($_POST); echo ("
    Lenght:"); @@ -423,33 +453,10 @@ public function editAction() echo ("
    Writing: $userUri, $key, $value"); $model->addStatement($userUri, $key, $valueArray); } - } - - public function profileeditorAction ($template) - { - $model = $this->_app->getBootstrap()->getResource('Model'); - $allowedPrefixes = $this->loadPropertiesSingle(); - - $multiple = false; - - $applicationController = $this->_app->getController('Xodx_ApplicationController'); - $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; - $stringArray = explode("id=", $userUri); - $name = $stringArray[1]; - - $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; - //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; - - $profiles = $model->sparqlQuery( $query); - $template->allowedPrefixes = $allowedPrefixes; - $template->profile = $profiles; - $template->multiple = $multiple; - $template->config = $config; $template->addContent('templates/profileeditor.phtml'); - return $template; + } } /** @@ -485,14 +492,6 @@ public function loadPropertyRegex() $properties[$property] = $this->propertyRegex($element); } } - - //echo("Dump:
    "); - //var_dump($properties); - //var_dump($single); - //var_dump($multiple); - //var_dump($config["editor.single"]); - //var_dump($config["editor.multiple"]); - return $properties; } @@ -511,6 +510,28 @@ public function loadPropertiesSingle() $single = explode(",",$config["editor.single"]); $skip = false; + foreach($single as $key => $element) + { + if (!$skip) + { + $properties[] = $element; + $skip = true; + } + else + { + $skip = false; + } + } + return $properties; + } + + public function loadPropertiesMultiple() + { + $properties = array(); + $config = $this->_app->getBootstrap()->getResource('Config'); + $single = explode(",",$config["editor.multiple"]); + $skip = false; + foreach($single as $key => $element) { if (!$skip) diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 010d7b2..6a2fadc 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -1,18 +1,14 @@ 

    Profil Editor

    -
    + +
    profile)) -{ - $multiple = $this->multiple; - //var_dump($multiple); - $stringMultiple=(string)$multiple; - //var_dump($this->profile); - //echo ("
    "); + { $counter = 0; - foreach ($this->allowedPrefixes as $prefix) + echo ("Single
    "); + foreach ($this->allowedSinglePrefixes as $prefix) { $elementX = ""; //HACK: Do we have LINQ or at least something to make this better? @@ -35,6 +31,32 @@ if (isset($this->profile)) "); $counter = $counter + 1; } + + echo ("Multiple
    "); + foreach ($this->allowedMultiplePrefixes as $prefix) + { + //$elementX = ""; + ////HACK: Do we have LINQ or at least something to make this better? + //foreach ($this->profile as $key => $element) + //{ + //if ($element["p"] == $prefix) + //{ + //$elementX = $element["o"]; + //} + //} + //$counterText = (string)$counter; + //$prefixText = $counterText ."_prefix"; + //$valueText = $counterText . "_value"; + //echo ("
    + // + //
    + // + // + //
    + //
    "); + //$counter = $counter + 1; + echo ("Prefix: $prefix
    "); + } } else { From 1fa84563f66840c02723ac9e241cc78f1536c6da Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 29 Sep 2013 18:08:36 +0200 Subject: [PATCH 103/143] Write Fields for Multiple Properties --- classes/Xodx/PersonController.php | 283 +++++++++++++++------------ templates/person/profileeditor.phtml | 62 +++--- 2 files changed, 194 insertions(+), 151 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 37d76f3..6ae7176 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -298,164 +298,191 @@ public function profileeditorAction ($template) if (count ($_POST) == 0) { + // Show editor with data from database + $allowedSinglePrefixes = $this->loadPropertiesSingle(); + $allowedMultiplePrefixes = $this->loadPropertiesMultiple(); - $allowedSinglePrefixes = $this->loadPropertiesSingle(); - $allowedMultiplePrefixes = $this->loadPropertiesMultiple(); + $applicationController = $this->_app->getController('Xodx_ApplicationController'); + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; + $stringArray = explode("id=", $userUri); + $name = $stringArray[1]; - $applicationController = $this->_app->getController('Xodx_ApplicationController'); - $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; - $stringArray = explode("id=", $userUri); - $name = $stringArray[1]; + $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; + //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; - $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; - //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; + $profiles = $model->sparqlQuery( $query); + $template->allowedSinglePrefixes = $allowedSinglePrefixes; + $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; + $template->profile = $profiles; + $template->config = $config; - $profiles = $model->sparqlQuery( $query); - $template->allowedSinglePrefixes = $allowedSinglePrefixes; - $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; - $template->profile = $profiles; - $template->config = $config; - - $template->addContent('templates/profileeditor.phtml'); - - return $template; + $template->addContent('templates/profileeditor.phtml'); + return $template; } else { - //This is stuff for Debugging - echo ("You sent me this:
    "); - var_dump($_POST); - echo ("
    Lenght:"); - echo (count($_POST)); - echo ("ArrayForEach

    "); - foreach ($_POST as $key => $value) - { - echo ($key); - echo ("->"); - echo ($value); - echo ("
    "); - } + //Process POSTed values an show ProfileEditor with + // a) Data from POST if it needs to be corrected + // TODO: Indicated that data... + // b) Data from Database if everything was fine so the new data in the DB can be viewed. + + //This is stuff for Debugging + echo ("You sent me this:
    "); + var_dump($_POST); + echo ("
    Lenght:"); + echo (count($_POST)); + echo ("ArrayForEach

    "); + foreach ($_POST as $key => $value) + { + echo ($key); + echo ("->"); + echo ($value); + echo ("
    "); + } - echo ("
    "); -//This is real sourcecode! - $model = $this->_app->getBootstrap()->getResource('model'); - $applicationController = $this->_app->getController('Xodx_ApplicationController'); - $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; - $stringArray = explode("id=", $userUri); - $name = $stringArray[1]; - $propertyRegex = $this -> loadPropertyRegex(); - - $prefixesPrepare = array(); - $valuesPrepare = array(); - $valuesNew = array(); - $newKey; - $newValue; - $oldValue; - $changedADD = array(); - $changedDELETE = array(); - $wrong = array(); - $multiple = $_POST["multiple"]; - unset($_POST["multiple"]); - - //TODO: GET NAME - - $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; - $databaseValues = $model->sparqlQuery($query); - - //prepare $_POST into prefix --> value - foreach ($_POST as $key => $value) - { - $keyArray = explode("_", $key); - $number = (int)$keyArray[0]; - if ($keyArray[1] == "value") + echo ("
    "); + + //This is real sourcecode! + $model = $this->_app->getBootstrap()->getResource('model'); + $applicationController = $this->_app->getController('Xodx_ApplicationController'); + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; + $stringArray = explode("id=", $userUri); + $name = $stringArray[1]; + $propertyRegex = $this -> loadPropertyRegex(); + + $prefixesSinglePrepare = array(); + $valuesSinglePrepare = array(); + $prefixesMultiplePrepare = array(); + $valuesMultiplePrepare = array(); + $valuesNew = array(); + $newKey; + $newValue; + $oldValue; + $changedADD = array(); + $changedDELETE = array(); + $wrong = array(); + + //TODO: GET NAME + + $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; + $databaseValues = $model->sparqlQuery($query); + + //prepare $_POST into prefix --> value + foreach ($_POST as $key => $value) { - $valuesPrepare[$number] = $value; + $keyArray = explode("_", $key); + $number = (int)$keyArray[0]; + //single + if ($keyArray[1] == "value") + { + $valuesSinglePrepare[$number] = $value; + } + + if ($keyArray[1] == "prefix") + { + $prefixesSinglePrepare[$number] = $value; + } + + //multiple } - if ($keyArray[1] == "prefix") + foreach ($prefixesSinglePrepare as $key => $value) { - $prefixesPrepare[$number] = $value; + $valuesNew[$value] = $valuesSinglePrepare[(int)$key]; } - } - foreach ($prefixesPrepare as $key => $value) - { - $valuesNew[$value] = $valuesPrepare[(int)$key]; - } + echo("Debug valuesNew: "); + var_dump($valuesNew); + //echo("
    Debug prefixesPrepare: "); + //var_dump($prefixesSinglePrepare); + echo("
    "); - echo("Debug valuesNew: "); - var_dump($valuesNew); - //echo("
    Debug prefixesPrepare: "); - //var_dump($prefixesPrepare); - echo("
    "); + foreach ($valuesNew as $key => $value) + { + //Reset old values + $oldValue = ""; + $newKey = $key; - foreach ($valuesNew as $key => $value) - { - //Reset old values - $oldValue = ""; - $newKey = $key; + //find corresponding value in query + //Searches for equivalent of $newKey + foreach ($databaseValues as $key => $element) + { + $p = $element["p"]; + $o = $element["o"]; + //echo "
    $p -- $o"; + if (strcmp ($element["p"], $newKey) == 0) + { + $oldValue = $element["o"]; + } + } - //find corresponding value in query - //Searches for equivalent of $newKey - foreach ($databaseValues as $key => $element) - { - $p = $element["p"]; - $o = $element["o"]; - //echo "
    $p -- $o"; - if (strcmp ($element["p"], $newKey) == 0) + if ($value != $oldValue) { - $oldValue = $element["o"]; + //echo ("$value != $oldValue
    "); + + $rString = $propertyRegex[$newKey]; + //echo ("Regex for $newKey: $rString
    "); + //$fooo = preg_match($String, $value); + //var_dump($fooo); + if (preg_match($String, $value) === true) + { + echo ("Match: $value for $newKey"); + $changedADD[$newKey] = $value; + $changedDELETE[$newKey] = $oldValue; + } + else + { + echo ("Wrong Format: $value for $newKey
    "); + $wrong[$newKey] = $value; + } } } - if ($value != $oldValue) + echo("Debug Delete: "); + var_dump($changedDELETE); + echo("
    Debug Add: "); + var_dump($changedADD); + echo("
    Wrong: "); + echo(count($wrong)); + echo("
    "); + var_dump($wrong); + + if (count($wrong) > 0) { - //echo ("$value != $oldValue
    "); + //Allow wrong Properties to be corrected - $rString = $propertyRegex[$newKey]; - //echo ("Regex for $newKey: $rString
    "); - //$fooo = preg_match($String, $value); - //var_dump($fooo); - if (preg_match($String, $value) === true) + + } + else + { + //Write Properties to Database + foreach ($changedDELETE as $key => $value) { - echo ("Match: $value for $newKey"); - $changedADD[$newKey] = $value; - $changedDELETE[$newKey] = $oldValue; + //$keyArray = array('value' => ); + $valueArray = array('type' => 'literal', 'value' => $value); + echo ("
    Delete: $userUri, $key, $value"); + $model->deleteStatement($userUri, $key, $valueArray); } - else + foreach ($changedADD as $key => $value) { - echo ("Wrong Format: $value for $newKey
    "); - $wrong[$newKey] == $value; + //$keyArray = array('value' => ); + //array('type' => 'uri', 'value' => $newPersonUri) + $valueArray = array('type' => 'literal', 'value' => $value); + echo ("
    Writing: $userUri, $key, $value"); + $model->addStatement($userUri, $key, $valueArray); } - } - } - - echo("Debug Delete: "); - var_dump($changedDELETE); - echo("
    Debug Add: "); - var_dump($changedADD); - foreach ($changedDELETE as $key => $value) - { - //$keyArray = array('value' => ); - $valueArray = array('type' => 'literal', 'value' => $value); - echo ("
    Delete: $userUri, $key, $value"); - $model->deleteStatement($userUri, $key, $valueArray); - } - foreach ($changedADD as $key => $value) - { - //$keyArray = array('value' => ); - //array('type' => 'uri', 'value' => $newPersonUri) - $valueArray = array('type' => 'literal', 'value' => $value); - echo ("
    Writing: $userUri, $key, $value"); - $model->addStatement($userUri, $key, $valueArray); - } + //Show Profileeditor with Values from Database. + $_POST = NULL; + $template = $this -> profileeditorAction($template); + return $template; + } - $template->addContent('templates/profileeditor.phtml'); - return $template; + $template->addContent('templates/profileeditor.phtml'); + return $template; } } diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 6a2fadc..d7deee3 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -7,7 +7,7 @@ if (isset($this->profile)) { $counter = 0; - echo ("Single
    "); + //echo ("Single
    "); foreach ($this->allowedSinglePrefixes as $prefix) { $elementX = ""; @@ -32,30 +32,46 @@ if (isset($this->profile)) $counter = $counter + 1; } - echo ("Multiple
    "); + $counter = 0; + //echo ("Multiple
    "); foreach ($this->allowedMultiplePrefixes as $prefix) { - //$elementX = ""; - ////HACK: Do we have LINQ or at least something to make this better? - //foreach ($this->profile as $key => $element) - //{ - //if ($element["p"] == $prefix) - //{ - //$elementX = $element["o"]; - //} - //} - //$counterText = (string)$counter; - //$prefixText = $counterText ."_prefix"; - //$valueText = $counterText . "_value"; - //echo ("
    - // - //
    - // - // - //
    - //
    "); - //$counter = $counter + 1; - echo ("Prefix: $prefix
    "); + $elementX = ""; + $i = 0; + $counterText = (string)$counter; + //HACK: Do we have LINQ or at least something to make this better? + foreach ($this->profile as $key => $element) + { + if ($element["p"] == $prefix) + { + $elementX = $element["o"]; + + $prefixText = $counterText ."_Mprefix_$i"; + $valueText = $counterText . "_Mvalue_$i"; + echo ("
    + +
    + + +
    +
    "); + + $i=$i+1; + } + } + + $prefixText = $counterText ."_Mprefix_$i"; + $valueText = $counterText . "_Mvalue_$i"; + echo ("
    + +
    + + +
    +
    "); + + $counter = $counter + 1; + //echo ("Prefix: $prefix
    "); } } else From f87d8490477bc89dce346d53f89235cafec733d8 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 29 Sep 2013 18:45:41 +0200 Subject: [PATCH 104/143] config.ini-dist --- config.ini-dist | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config.ini-dist b/config.ini-dist index 062ff75..de9bc2f 100644 --- a/config.ini-dist +++ b/config.ini-dist @@ -1,7 +1,7 @@ [xodx] ; In this section you can tune some parameters of XODX -xodx.model = "http://localhost/Xodx" +xodx.model = "http://192.168.56.101/xodx-dev" push.enable = true; push.hub = "http://pubsubhubbub.appspot.com" @@ -9,14 +9,14 @@ push.hub = "http://pubsubhubbub.appspot.com" ;push.hub = "http://localhost/OntoWiki/pubsub/hubbub" ;Parameters for Profile Editor -editor.single = http://xmlns.com/foaf/0.1/depiction,URL -editor.multiple = http://xmlns.com/foaf/0.1/schoolHomepage,URL,http://xmlns.com/foaf/0.1/jabberID,Email +editor.single = http://xmlns.com/foaf/0.1/depiction,URL,http://xmlns.com/foaf/0.1/nick,Literal,http://xmlns.com/foaf/0.1/name,Literal +editor.multiple = http://xmlns.com/foaf/0.1/schoolHomepage,URL,http://xmlns.com/foaf/0.1/jabberID,Email,http://www.w3.org/2000/01/rdf-schema#seeAlso,URL,http://xmlns.com/foaf/0.1/based_near,URL,http://xmlns.com/foaf/0.1/weblog,URL,http://xmlns.com/foaf/0.1/workplaceHomepage,URL regex.URL = "_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/[^\s]*)?$_iuS" ; by http://mathiasbynens.be/demo/url-regex -regex.Email = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@ -(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" +regex.Email = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" ; by http://www.regular-expressions.info/email.html +regex.Literal = "[A-Za-z0-9]+" [erfurt] ; In this section you can configure the Erfurt framework @@ -53,4 +53,4 @@ foaf = 'http://xmlns.com/foaf/0.1/'; dssn = 'http://purl.org/net/dssn/'; ow = 'http://ns.ontowiki.net/SysOnt/'; ov = 'http://open.vocab.org/docs/'; -rel = 'http://purl.org/vocab/relationship/' +rel = 'http://purl.org/vocab/relationship/' \ No newline at end of file From 11e2c2c2d8ce4d02a77386c0a19328c2d0bc6c38 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 29 Sep 2013 20:56:39 +0200 Subject: [PATCH 105/143] Multiple Statements --- classes/Xodx/PersonController.php | 135 +++++++++++++++++++++------ templates/person/profileeditor.phtml | 4 +- 2 files changed, 110 insertions(+), 29 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 6ae7176..d6c67ed 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -295,13 +295,12 @@ public function getNotifications ($personUri) public function profileeditorAction ($template) { $model = $this->_app->getBootstrap()->getResource('Model'); + $allowedSinglePrefixes = $this->loadPropertiesSingle(); + $allowedMultiplePrefixes = $this->loadPropertiesMultiple(); if (count ($_POST) == 0) { // Show editor with data from database - $allowedSinglePrefixes = $this->loadPropertiesSingle(); - $allowedMultiplePrefixes = $this->loadPropertiesMultiple(); - $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; @@ -333,7 +332,7 @@ public function profileeditorAction ($template) var_dump($_POST); echo ("
    Lenght:"); echo (count($_POST)); - echo ("ArrayForEach

    "); + echo ("
    ArrayForEach
    "); foreach ($_POST as $key => $value) { echo ($key); @@ -345,7 +344,6 @@ public function profileeditorAction ($template) echo ("
    "); //This is real sourcecode! - $model = $this->_app->getBootstrap()->getResource('model'); $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; @@ -357,7 +355,8 @@ public function profileeditorAction ($template) $valuesSinglePrepare = array(); $prefixesMultiplePrepare = array(); $valuesMultiplePrepare = array(); - $valuesNew = array(); + $valuesSingleNew = array(); + $valuesMultipleNew = array(); $newKey; $newValue; $oldValue; @@ -370,11 +369,16 @@ public function profileeditorAction ($template) $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; $databaseValues = $model->sparqlQuery($query); + echo ("Database Values:
    "); + var_dump($databaseValues); + echo ("
    "); + //prepare $_POST into prefix --> value foreach ($_POST as $key => $value) { $keyArray = explode("_", $key); $number = (int)$keyArray[0]; + //single if ($keyArray[1] == "value") { @@ -387,20 +391,35 @@ public function profileeditorAction ($template) } //multiple + //$numberInKey is only needed if Property is multiple, so it is put inside the if statements. + if ($keyArray[1] == "Mvalue") + { + $numberInKey = (int)$keyArray[count($keyArray)-1]; + $valuesMultiplePrepare[$number][$numberInKey] = $value; + } + + if ($keyArray[1] == "Mprefix") + { + $numberInKey = (int)$keyArray[count($keyArray)-1]; + $prefixesMultiplePrepare[$number] = $value; + } } foreach ($prefixesSinglePrepare as $key => $value) { - $valuesNew[$value] = $valuesSinglePrepare[(int)$key]; + $valuesSingleNew[$value] = $valuesSinglePrepare[(int)$key]; } - echo("Debug valuesNew: "); - var_dump($valuesNew); - //echo("
    Debug prefixesPrepare: "); - //var_dump($prefixesSinglePrepare); - echo("
    "); + ////echo("Debug valuesNew: "); + ////var_dump($valuesSingleNew); + //echo("
    Debug prefixesMultiplePrepare: "); + //var_dump($prefixesMultiplePrepare); + //echo("
    Debug valuesMultiplePrepare: "); + //var_dump($valuesMultiplePrepare); + //echo("
    "); - foreach ($valuesNew as $key => $value) + //Single + foreach ($valuesSingleNew as $key => $value) { //Reset old values $oldValue = ""; @@ -421,17 +440,18 @@ public function profileeditorAction ($template) if ($value != $oldValue) { - //echo ("$value != $oldValue
    "); - $rString = $propertyRegex[$newKey]; - //echo ("Regex for $newKey: $rString
    "); - //$fooo = preg_match($String, $value); - //var_dump($fooo); - if (preg_match($String, $value) === true) + if (preg_match($rString, $value) === true) { echo ("Match: $value for $newKey"); - $changedADD[$newKey] = $value; - $changedDELETE[$newKey] = $oldValue; + $temp = array(); + $temp['p'] = $newKey; + $temp['o'] = $value; + $changedADD[] = $temp; + $temp = array(); + $temp['p'] = $newKey; + $temp['o'] = $oldValue; + $changedDELETE[] = $temp; } else { @@ -441,6 +461,63 @@ public function profileeditorAction ($template) } } + //Multiple + echo ("Multiple
    "); + foreach ($prefixesMultiplePrepare as $prefixKey => $prefix) + { + $values = $valuesMultiplePrepare[$prefixKey]; + foreach ($values as $valueKey => $value) + { + // 1. Forall key->value in newValues + // 1.1 Find corresponding value. + if ($value == "") + { + break; + } + $found = false; + //echo ("Looking for $prefix -> $value
    "); + foreach ($databaseValues as $key => $element) + { + //only for MultipleStatements + $p = $element["p"]; + $o = $element["o"]; + if (in_array($p, $allowedMultiplePrefixes)) + { + if (strcmp ($p, $prefix) == 0) + { + if (strcmp ($o, $value) == 0) + { + //1.2 Delete this pair from $oldValues + //TODO: Implement this. + $found = true; + } + } + } + } + if (!$found) + { + echo ("Not found: $prefix -> $value
    "); + $rString = $propertyRegex[$prefix]; + if (preg_match($rString, $value) === true) + { + echo ("Match: $value for $newKey"); + $temp = array(); + $temp['p'] = $prefix; + $temp['o'] = $value; + $changedADD[] = $temp; + } + else + { + echo ("Wrong Format: $value for $prefix
    "); + $temp = array(); + $temp['p'] = $prefix; + $temp['o'] = $value; + $wrong[] = $temp; + } + } + } + } + echo("Debug Delete: "); var_dump($changedDELETE); echo("
    Debug Add: "); @@ -462,17 +539,21 @@ public function profileeditorAction ($template) foreach ($changedDELETE as $key => $value) { //$keyArray = array('value' => ); - $valueArray = array('type' => 'literal', 'value' => $value); - echo ("
    Delete: $userUri, $key, $value"); - $model->deleteStatement($userUri, $key, $valueArray); + $valueArray = array('type' => 'literal', 'value' => $value['o']); + $keyToWrite = $value['p']; + $valueToWrite = $value['o']; + echo ("
    Delete: $userUri, $keyToWrite, $valueToWrite"); + //$model->deleteStatement($userUri, $keyToWrite, $valueArray); } foreach ($changedADD as $key => $value) { //$keyArray = array('value' => ); //array('type' => 'uri', 'value' => $newPersonUri) - $valueArray = array('type' => 'literal', 'value' => $value); - echo ("
    Writing: $userUri, $key, $value"); - $model->addStatement($userUri, $key, $valueArray); + $valueArray = array('type' => 'literal', 'value' => $value['o']); + $keyToDelete = $value['p']; + $valueToDelete = $value['o']; + echo ("
    Writing: $userUri, $keyToDelete, $valueToDelete"); + //$model->addStatement($userUri, $keyToDelete, $valueArray); } //Show Profileeditor with Values from Database. diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index d7deee3..76e0c6b 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -46,7 +46,7 @@ if (isset($this->profile)) { $elementX = $element["o"]; - $prefixText = $counterText ."_Mprefix_$i"; + $prefixText = $counterText ."_Mprefix"; $valueText = $counterText . "_Mvalue_$i"; echo ("
    @@ -60,7 +60,7 @@ if (isset($this->profile)) } } - $prefixText = $counterText ."_Mprefix_$i"; + $prefixText = $counterText ."_Mprefix"; $valueText = $counterText . "_Mvalue_$i"; echo ("
    From 409eb48986ca35b9e6a7c5467604fa01d13e78a8 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 29 Sep 2013 22:12:45 +0200 Subject: [PATCH 106/143] preg_match corrected --- classes/Xodx/PersonController.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index d6c67ed..4b2d88c 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -496,11 +496,12 @@ public function profileeditorAction ($template) } if (!$found) { - echo ("Not found: $prefix -> $value
    "); + //echo ("Not found: $prefix -> $value
    "); $rString = $propertyRegex[$prefix]; - if (preg_match($rString, $value) === true) + //echo ("$rString"); + if (preg_match($rString, $value) == true) { - echo ("Match: $value for $newKey"); + //echo ("Match: $value for $newKey"); $temp = array(); $temp['p'] = $prefix; $temp['o'] = $value; @@ -522,15 +523,15 @@ public function profileeditorAction ($template) var_dump($changedDELETE); echo("
    Debug Add: "); var_dump($changedADD); - echo("
    Wrong: "); - echo(count($wrong)); - echo("
    "); - var_dump($wrong); + //echo("
    Wrong: "); + //echo(count($wrong)); + //echo("
    "); + //var_dump($wrong); if (count($wrong) > 0) { //Allow wrong Properties to be corrected - + //TODO } else @@ -543,7 +544,7 @@ public function profileeditorAction ($template) $keyToWrite = $value['p']; $valueToWrite = $value['o']; echo ("
    Delete: $userUri, $keyToWrite, $valueToWrite"); - //$model->deleteStatement($userUri, $keyToWrite, $valueArray); + $model->deleteStatement($userUri, $keyToWrite, $valueArray); } foreach ($changedADD as $key => $value) { @@ -553,7 +554,7 @@ public function profileeditorAction ($template) $keyToDelete = $value['p']; $valueToDelete = $value['o']; echo ("
    Writing: $userUri, $keyToDelete, $valueToDelete"); - //$model->addStatement($userUri, $keyToDelete, $valueArray); + $model->addStatement($userUri, $keyToDelete, $valueArray); } //Show Profileeditor with Values from Database. From 5554f856420f499bcfd0a944e3b7e7c0ecaf459c Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 29 Sep 2013 22:42:30 +0200 Subject: [PATCH 107/143] Indicate wrong Properties Removed unused Echos and var_dumps --- classes/Xodx/PersonController.php | 65 +++++++++++++++------------- templates/person/profileeditor.phtml | 46 ++++++++++++++++---- 2 files changed, 73 insertions(+), 38 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 4b2d88c..73fd06f 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -328,20 +328,20 @@ public function profileeditorAction ($template) // b) Data from Database if everything was fine so the new data in the DB can be viewed. //This is stuff for Debugging - echo ("You sent me this:
    "); - var_dump($_POST); - echo ("
    Lenght:"); - echo (count($_POST)); - echo ("
    ArrayForEach
    "); - foreach ($_POST as $key => $value) - { - echo ($key); - echo ("->"); - echo ($value); - echo ("
    "); - } - - echo ("
    "); + //echo ("You sent me this:
    "); + //var_dump($_POST); + //echo ("
    Lenght:"); + //echo (count($_POST)); + //echo ("
    ArrayForEach
    "); + //foreach ($_POST as $key => $value) + //{ + //echo ($key); + //echo ("->"); + //echo ($value); + //echo ("
    "); + //} + + //echo ("
    "); //This is real sourcecode! $applicationController = $this->_app->getController('Xodx_ApplicationController'); @@ -369,9 +369,9 @@ public function profileeditorAction ($template) $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; $databaseValues = $model->sparqlQuery($query); - echo ("Database Values:
    "); - var_dump($databaseValues); - echo ("
    "); + //echo ("Database Values:
    "); + //var_dump($databaseValues); + //echo ("
    "); //prepare $_POST into prefix --> value foreach ($_POST as $key => $value) @@ -443,7 +443,7 @@ public function profileeditorAction ($template) $rString = $propertyRegex[$newKey]; if (preg_match($rString, $value) === true) { - echo ("Match: $value for $newKey"); + //echo ("Match: $value for $newKey"); $temp = array(); $temp['p'] = $newKey; $temp['o'] = $value; @@ -455,14 +455,13 @@ public function profileeditorAction ($template) } else { - echo ("Wrong Format: $value for $newKey
    "); + //echo ("Wrong Format: $value for $newKey
    "); $wrong[$newKey] = $value; } } } //Multiple - echo ("Multiple
    "); foreach ($prefixesMultiplePrepare as $prefixKey => $prefix) { $values = $valuesMultiplePrepare[$prefixKey]; @@ -509,7 +508,7 @@ public function profileeditorAction ($template) } else { - echo ("Wrong Format: $value for $prefix
    "); + //echo ("Wrong Format: $value for $prefix
    "); $temp = array(); $temp['p'] = $prefix; $temp['o'] = $value; @@ -519,10 +518,10 @@ public function profileeditorAction ($template) } } - echo("Debug Delete: "); - var_dump($changedDELETE); - echo("
    Debug Add: "); - var_dump($changedADD); + //echo("Debug Delete: "); + //var_dump($changedDELETE); + //echo("
    Debug Add: "); + //var_dump($changedADD); //echo("
    Wrong: "); //echo(count($wrong)); //echo("
    "); @@ -531,8 +530,19 @@ public function profileeditorAction ($template) if (count($wrong) > 0) { //Allow wrong Properties to be corrected - //TODO + //TODO: Mark the wrong keys. + foreach ($wrong as $key => $value) + { + $databaseValues[] = $value; + } + $template->allowedSinglePrefixes = $allowedSinglePrefixes; + $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; + $template->profile = $databaseValues; + $template->config = $config; + $template->wrong = $wrong; + $template->addContent('templates/profileeditor.phtml'); + return $template; } else { @@ -562,9 +572,6 @@ public function profileeditorAction ($template) $template = $this -> profileeditorAction($template); return $template; } - - $template->addContent('templates/profileeditor.phtml'); - return $template; } } diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 76e0c6b..df0728b 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -7,7 +7,12 @@ if (isset($this->profile)) { $counter = 0; - //echo ("Single
    "); + + if (count($this -> wrong) > 0) + { + echo ("Please correct the red Properties!

    "); + } + foreach ($this->allowedSinglePrefixes as $prefix) { $elementX = ""; @@ -33,7 +38,6 @@ if (isset($this->profile)) } $counter = 0; - //echo ("Multiple
    "); foreach ($this->allowedMultiplePrefixes as $prefix) { $elementX = ""; @@ -48,14 +52,38 @@ if (isset($this->profile)) $prefixText = $counterText ."_Mprefix"; $valueText = $counterText . "_Mvalue_$i"; - echo ("
    - -
    - - -
    -
    "); + $thisIsWrong = false; + + foreach($this->wrong as $key => $array) + { + if ($array['p'] == $prefix && $array['o'] == $elementX) + { + $thisIsWrong = true; + break; + } + } + + if ($thisIsWrong) + { + echo ("
    + +
    + + +
    +
    "); + } + else + { + echo ("
    + +
    + + +
    +
    "); + } $i=$i+1; } } From 5045b3de94dd3ccb73657cbe1fa52b14f18f932b Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Wed, 2 Oct 2013 18:49:18 +0200 Subject: [PATCH 108/143] Bugfixes --- classes/Xodx/PersonController.php | 99 ++++++++++------------------ config.ini-dist | 2 +- templates/person/profileeditor.phtml | 42 +++++++++--- 3 files changed, 68 insertions(+), 75 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 73fd06f..ad19738 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -327,42 +327,26 @@ public function profileeditorAction ($template) // TODO: Indicated that data... // b) Data from Database if everything was fine so the new data in the DB can be viewed. - //This is stuff for Debugging - //echo ("You sent me this:
    "); - //var_dump($_POST); - //echo ("
    Lenght:"); - //echo (count($_POST)); - //echo ("
    ArrayForEach
    "); - //foreach ($_POST as $key => $value) - //{ - //echo ($key); - //echo ("->"); - //echo ($value); - //echo ("
    "); - //} - - //echo ("
    "); - - //This is real sourcecode! - $applicationController = $this->_app->getController('Xodx_ApplicationController'); - $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; - $stringArray = explode("id=", $userUri); - $name = $stringArray[1]; - $propertyRegex = $this -> loadPropertyRegex(); - - $prefixesSinglePrepare = array(); - $valuesSinglePrepare = array(); - $prefixesMultiplePrepare = array(); - $valuesMultiplePrepare = array(); - $valuesSingleNew = array(); - $valuesMultipleNew = array(); - $newKey; - $newValue; - $oldValue; - $changedADD = array(); - $changedDELETE = array(); - $wrong = array(); + //This is real sourcecode! + $applicationController = $this->_app->getController('Xodx_ApplicationController'); + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; + $stringArray = explode("id=", $userUri); + $name = $stringArray[1]; + $propertyRegex = $this -> loadPropertyRegex(); + + $prefixesSinglePrepare = array(); + $valuesSinglePrepare = array(); + $prefixesMultiplePrepare = array(); + $valuesMultiplePrepare = array(); + $valuesSingleNew = array(); + $valuesMultipleNew = array(); + $newKey; + $newValue; + $oldValue; + $changedADD = array(); + $changedDELETE = array(); + $wrong = array(); //TODO: GET NAME @@ -410,14 +394,6 @@ public function profileeditorAction ($template) $valuesSingleNew[$value] = $valuesSinglePrepare[(int)$key]; } - ////echo("Debug valuesNew: "); - ////var_dump($valuesSingleNew); - //echo("
    Debug prefixesMultiplePrepare: "); - //var_dump($prefixesMultiplePrepare); - //echo("
    Debug valuesMultiplePrepare: "); - //var_dump($valuesMultiplePrepare); - //echo("
    "); - //Single foreach ($valuesSingleNew as $key => $value) { @@ -427,7 +403,7 @@ public function profileeditorAction ($template) //find corresponding value in query //Searches for equivalent of $newKey - foreach ($databaseValues as $key => $element) + foreach ($databaseValues as $dbkey => $element) { $p = $element["p"]; $o = $element["o"]; @@ -441,9 +417,9 @@ public function profileeditorAction ($template) if ($value != $oldValue) { $rString = $propertyRegex[$newKey]; - if (preg_match($rString, $value) === true) + if (preg_match($rString, $value) == true) { - //echo ("Match: $value for $newKey"); + echo ("Match: $value for $newKey with $rString"); $temp = array(); $temp['p'] = $newKey; $temp['o'] = $value; @@ -455,7 +431,7 @@ public function profileeditorAction ($template) } else { - //echo ("Wrong Format: $value for $newKey
    "); + echo ("Wrong Format: $value for $newKey with $rString
    "); $wrong[$newKey] = $value; } } @@ -518,16 +494,7 @@ public function profileeditorAction ($template) } } - //echo("Debug Delete: "); - //var_dump($changedDELETE); - //echo("
    Debug Add: "); - //var_dump($changedADD); - //echo("
    Wrong: "); - //echo(count($wrong)); - //echo("
    "); - //var_dump($wrong); - - if (count($wrong) > 0) + if (count($wrong) > 0 && !is_null($wrong)) { //Allow wrong Properties to be corrected //TODO: Mark the wrong keys. @@ -551,20 +518,20 @@ public function profileeditorAction ($template) { //$keyArray = array('value' => ); $valueArray = array('type' => 'literal', 'value' => $value['o']); - $keyToWrite = $value['p']; - $valueToWrite = $value['o']; - echo ("
    Delete: $userUri, $keyToWrite, $valueToWrite"); - $model->deleteStatement($userUri, $keyToWrite, $valueArray); + $keyToDelete = $value['p']; + $valueToDelete = $value['o']; + echo ("
    Delete: $userUri, $keyToDelete, $valueToDelete"); + $model->deleteStatement($userUri, $keyToDelete, $valueArray); } foreach ($changedADD as $key => $value) { //$keyArray = array('value' => ); //array('type' => 'uri', 'value' => $newPersonUri) $valueArray = array('type' => 'literal', 'value' => $value['o']); - $keyToDelete = $value['p']; - $valueToDelete = $value['o']; - echo ("
    Writing: $userUri, $keyToDelete, $valueToDelete"); - $model->addStatement($userUri, $keyToDelete, $valueArray); + $keyToWrite = $value['p']; + $valueToWrite = $value['o']; + echo ("
    Writing: $userUri, $keyToWrite, $valueToWrite"); + $model->addStatement($userUri, $keyToWrite, $valueArray); } //Show Profileeditor with Values from Database. diff --git a/config.ini-dist b/config.ini-dist index de9bc2f..ed6f5df 100644 --- a/config.ini-dist +++ b/config.ini-dist @@ -16,7 +16,7 @@ regex.URL = "_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})( ; by http://mathiasbynens.be/demo/url-regex regex.Email = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" ; by http://www.regular-expressions.info/email.html -regex.Literal = "[A-Za-z0-9]+" +regex.Literal = "[\s\S]+" [erfurt] ; In this section you can configure the Erfurt framework diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index df0728b..e74aee4 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -8,9 +8,10 @@ if (isset($this->profile)) { $counter = 0; - if (count($this -> wrong) > 0) + if (count($this -> wrong) > 0 && !is_null($this -> wrong)) { echo ("Please correct the red Properties!

    "); + //var_dump($this -> wrong); } foreach ($this->allowedSinglePrefixes as $prefix) @@ -27,13 +28,38 @@ if (isset($this->profile)) $counterText = (string)$counter; $prefixText = $counterText ."_prefix"; $valueText = $counterText . "_value"; - echo ("
    - -
    - - -
    -
    "); + $thisIsWrong = false; + + foreach($this->wrong as $keyX => $array) + { + if ($keyX == $prefix) + { + //echo ("Wrong: $prefix"); + $thisIsWrong = true; + break; + } + } + + if ($thisIsWrong) + { + echo ("
    + +
    + + +
    +
    "); + } + else + { + echo ("
    + +
    + + +
    +
    "); + } $counter = $counter + 1; } From 0318e4e18d529e7ab18570048bb77565d216d3d8 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Wed, 2 Oct 2013 18:54:54 +0200 Subject: [PATCH 109/143] Do not echo. --- classes/Xodx/PersonController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index ad19738..538df70 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -419,7 +419,7 @@ public function profileeditorAction ($template) $rString = $propertyRegex[$newKey]; if (preg_match($rString, $value) == true) { - echo ("Match: $value for $newKey with $rString"); + //echo ("Match: $value for $newKey with $rString"); $temp = array(); $temp['p'] = $newKey; $temp['o'] = $value; @@ -431,7 +431,7 @@ public function profileeditorAction ($template) } else { - echo ("Wrong Format: $value for $newKey with $rString
    "); + //echo ("Wrong Format: $value for $newKey with $rString
    "); $wrong[$newKey] = $value; } } @@ -494,6 +494,8 @@ public function profileeditorAction ($template) } } + var_dump($databaseValues); + if (count($wrong) > 0 && !is_null($wrong)) { //Allow wrong Properties to be corrected @@ -520,7 +522,7 @@ public function profileeditorAction ($template) $valueArray = array('type' => 'literal', 'value' => $value['o']); $keyToDelete = $value['p']; $valueToDelete = $value['o']; - echo ("
    Delete: $userUri, $keyToDelete, $valueToDelete"); + //echo ("
    Delete: $userUri, $keyToDelete, $valueToDelete"); $model->deleteStatement($userUri, $keyToDelete, $valueArray); } foreach ($changedADD as $key => $value) @@ -530,7 +532,7 @@ public function profileeditorAction ($template) $valueArray = array('type' => 'literal', 'value' => $value['o']); $keyToWrite = $value['p']; $valueToWrite = $value['o']; - echo ("
    Writing: $userUri, $keyToWrite, $valueToWrite"); + //echo ("
    Writing: $userUri, $keyToWrite, $valueToWrite"); $model->addStatement($userUri, $keyToWrite, $valueArray); } From 32af0933feacaedfb907cc1d4e39c39ac72aa884 Mon Sep 17 00:00:00 2001 From: DSSN Date: Tue, 8 Oct 2013 17:50:26 +0200 Subject: [PATCH 110/143] ProfileEditor works. --- classes/Xodx/PersonController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 538df70..63840a3 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -303,11 +303,11 @@ public function profileeditorAction ($template) // Show editor with data from database $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; + $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; $stringArray = explode("id=", $userUri); $name = $stringArray[1]; - $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; + $query = "PREFIX foaf: SELECT ?p ?o WHERE { <" . $userUri . "> a foaf:Person. <" . $userUri . "> ?p ?o }"; //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; $profiles = $model->sparqlQuery( $query); @@ -330,7 +330,7 @@ public function profileeditorAction ($template) //This is real sourcecode! $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=user&id=' . $userId; + $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; $stringArray = explode("id=", $userUri); $name = $stringArray[1]; $propertyRegex = $this -> loadPropertyRegex(); @@ -350,7 +350,7 @@ public function profileeditorAction ($template) //TODO: GET NAME - $query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:nick '$name'. ?person ?p ?o }"; + $query = "PREFIX foaf: SELECT ?p ?o WHERE { <" . $userUri . "> a foaf:Person. <" . $userUri . "> ?p ?o }"; $databaseValues = $model->sparqlQuery($query); //echo ("Database Values:
    "); @@ -417,7 +417,7 @@ public function profileeditorAction ($template) if ($value != $oldValue) { $rString = $propertyRegex[$newKey]; - if (preg_match($rString, $value) == true) + if (ereg($rString, $value) == true) { //echo ("Match: $value for $newKey with $rString"); $temp = array(); @@ -474,7 +474,7 @@ public function profileeditorAction ($template) //echo ("Not found: $prefix -> $value
    "); $rString = $propertyRegex[$prefix]; //echo ("$rString"); - if (preg_match($rString, $value) == true) + if (ereg($rString, $value) == true) { //echo ("Match: $value for $newKey"); $temp = array(); @@ -494,7 +494,7 @@ public function profileeditorAction ($template) } } - var_dump($databaseValues); +// var_dump($databaseValues); if (count($wrong) > 0 && !is_null($wrong)) { From e15e0f264ffa5d9a0f1e485562d9b349f3889504 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Fri, 11 Oct 2013 20:11:34 +0200 Subject: [PATCH 111/143] Changed way of storing editor Properties in config.ini --- classes/Xodx/PersonController.php | 169 +++++++++++++++++---------- config.ini-dist | 35 +++++- templates/person/profileeditor.phtml | 20 ++-- 3 files changed, 151 insertions(+), 73 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 63840a3..0f90bb8 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -322,33 +322,31 @@ public function profileeditorAction ($template) } else { - //Process POSTed values an show ProfileEditor with - // a) Data from POST if it needs to be corrected - // TODO: Indicated that data... - // b) Data from Database if everything was fine so the new data in the DB can be viewed. - - //This is real sourcecode! - $applicationController = $this->_app->getController('Xodx_ApplicationController'); - $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; - $stringArray = explode("id=", $userUri); - $name = $stringArray[1]; - $propertyRegex = $this -> loadPropertyRegex(); - - $prefixesSinglePrepare = array(); - $valuesSinglePrepare = array(); - $prefixesMultiplePrepare = array(); - $valuesMultiplePrepare = array(); - $valuesSingleNew = array(); - $valuesMultipleNew = array(); - $newKey; - $newValue; - $oldValue; - $changedADD = array(); - $changedDELETE = array(); - $wrong = array(); - - //TODO: GET NAME + //Process POSTed values an show ProfileEditor with + // a) Data from POST if it needs to be corrected + // TODO: Indicated that data... + // b) Data from Database if everything was fine so the new data in the DB can be viewed. + + //This is real sourcecode! + $applicationController = $this->_app->getController('Xodx_ApplicationController'); + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; + $stringArray = explode("id=", $userUri); + $name = $stringArray[1]; + $propertyRegex = $this -> loadPropertyRegex(); + + $prefixesSinglePrepare = array(); + $valuesSinglePrepare = array(); + $prefixesMultiplePrepare = array(); + $valuesMultiplePrepare = array(); + $valuesSingleNew = array(); + $valuesMultipleNew = array(); + $newKey; + $newValue; + $oldValue; + $changedADD = array(); + $changedDELETE = array(); + $wrong = array(); $query = "PREFIX foaf: SELECT ?p ?o WHERE { <" . $userUri . "> a foaf:Person. <" . $userUri . "> ?p ?o }"; $databaseValues = $model->sparqlQuery($query); @@ -414,9 +412,9 @@ public function profileeditorAction ($template) } } - if ($value != $oldValue) + if ($value != $oldValue ) { - $rString = $propertyRegex[$newKey]; + $rString = $allowedSinglePrefixes[$key]["regex"]; if (ereg($rString, $value) == true) { //echo ("Match: $value for $newKey with $rString"); @@ -432,7 +430,10 @@ public function profileeditorAction ($template) else { //echo ("Wrong Format: $value for $newKey with $rString
    "); - $wrong[$newKey] = $value; + if (!empty ($value)) + { + $wrong[$newKey] = $value; + } } } } @@ -472,9 +473,10 @@ public function profileeditorAction ($template) if (!$found) { //echo ("Not found: $prefix -> $value
    "); - $rString = $propertyRegex[$prefix]; + $rString = $allowedMultiplePrefixes[$prefix]["regex"]; //echo ("$rString"); - if (ereg($rString, $value) == true) + //var_dump($value); + if (preg_match($rString, $value) == true) { //echo ("Match: $value for $newKey"); $temp = array(); @@ -484,17 +486,20 @@ public function profileeditorAction ($template) } else { - //echo ("Wrong Format: $value for $prefix
    "); - $temp = array(); - $temp['p'] = $prefix; - $temp['o'] = $value; - $wrong[] = $temp; + //echo ("Wrong Format: $value for $prefix with $rString
    "); + if (!empty ($value)) + { + $temp = array(); + $temp['p'] = $prefix; + $temp['o'] = $value; + $wrong[] = $temp; + } } } } } -// var_dump($databaseValues); + // var_dump($databaseValues); if (count($wrong) > 0 && !is_null($wrong)) { @@ -588,47 +593,85 @@ public function propertyRegex($regexName) return $config[$regexString]; } - public function loadPropertiesSingle() + public function loadProperties() { - $properties = array(); + $propertiesPrepared = array(); $config = $this->_app->getBootstrap()->getResource('Config'); - $single = explode(",",$config["editor.single"]); - $skip = false; - - foreach($single as $key => $element) + //$single = explode(",",$config["editor.single"]); + //var_dump($config["editor.single"]); + //var_dump($config); + foreach ($config as $key => $value) { - if (!$skip) + //editor.person.property.1.uri + $keySplit = explode(".",$key); + if ($keySplit[0] == "editor") { - $properties[] = $element; - $skip = true; - } - else - { - $skip = false; + if ($keySplit[1] == "person") + { + if ($keySplit[2] == "property") + { + $propertiesPrepared[$keySplit[3]][$keySplit[4]] = $value; + //var_dump($keySplit); + //echo ("
    "); + } + } } } + //echo ("
    "); + //var_dump($propertiesPrepared); + $properties = array(); + foreach ($propertiesPrepared as $key => $value) + { + $properties[$value["uri"]]["type"] = $value["type"]; + $properties[$value["uri"]]["cardinality"] = $value["cardinality"]; + $properties[$value["uri"]]["regex"] = $this -> propertyRegex($value["type"]); + } + //echo ("
    "); + //var_dump($properties); return $properties; } + public function loadPropertiesAction() + { + return $this -> loadProperties(); + } - public function loadPropertiesMultiple() + public function loadPropertiesSingleAction() { - $properties = array(); - $config = $this->_app->getBootstrap()->getResource('Config'); - $single = explode(",",$config["editor.multiple"]); - $skip = false; + var_dump($this -> loadPropertiesSingle()); + } + + public function loadPropertiesMultipleAction() + { + var_dump($this -> loadPropertiesMultiple()); + } + + public function loadPropertiesSingle() + { + $properties = $this -> loadProperties(); + $single = array(); - foreach($single as $key => $element) + foreach($properties as $key => $element) { - if (!$skip) + if ($element["cardinality"] == "single") { - $properties[] = $element; - $skip = true; + $single[$key] = $element; } - else + } + return $single; + } + + public function loadPropertiesMultiple() + { + $properties = $this -> loadProperties(); + $multiple = array(); + + foreach($properties as $key => $element) + { + if ($element["cardinality"] == "multiple") { - $skip = false; + $multiple[$key] = $element; } } - return $properties; + return $multiple; } } diff --git a/config.ini-dist b/config.ini-dist index ed6f5df..6fff067 100644 --- a/config.ini-dist +++ b/config.ini-dist @@ -9,8 +9,39 @@ push.hub = "http://pubsubhubbub.appspot.com" ;push.hub = "http://localhost/OntoWiki/pubsub/hubbub" ;Parameters for Profile Editor -editor.single = http://xmlns.com/foaf/0.1/depiction,URL,http://xmlns.com/foaf/0.1/nick,Literal,http://xmlns.com/foaf/0.1/name,Literal -editor.multiple = http://xmlns.com/foaf/0.1/schoolHomepage,URL,http://xmlns.com/foaf/0.1/jabberID,Email,http://www.w3.org/2000/01/rdf-schema#seeAlso,URL,http://xmlns.com/foaf/0.1/based_near,URL,http://xmlns.com/foaf/0.1/weblog,URL,http://xmlns.com/foaf/0.1/workplaceHomepage,URL +;editor.single = http://xmlns.com/foaf/0.1/depiction,URL,http://xmlns.com/foaf/0.1/nick,Literal,http://xmlns.com/foaf/0.1/name,Literal +;editor.multiple = http://xmlns.com/foaf/0.1/schoolHomepage,URL,http://xmlns.com/foaf/0.1/jabberID,Email,http://www.w3.org/2000/01/rdf-schema#seeAlso,URL,http://xmlns.com/foaf/0.1/based_near,URL,http://xmlns.com/foaf/0.1/weblog,URL,http://xmlns.com/foaf/0.1/workplaceHomepage,URL + +;editor.person.class = http://...foaf...Person + +editor.person.property.1.uri = http://xmlns.com/foaf/0.1/nick +editor.person.property.1.type = Literal +editor.person.property.1.cardinality = single +editor.person.property.2.uri = http://xmlns.com/foaf/0.1/name +editor.person.property.2.type = Literal +editor.person.property.2.cardinality = single +editor.person.property.3.uri = http://xmlns.com/foaf/0.1/depiction +editor.person.property.3.type = URL +editor.person.property.3.cardinality = single + +editor.person.property.4.uri = http://xmlns.com/foaf/0.1/schoolHomepage +editor.person.property.4.type = URL +editor.person.property.4.cardinality = multiple +editor.person.property.5.uri = http://xmlns.com/foaf/0.1/jabberID +editor.person.property.5.type = Email +editor.person.property.5.cardinality = multiple +editor.person.property.6.uri = http://www.w3.org/2000/01/rdf-schema#seeAlso +editor.person.property.6.type = URL +editor.person.property.6.cardinality = multiple +editor.person.property.7.uri = http://xmlns.com/foaf/0.1/based_near +editor.person.property.7.type = URL +editor.person.property.7.cardinality = multiple +editor.person.property.8.uri = http://xmlns.com/foaf/0.1/weblog +editor.person.property.8.type = URL +editor.person.property.8.cardinality = multiple +editor.person.property.9.uri = http://xmlns.com/foaf/0.1/workplaceHomepage +editor.person.property.9.type = URL +editor.person.property.9.cardinality = multiple regex.URL = "_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/[^\s]*)?$_iuS" ; by http://mathiasbynens.be/demo/url-regex diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index e74aee4..82cff87 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -14,13 +14,17 @@ if (isset($this->profile)) //var_dump($this -> wrong); } - foreach ($this->allowedSinglePrefixes as $prefix) + foreach ($this->allowedSinglePrefixes as $prefixKey => $prefix) { $elementX = ""; //HACK: Do we have LINQ or at least something to make this better? + //echo ("$prefix
    "); + //var_dump($prefixKey); + //echo ("
    "); + foreach ($this->profile as $key => $element) { - if ($element["p"] == $prefix) + if ($element["p"] == $prefixKey) { $elementX = $element["o"]; } @@ -32,7 +36,7 @@ if (isset($this->profile)) foreach($this->wrong as $keyX => $array) { - if ($keyX == $prefix) + if ($array['p'] == $prefixKey) { //echo ("Wrong: $prefix"); $thisIsWrong = true; @@ -43,20 +47,20 @@ if (isset($this->profile)) if ($thisIsWrong) { echo ("
    - +
    - +
    "); } else { echo ("
    - +
    - +
    "); } @@ -64,7 +68,7 @@ if (isset($this->profile)) } $counter = 0; - foreach ($this->allowedMultiplePrefixes as $prefix) + foreach ($this->allowedMultiplePrefixes as $prefix => $prefixValue) { $elementX = ""; $i = 0; From 7716e3df96e3e9afd80e453e899bd0c70b0fcf9c Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Fri, 11 Oct 2013 23:07:58 +0200 Subject: [PATCH 112/143] Made LoadProperties reusable. --- classes/Xodx/PersonController.php | 22 ++++++++++------------ templates/person/profileeditor.phtml | 4 ++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 0f90bb8..7ff78b5 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -295,8 +295,8 @@ public function getNotifications ($personUri) public function profileeditorAction ($template) { $model = $this->_app->getBootstrap()->getResource('Model'); - $allowedSinglePrefixes = $this->loadPropertiesSingle(); - $allowedMultiplePrefixes = $this->loadPropertiesMultiple(); + $allowedSinglePrefixes = $this->loadPropertiesSingle("person"); + $allowedMultiplePrefixes = $this->loadPropertiesMultiple("person"); if (count ($_POST) == 0) { @@ -499,8 +499,6 @@ public function profileeditorAction ($template) } } - // var_dump($databaseValues); - if (count($wrong) > 0 && !is_null($wrong)) { //Allow wrong Properties to be corrected @@ -593,7 +591,7 @@ public function propertyRegex($regexName) return $config[$regexString]; } - public function loadProperties() + public function loadProperties($editorType) { $propertiesPrepared = array(); $config = $this->_app->getBootstrap()->getResource('Config'); @@ -606,7 +604,7 @@ public function loadProperties() $keySplit = explode(".",$key); if ($keySplit[0] == "editor") { - if ($keySplit[1] == "person") + if ($keySplit[1] == $editorType) { if ($keySplit[2] == "property") { @@ -637,17 +635,17 @@ public function loadPropertiesAction() public function loadPropertiesSingleAction() { - var_dump($this -> loadPropertiesSingle()); + var_dump($this -> loadPropertiesSingle("conference")); } public function loadPropertiesMultipleAction() { - var_dump($this -> loadPropertiesMultiple()); + var_dump($this -> loadPropertiesMultiple("person")); } - public function loadPropertiesSingle() + public function loadPropertiesSingle($editorType) { - $properties = $this -> loadProperties(); + $properties = $this -> loadProperties($editorType); $single = array(); foreach($properties as $key => $element) @@ -660,9 +658,9 @@ public function loadPropertiesSingle() return $single; } - public function loadPropertiesMultiple() + public function loadPropertiesMultiple($editorType) { - $properties = $this -> loadProperties(); + $properties = $this -> loadProperties($editorType); $multiple = array(); foreach($properties as $key => $element) diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index 82cff87..fac1cf5 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -8,6 +8,10 @@ if (isset($this->profile)) { $counter = 0; + //echo ("Database Values:
    "); + //var_dump($this->profile); + //echo ("
    "); + if (count($this -> wrong) > 0 && !is_null($this -> wrong)) { echo ("Please correct the red Properties!

    "); From 28cb47e9185c5e8756dedefde69421c525c61f61 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Fri, 11 Oct 2013 23:24:26 +0200 Subject: [PATCH 113/143] Moved config functions to ConfigHelper.php --- classes/Xodx/ConfigHelper.php | 100 ++++++++++++++++++++++++++ classes/Xodx/PersonController.php | 112 +++--------------------------- 2 files changed, 109 insertions(+), 103 deletions(-) create mode 100644 classes/Xodx/ConfigHelper.php diff --git a/classes/Xodx/ConfigHelper.php b/classes/Xodx/ConfigHelper.php new file mode 100644 index 0000000..3204a89 --- /dev/null +++ b/classes/Xodx/ConfigHelper.php @@ -0,0 +1,100 @@ + loadProperties($editorType); + $single = array(); + + foreach($properties as $key => $element) + { + if ($element["cardinality"] == "single") + { + $single[$key] = $element; + } + } + return $single; + } + + public function loadPropertiesMultiple($editorType) + { + $properties = $this -> loadProperties($editorType); + $multiple = array(); + + foreach($properties as $key => $element) + { + if ($element["cardinality"] == "multiple") + { + $multiple[$key] = $element; + } + } + return $multiple; + } + + public function loadPropertyRegex() + { + $properties = array(); + $config = $this->_app->getBootstrap()->getResource('Config'); + $bothConfigs = explode(",",$config["editor.single"].",".$config["editor.multiple"]); + $skip = false; + + foreach($bothConfigs as $key => $element) + { + if (!$skip) + { + $property = $element; + $skip = true; + } + else + { + $skip = false; + $properties[$property] = $this->propertyRegex($element); + } + } + return $properties; + } + + public function propertyRegex($regexName) + { + //echo "propertyRegex: $regexName
    "; + $config = $this->_app->getBootstrap()->getResource('Config'); + $regexString = "regex.".$regexName; + return $config[$regexString]; + } + + public function loadProperties($editorType) + { + $propertiesPrepared = array(); + $config = $this->_app->getBootstrap()->getResource('Config'); + foreach ($config as $key => $value) + { + $keySplit = explode(".",$key); + if ($keySplit[0] == "editor") + { + if ($keySplit[1] == $editorType) + { + if ($keySplit[2] == "property") + { + $propertiesPrepared[$keySplit[3]][$keySplit[4]] = $value; + } + } + } + } + $properties = array(); + foreach ($propertiesPrepared as $key => $value) + { + $properties[$value["uri"]]["type"] = $value["type"]; + $properties[$value["uri"]]["cardinality"] = $value["cardinality"]; + $properties[$value["uri"]]["regex"] = $this -> propertyRegex($value["type"]); + } + return $properties; + } +} + + diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 7ff78b5..ec6cb8f 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -295,8 +295,9 @@ public function getNotifications ($personUri) public function profileeditorAction ($template) { $model = $this->_app->getBootstrap()->getResource('Model'); - $allowedSinglePrefixes = $this->loadPropertiesSingle("person"); - $allowedMultiplePrefixes = $this->loadPropertiesMultiple("person"); + $configHelper = new Xodx_ConfigHelper($this->_app); + $allowedSinglePrefixes = $configHelper->loadPropertiesSingle("person"); + $allowedMultiplePrefixes = $configHelper->loadPropertiesMultiple("person"); if (count ($_POST) == 0) { @@ -560,116 +561,21 @@ private static function _issueE24fix ($date) } } - public function loadPropertyRegex() - { - $properties = array(); - $config = $this->_app->getBootstrap()->getResource('Config'); - $bothConfigs = explode(",",$config["editor.single"].",".$config["editor.multiple"]); - $skip = false; - - foreach($bothConfigs as $key => $element) - { - if (!$skip) - { - $property = $element; - $skip = true; - } - else - { - $skip = false; - $properties[$property] = $this->propertyRegex($element); - } - } - return $properties; - } - - public function propertyRegex($regexName) - { - //echo "propertyRegex: $regexName
    "; - $config = $this->_app->getBootstrap()->getResource('Config'); - $regexString = "regex.".$regexName; - return $config[$regexString]; - } - - public function loadProperties($editorType) - { - $propertiesPrepared = array(); - $config = $this->_app->getBootstrap()->getResource('Config'); - //$single = explode(",",$config["editor.single"]); - //var_dump($config["editor.single"]); - //var_dump($config); - foreach ($config as $key => $value) - { - //editor.person.property.1.uri - $keySplit = explode(".",$key); - if ($keySplit[0] == "editor") - { - if ($keySplit[1] == $editorType) - { - if ($keySplit[2] == "property") - { - $propertiesPrepared[$keySplit[3]][$keySplit[4]] = $value; - //var_dump($keySplit); - //echo ("
    "); - } - } - } - } - //echo ("
    "); - //var_dump($propertiesPrepared); - $properties = array(); - foreach ($propertiesPrepared as $key => $value) - { - $properties[$value["uri"]]["type"] = $value["type"]; - $properties[$value["uri"]]["cardinality"] = $value["cardinality"]; - $properties[$value["uri"]]["regex"] = $this -> propertyRegex($value["type"]); - } - //echo ("
    "); - //var_dump($properties); - return $properties; - } public function loadPropertiesAction() { - return $this -> loadProperties(); + $configHelper = new Xodx_ConfigHelper($this->_app); + return $configHelper -> loadProperties(); } public function loadPropertiesSingleAction() { - var_dump($this -> loadPropertiesSingle("conference")); + $configHelper = new Xodx_ConfigHelper($this->_app); + var_dump($configHelper -> loadPropertiesSingle("conference")); } public function loadPropertiesMultipleAction() { - var_dump($this -> loadPropertiesMultiple("person")); - } - - public function loadPropertiesSingle($editorType) - { - $properties = $this -> loadProperties($editorType); - $single = array(); - - foreach($properties as $key => $element) - { - if ($element["cardinality"] == "single") - { - $single[$key] = $element; - } - } - return $single; - } - - public function loadPropertiesMultiple($editorType) - { - $properties = $this -> loadProperties($editorType); - $multiple = array(); - - foreach($properties as $key => $element) - { - if ($element["cardinality"] == "multiple") - { - $multiple[$key] = $element; - } - } - return $multiple; + $configHelper = new Xodx_ConfigHelper($this->_app); + var_dump($configHelper -> loadPropertiesMultiple("person")); } } From be455802691c4bdbcfb9be98bad957065dbf8b0c Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Fri, 11 Oct 2013 23:26:25 +0200 Subject: [PATCH 114/143] Added ConferenceController.php (stub) --- classes/Xodx/ConferenceController.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 classes/Xodx/ConferenceController.php diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php new file mode 100644 index 0000000..bcefd13 --- /dev/null +++ b/classes/Xodx/ConferenceController.php @@ -0,0 +1,25 @@ +_app); + var_dump($configHelper -> loadPropertiesSingle("conference")); + } + +} From d7dcc330f76b07a574375ee58df65a135837b316 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Fri, 11 Oct 2013 23:40:03 +0200 Subject: [PATCH 115/143] Added conference in ini.dist --- config.ini-dist | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/config.ini-dist b/config.ini-dist index 6fff067..418b478 100644 --- a/config.ini-dist +++ b/config.ini-dist @@ -43,11 +43,51 @@ editor.person.property.9.uri = http://xmlns.com/foaf/0.1/workplaceHomepage editor.person.property.9.type = URL editor.person.property.9.cardinality = multiple -regex.URL = "_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/[^\s]*)?$_iuS" +editor.conference.property.1.uri = rdfs:label +editor.conference.property.1.type = String +editor.conference.property.1.cardinality = single +editor.conference.property.2.uri = ical:status +editor.conference.property.2.type = String +editor.conference.property.2.cardinality = single +editor.conference.property.3.uri = ical:summary +editor.conference.property.3.type = String +editor.conference.property.3.cardinality = single +editor.conference.property.4.uri = ical:description +editor.conference.property.4.type = Literal +editor.conference.property.4.cardinality = single +editor.conference.property.5.uri = ical:location +editor.conference.property.5.type = String +editor.conference.property.5.cardinality = single + +editor.conference.property.6.uri = ical:contact +editor.conference.property.6.type = String +editor.conference.property.6.cardinality = single +editor.conference.property.7.uri = ical:url +editor.conference.property.7.type = URL +editor.conference.property.7.cardinality = single +editor.conference.property.8.uri = ical:dtstart +editor.conference.property.8.type = DateTime +editor.conference.property.8.cardinality = single +editor.conference.property.9.uri = ical:dtend +editor.conference.property.9.type = DateTime +editor.conference.property.9.cardinality = single +editor.conference.property.10.uri = ical:created +editor.conference.property.10.type = DateTime +editor.conference.property.10.cardinality = single + +editor.conference.property.11.uri = ical:lastModified +editor.conference.property.11.type = DateTime +editor.conference.property.11.cardinality = single + ; by http://mathiasbynens.be/demo/url-regex -regex.Email = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" +regex.URL = "_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/[^\s]*)?$_iuS" ; by http://www.regular-expressions.info/email.html +regex.Email = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" regex.Literal = "[\s\S]+" +regex.String = "[\s\S]+" +; by http://regexlib.com/REDetails.aspx?regexp_id=610 +regex.DateTime = "^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$" + [erfurt] ; In this section you can configure the Erfurt framework @@ -84,4 +124,4 @@ foaf = 'http://xmlns.com/foaf/0.1/'; dssn = 'http://purl.org/net/dssn/'; ow = 'http://ns.ontowiki.net/SysOnt/'; ov = 'http://open.vocab.org/docs/'; -rel = 'http://purl.org/vocab/relationship/' \ No newline at end of file +rel = 'http://purl.org/vocab/relationship/' From 68ae8155cc6321bc1a9058d12ced8aff59e0bc4f Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 12 Oct 2013 14:23:58 +0200 Subject: [PATCH 116/143] Added Stubs for ConferenceEditor --- classes/Xodx/ConferenceController.php | 31 ++++ classes/Xodx/PersonController.php | 1 - templates/conference/conferenceeditor.phtml | 155 ++++++++++++++++++++ templates/partials/menu.phtml | 1 + 4 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 templates/conference/conferenceeditor.phtml diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index bcefd13..5744df3 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -22,4 +22,35 @@ public function PrefixesAction() var_dump($configHelper -> loadPropertiesSingle("conference")); } + public function editAction($template) + { + $model = $this->_app->getBootstrap()->getResource('Model'); + $configHelper = new Xodx_ConfigHelper($this->_app); + $allowedSinglePrefixes = $configHelper->loadPropertiesSingle("conference"); + + if (count ($_POST) == 0) + { + // Show editor with data from database + $applicationController = $this->_app->getController('Xodx_ApplicationController'); + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; + $stringArray = explode("id=", $userUri); + $name = $stringArray[1]; + + $query = "PREFIX foaf: SELECT ?p ?o WHERE { <" . $userUri . "> a foaf:Person. <" . $userUri . "> ?p ?o }"; + //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; + + $profiles = $model->sparqlQuery( $query); + $template->allowedSinglePrefixes = $allowedSinglePrefixes; + $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; + $template->profile = $profiles; + $template->addContent('templates/conferenceeditor.phtml'); + //echo ("FOOO"); + return $template; + } + else + { + //Currently do nothing. + } + } } diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index ec6cb8f..10c9309 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -315,7 +315,6 @@ public function profileeditorAction ($template) $template->allowedSinglePrefixes = $allowedSinglePrefixes; $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; $template->profile = $profiles; - $template->config = $config; $template->addContent('templates/profileeditor.phtml'); diff --git a/templates/conference/conferenceeditor.phtml b/templates/conference/conferenceeditor.phtml new file mode 100644 index 0000000..83782f7 --- /dev/null +++ b/templates/conference/conferenceeditor.phtml @@ -0,0 +1,155 @@ +

    Conference Editor

    + + +
    + +profile)) + { + /* + $counter = 0; + + //echo ("Database Values:
    "); + //var_dump($this->profile); + //echo ("
    "); + + if (count($this -> wrong) > 0 && !is_null($this -> wrong)) + { + echo ("Please correct the red Properties!

    "); + //var_dump($this -> wrong); + } + + foreach ($this->allowedSinglePrefixes as $prefixKey => $prefix) + { + $elementX = ""; + //HACK: Do we have LINQ or at least something to make this better? + //echo ("$prefix
    "); + //var_dump($prefixKey); + //echo ("
    "); + + foreach ($this->profile as $key => $element) + { + if ($element["p"] == $prefixKey) + { + $elementX = $element["o"]; + } + } + $counterText = (string)$counter; + $prefixText = $counterText ."_prefix"; + $valueText = $counterText . "_value"; + $thisIsWrong = false; + + foreach($this->wrong as $keyX => $array) + { + if ($array['p'] == $prefixKey) + { + //echo ("Wrong: $prefix"); + $thisIsWrong = true; + break; + } + } + + if ($thisIsWrong) + { + echo ("
    + +
    + + +
    +
    "); + } + else + { + echo ("
    + +
    + + +
    +
    "); + } + $counter = $counter + 1; + } + + $counter = 0; + foreach ($this->allowedMultiplePrefixes as $prefix => $prefixValue) + { + $elementX = ""; + $i = 0; + $counterText = (string)$counter; + //HACK: Do we have LINQ or at least something to make this better? + foreach ($this->profile as $key => $element) + { + if ($element["p"] == $prefix) + { + $elementX = $element["o"]; + + $prefixText = $counterText ."_Mprefix"; + $valueText = $counterText . "_Mvalue_$i"; + + $thisIsWrong = false; + + foreach($this->wrong as $key => $array) + { + if ($array['p'] == $prefix && $array['o'] == $elementX) + { + $thisIsWrong = true; + break; + } + } + + if ($thisIsWrong) + { + echo ("
    + +
    + + +
    +
    "); + } + else + { + echo ("
    + +
    + + +
    +
    "); + } + $i=$i+1; + } + } + + $prefixText = $counterText ."_Mprefix"; + $valueText = $counterText . "_Mvalue_$i"; + echo ("
    + +
    + + +
    +
    "); + + $counter = $counter + 1; + //echo ("Prefix: $prefix
    "); + */ + } +} +else +{ + echo ("Damn, profile not set..."); +} + +?> + +
    + +
    + +
    + + + diff --git a/templates/partials/menu.phtml b/templates/partials/menu.phtml index 4416b13..4c99d32 100644 --- a/templates/partials/menu.phtml +++ b/templates/partials/menu.phtml @@ -20,6 +20,7 @@ username != "guest") { + echo ("
  • Conference Editor
  • "); echo ("
  • Profile Editor
  • "); echo ("
  • Logout
  • "); } From 47f158deba3c00feee5cea76162a587afe73d06d Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 12 Oct 2013 15:31:15 +0200 Subject: [PATCH 117/143] Use correct Template --- classes/Xodx/ConferenceController.php | 11 ++++++----- .../{conferenceeditor.phtml => edit.phtml} | 16 +++++++++------- templates/conference/test.phtml | 1 + templates/person/profileeditor.phtml | 3 +-- 4 files changed, 17 insertions(+), 14 deletions(-) rename templates/conference/{conferenceeditor.phtml => edit.phtml} (96%) create mode 100644 templates/conference/test.phtml diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index 5744df3..fce4060 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -11,9 +11,10 @@ class Xodx_ConferenceController extends Xodx_ResourceController { - public function testAction() + public function testAction($template) { - echo ("Conference"); + $template->addContent('templates/test.phtml'); + return $template; } public function PrefixesAction() @@ -30,7 +31,7 @@ public function editAction($template) if (count ($_POST) == 0) { - // Show editor with data from database + //Show editor with data from database $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; @@ -42,15 +43,15 @@ public function editAction($template) $profiles = $model->sparqlQuery( $query); $template->allowedSinglePrefixes = $allowedSinglePrefixes; - $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; $template->profile = $profiles; - $template->addContent('templates/conferenceeditor.phtml'); + $template->addContent('templates/edit.phtml'); //echo ("FOOO"); return $template; } else { //Currently do nothing. + echo ("Nope."); } } } diff --git a/templates/conference/conferenceeditor.phtml b/templates/conference/edit.phtml similarity index 96% rename from templates/conference/conferenceeditor.phtml rename to templates/conference/edit.phtml index 83782f7..4ecffb0 100644 --- a/templates/conference/conferenceeditor.phtml +++ b/templates/conference/edit.phtml @@ -5,8 +5,7 @@ profile)) - { - /* +{ $counter = 0; //echo ("Database Values:
    "); @@ -16,9 +15,11 @@ if (isset($this->profile)) if (count($this -> wrong) > 0 && !is_null($this -> wrong)) { echo ("Please correct the red Properties!

    "); - //var_dump($this -> wrong); + var_dump($this -> wrong); } + //var_dump($this -> allowedSinglePrefixes); + foreach ($this->allowedSinglePrefixes as $prefixKey => $prefix) { $elementX = ""; @@ -43,7 +44,7 @@ if (isset($this->profile)) { if ($array['p'] == $prefixKey) { - //echo ("Wrong: $prefix"); + echo ("Wrong: $prefix"); $thisIsWrong = true; break; } @@ -72,7 +73,9 @@ if (isset($this->profile)) $counter = $counter + 1; } + $counter = 0; + foreach ($this->allowedMultiplePrefixes as $prefix => $prefixValue) { $elementX = ""; @@ -134,9 +137,9 @@ if (isset($this->profile))
    "); $counter = $counter + 1; - //echo ("Prefix: $prefix
    "); - */ + echo ("Prefix: $prefix
    "); } + } else { @@ -151,5 +154,4 @@ else
    - diff --git a/templates/conference/test.phtml b/templates/conference/test.phtml new file mode 100644 index 0000000..e583759 --- /dev/null +++ b/templates/conference/test.phtml @@ -0,0 +1 @@ +

    Test

    diff --git a/templates/person/profileeditor.phtml b/templates/person/profileeditor.phtml index fac1cf5..b6fe542 100644 --- a/templates/person/profileeditor.phtml +++ b/templates/person/profileeditor.phtml @@ -5,7 +5,7 @@ profile)) - { +{ $counter = 0; //echo ("Database Values:
    "); @@ -149,5 +149,4 @@ else - From 1600c88ade81cdaa28f08eff1ff7d612644a3ba1 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 12 Oct 2013 17:35:42 +0200 Subject: [PATCH 118/143] [b] Do not load PropertyRegex --- classes/Xodx/PersonController.php | 3 ++- templates/conference/edit.phtml | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 10c9309..6fd78a5 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -328,12 +328,13 @@ public function profileeditorAction ($template) // b) Data from Database if everything was fine so the new data in the DB can be viewed. //This is real sourcecode! + $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; $stringArray = explode("id=", $userUri); $name = $stringArray[1]; - $propertyRegex = $this -> loadPropertyRegex(); + //$propertyRegex = $this -> loadPropertyRegex(); $prefixesSinglePrepare = array(); $valuesSinglePrepare = array(); diff --git a/templates/conference/edit.phtml b/templates/conference/edit.phtml index 4ecffb0..b931c47 100644 --- a/templates/conference/edit.phtml +++ b/templates/conference/edit.phtml @@ -139,7 +139,6 @@ if (isset($this->profile)) $counter = $counter + 1; echo ("Prefix: $prefix
    "); } - } else { From a14280bb443013d659d47d782749595ef2dc5722 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 12 Oct 2013 18:52:23 +0200 Subject: [PATCH 119/143] ProfileEditor is completely functional. --- classes/Xodx/PersonController.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 6fd78a5..e0fc55d 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -351,6 +351,10 @@ public function profileeditorAction ($template) $query = "PREFIX foaf: SELECT ?p ?o WHERE { <" . $userUri . "> a foaf:Person. <" . $userUri . "> ?p ?o }"; $databaseValues = $model->sparqlQuery($query); + $notFoundMultipleKeys = $databaseValues; + + //var_dump($notFoundMultipleKeys); + //echo ("
    "); //echo ("Database Values:
    "); //var_dump($databaseValues); @@ -410,6 +414,7 @@ public function profileeditorAction ($template) if (strcmp ($element["p"], $newKey) == 0) { $oldValue = $element["o"]; + unset($notFoundMultipleKeys[$dbkey]); } } @@ -453,12 +458,14 @@ public function profileeditorAction ($template) } $found = false; //echo ("Looking for $prefix -> $value
    "); + + //echo ("
    "); foreach ($databaseValues as $key => $element) { //only for MultipleStatements $p = $element["p"]; $o = $element["o"]; - if (in_array($p, $allowedMultiplePrefixes)) + if (in_array($p, array_keys($allowedMultiplePrefixes))) { if (strcmp ($p, $prefix) == 0) { @@ -467,6 +474,10 @@ public function profileeditorAction ($template) //1.2 Delete this pair from $oldValues //TODO: Implement this. $found = true; + //echo ("$key
    "); + //echo ("Found: $prefix -> $value
    "); + unset($notFoundMultipleKeys[$key]); + //var_dump($notFoundMultipleKeys); } } } @@ -503,7 +514,6 @@ public function profileeditorAction ($template) if (count($wrong) > 0 && !is_null($wrong)) { //Allow wrong Properties to be corrected - //TODO: Mark the wrong keys. foreach ($wrong as $key => $value) { $databaseValues[] = $value; @@ -519,6 +529,20 @@ public function profileeditorAction ($template) } else { + //prepare $notFoundMultipleKeys + foreach ($notFoundMultipleKeys as $key => $element) + { + $p = $element["p"]; + $o = $element["o"]; + + if (in_array($p, array_keys($allowedMultiplePrefixes))) + { + $temp = array(); + $temp['p'] = $p; + $temp['o'] = $o; + $changedDELETE[] = $temp; + } + } //Write Properties to Database foreach ($changedDELETE as $key => $value) { From 39f370c65be58e6dd147a2e804ac884c2bf03a2f Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 12 Oct 2013 19:39:07 +0200 Subject: [PATCH 120/143] Read Type from config.ini --- classes/Xodx/ConferenceController.php | 9 ++++++--- classes/Xodx/ConfigHelper.php | 20 ++++++++++++++++++++ classes/Xodx/PersonController.php | 5 +++-- config.ini-dist | 26 ++++++++++++++------------ 4 files changed, 43 insertions(+), 17 deletions(-) diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index fce4060..2bb4103 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -34,12 +34,15 @@ public function editAction($template) //Show editor with data from database $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; + //$userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; $stringArray = explode("id=", $userUri); $name = $stringArray[1]; + $eventUri = "http://symbolicdata.org/Data/Conference/s2am-2013"; - $query = "PREFIX foaf: SELECT ?p ?o WHERE { <" . $userUri . "> a foaf:Person. <" . $userUri . "> ?p ?o }"; - //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; + $typeUri = $configHelper -> getEditorClass("conference"); + + $query = "PREFIX ns2: SELECT ?p ?o WHERE { <" . $eventUri . "> a <" . $typeUri . "> . <" . $eventUri . "> ?p ?o }"; + //$query = "PREFIX ical: SELECT ?event ?p ?o WHERE { ?event a ical:Event . ?event ?p ?o }"; $profiles = $model->sparqlQuery( $query); $template->allowedSinglePrefixes = $allowedSinglePrefixes; diff --git a/classes/Xodx/ConfigHelper.php b/classes/Xodx/ConfigHelper.php index 3204a89..30512a5 100644 --- a/classes/Xodx/ConfigHelper.php +++ b/classes/Xodx/ConfigHelper.php @@ -95,6 +95,26 @@ public function loadProperties($editorType) } return $properties; } + + public function getEditorClass($editorType) + { + $config = $this->_app->getBootstrap()->getResource('Config'); + foreach ($config as $key => $value) + { + $keySplit = explode(".",$key); + if ($keySplit[0] == "editor") + { + if ($keySplit[1] == $editorType) + { + if ($keySplit[2] == "class") + { + return $value; + } + } + } + } + + } } diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index e0fc55d..40063e3 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -298,6 +298,7 @@ public function profileeditorAction ($template) $configHelper = new Xodx_ConfigHelper($this->_app); $allowedSinglePrefixes = $configHelper->loadPropertiesSingle("person"); $allowedMultiplePrefixes = $configHelper->loadPropertiesMultiple("person"); + $typeUri = $configHelper -> getEditorClass("person"); if (count ($_POST) == 0) { @@ -308,7 +309,7 @@ public function profileeditorAction ($template) $stringArray = explode("id=", $userUri); $name = $stringArray[1]; - $query = "PREFIX foaf: SELECT ?p ?o WHERE { <" . $userUri . "> a foaf:Person. <" . $userUri . "> ?p ?o }"; + $query = "SELECT ?p ?o WHERE { <" . $userUri . "> a <" . $typeUri . "> . <" . $userUri . "> ?p ?o }"; //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; $profiles = $model->sparqlQuery( $query); @@ -349,7 +350,7 @@ public function profileeditorAction ($template) $changedDELETE = array(); $wrong = array(); - $query = "PREFIX foaf: SELECT ?p ?o WHERE { <" . $userUri . "> a foaf:Person. <" . $userUri . "> ?p ?o }"; + $query = "SELECT ?p ?o WHERE { <" . $userUri . "> a <" . $typeUri . "> . <" . $userUri . "> ?p ?o }"; $databaseValues = $model->sparqlQuery($query); $notFoundMultipleKeys = $databaseValues; diff --git a/config.ini-dist b/config.ini-dist index 418b478..ba5e257 100644 --- a/config.ini-dist +++ b/config.ini-dist @@ -12,7 +12,7 @@ push.hub = "http://pubsubhubbub.appspot.com" ;editor.single = http://xmlns.com/foaf/0.1/depiction,URL,http://xmlns.com/foaf/0.1/nick,Literal,http://xmlns.com/foaf/0.1/name,Literal ;editor.multiple = http://xmlns.com/foaf/0.1/schoolHomepage,URL,http://xmlns.com/foaf/0.1/jabberID,Email,http://www.w3.org/2000/01/rdf-schema#seeAlso,URL,http://xmlns.com/foaf/0.1/based_near,URL,http://xmlns.com/foaf/0.1/weblog,URL,http://xmlns.com/foaf/0.1/workplaceHomepage,URL -;editor.person.class = http://...foaf...Person +editor.person.class = http://xmlns.com/foaf/0.1/Person editor.person.property.1.uri = http://xmlns.com/foaf/0.1/nick editor.person.property.1.type = Literal @@ -43,35 +43,37 @@ editor.person.property.9.uri = http://xmlns.com/foaf/0.1/workplaceHomepage editor.person.property.9.type = URL editor.person.property.9.cardinality = multiple -editor.conference.property.1.uri = rdfs:label +editor.conference.class = http://symbolicdata.org/Data/Model#Conference + +editor.conference.property.1.uri = http://www.w3.org/2000/01/rdf-schema#label editor.conference.property.1.type = String editor.conference.property.1.cardinality = single -editor.conference.property.2.uri = ical:status +editor.conference.property.2.uri = http://www.w3.org/2002/12/cal/ical#status editor.conference.property.2.type = String editor.conference.property.2.cardinality = single -editor.conference.property.3.uri = ical:summary +editor.conference.property.3.uri = http://www.w3.org/2002/12/cal/ical#summary editor.conference.property.3.type = String editor.conference.property.3.cardinality = single -editor.conference.property.4.uri = ical:description +editor.conference.property.4.uri = http://www.w3.org/2002/12/cal/ical#description editor.conference.property.4.type = Literal editor.conference.property.4.cardinality = single -editor.conference.property.5.uri = ical:location +editor.conference.property.5.uri = http://www.w3.org/2002/12/cal/ical#location editor.conference.property.5.type = String editor.conference.property.5.cardinality = single -editor.conference.property.6.uri = ical:contact +editor.conference.property.6.uri = http://www.w3.org/2002/12/cal/ical#contact editor.conference.property.6.type = String editor.conference.property.6.cardinality = single -editor.conference.property.7.uri = ical:url +editor.conference.property.7.uri = http://www.w3.org/2002/12/cal/ical#url editor.conference.property.7.type = URL editor.conference.property.7.cardinality = single -editor.conference.property.8.uri = ical:dtstart +editor.conference.property.8.uri = http://www.w3.org/2002/12/cal/ical#dtstart editor.conference.property.8.type = DateTime editor.conference.property.8.cardinality = single -editor.conference.property.9.uri = ical:dtend +editor.conference.property.9.uri = http://www.w3.org/2002/12/cal/ical#dtend editor.conference.property.9.type = DateTime editor.conference.property.9.cardinality = single -editor.conference.property.10.uri = ical:created +editor.conference.property.10.uri = http://www.w3.org/2002/12/cal/ical#created editor.conference.property.10.type = DateTime editor.conference.property.10.cardinality = single @@ -124,4 +126,4 @@ foaf = 'http://xmlns.com/foaf/0.1/'; dssn = 'http://purl.org/net/dssn/'; ow = 'http://ns.ontowiki.net/SysOnt/'; ov = 'http://open.vocab.org/docs/'; -rel = 'http://purl.org/vocab/relationship/' +rel = 'http://purl.org/vocab/relationship/' \ No newline at end of file From 0dd7ac15c804d3d359f66195840e4d5cb2c4852c Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sat, 12 Oct 2013 20:03:54 +0200 Subject: [PATCH 121/143] List Conferences --- classes/Xodx/ConferenceController.php | 26 +++++++++++++++++++++++++- templates/conference/list.phtml | 12 ++++++++++++ templates/partials/menu.phtml | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 templates/conference/list.phtml diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index 2bb4103..4eab39e 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -37,7 +37,7 @@ public function editAction($template) //$userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; $stringArray = explode("id=", $userUri); $name = $stringArray[1]; - $eventUri = "http://symbolicdata.org/Data/Conference/s2am-2013"; + $eventUri = "http://symbolicdata.org/Data/Conference/s2am-2013"; //TODO: dynamic $typeUri = $configHelper -> getEditorClass("conference"); @@ -57,4 +57,28 @@ public function editAction($template) echo ("Nope."); } } + + public function listAction($template) + { + $model = $this->_app->getBootstrap()->getResource('Model'); + $configHelper = new Xodx_ConfigHelper($this->_app); + $typeUri = $configHelper -> getEditorClass("conference"); + $profiles = $model->sparqlQuery('SELECT DISTINCT ?event ?p ?o WHERE { ?event a <'. $typeUri .'> . ?event ?p ?o}'); + + foreach ($profiles as $key => $array) + { + //var_dump($array); + //echo ($array["p"]); + //echo ("
    "); + if ( strcmp($array["p"],"http://www.w3.org/2000/01/rdf-schema#label") !=0) + { + unset($profiles[$key]); + } + } + + //var_dump($profiles); + $template->profiles = $profiles; + $template->addContent('templates/list.phtml'); + return $template; + } } diff --git a/templates/conference/list.phtml b/templates/conference/list.phtml new file mode 100644 index 0000000..8485f6a --- /dev/null +++ b/templates/conference/list.phtml @@ -0,0 +1,12 @@ +

    List of Conferences

    +
      +profiles as $key) +{ + $event = $key["event"]; + $title = $key["o"]; + echo ("
    • $event - $title
    • "); +} + +?> +
    diff --git a/templates/partials/menu.phtml b/templates/partials/menu.phtml index 4c99d32..e387caa 100644 --- a/templates/partials/menu.phtml +++ b/templates/partials/menu.phtml @@ -20,6 +20,7 @@ username != "guest") { + echo ("
  • Show All Conferences
  • "); echo ("
  • Conference Editor
  • "); echo ("
  • Profile Editor
  • "); echo ("
  • Logout
  • "); From b7bb5756e9dc2553e7cb44e8a24c1c85d3b8e93f Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 13 Oct 2013 20:47:37 +0200 Subject: [PATCH 122/143] Show Conference depending on GET --- classes/Xodx/ConferenceController.php | 14 ++++++++++++-- templates/conference/list.phtml | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index 4eab39e..e7d67db 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -25,19 +25,29 @@ public function PrefixesAction() public function editAction($template) { - $model = $this->_app->getBootstrap()->getResource('Model'); + $bootstrap = $this->_app->getBootstrap(); + $model = $bootstrap->getResource('model'); $configHelper = new Xodx_ConfigHelper($this->_app); $allowedSinglePrefixes = $configHelper->loadPropertiesSingle("conference"); + $request = $bootstrap->getResource('request'); if (count ($_POST) == 0) { + $objectId = $request->getValue('id', 'get'); //Show editor with data from database $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); //$userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; $stringArray = explode("id=", $userUri); $name = $stringArray[1]; - $eventUri = "http://symbolicdata.org/Data/Conference/s2am-2013"; //TODO: dynamic + if (is_null($objectId)) + { + $eventUri = "http://symbolicdata.org/Data/Conference/s2am-2013"; //TODO: dynamic + } + else + { + $eventUri = $objectId; + } $typeUri = $configHelper -> getEditorClass("conference"); diff --git a/templates/conference/list.phtml b/templates/conference/list.phtml index 8485f6a..5c20178 100644 --- a/templates/conference/list.phtml +++ b/templates/conference/list.phtml @@ -5,7 +5,7 @@ foreach ($this->profiles as $key) { $event = $key["event"]; $title = $key["o"]; - echo ("
  • $event - $title
  • "); + echo ("
  • $event - $title
  • "); } ?> From 7938277fd6c509d82a0e6375105daea062315740 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 13 Oct 2013 20:55:49 +0200 Subject: [PATCH 123/143] Conferences a bit improved. --- classes/Xodx/ConferenceController.php | 32 ++++++++++++++------------- templates/conference/edit.phtml | 2 +- templates/conference/list.phtml | 3 ++- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index e7d67db..bc6d437 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -40,26 +40,28 @@ public function editAction($template) //$userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; $stringArray = explode("id=", $userUri); $name = $stringArray[1]; - if (is_null($objectId)) - { - $eventUri = "http://symbolicdata.org/Data/Conference/s2am-2013"; //TODO: dynamic - } - else + if (!is_null($objectId)) { $eventUri = $objectId; - } - $typeUri = $configHelper -> getEditorClass("conference"); - $query = "PREFIX ns2: SELECT ?p ?o WHERE { <" . $eventUri . "> a <" . $typeUri . "> . <" . $eventUri . "> ?p ?o }"; - //$query = "PREFIX ical: SELECT ?event ?p ?o WHERE { ?event a ical:Event . ?event ?p ?o }"; + $typeUri = $configHelper -> getEditorClass("conference"); + + $query = "PREFIX ns2: SELECT ?p ?o WHERE { <" . $eventUri . "> a <" . $typeUri . "> . <" . $eventUri . "> ?p ?o }"; + //$query = "PREFIX ical: SELECT ?event ?p ?o WHERE { ?event a ical:Event . ?event ?p ?o }"; - $profiles = $model->sparqlQuery( $query); - $template->allowedSinglePrefixes = $allowedSinglePrefixes; - $template->profile = $profiles; - $template->addContent('templates/edit.phtml'); - //echo ("FOOO"); - return $template; + $profiles = $model->sparqlQuery( $query); + $template->allowedSinglePrefixes = $allowedSinglePrefixes; + $template->profile = $profiles; + $template->addContent('templates/edit.phtml'); + //echo ("FOOO"); + return $template; + } + else + { + //this will create a new conference + return $template; + } } else { diff --git a/templates/conference/edit.phtml b/templates/conference/edit.phtml index b931c47..6235d09 100644 --- a/templates/conference/edit.phtml +++ b/templates/conference/edit.phtml @@ -142,7 +142,7 @@ if (isset($this->profile)) } else { - echo ("Damn, profile not set..."); + echo ("Create new Conference? This will be implemented soon."); } ?> diff --git a/templates/conference/list.phtml b/templates/conference/list.phtml index 5c20178..3c083a1 100644 --- a/templates/conference/list.phtml +++ b/templates/conference/list.phtml @@ -7,6 +7,7 @@ foreach ($this->profiles as $key) $title = $key["o"]; echo ("
  • $event - $title
  • "); } - +echo ("
  • Create new Conference
  • "); ?> + From f80faa18c1d2024a5e16f6eb27163554ce169f19 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Mon, 21 Oct 2013 13:35:59 +0200 Subject: [PATCH 124/143] [i] Moved Editor to own class --- templates/conference/list.phtml | 4 +- templates/editor/edit.phtml | 153 ++++++++++++++++++++++++++++++++ templates/partials/menu.phtml | 2 +- 3 files changed, 156 insertions(+), 3 deletions(-) create mode 100644 templates/editor/edit.phtml diff --git a/templates/conference/list.phtml b/templates/conference/list.phtml index 3c083a1..a84c9dc 100644 --- a/templates/conference/list.phtml +++ b/templates/conference/list.phtml @@ -5,9 +5,9 @@ foreach ($this->profiles as $key) { $event = $key["event"]; $title = $key["o"]; - echo ("
  • $event - $title
  • "); + echo ("
  • $event - $title
  • "); } -echo ("
  • Create new Conference
  • "); +echo ("
  • Create new Conference
  • "); ?> diff --git a/templates/editor/edit.phtml b/templates/editor/edit.phtml new file mode 100644 index 0000000..d1be51d --- /dev/null +++ b/templates/editor/edit.phtml @@ -0,0 +1,153 @@ +profile)) +{ + //echo ("Foo :"); + $caption = $this->caption; + echo ("

    $caption

    "); + + echo ("
    "); + + $counter = 0; + + //echo ("Database Values:
    "); + //var_dump($this->profile); + //echo ("
    "); + + if (count($this -> wrong) > 0 && !is_null($this -> wrong)) + { + echo ("Please correct the red Properties!

    "); + //var_dump($this -> wrong); + } + + foreach ($this->allowedSinglePrefixes as $prefixKey => $prefix) + { + $elementX = ""; + //HACK: Do we have LINQ or at least something to make this better? + //echo ("$prefix
    "); + //var_dump($prefixKey); + //echo ("
    "); + + foreach ($this->profile as $key => $element) + { + if ($element["p"] == $prefixKey) + { + $elementX = $element["o"]; + } + } + $counterText = (string)$counter; + $prefixText = $counterText ."_prefix"; + $valueText = $counterText . "_value"; + $thisIsWrong = false; + + foreach($this->wrong as $keyX => $array) + { + if ($array['p'] == $prefixKey) + { + //echo ("Wrong: $prefix"); + $thisIsWrong = true; + break; + } + } + + if ($thisIsWrong) + { + echo ("
    + +
    + + +
    +
    "); + } + else + { + echo ("
    + +
    + + +
    +
    "); + } + $counter = $counter + 1; + } + + $counter = 0; + foreach ($this->allowedMultiplePrefixes as $prefix => $prefixValue) + { + $elementX = ""; + $i = 0; + $counterText = (string)$counter; + //HACK: Do we have LINQ or at least something to make this better? + foreach ($this->profile as $key => $element) + { + if ($element["p"] == $prefix) + { + $elementX = $element["o"]; + + $prefixText = $counterText ."_Mprefix"; + $valueText = $counterText . "_Mvalue_$i"; + + $thisIsWrong = false; + + foreach($this->wrong as $key => $array) + { + if ($array['p'] == $prefix && $array['o'] == $elementX) + { + $thisIsWrong = true; + break; + } + } + + if ($thisIsWrong) + { + echo ("
    + +
    + + +
    +
    "); + } + else + { + echo ("
    + +
    + + +
    +
    "); + } + $i=$i+1; + } + } + + $prefixText = $counterText ."_Mprefix"; + $valueText = $counterText . "_Mvalue_$i"; + echo ("
    + +
    + + +
    +
    "); + + $counter = $counter + 1; + //echo ("Prefix: $prefix
    "); + } +} +else +{ + echo ("Damn, profile not set..."); +} + +?> + +
    + +
    + +
    + +
    diff --git a/templates/partials/menu.phtml b/templates/partials/menu.phtml index e387caa..3816d56 100644 --- a/templates/partials/menu.phtml +++ b/templates/partials/menu.phtml @@ -22,7 +22,7 @@ { echo ("
  • Show All Conferences
  • "); echo ("
  • Conference Editor
  • "); - echo ("
  • Profile Editor
  • "); + echo ("
  • Profile Editor
  • "); echo ("
  • Logout
  • "); } else From 6ad3313846ecd70016aab6c99a0e6a8ef5621a6f Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Mon, 21 Oct 2013 13:57:23 +0200 Subject: [PATCH 125/143] Editor --- classes/Xodx/ConferenceController.php | 2 - classes/Xodx/EditorController.php | 325 ++++++++++++++++++++++++++ classes/Xodx/PersonController.php | 299 ------------------------ 3 files changed, 325 insertions(+), 301 deletions(-) create mode 100644 classes/Xodx/EditorController.php diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index bc6d437..1a92280 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -43,8 +43,6 @@ public function editAction($template) if (!is_null($objectId)) { $eventUri = $objectId; - - $typeUri = $configHelper -> getEditorClass("conference"); $query = "PREFIX ns2: SELECT ?p ?o WHERE { <" . $eventUri . "> a <" . $typeUri . "> . <" . $eventUri . "> ?p ?o }"; diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php new file mode 100644 index 0000000..b89adc4 --- /dev/null +++ b/classes/Xodx/EditorController.php @@ -0,0 +1,325 @@ +_app->getBootstrap(); + $model = $bootstrap->getResource('model'); + $configHelper = new Xodx_ConfigHelper($this->_app); + $request = $bootstrap->getResource('request'); + $classId = $request->getValue('class', 'get'); + $typeUri = $configHelper -> getEditorClass($classId); + $applicationController = $this->_app->getController('Xodx_ApplicationController'); + + if (strcmp($classId,"person") == 0) + { + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; + $objectUri = $userUri; + } + else + { + $objectUri = $request->getValue('id', 'get'); + } + + $allowedSinglePrefixes = $configHelper->loadPropertiesSingle($classId); + $allowedMultiplePrefixes = $configHelper->loadPropertiesMultiple($classId); + + $template -> caption = $classId; + + //echo ("
    $objectUri"); + //echo ("
    $typeUri"); + + if (count ($_POST) == 0) + { + //$userId = $applicationController->getUser(); + + $query = "SELECT ?p ?o WHERE { <" . $objectUri . "> a <" . $typeUri . "> . <" . $objectUri . "> ?p ?o }"; + //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; + + //echo ("$query"); + //echo ("
    $objectUri"); + //echo ("
    $typeUri"); + + $profiles = $model->sparqlQuery( $query); + $template->allowedSinglePrefixes = $allowedSinglePrefixes; + $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; + $template->profile = $profiles; + + //echo ("Foo"); + + $template->addContent('templates/edit.phtml'); + + return $template; + } + else + { + //Process POSTed values an show ProfileEditor with + // a) Data from POST if it needs to be corrected + // TODO: Indicated that data... + // b) Data from Database if everything was fine so the new data in the DB can be viewed. + + //This is real sourcecode! + + $applicationController = $this->_app->getController('Xodx_ApplicationController'); + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; + $stringArray = explode("id=", $userUri); + $name = $stringArray[1]; + //$propertyRegex = $this -> loadPropertyRegex(); + + $prefixesSinglePrepare = array(); + $valuesSinglePrepare = array(); + $prefixesMultiplePrepare = array(); + $valuesMultiplePrepare = array(); + $valuesSingleNew = array(); + $valuesMultipleNew = array(); + $newKey; + $newValue; + $oldValue; + $changedADD = array(); + $changedDELETE = array(); + $wrong = array(); + + $query = "SELECT ?p ?o WHERE { <" . $userUri . "> a <" . $typeUri . "> . <" . $userUri . "> ?p ?o }"; + $databaseValues = $model->sparqlQuery($query); + $notFoundMultipleKeys = $databaseValues; + + //var_dump($notFoundMultipleKeys); + //echo ("
    "); + + //echo ("Database Values:
    "); + //var_dump($databaseValues); + //echo ("
    "); + + //prepare $_POST into prefix --> value + foreach ($_POST as $key => $value) + { + $keyArray = explode("_", $key); + $number = (int)$keyArray[0]; + + //single + if ($keyArray[1] == "value") + { + $valuesSinglePrepare[$number] = $value; + } + + if ($keyArray[1] == "prefix") + { + $prefixesSinglePrepare[$number] = $value; + } + + //multiple + //$numberInKey is only needed if Property is multiple, so it is put inside the if statements. + if ($keyArray[1] == "Mvalue") + { + $numberInKey = (int)$keyArray[count($keyArray)-1]; + $valuesMultiplePrepare[$number][$numberInKey] = $value; + } + + if ($keyArray[1] == "Mprefix") + { + $numberInKey = (int)$keyArray[count($keyArray)-1]; + $prefixesMultiplePrepare[$number] = $value; + } + } + + foreach ($prefixesSinglePrepare as $key => $value) + { + $valuesSingleNew[$value] = $valuesSinglePrepare[(int)$key]; + } + + //Single + foreach ($valuesSingleNew as $key => $value) + { + //Reset old values + $oldValue = ""; + $newKey = $key; + + //find corresponding value in query + //Searches for equivalent of $newKey + foreach ($databaseValues as $dbkey => $element) + { + $p = $element["p"]; + $o = $element["o"]; + //echo "
    $p -- $o"; + if (strcmp ($element["p"], $newKey) == 0) + { + $oldValue = $element["o"]; + unset($notFoundMultipleKeys[$dbkey]); + } + } + + if ($value != $oldValue ) + { + $rString = $allowedSinglePrefixes[$key]["regex"]; + if (ereg($rString, $value) == true) + { + //echo ("Match: $value for $newKey with $rString"); + $temp = array(); + $temp['p'] = $newKey; + $temp['o'] = $value; + $changedADD[] = $temp; + $temp = array(); + $temp['p'] = $newKey; + $temp['o'] = $oldValue; + $changedDELETE[] = $temp; + } + else + { + //echo ("Wrong Format: $value for $newKey with $rString
    "); + if (!empty ($value)) + { + $wrong[$newKey] = $value; + } + } + } + } + + //Multiple + foreach ($prefixesMultiplePrepare as $prefixKey => $prefix) + { + $values = $valuesMultiplePrepare[$prefixKey]; + foreach ($values as $valueKey => $value) + { + // 1. Forall key->value in newValues + // 1.1 Find corresponding value. + if ($value == "") + { + break; + } + $found = false; + //echo ("Looking for $prefix -> $value
    "); + + //echo ("
    "); + foreach ($databaseValues as $key => $element) + { + //only for MultipleStatements + $p = $element["p"]; + $o = $element["o"]; + if (in_array($p, array_keys($allowedMultiplePrefixes))) + { + if (strcmp ($p, $prefix) == 0) + { + if (strcmp ($o, $value) == 0) + { + //1.2 Delete this pair from $oldValues + //TODO: Implement this. + $found = true; + //echo ("$key
    "); + //echo ("Found: $prefix -> $value
    "); + unset($notFoundMultipleKeys[$key]); + //var_dump($notFoundMultipleKeys); + } + } + } + } + if (!$found) + { + //echo ("Not found: $prefix -> $value
    "); + $rString = $allowedMultiplePrefixes[$prefix]["regex"]; + //echo ("$rString"); + //var_dump($value); + if (preg_match($rString, $value) == true) + { + //echo ("Match: $value for $newKey"); + $temp = array(); + $temp['p'] = $prefix; + $temp['o'] = $value; + $changedADD[] = $temp; + } + else + { + //echo ("Wrong Format: $value for $prefix with $rString
    "); + if (!empty ($value)) + { + $temp = array(); + $temp['p'] = $prefix; + $temp['o'] = $value; + $wrong[] = $temp; + } + } + } + } + } + + if (count($wrong) > 0 && !is_null($wrong)) + { + //Allow wrong Properties to be corrected + foreach ($wrong as $key => $value) + { + $databaseValues[] = $value; + } + + $template->allowedSinglePrefixes = $allowedSinglePrefixes; + $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; + $template->profile = $databaseValues; + $template->config = $config; + $template->wrong = $wrong; + $template->addContent('templates/edit.phtml'); + return $template; + } + else + { + //prepare $notFoundMultipleKeys + foreach ($notFoundMultipleKeys as $key => $element) + { + $p = $element["p"]; + $o = $element["o"]; + + if (in_array($p, array_keys($allowedMultiplePrefixes))) + { + $temp = array(); + $temp['p'] = $p; + $temp['o'] = $o; + $changedDELETE[] = $temp; + } + } + //Write Properties to Database + foreach ($changedDELETE as $key => $value) + { + //$keyArray = array('value' => ); + $valueArray = array('type' => 'literal', 'value' => $value['o']); + $keyToDelete = $value['p']; + $valueToDelete = $value['o']; + //echo ("
    Delete: $userUri, $keyToDelete, $valueToDelete"); + $model->deleteStatement($userUri, $keyToDelete, $valueArray); + } + foreach ($changedADD as $key => $value) + { + //$keyArray = array('value' => ); + //array('type' => 'uri', 'value' => $newPersonUri) + $valueArray = array('type' => 'literal', 'value' => $value['o']); + $keyToWrite = $value['p']; + $valueToWrite = $value['o']; + //echo ("
    Writing: $userUri, $keyToWrite, $valueToWrite"); + $model->addStatement($userUri, $keyToWrite, $valueArray); + } + + //Show Profileeditor with Values from Database. + $_POST = NULL; + $template = $this -> profileeditorAction($template); + return $template; + } + } + } + +public function loadPropertiesAction() + { + $configHelper = new Xodx_ConfigHelper($this->_app); + return $configHelper -> loadProperties(); + } + + public function loadPropertiesSingleAction() + { + $configHelper = new Xodx_ConfigHelper($this->_app); + var_dump($configHelper -> loadPropertiesSingle("conference")); + } + + public function loadPropertiesMultipleAction() + { + $configHelper = new Xodx_ConfigHelper($this->_app); + var_dump($configHelper -> loadPropertiesMultiple("person")); + } +} diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index 40063e3..c02cc25 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -292,287 +292,6 @@ public function getNotifications ($personUri) return $pingResult; } - public function profileeditorAction ($template) - { - $model = $this->_app->getBootstrap()->getResource('Model'); - $configHelper = new Xodx_ConfigHelper($this->_app); - $allowedSinglePrefixes = $configHelper->loadPropertiesSingle("person"); - $allowedMultiplePrefixes = $configHelper->loadPropertiesMultiple("person"); - $typeUri = $configHelper -> getEditorClass("person"); - - if (count ($_POST) == 0) - { - // Show editor with data from database - $applicationController = $this->_app->getController('Xodx_ApplicationController'); - $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; - $stringArray = explode("id=", $userUri); - $name = $stringArray[1]; - - $query = "SELECT ?p ?o WHERE { <" . $userUri . "> a <" . $typeUri . "> . <" . $userUri . "> ?p ?o }"; - //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; - - $profiles = $model->sparqlQuery( $query); - $template->allowedSinglePrefixes = $allowedSinglePrefixes; - $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; - $template->profile = $profiles; - - $template->addContent('templates/profileeditor.phtml'); - - return $template; - } - else - { - //Process POSTed values an show ProfileEditor with - // a) Data from POST if it needs to be corrected - // TODO: Indicated that data... - // b) Data from Database if everything was fine so the new data in the DB can be viewed. - - //This is real sourcecode! - - $applicationController = $this->_app->getController('Xodx_ApplicationController'); - $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; - $stringArray = explode("id=", $userUri); - $name = $stringArray[1]; - //$propertyRegex = $this -> loadPropertyRegex(); - - $prefixesSinglePrepare = array(); - $valuesSinglePrepare = array(); - $prefixesMultiplePrepare = array(); - $valuesMultiplePrepare = array(); - $valuesSingleNew = array(); - $valuesMultipleNew = array(); - $newKey; - $newValue; - $oldValue; - $changedADD = array(); - $changedDELETE = array(); - $wrong = array(); - - $query = "SELECT ?p ?o WHERE { <" . $userUri . "> a <" . $typeUri . "> . <" . $userUri . "> ?p ?o }"; - $databaseValues = $model->sparqlQuery($query); - $notFoundMultipleKeys = $databaseValues; - - //var_dump($notFoundMultipleKeys); - //echo ("
    "); - - //echo ("Database Values:
    "); - //var_dump($databaseValues); - //echo ("
    "); - - //prepare $_POST into prefix --> value - foreach ($_POST as $key => $value) - { - $keyArray = explode("_", $key); - $number = (int)$keyArray[0]; - - //single - if ($keyArray[1] == "value") - { - $valuesSinglePrepare[$number] = $value; - } - - if ($keyArray[1] == "prefix") - { - $prefixesSinglePrepare[$number] = $value; - } - - //multiple - //$numberInKey is only needed if Property is multiple, so it is put inside the if statements. - if ($keyArray[1] == "Mvalue") - { - $numberInKey = (int)$keyArray[count($keyArray)-1]; - $valuesMultiplePrepare[$number][$numberInKey] = $value; - } - - if ($keyArray[1] == "Mprefix") - { - $numberInKey = (int)$keyArray[count($keyArray)-1]; - $prefixesMultiplePrepare[$number] = $value; - } - } - - foreach ($prefixesSinglePrepare as $key => $value) - { - $valuesSingleNew[$value] = $valuesSinglePrepare[(int)$key]; - } - - //Single - foreach ($valuesSingleNew as $key => $value) - { - //Reset old values - $oldValue = ""; - $newKey = $key; - - //find corresponding value in query - //Searches for equivalent of $newKey - foreach ($databaseValues as $dbkey => $element) - { - $p = $element["p"]; - $o = $element["o"]; - //echo "
    $p -- $o"; - if (strcmp ($element["p"], $newKey) == 0) - { - $oldValue = $element["o"]; - unset($notFoundMultipleKeys[$dbkey]); - } - } - - if ($value != $oldValue ) - { - $rString = $allowedSinglePrefixes[$key]["regex"]; - if (ereg($rString, $value) == true) - { - //echo ("Match: $value for $newKey with $rString"); - $temp = array(); - $temp['p'] = $newKey; - $temp['o'] = $value; - $changedADD[] = $temp; - $temp = array(); - $temp['p'] = $newKey; - $temp['o'] = $oldValue; - $changedDELETE[] = $temp; - } - else - { - //echo ("Wrong Format: $value for $newKey with $rString
    "); - if (!empty ($value)) - { - $wrong[$newKey] = $value; - } - } - } - } - - //Multiple - foreach ($prefixesMultiplePrepare as $prefixKey => $prefix) - { - $values = $valuesMultiplePrepare[$prefixKey]; - foreach ($values as $valueKey => $value) - { - // 1. Forall key->value in newValues - // 1.1 Find corresponding value. - if ($value == "") - { - break; - } - $found = false; - //echo ("Looking for $prefix -> $value
    "); - - //echo ("
    "); - foreach ($databaseValues as $key => $element) - { - //only for MultipleStatements - $p = $element["p"]; - $o = $element["o"]; - if (in_array($p, array_keys($allowedMultiplePrefixes))) - { - if (strcmp ($p, $prefix) == 0) - { - if (strcmp ($o, $value) == 0) - { - //1.2 Delete this pair from $oldValues - //TODO: Implement this. - $found = true; - //echo ("$key
    "); - //echo ("Found: $prefix -> $value
    "); - unset($notFoundMultipleKeys[$key]); - //var_dump($notFoundMultipleKeys); - } - } - } - } - if (!$found) - { - //echo ("Not found: $prefix -> $value
    "); - $rString = $allowedMultiplePrefixes[$prefix]["regex"]; - //echo ("$rString"); - //var_dump($value); - if (preg_match($rString, $value) == true) - { - //echo ("Match: $value for $newKey"); - $temp = array(); - $temp['p'] = $prefix; - $temp['o'] = $value; - $changedADD[] = $temp; - } - else - { - //echo ("Wrong Format: $value for $prefix with $rString
    "); - if (!empty ($value)) - { - $temp = array(); - $temp['p'] = $prefix; - $temp['o'] = $value; - $wrong[] = $temp; - } - } - } - } - } - - if (count($wrong) > 0 && !is_null($wrong)) - { - //Allow wrong Properties to be corrected - foreach ($wrong as $key => $value) - { - $databaseValues[] = $value; - } - - $template->allowedSinglePrefixes = $allowedSinglePrefixes; - $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; - $template->profile = $databaseValues; - $template->config = $config; - $template->wrong = $wrong; - $template->addContent('templates/profileeditor.phtml'); - return $template; - } - else - { - //prepare $notFoundMultipleKeys - foreach ($notFoundMultipleKeys as $key => $element) - { - $p = $element["p"]; - $o = $element["o"]; - - if (in_array($p, array_keys($allowedMultiplePrefixes))) - { - $temp = array(); - $temp['p'] = $p; - $temp['o'] = $o; - $changedDELETE[] = $temp; - } - } - //Write Properties to Database - foreach ($changedDELETE as $key => $value) - { - //$keyArray = array('value' => ); - $valueArray = array('type' => 'literal', 'value' => $value['o']); - $keyToDelete = $value['p']; - $valueToDelete = $value['o']; - //echo ("
    Delete: $userUri, $keyToDelete, $valueToDelete"); - $model->deleteStatement($userUri, $keyToDelete, $valueArray); - } - foreach ($changedADD as $key => $value) - { - //$keyArray = array('value' => ); - //array('type' => 'uri', 'value' => $newPersonUri) - $valueArray = array('type' => 'literal', 'value' => $value['o']); - $keyToWrite = $value['p']; - $valueToWrite = $value['o']; - //echo ("
    Writing: $userUri, $keyToWrite, $valueToWrite"); - $model->addStatement($userUri, $keyToWrite, $valueArray); - } - - //Show Profileeditor with Values from Database. - $_POST = NULL; - $template = $this -> profileeditorAction($template); - return $template; - } - } - } - /** * Quick fix for Erfurt issue #24 (https://github.com/AKSW/Erfurt/issues/24) */ @@ -585,22 +304,4 @@ private static function _issueE24fix ($date) return $date; } } - - public function loadPropertiesAction() - { - $configHelper = new Xodx_ConfigHelper($this->_app); - return $configHelper -> loadProperties(); - } - - public function loadPropertiesSingleAction() - { - $configHelper = new Xodx_ConfigHelper($this->_app); - var_dump($configHelper -> loadPropertiesSingle("conference")); - } - - public function loadPropertiesMultipleAction() - { - $configHelper = new Xodx_ConfigHelper($this->_app); - var_dump($configHelper -> loadPropertiesMultiple("person")); - } } From 0411eeb4ab15dd5bd2572b656a0c82f25684e755 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Mon, 21 Oct 2013 14:08:23 +0200 Subject: [PATCH 126/143] Editor works the way it should. Kinda. --- classes/Xodx/EditorController.php | 6 +++++- templates/editor/edit.phtml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php index b89adc4..765df3d 100644 --- a/classes/Xodx/EditorController.php +++ b/classes/Xodx/EditorController.php @@ -62,6 +62,7 @@ public function editAction ($template) //This is real sourcecode! + $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; @@ -86,6 +87,8 @@ public function editAction ($template) $databaseValues = $model->sparqlQuery($query); $notFoundMultipleKeys = $databaseValues; + //echo ("Foo"); + //var_dump($notFoundMultipleKeys); //echo ("
    "); @@ -96,6 +99,7 @@ public function editAction ($template) //prepare $_POST into prefix --> value foreach ($_POST as $key => $value) { + //echo ("$key - $value
    "); $keyArray = explode("_", $key); $number = (int)$keyArray[0]; @@ -299,7 +303,7 @@ public function editAction ($template) //Show Profileeditor with Values from Database. $_POST = NULL; - $template = $this -> profileeditorAction($template); + $template = $this -> editAction($template); return $template; } } diff --git a/templates/editor/edit.phtml b/templates/editor/edit.phtml index d1be51d..89a5001 100644 --- a/templates/editor/edit.phtml +++ b/templates/editor/edit.phtml @@ -5,7 +5,7 @@ if (isset($this->profile)) $caption = $this->caption; echo ("

    $caption

    "); - echo ("
    "); + echo ("
    "); $counter = 0; From 803ba83e875530be3145c8933b2e0cab8ee53c11 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Mon, 21 Oct 2013 14:08:49 +0200 Subject: [PATCH 127/143] Removed "edit" from ConferenceController.php --- classes/Xodx/ConferenceController.php | 45 --------------------------- 1 file changed, 45 deletions(-) diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index 1a92280..c738471 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -23,51 +23,6 @@ public function PrefixesAction() var_dump($configHelper -> loadPropertiesSingle("conference")); } - public function editAction($template) - { - $bootstrap = $this->_app->getBootstrap(); - $model = $bootstrap->getResource('model'); - $configHelper = new Xodx_ConfigHelper($this->_app); - $allowedSinglePrefixes = $configHelper->loadPropertiesSingle("conference"); - $request = $bootstrap->getResource('request'); - - if (count ($_POST) == 0) - { - $objectId = $request->getValue('id', 'get'); - //Show editor with data from database - $applicationController = $this->_app->getController('Xodx_ApplicationController'); - $userId = $applicationController->getUser(); - //$userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; - $stringArray = explode("id=", $userUri); - $name = $stringArray[1]; - if (!is_null($objectId)) - { - $eventUri = $objectId; - $typeUri = $configHelper -> getEditorClass("conference"); - - $query = "PREFIX ns2: SELECT ?p ?o WHERE { <" . $eventUri . "> a <" . $typeUri . "> . <" . $eventUri . "> ?p ?o }"; - //$query = "PREFIX ical: SELECT ?event ?p ?o WHERE { ?event a ical:Event . ?event ?p ?o }"; - - $profiles = $model->sparqlQuery( $query); - $template->allowedSinglePrefixes = $allowedSinglePrefixes; - $template->profile = $profiles; - $template->addContent('templates/edit.phtml'); - //echo ("FOOO"); - return $template; - } - else - { - //this will create a new conference - return $template; - } - } - else - { - //Currently do nothing. - echo ("Nope."); - } - } - public function listAction($template) { $model = $this->_app->getBootstrap()->getResource('Model'); From b23c3ab1ba46fbf048b25241e6a90616fb20c46d Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Mon, 21 Oct 2013 18:45:59 +0200 Subject: [PATCH 128/143] Documentation --- classes/Xodx/ConferenceController.php | 2 +- classes/Xodx/EditorController.php | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index c738471..38e665a 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -35,7 +35,7 @@ public function listAction($template) //var_dump($array); //echo ($array["p"]); //echo ("
    "); - if ( strcmp($array["p"],"http://www.w3.org/2000/01/rdf-schema#label") !=0) + if (strcmp($array["p"],"http://www.w3.org/2000/01/rdf-schema#label") !=0) { unset($profiles[$key]); } diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php index 765df3d..d926519 100644 --- a/classes/Xodx/EditorController.php +++ b/classes/Xodx/EditorController.php @@ -1,5 +1,13 @@ Date: Thu, 24 Oct 2013 18:44:46 +0200 Subject: [PATCH 129/143] Inserted RightsManagement --- classes/Xodx/EditorController.php | 13 +++++++++- classes/Xodx/RightsHelper.php | 40 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 classes/Xodx/RightsHelper.php diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php index d926519..0fcbf72 100644 --- a/classes/Xodx/EditorController.php +++ b/classes/Xodx/EditorController.php @@ -20,7 +20,7 @@ public function editAction ($template) $typeUri = $configHelper -> getEditorClass($classId); $applicationController = $this->_app->getController('Xodx_ApplicationController'); - if (strcmp($classId,"person") == 0) + if (strcmp($classId, "person") == 0) { $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; @@ -31,6 +31,17 @@ public function editAction ($template) $objectUri = $request->getValue('id', 'get'); } + $rightsHelper = new Xodx_RightsHelper($this->_app); + $hasRights = $rightsHelper -> HasRights('edit', $classId, $objectUri); + + //var_dump($hasRights); + + if (!$hasRights) + { + echo ("You do not have the rights for this. Sorry."); + return; + } + $allowedSinglePrefixes = $configHelper->loadPropertiesSingle($classId); $allowedMultiplePrefixes = $configHelper->loadPropertiesMultiple($classId); diff --git a/classes/Xodx/RightsHelper.php b/classes/Xodx/RightsHelper.php new file mode 100644 index 0000000..1d11581 --- /dev/null +++ b/classes/Xodx/RightsHelper.php @@ -0,0 +1,40 @@ +_app->getBootstrap(); + $model = $bootstrap->getResource('model'); + $applicationController = $this->_app->getController('Xodx_ApplicationController'); + + //This obviously has to be expanded. + if (strcmp($type,"person") == 0) + { + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; + if (strcmp($userUri, $id) == 0) + { + return true; + } + else + { + return false; + } + } + + if (strcmp($type,"conference") == 0) + { + return true; + } + } +} + From 705cdd9b9d6c546193014588547d11fc6c6e88b1 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Thu, 24 Oct 2013 18:55:21 +0200 Subject: [PATCH 130/143] Use urlencode/urldecode --- classes/Xodx/EditorController.php | 16 ++++++++++++---- templates/conference/list.phtml | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php index 0fcbf72..71bf7d4 100644 --- a/classes/Xodx/EditorController.php +++ b/classes/Xodx/EditorController.php @@ -22,15 +22,23 @@ public function editAction ($template) if (strcmp($classId, "person") == 0) { - $userId = $applicationController->getUser(); - $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; - $objectUri = $userUri; + $objectUri = urldecode($request->getValue('id', 'get')); + //var_dump($objectId); + if (empty($objectUri)) + { + $userId = $applicationController->getUser(); + $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; + $objectUri = $userUri; + } } else { - $objectUri = $request->getValue('id', 'get'); + $objectUri = urldecode($request->getValue('id', 'get')); } + //var_dump($objectUri); + //echo (urlencode($objectUri)); + $rightsHelper = new Xodx_RightsHelper($this->_app); $hasRights = $rightsHelper -> HasRights('edit', $classId, $objectUri); diff --git a/templates/conference/list.phtml b/templates/conference/list.phtml index a84c9dc..626366b 100644 --- a/templates/conference/list.phtml +++ b/templates/conference/list.phtml @@ -3,9 +3,10 @@ profiles as $key) { + $eventCoded = urlencode($key["event"]); $event = $key["event"]; $title = $key["o"]; - echo ("
  • $event - $title
  • "); + echo ("
  • $event - $title
  • "); } echo ("
  • Create new Conference
  • "); ?> From d4dba3df5968a94711da13794fb775c53145b3bb Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Thu, 24 Oct 2013 19:21:35 +0200 Subject: [PATCH 131/143] Corrected Bug n processing --- classes/Xodx/EditorController.php | 6 ++++-- templates/editor/edit.phtml | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php index 71bf7d4..c91b977 100644 --- a/classes/Xodx/EditorController.php +++ b/classes/Xodx/EditorController.php @@ -54,6 +54,7 @@ public function editAction ($template) $allowedMultiplePrefixes = $configHelper->loadPropertiesMultiple($classId); $template -> caption = $classId; + $template -> id = $objectUri; //echo ("
    $objectUri"); //echo ("
    $typeUri"); @@ -89,7 +90,6 @@ public function editAction ($template) //This is real sourcecode! - $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; @@ -110,7 +110,7 @@ public function editAction ($template) $changedDELETE = array(); $wrong = array(); - $query = "SELECT ?p ?o WHERE { <" . $userUri . "> a <" . $typeUri . "> . <" . $userUri . "> ?p ?o }"; + $query = "SELECT ?p ?o WHERE { <" . $objectUri . "> a <" . $typeUri . "> . <" . $objectUri . "> ?p ?o }"; $databaseValues = $model->sparqlQuery($query); $notFoundMultipleKeys = $databaseValues; @@ -275,6 +275,8 @@ public function editAction ($template) } } + //var_dump($wrong); + if (count($wrong) > 0 && !is_null($wrong)) { //Allow wrong Properties to be corrected diff --git a/templates/editor/edit.phtml b/templates/editor/edit.phtml index 89a5001..f8bb759 100644 --- a/templates/editor/edit.phtml +++ b/templates/editor/edit.phtml @@ -4,8 +4,8 @@ if (isset($this->profile)) //echo ("Foo :"); $caption = $this->caption; echo ("

    $caption

    "); - - echo ("
    "); + $idEncoded = urlencode($this -> id); + echo ("
    "); $counter = 0; @@ -41,7 +41,9 @@ if (isset($this->profile)) foreach($this->wrong as $keyX => $array) { - if ($array['p'] == $prefixKey) + //echo ($array['p']); + //if ($array['p'] == $prefixKey) + if ($keyX == $prefixKey) { //echo ("Wrong: $prefix"); $thisIsWrong = true; From 6fe49b0c137234a6ccd4a57d3bfd46149a9dcfa6 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Thu, 24 Oct 2013 19:35:50 +0200 Subject: [PATCH 132/143] Fixed Bug with wrong Single Key --- classes/Xodx/EditorController.php | 3 ++- templates/editor/edit.phtml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php index c91b977..2c0c6af 100644 --- a/classes/Xodx/EditorController.php +++ b/classes/Xodx/EditorController.php @@ -185,6 +185,7 @@ public function editAction ($template) if ($value != $oldValue ) { $rString = $allowedSinglePrefixes[$key]["regex"]; + //echo ("$rString - $value - $key"); if (ereg($rString, $value) == true) { //echo ("Match: $value for $newKey with $rString"); @@ -202,7 +203,7 @@ public function editAction ($template) //echo ("Wrong Format: $value for $newKey with $rString
    "); if (!empty ($value)) { - $wrong[$newKey] = $value; + $wrong[$key] = $value; } } } diff --git a/templates/editor/edit.phtml b/templates/editor/edit.phtml index f8bb759..d25bda3 100644 --- a/templates/editor/edit.phtml +++ b/templates/editor/edit.phtml @@ -11,6 +11,7 @@ if (isset($this->profile)) //echo ("Database Values:
    "); //var_dump($this->profile); + //var_dump($this->profile); //echo ("
    "); if (count($this -> wrong) > 0 && !is_null($this -> wrong)) From 85d4417f2231b33a0e26b694b3310fcd2a9df400 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Thu, 24 Oct 2013 19:41:24 +0200 Subject: [PATCH 133/143] Use objectId when writing to the DataBase --- classes/Xodx/EditorController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php index 2c0c6af..2c55a1d 100644 --- a/classes/Xodx/EditorController.php +++ b/classes/Xodx/EditorController.php @@ -317,8 +317,8 @@ public function editAction ($template) $valueArray = array('type' => 'literal', 'value' => $value['o']); $keyToDelete = $value['p']; $valueToDelete = $value['o']; - //echo ("
    Delete: $userUri, $keyToDelete, $valueToDelete"); - $model->deleteStatement($userUri, $keyToDelete, $valueArray); + //echo ("
    Delete: $objectUri, $keyToDelete, $valueToDelete"); + $model->deleteStatement($objectUri, $keyToDelete, $valueArray); } foreach ($changedADD as $key => $value) { @@ -327,8 +327,8 @@ public function editAction ($template) $valueArray = array('type' => 'literal', 'value' => $value['o']); $keyToWrite = $value['p']; $valueToWrite = $value['o']; - //echo ("
    Writing: $userUri, $keyToWrite, $valueToWrite"); - $model->addStatement($userUri, $keyToWrite, $valueArray); + //echo ("
    Writing: $objectUri, $keyToWrite, $valueToWrite"); + $model->addStatement($objectUri, $keyToWrite, $valueArray); } //Show Profileeditor with Values from Database. From 8e3de72490e27fd2a1114d4c444abd8feefbb370 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Fri, 25 Oct 2013 14:03:17 +0200 Subject: [PATCH 134/143] Create Conferences --- classes/Xodx/ConferenceController.php | 27 +++++++++++++++++++++++++++ templates/conference/list.phtml | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index 38e665a..b22bdbe 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -46,4 +46,31 @@ public function listAction($template) $template->addContent('templates/list.phtml'); return $template; } + + public function newAction($template) + { + $bootstrap = $this->_app->getBootstrap(); + $model = $bootstrap->getResource('model'); + $uid = uniqid(); + $conferenceId = $this->_app->getBaseUri() . '?c=conference&id=' . $uid; + //var_dump($conferenceId); + + //Create Conference + $valueToWrite = 'http://symbolicdata.org/Data/Model#Conference'; + $valueArray = array('type' => 'uri', 'value' => $valueToWrite); + $keyToWrite = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'; + + echo ("
    Writing: $conferenceId, $keyToWrite, $valueToWrite"); + $model->addStatement($conferenceId, $keyToWrite, $valueArray); + //Add Temporary Title + + $valueToWrite2 = $uid; + $valueArray2 = array('type' => 'literal', 'value' => $valueToWrite2); + $keyToWrite2 = 'http://www.w3.org/2000/01/rdf-schema#label'; + + echo ("
    Writing: $conferenceId, $keyToWrite2, $valueToWrite2"); + $model->addStatement($conferenceId, $keyToWrite2, $valueArray2); + + return $template; + } } diff --git a/templates/conference/list.phtml b/templates/conference/list.phtml index 626366b..06e2b99 100644 --- a/templates/conference/list.phtml +++ b/templates/conference/list.phtml @@ -8,7 +8,7 @@ foreach ($this->profiles as $key) $title = $key["o"]; echo ("
  • $event - $title
  • "); } -echo ("
  • Create new Conference
  • "); +echo ("
  • Create new Conference
  • "); ?> From 026054c052edf475dcd34a5ab2be5e08b065fd5b Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Fri, 25 Oct 2013 16:52:48 +0200 Subject: [PATCH 135/143] Fixed Bug where Wrong Value is shown. --- templates/editor/edit.phtml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/editor/edit.phtml b/templates/editor/edit.phtml index d25bda3..3184cae 100644 --- a/templates/editor/edit.phtml +++ b/templates/editor/edit.phtml @@ -17,7 +17,7 @@ if (isset($this->profile)) if (count($this -> wrong) > 0 && !is_null($this -> wrong)) { echo ("Please correct the red Properties!

    "); - //var_dump($this -> wrong); + var_dump($this -> wrong); } foreach ($this->allowedSinglePrefixes as $prefixKey => $prefix) @@ -44,10 +44,11 @@ if (isset($this->profile)) { //echo ($array['p']); //if ($array['p'] == $prefixKey) - if ($keyX == $prefixKey) + if (strcmp($keyX,$prefixKey) == 0) { - //echo ("Wrong: $prefix"); + //echo ("Wrong: $elementX"); $thisIsWrong = true; + $elementX = $this->wrong[$keyX]; break; } } From c72d0dc9c9e14b707ffb53074851f64bcb3a9d08 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Fri, 25 Oct 2013 17:12:08 +0200 Subject: [PATCH 136/143] Fixed Bug in config. --- classes/Xodx/EditorController.php | 5 +++-- config.ini-dist | 10 ++++++---- templates/editor/edit.phtml | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php index 2c55a1d..4ebc208 100644 --- a/classes/Xodx/EditorController.php +++ b/classes/Xodx/EditorController.php @@ -186,7 +186,7 @@ public function editAction ($template) { $rString = $allowedSinglePrefixes[$key]["regex"]; //echo ("$rString - $value - $key"); - if (ereg($rString, $value) == true) + if (preg_match($rString, $value)) { //echo ("Match: $value for $newKey with $rString"); $temp = array(); @@ -253,7 +253,8 @@ public function editAction ($template) $rString = $allowedMultiplePrefixes[$prefix]["regex"]; //echo ("$rString"); //var_dump($value); - if (preg_match($rString, $value) == true) + if (preg_match($rString, $value)) + //if (preg_match($rString, $value) === true) { //echo ("Match: $value for $newKey"); $temp = array(); diff --git a/config.ini-dist b/config.ini-dist index ba5e257..b1a2796 100644 --- a/config.ini-dist +++ b/config.ini-dist @@ -85,10 +85,12 @@ editor.conference.property.11.cardinality = single regex.URL = "_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/[^\s]*)?$_iuS" ; by http://www.regular-expressions.info/email.html regex.Email = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" -regex.Literal = "[\s\S]+" -regex.String = "[\s\S]+" +regex.Literal = "#[\s\S]+#" +regex.String = "#[\s\S]+#" ; by http://regexlib.com/REDetails.aspx?regexp_id=610 -regex.DateTime = "^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$" +öregex.DateTime = " ^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$" +regex.DateTime = "#(\d){1,4}-(\d){1,2}-(\d){1,2}#" + [erfurt] @@ -126,4 +128,4 @@ foaf = 'http://xmlns.com/foaf/0.1/'; dssn = 'http://purl.org/net/dssn/'; ow = 'http://ns.ontowiki.net/SysOnt/'; ov = 'http://open.vocab.org/docs/'; -rel = 'http://purl.org/vocab/relationship/' \ No newline at end of file +rel = 'http://purl.org/vocab/relationship/' \ No newline at end of file diff --git a/templates/editor/edit.phtml b/templates/editor/edit.phtml index 3184cae..b78e6e9 100644 --- a/templates/editor/edit.phtml +++ b/templates/editor/edit.phtml @@ -17,7 +17,7 @@ if (isset($this->profile)) if (count($this -> wrong) > 0 && !is_null($this -> wrong)) { echo ("Please correct the red Properties!

    "); - var_dump($this -> wrong); + //var_dump($this -> wrong); } foreach ($this->allowedSinglePrefixes as $prefixKey => $prefix) From 9cce18e12eca551cd4c0e40b2c19cb52249b160d Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 27 Oct 2013 20:31:15 +0100 Subject: [PATCH 137/143] Cleaned Coded and Added Comments --- classes/Xodx/ConferenceController.php | 15 ++--- classes/Xodx/EditorController.php | 95 +++++++++------------------ 2 files changed, 38 insertions(+), 72 deletions(-) diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index b22bdbe..763e4e8 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -28,20 +28,20 @@ public function listAction($template) $model = $this->_app->getBootstrap()->getResource('Model'); $configHelper = new Xodx_ConfigHelper($this->_app); $typeUri = $configHelper -> getEditorClass("conference"); + + //Get all Conferences $profiles = $model->sparqlQuery('SELECT DISTINCT ?event ?p ?o WHERE { ?event a <'. $typeUri .'> . ?event ?p ?o}'); + //Reduce to Label foreach ($profiles as $key => $array) { - //var_dump($array); - //echo ($array["p"]); - //echo ("
    "); if (strcmp($array["p"],"http://www.w3.org/2000/01/rdf-schema#label") !=0) { unset($profiles[$key]); } } - //var_dump($profiles); + //Add Values to $template $template->profiles = $profiles; $template->addContent('templates/list.phtml'); return $template; @@ -53,22 +53,21 @@ public function newAction($template) $model = $bootstrap->getResource('model'); $uid = uniqid(); $conferenceId = $this->_app->getBaseUri() . '?c=conference&id=' . $uid; - //var_dump($conferenceId); //Create Conference $valueToWrite = 'http://symbolicdata.org/Data/Model#Conference'; $valueArray = array('type' => 'uri', 'value' => $valueToWrite); $keyToWrite = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'; - echo ("
    Writing: $conferenceId, $keyToWrite, $valueToWrite"); + //echo ("
    Writing: $conferenceId, $keyToWrite, $valueToWrite"); $model->addStatement($conferenceId, $keyToWrite, $valueArray); - //Add Temporary Title + //Add Temporary Title $valueToWrite2 = $uid; $valueArray2 = array('type' => 'literal', 'value' => $valueToWrite2); $keyToWrite2 = 'http://www.w3.org/2000/01/rdf-schema#label'; - echo ("
    Writing: $conferenceId, $keyToWrite2, $valueToWrite2"); + //echo ("
    Writing: $conferenceId, $keyToWrite2, $valueToWrite2"); $model->addStatement($conferenceId, $keyToWrite2, $valueArray2); return $template; diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php index 4ebc208..53c0f64 100644 --- a/classes/Xodx/EditorController.php +++ b/classes/Xodx/EditorController.php @@ -15,15 +15,17 @@ public function editAction ($template) $bootstrap = $this->_app->getBootstrap(); $model = $bootstrap->getResource('model'); $configHelper = new Xodx_ConfigHelper($this->_app); + $rightsHelper = new Xodx_RightsHelper($this->_app); $request = $bootstrap->getResource('request'); $classId = $request->getValue('class', 'get'); $typeUri = $configHelper -> getEditorClass($classId); $applicationController = $this->_app->getController('Xodx_ApplicationController'); + //Needed switch to get personUri without passing it via $_GET if (strcmp($classId, "person") == 0) { $objectUri = urldecode($request->getValue('id', 'get')); - //var_dump($objectId); + //Use current UserId if no personUri was passed if (empty($objectUri)) { $userId = $applicationController->getUser(); @@ -36,47 +38,32 @@ public function editAction ($template) $objectUri = urldecode($request->getValue('id', 'get')); } - //var_dump($objectUri); - //echo (urlencode($objectUri)); - - $rightsHelper = new Xodx_RightsHelper($this->_app); + //RightsManagement. Ask rightsHelper if action is allowed. $hasRights = $rightsHelper -> HasRights('edit', $classId, $objectUri); - - //var_dump($hasRights); - if (!$hasRights) { echo ("You do not have the rights for this. Sorry."); return; } + //Get Prefixes to be shown in the Editor $allowedSinglePrefixes = $configHelper->loadPropertiesSingle($classId); $allowedMultiplePrefixes = $configHelper->loadPropertiesMultiple($classId); $template -> caption = $classId; $template -> id = $objectUri; - //echo ("
    $objectUri"); - //echo ("
    $typeUri"); - + //Switch if this was called from a Form. if (count ($_POST) == 0) { - //$userId = $applicationController->getUser(); - + //Get Values from Database $query = "SELECT ?p ?o WHERE { <" . $objectUri . "> a <" . $typeUri . "> . <" . $objectUri . "> ?p ?o }"; - //$query = "PREFIX foaf: SELECT ?p ?o WHERE { ?person a foaf:Person. ?person foaf:person '$userUri'. ?person ?p ?o }"; + $profiles = $model->sparqlQuery($query); - //echo ("$query"); - //echo ("
    $objectUri"); - //echo ("
    $typeUri"); - - $profiles = $model->sparqlQuery( $query); + //Add Values to $template $template->allowedSinglePrefixes = $allowedSinglePrefixes; $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; $template->profile = $profiles; - - //echo ("Foo"); - $template->addContent('templates/edit.phtml'); return $template; @@ -85,17 +72,13 @@ public function editAction ($template) { //Process POSTed values an show ProfileEditor with // a) Data from POST if it needs to be corrected - // TODO: Indicated that data... // b) Data from Database if everything was fine so the new data in the DB can be viewed. - //This is real sourcecode! - $applicationController = $this->_app->getController('Xodx_ApplicationController'); $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; $stringArray = explode("id=", $userUri); $name = $stringArray[1]; - //$propertyRegex = $this -> loadPropertyRegex(); $prefixesSinglePrepare = array(); $valuesSinglePrepare = array(); @@ -114,23 +97,13 @@ public function editAction ($template) $databaseValues = $model->sparqlQuery($query); $notFoundMultipleKeys = $databaseValues; - //echo ("Foo"); - - //var_dump($notFoundMultipleKeys); - //echo ("
    "); - - //echo ("Database Values:
    "); - //var_dump($databaseValues); - //echo ("
    "); - //prepare $_POST into prefix --> value foreach ($_POST as $key => $value) { - //echo ("$key - $value
    "); $keyArray = explode("_", $key); $number = (int)$keyArray[0]; - //single + //single Properties if ($keyArray[1] == "value") { $valuesSinglePrepare[$number] = $value; @@ -141,7 +114,7 @@ public function editAction ($template) $prefixesSinglePrepare[$number] = $value; } - //multiple + //multiple Properties //$numberInKey is only needed if Property is multiple, so it is put inside the if statements. if ($keyArray[1] == "Mvalue") { @@ -161,7 +134,7 @@ public function editAction ($template) $valuesSingleNew[$value] = $valuesSinglePrepare[(int)$key]; } - //Single + //Single Properties foreach ($valuesSingleNew as $key => $value) { //Reset old values @@ -185,10 +158,10 @@ public function editAction ($template) if ($value != $oldValue ) { $rString = $allowedSinglePrefixes[$key]["regex"]; - //echo ("$rString - $value - $key"); + //check Regex if (preg_match($rString, $value)) { - //echo ("Match: $value for $newKey with $rString"); + //If Value matches, add it to the Values that are written and deleted from the DB. $temp = array(); $temp['p'] = $newKey; $temp['o'] = $value; @@ -200,16 +173,17 @@ public function editAction ($template) } else { - //echo ("Wrong Format: $value for $newKey with $rString
    "); + //If the Value is empty, it might not pass the Regex, but shall not be shown as wrong. if (!empty ($value)) { + //Add Value to array which will later be shown as wrong values. $wrong[$key] = $value; } } } } - //Multiple + //Multiple Properties foreach ($prefixesMultiplePrepare as $prefixKey => $prefix) { $values = $valuesMultiplePrepare[$prefixKey]; @@ -222,12 +196,10 @@ public function editAction ($template) break; } $found = false; - //echo ("Looking for $prefix -> $value
    "); - //echo ("
    "); foreach ($databaseValues as $key => $element) { - //only for MultipleStatements + //only for needed MultipleStatements $p = $element["p"]; $o = $element["o"]; if (in_array($p, array_keys($allowedMultiplePrefixes))) @@ -237,26 +209,21 @@ public function editAction ($template) if (strcmp ($o, $value) == 0) { //1.2 Delete this pair from $oldValues - //TODO: Implement this. + //These Values are deleted from an extra Array + //At the End, all Values from this Array are deleted. $found = true; - //echo ("$key
    "); - //echo ("Found: $prefix -> $value
    "); unset($notFoundMultipleKeys[$key]); - //var_dump($notFoundMultipleKeys); } } } } if (!$found) { - //echo ("Not found: $prefix -> $value
    "); $rString = $allowedMultiplePrefixes[$prefix]["regex"]; - //echo ("$rString"); - //var_dump($value); + //check Regex if (preg_match($rString, $value)) - //if (preg_match($rString, $value) === true) { - //echo ("Match: $value for $newKey"); + //If Value matches, add it to the Values that are written to the DB. $temp = array(); $temp['p'] = $prefix; $temp['o'] = $value; @@ -264,9 +231,10 @@ public function editAction ($template) } else { - //echo ("Wrong Format: $value for $prefix with $rString
    "); + //If the Value is empty, it might not pass the Regex, but shall not be shown as wrong. if (!empty ($value)) { + //Add Value to array which will later be shown as wrong values. $temp = array(); $temp['p'] = $prefix; $temp['o'] = $value; @@ -277,16 +245,16 @@ public function editAction ($template) } } - //var_dump($wrong); - + //Check if there are any wrong Properties. if (count($wrong) > 0 && !is_null($wrong)) { //Allow wrong Properties to be corrected + //Therefore, change all the wrong values in the Values gotten from the database. foreach ($wrong as $key => $value) { $databaseValues[] = $value; } - + //Add Values to $template $template->allowedSinglePrefixes = $allowedSinglePrefixes; $template->allowedMultiplePrefixes = $allowedMultiplePrefixes; $template->profile = $databaseValues; @@ -297,7 +265,7 @@ public function editAction ($template) } else { - //prepare $notFoundMultipleKeys + //Prepare multiple Keys (deleted) foreach ($notFoundMultipleKeys as $key => $element) { $p = $element["p"]; @@ -323,8 +291,6 @@ public function editAction ($template) } foreach ($changedADD as $key => $value) { - //$keyArray = array('value' => ); - //array('type' => 'uri', 'value' => $newPersonUri) $valueArray = array('type' => 'literal', 'value' => $value['o']); $keyToWrite = $value['p']; $valueToWrite = $value['o']; @@ -332,7 +298,7 @@ public function editAction ($template) $model->addStatement($objectUri, $keyToWrite, $valueArray); } - //Show Profileeditor with Values from Database. + //Show Editor with Values from Database. $_POST = NULL; $template = $this -> editAction($template); return $template; @@ -340,7 +306,8 @@ public function editAction ($template) } } -public function loadPropertiesAction() + //The following functions are only for debug purposes, but left here, in case anybody might need them. + public function loadPropertiesAction() { $configHelper = new Xodx_ConfigHelper($this->_app); return $configHelper -> loadProperties(); From 4b074b0e8881c868851c752ddb55598cf0501560 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 27 Oct 2013 20:41:56 +0100 Subject: [PATCH 138/143] Kommentare --- classes/Xodx/ConfigHelper.php | 10 ++++++++++ classes/Xodx/RightsHelper.php | 1 + 2 files changed, 11 insertions(+) diff --git a/classes/Xodx/ConfigHelper.php b/classes/Xodx/ConfigHelper.php index 30512a5..95d68d6 100644 --- a/classes/Xodx/ConfigHelper.php +++ b/classes/Xodx/ConfigHelper.php @@ -7,11 +7,14 @@ class Xodx_ConfigHelper extends Saft_Helper { + //Returns all Single Properties for a given $editorType public function loadPropertiesSingle($editorType) { + //Load All Properties $properties = $this -> loadProperties($editorType); $single = array(); + //Find those whose cardinality is single foreach($properties as $key => $element) { if ($element["cardinality"] == "single") @@ -22,11 +25,14 @@ public function loadPropertiesSingle($editorType) return $single; } + //Returns all Multiple Properties for a given $editorType public function loadPropertiesMultiple($editorType) { + //Load All Properties $properties = $this -> loadProperties($editorType); $multiple = array(); + //Find those whose cardinality is multiple foreach($properties as $key => $element) { if ($element["cardinality"] == "multiple") @@ -37,6 +43,7 @@ public function loadPropertiesMultiple($editorType) return $multiple; } + //Returns all Properties with the corresponding RegExes, ready for preg_match public function loadPropertyRegex() { $properties = array(); @@ -60,6 +67,7 @@ public function loadPropertyRegex() return $properties; } + //Returns the RegEx for a given $regexName public function propertyRegex($regexName) { //echo "propertyRegex: $regexName
    "; @@ -68,6 +76,7 @@ public function propertyRegex($regexName) return $config[$regexString]; } + //Returns all properties for a given $editorType public function loadProperties($editorType) { $propertiesPrepared = array(); @@ -96,6 +105,7 @@ public function loadProperties($editorType) return $properties; } + //Returns the class (e.g foaf:person)of an Editor with the given class as it is in the config public function getEditorClass($editorType) { $config = $this->_app->getBootstrap()->getResource('Config'); diff --git a/classes/Xodx/RightsHelper.php b/classes/Xodx/RightsHelper.php index 1d11581..7335acc 100644 --- a/classes/Xodx/RightsHelper.php +++ b/classes/Xodx/RightsHelper.php @@ -10,6 +10,7 @@ */ class Xodx_RightsHelper extends Saft_Helper { + //Returns true if the User has the right to do a specified action. public function HasRights($action, $type, $id) { $bootstrap = $this->_app->getBootstrap(); From 58727bae5f0eef5d41a95d06b2f1538c3d74284a Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 27 Oct 2013 20:43:37 +0100 Subject: [PATCH 139/143] Shortened config.ini-dist --- config.ini-dist | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/config.ini-dist b/config.ini-dist index b1a2796..ebb05d5 100644 --- a/config.ini-dist +++ b/config.ini-dist @@ -9,8 +9,6 @@ push.hub = "http://pubsubhubbub.appspot.com" ;push.hub = "http://localhost/OntoWiki/pubsub/hubbub" ;Parameters for Profile Editor -;editor.single = http://xmlns.com/foaf/0.1/depiction,URL,http://xmlns.com/foaf/0.1/nick,Literal,http://xmlns.com/foaf/0.1/name,Literal -;editor.multiple = http://xmlns.com/foaf/0.1/schoolHomepage,URL,http://xmlns.com/foaf/0.1/jabberID,Email,http://www.w3.org/2000/01/rdf-schema#seeAlso,URL,http://xmlns.com/foaf/0.1/based_near,URL,http://xmlns.com/foaf/0.1/weblog,URL,http://xmlns.com/foaf/0.1/workplaceHomepage,URL editor.person.class = http://xmlns.com/foaf/0.1/Person @@ -88,11 +86,9 @@ regex.Email = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@( regex.Literal = "#[\s\S]+#" regex.String = "#[\s\S]+#" ; by http://regexlib.com/REDetails.aspx?regexp_id=610 -öregex.DateTime = " ^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$" +;regex.DateTime = " ^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$" regex.DateTime = "#(\d){1,4}-(\d){1,2}-(\d){1,2}#" - - [erfurt] ; In this section you can configure the Erfurt framework @@ -128,4 +124,4 @@ foaf = 'http://xmlns.com/foaf/0.1/'; dssn = 'http://purl.org/net/dssn/'; ow = 'http://ns.ontowiki.net/SysOnt/'; ov = 'http://open.vocab.org/docs/'; -rel = 'http://purl.org/vocab/relationship/' \ No newline at end of file +rel = 'http://purl.org/vocab/relationship/' From 550f86ee064246a62770941d9cff7c57e1c5472f Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 27 Oct 2013 20:55:33 +0100 Subject: [PATCH 140/143] Allow editing of newly created conference. --- classes/Xodx/ConferenceController.php | 2 ++ templates/conference/new.phtml | 8 ++++++++ templates/partials/menu.phtml | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 templates/conference/new.phtml diff --git a/classes/Xodx/ConferenceController.php b/classes/Xodx/ConferenceController.php index 763e4e8..9031abf 100644 --- a/classes/Xodx/ConferenceController.php +++ b/classes/Xodx/ConferenceController.php @@ -70,6 +70,8 @@ public function newAction($template) //echo ("
    Writing: $conferenceId, $keyToWrite2, $valueToWrite2"); $model->addStatement($conferenceId, $keyToWrite2, $valueArray2); + $template -> id = $conferenceId; + $template->addContent('templates/new.phtml'); return $template; } } diff --git a/templates/conference/new.phtml b/templates/conference/new.phtml new file mode 100644 index 0000000..f968865 --- /dev/null +++ b/templates/conference/new.phtml @@ -0,0 +1,8 @@ +

    Conference Created

    + +Conference succesfully created.
    + + id; + echo ("Edit this conference"); +?> diff --git a/templates/partials/menu.phtml b/templates/partials/menu.phtml index 3816d56..cac0743 100644 --- a/templates/partials/menu.phtml +++ b/templates/partials/menu.phtml @@ -21,7 +21,7 @@ if ($this->username != "guest") { echo ("
  • Show All Conferences
  • "); - echo ("
  • Conference Editor
  • "); + //echo ("
  • Conference Editor
  • "); echo ("
  • Profile Editor
  • "); echo ("
  • Logout
  • "); } From d9d5ad3c4582629f1407d39b33f17d5a81fac24f Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 27 Oct 2013 20:55:41 +0100 Subject: [PATCH 141/143] Removed unused template. --- templates/conference/edit.phtml | 156 -------------------------------- 1 file changed, 156 deletions(-) delete mode 100644 templates/conference/edit.phtml diff --git a/templates/conference/edit.phtml b/templates/conference/edit.phtml deleted file mode 100644 index 6235d09..0000000 --- a/templates/conference/edit.phtml +++ /dev/null @@ -1,156 +0,0 @@ -

    Conference Editor

    - - -
    - -profile)) -{ - $counter = 0; - - //echo ("Database Values:
    "); - //var_dump($this->profile); - //echo ("
    "); - - if (count($this -> wrong) > 0 && !is_null($this -> wrong)) - { - echo ("Please correct the red Properties!

    "); - var_dump($this -> wrong); - } - - //var_dump($this -> allowedSinglePrefixes); - - foreach ($this->allowedSinglePrefixes as $prefixKey => $prefix) - { - $elementX = ""; - //HACK: Do we have LINQ or at least something to make this better? - //echo ("$prefix
    "); - //var_dump($prefixKey); - //echo ("
    "); - - foreach ($this->profile as $key => $element) - { - if ($element["p"] == $prefixKey) - { - $elementX = $element["o"]; - } - } - $counterText = (string)$counter; - $prefixText = $counterText ."_prefix"; - $valueText = $counterText . "_value"; - $thisIsWrong = false; - - foreach($this->wrong as $keyX => $array) - { - if ($array['p'] == $prefixKey) - { - echo ("Wrong: $prefix"); - $thisIsWrong = true; - break; - } - } - - if ($thisIsWrong) - { - echo ("
    - -
    - - -
    -
    "); - } - else - { - echo ("
    - -
    - - -
    -
    "); - } - $counter = $counter + 1; - } - - - $counter = 0; - - foreach ($this->allowedMultiplePrefixes as $prefix => $prefixValue) - { - $elementX = ""; - $i = 0; - $counterText = (string)$counter; - //HACK: Do we have LINQ or at least something to make this better? - foreach ($this->profile as $key => $element) - { - if ($element["p"] == $prefix) - { - $elementX = $element["o"]; - - $prefixText = $counterText ."_Mprefix"; - $valueText = $counterText . "_Mvalue_$i"; - - $thisIsWrong = false; - - foreach($this->wrong as $key => $array) - { - if ($array['p'] == $prefix && $array['o'] == $elementX) - { - $thisIsWrong = true; - break; - } - } - - if ($thisIsWrong) - { - echo ("
    - -
    - - -
    -
    "); - } - else - { - echo ("
    - -
    - - -
    -
    "); - } - $i=$i+1; - } - } - - $prefixText = $counterText ."_Mprefix"; - $valueText = $counterText . "_Mvalue_$i"; - echo ("
    - -
    - - -
    -
    "); - - $counter = $counter + 1; - echo ("Prefix: $prefix
    "); - } -} -else -{ - echo ("Create new Conference? This will be implemented soon."); -} - -?> - -
    - -
    - -
    - - From 480d8e78d84f3c40539211fc81579948de2dfa4d Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Sun, 27 Oct 2013 21:01:07 +0100 Subject: [PATCH 142/143] Fixed Link in Template --- templates/conference/new.phtml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/conference/new.phtml b/templates/conference/new.phtml index f968865..a8b78e9 100644 --- a/templates/conference/new.phtml +++ b/templates/conference/new.phtml @@ -4,5 +4,6 @@ Conference succesfully created.
    id; - echo ("Edit this conference"); + $idCoded = urlencode($id); + echo ("Edit this conference"); ?> From 92989c5a816f6a36f6170ccc18ca65fa3bd9d2b7 Mon Sep 17 00:00:00 2001 From: Rico Feist Date: Tue, 12 Nov 2013 11:00:00 +0100 Subject: [PATCH 143/143] Added Editor --- classes/Xodx/ConfigHelper.php | 53 +++++--- classes/Xodx/EditorController.php | 208 +++++++++++++----------------- classes/Xodx/PersonController.php | 1 - classes/Xodx/RightsHelper.php | 8 +- templates/editor/edit.phtml | 83 ++++++------ 5 files changed, 171 insertions(+), 182 deletions(-) diff --git a/classes/Xodx/ConfigHelper.php b/classes/Xodx/ConfigHelper.php index 95d68d6..6e6a95e 100644 --- a/classes/Xodx/ConfigHelper.php +++ b/classes/Xodx/ConfigHelper.php @@ -7,17 +7,19 @@ class Xodx_ConfigHelper extends Saft_Helper { - //Returns all Single Properties for a given $editorType + /** + * Returns all Single Properties for a given $editorType + */ public function loadPropertiesSingle($editorType) { //Load All Properties - $properties = $this -> loadProperties($editorType); + $properties = $this->loadProperties($editorType); $single = array(); //Find those whose cardinality is single foreach($properties as $key => $element) { - if ($element["cardinality"] == "single") + if ($element['cardinality'] == 'single') { $single[$key] = $element; } @@ -25,17 +27,19 @@ public function loadPropertiesSingle($editorType) return $single; } - //Returns all Multiple Properties for a given $editorType + /** + * Returns all Multiple Properties for a given $editorType + */ public function loadPropertiesMultiple($editorType) { //Load All Properties - $properties = $this -> loadProperties($editorType); + $properties = $this->loadProperties($editorType); $multiple = array(); //Find those whose cardinality is multiple foreach($properties as $key => $element) { - if ($element["cardinality"] == "multiple") + if ($element['cardinality'] == 'multiple') { $multiple[$key] = $element; } @@ -43,7 +47,9 @@ public function loadPropertiesMultiple($editorType) return $multiple; } - //Returns all Properties with the corresponding RegExes, ready for preg_match + /** + * Returns all Properties with the corresponding RegExes, ready for preg_match + */ public function loadPropertyRegex() { $properties = array(); @@ -67,28 +73,33 @@ public function loadPropertyRegex() return $properties; } - //Returns the RegEx for a given $regexName + /** + * Returns the RegEx for a given $regexName + */ public function propertyRegex($regexName) { //echo "propertyRegex: $regexName
    "; $config = $this->_app->getBootstrap()->getResource('Config'); - $regexString = "regex.".$regexName; + $regexString = 'regex.' + . $regexName; return $config[$regexString]; } - //Returns all properties for a given $editorType + /** + * Returns all properties for a given $editorType + */ public function loadProperties($editorType) { $propertiesPrepared = array(); $config = $this->_app->getBootstrap()->getResource('Config'); foreach ($config as $key => $value) { - $keySplit = explode(".",$key); - if ($keySplit[0] == "editor") + $keySplit = explode('.',$key); + if ($keySplit[0] == 'editor') { if ($keySplit[1] == $editorType) { - if ($keySplit[2] == "property") + if ($keySplit[2] == 'property') { $propertiesPrepared[$keySplit[3]][$keySplit[4]] = $value; } @@ -98,25 +109,27 @@ public function loadProperties($editorType) $properties = array(); foreach ($propertiesPrepared as $key => $value) { - $properties[$value["uri"]]["type"] = $value["type"]; - $properties[$value["uri"]]["cardinality"] = $value["cardinality"]; - $properties[$value["uri"]]["regex"] = $this -> propertyRegex($value["type"]); + $properties[$value['uri']]['type'] = $value['type']; + $properties[$value['uri']]['cardinality'] = $value['cardinality']; + $properties[$value['uri']]['regex'] = $this->propertyRegex($value['type']); } return $properties; } - //Returns the class (e.g foaf:person)of an Editor with the given class as it is in the config + /** + * Returns the class (e.g foaf:person)of an Editor with the given class as it is in the config + */ public function getEditorClass($editorType) { $config = $this->_app->getBootstrap()->getResource('Config'); foreach ($config as $key => $value) { - $keySplit = explode(".",$key); - if ($keySplit[0] == "editor") + $keySplit = explode('.', $key); + if ($keySplit[0] == 'editor') { if ($keySplit[1] == $editorType) { - if ($keySplit[2] == "class") + if ($keySplit[2] == 'class') { return $value; } diff --git a/classes/Xodx/EditorController.php b/classes/Xodx/EditorController.php index 53c0f64..b0195b3 100644 --- a/classes/Xodx/EditorController.php +++ b/classes/Xodx/EditorController.php @@ -10,6 +10,9 @@ */ class Xodx_EditorController extends Xodx_ResourceController { + /** + * This shows the editor an processes any edited data. + */ public function editAction ($template) { $bootstrap = $this->_app->getBootstrap(); @@ -18,31 +21,26 @@ public function editAction ($template) $rightsHelper = new Xodx_RightsHelper($this->_app); $request = $bootstrap->getResource('request'); $classId = $request->getValue('class', 'get'); - $typeUri = $configHelper -> getEditorClass($classId); + $typeUri = $configHelper->getEditorClass($classId); $applicationController = $this->_app->getController('Xodx_ApplicationController'); //Needed switch to get personUri without passing it via $_GET - if (strcmp($classId, "person") == 0) - { + if (strcmp($classId, "person") == 0) { $objectUri = urldecode($request->getValue('id', 'get')); //Use current UserId if no personUri was passed - if (empty($objectUri)) - { + if (empty($objectUri)) { $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; $objectUri = $userUri; } - } - else - { + } else { $objectUri = urldecode($request->getValue('id', 'get')); } //RightsManagement. Ask rightsHelper if action is allowed. - $hasRights = $rightsHelper -> HasRights('edit', $classId, $objectUri); - if (!$hasRights) - { - echo ("You do not have the rights for this. Sorry."); + $hasRights = $rightsHelper->HasRights('edit', $classId, $objectUri); + if (!$hasRights) { + echo ('You do not have the rights for this. Sorry.'); return; } @@ -50,14 +48,20 @@ public function editAction ($template) $allowedSinglePrefixes = $configHelper->loadPropertiesSingle($classId); $allowedMultiplePrefixes = $configHelper->loadPropertiesMultiple($classId); - $template -> caption = $classId; - $template -> id = $objectUri; + $template->caption = $classId; + $template->id = $objectUri; //Switch if this was called from a Form. - if (count ($_POST) == 0) - { + if (count ($_POST) == 0) { //Get Values from Database - $query = "SELECT ?p ?o WHERE { <" . $objectUri . "> a <" . $typeUri . "> . <" . $objectUri . "> ?p ?o }"; + $query = "SELECT ?p ?o WHERE { <" + . $objectUri + . "> a <" + . $typeUri + . "> . <" + . $objectUri + . "> ?p ?o }"; + $profiles = $model->sparqlQuery($query); //Add Values to $template @@ -67,10 +71,8 @@ public function editAction ($template) $template->addContent('templates/edit.phtml'); return $template; - } - else - { - //Process POSTed values an show ProfileEditor with + } else { + //Process POSTed values and show ProfileEditor with // a) Data from POST if it needs to be corrected // b) Data from Database if everything was fine so the new data in the DB can be viewed. @@ -89,93 +91,85 @@ public function editAction ($template) $newKey; $newValue; $oldValue; - $changedADD = array(); - $changedDELETE = array(); + $changedAdd = array(); + $changedDelete = array(); $wrong = array(); - $query = "SELECT ?p ?o WHERE { <" . $objectUri . "> a <" . $typeUri . "> . <" . $objectUri . "> ?p ?o }"; + $query = 'SELECT ?p ?o WHERE { <' + . $objectUri + . '> a <' + . $typeUri + . '> . <' + . $objectUri + . '> ?p ?o }'; $databaseValues = $model->sparqlQuery($query); $notFoundMultipleKeys = $databaseValues; //prepare $_POST into prefix --> value - foreach ($_POST as $key => $value) - { - $keyArray = explode("_", $key); + foreach ($_POST as $key => $value) { + $keyArray = explode('_', $key); $number = (int)$keyArray[0]; //single Properties - if ($keyArray[1] == "value") - { + if ($keyArray[1] == 'value') { $valuesSinglePrepare[$number] = $value; } - if ($keyArray[1] == "prefix") - { + if ($keyArray[1] == 'prefix') { $prefixesSinglePrepare[$number] = $value; } //multiple Properties - //$numberInKey is only needed if Property is multiple, so it is put inside the if statements. - if ($keyArray[1] == "Mvalue") - { + //$numberInKey is only needed if Property is multiple, + //so it is put inside the if statements. + if ($keyArray[1] == 'Mvalue') { $numberInKey = (int)$keyArray[count($keyArray)-1]; $valuesMultiplePrepare[$number][$numberInKey] = $value; } - if ($keyArray[1] == "Mprefix") - { + if ($keyArray[1] == 'Mprefix') { $numberInKey = (int)$keyArray[count($keyArray)-1]; $prefixesMultiplePrepare[$number] = $value; } } - foreach ($prefixesSinglePrepare as $key => $value) - { + foreach ($prefixesSinglePrepare as $key => $value) { $valuesSingleNew[$value] = $valuesSinglePrepare[(int)$key]; } //Single Properties - foreach ($valuesSingleNew as $key => $value) - { + foreach ($valuesSingleNew as $key => $value) { //Reset old values $oldValue = ""; $newKey = $key; //find corresponding value in query //Searches for equivalent of $newKey - foreach ($databaseValues as $dbkey => $element) - { - $p = $element["p"]; - $o = $element["o"]; - //echo "
    $p -- $o"; - if (strcmp ($element["p"], $newKey) == 0) - { - $oldValue = $element["o"]; + foreach ($databaseValues as $dbkey => $element) { + $p = $element['p']; + $o = $element['o']; + if (strcmp ($element['p'], $newKey) == 0) { + $oldValue = $element['o']; unset($notFoundMultipleKeys[$dbkey]); } } - if ($value != $oldValue ) - { - $rString = $allowedSinglePrefixes[$key]["regex"]; + if ($value != $oldValue) { + $rString = $allowedSinglePrefixes[$key]['regex']; //check Regex - if (preg_match($rString, $value)) - { + if (preg_match($rString, $value)) { //If Value matches, add it to the Values that are written and deleted from the DB. $temp = array(); $temp['p'] = $newKey; $temp['o'] = $value; - $changedADD[] = $temp; + $changedAdd[] = $temp; $temp = array(); $temp['p'] = $newKey; $temp['o'] = $oldValue; - $changedDELETE[] = $temp; - } - else - { + $changedDelete[] = $temp; + } else { //If the Value is empty, it might not pass the Regex, but shall not be shown as wrong. - if (!empty ($value)) - { + if (!empty ($value)) { //Add Value to array which will later be shown as wrong values. $wrong[$key] = $value; } @@ -184,30 +178,23 @@ public function editAction ($template) } //Multiple Properties - foreach ($prefixesMultiplePrepare as $prefixKey => $prefix) - { + foreach ($prefixesMultiplePrepare as $prefixKey => $prefix) { $values = $valuesMultiplePrepare[$prefixKey]; - foreach ($values as $valueKey => $value) - { + foreach ($values as $valueKey => $value) { // 1. Forall key->value in newValues // 1.1 Find corresponding value. - if ($value == "") - { + if ($value == '') { break; } $found = false; - foreach ($databaseValues as $key => $element) - { + foreach ($databaseValues as $key => $element) { //only for needed MultipleStatements - $p = $element["p"]; - $o = $element["o"]; - if (in_array($p, array_keys($allowedMultiplePrefixes))) - { - if (strcmp ($p, $prefix) == 0) - { - if (strcmp ($o, $value) == 0) - { + $p = $element['p']; + $o = $element['o']; + if (in_array($p, array_keys($allowedMultiplePrefixes))) { + if (strcmp ($p, $prefix) == 0) { + if (strcmp ($o, $value) == 0) { //1.2 Delete this pair from $oldValues //These Values are deleted from an extra Array //At the End, all Values from this Array are deleted. @@ -217,23 +204,18 @@ public function editAction ($template) } } } - if (!$found) - { - $rString = $allowedMultiplePrefixes[$prefix]["regex"]; + if (!$found) { + $rString = $allowedMultiplePrefixes[$prefix]['regex']; //check Regex - if (preg_match($rString, $value)) - { + if (preg_match($rString, $value)) { //If Value matches, add it to the Values that are written to the DB. $temp = array(); $temp['p'] = $prefix; $temp['o'] = $value; - $changedADD[] = $temp; - } - else - { + $changedAdd[] = $temp; + } else { //If the Value is empty, it might not pass the Regex, but shall not be shown as wrong. - if (!empty ($value)) - { + if (!empty ($value)) { //Add Value to array which will later be shown as wrong values. $temp = array(); $temp['p'] = $prefix; @@ -246,12 +228,10 @@ public function editAction ($template) } //Check if there are any wrong Properties. - if (count($wrong) > 0 && !is_null($wrong)) - { + if (count($wrong) > 0 && !is_null($wrong)) { //Allow wrong Properties to be corrected //Therefore, change all the wrong values in the Values gotten from the database. - foreach ($wrong as $key => $value) - { + foreach ($wrong as $key => $value) { $databaseValues[] = $value; } //Add Values to $template @@ -262,66 +242,62 @@ public function editAction ($template) $template->wrong = $wrong; $template->addContent('templates/edit.phtml'); return $template; - } - else - { + } else { //Prepare multiple Keys (deleted) - foreach ($notFoundMultipleKeys as $key => $element) - { - $p = $element["p"]; - $o = $element["o"]; + foreach ($notFoundMultipleKeys as $key => $element) { + $p = $element['p']; + $o = $element['o']; - if (in_array($p, array_keys($allowedMultiplePrefixes))) - { + if (in_array($p, array_keys($allowedMultiplePrefixes))) { $temp = array(); $temp['p'] = $p; $temp['o'] = $o; - $changedDELETE[] = $temp; + $changedDelete[] = $temp; } } //Write Properties to Database - foreach ($changedDELETE as $key => $value) - { - //$keyArray = array('value' => ); - $valueArray = array('type' => 'literal', 'value' => $value['o']); + foreach ($changedDelete as $key => $value) { + $valueArray = array( + 'type' => 'literal', + 'value' => $value['o']); $keyToDelete = $value['p']; $valueToDelete = $value['o']; - //echo ("
    Delete: $objectUri, $keyToDelete, $valueToDelete"); $model->deleteStatement($objectUri, $keyToDelete, $valueArray); } - foreach ($changedADD as $key => $value) - { - $valueArray = array('type' => 'literal', 'value' => $value['o']); + foreach ($changedAdd as $key => $value) { + $valueArray = array( + 'type' => 'literal', + 'value' => $value['o']); $keyToWrite = $value['p']; $valueToWrite = $value['o']; - //echo ("
    Writing: $objectUri, $keyToWrite, $valueToWrite"); $model->addStatement($objectUri, $keyToWrite, $valueArray); } //Show Editor with Values from Database. - $_POST = NULL; - $template = $this -> editAction($template); + $_POST = null; + $template = $this->editAction($template); return $template; } } } - //The following functions are only for debug purposes, but left here, in case anybody might need them. + //The following functions are only for debug purposes, + //but left here, in case anybody might need them. public function loadPropertiesAction() { $configHelper = new Xodx_ConfigHelper($this->_app); - return $configHelper -> loadProperties(); + return $configHelper->loadProperties(); } public function loadPropertiesSingleAction() { $configHelper = new Xodx_ConfigHelper($this->_app); - var_dump($configHelper -> loadPropertiesSingle("conference")); + var_dump($configHelper->loadPropertiesSingle('conference')); } public function loadPropertiesMultipleAction() { $configHelper = new Xodx_ConfigHelper($this->_app); - var_dump($configHelper -> loadPropertiesMultiple("person")); + var_dump($configHelper->loadPropertiesMultiple('person')); } } diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index c02cc25..0534ca0 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -8,7 +8,6 @@ /** * The PersonController is responsible for all action concerning Persons. * This is showing the profile, befriending and maybe more in the future. - * - editing Profile information */ class Xodx_PersonController extends Xodx_ResourceController { diff --git a/classes/Xodx/RightsHelper.php b/classes/Xodx/RightsHelper.php index 7335acc..38b4ad7 100644 --- a/classes/Xodx/RightsHelper.php +++ b/classes/Xodx/RightsHelper.php @@ -10,7 +10,9 @@ */ class Xodx_RightsHelper extends Saft_Helper { - //Returns true if the User has the right to do a specified action. + /** + * Returns true if the User has the right to do a specified action. + */ public function HasRights($action, $type, $id) { $bootstrap = $this->_app->getBootstrap(); @@ -18,7 +20,7 @@ public function HasRights($action, $type, $id) $applicationController = $this->_app->getController('Xodx_ApplicationController'); //This obviously has to be expanded. - if (strcmp($type,"person") == 0) + if (strcmp($type, 'person') == 0) { $userId = $applicationController->getUser(); $userUri = $this->_app->getBaseUri() . '?c=person&id=' . $userId; @@ -32,7 +34,7 @@ public function HasRights($action, $type, $id) } } - if (strcmp($type,"conference") == 0) + if (strcmp($type, 'conference') == 0) { return true; } diff --git a/templates/editor/edit.phtml b/templates/editor/edit.phtml index b78e6e9..db7a43f 100644 --- a/templates/editor/edit.phtml +++ b/templates/editor/edit.phtml @@ -1,52 +1,39 @@ profile)) { - //echo ("Foo :"); $caption = $this->caption; - echo ("

    $caption

    "); - $idEncoded = urlencode($this -> id); - echo ("
    "); + echo ('

    $caption

    '); + $idEncoded = urlencode($this->id); + echo ("
    "); $counter = 0; - //echo ("Database Values:
    "); - //var_dump($this->profile); - //var_dump($this->profile); - //echo ("
    "); - - if (count($this -> wrong) > 0 && !is_null($this -> wrong)) + if (count($this->wrong) > 0 && !is_null($this->wrong)) { - echo ("Please correct the red Properties!

    "); - //var_dump($this -> wrong); + echo ('Please correct the red Properties!

    '); } foreach ($this->allowedSinglePrefixes as $prefixKey => $prefix) { $elementX = ""; - //HACK: Do we have LINQ or at least something to make this better? - //echo ("$prefix
    "); - //var_dump($prefixKey); - //echo ("
    "); foreach ($this->profile as $key => $element) { - if ($element["p"] == $prefixKey) + if ($element['p'] == $prefixKey) { - $elementX = $element["o"]; + $elementX = $element['o']; } } $counterText = (string)$counter; - $prefixText = $counterText ."_prefix"; - $valueText = $counterText . "_value"; + $prefixText = $counterText .'_prefix'; + $valueText = $counterText . '_value'; $thisIsWrong = false; foreach($this->wrong as $keyX => $array) { - //echo ($array['p']); - //if ($array['p'] == $prefixKey) if (strcmp($keyX,$prefixKey) == 0) { - //echo ("Wrong: $elementX"); $thisIsWrong = true; $elementX = $this->wrong[$keyX]; break; @@ -56,10 +43,13 @@ if (isset($this->profile)) if ($thisIsWrong) { echo ("
    - +
    - - + +
    "); } @@ -68,8 +58,10 @@ if (isset($this->profile)) echo ("
    - - + +
    "); } @@ -82,15 +74,16 @@ if (isset($this->profile)) $elementX = ""; $i = 0; $counterText = (string)$counter; - //HACK: Do we have LINQ or at least something to make this better? foreach ($this->profile as $key => $element) { - if ($element["p"] == $prefix) + if ($element['p'] == $prefix) { $elementX = $element["o"]; - $prefixText = $counterText ."_Mprefix"; - $valueText = $counterText . "_Mvalue_$i"; + $prefixText = $counterText + . '_Mprefix'; + $valueText = $counterText + . "_Mvalue_$i"; $thisIsWrong = false; @@ -106,10 +99,13 @@ if (isset($this->profile)) if ($thisIsWrong) { echo ("
    - +
    - - + +
    "); } @@ -118,8 +114,10 @@ if (isset($this->profile)) echo ("
    - - + +
    "); } @@ -127,23 +125,24 @@ if (isset($this->profile)) } } - $prefixText = $counterText ."_Mprefix"; + $prefixText = $counterText .'_Mprefix'; $valueText = $counterText . "_Mvalue_$i"; echo ("
    - - + +
    "); $counter = $counter + 1; - //echo ("Prefix: $prefix
    "); } } else { - echo ("Damn, profile not set..."); + echo ('Damn, profile not set...'); } ?>