mediawiki-extensions-Echo/includes/formatters/RevertedPresentationModel.php
Matthias Mullie 3f65ed519f Use current (with keys) array format for primary & secondary links
They're currently auto-converted to the new format, but ideally,
we wouldn't need that B/C code. And since this is the extension
others will likely look at for examples when implementing, we
should do it right here.

Also: there is no B/C correction for missing keys in secondary
links (description, icon).

Change-Id: If1a8b9911e81bb4c565f21a4b9e31fdc73426d93
2015-12-16 17:52:04 +01:00

46 lines
1,023 B
PHP

<?php
class EchoRevertedPresentationModel extends EchoEventPresentationModel {
public function getIconType() {
return 'revert';
}
public function canRender() {
return (bool)$this->event->getTitle();
}
public function getHeaderMessage() {
$msg = parent::getHeaderMessage();
$msg->params( $this->event->getTitle()->getPrefixedText() );
$msg->params( $this->getNumberOfEdits() );
return $msg;
}
public function getPrimaryLink() {
$url = $this->event->getTitle()->getLocalURL( array(
'oldid' => 'prev',
'diff' => $this->event->getExtraParam( 'revid' )
) );
return array(
'url' => $url,
'label' => $this->msg( 'notification-link-text-view-changes' )->text()
);
}
/**
* Return a number that represents if one or multiple edits
* have been reverted for formatting purposes.
* @return int
*/
private function getNumberOfEdits() {
$method = $this->event->getExtraParam( 'method' );
if ( $method && $method === 'rollback' ) {
return 2;
} else {
return 1;
}
}
}