Skip to content

Commit

Permalink
nodes as stdclass instead of array
Browse files Browse the repository at this point in the history
  • Loading branch information
pkeane committed Oct 8, 2011
1 parent 252081a commit 1790dcb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
10 changes: 10 additions & 0 deletions lib/Dase/DBO.php
Expand Up @@ -375,6 +375,16 @@ public function getIterator()
return new ArrayObject($this->fields); 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() public function asArray()
{ {
foreach ($this->fields as $k => $v) { foreach ($this->fields as $k => $v) {
Expand Down
9 changes: 4 additions & 5 deletions lib/Dase/DBO/Node.php
Expand Up @@ -116,16 +116,15 @@ public function asJson($r)


public function asPhp($r,$get_attachments = true) public function asPhp($r,$get_attachments = true)
{ {
$obj_ar = $this->asArray(); $obj = $this->asObj();
$obj_ar['id'] = $this->id;
$meta = array(); $meta = array();
foreach ($this->getAttvals() as $attval) { foreach ($this->getAttvals() as $attval) {
if (!isset($meta[$attval->att_ascii])) { if (!isset($meta[$attval->att_ascii])) {
$meta[$attval->att_ascii] = array(); $meta[$attval->att_ascii] = array();
} }
$meta[$attval->att_ascii][] = $attval->value; $meta[$attval->att_ascii][] = $attval->value;
} }
$obj_ar['meta'] = $meta; $obj->meta = $meta;


if ($get_attachments) { if ($get_attachments) {
$attachments = array(); $attachments = array();
Expand All @@ -145,8 +144,8 @@ public function asPhp($r,$get_attachments = true)
$attachments[$at->name]['items'] = $nodeset->asPhp($r); $attachments[$at->name]['items'] = $nodeset->asPhp($r);
} }
} }
$obj_ar['attachments'] = $attachments; $obj->attachments = $attachments;
} }
return $obj_ar; return $obj;
} }
} }
7 changes: 6 additions & 1 deletion lib/Dase/Handler/Page.php
Expand Up @@ -46,7 +46,12 @@ public function getNode($r) {
if ('image' == substr($node->mime,0,5)) { if ('image' == substr($node->mime,0,5)) {
$t->assign('is_image',1); $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) public function getDynamicPage($r,$uri_path)
Expand Down
8 changes: 4 additions & 4 deletions templates/pages/page-icons.tpl
@@ -1,11 +1,11 @@
{extends file="eanthro-layout.tpl"} {extends file="eanthro-layout.tpl"}


{block name="content"} {block name="content"}
<h1>{$node.title}</h1> <h1>{$node->title}</h1>
<ul> <ul>
{foreach item=subnode from=$node.attachments.icons.items} {foreach item=subnode from=$node->attachments.icons.items}
<li><img src="{$subnode.thumbnail_url}"></li> <li><img src="{$subnode->thumbnail_url}"></li>
{/foreach} {/foreach}
</ul> </ul>
{if $is_image} {if $is_image}
<img src="node/{$node->name}"> <img src="node/{$node->name}">
Expand Down

0 comments on commit 1790dcb

Please sign in to comment.