diff --git a/includes/class-PageYearMonthDayPDCsLog.php b/includes/class-PageYearMonthDayPDCsLog.php index 179c6af..e995b3c 100644 --- a/includes/class-PageYearMonthDayPDCsLog.php +++ b/includes/class-PageYearMonthDayPDCsLog.php @@ -1,67 +1,89 @@ . namespace itwikidelbot; /** * Abstraction of a page containing PDCs daily log * * e.g. https://it.wikipedia.org/wiki/Wikipedia:Pagine_da_cancellare/Conta/2017_aprile_20 */ class PageYearMonthDayPDCsLog extends PageYearMonthDayPDCs { /** * Template name of this page * * @override CategoryTemplated::TEMPLATE_NAME */ const TEMPLATE_NAME = 'PAGE_LOG'; /** * Get the template arguments * * @override PageTemplated::getTemplateArguments() * @return array */ public function getTemplateArguments() { $args = parent::getTemplateArguments(); + $protecteds = []; + + // first running PDCs $sections = []; foreach( $this->getPDCsByType() as $pdcs ) { if( $pdcs ) { - $type = reset( $pdcs )->getType(); - // call the entry template for each PDC $entries = []; foreach( $pdcs as $pdc ) { - $entries[] = "{{" . $pdc->getTitle() . "}}"; + if( $pdc->isProtected() ) { + // skip + $protecteds[] = $pdc; + } else { + $entries[] = "{{" . $pdc->getTitle() . "}}"; + } } // call the section template for each PDC type - $entries_txt = implode( "\n", $entries ); - $sections[] = Template::get( self::TEMPLATE_NAME . '.section', [ - $pdc->getType(), - $entries_txt - ] ); + if( $entries ) { + $entries_txt = implode( "\n", $entries ); + $sections[] = Template::get( self::TEMPLATE_NAME . '.section', [ + $pdc->getType(), + $entries_txt + ] ); + } } } + // then ended PDCs + $entries = []; + foreach( $protecteds as $pdc ) { + // call the entry template for each PDC + $entries[] = "{{" . $pdc->getTitle() . "}}"; + } + if( $entries ) { + $entries_txt = implode( "\n", $entries ); + $sections[] = Template::get( self::TEMPLATE_NAME . '.section', [ + 'concluse/annullate', + $entries_txt + ] ); + } + $args[] = implode( "\n", $sections ); return $args; } }