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


PHP ParserOptions::setInterfaceMessage方法代码示例

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


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

示例1: wfMsgExt

/**
 * Returns message in the requested format
 * @param string $key Key of the message
 * @param array $options Processing rules:
 *  <i>parse<i>: parses wikitext to html
 *  <i>parseinline<i>: parses wikitext to html and removes the surrounding p's added by parser or tidy
 *  <i>escape<i>: filters message trough htmlspecialchars
 *  <i>replaceafter<i>: parameters are substituted after parsing or escaping
 */
function wfMsgExt($key, $options)
{
    global $wgOut, $wgMsgParserOptions, $wgParser;
    $args = func_get_args();
    array_shift($args);
    array_shift($args);
    if (!is_array($options)) {
        $options = array($options);
    }
    $string = wfMsgGetKey($key, true, false, false);
    if (!in_array('replaceafter', $options)) {
        $string = wfMsgReplaceArgs($string, $args);
    }
    if (in_array('parse', $options)) {
        $string = $wgOut->parse($string, true, true);
    } elseif (in_array('parseinline', $options)) {
        $string = $wgOut->parse($string, true, true);
        $m = array();
        if (preg_match("~^<p>(.*)\n?</p>\$~", $string, $m)) {
            $string = $m[1];
        }
    } elseif (in_array('parsemag', $options)) {
        global $wgTitle;
        $parser = new Parser();
        $parserOptions = new ParserOptions();
        $parserOptions->setInterfaceMessage(true);
        $parser->startExternalParse($wgTitle, $parserOptions, OT_MSG);
        $string = $parser->transformMsg($string, $parserOptions);
    }
    if (in_array('escape', $options)) {
        $string = htmlspecialchars($string);
    }
    if (in_array('replaceafter', $options)) {
        $string = wfMsgReplaceArgs($string, $args);
    }
    return $string;
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:46,代码来源:GlobalFunctions.php

示例2: msgExt

 /**
  * Returns message in the requested format after parsing wikitext to html
  * This is meant to be equivalent to wfMsgExt() with parse, parsemag and
  * escape as available options but using the DPL local parser instead of
  * the global one (bugfix).
  */
 function msgExt($key, $options)
 {
     $args = func_get_args();
     array_shift($args);
     array_shift($args);
     if (!is_array($options)) {
         $options = array($options);
     }
     $string = wfMsgNoTrans($key);
     $string = wfMsgReplaceArgs($string, $args);
     if (in_array('parse', $options)) {
         $this->mParserOptions->setInterfaceMessage(true);
         $string = $this->mParser->recursiveTagParse($string);
         $this->mParserOptions->setInterfaceMessage(false);
         // $string = $parserOutput->getText();
     } elseif (in_array('parsemag', $options)) {
         $parser = new Parser();
         $parserOptions = new ParserOptions();
         $parserOptions->setInterfaceMessage(true);
         $parser->startExternalParse($this->mParserTitle, $parserOptions, OT_MSG);
         $string = $parser->transformMsg($string, $parserOptions);
     }
     if (in_array('escape', $options)) {
         $string = htmlspecialchars($string);
     }
     return $string;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:33,代码来源:DPL.php

示例3: addToSidebarPlain

 /**
  * Add content from plain text
  * @since 1.17
  * @param &$bar array
  * @param $text string
  */
 function addToSidebarPlain(&$bar, $text)
 {
     $lines = explode("\n", $text);
     $wikiBar = array();
     # We need to handle the wikitext on a different variable, to avoid trying to do an array operation on text, which would be a fatal error.
     $heading = '';
     foreach ($lines as $line) {
         if (strpos($line, '*') !== 0) {
             continue;
         }
         if (strpos($line, '**') !== 0) {
             $heading = trim($line, '* ');
             if (!array_key_exists($heading, $bar)) {
                 $bar[$heading] = array();
             }
         } else {
             $line = trim($line, '* ');
             if (strpos($line, '|') !== false) {
                 // sanity check
                 $line = array_map('trim', explode('|', $line, 2));
                 $link = wfMsgForContent($line[0]);
                 if ($link == '-') {
                     continue;
                 }
                 $text = wfMsgExt($line[1], 'parsemag');
                 if (wfEmptyMsg($line[1], $text)) {
                     $text = $line[1];
                 }
                 if (wfEmptyMsg($line[0], $link)) {
                     $link = $line[0];
                 }
                 if (preg_match('/^(?:' . wfUrlProtocols() . ')/', $link)) {
                     $href = $link;
                 } else {
                     $title = Title::newFromText($link);
                     if ($title) {
                         $title = $title->fixSpecialName();
                         $href = $title->getLocalURL();
                     } else {
                         $href = 'INVALID-TITLE';
                     }
                 }
                 $bar[$heading][] = array('text' => $text, 'href' => $href, 'id' => 'n-' . strtr($line[1], ' ', '-'), 'active' => false);
             } else {
                 if (substr($line, 0, 2) == '{{' && substr($line, -2) == '}}') {
                     global $wgParser, $wgTitle;
                     $line = substr($line, 2, strlen($line) - 4);
                     $options = new ParserOptions();
                     $options->setEditSection(false);
                     $options->setInterfaceMessage(true);
                     $wikiBar[$heading] = $wgParser->parse(wfMsgForContentNoTrans($line), $wgTitle, $options)->getText();
                 } else {
                     continue;
                 }
             }
         }
     }
     if (count($wikiBar) > 0) {
         $bar = array_merge($bar, $wikiBar);
     }
     return $bar;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:68,代码来源:Skin.php


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