1<?php
2/**
3 * This is the Dokuwiki export for FINDOLOGIC.
4 *
5 * If any bugs occur, please submit a new issue
6 * @see https://github.com/findologic/dokuwiki-plugin-findologic-xml-export/issues/new
7 * @author Dominik Brader <support@findologic.com>
8 */
9
10class DokuwikiPage
11{
12
13    /**
14     * @var string ID of the DokuWiki page.
15     */
16    public $id;
17
18    /**
19     * @var string URL of the DokuWiki page (absolute).
20     */
21    public $url;
22
23    /**
24     * @var string Author of the last change that was made to the DokuWiki page.
25     */
26    public $author;
27
28    /**
29     * @var DateTime DateTime object of last edited date.
30     */
31    public $lastEdit;
32
33    /**
34     * @var array Entire metadata of the page.
35     */
36    public $metadata;
37
38    /**
39     * Gets DokuWiki page data based on page ID.
40     *
41     * @param $page string page ID.
42     */
43    public function __construct($page)
44    {
45        $this->id = $page;
46        $this->url = wl($page, '', true);
47        $this->author = p_get_metadata($page)['last_change']['user'];
48        $date = new DateTime();
49        $this->lastEdit = $date->setTimestamp(p_get_metadata($page)['last_change']['date']);
50        $this->metadata = p_get_metadata($page);
51        // If no user was logged in, then no author is saved.
52        // DokuWiki uses '(external edit)' as value, so we use it too.
53        if (empty($this->author)) {
54            $this->author = '(external edit)';
55        }
56    }
57}