Robert Vogel has uploaded a new change for review. https://gerrit.wikimedia.org/r/277471
Change subject: Compat. REL1_27: Custom JSON format ...................................................................... Compat. REL1_27: Custom JSON format This change makes JSON output emitted by REL1_27 (actually REL1_25+) compatible with BlueSpice Needs to be properly tested against REL1_23 Change-Id: Iad3d8f3cfc8088b3d194d40b1e78b55d584474a0 --- M includes/AutoLoader.php M includes/api/BSApiBase.php A includes/api/BSApiFormatJson.php 3 files changed, 92 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation refs/changes/71/277471/1 diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index ff0c1b6..f852a58 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -58,6 +58,7 @@ //api $GLOBALS['wgAutoloadClasses']['BSStandardAPIResponse'] = __DIR__."/api/BSStandardAPIResponse.php"; $GLOBALS['wgAutoloadClasses']['BSExtendedApiContext'] = __DIR__."/api/BSExtendedApiContext.php"; +$GLOBALS['wgAutoloadClasses']['BSApiFormatJson'] = __DIR__."/api/BSApiFormatJson.php"; $GLOBALS['wgAutoloadClasses']['BSApiBase'] = __DIR__."/api/BSApiBase.php"; $GLOBALS['wgAutoloadClasses']['BSApiTasksBase'] = __DIR__."/api/BSApiTasksBase.php"; $GLOBALS['wgAutoloadClasses']['BSApiExtJSStoreBase'] = __DIR__."/api/BSApiExtJSStoreBase.php"; diff --git a/includes/api/BSApiBase.php b/includes/api/BSApiBase.php index 3646340..58ec19c 100644 --- a/includes/api/BSApiBase.php +++ b/includes/api/BSApiBase.php @@ -1,5 +1,36 @@ <?php +/** + * Provides the base 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 Robert Vogel <[email protected]> + * @author Patric Wirth <[email protected]> + * @package Bluespice_Foundation + * @copyright Copyright (C) 2016 Hallo Welt! - Medienwerkstatt GmbH, All rights reserved. + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or later + * @filesource + */ +/** + * Api base class in BlueSpice + * @package BlueSpice_Foundation + */ abstract class BSApiBase extends ApiBase { /** * Checks access permissions based on a list of titles and permissions. If @@ -47,4 +78,12 @@ 'api.php?action='.$this->getModuleName(), ); } + + /** + * Custom output printer for JSON. See class BSApiFormatJson for details + * @return BSApiFormatJson + */ + public function getCustomPrinter() { + return new BSApiFormatJson( $this->getMain(), $this->getParameter( 'format' ) ); + } } \ No newline at end of file diff --git a/includes/api/BSApiFormatJson.php b/includes/api/BSApiFormatJson.php new file mode 100644 index 0000000..9856578 --- /dev/null +++ b/includes/api/BSApiFormatJson.php @@ -0,0 +1,52 @@ +<?php +/** + * Provides the api json format 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 Robert Vogel <[email protected]> + * @package Bluespice_Foundation + * @copyright Copyright (C) 2016 Hallo Welt! - Medienwerkstatt GmbH, All rights reserved. + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or later + * @filesource + */ + +/** + * Api json formal class in BlueSpice + * @package BlueSpice_Foundation + */ +class BSApiFormatJson extends ApiFormatJson { + public function getAllowedParams() { + $aParams = parent::getAllowedParams(); + if( isset( $aParams['formatversion'] ) ) { + + /* + * This is needed for most ExtJS frontent components. + * New MediaWiki versions normalize JSON output in a way that + * fields with boolean true are converted to fields with empty + * string value and fields with boolean false just get removed from + * the JSON string. This breaks some ExtJS logic (mainly store + * implementations) + * Changing the 'formatversion' to 2, disables this behavior + */ + $aParams['formatversion'][ApiBase::PARAM_DFLT] = 2; + } + + return $aParams; + } +} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/277471 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iad3d8f3cfc8088b3d194d40b1e78b55d584474a0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation Gerrit-Branch: master Gerrit-Owner: Robert Vogel <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
