You are here

function ad_text_node_form in Advertisement 6

Same name and namespace in other branches
  1. 5.2 text/ad_text.module \ad_text_node_form()
  2. 5 text/ad_text.module \ad_text_node_form()
  3. 6.3 text/ad_text.module \ad_text_node_form()
  4. 6.2 text/ad_text.module \ad_text_node_form()

Adapi helper function for displaying a node form.

1 call to ad_text_node_form()
ad_text_adapi in text/ad_text.module
Implementation of hook_adapi().

File

text/ad_text.module, line 243
Enhances the ad module to support static text ads.

Code

function ad_text_node_form(&$node) {
  $form = array();
  $form['ad_text'] = array(
    '#type' => 'fieldset',
    '#title' => t('Text'),
    '#collapsible' => TRUE,
  );
  if (ad_adaccess($node, 'manage ad text') || arg(1) == 'add' && user_access('create advertisements')) {
    $access = TRUE;
  }
  else {
    $access = FALSE;
    $form['ad_text']['notice'] = array(
      '#type' => 'markup',
      '#value' => '<p>' . t('You do not have permission to edit this advertisement.') . '</p>',
    );
  }
  $form['ad_text']['text'] = array(
    '#type' => 'markup',
    '#value' => ad_text_display_ad($node),
  );
  $form['ad_text']['url'] = array(
    '#type' => 'textfield',
    '#title' => t('Destination URL'),
    '#maxlength' => 255,
    '#default_value' => isset($node->url) ? $node->url : '',
    '#description' => t('Enter the complete URL where you want people to be redirected when they click on this advertisement.  The URL must be valid and begin with http:// or https://, for example %url, unless you !disable.  If you do not enter a URL, the advertisement will not be clickable.', array(
      '%url' => t('http://www.sample.org/'),
      '!disable' => l(t('disable URL validation'), 'admin/content/ad/configure', array(
        'fragment' => 'edit-ad-validate-url-wrapper',
      )),
    )),
    '#disabled' => !$access,
  );
  $form['ad_text']['adheader'] = array(
    '#type' => 'textfield',
    '#title' => t('Ad header'),
    '#required' => $access,
    '#default_value' => isset($node->adheader) ? $node->adheader : '',
    '#description' => t('This is the first line of the ad which will be linked to the URL entered above.'),
    '#disabled' => !$access,
  );
  $form['ad_text']['adbody'] = array(
    '#type' => 'textarea',
    '#title' => t('Ad body'),
    '#required' => $access,
    '#default_value' => isset($node->adbody) ? $node->adbody : '',
    '#description' => t('This is the rest of the ad.'),
    '#disabled' => !$access,
  );
  return $form;
}