Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9deb2e7
Merge branch 'release/6.9.x'
fplanque Aug 25, 2017
46085e7
Merge branch 'release/6.9.x'
fplanque Aug 25, 2017
fd0a313
Merge branch 'release/6.9.x'
fplanque Nov 26, 2017
f901eb4
fix version number
fplanque Nov 26, 2017
56e0640
Merge branch 'release/6.9.x'
fplanque Dec 30, 2017
f44e25e
Merge branch 'release/6.9.6'
fplanque Jan 5, 2018
4f2227e
Created new type of select_input for Settings
midnight-studios Jan 5, 2018
927f343
Several fixes
midnight-studios Jan 8, 2018
0b867a7
Fixed label and input name for select_input
midnight-studios Jan 8, 2018
0bf36d2
Fixed remove field link
midnight-studios Jan 12, 2018
7f8a9f7
Fixed param name reference
midnight-studios Feb 23, 2018
d8e80a3
Fixed loading of fields on save and update
midnight-studios Feb 23, 2018
3639b7e
Fixed name references for params
midnight-studios Feb 23, 2018
c98ee6f
fix: exclude type of 'select_input' change:
midnight-studios Feb 23, 2018
de61c5f
fix: added single items become a button only
midnight-studios Feb 23, 2018
a9fdf2c
Fixed saved params order
midnight-studios Feb 25, 2018
2124ea7
Fixed param group injection
midnight-studios Feb 25, 2018
2774e06
Corrected comments
midnight-studios Feb 25, 2018
972ec8e
Fixed missing remove field buttons
midnight-studios Feb 25, 2018
aa5235c
Fix new fields insertion
midnight-studios Feb 26, 2018
4f08e44
Fixed remove button display for types
midnight-studios Feb 26, 2018
c1aa480
Delete .DS_Store
midnight-studios Feb 27, 2018
8da3837
Delete .DS_Store
midnight-studios Feb 27, 2018
fc9080b
Delete .DS_Store
midnight-studios Feb 27, 2018
b948d01
Fixed param by key
midnight-studios Mar 13, 2018
65e55db
Fixed parname reference
midnight-studios Mar 13, 2018
605a63a
Fix max_number if defined for selected input type
midnight-studios Mar 14, 2018
7dee1e4
Allow embedded scripts to be executed
midnight-studios Mar 14, 2018
85393db
Removed forced checkbox on select_input types
midnight-studios Mar 15, 2018
fc4e24f
Added Max number of entries reached
midnight-studios Mar 15, 2018
b0f9b06
Added removal old action messages
midnight-studios Mar 15, 2018
7a6b1e8
Several fixes
midnight-studios Mar 16, 2018
b92f4b2
Removed form class radio input type id restriction
midnight-studios Mar 16, 2018
d244979
Fix js break in modal window
midnight-studios Mar 27, 2018
3fff9ab
Fixed max items for total items if defined
midnight-studios Mar 27, 2018
633df95
fix Initialize color picker for color fields
midnight-studios Mar 29, 2018
2e283e9
Fix to get valid HTML id
midnight-studios Apr 4, 2018
ded7da4
Fix foldable settings init for dynamic calls
midnight-studios Apr 5, 2018
cf94da2
Several upgrades & fixes
midnight-studios Apr 5, 2018
4f619be
Merge branch 'develop' into Dynamic-Group-of-type-select_input
midnight-studios Apr 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 125 additions & 1 deletion htsrv/async.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,131 @@

echo $winfo;
break;

case 'add_plugin_sett_selected':

// Dislay a new Plugin(User)Settings set ( it's used only from plugins with "select_input" type settings):

// This does not require CSRF because it doesn't update the db, it only displays a new block of empty plugin setting fields

// Check permission to view plugin settings:
$current_User->check_perm( 'options', 'view', true );

// Set admin skin, used for buttons, @see button_class()
$admin_skin = $UserSettings->get( 'admin_skin', $current_User->ID );
require_once $adminskins_path.$admin_skin.'/_adminUI.class.php';
$AdminUI = new AdminUI();

param( 'plugin_ID', 'integer', true );
param( 'set_type', 'string', '' ); // 'Settings', 'UserSettings', 'CollSettings', 'MsgSettings', 'EmailSettings', 'Skin', 'Widget'
param( 'entry_type', 'string', '' );
param( 'entry_name', 'string', '' );
param( 'parname', 'string', '' );
param( 'k_nb', 'integer', true );

if( ! in_array( $set_type, array( 'Settings', 'UserSettings', 'CollSettings', 'MsgSettings', 'EmailSettings', 'Skin', 'Widget' ) ) )
{
bad_request_die( 'Invalid set_type param!' );
}

param( 'blog', 'integer', 0 );
$BlogCache = & get_BlogCache();
$Blog = & $BlogCache->get_by_ID( $blog, false, false );

$target_Object = NULL;

switch( $set_type )
{
case 'Widget':
$WidgetCache = & get_WidgetCache();
$Widget = & $WidgetCache->get_by_ID( $plugin_ID );
$Plugin = & $Widget->get_Plugin();
$plugin_Object = $Widget;
break;

case 'Skin':
$SkinCache = & get_SkinCache();
$Skin = & $SkinCache->get_by_ID( $plugin_ID );
$Plugin = $Skin;
$plugin_Object = $Skin;
break;

default:
// 'Settings', 'UserSettings', 'CollSettings', 'MsgSettings', 'EmailSettings'
$admin_Plugins = & get_Plugins_admin(); // use Plugins_admin, because a plugin might be disabled
$Plugin = & $admin_Plugins->get_by_ID( $plugin_ID );
$plugin_Object = $Plugin;
if( $set_type == 'UserSettings' )
{ // Initialize User object for this plugin type:
param( 'user_ID', 'integer', true );
$UserCache = & get_UserCache();
$target_Object = & $UserCache->get_by_ID( $user_ID );
}
break;
}

if( ! $Plugin )
{
bad_request_die('Invalid Plugin.');
}
param( 'set_path', '/^\w+(?:\[\w+\])+$/', '' );

load_funcs('plugins/_plugin.funcs.php');

// Init the new setting set:
_set_setting_by_path( $Plugin, $set_type, $set_path, array() );

// Get the new plugin setting set and display it with a fake Form
$r = get_plugin_settings_node_by_path( $Plugin, $set_type, $set_path, /* create: */ false );

$Form = new Form(); // fake Form to display plugin setting

$k_nb++; //advance the field number



/*
* When the action is called (user clicked the Add button) all items listed under [entries] will be added;
* to avoid this and only add the selected item (when the call is made) we pass the [type:selected] via a param
* here we will cycle trough the items, and if the items['type'] matches the passed param['type'] we can target the correct requested item only while ignoring the others
*
* [parent reference] & [child reference] : defined by the plugin/widget/skin settings
* [iteration] : defined by the user
*
* we use function: autoform_display_field( $parname, $parmeta, & $Form, $set_type, $Obj, $set_target = NULL, $use_value = NULL )
* $parname = the item [parent reference] + [iteration] + [child reference] (because the parent >> child combination may be requested multiple times )
* $parmeta = the item (defined by the plugin settings) and selected (by the user) we want to display ['set_meta']['entries']['entry_name']
*
* [iteration] : is an integer value that should present a natuaral progression (auto increment)
* JavaScript counts the items that exists at the time the action call is made and then passed the result in a param that is accessed here
* the iteration is then advanced for this call
*
*
* ['group_type'] : with inputs a group is usually injected, we use this param to tell groups where the inputs originated because the ['group'] logic is applied differently for 'select_inputs' (only)
*
*/

//cycle through avaiable items:
foreach( $r['set_meta']['entries'] as $l_entry_name => $l_entry_meta )
{
// if the passed param['type'] is set (exists) and it matches items['type'] and key matches $entry_name
if( isset( $l_entry_meta['type'] ) && $l_entry_meta['type'] == $entry_type && $entry_name == $l_entry_name )
{

if( isset( $l_entry_meta['inputs'] ) )
{
$r['set_meta']['entries'][$l_entry_name]['group_type'] = 'select_input'; // inject group type
}

$this->autoform_display_field( $parname.'['.$k_nb.']['.$l_entry_name.']', $r['set_meta']['entries'][$l_entry_name], $Form, $Product, NULL, $r['set_node'][$l_entry_name] );
//this call has only one item (the selected item), the rest is ignored, so break out alltogether
break 2;
}

}

break;

case 'add_plugin_sett_set':
// Dislay a new Plugin(User)Settings set ( it's used only from plugins with "array" type settings):

Expand Down Expand Up @@ -1086,4 +1210,4 @@
exit(0);
}

?>
?>
168 changes: 102 additions & 66 deletions inc/_core/_misc.funcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7653,6 +7653,7 @@ function get_fieldset_folding_icon( $id, $params = array() )
}



/**
* Output JavaScript code to collapse/expand fieldset
*/
Expand All @@ -7665,79 +7666,113 @@ function echo_fieldset_folding_js()

?>
<script type="text/javascript">
jQuery( 'span[id^=icon_folding_], span[id^=title_folding_]' ).click( function()
{
var is_icon = jQuery( this ).attr( 'id' ).match( /^icon_folding_/ );
var wrapper_obj = jQuery( this ).closest( '.fieldset_wrapper' );
var value_obj = is_icon ? jQuery( this ).prev() : jQuery( this ).prev().prev();


var init_fieldset_folding_js = function()
{

jQuery( 'span[id^=icon_folding_], span[id^=title_folding_]' ).click( function(e)
{

if( wrapper_obj.length == 0 || value_obj.length == 0 )
{ // Invalid layout
return false;
}
var is_icon = jQuery( this ).attr( 'id' ).match( /^icon_folding_/ );
var wrapper_obj = jQuery( this ).closest( '.fieldset_wrapper' );
var value_obj = is_icon ? jQuery( this ).prev() : jQuery( this ).prev().prev();

if( value_obj.val() == '1' )
{ // Collapse
wrapper_obj.removeClass( 'folded' );
value_obj.val( '0' );
}
else
{ // Expand
wrapper_obj.addClass( 'folded' );
value_obj.val( '1' );
}

// Change icon image
var clickimg = is_icon ? jQuery( this ) : jQuery( this ).prev();
if( clickimg.hasClass( 'fa' ) || clickimg.hasClass( 'glyphicon' ) )
{ // Fontawesome icon | Glyph bootstrap icon
if( clickimg.data( 'toggle' ) != '' )
{ // This icon has a class name to toggle
var icon_prefix = ( clickimg.hasClass( 'fa' ) ? 'fa' : 'glyphicon' );
if( clickimg.data( 'toggle-orig-class' ) == undefined )
{ // Store original class name in data
clickimg.data( 'toggle-orig-class', clickimg.attr( 'class' ).replace( new RegExp( '^'+icon_prefix+' (.+)$', 'g' ), '$1' ) );
}
if( clickimg.hasClass( clickimg.data( 'toggle-orig-class' ) ) )
{ // Replace original class name with exnpanded
clickimg.removeClass( clickimg.data( 'toggle-orig-class' ) )
.addClass( icon_prefix + '-' + clickimg.data( 'toggle' ) );
}
else
{ // Revert back original class
clickimg.removeClass( icon_prefix + '-' + clickimg.data( 'toggle' ) )
.addClass( clickimg.data( 'toggle-orig-class' ) );
if( wrapper_obj.length == 0 || value_obj.length == 0 )
{ // Invalid layout
return false;
}

if( value_obj.val() == '1' )
{ // Collapse
wrapper_obj.removeClass( 'folded' );
value_obj.val( '0' );
}
else
{ // Expand
wrapper_obj.addClass( 'folded' );
value_obj.val( '1' );
}

// Change icon image
var clickimg = is_icon ? jQuery( this ) : jQuery( this ).prev();
if( clickimg.hasClass( 'fa' ) || clickimg.hasClass( 'glyphicon' ) )
{ // Fontawesome icon | Glyph bootstrap icon
if( clickimg.data( 'toggle' ) != '' )
{ // This icon has a class name to toggle
var icon_prefix = ( clickimg.hasClass( 'fa' ) ? 'fa' : 'glyphicon' );
if( clickimg.data( 'toggle-orig-class' ) == undefined )
{ // Store original class name in data
clickimg.data( 'toggle-orig-class', clickimg.attr( 'class' ).replace( new RegExp( '^'+icon_prefix+' (.+)$', 'g' ), '$1' ) );
}
if( clickimg.hasClass( clickimg.data( 'toggle-orig-class' ) ) )
{ // Replace original class name with exnpanded
clickimg.removeClass( clickimg.data( 'toggle-orig-class' ) )
.addClass( icon_prefix + '-' + clickimg.data( 'toggle' ) );
}
else
{ // Revert back original class
clickimg.removeClass( icon_prefix + '-' + clickimg.data( 'toggle' ) )
.addClass( clickimg.data( 'toggle-orig-class' ) );
}
}
}
}
else
{ // Sprite icon
var icon_bg_pos = clickimg.css( 'background-position' );
clickimg.css( 'background-position', clickimg.data( 'xy' ) );
clickimg.data( 'xy', icon_bg_pos );
}
else
{ // Sprite icon
var icon_bg_pos = clickimg.css( 'background-position' );
clickimg.css( 'background-position', clickimg.data( 'xy' ) );
clickimg.data( 'xy', icon_bg_pos );
}

// Toggle title
var title = clickimg.attr( 'title' );
clickimg.attr( 'title', clickimg.data( 'title' ) );
clickimg.data( 'title', title );


e.stopPropagation();
e.preventDefault();

// This does the trick:
e.stopImmediatePropagation();

} );

// Toggle title
var title = clickimg.attr( 'title' );
clickimg.attr( 'title', clickimg.data( 'title' ) );
clickimg.data( 'title', title );
} );
jQuery( 'input[type=hidden][id^=folding_value_]' ).each( function()
{ // Check each feildset is folded correctly after refresh a page
var wrapper_obj = jQuery( this ).closest( '.fieldset_wrapper' );
if( jQuery( this ).val() == '1' )
{ // Collapse
wrapper_obj.addClass( 'folded' );
}
else
{ // Expand
wrapper_obj.removeClass( 'folded' );
}
} );

jQuery( 'input[type=hidden][id^=folding_value_]' ).each( function()
{ // Check each feildset is folded correctly after refresh a page
var wrapper_obj = jQuery( this ).closest( '.fieldset_wrapper' );
if( jQuery( this ).val() == '1' )
{ // Collapse
wrapper_obj.addClass( 'folded' );
}
else
{ // Expand
wrapper_obj.removeClass( 'folded' );
// Expand all fieldsets that have the fields with error
jQuery( '.field_error' ).closest( '.fieldset_wrapper.folded' ).find( 'span[id^=icon_folding_]' ).click();
};


init_fieldset_folding_js();
</script>
<?php
}

function init_fieldset_folding_js()
{
if( ! is_logged_in() )
{ // Only loggedin users can fold fieldset
return;
}
} );

// Expand all fieldsets that have the fields with error
jQuery( '.field_error' ).closest( '.fieldset_wrapper.folded' ).find( 'span[id^=icon_folding_]' ).click();
?>
<script type="text/javascript">

init_fieldset_folding_js();

</script>
<?php
}
Expand Down Expand Up @@ -8694,6 +8729,7 @@ function php_to_jquery_date_format( $php_format )
}



/**
* Check if given string is HTML
*
Expand Down Expand Up @@ -8863,4 +8899,4 @@ function fill_empty_days( $data, $default_data, $start_date, $end_date )

return $fixed_data;
}
?>
?>
5 changes: 3 additions & 2 deletions inc/_core/ui/forms/_form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3569,7 +3569,8 @@ function radio_input( $field_name, $field_value, $field_options, $field_label, $
$field_params['note_format'] = '<div>'.$field_params['note_format'].'</div>';
}

$field_params['id'] = false; // No ID attribute for the label
// Why is this set to false for this type? This is needed for js hooks
#$field_params['id'] = false; // No ID attribute for the label
$this->handle_common_params( $field_params, $field_name, $field_label );
unset($field_params['id']); // unset, so it gets handled correctly as default below

Expand Down Expand Up @@ -4708,4 +4709,4 @@ function end_line( $suffix_text = NULL, $field_type = '', $field_params = array(
}
}

?>
?>
Loading