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 {
|
2011-03-11 14:20:39 +00:00
|
|
|
|
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
|
|
|
|
* whether the user has the 'interwiki' right or not.
|
|
|
|
*/
|
2010-01-22 21:19:01 +00:00
|
|
|
function getDescription() {
|
|
|
|
global $wgUser;
|
|
|
|
|
|
|
|
return wfMsg( $wgUser->isAllowed( 'interwiki' ) ?
|
|
|
|
'interwiki' : 'interwiki-title-norights' );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
global $wgRequest, $wgOut, $wgUser;
|
|
|
|
|
|
|
|
$admin = $wgUser->isAllowed( 'interwiki' );
|
|
|
|
|
|
|
|
$this->setHeaders();
|
2008-12-31 18:44:54 +00:00
|
|
|
$this->outputHeader();
|
|
|
|
|
|
|
|
$admin = $wgUser->isAllowed( 'interwiki' );
|
2008-04-03 21:00:22 +00:00
|
|
|
$action = $wgRequest->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':
|
2011-03-11 14:20:39 +00:00
|
|
|
if( !$admin ) {
|
2011-06-11 22:14:03 +00:00
|
|
|
// Check permissions
|
2009-08-27 13:02:57 +00:00
|
|
|
$wgOut->permissionRequired( 'interwiki' );
|
2011-06-11 22:14:03 +00:00
|
|
|
} elseif( wfReadOnly() ) {
|
|
|
|
// Is the database in read-only mode?
|
2009-08-27 13:02:57 +00:00
|
|
|
$wgOut->readOnlyPage();
|
2011-06-11 22:14:03 +00:00
|
|
|
} else {
|
|
|
|
$this->showForm( $action );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2011-06-11 22:14:03 +00:00
|
|
|
$wgOut->returnToMain( false, $return );
|
2008-12-31 18:44:54 +00:00
|
|
|
break;
|
2009-08-27 13:02:57 +00:00
|
|
|
case 'submit':
|
2011-03-11 14:20:39 +00:00
|
|
|
if( !$admin ) {
|
2011-06-11 22:14:03 +00:00
|
|
|
// Check permissions
|
2008-12-31 18:44:54 +00:00
|
|
|
$wgOut->permissionRequired( 'interwiki' );
|
2011-06-11 22:14:03 +00:00
|
|
|
} elseif( wfReadOnly() ) {
|
|
|
|
// Is the database in read-only mode?
|
2009-08-27 13:02:57 +00:00
|
|
|
$wgOut->readOnlyPage();
|
2011-06-11 22:14:03 +00:00
|
|
|
} elseif( !$wgRequest->wasPosted() || !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
|
|
|
|
// Prevent cross-site request forgeries
|
2008-12-31 18:44:54 +00:00
|
|
|
$wgOut->addWikiMsg( 'sessionfailure' );
|
2011-06-11 22:14:03 +00:00
|
|
|
} else {
|
|
|
|
$this->doSubmit();
|
2008-12-31 18:44:54 +00:00
|
|
|
}
|
2011-06-11 22:14:03 +00:00
|
|
|
$wgOut->returnToMain( false, $return );
|
2008-12-31 18:44:54 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$this->showList( $admin );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function showForm( $action ) {
|
|
|
|
global $wgRequest, $wgUser, $wgOut;
|
2009-08-27 13:02:57 +00:00
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
$actionUrl = $this->getTitle()->getLocalURL( 'action=submit' );
|
|
|
|
$token = $wgUser->editToken();
|
2009-08-27 13:02:57 +00:00
|
|
|
|
2011-03-11 14:20:39 +00:00
|
|
|
switch( $action ) {
|
2009-08-27 13:02:57 +00:00
|
|
|
case 'delete':
|
2008-04-03 21:00:22 +00:00
|
|
|
|
|
|
|
$prefix = $wgRequest->getVal( 'prefix' );
|
2008-12-31 18:44:54 +00:00
|
|
|
$button = wfMsg( 'delete' );
|
|
|
|
$topmessage = wfMsg( 'interwiki_delquestion', $prefix );
|
|
|
|
$deletingmessage = wfMsgExt( 'interwiki_deleting', array( 'parseinline' ), $prefix );
|
|
|
|
$reasonmessage = wfMsg( 'deletecomment' );
|
2008-04-03 21:00:22 +00:00
|
|
|
|
|
|
|
$wgOut->addHTML(
|
2008-12-31 18:44:54 +00:00
|
|
|
Xml::openElement( 'fieldset' ) .
|
|
|
|
Xml::element( 'legend', null, $topmessage ) .
|
2009-08-27 13:02:57 +00:00
|
|
|
Xml::openElement( 'form', array( 'id' => 'mw-interwiki-deleteform', 'method' => 'post', 'action' => $actionUrl ) ) .
|
2008-12-31 18:44:54 +00:00
|
|
|
Xml::openElement( 'table' ) .
|
2011-06-11 22:14:03 +00:00
|
|
|
"<tr><td colspan='2'>$deletingmessage</td></tr>".
|
2009-08-27 13:02:57 +00:00
|
|
|
'<tr><td class="mw-label">' . Xml::label( $reasonmessage, 'mw-interwiki-deletereason' ) . '</td>' .
|
2008-12-31 18:44:54 +00:00
|
|
|
'<td class="mw-input">' .
|
2009-11-22 19:23:00 +00:00
|
|
|
Xml::input( 'wpInterwikiReason', 60, '', array( 'tabindex' => '1', 'id' => 'mw-interwiki-deletereason', 'maxlength' => '200' ) ) .
|
2009-08-27 13:02:57 +00:00
|
|
|
'</td></tr>' .
|
2009-11-20 19:54:02 +00:00
|
|
|
'<tr><td></td><td class="mw-submit">' . Xml::submitButton( $button, array( 'id' => 'mw-interwiki-submit' ) ) .
|
2011-06-11 22:14:03 +00:00
|
|
|
Html::hidden( 'wpInterwikiPrefix', $prefix ) .
|
|
|
|
Html::hidden( 'wpInterwikiAction', $action ) .
|
|
|
|
Html::hidden( 'wpEditToken', $token ) .
|
2008-12-31 18:44:54 +00:00
|
|
|
'</td></tr>' .
|
|
|
|
Xml::closeElement( 'table' ) .
|
|
|
|
Xml::closeElement( 'form' ) .
|
|
|
|
Xml::closeElement( 'fieldset' )
|
2008-04-03 21:00:22 +00:00
|
|
|
);
|
|
|
|
break;
|
2009-08-27 13:02:57 +00:00
|
|
|
case 'edit':
|
|
|
|
case 'add':
|
|
|
|
if( $action == 'edit' ){
|
2008-04-03 21:00:22 +00:00
|
|
|
$prefix = $wgRequest->getVal( 'prefix' );
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2009-08-27 13:02:57 +00:00
|
|
|
$row = $dbr->selectRow( 'interwiki', '*', array( 'iw_prefix' => $prefix ), __METHOD__ );
|
2011-03-11 14:20:39 +00:00
|
|
|
if( !$row ) {
|
2008-12-31 18:44:54 +00:00
|
|
|
$this->error( 'interwiki_editerror', $prefix );
|
2008-04-03 21:00:22 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-12-31 18:44:54 +00:00
|
|
|
$prefix = '<tt>' . htmlspecialchars( $row->iw_prefix ) . '</tt>';
|
|
|
|
$defaulturl = $row->iw_url;
|
|
|
|
$trans = $row->iw_trans;
|
|
|
|
$local = $row->iw_local;
|
2011-06-11 22:14:03 +00:00
|
|
|
$old = Html::hidden( 'wpInterwikiPrefix', $row->iw_prefix );
|
2008-12-31 18:44:54 +00:00
|
|
|
$topmessage = wfMsgExt( 'interwiki_edittext', array( 'parseinline' ) );
|
|
|
|
$intromessage = wfMsgExt( 'interwiki_editintro', array( 'parseinline' ) );
|
|
|
|
$button = wfMsg( 'edit' );
|
2008-04-03 21:00:22 +00:00
|
|
|
} else {
|
2008-12-31 18:44:54 +00:00
|
|
|
$prefix = $wgRequest->getVal( 'wpInterwikiPrefix' ) ? $wgRequest->getVal( 'wpInterwikiPrefix' ) : $wgRequest->getVal( 'prefix' );
|
2009-08-27 13:02:57 +00:00
|
|
|
$prefix = Xml::input( 'wpInterwikiPrefix', 20, $prefix, array( 'tabindex' => '1', 'id' => 'mw-interwiki-prefix', 'maxlength' => '20' ) );
|
2008-12-31 18:44:54 +00:00
|
|
|
$local = $wgRequest->getCheck( 'wpInterwikiLocal' );
|
|
|
|
$trans = $wgRequest->getCheck( 'wpInterwikiTrans' );
|
2008-04-03 21:00:22 +00:00
|
|
|
$old = '';
|
2011-06-11 22:14:03 +00:00
|
|
|
$defaulturl = $wgRequest->getVal( 'wpInterwikiURL' ) ? $wgRequest->getVal( 'wpInterwikiURL' ) : wfMsg( 'interwiki-defaulturl' );
|
2008-12-31 18:44:54 +00:00
|
|
|
$topmessage = wfMsgExt( 'interwiki_addtext', array( 'parseinline' ) );
|
|
|
|
$intromessage = wfMsgExt( 'interwiki_addintro', array( 'parseinline' ) );
|
|
|
|
$button = wfMsg( 'interwiki_addbutton' );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
|
|
|
|
2009-11-22 22:41:45 +00:00
|
|
|
$prefixmessage = wfMsgHtml( 'interwiki-prefix-label' );
|
|
|
|
$localmessage = wfMsg( 'interwiki-local-label' );
|
|
|
|
$transmessage = wfMsg( 'interwiki-trans-label' );
|
2008-12-31 18:44:54 +00:00
|
|
|
$reasonmessage = wfMsg( 'interwiki_reasonfield' );
|
2009-11-22 22:41:45 +00:00
|
|
|
$urlmessage = wfMsg( 'interwiki-url-label' );
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2008-05-29 18:38:56 +00:00
|
|
|
$wgOut->addHTML(
|
2009-11-22 19:23:00 +00:00
|
|
|
Xml::fieldset( $topmessage ) .
|
2008-12-31 18:44:54 +00:00
|
|
|
$intromessage .
|
2009-08-27 13:02:57 +00:00
|
|
|
Xml::openElement( 'form', array( 'id' => 'mw-interwiki-editform', 'method' => 'post', 'action' => $actionUrl ) ) .
|
|
|
|
Xml::openElement( 'table', array( 'id' => "mw-interwiki-$action" ) ) .
|
2008-12-31 18:44:54 +00:00
|
|
|
"<tr><td class='mw-label'>$prefixmessage</td><td><tt>$prefix</tt></td></tr>" .
|
2009-08-27 13:02:57 +00:00
|
|
|
'<tr><td class="mw-label">' . Xml::label( $localmessage, 'mw-interwiki-local' ) . '</td>' .
|
|
|
|
'<td class="mw-input">' . Xml::check( 'wpInterwikiLocal', $local, array( 'id' => 'mw-interwiki-local' ) ) . '</td></tr>' .
|
2008-12-31 18:44:54 +00:00
|
|
|
'<tr><td class="mw-label">' . Xml::label( $transmessage, 'mw-interwiki-trans' ) . '</td>' .
|
2009-08-27 13:02:57 +00:00
|
|
|
'<td class="mw-input">' . Xml::check( 'wpInterwikiTrans', $trans, array( 'id' => 'mw-interwiki-trans' ) ) . '</td></tr>' .
|
2008-12-31 18:44:54 +00:00
|
|
|
'<tr><td class="mw-label">' . Xml::label( $urlmessage, 'mw-interwiki-url' ) . '</td>' .
|
2009-08-27 13:02:57 +00:00
|
|
|
'<td class="mw-input">' . Xml::input( 'wpInterwikiURL', 60, $defaulturl, array( 'tabindex' => '1', 'maxlength' => '200', 'id' => 'mw-interwiki-url' ) ) . '</td></tr>' .
|
2008-12-31 18:44:54 +00:00
|
|
|
'<tr><td class="mw-label">' . Xml::label( $reasonmessage, 'mw-interwiki-editreason' ) . '</td>' .
|
2009-11-22 19:23:00 +00:00
|
|
|
'<td class="mw-input">' . Xml::input( 'wpInterwikiReason', 60, '', array( 'tabindex' => '1', 'id' => 'mw-interwiki-editreason', 'maxlength' => '200' ) ) .
|
2011-06-11 22:14:03 +00:00
|
|
|
Html::hidden( 'wpInterwikiAction', $action ) .
|
2008-12-31 18:44:54 +00:00
|
|
|
$old .
|
2011-06-11 22:14:03 +00:00
|
|
|
Html::hidden( 'wpEditToken', $token ) .
|
2008-12-31 18:44:54 +00:00
|
|
|
'</td></tr>' .
|
2009-11-20 19:54:02 +00:00
|
|
|
'<tr><td></td><td class="mw-submit">' . Xml::submitButton( $button, array( 'id' => 'mw-interwiki-submit' ) ) . '</td></tr>' .
|
2008-12-31 18:44:54 +00:00
|
|
|
Xml::closeElement( 'table' ) .
|
|
|
|
Xml::closeElement( 'form' ) .
|
|
|
|
Xml::closeElement( 'fieldset' )
|
2008-04-03 21:00:22 +00:00
|
|
|
);
|
|
|
|
break;
|
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() {
|
|
|
|
global $wgRequest, $wgOut;
|
|
|
|
$prefix = $wgRequest->getVal( 'wpInterwikiPrefix' );
|
|
|
|
$do = $wgRequest->getVal( 'wpInterwikiAction' );
|
2011-04-22 19:35:00 +00:00
|
|
|
// show an error if the prefix is invalid (only when adding one)
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
$reason = $wgRequest->getText( 'wpInterwikiReason' );
|
|
|
|
$selfTitle = $this->getTitle();
|
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
|
|
|
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
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
if ( $dbw->affectedRows() == 0 ) {
|
|
|
|
$this->error( 'interwiki_delfailed', $prefix );
|
|
|
|
$this->showForm( $do );
|
|
|
|
} else {
|
2009-08-27 13:02:57 +00:00
|
|
|
$wgOut->addWikiMsg( 'interwiki_deleted', $prefix );
|
2008-12-31 18:44:54 +00:00
|
|
|
$log = new LogPage( 'interwiki' );
|
|
|
|
$log->addEntry( 'iw_delete', $selfTitle, $reason, array( $prefix ) );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-08-27 13:02:57 +00:00
|
|
|
case 'edit':
|
|
|
|
case 'add':
|
2008-12-31 18:44:54 +00:00
|
|
|
$theurl = $wgRequest->getVal( 'wpInterwikiURL' );
|
|
|
|
$local = $wgRequest->getCheck( 'wpInterwikiLocal' ) ? 1 : 0;
|
|
|
|
$trans = $wgRequest->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
|
|
|
|
);
|
2011-06-11 22:14:03 +00:00
|
|
|
|
|
|
|
if( $prefix == '' || $theurl == '' ) {
|
|
|
|
$this->error( 'interwiki-submit-empty' );
|
|
|
|
$this->showForm( $do );
|
|
|
|
return;
|
|
|
|
}
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
if( $do == 'add' ){
|
|
|
|
$dbw->insert( 'interwiki', $data, __METHOD__, 'IGNORE' );
|
|
|
|
} else {
|
|
|
|
$dbw->update( 'interwiki', $data, array( 'iw_prefix' => $prefix ), __METHOD__, 'IGNORE' );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
if( $dbw->affectedRows() == 0 ) {
|
|
|
|
$this->error( "interwiki_{$do}failed", $prefix );
|
|
|
|
$this->showForm( $do );
|
|
|
|
} else {
|
|
|
|
$wgOut->addWikiMsg( "interwiki_{$do}ed", $prefix );
|
|
|
|
$log = new LogPage( 'interwiki' );
|
2009-08-27 13:02:57 +00:00
|
|
|
$log->addEntry( 'iw_' . $do, $selfTitle, $reason, array( $prefix, $theurl, $trans, $local ) );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2008-12-31 18:44:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2009-02-10 10:32:13 +00:00
|
|
|
function trans_local( $tl, $msg0, $msg1 ) {
|
2011-03-11 14:20:39 +00:00
|
|
|
if( $tl === '0' ) {
|
2009-02-10 10:32:13 +00:00
|
|
|
return $msg0;
|
2011-03-11 14:20:39 +00:00
|
|
|
}
|
|
|
|
if( $tl === '1' ) {
|
2009-02-10 10:32:13 +00:00
|
|
|
return $msg1;
|
2011-03-11 14:20:39 +00:00
|
|
|
}
|
2009-02-10 10:32:13 +00:00
|
|
|
return htmlspecialchars( $tl );
|
2009-02-07 03:30:23 +00:00
|
|
|
}
|
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
function showList( $admin ) {
|
2009-02-10 10:32:13 +00:00
|
|
|
global $wgUser, $wgOut, $wgScriptPath;
|
|
|
|
|
2010-04-17 22:52:42 +00:00
|
|
|
$wgOut->addExtensionStyle( "{$wgScriptPath}/extensions/Interwiki/Interwiki.css" );
|
2009-02-10 10:32:13 +00:00
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
$prefixmessage = wfMsgHtml( 'interwiki_prefix' );
|
|
|
|
$urlmessage = wfMsgHtml( 'interwiki_url' );
|
|
|
|
$localmessage = wfMsgHtml( 'interwiki_local' );
|
|
|
|
$transmessage = wfMsgHtml( 'interwiki_trans' );
|
2009-02-07 03:30:23 +00:00
|
|
|
$message_0 = wfMsgHtml( 'interwiki_0' );
|
|
|
|
$message_1 = wfMsgHtml( 'interwiki_1' );
|
2011-06-21 10:23:55 +00:00
|
|
|
$alignStart = 'class="mw-align-'.wfUILang()->AlignStart().'"';
|
|
|
|
$alignEnd = 'class="mw-align-'.wfUILang()->AlignEnd().'"';
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2009-02-07 03:30:23 +00:00
|
|
|
$out = '
|
2011-06-11 22:14:03 +00:00
|
|
|
<table class="mw-interwikitable wikitable intro">
|
2011-06-21 10:23:55 +00:00
|
|
|
<tr><th '.$alignStart.'>' . $prefixmessage . '</th><td>' . wfMsgExt( 'interwiki_prefix_intro', 'parseinline' ) . '</td></tr>
|
|
|
|
<tr><th '.$alignStart.'>' . $urlmessage . '</th><td>' . wfMsgExt( 'interwiki_url_intro', 'parseinline' ) . '</td></tr>
|
|
|
|
<tr><th '.$alignStart.'>' . $localmessage . '</th><td>' . wfMsgExt( 'interwiki_local_intro', 'parseinline' ) . '</td></tr>
|
|
|
|
<tr><th '.$alignEnd.'>' . $message_0 . '</th><td>' . wfMsgExt( 'interwiki_local_0_intro', 'parseinline' ) . '</td></tr>
|
|
|
|
<tr><th '.$alignEnd.'>' . $message_1 . '</th><td>' . wfMsgExt( 'interwiki_local_1_intro', 'parseinline' ) . '</td></tr>
|
|
|
|
<tr><th '.$alignStart.'>' . $transmessage . '</th><td>' . wfMsgExt( 'interwiki_trans_intro', 'parseinline' ) . '</td></tr>
|
|
|
|
<tr><th '.$alignEnd.'>' . $message_1 . '</th><td>' . wfMsgExt( 'interwiki_trans_1_intro', 'parseinline' ) . '</td></tr>
|
|
|
|
<tr><th '.$alignEnd.'>' . $message_0 . '</th><td>' . wfMsgExt( 'interwiki_trans_0_intro', 'parseinline' ) . '</td></tr>
|
2009-02-07 03:30:23 +00:00
|
|
|
</table>
|
|
|
|
';
|
2008-12-31 18:44:54 +00:00
|
|
|
$wgOut->addWikiMsg( 'interwiki_intro' );
|
2009-02-07 03:30:23 +00:00
|
|
|
$wgOut->addHTML( $out );
|
|
|
|
$wgOut->addWikiMsg( 'interwiki_intro_footer' );
|
2008-12-31 18:44:54 +00:00
|
|
|
|
2009-08-27 13:02:57 +00:00
|
|
|
// Privileged users can add new prefixes
|
2008-12-31 18:44:54 +00:00
|
|
|
if ( $admin ) {
|
|
|
|
$skin = $wgUser->getSkin();
|
|
|
|
$addtext = wfMsgHtml( 'interwiki_addtext' );
|
2011-06-12 11:45:15 +00:00
|
|
|
$addlink = $skin->link( $this->getTitle( 'add' ), $addtext );
|
2011-06-11 22:14:03 +00:00
|
|
|
$wgOut->addHTML( '<p class="mw-interwiki-addlink">' . $addlink . '</p>' );
|
2008-12-31 18:44:54 +00:00
|
|
|
}
|
2008-04-03 21:00:22 +00:00
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2009-08-27 13:02:57 +00:00
|
|
|
$res = $dbr->select( 'interwiki', '*', false, __METHOD__ );
|
2008-12-31 18:44:54 +00:00
|
|
|
$numrows = $res->numRows();
|
|
|
|
if ( $numrows == 0 ) {
|
2009-08-27 13:02:57 +00:00
|
|
|
// If the interwiki table is empty, display an error message
|
2008-12-31 18:44:54 +00:00
|
|
|
$this->error( 'interwiki_error' );
|
|
|
|
return;
|
|
|
|
}
|
2009-08-27 13:02:57 +00:00
|
|
|
|
2011-06-11 22:14:03 +00:00
|
|
|
$selfTitle = $this->getTitle();
|
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
$out = "
|
2011-06-11 22:14:03 +00:00
|
|
|
<table class='mw-interwikitable wikitable sortable body'>
|
2008-12-31 18:44:54 +00:00
|
|
|
<tr id='interwikitable-header'><th>$prefixmessage</th> <th>$urlmessage</th> <th>$localmessage</th> <th>$transmessage</th>";
|
2009-08-27 13:02:57 +00:00
|
|
|
// Privileged users can modify and delete existing prefixes
|
2008-12-31 18:44:54 +00:00
|
|
|
if( $admin ) {
|
|
|
|
$deletemessage = wfMsgHtml( 'delete' );
|
|
|
|
$editmessage = wfMsgHtml( 'edit' );
|
2009-11-20 19:54:02 +00:00
|
|
|
$out .= '<th class="unsortable">' . wfMsgHtml( 'interwiki_edit' ) . '</th>';
|
2008-12-31 18:44:54 +00:00
|
|
|
}
|
|
|
|
$out .= "</tr>\n";
|
2009-08-27 13:02:57 +00:00
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
while( $s = $res->fetchObject() ) {
|
|
|
|
$prefix = htmlspecialchars( $s->iw_prefix );
|
|
|
|
$url = htmlspecialchars( $s->iw_url );
|
2009-02-07 03:30:23 +00:00
|
|
|
$trans = $this->trans_local( $s->iw_trans, $message_0, $message_1 );
|
|
|
|
$local = $this->trans_local( $s->iw_local, $message_0, $message_1 );
|
2008-12-31 18:44:54 +00:00
|
|
|
$out .= "<tr class='mw-interwikitable-row'>
|
|
|
|
<td class='mw-interwikitable-prefix'>$prefix</td>
|
|
|
|
<td class='mw-interwikitable-url'>$url</td>
|
2009-02-10 10:32:13 +00:00
|
|
|
<td class='mw-interwikitable-local'>$local</td>
|
|
|
|
<td class='mw-interwikitable-trans'>$trans</td>";
|
2008-12-31 18:44:54 +00:00
|
|
|
if( $admin ) {
|
|
|
|
$out .= '<td class="mw-interwikitable-modify">';
|
|
|
|
$out .= $skin->link( $selfTitle, $editmessage, array(),
|
|
|
|
array( 'action' => 'edit', 'prefix' => $s->iw_prefix ) );
|
2009-11-20 19:54:02 +00:00
|
|
|
$out .= wfMsg( 'comma-separator' );
|
2008-12-31 18:44:54 +00:00
|
|
|
$out .= $skin->link( $selfTitle, $deletemessage, array(),
|
|
|
|
array( 'action' => 'delete', 'prefix' => $s->iw_prefix ) );
|
|
|
|
$out .= '</td>';
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2008-12-31 18:44:54 +00:00
|
|
|
|
|
|
|
$out .= "\n</tr>\n";
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2008-12-31 18:44:54 +00:00
|
|
|
$res->free();
|
2009-08-27 13:02:57 +00:00
|
|
|
$out .= '</table><br />';
|
2008-12-31 18:44:54 +00:00
|
|
|
$wgOut->addHTML( $out );
|
|
|
|
}
|
2009-08-27 13:02:57 +00:00
|
|
|
|
2008-12-31 18:44:54 +00:00
|
|
|
function error() {
|
|
|
|
global $wgOut;
|
|
|
|
$args = func_get_args();
|
|
|
|
$wgOut->wrapWikiMsg( "<p class='error'>$1</p>", $args );
|
2008-04-03 21:00:22 +00:00
|
|
|
}
|
2009-08-27 13:02:57 +00:00
|
|
|
|
2010-12-09 11:57:55 +00:00
|
|
|
}
|