Robert Vogel has submitted this change and it was merged.

Change subject: Used API instead of AjaxExportList
......................................................................


Used API instead of AjaxExportList

* Various small fixes
* Added some real validation of params
* Removed duplicated i18n key "bs-interwikilinks-link-added"
* Added new i18n key "bs-interwikilinks-link-edited"
* Fixed cache problem by using invalidations

=> Requires 271791

PatchSet6
* removed unkwnown param submitValue
* changed the api module name to bs-interwikilinks-tasks

Change-Id: I40fe6652b726d1091965c040d6c4fab208b05190
---
M InterWikiLinks/InterWikiLinks.class.php
M InterWikiLinks/InterWikiLinks.setup.php
M InterWikiLinks/i18n/en.json
M InterWikiLinks/i18n/qqq.json
A InterWikiLinks/includes/api/BSApiTasksInterWikiLinksManager.php
M InterWikiLinks/resources/BS.InterWikiLinks/InterWikiLinksDialog.js
M InterWikiLinks/resources/BS.InterWikiLinks/Panel.js
7 files changed, 325 insertions(+), 256 deletions(-)

Approvals:
  Robert Vogel: Looks good to me, approved
  Siebrand: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/InterWikiLinks/InterWikiLinks.class.php 
b/InterWikiLinks/InterWikiLinks.class.php
index 536a7da..fe34f97 100644
--- a/InterWikiLinks/InterWikiLinks.class.php
+++ b/InterWikiLinks/InterWikiLinks.class.php
@@ -112,204 +112,7 @@
                return '<div id="InterWikiLinksGrid"></div>';
        }
 
-       /**
-        * Provides a list of current interwiki links. This function is called 
via AJAX
-        * @return bool allow other hooked methods to be executed. always true.
-        */
-       public static function getInterWikiLinks() {
-               if ( BsCore::checkAccessAdmission( 'wikiadmin' ) === false ) 
return true;
-               global $wgRequest;
-               $iLimit = $wgRequest->getInt( 'limit', 25 );
-               $iStart = $wgRequest->getInt( 'start', 0 );
-
-               $data = array();
-
-               $dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select(
-                               'interwiki',
-                               '*',
-                               '',
-                               '',
-                               array( "ORDER BY" => "iw_prefix" )
-               );
-               $data['totalCount'] = $dbr->numRows( $res );
-
-               global $wgDBtype, $wgDBprefix;
-               if ( $wgDBtype == 'oracle' ) {
-                       $res = $dbr->query( "SELECT * FROM
-                                                                       (SELECT 
iw_prefix,iw_url,iw_api,iw_wikiid,iw_local,iw_trans,row_number() over (order by 
iw_prefix ASC) rnk
-                                                                               
FROM \"".strtoupper( $wgDBprefix )."INTERWIKI\"
-                                                                       )
-                                                                       where 
rnk BETWEEN ".($iStart+1)." AND ".($iLimit + $iStart)
-                                               );
-               } else {
-                       $res = $dbr->select(
-                                       'interwiki',
-                                       '*',
-                                       '',
-                                       '',
-                                       array(
-                                               "ORDER BY" => "iw_prefix",
-                                               "LIMIT" => $iLimit,
-                                               "OFFSET" => $iStart
-                                       )
-                       );
-               }
-
-               $data['iwlinks'] = array();
-               $tmp = array();
-               while ( $row = $dbr->fetchObject( $res )) {
-                       $tmp['iwl_prefix'] = $row->iw_prefix;
-                       $tmp['iwl_url'] = $row->iw_url;
-                       $data['iwlinks'][] = $tmp;
-               }
-               $dbr->freeResult( $res );
-
-               return FormatJson::encode( $data );
-       }
-
-       /**
-        * Creates or edits an interwiki link. Called via AJAX function
-        * @return bool allow other hooked methods to be executed. always true.
-        */
-       public static function doEditInterWikiLink( $bEditMode, $iw_prefix, 
$iw_url, $iw_old_prefix = '' ) {
-               if ( wfReadOnly() ) {
-                       global $wgReadOnly;
-                       return FormatJson::encode( array(
-                               'success' => false,
-                               'message' => array( wfMessage( 'bs-readonly', 
$wgReadOnly )->plain() )
-                               ) );
-               }
-               if ( BsCore::checkAccessAdmission( 'wikiadmin' ) === false ) 
return true;
-
-               $aAnswer = array(
-                       'success' => true,
-                       'errors' => array(),
-                       'message' => array()
-               );
-
-               if ( strlen( $iw_prefix ) > 32 ) {
-                       $aAnswer['success'] = false;
-                       $aAnswer['errors'][] = array('id' => 'iweditprefix', 
'message' => wfMessage( 'bs-interwikilinks-pfxtoolong' )->plain() );
-               }
-
-               if ( $iw_prefix == '' ) {
-                       $aAnswer['success'] = false;
-                       $aAnswer['errors'][] = array('id' => 'iweditprefix', 
'message' => wfMessage( 'bs-interwikilinks-nopfx' )->plain() );
-               }
-
-               if ( $iw_url == '' ) {
-                       $aAnswer['success'] = false;
-                       $aAnswer['errors'][] = array('id' => 'iwediturl', 
'message' => wfMessage( 'bs-interwikilinks-nourl' )->plain() );
-               }
-
-               $oValidationResult = BsValidator::isValid( 'Url', $iw_url, 
array( 'fullResponse' => true ) );
-               if ( $oValidationResult->getErrorCode() ) {
-                       $aAnswer['success'] = false;
-                       $aAnswer['errors'][] = array('id' => 'iwediturl', 
'message' => $oValidationResult->getI18N() );
-               }
-
-               if ( substr_count( $iw_prefix, ' ' )
-                       || substr_count( $iw_prefix, '"' )
-                       || substr_count( $iw_prefix, '&' )
-                       || substr_count( $iw_prefix, ':' ) ) {
-                       $aAnswer['success'] = false;
-                       $aAnswer['errors'][] = array('id' => 'iweditprefix', 
'message' => wfMessage( 'bs-interwikilinks-invalid-pfx-spc' )->plain() );
-               }
-
-               if ( strpos( $iw_url, ' ' ) ) {
-                       $aAnswer['success'] = false;
-                       $aAnswer['errors'][] = array('id' => 'iwediturl', 
'message' => wfMessage( 'bs-interwikilinks-invalid-url-spc' )->plain() );
-               }
-
-               if ( $bEditMode == 'true' ) {
-                       $sSearchPrefix = $iw_old_prefix;
-               } else {
-                       $sSearchPrefix = $iw_prefix;
-               }
-
-               $dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select( 'interwiki', 'iw_prefix', array( 
"iw_prefix" => $sSearchPrefix ) );
-               $num_row = $dbr->numRows( $res );
-
-               if ( $bEditMode == 'false' ) {
-                       if ( $num_row >= 1 ) {
-                               $aAnswer['success'] = false;
-                               $aAnswer['errors'][] = array( 'message' => 
wfMessage( 'bs-interwikilinks-pfxexists' )->plain() );
-                       }
-               } else {
-                       if ( $num_row < 1 ) {
-                               $aAnswer['success'] = false;
-                               $aAnswer['errors'][] = array( 'message' => 
wfMessage( 'bs-interwikilinks-nooldpfx' )->plain() );
-                       }
-               }
-
-               if ( $aAnswer['success'] ) {
-                       $dbw = wfGetDB( DB_MASTER );
-                       if ( $bEditMode == 'false' ) {
-                               $dbw->insert( 'interwiki',
-                                               array(
-                                                       'iw_prefix' => 
$iw_prefix,
-                                                       'iw_url' => $iw_url,
-                                                       'iw_local' => '0'
-                                               )
-                               );
-                       } else {
-                               $dbw->update( 'interwiki',
-                                       array( 'iw_prefix' => $iw_prefix, 
'iw_url' => $iw_url),
-                                       array( 'iw_prefix' => $iw_old_prefix )
-                               );
-                       }
-                       $aAnswer['message'][] = $bEditMode ? wfMessage( 
'bs-interwikilinks-link-added' )->plain() : wfMessage( 
'bs-interwikilinks-link-created' )->plain();
-               }
-
-               self::purgeTitles( $iw_prefix );
-
-               return FormatJson::encode( $aAnswer );
-       }
-
-
-
-       /**
-        * Deletes an interwiki link. Called via AJAX function
-        * @return bool allow other hooked methods to be executed. always true.
-        */
-       public static function doDeleteInterWikiLink( $iw_prefix ) {
-               if ( wfReadOnly() ) {
-                       global $wgReadOnly;
-                       return FormatJson::encode( array(
-                               'success' => false,
-                               'message' => array( wfMessage( 'bs-readonly', 
$wgReadOnly )->plain() )
-                               ) );
-               }
-               if ( BsCore::checkAccessAdmission( 'wikiadmin' ) === false ) 
return true;
-
-               $aAnswer = array(
-                       'success' => true,
-                       'errors' => array(),
-                       'message' => array()
-               );
-
-               if ( $aAnswer['success'] ) {
-                       $dbw = wfGetDB( DB_MASTER );
-                       $res1 = $dbw->delete( 'interwiki', array( 'iw_prefix' 
=> $iw_prefix ) );
-               }
-
-               if ( $res1 === false ) {
-                       $aAnswer['success'] = false;
-                       $aAnswer['errors'][] = array( 'message' => wfMessage( 
'bs-interwikilinks-nourl' )->plain() );
-               }
-
-               if ( $aAnswer['success'] ) {
-                       $aAnswer['message'][] = wfMessage( 
'bs-interwikilinks-link-deleted' )->plain();
-               }
-
-               self::purgeTitles( $iw_prefix );
-
-               return FormatJson::encode( $aAnswer );
-       }
-
-       protected static function purgeTitles($iw_prefix) {
+       public static function purgeTitles($iw_prefix) {
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select(
                        'iwlinks',
diff --git a/InterWikiLinks/InterWikiLinks.setup.php 
b/InterWikiLinks/InterWikiLinks.setup.php
index 76db4f4..40c01b8 100644
--- a/InterWikiLinks/InterWikiLinks.setup.php
+++ b/InterWikiLinks/InterWikiLinks.setup.php
@@ -2,6 +2,7 @@
 BsExtensionManager::registerExtension('InterWikiLinks', 
BsRUNLEVEL::FULL|BsRUNLEVEL::REMOTE, BsACTION::LOAD_SPECIALPAGE);
 
 $GLOBALS['wgAutoloadClasses']['InterWikiLinks'] = __DIR__ . 
'/InterWikiLinks.class.php';
+$GLOBALS['wgAutoloadClasses']['BSApiTasksInterWikiLinksManager'] = __DIR__ . 
'/includes/api/BSApiTasksInterWikiLinksManager.php';
 
 $wgMessagesDirs['InterWikiLinks'] = __DIR__ . '/i18n';
 
@@ -36,6 +37,4 @@
        'remoteBasePath' => &$GLOBALS['wgScriptPath']
 );
 
-$wgAjaxExportList[] = 'InterWikiLinks::getInterWikiLinks';
-$wgAjaxExportList[] = 'InterWikiLinks::doEditInterWikiLink';
-$wgAjaxExportList[] = 'InterWikiLinks::doDeleteInterWikiLink';
\ No newline at end of file
+$wgAPIModules['bs-interwikilinks-tasks'] = 'BSApiTasksInterWikiLinksManager';
\ No newline at end of file
diff --git a/InterWikiLinks/i18n/en.json b/InterWikiLinks/i18n/en.json
index 7d45239..5c8a391 100644
--- a/InterWikiLinks/i18n/en.json
+++ b/InterWikiLinks/i18n/en.json
@@ -26,5 +26,7 @@
        "bs-interwikilinks-confirmdeleteinterwikilink": "Are you sure, you want 
delete this interwiki link?",
        "bs-interwikilinks-insertlink-tabtitle": "Link into another wiki",
        "bs-interwikilinks-insertlink-labelprefix": "Prefix",
-       "bs-interwikilink-select-a-prefix": "Choose prefix"
+       "bs-interwikilink-select-a-prefix": "Choose prefix",
+       "bs-interwikilinks-link-edited": "The interwiki link has been edited",
+       "apihelp-bs-interwikilinks-tasks-description": "Provides the tasks for 
the extension InterWikiLinks."
 }
diff --git a/InterWikiLinks/i18n/qqq.json b/InterWikiLinks/i18n/qqq.json
index e982d67..c0cbeae 100644
--- a/InterWikiLinks/i18n/qqq.json
+++ b/InterWikiLinks/i18n/qqq.json
@@ -12,7 +12,6 @@
        "bs-interwikilinks-invalid-url-spc": "Text for the URL is invalid. 
Please do not use spaces.",
        "bs-interwikilinks-label": "Anchor text in admin tab for interwiki 
links.\n{{Identical|Interwiki link}}",
        "bs-interwikilinks-link-created": "Text for the interwiki link has been 
created.",
-       "bs-interwikilinks-link-added": "Text for the interwiki link has been 
added.",
        "bs-interwikilinks-link-deleted": "Text for the interwiki link has been 
deleted.",
        "bs-interwikilinks-nooldpfx": "Text for the previous prefix was not 
found.",
        "bs-interwikilinks-nopfx": "Text for please supply a prefix.",
@@ -29,5 +28,7 @@
        "bs-interwikilinks-confirmdeleteinterwikilink": "Text for are you sure, 
you want delete this interwiki link?",
        "bs-interwikilinks-insertlink-tabtitle": "Text for link in another 
wiki",
        "bs-interwikilinks-insertlink-labelprefix": "Text for 
prefix\n{{Identical|Prefix}}",
-       "bs-interwikilink-select-a-prefix": "Text for choose prefix"
+       "bs-interwikilink-select-a-prefix": "Text for choose prefix",
+       "bs-interwikilinks-link-edited": "Text for the interwiki link has been 
edited",
+       "apihelp-bs-interwikilinks-tasks-description": "Describes the API 
endpoint that provides tasks for the InterWikiLinks extension."
 }
diff --git a/InterWikiLinks/includes/api/BSApiTasksInterWikiLinksManager.php 
b/InterWikiLinks/includes/api/BSApiTasksInterWikiLinksManager.php
new file mode 100644
index 0000000..1d944aa
--- /dev/null
+++ b/InterWikiLinks/includes/api/BSApiTasksInterWikiLinksManager.php
@@ -0,0 +1,268 @@
+<?php
+/**
+ * Provides the Interwiki links manager tasks api for BlueSpice.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * This file is part of BlueSpice for MediaWiki
+ * For further information visit http://www.blue-spice.org
+ *
+ * @author     Patric Wirth <wi...@hallowelt.biz>
+ * @package    Bluespice_Extensions
+ * @copyright  Copyright (C) 2011 Hallo Welt! - Medienwerkstatt GmbH, All 
rights reserved.
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or 
later
+ */
+
+/**
+ * InterWikiLinksManager Api class
+ * @package BlueSpice_Extensions
+ */
+class BSApiTasksInterWikiLinksManager extends BSApiTasksBase {
+
+       /**
+        * Methods that can be called by task param
+        * @var array
+        */
+       protected $aTasks = array(
+               'editInterWikiLink',
+               'removeInterWikiLink',
+       );
+
+       /**
+        * Returns an array of tasks and their required permissions
+        * array( 'taskname' => array('read', 'edit') )
+        * @return array
+        */
+       protected function getRequiredTaskPermissions() {
+               return array(
+                       'editInterWikiLink' => array( 'wikiadmin' ),
+                       'removeInterWikiLink' => array( 'wikiadmin' ),
+               );
+       }
+
+       public function needsToken() {
+               parent::needsToken();
+       }
+
+       /**
+        * Creates or edits an interwiki link.
+        * @return stdClass Standard tasks API return
+        */
+       protected function task_editInterWikiLink( $oTaskData ) {
+               $oReturn = $this->makeStandardReturn();
+               $oPrefix = null;
+
+               $sOldPrefix = isset( $oTaskData->oldPrefix )
+                       ? (string) $oTaskData->oldPrefix
+                       : ''
+               ;
+               $sUrl = isset( $oTaskData->url )
+                       ? (string) $oTaskData->url
+                       : ''
+               ;
+               $sPrefix = isset( $oTaskData->prefix )
+                       ? (string) $oTaskData->prefix
+                       : ''
+               ;
+
+               //Make sure we get the db result!
+               if( !empty($sPrefix) ) {
+                       $sKey = wfMemcKey( 'interwiki', $sPrefix );
+                       wfGetMainCache()->delete( $sKey );
+               }
+               if( !empty($sOldPrefix) ) {
+                       $sKey = wfMemcKey( 'interwiki', $sOldPrefix );
+                       wfGetMainCache()->delete( $sKey );
+               }
+
+               if( !empty($sOldPrefix) && !$oPrefix = 
Interwiki::fetch($sOldPrefix) ) {
+                       $oReturn->errors[] = array(
+                               'id' => 'iweditprefix',
+                               'message' => wfMessage( 
'bs-interwikilinks-nooldpfx' )->plain(),
+                       );
+               } elseif( !empty($sPrefix) && $oPrefix = 
Interwiki::fetch($sPrefix) && $sPrefix !== $sOldPrefix) {
+                       $oReturn->errors[] = array(
+                               'id' => 'iweditprefix',
+                               'message' => wfMessage( 
'bs-interwikilinks-pfxexists' )->plain(),
+                       );
+               }
+               if( !empty($oReturn->errors) ) {
+                       return $oReturn;
+               }
+
+               if( !$oPrefix && empty($sUrl) ) {
+                       $oReturn->errors[] = array(
+                               'id' => 'iwediturl',
+                               'message' => wfMessage( 
'bs-interwikilinks-nourl' )->plain(),
+                       );
+               }
+               if( !$oPrefix && empty($sPrefix) ) {
+                       $oReturn->errors[] = array(
+                               'id' => 'iweditprefix',
+                               'message' => wfMessage( 
'bs-interwikilinks-nopfx' )->plain(),
+                       );
+               }
+               if( !empty($sUrl) ) {
+                       $oValidationResult = BsValidator::isValid(
+                               'Url',
+                               $sUrl,
+                               array( 'fullResponse' => true
+                       ));
+                       if( $oValidationResult->getErrorCode() ) {
+                               $oReturn->errors[] = array(
+                                       'id' => 'iwediturl',
+                                       'message' => 
$oValidationResult->getI18N()
+                               );
+                       }
+                       if( strpos( $sUrl, ' ' ) ) {
+                               $oReturn->errors[] = array(
+                                       'id' => 'iwediturl',
+                                       'message' => wfMessage(
+                                               
'bs-interwikilinks-invalid-url-spc'
+                                       )->plain()
+                               );
+                       }
+               }
+               if( !empty($sPrefix) ) {
+                       if ( strlen( $sPrefix ) > 32 ) {
+                               $oReturn->errors[] = array(
+                                       'id' => 'iweditprefix',
+                                       'message' => wfMessage(
+                                               'bs-interwikilinks-pfxtoolong'
+                                       )->plain(),
+                               );
+                       }
+
+                       foreach( array( ' ', '"', '&', ':') as $sInvalidChar ) {
+                               if( substr_count( $sPrefix, $sInvalidChar ) === 
0 ) {
+                                       continue;
+                               }
+                               //TODO (PW 19.02.2016): Return the invalid 
char(s)
+                               $oReturn->errors[] = array(
+                                       'id' => 'iweditprefix',
+                                       'message' => wfMessage(
+                                               
'bs-interwikilinks-invalid-pfx-spc'
+                                       )->plain()
+                               );
+                               break;
+                       }
+               }
+
+               if( !empty($oReturn->errors) ) {
+                       return $oReturn;
+               }
+
+               $oDB = $this->getDB();
+               $sTable = 'interwiki';
+               $aConditions = array(
+                       'iw_local' => '0',
+               );
+               $aValues = array(
+                       'iw_prefix' => $sPrefix,
+                       'iw_url' => $sUrl,
+               );
+
+               if( empty($sOldPrefix) ) {
+                       $oReturn->success = $oDB->insert(
+                               $sTable,
+                               array_merge( $aConditions, $aValues ),
+                               __METHOD__
+                       );
+                       $oReturn->message = wfMessage(
+                               'bs-interwikilinks-link-created'
+                       )->plain();
+
+                       //Make sure to invalidate as much as possible!
+                       $sKey = wfMemcKey( 'interwiki', $sPrefix );
+                       wfGetMainCache()->delete( $sKey );
+                       InterWikiLinks::purgeTitles( $sPrefix );
+                       return $oReturn;
+               }
+
+               $aConditions['iw_prefix'] = $sOldPrefix;
+               $oReturn->success = $oDB->update(
+                       $sTable,
+                       $aValues,
+                       $aConditions,
+                       __METHOD__
+               );
+               $oReturn->message = wfMessage(
+                       'bs-interwikilinks-link-edited'
+               )->plain();
+
+               //Make sure to invalidate as much as possible!
+               $sKey = wfMemcKey( 'interwiki', $sPrefix );
+               wfGetMainCache()->delete( $sKey );
+               $sKey = wfMemcKey( 'interwiki', $sOldPrefix );
+               wfGetMainCache()->delete( $sKey );
+               InterWikiLinks::purgeTitles( $sOldPrefix );
+
+               return $oReturn;
+       }
+
+       /**
+        * Creates or edits an interwiki link.
+        * @return stdClass Standard tasks API return
+        */
+       protected function task_removeInterWikiLink( $oTaskData ) {
+               $oReturn = $this->makeStandardReturn();
+               $oPrefix = null;
+
+               $sPrefix = isset( $oTaskData->prefix )
+                       ? (string) $oTaskData->prefix
+                       : ''
+               ;
+
+               if( empty($sPrefix) ) {
+                       $oReturn->errors[] = array(
+                               'id' => 'iweditprefix',
+                               'message' => wfMessage( 
'bs-interwikilinks-nopfx' )->plain(),
+                       );
+                       return $oReturn;
+               }
+
+               //Make sure we get the db result!
+               if( !empty($sPrefix) ) {
+                       $sKey = wfMemcKey( 'interwiki', $sPrefix );
+                       wfGetMainCache()->delete( $sKey );
+               }
+               if( !$oPrefix = Interwiki::fetch($sPrefix) ) {
+                       $oReturn->errors[] = array(
+                               'id' => 'iweditprefix',
+                               'message' => wfMessage( 
'bs-interwikilinks-nooldpfx' )->plain(),
+                       );
+                       return $oReturn;
+               }
+
+               $oReturn->success = (bool) $this->getDB()->delete(
+                       'interwiki',
+                       array( 'iw_prefix' => $sPrefix ),
+                       __METHOD__
+               );
+
+               if( $oReturn->success ) {
+                       $oReturn->message = wfMessage(
+                               'bs-interwikilinks-link-deleted'
+                       )->plain();
+               }
+
+               //Make sure to invalidate as much as possible!
+               $sKey = wfMemcKey( 'interwiki', $sPrefix );
+               wfGetMainCache()->delete( $sKey );
+               InterWikiLinks::purgeTitles( $sPrefix );
+
+               return $oReturn;
+       }
+}
\ No newline at end of file
diff --git a/InterWikiLinks/resources/BS.InterWikiLinks/InterWikiLinksDialog.js 
b/InterWikiLinks/resources/BS.InterWikiLinks/InterWikiLinksDialog.js
index 30ad41a..f4f6af3 100644
--- a/InterWikiLinks/resources/BS.InterWikiLinks/InterWikiLinksDialog.js
+++ b/InterWikiLinks/resources/BS.InterWikiLinks/InterWikiLinksDialog.js
@@ -21,14 +21,14 @@
                        fieldLabel: mw.message( 'bs-interwikilinks-labelprefix' 
).plain(),
                        labelWidth: 85,
                        labelAlign: 'right',
-                       name: 'iwl_prefix',
+                       name: 'iw_prefix',
                        allowBlank: false
                });
                this.tfIWLUrl = Ext.create( 'Ext.form.TextField', {
                        fieldLabel: mw.message( 'bs-interwikilinks-labelurl' 
).plain(),
                        labelWidth: 85,
                        labelAlign: 'right',
-                       name: 'iwl_url',
+                       name: 'iw_url',
                        allowBlank: false
                });
 
@@ -47,13 +47,13 @@
        },
        setData: function( obj ) {
                this.currentData = obj;
-               this.tfIWLPrefix.setValue( this.currentData.iwl_prefix );
-               this.tfIWLUrl.setValue( this.currentData.iwl_url );
+               this.tfIWLPrefix.setValue( this.currentData.iw_prefix );
+               this.tfIWLUrl.setValue( this.currentData.iw_url );
        },
        getData: function() {
-               this.selectedData.iwl_prefix = this.tfIWLPrefix.getValue();
-               this.selectedData.iwl_url = this.tfIWLUrl.getValue();
-               this.selectedData.iwl_prefix_old = this.currentData.iwl_prefix;
+               this.selectedData.iw_prefix = this.tfIWLPrefix.getValue();
+               this.selectedData.iw_url = this.tfIWLUrl.getValue();
+               this.selectedData.iw_prefix_old = this.currentData.iw_prefix;
 
                return this.selectedData;
        }
diff --git a/InterWikiLinks/resources/BS.InterWikiLinks/Panel.js 
b/InterWikiLinks/resources/BS.InterWikiLinks/Panel.js
index 9455f31..89170d4 100644
--- a/InterWikiLinks/resources/BS.InterWikiLinks/Panel.js
+++ b/InterWikiLinks/resources/BS.InterWikiLinks/Panel.js
@@ -15,37 +15,23 @@
 Ext.define( 'BS.InterWikiLinks.Panel', {
        extend: 'BS.CRUDGridPanel',
        initComponent: function() {
-               this.strMain = Ext.create( 'Ext.data.JsonStore', {
-                       proxy: {
-                               type: 'ajax',
-                               url: bs.util.getAjaxDispatcherUrl( 
'InterWikiLinks::getInterWikiLinks' ),
-                               reader: {
-                                       type: 'json',
-                                       root: 'iwlinks',
-                                       idProperty: 'iwl_prefix',
-                                       totalProperty: 'totalCount'
-                               }
-                       },
-                       autoLoad: true,
-                       fields: [ 'iwl_prefix', 'iwl_url' ],
-                       sortInfo: {
-                               field: 'id',
-                               direction: 'ASC'
-                       }
+               this.strMain = Ext.create( 'BS.store.BSApi', {
+                       apiAction: 'bs-interwiki-store',
+                       fields: [ 'iw_prefix', 'iw_url' ]
                });
 
                this.colIWLPrefix = Ext.create( 'Ext.grid.column.Column', {
-                       id: 'iwl_prefix',
+                       id: 'iw_prefix',
                        header: 
mw.message('bs-interwikilinks-headerprefix').plain(),
                        sortable: true,
-                       dataIndex: 'iwl_prefix',
+                       dataIndex: 'iw_prefix',
                        flex: 1
                } );
                this.colIWLUrl = Ext.create( 'Ext.grid.column.Column', {
-                       id: 'iwl_url',
+                       id: 'iw_url',
                        header: 
mw.message('bs-interwikilinks-headerurl').plain(),
                        sortable: true,
-                       dataIndex: 'iwl_url',
+                       dataIndex: 'iw_url',
                        flex: 1
                } );
 
@@ -62,7 +48,6 @@
                }
 
                this.active = 'add';
-               this.editmode = false;
                this.dlgIWLAdd.setTitle( mw.message( 
'bs-interwikilinks-titleaddinterwikilink' ).plain() );
                this.dlgIWLAdd.show();
                this.callParent( arguments );
@@ -75,7 +60,6 @@
 
                var selectedRow = 
this.grdMain.getSelectionModel().getSelection();
                this.active = 'edit';
-               this.editmode = true;
                this.dlgIWLEdit.setTitle( mw.message( 
'bs-interwikilinks-titleeditinterwikilink' ).plain() );
                this.dlgIWLEdit.setData( selectedRow[0].getData() );
                this.dlgIWLEdit.show();
@@ -97,15 +81,21 @@
        },
        onRemoveIWLOk: function() {
                var selectedRow = 
this.grdMain.getSelectionModel().getSelection();
-               var iwprefix = selectedRow[0].get( 'iwl_prefix' );
+               var iwprefix = selectedRow[0].get( 'iw_prefix' );
 
                Ext.Ajax.request( {
-                       url: bs.util.getAjaxDispatcherUrl(
-                               'InterWikiLinks::doDeleteInterWikiLink',
-                               [ iwprefix ]
-                       ),
+                       url: mw.util.wikiScript( 'api' ),
                        method: 'post',
                        scope: this,
+                       params: {
+                               action: 'bs-interwikilinks-tasks',
+                               task: 'removeInterWikiLink',
+                               format: 'json',
+                               token: mw.user.tokens.get( 'editToken', '' ),
+                               taskData: Ext.encode({
+                                       prefix: iwprefix
+                               })
+                       },
                        success: function( response, opts ) {
                                var responseObj = Ext.decode( 
response.responseText );
                                if ( responseObj.success === true ) {
@@ -118,16 +108,19 @@
        },
        onDlgIWLAddOk: function( data, iwl ) {
                Ext.Ajax.request( {
-                       url: bs.util.getAjaxDispatcherUrl(
-                               'InterWikiLinks::doEditInterWikiLink',
-                               [ 
-                                       this.editmode,
-                                       iwl.iwl_prefix,
-                                       iwl.iwl_url
-                               ]
-                       ),
+                       url: mw.util.wikiScript( 'api' ),
                        method: 'post',
                        scope: this,
+                       params: {
+                               action: 'bs-interwikilinks-tasks',
+                               task: 'editInterWikiLink',
+                               format: 'json',
+                               token: mw.user.tokens.get( 'editToken', '' ),
+                               taskData: Ext.encode({
+                                       prefix: iwl.iw_prefix,
+                                       url: iwl.iw_url
+                               })
+                       },
                        success: function( response, opts ) {
                                var responseObj = Ext.decode( 
response.responseText );
                                if ( responseObj.success === true ) {
@@ -142,17 +135,20 @@
        },
        onDlgIWLEditOk: function( data, iwl ) {
                Ext.Ajax.request( {
-                       url: bs.util.getAjaxDispatcherUrl(
-                               'InterWikiLinks::doEditInterWikiLink',
-                               [
-                                       this.editmode,
-                                       iwl.iwl_prefix,
-                                       iwl.iwl_url,
-                                       iwl.iwl_prefix_old
-                               ]
-                       ),
+                       url: mw.util.wikiScript( 'api' ),
                        method: 'post',
                        scope: this,
+                       params: {
+                               action: 'bs-interwikilinks-tasks',
+                               task: 'editInterWikiLink',
+                               format: 'json',
+                               token: mw.user.tokens.get( 'editToken', '' ),
+                               taskData: Ext.encode({
+                                       prefix: iwl.iw_prefix,
+                                       url: iwl.iw_url,
+                                       oldPrefix: iwl.iw_prefix_old
+                               })
+                       },
                        success: function( response, opts ) {
                                var responseObj = Ext.decode( 
response.responseText );
                                if ( responseObj.success === true ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/271790
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I40fe6652b726d1091965c040d6c4fab208b05190
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Pwirth <wi...@hallowelt.biz>
Gerrit-Reviewer: Dvogel hallowelt <daniel.vo...@hallowelt.com>
Gerrit-Reviewer: Ljonka <l.verhovs...@gmail.com>
Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz>
Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to