| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
namespace MediaWiki\Extension\DiscussionTools\Notifications; |
| 11 |
|
| 12 |
use MediaWiki\Extension\Notifications\DiscussionParser; |
| 13 |
use MediaWiki\Extension\Notifications\Formatters\EchoPresentationModelSection; |
| 14 |
use RuntimeException; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
class PlaintextEchoPresentationModelSection extends EchoPresentationModelSection { |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
protected function getParsedSectionTitle() { |
| 29 |
$plaintext = $this->getRawSectionTitle(); |
| 30 |
if ( !$plaintext ) { |
| 31 |
return false; |
| 32 |
} |
| 33 |
$plaintext = trim( $plaintext ); |
| 34 |
return $this->language->truncateForVisual( $plaintext, DiscussionParser::DEFAULT_SNIPPET_LENGTH ); |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public function getTitleWithSection() { |
| 41 |
$title = $this->event->getTitle(); |
| 42 |
if ( $title === null ) { |
| 43 |
throw new RuntimeException( 'Event #' . $this->event->getId() . ' with no title' ); |
| 44 |
} |
| 45 |
$section = $this->getParsedSectionTitle(); |
| 46 |
if ( $section ) { |
| 47 |
$title = $title->createFragmentTarget( $section ); |
| 48 |
} |
| 49 |
return $title; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public function getTruncatedSectionTitle() { |
| 59 |
if ( $this->exists() ) { |
| 60 |
return parent::getTruncatedSectionTitle(); |
| 61 |
} |
| 62 |
|
| 63 |
return wfMessage( 'discussiontools-notification-topic-hidden' )->inLanguage( $this->language )->text(); |
| 64 |
} |
| 65 |
} |