You are here

function dynamic_banner_admin_form in Dynamic Banner 6

Same name and namespace in other branches
  1. 7.2 dynamic_banner.module \dynamic_banner_admin_form()
  2. 7 includes/callbacks.inc \dynamic_banner_admin_form()
  3. 8.x dynamic_banner.module \dynamic_banner_admin_form()

Return a form for editing or creating an individual Banner

ingroup forms see path_admin_form_validate() see path_admin_form_submit()

1 string reference to 'dynamic_banner_admin_form'
dynamic_banner_menu in ./dynamic_banner.module
Implements hook_menu().

File

includes/callbacks.inc, line 144
Dynamic Banner Admin Pages and various other functions to make them work Most of the code in this file was derived from path module

Code

function dynamic_banner_admin_form(&$form_state, $dbid = NULL) {
  $form['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Existing system path'),
    '#maxlength' => 128,
    '#size' => 45,
    '#description' => t('Specify the existing path you wish to
      put a banner on. For example: home, user* (wild card), content! (random).'),
    '#field_prefix' => url(NULL, array(
      'absolute' => TRUE,
    )) . (variable_get('clean_url', 0) ? '' : '?q='),
    '#required' => TRUE,
  );
  $form['imgurl'] = array(
    '#type' => 'textfield',
    '#title' => t('Image Url'),
    '#maxlength' => 128,
    '#size' => 45,
    '#description' => t('Specify the path to the image.
      Starting from the root site directory(comma seperated for randoms).'),
    '#field_prefix' => url(NULL, array(
      'absolute' => TRUE,
    )) . (variable_get('clean_url', 0) ? '' : '?q='),
    '#required' => TRUE,
  );
  $form['text'] = array(
    '#type' => 'textfield',
    '#title' => t('Text'),
    '#maxlength' => 128,
    '#size' => 45,
    '#description' => t('Specify the text to associate with this
      banner (comma seperated for randoms) (also must match amount
      of elements from images). --optional--'),
    '#required' => FALSE,
  );
  $form['link'] = array(
    '#type' => 'textfield',
    '#title' => t('Link'),
    '#maxlength' => 128,
    '#size' => 45,
    '#description' => t('Specify the link you want your banner
      to point to. --optional--'),
    '#field_prefix' => url(NULL, array(
      'absolute' => TRUE,
    )) . (variable_get('clean_url', 0) ? '' : '?q='),
    '#required' => FALSE,
  );

  // update or creation of banners
  if (isset($dbid) && ($banner_edit = _dynamic_banner_load($dbid))) {
    $form['path']['#default_value'] = $banner_edit['path'];
    $form['imgurl']['#default_value'] = $banner_edit['imgurl'];
    $form['text']['#default_value'] = $banner_edit['text'];
    $form['link']['#default_value'] = $banner_edit['link'];
    $form['dbid'] = array(
      '#type' => 'hidden',
      '#value' => $dbid,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Update Banner'),
    );
  }
  else {
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Create a new Banner'),
    );
  }
  return $form;
}