Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 32 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| EchoFlowThanksPresentationModel | |
0.00% |
0 / 32 |
|
0.00% |
0 / 7 |
132 | |
0.00% |
0 / 1 |
| canRender | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getIconType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getHeaderMessage | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 | |||
| getCompactHeaderMessage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getBodyMessage | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| getPrimaryLink | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| getSecondaryLinks | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 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 | /** @inheritDoc */ |
| 11 | public function canRender() { |
| 12 | return (bool)$this->event->getTitle(); |
| 13 | } |
| 14 | |
| 15 | /** @inheritDoc */ |
| 16 | public function getIconType() { |
| 17 | return 'thanks'; |
| 18 | } |
| 19 | |
| 20 | /** @inheritDoc */ |
| 21 | public function getHeaderMessage() { |
| 22 | if ( $this->isBundled() ) { |
| 23 | $msg = $this->msg( 'notification-bundle-header-flow-thank' ); |
| 24 | $msg->params( $this->getBundleCount() ); |
| 25 | $msg->plaintextParams( $this->getTopicTitle() ); |
| 26 | $msg->params( $this->getViewingUserForGender() ); |
| 27 | return $msg; |
| 28 | } else { |
| 29 | // The following message is used here: |
| 30 | // * notification-header-flow-thank |
| 31 | $msg = parent::getHeaderMessage(); |
| 32 | $msg->plaintextParams( $this->getTopicTitle() ); |
| 33 | $msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) ); |
| 34 | $msg->params( $this->getViewingUserForGender() ); |
| 35 | return $msg; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | /** @inheritDoc */ |
| 40 | public function getCompactHeaderMessage() { |
| 41 | // The following message is used here: |
| 42 | // * notification-compact-header-flow-thank |
| 43 | $msg = parent::getCompactHeaderMessage(); |
| 44 | $msg->params( $this->getViewingUserForGender() ); |
| 45 | return $msg; |
| 46 | } |
| 47 | |
| 48 | /** @inheritDoc */ |
| 49 | public function getBodyMessage() { |
| 50 | $excerpt = $this->event->getExtraParam( 'excerpt' ); |
| 51 | if ( $excerpt ) { |
| 52 | $msg = new RawMessage( '$1' ); |
| 53 | $msg->plaintextParams( $excerpt ); |
| 54 | return $msg; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | /** @inheritDoc */ |
| 59 | public function getPrimaryLink() { |
| 60 | $title = Title::makeTitleSafe( NS_TOPIC, $this->event->getExtraParam( 'workflow' ) ); |
| 61 | if ( !$title ) { |
| 62 | // Workflow IDs that are invalid titles should never happen; we can try |
| 63 | // falling back on the page title and hope the #flow-post- anchor will be there. |
| 64 | $title = $this->event->getTitle(); |
| 65 | } |
| 66 | // Make a link to #flow-post-{postid} |
| 67 | $title = $title->createFragmentTarget( 'flow-post-' . $this->event->getExtraParam( 'post-id' ) ); |
| 68 | |
| 69 | return [ |
| 70 | 'url' => $title->getFullURL(), |
| 71 | 'label' => $this->msg( 'notification-link-text-view-post' )->text(), |
| 72 | ]; |
| 73 | } |
| 74 | |
| 75 | /** @inheritDoc */ |
| 76 | public function getSecondaryLinks() { |
| 77 | if ( $this->isBundled() ) { |
| 78 | return [ $this->getBoardLink() ]; |
| 79 | } else { |
| 80 | return [ $this->getAgentLink(), $this->getBoardLink() ]; |
| 81 | } |
| 82 | } |
| 83 | } |