本文整理汇总了PHP中wfIsBadImage函数 的典型用法代码示例。如果您正苦于以下问题:PHP wfIsBadImage函数的具体用法?PHP wfIsBadImage怎么用?PHP wfIsBadImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfIsBadImage函数 的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: toHTML
function toHTML()
{
global $wgLang;
$sk = $this->getSkin();
$params = array('width' => $this->mWidths, 'height' => $this->mHeights);
$i = 0;
$images = array();
foreach ($this->mImages as $pair) {
$nt = $pair[0];
$text = $pair[1];
# Give extensions a chance to select the file revision for us
$time = $descQuery = false;
$img = wfFindFile($nt, $time);
if ($nt->getNamespace() != NS_FILE || !$img) {
# We're dealing with a non-image, spit out the name and be done with it.
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
} elseif ($this->mWidths && $this->mHeights && !($thumb = $img->transform($params))) {
# Error generating thumbnail.
} elseif ($img->getMediaType() != 'BITMAP' && $img->getMediaType() != 'DRAWING' && $img->getMediaType() != 'MEDIATYPE_BITMAP' && $img->getMediaType() != 'MEDIATYPE_DRAWING') {
# non image, ignore
} else {
array_push($images, $pair);
}
}
if (count($images) > 0) {
$this->mImages = $images;
$html = ImageGalleryOriginal::toHTML();
// remove links
$trace = debug_backtrace();
$caller = $trace[1];
if ($caller['class'] == 'ParserOriginal' || $caller['class'] == 'Parser') {
preg_match_all('/<a [^>]*>(.*?<img.*?)<\\/a>/s', $html, $matches);
if (count($matches)) {
$html = str_replace($matches[0], $matches[1], $html);
}
}
return $html;
}
return "";
}
开发者ID:kiwix, 项目名称:tools, 代码行数:41, 代码来源:ImageGallery.php
示例2: toHTML
/**
* Return a HTML representation of the image gallery
*
* For each image in the gallery, display
* - a thumbnail
* - the image name
* - the additional text provided when adding the image
* - the size of the image
*
* @return string
*/
function toHTML()
{
if ($this->mPerRow > 0) {
$maxwidth = $this->mPerRow * ($this->mWidths + $this->getAllPadding());
$oldStyle = isset($this->mAttribs['style']) ? $this->mAttribs['style'] : '';
# _width is ignored by any sane browser. IE6 doesn't know max-width
# so it uses _width instead
$this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle;
}
$attribs = Sanitizer::mergeAttributes(['class' => 'gallery mw-gallery-' . $this->mMode], $this->mAttribs);
$modules = $this->getModules();
if ($this->mParser) {
$this->mParser->getOutput()->addModules($modules);
$this->mParser->getOutput()->addModuleStyles('mediawiki.page.gallery.styles');
} else {
$this->getOutput()->addModules($modules);
$this->getOutput()->addModuleStyles('mediawiki.page.gallery.styles');
}
$output = Xml::openElement('ul', $attribs);
if ($this->mCaption) {
$output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
}
if ($this->mShowFilename) {
// Preload LinkCache info for when generating links
// of the filename below
$lb = new LinkBatch();
foreach ($this->mImages as $img) {
$lb->addObj($img[0]);
}
$lb->execute();
}
$lang = $this->getRenderLang();
# Output each image...
foreach ($this->mImages as $pair) {
/** @var Title $nt */
$nt = $pair[0];
$text = $pair[1];
# "text" means "caption" here
$alt = $pair[2];
$link = $pair[3];
$descQuery = false;
if ($nt->getNamespace() === NS_FILE) {
# Get the file...
if ($this->mParser instanceof Parser) {
# Give extensions a chance to select the file revision for us
$options = [];
Hooks::run('BeforeParserFetchFileAndTitle', [$this->mParser, $nt, &$options, &$descQuery]);
# Fetch and register the file (file title may be different via hooks)
list($img, $nt) = $this->mParser->fetchFileAndTitle($nt, $options);
} else {
$img = wfFindFile($nt);
}
} else {
$img = false;
}
$params = $this->getThumbParams($img);
// $pair[4] is per image handler options
$transformOptions = $params + $pair[4];
$thumb = false;
if (!$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: ' . ($this->getThumbPadding() + $this->mHeights) . 'px;">' . htmlspecialchars($nt->getText()) . '</div>';
if ($this->mParser instanceof Parser) {
$this->mParser->addTrackingCategory('broken-file-category');
}
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: ' . ($this->getThumbPadding() + $this->mHeights) . 'px;">' . Linker::linkKnown($nt, htmlspecialchars($nt->getText())) . '</div>';
} else {
$thumb = $img->transform($transformOptions);
if (!$thumb) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: ' . ($this->getThumbPadding() + $this->mHeights) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
/** @var MediaTransformOutput $thumb */
$vpad = $this->getVPad($this->mHeights, $thumb->getHeight());
$imageParameters = ['desc-link' => true, 'desc-query' => $descQuery, 'alt' => $alt, 'custom-url-link' => $link];
// In the absence of both alt text and caption, fall back on
// providing screen readers with the filename as alt text
if ($alt == '' && $text == '') {
$imageParameters['alt'] = $nt->getText();
}
$this->adjustImageParameters($thumb, $imageParameters);
Linker::processResponsiveImages($img, $thumb, $transformOptions);
# Set both fixed width and min-height.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="width: ' . $this->getThumbDivWidth($thumb->getWidth()) . 'px;">' . '<div style="margin:' . $vpad . 'px auto;">' . $thumb->toHtml($imageParameters) . '</div></div>';
// Call parser transform hook
/** @var MediaHandler $handler */
$handler = $img->getHandler();
//.........这里部分代码省略.........
开发者ID:claudinec, 项目名称:galan-wiki, 代码行数:101, 代码来源:TraditionalImageGallery.php
示例3: toHTML
/**
* Return a HTML representation of the image gallery
*
* For each image in the gallery, display
* - a thumbnail
* - the image name
* - the additional text provided when adding the image
* - the size of the image
*
*/
function toHTML()
{
global $wgLang;
$sk = $this->getSkin();
$attribs = Sanitizer::mergeAttributes(array('class' => 'gallery', 'cellspacing' => '0', 'cellpadding' => '0'), $this->mAttribs);
$s = Xml::openElement('table', $attribs);
if ($this->mCaption) {
$s .= "\n\t<caption>{$this->mCaption}</caption>";
}
$params = array('width' => $this->mWidths, 'height' => $this->mHeights);
$i = 0;
foreach ($this->mImages as $pair) {
$nt = $pair[0];
$text = $pair[1];
# Give extensions a chance to select the file revision for us
$time = $descQuery = false;
wfRunHooks('BeforeGalleryFindFile', array(&$this, &$nt, &$time, &$descQuery));
$img = wfFindFile($nt, $time);
if ($nt->getNamespace() != NS_FILE || !$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($nt->getText()) . '</div>';
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . $sk->makeKnownLinkObj($nt, htmlspecialchars($nt->getText())) . '</div>';
} elseif (!($thumb = $img->transform($params))) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
$vpad = floor((1.25 * $this->mHeights - $thumb->height) / 2) - 2;
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="padding: ' . $vpad . 'px 0; width: ' . ($this->mWidths + 30) . 'px;">' . '<div style="margin-left: auto; margin-right: auto; width: ' . $this->mWidths . 'px;">' . $thumb->toHtml(array('desc-link' => true, 'desc-query' => $descQuery)) . '</div></div>';
// Call parser transform hook
if ($this->mParser && $img->getHandler()) {
$img->getHandler()->parserTransformHook($this->mParser, $img);
}
}
//TODO
//$ul = $sk->makeLink( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}", $ut );
if ($this->mShowBytes) {
if ($img) {
$nb = wfMsgExt('nbytes', array('parsemag', 'escape'), $wgLang->formatNum($img->getSize()));
} else {
$nb = wfMsgHtml('filemissing');
}
$nb = "{$nb}<br />\n";
} else {
$nb = '';
}
$textlink = $this->mShowFilename ? $sk->makeKnownLinkObj($nt, htmlspecialchars($wgLang->truncate($nt->getText(), 20, '...'))) . "<br />\n" : '';
# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
# in version 4.8.6 generated crackpot html in its absence, see:
# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
if ($i % $this->mPerRow == 0) {
$s .= "\n\t<tr>";
}
$s .= "\n\t\t" . '<td><div class="gallerybox" style="width: ' . ($this->mWidths + 35) . 'px;">' . $thumbhtml . "\n\t\t\t" . '<div class="gallerytext">' . "\n" . $textlink . $text . $nb . "\n\t\t\t</div>" . "\n\t\t</div></td>";
if ($i % $this->mPerRow == $this->mPerRow - 1) {
$s .= "\n\t</tr>";
}
++$i;
}
if ($i % $this->mPerRow != 0) {
$s .= "\n\t</tr>";
}
$s .= "\n</table>";
return $s;
}
开发者ID:amjadtbssm, 项目名称:website, 代码行数:76, 代码来源:ImageGallery.php
示例4: replaceInternalLinks2
//.........这里部分代码省略.........
continue;
}
wfProfileOut(__METHOD__ . "-might_be_img");
}
$wasblank = $text == '';
if ($wasblank) {
$text = $link;
} else {
# Bug 4598 madness. Handle the quotes only if they come from the alternate part
# [[Lista d''e paise d''o munno]] -> <a href="...">Lista d''e paise d''o munno</a>
# [[Criticism of Harry Potter|Criticism of ''Harry Potter'']]
# -> <a href="Criticism of Harry Potter">Criticism of <i>Harry Potter</i></a>
$text = $this->doQuotes($text);
}
# Link not escaped by : , create the various objects
if ($noforce) {
# Interwikis
wfProfileIn(__METHOD__ . "-interwiki");
if ($iw && $this->mOptions->getInterwikiMagic() && $nottalk && Language::fetchLanguageName($iw, null, 'mw')) {
// XXX: the above check prevents links to sites with identifiers that are not language codes
# Bug 24502: filter duplicates
if (!isset($this->mLangLinkLanguages[$iw])) {
$this->mLangLinkLanguages[$iw] = true;
$this->mOutput->addLanguageLink($nt->getFullText());
}
$s = rtrim($s . $prefix);
$s .= trim($trail, "\n") == '' ? '' : $prefix . $trail;
wfProfileOut(__METHOD__ . "-interwiki");
continue;
}
wfProfileOut(__METHOD__ . "-interwiki");
if ($ns == NS_FILE) {
wfProfileIn(__METHOD__ . "-image");
if (!wfIsBadImage($nt->getDBkey(), $this->mTitle)) {
if ($wasblank) {
# if no parameters were passed, $text
# becomes something like "File:Foo.png",
# which we don't want to pass on to the
# image generator
$text = '';
} else {
# recursively parse links inside the image caption
# actually, this will parse them in any other parameters, too,
# but it might be hard to fix that, and it doesn't matter ATM
$text = $this->replaceExternalLinks($text);
$holders->merge($this->replaceInternalLinks2($text));
}
# cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
$s .= $prefix . $this->armorLinks($this->makeImage($nt, $text, $holders)) . $trail;
} else {
$s .= $prefix . $trail;
}
wfProfileOut(__METHOD__ . "-image");
continue;
}
if ($ns == NS_CATEGORY) {
wfProfileIn(__METHOD__ . "-category");
$s = rtrim($s . "\n");
# bug 87
if ($wasblank) {
$sortkey = $this->getDefaultSort();
} else {
$sortkey = $text;
}
$sortkey = Sanitizer::decodeCharReferences($sortkey);
$sortkey = str_replace("\n", '', $sortkey);
开发者ID:Tarendai, 项目名称:spring-website, 代码行数:67, 代码来源:Parser.php
示例5: toHTML
function toHTML()
{
global $wgLang, $mvDefaultAspectRatio;
$sk = $this->getSkin();
$attribs = Sanitizer::mergeAttributes(array('class' => 'gallery', 'cellspacing' => '0', 'cellpadding' => '0'), $this->mAttribs);
$s = Xml::openElement('table', $attribs);
if ($this->mCaption) {
$s .= "\n\t<caption>" . htmlspecialchars($this->mCaption) . "</caption>";
}
$params = array('width' => $this->mWidths, 'height' => $this->mHeights);
$i = 0;
$this->already_named_resource = array();
foreach ($this->mImages as $pair) {
$nt = $pair[0];
$text = $pair[1];
# Give extensions a chance to select the file revision for us
$time = false;
wfRunHooks('BeforeGalleryFindFile', array(&$this, &$nt, &$time));
$img = wfFindFile($nt, array('time' => $time));
if ($nt->getNamespace() == MV_NS_MVD || $nt->getNamespace() == MV_NS_STREAM || $nt->getNamespace() == MV_NS_SEQUENCE) {
// @@todo fix sequence embed
// $vpad = floor( ( 1.25*$this->mHeights - $thumb->height ) /2 ) - 2;
$mvTitle = new MV_Title($nt);
// remap MVD namespace links into the Stream view (so contextual metadata is present)
if ($nt->getNamespace() == MV_NS_MVD) {
$nt = Title::MakeTitle(MV_NS_STREAM, ucfirst($mvTitle->getStreamName()) . '/' . $mvTitle->getTimeRequest());
}
$vidH = round($this->mWidths * $mvDefaultAspectRatio);
$vidRes = $this->mWidths . 'x' . $vidH;
// print "img url: " . $mvTitle->getStreamImageURL();
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="padding: 4px 0; width: ' . htmlspecialchars($this->mWidths + 5) . 'px;">' . '<div style="margin-left: auto; margin-right: auto; width: ' . htmlspecialchars($this->mWidths) . 'px;">' . $sk->makeKnownLinkObj($nt, '<img title="' . htmlspecialchars($mvTitle->getStreamNameText()) . '"' . ' width="160" height="120" src="' . $mvTitle->getStreamImageURL('160x120') . '">') . '</div>' . '</div>' . '<span class="gallerytext" style="float:left">' . $sk->makeKnownLinkObj($nt, $mvTitle->getStreamNameText() . ' ' . $mvTitle->getTimeDesc()) . '</span>' . '</div>';
$nb = '';
$textlink = '';
} else {
if ($nt->getNamespace() != NS_IMAGE || !$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($nt->getText()) . '</div>';
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . $sk->makeKnownLinkObj($nt, htmlspecialchars($nt->getText())) . '</div>';
} elseif (!($thumb = $img->transform($params))) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
$vpad = floor((1.25 * $this->mHeights - $thumb->height) / 2) - 2;
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="padding: ' . htmlspecialchars($vpad) . 'px 0; width: ' . htmlspecialchars($this->mWidths + 30) . 'px;">' . '<div style="margin-left: auto; margin-right: auto; width: ' . htmlspecialchars($this->mWidths) . 'px;">' . $thumb->toHtml(array('desc-link' => true)) . '</div></div>';
// Call parser transform hook
if ($this->mParser && $img->getHandler()) {
$img->getHandler()->parserTransformHook($this->mParser, $img);
}
}
if ($this->mShowBytes) {
if ($img) {
$nb = wfMsgExt('nbytes', array('parsemag', 'escape'), $wgLang->formatNum($img->getSize()));
} else {
$nb = wfMsgHtml('filemissing');
}
$nb = "{$nb}<br />\n";
} else {
$nb = '';
}
$textlink = $this->mShowFilename ? $sk->makeKnownLinkObj($nt, htmlspecialchars($wgLang->truncate($nt->getText(), 20))) . "<br />\n" : '';
}
# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
# in version 4.8.6 generated crackpot html in its absence, see:
# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
if ($i % $this->mPerRow == 0) {
$s .= "\n\t<tr>";
}
$s .= "\n\t\t" . '<td><div class="gallerybox" style="width: ' . ($this->mWidths + 10) . 'px;">' . $thumbhtml . "\n\t\t\t" . '<div class="gallerytext">' . "\n" . $textlink . htmlspecialchars($text) . $nb . "\n\t\t\t</div>" . "\n\t\t</div></td>";
if ($i % $this->mPerRow == $this->mPerRow - 1) {
$s .= "\n\t</tr>";
}
++$i;
}
if ($i % $this->mPerRow != 0) {
$s .= "\n\t</tr>";
}
$s .= "\n</table>";
return $s;
}
开发者ID:realsoc, 项目名称:mediawiki-extensions, 代码行数:81, 代码来源:MV_ImageGallery.php
示例6: toHTML
/**
* Return a HTML representation of the image gallery
*
* For each image in the gallery, display
* - a thumbnail
* - the image name
* - the additional text provided when adding the image
* - the size of the image
*
*/
function toHTML()
{
global $wgLang, $wgIgnoreImageErrors, $wgGenerateThumbnailOnParse;
$sk = $this->getSkin();
$s = '<table class="gallery" cellspacing="0" cellpadding="0">';
if ($this->mCaption) {
$s .= '<td class="galleryheader" colspan="4"><big>' . htmlspecialchars($this->mCaption) . '</big></td>';
}
$i = 0;
foreach ($this->mImages as $pair) {
$img =& $pair[0];
$text = $pair[1];
$name = $img->getName();
$nt = $img->getTitle();
if ($nt->getNamespace() != NS_IMAGE) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = '<div style="height: 152px;">' . htmlspecialchars($nt->getText()) . '</div>';
} else {
if ($this->mParsing && wfIsBadImage($nt->getDBkey())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = '<div style="height: 152px;">' . $sk->makeKnownLinkObj($nt, htmlspecialchars($nt->getText())) . '</div>';
} else {
if (!($thumb = $img->getThumbnail(120, 120, $wgGenerateThumbnailOnParse))) {
# Error generating thumbnail.
$thumbhtml = '<div style="height: 152px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
$vpad = floor((150 - $thumb->height) / 2) - 2;
$thumbhtml = '<div class="thumb" style="padding: ' . $vpad . 'px 0;">' . $sk->makeKnownLinkObj($nt, $thumb->toHtml()) . '</div>';
}
}
}
//TODO
//$ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
if ($this->mShowBytes) {
if ($img->exists()) {
$nb = wfMsgExt('nbytes', array('parsemag', 'escape'), $wgLang->formatNum($img->getSize()));
} else {
$nb = wfMsgHtml('filemissing');
}
$nb = "{$nb}<br />\n";
} else {
$nb = '';
}
$textlink = $this->mShowFilename ? $sk->makeKnownLinkObj($nt, htmlspecialchars($wgLang->truncate($nt->getText(), 20, '...'))) . "<br />\n" : '';
# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
# in version 4.8.6 generated crackpot html in its absence, see:
# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
$s .= $i % 4 == 0 ? '<tr>' : '';
$s .= '<td><div class="gallerybox">' . $thumbhtml . '<div class="gallerytext">' . "\n" . $textlink . $text . $nb . "</div></div></td>\n";
$s .= $i % 4 == 3 ? '</tr>' : '';
$i++;
}
if ($i % 4 != 0) {
$s .= "</tr>\n";
}
$s .= '</table>';
return $s;
}
开发者ID:puring0815, 项目名称:OpenKore, 代码行数:68, 代码来源:ImageGallery.php
示例7: render
static function render($input, $params, $parser)
{
global $wgScriptPath, $wgUser, $wgUrlProtocols, $wgNoFollowLinks;
wfLoadExtensionMessages('ImageMap');
$lines = explode("\n", $input);
$first = true;
$lineNum = 0;
$mapHTML = '';
$links = array();
# Define canonical desc types to allow i18n of 'imagemap_desc_types'
$descTypesCanonical = 'top-right, bottom-right, bottom-left, top-left, none';
$descType = self::BOTTOM_RIGHT;
$defaultLinkAttribs = false;
$realmap = true;
foreach ($lines as $line) {
++$lineNum;
$externLink = false;
$line = trim($line);
if ($line == '' || $line[0] == '#') {
continue;
}
if ($first) {
$first = false;
# The first line should have an image specification on it
# Extract it and render the HTML
$bits = explode('|', $line, 2);
if (count($bits) == 1) {
$image = $bits[0];
$options = '';
} else {
list($image, $options) = $bits;
}
$imageTitle = Title::newFromText($image);
if (!$imageTitle || $imageTitle->getNamespace() != NS_IMAGE) {
return self::error('imagemap_no_image');
}
if (wfIsBadImage($imageTitle->getDBkey(), $parser->mTitle)) {
return self::error('imagemap_bad_image');
}
// Parse the options so we can use links and the like in the caption
$parsedOptions = $parser->recursiveTagParse($options);
$imageHTML = $parser->makeImage($imageTitle, $parsedOptions);
$parser->replaceLinkHolders($imageHTML);
$imageHTML = $parser->mStripState->unstripBoth($imageHTML);
$imageHTML = Sanitizer::normalizeCharReferences($imageHTML);
$parser->mOutput->addImage($imageTitle->getDBkey());
$domDoc = new DOMDocument();
wfSuppressWarnings();
$ok = $domDoc->loadXML($imageHTML);
wfRestoreWarnings();
if (!$ok) {
return self::error('imagemap_invalid_image');
}
$xpath = new DOMXPath($domDoc);
$imgs = $xpath->query('//img');
if (!$imgs->length) {
return self::error('imagemap_invalid_image');
}
$imageNode = $imgs->item(0);
$thumbWidth = $imageNode->getAttribute('width');
$thumbHeight = $imageNode->getAttribute('height');
if (function_exists('wfFindFile')) {
$imageObj = wfFindFile($imageTitle);
} else {
// Old MW
$imageObj = wfFindFile($imageTitle);
}
if (!$imageObj || !$imageObj->exists()) {
return self::error('imagemap_invalid_image');
}
# Add the linear dimensions to avoid inaccuracy in the scale
# factor when one is much larger than the other
# (sx+sy)/(x+y) = s
$denominator = $imageObj->getWidth() + $imageObj->getHeight();
$numerator = $thumbWidth + $thumbHeight;
if ($denominator <= 0 || $numerator <= 0) {
return self::error('imagemap_invalid_image');
}
$scale = $numerator / $denominator;
continue;
}
# Handle desc spec
$cmd = strtok($line, " \t");
if ($cmd == 'desc') {
$typesText = wfMsgForContent('imagemap_desc_types');
if ($descTypesCanonical != $typesText) {
// i18n desc types exists
$typesText = $descTypesCanonical . ', ' . $typesText;
}
$types = array_map('trim', explode(',', $typesText));
$type = trim(strtok(''));
$descType = array_search($type, $types);
if ($descType > 4) {
// A localized descType is used. Subtract 5 to reach the canonical desc type.
$descType = $descType - 5;
}
if ($descType === false || $descType < 0) {
// <0? In theory never, but paranoia...
return self::error('imagemap_invalid_desc', $typesText);
}
//.........这里部分代码省略.........
开发者ID:akoehn, 项目名称:wikireader, 代码行数:101, 代码来源:ImageMap_body.php
示例8: replaceInternalLinks
//.........这里部分代码省略.........
$text = $this->replaceInternalLinks($text);
$s .= "{$prefix}[[{$link}|{$text}";
# note: no $trail, because without an end, there *is* no trail
wfProfileOut("{$fname}-might_be_img");
continue;
}
} else {
#it's not an image, so output it raw
$s .= "{$prefix}[[{$link}|{$text}";
# note: no $trail, because without an end, there *is* no trail
wfProfileOut("{$fname}-might_be_img");
continue;
}
wfProfileOut("{$fname}-might_be_img");
}
$wasblank = '' == $text;
if ($wasblank) {
$text = $link;
}
# Link not escaped by : , create the various objects
if ($noforce) {
# Interwikis
wfProfileIn("{$fname}-interwiki");
if ($iw && $this->mOptions->getInterwikiMagic() && $nottalk && $wgContLang->getLanguageName($iw)) {
$this->mOutput->addLanguageLink($nt->getFullText());
$s = rtrim($s . $prefix);
$s .= trim($trail, "\n") == '' ? '' : $prefix . $trail;
wfProfileOut("{$fname}-interwiki");
continue;
}
wfProfileOut("{$fname}-interwiki");
if ($ns == NS_IMAGE) {
wfProfileIn("{$fname}-image");
if (!wfIsBadImage($nt->getDBkey(), $this->mTitle)) {
# recursively parse links inside the image caption
# actually, this will parse them in any other parameters, too,
# but it might be hard to fix that, and it doesn't matter ATM
$text = $this->replaceExternalLinks($text);
$text = $this->replaceInternalLinks($text);
# cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
$s .= $prefix . $this->armorLinks($this->makeImage($nt, $text)) . $trail;
$this->mOutput->addImage($nt->getDBkey());
wfProfileOut("{$fname}-image");
continue;
} else {
# We still need to record the image's presence on the page
$this->mOutput->addImage($nt->getDBkey());
}
wfProfileOut("{$fname}-image");
}
if ($ns == NS_CATEGORY) {
wfProfileIn("{$fname}-category");
$s = rtrim($s . "\n");
# bug 87
if ($wasblank) {
$sortkey = $this->getDefaultSort();
} else {
$sortkey = $text;
}
$sortkey = Sanitizer::decodeCharReferences($sortkey);
$sortkey = str_replace("\n", '', $sortkey);
$sortkey = $wgContLang->convertCategoryKey($sortkey);
$this->mOutput->addCategory($nt->getDBkey(), $sortkey);
/**
* Strip the whitespace Category links produce, see bug 87
* @todo We might want to use trim($tmp, "\n") here.
开发者ID:renemilk, 项目名称:spring-website, 代码行数:67, 代码来源:Parser.php
示例9: thumbToHTML
/**
*
* @param File $img
* @param Title $nt
* @param string $text
* @param string $alt
* @param type $descQuery
* @return string
*/
private function thumbToHTML($img, $nt, $text = '', $alt = '', $descQuery = '')
{
if (!$img) {
$html = '<a class="CarError" style="height: ' . $this->mThumbHeight . 'px; width: ' . $this->mThumbWidth . 'px;">' . htmlspecialchars($nt->getText()) . '</a>';
} else {
if ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
$html = '<a class="CarError" style="height: ' . $this->mThumbHeight . 'px; width: ' . $this->mThumbWidth . 'px;">' . Linker::link($nt, htmlspecialchars($nt->getText()), array(), array(), array('known', 'noclasses')) . '</a>';
} else {
if (self::imgIsVertical($img)) {
$params = array('height' => $this->mPhotoHeight, 'width' => $this->mThumbHeight);
} else {
$params = array('height' => $this->mThumbHeight, 'width' => $this->mPhotoWidth);
}
if (!($thumb = $img->transform($params))) {
# Error generating thumbnail.
$html = '<a class="CarError" style="height: ' . $this->mThumbHeight . 'px; width: ' . $this->mThumbWidth . 'px;"></a>';
} else {
$imageParameters = array('desc-link' => true, 'desc-query' => $descQuery, 'alt' => $alt);
# In the absence of both alt text and caption, fall back on providing screen readers with the filename as alt text
if ($alt == '') {
$imageParameters['alt'] = $nt->getText();
}
$html = $thumb->toHtml($imageParameters);
}
}
}
return $html;
}
开发者ID:eFFemeer, 项目名称:seizamcore, 代码行数:37, 代码来源:CarZam.Carrousel.php
示例10: renderSlideshow
//.........这里部分代码省略.........
$caption = $linkOverlay = '';
// render caption overlay
if ($text != '') {
$caption = Xml::openElement('span', array('class' => 'wikia-slideshow-image-caption')) . Xml::openElement('span', array('class' => 'wikia-slideshow-image-caption-inner')) . $text . Xml::closeElement('span') . Xml::closeElement('span');
}
// parse link
$linkAttribs = $this->parseLink($nt->getLocalUrl(), $nt->getText(), $link);
// extra link tag attributes
$linkAttribs['id'] = "{$id}-{$index}";
$linkAttribs['style'] = 'width: ' . ($params['width'] - 80) . 'px';
if ($link == '') {
// tooltip to be used for not-linked images
$linkAttribs['title'] = wfMessage('wikiaPhotoGallery-slideshow-view-popout-tooltip')->text();
$linkAttribs['class'] = 'wikia-slideshow-image';
unset($linkAttribs['href']);
} else {
// linked images
$linkAttribs['class'] .= ' wikia-slideshow-image';
// support |linktext= syntax
if ($this->mData['images'][$p]['linktext'] != '') {
$linkText = $this->mData['images'][$p]['linktext'];
} else {
$linkText = $link;
}
// add link overlay
$linkOverlay = Xml::openElement('span', array('class' => 'wikia-slideshow-link-overlay')) . wfMessage('wikiaPhotoGallery-slideshow-view-link-overlay', Sanitizer::removeHTMLtags($linkText))->text() . Xml::closeElement('span');
}
// generate HTML for a single slideshow image
$thumbHtml = null;
$liAttribs = array('title' => null);
if ($nt->getNamespace() != NS_FILE || !$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbHtml = '<a class="image broken-image new" style="line-height: ' . $this->mHeights . 'px;">' . $nt->getText() . '</a>';
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbHtml = '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . $sk->makeKnownLinkObj($nt, $nt->getText()) . '</div>';
} elseif (!($thumb = $img->transform($thumbParams))) {
# Error generating thumbnail.
$thumbHtml = '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
$thumbAttribs = array('data-src' => $thumb->url, 'class' => 'thumbimage', 'width' => $thumb->width, 'height' => $thumb->height, 'style' => 'border: 0px;', 'data-image-name' => $img->getTitle()->getText(), 'data-image-key' => $img->getTitle()->getDBKey());
if (!empty($this->mData['images'][$p]['data-caption'])) {
$thumbAttribs['data-caption'] = $this->mData['images'][$p]['data-caption'];
}
$thumbHtml = Xml::element('img', $thumbAttribs);
}
// add CSS class so we can show first slideshow image before JS is loaded
if ($index == 0) {
$liAttribs['class'] = 'wikia-slideshow-first-image';
}
$slideshowHtml .= Xml::openElement('li', $liAttribs) . $thumbHtml . Xml::element('a', $linkAttribs, ' ') . $caption . $linkOverlay . '</li>';
$index++;
// Call parser transform hook
if ($this->mParser && is_object($img) && $img->getHandler()) {
$img->getHandler()->parserTransformHook($this->mParser, $img);
}
if (is_object($thumb)) {
wfDebug(__METHOD__ . ": image '" . $nt->getText() . "' {$thumb->width}x{$thumb->height}\n");
}
}
$slideshowHtml .= Xml::closeElement('ul');
$slideshowHtml .= Xml::closeElement('div');
// render prev/next buttons
global $wgBlankImgUrl;
$top = ($params['height'] >> 1) - 30 + 5;
$slideshowHtml .= Xml::openElement('div', array('class' => 'wikia-slideshow-prev-next'));
开发者ID:Tjorriemorrie, 项目名称:app, 代码行数:67, 代码来源:WikiaPhotoGallery.class.php
示例11: toHTML
/**
* Return a HTML representation of the image gallery
*
* For each image in the gallery, display
* - a thumbnail
* - the image name
* - the additional text provided when adding the image
* - the size of the image
*
* @return string
*/
function toHTML()
{
if ($this->mPerRow > 0) {
$maxwidth = $this->mPerRow * ($this->mWidths + self::THUMB_PADDING + self::GB_PADDING + self::GB_BORDERS);
$oldStyle = isset($this->mAttribs['style']) ? $this->mAttribs['style'] : '';
# _width is ignored by any sane browser. IE6 doesn't know max-width so it uses _width instead
$this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle;
}
$attribs = Sanitizer::mergeAttributes(array('class' => 'gallery'), $this->mAttribs);
$output = Xml::openElement('ul', $attribs);
if ($this->mCaption) {
$output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
}
$lang = $this->getLang();
$params = array('width' => $this->mWidths, 'height' => $this->mHeights);
# Output each image...
foreach ($this->mImages as $pair) {
$nt = $pair[0];
$text = $pair[1];
# "text" means "caption" here
$alt = $pair[2];
$link = $pair[3];
$descQuery = false;
if ($nt->getNamespace() == NS_FILE) {
# Get the file...
if ($this->mParser instanceof Parser) {
# Give extensions a chance to select the file revision for us
$options = array();
wfRunHooks('BeforeParserFetchFileAndTitle', array($this->mParser, $nt, &$options, &$descQuery));
# Fetch and register the file (file title may be different via hooks)
list($img, $nt) = $this->mParser->fetchFileAndTitle($nt, $options);
} else {
$img = wfFindFile($nt);
}
} else {
$img = false;
}
if (!$img) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . (self::THUMB_PADDING + $this->mHeights) . 'px;">' . htmlspecialchars($nt->getText()) . '</div>';
} elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . (self::THUMB_PADDING + $this->mHeights) . 'px;">' . Linker::link($nt, htmlspecialchars($nt->getText()), array(), array(), array('known', 'noclasses')) . '</div>';
} elseif (!($thumb = $img->transform($params))) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . (self::THUMB_PADDING + $this->mHeights) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>';
} else {
$vpad = (self::THUMB_PADDING + $this->mHeights - $thumb->height) / 2;
$imageParameters = array('desc-link' => true, 'desc-query' => $descQuery, 'alt' => $alt, 'custom-url-link' => $link);
# In the absence of both alt text and caption, fall back on providing screen readers with the filename as alt text
if ($alt == '' && $text == '') {
$imageParameters['alt'] = $nt->getText();
}
# Set both fixed width and min-height.
$thumbhtml = "\n\t\t\t" . '<div class="thumb" style="width: ' . ($this->mWidths + self::THUMB_PADDING) . 'px;">' . '<div style="margin:' . $vpad . 'px auto;">' . $thumb->toHtml($imageParameters) . '</div></div>';
// Call parser transform hook
if ($this->mParser && $img->getHandler()) {
$img->getHandler()->parserTransformHook($this->mParser, $img);
}
}
//TODO
// $linkTarget = Title::newFromText( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}" );
// $ul = Linker::link( $linkTarget, $ut );
if ($this->mShowBytes) {
if ($img) {
$fileSize = htmlspecialchars($lang->formatSize($img->getSize()));
} else {
$fileSize = wfMessage('filemissing')->escaped();
}
$fileSize = "{$fileSize}<br />\n";
} else {
$fileSize = '';
}
$textlink = $this->mShowFilename ? Linker::link($nt, htmlspecialchars($lang->truncate($nt->getText(), $this->mCaptionLength)), array(), array(), array('known', 'noclasses')) . "<br />\n" : '';
# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
# in version 4.8.6 generated crackpot html in its absence, see:
# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
# Weird double wrapping (the extra div inside the li) needed due to FF2 bug
# Can be safely removed if FF2 falls completely out of existence
$output .= "\n\t\t" . '<li class="gallerybox" style="width: ' . ($this->mWidths + self::THUMB_PADDING + self::GB_PADDING) . 'px">' . '<div style="width: ' . ($this->mWidths + self::THUMB_PADDING + self::GB_PADDING) . 'px">' . $thumbhtml . "\n\t\t\t" . '<div class="gallerytext">' . "\n" . $textlink . $text . $fileSize . "\n\t\t\t</div>" . "\n\t\t</div></li>";
}
$output .= "\n</ul>";
return $output;
}
开发者ID:Grprashanthkumar, 项目名称:ColfusionWeb, 代码行数:95, 代码来源:ImageGallery.php
示例12: testWfIsBadImage
/**
* @dataProvider provideWfIsBadImageList
* @covers ::wfIsBadImage
*/
public function testWfIsBadImage($name, $title, $blacklist, $expected, $desc)
{
$this->assertEquals($expected, wfIsBadImage($name, $title, $blacklist), $desc);
}
开发者ID:claudinec, 项目名称:galan-wiki, 代码行数:8, 代码来源:GlobalWithDBTest.php
NanoMichael/MicroTeX: A dynamic, cross-platform, and embeddable LaTeX rendering
阅读:883| 2022-08-12
bradtraversy/iweather: Ionic 3 mobile weather app
阅读:1584| 2022-08-30
joaomh/curso-de-matlab
阅读:1147| 2022-08-17
魔兽世界怀旧服已经开启两个多月了,但作为一个猎人玩家,抓到“断牙”,已经成为了一
阅读:1002| 2022-11-06
rugk/mastodon-simplified-federation: Simplifies following and interacting with r
阅读:1080| 2022-08-17
An issue was discovered in Inductive Automation Ignition before 7.9.20 and 8.x b
阅读:916| 2022-07-29
Tangshitao/Dense-Scene-Matching: Learning Camera Localization via Dense Scene Ma
阅读:759| 2022-08-16
json4s/json4s: JSON library
阅读:776| 2022-08-15
相信不少果粉在对自己的设备进行某些操作时,都会碰到Respring,但这个 Respring 到底
阅读:361| 2022-11-06
lightningtgc/MProgress.js: Material Progress —Google Material Design Progress l
阅读:406| 2022-08-17
请发表评论