2020-05-22 16:26:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools;
|
|
|
|
|
|
|
|
class HeadingItem extends ThreadItem {
|
|
|
|
private $placeholderHeading = false;
|
2020-10-01 19:36:11 +00:00
|
|
|
private $headingLevel;
|
2020-05-22 16:26:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ImmutableRange $range
|
2020-10-01 19:36:11 +00:00
|
|
|
* @param int $headingLevel Heading level (1-6)
|
2020-06-25 12:23:17 +00:00
|
|
|
* @param bool $placeholderHeading Item doesn't correspond to a real heading (e.g. 0th section)
|
2020-05-22 16:26:05 +00:00
|
|
|
*/
|
|
|
|
public function __construct(
|
2020-10-01 19:36:11 +00:00
|
|
|
ImmutableRange $range, int $headingLevel, bool $placeholderHeading = false
|
2020-05-22 16:26:05 +00:00
|
|
|
) {
|
|
|
|
parent::__construct( 'heading', 0, $range );
|
2020-10-01 19:36:11 +00:00
|
|
|
$this->headingLevel = $headingLevel;
|
2020-05-22 16:26:05 +00:00
|
|
|
$this->placeholderHeading = $placeholderHeading;
|
|
|
|
}
|
|
|
|
|
2020-09-16 12:06:14 +00:00
|
|
|
/**
|
|
|
|
* @return array JSON-serializable array
|
|
|
|
*/
|
|
|
|
public function jsonSerialize() : array {
|
|
|
|
return array_merge( parent::jsonSerialize(), [
|
2020-10-01 19:36:11 +00:00
|
|
|
'headingLevel' => $this->headingLevel,
|
2020-09-16 12:06:14 +00:00
|
|
|
'placeholderHeading' => $this->placeholderHeading,
|
|
|
|
] );
|
|
|
|
}
|
|
|
|
|
2020-10-01 19:36:11 +00:00
|
|
|
/**
|
|
|
|
* @return int Heading level (1-6)
|
|
|
|
*/
|
|
|
|
public function getHeadingLevel() : int {
|
|
|
|
return $this->headingLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $headingLevel Heading level (1-6)
|
|
|
|
*/
|
|
|
|
public function setHeadingLevel( int $headingLevel ) : void {
|
|
|
|
$this->headingLevel = $headingLevel;
|
|
|
|
}
|
|
|
|
|
2020-05-22 16:26:05 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isPlaceholderHeading() : bool {
|
|
|
|
return $this->placeholderHeading;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param bool $placeholderHeading
|
|
|
|
*/
|
|
|
|
public function setPlaceholderHeading( bool $placeholderHeading ) : void {
|
|
|
|
$this->placeholderHeading = $placeholderHeading;
|
|
|
|
}
|
|
|
|
}
|