http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72765
Revision: 72765
Author: kaldari
Date: 2010-09-10 23:07:27 +0000 (Fri, 10 Sep 2010)
Log Message:
-----------
beginning to add geotargetting interface
Modified Paths:
--------------
trunk/extensions/CentralNotice/SpecialCentralNotice.php
trunk/extensions/CentralNotice/centralnotice.css
trunk/extensions/CentralNotice/centralnotice.js
Modified: trunk/extensions/CentralNotice/SpecialCentralNotice.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialCentralNotice.php 2010-09-10
22:40:47 UTC (rev 72764)
+++ trunk/extensions/CentralNotice/SpecialCentralNotice.php 2010-09-10
23:07:27 UTC (rev 72765)
@@ -506,6 +506,16 @@
$htmlOut .= Xml::tags( 'td', array( 'valign' => 'top'
), wfMsgHtml( 'yourlanguage' ) );
$htmlOut .= Xml::tags( 'td', array(),
$this->languageMultiSelector( $noticeLanguages ) );
$htmlOut .= Xml::closeElement( 'tr' );
+ // Countries
+ $htmlOut .= Xml::openElement( 'tr' );
+ $htmlOut .= Xml::tags( 'td', array(), Xml::label(
'Geotargeted', 'geotargeted' ) );
+ $htmlOut .= Xml::tags( 'td', array(), Xml::check(
'geotargeted', false, wfArrayMerge( $readonly, array( 'value' => 0, 'id' =>
'geotargeted' ) ) ) );
+ $htmlOut .= Xml::closeElement( 'tr' );
+ $htmlOut .= Xml::openElement( 'tr', array(
'id'=>'geoMultiSelector' ) );
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top'
), 'Countries' );
+ $htmlOut .= Xml::tags( 'td', array(),
$this->geoMultiSelector() );
+ $htmlOut .= Xml::closeElement( 'tr' );
+
$htmlOut .= Xml::closeElement( 'table' );
$htmlOut .= Xml::hidden( 'change', 'weight' );
$htmlOut .= Xml::hidden( 'authtoken',
$wgUser->editToken() );
@@ -799,6 +809,15 @@
$htmlOut .= Xml::tags( 'td', array( 'valign' => 'top'
), wfMsgHtml( 'yourlanguage' ) );
$htmlOut .= Xml::tags( 'td', array(),
$this->languageMultiSelector( $noticeLanguages ) );
$htmlOut .= Xml::closeElement( 'tr' );
+ // Countries
+ $htmlOut .= Xml::openElement( 'tr' );
+ $htmlOut .= Xml::tags( 'td', array(), Xml::label(
'Geotargeted', 'geotargeted' ) );
+ $htmlOut .= Xml::tags( 'td', array(), Xml::check(
'geotargeted', false, wfArrayMerge( $readonly, array( 'value' =>
$row->not_name, 'id' => 'geotargeted' ) ) ) );
+ $htmlOut .= Xml::closeElement( 'tr' );
+ $htmlOut .= Xml::openElement( 'tr', array(
'id'=>'geoMultiSelector' ) );
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top'
), 'Countries' );
+ $htmlOut .= Xml::tags( 'td', array(),
$this->geoMultiSelector() );
+ $htmlOut .= Xml::closeElement( 'tr' );
// Enabled
$htmlOut .= Xml::openElement( 'tr' );
$htmlOut .= Xml::tags( 'td', array(), Xml::label(
wfMsgHtml( 'centralnotice-enabled' ), 'enabled' ) );
@@ -1405,9 +1424,279 @@
$wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>",
$message );
$this->centralNoticeError = true;
}
+
+ /**
+ * Generates a multiple select list of all countries.
+ * @param $selected The country codes of the selected countries
+ * @return multiple select list
+ */
+ function geoMultiSelector( $selected = array() ) {
+ $countries = array(
+ 'AF'=>'Afghanistan',
+ 'AL'=>'Albania',
+ 'DZ'=>'Algeria',
+ 'AS'=>'American Samoa',
+ 'AD'=>'Andorra',
+ 'AO'=>'Angola',
+ 'AI'=>'Anguilla',
+ 'AQ'=>'Antarctica',
+ 'AG'=>'Antigua and Barbuda',
+ 'AR'=>'Argentina',
+ 'AM'=>'Armenia',
+ 'AW'=>'Aruba',
+ 'AU'=>'Australia',
+ 'AT'=>'Austria',
+ 'AZ'=>'Azerbaijan',
+ 'BS'=>'Bahamas',
+ 'BH'=>'Bahrain',
+ 'BD'=>'Bangladesh',
+ 'BB'=>'Barbados',
+ 'BY'=>'Belarus',
+ 'BE'=>'Belgium',
+ 'BZ'=>'Belize',
+ 'BJ'=>'Benin',
+ 'BM'=>'Bermuda',
+ 'BT'=>'Bhutan',
+ 'BO'=>'Bolivia',
+ 'BA'=>'Bosnia and Herzegovina',
+ 'BW'=>'Botswana',
+ 'BV'=>'Bouvet Island',
+ 'BR'=>'Brazil',
+ 'IO'=>'British Indian Ocean Territory',
+ 'BN'=>'Brunei Darussalam',
+ 'BG'=>'Bulgaria',
+ 'BF'=>'Burkina Faso',
+ 'BI'=>'Burundi',
+ 'KH'=>'Cambodia',
+ 'CM'=>'Cameroon',
+ 'CA'=>'Canada',
+ 'CV'=>'Cape Verde',
+ 'KY'=>'Cayman Islands',
+ 'CF'=>'Central African Republic',
+ 'TD'=>'Chad',
+ 'CL'=>'Chile',
+ 'CN'=>'China',
+ 'CX'=>'Christmas Island',
+ 'CC'=>'Cocos (Keeling) Islands',
+ 'CO'=>'Colombia',
+ 'KM'=>'Comoros',
+ 'CD'=>'Congo, Democratic Republic of the',
+ 'CG'=>'Congo',
+ 'CK'=>'Cook Islands',
+ 'CR'=>'Costa Rica',
+ 'CI'=>'Côte d\'Ivoire',
+ 'HR'=>'Croatia',
+ 'CU'=>'Cuba',
+ 'CY'=>'Cyprus',
+ 'CZ'=>'Czech Republic',
+ 'DK'=>'Denmark',
+ 'DJ'=>'Djibouti',
+ 'DM'=>'Dominica',
+ 'DO'=>'Dominican Republic',
+ 'EC'=>'Ecuador',
+ 'EG'=>'Egypt',
+ 'SV'=>'El Salvador',
+ 'GQ'=>'Equatorial Guinea',
+ 'ER'=>'Eritrea',
+ 'EE'=>'Estonia',
+ 'ET'=>'Ethiopia',
+ 'FK'=>'Falkland Islands (Malvinas)',
+ 'FO'=>'Faroe Islands',
+ 'FJ'=>'Fiji',
+ 'FI'=>'Finland',
+ 'FR'=>'France',
+ 'GF'=>'French Guiana',
+ 'PF'=>'French Polynesia',
+ 'TF'=>'French Southern Territories',
+ 'GA'=>'Gabon',
+ 'GM'=>'Gambia',
+ 'GE'=>'Georgia',
+ 'DE'=>'Germany',
+ 'GH'=>'Ghana',
+ 'GI'=>'Gibraltar',
+ 'GR'=>'Greece',
+ 'GL'=>'Greenland',
+ 'GD'=>'Grenada',
+ 'GP'=>'Guadeloupe',
+ 'GU'=>'Guam',
+ 'GT'=>'Guatemala',
+ 'GW'=>'Guinea-Bissau',
+ 'GN'=>'Guinea',
+ 'GY'=>'Guyana',
+ 'HT'=>'Haiti',
+ 'HM'=>'Heard Island and McDonald Islands',
+ 'VA'=>'Holy See (Vatican City State)',
+ 'HN'=>'Honduras',
+ 'HK'=>'Hong Kong',
+ 'HU'=>'Hungary',
+ 'IS'=>'Iceland',
+ 'IN'=>'India',
+ 'ID'=>'Indonesia',
+ 'IR'=>'Iran',
+ 'IQ'=>'Iraq',
+ 'IE'=>'Ireland',
+ 'IL'=>'Israel',
+ 'IT'=>'Italy',
+ 'JM'=>'Jamaica',
+ 'JP'=>'Japan',
+ 'JO'=>'Jordan',
+ 'KZ'=>'Kazakhstan',
+ 'KE'=>'Kenya',
+ 'KI'=>'Kiribati',
+ 'KW'=>'Kuwait',
+ 'KG'=>'Kyrgyzstan',
+ 'LA'=>'Lao People\'s Democratic Republic',
+ 'LV'=>'Latvia',
+ 'LB'=>'Lebanon',
+ 'LS'=>'Lesotho',
+ 'LR'=>'Liberia',
+ 'LY'=>'Libyan Arab Jamahiriya',
+ 'LI'=>'Liechtenstein',
+ 'LT'=>'Lithuania',
+ 'LU'=>'Luxembourg',
+ 'MO'=>'Macao',
+ 'MK'=>'Macedonia, Republic of',
+ 'MG'=>'Madagascar',
+ 'MW'=>'Malawi',
+ 'MY'=>'Malaysia',
+ 'MV'=>'Maldives',
+ 'ML'=>'Mali',
+ 'MT'=>'Malta',
+ 'MH'=>'Marshall Islands',
+ 'MQ'=>'Martinique',
+ 'MR'=>'Mauritania',
+ 'MU'=>'Mauritius',
+ 'YT'=>'Mayotte',
+ 'MX'=>'Mexico',
+ 'FM'=>'Micronesia',
+ 'MD'=>'Moldova, Republic of',
+ 'MC'=>'Moldova',
+ 'MN'=>'Mongolia',
+ 'ME'=>'Montenegro',
+ 'MS'=>'Montserrat',
+ 'MA'=>'Morocco',
+ 'MZ'=>'Mozambique',
+ 'MM'=>'Myanmar',
+ 'NA'=>'Namibia',
+ 'NR'=>'Nauru',
+ 'NP'=>'Nepal',
+ 'AN'=>'Netherlands Antilles',
+ 'NL'=>'Netherlands',
+ 'NC'=>'New Caledonia',
+ 'NZ'=>'New Zealand',
+ 'NI'=>'Nicaragua',
+ 'NE'=>'Niger',
+ 'NG'=>'Nigeria',
+ 'NU'=>'Niue',
+ 'NF'=>'Norfolk Island',
+ 'KP'=>'North Korea',
+ 'MP'=>'Northern Mariana Islands',
+ 'NO'=>'Norway',
+ 'OM'=>'Oman',
+ 'PK'=>'Pakistan',
+ 'PW'=>'Palau',
+ 'PS'=>'Palestinian Territory',
+ 'PA'=>'Panama',
+ 'PG'=>'Papua New Guinea',
+ 'PY'=>'Paraguay',
+ 'PE'=>'Peru',
+ 'PH'=>'Philippines',
+ 'PN'=>'Pitcairn',
+ 'PL'=>'Poland',
+ 'PT'=>'Portugal',
+ 'PR'=>'Puerto Rico',
+ 'QA'=>'Qatar',
+ 'RE'=>'Reunion',
+ 'RO'=>'Romania',
+ 'RU'=>'Russian Federation',
+ 'RW'=>'Rwanda',
+ 'SH'=>'Saint Helena',
+ 'KN'=>'Saint Kitts and Nevis',
+ 'LC'=>'Saint Lucia',
+ 'PM'=>'Saint Pierre and Miquelon',
+ 'VC'=>'Saint Vincent and the Grenadines',
+ 'WS'=>'Samoa',
+ 'SM'=>'San Marino',
+ 'ST'=>'Sao Tome and Principe',
+ 'SA'=>'Saudi Arabia',
+ 'SN'=>'Senegal',
+ 'CS'=>'Serbia and Montenegro',
+ 'RS'=>'Serbia',
+ 'SC'=>'Seychelles',
+ 'SL'=>'Sierra Leone',
+ 'SG'=>'Singapore',
+ 'SK'=>'Slovakia',
+ 'SI'=>'Slovenia',
+ 'SB'=>'Solomon Islands',
+ 'SO'=>'Somalia',
+ 'ZA'=>'South Africa',
+ 'KR'=>'South Korea',
+ 'ES'=>'Spain',
+ 'LK'=>'Sri Lanka',
+ 'SD'=>'Sudan',
+ 'SR'=>'Suriname',
+ 'SJ'=>'Svalbard and Jan Mayen',
+ 'SZ'=>'Swaziland',
+ 'SE'=>'Sweden',
+ 'CH'=>'Switzerland',
+ 'SY'=>'Syrian Arab Republic',
+ 'TW'=>'Taiwan',
+ 'TJ'=>'Tajikistan',
+ 'TZ'=>'Tanzania',
+ 'TH'=>'Thailand',
+ 'TL'=>'Timor-Leste',
+ 'TG'=>'Togo',
+ 'TK'=>'Tokelau',
+ 'TO'=>'Tonga',
+ 'TT'=>'Trinidad and Tobago',
+ 'TN'=>'Tunisia',
+ 'TR'=>'Turkey',
+ 'TM'=>'Turkmenistan',
+ 'TC'=>'Turks and Caicos Islands',
+ 'TV'=>'Tuvalu',
+ 'UG'=>'Uganda',
+ 'UA'=>'Ukraine',
+ 'AE'=>'United Arab Emirates',
+ 'GB'=>'United Kingdom',
+ 'UM'=>'United States Minor Outlying Islands',
+ 'US'=>'United States',
+ 'UY'=>'Uruguay',
+ 'UZ'=>'Uzbekistan',
+ 'VU'=>'Vanuatu',
+ 'VE'=>'Venezuela',
+ 'VN'=>'Vietnam',
+ 'VG'=>'Virgin Islands, British',
+ 'VI'=>'Virgin Islands, U.S.',
+ 'WF'=>'Wallis and Futuna',
+ 'EH'=>'Western Sahara',
+ 'YE'=>'Yemen',
+ 'ZM'=>'Zambia',
+ 'ZW'=>'Zimbabwe'
+ );
+ $options = "\n";
+ foreach( $countries as $code => $name ) {
+ $options .= Xml::option(
+ $name,
+ $code,
+ in_array( $code, $selected )
+ ) . "\n";
+ }
+ $htmlOut = '';
+ if ( $this->editable ) {
+ $htmlOut .= Xml::tags( 'select',
+ array( 'multiple' => 'multiple', 'size' => 4,
'id' => 'geo_countries[]', 'name' => 'geo_countries[]' ),
+ $options
+ );
+ } else {
+ $htmlOut .= Xml::tags( 'select',
+ array( 'multiple' => 'multiple', 'size' => 4,
'id' => 'geo_countries[]', 'name' => 'geo_countries[]', 'disabled' =>
'disabled' ),
+ $options
+ );
+ }
+ return $htmlOut;
+ }
}
-
class CentralNoticePager extends TemplatePager {
var $viewPage, $special;
var $editable;
Modified: trunk/extensions/CentralNotice/centralnotice.css
===================================================================
--- trunk/extensions/CentralNotice/centralnotice.css 2010-09-10 22:40:47 UTC
(rev 72764)
+++ trunk/extensions/CentralNotice/centralnotice.css 2010-09-10 23:07:27 UTC
(rev 72765)
@@ -47,6 +47,9 @@
border-style: solid;
border-width: 1px;
}
+#preferences tr#geoMultiSelector {
+ display: none;
+}
/* Vector-specific definitions */
body.skin-vector #preferences fieldset.prefsection {
Modified: trunk/extensions/CentralNotice/centralnotice.js
===================================================================
--- trunk/extensions/CentralNotice/centralnotice.js 2010-09-10 22:40:47 UTC
(rev 72764)
+++ trunk/extensions/CentralNotice/centralnotice.js 2010-09-10 23:07:27 UTC
(rev 72765)
@@ -42,4 +42,16 @@
bannerField.value += buttonValue;
}
bannerField.focus();
-}
\ No newline at end of file
+}
+// Handle revealing the geoMultiSelector when the geotargetted checkbox is
checked
+( function( $ ) {
+ $(document).ready(function() {
+ $("#geotargeted").click(function () {
+ if ($('#geotargeted:checked').val() !== undefined) {
+ $("#geoMultiSelector").show('slow');
+ } else {
+ $("#geoMultiSelector").hide('slow');
+ }
+ });
+ });
+})(jQuery);
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs