本文整理汇总了PHP中User::getDefaultOption方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getDefaultOption方法的具体用法?PHP User::getDefaultOption怎么用?PHP User::getDefaultOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::getDefaultOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertOptionBatch
/**
* @param ResultWrapper $res
* @param DatabaseBase $dbw
* @return null|int
*/
function convertOptionBatch($res, $dbw)
{
$id = null;
foreach ($res as $row) {
$this->mConversionCount++;
$insertRows = array();
foreach (explode("\n", $row->user_options) as $s) {
$m = array();
if (!preg_match("/^(.[^=]*)=(.*)\$/", $s, $m)) {
continue;
}
// MW < 1.16 would save even default values. Filter them out
// here (as in User) to avoid adding many unnecessary rows.
$defaultOption = User::getDefaultOption($m[1]);
if (is_null($defaultOption) || $m[2] != $defaultOption) {
$insertRows[] = array('up_user' => $row->user_id, 'up_property' => $m[1], 'up_value' => $m[2]);
}
}
if (count($insertRows)) {
$dbw->insert('user_properties', $insertRows, __METHOD__, array('IGNORE'));
}
$dbw->update('user', array('user_options' => ''), array('user_id' => $row->user_id), __METHOD__);
$id = $row->user_id;
}
return $id;
}
示例2: getDefault
/**
* Returns the default gender option in this wiki.
* @return String
*/
protected function getDefault()
{
if ($this->default === null) {
$this->default = User::getDefaultOption('gender');
}
return $this->default;
}
示例3: 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:
global $wgUser;
$sk = $wgUser->getSkin();
$sk->makeThumbLinkObj( $this->title, $file, '', '', 'none', array( 'page' => $this->params['page'] ) );
break;
}
return true;
}
示例4: getShowImageParameters
private function getShowImageParameters()
{
global $wgUser, $wgImageLimits, $wgUseImageResize, $wgGenerateThumbnailOnParse;
$url = '';
$width = 0;
$height = 0;
if ($wgUser->getOption('imagesize') == '') {
$sizeSel = User::getDefaultOption('imagesize');
} else {
$sizeSel = intval($wgUser->getOption('imagesize'));
}
if (!isset($wgImageLimits[$sizeSel])) {
$sizeSel = User::getDefaultOption('imagesize');
}
$max = $wgImageLimits[$sizeSel];
$maxWidth = $max[0];
$maxHeight = $max[1];
if ($this->img->exists()) {
# image
$width = $this->img->getWidth();
$height = $this->img->getHeight();
if ($this->img->allowInlineDisplay() and $width and $height) {
# image
# 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.
}
if ($wgUseImageResize) {
$thumbnail = $this->img->getThumbnail($width, -1, $wgGenerateThumbnailOnParse);
if ($thumbnail == null) {
$url = $this->img->getViewURL();
} else {
$url = $thumbnail->getURL();
}
} else {
# No resize ability? Show the full image, but scale
# it down in the browser so it fits on the page.
$url = $this->img->getViewURL();
}
} else {
$url = $this->img->getViewURL();
}
}
}
return array($url, $width, $height);
}
示例5: onCustomEditor
/**
* Decide whether to bother showing the wikitext editor at all.
* If not, we expect the VE initialisation JS to activate.
* @param $article Article
* @param $user User
* @return bool Whether to show the wikitext editor or not.
*/
public static function onCustomEditor(Article $article, User $user)
{
$req = RequestContext::getMain()->getRequest();
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig('visualeditor');
if (!$user->getOption('visualeditor-enable') || $user->getOption('visualeditor-betatempdisable') || $user->getOption('visualeditor-autodisable') || $user->getOption('visualeditor-tabs') === 'prefer-wt' || $veConfig->get('VisualEditorDisableForAnons') && $user->isAnon() || false) {
return true;
}
$title = $article->getTitle();
$availableNamespaces = $veConfig->get('VisualEditorAvailableNamespaces');
$params = $req->getValueNames();
if ($user->isAnon()) {
$editor = $req->getCookie('VEE', '', User::getDefaultOption('visualeditor-editor'));
} else {
$editor = $user->getOption('visualeditor-editor');
}
return $req->getVal('action') !== 'edit' || !$veConfig->get('VisualEditorUseSingleEditTab') || $editor === 'wikitext' || !$title->inNamespaces(array_keys(array_filter($availableNamespaces))) || $title->getContentModel() !== CONTENT_MODEL_WIKITEXT || in_array('undo', $params) || in_array('undoafter', $params) || in_array('editintro', $params) || in_array('preload', $params) || in_array('preloadtitle', $params) || in_array('preloadparams', $params);
// Known-good parameters: edit, veaction, section, vesection, veswitched
}
示例6: fixUser
private function fixUser($i)
{
global $wgDontSwitchMeOverPrefs;
$user = User::newFromId($i);
// If the user doesn't exist or doesn't have our preference enabled, skip
if ($user->isAnon() || !$user->getOption('dontswitchmeover')) {
return;
}
$changed = false;
foreach ($wgDontSwitchMeOverPrefs as $pref => $oldVal) {
if ($user->getOption($pref) == User::getDefaultOption($pref)) {
$user->setOption($pref, $oldVal);
$changed = true;
}
}
if ($changed) {
$user->saveSettings();
}
}
示例7: gender
static function gender($parser, $user)
{
$forms = array_slice(func_get_args(), 2);
// default
$gender = User::getDefaultOption('gender');
// allow prefix.
$title = Title::newFromText($user);
if (is_object($title) && $title->getNamespace() == NS_USER) {
$user = $title->getText();
}
// check parameter, or use $wgUser if in interface message
$user = User::newFromName($user);
if ($user) {
$gender = $user->getOption('gender');
} elseif ($parser->mOptions->getInterfaceMessage()) {
global $wgUser;
$gender = $wgUser->getOption('gender');
}
return $parser->getFunctionLang()->gender($gender, $forms);
}
示例8: getGeolocationButtonParams
/**
* Returns geolocation button params
*/
private function getGeolocationButtonParams($refreshCache = false)
{
$sMemcKey = wfMemcKey($this->app->wg->title->getText(), $this->app->wg->title->getNamespace(), 'GeolocationButtonParams');
// use user default
if (empty($iWidth)) {
$wopt = $this->app->wg->user->getGlobalPreference('thumbsize');
if (!isset($this->app->wg->thumbLimits[$wopt])) {
$wopt = User::getDefaultOption('thumbsize');
}
$iWidth = $this->app->wg->thumbLimits[$wopt];
}
$aResult = array('align' => 'right', 'width' => $iWidth);
$aMemcResult = $this->app->wg->memc->get($sMemcKey);
$refreshCache = true;
// FIXME
if ($refreshCache || empty($aMemcResult)) {
$oArticle = new Article($this->app->wg->title);
$sRawText = $oArticle->getRawText();
$aMatches = array();
$string = $this->app->wg->contLang->getNsText(NS_IMAGE) . '|' . MWNamespace::getCanonicalName(NS_IMAGE);
$iFound = preg_match('#\\[\\[(' . $string . '):[^\\]]*|thumb[^\\]]*\\]\\]#', $sRawText, $aMatches);
if (!empty($iFound)) {
reset($aMatches);
$sMatch = current($aMatches);
$sMatch = str_replace('[[', '', $sMatch);
$sMatch = str_replace(']]', '', $sMatch);
$aMatch = explode('|', $sMatch);
foreach ($aMatch as $element) {
if ($element == 'left') {
$aResult['align'] = $element;
}
if (substr($element, -2) == 'px' && (int) substr($element, 0, -2) > 0) {
$aResult['width'] = (int) substr($element, 0, -2);
}
}
}
$iExpires = 60 * 60 * 24;
$this->app->wg->memc->set($sMemcKey, $aResult, $iExpires);
} else {
$aResult['align'] = $aMemcResult['align'];
if (!empty($aMemcResult['width'])) {
$aResult['width'] = $aMemcResult['width'];
}
}
// get default image width
return $aResult;
}
示例9: gender
/**
* gender handler
*/
function gender($lang, $args)
{
$this->checkType('gender', 1, $args[0], 'string');
$username = trim(array_shift($args));
if (is_array($args[0])) {
$args = $args[0];
}
$forms = array_values(array_map('strval', $args));
// Shortcuts
if (count($forms) === 0) {
return '';
} elseif (count($forms) === 1) {
return $forms[0];
}
if ($username === 'male' || $username === 'female') {
$gender = $username;
} else {
// default
$gender = User::getDefaultOption('gender');
// Check for "User:" prefix
$title = Title::newFromText($username);
if ($title && $title->getNamespace() == NS_USER) {
$username = $title->getText();
}
// check parameter, or use the ParserOptions if in interface message
$user = User::newFromName($username);
if ($user) {
$gender = GenderCache::singleton()->getGenderOf($user, __METHOD__);
} elseif ($username === '') {
$parserOptions = $this->getParserOptions();
if ($parserOptions->getInterfaceMessage()) {
$gender = GenderCache::singleton()->getGenderOf($parserOptions->getUser(), __METHOD__);
}
}
}
return array($lang->gender($gender, $forms));
}
示例10: body_ondblclick
function body_ondblclick()
{
global $wgUser;
if ($this->isEditable() && $wgUser->getOption("editondblclick")) {
$js = 'document.location = "' . $this->getEditUrl() . '";';
} else {
$js = '';
}
if (User::getDefaultOption('editondblclick')) {
return cbt_value($js, 'user', 'title');
} else {
// Optimise away for logged-out users
return cbt_value($js, 'loggedin dynamic');
}
}
示例11: makeImageLink2
/**
* Given parameters derived from [[Image:Foo|options...]], generate the
* HTML that that syntax inserts in the page.
*
* @param Title $title Title object
* @param File $file File object, or false if it doesn't exist
*
* @param array $frameParams Associative array of parameters external to the media handler.
* Boolean parameters are indicated by presence or absence, the value is arbitrary and
* will often be false.
* thumbnail If present, downscale and frame
* manualthumb Image name to use as a thumbnail, instead of automatic scaling
* framed Shows image in original size in a frame
* frameless Downscale but don't frame
* upright If present, tweak default sizes for portrait orientation
* upright_factor Fudge factor for "upright" tweak (default 0.75)
* border If present, show a border around the image
* align Horizontal alignment (left, right, center, none)
* valign Vertical alignment (baseline, sub, super, top, text-top, middle,
* bottom, text-bottom)
* alt Alternate text for image (i.e. alt attribute). Plain text.
* caption HTML for image caption.
* link-url URL to link to
* link-title Title object to link to
* no-link Boolean, suppress description link
*
* @param array $handlerParams Associative array of media handler parameters, to be passed
* to transform(). Typical keys are "width" and "page".
* @param string $time, timestamp of the file, set as false for current
* @param string $query, query params for desc url
* @return string HTML for an image, with links, wrappers, etc.
*/
function makeImageLink2(Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false, $query = "")
{
$res = null;
if (!wfRunHooks('ImageBeforeProduceHTML', array(&$this, &$title, &$file, &$frameParams, &$handlerParams, &$time, &$res))) {
return $res;
}
global $wgContLang, $wgUser, $wgThumbLimits, $wgThumbUpright;
if ($file && !$file->allowInlineDisplay()) {
wfDebug(__METHOD__ . ': ' . $title->getPrefixedDBkey() . " does not allow inline display\n");
return $this->link($title);
}
// Shortcuts
$fp =& $frameParams;
$hp =& $handlerParams;
// Clean up parameters
$page = isset($hp['page']) ? $hp['page'] : false;
if (!isset($fp['align'])) {
$fp['align'] = '';
}
if (!isset($fp['alt'])) {
$fp['alt'] = '';
}
# Backward compatibility, title used to always be equal to alt text
if (!isset($fp['title'])) {
$fp['title'] = $fp['alt'];
}
$prefix = $postfix = '';
if ('center' == $fp['align']) {
$prefix = '<div class="center">';
$postfix = '</div>';
$fp['align'] = 'none';
}
if ($file && !isset($hp['width'])) {
$hp['width'] = $file->getWidth($page);
if (isset($fp['thumbnail']) || isset($fp['framed']) || isset($fp['frameless']) || !$hp['width']) {
$wopt = $wgUser->getOption('thumbsize');
if (!isset($wgThumbLimits[$wopt])) {
$wopt = User::getDefaultOption('thumbsize');
}
// Reduce width for upright images when parameter 'upright' is used
if (isset($fp['upright']) && $fp['upright'] == 0) {
$fp['upright'] = $wgThumbUpright;
}
// Use width which is smaller: real image width or user preference width
// For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs
$prefWidth = isset($fp['upright']) ? round($wgThumbLimits[$wopt] * $fp['upright'], -1) : $wgThumbLimits[$wopt];
if ($hp['width'] <= 0 || $prefWidth < $hp['width']) {
$hp['width'] = $prefWidth;
}
}
}
if (isset($fp['thumbnail']) || isset($fp['manualthumb']) || isset($fp['framed'])) {
# Create a thumbnail. Alignment depends on language
# writing direction, # right aligned for left-to-right-
# languages ("Western languages"), left-aligned
# for right-to-left-languages ("Semitic languages")
#
# If thumbnail width has not been provided, it is set
# to the default user option as specified in Language*.php
if ($fp['align'] == '') {
$fp['align'] = $wgContLang->isRTL() ? 'left' : 'right';
}
return $prefix . $this->makeThumbLink2($title, $file, $fp, $hp, $time, $query) . $postfix;
}
if ($file && isset($fp['frameless'])) {
$srcWidth = $file->getWidth($page);
# For "frameless" option: do not present an image bigger than the source (for bitmap-style images)
# This is the same behaviour as the "thumb" option does it already.
//.........这里部分代码省略.........
示例12: modifiedImagePageOpenShowImage
function modifiedImagePageOpenShowImage()
{
global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgEnableUploads;
wfProfileIn(__METHOD__);
$full_url = $this->getFile()->getURL();
$anchoropen = '';
$anchorclose = '';
if ($wgUser->getOption('imagesize') == '') {
$sizeSel = User::getDefaultOption('imagesize');
} else {
$sizeSel = intval($wgUser->getOption('imagesize'));
}
if (!isset($wgImageLimits[$sizeSel])) {
$sizeSel = User::getDefaultOption('imagesize');
}
$max = $wgImageLimits[$sizeSel];
$maxWidth = $max[0];
$maxHeight = $max[1];
$maxWidth = 600;
$maxHeight = 460;
$sk = $wgUser->getSkin();
if ($this->getFile()->exists()) {
# image
$width = $this->getFile()->getWidth();
$height = $this->getFile()->getHeight();
$showLink = false;
if ($this->getFile()->allowInlineDisplay() && $width && $height) {
# image
# "Download high res version" link below the image
$msg = wfMsgHtml('show-big-image', $width, $height, intval($this->getFile()->getSize() / 1024));
# 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.
}
$thumbnail = $this->getFile()->transform(array('width' => $width), 0);
if ($thumbnail == null) {
$url = $this->getFile()->getViewURL();
} else {
$url = $thumbnail->getURL();
}
$anchoropen = "<a href=\"{$full_url}\">";
$anchorclose = "</a><br />";
if ($this->getFile()->mustRender()) {
$showLink = true;
} else {
$anchorclose .= "\n{$anchoropen}{$msg}</a>";
}
} else {
$url = $this->getFile()->getViewURL();
$showLink = true;
}
//$anchoropen = '';
//$anchorclose = '';
// $width = 'auto'; //'100%';
// $height = 'auto'; //'100%';
$wgOut->addHTML('<div class="fullImageLink" id="file">' . "<img border=\"0\" src=\"{$url}\" width=\"{$width}\" height=\"{$height}\" style=\"max-width: {$maxWidth}px;\" alt=\"" . htmlspecialchars($wgRequest->getVal('image')) . '" />' . $anchoropen . $anchorclose . '</div>');
} else {
# if direct link is allowed but it's not a renderable image, show an icon.
if ($this->getFile()->isSafeFile()) {
$icon = $this->getFile()->iconThumb();
$wgOut->addHTML('<div class="fullImageLink" id="file"><a href="' . $full_url . '">' . $icon->toHtml() . '</a></div>');
}
$showLink = true;
}
if ($showLink) {
$filename = wfEscapeWikiText($this->getFile()->getName());
$info = wfMsg('file-info', $sk->formatSize($this->getFile()->getSize()), $this->getFile()->getMimeType());
if (!$this->getFile()->isSafeFile()) {
$warning = wfMsg('mediawarning');
$wgOut->addWikiText(<<<END
<div class="fullMedia">
<span class="dangerousLink">[[Media:{$filename}|{$filename}]]</span>
<span class="fileInfo"> ({$info})</span>
</div>
<div class="mediaWarning">{$warning}</div>
END
);
} else {
$wgOut->addWikiText(<<<END
<div class="fullMedia">
[[Media:{$filename}|{$filename}]] <span class="fileInfo"> ({$info})</span>
</div>
END
);
}
}
if ($this->getFile()->fromSharedDirectory) {
$this->printSharedImageText();
//.........这里部分代码省略.........
示例13: openShowImage
protected function openShowImage()
{
global $wgImageLimits, $wgEnableUploads, $wgSend404Code;
$this->loadFile();
$out = $this->getContext()->getOutput();
$user = $this->getContext()->getUser();
$lang = $this->getContext()->getLanguage();
$dirmark = $lang->getDirMarkEntity();
$request = $this->getContext()->getRequest();
$sizeSel = intval($user->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];
if ($this->displayImg->exists()) {
# image
$page = $request->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 = wfMessage('parentheses', $this->displayImg->getLongDesc())->text();
wfRunHooks('ImageOpenShowImageInlineBefore', array(&$this, &$out));
if ($this->displayImg->allowInlineDisplay()) {
# image
# "Download high res version" link below the image
# $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
# 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 = wfMessage('show-big-image')->escaped();
if ($this->displayImg->getRepo()->canTransformVia404()) {
$thumbSizes = $wgImageLimits;
} else {
# Creating thumb links triggers thumbnail generation.
# Just generate the thumb for the current users prefs.
$thumbOption = $user->getOption('thumbsize');
$thumbSizes = array(isset($wgImageLimits[$thumbOption]) ? $wgImageLimits[$thumbOption] : $wgImageLimits[User::getDefaultOption('thumbsize')]);
}
# Generate thumbnails or thumbnail links as needed...
$otherSizes = array();
foreach ($thumbSizes 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)) {
$msgsmall .= ' ' . Html::rawElement('span', array('class' => 'mw-filepage-other-resolutions'), wfMessage('show-big-image-other')->rawParams($lang->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 = '';
} 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);
$showLink = true;
$anchorclose = Html::rawElement('div', array('class' => 'mw-filepage-resolutioninfo'), $msgsmall);
$isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
if ($isMulti) {
$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");
}
//.........这里部分代码省略.........
示例14: openShowImage
function openShowImage()
{
global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang;
$full_url = $this->img->getURL();
$linkAttribs = false;
$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];
//XXMOD for fixed width new layout. eventhough 800x600 is default 679 is max article width
if ($maxWidth > 679) {
$maxWidth = 629;
}
$maxHeight = $max[1];
$sk = $wgUser->getSkin();
$dirmark = $wgContLang->getDirMark();
if ($this->img->exists()) {
# image
$page = $wgRequest->getIntOrNull('page');
if (is_null($page)) {
$params = array();
$page = 1;
} else {
$params = array('page' => $page);
}
$width_orig = $this->img->getWidth();
$width = $width_orig;
$height_orig = $this->img->getHeight();
$height = $height_orig;
$mime = $this->img->getMimeType();
$showLink = false;
$linkAttribs = array('href' => $full_url);
$longDesc = $this->img->getLongDesc();
wfRunHooks('ImageOpenShowImageInlineBefore', array(&$this, &$wgOut));
if ($this->img->allowInlineDisplay()) {
# image
# "Download high res version" link below the image
#$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img->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');
$msgsmall = wfMsgExt('show-big-image-thumb', array('parseinline'), $wgLang->formatNum($width), $wgLang->formatNum($height));
} else {
# Image is small enough to show full size on image page
$msgbig = htmlspecialchars($this->img->getName());
$msgsmall = wfMsgExt('file-nohires', array('parseinline'));
}
$params['width'] = $width;
$thumbnail = $this->img->transform($params);
$anchorclose = "<br />";
if ($this->img->mustRender()) {
$showLink = true;
} else {
$anchorclose .= $msgsmall . '<br />' . Xml::tags('a', $linkAttribs, $msgbig) . "{$dirmark} " . $longDesc;
}
if ($this->img->isMultipage()) {
$wgOut->addHTML('<table class="multipageimage"><tr><td>');
}
if ($thumbnail) {
$options = array('alt' => $this->img->getTitle()->getPrefixedText(), 'file-link' => true);
$thumb = $thumbnail->toHtml($options);
$recent = wfTimestamp(TS_MW, time() - 3600);
//XXXCHANGED: Due to the CDN works, don't show the CDN image on the image
// page if it's been changed within the past hour, it needs some time
// to update
if ($this->img->timestamp > $recent) {
$thumb = preg_replace("@http://[a-z0-9]*.wikihow.com@im", "", $thumb);
}
$wgOut->addHTML('<div class="fullImageLink minor_section" id="file">' . $thumb . '</div>');
}
if ($this->img->isMultipage()) {
$count = $this->img->pageCount();
if ($page > 1) {
$label = $wgOut->parse(wfMsg('imgmultipageprev'), false);
$link = $sk->makeKnownLinkObj($this->mTitle, $label, 'page=' . ($page - 1));
$thumb1 = $sk->makeThumbLinkObj($this->mTitle, $this->img, $link, $label, 'none', array('page' => $page - 1));
} else {
$thumb1 = '';
}
//.........这里部分代码省略.........
示例15: makeImageLinkObj
/** @todo document */
function makeImageLinkObj($nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false, $thumb = false, $manual_thumb = '')
{
global $wgContLang, $wgUser, $wgThumbLimits;
$img = new Image($nt);
$url = $img->getViewURL();
$prefix = $postfix = '';
wfDebug("makeImageLinkObj: '{$width}'x'{$height}'\n");
if ('center' == $align) {
$prefix = '<div class="center">';
$postfix = '</div>';
$align = 'none';
}
if ($thumb || $framed) {
# Create a thumbnail. Alignment depends on language
# writing direction, # right aligned for left-to-right-
# languages ("Western languages"), left-aligned
# for right-to-left-languages ("Semitic languages")
#
# If thumbnail width has not been provided, it is set
# to the default user option as specified in Language*.php
if ($align == '') {
$align = $wgContLang->isRTL() ? 'left' : 'right';
}
if ($width === false) {
$wopt = $wgUser->getOption('thumbsize');
if (!isset($wgThumbLimits[$wopt])) {
$wopt = User::getDefaultOption('thumbsize');
}
$width = $wgThumbLimits[$wopt];
}
return $prefix . $this->makeThumbLinkObj($img, $label, $alt, $align, $width, $height, $framed, $manual_thumb) . $postfix;
} elseif ($width) {
# Create a resized image, without the additional thumbnail
# features
if ($height !== false && $img->getHeight() * $width / $img->getWidth() > $height) {
$width = $img->getWidth() * $height / $img->getHeight();
}
if ($manual_thumb == '') {
$thumb = $img->getThumbnail($width);
if ($thumb) {
if ($width > $thumb->width) {
// Requested a display size larger than the actual image;
// fake it up!
$height = floor($thumb->height * $width / $thumb->width);
wfDebug("makeImageLinkObj: client-size height set to '{$height}'\n");
} else {
$height = $thumb->height;
wfDebug("makeImageLinkObj: thumb height set to '{$height}'\n");
}
$url = $thumb->getUrl();
}
}
} else {
$width = $img->width;
$height = $img->height;
}
wfDebug("makeImageLinkObj2: '{$width}'x'{$height}'\n");
$u = $nt->escapeLocalURL();
if ($url == '') {
$s = $this->makeBrokenImageLinkObj($img->getTitle());
//$s .= "<br />{$alt}<br />{$url}<br />\n";
} else {
$s = '<a href="' . $u . '" class="image" title="' . $alt . '">' . '<img src="' . $url . '" alt="' . $alt . '" ' . ($width ? 'width="' . $width . '" height="' . $height . '" ' : '') . 'longdesc="' . $u . '" /></a>';
}
if ('' != $align) {
$s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
}
return str_replace("\n", ' ', $prefix . $s . $postfix);
}