diff --git a/daux.phar b/daux.phar old mode 100644 new mode 100755 index d3ed60e..8a13966 Binary files a/daux.phar and b/daux.phar differ diff --git a/libs/Format/Base/MarkdownPage.php b/libs/Format/Base/MarkdownPage.php index ac189ea..cc8659b 100644 --- a/libs/Format/Base/MarkdownPage.php +++ b/libs/Format/Base/MarkdownPage.php @@ -53,7 +53,7 @@ abstract class MarkdownPage extends SimplePage public static function fromFile(Content $file, $params) { - $page = new static($file->title, file_get_contents($file->getPath())); + $page = new static($file->getTitle(), $file->getContent()); $page->setFile($file); $page->setParams($params); diff --git a/libs/Format/HTML/MarkdownPage.php b/libs/Format/HTML/MarkdownPage.php index 1cc76c1..f96608e 100644 --- a/libs/Format/HTML/MarkdownPage.php +++ b/libs/Format/HTML/MarkdownPage.php @@ -56,7 +56,7 @@ class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage $entry_page['View Documentation'] = $params['base_page'] . $params['entry_page']->getUrl(); } } elseif ($params['file_uri'] === 'index') { - $entry_page[$params['entry_page']->title] = $params['base_page'] . $params['entry_page']->getUrl(); + $entry_page[$params['entry_page']->getTitle()] = $params['base_page'] . $params['entry_page']->getUrl(); } $page = [ diff --git a/libs/Tree/Content.php b/libs/Tree/Content.php index 466adf9..b28ad53 100644 --- a/libs/Tree/Content.php +++ b/libs/Tree/Content.php @@ -4,7 +4,7 @@ use Todaymade\Daux\DauxHelper; class Content extends Entry { - public $title; + protected $content; public function __construct($path = '', $parents = array()) { @@ -12,6 +12,20 @@ class Content extends Entry $this->value = $this->uri; } + + public function getContent() + { + if (!$this->content) { + $this->content = file_get_contents($this->getPath()); + } + + return $this->content; + } + + public function setContent($content) + { + $this->content = $content; + } protected function getFilename($file) { diff --git a/libs/Tree/Entry.php b/libs/Tree/Entry.php index aeec4de..cf47ed5 100644 --- a/libs/Tree/Entry.php +++ b/libs/Tree/Entry.php @@ -15,40 +15,28 @@ abstract class Entry public function __construct($path = '', $parents = array()) { - if (!isset($path) || $path == '' || !file_exists($path)) { - return; - } - $this->local_path = $path; - $this->parents = $parents; - $this->last_modified = filemtime($path); - $this->name = DauxHelper::pathinfo($path)['filename']; - $this->title = $this->getTitleInternal($this->name); - $this->uri = $this->getUrlInternal($this->getFilename($path)); - $this->index_page = false; + $this->setPath($path); + $this->setParents($parents); } + public function getName() { return $this->name; } - - public function setUri($uri) - { - $this->uri = $uri; - } - + + public function setName($name) + { + $this->name = $name; + } + public function getUri() { return $this->uri; } - public function getUrl() + public function setUri($uri) { - $url = ''; - foreach ($this->parents as $node) { - $url .= $node->uri . '/'; - } - $url .= $this->uri; - return $url; + $this->uri = $uri; } public function getIndexPage() @@ -101,16 +89,39 @@ abstract class Entry { return $this->title; } + + public function setTitle($title) + { + $this->title = $title; + } public function getParents() { return $this->parents; } + + public function setParents($parents) + { + $this->parents = $parents; + } public function getPath() { return $this->local_path; } + + public function setPath($path) + { + if (!isset($path) || $path == '' || !file_exists($path)) { + return; + } + $this->local_path = $path; + $this->last_modified = filemtime($path); + $this->name = DauxHelper::pathinfo($path)['filename']; + $this->title = $this->getTitleInternal($this->name); + $this->uri = $this->getUrlInternal($this->getFilename($path)); + $this->index_page = false; + } public function write($content) { @@ -121,6 +132,16 @@ abstract class Entry file_put_contents($this->local_path, $content); return true; } + + public function getUrl() + { + $url = ''; + foreach ($this->parents as $node) { + $url .= $node->uri . '/'; + } + $url .= $this->uri; + return $url; + } protected function getFilename($file) {