You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

69 lines
1.7 KiB

  1. <?php
  2. namespace dokuwiki\ChangeLog;
  3. /**
  4. * Class MediaChangeLog; handles changelog of a media file
  5. */
  6. class MediaChangeLog extends ChangeLog
  7. {
  8. /**
  9. * Returns path to changelog
  10. *
  11. * @return string path to file
  12. */
  13. protected function getChangelogFilename()
  14. {
  15. return mediaMetaFN($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 mediaFN($this->id, $rev);
  26. }
  27. /**
  28. * Returns mode
  29. *
  30. * @return string RevisionInfo::MODE_PAGE
  31. */
  32. protected function getMode()
  33. {
  34. return RevisionInfo::MODE_MEDIA;
  35. }
  36. /**
  37. * Adds an entry to the changelog
  38. *
  39. * @param array $info Revision info structure of a media file
  40. * @param int $timestamp log line date (optional)
  41. * @return array revision info of added log line
  42. *
  43. * @see also addMediaLogEntry() in inc/changelog.php file
  44. */
  45. public function addLogEntry(array $info, $timestamp = null)
  46. {
  47. global $conf;
  48. if (isset($timestamp)) unset($this->cache[$this->id][$info['date']]);
  49. // add changelog lines
  50. $logline = static::buildLogLine($info, $timestamp);
  51. io_saveFile(mediaMetaFN($this->id, '.changes'), $logline, $append = true);
  52. io_saveFile($conf['media_changelog'], $logline, $append = true); //global changelog cache
  53. // update cache
  54. $this->currentRevision = $info['date'];
  55. $info['mode'] = $this->getMode();
  56. $this->cache[$this->id][$this->currentRevision] = $info;
  57. return $info;
  58. }
  59. }