Skip to content

Commit

Permalink
Use new layout and logger support in Saft
Browse files Browse the repository at this point in the history
  • Loading branch information
white-gecko committed Jun 1, 2013
1 parent 0adb25f commit 3bd2420
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 56 deletions.
13 changes: 7 additions & 6 deletions classes/Xodx/ActivityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -48,23 +49,23 @@ public function addactivityAction ($template)
'content' => $actContent,
'replyObject' => $replyObject,
);
$debugStr = $this->addActivity($actorUri, $verbUri, $object);
$this->addActivity($actorUri, $verbUri, $object);
break;
case 'Comment';
$object = array(
'type' => $actType,
'content' => $actContent,
'replyObject' => $replyObject,
);
$debugStr = $this->addActivity($actorUri, $verbUri, $object);
$this->addActivity($actorUri, $verbUri, $object);
break;
case 'Bookmark';
$object = array(
'type' => 'Uri',
'content' => $actContent,
'replyObject' => $replyObject,
);
$debugStr = $this->addActivity($actorUri, $verbUri, $object);
$this->addActivity($actorUri, $verbUri, $object);
break;
case 'Photo';
$fieldName = 'content';
Expand All @@ -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;
}
Expand All @@ -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#';
Expand Down
2 changes: 1 addition & 1 deletion classes/Xodx/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions classes/Xodx/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
5 changes: 2 additions & 3 deletions classes/Xodx/PersonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'),
Expand Down
2 changes: 0 additions & 2 deletions classes/Xodx/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public function listAction($template)
$template->profilelistList = $persons;
$template->addContent('templates/profilelist.phtml');

$template->addDebug(var_export($profiles, true));

return $template;
}
}
2 changes: 1 addition & 1 deletion libraries/Saft
Submodule Saft updated 3 files
+12 −14 Layout.php
+17 −3 Logger.php
+41 −0 Template.php
7 changes: 4 additions & 3 deletions templates/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
</a>
<a class="brand"><img src="resources/img/xodx_20.png" alt="Xodx" title="[ˈɛksodʊs]" /></a>
<?php
foreach ($this->_menuFiles as $menuFile) {
include $menuFile;
}
$this->partial(
'templates/menu.phtml',
array('username' => $this->username, 'notifications' => $this->notifications)
);
?>
</div>
</div>
Expand Down
24 changes: 24 additions & 0 deletions templates/partials/friendlist.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<h3>Friends</h3>
<?php if($this->addFriend == true) : ?>
<form method="post" action="?c=person&amp;a=addfriend">
<div class="input-append">
<input type="hidden" name="person" value="<?= htmlentities($this->personUri) ?>" />
<input type="text" name="friend" placeholder="Add a friends URI" /><button class="btn btn-primary" type="submit">Add</button>
</div>
</form>
<?php endif; ?>
<?php foreach($this->knows as $contact) : ?>
<address>
<?php
if ($contact['name'] != null) {
$name = $contact['name'];
} elseif ($contact['nick'] != null) {
$name = $contact['nick'];
} else {
$name = "unknown name";
}
?>
<strong><?= $name ?></strong><br />
<a href="?c=person&amp;uri=<?= urlencode($contact['contactUri']) ?>"><?= $contact['contactUri'] ?></a>
</address>
<?php endforeach; ?>
22 changes: 6 additions & 16 deletions templates/profileshow.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,11 @@
</form>
<a class="btn btn-block" href="?c=feed&amp;a=getFeed&amp;uri=<?= urlencode($this->profileshowPersonUri) ?>">Show Activity Feed</a>
<hr />
<h3>Friends</h3>
<?php foreach($this->profileshowKnows as $contact) : ?>
<address>
<?php
if ($contact['name'] != null) {
$name = $contact['name'];
} elseif ($contact['nick'] != null) {
$name = $contact['nick'];
} else {
$name = "unknown name";
}
?>
<strong><?= $name ?></strong><br />
<a href="?c=person&amp;uri=<?= urlencode($contact['contactUri']) ?>"><?= $contact['contactUri'] ?></a>
</address>
<?php endforeach; ?>
<?php
$this->partial(
'templates/partials/friendlist.phtml',
array('personUri' => $this->profileshowPersonUri, 'knows' => $this->profileshowKnows, 'addFriend' => false)
);
?>
</div>
</div>
28 changes: 6 additions & 22 deletions templates/usershow.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,11 @@
<div class="span3">
<a class="btn btn-block" href="?c=feed&amp;a=getFeed&amp;uri=<?= urlencode($this->profileshowPersonUri) ?>">Show Activity Feed</a>
<hr />
<h3>Friends</h3>
<form method="post" action="?c=person&amp;a=addfriend">
<div class="input-append">
<input type="hidden" name="person" value="<?= htmlentities($this->profileshowPersonUri) ?>" />
<input type="text" name="friend" placeholder="Add a friends URI" /><button class="btn btn-primary" type="submit">Add</button>
</div>
</form>
<?php foreach($this->profileshowKnows as $contact) : ?>
<address>
<?php
if ($contact['name'] != null) {
$name = $contact['name'];
} elseif ($contact['nick'] != null) {
$name = $contact['nick'];
} else {
$name = "unknown name";
}
?>
<strong><?= $name ?></strong><br />
<a href="?c=person&amp;uri=<?= urlencode($contact['contactUri']) ?>"><?= $contact['contactUri'] ?></a>
</address>
<?php endforeach; ?>
<?php
$this->partial(
'templates/partials/friendlist.phtml',
array('personUri' => $this->profileshowPersonUri, 'knows' => $this->profileshowKnows, 'addFriend' => true)
);
?>
</div>
</div>

0 comments on commit 3bd2420

Please sign in to comment.