DynamicPageList3/includes/heading/DefinitionHeading.php

98 lines
1.7 KiB
PHP
Raw Normal View History

2020-11-22 20:02:14 +00:00
<?php
/**
* DynamicPageList3
* DPL DefinitionHeading Class
*
* @license GPL-2.0-or-later
* @package DynamicPageList3
*
2021-02-22 23:48:01 +00:00
*/
2020-11-22 20:02:14 +00:00
namespace DPL\Heading;
use DPL\Lister\Lister;
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.
*
* @access public
* @param integer Article start index for this heading.
* @param integer Article count for this heading.
* @param string Heading link/text display.
* @param array List of \DPL\Article.
* @param object List of \DPL\Lister\Lister
* @return string Heading HTML
*/
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-02-22 23:48:01 +00:00
if ( $this->showHeadingCount ) {
$item .= $this->articleCountMessage( $headingCount );
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;
}
}