2014-06-08 00:21:45 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: tim
|
|
|
|
* Date: 12.06.14
|
|
|
|
* Time: 21:55
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace enko\dokuwiki\objectrepresentation;
|
|
|
|
|
|
|
|
|
|
|
|
class DokuWikiPage extends DokuWikiNode
|
|
|
|
{
|
2014-06-08 01:58:27 +02:00
|
|
|
public $ChangeLog;
|
|
|
|
|
2014-06-08 00:21:45 +02:00
|
|
|
/**
|
|
|
|
* @param $filename
|
|
|
|
* @param null $parent
|
|
|
|
*/
|
2014-06-14 09:29:13 +02:00
|
|
|
public function __construct($filename, $parent = null,$loadChangesets = false, \DateTime $maxChangeSetAge = null)
|
2014-06-08 00:21:45 +02:00
|
|
|
{
|
2014-06-14 09:29:13 +02:00
|
|
|
parent::__construct($filename, $parent,$loadChangesets,$maxChangeSetAge);
|
2014-06-08 00:21:45 +02:00
|
|
|
$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);
|
|
|
|
}
|
2014-06-08 01:58:27 +02:00
|
|
|
$this->ChangeLog = new \ArrayObject();
|
2014-06-14 09:29:13 +02:00
|
|
|
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;
|
2014-06-14 10:24:20 +02:00
|
|
|
$changelog = new DokuWikiChangeset($entry['date'], $entry['extra'], $entry['id'], $entry['ip'], $entry['sum'], $entry['type'], $entry['user'],$this);
|
2014-06-14 09:29:13 +02:00
|
|
|
$this->ChangeLog->append($changelog);
|
|
|
|
}
|
2014-06-08 01:58:27 +02:00
|
|
|
}
|
2014-06-15 16:40:08 +02:00
|
|
|
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;
|
|
|
|
});
|
|
|
|
}
|
2014-06-08 01:58:27 +02:00
|
|
|
}
|
2014-06-08 00:21:45 +02:00
|
|
|
|
|
|
|
}
|
2014-06-14 10:19:19 +02:00
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
return strlen($this->getMetaData('title')) > 0 ? $this->getMetaData('title') : $this->getName();
|
|
|
|
}
|
2014-06-08 00:21:45 +02:00
|
|
|
}
|