2008-04-03 21:00:22 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-08-27 13:02:57 +00:00
|
|
|
* Implements Special:Interwiki
|
2008-12-31 18:44:54 +00:00
|
|
|
* @ingroup SpecialPage
|
2008-04-03 21:00:22 +00:00
|
|
|
*/
|
|
|
|
class SpecialInterwiki extends SpecialPage {
|
2009-08-27 13:02:57 +00:00
|
|
|
/**
|
|
|
|
* Constructor - sets up the new special page
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
2008-04-03 21:00:22 +00:00
|
|
|
parent::__construct( 'Interwiki' );
|
|
|
|
}
|
|
|
|
|
2011-03-11 14:20:39 +00:00
|
|
|
/**
|
|
|
|
* Different description will be shown on Special:SpecialPage depending on
|
2011-07-19 12:45:38 +00:00
|
|
|
* whether the user can modify the data.
|
2011-03-11 14:20:39 +00:00
|
|
|
*/
|
2010-01-22 21:19:01 +00:00
|
|
|
function getDescription() {
|
2012-04-25 10:08:42 +00:00
|
|
|
return $this->msg( $this->canModify() ?
|
2011-07-21 05:43:08 +00:00
|
|
|
'interwiki' : 'interwiki-title-norights' )->plain();
|
2010-01-22 21:19:01 +00:00
|
|
|
}
|
|
|
|
|
2009-08-27 13:02:57 +00:00
|
|
|
/**
|
|
|
|
* Show the special page
|
|
|
|
*
|
|
|
|
* @param $par Mixed: parameter passed to the page or null
|
|
|
|
*/
|
|
|
|
public function execute( $par ) {
|
2008-04-03 21:00:22 +00:00
|
|
|
$this->setHeaders();
|
2008-12-31 18:44:54 +00:00
|
|
|
$this->outputHeader();
|
|
|
|
|
2011-09-26 16:40:05 +00:00
|
|
|
$out = $this->getOutput();
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
|
|
$out->addModuleStyles( 'SpecialInterwiki' );
|
2011-07-19 12:45:38 +00:00
|
|
|
|
2011-09-26 16:40:05 +00:00
|
|
|
$action = $par ? $par : $request->getVal( 'action', $par );
|
2011-06-12 11:45:15 +00:00
|
|
|
$return = $this->getTitle();
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2011-03-11 14:20:39 +00:00
|
|
|
switch( $action ) {
|
2009-08-27 13:02:57 +00:00
|
|
|
case 'delete':
|
|
|
|
case 'edit':
|
|
|
|
case 'add':
|
2012-04-25 08:53:49 +00:00
|
|
|
if ( $this->canModify( $out ) ) {
|
2011-09-26 16:40:05 +00:00
|
|
|
$out->addHTML( $this->showForm( $action ) );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2011-09-26 16:40:05 +00:00
|
|
|
$out->returnToMain( false, $return );
|
2008-12-31 18:44:54 +00:00
|
|
|
break;
|
2009-08-27 13:02:57 +00:00
|
|
|
case 'submit':
|
2012-04-25 08:53:49 +00:00
|
|
|
if ( !$this->canModify( $out ) ) {
|
2011-07-19 12:45:38 +00:00
|
|
|
# Error msg added by canModify()
|
2012-04-25 08:53:49 +00:00
|
|
|
} elseif ( !$request->wasPosted() || !$this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) {
|
2011-06-11 22:14:03 +00:00
|
|
|
// Prevent cross-site request forgeries
|
2011-09-26 16:40:05 +00:00
|
|
|
$out->addWikiMsg( 'sessionfailure' );
|
2011-06-11 22:14:03 +00:00
|
|
|
} else {
|
|
|
|
$this->doSubmit();
|
2008-12-31 18:44:54 +00:00
|
|
|
}
|
2011-09-26 16:40:05 +00:00
|
|
|
$out->returnToMain( false, $return );
|
2008-12-31 18:44:54 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-07-19 12:45:38 +00:00
|
|
|
$this->showList();
|
2008-12-31 18:44:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-19 12:45:38 +00:00
|
|
|
/**
|
|
|
|
* Returns boolean whether the user can modify the data.
|
|
|
|
* @param $out If $wgOut object given, it adds the respective error message.
|
|
|
|
* @return Boolean
|
|
|
|
*/
|
|
|
|
public function canModify( $out = false ) {
|
2011-09-26 16:40:05 +00:00
|
|
|
global $wgInterwikiCache;
|
2012-04-25 08:53:49 +00:00
|
|
|
if ( !$this->getUser()->isAllowed( 'interwiki' ) ) {
|
2011-07-19 12:45:38 +00:00
|
|
|
# Check permissions
|
2012-04-25 10:02:50 +00:00
|
|
|
if ( $out ) {
|
|
|
|
throw new PermissionsError( 'interwiki' );
|
|
|
|
}
|
|
|
|
|
2011-07-19 12:45:38 +00:00
|
|
|
return false;
|
2012-04-25 08:53:49 +00:00
|
|
|
} elseif ( $wgInterwikiCache ) {
|
2011-07-19 12:45:38 +00:00
|
|
|
# Editing the interwiki cache is not supported
|
2012-04-25 10:02:50 +00:00
|
|
|
if ( $out ) {
|
|
|
|
$out->addWikiMsg( 'interwiki-cached' );
|
|
|
|
}
|
|
|
|
|
2011-07-19 12:45:38 +00:00
|
|
|
return false;
|
2012-04-25 08:53:49 +00:00
|
|
|
} elseif ( wfReadOnly() ) {
|
2011-07-19 12:45:38 +00:00
|
|
|
# Is the database in read-only mode?
|
2012-04-25 10:02:50 +00:00
|
|
|
if ( $out ) {
|
|
|
|
$out->readOnlyPage();
|
|
|
|
}
|
2011-07-19 12:45:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-21 10:49:52 +00:00
|
|
|
|
2011-07-19 12:45:38 +00:00
|
|
|
function showForm( $action ) {
|
2011-09-26 16:40:05 +00:00
|
|
|
$request = $this->getRequest();
|
2011-07-20 15:29:34 +00:00
|
|
|
|
2011-09-26 16:40:05 +00:00
|
|
|
$prefix = $request->getVal( 'prefix' );
|
2011-07-20 15:29:34 +00:00
|
|
|
$wpPrefix = '';
|
|
|
|
$label = array( 'class' => 'mw-label' );
|
|
|
|
$input = array( 'class' => 'mw-input' );
|
|
|
|
|
2012-05-18 10:07:43 +00:00
|
|
|
if ( $action === 'delete' ) {
|
2012-04-25 10:08:42 +00:00
|
|
|
$topmessage = $this->msg( 'interwiki_delquestion', $prefix )->text();
|
2012-05-20 21:44:27 +00:00
|
|
|
$intromessage = $this->msg( 'interwiki_deleting', $prefix )->escaped();
|
2011-07-20 15:29:34 +00:00
|
|
|
$wpPrefix = Html::hidden( 'wpInterwikiPrefix', $prefix );
|
|
|
|
$button = 'delete';
|
|
|
|
$formContent = '';
|
2012-05-18 10:07:43 +00:00
|
|
|
} elseif ( $action === 'edit' ) {
|
2011-07-20 15:29:34 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
$row = $dbr->selectRow( 'interwiki', '*', array( 'iw_prefix' => $prefix ), __METHOD__ );
|
2012-04-25 10:02:50 +00:00
|
|
|
|
2012-04-25 08:53:49 +00:00
|
|
|
if ( !$row ) {
|
2011-07-20 15:29:34 +00:00
|
|
|
$this->error( 'interwiki_editerror', $prefix );
|
|
|
|
return;
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2012-04-25 10:02:50 +00:00
|
|
|
|
2011-07-20 15:29:34 +00:00
|
|
|
$prefix = $row->iw_prefix;
|
|
|
|
$defaulturl = $row->iw_url;
|
|
|
|
$trans = $row->iw_trans;
|
|
|
|
$local = $row->iw_local;
|
|
|
|
$wpPrefix = Html::hidden( 'wpInterwikiPrefix', $row->iw_prefix );
|
2012-04-25 10:08:42 +00:00
|
|
|
$topmessage = $this->msg( 'interwiki_edittext' )->text();
|
2012-05-20 21:44:27 +00:00
|
|
|
$intromessage = $this->msg( 'interwiki_editintro' )->escaped();
|
2011-07-20 15:29:34 +00:00
|
|
|
$button = 'edit';
|
2012-05-18 10:07:43 +00:00
|
|
|
} elseif ( $action === 'add' ) {
|
2011-09-26 16:40:05 +00:00
|
|
|
$prefix = $request->getVal( 'wpInterwikiPrefix', $request->getVal( 'prefix' ) );
|
2011-07-20 15:29:34 +00:00
|
|
|
$prefix = Xml::input( 'wpInterwikiPrefix', 20, $prefix,
|
|
|
|
array( 'tabindex' => 1, 'id' => 'mw-interwiki-prefix', 'maxlength' => 20 ) );
|
2011-09-26 16:40:05 +00:00
|
|
|
$local = $request->getCheck( 'wpInterwikiLocal' );
|
|
|
|
$trans = $request->getCheck( 'wpInterwikiTrans' );
|
2012-04-25 10:08:42 +00:00
|
|
|
$defaulturl = $request->getVal( 'wpInterwikiURL', $this->msg( 'interwiki-defaulturl' )->text() );
|
|
|
|
$topmessage = $this->msg( 'interwiki_addtext' )->text();
|
2012-05-20 21:44:27 +00:00
|
|
|
$intromessage = $this->msg( 'interwiki_addintro' )->escaped();
|
2011-07-20 15:29:34 +00:00
|
|
|
$button = 'interwiki_addbutton';
|
|
|
|
}
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2012-05-18 10:07:43 +00:00
|
|
|
if ( $action === 'add' || $action === 'edit' ) {
|
2011-07-20 15:29:34 +00:00
|
|
|
$formContent = Html::rawElement( 'tr', null,
|
2012-04-25 10:08:42 +00:00
|
|
|
Html::element( 'td', $label, $this->msg( 'interwiki-prefix-label' )->text() ) .
|
2011-07-20 15:29:34 +00:00
|
|
|
Html::rawElement( 'td', null, '<tt>' . $prefix . '</tt>' )
|
|
|
|
) . Html::rawElement( 'tr', null,
|
2012-04-25 10:08:42 +00:00
|
|
|
Html::rawElement( 'td', $label, Xml::label( $this->msg( 'interwiki-local-label' )->text(), 'mw-interwiki-local' ) ) .
|
2011-07-20 15:29:34 +00:00
|
|
|
Html::rawElement( 'td', $input, Xml::check( 'wpInterwikiLocal', $local, array( 'id' => 'mw-interwiki-local' ) ) )
|
|
|
|
) . Html::rawElement( 'tr', null,
|
2012-04-25 10:08:42 +00:00
|
|
|
Html::rawElement( 'td', $label, Xml::label( $this->msg( 'interwiki-trans-label' )->text(), 'mw-interwiki-trans' ) ) .
|
2011-07-20 15:29:34 +00:00
|
|
|
Html::rawElement( 'td', $input, Xml::check( 'wpInterwikiTrans', $trans, array( 'id' => 'mw-interwiki-trans' ) ) )
|
|
|
|
) . Html::rawElement( 'tr', null,
|
2012-04-25 10:08:42 +00:00
|
|
|
Html::rawElement( 'td', $label, Xml::label( $this->msg( 'interwiki-url-label' )->text(), 'mw-interwiki-url' ) ) .
|
2011-07-20 15:29:34 +00:00
|
|
|
Html::rawElement( 'td', $input, Xml::input( 'wpInterwikiURL', 60, $defaulturl,
|
|
|
|
array( 'tabindex' => 1, 'maxlength' => 200, 'id' => 'mw-interwiki-url' ) ) )
|
2008-04-03 21:00:22 +00:00
|
|
|
);
|
2008-12-31 18:44:54 +00:00
|
|
|
}
|
2011-07-20 15:29:34 +00:00
|
|
|
|
|
|
|
return Xml::fieldset( $topmessage, Html::rawElement( 'form',
|
|
|
|
array( 'id' => "mw-interwiki-{$action}form", 'method' => 'post',
|
|
|
|
'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ),
|
2011-07-20 16:25:53 +00:00
|
|
|
Html::rawElement( 'p', null, $intromessage ) .
|
2011-07-20 15:29:34 +00:00
|
|
|
Html::rawElement( 'table', array( 'id' => "mw-interwiki-{$action}" ),
|
|
|
|
$formContent . Html::rawElement( 'tr', null,
|
2012-04-25 10:08:42 +00:00
|
|
|
Html::rawElement( 'td', $label, Xml::label( $this->msg( 'interwiki_reasonfield' )->text(),
|
2011-07-20 15:29:34 +00:00
|
|
|
"mw-interwiki-{$action}reason" ) ) .
|
|
|
|
Html::rawElement( 'td', $input, Xml::input( 'wpInterwikiReason', 60, '',
|
|
|
|
array( 'tabindex' => 1, 'id' => "mw-interwiki-{$action}reason", 'maxlength' => 200 ) ) )
|
|
|
|
) . Html::rawElement( 'tr', null,
|
|
|
|
Html::rawElement( 'td', null, '' ) .
|
|
|
|
Html::rawElement( 'td', array( 'class' => 'mw-submit' ),
|
2012-04-25 10:08:42 +00:00
|
|
|
Xml::submitButton( $this->msg( $button )->text(), array( 'id' => 'mw-interwiki-submit' ) ) )
|
2011-07-20 15:29:34 +00:00
|
|
|
) . $wpPrefix .
|
2011-09-26 16:40:05 +00:00
|
|
|
Html::hidden( 'wpEditToken', $this->getUser()->editToken() ) .
|
2011-07-20 15:29:34 +00:00
|
|
|
Html::hidden( 'wpInterwikiAction', $action )
|
|
|
|
)
|
|
|
|
) );
|
2008-12-31 18:44:54 +00:00
|
|
|
}
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
function doSubmit() {
|
2012-04-15 20:00:42 +00:00
|
|
|
global $wgContLang, $wgMemc;
|
2011-12-01 20:23:04 +00:00
|
|
|
|
2011-09-26 16:40:05 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$prefix = $request->getVal( 'wpInterwikiPrefix' );
|
|
|
|
$do = $request->getVal( 'wpInterwikiAction' );
|
2012-05-20 21:44:27 +00:00
|
|
|
// Show an error if the prefix is invalid (only when adding one).
|
|
|
|
// Invalid characters are ':', '&', '=' and whitespace.
|
2012-05-18 10:07:43 +00:00
|
|
|
if ( preg_match( '/[\s:&=]/', $prefix ) && $do === 'add' ) {
|
2008-12-31 18:44:54 +00:00
|
|
|
$this->error( 'interwiki-badprefix', htmlspecialchars( $prefix ) );
|
|
|
|
$this->showForm( $do );
|
|
|
|
return;
|
|
|
|
}
|
2011-09-26 16:40:05 +00:00
|
|
|
$reason = $request->getText( 'wpInterwikiReason' );
|
2008-12-31 18:44:54 +00:00
|
|
|
$selfTitle = $this->getTitle();
|
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2012-04-25 08:53:49 +00:00
|
|
|
switch( $do ) {
|
2009-08-27 13:02:57 +00:00
|
|
|
case 'delete':
|
2008-12-31 18:44:54 +00:00
|
|
|
$dbw->delete( 'interwiki', array( 'iw_prefix' => $prefix ), __METHOD__ );
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2012-05-18 10:07:43 +00:00
|
|
|
if ( $dbw->affectedRows() === 0 ) {
|
2008-12-31 18:44:54 +00:00
|
|
|
$this->error( 'interwiki_delfailed', $prefix );
|
|
|
|
$this->showForm( $do );
|
|
|
|
} else {
|
2011-09-26 16:40:05 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'interwiki_deleted', $prefix );
|
2008-12-31 18:44:54 +00:00
|
|
|
$log = new LogPage( 'interwiki' );
|
|
|
|
$log->addEntry( 'iw_delete', $selfTitle, $reason, array( $prefix ) );
|
2012-04-15 20:00:42 +00:00
|
|
|
$wgMemc->delete( wfMemcKey( 'interwiki', $prefix ) );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-08-27 13:02:57 +00:00
|
|
|
case 'add':
|
2011-12-01 20:23:04 +00:00
|
|
|
$prefix = $wgContLang->lc( $prefix );
|
2012-05-20 21:44:27 +00:00
|
|
|
// N.B.: no break!
|
2011-12-01 20:23:04 +00:00
|
|
|
case 'edit':
|
2011-09-26 16:40:05 +00:00
|
|
|
$theurl = $request->getVal( 'wpInterwikiURL' );
|
|
|
|
$local = $request->getCheck( 'wpInterwikiLocal' ) ? 1 : 0;
|
|
|
|
$trans = $request->getCheck( 'wpInterwikiTrans' ) ? 1 : 0;
|
2011-03-11 14:20:39 +00:00
|
|
|
$data = array(
|
|
|
|
'iw_prefix' => $prefix,
|
|
|
|
'iw_url' => $theurl,
|
|
|
|
'iw_local' => $local,
|
|
|
|
'iw_trans' => $trans
|
|
|
|
);
|
2012-04-25 08:53:49 +00:00
|
|
|
|
2012-05-18 10:07:43 +00:00
|
|
|
if ( $prefix === '' || $theurl === '' ) {
|
2011-06-11 22:14:03 +00:00
|
|
|
$this->error( 'interwiki-submit-empty' );
|
|
|
|
$this->showForm( $do );
|
|
|
|
return;
|
|
|
|
}
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2012-05-18 10:07:43 +00:00
|
|
|
if ( $do === 'add' ) {
|
2008-12-31 18:44:54 +00:00
|
|
|
$dbw->insert( 'interwiki', $data, __METHOD__, 'IGNORE' );
|
2012-05-20 21:44:27 +00:00
|
|
|
} else { // $do === 'edit'
|
2008-12-31 18:44:54 +00:00
|
|
|
$dbw->update( 'interwiki', $data, array( 'iw_prefix' => $prefix ), __METHOD__, 'IGNORE' );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-20 21:44:27 +00:00
|
|
|
// used here: interwiki_addfailed, interwiki_added, interwiki_edited
|
2012-05-18 10:07:43 +00:00
|
|
|
if ( $dbw->affectedRows() === 0 ) {
|
2008-12-31 18:44:54 +00:00
|
|
|
$this->error( "interwiki_{$do}failed", $prefix );
|
|
|
|
$this->showForm( $do );
|
|
|
|
} else {
|
2011-09-26 16:40:05 +00:00
|
|
|
$this->getOutput()->addWikiMsg( "interwiki_{$do}ed", $prefix );
|
2008-12-31 18:44:54 +00:00
|
|
|
$log = new LogPage( 'interwiki' );
|
2009-08-27 13:02:57 +00:00
|
|
|
$log->addEntry( 'iw_' . $do, $selfTitle, $reason, array( $prefix, $theurl, $trans, $local ) );
|
2012-04-15 20:00:42 +00:00
|
|
|
$wgMemc->delete( wfMemcKey( 'interwiki', $prefix ) );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2008-12-31 18:44:54 +00:00
|
|
|
break;
|
2012-04-25 08:53:49 +00:00
|
|
|
}
|
2008-12-31 18:44:54 +00:00
|
|
|
}
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2011-07-19 12:45:38 +00:00
|
|
|
function showList() {
|
|
|
|
$canModify = $this->canModify();
|
2009-02-07 03:30:23 +00:00
|
|
|
|
2011-09-26 16:40:05 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'interwiki_intro' );
|
|
|
|
$this->getOutput()->addHTML(
|
2011-07-19 12:45:38 +00:00
|
|
|
Html::rawElement( 'table', array( 'class' => 'mw-interwikitable wikitable intro' ),
|
|
|
|
self::addInfoRow( 'start', 'interwiki_prefix', 'interwiki_prefix_intro' ) .
|
|
|
|
self::addInfoRow( 'start', 'interwiki_url', 'interwiki_url_intro' ) .
|
|
|
|
self::addInfoRow( 'start', 'interwiki_local', 'interwiki_local_intro' ) .
|
|
|
|
self::addInfoRow( 'end', 'interwiki_0', 'interwiki_local_0_intro' ) .
|
|
|
|
self::addInfoRow( 'end', 'interwiki_1', 'interwiki_local_1_intro' ) .
|
|
|
|
self::addInfoRow( 'start', 'interwiki_trans', 'interwiki_trans_intro' ) .
|
2011-12-10 12:54:44 +00:00
|
|
|
self::addInfoRow( 'end', 'interwiki_0', 'interwiki_trans_0_intro' ) .
|
|
|
|
self::addInfoRow( 'end', 'interwiki_1', 'interwiki_trans_1_intro' )
|
2011-07-19 12:45:38 +00:00
|
|
|
) . "\n"
|
|
|
|
);
|
2008-12-31 18:44:54 +00:00
|
|
|
|
2011-07-19 12:45:38 +00:00
|
|
|
if ( $canModify ) {
|
2012-04-25 10:31:31 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'interwiki_intro_footer' );
|
2012-04-25 10:08:42 +00:00
|
|
|
$addtext = $this->msg( 'interwiki_addtext' )->escaped();
|
2011-07-19 12:45:38 +00:00
|
|
|
$addlink = Linker::linkKnown( $this->getTitle( 'add' ), $addtext );
|
2011-09-26 16:40:05 +00:00
|
|
|
$this->getOutput()->addHTML( '<p class="mw-interwiki-addlink">' . $addlink . '</p>' );
|
2008-12-31 18:44:54 +00:00
|
|
|
}
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2012-04-25 08:53:49 +00:00
|
|
|
if ( !method_exists( 'Interwiki', 'getAllPrefixes' ) ) {
|
2011-07-19 12:45:38 +00:00
|
|
|
# version 2.0 is not backwards compatible (but still display nice error)
|
2008-12-31 18:44:54 +00:00
|
|
|
$this->error( 'interwiki_error' );
|
|
|
|
return;
|
|
|
|
}
|
2011-07-19 12:45:38 +00:00
|
|
|
$iwPrefixes = Interwiki::getAllPrefixes( null );
|
|
|
|
|
2012-05-18 10:07:43 +00:00
|
|
|
if ( !is_array( $iwPrefixes ) || count( $iwPrefixes ) === 0 ) {
|
2011-07-19 12:45:38 +00:00
|
|
|
# If the interwiki table is empty, display an error message
|
|
|
|
$this->error( 'interwiki_error' );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$out = '';
|
|
|
|
|
2012-05-20 21:44:27 +00:00
|
|
|
# Output the existing Interwiki prefixes table header
|
2011-07-19 12:45:38 +00:00
|
|
|
$out .= Html::openElement( 'table', array( 'class' => 'mw-interwikitable wikitable sortable body' ) ) . "\n";
|
|
|
|
$out .= Html::openElement( 'tr', array( 'id' => 'interwikitable-header' ) ) .
|
2012-05-20 21:44:27 +00:00
|
|
|
Html::element( 'th', null, $this->msg( 'interwiki_prefix' )->text() ) .
|
|
|
|
Html::element( 'th', null, $this->msg( 'interwiki_url' )->text() ) .
|
|
|
|
Html::element( 'th', null, $this->msg( 'interwiki_local' )->text() ) .
|
|
|
|
Html::element( 'th', null, $this->msg( 'interwiki_trans' )->text() ) .
|
|
|
|
( $canModify ? Html::element( 'th', array( 'class' => 'unsortable' ), $this->msg( 'interwiki_edit' )->text() ) : '' );
|
2011-07-19 12:45:38 +00:00
|
|
|
$out .= Html::closeElement( 'tr' ) . "\n";
|
2009-08-27 13:02:57 +00:00
|
|
|
|
2011-06-11 22:14:03 +00:00
|
|
|
$selfTitle = $this->getTitle();
|
|
|
|
|
2012-05-20 21:44:27 +00:00
|
|
|
# Output the existing Interwiki prefixes table rows
|
2012-04-25 08:53:49 +00:00
|
|
|
foreach ( $iwPrefixes as $i => $iwPrefix ) {
|
2011-07-19 12:45:38 +00:00
|
|
|
$out .= Html::openElement( 'tr', array( 'class' => 'mw-interwikitable-row' ) );
|
2012-05-16 09:43:25 +00:00
|
|
|
$out .= Html::element( 'td', array( 'class' => 'mw-interwikitable-prefix' ),
|
2012-05-20 21:44:27 +00:00
|
|
|
$iwPrefix['iw_prefix'] );
|
2011-07-19 12:45:38 +00:00
|
|
|
$out .= Html::element( 'td', array( 'class' => 'mw-interwikitable-url' ), $iwPrefix['iw_url'] );
|
2012-05-20 21:44:27 +00:00
|
|
|
// The messages interwiki_0 and interwiki_1 are used here.
|
2011-07-19 12:45:38 +00:00
|
|
|
$out .= Html::element( 'td', array( 'class' => 'mw-interwikitable-local' ),
|
2012-05-20 21:44:27 +00:00
|
|
|
( isset( $iwPrefix['iw_local'] ) ? $this->msg( 'interwiki_' . $iwPrefix['iw_local'] )->text() : '-' ) );
|
2011-07-19 12:45:38 +00:00
|
|
|
$out .= Html::element( 'td', array( 'class' => 'mw-interwikitable-trans' ),
|
2012-05-20 21:44:27 +00:00
|
|
|
( isset( $iwPrefix['iw_trans'] ) ? $this->msg( 'interwiki_' . $iwPrefix['iw_trans'] )->text() : '-' ) );
|
2012-04-25 08:53:49 +00:00
|
|
|
if ( $canModify ) {
|
2011-07-19 12:45:38 +00:00
|
|
|
$out .= Html::rawElement( 'td', array( 'class' => 'mw-interwikitable-modify' ),
|
2012-04-25 10:08:42 +00:00
|
|
|
Linker::linkKnown( $selfTitle, $this->msg( 'edit' )->escaped(), array(),
|
2011-07-19 12:45:38 +00:00
|
|
|
array( 'action' => 'edit', 'prefix' => $iwPrefix['iw_prefix'] ) ) .
|
2012-04-25 10:08:42 +00:00
|
|
|
$this->msg( 'comma-separator' ) .
|
|
|
|
Linker::linkKnown( $selfTitle, $this->msg( 'delete' )->escaped(), array(),
|
2011-07-19 12:45:38 +00:00
|
|
|
array( 'action' => 'delete', 'prefix' => $iwPrefix['iw_prefix'] ) )
|
|
|
|
);
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2011-07-19 12:45:38 +00:00
|
|
|
$out .= Html::closeElement( 'tr' ) . "\n";
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2011-07-19 12:45:38 +00:00
|
|
|
$out .= Html::closeElement( 'table' );
|
|
|
|
|
2011-09-26 16:40:05 +00:00
|
|
|
$this->getOutput()->addHTML( $out );
|
2008-12-31 18:44:54 +00:00
|
|
|
}
|
2009-08-27 13:02:57 +00:00
|
|
|
|
2012-05-20 21:44:27 +00:00
|
|
|
/**
|
|
|
|
* Adds a row to the documentation table on the top of Special:Interwiki.
|
|
|
|
*/
|
2011-07-19 12:45:38 +00:00
|
|
|
static function addInfoRow( $align = 'start', $title, $text ) {
|
|
|
|
return Html::rawElement( 'tr', null,
|
2012-05-20 21:44:27 +00:00
|
|
|
// The classes mw-align-start and mw-align-end are used here.
|
2011-07-20 15:29:34 +00:00
|
|
|
Html::rawElement( 'th', array( 'class' => 'mw-align-' . $align ), wfMessage( $title )->escaped() ) .
|
2012-05-20 21:44:27 +00:00
|
|
|
// This message is expected to have wiki syntax
|
2011-07-20 15:29:34 +00:00
|
|
|
Html::rawElement( 'td', null, wfMessage( $text )->parse() )
|
2011-07-19 12:45:38 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
function error() {
|
|
|
|
$args = func_get_args();
|
2011-09-26 16:40:05 +00:00
|
|
|
$this->getOutput()->wrapWikiMsg( "<p class='error'>$1</p>", $args );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2010-12-09 11:57:55 +00:00
|
|
|
}
|
2011-09-26 16:40:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Needed to pass the URL as a raw parameter, because it contains $1
|
2012-05-20 21:44:27 +00:00
|
|
|
*/
|
2011-09-26 16:40:05 +00:00
|
|
|
class InterwikiLogFormatter extends LogFormatter {
|
|
|
|
protected function getMessageParameters() {
|
|
|
|
$params = parent::getMessageParameters();
|
2012-04-25 08:53:49 +00:00
|
|
|
if ( isset( $params[4] ) ) {
|
2012-04-27 23:24:48 +00:00
|
|
|
$params[4] = Message::rawParam( htmlspecialchars( $params[4] ) );
|
2011-09-26 16:40:05 +00:00
|
|
|
}
|
|
|
|
return $params;
|
|
|
|
}
|
|
|
|
}
|