id = $id; $this->setChangeLog(); } /** * set class property changelog */ abstract protected function setChangeLog(); /** * item filename resolver * * @param string $id page id or media id * @param int|string $rev revision timestamp, or empty string for current one * @return string full path */ abstract protected function itemFN($id, $rev = ''); /** * Get revisions, and set correct pagenation parameters (first, hasNext) * * @param int $first * @param bool $hasNext * @return array revisions to be shown in a pagenated list * @see also https://www.dokuwiki.org/devel:changelog */ protected function getRevisions(&$first, &$hasNext) { global $conf; $changelog =& $this->changelog; $revisions = []; $extEditRevInfo = $changelog->getExternalEditRevInfo(); /* we need to get one additional log entry to be able to * decide if this is the last page or is there another one. * @see Ui\Recent::getRecents() as well */ $num = $conf['recent']; if ($first == 0) { $num = $extEditRevInfo ? $num - 1 : $num; } $revlist = $changelog->getRevisions($first-1, $num +1 ); if (count($revlist) == 0 && $first != 0) { $first = 0; $num = $extEditRevInfo ? $num - 1 : $num; $revlist = $changelog->getRevisions(-1, $num + 1); } if ($first == 0 && $extEditRevInfo) { $revisions[] = $extEditRevInfo + [ 'item' => $this->item, 'current' => true, ]; } // decide if this is the last page or is there another one $hasNext = false; if (count($revlist) > $num) { $hasNext = true; array_pop($revlist); // remove one additional log entry } // append each revison info array to the revisions $fileLastMod = $this->itemFN($this->id); $lastMod = @filemtime($fileLastMod); // from wiki page, suppresses warning in case the file not exists foreach ($revlist as $rev) { $more = ['item' => $this->item]; if ($rev == $lastMod) { $more['current'] = true; } $revisions[] = $changelog->getRevisionInfo($rev) + $more; } return $revisions; } /** * Navigation buttons for Pagenation (prev/next) * * @param int $first * @param bool $hasNext * @param callable $callback returns array of hidden fields for the form button * @return string html */ protected function navigation($first, $hasNext, $callback) { global $conf; $html = '