• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wfBCP47函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wfBCP47函数的典型用法代码示例。如果您正苦于以下问题:PHP wfBCP47函数的具体用法?PHP wfBCP47怎么用?PHP wfBCP47使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wfBCP47函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testBCP47

 /**
  * test @see wfBCP47().
  * Please note the BCP 47 explicitly state that language codes are case
  * insensitive, there are some exceptions to the rule :)
  * This test is used to verify our formatting against all lower and
  * all upper cases language code.
  *
  * @see http://tools.ietf.org/html/bcp47
  * @dataProvider provideLanguageCodes()
  */
 public function testBCP47($code, $expected)
 {
     $code = strtolower($code);
     $this->assertEquals($expected, wfBCP47($code), "Applying BCP47 standard to lower case '{$code}'");
     $code = strtoupper($code);
     $this->assertEquals($expected, wfBCP47($code), "Applying BCP47 standard to upper case '{$code}'");
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:17,代码来源:wfBCP47Test.php


示例2: onBeforePageDisplay

 static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
 {
     $languageLinks = $out->getLanguageLinks();
     if (empty($languageLinks)) {
         return true;
     }
     // this is partly a ripoff from SkinTemplate::getLanguages()
     foreach ($languageLinks as $langLink) {
         $languageLinkTitle = Title::newFromText($langLink);
         $interwikiCode = $languageLinkTitle->getInterwiki();
         $out->addLink(array('rel' => 'alternate', 'hreflang' => wfBCP47($interwikiCode), 'href' => wfExpandIRI($languageLinkTitle->getFullURL())));
     }
     // We also must add the current language
     $currentPageLangCode = $out->getLanguage()->getCode();
     $currentPageTitle = $out->getTitle();
     $out->addLink(array('rel' => 'alternate', 'hreflang' => wfBCP47($currentPageLangCode), 'href' => wfExpandIRI($currentPageTitle->getFullURL())));
     return true;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-AltLangRelLinks,代码行数:18,代码来源:AltLangRelLinks.php


示例3: onBeforePageDisplay

 public static function onBeforePageDisplay(OutputPage $out, SkinTemplate $sk)
 {
     $config = $out->getConfig();
     if (self::canOutputHreflang($config)) {
         # Generate hreflang tags
         $languageLinks = $out->getLanguageLinks();
         if (empty($languageLinks)) {
             // shortcut - if we don't have any language links, don't bother
             return;
         }
         $addedLink = false;
         $pages = $config->get("HreflangPages");
         if (!$pages) {
             $pages = array();
             $foundPage = true;
         } else {
             $pages = array_flip($pages);
             $pageName = $out->getLanguage()->getHtmlCode() . ":" . $out->getTitle()->getBaseText();
             $foundPage = isset($pages[$pageName]);
         }
         foreach ($languageLinks as $languageLinkText) {
             $languageLinkTitle = Title::newFromText($languageLinkText);
             if (!$languageLinkTitle) {
                 continue;
             }
             $ilInterwikiCode = $languageLinkTitle->getInterwiki();
             if (!Language::isKnownLanguageTag($ilInterwikiCode)) {
                 continue;
             }
             $foundPage = $foundPage || isset($pages[$languageLinkText]);
             $tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => wfBCP47($ilInterwikiCode), 'href' => $languageLinkTitle->getFullURL()));
             $addedLink = true;
         }
         // Only add current language link if we had any other links
         if ($addedLink) {
             $tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => $out->getLanguage()->getHtmlCode(), 'href' => $out->getTitle()->getFullURL()));
         }
     }
     if ($foundPage && $tags) {
         $out->addHeadItem("hreflang:tags", join("\n", $tags));
     }
 }
开发者ID:smalyshev,项目名称:Hreflang-extension,代码行数:42,代码来源:Hreflang.hooks.php


示例4: getLanguageVariants

 /**
  * Returns an array of language variants that the page is available in
  * @return array
  */
 private function getLanguageVariants()
 {
     $pageLang = $this->title->getPageLanguage();
     $variants = $pageLang->getVariants();
     if (count($variants) > 1) {
         $pageLangCode = $pageLang->getCode();
         $output = array();
         // Loops over each variant
         foreach ($variants as $code) {
             // Gets variant name from language code
             $varname = $pageLang->getVariantname($code);
             // Don't list the current variant
             if ($varname !== $pageLangCode) {
                 // Appends variant link
                 $output[] = array('langname' => $varname, 'url' => $this->title->getLocalURL(array('variant' => $code)), 'lang' => wfBCP47($code));
             }
         }
         return $output;
     } else {
         // No variants
         return array();
     }
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:27,代码来源:SpecialMobileLanguages.php


示例5: mapCode

 protected function mapCode($code)
 {
     return str_replace('-', '_', wfBCP47($code));
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:4,代码来源:ApertiumWebService.php


示例6: showStoryForm

    /**
     * Outputs a form to edit the story with. Code based on <storysubmission>.
     *
     * @param $story
     */
    private function showStoryForm($story)
    {
        global $wgOut, $wgLang, $wgRequest, $wgUser, $wgScriptPath, $wgContLanguageCode;
        global $egStoryboardScriptPath, $egStorysubmissionWidth, $egStoryboardMaxStoryLen, $egStoryboardMinStoryLen;
        $wgOut->setPageTitle($story->story_title);
        efStoryboardAddJSLocalisation();
        $wgOut->addStyle($egStoryboardScriptPath . '/storyboard.css');
        $wgOut->includeJQuery();
        $wgOut->addScriptFile($egStoryboardScriptPath . '/jquery/jquery.validate.js');
        $wgOut->addScriptFile($egStoryboardScriptPath . '/storyboard.js');
        $fieldSize = 50;
        $width = $egStorysubmissionWidth;
        $maxLen = $wgRequest->getVal('maxlength');
        if (!is_int($maxLen)) {
            $maxLen = $egStoryboardMaxStoryLen;
        }
        $minLen = $wgRequest->getVal('minlength');
        if (!is_int($minLen)) {
            $minLen = $egStoryboardMinStoryLen;
        }
        $formBody = "<table width=\"{$width}\">";
        // The current value will be selected on page load with jQuery.
        $formBody .= '<tr>' . '<td width="100%"><label for="storystate">' . htmlspecialchars(wfMsg('storyboard-storystate')) . '</label></td><td>' . Html::rawElement('select', array('name' => 'storystate', 'id' => 'storystate'), '<option value="' . Storyboard_STORY_UNPUBLISHED . '">' . htmlspecialchars(wfMsg('storyboard-option-unpublished')) . '</option>' . '<option value="' . Storyboard_STORY_PUBLISHED . '">' . htmlspecialchars(wfMsg('storyboard-option-published')) . '</option>' . '<option value="' . Storyboard_STORY_HIDDEN . '">' . htmlspecialchars(wfMsg('storyboard-option-hidden')) . '</option>') . '</td></tr>';
        $languages = Language::getLanguageNames(false);
        $currentLang = array_key_exists($story->story_lang_code, $languages) ? $story->story_lang_code : $wgContLanguageCode;
        $options = array();
        ksort($languages);
        foreach ($languages as $code => $name) {
            $display = wfBCP47($code) . ' - ' . $name;
            $options[$display] = $code;
        }
        $languageSelector = new HTMLSelectField(array('name' => 'language', 'options' => $options));
        $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-language')) . '<td>' . $languageSelector->getInputHTML($currentLang) . '</td></tr>';
        $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-authorname')) . '<td>' . Html::input('name', $story->story_author_name, 'text', array('size' => $fieldSize, 'class' => 'required', 'minlength' => 2, 'maxlength' => 255)) . '</td></tr>';
        $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-authorlocation')) . '<td>' . Html::input('location', $story->story_author_location, 'text', array('size' => $fieldSize, 'maxlength' => 255, 'minlength' => 2)) . '</td></tr>';
        $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-authoroccupation')) . '<td>' . Html::input('occupation', $story->story_author_occupation, 'text', array('size' => $fieldSize, 'maxlength' => 255, 'minlength' => 4)) . '</td></tr>';
        $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-authoremail')) . '<td>' . Html::input('email', $story->story_author_email, 'text', array('size' => $fieldSize, 'maxlength' => 255, 'class' => 'required email')) . '</td></tr>';
        $formBody .= '<tr>' . '<td width="100%"><label for="storytitle">' . htmlspecialchars(wfMsg('storyboard-storytitle')) . '</label></td><td>' . Html::input('storytitle', $story->story_title, 'text', array('size' => $fieldSize, 'maxlength' => 255, 'minlength' => 2, 'id' => 'storytitle', 'class' => 'required storytitle', 'remote' => "{$wgScriptPath}/api.php?format=json&action=storyexists&currentid={$story->story_id}")) . '</td></tr>';
        $formBody .= '<tr><td colspan="2">' . wfMsg('storyboard-thestory') . Html::element('div', array('class' => 'storysubmission-charcount', 'id' => 'storysubmission-charlimitinfo'), wfMsgExt('storyboard-charsneeded', 'parsemag', $minLen)) . '<br />' . Html::element('textarea', array('id' => 'storytext', 'name' => 'storytext', 'rows' => 7, 'class' => 'required', 'onkeyup' => "stbValidateStory( this, {$minLen}, {$maxLen}, 'storysubmission-charlimitinfo', 'storysubmission-button' )"), $story->story_text) . '</td></tr>';
        $returnTo = $wgRequest->getVal('returnto');
        $query = "id={$story->story_id}";
        if ($returnTo) {
            $query .= "&returnto={$returnTo}";
        }
        $formBody .= '<tr><td colspan="2">' . Html::input('', wfMsg('htmlform-submit'), 'submit', array('id' => 'storysubmission-button')) . "&#160;&#160;<span class='editHelp'>" . Html::element('a', array('href' => $this->getTitle()->getLocalURL($query)), wfMsgExt('cancel', array('parseinline'))) . '</span>' . '</td></tr>';
        $formBody .= '</table>';
        $formBody .= Html::hidden('wpEditToken', $wgUser->editToken());
        $formBody .= Html::hidden('storyId', $story->story_id);
        $formBody = '<fieldset><legend>' . htmlspecialchars(wfMsgExt('storyboard-createdandmodified', 'parsemag', $wgLang->time($story->story_created), $wgLang->date($story->story_created), $wgLang->time($story->story_modified), $wgLang->date($story->story_modified))) . '</legend>' . $formBody . '</fieldset>';
        $query = "id={$story->story_id}";
        if ($returnTo) {
            $query .= "&returnto={$returnTo}";
        }
        $formBody = Html::rawElement('form', array('id' => 'storyform', 'name' => 'storyform', 'method' => 'post', 'action' => $this->getTitle()->getLocalURL($query)), $formBody);
        $wgOut->addHTML($formBody);
        $state = htmlspecialchars($story->story_state);
        $wgOut->addInlineScript(<<<EOT
jQuery(document).ready(function() {
\tjQuery('#storystate option[value="{$state}"]').attr('selected', 'selected');

\tjQuery("#storyform").validate({
\t\tmessages: {
\t\t\tstorytitle: {
\t\t\t\tremote: jQuery.validator.format( stbMsg( 'storyboard-alreadyexistschange' ) )
\t\t\t}
\t\t}
\t});
});

\$(
\tfunction() {
\t\tstbValidateStory( document.getElementById('storytext'), {$minLen}, {$maxLen}, 'storysubmission-charlimitinfo', 'storysubmission-button' )
\t}
);
jQuery(document).ready(function(){
\tjQuery("#storyform").validate();
});
EOT
);
    }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:85,代码来源:Story_body.php


示例7: execute


//.........这里部分代码省略.........
     try {
         $translationSearch = new CrossLanguageTranslationSearchQuery($params, $server);
         if (in_array($filter, $translationSearch->getAvailableFilters())) {
             if ($opts->getValue('language') === '') {
                 $params['language'] = $this->getLanguage()->getCode();
                 $opts->setValue('language', $params['language']);
             }
             $documents = $translationSearch->getDocuments();
             $total = $translationSearch->getTotalHits();
             $resultset = $translationSearch->getResultSet();
         } else {
             $resultset = $server->search($queryString, $params, $this->hl);
             $documents = $server->getDocuments($resultset);
             $total = $server->getTotalHits($resultset);
         }
     } catch (TTMServerException $e) {
         error_log('Translation search server unavailable:' . $e->getMessage());
         throw new ErrorPageError('tux-sst-solr-offline-title', 'tux-sst-solr-offline-body');
     }
     // Part 1: facets
     $facets = $server->getFacets($resultset);
     $facetHtml = '';
     if (count($facets['language']) > 0) {
         if ($filter !== '') {
             $facets['language'] = array_merge($facets['language'], array($opts->getValue('language') => $total));
         }
         $facetHtml = Html::element('div', array('class' => 'row facet languages', 'data-facets' => FormatJson::encode($this->getLanguages($facets['language'])), 'data-language' => $opts->getValue('language')), $this->msg('tux-sst-facet-language'));
     }
     if (count($facets['group']) > 0) {
         $facetHtml .= Html::element('div', array('class' => 'row facet groups', 'data-facets' => FormatJson::encode($this->getGroups($facets['group'])), 'data-group' => $opts->getValue('group')), $this->msg('tux-sst-facet-group'));
     }
     // Part 2: results
     $resultsHtml = '';
     $title = Title::newFromText($queryString);
     if ($title && !in_array($filter, $translationSearch->getAvailableFilters())) {
         $handle = new MessageHandle($title);
         $code = $handle->getCode();
         $language = $opts->getValue('language');
         if ($handle->isValid() && $code !== '' && $code !== $language) {
             $groupId = $handle->getGroup()->getId();
             $helpers = new TranslationHelpers($title, $groupId);
             $document['wiki'] = wfWikiId();
             $document['localid'] = $handle->getTitleForBase()->getPrefixedText();
             $document['content'] = $helpers->getTranslation();
             $document['language'] = $handle->getCode();
             array_unshift($documents, $document);
             $total++;
         }
     }
     foreach ($documents as $document) {
         $text = $document['content'];
         $text = TranslateUtils::convertWhiteSpaceToHTML($text);
         list($pre, $post) = $this->hl;
         $text = str_replace($pre, '<strong class="tux-search-highlight">', $text);
         $text = str_replace($post, '</strong>', $text);
         $title = Title::newFromText($document['localid'] . '/' . $document['language']);
         if (!$title) {
             // Should not ever happen but who knows...
             continue;
         }
         $resultAttribs = array('class' => 'row tux-message', 'data-title' => $title->getPrefixedText(), 'data-language' => $document['language']);
         $handle = new MessageHandle($title);
         if ($handle->isValid()) {
             $groupId = $handle->getGroup()->getId();
             $helpers = new TranslationHelpers($title, $groupId);
             $resultAttribs['data-definition'] = $helpers->getDefinition();
             $resultAttribs['data-translation'] = $helpers->getTranslation();
             $resultAttribs['data-group'] = $groupId;
             $uri = $title->getLocalUrl(array('action' => 'edit'));
             $link = Html::element('a', array('href' => $uri), $this->msg('tux-sst-edit')->text());
         } else {
             $url = wfParseUrl($document['uri']);
             $domain = $url['host'];
             $link = Html::element('a', array('href' => $document['uri']), $this->msg('tux-sst-view-foreign', $domain)->text());
         }
         $access = Html::rawElement('div', array('class' => 'row tux-edit tux-message-item'), $link);
         $titleText = $title->getPrefixedText();
         $titleAttribs = array('class' => 'row tux-title', 'dir' => 'ltr');
         $textAttribs = array('class' => 'row tux-text', 'lang' => wfBCP47($document['language']), 'dir' => Language::factory($document['language'])->getDir());
         $resultsHtml = $resultsHtml . Html::openElement('div', $resultAttribs) . Html::rawElement('div', $textAttribs, $text) . Html::element('div', $titleAttribs, $titleText) . $access . Html::closeElement('div');
     }
     $resultsHtml .= Html::rawElement('hr', array('class' => 'tux-pagination-line'));
     $prev = $next = '';
     $offset = $this->opts->getValue('offset');
     $params = $this->opts->getChangedValues();
     if ($total - $offset > $this->limit) {
         $newParams = array('offset' => $offset + $this->limit) + $params;
         $attribs = array('class' => 'mw-ui-button pager-next', 'href' => $this->getPageTitle()->getLocalUrl($newParams));
         $next = Html::element('a', $attribs, $this->msg('tux-sst-next')->text());
     }
     if ($offset) {
         $newParams = array('offset' => max(0, $offset - $this->limit)) + $params;
         $attribs = array('class' => 'mw-ui-button pager-prev', 'href' => $this->getPageTitle()->getLocalUrl($newParams));
         $prev = Html::element('a', $attribs, $this->msg('tux-sst-prev')->text());
     }
     $resultsHtml .= Html::rawElement('div', array('class' => 'tux-pagination-links'), "{$prev} {$next}");
     $search = $this->getSearchInput($queryString);
     $count = $this->msg('tux-sst-count')->numParams($total);
     $this->showSearch($search, $count, $facetHtml, $resultsHtml, $total);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:101,代码来源:SpecialSearchTranslations.php


示例8: getHeadLinksArray

 /**
  * @return array Array in format "link name or number => 'link html'".
  */
 public function getHeadLinksArray()
 {
     global $wgVersion;
     $tags = array();
     $config = $this->getConfig();
     $canonicalUrl = $this->mCanonicalUrl;
     $tags['meta-generator'] = Html::element('meta', array('name' => 'generator', 'content' => "MediaWiki {$wgVersion}"));
     if ($config->get('ReferrerPolicy') !== false) {
         $tags['meta-referrer'] = Html::element('meta', array('name' => 'referrer', 'content' => $config->get('ReferrerPolicy')));
     }
     $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
     if ($p !== 'index,follow') {
         // http://www.robotstxt.org/wc/meta-user.html
         // Only show if it's different from the default robots policy
         $tags['meta-robots'] = Html::element('meta', array('name' => 'robots', 'content' => $p));
     }
     foreach ($this->mMetatags as $tag) {
         if (0 == strcasecmp('http:', substr($tag[0], 0, 5))) {
             $a = 'http-equiv';
             $tag[0] = substr($tag[0], 5);
         } else {
             $a = 'name';
         }
         $tagName = "meta-{$tag[0]}";
         if (isset($tags[$tagName])) {
             $tagName .= $tag[1];
         }
         $tags[$tagName] = Html::element('meta', array($a => $tag[0], 'content' => $tag[1]));
     }
     foreach ($this->mLinktags as $tag) {
         $tags[] = Html::element('link', $tag);
     }
     # Universal edit button
     if ($config->get('UniversalEditButton') && $this->isArticleRelated()) {
         $user = $this->getUser();
         if ($this->getTitle()->quickUserCan('edit', $user) && ($this->getTitle()->exists() || $this->getTitle()->quickUserCan('create', $user))) {
             // Original UniversalEditButton
             $msg = $this->msg('edit')->text();
             $tags['universal-edit-button'] = Html::element('link', array('rel' => 'alternate', 'type' => 'application/x-wiki', 'title' => $msg, 'href' => $this->getTitle()->getEditURL()));
             // Alternate edit link
             $tags['alternative-edit'] = Html::element('link', array('rel' => 'edit', 'title' => $msg, 'href' => $this->getTitle()->getEditURL()));
         }
     }
     # Generally the order of the favicon and apple-touch-icon links
     # should not matter, but Konqueror (3.5.9 at least) incorrectly
     # uses whichever one appears later in the HTML source. Make sure
     # apple-touch-icon is specified first to avoid this.
     if ($config->get('AppleTouchIcon') !== false) {
         $tags['apple-touch-icon'] = Html::element('link', array('rel' => 'apple-touch-icon', 'href' => $config->get('AppleTouchIcon')));
     }
     if ($config->get('Favicon') !== false) {
         $tags['favicon'] = Html::element('link', array('rel' => 'shortcut icon', 'href' => $config->get('Favicon')));
     }
     # OpenSearch description link
     $tags['opensearch'] = Html::element('link', array('rel' => 'search', 'type' => 'application/opensearchdescription+xml', 'href' => wfScript('opensearch_desc'), 'title' => $this->msg('opensearch-desc')->inContentLanguage()->text()));
     if ($config->get('EnableAPI')) {
         # Real Simple Discovery link, provides auto-discovery information
         # for the MediaWiki API (and potentially additional custom API
         # support such as WordPress or Twitter-compatible APIs for a
         # blogging extension, etc)
         $tags['rsd'] = Html::element('link', array('rel' => 'EditURI', 'type' => 'application/rsd+xml', 'href' => wfExpandUrl(wfAppendQuery(wfScript('api'), array('action' => 'rsd')), PROTO_RELATIVE)));
     }
     # Language variants
     if (!$config->get('DisableLangConversion')) {
         $lang = $this->getTitle()->getPageLanguage();
         if ($lang->hasVariants()) {
             $variants = $lang->getVariants();
             foreach ($variants as $_v) {
                 $tags["variant-{$_v}"] = Html::element('link', array('rel' => 'alternate', 'hreflang' => wfBCP47($_v), 'href' => $this->getTitle()->getLocalURL(array('variant' => $_v))));
             }
         }
         # x-default link per https://support.google.com/webmasters/answer/189077?hl=en
         $tags["variant-x-default"] = Html::element('link', array('rel' => 'alternate', 'hreflang' => 'x-default', 'href' => $this->getTitle()->getLocalURL()));
     }
     # Copyright
     if ($this->copyrightUrl !== null) {
         $copyright = $this->copyrightUrl;
     } else {
         $copyright = '';
         if ($config->get('RightsPage')) {
             $copy = Title::newFromText($config->get('RightsPage'));
             if ($copy) {
                 $copyright = $copy->getLocalURL();
             }
         }
         if (!$copyright && $config->get('RightsUrl')) {
             $copyright = $config->get('RightsUrl');
         }
     }
     if ($copyright) {
         $tags['copyright'] = Html::element('link', array('rel' => 'copyright', 'href' => $copyright));
     }
     # Feeds
     if ($config->get('Feed')) {
         foreach ($this->getSyndicationLinks() as $format => $link) {
             # Use the page name for the title.  In principle, this could
             # lead to issues with having the same name for different feeds
//.........这里部分代码省略.........
开发者ID:GoProjectOwner,项目名称:mediawiki,代码行数:101,代码来源:OutputPage.php


示例9: getHtmlCode

 /**
  * Get the code in Bcp47 format which we can use
  * inside of html lang="" tags.
  *
  * NOTE: The return value of this function is NOT HTML-safe and must be escaped with
  * htmlspecialchars() or similar.
  *
  * @since 1.19
  * @return string
  */
 public function getHtmlCode()
 {
     if (is_null($this->mHtmlCode)) {
         $this->mHtmlCode = wfBCP47($this->getCode());
     }
     return $this->mHtmlCode;
 }
开发者ID:nanasess,项目名称:mediawiki,代码行数:17,代码来源:Language.php


示例10: doGettextHeader

    protected function doGettextHeader(MessageCollection $collection, $template, &$pluralCount)
    {
        global $wgSitename;
        $code = $collection->code;
        $name = TranslateUtils::getLanguageName($code);
        $native = TranslateUtils::getLanguageName($code, $code);
        $authors = $this->doAuthors($collection);
        if (isset($this->extra['header'])) {
            $extra = "# --\n" . $this->extra['header'];
        } else {
            $extra = '';
        }
        $output = <<<PHP
# Translation of {$this->group->getLabel()} to {$name} ({$native})
# Exported from {$wgSitename}
#
{$authors}{$extra}
PHP;
        // Make sure there is no empty line before msgid
        $output = trim($output) . "\n";
        $specs = isset($template['HEADERS']) ? $template['HEADERS'] : array();
        $timestamp = wfTimestampNow();
        $specs['PO-Revision-Date'] = self::formatTime($timestamp);
        if ($this->offlineMode) {
            $specs['POT-Creation-Date'] = self::formatTime($timestamp);
        } elseif ($this->group instanceof MessageGroupBase) {
            $specs['X-POT-Import-Date'] = self::formatTime(wfTimestamp(TS_MW, $this->getPotTime()));
        }
        $specs['Content-Type'] = 'text/plain; charset=UTF-8';
        $specs['Content-Transfer-Encoding'] = '8bit';
        $specs['Language'] = wfBCP47($this->group->mapCode($code));
        Hooks::run('Translate:GettextFFS:headerFields', array(&$specs, $this->group, $code));
        $specs['X-Generator'] = $this->getGenerator();
        if ($this->offlineMode) {
            $specs['X-Language-Code'] = $code;
            $specs['X-Message-Group'] = $this->group->getId();
        }
        $plural = self::getPluralRule($code);
        if ($plural) {
            $specs['Plural-Forms'] = $plural;
        } elseif (!isset($specs['Plural-Forms'])) {
            $specs['Plural-Forms'] = 'nplurals=2; plural=(n != 1);';
        }
        $match = array();
        preg_match('/nplurals=(\\d+);/', $specs['Plural-Forms'], $match);
        $pluralCount = $match[1];
        $output .= 'msgid ""' . "\n";
        $output .= 'msgstr ""' . "\n";
        $output .= '""' . "\n";
        foreach ($specs as $k => $v) {
            $output .= self::escape("{$k}: {$v}\n") . "\n";
        }
        $output .= "\n";
        return $output;
    }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:55,代码来源:GettextFFS.php


示例11: doBox

 /**
  * @param $msg string
  * @param $code string
  * @param $title Title
  * @param $makelink
  * @return string
  */
 protected function doBox($msg, $code, $title = false, $makelink = false)
 {
     global $wgUser, $wgLang;
     $name = TranslateUtils::getLanguageName($code, false, $wgLang->getCode());
     $code = wfBCP47($code);
     $skin = $wgUser->getSkin();
     $attributes = array();
     if (!$title) {
         $attributes['class'] = 'mw-sp-translate-in-other-big';
     } elseif ($code === 'en') {
         $attributes['class'] = 'mw-sp-translate-edit-definition';
     } else {
         $attributes['class'] = 'mw-sp-translate-edit-committed';
     }
     if (mb_strlen($msg) < 100 && !$title) {
         $attributes['class'] = 'mw-sp-translate-in-other-small';
     }
     $msg = TranslateUtils::convertWhiteSpaceToHTML($msg);
     if (!$title) {
         $title = "{$name} ({$code})";
     }
     if ($makelink) {
         $linkTitle = Title::newFromText($makelink);
         $title = $skin->link($linkTitle, htmlspecialchars($title), array(), array('action' => 'edit'));
     }
     return TranslateUtils::fieldset($title, Html::element('span', null, $msg), $attributes);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:34,代码来源:TranslationHelpers.php


示例12: profilePreferences

 /**
  * @param $user User
  * @param $context IContextSource
  * @param $defaultPreferences
  * @return void
  */
 static function profilePreferences($user, IContextSource $context, &$defaultPreferences)
 {
     global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode, $wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars, $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication, $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress;
     ## User info #####################################
     // Information panel
     $defaultPreferences['username'] = array('type' => 'info', 'label-message' => 'username', 'default' => $user->getName(), 'section' => 'personal/info');
     $defaultPreferences['userid'] = array('type' => 'info', 'label-message' => 'uid', 'default' => $user->getId(), 'section' => 'personal/info');
     # Get groups to which the user belongs
     $userEffectiveGroups = $user->getEffectiveGroups();
     $userGroups = $userMembers = array();
     foreach ($userEffectiveGroups as $ueg) {
         if ($ueg == '*') {
             // Skip the default * group, seems useless here
             continue;
         }
         $groupName = User::getGroupName($ueg);
         $userGroups[] = User::makeGroupLinkHTML($ueg, $groupName);
         $memberName = User::getGroupMember($ueg, $user->getName());
         $userMembers[] = User::makeGroupLinkHTML($ueg, $memberName);
     }
     asort($userGroups);
     asort($userMembers);
     $lang = $context->getLanguage();
     $defaultPreferences['usergroups'] = array('type' => 'info', 'label' => $context->msg('prefs-memberingroups')->numParams(count($userGroups))->parse(), 'default' => $context->msg('prefs-memberingroups-type', $lang->commaList($userGroups), $lang->commaList($userMembers))->plain(), 'raw' => true, 'section' => 'personal/info');
     $defaultPreferences['editcount'] = array('type' => 'info', 'label-message' => 'prefs-edits', 'default' => $lang->formatNum($user->getEditCount()), 'section' => 'personal/info');
     if ($user->getRegistration()) {
         $displayUser = $context->getUser();
         $userRegistration = $user->getRegistration();
         $defaultPreferences['registrationdate'] = array('type' => 'info', 'label-message' => 'prefs-registration', 'default' => $context->msg('prefs-registration-date-time', $lang->userTimeAndDate($userRegistration, $displayUser), $lang->userDate($userRegistration, $displayUser), $lang->userTime($userRegistration, $displayUser))->parse(), 'section' => 'personal/info');
     }
     // Actually changeable stuff
     $defaultPreferences['realname'] = array('type' => $wgAuth->allowPropChange('realname') ? 'text' : 'info', 'default' => $user->getRealName(), 'section' => 'personal/info', 'label-message' => 'yourrealname', 'help-message' => 'prefs-help-realname');
     $defaultPreferences['gender'] = array('type' => 'select', 'section' => 'personal/info', 'options' => array($context->msg('gender-male')->text() => 'male', $context->msg('gender-female')->text() => 'female', $context->msg('gender-unknown')->text() => 'unknown'), 'label-message' => 'yourgender', 'help-message' => 'prefs-help-gender');
     if ($wgAuth->allowPasswordChange()) {
         $link = Linker::link(SpecialPage::getTitleFor('ChangePassword'), $context->msg('prefs-resetpass')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
         $defaultPreferences['password'] = array('type' => 'info', 'raw' => true, 'default' => $link, 'label-message' => 'yourpassword', 'section' => 'personal/info');
     }
     if ($wgCookieExpiration > 0) {
         $defaultPreferences['rememberpassword'] = array('type' => 'toggle', 'label' => $context->msg('tog-rememberpassword')->numParams(ceil($wgCookieExpiration / (3600 * 24)))->text(), 'section' => 'personal/info');
     }
     // Language
     /** WIKIA CHANGE BEGIN **/
     $languages = wfGetFixedLanguageNames();
     /** WIKIA CHANGE END **/
     if (!array_key_exists($wgLanguageCode, $languages)) {
         $languages[$wgLanguageCode] = $wgLanguageCode;
     }
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $display = wfBCP47($code) . ' - ' . $name;
         $options[$display] = $code;
     }
     $defaultPreferences['language'] = array('type' => 'select', 'section' => 'personal/i18n', 'options' => $options, 'label-message' => 'yourlanguage');
     /* see if there are multiple language variants to choose from*/
     $variantArray = array();
     if (!$wgDisableLangConversion) {
         $variants = $wgContLang->getVariants();
         foreach ($variants as $v) {
             $v = str_replace('_', '-', strtolower($v));
             $variantArray[$v] = $wgContLang->getVariantname($v, false);
         }
         $options = array();
         foreach ($variantArray as $code => $name) {
             $display = wfBCP47($code) . ' - ' . $name;
             $options[$display] = $code;
         }
         if (count($variantArray) > 1) {
             $defaultPreferences['variant'] = array('label-message' => 'yourvariant', 'type' => 'select', 'options' => $options, 'section' => 'personal/i18n', 'help-message' => 'prefs-help-variant');
         }
     }
     if (count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
         $defaultPreferences['noconvertlink'] = array('type' => 'toggle', 'section' => 'personal/i18n', 'label-message' => 'tog-noconvertlink');
     }
     // show a preview of the old signature first
     $oldsigWikiText = $wgParser->preSaveTransform("~~~", $context->getTitle(), $user, ParserOptions::newFromContext($context));
     $oldsigHTML = $context->getOutput()->parseInline($oldsigWikiText, true, true);
     $defaultPreferences['oldsig'] = array('type' => 'info', 'raw' => true, 'label-message' => 'tog-oldsig', 'default' => $oldsigHTML, 'section' => 'personal/signature');
     $defaultPreferences['nickname'] = array('type' => $wgAuth->allowPropChange('nickname') ? 'text' : 'info', 'maxlength' => $wgMaxSigChars, 'label-message' => 'yournick', 'validation-callback' => array('Preferences', 'validateSignature'), 'section' => 'personal/signature', 'filter-callback' => array('Preferences', 'cleanSignature'));
     $defaultPreferences['fancysig'] = array('type' => 'toggle', 'label-message' => 'tog-fancysig', 'help-message' => 'prefs-help-signature', 'section' => 'personal/signature');
     ## Email stuff
     if ($wgEnableEmail) {
         $helpMessages[] = $wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email';
         if ($wgEnableUserEmail) {
             // additional messages when users can send email to each other
             $helpMessages[] = 'prefs-help-email-others';
         }
         $link = Linker::link(SpecialPage::getTitleFor('ChangeEmail'), $context->msg($user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
         $emailAddress = $user->getEmail() ? htmlspecialchars($user->getEmail()) : '';
         if ($wgAuth->allowPropChange('emailaddress')) {
             $emailAddress .= $emailAddress == '' ? $link : " ({$link})";
         }
         $defaultPreferences['emailaddress'] = array('type' => 'info', 'raw' => true, 'default' => $emailAddress, 'label-message' => 'youremail', 'section' => 'personal/email', 'help-messages' => $helpMessages);
         $disableEmailPrefs = false;
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:Preferences.php


示例13: asBCP47FormattedLanguageCode

 /**
  * @see IETF language tag / BCP 47 standards
  *
  * @since 2.4
  *
  * @param string $languageCode
  *
  * @return string
  */
 public static function asBCP47FormattedLanguageCode($languageCode)
 {
     return wfBCP47($languageCode);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:13,代码来源:Localizer.php


示例14: addAcceptLanguage

 /**
  * bug 21672: Add Accept-Language to Vary and XVO headers
  * if there's no 'variant' parameter existed in GET.
  *
  * For example:
  *   /w/index.php?title=Main_page should always be served; but
  *   /w/index.php?title=Main_page&variant=zh-cn should never be served.
  */
 function addAcceptLanguage()
 {
     $lang = $this->getTitle()->getPageLanguage();
     if (!$this->getRequest()->getCheck('variant') && $lang->hasVariants()) {
         $variants = $lang->getVariants();
         $aloption = array();
         foreach ($variants as $variant) {
             if ($variant === $lang->getCode()) {
                 continue;
             } else {
                 $aloption[] = 'string-contains=' . $variant;
                 // IE and some other browsers use BCP 47 standards in
                 // their Accept-Language header, like "zh-CN" or "zh-Hant".
                 // We should handle these too.
                 $variantBCP47 = wfBCP47($variant);
                 if ($variantBCP47 !== $variant) {
                     $aloption[] = 'string-contains=' . $variantBCP47;
                 }
             }
         }
         $this->addVaryHeader('Accept-Language', $aloption);
     }
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:31,代码来源:OutputPage.php


示例15: getOtherLanguagesBox

 public function getOtherLanguagesBox()
 {
     $code = $this->handle->getCode();
     $page = $this->handle->getKey();
     $ns = $this->handle->getTitle()->getNamespace();
     $boxes = array();
     foreach (self::getFallbacks($code) as $fbcode) {
         $text = TranslateUtils::getMessageContent($page, $fbcode, $ns);
         if ($text === null) {
             continue;
         }
         $context = RequestContext::getMain();
         $label = TranslateUtils::getLanguageName($fbcode, $context->getLanguage()->getCode()) . $context->msg('word-separator')->text() . $context->msg('parentheses', wfBCP47($fbcode))->text();
         $target = Title::makeTitleSafe($ns, "{$page}/{$fbcode}");
         if ($target) {
             $label = self::ajaxEditLink($target, htmlspecialchars($label));
         }
         $dialogID = $this->dialogID();
         $id = Sanitizer::escapeId("other-{$fbcode}-{$dialogID}");
         $params = array('class' => 'mw-translate-edit-item');
         $display = TranslateUtils::convertWhiteSpaceToHTML($text);
         $display = Html::rawElement('div', array('lang' => $fbcode, 'dir' => Language::factory($fbcode)->getDir()), $display);
         $contents = self::legend($label) . "\n" . $this->adder($id, $fbcode) . $display . self::clear();
         $boxes[] = Html::rawElement('div', $params, $contents) . $this->wrapInsert($id, $text);
     }
     if (count($boxes)) {
         $sep = Html::element('hr', array('class' => 'mw-translate-sep'));
         return TranslateUtils::fieldset(wfMessage('translate-edit-in-other-languages', $page)->escaped(), implode("{$sep}\n", $boxes), array('class' => 'mw-sp-translate-edit-inother'));
     }
     return null;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:31,代码来源:TranslationHelpers.php


示例16: getCanonicalLanguageCode

 /**
  * @param string $languageCode Any non-standard or canonical language code
  *
  * @return string Canonical language code
  */
 public function getCanonicalLanguageCode($languageCode)
 {
     // First we check the case since most languages will be cached very quickly
     if (isset(self::$canonicalLanguageCodeCache[$languageCode])) {
         return self::$canonicalLanguageCodeCache[$languageCode];
     }
     // Wikibase list goes first in case we want to override
     // Like "simple" goes to en-x-simple not en
     if (isset($this->canonicalLanguageCodes[$languageCode])) {
         return $this->canonicalLanguageCodes[$languageCode];
     }
     self::$canonicalLanguageCodeCache[$languageCode] = wfBCP47($languageCode);
     return self::$canonicalLanguageCodeCache[$languageCode];
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:19,代码来源:RdfVocabulary.php


示例17: getHeadLinksArray

 /**
  * @return array in format "link name or number => 'link html'".
  */
 public function getHeadLinksArray()
 {
     global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, $wgSitename, $wgVersion, $wgFeed, $wgOverrideSite 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wfBacktrace函数代码示例发布时间:2022-05-23
下一篇:
PHP wfAssembleUrl函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap