本文整理汇总了PHP中Parser::getOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP Parser::getOutput方法的具体用法?PHP Parser::getOutput怎么用?PHP Parser::getOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser::getOutput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Renrder the survey div.
*
* @since 0.1
*
* @param Parser $parser
*
* @return string
*/
public function render(Parser $parser)
{
static $loadedJs = false;
if (!$loadedJs) {
$parser->getOutput()->addModules('ext.survey.tag');
$parser->getOutput()->addHeadItem(Skin::makeVariablesScript(array('wgSurveyDebug' => SurveySettings::get('JSDebug'))));
}
return Html::element('span', $this->parameters, $this->contents);
}
示例2: fmRender
public static function fmRender($input, array $args, Parser $parser, PPFrame $frame)
{
global $wgResourceModules;
global $wgOut;
$wgOut->addModules('ext.FinancialMathematics');
$parser->getOutput()->addModules('ext.FinancialMathematics');
$xml = simplexml_load_string($input);
if (!$xml) {
$_out = "<span class='fin-math-warning'>" . wfMessage('fm-error-xml')->text() . print_r($input, 1) . "</span>";
}
if ($xml) {
//http://stackoverflow.com/questions/834875/recursive-cast-from-simplexmlobject-to-array
$x = json_decode(json_encode((array) simplexml_load_string($input)), 1);
$m = new CT1_Concept_All();
$result = $m->get_controller($x);
if (isset($result['warning'])) {
$_out = "<span class='fin-math-warning'>" . $result['warning'] . "</span>";
} else {
if (isset($result['formulae'])) {
$_out = $result['formulae'];
}
}
}
if (!isset($_out)) {
$_out = "<span class='fin-math-warning'>" . wfMessage('fm-error-no-output')->text() . "</span>";
}
//From https://www.mediawiki.org/wiki/QINU_fix
$localParser = new Parser();
$output = FinancialMathematicsHooks::renderRawHTML($localParser, $_out);
return $output;
}
示例3: renderGallery
/**
* Parser hook handler for {{#articletype}}
*
* @param Parser $parser : Parser instance available to render
* wikitext into html, or parser methods.
*
* @return string: HTML to insert in the page.
*/
public static function renderGallery($input, array $args, Parser $parser, PPFrame $frame)
{
$parser->getOutput()->addModules('ext.promoter.gallery');
$pageName = $parser->getTitle()->getText();
try {
$renderedAds = array();
$adChooser = new AdChooser($pageName, !$parser->getUser()->isLoggedIn());
$ads = $adChooser->getAds();
foreach ($ads as $ad) {
$renderedAds[] = Ad::fromName($ad['name'])->renderHtml();
}
} catch (AdCampaignExistenceException $e) {
wfDebugLog('Promoter', $e->getMessage());
//@todo i18n
return '<span class="error">No campaign for this page</span>';
} catch (MWException $e) {
wfDebugLog('Promoter', $e->getMessage());
return '<span class="error text-danger">An error occurred [' . $e->getMessage() . ']</span>';
}
$html = '<div class="promotion-gallery hidden hidden-print">' . '<h5 class="sr-only">זוהי גלריה המקדמת ערכים שונים באתר.</h5>' . '<div class="gallery-controls">' . '<span class="sr-only">בכל רגע מוצגות 3 ידיעות בגלריה. ניתן להציג ידיעה נוספת או לחזור לאחור באמצעות הכפתורים הבאים, או באמצעות מקשי החיצים כאשר הפוקוס הוא על הגלריה</span>' . '<a href="#" class="owl-prev"><span class="fa fa-chevron-right fa-lg" title="הקודם"></span><span class="sr-only">הצגת הידיעה הקודמת</span></a>' . '<a href="#" class="owl-next"><span class="fa fa-chevron-left fa-lg" title="הבא"></span><span class="sr-only">הצגת הידיעה הבאה</span></a>' . '</div>';
if ($args['title']) {
$html .= '<div class="header">' . $args['title'] . '</div>';
}
$html .= '<div class="owl-carousel clearfix" tabindex="0">' . implode('', $renderedAds) . '</div>' . '</div>';
return $html;
}
示例4: onSparkRender
/**
* @since 0.1
*
* @param mixed $input
* @param array $args
* @param Parser $parser
* @param PPFrame $frame
*/
public static function onSparkRender($input, array $args, Parser $parser, $frame = null)
{
global $wgVersion;
global $wgOut;
global $egSparkScriptJquery;
global $egSparkScriptJquerySpark;
static $loadedJs = false;
if (version_compare($wgVersion, '1.17', '<')) {
// We do not have resource loader
if (!$loadedJs) {
$wgOut->addScript('<script src="' . $egSparkScriptJquery . '" type="text/javascript"></script>');
wfDebugLog('spark', "AddScript:" . ' <script src="' . $egSparkScriptJquery . '" type="text/javascript"></script>');
//echo "AddScript:".' <script src="'.$egSparkScriptJquery.'" type="text/javascript"></script>';
$wgOut->addScript('<script src="' . $egSparkScriptJquerySpark . '" type="text/javascript"></script>');
wfDebugLog('spark', "AddScript:" . ' <script src="' . $egSparkScriptJquerySpark . '" type="text/javascript"></script>');
//echo "AddScript:".' <script src="'.$egSparkScriptJquerySpark.'" type="text/javascript"></script>';
$loadedJs = true;
}
} else {
// We have resource loader
// If we have resource loader
if (!$loadedJs) {
$parser->getOutput()->addModules('ext.spark');
$loadedJs = true;
}
}
$tag = new SparkTag($args, $input);
// PPFrame maybe not existing
return $tag->render($parser, $frame);
}
示例5: render
/**
* @param Parser $parser
* @return array
*/
public static function render($parser)
{
$html = '';
$html .= $parser->insertStripItem('<a href="#" class="custom-watchlist-wrapper" id="add-to-watchlist"></a>');
$parser->getOutput()->addModules('ext.customwatchlist.foo');
return array($html, 'markerType' => 'nowiki');
}
示例6: 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;
}
示例7: clearStorage
/**
* Clear all stored data for a given parser.
*
* @param Parser $parser
*/
public static function clearStorage(Parser $parser)
{
$output = $parser->getOutput();
$title = $parser->getTitle();
if (!isset($output) || !isset($title)) {
return;
}
$output->mSMWData = new SMWSemanticData(new SMWDIWikiPage($title->getDBkey(), $title->getNamespace(), $title->getInterwiki()));
}
示例8: renderFentt
static function renderFentt($input, array $args, Parser $parser, PPFrame $frame)
{
if (!self::$css_module_added) {
// Tell ResourceLoader that we need our css module
$parser->getOutput()->addModuleStyles('ext.FenTT');
self::$css_module_added = true;
}
return FenTT::renderFentt($input, $args);
}
示例9: 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 '';
}
示例10: sprintbtn
/**
* @param Parser $parser
* @return string
*/
public static function sprintbtn($parser)
{
$html = '';
$title = $parser->getTitle();
$link = $title->getFullURL('printable=yes');
$link = '#';
$parser->getOutput()->addModules('ext.stools.foo');
$html .= $parser->insertStripItem('<a id="print-button" href="' . $link . '" type="button" class="btn btn-primary"><i class="fa fa-print"></i> ' . wfMessage('stools-button-print')->plain() . '</a>');
return $html;
}
示例11: renderPlaceholder
/**
* @desc Based on parser tag arguments validation parsers an error or placeholder
*
* @param String $input
* @param Array $args
* @param Parser $parser
* @param PPFrame $frame
*
* @return String
*/
public function renderPlaceholder($input, array $args, Parser $parser, PPFrame $frame)
{
// register resource loader module dependencies for map parser tag
// done separately for CSS and JS, so CSS will go to top of the page
$parser->getOutput()->addModuleStyles('ext.wikia.WikiaMaps.ParserTag');
$parser->getOutput()->addModuleScripts('ext.wikia.WikiaMaps.ParserTag');
$errorMessage = '';
$params = $this->sanitizeParserTagArguments($args);
$isValid = $this->validateParseTagParams($params, $errorMessage);
if ($isValid) {
$params['map'] = $this->getMapObj($params['id']);
if (!empty($params['map']->id)) {
return $this->sendRequest('WikiaMapsParserTagController', 'mapThumbnail', $params);
} else {
$errorMessage = wfMessage('wikia-interactive-maps-parser-tag-error-no-map-found')->plain();
}
}
return $this->sendRequest('WikiaMapsParserTagController', 'parserTagError', ['errorMessage' => $errorMessage]);
}
示例12: renderVote
/**
* Callback function for registerParserHook.
*
* @param string $input User-supplied input, unused
* @param array $args User-supplied arguments
* @param Parser $parser Instance of Parser, unused
* @return string HTML
*/
public static function renderVote($input, $args, $parser)
{
global $wgOut, $wgUser;
wfProfileIn(__METHOD__);
// Disable parser cache (sadly we have to do this, because the caching is
// messing stuff up; we want to show an up-to-date rating instead of old
// or totally wrong rating, i.e. another page's rating...)
$parser->disableCache();
// Add CSS & JS
// In order for us to do this *here* instead of having to do this in
// registerParserHook(), we must've disabled parser cache
$parser->getOutput()->addModuleStyles('ext.voteNY.styles');
if ($wgUser->isAllowed('voteny')) {
$parser->getOutput()->addModules('ext.voteNY.scripts');
}
// Define variable - 0 means that we'll get that green voting box by default
$type = 0;
// Determine what kind of a voting gadget the user wants: a box or pretty stars?
if (preg_match("/^\\s*type\\s*=\\s*(.*)/mi", $input, $matches)) {
$type = htmlspecialchars($matches[1]);
} elseif (!empty($args['type'])) {
$type = intval($args['type']);
}
$output = null;
$title = $wgOut->getTitle();
if ($title) {
$articleID = $title->getArticleID();
switch ($type) {
case 0:
$vote = new Vote($articleID);
break;
case 1:
$vote = new VoteStars($articleID);
break;
default:
$vote = new Vote($articleID);
}
$output = $vote->display();
}
wfProfileOut(__METHOD__);
return $output;
}
示例13: renderTabber
/**
* Renders the necessary HTML for a <tabber> tag.
*
* @access public
* @param string The input URL between the beginning and ending tags.
* @param array Array of attribute arguments on that beginning tag.
* @param object Mediawiki Parser Object
* @param object Mediawiki PPFrame Object
* @return string HTML
*/
public static function renderTabber($input, array $args, Parser $parser, PPFrame $frame)
{
$parser->getOutput()->addModules('ext.Tabber');
$key = md5($input);
$arr = explode("|-|", $input);
$htmlTabs = '';
foreach ($arr as $tab) {
$htmlTabs .= self::buildTab($tab, $parser);
}
$HTML = '<div id="tabber-' . $key . '" class="tabber">' . $htmlTabs . "</div>";
return $HTML;
}
示例14: addSpecificMapHTML
/**
* @see MapsBaseMap::addSpecificMapHTML()
*
*/
public function addSpecificMapHTML(Parser $parser)
{
global $egValidatorErrorLevel;
MapsGoogleMaps::addOverlayOutput($this->output, $this->mapName, $this->overlays, $this->controls);
if ($egValidatorErrorLevel >= Validator_ERRORS_WARN) {
$couldNotGeocodeMsg = Xml::escapeJsString(wfMsg('ukgeocoding_couldNotGeocode'));
$showErrorJs = "document.getElementById( '{$this->mapName}_errors' ).innerHTML = '{$couldNotGeocodeMsg}';";
} else {
$showErrorJs = '';
}
$this->output .= Html::element('div', array('id' => $this->mapName, 'style' => "width: {$this->width}; height: {$this->height}; background-color: #cccccc;"), wfMsg('maps-loading-map')) . "<div id='{$this->mapName}_errors'></div>";
$parser->getOutput()->addHeadItem(Html::inlineScript(<<<EOT
\$(function() {
\tvar map = initializeGoogleMap('{$this->mapName}',
\t\t{
\t\tlat: 0,
\t\tlon: 0,
\t\tzoom: {$this->zoom},
\t\ttype: {$this->type},
\t\ttypes: [{$this->types}],
\t\tcontrols: [{$this->controls}],
\t\tscrollWheelZoom: {$this->autozoom}
\t\t},
\t\t[]
\t);
\tvar localSearch = new GlocalSearch();
\tfunction usePointFromPostcode( marker, callbackFunction ) {
\t\tlocalSearch.setSearchCompleteCallback( null,
\t\t\tfunction() {
\t\t\t\tif ( localSearch.results[0] ) {
\t\t\t\t\tcallbackFunction(new GLatLng(localSearch.results[0].lat, localSearch.results[0].lng), marker);
\t\t\t\t} else {
\t\t\t\t\t{$showErrorJs}
\t\t\t\t}
\t\t\t}
\t\t);
\t\tlocalSearch.execute(marker.location + ", UK");
\t}
\tfunction updateGoogleMap(point, marker) {
\t\tmap.addOverlay(createGMarker(point, marker.title, marker.label, marker.icon));
\t\tbounds.extend(point);
\t\tmap.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
\t\tif({$this->zoom}!=null) map.setZoom({$this->zoom});
\t}
\tvar markers = [{$this->markerString}];
\tvar bounds = new GLatLngBounds();
\tfor(i in markers) {
\t\tusePointFromPostcode(markers[i], updateGoogleMap);
\t}
});\t\t\t\t
EOT
));
}
示例15: render
/**
* Call controller view to render <lyricfind> parser hook
*
* Add an article to appriopriate category
*
* Example:
*
* <lyricfind
* artist="Paradise Lost"
* album="Draconian Times"
* additionalAlbums="Draconian Times MMXI"
* song="Forever Failure"
* songwriter="Nick Holmes"
* publisher="Music for Nations"
* amgid=28750800>
* Understand procedure, understand war
* ...
* </lyricfind>
*
* @param $content string tag content
* @param array $arguments tag atribbutes
* @param Parser $parser parser instance
* @return string rendered content
*/
public static function render($content, array $arguments, Parser $parser)
{
wfProfileIn(__METHOD__);
$data = array_merge($arguments, ['lyric' => self::encodeLyric($content)]);
// RingTone URL
$data['ringtoneUrl'] = 'http://www.ringtonematcher.com/co/ringtonematcher/02/noc.asp' . http_build_query(['sid' => 'WILWros', 'artist' => $data['artist'], 'song' => $data['song']]);
// merge albums data
$data['albums'] = array($data['album']);
if (isset($data['additionalalbums']) && $data['additionalalbums'] != '') {
$data['albums'] = array_merge($data['albums'], explode(',', $data['additionalalbums']));
}
$html = F::app()->renderPartial('LyricFindParser', 'content', $data);
// add a category + CSS and JavaScript
$parser->getOutput()->addCategory(self::CATEGORY, self::CATEGORY);
$parser->getOutput()->addModules('ext.lyrics.lyricbox');
// generate a marker
$marker = $parser->uniqPrefix() . '-lyricfind-' . count(self::$markers) . "-";
self::$markers[$marker] = $html;
wfProfileOut(__METHOD__);
return $marker;
}