Tpt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/87661
Change subject: Fix a fatal error when the Page image doesn't exit
......................................................................
Fix a fatal error when the Page image doesn't exit
Improve code of the addition of pref and next links to Page: pages
Use the same order as the old interface
Change-Id: I9df4eac6252b59736b1080e15d0cabf759547f2c
---
M ProofreadPage.body.php
1 file changed, 65 insertions(+), 39 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage
refs/changes/61/87661/1
diff --git a/ProofreadPage.body.php b/ProofreadPage.body.php
index 01de00d..45771c8 100644
--- a/ProofreadPage.body.php
+++ b/ProofreadPage.body.php
@@ -865,52 +865,78 @@
}
/**
- * Add the links to previous, next, index page and scan image.
+ * Add the links to previous, next, index page and scan image to Page:
pages.
* @param $skin SkinTemplate object
* @param $links Structured navigation links
*/
public static function onSkinTemplateNavigation( &$skin, &$links ) {
- global $wgOut, $wgExtensionAssetsPath;
- $titleText = $wgOut->getPageTitle();
- $title = Title::newFromText( $titleText );
- if( $title->inNamespace( self::getPageNamespaceId() ) ) {
- $page = ProofreadPagePage::newFromTitle( $title );
- $indexPage = $page->getIndex();
- if ( $indexPage !== null ) {
- list( $prevTitle, $nextTitle ) =
$indexPage->getPreviousAndNextPages( $page->getTitle() );
- if ( $prevTitle !== null ) {
- if( !$prevTitle->exists() ) {
- $prevLink =
$prevTitle->getEditURL();
- } else {
- $prevLink =
$prevTitle->getLinkUrl();
- }
-
$links['namespaces']['proofreadPagePrevLink'] = array( 'class' => '', 'href' =>
$prevLink,
- 'text' => wfMessage(
'proofreadpage_prevpage' )->plain() );
- }
- if ( $nextTitle !== null ) {
- if( !$nextTitle->exists() ) {
- $nextLink =
$nextTitle->getEditURL();
- } else {
- $nextLink =
$nextTitle->getLinkUrl();
- }
-
$links['namespaces']['proofreadPageNextLink'] = array( 'class' => '', 'href' =>
$nextLink,
- 'text' => wfMessage(
'proofreadpage_nextpage' )->plain() );
- }
- $indexLink =
$indexPage->getTitle()->getLinkUrl();
- $links['namespaces']['proofreadPageIndexLink']
= array( 'class' => '', 'href' => $indexLink,
- 'text' => wfMessage(
'proofreadpage_index' )->plain() );
+ global $wgOut;
- $image = $page->getImage();
- $width = $image->getWidth();
- $filePage = $page->getPageNumber();
- $params = array( 'width' => $width, 'page' =>
$filePage );
- $image->getHandler()->normaliseParams( $image,
$params );
- $thumbName = $image->thumbName( $params );
- $imageUrl = $image->getThumbUrl( $thumbName );
- $links['namespaces']['proofreadPageScanLink'] =
array( 'class' => '', 'href' => $imageUrl,
- 'text' => wfMessage(
'proofreadpage_image')->plain() );
+ $title = $wgOut->getTitle();
+ if( !$title->inNamespace( self::getPageNamespaceId() ) ) {
+ return;
+ }
+
+ $page = ProofreadPagePage::newFromTitle( $title );
+ $indexPage = $page->getIndex();
+ if ( $indexPage ) {
+ list( $prevTitle, $nextTitle ) =
$indexPage->getPreviousAndNextPages( $page->getTitle() );
+
+ if ( $prevTitle !== null ) {
+ if( !$prevTitle->exists() ) {
+ $prevLink = $prevTitle->getEditURL();
+ } else {
+ $prevLink = $prevTitle->getLinkUrl();
+ }
+ $links['namespaces']['proofreadPagePrevLink'] =
array(
+ 'class' => '',
+ 'href' => $prevLink,
+ 'text' => wfMessage(
'proofreadpage_prevpage' )->plain()
+ );
+ }
+
+ $indexLink = $indexPage->getTitle()->getLinkUrl();
+ $links['namespaces']['proofreadPageIndexLink'] = array(
+ 'class' => '',
+ 'href' => $indexLink,
+ 'text' => wfMessage( 'proofreadpage_index'
)->plain()
+ );
+
+ if ( $nextTitle !== null ) {
+ if( !$nextTitle->exists() ) {
+ $nextLink = $nextTitle->getEditURL();
+ } else {
+ $nextLink = $nextTitle->getLinkUrl();
+ }
+ $links['namespaces']['proofreadPageNextLink'] =
array(
+ 'class' => '',
+ 'href' => $nextLink,
+ 'text' => wfMessage(
'proofreadpage_nextpage' )->plain()
+ );
}
}
+
+ $image = $page->getImage();
+ if ( $image ) {
+ $transformAttributes = array(
+ 'width' => $image->getWidth()
+ );
+ if ( $image->isMultipage() ) {
+ $pageNumber = $this->getPageNumber();
+ if ( $pageNumber !== null ) {
+ $transformAttributes['page'] =
$pageNumber;
+ }
+ }
+ $image->getHandler()->normaliseParams( $image, $params
);
+ $thumbName = $image->thumbName( $params );
+ $imageUrl = $image->getThumbUrl( $thumbName );
+ $links['namespaces']['proofreadPageScanLink'] = array(
+ 'class' => '',
+ 'href' => $imageUrl,
+ 'text' => wfMessage(
'proofreadpage_image')->plain()
+ );
+ }
+
return true;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/87661
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9df4eac6252b59736b1080e15d0cabf759547f2c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: pagePagesRefactoring
Gerrit-Owner: Tpt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits