Index: trunk/extensions/CentralNotice/SpecialBannerListLoader.php |
— | — | @@ -72,7 +72,8 @@ |
73 | 73 | |
74 | 74 | if ( !$templates && $this->project == 'wikipedia' ) { |
75 | 75 | // See if we have any preferred notices for this language wikipedia |
76 | | - $notices = CentralNoticeDB::getNotices( 'wikipedia', $this->language, false, 1, 1, $this->location ); |
| 76 | + $notices = CentralNoticeDB::getNotices( 'wikipedia', $this->language, |
| 77 | + false, 1, 1, $this->location ); |
77 | 78 | |
78 | 79 | if ( $notices ) { |
79 | 80 | // Pull banners |
— | — | @@ -82,7 +83,8 @@ |
83 | 84 | |
84 | 85 | // Didn't find any preferred matches so do an old style lookup |
85 | 86 | if ( !$templates ) { |
86 | | - $templates = CentralNotice::selectNoticeTemplates( $this->project, $this->language, $this->location ); |
| 87 | + $templates = CentralNotice::selectNoticeTemplates( |
| 88 | + $this->project, $this->language, $this->location ); |
87 | 89 | } |
88 | 90 | |
89 | 91 | return FormatJson::encode( $templates ); |
Index: trunk/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -123,19 +123,29 @@ |
124 | 124 | global $wgDBtype, $wgExtNewTables, $wgExtNewFields; |
125 | 125 | |
126 | 126 | if ( $wgDBtype == 'mysql' ) { |
127 | | - $wgExtNewTables[] = array( 'cn_notices', $base . '/CentralNotice.sql' ); |
128 | | - $wgExtNewFields[] = array( 'cn_notices', 'not_preferred', $base . '/patches/patch-notice_preferred.sql' ); |
129 | | - $wgExtNewTables[] = array( 'cn_notice_languages', $base . '/patches/patch-notice_languages.sql' ); |
130 | | - $wgExtNewFields[] = array( 'cn_templates', 'tmp_display_anon', $base . '/patches/patch-template_settings.sql' ); |
131 | | - $wgExtNewTables[] = array( 'cn_notice_countries', $base . '/patches/patch-notice_countries.sql' ); |
| 127 | + $wgExtNewTables[] = array( 'cn_notices', |
| 128 | + $base . '/CentralNotice.sql' ); |
| 129 | + $wgExtNewFields[] = array( 'cn_notices', 'not_preferred', |
| 130 | + $base . '/patches/patch-notice_preferred.sql' ); |
| 131 | + $wgExtNewTables[] = array( 'cn_notice_languages', |
| 132 | + $base . '/patches/patch-notice_languages.sql' ); |
| 133 | + $wgExtNewFields[] = array( 'cn_templates', 'tmp_display_anon', |
| 134 | + $base . '/patches/patch-template_settings.sql' ); |
| 135 | + $wgExtNewTables[] = array( 'cn_notice_countries', |
| 136 | + $base . '/patches/patch-notice_countries.sql' ); |
132 | 137 | } |
133 | 138 | } else { |
134 | 139 | if ( $updater->getDB()->getType() == 'mysql' ) { |
135 | | - $updater->addExtensionUpdate( array( 'addTable', 'cn_notices', $base . '/CentralNotice.sql' ) ); |
136 | | - $updater->addExtensionUpdate( array( 'addField', 'cn_notices', 'not_preferred', $base . '/patches/patch-notice_preferred.sql' ) ); |
137 | | - $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_languages', $base . '/patches/patch-notice_languages.sql' ) ); |
138 | | - $updater->addExtensionUpdate( array( 'addField', 'cn_templates', 'tmp_display_anon', $base . '/patches/patch-template_settings.sql' ) ); |
139 | | - $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_countries', $base . '/patches/patch-notice_countries.sql' ) ); |
| 140 | + $updater->addExtensionUpdate( array( 'addTable', 'cn_notices', |
| 141 | + $base . '/CentralNotice.sql' ) ); |
| 142 | + $updater->addExtensionUpdate( array( 'addField', 'cn_notices', 'not_preferred', |
| 143 | + $base . '/patches/patch-notice_preferred.sql' ) ); |
| 144 | + $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_languages', |
| 145 | + $base . '/patches/patch-notice_languages.sql' ) ); |
| 146 | + $updater->addExtensionUpdate( array( 'addField', 'cn_templates', 'tmp_display_anon', |
| 147 | + $base . '/patches/patch-template_settings.sql' ) ); |
| 148 | + $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_countries', |
| 149 | + $base . '/patches/patch-notice_countries.sql' ) ); |
140 | 150 | } |
141 | 151 | } |
142 | 152 | return true; |
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -147,7 +147,8 @@ |
148 | 148 | if ( $noticeName == '' ) { |
149 | 149 | $this->showError( 'centralnotice-null-string' ); |
150 | 150 | } else { |
151 | | - $this->addNotice( $noticeName, '0', $start, $project_name, $project_languages, $geotargeted, $geo_countries ); |
| 151 | + $this->addNotice( $noticeName, '0', $start, $project_name, |
| 152 | + $project_languages, $geotargeted, $geo_countries ); |
152 | 153 | } |
153 | 154 | } |
154 | 155 | |
— | — | @@ -418,7 +419,10 @@ |
419 | 420 | |
420 | 421 | // If campaign is currently active, set special class on table row. |
421 | 422 | $attribs = array(); |
422 | | - if ( wfTimestamp() > wfTimestamp( TS_UNIX , $row->not_start ) && wfTimestamp() < wfTimestamp( TS_UNIX , $row->not_end ) && $row->not_enabled == '1' ) { |
| 423 | + if ( wfTimestamp() > wfTimestamp( TS_UNIX , $row->not_start ) |
| 424 | + && wfTimestamp() < wfTimestamp( TS_UNIX , $row->not_end ) |
| 425 | + && $row->not_enabled == '1' ) |
| 426 | + { |
423 | 427 | $attribs = array( 'class' => 'cn-active-campaign' ); |
424 | 428 | } |
425 | 429 | |
— | — | @@ -481,7 +485,8 @@ |
482 | 486 | // Name |
483 | 487 | $htmlOut .= Xml::openElement( 'tr' ); |
484 | 488 | $htmlOut .= Xml::tags( 'td', array(), wfMsgHtml( 'centralnotice-notice-name' ) ); |
485 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::input( 'noticeName', 25, $wgRequest->getVal( 'noticeName' ) ) ); |
| 489 | + $htmlOut .= Xml::tags( 'td', array(), |
| 490 | + Xml::input( 'noticeName', 25, $wgRequest->getVal( 'noticeName' ) ) ); |
486 | 491 | $htmlOut .= Xml::closeElement( 'tr' ); |
487 | 492 | // Start Date |
488 | 493 | $htmlOut .= Xml::openElement( 'tr' ); |
— | — | @@ -501,15 +506,21 @@ |
502 | 507 | // Languages |
503 | 508 | $htmlOut .= Xml::openElement( 'tr' ); |
504 | 509 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'yourlanguage' ) ); |
505 | | - $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $noticeLanguages ) ); |
| 510 | + $htmlOut .= Xml::tags( 'td', array(), |
| 511 | + $this->languageMultiSelector( $noticeLanguages ) ); |
506 | 512 | $htmlOut .= Xml::closeElement( 'tr' ); |
507 | 513 | // Countries |
508 | 514 | $htmlOut .= Xml::openElement( 'tr' ); |
509 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-geotargeted' ), 'geotargeted' ) ); |
510 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'geotargeted', false, wfArrayMerge( $readonly, array( 'value' => 1, 'id' => 'geotargeted' ) ) ) ); |
| 515 | + $htmlOut .= Xml::tags( 'td', array(), |
| 516 | + Xml::label( wfMsg( 'centralnotice-geotargeted' ), 'geotargeted' ) ); |
| 517 | + $htmlOut .= Xml::tags( 'td', array(), |
| 518 | + Xml::check( 'geotargeted', false, |
| 519 | + wfArrayMerge( $readonly, array( 'value' => 1, 'id' => 'geotargeted' ) ) ) ); |
511 | 520 | $htmlOut .= Xml::closeElement( 'tr' ); |
512 | | - $htmlOut .= Xml::openElement( 'tr', array( 'id'=>'geoMultiSelector', 'style'=>'display:none;' ) ); |
513 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'centralnotice-countries' ) ); |
| 521 | + $htmlOut .= Xml::openElement( 'tr', |
| 522 | + array( 'id'=>'geoMultiSelector', 'style'=>'display:none;' ) ); |
| 523 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 524 | + wfMsgHtml( 'centralnotice-countries' ) ); |
514 | 525 | $htmlOut .= Xml::tags( 'td', array(), $this->geoMultiSelector() ); |
515 | 526 | $htmlOut .= Xml::closeElement( 'tr' ); |
516 | 527 | |
— | — | @@ -651,7 +662,8 @@ |
652 | 663 | |
653 | 664 | // If there were no errors, reload the page to prevent duplicate form submission |
654 | 665 | if ( !$this->centralNoticeError ) { |
655 | | - $wgOut->redirect( $this->getTitle()->getLocalUrl( "method=listNoticeDetail¬ice=$notice" ) ); |
| 666 | + $wgOut->redirect( $this->getTitle()->getLocalUrl( |
| 667 | + "method=listNoticeDetail¬ice=$notice" ) ); |
656 | 668 | return; |
657 | 669 | } |
658 | 670 | } else { |
— | — | @@ -669,7 +681,8 @@ |
670 | 682 | $htmlOut .= Xml::openElement( 'form', |
671 | 683 | array( |
672 | 684 | 'method' => 'post', |
673 | | - 'action' => $this->getTitle()->getLocalUrl( "method=listNoticeDetail¬ice=$notice" ) |
| 685 | + 'action' => $this->getTitle()->getLocalUrl( |
| 686 | + "method=listNoticeDetail¬ice=$notice" ) |
674 | 687 | ) |
675 | 688 | ); |
676 | 689 | } |
— | — | @@ -820,41 +833,64 @@ |
821 | 834 | // Languages |
822 | 835 | $htmlOut .= Xml::openElement( 'tr' ); |
823 | 836 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'yourlanguage' ) ); |
824 | | - $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $noticeLanguages ) ); |
| 837 | + $htmlOut .= Xml::tags( 'td', array(), |
| 838 | + $this->languageMultiSelector( $noticeLanguages ) ); |
825 | 839 | $htmlOut .= Xml::closeElement( 'tr' ); |
826 | 840 | // Countries |
827 | 841 | $htmlOut .= Xml::openElement( 'tr' ); |
828 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-geotargeted' ), 'geotargeted' ) ); |
829 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'geotargeted', $isGeotargeted, wfArrayMerge( $readonly, array( 'value' => $row->not_name, 'id' => 'geotargeted' ) ) ) ); |
| 842 | + $htmlOut .= Xml::tags( 'td', array(), |
| 843 | + Xml::label( wfMsg( 'centralnotice-geotargeted' ), 'geotargeted' ) ); |
| 844 | + $htmlOut .= Xml::tags( 'td', array(), |
| 845 | + Xml::check( 'geotargeted', $isGeotargeted, |
| 846 | + wfArrayMerge( |
| 847 | + $readonly, |
| 848 | + array( 'value' => $row->not_name, 'id' => 'geotargeted' ) ) ) ); |
830 | 849 | $htmlOut .= Xml::closeElement( 'tr' ); |
831 | 850 | if ( $isGeotargeted ) { |
832 | 851 | $htmlOut .= Xml::openElement( 'tr', array( 'id'=>'geoMultiSelector' ) ); |
833 | 852 | } else { |
834 | | - $htmlOut .= Xml::openElement( 'tr', array( 'id'=>'geoMultiSelector', 'style'=>'display:none;' ) ); |
| 853 | + $htmlOut .= Xml::openElement( 'tr', |
| 854 | + array( 'id'=>'geoMultiSelector', 'style'=>'display:none;' ) ); |
835 | 855 | } |
836 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'centralnotice-countries' ) ); |
| 856 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 857 | + wfMsgHtml( 'centralnotice-countries' ) ); |
837 | 858 | $htmlOut .= Xml::tags( 'td', array(), $this->geoMultiSelector( $countries ) ); |
838 | 859 | $htmlOut .= Xml::closeElement( 'tr' ); |
839 | 860 | // Enabled |
840 | 861 | $htmlOut .= Xml::openElement( 'tr' ); |
841 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-enabled' ), 'enabled' ) ); |
842 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'enabled', $isEnabled, wfArrayMerge( $readonly, array( 'value' => $row->not_name, 'id' => 'enabled' ) ) ) ); |
| 862 | + $htmlOut .= Xml::tags( 'td', array(), |
| 863 | + Xml::label( wfMsg( 'centralnotice-enabled' ), 'enabled' ) ); |
| 864 | + $htmlOut .= Xml::tags( 'td', array(), |
| 865 | + Xml::check( 'enabled', $isEnabled, |
| 866 | + wfArrayMerge( $readonly, |
| 867 | + array( 'value' => $row->not_name, 'id' => 'enabled' ) ) ) ); |
843 | 868 | $htmlOut .= Xml::closeElement( 'tr' ); |
844 | 869 | // Preferred |
845 | 870 | $htmlOut .= Xml::openElement( 'tr' ); |
846 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-preferred' ), 'preferred' ) ); |
847 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'preferred', $isPreferred, wfArrayMerge( $readonly, array( 'value' => $row->not_name, 'id' => 'preferred' ) ) ) ); |
| 871 | + $htmlOut .= Xml::tags( 'td', array(), |
| 872 | + Xml::label( wfMsg( 'centralnotice-preferred' ), 'preferred' ) ); |
| 873 | + $htmlOut .= Xml::tags( 'td', array(), |
| 874 | + Xml::check( 'preferred', $isPreferred, |
| 875 | + wfArrayMerge( $readonly, |
| 876 | + array( 'value' => $row->not_name, 'id' => 'preferred' ) ) ) ); |
848 | 877 | $htmlOut .= Xml::closeElement( 'tr' ); |
849 | 878 | // Locked |
850 | 879 | $htmlOut .= Xml::openElement( 'tr' ); |
851 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-locked' ), 'locked' ) ); |
852 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'locked', $isLocked, wfArrayMerge( $readonly, array( 'value' => $row->not_name, 'id' => 'locked' ) ) ) ); |
| 880 | + $htmlOut .= Xml::tags( 'td', array(), |
| 881 | + Xml::label( wfMsg( 'centralnotice-locked' ), 'locked' ) ); |
| 882 | + $htmlOut .= Xml::tags( 'td', array(), |
| 883 | + Xml::check( 'locked', $isLocked, |
| 884 | + wfArrayMerge( $readonly, |
| 885 | + array( 'value' => $row->not_name, 'id' => 'locked' ) ) ) ); |
853 | 886 | $htmlOut .= Xml::closeElement( 'tr' ); |
854 | 887 | if ( $this->editable ) { |
855 | 888 | // Locked |
856 | 889 | $htmlOut .= Xml::openElement( 'tr' ); |
857 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-remove' ), 'remove' ) ); |
858 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'remove', false, array( 'value' => $row->not_name, 'id' => 'remove' ) ) ); |
| 890 | + $htmlOut .= Xml::tags( 'td', array(), |
| 891 | + Xml::label( wfMsg( 'centralnotice-remove' ), 'remove' ) ); |
| 892 | + $htmlOut .= Xml::tags( 'td', array(), |
| 893 | + Xml::check( 'remove', false, |
| 894 | + array( 'value' => $row->not_name, 'id' => 'remove' ) ) ); |
859 | 895 | $htmlOut .= Xml::closeElement( 'tr' ); |
860 | 896 | } |
861 | 897 | $htmlOut .= Xml::closeElement( 'table' ); |
— | — | @@ -982,9 +1018,13 @@ |
983 | 1019 | $htmlOut = Xml::fieldset( wfMsg( "centralnotice-available-templates" ) ); |
984 | 1020 | |
985 | 1021 | // Show paginated list of banners |
986 | | - $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), $pager->getNavigationBar() ); |
| 1022 | + $htmlOut .= Xml::tags( 'div', |
| 1023 | + array( 'class' => 'cn-pager' ), |
| 1024 | + $pager->getNavigationBar() ); |
987 | 1025 | $htmlOut .= $pager->getBody(); |
988 | | - $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), $pager->getNavigationBar() ); |
| 1026 | + $htmlOut .= Xml::tags( 'div', |
| 1027 | + array( 'class' => 'cn-pager' ), |
| 1028 | + $pager->getNavigationBar() ); |
989 | 1029 | |
990 | 1030 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
991 | 1031 | } else { |
— | — | @@ -1074,7 +1114,9 @@ |
1075 | 1115 | return $templates; |
1076 | 1116 | } |
1077 | 1117 | |
1078 | | - function addNotice( $noticeName, $enabled, $start, $project_name, $project_languages, $geotargeted, $geo_countries ) { |
| 1118 | + function addNotice( $noticeName, $enabled, $start, $project_name, |
| 1119 | + $project_languages, $geotargeted, $geo_countries ) |
| 1120 | + { |
1079 | 1121 | if ( $this->noticeExists( $noticeName ) ) { |
1080 | 1122 | $this->showError( 'centralnotice-notice-exists' ); |
1081 | 1123 | return; |
— | — | @@ -1093,12 +1135,17 @@ |
1094 | 1136 | $end['month'] = '10'; |
1095 | 1137 | $end['year'] = $start['year']; |
1096 | 1138 | } else { |
1097 | | - $end['month'] = ( substr( $start['month'], 0, 1 ) ) == 0 ? 0 . ( intval( $start['month'] ) + 1 ) : ( $start['month'] + 1 ); |
| 1139 | + $end['month'] = |
| 1140 | + ( substr( $start['month'], 0, 1 ) ) == 0 |
| 1141 | + ? 0 . ( intval( $start['month'] ) + 1 ) |
| 1142 | + : ( $start['month'] + 1 ); |
1098 | 1143 | $end['year'] = $start['year']; |
1099 | 1144 | } |
1100 | 1145 | |
1101 | | - $startTs = wfTimeStamp( TS_MW, "{$start['year']}:{$start['month']}:{$start['day']} {$start['hour']}:{$start['min']}:00" ); |
1102 | | - $endTs = wfTimeStamp( TS_MW, "{$end['year']}:{$end['month']}:{$start['day']} {$start['hour']}:{$start['min']}:00" ); |
| 1146 | + $startTs = wfTimeStamp( TS_MW, "{$start['year']}:{$start['month']}:{$start['day']} " . |
| 1147 | + "{$start['hour']}:{$start['min']}:00" ); |
| 1148 | + $endTs = wfTimeStamp( TS_MW, "{$end['year']}:{$end['month']}:{$start['day']} " . |
| 1149 | + "{$start['hour']}:{$start['min']}:00" ); |
1103 | 1150 | |
1104 | 1151 | $res = $dbw->insert( 'cn_notices', |
1105 | 1152 | array( 'not_name' => $noticeName, |
— | — | @@ -1116,7 +1163,8 @@ |
1117 | 1164 | foreach( $project_languages as $code ) { |
1118 | 1165 | $insertArray[] = array( 'nl_notice_id' => $not_id, 'nl_language' => $code ); |
1119 | 1166 | } |
1120 | | - $res = $dbw->insert( 'cn_notice_languages', $insertArray, __METHOD__, array( 'IGNORE' ) ); |
| 1167 | + $res = $dbw->insert( 'cn_notice_languages', $insertArray, |
| 1168 | + __METHOD__, array( 'IGNORE' ) ); |
1121 | 1169 | |
1122 | 1170 | if ( $geotargeted ) { |
1123 | 1171 | // Do multi-row insert for campaign countries |
— | — | @@ -1124,7 +1172,8 @@ |
1125 | 1173 | foreach( $geo_countries as $code ) { |
1126 | 1174 | $insertArray[] = array( 'nc_notice_id' => $not_id, 'nc_country' => $code ); |
1127 | 1175 | } |
1128 | | - $res = $dbw->insert( 'cn_notice_countries', $insertArray, __METHOD__, array( 'IGNORE' ) ); |
| 1176 | + $res = $dbw->insert( 'cn_notice_countries', $insertArray, |
| 1177 | + __METHOD__, array( 'IGNORE' ) ); |
1129 | 1178 | } |
1130 | 1179 | |
1131 | 1180 | $dbw->commit(); |
— | — | @@ -1207,7 +1256,8 @@ |
1208 | 1257 | $row = $dbr->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) ); |
1209 | 1258 | $languages = array(); |
1210 | 1259 | if ( $row ) { |
1211 | | - $res = $dbr->select( 'cn_notice_languages', 'nl_language', array( 'nl_notice_id' => $row->not_id ) ); |
| 1260 | + $res = $dbr->select( 'cn_notice_languages', 'nl_language', |
| 1261 | + array( 'nl_notice_id' => $row->not_id ) ); |
1212 | 1262 | foreach ( $res as $langRow ) { |
1213 | 1263 | $languages[] = $langRow->nl_language; |
1214 | 1264 | } |
— | — | @@ -1221,7 +1271,8 @@ |
1222 | 1272 | $row = $dbr->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) ); |
1223 | 1273 | $countries = array(); |
1224 | 1274 | if ( $row ) { |
1225 | | - $res = $dbr->select( 'cn_notice_countries', 'nc_country', array( 'nc_notice_id' => $row->not_id ) ); |
| 1275 | + $res = $dbr->select( 'cn_notice_countries', 'nc_country', |
| 1276 | + array( 'nc_notice_id' => $row->not_id ) ); |
1226 | 1277 | foreach ( $res as $countryRow ) { |
1227 | 1278 | $countries[] = $countryRow->nc_country; |
1228 | 1279 | } |
— | — | @@ -1384,7 +1435,8 @@ |
1385 | 1436 | function languageMultiSelector( $selected = array(), $customisedOnly = true ) { |
1386 | 1437 | global $wgContLanguageCode, $wgExtensionAssetsPath, $wgLang; |
1387 | 1438 | $scriptPath = "$wgExtensionAssetsPath/CentralNotice"; |
1388 | | - // Make sure the site language is in the list; a custom language code might not have a defined name... |
| 1439 | + // Make sure the site language is in the list; a custom language code |
| 1440 | + // might not have a defined name... |
1389 | 1441 | $languages = Language::getLanguageNames( $customisedOnly ); |
1390 | 1442 | if( !array_key_exists( $wgContLanguageCode, $languages ) ) { |
1391 | 1443 | $languages[$wgContLanguageCode] = $wgContLanguageCode; |
— | — | @@ -1406,16 +1458,26 @@ |
1407 | 1459 | $options |
1408 | 1460 | ); |
1409 | 1461 | $buttons = array(); |
1410 | | - $buttons[] = '<a href="#" onclick="selectLanguages(true);return false;">' . wfMsg( 'powersearch-toggleall' ) . '</a>'; |
1411 | | - $buttons[] = '<a href="#" onclick="selectLanguages(false);return false;">' . wfMsg( 'powersearch-togglenone' ) . '</a>'; |
1412 | | - $buttons[] = '<a href="#" onclick="top10Languages();return false;">' . wfMsg( 'centralnotice-top-ten-languages' ) . '</a>'; |
| 1462 | + $buttons[] = '<a href="#" onclick="selectLanguages(true);return false;">' . |
| 1463 | + wfMsg( 'powersearch-toggleall' ) . '</a>'; |
| 1464 | + $buttons[] = '<a href="#" onclick="selectLanguages(false);return false;">' . |
| 1465 | + wfMsg( 'powersearch-togglenone' ) . '</a>'; |
| 1466 | + $buttons[] = '<a href="#" onclick="top10Languages();return false;">' . |
| 1467 | + wfMsg( 'centralnotice-top-ten-languages' ) . '</a>'; |
1413 | 1468 | $htmlOut .= Xml::tags( 'div', |
1414 | 1469 | array( 'style' => 'margin-top: 0.2em;' ), |
1415 | | - '<img src="'.$scriptPath.'/up-arrow.png" style="vertical-align:baseline;"/>' . wfMsg( 'centralnotice-select', $wgLang->commaList( $buttons ) ) |
| 1470 | + '<img src="'.$scriptPath.'/up-arrow.png" style="vertical-align:baseline;"/>' . |
| 1471 | + wfMsg( 'centralnotice-select', $wgLang->commaList( $buttons ) ) |
1416 | 1472 | ); |
1417 | 1473 | } else { |
1418 | 1474 | $htmlOut .= Xml::tags( 'select', |
1419 | | - array( 'multiple' => 'multiple', 'size' => 4, 'id' => 'project_languages[]', 'name' => 'project_languages[]', 'disabled' => 'disabled' ), |
| 1475 | + array( |
| 1476 | + 'multiple' => 'multiple', |
| 1477 | + 'size' => 4, |
| 1478 | + 'id' => 'project_languages[]', |
| 1479 | + 'name' => 'project_languages[]', |
| 1480 | + 'disabled' => 'disabled' |
| 1481 | + ), |
1420 | 1482 | $options |
1421 | 1483 | ); |
1422 | 1484 | } |
— | — | @@ -1542,12 +1604,23 @@ |
1543 | 1605 | $htmlOut = ''; |
1544 | 1606 | if ( $this->editable ) { |
1545 | 1607 | $htmlOut .= Xml::tags( 'select', |
1546 | | - array( 'multiple' => 'multiple', 'size' => 5, 'id' => 'geo_countries[]', 'name' => 'geo_countries[]' ), |
| 1608 | + array( |
| 1609 | + 'multiple' => 'multiple', |
| 1610 | + 'size' => 5, |
| 1611 | + 'id' => 'geo_countries[]', |
| 1612 | + 'name' => 'geo_countries[]' |
| 1613 | + ), |
1547 | 1614 | $options |
1548 | 1615 | ); |
1549 | 1616 | } else { |
1550 | 1617 | $htmlOut .= Xml::tags( 'select', |
1551 | | - array( 'multiple' => 'multiple', 'size' => 5, 'id' => 'geo_countries[]', 'name' => 'geo_countries[]', 'disabled' => 'disabled' ), |
| 1618 | + array( |
| 1619 | + 'multiple' => 'multiple', |
| 1620 | + 'size' => 5, |
| 1621 | + 'id' => 'geo_countries[]', |
| 1622 | + 'name' => 'geo_countries[]', |
| 1623 | + 'disabled' => 'disabled' |
| 1624 | + ), |
1552 | 1625 | $options |
1553 | 1626 | ); |
1554 | 1627 | } |
— | — | @@ -1578,7 +1651,8 @@ |
1579 | 1652 | 'join_conds' => array( |
1580 | 1653 | 'cn_assignments' => array( |
1581 | 1654 | 'LEFT JOIN', |
1582 | | - "cn_assignments.tmp_id = cn_templates.tmp_id AND cn_assignments.not_id = $noticeId" |
| 1655 | + "cn_assignments.tmp_id = cn_templates.tmp_id " . |
| 1656 | + "AND cn_assignments.not_id = $noticeId" |
1583 | 1657 | ) |
1584 | 1658 | ) |
1585 | 1659 | ); |
— | — | @@ -1607,7 +1681,9 @@ |
1608 | 1682 | // Weight select |
1609 | 1683 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
1610 | 1684 | Xml::listDropDown( "weight[$row->tmp_id]", |
1611 | | - CentralNotice::dropDownList( wfMsg( 'centralnotice-weight' ), range ( 0, 100, 5 ) ) , |
| 1685 | + CentralNotice::dropDownList( |
| 1686 | + wfMsg( 'centralnotice-weight' ), range ( 0, 100, 5 ) |
| 1687 | + ) , |
1612 | 1688 | '', |
1613 | 1689 | '25', |
1614 | 1690 | '', |
Index: trunk/extensions/CentralNotice/SpecialBannerLoader.php |
— | — | @@ -53,7 +53,8 @@ |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Generate the JS for the requested banner |
57 | | - * @return a string of Javascript containing a call to insertBanner() with JSON containing the banner content as the parameter |
| 57 | + * @return a string of Javascript containing a call to insertBanner() |
| 58 | + * with JSON containing the banner content as the parameter |
58 | 59 | */ |
59 | 60 | function getJsNotice( $bannerName ) { |
60 | 61 | // Make sure the banner exists |
— | — | @@ -165,16 +166,18 @@ |
166 | 167 | wfRestoreWarnings(); |
167 | 168 | if ( !$count ) { |
168 | 169 | // Pull long-cached amount |
169 | | - $count = intval( $wgMemc->get( wfMemcKey( 'centralnotice', 'counter', 'fallback' ) ) ); |
| 170 | + $count = intval( $wgMemc->get( |
| 171 | + wfMemcKey( 'centralnotice', 'counter', 'fallback' ) ) ); |
170 | 172 | if ( !$count ) { |
171 | 173 | // Return hard-coded amount if all else fails |
172 | 174 | return 1100000; // Update as needed during fundraiser |
173 | 175 | } |
174 | 176 | } |
175 | | - $wgMemc->set( wfMemcKey( 'centralnotice', 'counter' ), $count, 60 ); // Expire in 60 seconds |
176 | | - $wgMemc->set( wfMemcKey( 'centralnotice', 'counter', 'fallback' ), $count ); // No expiration |
| 177 | + // Expire in 60 seconds |
| 178 | + $wgMemc->set( wfMemcKey( 'centralnotice', 'counter' ), $count, 60 ); |
| 179 | + // No expiration |
| 180 | + $wgMemc->set( wfMemcKey( 'centralnotice', 'counter', 'fallback' ), $count ); |
177 | 181 | } |
178 | 182 | return $count; |
179 | 183 | } |
180 | | - |
181 | 184 | } |
Index: trunk/extensions/CentralNotice/SpecialBannerController.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | global $wgCentralPagePath; |
45 | 45 | |
46 | 46 | $js = $this->getScriptFunctions() . $this->getToggleScripts(); |
47 | | - $js .= <<<EOT |
| 47 | + $js .= <<<JAVASCRIPT |
48 | 48 | ( function( $ ) { |
49 | 49 | $.ajaxSetup({ cache: true }); |
50 | 50 | $.centralNotice = { |
— | — | @@ -53,12 +53,18 @@ |
54 | 54 | 'fn': { |
55 | 55 | 'loadBanner': function( bannerName ) { |
56 | 56 | // Get the requested banner |
57 | | - var bannerPageQuery = $.param( { 'banner': bannerName, 'userlang': wgUserLanguage, 'db': wgDBname, 'sitename': wgSiteName, 'country': Geo.country } ); |
| 57 | + var bannerPageQuery = $.param( { |
| 58 | + 'banner': bannerName, 'userlang': wgUserLanguage, |
| 59 | + 'db': wgDBname, 'sitename': wgSiteName, 'country': Geo.country } ); |
58 | 60 | var bannerPage = '?title=Special:BannerLoader&' + bannerPageQuery; |
59 | | -EOT; |
60 | | - $js .= "\n\t\t\t\tvar bannerScript = '<script type=\"text/javascript\" src=\"".Xml::escapeJsString( $wgCentralPagePath )."' + bannerPage + '\"></script>';\n"; |
61 | | - $js .= <<<EOT |
62 | | - $( '#siteNotice' ).prepend( '<div id="centralNotice" class="' + ( wgNoticeToggleState ? 'expanded' : 'collapsed' ) + '">'+bannerScript+'</div>' ); |
| 61 | +JAVASCRIPT; |
| 62 | + $js .= "\n\t\t\t\tvar bannerScript = '<script type=\"text/javascript\" src=\"" . |
| 63 | + Xml::escapeJsString( $wgCentralPagePath ) . |
| 64 | + "' + bannerPage + '\"></script>';\n"; |
| 65 | + $js .= <<<JAVASCRIPT |
| 66 | + $( '#siteNotice' ).prepend( '<div id="centralNotice" class="' + |
| 67 | + ( wgNoticeToggleState ? 'expanded' : 'collapsed' ) + |
| 68 | + '">'+bannerScript+'</div>' ); |
63 | 69 | }, |
64 | 70 | 'loadBannerList': function( geoOverride ) { |
65 | 71 | if ( geoOverride ) { |
— | — | @@ -85,7 +91,9 @@ |
86 | 92 | |
87 | 93 | for( var i = 0; i < bannerList.length; i++ ) { |
88 | 94 | // Only include this banner if it's inteded for the current user |
89 | | - if( ( wgUserName && bannerList[i].display_account ) || ( !wgUserName && bannerList[i].display_anon == 1 ) ) { |
| 95 | + if( ( wgUserName && bannerList[i].display_account ) || |
| 96 | + ( !wgUserName && bannerList[i].display_anon == 1 ) ) |
| 97 | + { |
90 | 98 | // add the banner to our list once per weight |
91 | 99 | for( var j=0; j < bannerList[i].weight; j++ ) { |
92 | 100 | groomedBannerList.push( bannerList[i] ); |
— | — | @@ -98,7 +106,9 @@ |
99 | 107 | |
100 | 108 | // Load a random banner from our groomed list |
101 | 109 | $.centralNotice.fn.loadBanner( |
102 | | - groomedBannerList[ Math.floor( Math.random() * groomedBannerList.length ) ].name |
| 110 | + groomedBannerList[ |
| 111 | + Math.floor( Math.random() * groomedBannerList.length ) |
| 112 | + ].name |
103 | 113 | ); |
104 | 114 | }, |
105 | 115 | 'getQueryStringVariables': function() { |
— | — | @@ -123,19 +133,19 @@ |
124 | 134 | } |
125 | 135 | } ); //document ready |
126 | 136 | } )( jQuery ); |
127 | | -EOT; |
| 137 | +JAVASCRIPT; |
128 | 138 | return $js; |
129 | 139 | |
130 | 140 | } |
131 | 141 | |
132 | 142 | function getToggleScripts() { |
133 | | - $showStyle = <<<END |
| 143 | + $showStyle = <<<HTML |
134 | 144 | <style type="text/css"> |
135 | 145 | #centralNotice .siteNoticeSmall {display:none;} |
136 | 146 | #centralNotice.collapsed .siteNoticeBig {display:none;} |
137 | 147 | #centralNotice.collapsed .siteNoticeSmall {display:block;} |
138 | 148 | </style> |
139 | | -END; |
| 149 | +HTML; |
140 | 150 | $encShowStyle = Xml::encodeJsVar( $showStyle ); |
141 | 151 | |
142 | 152 | $script = " |
— | — | @@ -145,7 +155,7 @@ |
146 | 156 | } |
147 | 157 | |
148 | 158 | function getScriptFunctions() { |
149 | | - $script = " |
| 159 | + $script = <<<JAVASCRIPT |
150 | 160 | function insertBanner(bannerJson) { |
151 | 161 | jQuery('div#centralNotice').prepend( bannerJson.banner ); |
152 | 162 | } |
— | — | @@ -170,7 +180,9 @@ |
171 | 181 | e.setTime( e.getTime() + (7*24*60*60*1000) ); // one week |
172 | 182 | var work='hidesnmessage='+state+'; expires=' + e.toGMTString() + '; path=/'; |
173 | 183 | document.cookie = work; |
174 | | -}\n\n"; |
| 184 | +} |
| 185 | + |
| 186 | +JAVASCRIPT; |
175 | 187 | return $script; |
176 | 188 | } |
177 | 189 | |
Index: trunk/extensions/CentralNotice/SpecialBannerAllocation.php |
— | — | @@ -59,7 +59,9 @@ |
60 | 60 | |
61 | 61 | $htmlOut .= Xml::openElement( 'table', array ( 'id' => 'envpicker', 'cellpadding' => 7 ) ); |
62 | 62 | $htmlOut .= Xml::openElement( 'tr' ); |
63 | | - $htmlOut .= Xml::tags( 'td', array( 'style' => 'width: 20%;' ), wfMsg( 'centralnotice-project-name' ) ); |
| 63 | + $htmlOut .= Xml::tags( 'td', |
| 64 | + array( 'style' => 'width: 20%;' ), |
| 65 | + wfMsg( 'centralnotice-project-name' ) ); |
64 | 66 | $htmlOut .= Xml::openElement( 'td' ); |
65 | 67 | $htmlOut .= Xml::openElement( 'select', array( 'name' => 'project' ) ); |
66 | 68 | foreach ( $wgNoticeProjects as $value ) { |
— | — | @@ -69,9 +71,12 @@ |
70 | 72 | $htmlOut .= Xml::closeElement( 'td' ); |
71 | 73 | $htmlOut .= Xml::closeElement( 'tr' ); |
72 | 74 | $htmlOut .= Xml::openElement( 'tr' ); |
73 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsg( 'centralnotice-project-language' ) ); |
| 75 | + $htmlOut .= Xml::tags( 'td', |
| 76 | + array( 'valign' => 'top' ), |
| 77 | + wfMsg( 'centralnotice-project-language' ) ); |
74 | 78 | $htmlOut .= Xml::openElement( 'td' ); |
75 | | - // Make sure the site language is in the list; a custom language code might not have a defined name... |
| 79 | + // Make sure the site language is in the list; a custom language code |
| 80 | + // might not have a defined name... |
76 | 81 | $languages = Language::getLanguageNames( true ); |
77 | 82 | if( !array_key_exists( $wgLanguageCode, $languages ) ) { |
78 | 83 | $languages[$wgLanguageCode] = $wgLanguageCode; |
— | — | @@ -79,7 +84,9 @@ |
80 | 85 | ksort( $languages ); |
81 | 86 | $htmlOut .= Xml::openElement( 'select', array( 'name' => 'language' ) ); |
82 | 87 | foreach( $languages as $code => $name ) { |
83 | | - $htmlOut .= Xml::option( wfMsg( 'centralnotice-language-listing', $code, $name ), $code, $code === $this->language ); |
| 88 | + $htmlOut .= Xml::option( |
| 89 | + wfMsg( 'centralnotice-language-listing', $code, $name ), |
| 90 | + $code, $code === $this->language ); |
84 | 91 | } |
85 | 92 | $htmlOut .= Xml::closeElement( 'select' ); |
86 | 93 | $htmlOut .= Xml::closeElement( 'td' ); |
— | — | @@ -153,10 +160,13 @@ |
154 | 161 | $totalWeight += $banner['weight']; |
155 | 162 | } |
156 | 163 | if ( $banners ) { |
157 | | - $htmlOut .= Xml::openElement( 'table', array ( 'cellpadding' => 9, 'class' => 'wikitable sortable' ) ); |
| 164 | + $htmlOut .= Xml::openElement( 'table', |
| 165 | + array ( 'cellpadding' => 9, 'class' => 'wikitable sortable' ) ); |
158 | 166 | $htmlOut .= Xml::openElement( 'tr' ); |
159 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), wfMsg ( 'centralnotice-percentage' ) ); |
160 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '60%' ), wfMsg ( 'centralnotice-banner' ) ); |
| 167 | + $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), |
| 168 | + wfMsg ( 'centralnotice-percentage' ) ); |
| 169 | + $htmlOut .= Xml::element( 'th', array( 'width' => '60%' ), |
| 170 | + wfMsg ( 'centralnotice-banner' ) ); |
161 | 171 | $htmlOut .= Xml::closeElement( 'tr' ); |
162 | 172 | foreach ( $banners as $banner ) { |
163 | 173 | $htmlOut .= Xml::openElement( 'tr' ); |
— | — | @@ -165,7 +175,8 @@ |
166 | 176 | $htmlOut .= wfMsg ( 'percent', $wgLang->formatNum( $percentage ) ); |
167 | 177 | $htmlOut .= Xml::closeElement( 'td' ); |
168 | 178 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
169 | | - $sk->makeLinkObj( $viewPage, htmlspecialchars( $banner['name'] ), 'template=' . urlencode( $banner['name'] ) ) |
| 179 | + $sk->makeLinkObj( $viewPage, htmlspecialchars( $banner['name'] ), |
| 180 | + 'template=' . urlencode( $banner['name'] ) ) |
170 | 181 | ); |
171 | 182 | $htmlOut .= Xml::closeElement( 'tr' ); |
172 | 183 | } |
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php |
— | — | @@ -146,7 +146,8 @@ |
147 | 147 | $newTemplate = $wgRequest->getVal( 'newTemplate' ); |
148 | 148 | // We use the returned name in case any special characters had to be removed |
149 | 149 | $template = $this->cloneTemplate( $oldTemplate, $newTemplate ); |
150 | | - $wgOut->redirect( $this->getTitle( 'view' )->getLocalUrl( "template=$template" ) ); |
| 150 | + $wgOut->redirect( |
| 151 | + $this->getTitle( 'view' )->getLocalUrl( "template=$template" ) ); |
151 | 152 | return; |
152 | 153 | |
153 | 154 | } else { |
— | — | @@ -188,9 +189,11 @@ |
189 | 190 | $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-manage-templates' ) ); |
190 | 191 | |
191 | 192 | // Show paginated list of banners |
192 | | - $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), $pager->getNavigationBar() ); |
| 193 | + $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), |
| 194 | + $pager->getNavigationBar() ); |
193 | 195 | $htmlOut .= $pager->getBody(); |
194 | | - $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), $pager->getNavigationBar() ); |
| 196 | + $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), |
| 197 | + $pager->getNavigationBar() ); |
195 | 198 | |
196 | 199 | if ( $this->editable ) { |
197 | 200 | $htmlOut .= Xml::closeElement( 'form' ); |
— | — | @@ -219,40 +222,53 @@ |
220 | 223 | // Build HTML |
221 | 224 | $htmlOut = ''; |
222 | 225 | $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
223 | | - $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post', 'onsubmit' => 'return validateBannerForm(this)' ) ); |
| 226 | + $htmlOut .= Xml::openElement( 'form', |
| 227 | + array( 'method' => 'post', 'onsubmit' => 'return validateBannerForm(this)' ) ); |
224 | 228 | $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-add-template' ) ); |
225 | 229 | $htmlOut .= Html::hidden( 'wpMethod', 'addTemplate' ); |
226 | 230 | $htmlOut .= Xml::tags( 'p', null, |
227 | | - Xml::inputLabel( wfMsg( 'centralnotice-banner-name' ), 'templateName', 'templateName', 25, $wgRequest->getVal( 'templateName' ) ) |
| 231 | + Xml::inputLabel( |
| 232 | + wfMsg( 'centralnotice-banner-name' ), |
| 233 | + 'templateName', 'templateName', 25, $wgRequest->getVal( 'templateName' ) |
| 234 | + ) |
228 | 235 | ); |
229 | 236 | |
230 | 237 | $htmlOut .= Xml::openElement( 'p', null ); |
231 | 238 | $htmlOut .= wfMsg( 'centralnotice-banner-display' ); |
232 | 239 | if ( $wgRequest->wasPosted() ) { |
233 | | - $displayAnon = $wgRequest->getCheck( 'displayAnon' ); // Restore checkbox state in event of error |
| 240 | + // Restore checkbox state in event of error |
| 241 | + $displayAnon = $wgRequest->getCheck( 'displayAnon' ); |
234 | 242 | } else { |
235 | | - $displayAnon = true; // Default is checked |
| 243 | + // Default is checked |
| 244 | + $displayAnon = true; |
236 | 245 | } |
237 | 246 | $htmlOut .= Xml::check( 'displayAnon', $displayAnon, array( 'id' => 'displayAnon' ) ); |
238 | 247 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' ); |
239 | 248 | if ( $wgRequest->wasPosted() ) { |
240 | | - $displayAccount = $wgRequest->getCheck( 'displayAccount' ); // Restore checkbox state in event of error |
| 249 | + // Restore checkbox state in event of error |
| 250 | + $displayAccount = $wgRequest->getCheck( 'displayAccount' ); |
241 | 251 | } else { |
242 | | - $displayAccount = true; // Default is checked |
| 252 | + // Default is checked |
| 253 | + $displayAccount = true; |
243 | 254 | } |
244 | | - $htmlOut .= Xml::check( 'displayAccount', $displayAccount, array( 'id' => 'displayAccount' ) ); |
| 255 | + $htmlOut .= Xml::check( 'displayAccount', $displayAccount, |
| 256 | + array( 'id' => 'displayAccount' ) ); |
245 | 257 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' ); |
246 | 258 | $htmlOut .= Xml::closeElement( 'p' ); |
247 | 259 | |
248 | 260 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-banner' ) ); |
249 | 261 | $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' ); |
250 | 262 | $buttons = array(); |
251 | | - $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' . wfMsg( 'centralnotice-close-button' ) . '</a>'; |
252 | | - $buttons[] = '<a href="#" onclick="insertButton(\'hide\');return false;">' . wfMsg( 'centralnotice-hide-button' ) . '</a>'; |
253 | | - $buttons[] = '<a href="#" onclick="insertButton(\'translate\');return false;">' . wfMsg( 'centralnotice-translate-button' ) . '</a>'; |
| 263 | + $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' . |
| 264 | + wfMsg( 'centralnotice-close-button' ) . '</a>'; |
| 265 | + $buttons[] = '<a href="#" onclick="insertButton(\'hide\');return false;">' . |
| 266 | + wfMsg( 'centralnotice-hide-button' ) . '</a>'; |
| 267 | + $buttons[] = '<a href="#" onclick="insertButton(\'translate\');return false;">' . |
| 268 | + wfMsg( 'centralnotice-translate-button' ) . '</a>'; |
254 | 269 | $htmlOut .= Xml::tags( 'div', |
255 | 270 | array( 'style' => 'margin-bottom: 0.2em;' ), |
256 | | - '<img src="'.$scriptPath.'/down-arrow.png" style="vertical-align:baseline;"/>' . wfMsg( 'centralnotice-insert', $wgLang->commaList( $buttons ) ) |
| 271 | + '<img src="'.$scriptPath.'/down-arrow.png" style="vertical-align:baseline;"/>' . |
| 272 | + wfMsg( 'centralnotice-insert', $wgLang->commaList( $buttons ) ) |
257 | 273 | ); |
258 | 274 | |
259 | 275 | // Restore banner body state in the event of an error on form submit |
— | — | @@ -319,14 +335,16 @@ |
320 | 336 | // Begin View Banner fieldset |
321 | 337 | $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
322 | 338 | |
323 | | - $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-banner-heading', $currentTemplate ) ); |
| 339 | + $htmlOut .= Xml::element( 'h2', null, |
| 340 | + wfMsg( 'centralnotice-banner-heading', $currentTemplate ) ); |
324 | 341 | |
325 | 342 | // Show preview of banner |
326 | 343 | $render = new SpecialBannerLoader(); |
327 | 344 | $render->siteName = 'Wikipedia'; |
328 | 345 | $render->language = $wpUserLang; |
329 | 346 | if ( $render->language != '' ) { |
330 | | - $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-preview' ) . " ($render->language)", |
| 347 | + $htmlOut .= Xml::fieldset( |
| 348 | + wfMsg( 'centralnotice-preview' ) . " ($render->language)", |
331 | 349 | $render->getHtmlNotice( $wgRequest->getText( 'template' ) ) |
332 | 350 | ); |
333 | 351 | } else { |
— | — | @@ -336,7 +354,8 @@ |
337 | 355 | } |
338 | 356 | |
339 | 357 | // Pull banner text and respect any inc: markup |
340 | | - $bodyPage = Title::newFromText( "Centralnotice-template-{$currentTemplate}", NS_MEDIAWIKI ); |
| 358 | + $bodyPage = Title::newFromText( |
| 359 | + "Centralnotice-template-{$currentTemplate}", NS_MEDIAWIKI ); |
341 | 360 | $curRev = Revision::newFromTitle( $bodyPage ); |
342 | 361 | $body = $curRev ? $curRev->getText() : ''; |
343 | 362 | |
— | — | @@ -363,22 +382,29 @@ |
364 | 383 | ); |
365 | 384 | |
366 | 385 | // Table headers |
367 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '15%' ), wfMsg( 'centralnotice-message' ) ); |
368 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '5%' ), wfMsg ( 'centralnotice-number-uses' ) ); |
369 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), wfMsg ( 'centralnotice-english' ) ); |
| 386 | + $htmlOut .= Xml::element( 'th', array( 'width' => '15%' ), |
| 387 | + wfMsg( 'centralnotice-message' ) ); |
| 388 | + $htmlOut .= Xml::element( 'th', array( 'width' => '5%' ), |
| 389 | + wfMsg ( 'centralnotice-number-uses' ) ); |
| 390 | + $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), |
| 391 | + wfMsg ( 'centralnotice-english' ) ); |
370 | 392 | $languages = Language::getLanguageNames(); |
371 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), $languages[$wpUserLang] ); |
| 393 | + $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), |
| 394 | + $languages[$wpUserLang] ); |
372 | 395 | |
373 | 396 | // Remove duplicate message fields |
374 | 397 | $filteredFields = array(); |
375 | 398 | foreach ( $fields[1] as $field ) { |
376 | | - $filteredFields[$field] = array_key_exists( $field, $filteredFields ) ? $filteredFields[$field] + 1 : 1; |
| 399 | + $filteredFields[$field] = array_key_exists( $field, $filteredFields ) |
| 400 | + ? $filteredFields[$field] + 1 : 1; |
377 | 401 | } |
378 | 402 | |
379 | 403 | // Table rows |
380 | 404 | foreach ( $filteredFields as $field => $count ) { |
381 | 405 | // Message |
382 | | - $message = ( $wpUserLang == 'en' ) ? "Centralnotice-{$currentTemplate}-{$field}" : "Centralnotice-{$currentTemplate}-{$field}/{$wpUserLang}"; |
| 406 | + $message = ( $wpUserLang == 'en' ) |
| 407 | + ? "Centralnotice-{$currentTemplate}-{$field}" |
| 408 | + : "Centralnotice-{$currentTemplate}-{$field}/{$wpUserLang}"; |
383 | 409 | |
384 | 410 | // English value |
385 | 411 | $htmlOut .= Xml::openElement( 'tr' ); |
— | — | @@ -393,7 +419,11 @@ |
394 | 420 | // English text |
395 | 421 | $englishText = wfMsg( 'centralnotice-message-not-set' ); |
396 | 422 | $englishTextExists = false; |
397 | | - if ( Title::newFromText( "Centralnotice-{$currentTemplate}-{$field}", NS_MEDIAWIKI )->exists() ) { |
| 423 | + if ( |
| 424 | + Title::newFromText( |
| 425 | + "Centralnotice-{$currentTemplate}-{$field}", NS_MEDIAWIKI |
| 426 | + )->exists() ) |
| 427 | + { |
398 | 428 | $englishText = wfMsgExt( "Centralnotice-{$currentTemplate}-{$field}", |
399 | 429 | array( 'language' => 'en' ) |
400 | 430 | ); |
— | — | @@ -401,7 +431,10 @@ |
402 | 432 | } |
403 | 433 | $htmlOut .= Xml::tags( 'td', null, |
404 | 434 | Xml::element( 'span', |
405 | | - array( 'style' => 'font-style:italic;' . ( !$englishTextExists ? 'color:silver' : '' ) ), |
| 435 | + array( |
| 436 | + 'style' => 'font-style:italic;' . |
| 437 | + ( !$englishTextExists ? 'color:silver' : '' ) |
| 438 | + ), |
406 | 439 | $englishText |
407 | 440 | ) |
408 | 441 | ); |
— | — | @@ -416,9 +449,13 @@ |
417 | 450 | $foreignTextExists = true; |
418 | 451 | } |
419 | 452 | $htmlOut .= Xml::tags( 'td', null, |
420 | | - Xml::input( "updateText[{$wpUserLang}][{$currentTemplate}-{$field}]", '', $foreignText, |
| 453 | + Xml::input( |
| 454 | + "updateText[{$wpUserLang}][{$currentTemplate}-{$field}]", |
| 455 | + '', |
| 456 | + $foreignText, |
421 | 457 | wfArrayMerge( $readonly, |
422 | | - array( 'style' => 'width:100%;' . ( !$foreignTextExists ? 'color:red' : '' ) ) ) |
| 458 | + array( 'style' => 'width:100%;' . |
| 459 | + ( !$foreignTextExists ? 'color:red' : '' ) ) ) |
423 | 460 | ) |
424 | 461 | ); |
425 | 462 | $htmlOut .= Xml::closeElement( 'tr' ); |
— | — | @@ -430,7 +467,10 @@ |
431 | 468 | $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() ); |
432 | 469 | $htmlOut .= Xml::tags( 'div', |
433 | 470 | array( 'class' => 'cn-buttons' ), |
434 | | - Xml::submitButton( wfMsg( 'centralnotice-modify' ), array( 'name' => 'update' ) ) |
| 471 | + Xml::submitButton( |
| 472 | + wfMsg( 'centralnotice-modify' ), |
| 473 | + array( 'name' => 'update' ) |
| 474 | + ) |
435 | 475 | ); |
436 | 476 | } |
437 | 477 | |
— | — | @@ -457,7 +497,12 @@ |
458 | 498 | ); |
459 | 499 | $htmlOut .= Xml::tags( 'tr', null, |
460 | 500 | Xml::tags( 'td', null, '' ) . |
461 | | - Xml::tags( 'td', null, $sk->makeLinkObj( $newPage, wfMsgHtml( 'centralnotice-preview-all-template-translations' ), "template=$currentTemplate&wpUserLanguage=all" ) ) |
| 501 | + Xml::tags( 'td', null, |
| 502 | + $sk->makeLinkObj( |
| 503 | + $newPage, |
| 504 | + wfMsgHtml( 'centralnotice-preview-all-template-translations' ), |
| 505 | + "template=$currentTemplate&wpUserLanguage=all" ) |
| 506 | + ) |
462 | 507 | ); |
463 | 508 | $htmlOut .= Xml::closeElement( 'table' ); |
464 | 509 | $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() ); |
— | — | @@ -467,7 +512,12 @@ |
468 | 513 | |
469 | 514 | // Show edit form |
470 | 515 | if ( $this->editable ) { |
471 | | - $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post', 'onsubmit' => 'return validateBannerForm(this)' ) ); |
| 516 | + $htmlOut .= Xml::openElement( 'form', |
| 517 | + array( |
| 518 | + 'method' => 'post', |
| 519 | + 'onsubmit' => 'return validateBannerForm(this)' |
| 520 | + ) |
| 521 | + ); |
472 | 522 | $htmlOut .= Html::hidden( 'wpMethod', 'editTemplate' ); |
473 | 523 | } |
474 | 524 | |
— | — | @@ -485,9 +535,11 @@ |
486 | 536 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-settings' ) ); |
487 | 537 | $htmlOut .= Xml::openElement( 'p', null ); |
488 | 538 | $htmlOut .= wfMsg( 'centralnotice-banner-display' ); |
489 | | - $htmlOut .= Xml::check( 'displayAnon', $displayAnon, wfArrayMerge( $disabled, array( 'id' => 'displayAnon' ) ) ); |
| 539 | + $htmlOut .= Xml::check( 'displayAnon', $displayAnon, |
| 540 | + wfArrayMerge( $disabled, array( 'id' => 'displayAnon' ) ) ); |
490 | 541 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' ); |
491 | | - $htmlOut .= Xml::check( 'displayAccount', $displayAccount, wfArrayMerge( $disabled, array( 'id' => 'displayAccount' ) ) ); |
| 542 | + $htmlOut .= Xml::check( 'displayAccount', $displayAccount, |
| 543 | + wfArrayMerge( $disabled, array( 'id' => 'displayAccount' ) ) ); |
492 | 544 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' ); |
493 | 545 | $htmlOut .= Xml::closeElement( 'p' ); |
494 | 546 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
— | — | @@ -495,12 +547,17 @@ |
496 | 548 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-edit-template' ) ); |
497 | 549 | $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' ); |
498 | 550 | $buttons = array(); |
499 | | - $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' . wfMsg( 'centralnotice-close-button' ) . '</a>'; |
500 | | - $buttons[] = '<a href="#" onclick="insertButton(\'hide\');return false;">' . wfMsg( 'centralnotice-hide-button' ) . '</a>'; |
501 | | - $buttons[] = '<a href="#" onclick="insertButton(\'translate\');return false;">' . wfMsg( 'centralnotice-translate-button' ) . '</a>'; |
| 551 | + $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' . |
| 552 | + wfMsg( 'centralnotice-close-button' ) . '</a>'; |
| 553 | + $buttons[] = '<a href="#" onclick="insertButton(\'hide\');return false;">' . |
| 554 | + wfMsg( 'centralnotice-hide-button' ) . '</a>'; |
| 555 | + $buttons[] = '<a href="#" onclick="insertButton(\'translate\');return false;">' . |
| 556 | + wfMsg( 'centralnotice-translate-button' ) . '</a>'; |
502 | 557 | $htmlOut .= Xml::tags( 'div', |
503 | 558 | array( 'style' => 'margin-bottom: 0.2em;' ), |
504 | | - '<img src="'.$scriptPath.'/down-arrow.png" style="vertical-align:baseline;"/>' . wfMsg( 'centralnotice-insert', $wgLang->commaList( $buttons ) ) |
| 559 | + '<img src="' . $scriptPath . '/down-arrow.png" ' . |
| 560 | + 'style="vertical-align:baseline;"/>' . |
| 561 | + wfMsg( 'centralnotice-insert', $wgLang->commaList( $buttons ) ) |
505 | 562 | ); |
506 | 563 | } else { |
507 | 564 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-banner' ) ); |
— | — | @@ -508,7 +565,8 @@ |
509 | 566 | $htmlOut .= Xml::textarea( 'templateBody', $body, 60, 20, $readonly ); |
510 | 567 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
511 | 568 | if ( $this->editable ) { |
512 | | - $htmlOut .= Html::hidden( 'mainform', 'true' ); // Indicate which form was submitted |
| 569 | + // Indicate which form was submitted |
| 570 | + $htmlOut .= Html::hidden( 'mainform', 'true' ); |
513 | 571 | $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() ); |
514 | 572 | $htmlOut .= Xml::tags( 'div', |
515 | 573 | array( 'class' => 'cn-buttons' ), |
— | — | @@ -529,8 +587,12 @@ |
530 | 588 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-clone-notice' ) ); |
531 | 589 | $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' => 9 ) ); |
532 | 590 | $htmlOut .= Xml::openElement( 'tr' ); |
533 | | - $htmlOut .= Xml::inputLabel( wfMsg( 'centralnotice-clone-name' ), 'newTemplate', 'newTemplate', '25' ); |
534 | | - $htmlOut .= Xml::submitButton( wfMsg( 'centralnotice-clone' ), array ( 'id' => 'clone' ) ); |
| 591 | + $htmlOut .= Xml::inputLabel( |
| 592 | + wfMsg( 'centralnotice-clone-name' ), |
| 593 | + 'newTemplate', 'newTemplate', '25' ); |
| 594 | + $htmlOut .= Xml::submitButton( |
| 595 | + wfMsg( 'centralnotice-clone' ), |
| 596 | + array ( 'id' => 'clone' ) ); |
535 | 597 | $htmlOut .= Html::hidden( 'oldTemplate', $currentTemplate ); |
536 | 598 | |
537 | 599 | $htmlOut .= Xml::closeElement( 'tr' ); |
— | — | @@ -776,8 +838,9 @@ |
777 | 839 | // Remove duplicates |
778 | 840 | $filteredFields = array(); |
779 | 841 | foreach ( $fields[1] as $field ) { |
780 | | - $filteredFields[$field] = array_key_exists( $field, $filteredFields ) ? $filteredFields[$field] + 1 : |
781 | | - 1; |
| 842 | + $filteredFields[$field] = array_key_exists( $field, $filteredFields ) |
| 843 | + ? $filteredFields[$field] + 1 |
| 844 | + : 1; |
782 | 845 | } |
783 | 846 | return $filteredFields; |
784 | 847 | } |
— | — | @@ -800,7 +863,9 @@ |
801 | 864 | // Iterate through all possible message fields |
802 | 865 | foreach ( $fields as $field => $count ) { |
803 | 866 | // Put all message fields together for a lookup |
804 | | - $message = ( $lang == 'en' ) ? "Centralnotice-{$template}-{$field}" : "Centralnotice-{$template}-{$field}/{$lang}"; |
| 867 | + $message = ( $lang == 'en' ) |
| 868 | + ? "Centralnotice-{$template}-{$field}" |
| 869 | + : "Centralnotice-{$template}-{$field}/{$lang}"; |
805 | 870 | if ( Title::newFromText( $message, NS_MEDIAWIKI )->exists() ) { |
806 | 871 | $translations[$lang][$field] = wfMsgExt( |
807 | 872 | "Centralnotice-{$template}-{$field}", |
— | — | @@ -821,7 +886,8 @@ |
822 | 887 | public static function templateExists( $templateName ) { |
823 | 888 | $dbr = wfGetDB( DB_SLAVE ); |
824 | 889 | $eTemplateName = htmlspecialchars( $templateName ); |
825 | | - $row = $dbr->selectRow( 'cn_templates', 'tmp_name', array( 'tmp_name' => $eTemplateName ) ); |
| 890 | + $row = $dbr->selectRow( 'cn_templates', 'tmp_name', |
| 891 | + array( 'tmp_name' => $eTemplateName ) ); |
826 | 892 | if ( $row ) { |
827 | 893 | return true; |
828 | 894 | } else { |