本文整理汇总了PHP中Title::getLocalURL方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::getLocalURL方法的具体用法?PHP Title::getLocalURL怎么用?PHP Title::getLocalURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::getLocalURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAction
/**
* Prepare the form action
*
* @return string
*/
private function getAction()
{
$q = array();
$q['action'] = 'delete';
if ($this->oldimage) {
$q['oldimage'] = $this->oldimage;
}
return $this->title->getLocalURL($q);
}
示例2: getLanguageVariants
/**
* Returns an array of language variants that the page is available in
* @return array
*/
private function getLanguageVariants()
{
$pageLang = $this->title->getPageLanguage();
$variants = $pageLang->getVariants();
if (count($variants) > 1) {
$pageLangCode = $pageLang->getCode();
$output = array();
// Loops over each variant
foreach ($variants as $code) {
// Gets variant name from language code
$varname = $pageLang->getVariantname($code);
// Don't list the current variant
if ($varname !== $pageLangCode) {
// Appends variant link
$output[] = array('langname' => $varname, 'url' => $this->title->getLocalURL(array('variant' => $code)), 'lang' => wfBCP47($code));
}
}
return $output;
} else {
// No variants
return array();
}
}
示例3: execute
function execute()
{
global $wgOut, $wgRequest, $wgUser;
$repoExists = (bool) $this->repo;
$repoPath = $wgRequest->getVal('wpRepoPath', $repoExists ? $this->repo->getPath() : '');
$bugPath = $wgRequest->getVal('wpBugPath', $repoExists ? $this->repo->getBugzillaBase() : '');
$viewPath = $wgRequest->getVal('wpViewPath', $repoExists ? $this->repo->getViewVcBase() : '');
if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'), $this->repoName)) {
// @todo log
$dbw = wfGetDB(DB_MASTER);
if ($repoExists) {
$dbw->update('code_repo', array('repo_path' => $repoPath, 'repo_viewvc' => $viewPath, 'repo_bugzilla' => $bugPath), array('repo_id' => $this->repo->getId()), __METHOD__);
} else {
$dbw->insert('code_repo', array('repo_name' => $this->repoName, 'repo_path' => $repoPath, 'repo_viewvc' => $viewPath, 'repo_bugzilla' => $bugPath), __METHOD__);
}
$wgOut->wrapWikiMsg('<div class="successbox">$1</div>', array('repoadmin-edit-sucess', $this->repoName));
return;
}
$wgOut->addHTML(Xml::fieldset(wfMsg('repoadmin-edit-legend', $this->repoName)) . Xml::openElement('form', array('method' => 'post', 'action' => $this->title->getLocalURL())) . Xml::buildForm(array('repoadmin-edit-path' => Xml::input('wpRepoPath', 60, $repoPath, array('dir' => 'ltr')), 'repoadmin-edit-bug' => Xml::input('wpBugPath', 60, $bugPath, array('dir' => 'ltr')), 'repoadmin-edit-view' => Xml::input('wpViewPath', 60, $viewPath, array('dir' => 'ltr')))) . Html::hidden('wpEditToken', $wgUser->editToken($this->repoName)) . Xml::submitButton(wfMsg('repoadmin-edit-button')) . '</form></fieldset>');
}
示例4: threadCommands
/**
* @param $thread Thread
* Example return value:
* array (
* edit => array( 'label' => 'Edit',
* 'href' => 'http...',
* 'enabled' => false ),
* reply => array( 'label' => 'Reply',
* 'href' => 'http...',
* 'enabled' => true )
* )
*/
function threadCommands($thread)
{
$commands = array();
$isLqtPage = LqtDispatch::isLqtPage($thread->getTitle());
$history_url = self::permalinkUrlWithQuery($thread, array('action' => 'history'));
$commands['history'] = array('label' => wfMessage('history_short')->parse(), 'href' => $history_url, 'enabled' => true);
if ($thread->isHistorical()) {
return array();
}
$user_can_edit = $thread->root()->getTitle()->quickUserCan('edit');
$editMsg = $user_can_edit ? 'edit' : 'viewsource';
if ($isLqtPage) {
$commands['edit'] = array('label' => wfMessage($editMsg)->parse(), 'href' => $this->talkpageUrl($this->title, 'edit', $thread, true, $this->request), 'enabled' => true);
}
if ($this->user->isAllowed('delete')) {
$delete_url = $thread->title()->getLocalURL('action=delete');
$deleteMsg = $thread->type() == Threads::TYPE_DELETED ? 'lqt_undelete' : 'delete';
$commands['delete'] = array('label' => wfMessage($deleteMsg)->parse(), 'href' => $delete_url, 'enabled' => true);
}
if ($isLqtPage) {
if (!$thread->isTopmostThread() && $this->user->isAllowed('lqt-split')) {
$splitUrl = SpecialPage::getTitleFor('SplitThread', $thread->title()->getPrefixedText())->getLocalURL();
$commands['split'] = array('label' => wfMessage('lqt-thread-split')->parse(), 'href' => $splitUrl, 'enabled' => true);
}
if ($this->user->isAllowed('lqt-merge')) {
$mergeParams = $_GET;
$mergeParams['lqt_merge_from'] = $thread->id();
unset($mergeParams['title']);
$mergeUrl = $this->title->getLocalURL(wfArrayToCgi($mergeParams));
$label = wfMessage('lqt-thread-merge')->parse();
$commands['merge'] = array('label' => $label, 'href' => $mergeUrl, 'enabled' => true);
}
}
$commands['link'] = array('label' => wfMessage('lqt_permalink')->parse(), 'href' => $thread->title()->getLocalURL(), 'enabled' => true, 'showlabel' => true, 'tooltip' => wfMessage('lqt_permalink')->parse());
Hooks::run('LiquidThreadsThreadCommands', array($thread, &$commands));
return $commands;
}
示例5: tabAction
/**
* Builds an array with tab definition
*
* @param Title $title Page Where the tab links to
* @param string|array $message Message key or an array of message keys (will fall back)
* @param bool $selected Display the tab as selected
* @param string $query Query string attached to tab URL
* @param bool $checkEdit Check if $title exists and mark with .new if one doesn't
*
* @return array
*/
function tabAction($title, $message, $selected, $query = '', $checkEdit = false)
{
$classes = array();
if ($selected) {
$classes[] = 'selected';
}
if ($checkEdit && !$title->isKnown()) {
$classes[] = 'new';
if ($query !== '') {
$query = 'action=edit&redlink=1&' . $query;
} else {
$query = 'action=edit&redlink=1';
}
}
// wfMessageFallback will nicely accept $message as an array of fallbacks
// or just a single key
$msg = wfMessageFallback($message)->setContext($this->getContext());
if (is_array($message)) {
// for hook compatibility just keep the last message name
$message = end($message);
}
if ($msg->exists()) {
$text = $msg->text();
} else {
global $wgContLang;
$text = $wgContLang->getConverter()->convertNamespace(MWNamespace::getSubject($title->getNamespace()));
}
$result = array();
if (!Hooks::run('SkinTemplateTabAction', array(&$this, $title, $message, $selected, $checkEdit, &$classes, &$query, &$text, &$result))) {
return $result;
}
return array('class' => implode(' ', $classes), 'text' => $text, 'href' => $title->getLocalURL($query), 'primary' => true);
}
示例6: getActionURL
/**
* Returns the URL to use in the form's action attribute.
* This is used by EditPage subclasses when simply customizing the action
* variable in the constructor is not enough. This can be used when the
* EditPage lives inside of a Special page rather than a custom page action.
*
* @param $title Title object for which is being edited (where we go to for &action= links)
* @return string
*/
protected function getActionURL(Title $title)
{
return $title->getLocalURL(array('action' => $this->action));
}
示例7: beforePageDisplayHTML
//.........这里部分代码省略.........
}
}
if (self::$enableImages == 1) {
$disableImages = $wgRequest->getCookie('disableImages');
if ($disableImages) {
$wgRequest->response()->setcookie('disableImages', '');
}
$location = str_replace('?enableImages=1', '', str_replace('&enableImages=1', '', $wgRequest->getFullRequestURL()));
$location = str_replace('&mfi=1', '', str_replace('&mfi=0', '', $location));
$location = $this->getRelativeURL($location);
$wgRequest->response()->header('Location: ' . $location . '&mfi=1');
}
self::$format = $wgRequest->getText('format');
self::$callback = $wgRequest->getText('callback');
self::$requestedSegment = $wgRequest->getText('seg', 0);
self::$search = $wgRequest->getText('search');
self::$searchField = $wgRequest->getText('search', '');
$device = new DeviceDetection();
if ($xDevice) {
$formatName = $xDevice;
} else {
$formatName = $device->formatName($userAgent, $acceptHeader);
}
self::$device = $device->format($formatName);
if (self::$device['view_format'] === 'wml') {
$this->contentFormat = 'WML';
} elseif (self::$device['view_format'] === 'html') {
$this->contentFormat = 'XHTML';
}
if (self::$useFormat === 'mobile-wap') {
$this->contentFormat = 'WML';
}
if ($mobileAction == 'leave_feedback') {
echo $this->renderLeaveFeedbackXHTML();
wfProfileOut(__METHOD__);
exit;
}
if ($mobileAction == 'leave_feedback_post') {
$this->getMsg();
$subject = $wgRequest->getText('subject', '');
$message = $wgRequest->getText('message', '');
$token = $wgRequest->getText('edittoken', '');
$title = Title::newFromText(self::$messages['mobile-frontend-feedback-page']);
if ($title->userCan('edit') && !$wgUser->isBlockedFrom($title) && $wgUser->matchEditToken($token)) {
$article = new Article($title, 0);
$rawtext = $article->getRawText();
$rawtext .= "\n== {$subject} == \n {$message} ~~~~ \n <small>User agent: {$userAgent}</small> ";
$article->doEdit($rawtext, '');
}
$location = str_replace('&mobileaction=leave_feedback_post', '', $wgRequest->getFullRequestURL() . '¬iceid=1&useformat=mobile');
$location = $this->getRelativeURL($location);
$wgRequest->response()->header('Location: ' . $location);
wfProfileOut(__METHOD__);
exit;
}
if ($mobileAction == 'disable_mobile_site' && $this->contentFormat == 'XHTML') {
echo $this->renderDisableMobileSiteXHTML();
wfProfileOut(__METHOD__);
exit;
}
if ($mobileAction == 'opt_in_mobile_site' && $this->contentFormat == 'XHTML') {
echo $this->renderOptInMobileSiteXHTML();
wfProfileOut(__METHOD__);
exit;
}
if ($mobileAction == 'opt_out_mobile_site' && $this->contentFormat == 'XHTML') {
echo $this->renderOptOutMobileSiteXHTML();
wfProfileOut(__METHOD__);
exit;
}
if ($mobileAction == 'opt_in_cookie') {
wfIncrStats('mobile.opt_in_cookie_set');
$this->setOptInOutCookie('1');
$this->disableCaching();
$location = wfExpandUrl(Title::newMainPage()->getFullURL(), PROTO_CURRENT);
$wgRequest->response()->header('Location: ' . $location);
}
if ($mobileAction == 'opt_out_cookie') {
$this->setOptInOutCookie('');
}
$this->getMsg();
$this->disableCaching();
$this->sendXDeviceVaryHeader();
$this->sendApplicationVersionVaryHeader();
$this->checkUserStatus();
$this->checkUserLoggedIn();
if (self::$title->isSpecial('Userlogin') && self::$isBetaGroupMember) {
self::$wsLoginToken = $wgRequest->getSessionData('wsLoginToken');
$q = array('action' => 'submitlogin', 'type' => 'login');
$returnToVal = $wgRequest->getVal('returnto');
if ($returnToVal) {
$q['returnto'] = $returnToVal;
}
self::$wsLoginFormAction = self::$title->getLocalURL($q);
}
$this->setDefaultLogo();
ob_start(array($this, 'DOMParse'));
wfProfileOut(__METHOD__);
return true;
}
示例8: makeThumbLink2
/**
* @param Title $title
* @param File $file
* @param array $frameParams
* @param array $handlerParams
* @param bool $time
* @param string $query
* @return string
*/
public static function makeThumbLink2(Title $title, $file, $frameParams = [], $handlerParams = [], $time = false, $query = "")
{
$exists = $file && $file->exists();
# Shortcuts
$fp =& $frameParams;
$hp =& $handlerParams;
$page = isset($hp['page']) ? $hp['page'] : false;
if (!isset($fp['align'])) {
$fp['align'] = 'right';
}
if (!isset($fp['alt'])) {
$fp['alt'] = '';
}
if (!isset($fp['title'])) {
$fp['title'] = '';
}
if (!isset($fp['caption'])) {
$fp['caption'] = '';
}
if (empty($hp['width'])) {
// Reduce width for upright images when parameter 'upright' is used
$hp['width'] = isset($fp['upright']) ? 130 : 180;
}
$thumb = false;
$noscale = false;
$manualthumb = false;
if (!$exists) {
$outerWidth = $hp['width'] + 2;
} else {
if (isset($fp['manualthumb'])) {
# Use manually specified thumbnail
$manual_title = Title::makeTitleSafe(NS_FILE, $fp['manualthumb']);
if ($manual_title) {
$manual_img = wfFindFile($manual_title);
if ($manual_img) {
$thumb = $manual_img->getUnscaledThumb($hp);
$manualthumb = true;
} else {
$exists = false;
}
}
} elseif (isset($fp['framed'])) {
// Use image dimensions, don't scale
$thumb = $file->getUnscaledThumb($hp);
$noscale = true;
} else {
# Do not present an image bigger than the source, for bitmap-style images
# This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
$srcWidth = $file->getWidth($page);
if ($srcWidth && !$file->mustRender() && $hp['width'] > $srcWidth) {
$hp['width'] = $srcWidth;
}
$thumb = $file->transform($hp);
}
if ($thumb) {
$outerWidth = $thumb->getWidth() + 2;
} else {
$outerWidth = $hp['width'] + 2;
}
}
# ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
# So we don't need to pass it here in $query. However, the URL for the
# zoom icon still needs it, so we make a unique query for it. See bug 14771
$url = $title->getLocalURL($query);
if ($page) {
$url = wfAppendQuery($url, ['page' => $page]);
}
if ($manualthumb && !isset($fp['link-title']) && !isset($fp['link-url']) && !isset($fp['no-link'])) {
$fp['link-url'] = $url;
}
$s = "<div class=\"thumb t{$fp['align']}\">" . "<div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
if (!$exists) {
$s .= self::makeBrokenImageLinkObj($title, $fp['title'], '', '', '', $time == true);
$zoomIcon = '';
} elseif (!$thumb) {
$s .= wfMessage('thumbnail_error', '')->escaped();
$zoomIcon = '';
} else {
if (!$noscale && !$manualthumb) {
self::processResponsiveImages($file, $thumb, $hp);
}
$params = ['alt' => $fp['alt'], 'title' => $fp['title'], 'img-class' => (isset($fp['class']) && $fp['class'] !== '' ? $fp['class'] . ' ' : '') . 'thumbimage'];
$params = self::getImageLinkMTOParams($fp, $query) + $params;
$s .= $thumb->toHtml($params);
if (isset($fp['framed'])) {
$zoomIcon = "";
} else {
$zoomIcon = Html::rawElement('div', ['class' => 'magnify'], Html::rawElement('a', ['href' => $url, 'class' => 'internal', 'title' => wfMessage('thumbnail-more')->text()], ""));
}
}
$s .= ' <div class="thumbcaption">' . $zoomIcon . $fp['caption'] . "</div></div></div>";
//.........这里部分代码省略.........
示例9: selfLink2
protected function selfLink2($title, $overrides)
{
$changed = $this->opts->getChangedValues();
$target = $this->title->getLocalURL(wfArrayToCGI($overrides, $changed));
return Xml::tags('a', array('href' => $target), $title);
}
示例10: array
function makeThumbLink2(Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false)
{
global $wgStylePath, $wgContLang;
$exists = $file && $file->exists();
# Shortcuts
$fp =& $frameParams;
$hp =& $handlerParams;
$page = isset($hp['page']) ? $hp['page'] : false;
if (!isset($fp['align'])) {
$fp['align'] = 'right';
}
if (!isset($fp['alt'])) {
$fp['alt'] = '';
}
if (!isset($fp['caption'])) {
$fp['caption'] = '';
}
$imageClass = "";
if (empty($hp['width'])) {
// Reduce width for upright images when parameter 'upright' is used
$hp['width'] = isset($fp['upright']) ? 130 : 180;
}
$thumb = false;
if (!$exists) {
$outerWidth = $hp['width'] + 2;
} else {
if (isset($fp['manualthumb'])) {
# Use manually specified thumbnail
$manual_title = Title::makeTitleSafe(NS_IMAGE, $fp['manualthumb']);
if ($manual_title) {
$manual_img = wfFindFile($manual_title);
if ($manual_img) {
$thumb = $manual_img->getUnscaledThumb();
} else {
$exists = false;
}
}
} elseif (isset($fp['framed'])) {
// Use image dimensions, don't scale
$thumb = $file->getUnscaledThumb($page);
} else {
# Do not present an image bigger than the source, for bitmap-style images
# This is a hack to maintain compatibility with arbitrary pre-1.10 behaviour
$srcWidth = $file->getWidth($page);
if ($srcWidth && !$file->mustRender() && $hp['width'] > $srcWidth) {
$hp['width'] = $srcWidth;
}
if ($sourceWidth >= 400) {
//this is our low threshold, so show it as big as possible
$hp['width'] = min(700, $srcWidth);
$maxWidth = 1100;
$imageClass .= " largeimage ";
} else {
$maxWidth = $hp['width'];
}
$thumb = $file->transform($hp);
}
if ($thumb) {
$outerWidth = $thumb->getWidth() + 2;
} else {
$outerWidth = $hp['width'] + 2;
}
}
$query = $page ? 'page=' . urlencode($page) : '';
$url = $title->getLocalURL($query);
$more = htmlspecialchars(wfMsg('thumbnail-more'));
$w = $h = "";
if ($thumb) {
$w = $thumb->getWidth();
$h = $thumb->getHeight();
}
//XXCHANGED FOR ROUNDED CORNERS
#$s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
#$s = "<div class=\"thumb t{$fp['align']}\" style=\"width:{$width}px;height:{$h}px\><div class=\"rounders\" style=\"\">";
$imageClass .= " t{$fp['align']} ";
$imageClass .= " mthumb ";
//$s = "<div class=\"thumb t{$fp['align']}\">";
if (!$exists) {
$s .= $this->makeBrokenImageLinkObj($title, '', '', '', '', $time == true);
$zoomicon = '';
} elseif (!$thumb) {
$s .= htmlspecialchars(wfMsg('thumbnail_error', ''));
$zoomicon = '';
} else {
$s .= $thumb->toHtml(array('alt' => $fp['alt'], 'desc-link' => true));
if (isset($fp['framed'])) {
$zoomicon = "";
} else {
$zoomicon = '';
}
}
$s .= $zoomicon . "<span class='caption'>" . $fp['caption'] . "</span>";
#echo $s; exit;
if (class_exists('InaccurateImages')) {
$rptLink = InaccurateImages::getReportImageLink();
}
$s = "<div class='mwimg {$imageClass}' style='max-width:{$maxWidth}px'>{$rptLink}{$s}</div>";
return str_replace("\n", ' ', $s);
}
示例11: array
function makeThumbLink2(Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false, $query = "")
{
global $wgStylePath, $wgContLang;
$exists = $file && $file->exists();
# Shortcuts
$fp =& $frameParams;
$hp =& $handlerParams;
$page = isset($hp['page']) ? $hp['page'] : false;
if (!isset($fp['align'])) {
$fp['align'] = 'right';
}
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'];
}
if (!isset($fp['caption'])) {
$fp['caption'] = '';
}
if (empty($hp['width'])) {
// Reduce width for upright images when parameter 'upright' is used
$hp['width'] = isset($fp['upright']) ? 130 : 180;
}
$thumb = false;
if (!$exists) {
$outerWidth = $hp['width'] + 2;
} else {
if (isset($fp['manualthumb'])) {
# Use manually specified thumbnail
$manual_title = Title::makeTitleSafe(NS_FILE, $fp['manualthumb']);
if ($manual_title) {
$manual_img = wfFindFile($manual_title);
if ($manual_img) {
$thumb = $manual_img->getUnscaledThumb();
} else {
$exists = false;
}
}
} elseif (isset($fp['framed'])) {
// Use image dimensions, don't scale
$thumb = $file->getUnscaledThumb($page);
} else {
# Do not present an image bigger than the source, for bitmap-style images
# This is a hack to maintain compatibility with arbitrary pre-1.10 behaviour
$srcWidth = $file->getWidth($page);
if ($srcWidth && !$file->mustRender() && $hp['width'] > $srcWidth) {
$hp['width'] = $srcWidth;
}
$thumb = $file->transform($hp);
}
if ($thumb) {
$outerWidth = $thumb->getWidth() + 2;
} else {
$outerWidth = $hp['width'] + 2;
}
}
# ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
# So we don't need to pass it here in $query. However, the URL for the
# zoom icon still needs it, so we make a unique query for it. See bug 14771
$url = $title->getLocalURL($query);
if ($page) {
$url = wfAppendQuery($url, 'page=' . urlencode($page));
}
$more = htmlspecialchars(wfMsg('thumbnail-more'));
$s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
if (!$exists) {
$s .= $this->makeBrokenImageLinkObj($title, '', '', '', '', $time == true);
$zoomicon = '';
} elseif (!$thumb) {
$s .= htmlspecialchars(wfMsg('thumbnail_error', ''));
$zoomicon = '';
} else {
$s .= $thumb->toHtml(array('alt' => $fp['alt'], 'title' => $fp['title'], 'img-class' => 'thumbimage', 'desc-link' => true, 'desc-query' => $query));
if (isset($fp['framed'])) {
$zoomicon = "";
} else {
$zoomicon = '<div class="magnify">' . '<a href="' . $url . '" class="internal" title="' . $more . '">' . '<img src="' . $wgStylePath . '/common/images/magnify-clip.png" ' . 'width="15" height="11" alt="" /></a></div>';
}
}
$s .= ' <div class="thumbcaption">' . $zoomicon . $fp['caption'] . "</div></div></div>";
return str_replace("\n", ' ', $s);
}
示例12: buildTagFilterSelector
/**
* Build a text box to select a change tag
*
* @param $selected String: tag to select by default
* @param $fullForm Boolean:
* - if false, then it returns an array of (label, form).
* - if true, it returns an entire form around the selector.
* @param $title Title object to send the form to.
* Used when, and only when $fullForm is true.
* @return String or array:
* - if $fullForm is false: Array with
* - if $fullForm is true: String, html fragment
*/
public static function buildTagFilterSelector($selected = '', $fullForm = false, Title $title = null)
{
global $wgUseTagFilter;
if (!$wgUseTagFilter || !count(self::listDefinedTags())) {
return $fullForm ? '' : array();
}
$data = array(Html::rawElement('label', array('for' => 'tagfilter'), wfMsgExt('tag-filter', 'parseinline')), Xml::input('tagfilter', 20, $selected));
if (!$fullForm) {
return $data;
}
$html = implode(' ', $data);
$html .= "\n" . Xml::element('input', array('type' => 'submit', 'value' => wfMsg('tag-filter-submit')));
$html .= "\n" . Html::hidden('title', $title->getPrefixedText());
$html = Xml::tags('form', array('action' => $title->getLocalURL(), 'method' => 'get'), $html);
return $html;
}
示例13: array
function makeThumbLink2(Title $title, $file, $frameParams = array(), $handlerParams = array())
{
global $wgStylePath, $wgContLang;
$exists = $file && $file->exists();
# Shortcuts
$fp =& $frameParams;
$hp =& $handlerParams;
$page = isset($hp['page']) ? $hp['page'] : false;
if (!isset($fp['align'])) {
$fp['align'] = 'right';
}
if (!isset($fp['alt'])) {
$fp['alt'] = '';
}
if (!isset($fp['caption'])) {
$fp['caption'] = '';
}
if (empty($hp['width'])) {
// Reduce width for upright images when parameter 'upright' is used
$hp['width'] = isset($fp['upright']) ? 130 : 180;
}
$thumb = false;
if (!$exists) {
$outerWidth = $hp['width'] + 2;
} else {
if (isset($fp['manualthumb'])) {
# Use manually specified thumbnail
$manual_title = Title::makeTitleSafe(NS_IMAGE, $fp['manualthumb']);
if ($manual_title) {
$manual_img = wfFindFile($manual_title);
if ($manual_img) {
$thumb = $manual_img->getUnscaledThumb();
} else {
$exists = false;
}
}
} elseif (isset($fp['framed'])) {
// Use image dimensions, don't scale
$thumb = $file->getUnscaledThumb($page);
} else {
# Do not present an image bigger than the source, for bitmap-style images
# This is a hack to maintain compatibility with arbitrary pre-1.10 behaviour
$srcWidth = $file->getWidth($page);
if ($srcWidth && !$file->mustRender() && $hp['width'] > $srcWidth) {
$hp['width'] = $srcWidth;
}
$thumb = $file->transform($hp);
}
if ($thumb) {
$outerWidth = $thumb->getWidth() + 2;
} else {
$outerWidth = $hp['width'] + 2;
}
}
$query = $page ? 'page=' . urlencode($page) : '';
$url = $title->getLocalURL($query);
$more = htmlspecialchars(wfMsg('thumbnail-more'));
$magnifyalign = $wgContLang->isRTL() ? 'left' : 'right';
$textalign = $wgContLang->isRTL() ? ' style="text-align:right"' : '';
$s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
if (!$exists) {
$s .= $this->makeBrokenImageLinkObj($title);
$zoomicon = '';
} elseif (!$thumb) {
$s .= htmlspecialchars(wfMsg('thumbnail_error', ''));
$zoomicon = '';
} else {
$path = $thumb->file->path;
$bitmap = true;
if (strstr(strtolower($path), "svg")) {
$bitmap = false;
} else {
// $thumb->url = $thumb->file->getURL();
}
$s .= $thumb->toHtml(array('alt' => $fp['alt'], 'img-class' => 'thumbimage', 'file-link' => $bitmap));
if ($bitmap) {
$s = str_replace("href=", "title=\"" . $fp['alt'] . "\" rel=\"lightbox\" href=", $s);
//kelson
}
/*
if ( isset( $fp['framed'] ) ) {
$zoomicon="";
} else {
$zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
'<a href="'.$url.'" rel="lightbox" class="internal" title="'.$more.'">'.
'<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
'width="15" height="11" alt="" /></a></div>';
}
*/
}
$s .= ' <div class="thumbcaption"' . $textalign . '>' . $zoomicon . $fp['caption'] . "</div></div></div>";
return str_replace("\n", ' ', $s);
}
示例14: buildShareUrl
private static function buildShareUrl($service, Title $title)
{
/** Legit globals */
global $egShareBarServices, $wgSitename;
/** Evil globals */
global $wgUser, $wgLanguageCode, $wgContLang;
/// Data gathering
$pageName = $title->getPrefixedText();
$url = wfExpandUrl($title->getLocalURL());
$msg = wfMessage("ext-sharebar-{$service}-msg");
$text = $msg->exists() ? $msg->params($pageName, $wgSitename, $url)->text() : '';
$categories = implode(',', array_keys($title->getParentCategories()));
$categories = str_replace($wgContLang->getNsText(NS_CATEGORY) . ':', '', $categories);
$categories = str_replace('_', ' ', $categories);
// Array of placeholder keys to replace with actual values
$placeholders = array('{url}' => rawurlencode($url), '{title}' => rawurlencode($pageName), '{text}' => rawurlencode($text), '{user_name}' => rawurlencode($wgUser->isLoggedIn() ? $wgUser->getName() : ''), '{user_email}' => rawurlencode($wgUser->isLoggedIn() ? $wgUser->getEmail() : ''), '{language}' => $wgLanguageCode, '{categories}' => rawurlencode($categories));
$serviceUrl = array('facebook' => 'http://www.facebook.com/sharer/sharer.php?s=100&p[url]={URL}&p[title]={TITLE}&p[summary]={TEXT}', 'twitter' => 'https://twitter.com/intent/tweet?url={URL}&text={TEXT}', 'gplus' => 'https://plus.google.com/share?url={URL}', 'send' => $egShareBarServices['send']['url'] . '?page={TITLE}&pageUrl={URL}&senderName={USER_NAME}&senderEmail={USER_EMAIL}', 'changerequest' => $egShareBarServices['changerequest']['url'] . '?page={TITLE}&name={USER_NAME}&email={USER_EMAIL}&lang={language}&categories={categories}');
$url = str_ireplace(array_keys($placeholders), array_values($placeholders), $serviceUrl[$service]);
return $url;
}
示例15: buildTagFilterSelector
/**
* Build a text box to select a change tag
*
* @param string $selected Tag to select by default
* @param bool $fullForm Affects return value, see below
* @param Title $title Title object to send the form to. Used only if $fullForm is true.
* @param bool $ooui Use an OOUI TextInputWidget as selector instead of a non-OOUI input field
* You need to call OutputPage::enableOOUI() yourself.
* @return string|array
* - if $fullForm is false: an array of (label, selector).
* - if $fullForm is true: HTML of entire form built around the selector.
*/
public static function buildTagFilterSelector($selected = '', $fullForm = false, Title $title = null, $ooui = false)
{
global $wgUseTagFilter;
if (!$wgUseTagFilter || !count(self::listDefinedTags())) {
return $fullForm ? '' : array();
}
$data = array(Html::rawElement('label', array('for' => 'tagfilter'), wfMessage('tag-filter')->parse()));
if ($ooui) {
$data[] = new OOUI\TextInputWidget(array('id' => 'tagfilter', 'name' => 'tagfilter', 'value' => $selected, 'classes' => 'mw-tagfilter-input'));
} else {
$data[] = Xml::input('tagfilter', 20, $selected, array('class' => 'mw-tagfilter-input mw-ui-input mw-ui-input-inline', 'id' => 'tagfilter'));
}
if (!$fullForm) {
return $data;
}
$html = implode(' ', $data);
$html .= "\n" . Xml::element('input', array('type' => 'submit', 'value' => wfMessage('tag-filter-submit')->text()));
$html .= "\n" . Html::hidden('title', $title->getPrefixedText());
$html = Xml::tags('form', array('action' => $title->getLocalURL(), 'class' => 'mw-tagfilter-form', 'method' => 'get'), $html);
return $html;
}