From 948aba443666f9042e39aa6ff81620d681a1de10 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Tue, 10 Dec 2013 21:25:07 +0100 Subject: [PATCH 01/11] Add a function for obtaining a child-node by its name. refs T6 --- DokuWikiObjectRepresentation.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/DokuWikiObjectRepresentation.class.php b/DokuWikiObjectRepresentation.class.php index ca9b464..5f93b50 100644 --- a/DokuWikiObjectRepresentation.class.php +++ b/DokuWikiObjectRepresentation.class.php @@ -178,6 +178,18 @@ class DokuWikiNameSpace extends DokuWikiNode { return $this->nodes; } + public function hasChild($nodeName) { + if ($this->nodes->count() > 0) { + foreach($this->nodes as $node) { + /** @var DokuWikiNode $node */ + if (($node instanceof DokuWikiPage) && ($node->getName() == $nodeName)) { + return $node; + } + } + } + return null; + } + } /** From d0cdfe2e698226540fef7dbf07499d30de61d3e0 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 8 Jun 2014 00:21:45 +0200 Subject: [PATCH 02/11] Refactored all classes into single files. --- DokuWikiObjectRepresentation.class.php | 280 ------------------ .../DokuWikiObjectRepresentation.class.php | 25 ++ .../objectrepresentation/DokuWikiIterator.php | 78 +++++ .../DokuWikiNameSpace.php | 80 +++++ .../objectrepresentation/DokuWikiNode.php | 137 +++++++++ .../objectrepresentation/DokuWikiPage.php | 31 ++ 6 files changed, 351 insertions(+), 280 deletions(-) delete mode 100644 DokuWikiObjectRepresentation.class.php create mode 100755 lib/enko/DokuWikiObjectRepresentation.class.php create mode 100755 lib/enko/dokuwiki/objectrepresentation/DokuWikiIterator.php create mode 100755 lib/enko/dokuwiki/objectrepresentation/DokuWikiNameSpace.php create mode 100755 lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php create mode 100755 lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php diff --git a/DokuWikiObjectRepresentation.class.php b/DokuWikiObjectRepresentation.class.php deleted file mode 100644 index 5f93b50..0000000 --- a/DokuWikiObjectRepresentation.class.php +++ /dev/null @@ -1,280 +0,0 @@ -content; - } - - /** - * @param string $content - * @return $this - */ - public function setContent($content = '') { - $this->content = $content; - return $this; - } - - /** - * @param $key - * @param $value - */ - public function setMetaData($key,$value) { - $this->metadata[$key] = $value; - } - - /** - * @param $key - * @return mixed - */ - public function getMetaData($key) { - return $this->metadata[$key]; - } - - /** - * @return mixed - */ - public function getName() { - return $this->name; - } - - /** - * @param $filename - * @param null $parent - */ - function __construct ($filename, $parent = null) { - $this->filename = $filename; - $this->parent = $parent; - $this->metadata = new ArrayObject(); - if (is_null ($parent) && is_dir ($filename)) { - $this->name = 'root'; - } else { - $parts = pathinfo($filename); - if (is_dir($filename)) { - $this->name = $parts['basename']; - } else { - $this->name = $parts['filename']; - } - } - } - - /** - * @return String - */ - public function getFilename () { - return $this->filename; - } - - /** - * @return string - */ - public function toString () { - return $this->name; - } - - /** - * @return string - */ - public function getFullID() { - $path = array(); - $node = $this; - while ($parent = $node->parent) { - if ($parent->name != 'root') { - $path[] = $parent->name; - } - $node = $parent; - } - $path = array_reverse($path); - if ($this->name != 'root') { - $path[] = $this->name; - } - return implode(':',$path); - } - -} - -/** - * Class DokuWikiNameSpace - */ -class DokuWikiNameSpace extends DokuWikiNode { - - /** @var \ArrayObject */ - public $nodes; - - /** - * @param $path - * @param null $parent - */ - function __construct ($path, $parent = null) { - parent::__construct ($path, $parent); - $files = dir ($path); - - $this->nodes = new ArrayObject(); - - while (($realfile = $files->read ())) { - $node = null; - $file = $path . DIRECTORY_SEPARATOR . $realfile; - if (is_dir ($file)) { - if (!(($realfile == '.') or ($realfile == '..'))) { - $node = new DokuWikiNameSpace($file, $this); - } - } else { - $node = new DokuWikiPage($file, $this); - } - if ($node) { - $this->nodes->append ($node); - } - } - } - - /** - * @return string - */ - public function toString () { - $retval = ''; - foreach ($this->nodes as $node) { - /** @var $node DokuWikiNode */ - if ($this->name == 'root') { - $retval .= $node->toString() . "\n"; - } else { - $retval .= $this->name . ":" . $node->toString() . "\n"; - } - } - return $retval; - } - - public function getNodes() { - return $this->nodes; - } - - public function hasChild($nodeName) { - if ($this->nodes->count() > 0) { - foreach($this->nodes as $node) { - /** @var DokuWikiNode $node */ - if (($node instanceof DokuWikiPage) && ($node->getName() == $nodeName)) { - return $node; - } - } - } - return null; - } - -} - -/** - * Class DokuWikiPage - */ -class DokuWikiPage extends DokuWikiNode { - /** - * @param $filename - * @param null $parent - */ - public function __construct($filename, $parent = null) { - parent::__construct($filename,$parent); - $this->content = file_get_contents($this->filename); - if (($this->name == 'start') && ($this->parent->name != 'root')) { - $this->parent->content = $this->content; - } - $metadata = p_get_metadata($this->getFullID()); - foreach($metadata as $key => $value) { - $this->setMetaData($key,$value); - } - - } -} - -/** - * Class DokuWikiIterator - */ -class DokuWikiIterator { - - /** - * @var DokuWikiNameSpace - */ - private $root; - - /** - * @param callable $callback - */ - public function runMetadataExtractor(Callable $callback) { - $this->all($callback); - } - - /** - * @param DokuWikiNameSpace $ns - * @param callable $callback - */ - private function _all(DokuWikiNameSpace $ns, Callable $callback) { - $callback($ns); - foreach($ns->nodes as $node) { - /** $node DokuWikiNode */ - if ($node instanceof DokuWikiPage) { - $callback($node); - } - if ($node instanceof DokuWikiNameSpace) { - $this->_all($node,$callback); - } - } - } - - /** - * @param callable $callback - * @return $this - */ - public function all(Callable $callback) { - $this->_all($this->root,$callback); - return $this; - } - - /** - * - */ - public function __construct () { - global $conf; - $basedir = $conf['datadir']; - - $this->root = new DokuWikiNameSpace($basedir); - } - - /** - * @return string - */ - public function toString () { - return $this->root->toString(); - } - - public function getRoot() { - return $this->root; - } -} \ No newline at end of file diff --git a/lib/enko/DokuWikiObjectRepresentation.class.php b/lib/enko/DokuWikiObjectRepresentation.class.php new file mode 100755 index 0000000..8e394fe --- /dev/null +++ b/lib/enko/DokuWikiObjectRepresentation.class.php @@ -0,0 +1,25 @@ +all($callback); + } + + /** + * @param DokuWikiNameSpace $ns + * @param callable $callback + */ + private function _all(DokuWikiNameSpace $ns, Callable $callback) + { + $callback($ns); + foreach ($ns->nodes as $node) { + /** $node DokuWikiNode */ + if ($node instanceof DokuWikiPage) { + $callback($node); + } + if ($node instanceof DokuWikiNameSpace) { + $this->_all($node, $callback); + } + } + } + + /** + * @param callable $callback + * @return $this + */ + public function all(Callable $callback) + { + $this->_all($this->root, $callback); + return $this; + } + + /** + * + */ + public function __construct() + { + global $conf; + $basedir = $conf['datadir']; + + $this->root = new DokuWikiNameSpace($basedir); + } + + /** + * @return string + */ + public function toString() + { + return $this->root->toString(); + } + + public function getRoot() + { + return $this->root; + } +} \ No newline at end of file diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiNameSpace.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiNameSpace.php new file mode 100755 index 0000000..cee50bc --- /dev/null +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiNameSpace.php @@ -0,0 +1,80 @@ +nodes = new \ArrayObject(); + + while (($realfile = $files->read())) { + $node = null; + $file = $path . DIRECTORY_SEPARATOR . $realfile; + if (is_dir($file)) { + if (!(($realfile == '.') or ($realfile == '..'))) { + $node = new DokuWikiNameSpace($file, $this); + } + } else { + $node = new DokuWikiPage($file, $this); + } + if ($node) { + $this->nodes->append($node); + } + } + } + + /** + * @return string + */ + public function toString() + { + $retval = ''; + foreach ($this->nodes as $node) { + /** @var $node DokuWikiNode */ + if ($this->name == 'root') { + $retval .= $node->toString() . "\n"; + } else { + $retval .= $this->name . ":" . $node->toString() . "\n"; + } + } + return $retval; + } + + public function getNodes() + { + return $this->nodes; + } + + public function hasChild($nodeName) + { + if ($this->nodes->count() > 0) { + foreach ($this->nodes as $node) { + /** @var DokuWikiNode $node */ + if (($node instanceof DokuWikiPage) && ($node->getName() == $nodeName)) { + return $node; + } + } + } + return null; + } + +} \ No newline at end of file diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php new file mode 100755 index 0000000..866e27a --- /dev/null +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php @@ -0,0 +1,137 @@ +content; + } + + /** + * @param string $content + * @return $this + */ + public function setContent($content = '') + { + $this->content = $content; + return $this; + } + + /** + * @param $key + * @param $value + */ + public function setMetaData($key, $value) + { + $this->metadata[$key] = $value; + } + + /** + * @param $key + * @return mixed + */ + public function getMetaData($key) + { + return $this->metadata[$key]; + } + + /** + * @return mixed + */ + public function getName() + { + return $this->name; + } + + /** + * @param $filename + * @param null $parent + */ + function __construct($filename, $parent = null) + { + $this->filename = $filename; + $this->parent = $parent; + $this->metadata = new \ArrayObject(); + if (is_null($parent) && is_dir($filename)) { + $this->name = 'root'; + } else { + $parts = pathinfo($filename); + if (is_dir($filename)) { + $this->name = $parts['basename']; + } else { + $this->name = $parts['filename']; + } + } + } + + /** + * @return String + */ + public function getFilename() + { + return $this->filename; + } + + /** + * @return string + */ + public function toString() + { + return $this->name; + } + + /** + * @return string + */ + public function getFullID() + { + $path = array(); + $node = $this; + while ($parent = $node->parent) { + if ($parent->name != 'root') { + $path[] = $parent->name; + } + $node = $parent; + } + $path = array_reverse($path); + if ($this->name != 'root') { + $path[] = $this->name; + } + return implode(':', $path); + } + +} \ No newline at end of file diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php new file mode 100755 index 0000000..f4691a4 --- /dev/null +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php @@ -0,0 +1,31 @@ +content = file_get_contents($this->filename); + if (($this->name == 'start') && ($this->parent->name != 'root')) { + $this->parent->content = $this->content; + } + $metadata = p_get_metadata($this->getFullID()); + foreach ($metadata as $key => $value) { + $this->setMetaData($key, $value); + } + + } +} \ No newline at end of file From d8fa89156eb03949c2f4e4f5da738fe42863c93c Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 8 Jun 2014 00:45:52 +0200 Subject: [PATCH 03/11] Added autoloader info --- composer.json | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) mode change 100644 => 100755 composer.json diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 index 7d56a90..7c2f9f1 --- a/composer.json +++ b/composer.json @@ -1,18 +1,23 @@ { - "name": "enko/dokuwikiobjectrepresentation", - "type": "library", - "description": "DokuWiki data abstraction from the future", - "keywords": ["dokuwiki","abstraction"], - "homepage": "https://bk-dev.hacked.jp/project/view/1/", - "license": "GPL2", - "authors": [ - { - "name": "Tim Schumacher", - "email": "tim@bandenkrieg.hacked.jp", - "role": "Developer" + "name": "enko/dokuwikiobjectrepresentation", + "type": "library", + "description": "DokuWiki data abstraction from the future", + "keywords": ["dokuwiki", "abstraction"], + "homepage": "https://bk-dev.hacked.jp/project/view/1/", + "license": "GPL2", + "authors": [ + { + "name": "Tim Schumacher", + "email": "tim@bandenkrieg.hacked.jp", + "role": "Developer" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-4": { + "enko\\dokuwiki\\objectrepresentation\\": "lib/enko/dokuwiki/objectrepresentation" + } } - ], - "require": { - "php": ">=5.3.0" - } } \ No newline at end of file From 5be961ccab993aef207b5be110f14b9c6c2fad9f Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 8 Jun 2014 00:52:58 +0200 Subject: [PATCH 04/11] Updated the project url --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7c2f9f1..92c8c18 100755 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "type": "library", "description": "DokuWiki data abstraction from the future", "keywords": ["dokuwiki", "abstraction"], - "homepage": "https://bk-dev.hacked.jp/project/view/1/", + "homepage": "https://phablab.krautspace.de/project/view/1/", "license": "GPL2", "authors": [ { @@ -20,4 +20,4 @@ "enko\\dokuwiki\\objectrepresentation\\": "lib/enko/dokuwiki/objectrepresentation" } } -} \ No newline at end of file +} From e9576d0d581d117ede6e4223c01e7a517a062e5a Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 8 Jun 2014 01:57:48 +0200 Subject: [PATCH 05/11] Create a class that represents a changeset of dokuwiki page. --- .../DokuWikiChangeset.php | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 lib/enko/dokuwiki/objectrepresentation/DokuWikiChangeset.php diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiChangeset.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiChangeset.php new file mode 100755 index 0000000..97b10bc --- /dev/null +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiChangeset.php @@ -0,0 +1,100 @@ +content; + } + + /** + * @return \DateTime + */ + public function getDate() + { + return $this->date; + } + + /** + * @return mixed + */ + public function getExtra() + { + return $this->extra; + } + + /** + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * @return mixed + */ + public function getIp() + { + return $this->ip; + } + + /** + * @return mixed + */ + public function getSum() + { + return $this->sum; + } + + /** + * @return mixed + */ + public function getType() + { + return $this->type; + } + + /** + * @return mixed + */ + public function getUser() + { + return $this->user; + } + + function __construct($date,$extra, $id, $ip, $sum, $type, $user) + { + $this->date = new \DateTime(); + $this->date->setTimestamp($date); + $this->extra = $extra; + $this->id = $id; + $this->ip = $ip; + $this->sum = $sum; + $this->type = $type; + $this->user = $user; + $this->content = rawWiki($id,$this->date->format('U')); + } + + +} \ No newline at end of file From 29ebda487aa2d866ef63e882830681a5513fa60b Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 8 Jun 2014 01:58:27 +0200 Subject: [PATCH 06/11] Extract the changesets of a dokuwikipage and put it into DokuWikiPage::ChangeLog. --- .../dokuwiki/objectrepresentation/DokuWikiPage.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php index f4691a4..fdffa68 100755 --- a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php @@ -11,6 +11,8 @@ namespace enko\dokuwiki\objectrepresentation; class DokuWikiPage extends DokuWikiNode { + public $ChangeLog; + /** * @param $filename * @param null $parent @@ -26,6 +28,17 @@ class DokuWikiPage extends DokuWikiNode foreach ($metadata as $key => $value) { $this->setMetaData($key, $value); } + // extract changelog + $this->ChangeLog = new \ArrayObject(); + $file = metaFN($this->getFullID(), '.changes'); + if (file_exists($file)) { + $changelog_entries = explode("\n", file_get_contents($file)); + foreach ($changelog_entries as $raw_entry) { + $entry = parseChangelogLine($raw_entry); + $changelog = new DokuWikiChangeset($entry['date'], $entry['extra'], $entry['id'], $entry['ip'], $entry['sum'], $entry['type'], $entry['user']); + $this->ChangeLog->append($changelog); + } + } } } \ No newline at end of file From 0b248d7dec6336bf76b154b75318474ca5ac0228 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 14 Jun 2014 09:29:13 +0200 Subject: [PATCH 07/11] Add a option to load the changesets. The default is, not to load the changesets. --- .../objectrepresentation/DokuWikiIterator.php | 4 ++-- .../DokuWikiNameSpace.php | 8 +++---- .../objectrepresentation/DokuWikiNode.php | 10 +++++++- .../objectrepresentation/DokuWikiPage.php | 24 +++++++++++-------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiIterator.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiIterator.php index e938875..0c3b983 100755 --- a/lib/enko/dokuwiki/objectrepresentation/DokuWikiIterator.php +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiIterator.php @@ -55,12 +55,12 @@ class DokuWikiIterator /** * */ - public function __construct() + public function __construct($loadChangesets = false, \DateTime $maxChangeSetAge = null) { global $conf; $basedir = $conf['datadir']; - $this->root = new DokuWikiNameSpace($basedir); + $this->root = new DokuWikiNameSpace($basedir, null, $loadChangesets, $maxChangeSetAge); } /** diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiNameSpace.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiNameSpace.php index cee50bc..f57d030 100755 --- a/lib/enko/dokuwiki/objectrepresentation/DokuWikiNameSpace.php +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiNameSpace.php @@ -19,9 +19,9 @@ class DokuWikiNameSpace extends DokuWikiNode * @param $path * @param null $parent */ - function __construct($path, $parent = null) + function __construct($path, $parent = null,$loadChangesets = false, \DateTime $maxChangeSetAge = null) { - parent::__construct($path, $parent); + parent::__construct($path, $parent, $loadChangesets, $maxChangeSetAge); $files = dir($path); $this->nodes = new \ArrayObject(); @@ -31,10 +31,10 @@ class DokuWikiNameSpace extends DokuWikiNode $file = $path . DIRECTORY_SEPARATOR . $realfile; if (is_dir($file)) { if (!(($realfile == '.') or ($realfile == '..'))) { - $node = new DokuWikiNameSpace($file, $this); + $node = new DokuWikiNameSpace($file, $this, $loadChangesets, $maxChangeSetAge); } } else { - $node = new DokuWikiPage($file, $this); + $node = new DokuWikiPage($file, $this, $loadChangesets, $maxChangeSetAge); } if ($node) { $this->nodes->append($node); diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php index 866e27a..138f805 100755 --- a/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php @@ -32,6 +32,12 @@ abstract class DokuWikiNode /** @var DokuWikiNameSpace */ protected $parent = null; + /** @var bool */ + protected $loadChangesets = false; + + /** @var \DateTime */ + protected $maxChangeSetAge = null; + /** * @return string @@ -81,11 +87,13 @@ abstract class DokuWikiNode * @param $filename * @param null $parent */ - function __construct($filename, $parent = null) + function __construct($filename, $parent = null, $loadChangesets = false, \DateTime $maxChangeSetAge = null) { $this->filename = $filename; $this->parent = $parent; $this->metadata = new \ArrayObject(); + $this->loadChangesets = $loadChangesets; + $this->maxChangeSetAge = $maxChangeSetAge; if (is_null($parent) && is_dir($filename)) { $this->name = 'root'; } else { diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php index fdffa68..4be402c 100755 --- a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php @@ -17,9 +17,9 @@ class DokuWikiPage extends DokuWikiNode * @param $filename * @param null $parent */ - public function __construct($filename, $parent = null) + public function __construct($filename, $parent = null,$loadChangesets = false, \DateTime $maxChangeSetAge = null) { - parent::__construct($filename, $parent); + parent::__construct($filename, $parent,$loadChangesets,$maxChangeSetAge); $this->content = file_get_contents($this->filename); if (($this->name == 'start') && ($this->parent->name != 'root')) { $this->parent->content = $this->content; @@ -28,15 +28,19 @@ class DokuWikiPage extends DokuWikiNode foreach ($metadata as $key => $value) { $this->setMetaData($key, $value); } - // extract changelog $this->ChangeLog = new \ArrayObject(); - $file = metaFN($this->getFullID(), '.changes'); - if (file_exists($file)) { - $changelog_entries = explode("\n", file_get_contents($file)); - foreach ($changelog_entries as $raw_entry) { - $entry = parseChangelogLine($raw_entry); - $changelog = new DokuWikiChangeset($entry['date'], $entry['extra'], $entry['id'], $entry['ip'], $entry['sum'], $entry['type'], $entry['user']); - $this->ChangeLog->append($changelog); + if ($this->loadChangesets) { + // extract changelog + $file = metaFN($this->getFullID(), '.changes'); + if (file_exists($file)) { + $changelog_entries = explode("\n", file_get_contents($file)); + foreach ($changelog_entries as $raw_entry) { + $entry = parseChangelogLine($raw_entry); + if ((!is_null($this->maxChangeSetAge)) && ($this->maxChangeSetAge->format('U') > $entry['date'])) + continue; + $changelog = new DokuWikiChangeset($entry['date'], $entry['extra'], $entry['id'], $entry['ip'], $entry['sum'], $entry['type'], $entry['user']); + $this->ChangeLog->append($changelog); + } } } From 8bda3d90f6cd7d0f47b8ffa1e919cf2f3b2bd40d Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 14 Jun 2014 10:19:19 +0200 Subject: [PATCH 08/11] Generate the title for the page. --- .../dokuwiki/objectrepresentation/DokuWikiChangeset.php | 8 +++++++- lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiChangeset.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiChangeset.php index 97b10bc..67451a4 100755 --- a/lib/enko/dokuwiki/objectrepresentation/DokuWikiChangeset.php +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiChangeset.php @@ -18,6 +18,7 @@ class DokuWikiChangeset { private $sum; private $extra; private $content; + private $page; /** * @return mixed @@ -75,6 +76,10 @@ class DokuWikiChangeset { return $this->type; } + public function getPage() { + return $this->page; + } + /** * @return mixed */ @@ -83,7 +88,7 @@ class DokuWikiChangeset { return $this->user; } - function __construct($date,$extra, $id, $ip, $sum, $type, $user) + function __construct($date,$extra, $id, $ip, $sum, $type, $user, DokuWikiPage $page) { $this->date = new \DateTime(); $this->date->setTimestamp($date); @@ -94,6 +99,7 @@ class DokuWikiChangeset { $this->type = $type; $this->user = $user; $this->content = rawWiki($id,$this->date->format('U')); + $this->page = $page; } diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php index fdffa68..c78dad3 100755 --- a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php @@ -35,10 +35,14 @@ class DokuWikiPage extends DokuWikiNode $changelog_entries = explode("\n", file_get_contents($file)); foreach ($changelog_entries as $raw_entry) { $entry = parseChangelogLine($raw_entry); - $changelog = new DokuWikiChangeset($entry['date'], $entry['extra'], $entry['id'], $entry['ip'], $entry['sum'], $entry['type'], $entry['user']); + $changelog = new DokuWikiChangeset($entry['date'], $entry['extra'], $entry['id'], $entry['ip'], $entry['sum'], $entry['type'], $entry['user'],$this); $this->ChangeLog->append($changelog); } } } + + public function getTitle() { + return strlen($this->getMetaData('title')) > 0 ? $this->getMetaData('title') : $this->getName(); + } } \ No newline at end of file From 040a3fbd8af686f440ac30eff1451be0218bc8d3 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 14 Jun 2014 10:24:20 +0200 Subject: [PATCH 09/11] fix typo --- lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php index eca314d..caf5f5c 100755 --- a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php @@ -38,7 +38,7 @@ class DokuWikiPage extends DokuWikiNode $entry = parseChangelogLine($raw_entry); if ((!is_null($this->maxChangeSetAge)) && ($this->maxChangeSetAge->format('U') > $entry['date'])) continue; - $changelog = new DokuWikiChangeset($entry['date'], $entry['extra'], $entry['id'], $entry['ip'], $entry['sum'], $entry['type'], $entry['user'],$page); + $changelog = new DokuWikiChangeset($entry['date'], $entry['extra'], $entry['id'], $entry['ip'], $entry['sum'], $entry['type'], $entry['user'],$this); $this->ChangeLog->append($changelog); } } From 56ce743994220670647387f59d6a004b25a49b28 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 15 Jun 2014 16:39:47 +0200 Subject: [PATCH 10/11] Suply a getter for the node parent. --- lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php index 138f805..b49bce2 100755 --- a/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiNode.php @@ -83,6 +83,13 @@ abstract class DokuWikiNode return $this->name; } + /** + * @return DokuWikiNameSpace + */ + public function getParent() { + return $this->parent; + } + /** * @param $filename * @param null $parent From 174d217f1145164578cd55f5d46aa08055354b59 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 15 Jun 2014 16:40:08 +0200 Subject: [PATCH 11/11] Sort the changelog. --- lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php index caf5f5c..eacc13a 100755 --- a/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php +++ b/lib/enko/dokuwiki/objectrepresentation/DokuWikiPage.php @@ -42,6 +42,14 @@ class DokuWikiPage extends DokuWikiNode $this->ChangeLog->append($changelog); } } + if ($this->ChangeLog->count() > 0) { + $this->ChangeLog->uasort(function(DokuWikiChangeset $a, DokuWikiChangeset $b){ + if ($a->getDate() == $b->getDate()) { + return 0; + } + return ($a->getDate() > $b->getDate()) ? -1 : 1; + }); + } } }