PageChangeLog.php 1.4 KB

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