function execute($par)
 {
     global $wgRequest, $wgOut;
     $this->setHeaders();
     $this->outputHeader();
     # no UI when including()
     if (!$this->including()) {
         $code = $wgRequest->getVal('code', $par);
         $suppressComplete = $wgRequest->getVal('suppresscomplete', $par);
         $suppressEmpty = $wgRequest->getVal('suppressempty', false);
         $wgOut->addHTML($this->languageForm($code, $suppressComplete));
     } else {
         $paramArray = explode('/', $par);
         $code = $paramArray[0];
         $suppressComplete = isset($paramArray[1]) && (bool) $paramArray[1];
         $suppressEmpty = isset($paramArray[2]) && (bool) $paramArray[2];
     }
     $out = '';
     if (array_key_exists($code, Language::getLanguageNames())) {
         $out .= $this->getGroupStats($code, $suppressComplete, $suppressEmpty);
     } else {
         if ($code) {
             $wgOut->addWikiMsg('translate-page-no-such-language');
         }
     }
     $wgOut->addHTML($out);
 }
示例#2
0
/**
 * Takes all available languages if none are specified.
 * 
 * @global array $wgPolyglotLanguages 
 */
function wfPolyglotExtension()
{
    global $wgPolyglotLanguages;
    if ($wgPolyglotLanguages === null) {
        $wgPolyglotLanguages = array_keys(Language::getLanguageNames());
    }
}
示例#3
0
 /**
  * Assuming the user's interface language is fi
  * Given input Page, it returns Page/fi if it exists, otherwise Page
  * Given input Page/de, it returns Page/fi if it exists, otherwise Page/de if it exists, otherwise Page
  * @return Title|null
  */
 protected function findTitle($par)
 {
     global $wgLang, $wgLanguageCode;
     // base = title without language code suffix
     // provided = the title as it was given
     $base = $provided = Title::newFromText($par);
     if (strpos($par, '/') !== false) {
         $pos = strrpos($par, '/');
         $basepage = substr($par, 0, $pos);
         $code = substr($par, $pos + 1);
         $codes = Language::getLanguageNames(false);
         if (isset($codes[$code])) {
             $base = Title::newFromText($basepage);
         }
     }
     if (!$base) {
         return null;
     }
     $uiCode = $wgLang->getCode();
     $proposed = Title::newFromText($base->getPrefixedText() . "/{$uiCode}");
     if ($uiCode !== $wgLanguageCode && $proposed && $proposed->exists()) {
         return $proposed;
     } elseif ($provided && $provided->exists()) {
         return $provided;
     } else {
         return $base;
     }
 }
示例#4
0
 public function execute()
 {
     global $wgUser, $wgTranslateWorkflowStates;
     if (!$wgTranslateWorkflowStates) {
         $this->dieUsage('Message group review not in use', 'disabled');
     }
     if (!$wgUser->isallowed(self::$right)) {
         $this->dieUsage('Permission denied', 'permissiondenied');
     }
     $requestParams = $this->extractRequestParams();
     $group = MessageGroups::getGroup($requestParams['group']);
     if (!$group) {
         $this->dieUsageMsg(array('missingparam', 'group'));
     }
     $languages = Language::getLanguageNames(false);
     if (!isset($languages[$requestParams['language']])) {
         $this->dieUsageMsg(array('missingparam', 'language'));
     }
     $dbr = wfGetDB(DB_SLAVE);
     $groupid = $group->getId();
     $currentState = $dbr->selectField('translate_groupreviews', 'tgr_state', array('tgr_group' => $groupid, 'tgr_lang' => $requestParams['language']), __METHOD__);
     if ($currentState == $requestParams['state']) {
         $this->dieUsage('The requested state is identical to the current state', 'sameworkflowstate');
     }
     $dbw = wfGetDB(DB_MASTER);
     $table = 'translate_groupreviews';
     $row = array('tgr_group' => $groupid, 'tgr_lang' => $requestParams['language'], 'tgr_state' => $requestParams['state']);
     $index = array('tgr_group', 'tgr_language');
     $res = $dbw->replace($table, array($index), $row, __METHOD__);
     $logger = new LogPage('translationreview');
     $logParams = array($requestParams['language'], $group->getLabel(), $currentState, $requestParams['state']);
     $logger->addEntry('group', SpecialPage::getTitleFor('Translate', $groupid), '', $logParams, $wgUser);
     $output = array('review' => array('group' => $group->getId(), 'language' => $requestParams['language'], 'state' => $requestParams['state']));
     $this->getResult()->addValue(null, $this->getModuleName(), $output);
 }
示例#5
0
 public function stripInterlang($content)
 {
     global $wgContLang;
     $lang_mask = "(" . join("|", array_keys(Language::getLanguageNames())) . ")";
     $content = preg_replace("@\\[\\[" . $lang_mask . ":[^\\]]*?].*?\\]@si", '', $content);
     $content = trim($content);
     return $content;
 }
示例#6
0
function wfPolyglotExtension()
{
    global $wgPolyglotLanguages;
    if ($wgPolyglotLanguages === null) {
        $wgPolyglotLanguages = @$GLOBALS['wgLanguageSelectorLanguages'];
    }
    if ($wgPolyglotLanguages === null) {
        $wgPolyglotLanguages = array_keys(Language::getLanguageNames());
    }
}
 function execute($par)
 {
     global $wgOut;
     $wgOut->setPageTitle(wfMsg('communityhiring-header'));
     $formDescriptor = array('about-intro' => array('type' => 'info', 'default' => wfMsgExt('communityhiring-about-intro', 'parse'), 'raw' => 1, 'section' => 'aboutyou'), 'given-name' => array('type' => 'text', 'label-message' => 'communityhiring-given', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'family-name' => array('type' => 'text', 'label-message' => 'communityhiring-family', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'address-line1' => array('type' => 'textarea', 'label-message' => 'communityhiring-address', 'section' => 'aboutyou', 'rows' => '3', 'cols' => '20'), 'address-city' => array('type' => 'text', 'label-message' => 'communityhiring-address-city', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'address-postal' => array('type' => 'text', 'label-message' => 'communityhiring-address-postal', 'section' => 'aboutyou'), 'address-country' => array('type' => 'text', 'label-message' => 'communityhiring-address-country', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'phone' => array('type' => 'text', 'label-message' => 'communityhiring-phone', 'section' => 'aboutyou'), 'email' => array('type' => 'text', 'label-message' => 'communityhiring-email', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'paragraph-intro' => array('type' => 'info', 'default' => wfMsgExt('communityhiring-paragraphs-intro', 'parse'), 'raw' => 1, 'section' => 'paragraphs', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'significance' => array('type' => 'textarea', 'label-message' => 'communityhiring-significance', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'excitement' => array('type' => 'textarea', 'label-message' => 'communityhiring-excitement', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'experiences' => array('type' => 'textarea', 'label-message' => 'communityhiring-experiences', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'other' => array('type' => 'textarea', 'label-message' => 'communityhiring-other', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1), 'languages' => array('type' => 'textarea', 'options' => array_flip(Language::getLanguageNames()), 'section' => 'demonstrative/languages', 'rows' => '3', 'label-message' => 'communityhiring-languages-label', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'contributor' => array('type' => 'radio', 'label-message' => 'communityhiring-contributor', 'section' => 'demonstrative/involvement', 'options' => array('Yes' => 'yes', 'No' => 'no')), 'usernames' => array('type' => 'textarea', 'rows' => '3', 'cols' => '20', 'label-message' => 'communityhiring-usernames', 'section' => 'demonstrative/involvement', 'vertical-label' => 1), 'wikimedia-links' => array('type' => 'textarea', 'label-message' => 'communityhiring-links', 'section' => 'demonstrative/involvement', 'rows' => '3', 'cols' => '20', 'vertical-label' => 1), 'other-links' => array('type' => 'textarea', 'label-message' => 'communityhiring-links-other', 'section' => 'demonstrative', 'rows' => '3', 'cols' => '20', 'vertical-label' => 1), 'availability-time' => array('type' => 'text', 'label-message' => 'communityhiring-availability-intro', 'section' => 'availability', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'availability-info' => array('type' => 'textarea', 'label-message' => 'communityhiring-availability-info', 'section' => 'availability', 'rows' => '5', 'cols' => '20', 'vertical-label' => 1), 'relocation' => array('type' => 'radio', 'label-message' => 'communityhiring-relocation-ok', 'section' => 'availability', 'vertical-label' => 1, 'options' => array('Yes' => 'yes', 'No' => 'no', 'It would be hard, but maybe I would' => 'maybe')), 'research' => array('type' => 'textarea', 'rows' => '5', 'label-message' => 'communityhiring-research', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')));
     $form = new HTMLForm($formDescriptor, 'communityhiring');
     $form->setIntro(wfMsgExt('communityhiring-intro', 'parse'));
     $form->setSubmitCallback(array($this, 'submit'));
     $form->setTitle($this->getTitle());
     $form->show();
 }
示例#8
0
    function buildForm()
    {
        global $wgScript;
        $languages = Language::getLanguageNames(false);
        ksort($languages);
        $out = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'id' => 'mw-allmessages-form')) . Xml::fieldset(wfMsg('allmessages-filter-legend')) . Xml::hidden('title', $this->getTitle()) . Xml::openElement('table', array('class' => 'mw-allmessages-table')) . "\n" . '<tr>
				<td class="mw-label">' . Xml::label(wfMsg('allmessages-prefix'), 'mw-allmessages-form-prefix') . "</td>\n\n\t\t\t\t<td class=\"mw-input\">" . Xml::input('prefix', 20, str_replace('_', ' ', $this->prefix), array('id' => 'mw-allmessages-form-prefix')) . "</td>\n\n\t\t\t</tr>\n\t\t\t<tr>\n\n\t\t\t\t<td class='mw-label'>" . wfMsg('allmessages-filter') . "</td>\n\n\t\t\t\t<td class='mw-input'>" . Xml::radioLabel(wfMsg('allmessages-filter-unmodified'), 'filter', 'unmodified', 'mw-allmessages-form-filter-unmodified', $this->filter == 'unmodified' ? true : false) . Xml::radioLabel(wfMsg('allmessages-filter-all'), 'filter', 'all', 'mw-allmessages-form-filter-all', $this->filter == 'all' ? true : false) . Xml::radioLabel(wfMsg('allmessages-filter-modified'), 'filter', 'modified', 'mw-allmessages-form-filter-modified', $this->filter == 'modified' ? true : false) . "</td>\n\n\t\t\t</tr>\n\t\t\t<tr>\n\n\t\t\t\t<td class=\"mw-label\">" . Xml::label(wfMsg('allmessages-language'), 'mw-allmessages-form-lang') . "</td>\n\n\t\t\t\t<td class=\"mw-input\">" . Xml::openElement('select', array('id' => 'mw-allmessages-form-lang', 'name' => 'lang'));
        foreach ($languages as $lang => $name) {
            $selected = $lang == $this->langCode ? true : false;
            $out .= Xml::option($lang . ' - ' . $name, $lang, $selected) . "\n";
        }
        $out .= Xml::closeElement('select') . "</td>\n\n\t\t\t</tr>\n\t\t\t<tr>\n\n\t\t\t\t<td></td>\n\t\t\t\t<td>" . Xml::submitButton(wfMsg('allmessages-filter-submit')) . "</td>\n\n\t\t\t</tr>" . Xml::closeElement('table') . $this->table->getHiddenFields(array('title', 'prefix', 'filter', 'lang')) . Xml::closeElement('fieldset') . Xml::closeElement('form');
        return $out;
    }
 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;
 }
 /**
  * Get localized language names for a particular language, using fallback languages for missing
  * items.
  *
  * @param $code string
  * @param $fbMethod int
  * @param $list int
  * @return an associative array of language codes and localized language names
  */
 public static function getNames($code, $fbMethod = self::FALLBACK_NATIVE, $list = self::LIST_MW)
 {
     $xx = self::loadLanguage($code);
     $native = Language::getLanguageNames($list === self::LIST_MW_SUPPORTED);
     if ($fbMethod === self::FALLBACK_NATIVE) {
         $names = array_merge($native, $xx);
     } elseif ($fbMethod === self::FALLBACK_NORMAL) {
         // Load missing language names from fallback languages
         $fb = $xx;
         if (is_callable(array('Language', 'getFallbacksFor'))) {
             // MediaWiki 1.19
             $fallbacks = Language::getFallbacksFor($code);
             foreach ($fallbacks as $fallback) {
                 // Overwrite the things in fallback with what we have already
                 $fb = array_merge(self::loadLanguage($fallback), $fb);
             }
         } else {
             // MediaWiki 1.18 or earlier
             $fallback = $code;
             while ($fallback = Language::getFallbackFor($fallback)) {
                 // Overwrite the things in fallback with what we have already
                 $fb = array_merge(self::loadLanguage($fallback), $fb);
             }
         }
         /* Add native names for codes that are not in cldr */
         $names = array_merge($native, $fb);
         /* As a last resort, try the native name in Names.php */
         if (!isset($names[$code]) && isset($native[$code])) {
             $names[$code] = $native[$code];
         }
     } else {
         throw new MWException("Invalid value for 2:\$fallback in " . __METHOD__);
     }
     switch ($list) {
         case self::LIST_MW:
         case self::LIST_MW_SUPPORTED:
             /* Remove entries that are not in fb */
             $names = array_intersect_key($names, $native);
             /* And fall to the return */
         /* And fall to the return */
         case self::LIST_MW_AND_CLDR:
             return $names;
         default:
             throw new MWException("Invalid value for 3:\$list in " . __METHOD__);
     }
 }
 public static function forGroup($id)
 {
     # Fetch from database
     $dbr = wfGetDB(DB_SLAVE);
     $conds = array('gs_group' => $id);
     $res = $dbr->select('groupstats', '*', $conds);
     while ($row = $dbr->fetchRow($res)) {
         $stats[$row['gs_lang']] = $row;
     }
     # Go over each language filling missing entries
     foreach (Language::getLanguageNames() as $lang => $name) {
         if (!empty($stats[$lang])) {
             continue;
         }
         $stats[$lang] = self::forItem($id, $lang);
     }
     return $stats;
 }
示例#12
0
 /**
  * Renders the storyboard tag.
  * 
  * @param $input
  * @param array $args
  * @param Parser $parser
  * @param $frame
  * 
  * @return array
  */
 public static function render($input, array $args, Parser $parser, $frame)
 {
     global $wgScriptPath, $wgStylePath, $wgStyleVersion, $wgContLanguageCode;
     global $egStoryboardScriptPath, $egStoryboardWidth, $egStoryboardHeight;
     efStoryboardAddJSLocalisation($parser);
     // TODO: Combine+minfiy JS files, add switch to use combined+minified version
     $parser->getOutput()->addHeadItem(Html::linkedStyle("{$egStoryboardScriptPath}/storyboard.css?{$wgStyleVersion}") . Html::linkedScript("{$wgStylePath}/common/jquery.min.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/jquery/jquery.ajaxscroll.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/tags/Storyboard/storyboard.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/storyboard.js?{$wgStyleVersion}"));
     $width = StoryboardUtils::getDimension($args, 'width', $egStoryboardWidth);
     $height = StoryboardUtils::getDimension($args, 'height', $egStoryboardHeight);
     $languages = Language::getLanguageNames();
     if (array_key_exists('language', $args) && array_key_exists($args['language'], $languages)) {
         $language = $args['language'];
     } else {
         $language = $wgContLanguageCode;
     }
     $parser->getOutput()->addHeadItem(Html::inlineScript("var storyboardLanguage = '{$language}';"));
     $output = Html::element('div', array('class' => 'storyboard', 'style' => "height: {$height}; width: {$width};"));
     return array($output, 'noparse' => true, 'isHTML' => true);
 }
 /**
  * Constructor
  *
  * @param $langobj Language: the Language Object
  * @param $maincode String: the main language code of this language
  * @param $variants Array: the supported variants of this language
  * @param $variantfallbacks Array: the fallback language of each variant
  * @param $flags Array: defining the custom strings that maps to the flags
  * @param $manualLevel Array: limit for supported variants
  */
 public function __construct($langobj, $maincode, $variants = array(), $variantfallbacks = array(), $flags = array(), $manualLevel = array())
 {
     global $wgDisabledVariants;
     $this->mLangObj = $langobj;
     $this->mMainLanguageCode = $maincode;
     $this->mVariants = array_diff($variants, $wgDisabledVariants);
     $this->mVariantFallbacks = $variantfallbacks;
     $this->mVariantNames = Language::getLanguageNames();
     $this->mCacheKey = wfMemcKey('conversiontables', $maincode);
     $defaultflags = array('A' => 'A', 'T' => 'T', 'R' => 'R', 'D' => 'D', '-' => '-', 'H' => 'H', 'N' => 'N');
     $this->mFlags = array_merge($defaultflags, $flags);
     foreach ($this->mVariants as $v) {
         if (array_key_exists($v, $manualLevel)) {
             $this->mManualLevel[$v] = $manualLevel[$v];
         } else {
             $this->mManualLevel[$v] = 'bidirectional';
         }
         $this->mFlags[$v] = $v;
     }
 }
示例#14
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;
 }
示例#15
0
 public function __construct($options = array())
 {
     $this->_defaults[] = $this->_base_defaults;
     parent::__construct($options);
     if (!isset($this->options['languages']) && isset(Booty::$skinOptions['languages'])) {
         $this->options['languages'] = Booty::$skinOptions['languages'];
     }
     $this->addTemplatePath(dirname(__FILE__) . '/templates');
     if (isset($this->options['languages'])) {
         $names = Language::getLanguageNames();
         $languages = array();
         foreach ($this->options['languages'] as $code) {
             if (array_key_exists($code, $names)) {
                 $languages[$code] = $names[$code];
             }
         }
         $this->data['languages'] = $languages;
         $context = RequestContext::getMain();
         $active = $context->getLanguage();
         $this->data['active_language'] = array('name' => $active->fetchLanguageName($active->getCode()), 'code' => $active->getCode());
     }
 }
	/**
	 * Retrieves and shows the user language and test wiki
	 * @param $target Mixed: user whose language and test wiki we're looking up
	 */
	function showInfo( $target ) {
		global $wgOut, $wmincPref, $wmincProjectSite;
		if( User::isIP( $target ) ) {
			# show error if it is an IP address
			$wgOut->addHTML( Xml::span( wfMsg( 'wminc-ip', $target ), 'error' ) );
			return;
		}
		$user = User::newFromName( $target );
		$name = $user->getName();
		$id = $user->getId();
		$langNames = Language::getLanguageNames();
		$linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;
		if ( $user == null || $id == 0 ) {
			# show error if a user with that name does not exist
			$wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) );
			return;
		}
		$userproject = $user->getOption( $wmincPref . '-project' );
		$userproject = ( $userproject ? $userproject : 'none' );
		$usercode = $user->getOption( $wmincPref . '-code' );
		$prefix = IncubatorTest::displayPrefix( $userproject, $usercode ? $usercode : 'none' );
		if ( IncubatorTest::isContentProject( $userproject ) ) {
			$testwiki = $linker->link( Title::newFromText( $prefix ) );
		} elseif ( $prefix == $wmincProjectSite['short'] ) {
			$testwiki = htmlspecialchars( $wmincProjectSite['name'] );
		} else {
			$testwiki = wfMsgHtml( 'wminc-testwiki-none' );
		}
		$wgOut->addHtml(
			Xml::openElement( 'ul' ) .
			'<li>' . wfMsgHtml( 'username' ) . ' ' .
				$linker->userLink( $id, $name ) . $linker->userToolLinks( $id, $name, true ) . '</li>' .
			'<li>' . wfMsgHtml( 'loginlanguagelabel', $langNames[$user->getOption( 'language' )] .
				' (' . $user->getOption( 'language' ) . ')' ) . '</li>' .
			'<li>' . wfMsgHtml( 'wminc-testwiki' ) . ' ' . $testwiki . '</li>' .
			Xml::closeElement( 'ul' )
		);
	}
 function showEditForm($messageName)
 {
     global $wgOut, $wgUser;
     $originalMsgs = array();
     $encAction = $this->getTitle()->escapeFullUrl();
     $languages = Language::getLanguageNames(true);
     $sk = $wgUser->getSkin();
     $wgOut->addHTML("<h3>Showing values for message name \"" . htmlspecialchars($messageName) . "\"</h3>\n");
     $wgOut->addHTML('<p>' . $sk->makeLinkObj($this->getTitle(), wfMsg('editmsg-new-search')) . '</p>');
     $wgOut->addHTML("<form method=\"POST\" action=\"{$encAction}\"><table>");
     foreach ($languages as $lang => $langName) {
         $messages = false;
         require Language::getMessagesFileName($lang);
         if (isset($messages[$messageName])) {
             $msgValue = $messages[$messageName];
             $originalMsgs[$lang] = $msgValue;
             $wgOut->addHTML('<tr>' . Xml::element('td', null, $lang) . Xml::tags('td', null, Xml::element('textarea', array('name' => "msg[{$lang}]", 'rows' => ceil(mb_strlen($msgValue) / 70) + substr_count($msgValue, "\n"), 'cols' => '70'), $msgValue)) . '</tr>');
         }
     }
     $wgOut->addHTML("</table>");
     $wgOut->addHTML(Xml::element('input', array('type' => 'hidden', 'name' => 'originalMsgs', 'value' => chunk_split(base64_encode(gzdeflate(json_encode($originalMsgs))), 120, ' '))));
     $wgOut->addHTML(Xml::element('input', array('type' => 'hidden', 'name' => 'messageName', 'value' => $messageName)));
     $wgOut->addHTML('<p>' . Xml::element('input', array('type' => 'submit', 'name' => 'editmsg_get_patch', 'value' => wfMsg('editmsg-get-patch'))) . '</p></form>');
 }
示例#18
0
 public function appendLanguages($property)
 {
     $params = $this->extractRequestParams();
     $langCode = isset($params['inlanguagecode']) ? $params['inlanguagecode'] : '';
     if ($langCode) {
         $langNames = Language::getTranslatedLanguageNames($langCode);
     } else {
         $langNames = Language::getLanguageNames();
     }
     $data = array();
     foreach ($langNames as $code => $name) {
         $lang = array('code' => $code);
         ApiResult::setContent($lang, $name);
         $data[] = $lang;
     }
     $this->getResult()->setIndexedTagName($data, 'lang');
     return $this->getResult()->addValue('query', $property, $data);
 }
	public function loadMediaWiki() {
		$mwLanguages = Language::getLanguageNames( true );
		foreach ( $mwLanguages as $code => $name ) {
			$obj = Language::factory( $code );
			$method = new ReflectionMethod( $obj, 'convertPlural' );
			if ( $method->getDeclaringClass()->name === 'Language' ) {
				$mwLanguages[$code] = false;
			}
		}
		return $mwLanguages;
	}
示例#20
0
 /**
  * check if domain is not taken or is creatable
  */
 private function checkDomain()
 {
     global $wgUser;
     $status = 0;
     wfProfileIn(__METHOD__);
     if (strlen($this->mDomain) === 0) {
         // empty field
         $status = self::ERROR_DOMAIN_IS_EMPTY;
     } elseif (strlen($this->mDomain) < 3) {
         // too short
         $status = self::ERROR_DOMAIN_TOO_SHORT;
     } elseif (strlen($this->mDomain) > 50) {
         // too long
         $status = self::ERROR_DOMAIN_TOO_LONG;
     } elseif (preg_match('/[^a-z0-9-]/i', $this->mDomain)) {
         // invalid name
         $status = self::ERROR_DOMAIN_BAD_NAME;
     } elseif (in_array($this->mDomain, array_keys(Language::getLanguageNames()))) {
         // invalid name (name is used language)
         $status = self::ERROR_DOMAIN_POLICY_VIOLATIONS;
     } elseif (!$wgUser->isAllowed("staff") && AutoCreateWiki::checkBadWords($this->mDomain, "domain") === false) {
         // invalid name (bad words)
         $status = self::ERROR_DOMAIN_POLICY_VIOLATIONS;
     } else {
         if (AutoCreateWiki::domainExists($this->mDomain, $this->mLanguage)) {
             $status = self::ERROR_DOMAIN_NAME_TAKEN;
         }
     }
     wfProfileOut(__METHOD__);
     return $status;
 }
示例#21
0
	$groups = array( $group );
}

if ( !isset( $options['lang'] ) || strval( $options['lang'] ) === '' ) {
	STDERR( "ESG3: List of language codes must be supplied with lang parameter." );
	exit( 1 );
}

$start = isset( $options['start'] ) ? strtotime( $options['start'] ) : false;
$end = isset( $options['end'] ) ? strtotime( $options['end'] ) : false;

STDOUT( "Conflict times: " . wfTimestamp( TS_ISO_8601, $start ) . " - " . wfTimestamp( TS_ISO_8601, $end ) );

$codes = array_filter( array_map( 'trim', explode( ',', $options['lang'] ) ) );

$supportedCodes = array_keys( Language::getLanguageNames( false ) );
ksort( $supportedCodes );

if ( $codes[0] === '*' ) {
	$codes = $supportedCodes;
}

foreach ( $groups as &$group ) {
	// No sync possible for meta groups
	if ( $group->isMeta() ) {
		continue;
	}

	STDOUT( "{$group->getLabel()} ", $group );

	foreach ( $codes as $code ) {
 /**
  * Handler for the BeforePageDisplay hook
  *
  * @param $out OutputPage
  * @param $text String
  * @return bool
  */
 public function beforePageDisplayHTML(&$out, &$text)
 {
     global $wgRequest, $wgConf, $wgEnableZeroRatedMobileAccessTesting;
     wfProfileIn(__METHOD__);
     $DB = wfGetDB(DB_MASTER);
     $DBName = $DB->getDBname();
     list($site, $lang) = $wgConf->siteFromDB($DBName);
     if ($site == 'wikipedia' || $wgEnableZeroRatedMobileAccessTesting) {
         $xDevice = isset($_SERVER['HTTP_X_DEVICE']) ? $_SERVER['HTTP_X_DEVICE'] : '';
         self::$useFormat = $wgRequest->getText('useformat');
         if (self::$useFormat !== 'mobile' && self::$useFormat !== 'mobile-wap' && !$xDevice) {
             wfProfileOut(__METHOD__);
             return true;
         }
         $output = '';
         self::$renderZeroRatedLandingPage = $wgRequest->getFuzzyBool('renderZeroRatedLandingPage');
         self::$renderZeroRatedBanner = $wgRequest->getFuzzyBool('renderZeroRatedBanner');
         self::$renderZeroRatedRedirect = $wgRequest->getFuzzyBool('renderZeroRatedRedirect');
         self::$forceClickToViewImages = $wgRequest->getFuzzyBool('forceClickToViewImages');
         self::$acceptBilling = $wgRequest->getVal('acceptbilling');
         self::$title = $out->getTitle();
         $carrier = $wgRequest->getHeader('HTTP_X_CARRIER');
         if ($carrier !== '(null)' && $carrier) {
             self::$renderZeroRatedBanner = true;
         }
         if (self::$title->getNamespace() == NS_FILE) {
             self::$isFilePage = true;
         }
         if (self::$acceptBilling === 'no') {
             $targetUrl = $wgRequest->getVal('returnto');
             $out->redirect($targetUrl, '301');
             $out->output();
         }
         if (self::$acceptBilling === 'yes') {
             $targetUrl = $wgRequest->getVal('returnto');
             if ($targetUrl) {
                 $out->redirect($targetUrl, '301');
                 $out->output();
             }
         }
         if (self::$isFilePage && self::$acceptBilling !== 'yes') {
             $acceptBillingYes = Html::rawElement('a', array('href' => $wgRequest->appendQuery('renderZeroRatedBanner=true&acceptbilling=yes')), wfMsg('zero-rated-mobile-access-banner-text-data-charges-yes'));
             $referrer = $wgRequest->getHeader('referer');
             $acceptBillingNo = Html::rawElement('a', array('href' => $wgRequest->appendQuery('acceptbilling=no&returnto=' . urlencode($referrer))), wfMsg('zero-rated-mobile-access-banner-text-data-charges-no'));
             $bannerText = Html::rawElement('h3', array('id' => 'zero-rated-banner-text'), wfMsg('zero-rated-mobile-access-banner-text-data-charges', $acceptBillingYes, $acceptBillingNo));
             $banner = Html::rawElement('div', array('style' => 'display:none;', 'id' => 'zero-rated-banner-red'), $bannerText);
             $output .= $banner;
             $out->clearHTML();
             $out->setPageTitle(null);
         } elseif (self::$renderZeroRatedRedirect === true) {
             $returnto = $wgRequest->getVal('returnto');
             $acceptBillingYes = Html::rawElement('a', array('href' => $wgRequest->appendQuery('renderZeroRatedBanner=true&acceptbilling=yes&returnto=' . urlencode($returnto))), wfMsg('zero-rated-mobile-access-banner-text-data-charges-yes'));
             $referrer = $wgRequest->getHeader('referer');
             $acceptBillingNo = Html::rawElement('a', array('href' => $wgRequest->appendQuery('acceptbilling=no&returnto=' . urlencode($referrer))), wfMsg('zero-rated-mobile-access-banner-text-data-charges-no'));
             $bannerText = Html::rawElement('h3', array('id' => 'zero-rated-banner-text'), wfMsg('zero-rated-mobile-access-banner-text-data-charges', $acceptBillingYes, $acceptBillingNo));
             $banner = Html::rawElement('div', array('style' => 'display:none;', 'id' => 'zero-rated-banner-red'), $bannerText);
             $output .= $banner;
             $out->clearHTML();
             $out->setPageTitle(null);
         } elseif (self::$renderZeroRatedBanner === true) {
             self::$carrier = $this->lookupCarrier($carrier);
             if (isset(self::$carrier['name'])) {
                 $html = $out->getHTML();
                 $parsedHtml = $this->parseLinksForZeroQueryString($html);
                 $out->clearHTML();
                 $out->addHTML($parsedHtml);
                 $carrierLink = isset(self::$carrier['link']) ? self::$carrier['link'] : '';
                 $bannerText = Html::rawElement('span', array('id' => 'zero-rated-banner-text'), wfMsg('zero-rated-mobile-access-banner-text', $carrierLink));
                 $banner = Html::rawElement('div', array('style' => 'display:none;', 'id' => 'zero-rated-banner'), $bannerText);
                 $output .= $banner;
             }
         }
         if (self::$renderZeroRatedLandingPage === true) {
             $out->clearHTML();
             $out->setPageTitle(null);
             $output .= wfMsg('zero-rated-mobile-access-desc');
             $languageNames = Language::getLanguageNames();
             $country = $wgRequest->getVal('country');
             $ip = $wgRequest->getVal('ip', wfGetIP());
             // Temporary hack to allow for testing on localhost
             $countryIps = array('GERMANY' => '80.237.226.75', 'MEXICO' => '187.184.240.247', 'THAILAND' => '180.180.150.104', 'FRANCE' => '90.6.70.28');
             $ip = strpos($ip, '192.168.') === 0 ? $countryIps['THAILAND'] : $ip;
             if (IP::isValid($ip)) {
                 // If no country was passed, try to do GeoIP lookup
                 // Requires php5-geoip package
                 if (!$country && function_exists('geoip_country_code_by_name')) {
                     $country = geoip_country_code_by_name($ip);
                 }
                 self::addDebugOutput($country);
             }
             $languageOptions = $this->createLanguageOptionsFromWikiText();
             // self::$displayDebugOutput = true;
             $languagesForCountry = isset($languageOptions[self::getFullCountryNameFromCode($country)]) ? $languageOptions[self::getFullCountryNameFromCode($country)] : null;
             self::addDebugOutput(self::getFullCountryNameFromCode($country));
             self::addDebugOutput($languagesForCountry);
             self::writeDebugOutput();
             if (is_array($languagesForCountry)) {
                 $sizeOfLanguagesForCountry = sizeof($languagesForCountry);
                 for ($i = 0; $i < $sizeOfLanguagesForCountry; $i++) {
                     $languageName = $languageNames[$languagesForCountry[$i]['language']];
                     $languageCode = $languagesForCountry[$i]['language'];
                     $output .= Html::element('hr');
                     $output .= Html::element('h3', array('id' => 'lang_' . $languageCode), $languageName);
                     if ($i == 0) {
                         $output .= self::getSearchFormHtml($languageCode);
                     } else {
                         $languageUrl = sprintf(self::$formatMobileUrl, $languageCode);
                         $output .= Html::element('a', array('id' => 'lang_' . $languageCode, 'href' => $languageUrl), wfMessage('zero-rated-mobile-access-home-page-selection', $languageName)->inLanguage($languageCode));
                         $output .= Html::element('br');
                     }
                 }
             }
             $output .= Html::element('hr');
             $output .= wfMsg('zero-rated-mobile-access-home-page-selection-text');
             $output .= Html::openElement('select', array('id' => 'languageselection', 'onchange' => 'javascript:window.location = this.options[this.selectedIndex].value;'));
             $output .= Html::element('option', array('value' => ''), wfMsg('zero-rated-mobile-access-language-selection'));
             foreach ($languageNames as $languageCode => $languageName) {
                 $output .= Html::element('option', array('value' => sprintf(self::$formatMobileUrl, $languageCode)), $languageName);
             }
             $output .= Html::closeElement('select');
         }
         if ($output) {
             $output = Html::openElement('div', array('id' => 'zero-landing-page')) . $output . Html::closeElement('div');
             $out->addHTML($output);
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
 /**
  * Returns a list of languages that can be translated to.
  * 
  * @since 1.2
  * 
  * @param string $currentLang
  * 
  * @return array
  */
 public static function getLanguages($currentLang)
 {
     global $wgUser, $wgLanguageCode, $egLiveTranslateLanguages;
     $allowedLanguages = array_merge($egLiveTranslateLanguages, array($currentLang));
     $targetLang = $wgLanguageCode;
     $languages = Language::getLanguageNames(false);
     if ($wgUser->isLoggedIn()) {
         $userLang = $wgUser->getOption('language');
         if (array_key_exists($userLang, $languages) && in_array($userLang, $allowedLanguages)) {
             $targetLang = $userLang;
         }
     }
     $options = array();
     ksort($languages);
     foreach ($languages as $code => $name) {
         if (in_array($code, $allowedLanguages) && $code != $currentLang) {
             $display = wfBCP47($code) . ' - ' . $name;
             $options[$display] = $code;
         }
     }
     return $options;
 }
示例#24
0
 function execute($par)
 {
     global $wgOut;
     $langNames = Language::getLanguageNames();
     $this->setHeaders();
     $this->outputHeader();
     $matrix = new SiteMatrix();
     $localLanguageNames = self::getLocalLanguageNames();
     # Construct the HTML
     # Header row
     $s = Xml::openElement('table', array('class' => 'wikitable', 'id' => 'mw-sitematrix-table')) . "<tr>" . Xml::element('th', array('rowspan' => 2), wfMsg('sitematrix-language')) . Xml::element('th', array('colspan' => count($matrix->getSites())), wfMsg('sitematrix-project')) . "</tr>\n\t\t\t<tr>";
     foreach ($matrix->getNames() as $id => $name) {
         $url = $matrix->getSiteUrl($id);
         $s .= Xml::tags('th', null, "<a href=\"{$url}\">{$name}</a>");
     }
     $s .= "</tr>\n";
     # Bulk of table
     foreach ($matrix->getLangList() as $lang) {
         $anchor = strtolower('<a id="' . htmlspecialchars($lang) . '" name="' . htmlspecialchars($lang) . '"></a>');
         $s .= '<tr>';
         $attribs = array();
         if (isset($localLanguageNames[$lang])) {
             $attribs['title'] = $localLanguageNames[$lang];
         }
         $langDisplay = isset($langNames[$lang]) ? $langNames[$lang] : '';
         if (isset($localLanguageNames[$lang]) && strlen($localLanguageNames[$lang]) && $langDisplay != $localLanguageNames[$lang]) {
             $langDisplay .= ' (' . $localLanguageNames[$lang] . ')';
         }
         $s .= '<td>' . $anchor . Xml::element('strong', $attribs, $langDisplay) . '</td>';
         foreach ($matrix->getNames() as $site => $name) {
             $url = $matrix->getUrl($lang, $site);
             if ($matrix->exist($lang, $site)) {
                 # Wiki exists
                 $closed = $matrix->isClosed($lang, $site);
                 $s .= "<td>" . ($closed ? "<del>" : '') . "<a href=\"{$url}\">{$lang}</a>" . ($closed ? "</del>" : '') . '</td>';
             } else {
                 # Non-existent wiki
                 $s .= "<td><a href=\"{$url}\" class=\"new\">{$lang}</a></td>";
             }
         }
         $s .= "</tr>\n";
     }
     $language = $this->getLanguage();
     # Total
     $totalCount = 0;
     $s .= '<tr><th rowspan="2"><a id="total" name="total"></a>' . wfMsgHtml('sitematrix-sitetotal') . '</th>';
     foreach ($matrix->getNames() as $site => $name) {
         $url = $matrix->getSiteUrl($site);
         $count = $matrix->getCountPerSite($site);
         $totalCount += $count;
         $count = $language->formatNum($count);
         $s .= "<th><a href=\"{$url}\">{$count}</a></th>";
     }
     $s .= '</tr>';
     $s .= '<tr>';
     $noProjects = count($matrix->getNames());
     $totalCount = $language->formatNum($totalCount);
     $s .= "<th colspan=\"{$noProjects}\">{$totalCount}</th>";
     $s .= '</tr>';
     $s .= Xml::closeElement('table') . "\n";
     # Specials
     $s .= '<h2 id="mw-sitematrix-others">' . wfMsg('sitematrix-others') . '</h2>';
     $s .= Xml::openElement('table', array('class' => 'wikitable', 'id' => 'mw-sitematrix-other-table')) . "<tr>" . Xml::element('th', null, wfMsg('sitematrix-other-projects')) . "</tr>";
     foreach ($matrix->getSpecials() as $special) {
         list($lang, $site) = $special;
         $langhost = str_replace('_', '-', $lang);
         $url = $matrix->getUrl($lang, $site);
         # Handle options
         $flags = array();
         if ($matrix->isPrivate($lang . $site)) {
             $flags[] = wfMsgHtml('sitematrix-private');
         }
         if ($matrix->isFishbowl($lang . $site)) {
             $flags[] = wfMsgHtml('sitematrix-fishbowl');
         }
         $flagsStr = implode(', ', $flags);
         if ($site != 'wiki') {
             $langhost .= $site;
         }
         $closed = $matrix->isClosed($lang, $site);
         $s .= '<tr><td>' . ($closed ? '<del>' : '') . $language->specialList('<a href="' . $url . '/">' . $langhost . "</a>", $flagsStr) . ($closed ? '</del>' : '') . "</td></tr>\n";
     }
     $s .= Xml::closeElement('table') . "\n";
     $wgOut->addHTML($s);
     $wgOut->addWikiMsg('sitematrix-total', $language->formatNum($matrix->getCount()));
 }
	/**
	 * Show a language selector to allow the user to choose the language to
	 * translate.
	 */
	function showLanguageSelector( $selectedCode ) {
		$s = 
			Xml::openElement( 'form', 
				array( 
					'action' => $this->getTitle( false )->getLocalUrl()
				) 
			) .
			Xml::openElement( 
				'select', 
				array( 'id' => 'secondary_lang', 'name' => 'secondary_lang' ) 
			) . "\n";
		
		$languages = Language::getLanguageNames();
		ksort( $languages );
		foreach ( $languages as $code => $name ) {
			$s .= "\n" . Xml::option( "$code - $name", $code, $code == $selectedCode );
		}
		$s .= "\n</select>\n" . 
			'<p>' . Xml::submitButton( wfMsg( 'securepoll-submit-select-lang' ) ) . '</p>' .
			"</form>\n";
		global $wgOut;
		$wgOut->addHTML( $s );
	}
示例#26
0
    /**
     * @access private
     */
    function mainPrefsForm($status, $message = '')
    {
        global $wgUser, $wgOut, $wgLang, $wgContLang, $wgAuth;
        global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
        global $wgDisableLangConversion, $wgDisableTitleConversion;
        global $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifMinorEdits;
        global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
        global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
        global $wgContLanguageCode, $wgDefaultSkin, $wgCookieExpiration;
        global $wgEmailConfirmToEdit, $wgEnableMWSuggest, $wgLocalTZoffset;
        $wgOut->setPageTitle(wfMsg('preferences'));
        $wgOut->setArticleRelated(false);
        $wgOut->setRobotPolicy('noindex,nofollow');
        $wgOut->addScriptFile('prefs.js');
        $wgOut->disallowUserJs();
        # Prevent hijacked user scripts from sniffing passwords etc.
        if ($this->mSuccess || 'success' == $status) {
            $wgOut->wrapWikiMsg('<div class="successbox"><strong>$1</strong></div>', 'savedprefs');
        } else {
            if ('error' == $status) {
                $wgOut->addWikiText('<div class="errorbox"><strong>' . $message . '</strong></div>');
            } else {
                if ('' != $status) {
                    $wgOut->addWikiText($message . "\n----");
                }
            }
        }
        $qbs = $wgLang->getQuickbarSettings();
        $mathopts = $wgLang->getMathNames();
        $dateopts = $wgLang->getDatePreferences();
        $togs = User::getToggles();
        $titleObj = SpecialPage::getTitleFor('Preferences');
        # Pre-expire some toggles so they won't show if disabled
        $this->mUsedToggles['shownumberswatching'] = true;
        $this->mUsedToggles['showupdated'] = true;
        $this->mUsedToggles['enotifwatchlistpages'] = true;
        $this->mUsedToggles['enotifusertalkpages'] = true;
        $this->mUsedToggles['enotifminoredits'] = true;
        $this->mUsedToggles['enotifrevealaddr'] = true;
        $this->mUsedToggles['ccmeonemails'] = true;
        $this->mUsedToggles['uselivepreview'] = true;
        $this->mUsedToggles['noconvertlink'] = true;
        if (!$this->mEmailFlag) {
            $emfc = 'checked="checked"';
        } else {
            $emfc = '';
        }
        if ($wgEmailAuthentication && $this->mUserEmail != '') {
            if ($wgUser->getEmailAuthenticationTimestamp()) {
                // date and time are separate parameters to facilitate localisation.
                // $time is kept for backward compat reasons.
                // 'emailauthenticated' is also used in SpecialConfirmemail.php
                $time = $wgLang->timeAndDate($wgUser->getEmailAuthenticationTimestamp(), true);
                $d = $wgLang->date($wgUser->getEmailAuthenticationTimestamp(), true);
                $t = $wgLang->time($wgUser->getEmailAuthenticationTimestamp(), true);
                $emailauthenticated = wfMsg('emailauthenticated', $time, $d, $t) . '<br />';
                $disableEmailPrefs = false;
            } else {
                $disableEmailPrefs = true;
                $skin = $wgUser->getSkin();
                $emailauthenticated = wfMsg('emailnotauthenticated') . '<br />' . $skin->makeKnownLinkObj(SpecialPage::getTitleFor('Confirmemail'), wfMsg('emailconfirmlink')) . '<br />';
            }
        } else {
            $emailauthenticated = '';
            $disableEmailPrefs = false;
        }
        if ($this->mUserEmail == '') {
            $emailauthenticated = wfMsg('noemailprefs') . '<br />';
        }
        $ps = $this->namespacesCheckboxes();
        $enotifwatchlistpages = $wgEnotifWatchlist ? $this->getToggle('enotifwatchlistpages', false, $disableEmailPrefs) : '';
        $enotifusertalkpages = $wgEnotifUserTalk ? $this->getToggle('enotifusertalkpages', false, $disableEmailPrefs) : '';
        $enotifminoredits = $wgEnotifWatchlist && $wgEnotifMinorEdits ? $this->getToggle('enotifminoredits', false, $disableEmailPrefs) : '';
        $enotifrevealaddr = ($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress ? $this->getToggle('enotifrevealaddr', false, $disableEmailPrefs) : '';
        # </FIXME>
        $wgOut->addHTML(Xml::openElement('form', array('action' => $titleObj->getLocalUrl(), 'method' => 'post', 'id' => 'mw-preferences-form')) . Xml::openElement('div', array('id' => 'preferences')));
        # User data
        $wgOut->addHTML(Xml::fieldset(wfMsg('prefs-personal')) . Xml::openElement('table') . $this->tableRow(Xml::element('h2', null, wfMsg('prefs-personal'))));
        # Get groups to which the user belongs
        $userEffectiveGroups = $wgUser->getEffectiveGroups();
        $userEffectiveGroupsArray = array();
        foreach ($userEffectiveGroups as $ueg) {
            if ($ueg == '*') {
                // Skip the default * group, seems useless here
                continue;
            }
            $userEffectiveGroupsArray[] = User::makeGroupLinkHTML($ueg);
        }
        asort($userEffectiveGroupsArray);
        $sk = $wgUser->getSkin();
        $toolLinks = array();
        $toolLinks[] = $sk->makeKnownLinkObj(SpecialPage::getTitleFor('ListGroupRights'), wfMsg('listgrouprights'));
        # At the moment one tool link only but be prepared for the future...
        # FIXME: Add a link to Special:Userrights for users who are allowed to use it.
        # $wgUser->isAllowed( 'userrights' ) seems to strict in some cases
        $userInformationHtml = $this->tableRow(wfMsgHtml('username'), htmlspecialchars($wgUser->getName())) . $this->tableRow(wfMsgHtml('uid'), $wgLang->formatNum(htmlspecialchars($wgUser->getId()))) . $this->tableRow(wfMsgExt('prefs-memberingroups', array('parseinline'), count($userEffectiveGroupsArray)), $wgLang->commaList($userEffectiveGroupsArray) . '<br />(' . implode(' | ', $toolLinks) . ')') . $this->tableRow(wfMsgHtml('prefs-edits'), $wgLang->formatNum($wgUser->getEditCount()));
        if (wfRunHooks('PreferencesUserInformationPanel', array($this, &$userInformationHtml))) {
            $wgOut->addHTML($userInformationHtml);
        }
        if ($wgAllowRealName) {
            $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('yourrealname'), 'wpRealName'), Xml::input('wpRealName', 25, $this->mRealName, array('id' => 'wpRealName')), Xml::tags('div', array('class' => 'prefsectiontip'), wfMsgExt('prefs-help-realname', 'parseinline'))));
        }
        if ($wgEnableEmail) {
            $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('youremail'), 'wpUserEmail'), Xml::input('wpUserEmail', 25, $this->mUserEmail, array('id' => 'wpUserEmail')), Xml::tags('div', array('class' => 'prefsectiontip'), wfMsgExt($wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email', 'parseinline'))));
        }
        global $wgParser, $wgMaxSigChars;
        if (mb_strlen($this->mNick) > $wgMaxSigChars) {
            $invalidSig = $this->tableRow('&nbsp;', Xml::element('span', array('class' => 'error'), wfMsgExt('badsiglength', 'parsemag', $wgLang->formatNum($wgMaxSigChars))));
        } elseif (!empty($this->mToggles['fancysig']) && false === $wgParser->validateSig($this->mNick)) {
            $invalidSig = $this->tableRow('&nbsp;', Xml::element('span', array('class' => 'error'), wfMsg('badsig')));
        } else {
            $invalidSig = '';
        }
        $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('yournick'), 'wpNick'), Xml::input('wpNick', 25, $this->mNick, array('id' => 'wpNick', 'maxlength' => $wgMaxSigChars))) . $invalidSig . $this->tableRow('&nbsp;', $this->getToggle('fancysig')));
        list($lsLabel, $lsSelect) = Xml::languageSelector($this->mUserLanguage);
        $wgOut->addHTML($this->tableRow($lsLabel, $lsSelect));
        /* see if there are multiple language variants to choose from*/
        if (!$wgDisableLangConversion) {
            $variants = $wgContLang->getVariants();
            $variantArray = array();
            $languages = Language::getLanguageNames(true);
            foreach ($variants as $v) {
                $v = str_replace('_', '-', strtolower($v));
                if (array_key_exists($v, $languages)) {
                    // If it doesn't have a name, we'll pretend it doesn't exist
                    $variantArray[$v] = $languages[$v];
                }
            }
            $options = "\n";
            foreach ($variantArray as $code => $name) {
                $selected = $code == $this->mUserVariant;
                $options .= Xml::option("{$code} - {$name}", $code, $selected) . "\n";
            }
            if (count($variantArray) > 1) {
                $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('yourvariant'), 'wpUserVariant'), Xml::tags('select', array('name' => 'wpUserVariant', 'id' => 'wpUserVariant'), $options)));
            }
            if (count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
                $wgOut->addHTML(Xml::tags('tr', null, Xml::tags('td', array('colspan' => '2'), $this->getToggle("noconvertlink"))));
            }
        }
        # Password
        if ($wgAuth->allowPasswordChange()) {
            $link = $wgUser->getSkin()->link(SpecialPage::getTitleFor('ResetPass'), wfMsgHtml('prefs-resetpass'), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
            $wgOut->addHTML($this->tableRow(Xml::element('h2', null, wfMsg('changepassword'))) . $this->tableRow('<ul><li>' . $link . '</li></ul>'));
        }
        # <FIXME>
        # Enotif
        if ($wgEnableEmail) {
            $moreEmail = '';
            if ($wgEnableUserEmail) {
                // fixme -- the "allowemail" pseudotoggle is a hacked-together
                // inversion for the "disableemail" preference.
                $emf = wfMsg('allowemail');
                $disabled = $disableEmailPrefs ? ' disabled="disabled"' : '';
                $moreEmail = "<input type='checkbox' {$emfc} {$disabled} value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>{$emf}</label>" . $this->getToggle('ccmeonemails', '', $disableEmailPrefs);
            }
            $wgOut->addHTML($this->tableRow(Xml::element('h2', null, wfMsg('email'))) . $this->tableRow($emailauthenticated . $enotifrevealaddr . $enotifwatchlistpages . $enotifusertalkpages . $enotifminoredits . $moreEmail));
        }
        # </FIXME>
        $wgOut->addHTML(Xml::closeElement('table') . Xml::closeElement('fieldset'));
        # Quickbar
        #
        if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
            $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('qbsettings') . "</legend>\n");
            for ($i = 0; $i < count($qbs); ++$i) {
                if ($i == $this->mQuickbar) {
                    $checked = ' checked="checked"';
                } else {
                    $checked = "";
                }
                $wgOut->addHTML("<div><label><input type='radio' name='wpQuickbar' value=\"{$i}\"{$checked} />{$qbs[$i]}</label></div>\n");
            }
            $wgOut->addHTML("</fieldset>\n\n");
        } else {
            # Need to output a hidden option even if the relevant skin is not in use,
            # otherwise the preference will get reset to 0 on submit
            $wgOut->addHTML(Xml::hidden('wpQuickbar', $this->mQuickbar));
        }
        # Skin
        #
        global $wgAllowUserSkin;
        if ($wgAllowUserSkin) {
            $wgOut->addHTML("<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n");
            $mptitle = Title::newMainPage();
            $previewtext = wfMsg('skin-preview');
            # Only show members of Skin::getSkinNames() rather than
            # $skinNames (skins is all skin names from Language.php)
            $validSkinNames = Skin::getUsableSkins();
            # Sort by UI skin name. First though need to update validSkinNames as sometimes
            # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
            foreach ($validSkinNames as $skinkey => &$skinname) {
                $msgName = "skinname-{$skinkey}";
                $localisedSkinName = wfMsg($msgName);
                if (!wfEmptyMsg($msgName, $localisedSkinName)) {
                    $skinname = $localisedSkinName;
                }
            }
            asort($validSkinNames);
            foreach ($validSkinNames as $skinkey => $sn) {
                $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
                $mplink = htmlspecialchars($mptitle->getLocalURL("useskin={$skinkey}"));
                $previewlink = "(<a target='_blank' href=\"{$mplink}\">{$previewtext}</a>)";
                if ($skinkey == $wgDefaultSkin) {
                    $sn .= ' (' . wfMsg('default') . ')';
                }
                $wgOut->addHTML("<input type='radio' name='wpSkin' id=\"wpSkin{$skinkey}\" value=\"{$skinkey}\"{$checked} /> <label for=\"wpSkin{$skinkey}\">{$sn}</label> {$previewlink}<br />\n");
            }
            $wgOut->addHTML("</fieldset>\n\n");
        }
        # Math
        #
        global $wgUseTeX;
        if ($wgUseTeX) {
            $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('math') . '</legend>');
            foreach ($mathopts as $k => $v) {
                $checked = $k == $this->mMath;
                $wgOut->addHTML(Xml::openElement('div') . Xml::radioLabel(wfMsg($v), 'wpMath', $k, "mw-sp-math-{$k}", $checked) . Xml::closeElement('div') . "\n");
            }
            $wgOut->addHTML("</fieldset>\n\n");
        }
        # Files
        #
        $imageLimitOptions = null;
        foreach ($wgImageLimits as $index => $limits) {
            $selected = $index == $this->mImageSize;
            $imageLimitOptions .= Xml::option("{$limits[0]}×{$limits[1]}" . wfMsg('unit-pixel'), $index, $selected);
        }
        $imageThumbOptions = null;
        foreach ($wgThumbLimits as $index => $size) {
            $selected = $index == $this->mThumbSize;
            $imageThumbOptions .= Xml::option($size . wfMsg('unit-pixel'), $index, $selected);
        }
        $imageSizeId = 'wpImageSize';
        $thumbSizeId = 'wpThumbSize';
        $wgOut->addHTML(Xml::fieldset(wfMsg('files')) . "\n" . Xml::openElement('table') . '<tr>
					<td class="mw-label">' . Xml::label(wfMsg('imagemaxsize'), $imageSizeId) . '</td>
					<td class="mw-input">' . Xml::openElement('select', array('name' => $imageSizeId, 'id' => $imageSizeId)) . $imageLimitOptions . Xml::closeElement('select') . '</td>
				</tr><tr>
					<td class="mw-label">' . Xml::label(wfMsg('thumbsize'), $thumbSizeId) . '</td>
					<td class="mw-input">' . Xml::openElement('select', array('name' => $thumbSizeId, 'id' => $thumbSizeId)) . $imageThumbOptions . Xml::closeElement('select') . '</td>
				</tr>' . Xml::closeElement('table') . Xml::closeElement('fieldset'));
        # Date format
        #
        # Date/Time
        #
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('datetime')) . "\n");
        if ($dateopts) {
            $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('dateformat')) . "\n");
            $idCnt = 0;
            $epoch = '20010115161234';
            # Wikipedia day
            foreach ($dateopts as $key) {
                if ($key == 'default') {
                    $formatted = wfMsg('datedefault');
                } else {
                    $formatted = $wgLang->timeanddate($epoch, false, $key);
                }
                $wgOut->addHTML(Xml::tags('div', null, Xml::radioLabel($formatted, 'wpDate', $key, "wpDate{$idCnt}", $key == $this->mDate)) . "\n");
                $idCnt++;
            }
            $wgOut->addHTML(Xml::closeElement('fieldset') . "\n");
        }
        $nowlocal = Xml::openElement('span', array('id' => 'wpLocalTime')) . $wgLang->time($now = wfTimestampNow(), true) . Xml::closeElement('span');
        $nowserver = $wgLang->time($now, false) . Xml::hidden('wpServerTime', substr($now, 8, 2) * 60 + substr($now, 10, 2));
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('timezonelegend')) . Xml::openElement('table') . $this->addRow(wfMsg('servertime'), $nowserver) . $this->addRow(wfMsg('localtime'), $nowlocal));
        $opt = Xml::openElement('select', array('name' => 'wpTimeZone', 'id' => 'wpTimeZone', 'onchange' => 'javascript:updateTimezoneSelection(false)'));
        $opt .= Xml::option(wfMsg('timezoneuseserverdefault'), "System|{$wgLocalTZoffset}", $this->mTimeZone === "System|{$wgLocalTZoffset}");
        $opt .= Xml::option(wfMsg('timezoneuseoffset'), 'Offset', $this->mTimeZone === 'Offset');
        if (function_exists('timezone_identifiers_list')) {
            $optgroup = '';
            $tzs = timezone_identifiers_list();
            sort($tzs);
            $selZone = explode('|', $this->mTimeZone, 3);
            $selZone = $selZone[0] == 'ZoneInfo' ? $selZone[2] : null;
            $now = date_create('now');
            foreach ($tzs as $tz) {
                $z = explode('/', $tz, 2);
                # timezone_identifiers_list() returns a number of
                # backwards-compatibility entries. This filters them out of the
                # list presented to the user.
                if (count($z) != 2 || !in_array($z[0], array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific'))) {
                    continue;
                }
                if ($optgroup != $z[0]) {
                    if ($optgroup !== '') {
                        $opt .= Xml::closeElement('optgroup');
                    }
                    $optgroup = $z[0];
                    $opt .= Xml::openElement('optgroup', array('label' => $z[0]));
                }
                $minDiff = floor(timezone_offset_get(timezone_open($tz), $now) / 60);
                $opt .= Xml::option(str_replace('_', ' ', $tz), "ZoneInfo|{$minDiff}|{$tz}", $selZone === $tz, array('label' => $z[1]));
            }
            if ($optgroup !== '') {
                $opt .= Xml::closeElement('optgroup');
            }
        }
        $opt .= Xml::closeElement('select');
        $wgOut->addHTML($this->addRow(Xml::label(wfMsg('timezoneselect'), 'wpTimeZone'), $opt));
        $wgOut->addHTML($this->addRow(Xml::label(wfMsg('timezoneoffset'), 'wpHourDiff'), Xml::input('wpHourDiff', 6, $this->mHourDiff, array('id' => 'wpHourDiff', 'onfocus' => 'javascript:updateTimezoneSelection(true)', 'onblur' => 'javascript:updateTimezoneSelection(false)'))) . "<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td class='mw-submit'>" . Xml::element('input', array('type' => 'button', 'value' => wfMsg('guesstimezone'), 'onclick' => 'javascript:guessTimezone()', 'id' => 'guesstimezonebutton', 'style' => 'display:none;')) . "</td>\n\t\t\t</tr>" . Xml::closeElement('table') . Xml::tags('div', array('class' => 'prefsectiontip'), wfMsgExt('timezonetext', 'parseinline')) . Xml::closeElement('fieldset') . Xml::closeElement('fieldset') . "\n\n");
        # Editing
        #
        global $wgLivePreview;
        $wgOut->addHTML(Xml::fieldset(wfMsg('textboxsize')) . wfMsgHTML('prefs-edit-boxsize') . ' ' . Xml::inputLabel(wfMsg('rows'), 'wpRows', 'wpRows', 3, $this->mRows) . ' ' . Xml::inputLabel(wfMsg('columns'), 'wpCols', 'wpCols', 3, $this->mCols) . $this->getToggles(array('editsection', 'editsectiononrightclick', 'editondblclick', 'editwidth', 'showtoolbar', 'previewonfirst', 'previewontop', 'minordefault', 'externaleditor', 'externaldiff', $wgLivePreview ? 'uselivepreview' : false, 'forceeditsummary')));
        $wgOut->addHTML(Xml::closeElement('fieldset'));
        # Recent changes
        global $wgRCMaxAge;
        $wgOut->addHTML(Xml::fieldset(wfMsg('prefs-rc')) . Xml::openElement('table') . '<tr>
					<td class="mw-label">' . Xml::label(wfMsg('recentchangesdays'), 'wpRecentDays') . '</td>
					<td class="mw-input">' . Xml::input('wpRecentDays', 3, $this->mRecentDays, array('id' => 'wpRecentDays')) . ' ' . wfMsgExt('recentchangesdays-max', 'parsemag', $wgLang->formatNum(ceil($wgRCMaxAge / (3600 * 24)))) . '</td>
				</tr><tr>
					<td class="mw-label">' . Xml::label(wfMsg('recentchangescount'), 'wpRecent') . '</td>
					<td class="mw-input">' . Xml::input('wpRecent', 3, $this->mRecent, array('id' => 'wpRecent')) . '</td>
				</tr>' . Xml::closeElement('table') . '<br />');
        $toggles[] = 'hideminor';
        if ($wgRCShowWatchingUsers) {
            $toggles[] = 'shownumberswatching';
        }
        $toggles[] = 'usenewrc';
        $wgOut->addHTML($this->getToggles($toggles) . Xml::closeElement('fieldset'));
        # Watchlist
        $wgOut->addHTML(Xml::fieldset(wfMsg('prefs-watchlist')) . Xml::inputLabel(wfMsg('prefs-watchlist-days'), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays) . ' ' . wfMsgHTML('prefs-watchlist-days-max') . '<br /><br />' . $this->getToggle('extendwatchlist') . Xml::inputLabel(wfMsg('prefs-watchlist-edits'), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits) . ' ' . wfMsgHTML('prefs-watchlist-edits-max') . '<br /><br />' . $this->getToggles(array('watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu')));
        if ($wgUser->isAllowed('createpage') || $wgUser->isAllowed('createtalk')) {
            $wgOut->addHTML($this->getToggle('watchcreations'));
        }
        foreach (array('edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion') as $action => $toggle) {
            if ($wgUser->isAllowed($action)) {
                $wgOut->addHTML($this->getToggle($toggle));
            }
        }
        $this->mUsedToggles['watchcreations'] = true;
        $this->mUsedToggles['watchdefault'] = true;
        $this->mUsedToggles['watchmoves'] = true;
        $this->mUsedToggles['watchdeletion'] = true;
        $wgOut->addHTML(Xml::closeElement('fieldset'));
        # Search
        $mwsuggest = $wgEnableMWSuggest ? $this->addRow(Xml::label(wfMsg('mwsuggest-disable'), 'wpDisableMWSuggest'), Xml::check('wpDisableMWSuggest', $this->mDisableMWSuggest, array('id' => 'wpDisableMWSuggest'))) : '';
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('searchresultshead')) . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('prefs-searchoptions')) . Xml::openElement('table') . $this->addRow(Xml::label(wfMsg('resultsperpage'), 'wpSearch'), Xml::input('wpSearch', 4, $this->mSearch, array('id' => 'wpSearch'))) . $this->addRow(Xml::label(wfMsg('contextlines'), 'wpSearchLines'), Xml::input('wpSearchLines', 4, $this->mSearchLines, array('id' => 'wpSearchLines'))) . $this->addRow(Xml::label(wfMsg('contextchars'), 'wpSearchChars'), Xml::input('wpSearchChars', 4, $this->mSearchChars, array('id' => 'wpSearchChars'))) . $mwsuggest . Xml::closeElement('table') . Xml::closeElement('fieldset') . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('prefs-namespaces')) . wfMsgExt('defaultns', array('parse')) . $ps . Xml::closeElement('fieldset') . Xml::closeElement('fieldset'));
        # Misc
        #
        $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
        $wgOut->addHTML('<label for="wpStubs">' . wfMsg('stub-threshold') . '</label>&nbsp;');
        $wgOut->addHTML(Xml::input('wpStubs', 6, $this->mStubs, array('id' => 'wpStubs')));
        $msgUnderline = htmlspecialchars(wfMsg('tog-underline'));
        $msgUnderlinenever = htmlspecialchars(wfMsg('underline-never'));
        $msgUnderlinealways = htmlspecialchars(wfMsg('underline-always'));
        $msgUnderlinedefault = htmlspecialchars(wfMsg('underline-default'));
        $uopt = $wgUser->getOption("underline");
        $s0 = $uopt == 0 ? ' selected="selected"' : '';
        $s1 = $uopt == 1 ? ' selected="selected"' : '';
        $s2 = $uopt == 2 ? ' selected="selected"' : '';
        $wgOut->addHTML("\n<div class='toggle'><p><label for='wpOpunderline'>{$msgUnderline}</label>\n<select name='wpOpunderline' id='wpOpunderline'>\n<option value=\"0\"{$s0}>{$msgUnderlinenever}</option>\n<option value=\"1\"{$s1}>{$msgUnderlinealways}</option>\n<option value=\"2\"{$s2}>{$msgUnderlinedefault}</option>\n</select></p></div>");
        foreach ($togs as $tname) {
            if (!array_key_exists($tname, $this->mUsedToggles)) {
                if ($tname == 'norollbackdiff' && $wgUser->isAllowed('rollback')) {
                    $wgOut->addHTML($this->getToggle($tname));
                } else {
                    $wgOut->addHTML($this->getToggle($tname));
                }
            }
        }
        $wgOut->addHTML('</fieldset>');
        wfRunHooks('RenderPreferencesForm', array($this, $wgOut));
        $token = htmlspecialchars($wgUser->editToken());
        $skin = $wgUser->getSkin();
        $wgOut->addHTML("\n\t<div id='prefsubmit'>\n\t<div>\n\t\t<input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml('saveprefs') . '"' . $skin->tooltipAndAccesskey('save') . " />\n\t\t<input type='submit' name='wpReset' value=\"" . wfMsgHtml('resetprefs') . "\" />\n\t</div>\n\n\t</div>\n\n\t<input type='hidden' name='wpEditToken' value=\"{$token}\" />\n\t</div></form>\n");
        $wgOut->addHTML(Xml::tags('div', array('class' => "prefcache"), wfMsgExt('clearyourcache', 'parseinline')));
    }
function getLanguageList()
{
    global $wgDummyLanguageCodes;
    $codes = array();
    foreach (Language::getLanguageNames() as $code => $name) {
        if (in_array($code, $wgDummyLanguageCodes)) {
            continue;
        }
        $codes[$code] = $code . ' - ' . $name;
    }
    ksort($codes);
    return $codes;
}
示例#28
0
	/**
	 * @param $code string
	 * @param $authors array
	 * @return string
	 */
	protected function header( $code, $authors ) {
		$names = Language::getLanguageNames();
		$name = $names[ $code ];

		$authorsList = $this->authorsList( $authors );

		/** @cond doxygen_bug */
		return <<<EOT
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the
 * full text of the license. */

/**
 * @requires OpenLayers/Lang.js
 */

/**
$authorsList
 *
 * Namespace: OpenLayers.Lang["$code"]
 * Dictionary for $name.  Keys for entries are used in calls to
 *     <OpenLayers.Lang.translate>.  Entry bodies are normal strings or
 *     strings formatted for use with <OpenLayers.String.format> calls.
 */
OpenLayers.Lang["$code"] = OpenLayers.Util.applyDefaults({

EOT;
		/** @endcond */
	}
示例#29
0
文件: Xml.php 项目: rocLv/conference
 /**
  *
  * @param $selected The language code of the selected language
  * @param $customisedOnly If true only languages which have some content are listed
  * @return array of label and select
  */
 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;
     }
     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 : $wgContLanguageCode;
     $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));
 }
示例#30
0
 public static function getFixedLanguageNames()
 {
     $languages = Language::getLanguageNames();
     $filter_languages = explode(',', wfMsg('requestwiki-filter-language'));
     foreach ($filter_languages as $key) {
         unset($languages[$key]);
     }
     return $languages;
 }