xref: /dokuwiki/inc/ChangeLog/PageChangeLog.php (revision 8e7694e09b852a01b431ebce2c1c99e4945f23b8)
1<?php
2
3namespace dokuwiki\ChangeLog;
4
5/**
6 * Class PageChangeLog; handles changelog of a wiki page
7 */
8class PageChangeLog extends ChangeLog
9{
10
11    /**
12     * Returns path to changelog
13     *
14     * @return string path to file
15     */
16    protected function getChangelogFilename()
17    {
18        return metaFN($this->id, '.changes');
19    }
20
21    /**
22     * Returns path to current page/media
23     *
24     * @param string|int $rev empty string or revision timestamp
25     * @return string path to file
26     */
27    protected function getFilename($rev = '')
28    {
29        return wikiFN($this->id, $rev);
30    }
31
32
33
34    /**
35     * Adds an entry to the changelog
36     *
37     * @param array $info    Revision info structure of a page
38     * @param int $timestamp logline date (optional)
39     * @return array revision info of added logline
40     *
41     * @see also addLogEntry() in inc/changelog.php file
42     */
43    public function addLogEntry(array $info, $timestamp = null)
44    {
45        global $conf;
46
47        if (isset($timestamp)) unset($this->cache[$this->id][$info['date']]);
48
49        // add changelog lines
50        $logline = $this->buildLogLine($info, $timestamp);
51        io_saveFile(metaFN($this->id,'.changes'), $logline, $append = true);
52        io_saveFile($conf['changelog'], $logline, $append = true); //global changelog cache
53
54        // update cache
55        $this->currentRevision = $info['date'];
56        $this->cache[$this->id][$this->currentRevision] = $info;
57        return $info;
58    }
59
60}
61