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


PHP Parser::startExternalParse方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     $this->parser = new Parser();
     $title = Title::newFromText('test');
     $options = new ParserOptions();
     $this->parser->startExternalParse($title, $options, 'text', true);
     parent::setUp();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:8,代码来源:MediaWikiParserTest.php

示例2: setUp

 function setUp()
 {
     parent::setUp();
     $parser = new Parser();
     $options = new ParserOptions();
     $options->setTemplateCallback(array($this, 'templateCallback'));
     $parser->startExternalParse(Title::newMainPage(), $options, Parser::OT_HTML, true);
     try {
         $engine = new Scribunto_LuaSandboxEngine(array('parser' => $parser) + $this->sandboxOpts);
         $engine->setTitle($parser->getTitle());
         $engine->getInterpreter();
         $this->engines['LuaSandbox'] = $engine;
     } catch (Scribunto_LuaInterpreterNotFoundError $e) {
         $this->markTestSkipped("LuaSandbox interpreter not available");
         return;
     }
     try {
         $engine = new Scribunto_LuaStandaloneEngine(array('parser' => $parser) + $this->standaloneOpts);
         $engine->setTitle($parser->getTitle());
         $engine->getInterpreter();
         $this->engines['LuaStandalone'] = $engine;
     } catch (Scribunto_LuaInterpreterNotFoundError $e) {
         $this->markTestSkipped("LuaStandalone interpreter not available");
         return;
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:LuaEnvironmentComparisonTest.php

示例3: setUpParser

 protected function setUpParser()
 {
     $parser = new Parser();
     $options = new ParserOptions();
     $title = Title::newFromText('Test');
     $parser->Options($options);
     $parser->startExternalParse($title, $options, 'text', true);
     return $parser;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:9,代码来源:PortableInfoboxParserTagControllerTest.php

示例4: makeEngine

 private function makeEngine($class, $opts)
 {
     $parser = new Parser();
     $options = new ParserOptions();
     $options->setTemplateCallback(array($this, 'templateCallback'));
     $parser->startExternalParse(Title::newMainPage(), $options, Parser::OT_HTML, true);
     $engine = new $class(array('parser' => $parser) + $opts);
     $parser->scribunto_engine = $engine;
     $engine->setTitle($parser->getTitle());
     $engine->getInterpreter();
     return $engine;
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:12,代码来源:LuaEnvironmentComparisonTest.php

示例5: execute

 public function execute()
 {
     $text = $this->getParameter("text");
     $title = $this->getParameter("title");
     $arguments = $this->getFrameArguments();
     if ($arguments === null) {
         $this->getResult()->setWarning("Arguments json format incorect or empty");
     }
     $parser = new Parser();
     $parser->startExternalParse(Title::newFromText($title), new ParserOptions(), 'text', true);
     $frame = $parser->getPreprocessor()->newCustomFrame($arguments);
     try {
         $output = PortableInfoboxParserTagController::getInstance()->render($text, $parser, $frame);
         $this->getResult()->addValue(null, $this->getModuleName(), ['text' => ['*' => $output]]);
     } catch (\Wikia\PortableInfobox\Parser\Nodes\UnimplementedNodeException $e) {
         $this->dieUsage(wfMessage('unimplemented-infobox-tag', [$e->getMessage()])->escaped(), "notimplemented");
     } catch (\Wikia\PortableInfobox\Parser\XmlMarkupParseErrorException $e) {
         $this->dieUsage(wfMessage('xml-parse-error')->text(), "badxml");
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:20,代码来源:ApiPortableInfobox.class.php

示例6: execute

 function execute($params)
 {
     global $wgRequest, $wgOut, $wgUser;
     global $wgContLang, $wgProxyKey, $wgParser;
     $article = $wgRequest->getText('article', $params);
     $map = $wgRequest->getText('map', $params);
     $wgOut->disable();
     header("Cache-Control: no-cache, must-revalidate");
     header("Content-type: application/vnd.google-earth.kml+xml");
     header('Content-Disposition: attachment; filename="' . $article . '.kml"');
     $title = Title::newFromText($article);
     if ($title) {
         $revision = Revision::newFromTitle($title);
         $mapOptions = GoogleMaps::getMapSettings($title, array('icons' => 'http://maps.google.com/mapfiles/kml/pal4/{label}.png', 'icon' => 'icon57'));
         $exporter = new GoogleMapsKmlExporter($wgContLang, str_replace('{label}', $mapOptions['icon'], $mapOptions['icons']));
         $popts = ParserOptions::newFromUser($wgUser);
         $popts->setEditSection(false);
         $wgParser->startExternalParse($this->getTitle(), $popts, OT_WIKI, true);
         $localParser = new Parser();
         $localParser->startExternalParse($this->getTitle(), $popts, OT_WIKI, true);
         if (preg_match_all("/<googlemap( .*?|)>(.*?)<\\/googlemap>/s", $revision->getText(), $matches)) {
             $exporter->addFileHeader();
             for ($i = 0; $i < count($matches[2]); $i++) {
                 $attrs = Sanitizer::decodeTagAttributes($matches[1][$i]);
                 $mapOptions['version'] = isset($attrs['version']) ? $attrs['version'] : "0";
                 $exporter->addHeader(isset($attrs['title']) ? $attrs['title'] : "Map #" . ($i + 1));
                 GoogleMaps::renderContent($matches[2][$i], $wgParser, $localParser, $exporter, $mapOptions);
                 $exporter->addTrailer();
             }
             $exporter->addFileTrailer();
             echo $exporter->render();
         } else {
             echo "No maps in {$article}!";
         }
     } else {
         echo "No article found by the name of {$article}";
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:38,代码来源:SpecialGoogleMapsKML.php

示例7: 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

示例8: getEngine

 function getEngine()
 {
     if (!$this->engine) {
         $parser = new Parser();
         $options = new ParserOptions();
         $options->setTemplateCallback(array($this, 'templateCallback'));
         $parser->startExternalParse(Title::newMainPage(), $options, Parser::OT_HTML, true);
         $class = "Scribunto_{$this->engineName}Engine";
         $this->engine = new $class(self::$engineConfigurations[$this->engineName] + array('parser' => $parser));
         $this->engine->setTitle($parser->getTitle());
     }
     return $this->engine;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:LuaEngineTestBase.php

示例9: 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

示例10: prepareAction

 /**
  *
  */
 function prepareAction()
 {
     // get options from the request, but keep the explicitly set options
     global $wgVersion;
     if (version_compare($wgVersion, '1.20', '>=')) {
         $data = $this->getRequest()->getValues();
     } else {
         // TODO: remove else branch when raising supported version to MW 1.20, getValues() was buggy before
         $data = $_POST + $_GET;
     }
     $this->mOptions = SFUtils::array_merge_recursive_distinct($data, $this->mOptions);
     global $wgParser;
     if ($wgParser === null) {
         $wgParser = new Parser();
     }
     $wgParser->startExternalParse(null, ParserOptions::newFromUser($this->getUser()), Parser::OT_WIKI);
     // MW uses the parameter 'title' instead of 'target' when submitting
     // data for formedit action => use that
     if (!array_key_exists('target', $this->mOptions) && array_key_exists('title', $this->mOptions)) {
         $this->mOptions['target'] = $this->mOptions['title'];
         unset($this->mOptions['title']);
     }
     // if the 'query' parameter was used, unpack the param string
     if (array_key_exists('query', $this->mOptions)) {
         $this->addOptionsFromString($this->mOptions['query']);
         unset($this->mOptions['query']);
     }
     // if an action is explicitly set in the form data, use that
     if (array_key_exists('wpSave', $this->mOptions)) {
         // set action to 'save' if requested
         $this->mAction = self::ACTION_SAVE;
         unset($this->mOptions['wpSave']);
     } else {
         if (array_key_exists('wpPreview', $this->mOptions)) {
             // set action to 'preview' if requested
             $this->mAction = self::ACTION_PREVIEW;
             unset($this->mOptions['wpPreview']);
         } else {
             if (array_key_exists('wpDiff', $this->mOptions)) {
                 // set action to 'preview' if requested
                 $this->mAction = self::ACTION_DIFF;
                 unset($this->mOptions['wpDiff']);
             } else {
                 if (array_key_exists('action', $this->mOptions)) {
                     switch ($this->mOptions['action']) {
                         case 'sfautoedit':
                             $this->mAction = self::ACTION_SAVE;
                             break;
                         case 'preview':
                             $this->mAction = self::ACTION_PREVIEW;
                             break;
                         default:
                             $this->mAction = self::ACTION_FORMEDIT;
                     }
                 } else {
                     // set default action
                     $this->mAction = self::ACTION_FORMEDIT;
                 }
             }
         }
     }
     $hookQuery = null;
     // ensure 'form' key exists
     if (array_key_exists('form', $this->mOptions)) {
         $hookQuery = $this->mOptions['form'];
     } else {
         $this->mOptions['form'] = '';
     }
     // ensure 'target' key exists
     if (array_key_exists('target', $this->mOptions)) {
         if ($hookQuery !== null) {
             $hookQuery .= '/' . $this->mOptions['target'];
         }
     } else {
         $this->mOptions['target'] = '';
     }
     // Normalize form and target names
     $form = Title::newFromText($this->mOptions['form']);
     if ($form !== null) {
         $this->mOptions['form'] = $form->getPrefixedText();
     }
     $target = Title::newFromText($this->mOptions['target']);
     if ($target !== null) {
         $this->mOptions['target'] = $target->getPrefixedText();
     }
     Hooks::run('sfSetTargetName', array(&$this->mOptions['target'], $hookQuery));
     // set html return status. If all goes well, this will not be changed
     $this->mStatus = 200;
 }
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:92,代码来源:SF_AutoeditAPI.php


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