You are here

public function ActivityActionHandler::messagesForm in Activity 7

Display the token message form.

Parameters

&$form: The FAPI form.

$form_state: The state of the form.

File

./activity_action_handlers.inc, line 161

Class

ActivityActionHandler

Code

public function messagesForm(&$form, $form_state) {
  $messages = $this
    ->messages() + array(
    'public' => array(
      'title' => 'Public Message',
      'description' => 'Message displayed to everyone who is not a part of this Activity',
    ),
  );
  foreach (activity_enabled_languages() as $id => $language) {
    $form[$id] = array(
      '#type' => 'fieldset',
      '#title' => t('@name messages', array(
        '@name' => $language->name,
      )),
    );
    foreach ($messages as $object_key => $information) {
      $current_message = '';
      if (isset($this->templates[$id]) && isset($this->templates[$id][$object_key])) {
        $current_message = $this->templates[$id][$object_key];
      }
      $form[$id][$object_key] = array(
        '#type' => 'textarea',
        '#title' => t($information['title']),
        '#description' => t($information['description']),
        '#default_value' => $current_message,
      );
    }
  }

  // The token.module provides the UI for the tokens. While not required,
  // it adds a nice UI.
  if (module_exists('token')) {
    $form['token_help'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array_keys($messages),
    );
  }
}