/**
  * @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;
 }
 /**
  * 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;
 }
 /**
  * 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 '';
 }
 /**
  * @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;
 }