summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialBooksources.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialBooksources.php')
-rw-r--r--includes/specials/SpecialBooksources.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/includes/specials/SpecialBooksources.php b/includes/specials/SpecialBooksources.php
index 72f4e466..7028fdcb 100644
--- a/includes/specials/SpecialBooksources.php
+++ b/includes/specials/SpecialBooksources.php
@@ -26,7 +26,6 @@
* The parser creates links to this page when dealing with ISBNs in wikitext
*
* @author Rob Church <robchur@gmail.com>
- * @todo Validate ISBNs using the standard check-digit method
* @ingroup SpecialPage
*/
class SpecialBookSources extends SpecialPage {
@@ -73,7 +72,9 @@ class SpecialBookSources extends SpecialPage {
$sum = 0;
if ( strlen( $isbn ) == 13 ) {
for ( $i = 0; $i < 12; $i++ ) {
- if ( $i % 2 == 0 ) {
+ if ( $isbn[$i] === 'X' ) {
+ return false;
+ } elseif ( $i % 2 == 0 ) {
$sum += $isbn[$i];
} else {
$sum += 3 * $isbn[$i];
@@ -81,11 +82,14 @@ class SpecialBookSources extends SpecialPage {
}
$check = ( 10 - ( $sum % 10 ) ) % 10;
- if ( $check == $isbn[12] ) {
+ if ( (string)$check === $isbn[12] ) {
return true;
}
} elseif ( strlen( $isbn ) == 10 ) {
for ( $i = 0; $i < 9; $i++ ) {
+ if ( $isbn[$i] === 'X' ) {
+ return false;
+ }
$sum += $isbn[$i] * ( $i + 1 );
}
@@ -93,7 +97,7 @@ class SpecialBookSources extends SpecialPage {
if ( $check == 10 ) {
$check = "X";
}
- if ( $check == $isbn[9] ) {
+ if ( (string)$check === $isbn[9] ) {
return true;
}
}
@@ -131,9 +135,14 @@ class SpecialBookSources extends SpecialPage {
'isbn',
20,
$this->isbn,
- array( 'autofocus' => true )
+ array( 'autofocus' => '', 'class' => 'mw-ui-input-inline' )
);
- $form .= '&#160;' . Xml::submitButton( $this->msg( 'booksources-go' )->text() ) . "</p>\n";
+
+ $form .= '&#160;' . Html::submitButton(
+ $this->msg( 'booksources-search' )->text(),
+ array(), array( 'mw-ui-progressive' )
+ ) . "</p>\n";
+
$form .= Html::closeElement( 'form' ) . "\n";
$form .= Html::closeElement( 'fieldset' ) . "\n";
@@ -152,7 +161,7 @@ class SpecialBookSources extends SpecialPage {
# Hook to allow extensions to insert additional HTML,
# e.g. for API-interacting plugins and so on
- wfRunHooks( 'BookInformation', array( $this->isbn, $this->getOutput() ) );
+ Hooks::run( 'BookInformation', array( $this->isbn, $this->getOutput() ) );
# Check for a local page such as Project:Book_sources and use that if available
$page = $this->msg( 'booksources' )->inContentLanguage()->text();