summaryrefslogtreecommitdiff
path: root/extensions/Interwiki/Interwiki_body.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-01-28 09:50:25 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-01-28 09:50:25 -0500
commit5744df39e15f85c6cc8a9faf8924d77e76d2b216 (patch)
treea8c8dd40a94d1fa0d5377566aa5548ae55a163da /extensions/Interwiki/Interwiki_body.php
parent4bb2aeca1d198391ca856aa16c40b8559c68daec (diff)
parent224b22a051051f6c2e494c3a2fb4adb42898e2d1 (diff)
Merge branch 'archwiki'
Conflicts: extensions/FluxBBAuthPlugin.php extensions/SyntaxHighlight_GeSHi/README extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.i18n.php extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php extensions/SyntaxHighlight_GeSHi/geshi/docs/CHANGES extensions/SyntaxHighlight_GeSHi/geshi/docs/THANKS extensions/SyntaxHighlight_GeSHi/geshi/docs/TODO extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractClass.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractClass_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateClass.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateClass_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Class.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Class_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Constant.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Constructor.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Destructor.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Function.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Global.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/I.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Index.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Interface.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Interface_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/L.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Lminus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Lplus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Method.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Page.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Page_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateClass.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateClass_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateVariable.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/StaticMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/StaticVariable.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/T.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Tminus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Tplus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Variable.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/blank.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/class_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/file.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/function_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/next_button.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/next_button_disabled.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/package.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/package_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/previous_button.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/previous_button_disabled.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/private_class_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/tutorial.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/tutorial_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/up_button.png extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt extensions/SyntaxHighlight_GeSHi/geshi/geshi.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/4cs.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502acme.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502kickass.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502tasm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/68000devpac.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/abap.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/actionscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/actionscript3.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ada.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/algol68.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/apache.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/applescript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/apt_sources.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/asm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/asp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/autoconf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/autohotkey.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/autoit.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/avisynth.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/awk.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bascomavr.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bash.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/basic4gl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bibtex.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/blitzbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bnf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/boo.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/c.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/c_loadrunner.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/c_mac.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/caddcl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cadlisp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cfdg.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cfm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/chaiscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cil.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/clojure.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cmake.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cobol.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/coffeescript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cpp-qt.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cpp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/csharp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/css.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cuesheet.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/d.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/dcs.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/delphi.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/diff.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/div.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/dos.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/dot.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/e.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ecmascript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/eiffel.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/email.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/epc.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/erlang.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/euphoria.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/f1.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/falcon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/fo.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/fortran.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/freebasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/fsharp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gambas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gdb.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/genero.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/genie.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gettext.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/glsl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gnuplot.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/go.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/groovy.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gwbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/haskell.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/hicest.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/hq9plus.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/html4strict.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/html5.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/icon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/idl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ini.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/inno.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/intercal.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/io.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/j.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/java.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/java5.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/javascript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/jquery.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/kixtart.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/klonec.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/klonecpp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/latex.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lb.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lisp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/llvm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/locobasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/logtalk.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lolcode.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lotusformulas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lotusscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lsl2.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lua.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/m68k.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/magiksf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/make.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mapbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/matlab.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mirc.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mmix.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/modula2.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/modula3.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mpasm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mxml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mysql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/newlisp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/nsis.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oberon2.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/objc.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/objeck.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ocaml-brief.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ocaml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oobas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oracle11.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oracle8.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oxygene.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oz.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pascal.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pcre.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/per.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/perl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/perl6.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pic16.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pike.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pixelbender.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pli.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/plsql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/postgresql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/povray.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/powerbuilder.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/powershell.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/proftpd.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/progress.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/prolog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/properties.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/providex.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/purebasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pycon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/python.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/q.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/qbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rails.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rebol.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/reg.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/robots.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rpmspec.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rsplus.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ruby.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/sas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/scala.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/scheme.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/scilab.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/sdlbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/smalltalk.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/smarty.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/sql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/systemverilog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/tcl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/teraterm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/text.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/thinbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/tsql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/typoscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/unicon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/uscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vala.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vb.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vbnet.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/verilog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vhdl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vim.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/visualfoxpro.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/visualprolog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/whitespace.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/whois.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/winbatch.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xorg_conf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xpp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/yaml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/z80.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/zxbasic.php
Diffstat (limited to 'extensions/Interwiki/Interwiki_body.php')
-rw-r--r--extensions/Interwiki/Interwiki_body.php456
1 files changed, 456 insertions, 0 deletions
diff --git a/extensions/Interwiki/Interwiki_body.php b/extensions/Interwiki/Interwiki_body.php
new file mode 100644
index 00000000..ec104968
--- /dev/null
+++ b/extensions/Interwiki/Interwiki_body.php
@@ -0,0 +1,456 @@
+<?php
+/**
+ * Implements Special:Interwiki
+ * @ingroup SpecialPage
+ */
+class SpecialInterwiki extends SpecialPage {
+ /**
+ * Constructor - sets up the new special page
+ */
+ public function __construct() {
+ parent::__construct( 'Interwiki' );
+ }
+
+ /**
+ * Different description will be shown on Special:SpecialPage depending on
+ * whether the user can modify the data.
+ * @return String
+ */
+ function getDescription() {
+ return $this->msg( $this->canModify() ?
+ 'interwiki' : 'interwiki-title-norights' )->plain();
+ }
+
+ /**
+ * Show the special page
+ *
+ * @param $par Mixed: parameter passed to the page or null
+ */
+ public function execute( $par ) {
+ $this->setHeaders();
+ $this->outputHeader();
+
+ $out = $this->getOutput();
+ $request = $this->getRequest();
+
+ $out->addModules( 'ext.interwiki.specialpage' );
+
+ $action = $par ? $par : $request->getVal( 'action', $par );
+ $return = $this->getTitle();
+
+ switch( $action ) {
+ case 'delete':
+ case 'edit':
+ case 'add':
+ if ( $this->canModify( $out ) ) {
+ $this->showForm( $action );
+ }
+ $out->returnToMain( false, $return );
+ break;
+ case 'submit':
+ if ( !$this->canModify( $out ) ) {
+ # Error msg added by canModify()
+ } elseif ( !$request->wasPosted() ||
+ !$this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) )
+ ) {
+ // Prevent cross-site request forgeries
+ $out->addWikiMsg( 'sessionfailure' );
+ } else {
+ $this->doSubmit();
+ }
+ $out->returnToMain( false, $return );
+ break;
+ default:
+ $this->showList();
+ break;
+ }
+ }
+
+ /**
+ * Returns boolean whether the user can modify the data.
+ * @param $out OutputPage|bool If $wgOut object given, it adds the respective error message.
+ * @throws PermissionsError
+ * @return bool
+ */
+ public function canModify( $out = false ) {
+ global $wgInterwikiCache;
+ if ( !$this->getUser()->isAllowed( 'interwiki' ) ) {
+ # Check permissions
+ if ( $out ) {
+ throw new PermissionsError( 'interwiki' );
+ }
+
+ return false;
+ } elseif ( $wgInterwikiCache ) {
+ # Editing the interwiki cache is not supported
+ if ( $out ) {
+ $out->addWikiMsg( 'interwiki-cached' );
+ }
+
+ return false;
+ } elseif ( wfReadOnly() ) {
+ # Is the database in read-only mode?
+ if ( $out ) {
+ $out->readOnlyPage();
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @param $action string
+ */
+ function showForm( $action ) {
+ $request = $this->getRequest();
+
+ $prefix = $request->getVal( 'prefix' );
+ $wpPrefix = '';
+ $label = array( 'class' => 'mw-label' );
+ $input = array( 'class' => 'mw-input' );
+
+ if ( $action === 'delete' ) {
+ $topmessage = $this->msg( 'interwiki_delquestion', $prefix )->text();
+ $intromessage = $this->msg( 'interwiki_deleting', $prefix )->escaped();
+ $wpPrefix = Html::hidden( 'wpInterwikiPrefix', $prefix );
+ $button = 'delete';
+ $formContent = '';
+ } elseif ( $action === 'edit' ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ $row = $dbr->selectRow( 'interwiki', '*', array( 'iw_prefix' => $prefix ), __METHOD__ );
+
+ if ( !$row ) {
+ $this->error( 'interwiki_editerror', $prefix );
+ return;
+ }
+
+ $prefix = $prefixElement = $row->iw_prefix;
+ $defaulturl = $row->iw_url;
+ $trans = $row->iw_trans;
+ $local = $row->iw_local;
+ $wpPrefix = Html::hidden( 'wpInterwikiPrefix', $row->iw_prefix );
+ $topmessage = $this->msg( 'interwiki_edittext' )->text();
+ $intromessage = $this->msg( 'interwiki_editintro' )->escaped();
+ $button = 'edit';
+ } elseif ( $action === 'add' ) {
+ $prefix = $request->getVal( 'wpInterwikiPrefix', $request->getVal( 'prefix' ) );
+ $prefixElement = Xml::input( 'wpInterwikiPrefix', 20, $prefix,
+ array( 'tabindex' => 1, 'id' => 'mw-interwiki-prefix', 'maxlength' => 20 ) );
+ $local = $request->getCheck( 'wpInterwikiLocal' );
+ $trans = $request->getCheck( 'wpInterwikiTrans' );
+ $defaulturl = $request->getVal( 'wpInterwikiURL', $this->msg( 'interwiki-defaulturl' )->text() );
+ $topmessage = $this->msg( 'interwiki_addtext' )->text();
+ $intromessage = $this->msg( 'interwiki_addintro' )->escaped();
+ $button = 'interwiki_addbutton';
+ }
+
+ if ( $action === 'add' || $action === 'edit' ) {
+ $formContent = Html::rawElement( 'tr', null,
+ Html::element( 'td', $label, $this->msg( 'interwiki-prefix-label' )->text() ) .
+ Html::rawElement( 'td', null, '<tt>' . $prefixElement . '</tt>' )
+ ) . Html::rawElement(
+ 'tr',
+ null,
+ Html::rawElement(
+ 'td',
+ $label,
+ Xml::label( $this->msg( 'interwiki-local-label' )->text(), 'mw-interwiki-local' )
+ ) .
+ Html::rawElement(
+ 'td',
+ $input,
+ Xml::check( 'wpInterwikiLocal', $local, array( 'id' => 'mw-interwiki-local' ) )
+ )
+ ) . Html::rawElement( 'tr', null,
+ Html::rawElement(
+ 'td',
+ $label,
+ Xml::label( $this->msg( 'interwiki-trans-label' )->text(), 'mw-interwiki-trans' )
+ ) .
+ Html::rawElement(
+ 'td',
+ $input, Xml::check( 'wpInterwikiTrans', $trans, array( 'id' => 'mw-interwiki-trans' ) ) )
+ ) . Html::rawElement( 'tr', null,
+ Html::rawElement(
+ 'td',
+ $label,
+ Xml::label( $this->msg( 'interwiki-url-label' )->text(), 'mw-interwiki-url' )
+ ) .
+ Html::rawElement( 'td', $input, Xml::input( 'wpInterwikiURL', 60, $defaulturl,
+ array( 'tabindex' => 1, 'maxlength' => 200, 'id' => 'mw-interwiki-url' ) ) )
+ );
+ }
+
+ $form = Xml::fieldset( $topmessage, Html::rawElement(
+ 'form',
+ array(
+ 'id' => "mw-interwiki-{$action}form",
+ 'method' => 'post',
+ 'action' => $this->getTitle()->getLocalUrl( array(
+ 'action' => 'submit',
+ 'prefix' => $prefix
+ ) )
+ ),
+ Html::rawElement( 'p', null, $intromessage ) .
+ Html::rawElement( 'table', array( 'id' => "mw-interwiki-{$action}" ),
+ $formContent . Html::rawElement( 'tr', null,
+ Html::rawElement( 'td', $label, Xml::label( $this->msg( 'interwiki_reasonfield' )->text(),
+ "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' ),
+ Xml::submitButton( $this->msg( $button )->text(), array( 'id' => 'mw-interwiki-submit' ) ) )
+ ) . $wpPrefix .
+ Html::hidden( 'wpEditToken', $this->getUser()->getEditToken() ) .
+ Html::hidden( 'wpInterwikiAction', $action )
+ )
+ ) );
+ $this->getOutput()->addHTML( $form );
+ return;
+ }
+
+ function doSubmit() {
+ global $wgContLang, $wgMemc;
+
+ $request = $this->getRequest();
+ $prefix = $request->getVal( 'wpInterwikiPrefix' );
+ $do = $request->getVal( 'wpInterwikiAction' );
+ // Show an error if the prefix is invalid (only when adding one).
+ // Invalid characters for a title should also be invalid for a prefix.
+ // Whitespace, ':', '&' and '=' are invalid, too.
+ // (Bug 30599).
+ global $wgLegalTitleChars;
+ $validPrefixChars = preg_replace( '/[ :&=]/', '', $wgLegalTitleChars );
+ if ( preg_match( "/\s|[^$validPrefixChars]/", $prefix ) && $do === 'add' ) {
+ $this->error( 'interwiki-badprefix', htmlspecialchars( $prefix ) );
+ $this->showForm( $do );
+ return;
+ }
+ $reason = $request->getText( 'wpInterwikiReason' );
+ $selfTitle = $this->getTitle();
+ $dbw = wfGetDB( DB_MASTER );
+ switch( $do ) {
+ case 'delete':
+ $dbw->delete( 'interwiki', array( 'iw_prefix' => $prefix ), __METHOD__ );
+
+ if ( $dbw->affectedRows() === 0 ) {
+ $this->error( 'interwiki_delfailed', $prefix );
+ $this->showForm( $do );
+ } else {
+ $this->getOutput()->addWikiMsg( 'interwiki_deleted', $prefix );
+ $log = new LogPage( 'interwiki' );
+ $log->addEntry( 'iw_delete', $selfTitle, $reason, array( $prefix ) );
+ $wgMemc->delete( wfMemcKey( 'interwiki', $prefix ) );
+ }
+ break;
+ case 'add':
+ $prefix = $wgContLang->lc( $prefix );
+ // N.B.: no break!
+ case 'edit':
+ $theurl = $request->getVal( 'wpInterwikiURL' );
+ $local = $request->getCheck( 'wpInterwikiLocal' ) ? 1 : 0;
+ $trans = $request->getCheck( 'wpInterwikiTrans' ) ? 1 : 0;
+ $data = array(
+ 'iw_prefix' => $prefix,
+ 'iw_url' => $theurl,
+ 'iw_local' => $local,
+ 'iw_trans' => $trans
+ );
+
+ if ( $prefix === '' || $theurl === '' ) {
+ $this->error( 'interwiki-submit-empty' );
+ $this->showForm( $do );
+ return;
+ }
+
+ // Simple URL validation: check that the protocol is one of
+ // the supported protocols for this wiki.
+ // (bug 30600)
+ if ( !wfParseUrl( $theurl ) ) {
+ $this->error( 'interwiki-submit-invalidurl' );
+ $this->showForm( $do );
+ return;
+ }
+
+ if ( $do === 'add' ) {
+ $dbw->insert( 'interwiki', $data, __METHOD__, 'IGNORE' );
+ } else { // $do === 'edit'
+ $dbw->update( 'interwiki', $data, array( 'iw_prefix' => $prefix ), __METHOD__, 'IGNORE' );
+ }
+
+ // used here: interwiki_addfailed, interwiki_added, interwiki_edited
+ if ( $dbw->affectedRows() === 0 ) {
+ $this->error( "interwiki_{$do}failed", $prefix );
+ $this->showForm( $do );
+ } else {
+ $this->getOutput()->addWikiMsg( "interwiki_{$do}ed", $prefix );
+ $log = new LogPage( 'interwiki' );
+ $log->addEntry( 'iw_' . $do, $selfTitle, $reason, array( $prefix, $theurl, $trans, $local ) );
+ $wgMemc->delete( wfMemcKey( 'interwiki', $prefix ) );
+ }
+ break;
+ }
+ }
+
+ function showList() {
+ $canModify = $this->canModify();
+
+ $this->getOutput()->addWikiMsg( 'interwiki_intro' );
+ // Make collapsible.
+ $this->getOutput()->addHTML(
+ Html::openElement(
+ 'div', array(
+ 'class' => 'mw-collapsible mw-collapsed',
+ 'data-collapsetext' => $this->msg( 'interwiki-legend-hide' )->escaped(),
+ 'data-expandtext' => $this->msg('interwiki-legend-show' )->escaped()
+ ) ) );
+ $this->getOutput()->addHTML(
+ Html::rawElement(
+ 'table', array( 'class' => 'mw-interwikitable wikitable intro' ),
+ $this->addInfoRow( 'start', 'interwiki_prefix', 'interwiki_prefix_intro' ) . "\n" .
+ $this->addInfoRow( 'start', 'interwiki_url', 'interwiki_url_intro' ) . "\n" .
+ $this->addInfoRow( 'start', 'interwiki_local', 'interwiki_local_intro' ) . "\n" .
+ $this->addInfoRow( 'end', 'interwiki_0', 'interwiki_local_0_intro' ) . "\n" .
+ $this->addInfoRow( 'end', 'interwiki_1', 'interwiki_local_1_intro' ) . "\n" .
+ $this->addInfoRow( 'start', 'interwiki_trans', 'interwiki_trans_intro' ) . "\n" .
+ $this->addInfoRow( 'end', 'interwiki_0', 'interwiki_trans_0_intro' ) . "\n" .
+ $this->addInfoRow( 'end', 'interwiki_1', 'interwiki_trans_1_intro' ) . "\n"
+ )
+ );
+
+ $this->getOutput()->addHTML( Html::closeElement( 'div' ) ); // end collapsible.
+
+ if ( $canModify ) {
+ $this->getOutput()->addHTML( "<br />" . $this->msg( 'interwiki_intro_footer' )->parse() );
+ $addtext = $this->msg( 'interwiki_addtext' )->escaped();
+ $addlink = Linker::linkKnown( $this->getTitle( 'add' ), $addtext );
+ $this->getOutput()->addHTML( '<p class="mw-interwiki-addlink">' . $addlink . '</p>' );
+ }
+
+ if ( !method_exists( 'Interwiki', 'getAllPrefixes' ) ) {
+ # version 2.0 is not backwards compatible (but still display nice error)
+ $this->error( 'interwiki_error' );
+ return;
+ }
+ $iwPrefixes = Interwiki::getAllPrefixes( null );
+
+ if ( !is_array( $iwPrefixes ) || count( $iwPrefixes ) === 0 ) {
+ # If the interwiki table is empty, display an error message
+ $this->error( 'interwiki_error' );
+ return;
+ }
+
+ # Output the existing Interwiki prefixes table header
+ $out = '';
+ $out .= Html::openElement(
+ 'table',
+ array( 'class' => 'mw-interwikitable wikitable sortable body' )
+ ) . "\n";
+ $out .= Html::openElement( 'tr', array( 'id' => 'interwikitable-header' ) ) .
+ 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()
+ ) :
+ ''
+ );
+ $out .= Html::closeElement( 'tr' ) . "\n";
+
+ $selfTitle = $this->getTitle();
+
+ # Output the existing Interwiki prefixes table rows
+ foreach ( $iwPrefixes as $iwPrefix ) {
+ $out .= Html::openElement( 'tr', array( 'class' => 'mw-interwikitable-row' ) );
+ $out .= Html::element( 'td', array( 'class' => 'mw-interwikitable-prefix' ),
+ $iwPrefix['iw_prefix'] );
+ $out .= Html::element(
+ 'td',
+ array( 'class' => 'mw-interwikitable-url' ),
+ $iwPrefix['iw_url']
+ );
+ $attribs = array( 'class' => 'mw-interwikitable-local' );
+ // Green background for cells with "yes".
+ if( $iwPrefix['iw_local'] ) {
+ $attribs['style'] = 'background: lime;';
+ }
+ // The messages interwiki_0 and interwiki_1 are used here.
+ $contents = isset( $iwPrefix['iw_local'] ) ?
+ $this->msg( 'interwiki_' . $iwPrefix['iw_local'] )->text() :
+ '-';
+ $out .= Html::element( 'td', $attribs, $contents );
+ $attribs = array( 'class' => 'mw-interwikitable-trans' );
+ // Green background for cells with "yes".
+ if( $iwPrefix['iw_trans'] ) {
+ $attribs['style'] = 'background: lime;';
+ }
+ // The messages interwiki_0 and interwiki_1 are used here.
+ $contents = isset( $iwPrefix['iw_trans'] ) ?
+ $this->msg( 'interwiki_' . $iwPrefix['iw_trans'] )->text() :
+ '-';
+ $out .= Html::element( 'td', $attribs, $contents );
+
+ // Additional column when the interwiki table can be modified.
+ if ( $canModify ) {
+ $out .= Html::rawElement( 'td', array( 'class' => 'mw-interwikitable-modify' ),
+ Linker::linkKnown( $selfTitle, $this->msg( 'edit' )->escaped(), array(),
+ array( 'action' => 'edit', 'prefix' => $iwPrefix['iw_prefix'] ) ) .
+ $this->msg( 'comma-separator' ) .
+ Linker::linkKnown( $selfTitle, $this->msg( 'delete' )->escaped(), array(),
+ array( 'action' => 'delete', 'prefix' => $iwPrefix['iw_prefix'] ) )
+ );
+ }
+ $out .= Html::closeElement( 'tr' ) . "\n";
+ }
+ $out .= Html::closeElement( 'table' );
+
+ $this->getOutput()->addHTML( $out );
+ }
+
+ /**
+ * Adds a row to the documentation table on the top of Special:Interwiki.
+ * @param $align string
+ * @param $title string
+ * @param $text string
+ * @return string
+ */
+ private function addInfoRow( $align = 'start', $title, $text ) {
+ return Html::rawElement( 'tr', null,
+ // The classes mw-align-start and mw-align-end are used here.
+ Html::rawElement(
+ 'th',
+ array( 'class' => 'mw-align-' . $align ),
+ $this->msg( $title )->escaped()
+ ) .
+ // This message is expected to have wiki syntax
+ Html::rawElement( 'td', null, $this->msg( $text )->parse() )
+ );
+ }
+
+ function error() {
+ $args = func_get_args();
+ $this->getOutput()->wrapWikiMsg( "<p class='error'>$1</p>", $args );
+ }
+}
+
+/**
+ * Needed to pass the URL as a raw parameter, because it contains $1
+ */
+class InterwikiLogFormatter extends LogFormatter {
+ /**
+ * @return array
+ */
+ protected function getMessageParameters() {
+ $params = parent::getMessageParameters();
+ if ( isset( $params[4] ) ) {
+ $params[4] = Message::rawParam( htmlspecialchars( $params[4] ) );
+ }
+ return $params;
+ }
+}