本文整理汇总了PHP中Linker::makeThumbLinkObj方法的典型用法代码示例。如果您正苦于以下问题:PHP Linker::makeThumbLinkObj方法的具体用法?PHP Linker::makeThumbLinkObj怎么用?PHP Linker::makeThumbLinkObj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Linker
的用法示例。
在下文中一共展示了Linker::makeThumbLinkObj方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run a thumbnail job on a given PDF file.
* @return bool true
*/
public function run()
{
if (!isset($this->params['page'])) {
wfDebugLog('thumbnails', 'A page for thumbnails job of ' . $this->title->getText() . ' was not specified! That should never happen!');
return true;
// no page set? that should never happen
}
$file = wfLocalFile($this->title);
// we just want a local file
if (!$file) {
return true;
// Just silently fail, perhaps the file was already deleted, don't bother
}
switch ($this->params['jobtype']) {
case self::BIG_THUMB:
global $wgImageLimits;
// Ignore user preferences, do default thumbnails
// everything here shamelessy copied and reused from includes/ImagePage.php
$sizeSel = User::getDefaultOption('imagesize');
// The user offset might still be incorrect, specially if
// $wgImageLimits got changed (see bug #8858).
if (!isset($wgImageLimits[$sizeSel])) {
// Default to the first offset in $wgImageLimits
$sizeSel = 0;
}
$max = $wgImageLimits[$sizeSel];
$maxWidth = $max[0];
$maxHeight = $max[1];
$width_orig = $file->getWidth($this->params['page']);
$width = $width_orig;
$height_orig = $file->getHeight($this->params['page']);
$height = $height_orig;
if ($width > $maxWidth || $height > $maxHeight) {
# Calculate the thumbnail size.
# First case, the limiting factor is the width, not the height.
if ($width / $height >= $maxWidth / $maxHeight) {
//$height = round( $height * $maxWidth / $width );
$width = $maxWidth;
# Note that $height <= $maxHeight now.
} else {
$newwidth = floor($width * $maxHeight / $height);
//$height = round( $height * $newwidth / $width );
$width = $newwidth;
# Note that $height <= $maxHeight now, but might not be identical
# because of rounding.
}
$transformParams = array('page' => $this->params['page'], 'width' => $width);
$file->transform($transformParams);
}
break;
case self::SMALL_THUMB:
Linker::makeThumbLinkObj($this->title, $file, '', '', 'none', array('page' => $this->params['page']));
break;
}
return true;
}
示例2: execute
function execute( $par ) {
$this->setHeaders();
$this->outputHeader();
$request = $this->getRequest();
$file = !is_null( $par ) ? $par : $request->getText( 'file' );
$title = Title::newFromText( $file, NS_FILE );
if ( ! $title instanceof Title || $title->getNamespace() != NS_FILE ) {
$this->showForm( $title );
} else {
$file = wfFindFile( $title );
if ( $file && $file->exists() ){
$this->svg = new DOMDocument( '1.0' );
$this->svg->load( $file->getLocalRefPath() );
$this->xpath = new DOMXpath( $this->svg );
$this->xpath->registerNamespace( 'svg', 'http://www.w3.org/2000/svg' );
if( $this->makeTranslationReady() ){
$this->extractTranslations();
$this->tidyTranslations();
$params = $request->getQueryValues();
if( count( $params ) > 2 && isset( $params['title'] ) && isset( $params['file'] ) && isset( $params['step'] ) ){
$filename = $params['file'];
unset( $params['title'], $params['file'], $params['step'] );
$this->updateTranslations( $params );
$this->updateSVG();
$this->saveSVG( $file->getLocalRefPath(), $filename );
$file->purgeThumbnails();
} else {
$this->thumb = Linker::makeThumbLinkObj( $title, $file, $label = '', '',
$align = $this->getLanguage()->alignEnd(), array( 'width' => 250, 'height' => 250 ) );
$this->printTranslations( $file->getName() );
}
} else {
$this->getOutput()->addWikiMsg( 'translatesvg-unsuccessful' );
}
} else {
$this->getOutput()->setStatusCode( 404 );
$this->showForm( $title );
}
}
}
示例3: showForm
/**
* Shows the search form
*/
private function showForm()
{
global $wgScript, $wgOut, $wgRequest;
/* Build form */
$html = Xml::openElement('form', array('action' => $wgScript)) . "\n";
// Name of SpecialPage
$html .= Html::hidden('title', $this->getTitle()->getPrefixedText()) . "\n";
// Limit
$html .= Html::hidden('limit', $wgRequest->getInt('limit', 50));
// Input box with target prefilled if available
$formContent = "\t" . Xml::input('target', 40, is_null($this->target) ? '' : $this->target->getText()) . "\n\t" . Xml::element('input', array('type' => 'submit', 'value' => wfMsg('globalusage-ok'))) . "\n\t<p>" . Xml::checkLabel(wfMsg('globalusage-filterlocal'), 'filterlocal', 'mw-filterlocal', $this->filterLocal) . '</p>';
if (!is_null($this->target) && wfFindFile($this->target)) {
// Show the image if it exists
$html .= Linker::makeThumbLinkObj($this->target, wfFindFile($this->target), $this->target->getPrefixedText(), '', wfUILang()->alignEnd(), array(), false, false);
}
// Wrap the entire form in a nice fieldset
$html .= Xml::fieldSet(wfMsg('globalusage-text'), $formContent) . "\n</form>";
$wgOut->addHtml($html);
}
示例4: openShowImage
//.........这里部分代码省略.........
}
} elseif ($width == 0 && $height == 0) {
# Some sort of audio file that doesn't have dimensions
# Don't output a no hi res message for such a file
$msgsmall = '';
} elseif ($this->displayImg->isVectorized()) {
# For vectorized images, full size is just the frame size
$msgsmall = '';
} else {
# Image is small enough to show full size on image page
$msgsmall = wfMessage('file-nohires')->parse();
}
$params['width'] = $width;
$params['height'] = $height;
$thumbnail = $this->displayImg->transform($params);
Linker::processResponsiveImages($this->displayImg, $thumbnail, $params);
$anchorclose = Html::rawElement('div', array('class' => 'mw-filepage-resolutioninfo'), $msgsmall);
$isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
if ($isMulti) {
$out->addModules('mediawiki.page.image.pagination');
$out->addHTML('<table class="multipageimage"><tr><td>');
}
if ($thumbnail) {
$options = array('alt' => $this->displayImg->getTitle()->getPrefixedText(), 'file-link' => true);
$out->addHTML('<div class="fullImageLink" id="file">' . $thumbnail->toHtml($options) . $anchorclose . "</div>\n");
}
if ($isMulti) {
$count = $this->displayImg->pageCount();
if ($page > 1) {
$label = $out->parse(wfMessage('imgmultipageprev')->text(), false);
// on the client side, this link is generated in ajaxifyPageNavigation()
// in the mediawiki.page.image.pagination module
$link = Linker::linkKnown($this->getTitle(), $label, array(), array('page' => $page - 1));
$thumb1 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page - 1));
} else {
$thumb1 = '';
}
if ($page < $count) {
$label = wfMessage('imgmultipagenext')->text();
$link = Linker::linkKnown($this->getTitle(), $label, array(), array('page' => $page + 1));
$thumb2 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page + 1));
} else {
$thumb2 = '';
}
global $wgScript;
$formParams = array('name' => 'pageselector', 'action' => $wgScript);
$options = array();
for ($i = 1; $i <= $count; $i++) {
$options[] = Xml::option($lang->formatNum($i), $i, $i == $page);
}
$select = Xml::tags('select', array('id' => 'pageselector', 'name' => 'page'), implode("\n", $options));
$out->addHTML('</td><td><div class="multipageimagenavbox">' . Xml::openElement('form', $formParams) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . wfMessage('imgmultigoto')->rawParams($select)->parse() . Xml::submitButton(wfMessage('imgmultigo')->text()) . Xml::closeElement('form') . "<hr />{$thumb1}\n{$thumb2}<br style=\"clear: both\" /></div></td></tr></table>");
}
} elseif ($this->displayImg->isSafeFile()) {
# if direct link is allowed but it's not a renderable image, show an icon.
$icon = $this->displayImg->iconThumb();
$out->addHTML('<div class="fullImageLink" id="file">' . $icon->toHtml(array('file-link' => true)) . "</div>\n");
}
$longDesc = wfMessage('parentheses', $this->displayImg->getLongDesc())->text();
$medialink = "[[Media:{$filename}|{$linktext}]]";
if (!$this->displayImg->isSafeFile()) {
$warning = wfMessage('mediawarning')->plain();
// dirmark is needed here to separate the file name, which
// most likely ends in Latin characters, from the description,
// which may begin with the file type. In RTL environment
// this will get messy.
示例5: makeThumbLinkObj
public function makeThumbLinkObj(Title $title, $file, $label = '', $alt, $align = 'right', $params = [], $framed = false, $manualthumb = "")
{
return Linker::makeThumbLinkObj($title, $file, $label, $alt, $align, $params, $framed, $manualthumb);
}
示例6: openShowImage
protected function openShowImage()
{
global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgEnableUploads, $wgSend404Code;
$this->loadFile();
$sizeSel = intval($wgUser->getOption('imagesize'));
if (!isset($wgImageLimits[$sizeSel])) {
$sizeSel = User::getDefaultOption('imagesize');
// The user offset might still be incorrect, specially if
// $wgImageLimits got changed (see bug #8858).
if (!isset($wgImageLimits[$sizeSel])) {
// Default to the first offset in $wgImageLimits
$sizeSel = 0;
}
}
$max = $wgImageLimits[$sizeSel];
$maxWidth = $max[0];
$maxHeight = $max[1];
$dirmark = $wgLang->getDirMark();
if ($this->displayImg->exists()) {
# image
$page = $wgRequest->getIntOrNull('page');
if (is_null($page)) {
$params = array();
$page = 1;
} else {
$params = array('page' => $page);
}
$width_orig = $this->displayImg->getWidth($page);
$width = $width_orig;
$height_orig = $this->displayImg->getHeight($page);
$height = $height_orig;
$longDesc = wfMsg('parentheses', $this->displayImg->getLongDesc());
wfRunHooks('ImageOpenShowImageInlineBefore', array(&$this, &$wgOut));
if ($this->displayImg->allowInlineDisplay()) {
# image
# "Download high res version" link below the image
# $msgsize = wfMsgHtml( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime );
# We'll show a thumbnail of this image
if ($width > $maxWidth || $height > $maxHeight) {
# Calculate the thumbnail size.
# First case, the limiting factor is the width, not the height.
if ($width / $height >= $maxWidth / $maxHeight) {
$height = round($height * $maxWidth / $width);
$width = $maxWidth;
# Note that $height <= $maxHeight now.
} else {
$newwidth = floor($width * $maxHeight / $height);
$height = round($height * $newwidth / $width);
$width = $newwidth;
# Note that $height <= $maxHeight now, but might not be identical
# because of rounding.
}
$msgbig = wfMsgHtml('show-big-image');
$otherSizes = array();
foreach ($wgImageLimits as $size) {
if ($size[0] < $width_orig && $size[1] < $height_orig && $size[0] != $width && $size[1] != $height) {
$otherSizes[] = $this->makeSizeLink($params, $size[0], $size[1]);
}
}
$msgsmall = wfMessage('show-big-image-preview')->rawParams($this->makeSizeLink($params, $width, $height))->parse();
if (count($otherSizes) && $this->displayImg->getRepo()->canTransformVia404()) {
$msgsmall .= ' ' . Html::rawElement('span', array('class' => 'mw-filepage-other-resolutions'), wfMessage('show-big-image-other')->rawParams($wgLang->pipeList($otherSizes))->params(count($otherSizes))->parse());
}
} elseif ($width == 0 && $height == 0) {
# Some sort of audio file that doesn't have dimensions
# Don't output a no hi res message for such a file
$msgsmall = '';
} else {
# Image is small enough to show full size on image page
$msgsmall = wfMessage('file-nohires')->parse();
}
$params['width'] = $width;
$params['height'] = $height;
$thumbnail = $this->displayImg->transform($params);
$showLink = true;
$anchorclose = Html::rawElement('div', array('class' => 'mw-filepage-resolutioninfo'), $msgsmall);
$isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
if ($isMulti) {
$wgOut->addHTML('<table class="multipageimage"><tr><td>');
}
if ($thumbnail) {
$options = array('alt' => $this->displayImg->getTitle()->getPrefixedText(), 'file-link' => true);
$wgOut->addHTML('<div class="fullImageLink" id="file">' . $thumbnail->toHtml($options) . $anchorclose . "</div>\n");
}
if ($isMulti) {
$count = $this->displayImg->pageCount();
if ($page > 1) {
$label = $wgOut->parse(wfMsg('imgmultipageprev'), false);
$link = Linker::link($this->getTitle(), $label, array(), array('page' => $page - 1), array('known', 'noclasses'));
$thumb1 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page - 1));
} else {
$thumb1 = '';
}
if ($page < $count) {
$label = wfMsg('imgmultipagenext');
$link = Linker::link($this->getTitle(), $label, array(), array('page' => $page + 1), array('known', 'noclasses'));
$thumb2 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page + 1));
} else {
$thumb2 = '';
}
//.........这里部分代码省略.........