- public static function languageSelector( $selected, $customisedOnly = true ) {
- global $wgContLanguageCode;
- /**
- * Make sure the site language is in the list; a custom language code
- * might not have a defined name...
- */
- $languages = Language::getLanguageNames( $customisedOnly );
- if( !array_key_exists( $wgContLanguageCode, $languages ) ) {
- $languages[$wgContLanguageCode] = $wgContLanguageCode;
+ public static function dateMenu( $year, $month ) {
+ # Offset overrides year/month selection
+ if( $month && $month !== -1 ) {
+ $encMonth = intval( $month );
+ } else {
+ $encMonth = '';
+ }
+ if( $year ) {
+ $encYear = intval( $year );
+ } elseif( $encMonth ) {
+ $thisMonth = intval( gmdate( 'n' ) );
+ $thisYear = intval( gmdate( 'Y' ) );
+ if( intval($encMonth) > $thisMonth ) {
+ $thisYear--;
+ }
+ $encYear = $thisYear;
+ } else {
+ $encYear = '';
+ }
+ return Xml::label( wfMsg( 'year' ), 'year' ) . ' '.
+ Xml::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) . ' '.
+ Xml::label( wfMsg( 'month' ), 'month' ) . ' '.
+ Xml::monthSelector( $encMonth, -1 );
+ }
+
+ /**
+ * Construct a language selector appropriate for use in a form or preferences
+ *
+ * @param string $selected The language code of the selected language
+ * @param boolean $customisedOnly If true only languages which have some content are listed
+ * @param string $language The ISO code of the language to display the select list in (optional)
+ * @return array containing 2 items: label HTML and select list HTML
+ */
+ public static function languageSelector( $selected, $customisedOnly = true, $language = null ) {
+ global $wgLanguageCode;
+
+ // If a specific language was requested and CLDR is installed, use it
+ if ( $language && is_callable( array( 'LanguageNames', 'getNames' ) ) ) {
+ if ( $customisedOnly ) {
+ $listType = LanguageNames::LIST_MW_SUPPORTED; // Only pull names that have localisation in MediaWiki
+ } else {
+ $listType = LanguageNames::LIST_MW; // Pull all languages that are in Names.php
+ }
+ // Retrieve the list of languages in the requested language (via CLDR)
+ $languages = LanguageNames::getNames(
+ $language, // Code of the requested language
+ LanguageNames::FALLBACK_NORMAL, // Use fallback chain
+ $listType
+ );
+ } else {
+ $languages = Language::getLanguageNames( $customisedOnly );
+ }
+
+ // Make sure the site language is in the list; a custom language code might not have a
+ // defined name...
+ if( !array_key_exists( $wgLanguageCode, $languages ) ) {
+ $languages[$wgLanguageCode] = $wgLanguageCode;