diff --git a/includes/class-CategoryYear.php b/includes/class-CategoryYear.php index 51ddf62..d3efbfa 100644 --- a/includes/class-CategoryYear.php +++ b/includes/class-CategoryYear.php @@ -1,48 +1,40 @@ . namespace itwikidelbot; /** * Handle a yearly category * * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_-_2017 */ class CategoryYear extends PageYear { /** * Template name of this category * * @override CategoryTemplated::TEMPLATE_NAME */ const TEMPLATE_NAME = 'CATEGORY_YEAR'; - /** - * Template arguments - * - * @override CategoryTemplated::getTemplateArguments() - */ - public function getTemplateArguments() { - return [ $this->getYear() ]; - } } diff --git a/includes/class-CategoryYearMonth.php b/includes/class-CategoryYearMonth.php index c898840..b4fc392 100644 --- a/includes/class-CategoryYearMonth.php +++ b/includes/class-CategoryYearMonth.php @@ -1,54 +1,53 @@ . namespace itwikidelbot; /** * Handle a monthly category * * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_-_aprile_2018 */ class CategoryYearMonth extends PageYearMonth { /** * Template name of this category * * @override CategoryTemplated::TEMPLATE_NAME */ const TEMPLATE_NAME = 'CATEGORY_MONTH'; /** * Template arguments * * @override CategoryTemplated::getTemplateArguments() */ public function getTemplateArguments() { - return [ - ( new CategoryYear( $this->getYear() ) ) - ->getTemplatedTitle(), - $this->getYear(), - $this->getMonth(), - Months::number2name( $this->getMonth() - 1 ), - ]; + return array_merge( [ + ( new CategoryYear( $this->getYear() ) ) + ->getTemplatedTitle() + ], + parent::getTemplateArguments() + ); } } diff --git a/includes/class-CategoryYearMonthDay.php b/includes/class-CategoryYearMonthDay.php index b518d89..98a434c 100644 --- a/includes/class-CategoryYearMonthDay.php +++ b/includes/class-CategoryYearMonthDay.php @@ -1,56 +1,54 @@ . namespace itwikidelbot; /** * Handle a daily category that contains semplified PDC pages * * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_del_19_febbraio_2018 */ class CategoryYearMonthDay extends PageYearMonthDay { /** * Template name * * @override CategoryTemplated::TEMPLATE_NAME */ const TEMPLATE_NAME = 'CATEGORY_DAY'; /** * Template arguments * - * @override CategoryTemplated::getTemplateArguments() + * @override CategoryYearMonth::getTemplateArguments() */ public function getTemplateArguments() { - return [ - ( new CategoryYearMonth( $this->getYear(), $this->getMonth() ) ) - ->getTemplatedTitle(), - $this->getYear(), - $this->getMonth(), - Months::number2name( $this->getMonth() - 1 ), - $this->getDay(), - ]; + return array_merge( [ + ( new CategoryYearMonth( $this->getYear(), $this->getMonth() ) ) + ->getTemplatedTitle() + ], + parent::getTemplateArguments() + ); } } diff --git a/includes/class-PageYear.php b/includes/class-PageYear.php index af40aa5..32709d3 100644 --- a/includes/class-PageYear.php +++ b/includes/class-PageYear.php @@ -1,51 +1,60 @@ . namespace itwikidelbot; /** * Abstraction of a page related to a year */ abstract class PageYear extends PageTemplated { /** * Year * * @var int */ private $year; /** * Constructor * * @param $year int * @see PageTemplated::__construct() */ public function __construct( $year ) { $this->year = $year; parent::__construct(); } /** * Get the year * * @return int */ public function getYear() { return $this->year; } + /** + * Template arguments + * + * @override CategoryTemplated::getTemplateArguments() + */ + public function getTemplateArguments() { + return [ $this->getYear() ]; + } + } diff --git a/includes/class-PageYearMonth.php b/includes/class-PageYearMonth.php index d7cc889..5d491a8 100644 --- a/includes/class-PageYearMonth.php +++ b/includes/class-PageYearMonth.php @@ -1,52 +1,64 @@ . namespace itwikidelbot; /** * Abstraction of a page related to a month (in a certain year) */ abstract class PageYearMonth extends PageYear { /** * Month * * @var int 1-12 */ private $month; /** * Constructor * * @param $year int * @param $month int 1-12 * @see PageYear::__construct() */ public function __construct( $year, $month ) { $this->month = $month; parent::__construct( $year ); } /** * Get the month * * @return int 1-12 */ public function getMonth() { return $this->month; } + /** + * Template arguments + * + * @override PageYear::getTemplateArguments() + */ + public function getTemplateArguments() { + return array_merge( parent::getTemplateArguments(), [ + $this->getMonth(), + Months::number2name( $this->getMonth() - 1 ), + ] ); + } + } diff --git a/includes/class-PageYearMonthDay.php b/includes/class-PageYearMonthDay.php index 738e1ae..db43ba5 100644 --- a/includes/class-PageYearMonthDay.php +++ b/includes/class-PageYearMonthDay.php @@ -1,53 +1,64 @@ . namespace itwikidelbot; /** * Abstraction of a page related to a day (in a certain month of a certain year) */ abstract class PageYearMonthDay extends PageYearMonth { /** * Day * * @var int 1-31 */ private $day; /** * Constructor * * @param $year int * @param $month int 1-12 * @param $day int 1-31 * @see PageYearMonth::__construct() */ public function __construct( $year, $month, $day ) { $this->day = $day; parent::__construct( $year, $month ); } /** * Get the day * * @return int 1-13 */ public function getDay() { return $this->day; } + /** + * Template arguments + * + * @override PageYearMonth::getTemplateArguments() + */ + public function getTemplateArguments() { + return array_merge( parent::getTemplateArguments(), [ + $this->getDay() + ] ); + } + }