From 3bd242097f2a862d1a231ea131491cc2b2c4fc43 Mon Sep 17 00:00:00 2001 From: Natanael Arndt Date: Sat, 1 Jun 2013 14:18:15 +0200 Subject: [PATCH] Use new layout and logger support in Saft --- classes/Xodx/ActivityController.php | 13 ++++++------ classes/Xodx/Application.php | 2 +- classes/Xodx/ApplicationController.php | 5 +++-- classes/Xodx/PersonController.php | 5 ++--- classes/Xodx/ProfileController.php | 2 -- libraries/Saft | 2 +- templates/layout.phtml | 7 ++++--- templates/partials/friendlist.phtml | 24 ++++++++++++++++++++++ templates/profileshow.phtml | 22 ++++++-------------- templates/usershow.phtml | 28 ++++++-------------------- 10 files changed, 54 insertions(+), 56 deletions(-) create mode 100644 templates/partials/friendlist.phtml diff --git a/classes/Xodx/ActivityController.php b/classes/Xodx/ActivityController.php index 4372f25..b1384e3 100644 --- a/classes/Xodx/ActivityController.php +++ b/classes/Xodx/ActivityController.php @@ -23,6 +23,7 @@ public function addactivityAction ($template) { $bootstrap = $this->_app->getBootstrap(); + $logger = $bootstrap->getResource('logger'); $request = $bootstrap->getResource('request'); $actorUri = $request->getValue('actor', 'post'); $verb = $request->getValue('verb', 'post'); @@ -48,7 +49,7 @@ public function addactivityAction ($template) 'content' => $actContent, 'replyObject' => $replyObject, ); - $debugStr = $this->addActivity($actorUri, $verbUri, $object); + $this->addActivity($actorUri, $verbUri, $object); break; case 'Comment'; $object = array( @@ -56,7 +57,7 @@ public function addactivityAction ($template) 'content' => $actContent, 'replyObject' => $replyObject, ); - $debugStr = $this->addActivity($actorUri, $verbUri, $object); + $this->addActivity($actorUri, $verbUri, $object); break; case 'Bookmark'; $object = array( @@ -64,7 +65,7 @@ public function addactivityAction ($template) 'content' => $actContent, 'replyObject' => $replyObject, ); - $debugStr = $this->addActivity($actorUri, $verbUri, $object); + $this->addActivity($actorUri, $verbUri, $object); break; case 'Photo'; $fieldName = 'content'; @@ -77,13 +78,12 @@ public function addactivityAction ($template) 'mime' => $fileInfo['mimeType'], 'replyObject' => $replyObject, ); - $debugStr = $this->addActivity($actorUri, $verbUri, $object); + $this->addActivity($actorUri, $verbUri, $object); break; default: - $debugStr = 'The given activity type ("' . $actType . '") is unknown.'; + $logger->info('The given activity type ("' . $actType . '") is unknown.'); break; } - $template->addDebug($debugStr); return $template; } @@ -100,6 +100,7 @@ public function addActivity ($actorUri, $verbUri, $object) $store = $bootstrap->getResource('store'); $model = $bootstrap->getResource('model'); $config = $bootstrap->getResource('config'); + $logger = $bootstrap->getResource('logger'); $graphUri = $model->getModelIri(); $nsXsd = 'http://www.w3.org/2001/XMLSchema#'; $nsRdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; diff --git a/classes/Xodx/Application.php b/classes/Xodx/Application.php index 07b4891..29f9aa4 100644 --- a/classes/Xodx/Application.php +++ b/classes/Xodx/Application.php @@ -20,7 +20,6 @@ public function run() { * Prepare Template */ $this->_layout->setLayout('templates/layout.phtml'); - $this->_layout->addMenu('templates/menu.phtml'); $request = $bootstrap->getResource('request'); @@ -48,6 +47,7 @@ public function run() { $this->_layout->username = $user->getName(); $this->_layout->notifications = $userController->getNotifications($user->getUri()); + $this->_layout->addDebug($bootstrap->getResource('logger')->getLastLog()); $config = $bootstrap->getResource('config'); if (isset($config['debug']) && $config['debug'] == false) { diff --git a/classes/Xodx/ApplicationController.php b/classes/Xodx/ApplicationController.php index f9caef0..289d4f0 100644 --- a/classes/Xodx/ApplicationController.php +++ b/classes/Xodx/ApplicationController.php @@ -48,6 +48,7 @@ public function newuserAction ($template) { $model = $bootstrap->getResource('model'); $store = $bootstrap->getResource('store'); $request = $bootstrap->getResource('request'); + $logger = $bootstrap->getResource('logger'); // get URI $personUri = $request->getValue('personUri', 'post'); @@ -105,7 +106,7 @@ public function newuserAction ($template) { if (!empty($personUri)) { $linkeddataHelper = $this->_app->getHelper('Saft_Helper_LinkeddataHelper'); $newStatements = $linkeddataHelper->getResource($personUri); - $template->addDebug(var_export($newStatements, true)); + $logger->debug(var_export($newStatements, true)); if ($newStatements === null) { $formError['personUri'] = true; $template->formError = $formError; @@ -128,7 +129,7 @@ public function newuserAction ($template) { } else if ($type == $nsFoaf . 'PersonalProfileDocument') { $personUri = $memModel->getValue($personUri, $nsFoaf . 'primaryTopic'); $newStatements = $linkeddataHelper->getResource($personUri); - $template->addDebug(var_export($newStatements, true)); + $logger->debug(var_export($newStatements, true)); $memModel = new Erfurt_Rdf_MemoryModel($newStatements); break; } diff --git a/classes/Xodx/PersonController.php b/classes/Xodx/PersonController.php index d5f34a1..b058cec 100644 --- a/classes/Xodx/PersonController.php +++ b/classes/Xodx/PersonController.php @@ -24,6 +24,7 @@ public function showAction ($template) $bootstrap = $this->_app->getBootstrap(); $model = $bootstrap->getResource('model'); $request = $bootstrap->getResource('request'); + $logger = $bootstrap->getResource('logger'); $personUri = $request->getValue('uri', 'get'); $id = $request->getValue('id', 'get'); $controller = $request->getValue('c', 'get'); @@ -59,13 +60,11 @@ public function showAction ($template) $linkeddataHelper = $this->_app->getHelper('Saft_Helper_LinkeddataHelper'); $newStatements = $linkeddataHelper->getResource($personUri); if ($newStatements !== null) { - $template->addDebug('Import Profile with LinkedDate'); + $logger->info('Import Profile with LinkedDate'); $modelNew = new Erfurt_Rdf_MemoryModel($newStatements); $newStatements = $modelNew->getStatements(); - $template->addDebug(var_export($newStatements, true)); - $profile = array(); $profile[0] = array( 'depiction' => $modelNew->getValue($personUri, $nsFoaf . 'depiction'), diff --git a/classes/Xodx/ProfileController.php b/classes/Xodx/ProfileController.php index 44ce041..9d3206e 100644 --- a/classes/Xodx/ProfileController.php +++ b/classes/Xodx/ProfileController.php @@ -37,8 +37,6 @@ public function listAction($template) $template->profilelistList = $persons; $template->addContent('templates/profilelist.phtml'); - $template->addDebug(var_export($profiles, true)); - return $template; } } diff --git a/libraries/Saft b/libraries/Saft index 81c0df7..e135046 160000 --- a/libraries/Saft +++ b/libraries/Saft @@ -1 +1 @@ -Subproject commit 81c0df773dd46990e75d2587ff590e4d808adbda +Subproject commit e135046f0e80ecc3a730bf1488cd0b2ff26c904c diff --git a/templates/layout.phtml b/templates/layout.phtml index 9eef646..ff0b4d8 100644 --- a/templates/layout.phtml +++ b/templates/layout.phtml @@ -30,9 +30,10 @@ Xodx _menuFiles as $menuFile) { - include $menuFile; - } + $this->partial( + 'templates/menu.phtml', + array('username' => $this->username, 'notifications' => $this->notifications) + ); ?> diff --git a/templates/partials/friendlist.phtml b/templates/partials/friendlist.phtml new file mode 100644 index 0000000..6686004 --- /dev/null +++ b/templates/partials/friendlist.phtml @@ -0,0 +1,24 @@ +

Friends

+addFriend == true) : ?> +
+
+ + +
+
+ +knows as $contact) : ?> +
+ +
+ +
+ diff --git a/templates/profileshow.phtml b/templates/profileshow.phtml index e5a877a..3558c3f 100644 --- a/templates/profileshow.phtml +++ b/templates/profileshow.phtml @@ -49,21 +49,11 @@ Show Activity Feed
-

Friends

- profileshowKnows as $contact) : ?> -
- -
- -
- + partial( + 'templates/partials/friendlist.phtml', + array('personUri' => $this->profileshowPersonUri, 'knows' => $this->profileshowKnows, 'addFriend' => false) + ); + ?> diff --git a/templates/usershow.phtml b/templates/usershow.phtml index b0ba8f6..92ac1a0 100644 --- a/templates/usershow.phtml +++ b/templates/usershow.phtml @@ -91,27 +91,11 @@
Show Activity Feed
-

Friends

-
-
- - -
-
- profileshowKnows as $contact) : ?> -
- -
- -
- + partial( + 'templates/partials/friendlist.phtml', + array('personUri' => $this->profileshowPersonUri, 'knows' => $this->profileshowKnows, 'addFriend' => true) + ); + ?>