public function SiteBannerContextReactionChangeBannerText::options_form in Site Banner 7
Administration panel for setting banner text for selected contexts.
Overrides context_reaction::options_form
File
- ./
site_banner_context_reaction_functions.inc, line 60
Class
- SiteBannerContextReactionChangeBannerText
- Handle changing the site banner text reaction.
Code
public function options_form($context) {
$default_prepend_text = site_banner_get_prepend_site_banner_text($context);
$default_banner_text = site_banner_get_site_banner_text($context);
$default_delimiter_text = site_banner_get_delimiter($context);
$default_append_text = site_banner_get_append_text($context);
// Get all enabled contexts and provide help on existing context values.
$prepend_text_description = 'For all contexts tagged with this context\'s
tag, this is text that will be added before all active context\'s
banner text.';
$delimiter_text_description = 'For all contexts tagged with this context\'s
tag, this is text that will be added in between successive banner texts.
This is typically a single character like a backslash \'\\\' or comma
\',\'.';
$append_text_description = 'For all contexts tagged with this context\'s
tag, this is text that will be added after all active context\'s
banner text.';
$prepend_examples = '';
$delimiter_examples = '';
$append_examples = '';
foreach (context_enabled_contexts() as $context_iterator) {
if (isset($context_iterator->tag) && !empty($context_iterator->tag)) {
$prefix = "{$context_iterator->name} (tag = {$context_iterator->tag},";
$prepend_examples = " {$prefix} prepend text = " . filter_xss_admin(site_banner_get_prepend_site_banner_text($context_iterator)) . ')';
$delimiter_examples = " {$prefix} delimiter text = " . filter_xss_admin(site_banner_get_delimiter($context_iterator)) . ')';
$append_examples = " {$prefix} append text = " . filter_xss_admin(site_banner_get_append_text($context_iterator)) . ')';
}
}
if (!empty($prepend_examples)) {
$prepend_text_description .= " Existing values are: {$prepend_examples}.";
$append_text_description .= " Existing values are: {$append_examples}.";
$delimiter_text_description .= " Existing values are: {$delimiter_examples}.";
}
$form = site_banner_generate_banner_text_form_elements($default_banner_text);
$form['site_banner_tag_prepend_text'] = array(
'#title' => t('Prepended banner text'),
'#description' => $prepend_text_description,
'#type' => 'textfield',
'#size' => 50,
'#maxlength' => 100,
'#default_value' => $default_prepend_text,
);
$form['site_banner_text']['#description'] = t('The text to be added to the site banner.');
$form['site_banner_tag_delimiter_text'] = array(
'#title' => t('Banner text delimiter'),
'#description' => $delimiter_text_description,
'#type' => 'textfield',
'#size' => 50,
'#maxlength' => 100,
'#default_value' => $default_delimiter_text,
);
$form['site_banner_tag_append_text'] = array(
'#title' => t('Appended banner text'),
'#description' => $append_text_description,
'#type' => 'textfield',
'#size' => 50,
'#maxlength' => 100,
'#default_value' => $default_append_text,
);
return $form;
}