jenkins-bot has submitted this change and it was merged.

Change subject: ChoiceData: in category, substitue {{{campaign}}} and 
{{{banner}}
......................................................................


ChoiceData: in category, substitue {{{campaign}}} and {{{banner}}

This is a temporary fix to provide useful category information in
choice data, in most circumstances. A general reworking of categories
in CentralNotice is pending.

Change-Id: I6a3f93e1101f324a43a59cd651801078ba21246d
---
M includes/ChoiceDataProvider.php
1 file changed, 13 insertions(+), 3 deletions(-)

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



diff --git a/includes/ChoiceDataProvider.php b/includes/ChoiceDataProvider.php
index 955185c..8f850e0 100644
--- a/includes/ChoiceDataProvider.php
+++ b/includes/ChoiceDataProvider.php
@@ -102,8 +102,18 @@
                foreach ( $dbRows as $dbRow ) {
 
                        $campaignId = $dbRow->not_id;
+                       $campaignName = $dbRow->not_name;
                        $bannerId = $dbRow->tmp_id;
+                       $bannerName = $dbRow->tmp_name;
                        $bucket = $dbRow->asn_bucket;
+
+                       // FIXME Temporary hack to substitute the magic words 
{{{campaign}}}
+                       // and {{{banner}}} in banner categories. (These are 
the magic
+                       // words mentioned in the CN Admin UI.)
+                       $category = $dbRow->tmp_category;
+                       $category = str_replace( '{{{campaign}}}', 
$campaignName, $category);
+                       $category = str_replace( '{{{banner}}}', $bannerName, 
$category);
+                       $category = Banner::sanitizeRenderedCategory( $category 
);
 
                        // The first time we see any campaign, create the 
corresponding
                        // outer K/V entry. The campaign-specific properties 
should be
@@ -111,7 +121,7 @@
                        // keys don't make it into data structure we return.
                        if ( !isset ( $choices[$campaignId] ) ) {
                                $choices[$campaignId] = array(
-                                       'name' => $dbRow->not_name,
+                                       'name' => $campaignName,
                                        'start' => intval( wfTimestamp( 
TS_UNIX, $dbRow->not_start ) ),
                                        'end' => intval( wfTimestamp( TS_UNIX, 
$dbRow->not_end ) ),
                                        'preferred' => intval( 
$dbRow->not_preferred ),
@@ -127,10 +137,10 @@
                        $assignmentKey = $bannerId . ':' . $bucket;
 
                        $choices[$campaignId]['banners'][$assignmentKey] = 
array(
-                               'name' => $dbRow->tmp_name,
+                               'name' => $bannerName,
                                'bucket' => intval( $bucket ),
                                'weight' => intval( $dbRow->tmp_weight ),
-                               'category' => $dbRow->tmp_category,
+                               'category' => $category,
                                'display_anon' => (bool) 
$dbRow->tmp_display_anon,
                                'display_account' => (bool) 
$dbRow->tmp_display_account,
                                'devices' => array() // To be filled by the 
last query

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6a3f93e1101f324a43a59cd651801078ba21246d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: campaign_mixins
Gerrit-Owner: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to