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


PHP Parser::uniqPrefix方法代码示例

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


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

示例1: renderTag

 /**
  * @param $input
  * @param $args
  * @param Parser $parser
  * @return string
  */
 public function renderTag($input, $args, Parser $parser)
 {
     wfProfileIn(__METHOD__);
     // there must be something between tags
     if (empty($input)) {
         wfProfileOut(__METHOD__);
         return '';
     }
     // we support only the Oasis skin for this feature
     if (!F::app()->checkSkin('oasis')) {
         wfProfileOut(__METHOD__);
         return '';
     }
     $widgetType = 'Widget' . Sanitizer::escapeId($input, 0);
     // try to load widget
     if ($this->load($widgetType) == false) {
         wfProfileOut(__METHOD__);
         return '';
     }
     // seek for style attribute (RT #19092)
     if (isset($args['style'])) {
         $style = ' style="' . htmlspecialchars($args['style']) . '"';
         unset($args['style']);
     } else {
         $style = '';
     }
     // create array for getParams method of widget framework
     $id = 'widget_' . $this->count++;
     $widget = array('type' => $widgetType, 'id' => $id, 'param' => $args, 'widgetTag' => true);
     // configure widget
     $widgetParams = $this->getParams($widget);
     // set additional params
     $widgetParams['skinname'] = $this->skinname;
     // inform widget he's rendered by WidgetTag
     $widgetParams['_widgetTag'] = true;
     // try to display it using widget function
     $output = $widgetType($id, $widgetParams);
     // Add any required javascript and CSS for the widget
     #$output .= $this->getAssets($widget);
     // wrap widget content
     $output = $this->wrap($widget, $output);
     // wrap widget HTML
     $output = "<div class=\"widgetTag\"{$style}>{$output}</div>";
     // use markers to avoid RT #20855 when widget' HTML is multiline
     $marker = $parser->uniqPrefix() . "-WIDGET-{$this->count}-";
     $this->markers[$marker] = $output;
     wfProfileOut(__METHOD__);
     return $marker;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:55,代码来源:WidgetTagRenderer.class.php

示例2: 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;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:45,代码来源:LyricFindParserController.class.php

示例3: displaytitle

 /**
  * Override the title of the page when viewed, provided we've been given a
  * title which will normalise to the canonical title
  *
  * @param Parser $parser Parent parser
  * @param string $text Desired title text
  * @param string $uarg
  * @return string
  */
 public static function displaytitle($parser, $text = '', $uarg = '')
 {
     global $wgRestrictDisplayTitle;
     static $magicWords = null;
     if (is_null($magicWords)) {
         $magicWords = new MagicWordArray(array('displaytitle_noerror', 'displaytitle_noreplace'));
     }
     $arg = $magicWords->matchStartToEnd($uarg);
     // parse a limited subset of wiki markup (just the single quote items)
     $text = $parser->doQuotes($text);
     // remove stripped text (e.g. the UNIQ-QINU stuff) that was generated by tag extensions/whatever
     $text = preg_replace('/' . preg_quote($parser->uniqPrefix(), '/') . '.*?' . preg_quote(Parser::MARKER_SUFFIX, '/') . '/', '', $text);
     // list of disallowed tags for DISPLAYTITLE
     // these will be escaped even though they are allowed in normal wiki text
     $bad = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr', 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rtc', 'rp', 'br');
     // disallow some styles that could be used to bypass $wgRestrictDisplayTitle
     if ($wgRestrictDisplayTitle) {
         $htmlTagsCallback = function (&$params) {
             $decoded = Sanitizer::decodeTagAttributes($params);
             if (isset($decoded['style'])) {
                 // this is called later anyway, but we need it right now for the regexes below to be safe
                 // calling it twice doesn't hurt
                 $decoded['style'] = Sanitizer::checkCss($decoded['style']);
                 if (preg_match('/(display|user-select|visibility)\\s*:/i', $decoded['style'])) {
                     $decoded['style'] = '/* attempt to bypass $wgRestrictDisplayTitle */';
                 }
             }
             $params = Sanitizer::safeEncodeTagAttributes($decoded);
         };
     } else {
         $htmlTagsCallback = null;
     }
     // only requested titles that normalize to the actual title are allowed through
     // if $wgRestrictDisplayTitle is true (it is by default)
     // mimic the escaping process that occurs in OutputPage::setPageTitle
     $text = Sanitizer::normalizeCharReferences(Sanitizer::removeHTMLtags($text, $htmlTagsCallback, array(), array(), $bad));
     $title = Title::newFromText(Sanitizer::stripAllTags($text));
     if (!$wgRestrictDisplayTitle || $title instanceof Title && !$title->hasFragment() && $title->equals($parser->mTitle)) {
         $old = $parser->mOutput->getProperty('displaytitle');
         if ($old === false || $arg !== 'displaytitle_noreplace') {
             $parser->mOutput->setDisplayTitle($text);
         }
         if ($old !== false && $old !== $text && !$arg) {
             $converter = $parser->getConverterLanguage()->getConverter();
             return '<span class="error">' . wfMessage('duplicate-displaytitle', $converter->markNoConversion(wfEscapeWikiText($old)), $converter->markNoConversion(wfEscapeWikiText($text)))->inContentLanguage()->text() . '</span>';
         }
     }
     return '';
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:58,代码来源:CoreParserFunctions.php

示例4: onClearState

 /**
  * @param Parser $parser
  * @return bool
  */
 public function onClearState(&$parser)
 {
     // hack marker prefixes to get identical output
     if (!isset($this->dtUniqPrefix)) {
         $this->dtUniqPrefix = $parser->uniqPrefix();
     } else {
         $parser->mUniqPrefix = $this->dtUniqPrefix;
     }
     return true;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:14,代码来源:ParserDiffTest.php


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