You are here

function legal_preview in Legal 7

Same name and namespace in other branches
  1. 5 legal.module \legal_preview()
  2. 6.8 legal.admin.inc \legal_preview()
  3. 6.7 legal.module \legal_preview()
  4. 7.2 legal.admin.inc \legal_preview()

After build function for legal_administration form.

1 string reference to 'legal_preview'
legal_administration in ./legal.admin.inc
Module settings form.

File

./legal.admin.inc, line 271
Administration UI for the Legal module.

Code

function legal_preview($form, $form_values) {
  switch ($form['display_header']['display']['#value']) {
    case 1:

    // Scroll box (CSS).
    case 2:

      // HTML.
      $form['legal']['conditions'] = array(
        '#markup' => check_markup($form_values['values']['conditions']['value'], $form_values['values']['conditions']['format']),
      );
      $form['legal']['legal_accept']['#title'] = t('<strong>Accept</strong> Terms & Conditions of Use');
      if (module_exists('token')) {
        $form['legal']['conditions']['#markup'] = token_replace($form['legal']['conditions']['#markup']);
      }
      break;
    case 3:

      // Page Link.
      $form['legal']['conditions'] = array(
        '#markup' => '',
      );
      $form['legal']['legal_accept']['#title'] = t('<strong>Accept</strong> <a href="@terms">Terms & Conditions</a> of Use', array(
        '@terms' => url('legal'),
      ));
      break;
    default:

      // Scroll box (HTML).
      $form['legal']['conditions'] = array(
        '#id' => 'preview',
        '#name' => 'preview',
        '#type' => 'textarea',
        '#title' => t('Terms & Conditions'),
        '#value' => check_markup($form_values['values']['conditions']['value'], $form_values['values']['conditions']['format']),
        '#parents' => array(
          'legal',
        ),
        '#rows' => 10,
        '#attributes' => array(
          'readonly' => 'readonly',
        ),
      );
      $form['legal']['legal_accept']['#title'] = t('<strong>Accept</strong> Terms & Conditions of Use');
      if (module_exists('token')) {
        $form['legal']['conditions']['#value'] = token_replace($form['legal']['conditions']['#value']);
      }
  }

  // Overide additional checkboxes in preview.
  if (!empty($form_values['extras'])) {
    foreach ($form_values['extras'] as $key => $label) {
      if (empty($label)) {
        unset($form['legal'][$key]);
      }
      else {
        $form['legal'][$key]['#title'] = filter_xss_admin($label);
      }
    }
  }
  return $form;
}