public function getPage($path = '') { $pageTree = $this->getBranch()->getCommit()->getTree(); $pageObj = $pageTree->resolvePath($path); $name = $path === '' ? '' : $path; $page = $page = new Page($this, $name); if ($pageObj instanceof Tree) { $page->setHasSubpages(true)->setTree($pageObj)->setPath($path)->setBlob($pageObj->resolvePath('index.md')); } else { $page->setBlob($pageObj)->setPath($path); } return $page; }
public function getPages() { $pages = array(); if ($this->getTree() instanceof Tree) { foreach ($this->getTree()->getEntries() as $name => $pageObj) { $page = new Page($this->getWiki(), $name); if ($name === 'index.md') { continue; } if ($pageObj[1] instanceof Tree) { $path = $this->getPath(); $path .= strlen($path) > 0 ? '/' : ''; $path .= $name; $page->setHasSubpages(true)->setTree($pageObj[1])->setPath($path)->setBlob($pageObj[1]->resolvePath('index.md')); } else { $page->setBlob($pageObj[1])->setPath($this->getPath() . '/' . $name); } array_push($pages, $page); } } return $pages; }