* 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 {
$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];
}
$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 );
}
if ( $check == 10 ) {
$check = "X";
}
- if ( $check == $isbn[9] ) {
+ if ( (string)$check === $isbn[9] ) {
return true;
}
}
* @return string
*/
private function makeForm() {
- global $wgScript;
-
$form = Html::openElement( 'fieldset' ) . "\n";
$form .= Html::element(
'legend',
array(),
$this->msg( 'booksources-search-legend' )->text()
) . "\n";
- $form .= Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . "\n";
+ $form .= Html::openElement( 'form', array( 'method' => 'get', 'action' => wfScript() ) ) . "\n";
$form .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) . "\n";
$form .= '<p>' . Xml::inputLabel(
$this->msg( 'booksources-isbn' )->text(),
'isbn',
20,
$this->isbn,
- array( 'autofocus' => true )
+ array( 'autofocus' => true, 'class' => 'mw-ui-input-inline' )
);
- $form .= ' ' . Xml::submitButton( $this->msg( 'booksources-go' )->text() ) . "</p>\n";
+
+ if ( $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
+ $form .= ' ' . Xml::submitButton(
+ $this->msg( 'booksources-search' )->text(),
+ array( 'class' => 'mw-ui-button mw-ui-progressive' )
+ ) . "</p>\n";
+ } else {
+ $form .= ' ' . Xml::submitButton(
+ $this->msg( 'booksources-search' )->text()
+ ) . "</p>\n";
+ }
+
$form .= Html::closeElement( 'form' ) . "\n";
$form .= Html::closeElement( 'fieldset' ) . "\n";