示例#1
0
 /**
  * (non-PHPdoc)
  * @see EPPager::getFormattedValue()
  */
 public function getFormattedValue($name, $value)
 {
     switch ($name) {
         case 'name':
             $value = EPCourse::getLinkFor($value);
             break;
         case 'org_id':
             $value = EPOrg::selectRow('name', array('id' => $value))->getLink();
             break;
         case 'term':
             $value = htmlspecialchars($value);
             break;
         case 'lang':
             $langs = LanguageNames::getNames($this->getLanguage()->getCode());
             if (array_key_exists($value, $langs)) {
                 $value = htmlspecialchars($langs[$value]);
             } else {
                 $value = '<i>' . htmlspecialchars($this->getMsg('invalid-lang')) . '</i>';
             }
             break;
         case 'start':
         case 'end':
             $value = htmlspecialchars($this->getLanguage()->date($value));
             break;
         case '_status':
             $value = htmlspecialchars(EPCourse::getStatusMessage($this->currentObject->getStatus()));
         case 'students':
             $value = htmlspecialchars($this->getLanguage()->formatNum($value));
             break;
     }
     return $value;
 }
 public static function languageName(&$parser, $code = '', $outputLanguage = '')
 {
     global $wgLang;
     if (!$code) {
         return '';
     }
     if (!$outputLanguage) {
         $outputLanguage = $parser->getOptions()->getUserLang();
     }
     $cldr = is_callable(array('LanguageNames', 'getNames'));
     if ($outputLanguage !== 'native' && $cldr) {
         $languages = LanguageNames::getNames($outputLanguage, LanguageNames::FALLBACK_NORMAL, LanguageNames::LIST_MW_AND_CLDR);
     } else {
         $languages = Language::getLanguageNames(false);
     }
     return isset($languages[$code]) ? $languages[$code] : $code;
 }
 /**
  * JavsScript selector for language codes.
  * @return JsSelectToInput
  */
 protected static function languageSelector()
 {
     if (is_callable(array('LanguageNames', 'getNames'))) {
         $lang = RequestContext::getMain()->getLanguage();
         $languages = LanguageNames::getNames($lang->getCode(), LanguageNames::FALLBACK_NORMAL);
     } else {
         $languages = Language::fetchLanguageNames();
     }
     ksort($languages);
     $selector = new XmlSelect('mw-language-selector', 'mw-language-selector');
     foreach ($languages as $code => $name) {
         $selector->addOption("{$code} - {$name}", $code);
     }
     $jsSelect = new JsSelectToInput($selector);
     $jsSelect->setSourceId('mw-language-selector');
     return $jsSelect;
 }
示例#4
0
 public static function trailerForm(&$items, $opts)
 {
     $opts->consumeValue('trailer');
     global $wgRequest;
     $default = $wgRequest->getVal('trailer', '');
     global $wgLang;
     if (is_callable(array('LanguageNames', 'getNames'))) {
         $languages = LanguageNames::getNames($wgLang->getCode(), LanguageNames::FALLBACK_NORMAL, LanguageNames::LIST_MW);
     } else {
         $languages = Language::getLanguageNames(false);
     }
     ksort($languages);
     $options = Xml::option(wfMsg('cleanchanges-language-na'), '', $default === '');
     foreach ($languages as $code => $name) {
         $selected = "/{$code}" === $default;
         $options .= Xml::option("{$code} - {$name}", "/{$code}", $selected) . "\n";
     }
     $str = Xml::openElement('select', array('name' => 'trailer', 'class' => 'mw-language-selector', 'id' => 'sp-rc-language')) . $options . Xml::closeElement('select');
     $items['tailer'] = array(wfMsgHtml('cleanchanges-language'), $str);
     return true;
 }
 /**
  * Generates a multiple select list of all languages.
  * @param $selected The language codes of the selected languages
  * @param $customisedOnly If true only languages which have some content are listed
  * @return multiple select list
  */
 function languageMultiSelector($selected = array(), $customisedOnly = true)
 {
     global $wgLanguageCode, $wgExtensionAssetsPath, $wgLang;
     $scriptPath = "{$wgExtensionAssetsPath}/CentralNotice";
     if (is_callable(array('LanguageNames', 'getNames'))) {
         // Retrieve the list of languages in user's language (via CLDR)
         $languages = LanguageNames::getNames($wgLang->getCode(), LanguageNames::FALLBACK_NORMAL, LanguageNames::LIST_MW);
     } else {
         // Use this as fallback if CLDR extension is not enabled
         $languages = Language::getLanguageNames();
     }
     // 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;
     }
     ksort($languages);
     $options = "\n";
     foreach ($languages as $code => $name) {
         $options .= Xml::option(wfMsg('centralnotice-language-listing', $code, $name), $code, in_array($code, $selected)) . "\n";
     }
     $htmlOut = '';
     if ($this->editable) {
         $htmlOut .= Xml::tags('select', array('multiple' => 'multiple', 'size' => 6, 'id' => 'project_languages[]', 'name' => 'project_languages[]'), $options);
         $buttons = array();
         $buttons[] = '<a href="#" onclick="selectLanguages(true);return false;">' . wfMsg('powersearch-toggleall') . '</a>';
         $buttons[] = '<a href="#" onclick="selectLanguages(false);return false;">' . wfMsg('powersearch-togglenone') . '</a>';
         $buttons[] = '<a href="#" onclick="top10Languages();return false;">' . wfMsg('centralnotice-top-ten-languages') . '</a>';
         $htmlOut .= Xml::tags('div', array('style' => 'margin-top: 0.2em;'), '<img src="' . $scriptPath . '/up-arrow.png" style="vertical-align:baseline;"/>' . wfMsg('centralnotice-select', $wgLang->commaList($buttons)));
     } else {
         $htmlOut .= Xml::tags('select', array('multiple' => 'multiple', 'size' => 6, 'id' => 'project_languages[]', 'name' => 'project_languages[]', 'disabled' => 'disabled'), $options);
     }
     return $htmlOut;
 }
示例#6
0
/** This function sets the changed data specified by the user.
 */
function profile_update($db_login)
{
    global $params, $db;
    $playerID = $params->SESSION->player->playerID;
    $data = $params->POST->data;
    $password = $params->POST->password;
    // list of fields, that should be inserted into the player record
    $fields = array("origin", "icq", "avatar", "description", "template", "language", "gfxpath", "email2");
    // validate language code
    $uaLanguageNames = LanguageNames::getLanguageNames();
    if (!array_key_exists($data['language'], $uaLanguageNames)) {
        unset($data['language']);
    }
    // recode description
    $data['description'] = nl2br($data['description']);
    if ($set = db_makeSetStatementSecure($data, $fields)) {
        $query = sprintf('UPDATE Player SET %s WHERE playerID = %d', $set, $playerID);
        if (!$db->query($query)) {
            return _('Die Daten konnten gar nicht oder zumindest nicht vollständig aktualisiert werden.');
        }
    }
    // ***** now update the password, if it is set **** **************************
    if (strlen($password['password1'])) {
        // typo?
        if (strcmp($password['password1'], $password['password2']) != 0) {
            return _('Das Paßwort stimmt nicht mit der Wiederholung überein.');
        }
        // password too short?
        if (!preg_match('/^\\w{6,}$/', unhtmlentities($password['password1']))) {
            return _('Das Passwort muss mindestens 6 Zeichen lang sein!');
        }
        // set password
        $query = sprintf("UPDATE Login SET password = '%s' WHERE LoginID = %d", $password['password1'], $playerID);
        if (!$db_login->query($query)) {
            return _('Die Daten konnten gar nicht oder zumindest nicht vollständig aktualisiert werden.');
        }
    }
    return _('Die Daten wurden erfolgreich aktualisiert.');
}
	/**
	 * JavsScript selector for language codes.
	 * @return \JsSelectToInput
	 */
	protected static function languageSelector() {
		global $wgLang;

		if ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) {
			$languages = LanguageNames::getNames( $wgLang->getCode(),
				LanguageNames::FALLBACK_NORMAL
			);
		} else {
			$languages = Language::getLanguageNames( false );
		}

		ksort( $languages );

		$selector = new XmlSelect( 'mw-language-selector', 'mw-language-selector'  );
		foreach ( $languages as $code => $name ) {
			$selector->addOption( "$code - $name", $code );
		}

		$jsSelect = new JsSelectToInput( $selector );
		$jsSelect->setSourceId( 'mw-language-selector' );

		return $jsSelect;
	}
	public function execute( $par ) {
		global $wgLang, $wgOut, $wgRequest;

		$this->purge = $wgRequest->getVal( 'action' ) === 'purge';

		$this->setHeaders();
		$wgOut->addModules( 'ext.translate.special.supportedlanguages' );

		$cache = wfGetCache( CACHE_ANYTHING );
		$cachekey = wfMemcKey( 'translate-supportedlanguages', $wgLang->getCode() );
		$data = $cache->get( $cachekey );
		if ( !$this->purge && is_string( $data ) ) {
			$wgOut->addHtml( $data );
			return;
		}

		$this->outputHeader();
		$wgOut->addWikiMsg( 'supportedlanguages-colorlegend', $this->getColorLegend() );
		$wgOut->addWikiMsg( 'supportedlanguages-localsummary' );

		// Check if CLDR extension has been installed.
		$cldrInstalled = class_exists( 'LanguageNames' );

		if ( $cldrInstalled ) {
			$locals = LanguageNames::getNames( $wgLang->getCode(),
				LanguageNames::FALLBACK_NORMAL,
				LanguageNames::LIST_MW_AND_CLDR
			);
		}

		$natives = Language::getLanguageNames( false );
		ksort( $natives );

		$this->outputLanguageCloud( $natives );


		// Requires NS_PORTAL. If not present, display error text.
		if ( !defined( 'NS_PORTAL' ) ) {
			$users = $this->fetchTranslatorsAuto();
		} else {
			$users = $this->fetchTranslatorsPortal( $natives );
		}

		$this->preQueryUsers( $users );

		list( $editcounts, $lastedits ) = $this->getUserStats();
		global $wgUser;

		$skin = $wgUser->getSkin();

		// Information to be used inside the foreach loop.
		$linkInfo['rc']['title'] = SpecialPage::getTitleFor( 'Recentchanges' );
		$linkInfo['rc']['msg'] = wfMsg( 'supportedlanguages-recenttranslations' );
		$linkInfo['stats']['title'] = SpecialPage::getTitleFor( 'LanguageStats' );
		$linkInfo['stats']['msg'] = wfMsg( 'languagestats' );

		foreach ( array_keys( $natives ) as $code ) {
			if ( !isset( $users[$code] ) ) continue;

			// If CLDR is installed, add localised header and link title.
			if ( $cldrInstalled ) {
				$headerText = wfMsg( 'supportedlanguages-portallink', $code, $locals[$code], $natives[$code] );
			} else {
				// No CLDR, so a less localised header and link title.
				$headerText = wfMsg( 'supportedlanguages-portallink-nocldr', $code, $natives[$code] );
			}

			$headerText = htmlspecialchars( $headerText );

			$wgOut->addHtml( Html::openElement( 'h2', array( 'id' => $code ) ) );
			if ( defined( 'NS_PORTAL' ) ) {
				$portalTitle = Title::makeTitleSafe( NS_PORTAL, $code );
				$wgOut->addHtml( $skin->linkKnown( $portalTitle, $headerText ) );
			} else {
				$wgOut->addHtml( $headerText );
			}

			$wgOut->addHTML( "</h2>" );

			// Add useful links for language stats and recent changes for the language.
			$links = array();
			$links[] = $skin->link(
				$linkInfo['stats']['title'],
				$linkInfo['stats']['msg'],
				array(),
				array(
					'code' => $code,
					'suppresscomplete' => '1'
				),
				array( 'known', 'noclasses' )
			);
			$links[] = $skin->link(
				$linkInfo['rc']['title'],
				$linkInfo['rc']['msg'],
				array(),
				array(
					'translations' => 'only',
					'trailer' => "/" . $code
				),
				array( 'known', 'noclasses' )
			);
			$linkList = $wgLang->listToText( $links );

			$wgOut->addHTML( "<p>" . $linkList . "</p>\n" );
			$this->makeUserList( $users[$code], $editcounts, $lastedits );

		}
		$wgOut->addHtml( Html::element( 'hr' ) );
		$wgOut->addWikiMsg( 'supportedlanguages-count', $wgLang->formatNum( count( $users ) ) );

		$cache->set( $cachekey, $wgOut->getHTML(), 3600 );
	}
	/**
	 * Itterate through available languages, loading and parsing the data
	 * message from the MediaWiki namespace and writing the data to its output
	 * file handle.
	 */
	protected function writeFiles() {
		$langs = self::parseLanguageCodes( '*' );
		unset( $langs[array_search( 'en', $langs )] );
		$langs = array_merge( array( 'en' ), $langs );
		foreach ( $langs as $l ) {
			// Load message page.
			switch ( $this->type ) {
				case 'special':
					$title = Title::makeTitleSafe( NS_MEDIAWIKI, 'Sp-translate-data-SpecialPageAliases/' . $l );
					break;
				case 'magic':
					$title = Title::makeTitleSafe( NS_MEDIAWIKI, 'Sp-translate-data-MagicWords/' . $l );
					break;
				default:
					exit( 1 );
			}

			// Parse message page.
			if ( !$title || !$title->exists() ) {
				$this->output( "Skiping $l...\n" );

				$messagesNew = array();
			} else {
				$this->output( "Processing $l...\n" );

				$article = new Article( $title );
				$data = $article->getContent();

				// Parse message file.
				$segments = explode( "\n", $data );
				array_shift( $segments );
				array_shift( $segments );
				unset( $segments[count( $segments ) -1] );
				unset( $segments[count( $segments ) -1] );
				$messagesNew = array();
				foreach ( $segments as $segment ) {
					$parts = explode( ' = ', $segment );
					$key = array_shift( $parts );
					$translations = explode( ', ', implode( $parts ) );
					$messagesNew[$key] = $translations;
				}
			}

			// Write data to handles.
			$namesEn = LanguageNames::getNames( 'en' );
				$namesNative = Language::getLanguageNames();
			foreach ( $this->handles as $group => $handle ) {
				// Find messages to write to this handle.
				$messagesOut = array();
				foreach ( $this->messagesOld[$group]['en'] as $key => $message ) {
					if ( array_key_exists( $key, $messagesNew ) ) {
						$messagesOut[$key] = $messagesNew[$key];
					} elseif ( isset( $this->messagesOld[$group][$l][$key] ) ) {
						$messagesOut[$key] = $this->messagesOld[$group][$l][$key];
					}
				}

				// If there are messages to write, write them.
				if ( count( $messagesOut ) > 0 ) {
					switch( $this->type ) {
						case 'special':
							$out = "\n\n/** {$namesEn[$l]} ({$namesNative[$l]}) */\n\$specialPageAliases['{$l}'] = array(\n";
							break;
						case 'magic':
							$out = "\n\n/** {$namesEn[$l]} ({$namesNative[$l]}) */\n\$magicWords['{$l}'] = array(\n";
							break;
					}
					foreach ( $messagesOut as $key => $translations ) {
						foreach ( $translations as $id => $translation ) {
							$translations[$id] = addslashes( $translation );
							if ( $this->type === 'magic' && $translation == '0' ) {
									unset( $translations[$id] );
							}
						}
						$translations = implode( "', '", $translations );
						switch( $this->type ) {
							case 'special':
								$out .= "\t'$key' => array( '$translations' ),\n";
								break;
							case 'magic':
								if ( $this->messagesOld[$group]['en'][$key][0] === 0 ) {
									$out .= "\t'$key' => array( 0, '$translations' ),\n";
								} else {
									$out .= "\t'$key' => array( '$translations' ),\n";
								}
								break;
						}
					}
					$out .= ");";
					fwrite( $handle, $out );
				}
			}
		}
	}
	/**
	 * Get translated language names.
	 * @return array
	 */
	public static function getLanguageNames( /*string */ $code ) {
		if ( is_callable( array( 'Language', 'getTranslatedLanguageNames' ) ) ) {
			return Language::getTranslatedLanguageNames( $code );
		} elseif ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) {
			return LanguageNames::getNames( $code,
				LanguageNames::FALLBACK_NORMAL,
				LanguageNames::LIST_MW
			);
		} else {
			return Language::getLanguageNames( false );
		}
	}
	/**
	 * @param $wm Wikimania
	 * @param $u User
	 * @return array
	 */
	private function getFields( Wikimania $wm, User $u ) {
		static $fields;
		if( !$fields ) {
			$langList = array_flip( LanguageNames::getNames( $u->getOption( 'lang') ) );
			$langListWithEmpty = $langList;
			$langListWithEmpty[''] = '';
			$fields = array(
				/** PERSONAL INFORMATION **/
				'reg_fname' => array(
					'type' => 'text',
					'label-message' => 'wikimania-reg-fname',
					'section' => 'personal-info',
					'required' => true,
				),
				'reg_lname' => array(
					'type' => 'text',
					'label-message' => 'wikimania-reg-lname',
					'section' => 'personal-info',
					'required' => true,
				),
				'reg_gender' => array(
					'type' => 'radio',
					'label-message' => 'wikimania-reg-gender',
					'options' => self::getGenderPossibilities(),
					'section' => 'personal-info',
					'required' => true,
				),
				'reg_country' => array(
					'type' => 'select',
					'options' => array(),
					'section' => 'personal-info',
					'required' => true,
				),
				/** LINGUISTIC ABILItIES **/
				'langn' => array(
					'type' => 'select',
					'label-message' => 'wikimania-reg-langn',
					'options' => $langList,
					'section' => 'linguistic-abilities',
					'required' => true,
				),
				'lang1' => array(
					'type' => 'select',
					'label-message' => 'wikimania-reg-lang1',
					'options' => $langListWithEmpty,
					'section' => 'linguistic-abilities',
				),
				'lang2' => array(
					'type' => 'select',
					'label-message' => 'wikimania-reg-lang2',
					'options' => $langListWithEmpty,
					'section' => 'linguistic-abilities',
				),
				'lang3' => array(
					'type' => 'select',
					'label-message' => 'wikimania-reg-lang3',
					'options' => $langListWithEmpty,
					'section' => 'linguistic-abilities',
				),
			);
		}
		return $fields;
	}
	/**
	 * Hook: SpecialSearchProfileForm
	 */
	public static function searchProfileForm( SpecialSearch $search, &$form, /*string*/ $profile, $term, array $opts ) {
		if ( $profile !== 'translation' ) {
			return true;
		}

		if ( !$search->getSearchEngine()->supports( 'title-suffix-filter' ) ) {
			return false;
		}

		$hidden = '';
		foreach ( $opts as $key => $value ) {
			$hidden .= Html::hidden( $key, $value );
		}

		$context = $search->getContext();
		$code = $context->getLanguage()->getCode();
		$selected = $context->getRequest()->getVal( 'languagefilter' );

		if ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) {
			$languages = LanguageNames::getNames( $code,
				LanguageNames::FALLBACK_NORMAL,
				LanguageNames::LIST_MW
			);
		} else {
			$languages = Language::getLanguageNames( false );
		}

		ksort( $languages );

		$selector = new XmlSelect( 'languagefilter', 'languagefilter' );
		$selector->setDefault( $selected );
		$selector->addOption( wfMessage( 'translate-search-nofilter' )->text(), '-' );
		foreach ( $languages as $code => $name ) {
			$selector->addOption( "$code - $name", $code );
		}

		$selector = $selector->getHTML();

		$label = Xml::label( wfMessage( 'translate-search-languagefilter' )->text(), 'languagefilter' ) . '&#160;';
		$params = array( 'id' => 'mw-searchoptions' );

		$form = Xml::fieldset( false, false, $params ) .
			$hidden . $label . $selector .
			Html::closeElement( 'fieldset' );
		return false;
	}
示例#13
0
/** This function sets the changed data specified by the user.
 */
function profile_update($db_login)
{
    global $db;
    $playerID = $_SESSION['player']->playerID;
    $data = array('avatar' => Request::getVar('inputPlayerAvatar', ''), 'description' => Request::getVar('inputPlayerDescription', '', true), 'email2' => Request::getVar('inputPlayerEmail2', ''), 'gfxpath' => Request::getVar('inputPlayerGFX', ''), 'icq' => Request::getVar('inputPlayerICQ', ''), 'language' => Request::getVar('inputPlayerLang', ''), 'origin' => Request::getVar('inputPlayerOrigin', ''), 'template' => Request::getVar('inputPlayerTemplate', ''), 'passwordNew' => Request::getVar('inputPlayerPasswordNew', ''), 'passwordRe' => Request::getVar('inputPlayerPasswordRe', ''), 'jabberPwdNew' => Request::getVar('inputJabberPasswordNew', ''), 'jabberPwdRe' => Request::getVar('inputJabberPasswordRe', ''));
    // validate language code
    $uaLanguageNames = LanguageNames::getLanguageNames();
    if (!isset($uaLanguageNames[$data['language']])) {
        unset($data['language']);
    }
    // check if avatar is a image
    if (isset($data['avatar']) && !empty($data['avatar'])) {
        $avatarInfo = checkAvatar($data['avatar']);
        if (!$avatarInfo) {
            return array('type' => 'error', 'message' => 'Ungültiges Bild oder URL beim Avatar! Wird zurückgesetzt!');
        } else {
            $data['avatar'] = $avatarInfo;
        }
    } else {
        $data['avatar'] = '';
    }
    if (filter_var($data['email2'], FILTER_VALIDATE_EMAIL) === false) {
        return array('type' => 'error', 'message' => 'Ungültiges E-Mail Adresse. Bitte nimm deine Eingaben erneut vor!');
    }
    if (strcmp($data['jabberPwdNew'], $data['jabberPwdRe']) != 0) {
        return array('type' => 'error', 'message' => _('Das Jabber Passwort stimmt nicht mit der Wiederholung überein.'));
    }
    // password too short?
    if (empty($data['jabberPwdNew'])) {
        $data['jabberPwdNew'] = null;
    } else {
        if (!preg_match('/^\\w{6,}$/', unhtmlentities($data['jabberPwdNew']))) {
            return array('type' => 'error', 'message' => _('Das Jabber Passwort muss mindestens 6 Zeichen lang sein!'));
        }
    }
    $sql = $db->prepare("UPDATE " . PLAYER_TABLE . "\n                       SET origin = :origin,\n                         icq = :icq,\n                         avatar = :avatar,\n                         description = :description,\n                         template = :template,\n                         language = :language,\n                         gfxpath = :gfxpath,\n                         email2 = :email2,\n                         avatar = :avatar,\n                         jabberPassword = :jabberPassword\n                       WHERE playerID = :playerID");
    $sql->bindValue('origin', $data['origin'], PDO::PARAM_STR);
    $sql->bindValue('icq', $data['icq'], PDO::PARAM_INT);
    $sql->bindValue('description', $data['description'], PDO::PARAM_STR);
    $sql->bindValue('template', $data['template'], PDO::PARAM_INT);
    $sql->bindValue('language', $data['language'], PDO::PARAM_STR);
    $sql->bindValue('gfxpath', $data['gfxpath'], PDO::PARAM_STR);
    $sql->bindValue('email2', $data['email2'], PDO::PARAM_STR);
    $sql->bindValue('avatar', $data['avatar'], PDO::PARAM_STR);
    $sql->bindValue('jabberPassword', $data['jabberPwdNew'], PDO::PARAM_STR);
    $sql->bindValue('playerID', $playerID, PDO::PARAM_INT);
    if (!$sql->execute()) {
        return array('type' => 'error', 'message' => _('Die Daten konnten gar nicht oder zumindest nicht vollständig aktualisiert werden.'));
    }
    // ***** now update the password, if it is set **** **************************
    if (strlen($data['passwordNew'])) {
        // typo?
        if (strcmp($data['passwordNew'], $data['passwordRe']) != 0) {
            return array('type' => 'error', 'message' => _('Das Spiel Passwort stimmt nicht mit der Wiederholung überein.'));
        }
        // password too short?
        if (!preg_match('/^\\w{6,}$/', unhtmlentities($data['passwordNew']))) {
            return array('type' => 'error', 'message' => _('Das Spiel Passwort muss mindestens 6 Zeichen lang sein!'));
        }
        // set password
        $sql = $db_login->prepare("UPDATE Login SET password = :password WHERE LoginID = :loginID");
        $sql->bindValue('password', $data['passwordNew'], PDO::PARAM_STR);
        $sql->bindValue('loginID', $playerID, PDO::PARAM_INT);
        if (!$sql->execute() || $sql->rowCount() == 0) {
            return array('type' => 'error', 'message' => _('Die Daten konnten gar nicht oder zumindest nicht vollständig aktualisiert werden.'));
        }
    }
    return array('type' => 'success', 'message' => _('Die Daten wurden erfolgreich aktualisiert.'));
}
示例#14
0
 /**
  * @return array
  */
 public static function getLocalLanguageNames()
 {
     if (class_exists('LanguageNames')) {
         global $wgLang;
         return LanguageNames::getNames($wgLang->getCode());
     }
     return array();
 }
示例#15
0
文件: Xml.php 项目: Tjorriemorrie/app
 /**
  * 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, LanguageNames::FALLBACK_NORMAL, $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;
     }
     ksort($languages);
     /**
      * If a bogus value is set, default to the content language.
      * Otherwise, no default is selected and the user ends up
      * with an Afrikaans interface since it's first in the list.
      */
     $selected = isset($languages[$selected]) ? $selected : $wgLanguageCode;
     $options = "\n";
     foreach ($languages as $code => $name) {
         $options .= Xml::option("{$code} - {$name}", $code, $code == $selected) . "\n";
     }
     return array(Xml::label(wfMsg('yourlanguage'), 'wpUserLanguage'), Xml::tags('select', array('id' => 'wpUserLanguage', 'name' => 'wpUserLanguage'), $options));
 }
示例#16
0
 /**
  * Returns a list of language names that can be used by
  * a select input localized in the lang of which the code is provided.
  *
  * @since 0.1
  *
  * @param string $langCode
  *
  * @return array
  */
 public static function getLanguageOptions($langCode)
 {
     return self::getKeyPrefixedValues(LanguageNames::getNames($langCode));
 }
	protected function languages( $language ) {
		if ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) {
			$languages = LanguageNames::getNames( $language,
				LanguageNames::FALLBACK_NORMAL,
				LanguageNames::LIST_MW
			);
		} else {
			$languages = Language::getLanguageNames( false );
		}

		ksort( $languages );

		$options = array();
		foreach ( $languages as $code => $name ) {
			$options["$code - $name"] = $code;
		}
		return $options;
	}