4 namespace dokuwiki\Subscriptions
;
8 use InlineDiffFormatter
;
9 use UnifiedDiffFormatter
;
11 class PageSubscriptionSender
extends SubscriptionSender
15 * Send the diff for some page change
17 * @param string $subscriber_mail The target mail address
18 * @param string $template Mail template ('subscr_digest', 'subscr_single', 'mailtext', ...)
19 * @param string $id Page for which the notification is
20 * @param int|null $rev Old revision if any
21 * @param string $summary Change summary if any
22 * @param int|null $current_rev New revision if any
24 * @return bool true if successfully sent
26 public function sendPageDiff($subscriber_mail, $template, $id, $rev = null, $summary = '', $current_rev = null)
28 global $DIFF_INLINESTYLES;
30 // prepare replacements (keys not set in hrep will be taken from trep)
33 'NEWPAGE' => wl($id, $current_rev?
('rev='.$current_rev):'', true, '&'),
34 'SUMMARY' => $summary,
35 'SUBSCRIBE' => wl($id, ['do' => 'subscribe'], true, '&'),
41 $trep['OLDPAGE'] = wl($id, "rev=$rev", true, '&');
43 $old_content = rawWiki($id, $rev);
44 $new_content = rawWiki($id);
47 explode("\n", $old_content),
48 explode("\n", $new_content)
50 $dformat = new UnifiedDiffFormatter();
51 $tdiff = $dformat->format($df);
53 $DIFF_INLINESTYLES = true;
55 explode("\n", $old_content),
56 explode("\n", $new_content)
58 $dformat = new InlineDiffFormatter();
59 $hdiff = $dformat->format($df);
60 $hdiff = '<table>' . $hdiff . '</table>';
61 $DIFF_INLINESTYLES = false;
64 $trep['OLDPAGE'] = '---';
65 $tdiff = rawWiki($id);
66 $hdiff = nl2br(hsc($tdiff));
69 $trep['DIFF'] = $tdiff;
70 $hrep['DIFF'] = $hdiff;
72 $headers = ['Message-Id' => $this->getMessageID($id)];
74 $headers['In-Reply-To'] = $this->getMessageID($id, $rev);