You are here

function messaging_admin_message_form in Messaging 6

Same name and namespace in other branches
  1. 5 messaging.module \messaging_admin_message_form()
  2. 6.2 messaging.admin.inc \messaging_admin_message_form()
  3. 6.3 messaging.admin.inc \messaging_admin_message_form()

Edit message formats

1 string reference to 'messaging_admin_message_form'
messaging_admin_template_edit in ./messaging.admin.inc
Message groups edit page

File

./messaging.admin.inc, line 127
Messaging Framework - Admin UI

Code

function messaging_admin_message_form($form_state, $group, $group_info) {
  $form['group'] = array(
    '#type' => 'value',
    '#value' => $group,
  );
  $keylist = module_invoke_all('messaging', 'message keys', $group);
  $send_methods = array(
    'default' => t('Default'),
  );
  $send_methods += messaging_method_list();
  $form['messages'] = array(
    '#tree' => TRUE,
  );
  foreach ($keylist as $key => $keyname) {
    $form['messages'][$key] = array(
      '#type' => 'fieldset',
      '#title' => $keyname,
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    foreach ($send_methods as $method => $methodname) {
      $text = messaging_message_part($group, $key, $method, FALSE);
      $form['messages'][$key][$method] = array(
        '#title' => $methodname,
        '#type' => 'textarea',
        '#default_value' => $text,
        // Adjust size to actual number of lines
        '#rows' => count(explode("\n", $text)),
      );
    }
  }

  // Tokens for text replacement
  if ($tokens = messaging_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'),
  );
  return $form;
}