mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 09:40:41 +00:00
Merge "Improve EchoPresentationModelSection"
This commit is contained in:
commit
a37ecff5df
|
@ -8,12 +8,12 @@ use MediaWiki\Revision\RevisionRecord;
|
||||||
class EchoPresentationModelSection {
|
class EchoPresentationModelSection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string|false|null
|
||||||
*/
|
*/
|
||||||
private $rawSectionTitle = null;
|
private $rawSectionTitle = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string|false|null
|
||||||
*/
|
*/
|
||||||
private $parsedSectionTitle = null;
|
private $parsedSectionTitle = null;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class EchoPresentationModelSection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the raw (unparsed) section title
|
* Get the raw (unparsed) section title
|
||||||
* @return string Section title
|
* @return string|false Section title
|
||||||
*/
|
*/
|
||||||
private function getRawSectionTitle() {
|
private function getRawSectionTitle() {
|
||||||
if ( $this->rawSectionTitle !== null ) {
|
if ( $this->rawSectionTitle !== null ) {
|
||||||
|
@ -70,7 +70,7 @@ class EchoPresentationModelSection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the section title parsed to plain text
|
* Get the section title parsed to plain text
|
||||||
* @return string Section title (plain text)
|
* @return string|false Section title (plain text)
|
||||||
*/
|
*/
|
||||||
private function getParsedSectionTitle() {
|
private function getParsedSectionTitle() {
|
||||||
if ( $this->parsedSectionTitle !== null ) {
|
if ( $this->parsedSectionTitle !== null ) {
|
||||||
|
@ -109,17 +109,18 @@ class EchoPresentationModelSection {
|
||||||
public function getTitleWithSection() {
|
public function getTitleWithSection() {
|
||||||
$title = $this->event->getTitle();
|
$title = $this->event->getTitle();
|
||||||
$section = $this->getParsedSectionTitle();
|
$section = $this->getParsedSectionTitle();
|
||||||
$fragment = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 );
|
|
||||||
if ( $section ) {
|
if ( $section ) {
|
||||||
$title = Title::makeTitle(
|
$fragment = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 );
|
||||||
$title->getNamespace(),
|
$title = $title->createFragmentTarget( $fragment );
|
||||||
$title->getDBkey(),
|
|
||||||
$fragment
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get truncated section title, according to user's language.
|
||||||
|
* You should only call this if EchoPresentationModelSection::exists returns true.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getTruncatedSectionTitle() {
|
public function getTruncatedSectionTitle() {
|
||||||
return $this->language->embedBidi( $this->language->truncateForVisual(
|
return $this->language->embedBidi( $this->language->truncateForVisual(
|
||||||
$this->getParsedSectionTitle(),
|
$this->getParsedSectionTitle(),
|
||||||
|
|
Loading…
Reference in a new issue