mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
formatters: Minor cleanup
* Fix some indenting * Remove some unnecessary temporary variables Change-Id: I2330238a090b7f5ccd14d8e44aeaff10d731352e
This commit is contained in:
parent
f74cee0b4f
commit
bd062137bb
|
@ -18,18 +18,18 @@ class EchoFlyoutFormatter extends EchoEventFormatter {
|
||||||
);
|
);
|
||||||
|
|
||||||
$html = Xml::tags(
|
$html = Xml::tags(
|
||||||
'div',
|
'div',
|
||||||
[ 'class' => 'mw-echo-title' ],
|
[ 'class' => 'mw-echo-title' ],
|
||||||
$model->getHeaderMessage()->parse()
|
$model->getHeaderMessage()->parse()
|
||||||
) . "\n";
|
) . "\n";
|
||||||
|
|
||||||
$body = $model->getBodyMessage();
|
$body = $model->getBodyMessage();
|
||||||
if ( $body ) {
|
if ( $body ) {
|
||||||
$html .= Xml::tags(
|
$html .= Xml::tags(
|
||||||
'div',
|
'div',
|
||||||
[ 'class' => 'mw-echo-payload' ],
|
[ 'class' => 'mw-echo-payload' ],
|
||||||
$body->parse()
|
$body->parse()
|
||||||
) . "\n";
|
) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$ts = $this->language->getHumanTimestamp(
|
$ts = $this->language->getHumanTimestamp(
|
||||||
|
@ -63,15 +63,13 @@ class EchoFlyoutFormatter extends EchoEventFormatter {
|
||||||
$html = Xml::tags( 'div', [ 'class' => 'mw-echo-content' ], $html );
|
$html = Xml::tags( 'div', [ 'class' => 'mw-echo-content' ], $html );
|
||||||
|
|
||||||
// And then add the icon in front and wrap with mw-echo-state class.
|
// And then add the icon in front and wrap with mw-echo-state class.
|
||||||
$html = Xml::tags( 'div', [ 'class' => 'mw-echo-state' ], $icon . $html );
|
return Xml::tags( 'div', [ 'class' => 'mw-echo-state' ], $icon . $html );
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getIconURL( EchoEventPresentationModel $model ) {
|
private function getIconURL( EchoEventPresentationModel $model ) {
|
||||||
return EchoIcon::getUrl(
|
return EchoIcon::getUrl(
|
||||||
$model->getIconType(),
|
$model->getIconType(),
|
||||||
$this->language->getDir()
|
$this->language->getDir()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,11 +70,11 @@ class EchoIcon {
|
||||||
// rasterizing module
|
// rasterizing module
|
||||||
if ( $url === false || $url === null ) {
|
if ( $url === false || $url === null ) {
|
||||||
$iconUrl = wfScript( 'load' ) . '?' . wfArrayToCgi( [
|
$iconUrl = wfScript( 'load' ) . '?' . wfArrayToCgi( [
|
||||||
'modules' => 'ext.echo.emailicons',
|
'modules' => 'ext.echo.emailicons',
|
||||||
'image' => $icon,
|
'image' => $icon,
|
||||||
'lang' => $lang,
|
'lang' => $lang,
|
||||||
'format' => 'rasterized'
|
'format' => 'rasterized'
|
||||||
] );
|
] );
|
||||||
} else {
|
} else {
|
||||||
// For icons that are defined by URL
|
// For icons that are defined by URL
|
||||||
$iconUrl = $wgEchoNotificationIcons[ $icon ][ 'url' ];
|
$iconUrl = $wgEchoNotificationIcons[ $icon ][ 'url' ];
|
||||||
|
|
|
@ -111,9 +111,7 @@ class EchoEditUserTalkPresentationModel extends EchoEventPresentationModel {
|
||||||
$revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup();
|
$revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup();
|
||||||
$revisionRecord = $revisionLookup->getRevisionById( $firstNotificationRevId );
|
$revisionRecord = $revisionLookup->getRevisionById( $firstNotificationRevId );
|
||||||
$previousRevision = $revisionRecord ? $revisionLookup->getPreviousRevision( $revisionRecord ) : null;
|
$previousRevision = $revisionRecord ? $revisionLookup->getPreviousRevision( $revisionRecord ) : null;
|
||||||
$oldRevisionID = $previousRevision ? $previousRevision->getId() : 0;
|
return $previousRevision ? $previousRevision->getId() : 0;
|
||||||
|
|
||||||
return $oldRevisionID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getSubjectMessageKey() {
|
protected function getSubjectMessageKey() {
|
||||||
|
|
|
@ -251,8 +251,7 @@ abstract class EchoEventPresentationModel implements JsonSerializable, MessageLo
|
||||||
*/
|
*/
|
||||||
final protected function getNotificationCountForOutput( $includeCurrent = true, $groupCallback = null ) {
|
final protected function getNotificationCountForOutput( $includeCurrent = true, $groupCallback = null ) {
|
||||||
$count = $this->getBundleCount( $includeCurrent, $groupCallback );
|
$count = $this->getBundleCount( $includeCurrent, $groupCallback );
|
||||||
$cappedCount = EchoNotificationController::getCappedNotificationCount( $count );
|
return EchoNotificationController::getCappedNotificationCount( $count );
|
||||||
return $cappedCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,9 +27,8 @@ class EchoMentionInSummaryPresentationModel extends EchoEventPresentationModel {
|
||||||
$summary = Linker::formatComment( $summary );
|
$summary = Linker::formatComment( $summary );
|
||||||
$summary = Sanitizer::stripAllTags( $summary );
|
$summary = Sanitizer::stripAllTags( $summary );
|
||||||
|
|
||||||
$msg = $this->msg( 'notification-body-mention' )
|
return $this->msg( 'notification-body-mention' )
|
||||||
->plaintextParams( $summary );
|
->plaintextParams( $summary );
|
||||||
return $msg;
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -51,9 +50,7 @@ class EchoMentionInSummaryPresentationModel extends EchoEventPresentationModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDiffURL() {
|
private function getDiffURL() {
|
||||||
$title = $this->event->getTitle();
|
return $this->event->getTitle()->getLocalURL( [
|
||||||
|
|
||||||
return $title->getLocalURL( [
|
|
||||||
'oldid' => 'prev',
|
'oldid' => 'prev',
|
||||||
'diff' => $this->event->getExtraParam( 'revid' )
|
'diff' => $this->event->getExtraParam( 'revid' )
|
||||||
] );
|
] );
|
||||||
|
|
|
@ -98,9 +98,7 @@ class EchoMentionPresentationModel extends EchoEventPresentationModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSecondaryLinks() {
|
public function getSecondaryLinks() {
|
||||||
$title = $this->event->getTitle();
|
$url = $this->event->getTitle()->getLocalURL( [
|
||||||
|
|
||||||
$url = $title->getLocalURL( [
|
|
||||||
'oldid' => 'prev',
|
'oldid' => 'prev',
|
||||||
'diff' => $this->event->getExtraParam( 'revid' )
|
'diff' => $this->event->getExtraParam( 'revid' )
|
||||||
] );
|
] );
|
||||||
|
|
|
@ -40,18 +40,18 @@ class SpecialNotificationsFormatter extends EchoEventFormatter {
|
||||||
);
|
);
|
||||||
|
|
||||||
$html = Xml::tags(
|
$html = Xml::tags(
|
||||||
'div',
|
'div',
|
||||||
[ 'class' => 'mw-echo-title' ],
|
[ 'class' => 'mw-echo-title' ],
|
||||||
$model->getHeaderMessage()->parse()
|
$model->getHeaderMessage()->parse()
|
||||||
) . "\n";
|
) . "\n";
|
||||||
|
|
||||||
$body = $model->getBodyMessage();
|
$body = $model->getBodyMessage();
|
||||||
if ( $body ) {
|
if ( $body ) {
|
||||||
$html .= Xml::tags(
|
$html .= Xml::tags(
|
||||||
'div',
|
'div',
|
||||||
[ 'class' => 'mw-echo-payload' ],
|
[ 'class' => 'mw-echo-payload' ],
|
||||||
$body->escaped()
|
$body->escaped()
|
||||||
) . "\n";
|
) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$ts = $this->language->getHumanTimestamp(
|
$ts = $this->language->getHumanTimestamp(
|
||||||
|
@ -102,15 +102,13 @@ class SpecialNotificationsFormatter extends EchoEventFormatter {
|
||||||
// And then add the mark as read button
|
// And then add the mark as read button
|
||||||
// and the icon in front and wrap with
|
// and the icon in front and wrap with
|
||||||
// mw-echo-state class.
|
// mw-echo-state class.
|
||||||
$html = Xml::tags( 'div', [ 'class' => 'mw-echo-state' ], $markAsReadButton . $icon . $html );
|
return Xml::tags( 'div', [ 'class' => 'mw-echo-state' ], $markAsReadButton . $icon . $html );
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getIconURL( EchoEventPresentationModel $model ) {
|
private function getIconURL( EchoEventPresentationModel $model ) {
|
||||||
return EchoIcon::getUrl(
|
return EchoIcon::getUrl(
|
||||||
$model->getIconType(),
|
$model->getIconType(),
|
||||||
$this->language->getDir()
|
$this->language->getDir()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue