[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Subscriptions/ -> MediaSubscriptionSender.php (source)

   1  <?php
   2  
   3  namespace dokuwiki\Subscriptions;
   4  
   5  class MediaSubscriptionSender extends SubscriptionSender
   6  {
   7      /**
   8       * Send the diff for some media change
   9       *
  10       * @fixme this should embed thumbnails of images in HTML version
  11       *
  12       * @param string   $subscriber_mail The target mail address
  13       * @param string   $template        Mail template ('uploadmail', ...)
  14       * @param string   $id              Media file for which the notification is
  15       * @param int|bool $rev             Old revision if any
  16       * @param int|bool $current_rev     New revision if any
  17       */
  18      public function sendMediaDiff($subscriber_mail, $template, $id, $rev = false, $current_rev = false)
  19      {
  20          global $conf;
  21  
  22          $file = mediaFN($id);
  23          [$mime, /* ext */] = mimetype($id);
  24  
  25          $trep = [
  26              'MIME' => $mime,
  27              'MEDIA' => ml($id, $current_rev ? ('rev=' . $current_rev) : '', true, '&', true),
  28              'SIZE' => filesize_h(filesize($file)),
  29          ];
  30  
  31          if ($rev && $conf['mediarevisions']) {
  32              $trep['OLD'] = ml($id, "rev=$rev", true, '&', true);
  33          } else {
  34              $trep['OLD'] = '---';
  35          }
  36  
  37          $headers = ['Message-Id' => $this->getMessageID($id, @filemtime($file))];
  38          if ($rev) {
  39              $headers['In-Reply-To'] = $this->getMessageID($id, $rev);
  40          }
  41  
  42          $this->send($subscriber_mail, 'upload', $id, $template, $trep, null, $headers);
  43      }
  44  }