[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ChangeLog/ -> MediaChangeLog.php (source)

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