当前位置: 首页>>代码示例>>PHP>>正文


PHP ParserOptions::getUserLang方法代码示例

本文整理汇总了PHP中ParserOptions::getUserLang方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOptions::getUserLang方法的具体用法?PHP ParserOptions::getUserLang怎么用?PHP ParserOptions::getUserLang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParserOptions的用法示例。


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

示例1: formatHeadings


//.........这里部分代码省略.........
             # the two are different if the line contains a link
             $headline = $numbering . ' ' . $headline;
         }
         # Create the anchor for linking from the TOC to the section
         $anchor = $safeHeadline;
         $legacyAnchor = $legacyHeadline;
         if ($refers[$arrayKey] > 1) {
             $anchor .= '_' . $refers[$arrayKey];
         }
         if ($legacyHeadline !== false && $refers[$legacyArrayKey] > 1) {
             $legacyAnchor .= '_' . $refers[$legacyArrayKey];
         }
         if ($enoughToc && (!isset($wgMaxTocLevel) || $toclevel < $wgMaxTocLevel)) {
             $toc .= Linker::tocLine($anchor, $tocline, $numbering, $toclevel, $isTemplate ? false : $sectionIndex);
         }
         # Add the section to the section tree
         # Find the DOM node for this header
         while ($node && !$isTemplate) {
             if ($node->getName() === 'h') {
                 $bits = $node->splitHeading();
                 if ($bits['i'] == $sectionIndex) {
                     break;
                 }
             }
             $byteOffset += mb_strlen($this->mStripState->unstripBoth($frame->expand($node, PPFrame::RECOVER_ORIG)));
             $node = $node->getNextSibling();
         }
         $tocraw[] = array('toclevel' => $toclevel, 'level' => $level, 'line' => $tocline, 'number' => $numbering, 'index' => ($isTemplate ? 'T-' : '') . $sectionIndex, 'fromtitle' => $titleText, 'byteoffset' => $isTemplate ? null : $byteOffset, 'anchor' => $anchor);
         # give headline the correct <h#> tag
         if ($sectionIndex !== false) {
             // Output edit section links as markers with styles that can be customized by skins
             if ($isTemplate) {
                 # Put a T flag in the section identifier, to indicate to extractSections()
                 # that sections inside <includeonly> should be counted.
                 $editlinkArgs = array($titleText, "T-{$sectionIndex}");
             } else {
                 $editlinkArgs = array($this->mTitle->getPrefixedText(), $sectionIndex, $headlineHint);
             }
             // We use a bit of pesudo-xml for editsection markers. The language converter is run later on
             // Using a UNIQ style marker leads to the converter screwing up the tokens when it converts stuff
             // And trying to insert strip tags fails too. At this point all real inputted tags have already been escaped
             // so we don't have to worry about a user trying to input one of these markers directly.
             // We use a page and section attribute to stop the language converter from converting these important bits
             // of data, but put the headline hint inside a content block because the language converter is supposed to
             // be able to convert that piece of data.
             $editlink = '<mw:editsection page="' . htmlspecialchars($editlinkArgs[0]);
             $editlink .= '" section="' . htmlspecialchars($editlinkArgs[1]) . '"';
             if (isset($editlinkArgs[2])) {
                 $editlink .= '>' . $editlinkArgs[2] . '</mw:editsection>';
             } else {
                 $editlink .= '/>';
             }
         } else {
             $editlink = '';
         }
         $head[$headlineCount] = Linker::makeHeadline($level, $matches['attrib'][$headlineCount], $anchor, $headline, $editlink, $legacyAnchor);
         $headlineCount++;
     }
     $this->setOutputType($oldType);
     # Never ever show TOC if no headers
     if ($numVisible < 1) {
         $enoughToc = false;
     }
     if ($enoughToc) {
         if ($prevtoclevel > 0 && $prevtoclevel < $wgMaxTocLevel) {
             $toc .= Linker::tocUnindent($prevtoclevel - 1);
         }
         $toc = Linker::tocList($toc, $this->mOptions->getUserLang());
         $this->mOutput->setTOCHTML($toc);
     }
     if ($isMain) {
         $this->mOutput->setSections($tocraw);
     }
     # split up and insert constructed headlines
     $blocks = preg_split('/<H[1-6].*?' . '>.*?<\\/H[1-6]>/i', $text);
     $i = 0;
     foreach ($blocks as $block) {
         if ($showEditLink && $headlineCount > 0 && $i == 0 && $block !== "\n") {
             # This is the [edit] link that appears for the top block of text when
             # section editing is enabled
             # Disabled because it broke block formatting
             # For example, a bullet point in the top line
             # $full .= $sk->editSectionLink(0);
         }
         $full .= $block;
         if ($enoughToc && !$i && $isMain && !$this->mForceTocPosition) {
             # Top anchor now in skin
             $full = $full . $toc;
         }
         if (!empty($head[$i])) {
             $full .= $head[$i];
         }
         $i++;
     }
     if ($this->mForceTocPosition) {
         return str_replace('<!--MWTOC-->', $toc, $full);
     } else {
         return $full;
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:101,代码来源:Parser.php

示例2: getParserFor

 /**
  * Get Parser instance that's suitable for passing it to CoreParserFunctions
  * in MessageCache::transform()
  *
  * @author Władysław Bodzek <wladek@wikia-inc.com>
  *
  * @param ParserOptions $popts
  * @return Parser
  */
 function getParserFor(ParserOptions $popts)
 {
     $interfaceMessage = $popts->getInterfaceMessage();
     $userLanguage = $popts->getUserLang();
     $hash = array();
     foreach (array($interfaceMessage, $userLanguage) as $obj) {
         if (is_object($obj)) {
             $hash[] = get_class($obj);
         } else {
             $hash[] = serialize($obj);
         }
     }
     $hash = implode('|', $hash);
     if (!isset(self::$parsersCache[$hash])) {
         if (count(self::$parsersCache) > 25) {
             foreach (self::$parsersCache as $parser) {
                 ParserPool::release($parser);
             }
         }
         $parser = ParserPool::get();
         $parser->startExternalParse(new Title('DoesntExistXYZ'), $popts, Parser::OT_PREPROCESS, true);
         self::$parsersCache[$hash] = $parser;
     }
     return self::$parsersCache[$hash];
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:MessageCache.php


注:本文中的ParserOptions::getUserLang方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。