You are here

function messaging_admin_message_form in Messaging 5

Same name and namespace in other branches
  1. 6 messaging.admin.inc \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_message_edit in ./messaging.module
Message groups edit page

File

./messaging.module, line 191

Code

function messaging_admin_message_form($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;
}