DynamicPageList3/includes/lister/OrderedList.php

66 lines
1.4 KiB
PHP
Raw Normal View History

2020-11-22 20:03:02 +00:00
<?php
namespace DPL\Lister;
class OrderedList extends UnorderedList {
/**
* Listing style for this class.
*
2021-10-01 22:52:30 +00:00
* @var int
2020-11-22 20:03:02 +00:00
*/
public $style = parent::LIST_ORDERED;
/**
* List(Section) Start
*
2021-02-22 23:48:01 +00:00
* @var string
2020-11-22 20:03:02 +00:00
*/
public $listStart = '<ol%s>';
/**
* List(Section) End
*
2021-02-22 23:48:01 +00:00
* @var string
2020-11-22 20:03:02 +00:00
*/
public $listEnd = '</ol>';
/**
* Offset Count
*
2021-02-22 23:48:01 +00:00
* @var int
2020-11-22 20:03:02 +00:00
*/
private $offsetCount = 0;
/**
* Format the list of articles.
*
2021-10-01 22:52:30 +00:00
* @param array $articles
* @param int $start
* @param int $count
* @return string
2020-11-22 20:03:02 +00:00
*/
2021-02-22 23:48:01 +00:00
public function formatList( $articles, $start, $count ) {
2020-11-22 20:03:02 +00:00
$this->offsetCount = $count;
2021-10-01 22:52:30 +00:00
2021-02-22 23:48:01 +00:00
return parent::formatList( $articles, $start, $count );
2020-11-22 20:03:02 +00:00
}
/**
* Return $this->listStart with attributes replaced.
*
2021-10-01 22:52:30 +00:00
* @return string
2020-11-22 20:03:02 +00:00
*/
public function getListStart() {
// increase start value of ordered lists at multi-column output
2021-10-01 22:52:30 +00:00
// The offset that comes from the URL parameter is zero based, but has to be +1'ed for display.
2021-02-22 23:48:01 +00:00
$offset = $this->getParameters()->getParameter( 'offset' ) + 1;
2020-11-22 20:03:02 +00:00
2021-02-22 23:48:01 +00:00
if ( $offset != 0 ) {
2021-10-01 22:52:30 +00:00
// @TODO: So this adds the total count of articles to the offset. I have not found a case where this does not mess up the displayed count. I am commenting this out for now.
// $offset += $this->offsetCount;
2020-11-22 20:03:02 +00:00
}
2021-02-22 23:48:01 +00:00
return sprintf( $this->listStart, $this->listAttributes . ' start="' . $offset . '"' );
2020-11-22 20:03:02 +00:00
}
}