Smuggli has uploaded a new change for review.
https://gerrit.wikimedia.org/r/166739
Change subject: Fixed some issues in preferences
......................................................................
Fixed some issues in preferences
* Multiselect and sortable fields did not work
* Added styling for sort fields
* Added own module for multiselect
* Unified some file names
* Some small cleanups
Change-Id: I52d2cf8a5c44d674e566dd1476ff599a6bf497b8
---
M includes/Config.class.php
M includes/Core.class.php
M includes/html/htmlformfields/HTMLMultiSelectEx.php
M includes/html/htmlformfields/HTMLMultiSelectPlusAdd.php
M includes/html/htmlformfields/HTMLMultiSelectSortList.php
M resources/Resources.php
A resources/bluespice/bluespice.html.formfields.multiselect.js
A resources/bluespice/bluespice.html.formfields.sortable.css
R resources/bluespice/bluespice.html.formfields.sortable.js
D resources/bluespice/bluespice.multiselect.js
M resources/bluespice/bluespice.util.js
11 files changed, 74 insertions(+), 55 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation
refs/changes/39/166739/1
diff --git a/includes/Config.class.php b/includes/Config.class.php
index fe14a36..d5916d7 100644
--- a/includes/Config.class.php
+++ b/includes/Config.class.php
@@ -243,9 +243,6 @@
return self::$prSettings[$key];
}
$_path = explode ( '::', $path );
- $adapter = null;
- $extension = null;
- $varname = null;
$len = count ( $_path );
if ( $len < 2 || $len > 3 ) {
@@ -253,9 +250,10 @@
return false;
}
+ $extension = null;
$adapter = array_shift ( $_path );
$len--;
- if ( $len == 2 ) {
+ if ( $len === 2 ) {
$extension = array_shift ( $_path );
}
$varname = array_shift ( $_path );
@@ -306,7 +304,7 @@
public static function saveSettings() {
$dbw = wfGetDB ( DB_WRITE );
- $dbw->delete('bs_settings', '*');
+ $dbw->delete( 'bs_settings', '*' );
$aSettings = array();
diff --git a/includes/Core.class.php b/includes/Core.class.php
index 6c19159..1c46950 100644
--- a/includes/Core.class.php
+++ b/includes/Core.class.php
@@ -114,8 +114,10 @@
global $wgScriptPath;
$sPath = $wgScriptPath .
"/extensions/BlueSpiceFoundation/resources/bluespice/images/";
- BsConfig::registerVar( 'MW::FileExtensions', array('doc',
'docx', 'pdf', 'xls'), BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_ARRAY_STRING,
'bs-pref-fileextensions', 'multiselectplusadd' );
- BsConfig::registerVar( 'MW::ImageExtensions', array('png',
'gif', 'jpg', 'jpeg'), BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_ARRAY_STRING,
'bs-pref-imageextensions', 'multiselectplusadd' );
+ $aFiles = array( 'doc', 'docx', 'pdf', 'xls', 'xlsx' );
+ $aImages = array( 'png', 'gif', 'jpg', 'jpeg' );
+ BsConfig::registerVar( 'MW::FileExtensions', $aFiles,
BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_ARRAY_STRING,
'bs-pref-fileextensions', 'multiselectplusadd' );
+ BsConfig::registerVar( 'MW::ImageExtensions', $aImages,
BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_ARRAY_STRING,
'bs-pref-imageextensions', 'multiselectplusadd' );
BsConfig::registerVar( 'MW::LogoPath', $sPath . 'bs-logo.png',
BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_STRING, 'bs-pref-logopath' );
BsConfig::registerVar( 'MW::FaviconPath', $sPath .
'favicon.ico', BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_STRING,
'bs-pref-faviconpath' );
BsConfig::registerVar( 'MW::DefaultUserImage', $sPath .
'bs-user-default-image.png', BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_STRING,
'bs-pref-defaultuserimage' );
diff --git a/includes/html/htmlformfields/HTMLMultiSelectEx.php
b/includes/html/htmlformfields/HTMLMultiSelectEx.php
index 9dd9a45..927e233 100644
--- a/includes/html/htmlformfields/HTMLMultiSelectEx.php
+++ b/includes/html/htmlformfields/HTMLMultiSelectEx.php
@@ -17,6 +17,8 @@
}
function getInputHTML( $value ) {
+ $this->mParent->getOutput()->addModules(
'ext.bluespice.html.formfields.multiselect' );
+
$aOptions = ( isset( $this->mParams['options'] ) ) ?
$this->mParams['options'] : array();
$html = $this->formatOptions( $aOptions, $value );
diff --git a/includes/html/htmlformfields/HTMLMultiSelectPlusAdd.php
b/includes/html/htmlformfields/HTMLMultiSelectPlusAdd.php
index 816e55b..0c6f0ae 100644
--- a/includes/html/htmlformfields/HTMLMultiSelectPlusAdd.php
+++ b/includes/html/htmlformfields/HTMLMultiSelectPlusAdd.php
@@ -13,8 +13,8 @@
$attrs = array(
'type' => 'button',
'id' => $this->mName . '-add',
- 'title' => wfMessage(
strtolower($this->mParams['title']) )->plain(),
- 'msg' => wfMessage( strtolower( $this->mParams['title']
) )->plain(),
+ 'title' => wfMessage( 'bs-extjs-add' )->text(),
+ 'msg' => '',
'targetField' => $this->mName,
'class' => 'bsMultiSelectAddButton',
'onclick' => 'bs.util.addEntryToMultiSelect(this);',
diff --git a/includes/html/htmlformfields/HTMLMultiSelectSortList.php
b/includes/html/htmlformfields/HTMLMultiSelectSortList.php
index d9c950b..950b186 100644
--- a/includes/html/htmlformfields/HTMLMultiSelectSortList.php
+++ b/includes/html/htmlformfields/HTMLMultiSelectSortList.php
@@ -7,44 +7,44 @@
class HTMLMultiSelectSortList extends HTMLMultiSelectEx {
function getInputHTML( $value ) {
-
$this->mParent->getOutput()->addModules('ext.bluespice.html.formfields');
+ $this->mParent->getOutput()->addModules(
'ext.bluespice.html.formfields.sortable' );
$aValidated = $this->reValidate($value,
$this->mParams['options']);
-
+
$aOptions = array();
foreach( $aValidated as $aOption ) {
$aOptions[] = $aOption['key'];
}
-
- $html = $this->formatOptions( $aOptions, $value,
'multiselectsort' );
+
+ $html = $this->formatOptions( $aOptions, $value,
'multiselectsort bs-multiselect-sortable' );
$sHTMLList = '<ul class="multiselectsortlist">';
-
+
foreach( $aValidated as $aOption ) {
- $sHTMLList .= '<li class="multiselectsortlistitem"
data-value="'.$aOption['key'].'">'.$aOption['title'].'</li>';
+ $sHTMLList .= '<li class="multiselectsortlistitem
bs-multiselect-item"
data-value="'.$aOption['key'].'">'.$aOption['title'].'</li>';
}
-
+
$sHTMLList .= '</ul>';
return $sHTMLList.$html;
}
-
-
+
+
private function reValidate( $value, $aOptions) {
$aValidated = array();
-
+
foreach( $value as $sValue ) {
if( isset($aOptions[$sValue]) ) {
$aValidated[] = array('key' => $sValue, 'title'
=> $aOptions[$sValue]);
unset($aOptions[$sValue]);
}
}
-
+
if(!empty($aOptions)) {
foreach( $aOptions as $key => $sOption ) {
$aValidated[] = array('key' => $key, 'title' =>
$sOption);
}
}
-
+
return $aValidated;
}
diff --git a/resources/Resources.php b/resources/Resources.php
index 7394fc7..9071a02 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -19,8 +19,7 @@
'bluespice/bluespice.wikiText.js',
'bluespice/bluespice.string.js',
'bluespice/bluespice.xhr.js',
- 'bluespice/bluespice.ping.js',
- 'bluespice/bluespice.multiselect.js'
+ 'bluespice/bluespice.ping.js'
),
'dependencies' => array(
'jquery',
@@ -51,7 +50,6 @@
'bs-two-units-ago',
'bs-one-unit-ago',
'bs-now',
-
'blanknamespace', //MediaWiki
),
'position' => 'bottom' // available since r85616
@@ -114,8 +112,7 @@
) + $aResourceModuleTemplate;
$wgResourceModules['ext.bluespice.extjs.styles'] = array(
- //Those are mainly Ext.ux styles that are not part of ext-all.css or the
- //theme
+ //Those are mainly Ext.ux styles that are not part of ext-all.css or
the theme
'styles' => array(
'bluespice.extjs/Ext.ux/css/GroupTabPanel.css',
'bluespice.extjs/Ext.ux/css/ItemSelector.css',
@@ -134,7 +131,6 @@
),
'messages' => array(
'bs-extjs-portal-config',
-//unused 'bs-extjs-portal-portlets',
'bs-extjs-portal-title',
'bs-extjs-portal-height',
'bs-extjs-portal-count',
@@ -154,12 +150,24 @@
)
) + $aResourceModuleTemplate;
-$wgResourceModules['ext.bluespice.html.formfields'] = array(
+$wgResourceModules['ext.bluespice.html.formfields.sortable'] = array(
'scripts' => array(
- 'bluespice/bluespice.html.formfields.js'
+ 'bluespice/bluespice.html.formfields.sortable.js'
+ ),
+ 'styles' => array(
+ 'bluespice/bluespice.html.formfields.sortable.css'
),
'dependencies' => array(
- 'ext.bluespice.extjs'
+ 'ext.bluespice'
+ )
+) + $aResourceModuleTemplate;
+
+$wgResourceModules['ext.bluespice.html.formfields.multiselect'] = array(
+ 'scripts' => array(
+ 'bluespice/bluespice.html.formfields.multiselect.js'
+ ),
+ 'dependencies' => array(
+ 'ext.bluespice'
)
) + $aResourceModuleTemplate;
diff --git a/resources/bluespice/bluespice.html.formfields.multiselect.js
b/resources/bluespice/bluespice.html.formfields.multiselect.js
new file mode 100644
index 0000000..2eb9e82
--- /dev/null
+++ b/resources/bluespice/bluespice.html.formfields.multiselect.js
@@ -0,0 +1,20 @@
+( function ( mw, bs, $, undefined ) {
+ var forms = $( 'form' );
+ forms.each( function() {
+ $( this ).submit( function() {
+ $( this ).find( '.multiselectplusadd' ).each( function(
index, item ) {
+ for ( i = item.length - 1; i>=0; i-- ) {
+ item.options[i].selected = true;
+ }
+ }) ;
+ return true;
+ });
+ });
+ forms.each( function() {
+ $( this ).find( '.multiselectplusadd' ).each( function( index,
item ) {
+ for ( i = item.length - 1; i >= 0; i-- ) {
+ item.options[i].selected = true;
+ }
+ });
+ });
+}( mediaWiki, blueSpice, jQuery ) );
\ No newline at end of file
diff --git a/resources/bluespice/bluespice.html.formfields.sortable.css
b/resources/bluespice/bluespice.html.formfields.sortable.css
new file mode 100644
index 0000000..ca6a0bf
--- /dev/null
+++ b/resources/bluespice/bluespice.html.formfields.sortable.css
@@ -0,0 +1,10 @@
+.bs-multiselect-sortable {
+ display: none;
+}
+.bs-multiselect-item {
+ border: 1px solid #d3d3d3;
+ background: #e6e6e6;
+ padding: 2px 5px;
+ margin: 5px 0;
+ list-style-type: none;
+}
\ No newline at end of file
diff --git a/resources/bluespice/bluespice.html.formfields.js
b/resources/bluespice/bluespice.html.formfields.sortable.js
similarity index 83%
rename from resources/bluespice/bluespice.html.formfields.js
rename to resources/bluespice/bluespice.html.formfields.sortable.js
index 4a6c3f0..05d2ce5 100644
--- a/resources/bluespice/bluespice.html.formfields.js
+++ b/resources/bluespice/bluespice.html.formfields.sortable.js
@@ -1,7 +1,6 @@
-$(document).ready(function(){
-
+( function ( mw, bs, $, undefined ) {
$( '.multiselectsortlist' ).sortable( {
- update: function( event, ui ) {
+ update: function( event, ui ) {
$( this ).next().children().remove(); //Remove all
"option" tags from the hidden "select" element
$( this ).children().each( function( index, element ) {
$( this ).parent().next() //The "select" element
@@ -10,5 +9,4 @@
});
}
});
-
-});
\ No newline at end of file
+}( mediaWiki, blueSpice, jQuery ) );
\ No newline at end of file
diff --git a/resources/bluespice/bluespice.multiselect.js
b/resources/bluespice/bluespice.multiselect.js
deleted file mode 100644
index 8ce4a8d..0000000
--- a/resources/bluespice/bluespice.multiselect.js
+++ /dev/null
@@ -1,19 +0,0 @@
-$('form').each(function() {
- $(this).submit(function() {
- $(this).find('.multiselectplusadd').each(function(index, item) {
- var i;
- for (i = item.length - 1; i>=0; i--) {
- item.options[i].selected = true;
- }
- }) ;
- return true;
- });
-});
-$('form').each(function() {
- $(this).find('.multiselectplusadd').each(function(index, item) {
- var i;
- for (i = item.length - 1; i>=0; i--) {
- item.options[i].selected = false;
- }
- });
-});
\ No newline at end of file
diff --git a/resources/bluespice/bluespice.util.js
b/resources/bluespice/bluespice.util.js
index f11f22d..c8959c9 100644
--- a/resources/bluespice/bluespice.util.js
+++ b/resources/bluespice/bluespice.util.js
@@ -468,7 +468,7 @@
oSelect = document.getElementById(
'mw-input-' + 'wp' + sFieldName );
}
- oSelect.options[oSelect.options.length] = new
Option( text, text, false, false );
+ oSelect.options[oSelect.options.length] = new
Option( text, text, false, true );
}
});
};
--
To view, visit https://gerrit.wikimedia.org/r/166739
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I52d2cf8a5c44d674e566dd1476ff599a6bf497b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Smuggli <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits