diff --git a/includes/class-PageYearMonthDayPDCsCount.php b/includes/class-PageYearMonthDayPDCsCount.php
index 4c7c606..d1a33ba 100644
--- a/includes/class-PageYearMonthDayPDCsCount.php
+++ b/includes/class-PageYearMonthDayPDCsCount.php
@@ -1,126 +1,157 @@
.
namespace itwikidelbot;
/**
* Abstraction of a page containing PDCs' log of the day
*/
class PageYearMonthDayPDCsCount extends PageYearMonthDayPDCs {
/**
* Template name of this page
*
* @override CategoryTemplated::TEMPLATE_NAME
*/
const TEMPLATE_NAME = 'PAGE_COUNT';
/**
* Get the template arguments:
* 1: page title
* 2: temperature
* 3: '1' if it's multiple
* 4: color associated to the PDC e.g. '#fff'
* 5: number of the row
* 6: PDC type e.g. 'consensuale'
* 7: duration e.g. 'un giorno'
* 8: title of the log page
* 9: human date 'year monthname day'
*
* @override PageTemplated::getTemplateArguments()
* @return array
*/
public function getTemplateArguments() {
$sections = [];
// runnings
$i = 0;
$entries = [];
foreach( $this->getRunningPDCsByType() as $type => $pdcs ) {
foreach( $pdcs as $pdc ) {
$entries[] = $this->createPDCEntryContent( ++$i, $pdc );
}
}
if( $entries ) {
$sections[] = Template::get( self::TEMPLATE_NAME . '.RUNNING.section', [
implode( "\n", $entries )
] );
}
// endeds
$i = 0;
$entries = [];
foreach( $this->getEndedPDCsByType() as $type => $pdcs ) {
foreach( $pdcs as $pdc ) {
$entries[] = $this->createPDCEntryContent( ++$i, $pdc );
}
}
if( $entries ) {
$sections[] = Template::get( self::TEMPLATE_NAME . '.ENDED.section', [
implode( "\n", $entries )
] );
}
+ // with some fixable errors
+ $erroneous = [];
+ foreach( $this->getPDCs() as $pdc ) {
+ if( ! $pdc->isTitleSubjectConsistent() ) {
+ $erroneous[] = self::createPDCErrorMessage( $pdc,
+ Template::get( self::TEMPLATE_NAME . '.ERRONEOUS.msg.sortkey', [
+ $pdc->getTitleSubject()
+ ] )
+ );
+ }
+ }
+ if( $erroneous ) {
+ $sections[] = Template::get( self::TEMPLATE_NAME . '.ERRONEOUS.section', [
+ implode( "\n", $erroneous )
+ ] );
+ }
+
$args = parent::getTemplateArguments();
// Does it have content?
if( $sections ) {
$args[] = implode( "\n", $sections );
} else {
$args[] = Template::get( self::TEMPLATE_NAME . '.empty' );
}
return $args;
}
/**
* Get the PDC entry content
*
* @param $pdc PDC
* @param $i Ordinal number passed from the count page
* @return string
*/
public function createPDCEntryContent( $i, PDC $pdc ) {
$template_name = self::TEMPLATE_NAME;
$template_name .= $pdc->isRunning()
? '.RUNNING.entry'
: '.ENDED.entry';
$turnover = $pdc->getTurnover();
return Template::get( $template_name, [
$pdc->getTitleSubject(),
$pdc->getTemperature(),
$pdc->isMultiple(),
'', // TODO: Ex color. Now unuseful.
$i,
$pdc->getHumanType(),
$pdc->getHumanDuration(),
$this->getTitle(),
sprintf( '%d %s %d',
$this->getYear(),
$this->getMonthName(),
$this->getDay()
),
$turnover ? $turnover : '',
implode( ', ', $pdc->getSubjectThemes() )
] );
}
+ /**
+ * Create a PDC error message
+ *
+ * @param $pdc object
+ * @param $message string
+ * @return string
+ */
+ public static function createPDCErrorMessage( $pdc, $message ) {
+ return Template::get( self::TEMPLATE_NAME . '.ERRONEOUS.entry', [
+ $pdc->getTitle(),
+ $message,
+ ] );
+ }
+
}
diff --git a/templates/PAGE_COUNT.ERRONEOUS.entry.tpl b/templates/PAGE_COUNT.ERRONEOUS.entry.tpl
new file mode 100644
index 0000000..d8ec7cb
--- /dev/null
+++ b/templates/PAGE_COUNT.ERRONEOUS.entry.tpl
@@ -0,0 +1,12 @@
+
+This is the template for a single erroneous PDC entry.
+
+Placeholders:
+ %1$s: PDC title
+ %2$s: error message
+
+
+;[[Wikipedia:Pagine da cancellare/Esempio]]: Ricontrollare cose.
+
+
+;[[%1$s]]: %2$s
diff --git a/templates/PAGE_COUNT.ERRONEOUS.msg.sortkey.tpl b/templates/PAGE_COUNT.ERRONEOUS.msg.sortkey.tpl
new file mode 100644
index 0000000..7501697
--- /dev/null
+++ b/templates/PAGE_COUNT.ERRONEOUS.msg.sortkey.tpl
@@ -0,0 +1,10 @@
+
+This is the template for the error message of a PDC when it has a wrong category sortkey.
+
+Please do not insert newlines.
+
+Placeholders:
+ %1$s: actual category sortkey
+
+
+Rilevata inconsistenza (forse dovuta ad uno spostamento). L'attuale valore di DEFAULTSORT รจ %s ma non corrisponde con il titolo della pagina. Correggi il valore di DEFAULTSORT ed eventualmente anche il valore del template {{Cancellazione/proposta}}.
diff --git a/templates/PAGE_COUNT.ERRONEOUS.section.tpl b/templates/PAGE_COUNT.ERRONEOUS.section.tpl
new file mode 100644
index 0000000..8b7b186
--- /dev/null
+++ b/templates/PAGE_COUNT.ERRONEOUS.section.tpl
@@ -0,0 +1,10 @@
+
+This is the template for a section of erroneous PDCs.
+
+Placeholders:
+ %1$s: errors
+
+
+'''Attenzione:''' Sono state rilevate alcune PDC con errori:
+
+%1$s