Page Menu
Home
GitPull.it
Search
Configure Global Search
Log In
Files
F15181301
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/bot.php b/bot.php
index e688924..e7d3a98 100755
--- a/bot.php
+++ b/bot.php
@@ -1,31 +1,38 @@
#!/usr/bin/php
<?php
# Copyright (C) 2018 Valerio Bozzolan
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
namespace itwikidelbot;
// autoload classes
require __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'autoload.php';
// load credentials
require __DIR__ . DIRECTORY_SEPARATOR . 'config.php';
-// create the category year
+// create the yearly category
$year = date( 'Y' );
-( new CategoryYear( $year ) )->saveIfNotExists();
+( new CategoryYear( $year ) )
+ ->saveIfNotExists();
-// create the month category
+// create the monthly category
$month = date( 'n' ); // 1-12
-( new CategoryYearMonth( $year, $month ) )->saveIfNotExists();
+( new CategoryYearMonth( $year, $month ) )
+ ->saveIfNotExists();
+
+// create the daily category
+$day = date( 'j' );
+( new CategoryYearMonthDay( $year, $month, $day ) )
+ ->saveIfNotExists();
diff --git a/includes/class-CategoryYearMonthDay.php b/includes/class-CategoryYearMonthDay.php
new file mode 100644
index 0000000..ff4c2c7
--- /dev/null
+++ b/includes/class-CategoryYearMonthDay.php
@@ -0,0 +1,110 @@
+<?php
+# it.wiki deletion bot in PHP
+# Copyright (C) 2013 Mauro742, MauroBot
+# https://it.wikipedia.org/wiki/Utente:Mauro742
+# https://it.wikipedia.org/wiki/Utente:MauroBot
+# Originally under Creative Commons BY SA 3.0 International
+# Utente:MauroBot/BotCancellazioni/category.js
+# https://creativecommons.org/licenses/by-sa/3.0/
+# https://wikimediafoundation.org/wiki/Special:MyLanguage/Terms_of_Use/it
+# Copyright (C) 2018 Valerio Bozzolan
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+namespace itwikidelbot;
+
+/**
+ * Handle a daily category
+ *
+ * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_del_19_febbraio_2018
+ */
+class CategoryYearMonthDay extends CategoryTemplated {
+
+ /**
+ * Year
+ *
+ * @var int
+ */
+ private $year;
+
+ /**
+ * Month
+ *
+ * @var int 1-12
+ */
+ private $month;
+
+ /**
+ * Day
+ *
+ * @var int 1-31
+ */
+ private $day;
+
+ /**
+ * The template name for a daily category
+ *
+ * @override CategoryTemplated::TEMPLATE_NAME
+ */
+ const TEMPLATE_NAME = 'CATEGORY_DAY';
+
+ /**
+ * Format of the generic title of a daily category
+ *
+ * e.g. 'Categoria:Cancellazioni del 19 aprile 2018'
+ */
+ const GENERIC_TITLE = 'Categoria:Cancellazioni del %3$s %2$s %1$d';
+
+ /**
+ * Constructor
+ *
+ * @param $year int
+ * @param $month int 1-12
+ * @param $day int 1-31
+ */
+ public function __construct( $year, $month, $day ) {
+ parent::__construct( self::title( $year, $month, $day ) );
+ $this->year = $year;
+ $this->month = $month;
+ $this->day = $day;
+ }
+
+ /**
+ * Get the template arguments
+ *
+ * @override CategoryTemplated::getTemplateArguments()
+ * @return array
+ */
+ protected function getTemplateArguments() {
+ return [
+ CategoryYearMonth::title( $this->year, $this->month ),
+ $this->year,
+ $this->month,
+ Months::number2name( $this->month - 1 ),
+ $this->day,
+ ];
+ }
+
+ /**
+ * Title of a daily category
+ *
+ * @param $year int
+ * @param $month int 1-12
+ * @param $day int 1-31
+ * @return string Category name e.g. 'Categoria:Cancellazioni del 19 febbraio 2018'
+ */
+ public static function title( $year, $month, $day ) {
+ $human_month = Months::number2name( $month - 1 );
+ return sprintf( self::GENERIC_TITLE, $year, $human_month, $day );
+ }
+}
diff --git a/templates/CATEGORY_DAY_CONTENT.template b/templates/CATEGORY_DAY_CONTENT.template
new file mode 100644
index 0000000..c73885f
--- /dev/null
+++ b/templates/CATEGORY_DAY_CONTENT.template
@@ -0,0 +1,21 @@
+<!-- START DOCUMENTATION -->
+This is the template for the content 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
+
+<!-- START SPECIFIC EXAMPLE -->
+{{Cancellazione/cat|2018/4/19}}
+
+[[Categoria:Cancellazioni - aprile 2018| 19022018]]
+
+<!-- START TEMPLATE -->
+{{Cancellazione/cat|%2$d/%3$d/%5$d}}
+
+[[Categoria:Cancellazioni - %4$s %2$d| %5$02d%3$02d%2$d]]
diff --git a/templates/CATEGORY_DAY_SUMMARY.template b/templates/CATEGORY_DAY_SUMMARY.template
new file mode 100644
index 0000000..ffb7fbc
--- /dev/null
+++ b/templates/CATEGORY_DAY_SUMMARY.template
@@ -0,0 +1,17 @@
+<!-- START DOCUMENTATION -->
+This is the template for the edit summary 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
+
+<!-- START SPECIFIC EXAMPLE -->
+Bot: creazione categoria di servizio giornaliera per il 19 aprile 2018
+
+<!-- START TEMPLATE -->
+Bot: creazione categoria di servizio giornaliera per il %5$d %4$s %2$d
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Nov 19, 06:07 (15 m, 23 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2265082
Default Alt Text
(5 KB)
Attached To
Mode
R32 Italian Wikipedia Deletion Bot
Attached
Detach File
Event Timeline