Example #1
0
 /**
  * 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);
 }
 /**
  * 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();
     }
 }
Example #3
0
 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>');
 }
Example #4
0
 /**
  * @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;
 }
 /**
  * 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);
 }
Example #6
0
 /**
  * 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));
 }
 /**
  * @param $out OutputPage
  * @param $text String
  * @return bool
  */
 public function beforePageDisplayHTML(&$out, &$text)
 {
     global $wgContLang, $wgRequest, $wgMemc, $wgUser;
     wfProfileIn(__METHOD__);
     $userAgent = $_SERVER['HTTP_USER_AGENT'];
     $acceptHeader = isset($_SERVER["HTTP_ACCEPT"]) ? $_SERVER["HTTP_ACCEPT"] : '';
     $uAmd5 = md5($userAgent);
     $key = wfMemcKey('mobile', 'ua', $uAmd5);
     $props = null;
     try {
         $props = $wgMemc->get($key);
         if (!$props) {
             $wurflConfigFile = RESOURCES_DIR . 'wurfl-config.xml';
             $wurflConfig = new WURFL_Configuration_XmlConfig($wurflConfigFile);
             $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
             $wurflManager = $wurflManagerFactory->create();
             $device = $wurflManager->getDeviceForHttpRequest($_SERVER);
             if ($device->isSpecific() === true) {
                 $props = $device->getAllCapabilities();
                 $wgMemc->set($key, $props, 86400);
             } else {
                 $wgMemc->set($key, 'generic', 86400);
                 $props = 'generic';
             }
         }
     } catch (Exception $e) {
         // echo $e->getMessage();
     }
     // Note: The WebRequest Class calls are made in this block because
     // since PHP 5.1.x, all objects have their destructors called
     // before the output buffer callback function executes.
     // Thus, globalized objects will not be available as expected in the function.
     // This is stated to be intended behavior, as per the following: [http://bugs.php.net/bug.php?id=40104]
     $xDevice = isset($_SERVER['HTTP_X_DEVICE']) ? $_SERVER['HTTP_X_DEVICE'] : '';
     self::$useFormat = $wgRequest->getText('useformat');
     $mobileAction = $wgRequest->getText('mobileaction');
     $action = $wgRequest->getText('action');
     if (self::$useFormat !== 'mobile' && self::$useFormat !== 'mobile-wap' && !$xDevice) {
         wfProfileOut(__METHOD__);
         return true;
     }
     if ($action === 'edit' || $mobileAction === 'view_normal_site') {
         wfProfileOut(__METHOD__);
         return true;
     }
     self::$title = $out->getTitle();
     if (self::$title->isMainPage()) {
         self::$isMainPage = true;
     }
     if (self::$title->getNamespace() == NS_FILE) {
         self::$isFilePage = true;
     }
     self::$htmlTitle = $out->getHTMLTitle();
     self::$disableImages = $wgRequest->getText('disableImages', 0);
     self::$enableImages = $wgRequest->getText('enableImages', 0);
     self::$displayNoticeId = $wgRequest->getText('noticeid', '');
     if (self::$disableImages == 1) {
         $wgRequest->response()->setcookie('disableImages', 1);
         $location = str_replace('?disableImages=1', '', str_replace('&disableImages=1', '', $wgRequest->getFullRequestURL()));
         $location = str_replace('&mfi=1', '', str_replace('&mfi=0', '', $location));
         $location = $this->getRelativeURL($location);
         $wgRequest->response()->header('Location: ' . $location . '&mfi=0');
     } elseif (self::$disableImages == 0) {
         $disableImages = $wgRequest->getCookie('disableImages');
         if ($disableImages) {
             self::$disableImages = $disableImages;
         }
     }
     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() . '&noticeid=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;
 }
Example #8
0
 /**
  * @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>";
     return str_replace("\n", ' ', $s);
 }
Example #9
0
 protected function selfLink2($title, $overrides)
 {
     $changed = $this->opts->getChangedValues();
     $target = $this->title->getLocalURL(wfArrayToCGI($overrides, $changed));
     return Xml::tags('a', array('href' => $target), $title);
 }
Example #10
0
 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);
 }
Example #11
0
 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);
 }
Example #12
0
 /**
  * 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('&#160;', $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;
 }
Example #13
0
 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);
 }
 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;
 }
Example #15
0
 /**
  * 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('&#160;', $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;
 }
 /**
  * Get some extra buttons for another footer
  * @param $title Title
  * @return string
  */
 protected function getSecondFooter(Title $title)
 {
     $html = '';
     if ($title->userCan('edit')) {
         $html .= new OOUI\ButtonWidget(['label' => wfMessage('collaborationkit-hub-manage')->inContentLanguage()->text(), 'href' => $title->getLocalURL(['action' => 'edit']), 'flags' => ['primary', 'progressive']]);
         // TODO make sure they have create permission, too
         $html .= new OOUI\ButtonWidget(['label' => wfMessage('collaborationkit-hub-addpage')->inContentLanguage()->text(), 'href' => SpecialPage::getTitleFor('CreateHubFeature')->getFullUrl(['collaborationhub' => $title->getFullText()]), 'flags' => ['primary', 'progressive']]);
     }
     return $html;
 }
Example #17
0
 /**
  * @param $title Title
  * @param  $file File
  * @param array $frameParams
  * @param array $handlerParams
  * @param bool $time
  * @param string $query
  * @return mixed
  */
 static 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'] = '';
     }
     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;
     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);
                 } else {
                     $exists = false;
                 }
             }
         } elseif (isset($fp['framed'])) {
             // Use image dimensions, don't scale
             $thumb = $file->getUnscaledThumb($hp);
         } 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));
     }
     $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 .= htmlspecialchars(wfMsg('thumbnail_error', ''));
         $zoomIcon = '';
     } else {
         $params = array('alt' => $fp['alt'], 'title' => $fp['title'], 'img-class' => 'thumbimage');
         $params = self::getImageLinkMTOParams($fp, $query) + $params;
         $s .= $thumb->toHtml($params);
         if (isset($fp['framed'])) {
             $zoomIcon = "";
         } else {
             $zoomIcon = Html::rawElement('div', array('class' => 'magnify'), Html::rawElement('a', array('href' => $url, 'class' => 'internal', 'title' => wfMsg('thumbnail-more')), Html::element('img', array('src' => $wgStylePath . '/common/images/magnify-clip' . ($wgContLang->isRTL() ? '-rtl' : '') . '.png', 'width' => 15, 'height' => 11, 'alt' => ""))));
         }
     }
     $s .= '  <div class="thumbcaption">' . $zoomIcon . $fp['caption'] . "</div></div></div>";
     return str_replace("\n", ' ', $s);
 }
 /**
  * For administrators, add a link to the special 'AdminLinks' page
  * among the user's "personal URLs" at the top, if they have
  * the 'adminlinks' permission.
  *
  * @param array $personal_urls
  * @param Title $title
  *
  * @return bool true
  */
 public static function addURLToUserLinks(array &$personal_urls, Title &$title)
 {
     global $wgUser;
     // if user is a sysop, add link
     if ($wgUser->isAllowed('adminlinks')) {
         $al = SpecialPage::getTitleFor('AdminLinks');
         $href = $al->getLocalURL();
         $admin_links_vals = array('text' => wfMessage('adminlinks')->text(), 'href' => $href, 'active' => $href == $title->getLocalURL());
         // find the location of the 'my preferences' link, and
         // add the link to 'AdminLinks' right before it.
         // this is a "key-safe" splice - it preserves both the
         // keys and the values of the array, by editing them
         // separately and then rebuilding the array.
         // based on the example at http://us2.php.net/manual/en/function.array-splice.php#31234
         $tab_keys = array_keys($personal_urls);
         $tab_values = array_values($personal_urls);
         $prefs_location = array_search('preferences', $tab_keys);
         array_splice($tab_keys, $prefs_location, 0, 'adminlinks');
         array_splice($tab_values, $prefs_location, 0, array($admin_links_vals));
         $personal_urls = array();
         for ($i = 0; $i < count($tab_keys); $i++) {
             $personal_urls[$tab_keys[$i]] = $tab_values[$i];
         }
     }
     return true;
 }
 public function showDiffPage($diffOnly = false)
 {
     # Allow frames except in certain special cases
     $out = $this->getOutput();
     $out->allowClickjacking();
     $out->setRobotPolicy('noindex,nofollow');
     if (!$this->loadRevisionData()) {
         $this->showMissingRevision();
         return;
     }
     $user = $this->getUser();
     $permErrors = $this->mNewPage->getUserPermissionsErrors('read', $user);
     if ($this->mOldPage) {
         # mOldPage might not be set, see below.
         $permErrors = wfMergeErrorArrays($permErrors, $this->mOldPage->getUserPermissionsErrors('read', $user));
     }
     if (count($permErrors)) {
         throw new PermissionsError('read', $permErrors);
     }
     $rollback = '';
     $query = array();
     # Carry over 'diffonly' param via navigation links
     if ($diffOnly != $user->getBoolOption('diffonly')) {
         $query['diffonly'] = $diffOnly;
     }
     # Cascade unhide param in links for easy deletion browsing
     if ($this->unhide) {
         $query['unhide'] = 1;
     }
     # Check if one of the revisions is deleted/suppressed
     $deleted = $suppressed = false;
     $allowed = $this->mNewRev->userCan(Revision::DELETED_TEXT, $user);
     $revisionTools = array();
     # mOldRev is false if the difference engine is called with a "vague" query for
     # a diff between a version V and its previous version V' AND the version V
     # is the first version of that article. In that case, V' does not exist.
     if ($this->mOldRev === false) {
         $out->setPageTitle($this->msg('difference-title', $this->mNewPage->getPrefixedText()));
         $samePage = true;
         $oldHeader = '';
     } else {
         Hooks::run('DiffViewHeader', array($this, $this->mOldRev, $this->mNewRev));
         if ($this->mNewPage->equals($this->mOldPage)) {
             $out->setPageTitle($this->msg('difference-title', $this->mNewPage->getPrefixedText()));
             $samePage = true;
         } else {
             $out->setPageTitle($this->msg('difference-title-multipage', $this->mOldPage->getPrefixedText(), $this->mNewPage->getPrefixedText()));
             $out->addSubtitle($this->msg('difference-multipage'));
             $samePage = false;
         }
         if ($samePage && $this->mNewPage->quickUserCan('edit', $user)) {
             if ($this->mNewRev->isCurrent() && $this->mNewPage->userCan('rollback', $user)) {
                 $rollbackLink = Linker::generateRollback($this->mNewRev, $this->getContext());
                 if ($rollbackLink) {
                     $out->preventClickjacking();
                     $rollback = '&#160;&#160;&#160;' . $rollbackLink;
                 }
             }
             if (!$this->mOldRev->isDeleted(Revision::DELETED_TEXT) && !$this->mNewRev->isDeleted(Revision::DELETED_TEXT)) {
                 $undoLink = Html::element('a', array('href' => $this->mNewPage->getLocalURL(array('action' => 'edit', 'undoafter' => $this->mOldid, 'undo' => $this->mNewid)), 'title' => Linker::titleAttrib('undo')), $this->msg('editundo')->text());
                 $revisionTools['mw-diff-undo'] = $undoLink;
             }
         }
         # Make "previous revision link"
         if ($samePage && $this->mOldRev->getPrevious()) {
             $prevlink = Linker::linkKnown($this->mOldPage, $this->msg('previousdiff')->escaped(), array('id' => 'differences-prevlink'), array('diff' => 'prev', 'oldid' => $this->mOldid) + $query);
         } else {
             $prevlink = '&#160;';
         }
         if ($this->mOldRev->isMinor()) {
             $oldminor = ChangesList::flag('minor');
         } else {
             $oldminor = '';
         }
         $ldel = $this->revisionDeleteLink($this->mOldRev);
         $oldRevisionHeader = $this->getRevisionHeader($this->mOldRev, 'complete');
         $oldChangeTags = ChangeTags::formatSummaryRow($this->mOldTags, 'diff');
         $oldHeader = '<div id="mw-diff-otitle1"><strong>' . $oldRevisionHeader . '</strong></div>' . '<div id="mw-diff-otitle2">' . Linker::revUserTools($this->mOldRev, !$this->unhide) . '</div>' . '<div id="mw-diff-otitle3">' . $oldminor . Linker::revComment($this->mOldRev, !$diffOnly, !$this->unhide) . $ldel . '</div>' . '<div id="mw-diff-otitle5">' . $oldChangeTags[0] . '</div>' . '<div id="mw-diff-otitle4">' . $prevlink . '</div>';
         if ($this->mOldRev->isDeleted(Revision::DELETED_TEXT)) {
             $deleted = true;
             // old revisions text is hidden
             if ($this->mOldRev->isDeleted(Revision::DELETED_RESTRICTED)) {
                 $suppressed = true;
                 // also suppressed
             }
         }
         # Check if this user can see the revisions
         if (!$this->mOldRev->userCan(Revision::DELETED_TEXT, $user)) {
             $allowed = false;
         }
     }
     # Make "next revision link"
     # Skip next link on the top revision
     if ($samePage && !$this->mNewRev->isCurrent()) {
         $nextlink = Linker::linkKnown($this->mNewPage, $this->msg('nextdiff')->escaped(), array('id' => 'differences-nextlink'), array('diff' => 'next', 'oldid' => $this->mNewid) + $query);
     } else {
         $nextlink = '&#160;';
     }
     if ($this->mNewRev->isMinor()) {
         $newminor = ChangesList::flag('minor');
     } else {
         $newminor = '';
     }
     # Handle RevisionDelete links...
     $rdel = $this->revisionDeleteLink($this->mNewRev);
     # Allow extensions to define their own revision tools
     Hooks::run('DiffRevisionTools', array($this->mNewRev, &$revisionTools, $this->mOldRev, $user));
     $formattedRevisionTools = array();
     // Put each one in parentheses (poor man's button)
     foreach ($revisionTools as $key => $tool) {
         $toolClass = is_string($key) ? $key : 'mw-diff-tool';
         $element = Html::rawElement('span', array('class' => $toolClass), $this->msg('parentheses')->rawParams($tool)->escaped());
         $formattedRevisionTools[] = $element;
     }
     $newRevisionHeader = $this->getRevisionHeader($this->mNewRev, 'complete') . ' ' . implode(' ', $formattedRevisionTools);
     $newChangeTags = ChangeTags::formatSummaryRow($this->mNewTags, 'diff');
     $newHeader = '<div id="mw-diff-ntitle1"><strong>' . $newRevisionHeader . '</strong></div>' . '<div id="mw-diff-ntitle2">' . Linker::revUserTools($this->mNewRev, !$this->unhide) . " {$rollback}</div>" . '<div id="mw-diff-ntitle3">' . $newminor . Linker::revComment($this->mNewRev, !$diffOnly, !$this->unhide) . $rdel . '</div>' . '<div id="mw-diff-ntitle5">' . $newChangeTags[0] . '</div>' . '<div id="mw-diff-ntitle4">' . $nextlink . $this->markPatrolledLink() . '</div>';
     if ($this->mNewRev->isDeleted(Revision::DELETED_TEXT)) {
         $deleted = true;
         // new revisions text is hidden
         if ($this->mNewRev->isDeleted(Revision::DELETED_RESTRICTED)) {
             $suppressed = true;
             // also suppressed
         }
     }
     # If the diff cannot be shown due to a deleted revision, then output
     # the diff header and links to unhide (if available)...
     if ($deleted && (!$this->unhide || !$allowed)) {
         $this->showDiffStyle();
         $multi = $this->getMultiNotice();
         $out->addHTML($this->addHeader('', $oldHeader, $newHeader, $multi));
         if (!$allowed) {
             $msg = $suppressed ? 'rev-suppressed-no-diff' : 'rev-deleted-no-diff';
             # Give explanation for why revision is not visible
             $out->wrapWikiMsg("<div id='mw-{$msg}' class='mw-warning plainlinks'>\n\$1\n</div>\n", array($msg));
         } else {
             # Give explanation and add a link to view the diff...
             $query = $this->getRequest()->appendQueryValue('unhide', '1');
             $link = $this->getTitle()->getFullURL($query);
             $msg = $suppressed ? 'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff';
             $out->wrapWikiMsg("<div id='mw-{$msg}' class='mw-warning plainlinks'>\n\$1\n</div>\n", array($msg, $link));
         }
         # Otherwise, output a regular diff...
     } else {
         # Add deletion notice if the user is viewing deleted content
         $notice = '';
         if ($deleted) {
             $msg = $suppressed ? 'rev-suppressed-diff-view' : 'rev-deleted-diff-view';
             $notice = "<div id='mw-{$msg}' class='mw-warning plainlinks'>\n" . $this->msg($msg)->parse() . "</div>\n";
         }
         $this->showDiff($oldHeader, $newHeader, $notice);
         if (!$diffOnly) {
             $this->renderNewRevision();
         }
     }
 }
Example #20
0
 /**
  * @param $title Title
  * @param  $file File
  * @param array $frameParams
  * @param array $handlerParams
  * @param bool $time
  * @param string $query
  * @return mixed
  */
 public static 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'] = '';
     }
     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;
     if (!$exists) {
         $width = $hp['width'];
     } 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);
                 } else {
                     $exists = false;
                 }
             }
         } elseif (isset($fp['framed'])) {
             // Use image dimensions, don't scale
             $thumb = $file->getUnscaledThumb($hp);
         } 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);
             /* Wikia change start - Jakub */
             F::app()->runHook('LinkerMakeThumbLink2FileOriginalSize', array($file, &$srcWidth));
             /* Wikia change end */
             if ($srcWidth && !$file->mustRender() && $hp['width'] > $srcWidth) {
                 $hp['width'] = $srcWidth;
             }
             $thumb = $file->transform($hp);
         }
         if ($thumb) {
             $width = $thumb->getWidth();
         } else {
             $width = $hp['width'];
         }
     }
     # 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/file page 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));
     }
     $params = array();
     $origHTML = null;
     /* Wikia change/refactor start - @author Liz */
     // TODO: Look into making this a separate function
     if (!$exists) {
         $origHTML = self::makeBrokenImageLinkObj($title, $fp['title'], '', '', '', $time == true);
     } elseif (!$thumb) {
         $origHTML = htmlspecialchars(wfMsg('thumbnail_error', ''));
     } else {
         $params = array('alt' => $fp['alt'], 'title' => $fp['title'], 'img-class' => 'thumbimage', 'align' => $fp['align'], 'outerWidth' => $width, 'file' => $file, 'url' => $url);
         $params = self::getImageLinkMTOParams($fp, $query) + $params;
         // Split rendering between 'wikiamobile' which uses the old non-templated path
         // vs everything else which should use the new templated controller
         if (F::app()->checkSkin('wikiamobile')) {
             $origHTML = $thumb->toHtml($params);
         } else {
             $origHTML = $thumb->renderView($params);
         }
     }
     $isMobile = F::app()->checkSkin('wikiamobile');
     if ($isMobile) {
         // Hook only used for mobile now
         wfRunHooks('ThumbnailAfterProduceHTML', array($frameParams, $thumb, $origHTML, &$origHTML));
     } else {
         // Render with controller for desktop
         $params['html'] = $origHTML;
         $origHTML = F::app()->renderView('ThumbnailController', 'articleBlock', $params);
     }
     /* Wikia change/refactor end */
     return str_replace("\n", ' ', $origHTML);
 }