public function parse($type = 'page', $id = 1) { #fwrite(STDOUT, 'parse: '.$type.', '.$id.PHP_EOL); $this->parseMetaSettings(); #ve($this->variables); if ($this->templateChanged) { $this->templateChanged = false; $this->parseElements(); } $isIndexPage = $type == 'page'; $isPermalinkPage = $type == 'post'; $totalPages = ceil(count($this->settings['posts']) / $this->settings['postsPerPage']); $posts = array(); if ($isIndexPage) { $postIdMin = ($id - 1) * $this->settings['postsPerPage']; $postIdMax = $postIdMin + $this->settings['postsPerPage']; #fwrite(STDOUT, 'ids: '.$postIdMin.' - '.$postIdMax.PHP_EOL); for ($postId = $postIdMin; $postId < $postIdMax; $postId++) { if (isset($this->settings['posts'][$postId])) { $postObj = $this->makePostFromIndex($postId, $isPermalinkPage); if ($postObj) { $posts[] = $postObj; } } else { break; } } } elseif ($isPermalinkPage) { $postObj = $this->makePostFromIndex($id - 1, $isPermalinkPage); if ($postObj) { $posts[] = $postObj; $variable = new Variable(); $variable->setName('PostTitle'); $variable->setValue($postObj->getTitle()); $this->variables['PostTitle'] = $variable; #fwrite(STDOUT, 'PostTitle: '.$postObj->getTitle().PHP_EOL); } #ve($postObj); } #ve($posts); #ve($this->variables); $this->setElementsValues($this->rootElement, $isIndexPage, $isPermalinkPage, $posts, $id, $totalPages, $this->settings['pages']); return $this->renderElements($this->rootElement); }
public function testSetReference() { $variable = new Variable(); $variable->setReference('ref1'); $this->assertEquals('ref1', $variable->getReference()); }