DynamicPageList3/includes/Heading/DefinitionHeading.php

91 lines
1.5 KiB
PHP
Raw Normal View History

2020-11-22 20:02:14 +00:00
<?php
namespace MediaWiki\Extension\DynamicPageList3\Heading;
2020-11-22 20:02:14 +00:00
use MediaWiki\Extension\DynamicPageList3\Lister\Lister;
2020-11-22 20:02:14 +00:00
class DefinitionHeading extends Heading {
/**
* Heading List Start
* Use %s for attribute placement. Example: <div%s>
*
2021-02-22 23:48:01 +00:00
* @var string
2020-11-22 20:02:14 +00:00
*/
public $headListStart = '<dt>';
/**
* Heading List End
*
2021-02-22 23:48:01 +00:00
* @var string
2020-11-22 20:02:14 +00:00
*/
public $headListEnd = '</dt>';
/**
* Heading List Start
* Use %s for attribute placement. Example: <div%s>
*
2021-02-22 23:48:01 +00:00
* @var string
2020-11-22 20:02:14 +00:00
*/
public $headItemStart = '';
/**
* Heading List End
*
2021-02-22 23:48:01 +00:00
* @var string
2020-11-22 20:02:14 +00:00
*/
public $headItemEnd = '';
/**
* List(Section) Start
*
2021-02-22 23:48:01 +00:00
* @var string
2020-11-22 20:02:14 +00:00
*/
public $listStart = '<dl%s>';
/**
* List(Section) End
*
2021-02-22 23:48:01 +00:00
* @var string
2020-11-22 20:02:14 +00:00
*/
public $listEnd = '</dl>';
/**
* Item Start
*
2021-02-22 23:48:01 +00:00
* @var string
2020-11-22 20:02:14 +00:00
*/
public $itemStart = '<dd%s>';
/**
* Item End
*
2021-02-22 23:48:01 +00:00
* @var string
2020-11-22 20:02:14 +00:00
*/
public $itemEnd = '</dd>';
/**
* Format a heading group.
*
2021-10-01 22:52:30 +00:00
* @param int $headingStart
* @param int $headingCount
* @param string $headingLink
* @param array $articles
* @param Lister $lister
* @return string
2020-11-22 20:02:14 +00:00
*/
2021-02-22 23:48:01 +00:00
public function formatItem( $headingStart, $headingCount, $headingLink, $articles, Lister $lister ) {
2020-11-22 20:02:14 +00:00
$item = '';
$item .= $this->headListStart . $headingLink;
2021-10-01 22:52:30 +00:00
2021-02-22 23:48:01 +00:00
if ( $this->showHeadingCount ) {
$item .= $this->articleCountMessage( $headingCount );
2020-11-22 20:02:14 +00:00
}
2021-10-01 22:52:30 +00:00
2020-11-22 20:02:14 +00:00
$item .= $this->headListEnd;
2021-02-22 23:48:01 +00:00
$item .= $this->getItemStart() . $lister->formatList( $articles, $headingStart, $headingCount ) . $this->getItemEnd();
2020-11-22 20:02:14 +00:00
return $item;
}
}