function messaging_template_admin_message_form in Messaging 6.4
Edit message formats
1 string reference to 'messaging_template_admin_message_form'
- messaging_template_admin_template_edit in messaging_template/
messaging_template.admin.inc - Message groups edit page
File
- messaging_template/
messaging_template.admin.inc, line 162 - Messaging Framework - Admin UI
Code
function messaging_template_admin_message_form($form_state, $group_info, $language) {
$group = $group_info['group'];
$form['group'] = array(
'#type' => 'value',
'#value' => $group,
);
$form['language'] = array(
'#type' => 'value',
'#value' => $language,
);
$form['module'] = array(
'#type' => 'value',
'#value' => isset($group_info['module']) ? $group_info['module'] : '',
);
$keylist = module_invoke_all('messaging', 'message keys', $group, $language);
$send_methods = array(
'default' => t('Default'),
);
$send_methods += messaging_method_list();
$form['messages'] = array(
'#tree' => TRUE,
);
// Get list of allowed filter formats for this user
$formats_all = _messaging_template_filter_formats(TRUE);
$formats_allowed = _messaging_template_filter_formats(FALSE);
foreach ($send_methods as $method => $methodname) {
// Get all texts for this group/method/language
$texts = messaging_template_message_part($group, NULL, $method, $language, FALSE);
$form['messages'][$method] = array(
'#type' => 'fieldset',
'#title' => $methodname,
'#collapsible' => TRUE,
'#collapsed' => $texts ? FALSE : TRUE,
);
foreach ($keylist as $key => $keyname) {
$elements = array(
'#title' => $keyname,
'#type' => 'fieldset',
'#attributes' => array(
'class' => 'messaging-template-part',
),
);
$part = isset($texts[$key]) ? $texts[$key] : NULL;
$text = $part ? $part->message : '';
$format = $part && !empty($part->format) ? $part->format : 0;
// Check access to input format and format the form accordingly
$enabled = isset($formats_allowed[$format]);
$elements['enabled'] = array(
'#type' => 'value',
'#value' => $enabled,
);
$elements['tpid'] = array(
'#type' => 'value',
'#value' => $part && isset($part->tpid) ? $part->tpid : 0,
);
//$elements['title']['#value'] = $keyname;
// Filter format, if disabled just show this one
$elements['format'] = array(
'#title' => t('Format'),
'#type' => 'select',
'#default_value' => $format,
'#options' => $enabled ? $formats_allowed : $formats_all,
'#disabled' => !$enabled,
//'#prefix' => '<div class="text-part-header">',
'#prefix' => '<div class="format-select">',
'#suffix' => '</div>',
);
/*
$elements['title'] = array(
//'#prefix' => '<div class="text-part-header">',
'#value' => '<span><strong>' . $keyname . '</strong></span>',
'#suffix' => '</div>',
);
*/
$elements['message'] = array(
'#type' => 'textarea',
'#default_value' => $text,
// Adjust size to actual number of lines
'#rows' => count(explode("\n", $text)),
'#disabled' => !$enabled,
);
$form['messages'][$method][$key] = $elements;
}
}
// Tokens for text replacement
if ($tokens = messaging_template_tokens_get_list($group)) {
$headers = array(
t('Token'),
t('Replacement value'),
);
$rows = array();
foreach ($tokens as $token => $token_description) {
$row = array();
$row[] = '[' . $token . ']';
$row[] = $token_description;
$rows[] = $row;
}
$form['tokens'] = array(
'#title' => t('Available tokens'),
'#type' => 'fieldset',
'#description' => t('These special strings will be replaced by their real value at run time.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['tokens']['list'] = array(
'#value' => theme('table', $headers, $rows, array(
'class' => 'description',
)),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
$form['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset to defaults'),
);
return $form;
}