From 40b0bf7de13b2e34076dfb62b2cbbab55e3f0239 Mon Sep 17 00:00:00 2001 From: bgamrat Date: Tue, 11 Nov 2014 15:50:35 -0500 Subject: [PATCH 1/4] Added multiselect support --- .../ezflow/datatypes/ezpage/ezpagetype.php | 9 ++- .../standard/templates/block/edit/edit.tpl | 61 +++++++++++++++++-- .../ezextension/ezflow/settings/block.ini | 4 ++ 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php b/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php index 389f2c35..9a10d976 100644 --- a/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php +++ b/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php @@ -278,7 +278,14 @@ function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute ) foreach ( $params as $param => $value ) { - $fetchParams[$param] = $value; + if (is_array($value)) + { + $customAttributes[$param] = implode(',', $value); + } + else + { + $customAttributes[$param] = $value; + } } $block->setAttribute( 'fetch_params', serialize( $fetchParams ) ); diff --git a/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl b/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl index 7c53d402..8955071d 100644 --- a/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl +++ b/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl @@ -86,6 +86,11 @@ $custom_attribute_types = array() $custom_attribute_names = array() $custom_attribute_selections = array() + $custom_attribute_value = '' + $custom_attribute_values = array() + $custom_attribute_default = '' + $custom_attribute_multiselect_setting = false() + $custom_attribute_multiselect_value = false() $loop_count = 0} {if ezini_hasvariable( $block.type, 'CustomAttributes', 'block.ini' )} {set $custom_attributes = ezini( $block.type, 'CustomAttributes', 'block.ini' )} @@ -129,12 +134,56 @@ {/case} {case match = 'select'} - {set $custom_attribute_selections = ezini( $block.type, concat( 'CustomAttributeSelection_', $custom_attrib ), 'block.ini' )} - + {set $custom_attribute_selections = ezini( $block.type, concat( 'CustomAttributeSelection_', $custom_attrib ),'block.ini' )} + + {* Check if there is a default value for the select *} + {if ezini_hasvariable( $block.type, concat( 'CustomAttributeSelectionDefault_', $custom_attrib ), 'block.ini' )} + {set $custom_attribute_default = ezini( $block.type, concat( 'CustomAttributeSelectionDefault_', $custom_attrib ), 'block.ini' )} + {else} + {set $custom_attribute_default = ''} + {/if} + + {* Check if there is a value set for the custom attribute - empty is assumed to be no value *} + {if $block.custom_attributes[$custom_attrib]|ne( '' )} + {set $custom_attribute_value = $block.custom_attributes[$custom_attrib]} + {else} + {set $custom_attribute_value = $custom_attribute_default} + {/if} + + {* Test for multiselect option *} + {set $custom_attribute_multiselect_setting = ezini_hasvariable( $block.type, concat( 'CustomAttributeMultipleSelection_', $custom_attrib ), 'block.ini' )} + {* If multiselect select option is set, use the value *} + {if $custom_attribute_multiselect_setting} + {* Test against common settings which may be used *} + {set $custom_attribute_multiselect_value = array('1',1,'true',true())|contains(ezini( $block.type, concat( 'CustomAttributeMultipleSelection_', $custom_attrib ), 'block.ini' ))} + {else} + {* Default value is false - single select *} + {set $custom_attribute_multiselect_value = false()} + {/if} + + {* Set custom_attribute_values based on the multiselect setting value *} + {if $custom_attribute_multiselect_value} + {set $custom_attribute_values = $custom_attribute_value|explode(',')} + {else} + {set $custom_attribute_values = array( $custom_attribute_value )} + {/if} + + {def $i_selected = ''} + {/case} {case} diff --git a/packages/ezflow_extension/ezextension/ezflow/settings/block.ini b/packages/ezflow_extension/ezextension/ezflow/settings/block.ini index 794da2e3..4432ada8 100644 --- a/packages/ezflow_extension/ezextension/ezflow/settings/block.ini +++ b/packages/ezflow_extension/ezextension/ezflow/settings/block.ini @@ -75,6 +75,10 @@ RootSubtree=1 # CustomAttributeSelection_color[] # CustomAttributeSelection_color[blue]=Blue # CustomAttributeSelection_color[green]=Green +# Set the default +# CustomAttributeSelectionDefault_color=green +# Allow multiple items to be selected +# CustomAttributeMultipleSelection_color[]=1 # UseBrowseMode[node_id]=true # Optional: set the browse mode start node for a custom attribute # CustomAttributeStartBrowseNode[node_id]= From bb098b279a90987892767df1192dc1e9042bf0e6 Mon Sep 17 00:00:00 2001 From: bgamrat Date: Tue, 11 Nov 2014 16:06:25 -0500 Subject: [PATCH 2/4] Added multiselect support - fix --- .../ezflow/datatypes/ezpage/ezpagetype.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php b/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php index 9a10d976..1a962d14 100644 --- a/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php +++ b/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php @@ -278,14 +278,7 @@ function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute ) foreach ( $params as $param => $value ) { - if (is_array($value)) - { - $customAttributes[$param] = implode(',', $value); - } - else - { - $customAttributes[$param] = $value; - } + $fetchParams[$param] = $value; } $block->setAttribute( 'fetch_params', serialize( $fetchParams ) ); @@ -320,7 +313,14 @@ function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute ) foreach ( $params as $param => $value ) { - $customAttributes[$param] = $value; + if (is_array($value)) + { + $customAttributes[$param] = implode(',', $value); + } + else + { + $customAttributes[$param] = $value; + } } $block->setAttribute( 'custom_attributes', $customAttributes ); From 8669ff3b0eb3d439a6635c26f5774a2ef4b14521 Mon Sep 17 00:00:00 2001 From: bgamrat Date: Tue, 11 Nov 2014 16:09:53 -0500 Subject: [PATCH 3/4] Added multiselect support - code cleanup --- .../ezextension/ezflow/datatypes/ezpage/ezpagetype.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php b/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php index 1a962d14..a8196da2 100644 --- a/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php +++ b/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php @@ -278,7 +278,7 @@ function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute ) foreach ( $params as $param => $value ) { - $fetchParams[$param] = $value; + $fetchParams[$param] = $value; } $block->setAttribute( 'fetch_params', serialize( $fetchParams ) ); From 02c9a13583226f5be6f79f6f72ce633060552931 Mon Sep 17 00:00:00 2001 From: bgamrat Date: Wed, 12 Nov 2014 10:26:05 -0500 Subject: [PATCH 4/4] Updates with respect to Peter's comments --- .../standard/templates/block/edit/edit.tpl | 22 ++++++++++++++----- .../ezextension/ezflow/settings/block.ini | 18 +++++++++++++-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl b/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl index 8955071d..6797b2dc 100644 --- a/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl +++ b/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl @@ -143,19 +143,19 @@ {set $custom_attribute_default = ''} {/if} - {* Check if there is a value set for the custom attribute - empty is assumed to be no value *} - {if $block.custom_attributes[$custom_attrib]|ne( '' )} + {* Check if this is a new block *} + {if is_set( $block.custom_attributes[$custom_attrib] )} {set $custom_attribute_value = $block.custom_attributes[$custom_attrib]} {else} {set $custom_attribute_value = $custom_attribute_default} {/if} {* Test for multiselect option *} - {set $custom_attribute_multiselect_setting = ezini_hasvariable( $block.type, concat( 'CustomAttributeMultipleSelection_', $custom_attrib ), 'block.ini' )} + {set $custom_attribute_multiselect_setting = ezini_hasvariable( $block.type, concat( 'CustomAttributeSelectionMultiple_', $custom_attrib ), 'block.ini' )} {* If multiselect select option is set, use the value *} {if $custom_attribute_multiselect_setting} - {* Test against common settings which may be used *} - {set $custom_attribute_multiselect_value = array('1',1,'true',true())|contains(ezini( $block.type, concat( 'CustomAttributeMultipleSelection_', $custom_attrib ), 'block.ini' ))} + {* If multiselect is enabled *} + {set $custom_attribute_multiselect_value = ezini( $block.type, concat( 'CustomAttributeSelectionMultiple_', $custom_attrib ), 'block.ini' )|eq( 'enabled' )} {else} {* Default value is false - single select *} {set $custom_attribute_multiselect_value = false()} @@ -168,8 +168,18 @@ {set $custom_attribute_values = array( $custom_attribute_value )} {/if} + {def $i_selected = ''} - + + {* If an allow empty option has been set *} + {if ezini_hasvariable( $block.type, concat( 'CustomAttributeSelectionEmpty_', $custom_attrib ), 'block.ini' )} + {* Test allow empty option, this ensures the value is sent to the server and set *} + {if ezini( $block.type, concat( 'CustomAttributeSelectionMultiple_', $custom_attrib ), 'block.ini' )|eq( 'enabled' )} + + {/if} + {/if} + {foreach $custom_attribute_selections as $selection_value => $selection_name} {* mark option as selected *} diff --git a/packages/ezflow_extension/ezextension/ezflow/settings/block.ini b/packages/ezflow_extension/ezextension/ezflow/settings/block.ini index 4432ada8..8720c437 100644 --- a/packages/ezflow_extension/ezextension/ezflow/settings/block.ini +++ b/packages/ezflow_extension/ezextension/ezflow/settings/block.ini @@ -72,13 +72,27 @@ RootSubtree=1 # text / checkbox / select / string (default) # CustomAttributeTypes[node_id]=string # CustomAttributeTypes[color]=select +# Select attribute configuration +# CustomAttributeSelection_name[value]=Label +# name must correspond to a CustomAttributeTypes[name]=select setting +# value is the value which will be stored. It MUST NOT contain commas. +# Label is the label that will be displayed in the select input. It may be any string. +# CustomAttributeSelectionDefault_name=value +# This sets the default value of the select input. value must match a CustomAttributeSelection_name[value] setting +# Multiple values may be included, separated by commas +# If this value is omitted, the default is assumed to be an empty string +# CustomAttributeSelectionEmpty_name=enabled +# Indicates whether the selection can be empty. When enabled, an empty value with the label '--' will be added to the select +# CustomAttributeSelectionMultiple_name=enabled +# Multiple selections may be enabled by setting CustomAttributeSelectionMultiple_name to enabled # CustomAttributeSelection_color[] # CustomAttributeSelection_color[blue]=Blue # CustomAttributeSelection_color[green]=Green +# CustomAttributeSelection_color[red]=Red # Set the default -# CustomAttributeSelectionDefault_color=green +# CustomAttributeSelectionDefault_color=green,red # Allow multiple items to be selected -# CustomAttributeMultipleSelection_color[]=1 +# CustomAttributeSelectionMultiple_color=enabled # UseBrowseMode[node_id]=true # Optional: set the browse mode start node for a custom attribute # CustomAttributeStartBrowseNode[node_id]=