Permalink
Browse files

nodes as stdclass instead of array

  • Loading branch information...
1 parent 252081a commit 1790dcb095c464f5ba9709d90107feda5ccd9969 @pkeane committed Oct 8, 2011
Showing with 24 additions and 10 deletions.
  1. +10 −0 lib/Dase/DBO.php
  2. +4 −5 lib/Dase/DBO/Node.php
  3. +6 −1 lib/Dase/Handler/Page.php
  4. +4 −4 templates/pages/page-icons.tpl
View
@@ -375,6 +375,16 @@ public function getIterator()
return new ArrayObject($this->fields);
}
+ public function asObj()
+ {
+ $obj = new stdClass();
+ foreach ($this->fields as $k => $v) {
+ $obj->$k = $v;
+ }
+ $obj->id = $this->id;
+ return $obj;
+ }
+
public function asArray()
{
foreach ($this->fields as $k => $v) {
@@ -116,16 +116,15 @@ public function asJson($r)
public function asPhp($r,$get_attachments = true)
{
- $obj_ar = $this->asArray();
- $obj_ar['id'] = $this->id;
+ $obj = $this->asObj();
$meta = array();
foreach ($this->getAttvals() as $attval) {
if (!isset($meta[$attval->att_ascii])) {
$meta[$attval->att_ascii] = array();
}
$meta[$attval->att_ascii][] = $attval->value;
}
- $obj_ar['meta'] = $meta;
+ $obj->meta = $meta;
if ($get_attachments) {
$attachments = array();
@@ -145,8 +144,8 @@ public function asPhp($r,$get_attachments = true)
$attachments[$at->name]['items'] = $nodeset->asPhp($r);
}
}
- $obj_ar['attachments'] = $attachments;
+ $obj->attachments = $attachments;
}
- return $obj_ar;
+ return $obj;
}
}
@@ -46,7 +46,12 @@ public function getNode($r) {
if ('image' == substr($node->mime,0,5)) {
$t->assign('is_image',1);
}
- $r->renderResponse($t->fetch('page.tpl'));
+ $template_file = 'pages/page-'.$node->alias.'.tpl';
+ if ($t->template_exists($template_file)) {
+ $r->renderResponse($t->fetch($template_file));
+ } else {
+ $r->renderResponse($t->fetch('page.tpl'));
+ }
}
public function getDynamicPage($r,$uri_path)
@@ -1,11 +1,11 @@
{extends file="eanthro-layout.tpl"}
{block name="content"}
-<h1>{$node.title}</h1>
+<h1>{$node->title}</h1>
<ul>
-{foreach item=subnode from=$node.attachments.icons.items}
-<li><img src="{$subnode.thumbnail_url}"></li>
-{/foreach}
+ {foreach item=subnode from=$node->attachments.icons.items}
+ <li><img src="{$subnode->thumbnail_url}"></li>
+ {/foreach}
</ul>
{if $is_image}
<img src="node/{$node->name}">

0 comments on commit 1790dcb

Please sign in to comment.