| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\Thanks; |
| 4 |
|
| 5 |
use Flow\Notifications\FlowPresentationModel; |
| 6 |
use MediaWiki\Language\RawMessage; |
| 7 |
use MediaWiki\Title\Title; |
| 8 |
|
| 9 |
class EchoFlowThanksPresentationModel extends FlowPresentationModel { |
| 10 |
public function canRender() { |
| 11 |
return (bool)$this->event->getTitle(); |
| 12 |
} |
| 13 |
|
| 14 |
public function getIconType() { |
| 15 |
return 'thanks'; |
| 16 |
} |
| 17 |
|
| 18 |
public function getHeaderMessage() { |
| 19 |
if ( $this->isBundled() ) { |
| 20 |
$msg = $this->msg( 'notification-bundle-header-flow-thank' ); |
| 21 |
$msg->params( $this->getBundleCount() ); |
| 22 |
$msg->plaintextParams( $this->getTopicTitle() ); |
| 23 |
$msg->params( $this->getViewingUserForGender() ); |
| 24 |
return $msg; |
| 25 |
} else { |
| 26 |
|
| 27 |
|
| 28 |
$msg = parent::getHeaderMessage(); |
| 29 |
$msg->plaintextParams( $this->getTopicTitle() ); |
| 30 |
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) ); |
| 31 |
$msg->params( $this->getViewingUserForGender() ); |
| 32 |
return $msg; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
public function getCompactHeaderMessage() { |
| 37 |
|
| 38 |
|
| 39 |
$msg = parent::getCompactHeaderMessage(); |
| 40 |
$msg->params( $this->getViewingUserForGender() ); |
| 41 |
return $msg; |
| 42 |
} |
| 43 |
|
| 44 |
public function getBodyMessage() { |
| 45 |
$excerpt = $this->event->getExtraParam( 'excerpt' ); |
| 46 |
if ( $excerpt ) { |
| 47 |
$msg = new RawMessage( '$1' ); |
| 48 |
$msg->plaintextParams( $excerpt ); |
| 49 |
return $msg; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
public function getPrimaryLink() { |
| 54 |
$title = Title::makeTitleSafe( NS_TOPIC, $this->event->getExtraParam( 'workflow' ) ); |
| 55 |
if ( !$title ) { |
| 56 |
|
| 57 |
|
| 58 |
$title = $this->event->getTitle(); |
| 59 |
} |
| 60 |
|
| 61 |
$title = $title->createFragmentTarget( 'flow-post-' . $this->event->getExtraParam( 'post-id' ) ); |
| 62 |
|
| 63 |
return [ |
| 64 |
'url' => $title->getFullURL(), |
| 65 |
'label' => $this->msg( 'notification-link-text-view-post' )->text(), |
| 66 |
]; |
| 67 |
} |
| 68 |
|
| 69 |
public function getSecondaryLinks() { |
| 70 |
if ( $this->isBundled() ) { |
| 71 |
return [ $this->getBoardLink() ]; |
| 72 |
} else { |
| 73 |
return [ $this->getAgentLink(), $this->getBoardLink() ]; |
| 74 |
} |
| 75 |
} |
| 76 |
} |