function _semantic_panels_form_element_attributes in Semantic Panels 7.2
Same name and namespace in other branches
- 7 plugins/styles/semantic_panels.inc \_semantic_panels_form_element_attributes()
Get "Other Attribute(s)" fieldset
2 calls to _semantic_panels_form_element_attributes()
- _semantic_panels_form_element in plugins/
styles/ semantic_panels.inc - _semantic_panels_form_element_link in plugins/
styles/ semantic_panels.inc
File
- plugins/
styles/ semantic_panels.inc, line 116
Code
function _semantic_panels_form_element_attributes(&$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];
$key_class = str_replace('_', '-', $key);
$element_key_class = $element_key_class == '' ? $key_class : $element_key_class . '-' . $key_class;
}
}
else {
$root_element =& $root_element[$element_key];
$settings =& $settings[$element_key];
$element_key_class = str_replace('_', '-', $element_key);
}
$root_element['class_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Add CSS class(es)'),
'#default_value' => isset($settings['class_enable']) ? $settings['class_enable'] : 0,
'#attributes' => array(
'class' => array(
$element_key_class . '-class-enable',
),
),
);
$root_element['class'] = array(
'#type' => 'textfield',
'#title' => t('CSS class(es)'),
'#default_value' => isset($settings['class']) ? $settings['class'] : '',
'#states' => array(
'visible' => array(
'.' . $element_key_class . '-class-enable' => array(
'checked' => TRUE,
),
),
),
);
$root_element['attributes'] = array(
'#type' => 'fieldset',
'#title' => t('Other attribute(s)'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('You can override the available attributes below by setting the <em>semantic_panels_attributes</em> variable.'),
);
foreach ($attributes as $attribute => $attribute_data) {
$root_element['attributes'][$attribute] = array(
'#type' => 'fieldset',
'#title' => $attribute,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$root_element['attributes'][$attribute]['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Add <em>@attribute</em> attribute', array(
'@attribute' => $attribute,
)),
'#default_value' => isset($settings['attributes'][$attribute]['enabled']) ? $settings['attributes'][$attribute]['enabled'] : 0,
'#attributes' => array(
'class' => array(
$element_key_class . '-' . $attribute . '-enabled',
),
),
);
$root_element['attributes'][$attribute]['value'] = array(
'#type' => 'textfield',
'#title' => t("<em>@attribute</em> value", array(
'@attribute' => $attribute,
)),
'#default_value' => isset($settings['attributes'][$attribute]['value']) ? $settings['attributes'][$attribute]['value'] : '',
'#states' => array(
'visible' => array(
'.' . $element_key_class . '-' . $attribute . '-enabled' => array(
'checked' => TRUE,
),
),
),
'#description' => t('Value is not required'),
);
}
}