Debian Codegraph @

extensions/Thanks/includes/EchoFlowThanksPresentationModel.php

raw symbols SCIP
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 // The following message is used here:
27 // * notification-header-flow-thank
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 // The following message is used here:
38 // * notification-compact-header-flow-thank
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 // Workflow IDs that are invalid titles should never happen; we can try
57 // falling back on the page title and hope the #flow-post- anchor will be there.
58 $title = $this->event->getTitle();
59 }
60 // Make a link to #flow-post-{postid}
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 }