Mglaser has uploaded a new change for review.
https://gerrit.wikimedia.org/r/286759
Change subject: Dashboard: Added custom widget
......................................................................
Dashboard: Added custom widget
A custom widget can now be used. It displays any given wiki article
in the widget. This can be used to create customized widgets with
arbitrary content.
Change-Id: Idb926dc401625e1d1adb96c65765e44c95e79cc9
---
M Dashboards/Dashboards.class.php
M Dashboards/Dashboards.setup.php
M Dashboards/i18n/en.json
M Dashboards/i18n/qqq.json
A Dashboards/includes/api/BSApiDashboardWidgets.php
D Dashboards/resources/BS.Dashboards/ArticlePortlet.js
D Dashboards/resources/BS.Dashboards/ArticlePortletConfig.js
A Dashboards/resources/BS.Dashboards/CustomPortlet.js
A Dashboards/resources/BS.Dashboards/CustomPortletConfig.js
9 files changed, 157 insertions(+), 28 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions
refs/changes/59/286759/1
diff --git a/Dashboards/Dashboards.class.php b/Dashboards/Dashboards.class.php
index 06164ff..7546afd 100644
--- a/Dashboards/Dashboards.class.php
+++ b/Dashboards/Dashboards.class.php
@@ -211,6 +211,12 @@
'title' => wfMessage(
'bs-dashboard-userportlet-calendar-title' )->plain()
)
);
+ $aPortalConfig[0][] = array(
+ 'type' => 'BS.Dashboards.CustomPortlet',
+ 'config' => array(
+ 'title' => wfMessage(
'bs-dashboard-userportlet-custom-title' )->plain()
+ )
+ );
return true;
}
@@ -229,6 +235,14 @@
'title' => wfMessage(
'bs-dashboard-userportlet-calendar-title' )->plain(),
'description' => wfMessage(
'bs-dashboard-userportlet-calendar-description' )->plain()
);
+ $aPortlets[] = array(
+ 'type' => 'BS.Dashboards.CustomPortlet',
+ 'config' => array(
+ 'title' => wfMessage(
'bs-dashboard-userportlet-custom-title' )->plain(),
+ ),
+ 'title' => wfMessage(
'bs-dashboard-userportlet-custom-title' )->plain(),
+ 'description' => wfMessage(
'bs-dashboard-userportlet-custom-description' )->plain()
+ );
return true;
}
}
\ No newline at end of file
diff --git a/Dashboards/Dashboards.setup.php b/Dashboards/Dashboards.setup.php
index fea42bc..0be21ed 100644
--- a/Dashboards/Dashboards.setup.php
+++ b/Dashboards/Dashboards.setup.php
@@ -13,12 +13,14 @@
$wgAutoloadClasses['SpecialUserDashboard'] =
__DIR__.'/includes/specials/SpecialUserDashboard.php';
$GLOBALS['wgAutoloadClasses']['BSApiDashboardTasks'] = __DIR__ .
'/includes/api/BSApiDashboardTasks.php';
$GLOBALS['wgAutoloadClasses']['BSApiDashboardStore'] = __DIR__ .
'/includes/api/BSApiDashboardStore.php';
+$GLOBALS['wgAutoloadClasses']['BSApiDashboardWidgets'] = __DIR__ .
'/includes/api/BSApiDashboardWidgets.php';
$wgSpecialPages['AdminDashboard'] = 'SpecialAdminDashboard';
$wgSpecialPages['UserDashboard'] = 'SpecialUserDashboard';
$wgAPIModules['bs-dashboards-tasks'] = 'BSApiDashboardTasks';
$wgAPIModules['bs-dashboards-store'] = 'BSApiDashboardStore';
+$wgAPIModules['bs-dashboards-widgets'] = 'BSApiDashboardWidgets';
$wgHooks['LoadExtensionSchemaUpdates'][] = 'Dashboards::getSchemaUpdates';
$wgHooks['BSDashboardsUserDashboardPortalPortlets'][] =
'Dashboards::onBSDashboardsUserDashboardPortalPortlets';
@@ -50,7 +52,8 @@
'messages' => array(
'bs-dashboards-addportlet',
'bs-dashboards-portlets',
- 'bs-extjs-rssfeeder-rss-title'
+ 'bs-extjs-rssfeeder-rss-title',
+ 'bs-dashboard-userportlet-custom-wiki-article'
)
) + $aResourceModuleTemplate;
diff --git a/Dashboards/i18n/en.json b/Dashboards/i18n/en.json
index 36657d9..9a1adf9 100644
--- a/Dashboards/i18n/en.json
+++ b/Dashboards/i18n/en.json
@@ -13,5 +13,9 @@
"admindashboard": "Admin dashboard",
"userdashboard": "User dashboard",
"bs-dashboard-userportlet-calendar-title": "Calendar",
- "bs-dashboard-userportlet-calendar-description": "Calendar"
+ "bs-dashboard-userportlet-calendar-description": "Calendar",
+ "bs-dashboard-userportlet-custom-title": "Custom",
+ "bs-dashboard-userportlet-custom-description": "Use a wiki page to
define the widget",
+ "bs-dashboard-userportlet-custom-wiki-article": "Wiki article",
+ "apihelp-bs-dashboard-task-param-dc": "Cache control parameter. Used by
ExtJS."
}
diff --git a/Dashboards/i18n/qqq.json b/Dashboards/i18n/qqq.json
index a48e145..2ca731d 100644
--- a/Dashboards/i18n/qqq.json
+++ b/Dashboards/i18n/qqq.json
@@ -16,5 +16,9 @@
"admindashboard": "Special page name for admin dashboard.\n\n\"admin\"
is short for administrator.\n\nSee also:\n* {{msg-mw|Userdashboard}}",
"userdashboard": "Special page name for user dashboard.\n\nSee also:\n*
{{msg-mw|Admindashboard}}",
"bs-dashboard-userportlet-calendar-title": "Portlet title for
calendar\n{{Identical|Calendar}}",
- "bs-dashboard-userportlet-calendar-description": "portlet description
for calendar\n{{Identical|Calendar}}"
+ "bs-dashboard-userportlet-calendar-description": "Portlet description
for calendar\n{{Identical|Calendar}}",
+ "bs-dashboard-userportlet-custom-title": "Portlet title for custom
widget",
+ "bs-dashboard-userportlet-custom-description": "Portlet description for
custom widget",
+ "bs-dashboard-userportlet-custom-wiki-article": "Label for wiki article
parameter used in config dialog",
+ "apihelp-bs-dashboard-task-param-dc": "Label for cache control
parameter in api call"
}
diff --git a/Dashboards/includes/api/BSApiDashboardWidgets.php
b/Dashboards/includes/api/BSApiDashboardWidgets.php
new file mode 100644
index 0000000..c8c666e
--- /dev/null
+++ b/Dashboards/includes/api/BSApiDashboardWidgets.php
@@ -0,0 +1,60 @@
+<?php
+
+class BSApiDashboardWidgets extends BSApiTasksBase {
+
+ protected $aTasks = array(
+ 'custom'
+ );
+
+ protected function getRequiredTaskPermissions() {
+ return array(
+ 'custom' => array( 'read' )
+ );
+ }
+
+ public function task_custom( $oTaskData, $aParams ) {
+ $oResponse = $this->makeStandardReturn();
+
+ $oTitle = Title::newFromText( $oTaskData->wikiArticle );
+ if ( !$oTitle->userCan( 'read' ) ) {
+ $oResponse->success = false;
+ $oResponse->payload = array( "html" => wfMessage(
'bs-permissionerror' )->plain() );
+ return $oResponse;
+ }
+ $oWikiPage = WikiPage::factory( $oTitle );
+
+ $sHTML = $oWikiPage->getContent()->getParserOutput( $oTitle
)->getText();
+
+ $oResponse->success = true;
+ $oResponse->payload = array( "html" => $sHTML );
+ return $oResponse;
+ }
+
+ public function needsToken() {
+ return false;
+ }
+ /**
+ * Returns an array of allowed parameters
+ * @return array
+ */
+ protected function getAllowedParams() {
+ $paramList = parent::getAllowedParams();
+
+ return array_merge(
+ $paramList,
+ array(
+ '_dc' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => false,
+ //TODO: Description
+ 10 /*ApiBase::PARAM_HELP_MSG*/ =>
'apihelp-bs-dashboard-task-param-dc',
+ ),
+ 'token' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => false,
+ 10 /*ApiBase::PARAM_HELP_MSG*/ =>
'apihelp-bs-task-param-token',
+ )
+ )
+ );
+ }
+}
\ No newline at end of file
diff --git a/Dashboards/resources/BS.Dashboards/ArticlePortlet.js
b/Dashboards/resources/BS.Dashboards/ArticlePortlet.js
deleted file mode 100644
index 82a1cea..0000000
--- a/Dashboards/resources/BS.Dashboards/ArticlePortlet.js
+++ /dev/null
@@ -1,11 +0,0 @@
-Ext.define('BS.Dashboards.ArticlePortlet', {
- extend: 'BS.portal.Portlet',
- height: 300,
-
- portletConfigClass : 'BS.Dashboards.ArticlePortletConfig',
-
- initComponent: function() {
- this.contentUrl = bs.util.getAjaxDispatcherUrl(
'Dashboards::getArticlePortlet', [ this.portletArticle ] );
- this.callParent(arguments);
- },
-});
diff --git a/Dashboards/resources/BS.Dashboards/ArticlePortletConfig.js
b/Dashboards/resources/BS.Dashboards/ArticlePortletConfig.js
deleted file mode 100644
index 2814596..0000000
--- a/Dashboards/resources/BS.Dashboards/ArticlePortletConfig.js
+++ /dev/null
@@ -1,14 +0,0 @@
-Ext.define('BS.Dashboards.ArticlePortletConfig', {
- extend: 'BS.portal.PortletConfig',
-
- afterInitComponent: function() {
- this.callParent( arguments );
- },
- setConfigControlValues: function( cfg ) {
- this.callParent( arguments );
- },
- getConfigControlValues: function() {
- var cfg = this.callParent( arguments );
- return cfg;
- }
-});
\ No newline at end of file
diff --git a/Dashboards/resources/BS.Dashboards/CustomPortlet.js
b/Dashboards/resources/BS.Dashboards/CustomPortlet.js
new file mode 100644
index 0000000..f34da0c
--- /dev/null
+++ b/Dashboards/resources/BS.Dashboards/CustomPortlet.js
@@ -0,0 +1,48 @@
+Ext.define('BS.Dashboards.CustomPortlet', {
+ extend: 'BS.portal.Portlet',
+ height: 300,
+
+ portletConfigClass : 'BS.Dashboards.CustomPortletConfig',
+
+ initComponent: function() {
+ //this.portletArticle
+ this.cContent = Ext.create('Ext.Component', {
+ loader: {
+ url: '',
+ target: this.cContent,
+ renderer: function( loader, response, active ) {
+ var responseObj = Ext.JSON.decode(
response.responseText );
+ loader.getTarget().update(
responseObj.payload.html );
+ return true;
+ }
+ },
+ autoScroll: true
+ });
+
+ this.cContent.getLoader().load({
+ url: bs.api.makeUrl(
+ 'bs-dashboards-widgets',
+ {
+ "task": "custom",
+ "taskData":Ext.JSON.encode(
{"wikiArticle": this.wikiArticle} )
+ }
+ )
+ });
+
+ this.items = [
+ this.cContent
+ ];
+
+ this.callParent( arguments );
+ },
+
+ getPortletConfig: function() {
+ var cfg = this.callParent( arguments );
+ cfg.wikiArticle = this.wikiArticle;
+ return cfg;
+ },
+ setPortletConfig: function( oConfig ) {
+ this.wikiArticle = oConfig.wikiArticle;
+ this.callParent( arguments );
+ }
+});
diff --git a/Dashboards/resources/BS.Dashboards/CustomPortletConfig.js
b/Dashboards/resources/BS.Dashboards/CustomPortletConfig.js
new file mode 100644
index 0000000..177110e
--- /dev/null
+++ b/Dashboards/resources/BS.Dashboards/CustomPortletConfig.js
@@ -0,0 +1,21 @@
+Ext.define('BS.Dashboards.CustomPortletConfig', {
+ extend: 'BS.portal.PortletConfig',
+
+ afterInitComponent: function() {
+ this.tfArticle = Ext.create( 'Ext.form.TextField',{
+ fieldLabel: mw.message(
'bs-dashboard-userportlet-custom-wiki-article' ).plain(),
+ labelAlign: 'right'
+ });
+ this.items.push( this.tfArticle );
+ this.callParent( arguments );
+ },
+ setConfigControlValues: function( cfg ) {
+ this.tfArticle.setValue( cfg.wikiArticle );
+ this.callParent( arguments );
+ },
+ getConfigControlValues: function() {
+ var cfg = this.callParent( arguments );
+ cfg.wikiArticle = this.tfArticle.getValue();
+ return cfg;
+ }
+});
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/286759
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb926dc401625e1d1adb96c65765e44c95e79cc9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Mglaser <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits