本文整理汇总了PHP中Parser::recursiveTagParse方法的典型用法代码示例。如果您正苦于以下问题:PHP Parser::recursiveTagParse方法的具体用法?PHP Parser::recursiveTagParse怎么用?PHP Parser::recursiveTagParse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser::recursiveTagParse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderCollection
public static function renderCollection($input, array $args, Parser $parser, PPFrame $frame)
{
$string_array = array();
$parsed_input = $parser->recursiveTagParse($input, $frame);
if (Collection::startsWith($parsed_input, "Coll") === true) {
$results = Collection::getResults($parsed_input);
$string_array[] = '{| class="wikitable"';
$string_array[] = "! ";
foreach ($results['langs'] as $lang) {
$string_array[] = "!" . $lang;
}
$string_array[] = "|-";
foreach (array_keys($results['data']) as $pagename) {
$string_array[] = "|[[" . $pagename . " |Edit]]";
foreach ($results['langs'] as $lang) {
if (isset($results['data'][$pagename][$lang])) {
$string_array[] = "|" . implode("<br/>", $results['data'][$pagename][$lang]);
} else {
$string_array[] = "|";
}
}
$string_array[] = "|-";
}
$string_array[] = "|}";
return $parser->recursiveTagParse(implode("\n\n", $string_array), $frame);
} else {
return $parser->recursiveTagParse("No results", $frame);
}
}
示例2: parse
/**
* Transforms from wikitext string to HTML.
* Require a value.
*
* @param string|boolean $value A string or boolean <i>true</i>
* @return string
* @throws UserError When value is not a signed integer.
*/
protected function parse($value)
{
if (!$this->parser instanceof \Parser) {
throw new \MWException('Parser must be set using setParser()');
}
if ($value === true) {
// parameter specified without value
Tools::ThrowUserError(wfMessage('wfmk-value-required', $this->getName()));
}
return $this->parser->recursiveTagParse($value);
}
示例3: parseSpoilerTag
/**
* Parses the <spoiler> tag.
*
* @access public
* @param string User input between <spoiler>
* @param array Array of arguments from the opening spoiler tag.
* @param object Mediawiki Parser Object
* @param object PPFrame object
* @return string HTML
*/
public static function parseSpoilerTag($input, array $args, Parser $parser, PPFrame $frame)
{
$out = $parser->getOutput();
$out->addModules('ext.spoilers');
$renderedInput = $parser->recursiveTagParse($input);
$output = "<div class='spoilers'>\n\t\t\t\t\t\t<div class='spoilers-button-container'>\n\t\t\t\t\t\t\t<span class='spoilers-button'>\n\t\t\t\t\t\t\t\t<span class='spoilers-show'>" . ($args['show'] ? htmlentities($args['show'], ENT_QUOTES) : wfMessage('spoilers_show_default')->text()) . "</span>\n\t\t\t\t\t\t\t\t<span class='spoilers-hide' style='display:none;'>" . ($args['hide'] ? htmlentities($args['hide'], ENT_QUOTES) : wfMessage('spoilers_hide_default')->text()) . "</span>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class='spoilers-body' style='display:none;'>{$renderedInput}</div>\n\t\t\t\t\t</div>";
return $output;
}
示例4: render
/**
* Renderer for <emblem> parser tag hook
*
* @param $input
* @param $args Array
* @param $parser Parser
* @param $frame
*/
public static function render($input, $args, Parser $parser, PPFrame $frame)
{
$output = $parser->getOutput();
if (!isset($output->articleEmblems)) {
$output->articleEmblems = array();
}
$output->articleEmblems[] = $parser->recursiveTagParse($input, $frame);
return '';
}
示例5: hideContent
/**
* @static
* @param $contents
* @param $attributes
* @param Parser $parser
* @return string
*/
public static function hideContent($contents, $attributes, $parser)
{
$app = F::app();
if ($app->checkSkin($app->wg->MobileSkins)) {
return '';
} else {
return $parser->recursiveTagParse($contents);
}
}
示例6: parseWikitext
/**
* Utility function to parse wikitext without having to care
* about handling a tag extension or parser function.
*
* @since 0.4.4
*
* @param string $text The wikitext to be parsed
*
* @return string the parsed output
*/
protected function parseWikitext($text)
{
// Parse the wikitext to HTML.
if ($this->isFunction()) {
return $this->parser->parse(text, $this->parser->mTitle, $this->parser->mOptions, true, false)->getText();
} else {
return $this->parser->recursiveTagParse($text, $this->frame);
}
}
示例7: renderModuleContainerTag
public static function renderModuleContainerTag($content, array $attributes, Parser $parser, PPFrame $frame)
{
if (!empty($attributes['content-title'])) {
$title = Title::newFromText($attributes['content-title']);
if ($title->exists()) {
$article = Article::newFromTitle($title, RequestContext::getMain());
$attributes['content'] = $parser->recursiveTagParse($article->getContent());
}
}
return F::app()->renderView('Njord', 'modula', $attributes);
}
示例8: error
/**
* Return an error message based on an error ID
*
* @param string $key Message name for the error
* @param string $param Parameter to pass to the message
* @param string $parse Whether to parse the message ('parse') or not ('noparse')
* @return string XHTML or wikitext ready for output
*/
function error($key, $param = null, $parse = 'parse')
{
# We rely on the fact that PHP is okay with passing unused argu-
# ments to functions. If $1 is not used in the message, wfMessage will
# just ignore the extra parameter.
$ret = '<strong class="error mw-ext-cite-error">' . wfMessage('cite_error', wfMessage($key, $param)->inContentLanguage()->plain())->inContentLanguage()->plain() . '</strong>';
if ($parse == 'parse') {
$ret = $this->mParser->recursiveTagParse($ret);
}
return $ret;
}
示例9: parse
/**
* Parse a given fragment and fix up Tidy's trail of blood on
* it...
*
* @param string $in The text to parse
* @return string The parsed text
*/
function parse($in)
{
if (method_exists($this->mParser, 'recursiveTagParse')) {
// New fast method
return $this->mParser->recursiveTagParse($in);
} else {
// Old method
$ret = $this->mParser->parse($in, $this->mParser->mTitle, $this->mParser->mOptions, false, false);
$text = $ret->getText();
return $this->fixTidy($text);
}
}
示例10: parserFunction_ev
/**
* Embeds video of the chosen service
* @param Parser $parser Instance of running Parser.
* @param String $service Which online service has the video.
* @param String $id Identifier of the chosen service
* @param String $width Width of video (optional)
* @param String $desc description to show (optional, unused)
* @param String $align alignment of the video (optional, unused)
* @return String Encoded representation of input params (to be processed later)
*/
public static function parserFunction_ev($parser, $service = null, $id = null, $width = null, $align = null, $desc = null)
{
global $wgScriptPath;
# Initialize things once
if (!EmbedVideo::$initialized) {
EmbedVideo::VerifyWidthMinAndMax();
# Add system messages
wfLoadExtensionMessages('embedvideo');
$parser->disableCache();
EmbedVideo::$initialized = true;
}
# Get the name of the host
if ($service === null || $id === null) {
return EmbedVideo::errMissingParams($service, $id);
}
$service = trim($service);
$id = trim($id);
$desc = $parser->recursiveTagParse($desc);
$entry = EmbedVideo::getServiceEntry($service);
if (!$entry) {
return EmbedVideo::errBadService($service);
}
if (!EmbedVideo::sanitizeWidth($entry, $width)) {
return EmbedVideo::errBadWidth($width);
}
$height = EmbedVideo::getHeight($entry, $width);
$hasalign = $align !== null;
if ($hasalign) {
$desc = EmbedVideo::getDescriptionMarkup($desc);
}
# If the service has an ID pattern specified, verify the id number
if (!EmbedVideo::verifyID($entry, $id)) {
return EmbedVideo::errBadID($service, $id);
}
# if the service has it's own custom extern declaration, use that instead
if (array_key_exists('extern', $entry) && ($clause = $entry['extern']) != null) {
$clause = wfMsgReplaceArgs($clause, array($wgScriptPath, $id, $width, $height));
if ($hasalign) {
$clause = EmbedVideo::generateAlignExternClause($clause, $align, $desc, $width, $height);
}
return array($clause, 'noparse' => true, 'isHTML' => true);
}
# Build URL and output embedded flash object
$url = wfMsgReplaceArgs($entry['url'], array($id, $width, $height));
$clause = "";
if ($hasalign) {
$clause = EmbedVideo::generateAlignClause($url, $width, $height, $align, $desc);
} else {
$clause = EmbedVideo::generateNormalClause($url, $width, $height);
}
return array($clause, 'noparse' => true, 'isHTML' => true);
}
示例11: parserHook
/**
* This function is the callback that the ParserFirstCallInit hook assigns
* to the parser whenever a supported FBML tag is encountered (like <fb:like-box>).
* Function createParserHook($tag) creates an anonymous (lambda-style)
* function that simply redirects to parserHook(), filling in the missing
* $tag argument with the $tag provided to createParserHook.
*/
public static function parserHook($tag, $text, $args, Parser $parser)
{
if ($tag == 'fb:like-box' && isset($args['profileid'])) {
$args['profile_id'] = $args['profileid'];
unset($args['profileid']);
}
// add custom attribute to look for in DOM. We use this to determine
// if the Facebook SDK should be loaded.
$args['data-type'] = 'xfbml-tag';
// Allow other tags by default
$attrs = self::implodeAttrs($args);
return "<{$tag}{$attrs}>" . $parser->recursiveTagParse($text) . "</{$tag}>";
}
示例12: buildTab
/**
* @param $tab
* @param Parser $parser
* @return string
*/
function buildTab($tab, $parser)
{
if (trim($tab) == '') {
return '';
}
$arr = explode("=", $tab);
$tabName = array_shift($arr);
// Wikia Change Start @author aquilax
$tabName = trim($tabName);
// Wikia Change End
$tabBody = $parser->recursiveTagParse(implode("=", $arr));
$tab = '<div class="tabbertab" title="' . htmlspecialchars($tabName) . '">' . '<p>' . $tabBody . '</p>' . '</div>';
return $tab;
}
示例13: buildTab
/**
* Build individual tab.
*
* @access private
* @param string Tab information
* @param object Mediawiki Parser Object
* @return string HTML
*/
private static function buildTab($tab = '', Parser $parser)
{
$tab = trim($tab);
if (empty($tab)) {
return $tab;
}
$args = explode('=', $tab);
$tabName = array_shift($args);
$tabBody = $parser->recursiveTagParse(implode('=', $args));
$tab = '
<div class="tabbertab" title="' . htmlspecialchars($tabName) . '">
<p>' . $tabBody . '</p>
</div>';
return $tab;
}
示例14: renderChosen
/**
* @param $input
* @param $argv
* @param Parser $parser
* @return mixed|string
*/
function renderChosen($input, $argv, $parser)
{
# Prevent caching
#$parser->disableCache();
global $wgParserCacheExpireTime;
$wgParserCacheExpireTime = 60;
wfDebug("soft disable Cache (choose)\n");
# Parse the options and calculate total weight
$len = preg_match_all("/<option(?:(?:\\s[^>]*?)?\\sweight=[\"']?([^\\s>]+))?" . "(?:\\s[^>]*)?>([\\s\\S]*?)<\\/option>/", $input, $out);
$r = 0;
for ($i = 0; $i < $len; $i++) {
if (strlen($out[1][$i]) == 0) {
$out[1][$i] = 1;
} else {
$out[1][$i] = intval($out[1][$i]);
}
$r += $out[1][$i];
}
# Choose an option at random
if ($r <= 0) {
return "";
}
$r = mt_rand(1, $r);
for ($i = 0; $i < $len; $i++) {
$r -= $out[1][$i];
if ($r <= 0) {
$input = $out[2][$i];
break;
}
}
# If running new parser, take the easy way out
if (defined('Parser::VERSION') && version_compare(Parser::VERSION, '1.6.1', '>')) {
return $parser->recursiveTagParse($input);
}
# Otherwise, create new parser to handle rendering
$localParser = new Parser();
# Initialize defaults, then copy info from parent parser
$localParser->clearState();
$localParser->mTagHooks = $parser->mTagHooks;
$localParser->mTemplates = $parser->mTemplates;
$localParser->mTemplatePath = $parser->mTemplatePath;
$localParser->mFunctionHooks = $parser->mFunctionHooks;
$localParser->mFunctionSynonyms = $parser->mFunctionSynonyms;
# Render the chosen option
$output = $localParser->parse($input, $parser->mTitle, $parser->mOptions, false, false);
return $output->getText();
}
示例15: renderTag
public function renderTag($input, $params, Parser $parser, PPFrame $frame)
{
//$this->frame = $frame;
global $wgRTEParserEnabled, $wgHTTPProxy, $wgFogbugzAPIConfig, $wgCaptchaDirectory, $wgCaptchaDirectoryLevels, $wgStylePath;
if (!isset($params['id'])) {
return '';
}
$output = Xml::openElement('span', array('class' => 'fogbugz_tck', 'data-id' => $parser->recursiveTagParse($params['id'], $frame)));
//$output .= $input;
$output .= Xml::openElement('img', array('src' => $wgStylePath . '/common/images/ajax.gif'));
$output .= Xml::closeElement('span');
$data = array('wikitext' => RTEData::get('wikitext', self::$mWikitextIdx), 'placeholder' => 1);
//$dataIdx = RTEData::put('data', $data);
//$output = RTEData::addIdxToTag($dataIdx, $output);
$output .= F::build('JSSnippets')->addToStack(array('/extensions/wikia/FogbugzTag/js/FogbugzTag.js'));
return $output;
}