function _semantic_panels_form_element_link in Semantic Panels 7
Same name and namespace in other branches
- 7.2 plugins/styles/semantic_panels.inc \_semantic_panels_form_element_link()
1 call to _semantic_panels_form_element_link()
- _semantic_panels_form_element in plugins/
styles/ semantic_panels.inc
File
- plugins/
styles/ semantic_panels.inc, line 247
Code
function _semantic_panels_form_element_link(&$root_element, $settings, $element_key, $display) {
$element_key_class = str_replace('_', '-', $element_key);
$root_element[$element_key]['link_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Output as link'),
'#default_value' => isset($settings[$element_key]['link_enabled']) ? $settings[$element_key]['link_enabled'] : 0,
'#attributes' => array(
'class' => array(
$element_key_class . '-link-enabled',
),
),
);
$root_element[$element_key]['link'] = array(
'#type' => 'fieldset',
'#title' => 'Link options',
'#states' => array(
'visible' => array(
'.' . $element_key_class . '-link-enabled' => array(
'checked' => TRUE,
),
),
),
);
$root_element[$element_key]['link']['path'] = array(
'#type' => 'textfield',
'#title' => t('Link path'),
'#default_value' => isset($settings[$element_key]['link']['path']) ? $settings[$element_key]['link']['path'] : '',
'#description' => t('The Drupal path or absolute URL for this link.'),
);
if (module_exists('token')) {
$root_element[$element_key]['link']['contexts'] = array(
'#title' => t('Substitutions'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$tokens_types = array();
if (isset($display->context) && !empty($display->context)) {
$tokens_types = array_map('_semantic_panels_context_token_types_map', $display->context);
}
$root_element[$element_key]['link']['contexts']['tokens']['help'] = array(
'#theme' => 'token_tree',
'#token_types' => $tokens_types,
'#dialog' => TRUE,
'#options' => array(),
);
// Add custom css to ensure the token dialog is visible.
$root_element['#attached']['css'][] = drupal_get_path('module', 'semantic_panels') . '/plugins/styles/semantic_panels_dialog.css';
if (!empty($tokens_types)) {
$root_element[$element_key]['link']['path']['#description'] .= ' ' . t('You may access panel context(s) keywords and other tokens from the <em>Substitutions</em> below.');
}
else {
$root_element[$element_key]['link']['path']['#description'] .= ' ' . t('If you add context(s) to this panel you may access their keywords from the <em>Substitutions</em> below.');
}
}
else {
$root_element[$element_key]['link']['path']['#description'] .= ' ' . t('Enable token module to access panel context(s) keywords and other tokens.');
}
_semantic_panels_form_element_attributes($root_element, $settings, array(
$element_key,
'link',
));
}