diff --git a/includes/class-Bot.php b/includes/class-Bot.php index 1f21529..dc449bc 100644 --- a/includes/class-Bot.php +++ b/includes/class-Bot.php @@ -1,173 +1,215 @@ . namespace itwikidelbot; use DateTime; use DateInterval; /** * The Bot class helps in running the bot */ class Bot { /** * The date * * @var DateTime */ private $dateTime; /** * A cache of already done dates. * It's an array of booleans like [year][month] = true. * * @var array */ private $cache = []; /** * Construct * * @param $date DateTime */ public function __construct( DateTime $date = null ) { if( ! $date ) { $date = new DateTime(); } $this->setDate( $date ); } /** * Static construct * * @param $date string */ public static function createFromString( $date = 'now' ) { return new self( new DateTime( $date ) ); } /** * Static construct * * @param $y int Year * @param $m int Month 1-12 * @param $d int Day 1-31 */ public static function createFromYearMonthDay( $y, $m, $d ) { return new self( DateTime::createFromFormat( "Y m d", "$y $m $d") ); } /** * Get the date * * @return DateTime */ public function getDate() { return $this->dateTime; } /** * Set the date * * @param $date DateTime * @return self */ public function setDate( DateTime $date ) { $this->dateTime = $date; } /** * Add a day * * @return self */ public function nextDay() { return $this->addDays( 1 ); } /** * Add a day * * @return self */ public function previousDay() { return $this->subDays( 1 ); } /** * Add a certain number of days * * @param $days int * @return self */ public function addDays( $days ) { $this->getDate()->add( new DateInterval( sprintf( 'P%dD', $days ) ) ); return $this; } /** * Subtract a certain number of days * * @param $days int * @return self */ public function subDays( $days ) { $this->getDate()->sub( new DateInterval( sprintf( 'P%dD', $days ) ) ); return $this; } /** * Run the bot at the internal date * * @TODO: do not repeat twice the same yearly and montly categories * @return self */ public function run() { $date = $this->getDate(); $year = $date->format( 'Y' ); $month = $date->format( 'n' ); // 1-12 $day = $date->format( 'j' ); // create the yearly category (once) $cache = & $this->cache; if( ! isset( $cache[ $year ] ) ) { $cache[ $year ] = []; ( new CategoryYear( $year ) ) ->saveIfNotExists(); } // create the monthly category (once) $cache = & $cache[ $year ]; if( ! isset( $cache[ $month ] ) ) { $cache[ $month ] = true; ( new CategoryYearMonth( $year, $month ) ) ->saveIfNotExists(); } - // create the daily category - ( new CategoryYearMonthDayTypes( $year, $month, $day ) ) - ->saveIfNotExists() - ->run(); + // PDCs indexed by page ID + $pdcs = []; + + // handle every PDC type + foreach( CategoryYearMonthDayTypes::all() as $CategoryType ) { + + // fetch PDCs from this type + $category_type = new $CategoryType( $year, $month, $day ); + $category_type_pdcs = $category_type->fetchPDCs(); + + // save the specific daily category type only if it's not empty + if( $category_type_pdcs ) { + $category_type->saveIfNotExists(); + } + + // merge the same PDCs into one + foreach( $category_type_pdcs as $category_type_pdc ) { + $id = $category_type_pdc->getID(); + if( isset( $pdcs[ $id ] ) ) { + $pdcs[ $id ]->merge( $category_type_pdc ); + } else { + $pdcs[ $id ] = $category_type_pdc; + } + } + } + + PDCs::sortByCreationDate( $pdcs ); + + // TODO: remove these debugging lines + foreach( $pdcs as $pdc ) { + if( $pdc->getDurationDays() > 7 ) { + Log::info( sprintf( + 'the PDC %s expired after %d days', + $pdc->getTitle(), + $pdc->getDurationDays() + ) ); + } + } + + $pdcs_by_type = PDCs::indexByType( $pdcs ); + + PageYearMonthDayPDCsCount::createFromDateTimePDCs( $this->getDate(), $pdcs_by_type ) + ->save(); + + PageYearMonthDayPDCsLog::createFromDateTimePDCs( $this->getDate(), $pdcs_by_type ) + ->save(); return $this; } } diff --git a/includes/class-CategoryYearMonthDay.php b/includes/class-CategoryYearMonthDay.php index acd037a..9c64791 100644 --- a/includes/class-CategoryYearMonthDay.php +++ b/includes/class-CategoryYearMonthDay.php @@ -1,69 +1,289 @@ . namespace itwikidelbot; +use \cli\Log; + /** * Handle a daily category that directly contains semplified ("semplificate") PDC pages * It contains other sub-categories. * * 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'; + /** + * PDC type + * + * The part of the category title that rappresent this type of PDC. + */ + const PDC_TYPE = 'semplificate'; + + /** + * PDC type (in an human form) + * + * Abbreviation of the PDC_TYPE. It's used in the counting page. + * + * @var string + */ + const PDC_TYPE_HUMAN = 'semplificata'; + + /** + * Title format + * + * Used to describe both the plain text title and its matching pattern. + * + * Don't use placeholders different from '%s'. + * + * Arguments: + * 1: day + * 2: month name + * 3: year + */ + const TITLE_FORMAT = 'Categoria:Cancellazioni del %s %s %s'; + + /** + * Title format arguments + * + * Arguments that can create this page title, when filling the title format. + * + * @return array Arguments for the TITLE_FORMAT + */ + protected function getTitleFormatArguments() { + return [ + $this->getDay(), // 1: day + $this->getMonthName(), // 2: month name + $this->getYear(), // 3: year + ]; + } + + /** + * Title format pattern groups + * + * Regex groups that can create a regex for this page title, when filling the title format. + * + * @return array Array of regex groups for the TITLE_FORMAT + */ + protected static function titleFormatGroups() { + return [ + '([0-9]{1,2})', // 1: day + '([a-z]+)', // 2: month name + '([0-9]{4})', // 3: year + ]; + } + + /** + * Title regex + * + * Complete regex that can match arguments (day, month, etc.) from a page title. + * + * @return string regex + */ + protected static function titleRegex() { + return '/^' . vsprintf( static::TITLE_FORMAT, static::titleFormatGroups() ) . '$/'; + } + + /** + * Get the title of this page + * + * It's obtained filling the title format with its arguments. + * + * @override PageTemplated#getTemplatedTitle() + * @return string + */ + public function getTemplatedTitle() { + return vsprintf( static::TITLE_FORMAT, $this->getTitleFormatArguments() ); + } + + /** + * Static constructor + * + * Create an CategoryYearMonthDay object extracting informations from a specific page title (if it matches the title format). + * + * @param $title string Page title to be matched + * @return self|false + */ + public static function createParsingTitle( $title ) { + if( 1 === preg_match( static::titleRegex(), $title, $matches ) ) { + + // discard the first match group: it's simply the $title itself + array_shift( $matches ); + + return static::createFromTitleFormatArguments( $matches ); + } + return false; + } + + /** + * Static constructor + * + * Create a CategoryYearMonthDay object from its title format arguments + * + * @see self::createFromTitle() + * @see PageYearMonth::__construct() + * @param $arguments Arguments for the page title format + * @return self + */ + protected static function createFromTitleFormatArguments( $arguments ) { + list( $day, $month_name, $year ) = $arguments; + return new static( + (int) $year, + Months::name2number( $month_name ) + 1, + (int) $day + ); + } + /** * Template arguments: * * 1: category title * 2: year * 3: month 1-12 * 4: month name * 5: day 1-31 * * @override CategoryYearMonth::getTemplateArguments() */ public function getTemplateArguments() { return array_merge( [ ( new CategoryYearMonth( $this->getYear(), $this->getMonth() ) ) ->getTemplatedTitle() ], parent::getTemplateArguments() ); } /** - * Does a certain specific category name match the pattern of this category? + * Fetch PDCs from this category * - * @param $category_name string - * @return bool + * @return array */ - public static function matchCategoryName( $category_name ) { - return 1 === preg_match( '/^Categoria:Cancellazioni del [0-9]+ [a-z]+ [0-9]+$/', $category_name ); + public function fetchPDCs() { + $api = self::api()->createQuery( [ + 'action' => 'query', + + // generator=categorymembers: get pages in category + // gmtitle=: specify the category title + // gmtype=page: get sub-pages + // gmsort=timestamp: order by insertion date in that category + // gmdir=asc: ascending order + // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Bcategorymembers + // Note: Generator parameter names must be prefixed with a 'g' + 'generator' => 'categorymembers', + 'gcmtitle' => $this->getTitle(), +// 'gcmtype' => 'page', // Note: Ignored when cmsort=timestamp is set. + 'gcmnamespace' => 4, // Wikipedia + 'gcmlimit' => 100, + 'gcmsort' => 'timestamp', + 'gcmdir' => 'asc', +// + // for each page load infos, categories and latest revision + // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Binfo + // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Bcategories + // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Brevisions + // Note: probably the revisions parameter is unuseful for last update date (already provided by "touched"). + // Note: revisions can be still useful to know the creation date + 'prop' => [ 'info' , 'categories'/*, 'revisions'*/ ], + + // inprop=protecion: list of the protection level of each page + // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Bcategories + 'inprop' => 'protection', + + // clprop=sortkey: adds the sortkey and sortkey prefix for the category + // clprop=timestamp: adds the timestamp of when the page was included + // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Binfo + 'clprop' => [ 'sortkey', 'timestamp' ], + + // rvprop=timestamp: timestamp of the revision + // rvlimit=1: only 1 revision + // rvdir=older: order by oldest + // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Brevisions +// 'rvprop' => 'timestamp', +// 'rvdir' => 'older', +// 'rvlimit' => 1, + ] ); + + $all = []; + while( $api->hasNext() ) { + $next = $api->fetchNext(); + + if( isset( $next->query->pages ) ) { + foreach( $next->query->pages as $page ) { + + // multiple call will add more infos on the same page + // https://www.mediawiki.org/wiki/API:Query#Generators_and_continuation + // TODO: use batchcomplete for better memory usage + $pageid = $page->pageid; + if( isset( $all[ $pageid ] ) ) { + foreach( $page as $property => $value ) { + if( isset( $all[ $pageid ]->{$property} ) && is_array( $all[ $pageid ]->{$property} ) ) { + // merge categories + $all[ $pageid ]->{$property} = array_merge( + $all[ $pageid ]->{$property}, + $value + ); + } else { + $all[ $pageid ]->{$property} = $value; + } + } + } else { + $all[ $pageid ] = $page; + } + } + } + } + + $pdcs = []; + foreach( $all as $page ) { + try { + $pdcs[] = PDC::createFromRaw( $page ); + } catch( PDCException $e ) { + Log::warn( sprintf( + "exception in PDC '%s': %s", + $page->title, + $e->getMessage() + ) ); + } + } + + return $pdcs; + } + + /** + * Get a "genericity" score of this PDC category type. + * + * @see CategoryYearMonthDayTypes::genericityFromClass() + * @return int + */ + public static function genericity() { + return CategoryYearMonthDayTypes::genericityFromClass( static::class ); } + } diff --git a/includes/class-CategoryYearMonthDayType.php b/includes/class-CategoryYearMonthDayType.php index 5e44bef..fb9fb6f 100644 --- a/includes/class-CategoryYearMonthDayType.php +++ b/includes/class-CategoryYearMonthDayType.php @@ -1,173 +1,107 @@ . namespace itwikidelbot; -use \cli\Log; - /** * Abstraction of a daily category with a specified PDC type */ abstract class CategoryYearMonthDayType extends CategoryYearMonthDay { /** * Template name of this category * * @override CategoryTemplated::TEMPLATE_NAME */ const TEMPLATE_NAME = 'CATEGORY_DAY_PDCTYPE'; /** - * PDC type e.g. 'consensuale' + * Title format * - * To be overrided - */ - const PDC_TYPE = 'EXAMPLE'; - - /** - * Get the PDC type + * Used to describe both the plain text title and its matching pattern. * - * @return string e.g. 'consensuale' + * Don't use placeholders different from '%s'. + * + * Arguments: + * 1: PDC type + * 4: day + * 3: human month + * 2: year + * + * @override CategoryYearMonthDay::TITLE_FORMAT */ - public static function getPDCType() { - return static::PDC_TYPE; - } + const TITLE_FORMAT = 'Categoria:Cancellazioni %s del %s %s %s'; /** - * Get template arguments + * Title format arguments * - * @override CategoryTemplated::getTemplateArguments() + * Arguments that can create this page title, when filling the title format. + * + * @return array Arguments for the TITLE_FORMAT + * @override CategoryYearMonthDay::getTitleFormatArguments() */ - public function getTemplateArguments() { - $parent_arguments = parent::getTemplateArguments(); - $parent_arguments[] = static::getPDCType(); - return $parent_arguments; + protected function getTitleFormatArguments() { + return [ + static::PDC_TYPE, // 1: PDC type + $this->getDay(), // 2: day + $this->getMonthName(), // 3: month name + $this->getYear(), // 4: year + ]; } /** - * Create a PDF of this type (from raw) + * Title format regex groups + * + * Regex groups that can create a regex for this page title, when filling the title format. * - * @param $pdc_raw mixed Raw PDC data - * @see PDC::createFromRaw() + * @return array Array of regex groups for the TITLE_FORMAT + * @override CategoryYearMonthDay::titleFormatGroups() */ - public function createPDCFromRaw( $pdc_raw ) { - return PDC::createFromRaw( $this, $pdc_raw ); + protected static function titleFormatGroups() { + return [ + preg_quote( static::PDC_TYPE ), // 1: PDC type (it's correct that is not grouped) + '([0-9]{1,2})', // 2: day + '([a-z]+)', // 3: month name + '([0-9]{4})', // 4: year + ]; } /** - * Fetch PDCs of this type + * Get template arguments * - * @return array + * 1: category title + * 2: year + * 3: month 1-12 + * 4: month name + * 5: day 1-31 + * 6: PDC type + * + * @override CategoryTemplated::getTemplateArguments() */ - public function fetchPDCs() { - $api = self::api()->createQuery( [ - 'action' => 'query', - - // generator=categorymembers: get pages in category - // gmtitle=: specify the category title - // gmtype=page: get sub-pages - // gmsort=timestamp: order by insertion date in that category - // gmdir=asc: ascending order - // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Bcategorymembers - // Note: Generator parameter names must be prefixed with a 'g' - 'generator' => 'categorymembers', - 'gcmtitle' => $this->getTitle(), -// 'gcmtype' => 'page', // Note: Ignored when cmsort=timestamp is set. - 'gcmnamespace' => 4, // Wikipedia - 'gcmlimit' => 100, - 'gcmsort' => 'timestamp', - 'gcmdir' => 'asc', -// - // for each page load infos, categories and latest revision - // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Binfo - // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Bcategories - // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Brevisions - // Note: probably the revisions parameter is unuseful for last update date (already provided by "touched"). - // Note: revisions can be still useful to know the creation date - 'prop' => [ 'info' , 'categories'/*, 'revisions'*/ ], - - // inprop=protecion: list of the protection level of each page - // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Bcategories - 'inprop' => 'protection', - - // clprop=sortkey: adds the sortkey and sortkey prefix for the category - // clprop=timestamp: adds the timestamp of when the page was included - // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Binfo - 'clprop' => [ 'sortkey', 'timestamp' ], - - // rvprop=timestamp: timestamp of the revision - // rvlimit=1: only 1 revision - // rvdir=older: order by oldest - // https://it.wikipedia.org/w/api.php?action=help&modules=query%2Brevisions -// 'rvprop' => 'timestamp', -// 'rvdir' => 'older', -// 'rvlimit' => 1, - ] ); - - $all = []; - while( $api->hasNext() ) { - $next = $api->fetchNext(); - - if( isset( $next->query->pages ) ) { - foreach( $next->query->pages as $page ) { - - // multiple call will add more infos on the same page - // https://www.mediawiki.org/wiki/API:Query#Generators_and_continuation - // TODO: use batchcomplete for better memory usage - $pageid = $page->pageid; - if( isset( $all[ $pageid ] ) ) { - foreach( $page as $property => $value ) { - if( isset( $all[ $pageid ]->{$property} ) && is_array( $all[ $pageid ]->{$property} ) ) { - // merge categories values - $all[ $pageid ]->{$property} = array_merge( - $all[ $pageid ]->{$property}, - $value - ); - } else { - $all[ $pageid ]->{$property} = $value; - } - } - } else { - $all[ $pageid ] = $page; - } - } - } - } - - $pdcs = []; - foreach( $all as $page ) { - try { - $pdcs[] = $this->createPDCFromRaw( $page ); - } catch( PDCException $e ) { - Log::warn( sprintf( - "exception in PDC '%s': %s", - $page->title, - $e->getMessage() - ) ); - } - } - - return $pdcs; + public function getTemplateArguments() { + $parent_arguments = parent::getTemplateArguments(); + $parent_arguments[] = static::PDC_TYPE; + return $parent_arguments; } } diff --git a/includes/class-CategoryYearMonthDayTypeConsensual.php b/includes/class-CategoryYearMonthDayTypeConsensual.php index 7e1d251..29f1ce1 100644 --- a/includes/class-CategoryYearMonthDayTypeConsensual.php +++ b/includes/class-CategoryYearMonthDayTypeConsensual.php @@ -1,39 +1,46 @@ . namespace itwikidelbot; /** * Handle a daily consensual PDC category * * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_consensuali_del_13_aprile_2018 */ class CategoryYearMonthDayTypeConsensual extends CategoryYearMonthDayType { /** * PDC type * - * @override CategoryYearMonthDayType::PDC_TYPE + * @override CategoryYearMonthDay::PDC_TYPE */ const PDC_TYPE = 'consensuali'; + + /** + * PDC human type + * + * @override CategoryYearMonthDay::PDC_TYPE_HUMAN + */ + const PDC_TYPE_HUMAN = 'consensuale'; } diff --git a/includes/class-CategoryYearMonthDayTypeOrdinary.php b/includes/class-CategoryYearMonthDayTypeOrdinary.php index d71e4d0..901f4ea 100644 --- a/includes/class-CategoryYearMonthDayTypeOrdinary.php +++ b/includes/class-CategoryYearMonthDayTypeOrdinary.php @@ -1,39 +1,46 @@ . namespace itwikidelbot; /** * Handle a daily ordinary PDC category * * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_ordinarie_del_25_giugno_2012 */ class CategoryYearMonthDayTypeOrdinary extends CategoryYearMonthDayType { /** * PDC type * - * @override CategoryYearMonthDayType::PDC_TYPE + * @override CategoryYearMonthDay::PDC_TYPE */ const PDC_TYPE = 'ordinarie'; + + /** + * PDC human type + * + * @override CategoryYearMonthDay::PDC_TYPE_HUMAN + */ + const PDC_TYPE_HUMAN = 'ordinaria'; } diff --git a/includes/class-CategoryYearMonthDayTypeProlonged.php b/includes/class-CategoryYearMonthDayTypeProlonged.php index aad523c..f61d3aa 100644 --- a/includes/class-CategoryYearMonthDayTypeProlonged.php +++ b/includes/class-CategoryYearMonthDayTypeProlonged.php @@ -1,39 +1,46 @@ . namespace itwikidelbot; /** * Handle a daily prolonged PDC category * * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_consensuali_prorogate_del_11_aprile_2018 */ class CategoryYearMonthDayTypeProlonged extends CategoryYearMonthDayType { /** * PDC type * * @override CategoryYearMonthDayType::PDC_TYPE */ const PDC_TYPE = 'consensuali prorogate'; + + /** + * PDC human type + * + * @override CategoryYearMonthDay::PDC_TYPE_HUMAN + */ + const PDC_TYPE_HUMAN = 'consensuale prorogata'; } diff --git a/includes/class-CategoryYearMonthDayTypeSimple.php b/includes/class-CategoryYearMonthDayTypeSimple.php deleted file mode 100644 index ee2c3f9..0000000 --- a/includes/class-CategoryYearMonthDayTypeSimple.php +++ /dev/null @@ -1,59 +0,0 @@ -. - -namespace itwikidelbot; - -/** - * Handle a daily category of semplified PDCs - * - * Pratically, a semplified PDC category is the daily PDC category. - * So the template of this class cames from CategoryYearMonthDay. - * - * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_del_1_aprile_2017 - */ -class CategoryYearMonthDayTypeSimple extends CategoryYearMonthDayType { - - /** - * The same value for CategoryYearMonthDay::TEMPLATE_NAME. - * - * @see CategoryYearMonthDayType::TEMPLATE_NAME - */ - const TEMPLATE_NAME = 'CATEGORY_DAY'; - - /** - * PDC type - * - * @override CategoryYearMonthDayType::PDC_TYPE - */ - const PDC_TYPE = 'semplificate'; - - /** - * Template arguments - * - * @override CategoryYearMonth::getTemplateArguments() - */ - public function getTemplateArguments() { - return CategoryYearMonthDay::getTemplateArguments(); - } - -} diff --git a/includes/class-CategoryYearMonthDayTypeVoting.php b/includes/class-CategoryYearMonthDayTypeVoting.php index 1955517..3f22ed1 100644 --- a/includes/class-CategoryYearMonthDayTypeVoting.php +++ b/includes/class-CategoryYearMonthDayTypeVoting.php @@ -1,39 +1,46 @@ . namespace itwikidelbot; /** * Handle a daily voting PDC category * - * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_del_12_aprile_2018 + * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_con_votazione_del_13_maggio_2018 */ class CategoryYearMonthDayTypeVoting extends CategoryYearMonthDayType { /** * PDC type * * @override CategoryYearMonthDayType::PDC_TYPE */ const PDC_TYPE = 'con votazione'; + + /** + * PDC human type + * + * @override CategoryYearMonthDay::PDC_TYPE_HUMAN + */ + const PDC_TYPE_HUMAN = 'votazione'; } diff --git a/includes/class-CategoryYearMonthDayTypes.php b/includes/class-CategoryYearMonthDayTypes.php index d73a133..bc02b0d 100644 --- a/includes/class-CategoryYearMonthDayTypes.php +++ b/includes/class-CategoryYearMonthDayTypes.php @@ -1,160 +1,154 @@ . namespace itwikidelbot; -use \cli\Log; -use \InvalidArgumentException; +use InvalidArgumentException; /** - * Handler of all the PDCs in this day of the year + * Handler of all the PDC type categories */ -class CategoryYearMonthDayTypes extends CategoryYearMonthDay { +class CategoryYearMonthDayTypes { /** * PDC types * * Categories in order of importance (I think) * * @var array */ public static $TYPES = [ - CategoryYearMonthDayTypeVoting ::class, - CategoryYearMonthDayTypeProlonged ::class, - CategoryYearMonthDayTypeConsensual::class, - CategoryYearMonthDayTypeOrdinary ::class, + CategoryYearMonthDayTypeVoting ::class, // voting + CategoryYearMonthDayTypeOrdinary ::class, // ordinary + CategoryYearMonthDayTypeProlonged ::class, // prolonged + CategoryYearMonthDayTypeConsensual::class, // consensual CategoryYearMonthDay ::class, // simple ]; /** - * Get the corresponding class of a certain PDC type + * Other types of categories * - * @param $type string PDC type - * @return class + * @var array */ - public static function type2class( $type ) { - foreach( self::getAll() as $Type ) { - if( $Type::PDC_TYPE === $type ) { - return $Type; - } - } - throw new InvalidArgumentException( "unknown PDC type $pdc_type" ); + private static $OTHER_KNOWN_CATEGORIES = [ + 'Categoria:Procedure di cancellazione in corso', + 'Categoria:Procedure di cancellazione protette', + ]; + + /** + * Get all the types + * + * @return array + */ + public static function all() { + return self::$TYPES; } /** - * Get the corresponding class of a certain PDC type + * Create the corresponding category object from its title * * @param $title string Page title - * @return CategoryYearMonthDay + * @return CategoryYearMonthDay|false */ - public static function title2object( $title ) { - foreach( self::getAll() as $Type ) { + public static function createParsingTitle( $title ) { + foreach( self::all() as $Type ) { $category = $Type::createParsingTitle( $title ); if( $category ) { return $category; } } - throw new InvalidArgumentException( "unexpected PDC category '$title'" ); + if( ! in_array( $title, self::$OTHER_KNOWN_CATEGORIES, true ) ) { + throw new PDCException( "unexpected PDC category '$title'" ); + } + return false; } /** - * Get all the types + * Get a "genericity" score of a certain PDC category class name. * - * @return array + * Useful to comparate PDC types. + * + * E.g. a "simple" PDC has an higher score over a "consensual" PDC. + * + * @param $category string Class name + * @return int 0-4 */ - public static function getAll() { - return self::$TYPES; + public static function genericityFromClass( $category_class_name ) { + $i = array_search( $category_class_name, self::all(), true ); + if( false === $i ) { + throw new InvalidArgumentException( "unknown class name $category_class_name" ); + } + return $i; } /** - * Return the newer PDC, but setting the older start date. + * Get a "genericity" score of a certain PDC category instance. * - * @param $pdc1 PDC - * @param $pdc2 PDC - * @return $pdc PDC + * @see self::genericity() + * @param $category CategoryYearMonthDay + * @return int 0-4 */ - public function mergePDCs( $pdc1, $pdc2 ) { - if( $pdc2->getDurationDays() > $pdc1->getDurationDays() ) { - return $pdc2->setStartDate( $pdc1->getStartDate() ); - } - return $pdc1; + public static function genericityFromObject( CategoryYearMonthDay $category ) { + return self::genericityFromClass( get_class( $category ) ); } /** - * Operate on every PDC type + * Find the best category (the most recent) from a list + * + * @param $categories CategoryYearMonthDay[] + * @return CategoryYearMonthDay One of the $categories */ - public function run() { - - $pdcs_by_id = []; - foreach( self::$TYPES as $Category ) { - $category = new $Category( $this->getYear(), $this->getMonth(), $this->getDay() ); - - $pdcs = $category->fetchPDCs(); - if( count( $pdcs ) ) { - $category->saveIfNotExists(); - } - - // merge the same PDCs - foreach( $pdcs as $pdc ) { - $id = $pdc->getId(); - if( isset( $pdcs_by_id[ $id ] ) ) { - $pdcs_by_id[ $id ] = self::mergePDCs( $pdcs_by_id[ $id ], $pdc ); - } else { - $pdcs_by_id[ $id ] = $pdc; + public static function findBestCategory( $categories ) { + $best = null; + foreach( $categories as $category ) { + if( ! $best ) { + $best = $category; + } elseif( $category->getDateTime()->format('Y-m-d') === $best->getDateTime()->format('Y-m-d') ) { + // the day is the same: take the most precise + if( self::genericityFromObject( $category ) < self::genericityFromObject( $best ) ) { + $best = $category; } + } elseif( $category->getDateTime() > $best->getDateTime() ) { + // take the newest + $best = $category; } } - - // sort PDCs by start date - usort( $pdcs_by_id, function ( $a, $b ) { - return $a->getStartDate() > $b->getStartDate(); - } ); - - foreach( $pdcs_by_id as $i => $pdc ) { - if( $pdc->getDurationDays() > 7 ) { - Log::info( sprintf( - 'the PDC %s is expired after %d days', - $pdc->getTitle(), - $pdc->getDurationDays() - ) ); - } + if( ! $best ) { + throw new PDCException( 'cannot find the best categories' ); } + return $best; + } - // index PDcs by their type - $pdcs_by_type = []; - foreach( $pdcs_by_id as $pdc ) { - $type = $pdc->getType(); - if( ! isset( $pdcs_by_type[ $type ] ) ) { - $pdcs_by_type[ $type ] = []; - } - $pdcs_by_type[ $type ][] = $pdc; - } - - PageYearMonthDayPDCsCount::createFromDateTimePDCs( $this->getDateTime(), $pdcs_by_type ) - ->save(); - - PageYearMonthDayPDCsLog::createFromDateTimePDCs( $this->getDateTime(), $pdcs_by_type ) - ->save(); + /** + * + * + * @param $year int + * @param $month int + * @param $day int + * @return PDC[] + */ + public static function fetchYearMonthDayPDCs( $year, $month, $day ) { + $pdcs_by_id = []; } } diff --git a/includes/class-PDC.php b/includes/class-PDC.php index 5d9e1d6..691f087 100644 --- a/includes/class-PDC.php +++ b/includes/class-PDC.php @@ -1,439 +1,531 @@ . namespace itwikidelbot; use DateTime; /** * Handle a "Procedura di cancellazione" * * It is a page like "Wikipedia:Pagine da cancellare/ASD" */ class PDC extends Page { /** * Prefix of every PDC */ const PREFIX = 'Wikipedia:Pagine da cancellare/'; /** * Prefix of every multiple PDC */ const PREFIX_MULTIPLE = self::PREFIX . 'multiple/'; /** * PDC category type * - * @var CategoryYearMonthDayType + * @var CategoryYearMonthDay */ private $categoryType; /** * Page id * * @var int */ private $id; /** * Title of the PDC subject page (the Wikipedia article title) * * Obtained from {{DEFAULTSORT}} category sortkey * * @var string */ private $titleSubject; /** * Page length in bytes * * @var int */ private $length; /** - * When the PDC was added to the PDC type category + * Creation date * * @var date */ - private $startDate; + private $creationDate; /** * Last update * * @var date */ private $lasteditDate; /** * Is Protected? * * @var bool */ private $isProtected; /** * Properties that the raw object must have * + * @see self::createFromRaw() * @var array */ private static $RAW_PROPERTIES = [ 'pageid', 'title', 'length', 'touched', 'protection', - 'categories' + 'categories', + ]; + + /** + * Properties that a raw category must have + * + * @see self::createFromRaw() + * @var array + */ + private static $RAW_CATEGORY_PROPERTIES = [ + 'title', + 'sortkeyprefix', + 'timestamp', // TODO: remove as dependency if it's unuseful ]; /** * Constructor * - * @param $category_type CategoryYearMonthDayType PDC category type + * @param $category_type CategoryYearMonthDay PDC category type * @param $id int PDC page id * @param $title string PDC title prefixed * @param $title_subject string Title of the subject page (the Wikipedia article title) * @param $length int PDC length * @param $start DateTime When the PDC was added to the PDC type category + * @param $creation DateTime PDC creation date * @param $lastedit DateTime PDC lastedit date * @param $is_protected bool Is the PDC protected? * @see Page::__construct() * @throws PDCException */ - public function __construct( $category_type, $id, $title, $title_subject, $length, DateTime $start, DateTime $lastedit, $is_protected ) { - $this->categoryType = $category_type; + public function __construct( CategoryYearMonthDay $category_type, $id, $title, $title_subject, $length, DateTime $creation, DateTime $lastedit, $is_protected ) { $this->id = $id; $this->titleSubject = $title_subject; $this->length = $length; + $this->creationDate = $creation; $this->lasteditDate = $lastedit; $this->isProtected = $is_protected; - $this->setStartDate( $start ); + + $this->setCategoryType( $category_type ); parent::__construct( $title ); // consistence checks if( ! $this->isTitlePrefixValid() ) { throw new PDCException( 'not a PDC' ); } - //if( $this->getDurationDays() > 7 ) { - // throw new PDCExceptionExpired( 'not anymore a PDC of type ' . $this->getType() ); - //} + if( $this->getDurationDays() > 7 ) { + throw new PDCExceptionExpired( 'not anymore a PDC of type ' . $this->getType() ); + } $this->checkTitleSubjectConsistence(); } + /** + * Static constructor + * + * @see YearMonthDayTypes::fetchPDCs() + * @param $page mixed + * @return self + * @throws PDCException + */ + public static function createFromRaw( $page ) { + + // verify the API response consistence + foreach( self::$RAW_PROPERTIES as $property ) { + if( ! isset( $page->$property ) ) { + throw new PDCException( "missing property $property" ); + } + } + foreach( $page->categories as $category_raw ) { + foreach( self::$RAW_CATEGORY_PROPERTIES as $property ) { + if( ! isset( $category_raw->$property ) ) { + throw new PDCException( "missing property $property in categories" ); + } + } + } + if( 0 === count( $page->categories ) ) { + throw new PDCException( "no category" ); + } + + // get the page title of the subject from the {{DEFAULTSORT:xxx}} value + $title_subject = null; + foreach( $page->categories as $category_raw ) { + $title_subject = $category_raw->sortkeyprefix; + break; + } + + // array of instances of the class CategoryYearMonthDay (and subclasses) + $categories = []; + foreach( $page->categories as $category_raw ) { + $category = CategoryYearMonthDayTypes::createParsingTitle( $category_raw->title ); + if( $category ) { + $categories[] = $category; + } + } + + // creation date + $creation = null; + foreach( $categories as $category ) { + if( get_class( $category ) === CategoryYearMonthDay::class ) { + $creation = DateTime::createFromFormat( DateTime::ISO8601, $category_raw->timestamp ); + break; + } + } + if( ! $creation ) { + throw new Exception( "not into the main category" ); + } + + if( ! $categories ) { + throw new PDCException( sprintf( + "the PDC was in %d categories and/but no one was recognized", + count( $page->categories ) + ) ); + } + + // find the best (the newest) category to be applied + $best_category = CategoryYearMonthDayTypes::findBestCategory( $categories ); + + // read protection status + $is_protected = false; + foreach( $page->protection as $protection ) { + if( 'edit' === $protection->type && 'sysop' === $protection->level ) { + $is_protected = true; + break; + } + } + + return new self( + $best_category, + (int) $page->pageid, + $page->title, + $title_subject, + (int) $page->length, + $creation, + DateTime::createFromFormat( DateTime::ISO8601, $page->touched ), + $is_protected + ); + } + /** * Get the page id * * @return int */ public function getId() { return $this->id; } /** * Get the title of the subject page (the Wikipedia article title) * * Obtained from {{DEFAULTSORT}} category sortkey * * @return string */ public function getTitleSubject() { return $this->titleSubject; } /** * Get the page length * * @return int */ public function getLength() { return $this->length; } + /** + * Get the category type + * + * @return CategoryYearMonthDay + */ + public function getCategoryType() { + return $this->categoryType; + } + + /** + * Set the category type + * + * @param $category_type CategoryYearMonthDay + * @return self + */ + public function setCategoryType( CategoryYearMonthDay $category_type ) { + $this->categoryType = $category_type; + return $this; + } + /** * Get the start date of this PDC (of this type) * * @return DateTime */ public function getStartDate() { - return $this->startDate; + return $this->getCategoryType()->getDateTime(); } /** - * set the start date of this PDC (of this type) + * Get the creation date * - * @param $start_date DateTime - * @return self + * @return DateTime */ - public function setStartDate( DateTime $start_date ) { - $this->startDate = $start_date; - return $this; + public function getCreationDate() { + return $this->creationDate; } /** * Get the latest update date * * @return DateTime */ public function getLasteditDate() { return $this->lasteditDate; } /** * Get the PDC type class * * @return class */ public function getTypeClass() { - return get_class( $this->categoryType ); + return get_class( $this->getCategoryType() ); + } + + /** + * Get the PDC type class genericity + * + * @see CategoryYearMonthDay::genericity() + * @return int + */ + public function getCategoryGenericity() { + $class_name = self::getTypeClass(); + return $class_name::genericity(); } /** * Get the PDC type name * - * @return string e.g. 'consensuale' + * @return string e.g. 'con votazioni' */ public function getType() { $class = $this->getTypeClass(); - return $class::getPDCType(); + return $class::PDC_TYPE; + } + + /** + * Get the PDC human type + * + * @return string e.g. 'votazione' + */ + public function getHumanType() { + $class = $this->getTypeClass(); + return $class::PDC_TYPE_HUMAN; } /** * Check if this page is protected * * @return bool */ public function isProtected() { return $this->isProtected; } /** * Check if this PDC has a known prefix * * @return bool */ private function isTitlePrefixValid() { return $this->titlehasPrefix( self::PREFIX ); } /** * Check if this PDC involves multiple PDCs * * @return bool */ public function isMultiple() { return $this->titleHasPrefix( self::PREFIX_MULTIPLE ); } /** * Get the title prefix * * @return string */ private function getTitlePrefix() { return $this->isMultiple() ? self::PREFIX_MULTIPLE : self::PREFIX; } /** * Get the title unprefixed * * @return string */ private function getTitleUnprefixed() { return substr( $this->getTitle(), strlen( $this->getTitlePrefix() ) ); } /** * Check if the title has a certain prefix * * @param $prefix string * @return bool */ private function titleHasPrefix( $prefix ) { return 0 === strpos( $this->getTitle(), $prefix ); } /** * Verify if the title of the subject is consistent with the PDC title * * @return bool */ private function checkTitleSubjectConsistence() { // subject from {{DEFAULTSORT}} category prefix $subject = $this->getTitleSubject(); // subject generated unprefixing page title $subject_gen = $this->getTitleUnprefixed(); if( $subject !== $subject_gen ) { // Check if the PDC title ends with an enumeration e.g. 'asd/14' $status = preg_match( '@(.*)/[0-9]+$@', $subject_gen, $matches ); if( 1 === $status ) { // Get the interesting part e.g. 'asd' $subject_gen = $matches[ 1 ]; } } if( $subject !== $subject_gen ) { throw new PDCException( sprintf( 'the sortkey is "%s" and it is inconsistent with the PDC suffix "%s"', $subject_gen, $subject ) ); } } - /** - * Static constructor - * - * @param $type CategoryYearMonthDayType Specified PDC type - * @param $page mixed - * @return self - * @throws PDCException - */ - public static function createFromRaw( $type, $page ) { - - // verify consistence - foreach( self::$RAW_PROPERTIES as $property ) { - if( ! isset( $page->$property ) ) { - throw new PDCException( "PDC has not property $property" ); - } - } - - // read the title of the subject from the {{DEFAULTSORT}} category sortkey prefix - $title_subject = null; - foreach( $page->categories as $category ) { - $title_subject = $category->sortkeyprefix; - break; - } - if( ! isset( $title_subject ) ) { - throw new PDCException( 'missing category sortkeyprefix that contains title subject' ); - } - - // get the start date of this PDC from the timestamp - $date_added_in_category = null; - foreach( $page->categories as $category ) { - if( CategoryYearMonthDay::matchCategoryName( $category->title ) ) { - if( ! isset( $category->timestamp ) ) { - throw new PDCException( 'missing category timestamp' ); - } - $date_added_in_category = $category->timestamp; - break; - } - } - if( ! isset( $date_added_in_category ) ) { - throw new PDCException( 'missing timestamp of insertion into the daily category' ); - } - - // read protection status - $is_protected = false; - foreach( $page->protection as $protection ) { - if( 'edit' === $protection->type && 'sysop' === $protection->level ) { - $is_protected = true; - break; - } - } - - return new self( - $type, - (int) $page->pageid, - $page->title, - $title_subject, - (int) $page->length, - DateTime::createFromFormat( DateTime::ISO8601, $date_added_in_category ), - DateTime::createFromFormat( DateTime::ISO8601, $page->touched ), - $is_protected - ); - } - /** * Get the PDC temperature * * The temperature is a value betweeen 0-100 * * @return int */ public function getTemperature() { $slope = null; $offset = null; switch( $this->getType() ) { - case CategoryYearMonthDayTypeSimple::getPDCType(): + case CategoryYearMonthDay::PDC_TYPE; $slope = 0.0365; $offset = -24.0; break; - case CategoryYearMonthDayTypeConsensual::getPDCType(): + case CategoryYearMonthDayTypeConsensual::PDC_TYPE: $slope = 0.0075; $offset = -12.81; break; - case CategoryYearMonthDayTypeProlonged::getPDCType(): + case CategoryYearMonthDayTypeProlonged::PDC_TYPE: $slope = 0.0035; $offset = -9.76; break; - case CategoryYearMonthDayTypeOrdinary::getPDCType(): - case CategoryYearMonthDayTypeVoting ::getPDCType(): + case CategoryYearMonthDayTypeOrdinary::PDC_TYPE: + case CategoryYearMonthDayTypeVoting ::PDC_TYPE: $slope = 0.0025; $offset = -16.43; break; default: throw new PDCException( 'unexpected type' ); } $temp = round( $slope * $this->getLength() + $offset ); if ( $temp > 100 ) { $temp = 100; } elseif ( $temp < 0 ) { $temp = 0; } return $temp; } /** * Get the number of days of duration of this PDC * * @return int */ public function getDurationDays() { - return (int) $this->getLasteditDate()->diff( $this->getStartDate() )->format('%a'); + return (int) $this->getLasteditDate()->diff( $this->getStartDate() )->format( '%a' ); } /** * Get an human rappresentation of the duration of this PDC * * @return string */ public function getHumanDuration() { $days = $this->getDurationDays(); if( 0 === $days ) { return Template::get( 'DURATION.hours' ); } if( 1 === $days ) { return Template::get( 'DURATION.day' ); } return Template::get( 'DURATION.days', [ $days ] ); } + + /** + * Merge a PDC with in this one + * + * @param $pdc PDC + */ + public function merge( PDC $pdc ) { + if( $this->getId() !== $pdc->getId() ) { + throw new InvalidArgumentException( 'PDCs can be merged only if they are of the same type' ); + } + $this->setCategoryType( CategoryYearMonthDayTypes::findBestCategory( [ + $this->getCategoryType(), + $pdc ->getCategoryType() + ] ) ); + } } diff --git a/includes/class-CategoryYearMonthDayTypeVoting.php b/includes/class-PDCs.php similarity index 51% copy from includes/class-CategoryYearMonthDayTypeVoting.php copy to includes/class-PDCs.php index 1955517..60df9a6 100644 --- a/includes/class-CategoryYearMonthDayTypeVoting.php +++ b/includes/class-PDCs.php @@ -1,39 +1,53 @@ . namespace itwikidelbot; /** - * Handle a daily voting PDC category - * - * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_del_12_aprile_2018 + * PDCs handler */ -class CategoryYearMonthDayTypeVoting extends CategoryYearMonthDayType { +class PDCs { /** - * PDC type + * Sort some PDCs by creation date * - * @override CategoryYearMonthDayType::PDC_TYPE + * @param $pdcs array */ - const PDC_TYPE = 'con votazione'; + public static function sortByCreationDate( & $pdcs ) { + // sort PDCs by start date + usort( $pdcs, function ( $a, $b ) { + return $a->getCreationDate() > $b->getCreationDate(); + } ); + } + + /** + * Index some PDCs by their type + * + * @param $pdcs array + * @return array + */ + public static function indexByType( $pdcs ) { + $pdcs_by_type = []; + foreach( $pdcs as $pdc ) { + $type = $pdc->getType(); + if( ! isset( $pdcs_by_type[ $type ] ) ) { + $pdcs_by_type[ $type ] = []; + } + $pdcs_by_type[ $type ][] = $pdc; + } + return $pdcs_by_type; + } + } diff --git a/includes/class-PageTemplated.php b/includes/class-PageTemplated.php index 2753882..07b8915 100644 --- a/includes/class-PageTemplated.php +++ b/includes/class-PageTemplated.php @@ -1,128 +1,128 @@ . namespace itwikidelbot; /** * Handle a generic page associated to a template */ abstract class PageTemplated extends Page { /** * Template name of this page * * To be overrided */ const TEMPLATE_NAME = 'EXAMPLE_NAME'; /** * Constructor * * @param $args Template arguments */ public function __construct() { parent::__construct( $this->getTemplatedTitle() ); } /** * Get the name of the template * * @return string */ - public function getTemplateName() { + public static function getTemplateName() { return static::TEMPLATE_NAME; } /** * Get the name of the template for the page title * * @return string */ - public function getTemplateTitleName() { - return $this->getTemplateName() . '.title'; + public static function getTemplateTitleName() { + return static::getTemplateName() . '.title'; } /** * Get the name of the template for the summary * * @return string */ - public function getTemplateSummaryName() { - return $this->getTemplateName() . '.summary'; + public static function getTemplateSummaryName() { + return static::getTemplateName() . '.summary'; } /** * Get the name of the template for the content */ - public function getTemplateContentName() { - return $this->getTemplateName() . '.content'; + public static function getTemplateContentName() { + return static::getTemplateName() . '.content'; } /** * Get the template arguments * * @return array */ - abstract public function getTemplateArguments(); + public abstract function getTemplateArguments(); /** * Get the edit summary for this page from its template * * @return string */ public function getTemplatedSummary() { - return Template::get( $this->getTemplateSummaryName(), $this->getTemplateArguments() ); + return Template::get( static::getTemplateSummaryName(), $this->getTemplateArguments() ); } /** * Get the page title from its template * * @return string */ public function getTemplatedTitle() { - return Template::get( $this->getTemplateTitleName(), $this->getTemplateArguments() ); + return Template::get( static::getTemplateTitleName(), $this->getTemplateArguments() ); } /** * Get the page content for this page from its template * * @return string */ public function getTemplatedContent() { - return Template::get( $this->getTemplateContentName(), $this->getTemplateArguments() ); + return Template::get( static::getTemplateContentName(), $this->getTemplateArguments() ); } /** * Save this page from the content of its template * * @return mixed */ public function save() { return $this->saveByContentSummary( $this->getTemplatedContent(), $this->getTemplatedSummary() ); } /** * Save this page from the content of its template if it does not exist * * @return self */ public function saveIfNotExists() { if( ! $this->exists() ) { $this->save(); } return $this; } } diff --git a/includes/class-PageYearMonthDayPDCsCount.php b/includes/class-PageYearMonthDayPDCsCount.php index c61c17e..41de3ce 100644 --- a/includes/class-PageYearMonthDayPDCsCount.php +++ b/includes/class-PageYearMonthDayPDCsCount.php @@ -1,117 +1,117 @@ . 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: goto action label e.g. 'pagina di discussione' * * @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 ) ] ); } $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->isProtected() ? '.ENDED.entry' : '.RUNNING.entry'; return Template::get( $template_name, [ $pdc->getTitleSubject(), $pdc->getTemperature(), $pdc->isMultiple(), '', // TODO: Ex color. Now unuseful. $i, - $pdc->getType(), + $pdc->getHumanType(), $pdc->getHumanDuration(), $this->getTitle() ] ); } } diff --git a/templates/CATEGORY_DAY.title.tpl b/templates/CATEGORY_DAY.title.tpl deleted file mode 100644 index 6d6e59a..0000000 --- a/templates/CATEGORY_DAY.title.tpl +++ /dev/null @@ -1,17 +0,0 @@ - -This is the template for the title of a daily category. - -Placeholders: - %1$s: category title - %2$d: year - %3$d: month 1-12 - %3$02d: month 01-12 - %4$s: month name - %5$d: day 1-31 - %5$02d: day 01-31 - - -Categoria:Cancellazioni del 19 aprile 2018 - - -Categoria:Cancellazioni del %5$d %4$s %2$d diff --git a/templates/CATEGORY_DAY_PDCTYPE.title.tpl b/templates/CATEGORY_DAY_PDCTYPE.title.tpl deleted file mode 100644 index 837e8be..0000000 --- a/templates/CATEGORY_DAY_PDCTYPE.title.tpl +++ /dev/null @@ -1,18 +0,0 @@ - -This is the template for the title of a specific PDC type daily category. - -Placeholders: - %1$s: category title - %2$d: year - %3$d: month 1-12 - %3$02d: month 01-12 - %4$s: month name - %5$d: day 1-31 - %5$02d: day 01-31 - %6$s: PDC type - - -Categoria:Cancellazioni ordinarie del 19 aprile 2018 - - -Categoria:Cancellazioni %6$s del %5$d %4$s %2$d