Umherirrender has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/358049 )
Change subject: Use short array syntax - special ...................................................................... Use short array syntax - special Change-Id: If3aea4ddf3e66d56781e3a219becaa9657ccd49d --- M special/SpecialBannerAllocation.php M special/SpecialBannerLoader.php M special/SpecialCentralNotice.php M special/SpecialCentralNoticeBanners.php M special/SpecialCentralNoticeLogs.php M special/SpecialGlobalAllocation.php M special/SpecialHideBanners.php 7 files changed, 392 insertions(+), 392 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice refs/changes/49/358049/1 diff --git a/special/SpecialBannerAllocation.php b/special/SpecialBannerAllocation.php index 242778d..bb37a0e 100644 --- a/special/SpecialBannerAllocation.php +++ b/special/SpecialBannerAllocation.php @@ -83,9 +83,9 @@ $this->setHeaders(); // Output ResourceLoader module for styling and javascript functions - $out->addModules( array( + $out->addModules( [ 'ext.centralNotice.adminUi', - ) ); + ] ); // Initialize error variable $this->centralNoticeError = false; @@ -94,24 +94,24 @@ $out->addWikiMsg( 'centralnotice-summary' ); // Begin Banners tab content - $out->addHTML( Html::openElement( 'div', array( 'id' => 'preferences' ) ) ); + $out->addHTML( Html::openElement( 'div', [ 'id' => 'preferences' ] ) ); $htmlOut = ''; // Begin Allocation selection fieldset - $htmlOut .= Html::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); + $htmlOut .= Html::openElement( 'fieldset', [ 'class' => 'prefsection' ] ); - $htmlOut .= Html::openElement( 'form', array( 'method' => 'get' ) ); - $htmlOut .= Html::element( 'h2', array(), $this->msg( 'centralnotice-view-allocation' )->text() ); + $htmlOut .= Html::openElement( 'form', [ 'method' => 'get' ] ); + $htmlOut .= Html::element( 'h2', [], $this->msg( 'centralnotice-view-allocation' )->text() ); $htmlOut .= Xml::tags( 'p', null, $this->msg( 'centralnotice-allocation-instructions' )->text() ); - $htmlOut .= Html::openElement( 'table', array( 'id' => 'envpicker', 'cellpadding' => 7 ) ); + $htmlOut .= Html::openElement( 'table', [ 'id' => 'envpicker', 'cellpadding' => 7 ] ); $htmlOut .= Html::openElement( 'tr' ); $htmlOut .= Xml::tags( 'td', - array( 'style' => 'width: 20%;' ), + [ 'style' => 'width: 20%;' ], $this->msg( 'centralnotice-project-name' )->text() ); $htmlOut .= Html::openElement( 'td' ); - $htmlOut .= Html::openElement( 'select', array( 'name' => 'project' ) ); + $htmlOut .= Html::openElement( 'select', [ 'name' => 'project' ] ); foreach ( $wgNoticeProjects as $value ) { $htmlOut .= Xml::option( $value, $value, $value === $this->project ); @@ -122,7 +122,7 @@ $htmlOut .= Html::closeElement( 'tr' ); $htmlOut .= Html::openElement( 'tr' ); $htmlOut .= Xml::tags( 'td', - array( 'valign' => 'top' ), + [ 'valign' => 'top' ], $this->msg( 'centralnotice-project-lang' )->text() ); $htmlOut .= Html::openElement( 'td' ); @@ -136,7 +136,7 @@ ksort( $languages ); - $htmlOut .= Html::openElement( 'select', array( 'name' => 'language' ) ); + $htmlOut .= Html::openElement( 'select', [ 'name' => 'language' ] ); foreach ( $languages as $code => $name ) { $htmlOut .= Xml::option( @@ -148,13 +148,13 @@ $htmlOut .= Html::closeElement( 'td' ); $htmlOut .= Html::closeElement( 'tr' ); $htmlOut .= Html::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), $this->msg( 'centralnotice-country' )->text() ); + $htmlOut .= Xml::tags( 'td', [], $this->msg( 'centralnotice-country' )->text() ); $htmlOut .= Html::openElement( 'td' ); $userLanguageCode = $this->getLanguage()->getCode(); $countries = GeoTarget::getCountriesList( $userLanguageCode ); - $htmlOut .= Html::openElement( 'select', array( 'name' => 'country' ) ); + $htmlOut .= Html::openElement( 'select', [ 'name' => 'country' ] ); foreach ( $countries as $code => $name ) { $htmlOut .= Xml::option( $name, $code, $code === $this->location ); @@ -166,7 +166,7 @@ $htmlOut .= Html::closeElement( 'table' ); $htmlOut .= Xml::tags( 'div', - array( 'class' => 'cn-buttons' ), + [ 'class' => 'cn-buttons' ], Xml::submitButton( $this->msg( 'centralnotice-view' )->text() ) ); $htmlOut .= Html::closeElement( 'form' ); @@ -201,7 +201,7 @@ $htmlOut = ''; // Begin Allocation list fieldset - $htmlOut .= Html::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); + $htmlOut .= Html::openElement( 'fieldset', [ 'class' => 'prefsection' ] ); // Given our project and language combination, get banner choice data, // then filter on country @@ -212,10 +212,10 @@ foreach ( $devices as $deviceId => $deviceData ) { $htmlOut .= Html::openElement( 'div', - array( + [ 'id' => "cn-allocation-{$project}-{$language}-{$country}-{$deviceId}", 'class' => 'cn-allocation-group' - ) + ] ); $htmlOut .= Xml::tags( @@ -230,12 +230,12 @@ ); // FIXME matrix is chosen dynamically based on more UI inputs - $matrix = array(); + $matrix = []; for ( $i = 0; $i < $wgNoticeNumberOfBuckets; $i++ ) { - $matrix[] = array( 'anonymous' => 'true', 'bucket' => "$i" ); + $matrix[] = [ 'anonymous' => 'true', 'bucket' => "$i" ]; } for ( $i = 0; $i < $wgNoticeNumberOfBuckets; $i++ ) { - $matrix[] = array( 'anonymous' => 'false', 'bucket' => "$i" ); + $matrix[] = [ 'anonymous' => 'false', 'bucket' => "$i" ]; } foreach ( $matrix as $target ) { @@ -274,17 +274,17 @@ */ public function getTable( $type, $banners ) { $htmlOut = Html::openElement( 'table', - array( 'cellpadding' => 9, 'class' => 'wikitable sortable', 'style' => 'margin: 1em 0;' ) + [ 'cellpadding' => 9, 'class' => 'wikitable sortable', 'style' => 'margin: 1em 0;' ] ); - $htmlOut .= Html::element( 'h4', array(), $type ); + $htmlOut .= Html::element( 'h4', [], $type ); if ( count( $banners ) > 0 ) { $htmlOut .= Html::openElement( 'tr' ); - $htmlOut .= Html::element( 'th', array( 'width' => '5%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '5%' ], $this->msg( 'centralnotice-percentage' )->text() ); - $htmlOut .= Html::element( 'th', array( 'width' => '30%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '30%' ], $this->msg( 'centralnotice-banner' )->text() ); - $htmlOut .= Html::element( 'th', array( 'width' => '30%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '30%' ], $this->msg( 'centralnotice-notice' )->text() ); $htmlOut .= Html::closeElement( 'tr' ); } @@ -303,38 +303,38 @@ $percentage = sprintf( "%0.2f", round( $banner['allocation'] * 100, 2 ) ); // Row begin - $htmlOut .= Html::openElement( 'tr', array( 'class' => 'mw-sp-centralnotice-allocationrow' ) ); + $htmlOut .= Html::openElement( 'tr', [ 'class' => 'mw-sp-centralnotice-allocationrow' ] ); // Percentage - $htmlOut .= Html::openElement( 'td', array( 'align' => 'right' ) ); + $htmlOut .= Html::openElement( 'td', [ 'align' => 'right' ] ); $htmlOut .= $this->msg( 'percent', $percentage )->escaped(); $htmlOut .= Html::closeElement( 'td' ); // Banner name $viewBanner = $this->getTitleFor( 'CentralNoticeBanners', "edit/{$banner['name']}" ); - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); + $htmlOut .= Xml::openElement( 'td', [ 'valign' => 'top' ] ); $htmlOut .= Html::openElement( 'span', - array( 'class' => 'cn-'.$banner['campaign'].'-'.$banner['name'] ) ); + [ 'class' => 'cn-'.$banner['campaign'].'-'.$banner['name'] ] ); $htmlOut .= Linker::link( $viewBanner, htmlspecialchars( $banner['name'] ), - array(), - array( 'template' => $banner['name'] ) + [], + [ 'template' => $banner['name'] ] ); $htmlOut .= Html::closeElement( 'span' ); $htmlOut .= Html::closeElement( 'td' ); // Campaign name - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], Linker::link( $viewCampaign, htmlspecialchars( $banner['campaign'] ), - array(), - array( + [], + [ 'subaction' => 'noticeDetail', 'notice' => $banner['campaign'] - ) + ] ) ); diff --git a/special/SpecialBannerLoader.php b/special/SpecialBannerLoader.php index d015448..e48aa65 100644 --- a/special/SpecialBannerLoader.php +++ b/special/SpecialBannerLoader.php @@ -60,9 +60,9 @@ $this->bannerName = $request->getText( 'banner' ); $this->debug = $request->getFuzzyBool( 'debug' ); - $required_values = array( + $required_values = [ $this->campaignName, $this->bannerName, $language - ); + ]; foreach ( $required_values as $value ) { if ( is_null( $value ) ) { throw new MissingRequiredParamsException(); @@ -71,7 +71,7 @@ } function getSanitized( $param, $filter ) { - $matches = array(); + $matches = []; if ( preg_match( $filter, $this->getRequest()->getText( $param ), $matches ) ) { return $matches[0]; } @@ -159,12 +159,12 @@ $category = $bannerRenderer->substituteMagicWords( $settings['category'] ); $category = Banner::sanitizeRenderedCategory( $category ); - $bannerArray = array( + $bannerArray = [ 'bannerName' => $bannerName, 'bannerHtml' => $bannerHtml, 'campaign' => $this->campaignName, 'category' => $category, - ); + ]; $bannerJson = FormatJson::encode( $bannerArray ); diff --git a/special/SpecialCentralNotice.php b/special/SpecialCentralNotice.php index 499f0d3..e3085a6 100644 --- a/special/SpecialCentralNotice.php +++ b/special/SpecialCentralNotice.php @@ -15,7 +15,7 @@ * @var Campaign */ protected $campaign; - protected $campaignWarnings = array(); + protected $campaignWarnings = []; function __construct() { // Register special page @@ -93,7 +93,7 @@ * Output the start tag for the enclosing div we use on all subactions */ protected function outputEnclosingDivStartTag() { - $this->getOutput()->addHTML( Xml::openElement( 'div', array( 'id' => 'preferences' ) ) ); + $this->getOutput()->addHTML( Xml::openElement( 'div', [ 'id' => 'preferences' ] ) ); } /** @@ -114,7 +114,7 @@ $out = $this->getOutput(); $out->addHTML( Xml::element( 'h2', - array( 'class' => 'cn-special-section' ), + [ 'class' => 'cn-special-section' ], $this->msg( 'centralnotice-manage' )->text() ) ); $out->addModules( 'ext.centralNotice.adminUi.campaignPager' ); @@ -213,20 +213,20 @@ } $out = Html::element( 'input', - array( + [ 'id' => "{$name}Date", 'name' => "{$name}Date", 'type' => 'text', 'class' => 'centralnotice-datepicker centralnotice-datepicker-limit_one_year', - ) + ] ); $out .= Html::element( 'input', - array( + [ 'id' => "{$name}Date_timestamp", 'name' => "{$name}Date_timestamp", 'type' => 'hidden', 'value' => $ts, - ) + ] ); return $out; } else { @@ -237,10 +237,10 @@ protected function timeSelectorTd( $prefix, $editable, $timestamp = null ) { return Xml::tags( 'td', - array( + [ 'dir' => 'ltr', // Time is left-to-right in all languages 'class' => 'cn-timepicker', - ), + ], $this->timeSelector( $prefix, $editable, $timestamp ) ); } @@ -253,10 +253,10 @@ // Normalize timestamp format... $ts = wfTimestamp( TS_MW, $timestamp ); - $fields = array( - array( "hour", "centralnotice-hours", $hours, substr( $ts, 8, 2 ) ), - array( "min", "centralnotice-min", $minutes, substr( $ts, 10, 2 ) ), - ); + $fields = [ + [ "hour", "centralnotice-hours", $hours, substr( $ts, 8, 2 ) ], + [ "min", "centralnotice-min", $minutes, substr( $ts, 10, 2 ) ], + ]; return $this->createSelector( $prefix, $fields ); } else { @@ -274,14 +274,14 @@ * @return string HTML for the select list */ public function prioritySelector( $index, $editable, $priorityValue ) { - $priorities = array( + $priorities = [ CentralNotice::LOW_PRIORITY => wfMessage( 'centralnotice-priority-low' )->escaped(), CentralNotice::NORMAL_PRIORITY => wfMessage( 'centralnotice-priority-normal' )->escaped(), CentralNotice::HIGH_PRIORITY => wfMessage( 'centralnotice-priority-high' )->escaped(), CentralNotice::EMERGENCY_PRIORITY => wfMessage( 'centralnotice-priority-emergency' )->escaped(), - ); + ]; if ( $editable ) { @@ -294,10 +294,10 @@ // data-initial-value) must coordinate with CNCampaignPager and // ext.centralNotice.adminUi.campaignPager.js - $selectAttribs = array( + $selectAttribs = [ 'name' => 'priority', 'data-initial-value' => $priorityValue - ); + ]; if ( $index ) { $selectAttribs['data-campaign-name'] = $index; @@ -339,72 +339,72 @@ // If there was an error, we'll need to restore the state of the form if ( $request->wasPosted() && ( $request->getVal( 'subaction' ) === 'addCampaign' ) ) { $start = $this->getDateTime( 'start' ); - $noticeProjects = $request->getArray( 'projects', array() ); - $noticeLanguages = $request->getArray( 'project_languages', array() ); + $noticeProjects = $request->getArray( 'projects', [] ); + $noticeLanguages = $request->getArray( 'project_languages', [] ); } else { // Defaults $start = null; - $noticeProjects = array(); - $noticeLanguages = array(); + $noticeProjects = []; + $noticeLanguages = []; } $htmlOut = ''; // Section heading $htmlOut .= Xml::element( 'h2', - array( 'class' => 'cn-special-section' ), + [ 'class' => 'cn-special-section' ], $this->msg( 'centralnotice-add-notice' )->text() ); // Begin Add a campaign fieldset - $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); + $htmlOut .= Xml::openElement( 'fieldset', [ 'class' => 'prefsection' ] ); // Form for adding a campaign - $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post' ) ); + $htmlOut .= Xml::openElement( 'form', [ 'method' => 'post' ] ); $htmlOut .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ); $htmlOut .= Html::hidden( 'subaction', 'addCampaign' ); - $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' => 9 ) ); + $htmlOut .= Xml::openElement( 'table', [ 'cellpadding' => 9 ] ); // Name $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), $this->msg( 'centralnotice-notice-name' )->escaped() ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], $this->msg( 'centralnotice-notice-name' )->escaped() ); + $htmlOut .= Xml::tags( 'td', [], Xml::input( 'noticeName', 25, $request->getVal( 'noticeName' ) ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Start Date $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), $this->msg( 'centralnotice-start-date' )->escaped() ); - $htmlOut .= Xml::tags( 'td', array(), $this->dateSelector( 'start', $this->editable, $start ) ); + $htmlOut .= Xml::tags( 'td', [], $this->msg( 'centralnotice-start-date' )->escaped() ); + $htmlOut .= Xml::tags( 'td', [], $this->dateSelector( 'start', $this->editable, $start ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Start Time $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), $this->msg( 'centralnotice-start-time' )->escaped() ); + $htmlOut .= Xml::tags( 'td', [], $this->msg( 'centralnotice-start-time' )->escaped() ); $htmlOut .= $this->timeSelectorTd( 'start', $this->editable, $start ); $htmlOut .= Xml::closeElement( 'tr' ); // Project $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], $this->msg( 'centralnotice-projects' )->escaped() ); - $htmlOut .= Xml::tags( 'td', array(), $this->projectMultiSelector( $noticeProjects ) ); + $htmlOut .= Xml::tags( 'td', [], $this->projectMultiSelector( $noticeProjects ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Languages $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], $this->msg( 'centralnotice-languages' )->escaped() ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], $this->languageMultiSelector( $noticeLanguages ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Countries $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::label( $this->msg( 'centralnotice-geo' )->text(), 'geotargeted' ) ); - $htmlOut .= Xml::tags( 'td', array(), - Xml::check( 'geotargeted', false, array( 'value' => 1, 'id' => 'geotargeted' ) ) ); + $htmlOut .= Xml::tags( 'td', [], + Xml::check( 'geotargeted', false, [ 'value' => 1, 'id' => 'geotargeted' ] ) ); $htmlOut .= Xml::closeElement( 'tr' ); $htmlOut .= Xml::openElement( 'tr', - array( 'id'=> 'geoMultiSelector', 'style'=> 'display:none;' ) ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + [ 'id'=> 'geoMultiSelector', 'style'=> 'display:none;' ] ); + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], $this->msg( 'centralnotice-countries' )->escaped() ); - $htmlOut .= Xml::tags( 'td', array(), $this->geoMultiSelector() ); + $htmlOut .= Xml::tags( 'td', [], $this->geoMultiSelector() ); $htmlOut .= Xml::closeElement( 'tr' ); $htmlOut .= Xml::closeElement( 'table' ); @@ -413,7 +413,7 @@ // Submit button $htmlOut .= Xml::tags( 'div', - array( 'class' => 'cn-buttons' ), + [ 'class' => 'cn-buttons' ], $this->makeSummaryField( true ) . Xml::submitButton( $this->msg( 'centralnotice-modify' )->text() ) ); @@ -510,18 +510,18 @@ $htmlOut = ''; // Begin Campaign detail fieldset - $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); + $htmlOut .= Xml::openElement( 'fieldset', [ 'class' => 'prefsection' ] ); if ( $this->editable ) { $htmlOut .= Xml::openElement( 'form', - array( + [ 'method' => 'post', 'id' => 'centralnotice-notice-detail', - 'action' => $this->getPageTitle()->getLocalURL( array( + 'action' => $this->getPageTitle()->getLocalURL( [ 'subaction' => 'noticeDetail', 'notice' => $notice - ) ) - ) + ] ) + ] ); } @@ -561,10 +561,10 @@ // Submit button $htmlOut .= Xml::tags( 'div', - array( 'class' => 'cn-buttons' ), + [ 'class' => 'cn-buttons' ], Xml::submitButton( $this->msg( 'centralnotice-modify' )->text(), - array( 'id' => 'noticeDetailSubmit' ) + [ 'id' => 'noticeDetailSubmit' ] ) ); } @@ -733,7 +733,7 @@ if ( $request->getCheck( $mixinControlName ) ) { - $params = array(); + $params = []; foreach ( $mixinDef['parameters'] as $paramName => $paramDef ) { @@ -788,10 +788,10 @@ // If there were no errors, reload the page to prevent duplicate form submission if ( !$this->centralNoticeError ) { - $this->getOutput()->redirect( $this->getPageTitle()->getLocalURL( array( + $this->getOutput()->redirect( $this->getPageTitle()->getLocalURL( [ 'subaction' => 'noticeDetail', 'notice' => $notice - ) ) ); + ] ) ); return; } @@ -818,9 +818,9 @@ global $wgNoticeNumberOfBuckets, $wgCentralNoticeCampaignMixins; if ( $this->editable ) { - $readonly = array(); + $readonly = []; } else { - $readonly = array( 'disabled' => 'disabled' ); + $readonly = [ 'disabled' => 'disabled' ]; } $campaign = Campaign::getCampaignSettings( $notice ); @@ -837,11 +837,11 @@ $throttle = $request->getInt( 'throttle', 100 ); $isLocked = $request->getCheck( 'locked' ); $isArchived = $request->getCheck( 'archived' ); - $noticeProjects = $request->getArray( 'projects', array() ); - $noticeLanguages = $request->getArray( 'project_languages', array() ); + $noticeProjects = $request->getArray( 'projects', [] ); + $noticeLanguages = $request->getArray( 'project_languages', [] ); $isGeotargeted = $request->getCheck( 'geotargeted' ); $numBuckets = $request->getInt( 'buckets', 1 ); - $countries = $request->getArray( 'geo_countries', array() ); + $countries = $request->getArray( 'geo_countries', [] ); } else { // Defaults $start = $campaign[ 'start' ]; $end = $campaign[ 'end' ]; @@ -862,125 +862,125 @@ $htmlOut = ''; $htmlOut .= Xml::tags( 'h2', null, $this->msg( 'centralnotice-notice-heading', $notice )->text() ); - $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' => 9 ) ); + $htmlOut .= Xml::openElement( 'table', [ 'cellpadding' => 9 ] ); // Rows // Start Date $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), $this->msg( 'centralnotice-start-date' )->escaped() ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], $this->msg( 'centralnotice-start-date' )->escaped() ); + $htmlOut .= Xml::tags( 'td', [], $this->dateSelector( 'start', $this->editable, $start ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Start Time $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), $this->msg( 'centralnotice-start-time' )->escaped() ); + $htmlOut .= Xml::tags( 'td', [], $this->msg( 'centralnotice-start-time' )->escaped() ); $htmlOut .= $this->timeSelectorTd( 'start', $this->editable, $start ); $htmlOut .= Xml::closeElement( 'tr' ); // End Date $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), $this->msg( 'centralnotice-end-date' )->escaped() ); - $htmlOut .= Xml::tags( 'td', array(), $this->dateSelector( 'end', $this->editable, $end ) ); + $htmlOut .= Xml::tags( 'td', [], $this->msg( 'centralnotice-end-date' )->escaped() ); + $htmlOut .= Xml::tags( 'td', [], $this->dateSelector( 'end', $this->editable, $end ) ); $htmlOut .= Xml::closeElement( 'tr' ); // End Time $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), $this->msg( 'centralnotice-end-time' )->escaped() ); + $htmlOut .= Xml::tags( 'td', [], $this->msg( 'centralnotice-end-time' )->escaped() ); $htmlOut .= $this->timeSelectorTd( 'end', $this->editable, $end ); $htmlOut .= Xml::closeElement( 'tr' ); // Project $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], $this->msg( 'centralnotice-projects' )->escaped() ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], $this->projectMultiSelector( $noticeProjects ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Languages $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], $this->msg( 'centralnotice-languages' )->escaped() ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], $this->languageMultiSelector( $noticeLanguages ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Countries $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::label( $this->msg( 'centralnotice-geo' )->text(), 'geotargeted' ) ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::check( 'geotargeted', $isGeotargeted, array_replace( $readonly, - array( 'value' => $notice, 'id' => 'geotargeted' ) ) ) ); + [ 'value' => $notice, 'id' => 'geotargeted' ] ) ) ); $htmlOut .= Xml::closeElement( 'tr' ); - $htmlOut .= Xml::openElement( 'tr', array( 'id'=> 'geoMultiSelector' ) ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::openElement( 'tr', [ 'id'=> 'geoMultiSelector' ] ); + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], $this->msg( 'centralnotice-countries' )->escaped() ); - $htmlOut .= Xml::tags( 'td', array(), $this->geoMultiSelector( $countries ) ); + $htmlOut .= Xml::tags( 'td', [], $this->geoMultiSelector( $countries ) ); $htmlOut .= Xml::closeElement( 'tr' ); // User bucketing $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::label( $this->msg( 'centralnotice-buckets' )->text(), 'buckets' ) ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], $this->numBucketsDropDown( $wgNoticeNumberOfBuckets, $numBuckets ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Enabled $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::label( $this->msg( 'centralnotice-enabled' )->text(), 'enabled' ) ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::check( 'enabled', $isEnabled, array_replace( $readonly, - array( 'value' => $notice, 'id' => 'enabled' ) ) ) ); + [ 'value' => $notice, 'id' => 'enabled' ] ) ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Preferred / Priority $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::label( $this->msg( 'centralnotice-preferred' )->text(), 'priority' ) ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], $this::prioritySelector( false, $this->editable, $priority ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Throttle impressions $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::label( $this->msg( 'centralnotice-throttle' )->text(), 'throttle-enabled' ) ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::check( 'throttle-enabled', $isThrottled, array_replace( $readonly, - array( 'value' => $notice, 'id' => 'throttle-enabled' ) ) ) ); + [ 'value' => $notice, 'id' => 'throttle-enabled' ] ) ) ); $htmlOut .= Xml::closeElement( 'tr' ); // Throttle value - $htmlOut .= Xml::openElement( 'tr', array( 'class' => 'cn-throttle-amount' ) ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::openElement( 'tr', [ 'class' => 'cn-throttle-amount' ] ); + $htmlOut .= Xml::tags( 'td', [], Xml::label( $this->msg( 'centralnotice-throttle-amount' )->text(), 'throttle' ) ); $throttleLabel = strval( $throttle ) . "%"; if ( $this->editable ) { - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::span( $throttleLabel, 'cn-throttle', - array( 'id' => 'centralnotice-throttle-echo' ) ) . + [ 'id' => 'centralnotice-throttle-echo' ] ) . Html::hidden( 'throttle-cur', $throttle, - array( 'id' => 'centralnotice-throttle-cur' ) ) . - Xml::tags( 'div', array( 'id' => 'centralnotice-throttle-amount' ), '' ) ); + [ 'id' => 'centralnotice-throttle-cur' ] ) . + Xml::tags( 'div', [ 'id' => 'centralnotice-throttle-amount' ], '' ) ); } else { - $htmlOut .= Xml::tags( 'td', array(), $throttleLabel ); + $htmlOut .= Xml::tags( 'td', [], $throttleLabel ); } $htmlOut .= Xml::closeElement( 'tr' ); // Locked $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::label( $this->msg( 'centralnotice-locked' )->text(), 'locked' ) ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::check( 'locked', $isLocked, array_replace( $readonly, - array( 'value' => $notice, 'id' => 'locked' ) ) ) ); + [ 'value' => $notice, 'id' => 'locked' ] ) ) ); $htmlOut .= Xml::closeElement( 'tr' ); if ( $this->editable ) { // Locked $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::label( $this->msg( 'centralnotice-archive-campaign' )->text(), 'archive' ) ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::check( 'archive', $isArchived, - array( 'value' => $notice, 'id' => 'archive' ) ) ); + [ 'value' => $notice, 'id' => 'archive' ] ) ); $htmlOut .= Xml::closeElement( 'tr' ); } $htmlOut .= Xml::closeElement( 'table' ); @@ -998,12 +998,12 @@ $mixinControlName = self::makeNoticeMixinControlName( $mixinName ); - $attribs = array( + $attribs = [ 'value' => $notice, 'class' => 'noticeMixinCheck', 'id' => $mixinControlName, 'data-mixin-name' => $mixinName - ); + ]; if ( isset( $mixinsThisNotice[$mixinName] ) ) { @@ -1035,12 +1035,12 @@ $htmlOut .= Xml::label( $this->msg( $mixinDef['nameMsg'] )->text(), $mixinControlName, - array( 'for' => $mixinControlName ) + [ 'for' => $mixinControlName ] ); if ( !empty( $mixinDef['helpMsg'] ) ) { $htmlOut .= Html::element( 'div', - array( 'class' => 'htmlform-help' ), + [ 'class' => 'htmlform-help' ], $this->msg( $mixinDef['helpMsg'] )->text() ); } @@ -1077,25 +1077,25 @@ $dbr = CNDatabase::getDb(); $res = $dbr->select( // Aliases are needed to avoid problems with table prefixes - array( + [ 'notices' => 'cn_notices', 'assignments' => 'cn_assignments', 'templates' => 'cn_templates' - ), - array( + ], + [ 'templates.tmp_id', 'templates.tmp_name', 'assignments.tmp_weight', 'assignments.asn_bucket', 'notices.not_buckets', - ), - array( + ], + [ 'notices.not_name' => $notice, 'notices.not_id = assignments.not_id', 'assignments.tmp_id = templates.tmp_id' - ), + ], __METHOD__, - array( 'ORDER BY' => 'assignments.asn_bucket, notices.not_id' ) + [ 'ORDER BY' => 'assignments.asn_bucket, notices.not_id' ] ); // No banners found @@ -1104,14 +1104,14 @@ } if ( $this->editable ) { - $readonly = array(); + $readonly = []; } else { - $readonly = array( 'disabled' => 'disabled' ); + $readonly = [ 'disabled' => 'disabled' ]; } - $weights = array(); + $weights = []; - $banners = array(); + $banners = []; foreach ( $res as $row ) { $banners[] = $row; @@ -1147,30 +1147,30 @@ // Equal weight banners $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::label( $this->msg( 'centralnotice-balanced' )->text(), 'balanced' ) ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], Xml::check( 'balanced', $isBalanced, array_replace( $readonly, - array( 'value' => $notice, 'id' => 'balanced' ) ) ) ); + [ 'value' => $notice, 'id' => 'balanced' ] ) ) ); $htmlOut .= Xml::closeElement( 'tr' ); $htmlOut .= Xml::openElement( 'table', - array( + [ 'cellpadding' => 9, 'width' => '100%' - ) + ] ); if ( $this->editable ) { - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '5%' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'width' => '5%' ], $this->msg( "centralnotice-remove" )->text() ); } $htmlOut .= Xml::element( 'th', - array( 'align' => 'left', 'width' => '5%', 'class' => 'cn-weight' ), + [ 'align' => 'left', 'width' => '5%', 'class' => 'cn-weight' ], $this->msg( 'centralnotice-weight' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '5%' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'width' => '5%' ], $this->msg( 'centralnotice-bucket' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '70%' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'width' => '70%' ], $this->msg( 'centralnotice-templates' )->text() ); // Table rows @@ -1179,7 +1179,7 @@ if ( $this->editable ) { // Remove - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], Xml::check( 'removeTemplates[]', false, [ 'value' => $row->tmp_name, 'class' => 'bannerRemoveCheckbox' @@ -1188,13 +1188,13 @@ } // Weight - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'cn-weight' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'cn-weight' ], $this->weightDropDown( "weight[$row->tmp_id]", $row->tmp_weight ) ); // Bucket $numCampaignBuckets = min( intval( $row->not_buckets ), $wgNoticeNumberOfBuckets ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], $this->bucketDropDown( "bucket[$row->tmp_id]", ( $numCampaignBuckets == 1 ? null : intval( $row->asn_bucket ) ), @@ -1204,7 +1204,7 @@ ); // Banner - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], BannerRenderer::linkToBanner( $row->tmp_name ) ); @@ -1215,7 +1215,7 @@ // Sneak in some extra processing, to detect errors in bucket assignment. // Test for campaign buckets without an assigned banner or with multiple banners. - $assignedBuckets = array(); + $assignedBuckets = []; $numBuckets = $this->campaign->getBuckets(); foreach ( $banners as $banner ) { $bannerBucket = $banner->asn_bucket; @@ -1225,9 +1225,9 @@ } // Do any buckets not have a banner assigned? if ( count( $assignedBuckets ) < $numBuckets ) { - $this->campaignWarnings[] = array( + $this->campaignWarnings[] = [ 'centralnotice-banner-empty-bucket' - ); + ]; } return $htmlOut; @@ -1237,7 +1237,7 @@ $selected = intval( $selected ); if ( $this->editable ) { - $html = Html::openElement( 'select', array( 'name' => $name ) ); + $html = Html::openElement( 'select', [ 'name' => $name ] ); foreach ( range( 5, 100, 5 ) as $value ) { $html .= Xml::option( $value, $value, $value === $selected ); } @@ -1270,7 +1270,7 @@ ] ); foreach ( range( 0, $wgNoticeNumberOfBuckets - 1 ) as $value ) { - $attribs = array(); + $attribs = []; if ( $value >= $numberCampaignBuckets ) { $attribs['disabled'] = 'disabled'; } @@ -1294,7 +1294,7 @@ } if ( $this->editable ) { - $html = Html::openElement( 'select', array( 'name' => 'buckets', 'id' => 'buckets' ) ); + $html = Html::openElement( 'select', [ 'name' => 'buckets', 'id' => 'buckets' ] ); foreach ( range( 0, intval( log( $numBuckets, 2 ) ) ) as $value ) { $value = pow( 2, $value ); $html .= Xml::option( $value, $value, $value === $selected ); @@ -1320,21 +1320,21 @@ $htmlOut = Xml::fieldset( $this->msg( 'centralnotice-available-templates' )->text() ); // Banner search box - $htmlOut .= Html::openElement( 'fieldset', array( 'id' => 'cn-template-searchbox' ) ); + $htmlOut .= Html::openElement( 'fieldset', [ 'id' => 'cn-template-searchbox' ] ); $htmlOut .= Html::element( 'legend', null, $this->msg( 'centralnotice-filter-template-banner' )->text() ); - $htmlOut .= Html::element( 'label', array( 'for' => 'tplsearchkey' ), + $htmlOut .= Html::element( 'label', [ 'for' => 'tplsearchkey' ], $this->msg( 'centralnotice-filter-template-prompt' )->text() ); $htmlOut .= Html::input( 'tplsearchkey', $searchTerms ); $htmlOut .= Html::element( 'input', - array( + [ 'type'=> 'submit', 'name'=> 'template-search', 'value' => $this->msg( 'centralnotice-filter-template-submit' )->text() - ) + ] ); $htmlOut .= Html::closeElement( 'fieldset' ); @@ -1344,11 +1344,11 @@ // Show paginated list of banners $htmlOut .= Xml::tags( 'div', - array( 'class' => 'cn-pager' ), + [ 'class' => 'cn-pager' ], $pager->getNavigationBar() ); $htmlOut .= $pager->getBody(); $htmlOut .= Xml::tags( 'div', - array( 'class' => 'cn-pager' ), + [ 'class' => 'cn-pager' ], $pager->getNavigationBar() ); } else { @@ -1366,7 +1366,7 @@ * * @return string multiple select list */ - function languageMultiSelector( $selected = array() ) { + function languageMultiSelector( $selected = [] ) { global $wgLanguageCode; // Retrieve the list of languages in user's language @@ -1388,12 +1388,12 @@ ) . "\n"; } - $properties = array( + $properties = [ 'multiple' => 'multiple', 'id' =>'project_languages', 'name' => 'project_languages[]', 'class' => 'cn-multiselect' - ); + ]; if ( !$this->editable ) { $properties['disabled'] = 'disabled'; } @@ -1408,7 +1408,7 @@ * * @return string multiple select list */ - function projectMultiSelector( $selected = array() ) { + function projectMultiSelector( $selected = [] ) { global $wgNoticeProjects; $options = "\n"; @@ -1420,12 +1420,12 @@ ) . "\n"; } - $properties = array( + $properties = [ 'multiple' => 'multiple', 'id' =>'projects', 'name' => 'projects[]', 'class' => 'cn-multiselect' - ); + ]; if ( !$this->editable ) { $properties['disabled'] = 'disabled'; } @@ -1455,15 +1455,15 @@ return Xml::element( 'label', - array( 'class' => 'cn-change-summary-label' ), + [ 'class' => 'cn-change-summary-label' ], $this->msg( 'centralnotice-change-summary-label' )->escaped() ) . Xml::element( 'input', - array( + [ 'class' => 'cn-change-summary-input', 'placeholder' => $this->msg( $placeholderMsg )->escaped(), 'size' => 45, 'name' => 'changeSummary' - ) + ] ); } @@ -1473,7 +1473,7 @@ protected function paddedRange( $begin, $end ) { $unpaddedRange = range( $begin, $end ); - $paddedRange = array(); + $paddedRange = []; foreach ( $unpaddedRange as $number ) { $paddedRange[ ] = sprintf( "%02d", $number ); // pad number with 0 if needed } @@ -1492,7 +1492,7 @@ * * @return string multiple select list */ - function geoMultiSelector( $selected = array() ) { + function geoMultiSelector( $selected = [] ) { $userLanguageCode = $this->getLanguage()->getCode(); $countries = GeoTarget::getCountriesList( $userLanguageCode ); $options = "\n"; @@ -1504,12 +1504,12 @@ ) . "\n"; } - $properties = array( + $properties = [ 'multiple' => 'multiple', 'id' => 'geo_countries', 'name' => 'geo_countries[]', 'class' => 'cn-multiselect' - ); + ]; if ( !$this->editable ) { $properties['disabled'] = 'disabled'; } @@ -1566,15 +1566,15 @@ } // Clear the special page tab that's there already - $tabs['namespaces'] = array(); + $tabs['namespaces'] = []; // Now add our own foreach ( $wgNoticeTabifyPages as $page => $keys ) { - $tabs[ $keys[ 'type' ] ][ $page ] = array( + $tabs[ $keys[ 'type' ] ][ $page ] = [ 'text' => wfMessage( $keys[ 'message' ] ), 'href' => SpecialPage::getTitleFor( $page )->getFullURL(), 'class' => ( $alias === $page ) ? 'selected' : '', - ); + ]; } return true; diff --git a/special/SpecialCentralNoticeBanners.php b/special/SpecialCentralNoticeBanners.php index e355d5e..7c6c3ca 100644 --- a/special/SpecialCentralNoticeBanners.php +++ b/special/SpecialCentralNoticeBanners.php @@ -108,7 +108,7 @@ // Process the form that we sent out $formDescriptor = $this->generateBannerListForm( $this->bannerFilterString ); $htmlForm = new CentralNoticeHtmlForm( $formDescriptor, $this->getContext() ); - $htmlForm->setSubmitCallback( array( $this, 'processBannerList' ) ); + $htmlForm->setSubmitCallback( [ $this, 'processBannerList' ] ); $htmlForm->loadData(); $formResult = $htmlForm->trySubmit(); @@ -140,28 +140,28 @@ // Note: filter is normally set via JS, not form submission. But we // leave the info in the submitted form, in any case. - $formDescriptor = array( - 'bannerNameFilter' => array( + $formDescriptor = [ + 'bannerNameFilter' => [ 'section' => 'header/banner-search', 'class' => 'HTMLTextField', 'placeholder' => wfMessage( 'centralnotice-filter-template-prompt' ), - 'filter-callback' => array( $this, 'sanitizeSearchTerms' ), + 'filter-callback' => [ $this, 'sanitizeSearchTerms' ], 'default' => $filter, - ), - 'filterApply' => array( + ], + 'filterApply' => [ 'section' => 'header/banner-search', 'class' => 'HTMLButtonField', 'default' => wfMessage( 'centralnotice-filter-template-submit' )->text(), - ) - ); + ] + ]; // --- Create the management options --- // - $formDescriptor += array( - 'selectAllBanners' => array( + $formDescriptor += [ + 'selectAllBanners' => [ 'section' => 'header/banner-bulk-manage', 'class' => 'HTMLCheckField', 'disabled' => !$this->editable, - ), + ], /* TODO: Actually enable this feature 'archiveSelectedBanners' => array( 'section' => 'header/banner-bulk-manage', @@ -170,57 +170,57 @@ 'disabled' => !$this->editable, ), */ - 'deleteSelectedBanners' => array( + 'deleteSelectedBanners' => [ 'section' => 'header/banner-bulk-manage', 'class' => 'HTMLButtonField', 'default' => wfMessage( 'centralnotice-remove' )->text(), 'disabled' => !$this->editable, - ), - 'addNewBanner' => array( + ], + 'addNewBanner' => [ 'section' => 'header/one-off', 'class' => 'HTMLButtonField', 'default' => wfMessage( 'centralnotice-add-template' )->text(), 'disabled' => !$this->editable, - ), - 'newBannerName' => array( + ], + 'newBannerName' => [ 'section' => 'addBanner', 'class' => 'HTMLTextField', 'disabled' => !$this->editable, 'label' => wfMessage( 'centralnotice-banner-name' )->text(), - ), - 'newBannerEditSummary' => array( + ], + 'newBannerEditSummary' => [ 'section' => 'addBanner', 'class' => 'HTMLTextField', 'label-message' => 'centralnotice-change-summary-label', 'placeholder' => wfMessage( 'centralnotice-change-summary-action-prompt' ), 'disabled' => !$this->editable, - 'filter-callback' => array( $this, 'truncateSummaryField' ) - ), - 'removeBannerEditSummary' => array( + 'filter-callback' => [ $this, 'truncateSummaryField' ] + ], + 'removeBannerEditSummary' => [ 'section' => 'removeBanner', 'class' => 'HTMLTextField', 'label-message' => 'centralnotice-change-summary-label', 'placeholder' => wfMessage( 'centralnotice-change-summary-action-prompt' ), 'disabled' => !$this->editable, - 'filter-callback' => array( $this, 'truncateSummaryField' ) - ), - 'action' => array( + 'filter-callback' => [ $this, 'truncateSummaryField' ] + ], + 'action' => [ 'type' => 'hidden', - ) - ); + ] + ]; // --- Add all the banners via the fancy pager object --- $pager = new CNBannerPager( $this, 'banner-list', - array( - 'applyTo' => array( + [ + 'applyTo' => [ 'section' => 'banner-list', 'class' => 'HTMLCheckField', 'cssclass' => 'cn-bannerlist-check-applyto', - ) - ), - array(), + ] + ], + [], $filter, $this->editable ); @@ -264,7 +264,7 @@ false, false, // Default values of a zillion parameters... - false, array(), array(), null, + false, [], [], null, $formData['newBannerEditSummary'] ); @@ -288,7 +288,7 @@ case 'remove': $summary = $formData['removeBannerEditSummary']; - $failed = array(); + $failed = []; foreach ( $formData as $element => $value ) { $parts = explode( '-', $element, 2 ); if ( ( $parts[0] === 'applyTo' ) && ( $value === true ) ) { @@ -355,7 +355,7 @@ public function getFilterUrlParamAsArray() { return $this->bannerFilterString ? - array( 'filter' => $this->bannerFilterString ) : array(); + [ 'filter' => $this->bannerFilterString ] : []; } /** @@ -365,18 +365,18 @@ * @return array */ private function getBannerPreviewEditLinks() { - $links = array( + $links = [ Linker::linkKnown( SpecialPage::getTitleFor( 'Randompage' ), $this->msg( 'centralnotice-live-preview' )->escaped(), - array( 'class' => 'cn-banner-list-element-label-text' ), - array( + [ 'class' => 'cn-banner-list-element-label-text' ], + [ 'banner' => $this->bannerName, 'uselang' => $this->bannerLanguagePreview, 'force' => '1', - ) + ] ) - ); + ]; $bannerObj = Banner::fromName( $this->bannerName ); $bannerTitle = $bannerObj->getTitle(); @@ -385,8 +385,8 @@ $links[] = Linker::link( $bannerTitle, $this->msg( 'centralnotice-banner-edit-onwiki' )->escaped(), - array( 'class' => 'cn-banner-list-element-label-text' ), - array( 'action' => 'edit' ) + [ 'class' => 'cn-banner-list-element-label-text' ], + [ 'action' => 'edit' ] ); } @@ -418,7 +418,7 @@ // Now begin form processing $htmlForm = new CentralNoticeHtmlForm( $formDescriptor, $this->getContext(), 'centralnotice' ); - $htmlForm->setSubmitCallback( array( $this, 'processEditBanner' ) ); + $htmlForm->setSubmitCallback( [ $this, 'processEditBanner' ] ); $htmlForm->loadData(); $formResult = $htmlForm->tryAuthorizedSubmit(); @@ -432,7 +432,7 @@ $htmlForm = new CentralNoticeHtmlForm( $formDescriptor, $this->getContext(), 'centralnotice' ); - $htmlForm->setSubmitCallback( array( $this, 'processEditBanner' ) )->setId( 'cn-banner-editor' ); + $htmlForm->setSubmitCallback( [ $this, 'processEditBanner' ] )->setId( 'cn-banner-editor' ); // Push the form back to the user $htmlForm->suppressDefaultSubmit()-> @@ -442,7 +442,7 @@ displayForm( $formResult ); $out->addHTML( Xml::element( 'h2', - array( 'class' => 'cn-special-section' ), + [ 'class' => 'cn-special-section' ], $this->msg( 'centralnotice-campaigns-using-banner' )->text() ) ); $pager = new CNCampaignPager( $this, false, $this->banner->getId() ); @@ -470,19 +470,19 @@ } $bannerSettings = $banner->getBannerSettings( $this->bannerName, true ); - $formDescriptor = array(); + $formDescriptor = []; /* --- Banner Preview Section --- */ // FIXME Unused? See T161907 - $formDescriptor[ 'preview' ] = array( + $formDescriptor[ 'preview' ] = [ 'section' => 'preview', 'class' => 'HTMLCentralNoticeBanner', 'banner' => $this->bannerName, 'language' => $this->bannerLanguagePreview, - ); + ]; /* --- Banner Settings --- */ - $formDescriptor['banner-class'] = array( + $formDescriptor['banner-class'] = [ 'section' => 'settings', 'type' => 'selectorother', 'disabled' => !$this->editable, @@ -492,38 +492,38 @@ 'size' => 30, 'maxlength'=> 255, 'default' => $banner->getCategory(), - ); + ]; - $selected = array(); + $selected = []; if ( $bannerSettings[ 'anon' ] === 1 ) { $selected[] = 'anonymous'; } if ( $bannerSettings[ 'account' ] === 1 ) { $selected[] = 'registered'; } - $formDescriptor[ 'display-to' ] = array( + $formDescriptor[ 'display-to' ] = [ 'section' => 'settings', 'type' => 'multiselect', 'disabled' => !$this->editable, 'label-message' => 'centralnotice-banner-display', - 'options' => array( + 'options' => [ $this->msg( 'centralnotice-banner-logged-in' )->text() => 'registered', $this->msg( 'centralnotice-banner-anonymous' )->text() => 'anonymous' - ), + ], 'default' => $selected, 'cssclass' => 'separate-form-element', - ); + ]; $assignedDevices = array_values( CNDeviceTarget::getDevicesAssociatedWithBanner( $banner->getId() ) ); - $availableDevices = array(); + $availableDevices = []; foreach ( CNDeviceTarget::getAvailableDevices() as $k => $value ) { $header = $value[ 'header' ]; $label = $this->getOutput()->parseInline( $value[ 'label' ] ); $availableDevices[ "($header) $label" ] = $header; } - $formDescriptor[ 'device-classes' ] = array( + $formDescriptor[ 'device-classes' ] = [ 'section' => 'settings', 'type' => 'multiselect', 'disabled' => !$this->editable, @@ -531,12 +531,12 @@ 'options' => $availableDevices, 'default' => $assignedDevices, 'cssclass' => 'separate-form-element', - ); + ]; $mixinNames = array_keys( $wgCentralNoticeBannerMixins ); $availableMixins = array_combine( $mixinNames, $mixinNames ); $selectedMixins = array_keys( $banner->getMixins() ); - $formDescriptor['mixins'] = array( + $formDescriptor['mixins'] = [ 'section' => 'settings', 'type' => 'multiselect', 'disabled' => !$this->editable, @@ -545,7 +545,7 @@ 'cssclass' => 'separate-form-element', 'options' => $availableMixins, 'default' => $selectedMixins, - ); + ]; /* --- Translatable Messages Section --- */ $messages = $banner->getMessageFieldsFromCache(); @@ -553,14 +553,14 @@ if ( $messages ) { // Only show this part of the form if messages exist - $formDescriptor[ 'translate-language' ] = array( + $formDescriptor[ 'translate-language' ] = [ 'section' => 'banner-messages', 'class' => 'LanguageSelectHeaderElement', 'label-message' => 'centralnotice-language', 'options' => $languages, 'default' => $this->bannerLanguagePreview, 'cssclass' => 'separate-form-element', - ); + ]; $messageReadOnly = false; if ( $wgNoticeUseTranslateExtension && @@ -576,20 +576,20 @@ Linker::link( $title, htmlspecialchars( $messageName ), - array(), - array( + [], + [ 'group' => BannerMessageGroup::getTranslateGroupName( $banner->getName() ), 'task' => 'view' - ) + ] ) ); } else { $label = htmlspecialchars( $messageName ); } - $formDescriptor[ "message-$messageName" ] = array( + $formDescriptor[ "message-$messageName" ] = [ 'section' => 'banner-messages', 'class' => 'HTMLCentralNoticeBannerMessage', 'label-raw' => $label, @@ -597,7 +597,7 @@ 'message' => $messageName, 'language' => $this->bannerLanguagePreview, 'cssclass' => 'separate-form-element', - ); + ]; if ( !$this->editable || $messageReadOnly ) { $formDescriptor[ "message-$messageName" ][ 'readonly' ] = true; @@ -605,7 +605,7 @@ } if ( $wgNoticeUseTranslateExtension ) { - $formDescriptor[ 'priority-langs' ] = array( + $formDescriptor[ 'priority-langs' ] = [ 'section' => 'banner-messages', 'class' => 'HTMLLargeMultiSelectField', 'disabled' => !$this->editable, @@ -614,12 +614,12 @@ 'default' => $bannerSettings[ 'prioritylangs' ], 'help-message' => 'centralnotice-prioritylangs-explain', 'cssclass' => 'separate-form-element cn-multiselect', - ); + ]; } $liveMessageNames = $banner->getAvailableLanguages(); if ( $liveMessageNames ) { - $formDescriptor[ 'approved-languages' ] = array( + $formDescriptor[ 'approved-languages' ] = [ 'section' => 'banner-messages', 'class' => 'HTMLInfoField', 'disabled' => !$this->editable, @@ -629,7 +629,7 @@ ), 'default' => implode( ', ', $liveMessageNames ), 'cssclass' => 'separate-form-element', - ); + ]; } if ( $wgNoticeUseTranslateExtension && BannerMessageGroup::isUsingGroupReview() ) { @@ -639,35 +639,35 @@ ); if ( $readyStateLangs ) { - $formDescriptor[ 'pending-languages' ] = array( + $formDescriptor[ 'pending-languages' ] = [ 'section' => 'banner-messages', 'class' => 'HTMLInfoField', 'disabled' => !$this->editable, 'label-message' => 'centralnotice-messages-pending-approval', 'default' => implode( ', ', $readyStateLangs ), 'cssclass' => 'separate-form-element', - ); + ]; } } } /* -- The banner editor -- */ - $formDescriptor[ 'banner-magic-words' ] = array( + $formDescriptor[ 'banner-magic-words' ] = [ 'section' => 'edit-template', 'class' => 'HTMLInfoField', 'default' => Html::rawElement( 'div', - array( 'class' => 'separate-form-element' ), + [ 'class' => 'separate-form-element' ], $this->msg( 'centralnotice-edit-template-summary' )->escaped() ), 'rawrow' => true, - ); + ]; $renderer = new BannerRenderer( $this->getContext(), $banner ); $magicWords = $renderer->getMagicWords(); foreach ( $magicWords as &$word ) { $word = '{{{' . $word . '}}}'; } - $formDescriptor[ 'banner-mixin-words' ] = array( + $formDescriptor[ 'banner-mixin-words' ] = [ 'section' => 'edit-template', 'type' => 'info', 'default' => $this->msg( @@ -675,26 +675,26 @@ $this->getLanguage()->listToText( $magicWords ) )->text(), 'rawrow' => true, - ); + ]; - $buttons = array(); + $buttons = []; // TODO: Fix this gawdawful method of inserting the close button $buttons[ ] = '<a href="#" onclick="mw.centralNotice.adminUi.bannerEditor.insertButton(\'close\');' . 'return false;">' . $this->msg( 'centralnotice-close-button' )->text() . '</a>'; - $formDescriptor[ 'banner-insert-button' ] = array( + $formDescriptor[ 'banner-insert-button' ] = [ 'section' => 'edit-template', 'class' => 'HTMLInfoField', 'rawrow' => true, 'default' => Html::rawElement( 'div', - array( 'class' => 'banner-editing-top-hint separate-form-element' ), + [ 'class' => 'banner-editing-top-hint separate-form-element' ], $this->msg( 'centralnotice-insert' )-> rawParams( $this->getLanguage()->commaList( $buttons ) )-> escaped() ), - ); + ]; - $formDescriptor[ 'banner-body' ] = array( + $formDescriptor[ 'banner-body' ] = [ 'section' => 'edit-template', 'type' => 'textarea', 'readonly' => !$this->editable, @@ -702,49 +702,49 @@ 'placeholder' => '<!-- blank banner -->', 'default' => $banner->getBodyContent(), 'cssclass' => 'separate-form-element' - ); + ]; - $links = array(); + $links = []; foreach ( $banner->getIncludedTemplates() as $titleObj ) { $links[] = Linker::link( $titleObj ); } if ( $links ) { - $formDescriptor[ 'links' ] = array( + $formDescriptor[ 'links' ] = [ 'section' => 'edit-template', 'type' => 'info', 'label-message' => 'centralnotice-templates-included', 'default' => implode( '<br />', $links ), 'raw' => true - ); + ]; } /* --- Form bottom options --- */ - $formDescriptor[ 'summary' ] = array( + $formDescriptor[ 'summary' ] = [ 'section' => 'form-actions', 'class' => 'HTMLTextField', 'label-message' => 'centralnotice-change-summary-label', 'placeholder' => wfMessage( 'centralnotice-change-summary-prompt' ), 'disabled' => !$this->editable, - 'filter-callback' => array( $this, 'truncateSummaryField' ) - ); + 'filter-callback' => [ $this, 'truncateSummaryField' ] + ]; - $formDescriptor[ 'save-button' ] = array( + $formDescriptor[ 'save-button' ] = [ 'section' => 'form-actions', 'class' => 'HTMLSubmitField', 'default' => $this->msg( 'centralnotice-save-banner' )->text(), 'disabled' => !$this->editable, 'cssclass' => 'cn-formbutton', 'hidelabel' => true, - ); + ]; - $formDescriptor[ 'clone-button' ] = array( + $formDescriptor[ 'clone-button' ] = [ 'section' => 'form-actions', 'class' => 'HTMLButtonField', 'default' => $this->msg( 'centralnotice-clone' )->text(), 'disabled' => !$this->editable, 'cssclass' => 'cn-formbutton', 'hidelabel' => true, - ); + ]; /* TODO: Add this back in when we can actually support it $formDescriptor[ 'archive-button' ] = array( @@ -757,49 +757,49 @@ ); */ - $formDescriptor[ 'delete-button' ] = array( + $formDescriptor[ 'delete-button' ] = [ 'section' => 'form-actions', 'class' => 'HTMLButtonField', 'default' => $this->msg( 'centralnotice-delete-banner' )->text(), 'disabled' => !$this->editable, 'cssclass' => 'cn-formbutton', 'hidelabel' => true, - ); + ]; /* --- Hidden fields and such --- */ - $formDescriptor[ 'cloneName' ] = array( + $formDescriptor[ 'cloneName' ] = [ 'section' => 'clone-banner', 'type' => 'text', 'disabled' => !$this->editable, 'label-message' => 'centralnotice-clone-name', - ); + ]; - $formDescriptor[ 'cloneEditSummary' ] = array( + $formDescriptor[ 'cloneEditSummary' ] = [ 'section' => 'clone-banner', 'class' => 'HTMLTextField', 'label-message' => 'centralnotice-change-summary-label', 'placeholder' => wfMessage( 'centralnotice-change-summary-action-prompt' ), 'disabled' => !$this->editable, - 'filter-callback' => array( $this, 'truncateSummaryField' ) - ); + 'filter-callback' => [ $this, 'truncateSummaryField' ] + ]; - $formDescriptor[ 'deleteEditSummary' ] = array( + $formDescriptor[ 'deleteEditSummary' ] = [ 'section' => 'delete-banner', 'class' => 'HTMLTextField', 'label-message' => 'centralnotice-change-summary-label', 'placeholder' => wfMessage( 'centralnotice-change-summary-action-prompt' ), 'disabled' => !$this->editable, - 'filter-callback' => array( $this, 'truncateSummaryField' ) - ); + 'filter-callback' => [ $this, 'truncateSummaryField' ] + ]; - $formDescriptor[ 'action' ] = array( + $formDescriptor[ 'action' ] = [ 'section' => 'form-actions', 'type' => 'hidden', // The default is save so that we can still save the banner/form if the banner // preview has seriously borked JS. Maybe one day we'll be able to get Caja up // and working and not have this issue. 'default' => 'save', - ); + ]; // Save the banner object in an instance variable $this->banner = $banner; @@ -902,10 +902,10 @@ if ( array_key_exists( 'priority-langs', $formData ) ) { $prioLang = $formData[ 'priority-langs' ]; if ( !is_array( $prioLang ) ) { - $prioLang = array( $prioLang ); + $prioLang = [ $prioLang ]; } } else { - $prioLang = array(); + $prioLang = []; } $banner->setAllocation( @@ -931,7 +931,7 @@ if ( !Banner::isValidBannerName( $this->bannerName ) ) { $out->addHTML( - Xml::element( 'div', array( 'class' => 'error' ), + Xml::element( 'div', [ 'class' => 'error' ], wfMessage( 'centralnotice-generic-error' ) ) ); return; @@ -956,7 +956,7 @@ // Link and Preview all available translations $htmlOut .= Xml::tags( 'td', - array( 'valign' => 'top' ), + [ 'valign' => 'top' ], $bannerRenderer->previewFieldSet() ); } @@ -987,15 +987,15 @@ public function getInputHTML( $value ) { global $wgContLang; - $html = Xml::openElement( 'table', array( 'class' => 'cn-message-table' ) ); + $html = Xml::openElement( 'table', [ 'class' => 'cn-message-table' ] ); $html .= Xml::openElement( 'tr' ); $code = $wgContLang->getCode(); - $html .= Xml::element( 'td', array( 'class' => 'cn-message-text-origin-header' ), + $html .= Xml::element( 'td', [ 'class' => 'cn-message-text-origin-header' ], Language::fetchLanguageName( $code, $code ) ); - $html .= Xml::openElement( 'td', array( 'class' => 'cn-message-text-native-header' ) ); + $html .= Xml::openElement( 'td', [ 'class' => 'cn-message-text-native-header' ] ); $html .= parent::getInputHTML( $value ); $html .= Xml::closeElement( 'td' ); @@ -1009,7 +1009,7 @@ class HTMLLargeMultiSelectField extends HTMLMultiSelectField { public function getInputHTML( $value ) { if ( !is_array( $value ) ) { - $value = array( $value ); + $value = [ $value ]; } $options = "\n"; @@ -1021,11 +1021,11 @@ ) . "\n"; } - $properties = array( + $properties = [ 'multiple' => 'multiple', 'id' => $this->mID, 'name' => "$this->mName[]", - ); + ]; if ( !empty( $this->mParams[ 'disabled' ] ) ) { $properties[ 'disabled' ] = 'disabled'; diff --git a/special/SpecialCentralNoticeLogs.php b/special/SpecialCentralNoticeLogs.php index 5af8ac0..9720977 100644 --- a/special/SpecialCentralNoticeLogs.php +++ b/special/SpecialCentralNoticeLogs.php @@ -36,18 +36,18 @@ $out->addWikiMsg( 'centralnotice-summary' ); // Begin Banners tab content - $out->addHTML( Xml::openElement( 'div', array( 'id' => 'preferences' ) ) ); + $out->addHTML( Xml::openElement( 'div', [ 'id' => 'preferences' ] ) ); $htmlOut = ''; // Begin log selection fieldset - $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); + $htmlOut .= Xml::openElement( 'fieldset', [ 'class' => 'prefsection' ] ); $title = SpecialPage::getTitleFor( 'CentralNoticeLogs' ); $actionUrl = $title->getLocalURL(); - $htmlOut .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $actionUrl ) ); + $htmlOut .= Xml::openElement( 'form', [ 'method' => 'get', 'action' => $actionUrl ] ); $htmlOut .= Xml::element( 'h2', null, $this->msg( 'centralnotice-view-logs' )->text() ); - $htmlOut .= Xml::openElement( 'div', array( 'id' => 'cn-log-switcher' ) ); + $htmlOut .= Xml::openElement( 'div', [ 'id' => 'cn-log-switcher' ] ); $title = SpecialPage::getTitleFor( 'CentralNoticeLogs' ); $fullUrl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); @@ -71,7 +71,7 @@ $start = $this->getDateValue( 'start' ); $end = $this->getDateValue( 'end' ); - $htmlOut .= Xml::openElement( 'div', array( 'id' => 'cn-log-filters-container' ) ); + $htmlOut .= Xml::openElement( 'div', [ 'id' => 'cn-log-filters-container' ] ); $collapsedImg = $this->getContext()->getLanguage()->isRTL() ? '/CentralNotice/collapsed-rtl.png' : @@ -86,9 +86,9 @@ 'id="cn-uncollapsed-filter-arrow" ' . 'style="display:inline-block;position:relative;top:-2px;"/>' . '</a>'; - $htmlOut .= Xml::tags( 'span', array( 'style' => 'margin-left: 0.3em;' ), + $htmlOut .= Xml::tags( 'span', [ 'style' => 'margin-left: 0.3em;' ], $this->msg( 'centralnotice-filters' )->escaped() ); - $htmlOut .= Xml::openElement( 'div', array( 'id' => 'cn-log-filters' ) ); + $htmlOut .= Xml::openElement( 'div', [ 'id' => 'cn-log-filters' ] ); } else { // filters off $htmlOut .= '<a href="javascript:toggleFilterDisplay()">' . '<img src="' . $wgExtensionAssetsPath.$collapsedImg . '" ' . @@ -98,10 +98,10 @@ 'id="cn-uncollapsed-filter-arrow" ' . 'style="display:none;position:relative;top:-2px;"/>' . '</a>'; - $htmlOut .= Xml::tags( 'span', array( 'style' => 'margin-left: 0.3em;' ), + $htmlOut .= Xml::tags( 'span', [ 'style' => 'margin-left: 0.3em;' ], $this->msg( 'centralnotice-filters' )->escaped() ); $htmlOut .= Xml::openElement( 'div', - array( 'id' => 'cn-log-filters', 'style' => 'display:none;' ) ); + [ 'id' => 'cn-log-filters', 'style' => 'display:none;' ] ); } $htmlOut .= Xml::openElement( 'table' ); @@ -109,7 +109,7 @@ $htmlOut .= Xml::openElement( 'td' ); $htmlOut .= Xml::label( $this->msg( 'centralnotice-start-date' )->text(), 'month', - array( 'class' => 'cn-log-filter-label' ) ); + [ 'class' => 'cn-log-filter-label' ] ); $htmlOut .= Xml::closeElement( 'td' ); $htmlOut .= Xml::openElement( 'td' ); if ( $reset ) { @@ -124,7 +124,7 @@ $htmlOut .= Xml::openElement( 'td' ); $htmlOut .= Xml::label( $this->msg( 'centralnotice-end-date' )->text(), 'month', - array( 'class' => 'cn-log-filter-label' ) ); + [ 'class' => 'cn-log-filter-label' ] ); $htmlOut .= Xml::closeElement( 'td' ); $htmlOut .= Xml::openElement( 'td' ); if ( $reset ) { @@ -139,7 +139,7 @@ $htmlOut .= Xml::openElement( 'td' ); $htmlOut .= Xml::label( $this->msg( 'centralnotice-notice' )->text(), 'campaign', - array( 'class' => 'cn-log-filter-label' ) ); + [ 'class' => 'cn-log-filter-label' ] ); $htmlOut .= Xml::closeElement( 'td' ); $htmlOut .= Xml::openElement( 'td' ); $htmlOut .= Xml::input( 'campaign', 25, ( $reset ? '' : $campaign ) ); @@ -153,7 +153,7 @@ $htmlOut .= Xml::label( $this->msg( 'centralnotice-user' )->text(), 'user', - array( 'class' => 'cn-log-filter-label' ) + [ 'class' => 'cn-log-filter-label' ] ); $htmlOut .= Xml::closeElement( 'td' ); $htmlOut .= Xml::openElement( 'td' ); @@ -164,22 +164,22 @@ $htmlOut .= Xml::closeElement( 'tr' ); $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::openElement( 'td', array( 'colspan' => 2 ) ); + $htmlOut .= Xml::openElement( 'td', [ 'colspan' => 2 ] ); $htmlOut .= Xml::submitButton( $this->msg( 'centralnotice-apply-filters' )->text(), - array( + [ 'id' => 'centralnoticesubmit', 'name' => 'centralnoticesubmit', 'class' => 'cn-filter-buttons', - ) + ] ); $link = $title->getLinkURL(); $htmlOut .= Xml::submitButton( $this->msg( 'centralnotice-clear-filters' )->text(), - array( + [ 'id' => 'centralnoticelogreset', 'name' => 'centralnoticelogreset', 'class' => 'cn-filter-buttons', 'onclick' => "location.href = '$link'; return false;", - ) + ] ); $htmlOut .= Xml::closeElement( 'td' ); @@ -207,20 +207,20 @@ */ protected function dateSelector( $prefix, $editable = true, $date = '' ) { $out = Html::element( 'input', - array( + [ 'id' => "{$prefix}Date", 'name' => "{$prefix}Date", 'type' => 'text', 'class' => 'centralnotice-datepicker', - ) + ] ); $out .= Html::element( 'input', - array( + [ 'id' => "{$prefix}Date_timestamp", 'name' => "{$prefix}Date_timestamp", 'type' => 'hidden', 'value' => $date, - ) + ] ); return $out; } @@ -249,11 +249,11 @@ // Show paginated list of log entries $htmlOut .= Xml::tags( 'div', - array( 'class' => 'cn-pager' ), + [ 'class' => 'cn-pager' ], $pager->getNavigationBar() ); $htmlOut .= $pager->getBody(); $htmlOut .= Xml::tags( 'div', - array( 'class' => 'cn-pager' ), + [ 'class' => 'cn-pager' ], $pager->getNavigationBar() ); // End log fieldset @@ -283,7 +283,7 @@ 'log_type', $id, ( $this->logType == $type ? true : false ), - array( 'onclick' => "switchLogs( '".$fullUrl."', '".$type."' )" ) + [ 'onclick' => "switchLogs( '".$fullUrl."', '".$type."' )" ] ); $htmlOut .= Xml::label( $this->msg( $message )->text(), $id ); return $htmlOut; diff --git a/special/SpecialGlobalAllocation.php b/special/SpecialGlobalAllocation.php index 9b3c4dd..70f1da2 100644 --- a/special/SpecialGlobalAllocation.php +++ b/special/SpecialGlobalAllocation.php @@ -68,7 +68,7 @@ protected function getRequestParams() { $sanitize = function( $param, $regex ) { return filter_var( $param, FILTER_VALIDATE_REGEXP, - array( 'options' => array( 'regexp' => $regex ) ) ); + [ 'options' => [ 'regexp' => $regex ] ] ); }; $this->project = $sanitize( @@ -106,9 +106,9 @@ $this->setHeaders(); // Output ResourceLoader module for styling and javascript functions - $out->addModules( array( + $out->addModules( [ 'ext.centralNotice.adminUi', - ) ); + ] ); // Initialize error variable $this->centralNoticeError = false; @@ -117,26 +117,26 @@ $out->addWikiMsg( 'centralnotice-summary' ); // Begin Banners tab content - $out->addHTML( Html::openElement( 'div', array( 'id' => 'preferences' ) ) ); + $out->addHTML( Html::openElement( 'div', [ 'id' => 'preferences' ] ) ); $htmlOut = ''; // Begin Allocation selection fieldset - $htmlOut .= Html::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); + $htmlOut .= Html::openElement( 'fieldset', [ 'class' => 'prefsection' ] ); - $htmlOut .= Html::openElement( 'form', array( 'method' => 'get' ) ); - $htmlOut .= Html::element( 'h2', array(), + $htmlOut .= Html::openElement( 'form', [ 'method' => 'get' ] ); + $htmlOut .= Html::element( 'h2', [], $this->msg( 'centralnotice-view-allocation' )->text() ); $htmlOut .= Xml::tags( 'p', null, $this->msg( 'centralnotice-allocation-instructions' )->text() ); - $htmlOut .= Html::openElement( 'table', array( 'id' => 'envpicker', 'cellpadding' => 7 ) ); + $htmlOut .= Html::openElement( 'table', [ 'id' => 'envpicker', 'cellpadding' => 7 ] ); $htmlOut .= Html::openElement( 'tr' ); $htmlOut .= Xml::tags( 'td', - array( 'style' => 'width: 20%;' ), + [ 'style' => 'width: 20%;' ], $this->msg( 'centralnotice-project-name' )->text() ); $htmlOut .= Html::openElement( 'td' ); - $htmlOut .= Html::openElement( 'select', array( 'name' => 'project' ) ); + $htmlOut .= Html::openElement( 'select', [ 'name' => 'project' ] ); $htmlOut .= Xml::option( $this->msg( 'centralnotice-all' )->text(), '', '' === $this->project ); @@ -149,7 +149,7 @@ $htmlOut .= Html::closeElement( 'tr' ); $htmlOut .= Html::openElement( 'tr' ); $htmlOut .= Xml::tags( 'td', - array( 'valign' => 'top' ), + [ 'valign' => 'top' ], $this->msg( 'centralnotice-project-lang' )->text() ); $htmlOut .= Html::openElement( 'td' ); @@ -163,7 +163,7 @@ ksort( $languages ); - $htmlOut .= Html::openElement( 'select', array( 'name' => 'language' ) ); + $htmlOut .= Html::openElement( 'select', [ 'name' => 'language' ] ); $htmlOut .= Xml::option( $this->msg( 'centralnotice-all' )->text(), '', '' === $this->language ); @@ -177,13 +177,13 @@ $htmlOut .= Html::closeElement( 'td' ); $htmlOut .= Html::closeElement( 'tr' ); $htmlOut .= Html::openElement( 'tr' ); - $htmlOut .= Xml::tags( 'td', array(), $this->msg( 'centralnotice-country' )->text() ); + $htmlOut .= Xml::tags( 'td', [], $this->msg( 'centralnotice-country' )->text() ); $htmlOut .= Html::openElement( 'td' ); $userLanguageCode = $this->getLanguage()->getCode(); $countries = GeoTarget::getCountriesList( $userLanguageCode ); - $htmlOut .= Html::openElement( 'select', array( 'name' => 'country' ) ); + $htmlOut .= Html::openElement( 'select', [ 'name' => 'country' ] ); $htmlOut .= Xml::option( $this->msg( 'centralnotice-all' )->text(), '', '' === $this->location ); @@ -208,7 +208,7 @@ $htmlOut .= Html::closeElement( 'table' ); $htmlOut .= Xml::tags( 'div', - array( 'class' => 'cn-buttons' ), + [ 'class' => 'cn-buttons' ], Xml::submitButton( $this->msg( 'centralnotice-apply-filters' )->text() ) ); $htmlOut .= Html::closeElement( 'form' ); @@ -232,7 +232,7 @@ $htmlOut = ''; // Begin Allocation list fieldset - $htmlOut .= Html::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); + $htmlOut .= Html::openElement( 'fieldset', [ 'class' => 'prefsection' ] ); $languageLabel = $this->language ? htmlspecialchars( $this->language ) : $this->msg( 'centralnotice-all' )->text(); @@ -276,24 +276,24 @@ */ foreach ( $groupings as $grouping ) { - $htmlOut .= Html::element( 'h2', array(), + $htmlOut .= Html::element( 'h2', [], $this->msg( 'centralnotice-notice-heading', $grouping['label'] )->text() ); $htmlOut .= Html::openElement( 'table', - array( 'cellpadding' => 9, 'class' => 'wikitable', 'style' => 'margin: 1em 0;' ) + [ 'cellpadding' => 9, 'class' => 'wikitable', 'style' => 'margin: 1em 0;' ] ); $htmlOut .= Html::openElement( 'tr' ); - $htmlOut .= Html::element( 'th', array( 'width' => '30%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '30%' ], $this->msg( 'centralnotice-projects' )->text() ); - $htmlOut .= Html::element( 'th', array( 'width' => '30%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '30%' ], $this->msg( 'centralnotice-languages' )->text() ); - $htmlOut .= Html::element( 'th', array( 'width' => '30%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '30%' ], $this->msg( 'centralnotice-countries' )->text() ); $htmlOut .= Html::closeElement( 'tr' ); foreach ( $grouping['rows'] as $row ) { $htmlOut .= Html::openElement( 'tr', - array( 'class'=>'mw-sp-centralnotice-allocationrow' ) ); + [ 'class'=>'mw-sp-centralnotice-allocationrow' ] ); $htmlOut .= Html::openElement( 'td' ); $htmlOut .= $row['projects_label']; @@ -341,7 +341,7 @@ * rows: Cx,y = ({a}, {2}) + ({b}, {1, 2}). */ protected function analyzeGroupings() { - $groupings = array(); + $groupings = []; // starting with the intersection of all campaigns, working towards the // portion of each campaign which does not intersect any others, record @@ -353,8 +353,8 @@ $excludeKeys = array_diff( $campaignKeys, $intersectingKeys ); $result = $this->campaigns[$intersectingKeys[0]]; - $contributing = array(); - $excluding = array(); + $contributing = []; + $excluding = []; foreach ( $intersectingKeys as $key ) { $result = CampaignCriteria::intersect( $result, $this->campaigns[$key] ); @@ -365,7 +365,7 @@ if ( !$result ) { continue; } - $result = array( $result ); + $result = [ $result ]; foreach ( $excludeKeys as $key ) { foreach ( $result as $row ) { @@ -391,22 +391,22 @@ } // Optimization: compact by rendering as text - $rows = array(); + $rows = []; foreach ( $result as $row ) { - $rows[] = array( + $rows[] = [ 'countries_label' => $this->listCountries( $row['countries'] ), 'projects_label' => $this->listProjects( $row['projects'] ), 'languages_label' => $this->listLanguages( $row['languages'] ), - ); + ]; } - $groupings[] = array( + $groupings[] = [ 'label' => $label, 'a_country' => end( $result[0]['countries'] ), 'a_project' => end( $result[0]['projects'] ), 'a_language' => end( $result[0]['languages'] ), 'a_num_buckets' => $result[0]['bucket_count'], 'rows' => $rows, - ); + ]; } } } @@ -425,7 +425,7 @@ throw new InvalidArgumentException( "bad arguments to makeCombinations" ); } if ( $num == count( $list ) ) { - return array( $list ); + return [ $list ]; } $initialElement = array_shift( $list ); @@ -435,7 +435,7 @@ // those including the first element if ( $num == 1 ) { - $combinations[] = array( $initialElement ); + $combinations[] = [ $initialElement ]; } else { foreach ( self::makeCombinations( $list, $num - 1 ) as $innerCombination ) { array_unshift( $innerCombination, $initialElement ); @@ -463,12 +463,12 @@ // collapse any dimensions which do not vary. // TODO: the allocation hash should also be used to collapse groupings which // are identical because of e.g. z-index - $campaignIds = array(); - $banners = array(); + $campaignIds = []; + $banners = []; foreach ( $this->campaigns as $campaign ) { $campaignIds[] = $campaign['id']; foreach ( $campaign['banners'] as $name => $banner ) { - $banners[] = array( + $banners[] = [ 'name' => $name, 'weight' => $banner['weight'], 'bucket' => $banner['bucket'], @@ -477,12 +477,12 @@ 'campaign_num_buckets' => $campaign['bucket_count'], 'display_anon' => $banner['display_anon'], 'display_account' => $banner['display_account'], - ); + ]; } } $device = 'desktop'; // XXX - $hashes = array(); - foreach ( array( true, false ) as $isAnon ) { + $hashes = []; + foreach ( [ true, false ] as $isAnon ) { for ( $bucket = 0; $bucket < $numBuckets; $bucket++ ) { $device = 'desktop'; // XXX @@ -497,7 +497,7 @@ AllocationCalculator::filterAndAllocate( $country, $status, $device, $bucket, $campaigns ); - $allocSignatures = array(); + $allocSignatures = []; foreach ( $variations[$isAnon][$bucket] as $banner ) { $allocSignatures[] = "{$banner['name']}:{$banner['allocation']}"; } @@ -519,22 +519,22 @@ $variesBucket = ( $numBuckets > 1 ); $htmlOut = Html::openElement( 'table', - array( 'cellpadding' => 9, 'class' => 'wikitable sortable', 'style' => 'margin: 1em 0;' ) + [ 'cellpadding' => 9, 'class' => 'wikitable sortable', 'style' => 'margin: 1em 0;' ] ); // $htmlOut .= Html::element( 'caption', array( 'style' => 'font-size: 1.2em;' ), $caption ); $htmlOut .= Html::openElement( 'tr' ); - $htmlOut .= Html::element( 'th', array( 'width' => '5%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '5%' ], $this->msg( 'centralnotice-user-role' )->text() ); if ( $variesBucket ) { - $htmlOut .= Html::element( 'th', array( 'width' => '5%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '5%' ], $this->msg( 'centralnotice-bucket' )->text() ); } - $htmlOut .= Html::element( 'th', array( 'width' => '5%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '5%' ], $this->msg( 'centralnotice-percentage' )->text() ); - $htmlOut .= Html::element( 'th', array( 'width' => '30%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '30%' ], $this->msg( 'centralnotice-banner' )->text() ); - $htmlOut .= Html::element( 'th', array( 'width' => '30%' ), + $htmlOut .= Html::element( 'th', [ 'width' => '30%' ], $this->msg( 'centralnotice-notice' )->text() ); $htmlOut .= Html::closeElement( 'tr' ); @@ -568,7 +568,7 @@ $viewCampaign = $this->getTitleFor( 'CentralNotice' ); // Row begin - $htmlOut .= Html::openElement( 'tr', array( 'class'=>'mw-sp-centralnotice-allocationrow' ) ); + $htmlOut .= Html::openElement( 'tr', [ 'class'=>'mw-sp-centralnotice-allocationrow' ] ); if ( !$variesAnon ) { $anonLabel = $this->msg( 'centralnotice-all' )->text(); @@ -599,9 +599,9 @@ $htmlOut .= Html::closeElement( 'td' ); // Banner name - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); + $htmlOut .= Xml::openElement( 'td', [ 'valign' => 'top' ] ); $htmlOut .= Html::openElement( 'span', - array( 'class' => 'cn-'.$banner['campaign'].'-'.$banner['name'] ) ); + [ 'class' => 'cn-'.$banner['campaign'].'-'.$banner['name'] ] ); $htmlOut .= Linker::link( $viewBanner, htmlspecialchars( $banner['label'] ) @@ -610,15 +610,15 @@ $htmlOut .= Html::closeElement( 'td' ); // Campaign name - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], Linker::link( $viewCampaign, htmlspecialchars( $banner['campaign'] ), - array(), - array( + [], + [ 'subaction' => 'noticeDetail', 'notice' => $banner['campaign'] - ) + ] ) ); } else { @@ -642,7 +642,7 @@ */ protected static function filterCampaigns( $campaigns, $country, $language, $project ) { - $filtered = array(); + $filtered = []; foreach ( $campaigns as $campaign ) { $projectAllowed = ( !$project @@ -666,9 +666,9 @@ } class CampaignCriteria { - static protected $criteria = array( + static protected $criteria = [ 'projects', 'languages', 'countries' - ); + ]; public static function intersect( $a, $b ) { if ( !$a or !$b ) { @@ -699,7 +699,7 @@ return $rows; } - $newRows = array(); + $newRows = []; foreach ( $rows as $row ) { $difference = $row; diff --git a/special/SpecialHideBanners.php b/special/SpecialHideBanners.php index 4d29fc6..c0a03af 100644 --- a/special/SpecialHideBanners.php +++ b/special/SpecialHideBanners.php @@ -65,13 +65,13 @@ $created = time(); $exp = $created + $duration; - $value = array( + $value = [ 'v' => 1, 'created' => $created, 'reason' => $reason - ); + ]; - if ( is_callable( array( 'CentralAuthUser', 'getCookieDomain' ) ) ) { + if ( is_callable( [ 'CentralAuthUser', 'getCookieDomain' ] ) ) { $cookieDomain = CentralAuthUser::getCookieDomain(); } else { $cookieDomain = $wgNoticeCookieDomain; -- To view, visit https://gerrit.wikimedia.org/r/358049 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If3aea4ddf3e66d56781e3a219becaa9657ccd49d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CentralNotice Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits