summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremattias2013-01-19 00:21:15 (GMT)
committer emattias2013-01-19 00:21:15 (GMT)
commit4169e84bee98ced7c16519dbc9ccd471e99da3aa (patch)
tree1f6718decbe3ccfe4da0e72b48bb792e6372d283
parente938cc4cbbb6115a445078ec48819e6310b7eba9 (diff)
Make the get attributes fieldset fn support 2+ deep nesting
-rw-r--r--plugins/styles/semantic_panels.inc63
1 files changed, 43 insertions, 20 deletions
diff --git a/plugins/styles/semantic_panels.inc b/plugins/styles/semantic_panels.inc
index aab9428..e70fb64 100644
--- a/plugins/styles/semantic_panels.inc
+++ b/plugins/styles/semantic_panels.inc
@@ -244,14 +244,30 @@ function semantic_panels_pane_settings_form($settings, $display) {
return $form;
}
+function _semantic_panels_context_token_types_map($l){
+ return $l->keyword;
+}
+
/**
* Get "Other Attribute(s)" fieldset
*/
-function _semantic_panels_get_attributes_fieldset(&$form, $settings, $element_key){
- $element_key_class = str_replace('_', '-', $element_key);
+function _semantic_panels_get_attributes_fieldset(&$root_element, $settings, $element_key){
$attributes = _semantic_panels_get_attributes();
+ $element_key_class = '';
+
+ if(is_array($element_key)){
+ foreach($element_key as $key){
+ $root_element = &$root_element[$key];
+ $settings = &$settings[$key];
+ $element_key_class .= '-' . str_replace('_', '-', $key);
+ }
+ }else{
+ $root_element = &$root_element[$element_key];
+ $settings = &$settings[$element_key];
+ $element_key_class = '-' . str_replace('_', '-', $element_key);
+ }
- $form[$element_key]['attributes'] = array(
+ $root_element['attributes'] = array(
'#type' => 'fieldset',
'#title' => t('Other attribute(s)'),
'#collapsible' => TRUE,
@@ -261,25 +277,25 @@ function _semantic_panels_get_attributes_fieldset(&$form, $settings, $element_ke
foreach($attributes as $attribute => $attribute_data){
- $form[$element_key]['attributes'][$attribute] = array(
+ $root_element['attributes'][$attribute] = array(
'#type' => 'fieldset',
'#title' => $attribute,
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
- $form[$element_key]['attributes'][$attribute]['enabled'] = array(
+ $root_element['attributes'][$attribute]['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Add <em>@attribute</em> attribute', array('@attribute' => $attribute)),
- '#default_value' => !empty($settings[$element_key]['attributes'][$attribute]['enabled']),
+ '#default_value' => !empty($settings['attributes'][$attribute]['enabled']),
);
- $form[$element_key]['attributes'][$attribute]['value'] = array(
+ $root_element['attributes'][$attribute]['value'] = array(
'#type' => 'textfield',
'#title' => t("<em>@attribute</em> value",array('@attribute' => $attribute)),
- '#default_value' => $settings[$element_key]['attributes'][$attribute]['value'],
+ '#default_value' => $settings['attributes'][$attribute]['value'],
'#dependency' => array(
- 'edit-settings-' . $element_key_class . '-attributes-' . $attribute . '-enabled' => array(TRUE),
+ 'edit-settings' . $element_key_class . '-attributes-' . $attribute . '-enabled' => array(TRUE),
),
'#description' => t('Value is not required')
);
@@ -292,19 +308,26 @@ function _semantic_panels_get_attributes_fieldset(&$form, $settings, $element_ke
* Pane settings form submit handler.
*/
function semantic_panels_pane_settings_form_submit($form, &$settings, $form_state) {
-
foreach($settings as &$setting){
if(!empty($setting['attributes'])){
- $setting['attributes_array'] = array();
- foreach($setting['attributes'] as $machine_name => $attribute_settings){
- if(empty($setting['attributes'][$machine_name]['enabled'])){
- // Don't save disabled attributes
- unset($setting['attributes'][$machine_name]);
- }else{
- // Build up $settings['attributes_array'] ready for drupal_attributes with only enabled attributes
- $setting['attributes_array'][$machine_name] = $setting['attributes'][$machine_name]['value'];
- }
- }
+ _semantic_panels_attributes_save($setting);
+ }
+ // @TODO: Make this into a generalized loop instead
+ if(!empty($setting['link']['attributes'])){
+ _semantic_panels_attributes_save($setting['link']);
+ }
+ }
+}
+
+function _semantic_panels_attributes_save(&$setting){
+ $setting['attributes_array'] = array();
+ foreach($setting['attributes'] as $machine_name => $attribute_settings){
+ if(empty($setting['attributes'][$machine_name]['enabled'])){
+ // Don't save disabled attributes
+ unset($setting['attributes'][$machine_name]);
+ }else{
+ // Build up $settings['attributes_array'] ready for drupal_attributes with only enabled attributes
+ $setting['attributes_array'][$machine_name] = $setting['attributes'][$machine_name]['value'];
}
}
}