Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -506,6 +506,16 @@ |
507 | 507 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'yourlanguage' ) ); |
508 | 508 | $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $noticeLanguages ) ); |
509 | 509 | $htmlOut .= Xml::closeElement( 'tr' ); |
| 510 | + // Countries |
| 511 | + $htmlOut .= Xml::openElement( 'tr' ); |
| 512 | + $htmlOut .= Xml::tags( 'td', array(), Xml::label( 'Geotargeted', 'geotargeted' ) ); |
| 513 | + $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'geotargeted', false, wfArrayMerge( $readonly, array( 'value' => 0, 'id' => 'geotargeted' ) ) ) ); |
| 514 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 515 | + $htmlOut .= Xml::openElement( 'tr', array( 'id'=>'geoMultiSelector' ) ); |
| 516 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), 'Countries' ); |
| 517 | + $htmlOut .= Xml::tags( 'td', array(), $this->geoMultiSelector() ); |
| 518 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 519 | + |
510 | 520 | $htmlOut .= Xml::closeElement( 'table' ); |
511 | 521 | $htmlOut .= Xml::hidden( 'change', 'weight' ); |
512 | 522 | $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() ); |
— | — | @@ -799,6 +809,15 @@ |
800 | 810 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'yourlanguage' ) ); |
801 | 811 | $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $noticeLanguages ) ); |
802 | 812 | $htmlOut .= Xml::closeElement( 'tr' ); |
| 813 | + // Countries |
| 814 | + $htmlOut .= Xml::openElement( 'tr' ); |
| 815 | + $htmlOut .= Xml::tags( 'td', array(), Xml::label( 'Geotargeted', 'geotargeted' ) ); |
| 816 | + $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'geotargeted', false, wfArrayMerge( $readonly, array( 'value' => $row->not_name, 'id' => 'geotargeted' ) ) ) ); |
| 817 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 818 | + $htmlOut .= Xml::openElement( 'tr', array( 'id'=>'geoMultiSelector' ) ); |
| 819 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), 'Countries' ); |
| 820 | + $htmlOut .= Xml::tags( 'td', array(), $this->geoMultiSelector() ); |
| 821 | + $htmlOut .= Xml::closeElement( 'tr' ); |
803 | 822 | // Enabled |
804 | 823 | $htmlOut .= Xml::openElement( 'tr' ); |
805 | 824 | $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsgHtml( 'centralnotice-enabled' ), 'enabled' ) ); |
— | — | @@ -1405,9 +1424,279 @@ |
1406 | 1425 | $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", $message ); |
1407 | 1426 | $this->centralNoticeError = true; |
1408 | 1427 | } |
| 1428 | + |
| 1429 | + /** |
| 1430 | + * Generates a multiple select list of all countries. |
| 1431 | + * @param $selected The country codes of the selected countries |
| 1432 | + * @return multiple select list |
| 1433 | + */ |
| 1434 | + function geoMultiSelector( $selected = array() ) { |
| 1435 | + $countries = array( |
| 1436 | + 'AF'=>'Afghanistan', |
| 1437 | + 'AL'=>'Albania', |
| 1438 | + 'DZ'=>'Algeria', |
| 1439 | + 'AS'=>'American Samoa', |
| 1440 | + 'AD'=>'Andorra', |
| 1441 | + 'AO'=>'Angola', |
| 1442 | + 'AI'=>'Anguilla', |
| 1443 | + 'AQ'=>'Antarctica', |
| 1444 | + 'AG'=>'Antigua and Barbuda', |
| 1445 | + 'AR'=>'Argentina', |
| 1446 | + 'AM'=>'Armenia', |
| 1447 | + 'AW'=>'Aruba', |
| 1448 | + 'AU'=>'Australia', |
| 1449 | + 'AT'=>'Austria', |
| 1450 | + 'AZ'=>'Azerbaijan', |
| 1451 | + 'BS'=>'Bahamas', |
| 1452 | + 'BH'=>'Bahrain', |
| 1453 | + 'BD'=>'Bangladesh', |
| 1454 | + 'BB'=>'Barbados', |
| 1455 | + 'BY'=>'Belarus', |
| 1456 | + 'BE'=>'Belgium', |
| 1457 | + 'BZ'=>'Belize', |
| 1458 | + 'BJ'=>'Benin', |
| 1459 | + 'BM'=>'Bermuda', |
| 1460 | + 'BT'=>'Bhutan', |
| 1461 | + 'BO'=>'Bolivia', |
| 1462 | + 'BA'=>'Bosnia and Herzegovina', |
| 1463 | + 'BW'=>'Botswana', |
| 1464 | + 'BV'=>'Bouvet Island', |
| 1465 | + 'BR'=>'Brazil', |
| 1466 | + 'IO'=>'British Indian Ocean Territory', |
| 1467 | + 'BN'=>'Brunei Darussalam', |
| 1468 | + 'BG'=>'Bulgaria', |
| 1469 | + 'BF'=>'Burkina Faso', |
| 1470 | + 'BI'=>'Burundi', |
| 1471 | + 'KH'=>'Cambodia', |
| 1472 | + 'CM'=>'Cameroon', |
| 1473 | + 'CA'=>'Canada', |
| 1474 | + 'CV'=>'Cape Verde', |
| 1475 | + 'KY'=>'Cayman Islands', |
| 1476 | + 'CF'=>'Central African Republic', |
| 1477 | + 'TD'=>'Chad', |
| 1478 | + 'CL'=>'Chile', |
| 1479 | + 'CN'=>'China', |
| 1480 | + 'CX'=>'Christmas Island', |
| 1481 | + 'CC'=>'Cocos (Keeling) Islands', |
| 1482 | + 'CO'=>'Colombia', |
| 1483 | + 'KM'=>'Comoros', |
| 1484 | + 'CD'=>'Congo, Democratic Republic of the', |
| 1485 | + 'CG'=>'Congo', |
| 1486 | + 'CK'=>'Cook Islands', |
| 1487 | + 'CR'=>'Costa Rica', |
| 1488 | + 'CI'=>'Côte d\'Ivoire', |
| 1489 | + 'HR'=>'Croatia', |
| 1490 | + 'CU'=>'Cuba', |
| 1491 | + 'CY'=>'Cyprus', |
| 1492 | + 'CZ'=>'Czech Republic', |
| 1493 | + 'DK'=>'Denmark', |
| 1494 | + 'DJ'=>'Djibouti', |
| 1495 | + 'DM'=>'Dominica', |
| 1496 | + 'DO'=>'Dominican Republic', |
| 1497 | + 'EC'=>'Ecuador', |
| 1498 | + 'EG'=>'Egypt', |
| 1499 | + 'SV'=>'El Salvador', |
| 1500 | + 'GQ'=>'Equatorial Guinea', |
| 1501 | + 'ER'=>'Eritrea', |
| 1502 | + 'EE'=>'Estonia', |
| 1503 | + 'ET'=>'Ethiopia', |
| 1504 | + 'FK'=>'Falkland Islands (Malvinas)', |
| 1505 | + 'FO'=>'Faroe Islands', |
| 1506 | + 'FJ'=>'Fiji', |
| 1507 | + 'FI'=>'Finland', |
| 1508 | + 'FR'=>'France', |
| 1509 | + 'GF'=>'French Guiana', |
| 1510 | + 'PF'=>'French Polynesia', |
| 1511 | + 'TF'=>'French Southern Territories', |
| 1512 | + 'GA'=>'Gabon', |
| 1513 | + 'GM'=>'Gambia', |
| 1514 | + 'GE'=>'Georgia', |
| 1515 | + 'DE'=>'Germany', |
| 1516 | + 'GH'=>'Ghana', |
| 1517 | + 'GI'=>'Gibraltar', |
| 1518 | + 'GR'=>'Greece', |
| 1519 | + 'GL'=>'Greenland', |
| 1520 | + 'GD'=>'Grenada', |
| 1521 | + 'GP'=>'Guadeloupe', |
| 1522 | + 'GU'=>'Guam', |
| 1523 | + 'GT'=>'Guatemala', |
| 1524 | + 'GW'=>'Guinea-Bissau', |
| 1525 | + 'GN'=>'Guinea', |
| 1526 | + 'GY'=>'Guyana', |
| 1527 | + 'HT'=>'Haiti', |
| 1528 | + 'HM'=>'Heard Island and McDonald Islands', |
| 1529 | + 'VA'=>'Holy See (Vatican City State)', |
| 1530 | + 'HN'=>'Honduras', |
| 1531 | + 'HK'=>'Hong Kong', |
| 1532 | + 'HU'=>'Hungary', |
| 1533 | + 'IS'=>'Iceland', |
| 1534 | + 'IN'=>'India', |
| 1535 | + 'ID'=>'Indonesia', |
| 1536 | + 'IR'=>'Iran', |
| 1537 | + 'IQ'=>'Iraq', |
| 1538 | + 'IE'=>'Ireland', |
| 1539 | + 'IL'=>'Israel', |
| 1540 | + 'IT'=>'Italy', |
| 1541 | + 'JM'=>'Jamaica', |
| 1542 | + 'JP'=>'Japan', |
| 1543 | + 'JO'=>'Jordan', |
| 1544 | + 'KZ'=>'Kazakhstan', |
| 1545 | + 'KE'=>'Kenya', |
| 1546 | + 'KI'=>'Kiribati', |
| 1547 | + 'KW'=>'Kuwait', |
| 1548 | + 'KG'=>'Kyrgyzstan', |
| 1549 | + 'LA'=>'Lao People\'s Democratic Republic', |
| 1550 | + 'LV'=>'Latvia', |
| 1551 | + 'LB'=>'Lebanon', |
| 1552 | + 'LS'=>'Lesotho', |
| 1553 | + 'LR'=>'Liberia', |
| 1554 | + 'LY'=>'Libyan Arab Jamahiriya', |
| 1555 | + 'LI'=>'Liechtenstein', |
| 1556 | + 'LT'=>'Lithuania', |
| 1557 | + 'LU'=>'Luxembourg', |
| 1558 | + 'MO'=>'Macao', |
| 1559 | + 'MK'=>'Macedonia, Republic of', |
| 1560 | + 'MG'=>'Madagascar', |
| 1561 | + 'MW'=>'Malawi', |
| 1562 | + 'MY'=>'Malaysia', |
| 1563 | + 'MV'=>'Maldives', |
| 1564 | + 'ML'=>'Mali', |
| 1565 | + 'MT'=>'Malta', |
| 1566 | + 'MH'=>'Marshall Islands', |
| 1567 | + 'MQ'=>'Martinique', |
| 1568 | + 'MR'=>'Mauritania', |
| 1569 | + 'MU'=>'Mauritius', |
| 1570 | + 'YT'=>'Mayotte', |
| 1571 | + 'MX'=>'Mexico', |
| 1572 | + 'FM'=>'Micronesia', |
| 1573 | + 'MD'=>'Moldova, Republic of', |
| 1574 | + 'MC'=>'Moldova', |
| 1575 | + 'MN'=>'Mongolia', |
| 1576 | + 'ME'=>'Montenegro', |
| 1577 | + 'MS'=>'Montserrat', |
| 1578 | + 'MA'=>'Morocco', |
| 1579 | + 'MZ'=>'Mozambique', |
| 1580 | + 'MM'=>'Myanmar', |
| 1581 | + 'NA'=>'Namibia', |
| 1582 | + 'NR'=>'Nauru', |
| 1583 | + 'NP'=>'Nepal', |
| 1584 | + 'AN'=>'Netherlands Antilles', |
| 1585 | + 'NL'=>'Netherlands', |
| 1586 | + 'NC'=>'New Caledonia', |
| 1587 | + 'NZ'=>'New Zealand', |
| 1588 | + 'NI'=>'Nicaragua', |
| 1589 | + 'NE'=>'Niger', |
| 1590 | + 'NG'=>'Nigeria', |
| 1591 | + 'NU'=>'Niue', |
| 1592 | + 'NF'=>'Norfolk Island', |
| 1593 | + 'KP'=>'North Korea', |
| 1594 | + 'MP'=>'Northern Mariana Islands', |
| 1595 | + 'NO'=>'Norway', |
| 1596 | + 'OM'=>'Oman', |
| 1597 | + 'PK'=>'Pakistan', |
| 1598 | + 'PW'=>'Palau', |
| 1599 | + 'PS'=>'Palestinian Territory', |
| 1600 | + 'PA'=>'Panama', |
| 1601 | + 'PG'=>'Papua New Guinea', |
| 1602 | + 'PY'=>'Paraguay', |
| 1603 | + 'PE'=>'Peru', |
| 1604 | + 'PH'=>'Philippines', |
| 1605 | + 'PN'=>'Pitcairn', |
| 1606 | + 'PL'=>'Poland', |
| 1607 | + 'PT'=>'Portugal', |
| 1608 | + 'PR'=>'Puerto Rico', |
| 1609 | + 'QA'=>'Qatar', |
| 1610 | + 'RE'=>'Reunion', |
| 1611 | + 'RO'=>'Romania', |
| 1612 | + 'RU'=>'Russian Federation', |
| 1613 | + 'RW'=>'Rwanda', |
| 1614 | + 'SH'=>'Saint Helena', |
| 1615 | + 'KN'=>'Saint Kitts and Nevis', |
| 1616 | + 'LC'=>'Saint Lucia', |
| 1617 | + 'PM'=>'Saint Pierre and Miquelon', |
| 1618 | + 'VC'=>'Saint Vincent and the Grenadines', |
| 1619 | + 'WS'=>'Samoa', |
| 1620 | + 'SM'=>'San Marino', |
| 1621 | + 'ST'=>'Sao Tome and Principe', |
| 1622 | + 'SA'=>'Saudi Arabia', |
| 1623 | + 'SN'=>'Senegal', |
| 1624 | + 'CS'=>'Serbia and Montenegro', |
| 1625 | + 'RS'=>'Serbia', |
| 1626 | + 'SC'=>'Seychelles', |
| 1627 | + 'SL'=>'Sierra Leone', |
| 1628 | + 'SG'=>'Singapore', |
| 1629 | + 'SK'=>'Slovakia', |
| 1630 | + 'SI'=>'Slovenia', |
| 1631 | + 'SB'=>'Solomon Islands', |
| 1632 | + 'SO'=>'Somalia', |
| 1633 | + 'ZA'=>'South Africa', |
| 1634 | + 'KR'=>'South Korea', |
| 1635 | + 'ES'=>'Spain', |
| 1636 | + 'LK'=>'Sri Lanka', |
| 1637 | + 'SD'=>'Sudan', |
| 1638 | + 'SR'=>'Suriname', |
| 1639 | + 'SJ'=>'Svalbard and Jan Mayen', |
| 1640 | + 'SZ'=>'Swaziland', |
| 1641 | + 'SE'=>'Sweden', |
| 1642 | + 'CH'=>'Switzerland', |
| 1643 | + 'SY'=>'Syrian Arab Republic', |
| 1644 | + 'TW'=>'Taiwan', |
| 1645 | + 'TJ'=>'Tajikistan', |
| 1646 | + 'TZ'=>'Tanzania', |
| 1647 | + 'TH'=>'Thailand', |
| 1648 | + 'TL'=>'Timor-Leste', |
| 1649 | + 'TG'=>'Togo', |
| 1650 | + 'TK'=>'Tokelau', |
| 1651 | + 'TO'=>'Tonga', |
| 1652 | + 'TT'=>'Trinidad and Tobago', |
| 1653 | + 'TN'=>'Tunisia', |
| 1654 | + 'TR'=>'Turkey', |
| 1655 | + 'TM'=>'Turkmenistan', |
| 1656 | + 'TC'=>'Turks and Caicos Islands', |
| 1657 | + 'TV'=>'Tuvalu', |
| 1658 | + 'UG'=>'Uganda', |
| 1659 | + 'UA'=>'Ukraine', |
| 1660 | + 'AE'=>'United Arab Emirates', |
| 1661 | + 'GB'=>'United Kingdom', |
| 1662 | + 'UM'=>'United States Minor Outlying Islands', |
| 1663 | + 'US'=>'United States', |
| 1664 | + 'UY'=>'Uruguay', |
| 1665 | + 'UZ'=>'Uzbekistan', |
| 1666 | + 'VU'=>'Vanuatu', |
| 1667 | + 'VE'=>'Venezuela', |
| 1668 | + 'VN'=>'Vietnam', |
| 1669 | + 'VG'=>'Virgin Islands, British', |
| 1670 | + 'VI'=>'Virgin Islands, U.S.', |
| 1671 | + 'WF'=>'Wallis and Futuna', |
| 1672 | + 'EH'=>'Western Sahara', |
| 1673 | + 'YE'=>'Yemen', |
| 1674 | + 'ZM'=>'Zambia', |
| 1675 | + 'ZW'=>'Zimbabwe' |
| 1676 | + ); |
| 1677 | + $options = "\n"; |
| 1678 | + foreach( $countries as $code => $name ) { |
| 1679 | + $options .= Xml::option( |
| 1680 | + $name, |
| 1681 | + $code, |
| 1682 | + in_array( $code, $selected ) |
| 1683 | + ) . "\n"; |
| 1684 | + } |
| 1685 | + $htmlOut = ''; |
| 1686 | + if ( $this->editable ) { |
| 1687 | + $htmlOut .= Xml::tags( 'select', |
| 1688 | + array( 'multiple' => 'multiple', 'size' => 4, 'id' => 'geo_countries[]', 'name' => 'geo_countries[]' ), |
| 1689 | + $options |
| 1690 | + ); |
| 1691 | + } else { |
| 1692 | + $htmlOut .= Xml::tags( 'select', |
| 1693 | + array( 'multiple' => 'multiple', 'size' => 4, 'id' => 'geo_countries[]', 'name' => 'geo_countries[]', 'disabled' => 'disabled' ), |
| 1694 | + $options |
| 1695 | + ); |
| 1696 | + } |
| 1697 | + return $htmlOut; |
| 1698 | + } |
1409 | 1699 | } |
1410 | 1700 | |
1411 | | - |
1412 | 1701 | class CentralNoticePager extends TemplatePager { |
1413 | 1702 | var $viewPage, $special; |
1414 | 1703 | var $editable; |
Index: trunk/extensions/CentralNotice/centralnotice.css |
— | — | @@ -47,6 +47,9 @@ |
48 | 48 | border-style: solid; |
49 | 49 | border-width: 1px; |
50 | 50 | } |
| 51 | +#preferences tr#geoMultiSelector { |
| 52 | + display: none; |
| 53 | +} |
51 | 54 | |
52 | 55 | /* Vector-specific definitions */ |
53 | 56 | body.skin-vector #preferences fieldset.prefsection { |
Index: trunk/extensions/CentralNotice/centralnotice.js |
— | — | @@ -42,4 +42,16 @@ |
43 | 43 | bannerField.value += buttonValue; |
44 | 44 | } |
45 | 45 | bannerField.focus(); |
46 | | -} |
\ No newline at end of file |
| 46 | +} |
| 47 | +// Handle revealing the geoMultiSelector when the geotargetted checkbox is checked |
| 48 | +( function( $ ) { |
| 49 | + $(document).ready(function() { |
| 50 | + $("#geotargeted").click(function () { |
| 51 | + if ($('#geotargeted:checked').val() !== undefined) { |
| 52 | + $("#geoMultiSelector").show('slow'); |
| 53 | + } else { |
| 54 | + $("#geoMultiSelector").hide('slow'); |
| 55 | + } |
| 56 | + }); |
| 57 | + }); |
| 58 | +})(jQuery); |