jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/391971 )

Change subject: Add thank you subject generator
......................................................................


Add thank you subject generator

This version just writes files from the same mediawiki json we were
already using.

TODO: move the content to metawiki along with the body templates

Bug: T167806
Change-Id: Iec81e2a8f853b7d4bd432de186ea8630bfbe8ada
---
A sites/all/modules/thank_you/generators/ThankYouSubject.php
M sites/all/modules/thank_you/make_thank_you.drush.inc
M sites/all/modules/thank_you/thank_you.info
3 files changed, 41 insertions(+), 0 deletions(-)

Approvals:
  XenoRyet: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/sites/all/modules/thank_you/generators/ThankYouSubject.php 
b/sites/all/modules/thank_you/generators/ThankYouSubject.php
new file mode 100644
index 0000000..59fd40a
--- /dev/null
+++ b/sites/all/modules/thank_you/generators/ThankYouSubject.php
@@ -0,0 +1,39 @@
+<?php namespace thank_you\generators;
+
+use wmf_communication\MediaWikiMessages;
+
+class ThankYouSubject extends RenderTranslatedPage {
+
+  protected $proto_file = __DIR__ . 
'/../templates/subject/thank_you.$1.subject';
+  protected $key = 'donate_interface-email-subject';
+
+  public function execute($wantedLangs = []) {
+    watchdog(
+      'make-thank-you',
+      "Obtaining thank you subjects for placement into '{$this->proto_file}'",
+      NULL,
+      WATCHDOG_INFO
+    );
+    $messages = MediaWikiMessages::getInstance();
+    if (empty($wantedLangs)) {
+      $wantedLangs = $messages->languageList();
+      watchdog('make-thank-you', 'Trying all possible languages', NULL, 
WATCHDOG_INFO);
+    }
+    foreach ($wantedLangs as $lang) {
+      if (!$messages->msgExists($this->key, $lang)) {
+        watchdog('make-thank-you', "$lang -- {$this->key} is not available!", 
NULL, WATCHDOG_ERROR);
+        continue;
+      }
+
+      $subject = $messages->getMsg($this->key, $lang);
+      $file = str_replace('$1', $lang, $this->proto_file);
+
+      if (file_put_contents($file, $subject)) {
+        watchdog('make-thank-you', "$lang -- Wrote translation into $file", 
NULL, WATCHDOG_INFO);
+      }
+      else {
+        watchdog('make-thank-you', "$lang -- Could not open $file for 
writing!", NULL, WATCHDOG_ERROR);
+      }
+    }
+  }
+}
diff --git a/sites/all/modules/thank_you/make_thank_you.drush.inc 
b/sites/all/modules/thank_you/make_thank_you.drush.inc
index 7e3370a..b542966 100644
--- a/sites/all/modules/thank_you/make_thank_you.drush.inc
+++ b/sites/all/modules/thank_you/make_thank_you.drush.inc
@@ -46,6 +46,7 @@
 function get_thank_you_generators() {
     return array(
         'generic' => '\thank_you\generators\ThankYou',
+        'subject' => '\thank_you\generators\ThankYouSubject',
     );
 }
 
diff --git a/sites/all/modules/thank_you/thank_you.info 
b/sites/all/modules/thank_you/thank_you.info
index 1ed382e..0ff9b10 100644
--- a/sites/all/modules/thank_you/thank_you.info
+++ b/sites/all/modules/thank_you/thank_you.info
@@ -10,3 +10,4 @@
 files[] = generators/FindUnconsumedTokens.php
 files[] = generators/RenderTranslatedPage.php
 files[] = generators/ThankYou.php
+files[] = generators/ThankYouSubject.php

-- 
To view, visit https://gerrit.wikimedia.org/r/391971
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iec81e2a8f853b7d4bd432de186ea8630bfbe8ada
Gerrit-PatchSet: 3
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <ej...@ejegg.com>
Gerrit-Reviewer: XenoRyet <dkozlow...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to