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


PHP Sanitizer::removeHTMLtags方法代码示例

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


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

示例1: parseWikitext

 protected function parseWikitext($title, $newRevId)
 {
     $apiParams = array('action' => 'parse', 'page' => $title->getPrefixedDBkey(), 'oldid' => $newRevId, 'prop' => 'text|revid|categorieshtml|displaytitle|modules|jsconfigvars');
     $api = new ApiMain(new DerivativeRequest($this->getRequest(), $apiParams, false), true);
     $api->execute();
     if (defined('ApiResult::META_CONTENT')) {
         $result = $api->getResult()->getResultData(null, array('BC' => array(), 'Types' => array(), 'Strip' => 'all'));
     } else {
         $result = $api->getResultData();
     }
     $content = isset($result['parse']['text']['*']) ? $result['parse']['text']['*'] : false;
     $categorieshtml = isset($result['parse']['categorieshtml']['*']) ? $result['parse']['categorieshtml']['*'] : false;
     $links = isset($result['parse']['links']) ? $result['parse']['links'] : array();
     $revision = Revision::newFromId($result['parse']['revid']);
     $timestamp = $revision ? $revision->getTimestamp() : wfTimestampNow();
     $displaytitle = isset($result['parse']['displaytitle']) ? $result['parse']['displaytitle'] : false;
     $modules = isset($result['parse']['modules']) ? $result['parse']['modules'] : array();
     $jsconfigvars = isset($result['parse']['jsconfigvars']) ? $result['parse']['jsconfigvars'] : array();
     if ($content === false || strlen($content) && $revision === null) {
         return false;
     }
     if ($displaytitle !== false) {
         // Escape entities as in OutputPage::setPageTitle()
         $displaytitle = Sanitizer::normalizeCharReferences(Sanitizer::removeHTMLtags($displaytitle));
     }
     return array('content' => $content, 'categorieshtml' => $categorieshtml, 'basetimestamp' => $timestamp, 'starttimestamp' => wfTimestampNow(), 'displayTitleHtml' => $displaytitle, 'modules' => $modules, 'jsconfigvars' => $jsconfigvars);
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:27,代码来源:ApiVisualEditorEdit.php

示例2: setPageTitle

 /**
  * "Page title" means the contents of \<h1\>. It is stored as a valid HTML fragment.
  * This function allows good tags like \<sup\> in the \<h1\> tag, but not bad tags like \<script\>.
  * This function automatically sets \<title\> to the same content as \<h1\> but with all tags removed.
  * Bad tags that were escaped in \<h1\> will still be escaped in \<title\>, and good tags like \<i\> will be dropped entirely.
  *
  * @param $name string
  */
 public function setPageTitle($name)
 {
     # change "<script>foo&bar</script>" to "&lt;script&gt;foo&amp;bar&lt;/script&gt;"
     # but leave "<i>foobar</i>" alone
     $nameWithTags = Sanitizer::normalizeCharReferences(Sanitizer::removeHTMLtags($name));
     $this->mPagetitle = $nameWithTags;
     # change "<i>foo&amp;bar</i>" to "foo&bar"
     $this->setHTMLTitle(wfMsg('pagetitle', Sanitizer::stripAllTags($nameWithTags)));
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:17,代码来源:OutputPage.php

示例3: setOutputFormat

 /**
  * @see DataValue::setOutputFormat
  */
 public function setOutputFormat($formatstring)
 {
     if ($formatstring == $this->m_outformat) {
         return;
     }
     unset($this->trueCaption);
     unset($this->falseCaption);
     if ($formatstring === '') {
         // no format
         // (unsetting the captions is exactly the right thing here)
     } elseif (strtolower($formatstring) == '-') {
         // "plain" format
         $this->trueCaption = 'true';
         $this->falseCaption = 'false';
     } elseif (strtolower($formatstring) == 'x') {
         // X format
         $this->trueCaption = '<span style="font-family: sans-serif; ">X</span>';
         $this->falseCaption = '&nbsp;';
     } else {
         // format "truelabel, falselabel" (hopefully)
         $captions = explode(',', $formatstring, 2);
         if (count($captions) == 2) {
             // note: escaping needed to be safe; MW-sanitising would be an alternative
             $this->trueCaption = \Sanitizer::removeHTMLtags(trim($captions[0]));
             $this->falseCaption = \Sanitizer::removeHTMLtags(trim($captions[1]));
         }
         // else: no format that is recognised, ignore
     }
     // Localized version
     if (strpos($formatstring, 'LOCL') !== false) {
         $this->setLocalizedCaptions($formatstring);
     }
     $this->m_caption = $this->getStandardCaption(true);
     $this->m_outformat = $formatstring;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:38,代码来源:BooleanValue.php

示例4: 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
  * @return String
  */
 static function displaytitle($parser, $text = '')
 {
     global $wgRestrictDisplayTitle;
     #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', 'rp', 'br');
     #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, null, array(), array(), $bad));
     $title = Title::newFromText(Sanitizer::stripAllTags($text));
     if (!$wgRestrictDisplayTitle) {
         $parser->mOutput->setDisplayTitle($text);
     } elseif ($title instanceof Title && $title->getFragment() == '' && $title->equals($parser->mTitle)) {
         $parser->mOutput->setDisplayTitle($text);
     }
     return '';
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:30,代码来源:CoreParserFunctions.php

示例5: htmlspecialchars

    }
    // link icon
    if ($image['link'] != '') {
        $linkMsg = htmlspecialchars($image['link']);
    } else {
        $linkMsg = wfMsg('wikiaPhotoGallery-preview-add-link');
    }
    // image caption
    if ($image['caption'] != '') {
        $caption = Sanitizer::removeHTMLtags($image['caption']);
    } else {
        $caption = wfMsg('wikiaPhotoGallery-preview-add-caption');
    }
    // image description
    if ($image['linktext'] != '') {
        $linktext = Sanitizer::removeHTMLtags($image['linktext']);
    } else {
        $linktext = wfMsg('wikiaPhotoGallery-preview-add-description');
    }
    ?>
		<span class="WikiaPhotoGalleryPreviewSliderCaptionWrapper">
			<p class="WikiaPhotoGalleryPreviewSliderCaption WikiaPhotoGalleryPreviewItemCaption SliderTitle"><?php 
    echo $caption;
    ?>
</p>
			<p class="WikiaPhotoGalleryPreviewSliderCaption WikiaPhotoGalleryPreviewItemCaption SliderDescription"><?php 
    echo $linktext;
    ?>
</p>
			<p class="WikiaPhotoGalleryPreviewSliderCaption WikiaPhotoGalleryPreviewItemCaption SliderLink"><?php 
    echo $linkMsg;
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:sliderPreview.tmpl.php

示例6: testSelfClosingTag

 function testSelfClosingTag()
 {
     $GLOBALS['wgUseTidy'] = false;
     $this->assertEquals('<div>Hello world</div>', Sanitizer::removeHTMLtags('<div>Hello world</div />'), 'Self-closing closing div');
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:5,代码来源:SanitizerTest.php

示例7: srvus

 /**
  * strip/replaceVariables/unstrip for preprocessor regression testing
  */
 function srvus($text)
 {
     $text = $this->strip($text, $this->mStripState);
     $text = Sanitizer::removeHTMLtags($text);
     $text = $this->replaceVariables($text);
     $text = preg_replace('/<!--MWTEMPLATESECTION.*?-->/', '', $text);
     $text = $this->mStripState->unstripBoth($text);
     return $text;
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:12,代码来源:Parser_OldPP.php

示例8: 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(['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 = $parser->killMarkers($text);
     // list of disallowed tags for DISPLAYTITLE
     // these will be escaped even though they are allowed in normal wiki text
     $bad = ['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, [], [], $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>';
         } else {
             return '';
         }
     } else {
         $parser->addTrackingCategory('restricted-displaytitle-ignored');
         $converter = $parser->getConverterLanguage()->getConverter();
         return '<span class="error">' . wfMessage('restricted-displaytitle', $converter->markNoConversion(wfEscapeWikiText($text)))->inContentLanguage()->text() . '</span>';
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:63,代码来源:CoreParserFunctions.php

示例9: onInternalParseBeforeLinks

 static function onInternalParseBeforeLinks(Parser &$parser, &$text)
 {
     $varStore = self::get($parser);
     // only do this if '#var_final' was used
     if ($varStore->mFinalizedVarsStripState === null) {
         return true;
     }
     /*
      * all vars are final now, check whether requested vars can be inserted for '#final_var' or
      * if the default has to be inserted. In any case, adjust the strip item value
      */
     foreach ($varStore->mFinalizedVars as $stripStateId => $varName) {
         $varVal = $varStore->getVarValue($varName, '');
         if ($varVal !== '') {
             // replace strip item value with final variables value or registered default:
             //$varStore->mFinalizedVarsStripState->general->setPair( $stripStateId, $varVal );
             $varStore->stripStatePair($stripStateId, $varVal);
         }
     }
     /**
      * Unstrip all '#var_final' strip-markers with their final '#var' or default values.
      * This HAS to be done here and can't be done thru the normal unstrip process of MW.
      * This because the default value as well as the variables value stil have to be rendered properly since they
      * may contain links or even category links. On the other hand, they can't be parsed with Parser::recursiveTagParse()
      * since this would parse wiki templates and functions which are intended as normal text, kind of similar to
      * returning a parser functions value with 'noparse' => true.
      * Also, there is no way to expand the '#var_final' default value here, just if needed, since the output could be an
      * entirely different, e.g. if variables are used.
      * This method also takes care of recursive '#var_final' calls (within the default value) quite well.
      */
     $text = $varStore->mFinalizedVarsStripState->unstripGeneral($text);
     /*
      * Sanitize the whole thing, otherwise HTML and JS code injection would be possible.
      * Basically the same is happening in Parser::internalParse() right before 'InternalParseBeforeLinks' hook is called.
      */
     $text = Sanitizer::removeHTMLtags($text, array(&$parser, 'attributeStripCallback'), false, array_keys($parser->mTransparentTagHooks));
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:38,代码来源:Variables.php

示例10: 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
  * @return String
  */
 static function displaytitle($parser, $text = '')
 {
     global $wgRestrictDisplayTitle;
     // 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', '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) {
         $parser->mOutput->setDisplayTitle($text);
     } elseif ($title instanceof Title && !$title->hasFragment() && $title->equals($parser->mTitle)) {
         $parser->mOutput->setDisplayTitle($text);
     }
     return '';
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:47,代码来源:CoreParserFunctions.php

示例11: testRemoveHTMLtags

 /**
  * @dataProvider dataRemoveHTMLtags
  * @covers Sanitizer::removeHTMLtags
  */
 public function testRemoveHTMLtags($input, $output, $msg = null)
 {
     MWTidy::setInstance(false);
     $this->assertEquals($output, Sanitizer::removeHTMLtags($input), $msg);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:9,代码来源:SanitizerTest.php

示例12: braceSubstitution


//.........这里部分代码省略.........
                 $eqpos = strpos($arg, '=');
                 if ($eqpos === false) {
                     $assocArgs[$index++] = $arg;
                 } else {
                     $name = trim(substr($arg, 0, $eqpos));
                     $value = trim(substr($arg, $eqpos + 1));
                     if ($value === false) {
                         $value = '';
                     }
                     if ($name !== false) {
                         $assocArgs[$name] = $value;
                     }
                 }
             }
             # Add a new element to the templace recursion path
             $this->mTemplatePath[$part1] = 1;
         }
         if (!$noparse) {
             # If there are any <onlyinclude> tags, only include them
             if (in_string('<onlyinclude>', $text) && in_string('</onlyinclude>', $text)) {
                 preg_match_all('/<onlyinclude>(.*?)\\n?<\\/onlyinclude>/s', $text, $m);
                 $text = '';
                 foreach ($m[1] as $piece) {
                     $text .= $piece;
                 }
             }
             # Remove <noinclude> sections and <includeonly> tags
             $text = preg_replace('/<noinclude>.*?<\\/noinclude>/s', '', $text);
             $text = strtr($text, array('<includeonly>' => '', '</includeonly>' => ''));
             if ($this->ot['html'] || $this->ot['pre']) {
                 # Strip <nowiki>, <pre>, etc.
                 $text = $this->strip($text, $this->mStripState);
                 if ($this->ot['html']) {
                     $text = Sanitizer::removeHTMLtags($text, array(&$this, 'replaceVariables'), $assocArgs);
                 } elseif ($this->ot['pre'] && $this->mOptions->getRemoveComments()) {
                     $text = Sanitizer::removeHTMLcomments($text);
                 }
             }
             $text = $this->replaceVariables($text, $assocArgs);
             # If the template begins with a table or block-level
             # element, it should be treated as beginning a new line.
             if (!$piece['lineStart'] && preg_match('/^({\\||:|;|#|\\*)/', $text)) {
                 $text = "\n" . $text;
             }
         } elseif (!$noargs) {
             # $noparse and !$noargs
             # Just replace the arguments, not any double-brace items
             # This is used for rendered interwiki transclusion
             $text = $this->replaceVariables($text, $assocArgs, true);
         }
     }
     # Prune lower levels off the recursion check path
     $this->mTemplatePath = $lastPathLevel;
     if ($found && !$this->incrementIncludeSize('post-expand', strlen($text))) {
         # Error, oversize inclusion
         $text = $linestart . "[[{$titleText}]]<!-- WARNING: template omitted, post-expand include size too large -->";
         $noparse = true;
         $noargs = true;
     }
     if (!$found) {
         wfProfileOut($fname);
         return $piece['text'];
     } else {
         wfProfileIn(__METHOD__ . '-placeholders');
         if ($isHTML) {
             # Replace raw HTML by a placeholder
开发者ID:puring0815,项目名称:OpenKore,代码行数:67,代码来源:Parser.php

示例13: getLongHTMLText

 /**
  * Display the "long" value in HTML. This behaves largely like
  * getLongWikiText() but does not embed images.
  *
  * @param $linker mixed if a Linker is given, the result will be linked
  * @return string
  */
 public function getLongHTMLText($linker = null)
 {
     if ($this->m_fragment !== '') {
         $this->linkAttributes['class'] = 'smw-subobject-entity';
     }
     // init the Title object, may reveal hitherto unnoticed errors:
     if (!is_null($linker) && $this->m_outformat != '-') {
         $this->getTitle();
     }
     if (!$this->isValid()) {
         return $this->getErrorText();
     }
     if ($linker === null || $linker === false || $this->m_outformat == '-') {
         return \Sanitizer::removeHTMLtags($this->getWikiValue());
     } elseif ($this->getNamespace() == NS_MEDIA) {
         // this extra case is really needed
         return $linker->makeMediaLinkObj($this->getTitle(), \Sanitizer::removeHTMLtags($this->getLongCaptionText()));
     }
     // all others use default linking, no embedding of images here
     return $linker->link($this->getTitle(), \Sanitizer::removeHTMLtags($this->getLongCaptionText()), $this->linkAttributes);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:28,代码来源:SMW_DV_WikiPage.php

示例14: testSrvus

 /**
  * strip/replaceVariables/unstrip for preprocessor regression testing
  */
 function testSrvus($text, $title, $options, $outputType = self::OT_HTML)
 {
     $this->clearState();
     if (!$title instanceof Title) {
         $title = Title::newFromText($title);
     }
     $this->mTitle = $title;
     $this->mOptions = $options;
     $this->setOutputType($outputType);
     $text = $this->replaceVariables($text);
     $text = $this->mStripState->unstripBoth($text);
     $text = Sanitizer::removeHTMLtags($text);
     return $text;
 }
开发者ID:josephdye,项目名称:wikireader,代码行数:17,代码来源:Parser.php

示例15: renderSlider

 /**
  * Return a HTML representation of the image slider
  *
  * @author Jakub Kurcek
  */
 private function renderSlider()
 {
     wfProfileIn(__METHOD__);
     // do not render empty sliders
     if (empty($this->mFiles)) {
         wfProfileOut(__METHOD__);
         return '';
     }
     $orientation = $this->getParam('orientation');
     // setup image serving for main images and navigation thumbnails
     if ($orientation == 'mosaic') {
         $imagesDimensions = array('w' => WikiaPhotoGalleryHelper::WIKIA_GRID_SLIDER_MOSAIC_MIN_IMG_WIDTH, 'h' => WikiaPhotoGalleryHelper::SLIDER_MOSAIC_MIN_IMG_HEIGHT);
         $sliderClass = 'mosaic';
         $thumbDimensions = array("w" => WikiaPhotoGalleryHelper::WIKIA_GRID_THUMBNAIL_MAX_WIDTH, "h" => 100);
     } else {
         $imagesDimensions = array('w' => WikiaPhotoGalleryHelper::SLIDER_MIN_IMG_WIDTH, 'h' => WikiaPhotoGalleryHelper::SLIDER_MIN_IMG_HEIGHT);
         if ($orientation == 'right') {
             $sliderClass = 'vertical';
             $thumbDimensions = array("w" => 110, "h" => 50);
         } else {
             $sliderClass = 'horizontal';
             $thumbDimensions = array("w" => 90, "h" => 70);
         }
     }
     $out = array();
     $sliderImageLimit = $orientation == 'mosaic' ? 5 : 4;
     foreach ($this->mFiles as $p => $pair) {
         /**
          * @var $nt Title
          * @var $text String
          * @var $link String
          */
         $nt = $pair[0];
         $text = $pair[1];
         $link = $pair[2];
         $linkText = $this->mData['images'][$p]['linktext'];
         $shortText = $this->mData['images'][$p]['shorttext'];
         $time = $descQuery = false;
         // parse link (RT #142515)
         $linkAttribs = $this->parseLink($nt->getLocalUrl(), $nt->getText(), $link);
         wfRunHooks('BeforeGalleryFindFile', array(&$this, &$nt, &$time, &$descQuery));
         $file = wfFindFile($nt, $time);
         if (is_object($file) && $nt->getNamespace() == NS_FILE) {
             list($adjWidth, $adjHeight) = $this->fitWithin($file, $imagesDimensions);
             if (F::app()->checkSkin('wikiamobile')) {
                 $imageUrl = wfReplaceImageServer($file->getUrl(), $file->getTimestamp());
             } else {
                 $imageUrl = $this->resizeURL($file, $imagesDimensions);
             }
             // generate navigation thumbnails
             $thumbUrl = $this->cropURL($file, $thumbDimensions);
             // Handle videos
             $videoHtml = false;
             $videoPlayButton = false;
             $navClass = '';
             if (WikiaFileHelper::isFileTypeVideo($file)) {
                 // Get HTML for main video image
                 $htmlParams = array('file-link' => true, 'linkAttribs' => array('class' => 'wikiaPhotoGallery-slider force-lightbox'));
                 $videoHtml = $file->transform(array('width' => $imagesDimensions['w']))->toHtml($htmlParams);
                 // Get play button overlay for little video thumb
                 $videoPlayButton = $this->videoPlayButton;
                 $navClass = 'xxsmall video-thumbnail';
             }
             $data = array('imageUrl' => $imageUrl, 'imageTitle' => Sanitizer::removeHTMLtags($text), 'imageName' => $file->getTitle()->getText(), 'imageKey' => $file->getTitle()->getDBKey(), 'imageShortTitle' => Sanitizer::removeHTMLtags($shortText), 'imageLink' => !empty($link) ? $linkAttribs['href'] : '', 'imageDescription' => Sanitizer::removeHTMLtags($linkText), 'imageThumbnail' => $thumbUrl, 'adjWidth' => $adjWidth, 'adjHeight' => $adjHeight, 'centerTop' => $imagesDimensions['h'] > $adjHeight ? intval(($imagesDimensions['h'] - $adjHeight) / 2) : 0, 'centerLeft' => $imagesDimensions['w'] > $adjWidth ? intval(($imagesDimensions['w'] - $adjWidth) / 2) : 0, 'videoHtml' => $videoHtml, 'videoPlayButton' => $videoPlayButton, 'navClass' => $navClass);
             if (F::app()->checkSkin('wikiamobile')) {
                 $origWidth = $file->getWidth();
                 $origHeight = $file->getHeight();
                 $size = WikiaMobileMediaService::calculateMediaSize($origWidth, $origHeight);
                 $thumb = $file->transform($size);
                 $imageAttribs = array('src' => wfReplaceImageServer($thumb->getUrl(), $file->getTimestamp()), 'width' => $size['width'], 'height' => $size['height']);
                 $imageParams = array('full' => $imageUrl);
                 if ($this->mParser) {
                     $this->mParser->replaceLinkHolders($text);
                 }
                 $data['mediaInfo'] = array('attributes' => $imageAttribs, 'parameters' => $imageParams, 'caption' => $text, 'noscript' => Xml::element('img', $imageAttribs, '', true));
             }
             $out[] = $data;
         }
         if (count($out) >= $sliderImageLimit) {
             break;
         }
     }
     $html = '';
     //check if we have something to show (images might not match required sizes)
     if (count($out)) {
         $template = new EasyTemplate(dirname(__FILE__) . '/templates');
         $template->set_vars(array('sliderClass' => $sliderClass, 'files' => $out, 'thumbDimensions' => $thumbDimensions, 'sliderId' => $this->mData['id'], 'imagesDimensions' => $imagesDimensions));
         if (F::app()->checkSkin('wikiamobile')) {
             $html = $template->render('renderWikiaMobileSlider');
         } else {
             if ($orientation == 'mosaic') {
                 $html = $template->render('renderMosaicSlider');
             } else {
                 $html = $template->render('renderSlider');
             }
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:WikiaPhotoGallery.class.php


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