You are here

function _linkit_form in Linkit 7

Same name and namespace in other branches
  1. 6 linkit.module \_linkit_form()
1 string reference to '_linkit_form'
linkit_dashboard_page in ./linkit.module
Creates the dashboard.

File

./linkit.module, line 244
Main file for linkit module.

Code

function _linkit_form() {

  // Check if we have IMCE and access to it.
  $imce = module_invoke('imce', 'access');
  $form['link'] = array(
    '#type' => 'fieldset',
    '#title' => '',
    '#weight' => 0,
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#attributes' => array(
      'class' => array(
        'clearfix',
      ),
    ),
  );
  $form['link']['link'] = array(
    '#type' => 'textfield',
    '#title' => t('Link to'),
    '#description' => t('Search for your internal content <b>OR</b> type the URL (http://www.example.com)'),
    '#maxlength' => 255,
    '#size' => 80,
    '#autocomplete_path' => 'linkit/autocomplete',
    '#default_value' => '',
    '#weight' => 1,
  );
  if ($imce) {
    $imcebutton = array(
      '#type' => 'button',
      '#value' => t('Browse server'),
      '#name' => 'linkit-imce',
      '#id' => 'linkit-imce',
    );

    // Add extra class to edit-link field when we can use IMCE
    $form['link']['link']['#attributes'] = array(
      'class' => array(
        'with_imce',
      ),
    );

    // Add the imce buttom
    $form['link']['link']['#field_suffix'] = drupal_render($imcebutton);
  }
  $form['link']['attributes'] = array(
    '#type' => 'fieldset',
    '#title' => t('Attributes'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#attributes' => array(
      'class' => array(
        'clearfix',
      ),
    ),
    '#weight' => 2,
  );
  $form['link']['attributes']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#maxlength' => 255,
    '#size' => 40,
    '#default_value' => '',
    '#weight' => 0,
  );
  $form['link']['attributes']['id'] = array(
    '#type' => 'textfield',
    '#title' => t('ID'),
    '#maxlength' => 255,
    '#size' => 40,
    '#default_value' => '',
    '#weight' => 1,
  );
  $form['link']['attributes']['class'] = array(
    '#type' => 'textfield',
    '#title' => t('Class'),
    '#maxlength' => 255,
    '#size' => 40,
    '#default_value' => '',
    '#weight' => 2,
  );
  $form['link']['attributes']['rel'] = array(
    '#type' => 'textfield',
    '#title' => t('Rel'),
    '#maxlength' => 255,
    '#size' => 40,
    '#default_value' => '',
    '#weight' => 3,
  );
  $form['link']['attributes']['accesskey'] = array(
    '#type' => 'textfield',
    '#title' => t('Accesskey'),
    '#maxlength' => 255,
    '#size' => 40,
    '#default_value' => '',
    '#weight' => 4,
  );
  $form['link']['attributes']['anchor'] = array(
    '#type' => 'textfield',
    '#title' => t('Anchor'),
    '#maxlength' => 255,
    '#size' => 40,
    '#default_value' => '',
    '#weight' => 5,
    '#description' => t('Without the hash (#)'),
  );
  $form['link']['cancel'] = array(
    '#type' => 'button',
    '#value' => t('Cancel'),
    '#weight' => 10,
  );
  $form['link']['insert'] = array(
    '#type' => 'button',
    '#value' => t('Insert'),
    '#weight' => 11,
  );
  return $form;
}