jenkins-bot has submitted this change and it was merged.
Change subject: Clean up old unused code
......................................................................
Clean up old unused code
There is a lot of legacy code that is not used by any extension. It can be
removed.
Change-Id: Ia8de635e861c27aed8b231b2c64d14afdf439f25
---
M BlueSpiceFoundation.php
M extension.json
D includes/CAContext.php
D includes/CAResponse.php
D includes/CommonAJAXInterface.php
D includes/XHRBaseResponse.class.php
6 files changed, 1 insertion(+), 336 deletions(-)
Approvals:
Pwirth: Looks good to me, approved
jenkins-bot: Verified
diff --git a/BlueSpiceFoundation.php b/BlueSpiceFoundation.php
index ff7c47e..27b4870 100644
--- a/BlueSpiceFoundation.php
+++ b/BlueSpiceFoundation.php
@@ -54,10 +54,4 @@
array_unshift(
$wgExtensionFunctions,
'BsCore::doInitialise'
-);
-
-//make old ajax functions available, remove this after replacement implemented
-$wgAjaxExportList[] = 'BsCommonAJAXInterface::getTitleStoreData';
-$wgAjaxExportList[] = 'BsCommonAJAXInterface::getNamespaceStoreData';
-$wgAjaxExportList[] = 'BsCommonAJAXInterface::getUserStoreData';
-$wgAjaxExportList[] = 'BsCommonAJAXInterface::getFileUrl';
+);
\ No newline at end of file
diff --git a/extension.json b/extension.json
index 4cfc8e0..524094e 100644
--- a/extension.json
+++ b/extension.json
@@ -419,15 +419,6 @@
"BSNamespaceParser": "includes/parser/BSNamespaceParser.php",
"BSNamespaceValidator": "includes/validator/BSNamespaceValidator.php",
"BsMailer": "includes/Mailer.class.php",
- "BsXHRBaseResponse": "includes/XHRBaseResponse.class.php",
- "BsXHRJSONResponse": "includes/XHRBaseResponse.class.php",
- "BsXHRResponseStatus": "includes/XHRBaseResponse.class.php",
- "BsCommonAJAXInterface": "includes/CommonAJAXInterface.php",
- "BsCAI": "includes/CommonAJAXInterface.php",
- "BsCAContext": "includes/CAContext.php",
- "BsCAIContext": "includes/CAContext.php",
- "BsCAResponse": "includes/CAResponse.php",
- "BsCAIResponse": "includes/CAResponse.php",
"BsExtJSStoreParams": "includes/ExtJSStoreParams.php",
"BsExtJSSortParam": "includes/ExtJSStoreParams.php",
"BSNotifications": "includes/Notifications.class.php",
diff --git a/includes/CAContext.php b/includes/CAContext.php
deleted file mode 100644
index 8bd3dc7..0000000
--- a/includes/CAContext.php
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-
-class BsCAIContext {
-
- /**
- *
- * @var Title
- */
- protected $oTitle = null;
-
- /**
- *
- * @var Revision
- */
- protected $oRevision = null;
-
- /**
- *
- * @var SpecialPage
- */
- protected $oSpecialPage = null;
-
- /**
- *
- * @var Title
- */
- protected $oRelevantPage = null;
-
- /**
- *
- * @return BsCAContext
- */
- public static function newFromRequest(){
- $oRequest = RequestContext::getMain()->getRequest();
-
- //TODO: Lazy init?
- $aRequestParams = array(
- 'wgAction' =>
$oRequest->getVal('wgAction'),
- 'wgArticleId' =>
$oRequest->getVal('wgArticleId'),
- 'wgCanonicalNamespace' =>
$oRequest->getVal('wgCanonicalNamespace'),
- 'wgCanonicalSpecialPageName' =>
$oRequest->getVal('wgCanonicalSpecialPageName'),
- 'wgCurRevisionId' =>
$oRequest->getVal('wgCurRevisionId'),
- //'wgIsArticle' => $oRequest->getVal('wgisArticle'),
- 'wgNamespaceNumber' =>
$oRequest->getVal('wgNamespaceNumber'),
- 'wgPageName' => $oRequest->getVal('wgPageName'),
- 'wgRedirectedFrom' =>
$oRequest->getVal('wgRedirectedFrom'),
- 'wgRelevantPageName' =>
$oRequest->getVal('wgRelevantPageName'),
- 'wgTitle' => $oRequest->getVal('wgTitle')
- );
-
- $aParams = array(
- 'title' =>
Title::newFromID($aRequestParams['wgArticleId']),
- 'revision' =>
Revision::newFromId($aRequestParams['wgCurRevisionId']),
- 'specialpage' =>
SpecialPageFactory::getPage($aRequestParams['wgCanonicalSpecialPageName']),
- 'relevantpage' =>
Title::newFromText($aRequestParams['wgRelevantPageName']),
- );
-
- return new self( $aParams );
- }
-
- private function __construct( $aParams ) {
- $this->oTitle = $aParams['title'];
- $this->oRevision = $aParams['revision'];
- $this->oSpecialPage = $aParams['specialpage'];
- $this->oRelevantPage = $aParams['relevantpage'];
- }
-
- /**
- *
- * @return Title
- */
- public function getTitle() {
- return $this->oTitle;
- }
-
- /**
- *
- * @return boolean
- */
- public function isSpecialPage() {
- return $this->oTitle->isSpecialPage();
- }
-
- /**
- *
- * @return Revision
- */
- public function getRevision() {
- return $this->oRevision;
- }
-
- /**
- *
- * @return SpecialPage
- */
- public function getSpecialPage(){
- return $this->oSpecialPage;
- }
-}
-
-class BsCAContext extends BsCAIContext {}
\ No newline at end of file
diff --git a/includes/CAResponse.php b/includes/CAResponse.php
deleted file mode 100644
index c91c9a9..0000000
--- a/includes/CAResponse.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-class BsCAIResponse extends AjaxResponse {
-
- protected $mPayload = null;
- protected $bSuccess = true;
- protected $sMessage = '';
-
- /**
- *
- * @param string $sPermission
- * @param BsCAContext $oCAContext
- * @return BsCAResponse
- */
- public static function newFromPermission( $sPermission, $oCAContext =
null ) {
- $bUserCan = true;
- if( $oCAContext instanceof BsCAContext ) {
- $bUserCan = $oCAContext->getTitle()->userCan(
$sPermission );
- }
- else {
- $bUserCan =
RequestContext::getMain()->getTitle()->userCan( $sPermission );
- }
-
- $bSuccess = true;
- $sMessage = '';
-
- if( $bUserCan == false ) {
- $bSuccess = false;
- $sMessage = 'permissionserrors';
- }
-
- $oResponse = new self();
- $oResponse->setSuccess( $bSuccess );
- $oResponse->setMessage( $sMessage );
-
- return $oResponse;
- }
-
- public function __construct( $bSuccess = true, $mPayload = '',
$sMessage = '' ) {
- parent::__construct( null );
-
- //HINT: http://www.ietf.org/rfc/rfc4627.txt
- $this->mContentType = 'application/json';
-
- $this->bSuccess = $bSuccess;
- $this->mPayload = $mPayload;
- $this->sMessage = $sMessage;
- }
-
- public function setPayload( $mPayload ) {
- $this->mPayload = $mPayload;
- }
-
- public function setSuccess( $bSuccess ) {
- if( $bSuccess ) {
- $this->setResponseCode( '200 OK' );
- }
- else {
- $this->setResponseCode( '403 Forbidden' );
- }
- $this->bSuccess = $bSuccess;
- }
-
- public function isSuccess() {
- return $this->bSuccess;
- }
-
- public function setMessage( $sKeyOrMessage, $bNoKey = false ) {
- if( $bNoKey || empty($bNoKey) ) {
- $this->sMessage = $sKeyOrMessage;
- }
- else {
- $this->sMessage = wfMessage( $sKeyOrMessage )->plain();
- }
- }
-
- public function printText() {
- $this->addText( FormatJson::encode(
- array(
- 'success' => $this->bSuccess,
- 'message' => $this->sMessage,
- 'payload' => $this->mPayload,
- )
- )
- );
- parent::printText();
- }
-}
-
-class BsCAResponse extends BsCAIResponse {}
\ No newline at end of file
diff --git a/includes/CommonAJAXInterface.php b/includes/CommonAJAXInterface.php
deleted file mode 100644
index 15bbfeb..0000000
--- a/includes/CommonAJAXInterface.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-
-class BsCommonAJAXInterface {
-
-
//index.php?action=ajax&rs=BSCommonAJAXInterface::getNamespaceStoreData&rsargs[]={}
- public static function getNamespaceStoreData( $sOptions = '{}' ) {
- //TODO: Reflect $options ans
WebRequest::getVal('start|limit|...')
- //$aOptions = FormatJson::decode( $sOptions, true );
-
- $aNamespaces =
BsNamespaceHelper::getNamespacesForSelectOptions();
- $oResult = new stdClass();
- $oResult->namespaces = array();
-
- foreach ( $aNamespaces as $iNSid => $sNSName ){
- $oNamespace = new stdClass();
- $oNamespace->namespaceId = $iNSid;
- $oNamespace->namespaceName = $sNSName;
- $oNamespace->isNonincludable =
MWNamespace::isNonincludable( $iNSid );
- $oNamespace->namespaceContentModel =
MWNamespace::getNamespaceContentModel( $iNSid );
-
- $oResult->namespaces[] = $oNamespace;
- }
-
- return FormatJson::encode($oResult);
- }
-
- public static function getUserStoreData( $sOptions = '{}' ) {
- $aDefaultOptions = array(
- 'group' => '', //TODO: make array? How to operate them?
AND / OR
- 'permission' => '', //TODO: see above
- );
-
- //$aOptions = FormatJson::decode($sOptions, true);
- //TODO: recursive merge with $aDefaultOptions
-
- $oResult = new stdClass();
- $oResult->users = array();
-
- $dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select(
- 'user',
- 'user_id'
- );
-
- foreach( $res as $row ) {
- $oUser = User::newFromId( $row->user_id );
- $oUserData = new stdClass();
-
- //DB fields
- //PW: user_id needs to be casted to int or ExtJs can
not search the store by id property!
- $oUserData->user_id = (int) $oUser->getId();
- $oUserData->user_name = $oUser->getName();
-
- //Calculated fields
- $oUserData->display_name = BsCore::getUserDisplayName(
$oUser );
- $oUserData->page_prefixed_text =
$oUser->getUserPage()->getPrefixedText();
-
- $oResult->users[] = $oUserData;
- }
-
- return FormatJson::encode( $oResult );
- }
-
- /**
- * Calculate the real file path of an image to show an preview.
- * @deprecated Use MW API with query prop "imageinfo" and iiprop "url"
- * http://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii
- * @param type $output The ajax output which have to be valid JSON.
- */
- public static function getFileUrl( $file ) {
- $url = self::imageUrl( $file );
- //TODO: This is not good. We should use API and SecureFileStore
should
- //alter API response via Hook
- if ( BsExtensionManager::isContextActive(
'MW::SecureFileStore::Active' ) ) {
- $url = SecureFileStore::secureStuff( $url, true );
- }
- return FormatJson::encode(
- array(
- 'file' => $file,
- 'url' => $url
- )
- );
- }
-
- /**
- * Helper method for self::getFileRealLink
- * @deprecated Use MW API with query prop "imageinfo" and iiprop "url"
- * http://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii
- * @param string $name
- * @param boolean $fromSharedDirectory
- * @return string The url of the file with name $name
- */
- protected static function imageUrl( $name, $fromSharedDirectory = false
) {
- $image = null;
- if ( $fromSharedDirectory ) {
- $image = wfFindFile( $name );
- }
- if ( !$image ) {
- $image = wfLocalFile( $name );
- }
- if ( !$image ) {
- return $image;
- }
- return $image->getUrl();
- }
-}
-
-//Alias
-class BsCAI extends BsCommonAJAXInterface {}
\ No newline at end of file
diff --git a/includes/XHRBaseResponse.class.php
b/includes/XHRBaseResponse.class.php
deleted file mode 100644
index af042cd..0000000
--- a/includes/XHRBaseResponse.class.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-// TODO RBV (08.04.11 10:24): So umbauen, dass es dem ExtJS Standard
entspricht! { success: true/false }
-abstract class BsXHRBaseResponse {
- public $status = BsXHRResponseStatus::SUCCESS;
- public $shortMessage = '';
- public $longMessage = '';
-
- public abstract function __toString();
-}
-
-class BsXHRJSONResponse extends BsXHRBaseResponse {
- public function __toString() {
- return json_encode( $this );
- }
-}
-
-class BsXHRResponseStatus {
- const SUCCESS = 'success';
- const ERROR = 'error';
-}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/322650
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia8de635e861c27aed8b231b2c64d14afdf439f25
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: Dvogel hallowelt <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits