75 private Config $mainConfig;
89 $this->editor = $services->getUserFactory()->newFromAuthority(
$editor );
91 $this->oldid = $recentChange->
getAttribute(
'rc_last_oldid' );
92 $this->minorEdit = $recentChange->
getAttribute(
'rc_minor' );
93 $this->timestamp = $recentChange->
getAttribute(
'rc_timestamp' );
94 $this->summary = $recentChange->
getAttribute(
'rc_comment' );
98 $this->mainConfig = $services->getMainConfig();
99 $this->userOptionsLookup = $services->getUserOptionsLookup();
100 $this->urlUtils = $services->getUrlUtils();
101 $this->messageParser = $services->getMessageParser();
102 $this->contentLanguage = $services->getContentLanguage();
103 $this->emailer = $services->getEmailer();
109 private function composeCommonMailtext() {
110 $this->composed_common =
true;
112 # You as the WikiAdmin and Sysops can make use of plenty of
113 # named variables when composing your notification emails while
114 # simply editing the Meta pages
117 $postTransformKeys = [];
118 $pageTitleUrl = $this->title->getCanonicalURL();
119 $pageTitle = $this->title->getPrefixedText();
121 if ( $this->oldid ) {
125 $this->title->getCanonicalURL( [
'diff' =>
'next',
'oldid' => $this->oldid ] )
126 )->inContentLanguage()->text();
131 'enotif_lastvisited',
132 $this->title->getCanonicalURL( [
'diff' =>
'0',
'oldid' => $this->oldid ] )
133 )->inContentLanguage()->text();
135 $keys[
'$PAGELOG'] =
'';
138 $keys[
'$OLDID'] =
'';
139 $keys[
'$NEWPAGE'] =
'';
143 $this->title->getPrefixedDBkey() ] )
144 )->inContentLanguage()->text();
147 $keys[
'$PAGETITLE'] = $this->title->getPrefixedText();
148 $keys[
'$PAGETITLE_URL'] = $this->title->getCanonicalURL();
149 $keys[
'$PAGEMINOREDIT'] = $this->minorEdit ?
150 "\n\n" .
wfMessage(
'enotif_minoredit' )->inContentLanguage()->text() :
152 $keys[
'$UNWATCHURL'] = $this->title->getCanonicalURL(
'action=unwatch' );
154 if ( $this->editor->isAnon() ) {
155 # real anon (user:xxx.xxx.xxx.xxx)
156 $keys[
'$PAGEEDITOR'] =
wfMessage(
'enotif_anon_editor', $this->editor->getName() )
157 ->inContentLanguage()->text();
158 $keys[
'$PAGEEDITOR_EMAIL'] =
wfMessage(
'noemailtitle' )->inContentLanguage()->text();
159 } elseif ( $this->editor->isTemp() ) {
160 $keys[
'$PAGEEDITOR'] =
wfMessage(
'enotif_temp_editor', $this->editor->getName() )
161 ->inContentLanguage()->text();
162 $keys[
'$PAGEEDITOR_EMAIL'] =
wfMessage(
'noemailtitle' )->inContentLanguage()->text();
165 $this->editor->getRealName() !==
''
166 ? $this->editor->getRealName() : $this->editor->getName();
168 $keys[
'$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL();
171 $keys[
'$PAGEEDITOR_WIKI'] = $this->editor->getTalkPage()->getCanonicalURL();
172 $keys[
'$HELPPAGE'] = $this->urlUtils->expand(
173 Skin::makeInternalOrExternalUrl(
wfMessage(
'helppage' )->inContentLanguage()->text() ),
177 # Replace this after transforming the message, T37019
178 $postTransformKeys[
'$PAGESUMMARY'] = $this->summary ==
'' ?
' - ' :
$this->summary;
185 $this->subject =
wfMessage(
'enotif_subject_' . $this->pageStatus )->inContentLanguage()
186 ->params( $pageTitle, $keys[
'$PAGEEDITOR'] )->text();
191 $keys[
'$PAGEINTRO'] =
wfMessage(
'enotif_body_intro_' . $this->pageStatus )
192 ->inContentLanguage()
193 ->params( $pageTitle, $keys[
'$PAGEEDITOR'],
"<{$pageTitleUrl}>" )
198 $body = $this->messageParser->transform(
$body,
false,
null, $this->title );
199 $this->body = wordwrap( strtr(
$body, $postTransformKeys ), 72 );
201 # Reveal the page editor's address as REPLY-TO address only if
202 # the user has not opted-out and the option is enabled at the
203 # global configuration level.
204 $adminAddress =
new MailAddress(
206 wfMessage(
'emailsender' )->inContentLanguage()->text()
209 && ( $this->editor->getEmail() !=
'' )
210 && $this->userOptionsLookup->getOption( $this->editor,
'enotifrevealaddr' )
212 $editorAddress = MailAddress::newFromUser( $this->editor );
214 $this->from = $editorAddress;
216 $this->from = $adminAddress;
217 $this->replyto = $editorAddress;
220 $this->from = $adminAddress;
221 $this->replyto =
new MailAddress(
234 if ( !$this->composed_common ) {
235 $this->composeCommonMailtext();
242 $to = MailAddress::newFromUser( $watchingUser );
244 # $PAGEEDITDATE is the time and date of the page change
245 # expressed in terms of individual local time of the notification
246 # recipient, i.e. watching user
247 $watchingUserName = (
259 $this->contentLanguage->userDate( $this->timestamp, $watchingUser->
getUser() ),
260 $this->contentLanguage->userTime( $this->timestamp, $watchingUser->
getUser() )
266 if (
$source === self::WATCHLIST ) {
267 $headers[
'List-Help'] =
'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Watchlist';
270 $this->emailer->send(
277 'replyTo' => $this->replyto,
278 'headers' => $headers,