jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/362424 )
Change subject: BSPageAccess: Used store api and extJS grid instead of simple table for specialpage ...................................................................... BSPageAccess: Used store api and extJS grid instead of simple table for specialpage => #6655 Change-Id: I2952828107b1d9e9e2d819f90835926dce1060d7 --- M PageAccess/extension.json M PageAccess/i18n/en.json M PageAccess/i18n/qqq.json A PageAccess/includes/api/BSApiPageAccessStore.php M PageAccess/includes/specials/SpecialPageAccess.class.php A PageAccess/resources/BS.PageAccess/panel/Manager.js A PageAccess/resources/ext.bluespice.pageaccess.manager.js 7 files changed, 212 insertions(+), 18 deletions(-) Approvals: Mglaser: Looks good to me, approved jenkins-bot: Verified diff --git a/PageAccess/extension.json b/PageAccess/extension.json index 1d548e9..8f33546 100644 --- a/PageAccess/extension.json +++ b/PageAccess/extension.json @@ -15,6 +15,9 @@ "SpecialPages": { "PageAccess": "SpecialPageAccess" }, + "APIModules": { + "bs-pageaccess-store": "BSApiPageAccessStore" + }, "LogTypes": [ "bs-pageaccess" ], @@ -34,7 +37,27 @@ }, "AutoloadClasses": { "PageAccess": "PageAccess.class.php", - "SpecialPageAccess": "includes/specials/SpecialPageAccess.class.php" + "SpecialPageAccess": "includes/specials/SpecialPageAccess.class.php", + "BSApiPageAccessStore": "includes/api/BSApiPageAccessStore.php" + }, + "ResourceModules": { + "ext.PageAccess.manager": { + "scripts": [ + "ext.bluespice.pageaccess.manager.js" + ], + "styles": [], + "messages": [ + "bs-pageaccess-column-title", + "bs-pageaccess-column-groups" + ], + "dependencies": [ + "ext.bluespice.extjs" + ] + } + }, + "ResourceFileModulePaths": { + "localBasePath": "resources", + "remoteExtPath": "BlueSpiceExtensions/PageAccess/resources" }, "manifest_version": 1 } diff --git a/PageAccess/i18n/en.json b/PageAccess/i18n/en.json index 054813d..8ba7665 100644 --- a/PageAccess/i18n/en.json +++ b/PageAccess/i18n/en.json @@ -15,5 +15,7 @@ "log-description-bs-pageaccess": "This is a log of changes in the page access settings.", "log-show-hide-bs-pageaccess": "$1 page access log", "logentry-bs-pageaccess-change": "$1 {{GENDER:$2|has changed}} the access permissions of $3 to \"$4\"", - "action-pageaccess-viewspecialpage":"view the special page \"{{int:pageaccess}}\"" + "action-pageaccess-viewspecialpage":"view the special page \"{{int:pageaccess}}\"", + "bs-pageaccess-column-title": "Page title", + "bs-pageaccess-column-groups": "Groups" } diff --git a/PageAccess/i18n/qqq.json b/PageAccess/i18n/qqq.json index 8d58c86..319e53c 100644 --- a/PageAccess/i18n/qqq.json +++ b/PageAccess/i18n/qqq.json @@ -18,5 +18,7 @@ "log-description-bs-pageaccess": "Used in [[Special:Log]], description of the log type", "log-show-hide-bs-pageaccess": "Used in [[Special:Log]]. Parameters:\n* $1 - link text; one of {{msg-mw|Show}} or {{msg-mw|Hide}}\n{{Related|Log-show-hide}}", "logentry-bs-pageaccess-change": "Log message about changes on the access settings for a page.\nParameters:\n* $4 - comma separated list of the allowed groups", - "action-pageaccess-viewspecialpage": "placeholder to describe that view of special page \"{{int:pageaccess}}\" is restricted for the current user.\n\n{{Doc-action|pageaccess-viewspecialpage}}" + "action-pageaccess-viewspecialpage": "placeholder to describe that view of special page \"{{int:pageaccess}}\" is restricted for the current user.\n\n{{Doc-action|pageaccess-viewspecialpage}}", + "bs-pageaccess-column-title": "Extjs grid calumn label for Pagetitle\n{{Identical|Page title}}", + "bs-pageaccess-column-groups": "Extjs grid calumn label for Groups\n{{Identical|Groups}}" } diff --git a/PageAccess/includes/api/BSApiPageAccessStore.php b/PageAccess/includes/api/BSApiPageAccessStore.php new file mode 100644 index 0000000..5c331dc --- /dev/null +++ b/PageAccess/includes/api/BSApiPageAccessStore.php @@ -0,0 +1,85 @@ +<?php + +class BSApiPageAccessStore extends BSApiExtJSStoreBase { + + /** + * @global array $wgAdditionalGroups + * @param string $sQuery + * @return array + */ + protected function makeData( $sQuery = '' ) { + global $wgAdditionalGroups; + $aData = array(); + + $oDBr = $this->getDB( DB_SLAVE ); + $oRes = $oDBr->select( + [ 'page_props' ], + [ 'pp_page', 'pp_value' ], + [ 'pp_propname' => 'bs-page-access' ], + __METHOD__ + ); + + foreach( $oRes as $oRow ) { + $aGroups = []; + foreach( explode( ',',$oRow->pp_value ) as $sGroup ) { + $aGroups[] = [ + 'group_name' => $sGroup, + 'additional_group' => isset( $wgAdditionalGroups[$sGroup] ), + 'displayname' => wfMessage( "group-$sGroup" )->exists() + ? wfMessage( "group-$sGroup" ) + : $sGroup + , + ]; + } + + if( !$oTitle = Title::newFromID( $oRow->pp_page ) ) { + continue; + } + $aData[] = (object) [ + 'page_id' => (int) $oTitle->getArticleID(), + 'page_namespace' => (int) $oTitle->getNamespace(), + 'page_title' => $oTitle->getText(), + 'prefixedText' => $oTitle->getPrefixedText(), + 'groups' => $aGroups, + ]; + } + + return $aData; + } + + /** + * Performs string filtering the array of groups on the group_name and the + * displayname + * @param stdClass $oFilter + * @param stdClass $aDataSet + * @return boolean true if filter applies, false if not + */ + public function filterString( $oFilter, $aDataSet ) { + if( $oFilter->field !== 'groups') { + return parent::filterString( $oFilter, $aDataSet ); + } + + foreach( $aDataSet->groups as $iKey => $aGroup ) { + $bRes = BsStringHelper::filter( + $oFilter->comparison, + $aGroup['group_name'], + $oFilter->value + ); + if( $bRes ) { + return true; + } + + $bRes = BsStringHelper::filter( + $oFilter->comparison, + $aGroup['displayname'], + $oFilter->value + ); + if( $bRes ) { + return true; + } + } + + return false; + } + +} \ No newline at end of file diff --git a/PageAccess/includes/specials/SpecialPageAccess.class.php b/PageAccess/includes/specials/SpecialPageAccess.class.php index 82588ed..b373f7c 100644 --- a/PageAccess/includes/specials/SpecialPageAccess.class.php +++ b/PageAccess/includes/specials/SpecialPageAccess.class.php @@ -23,21 +23,10 @@ parent::execute( $par ); $oOutputPage = $this->getOutput(); - $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( - array( 'page_props' ), - array( 'pp_page', 'pp_value' ), - array( 'pp_propname' => 'bs-page-access' ) - ); - - #TODO: Beautify output! Ext grid? - while( $row = $dbr->fetchObject( $res ) ) { - $iPageID = $row->pp_page; - $oTitle = Title::newFromID( $iPageID ); - $oOutputPage->addHtml( Linker::link( $oTitle, null, array(), array(), array( 'known' ) ) ); - $oOutputPage->addHtml( " (" . $row->pp_value . ")" ); - $oOutputPage->addHtml( "<br/>" ); - } + $oOutputPage->addModules( 'ext.PageAccess.manager' ); + $oOutputPage->addHTML( Html::element( 'div', [ + 'id' => 'bs-pageaccess-manager' + ])); } protected function getGroupName() { diff --git a/PageAccess/resources/BS.PageAccess/panel/Manager.js b/PageAccess/resources/BS.PageAccess/panel/Manager.js new file mode 100644 index 0000000..c2c041a --- /dev/null +++ b/PageAccess/resources/BS.PageAccess/panel/Manager.js @@ -0,0 +1,75 @@ +Ext.define( 'BS.PageAccess.panel.Manager', { + extend: 'BS.CRUDGridPanel', + requires: [ 'BS.store.BSApi' ], + + initComponent: function() { + + this._gridCols = [ + { + text: mw.message( 'bs-pageaccess-column-title' ).plain(), + dataIndex: 'prefixedText', + sortable: true, + filterable:true, + renderer: this.renderPage, + flex: 1 + }, + { + text: mw.message( 'bs-pageaccess-column-groups' ).plain(), + dataIndex: 'groups', + sortable: true, + filterable:true, + renderer: this.renderGroups, + flex: 1 + } + ]; + + this._storeFields = [ + 'page_id', + 'page_title', + 'page_namespace', + 'prefixedText', + 'groups' + ]; + + this.callParent( arguments ); + }, + + makeGridColumns: function(){ + this.colMainConf.columns = this._gridCols; + return this.colMainConf.columns; + return this.callParent( arguments ); + }, + + makeRowActions: function() { + return []; + }, + + makeMainStore: function() { + this.strMain = new BS.store.BSApi({ + apiAction: 'bs-pageaccess-store', + fields: this._storeFields + }); + return this.callParent( arguments ); + }, + + makeTbarItems: function() { + return []; + }, + + renderGroups: function( val ) { + var res = ''; + for( var i = 0; i < val.length; i++ ) { + if( i > 0 ) { + res += ", "; + } + res += val[i].displayname; + } + return res; + }, + + renderPage: function( val ) { + return '<a href="' + mw.util.getUrl( val ) + '" title="' + val + '">' + + val + + "</a>"; + } +}); \ No newline at end of file diff --git a/PageAccess/resources/ext.bluespice.pageaccess.manager.js b/PageAccess/resources/ext.bluespice.pageaccess.manager.js new file mode 100644 index 0000000..c872bb5 --- /dev/null +++ b/PageAccess/resources/ext.bluespice.pageaccess.manager.js @@ -0,0 +1,18 @@ +( function( mw, $, bs, d, undefined ){ + function _renderGrid() { + Ext.onReady(function(){ + Ext.create( 'BS.PageAccess.panel.Manager', { + renderTo: 'bs-pageaccess-manager' + }); + }); + } + + var deps = mw.config.get( 'bsPageAccessManagerDeps', false ); + if( deps ) { + mw.loader.using( deps, _renderGrid ); + } + else { + _renderGrid(); + } + +})( mediaWiki, jQuery, blueSpice, document ); \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/362424 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2952828107b1d9e9e2d819f90835926dce1060d7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions Gerrit-Branch: REL1_27 Gerrit-Owner: Mglaser <gla...@hallowelt.biz> Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz> Gerrit-Reviewer: Pwirth <wi...@hallowelt.biz> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits