You are here

function linkit_dashboard_form in Linkit 7.2

Same name and namespace in other branches
  1. 7.3 linkit.module \linkit_dashboard_form()

Implements hook_form().

1 string reference to 'linkit_dashboard_form'
_linkit_dashboard in ./linkit.module
Creates the dashboard.

File

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

Code

function linkit_dashboard_form($form, &$form_state) {
  $profile = linkit_get_dashboard_profile();

  // If we do not have a Linkit profile, lets show the user a message.
  if (is_null($profile)) {
    drupal_set_message(t('There is no Linkit profile associated with your role.'), 'warning');
    $form['message'] = array(
      '#markup' => theme('status_messages') . '<a id="linkit-cancel" href="#">' . t('Close') . '</a>',
    );
    return $form;
  }
  $form['linkit_search'] = array(
    '#type' => 'textfield',
    '#title' => t('Search content'),
    '#description' => t('Start typing to find content or paste a URI. Use the arrow keys to navigate.'),
    '#maxlength' => 255,
    '#size' => 60,
    '#default_value' => '',
    '#weight' => -10,
  );

  // The IMCE button is generated with JavaScript, see linkit.js.
  $form['linkit_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Target path'),
    '#description' => t('Examples: <strong>node/123</strong>, <strong>http://www.example.com/path#anchor</strong>'),
    '#required' => TRUE,
    '#maxlength' => NULL,
    '#size' => 60,
    '#default_value' => '',
    '#weight' => -1,
  );
  $enabled_attributes = linkit_get_profile_attributes();

  // If we have enabled attributes, lets put them inside a fieldset.
  if (count($enabled_attributes)) {

    // Create the container fieldset.
    $form['linkit_attributes'] = array(
      '#type' => 'fieldset',
      '#title' => t('Attributes'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#weight' => 10,
    );

    // Append the attributes info the fieldset.
    foreach ($enabled_attributes as $name => $attribute) {

      // Add 'linkit_' prefix to ensure that is uniq.
      $form['linkit_attributes']['linkit_' . $name] = $attribute;
    }
  }
  $form['linkit_insert'] = array(
    '#type' => 'button',
    '#value' => t('Insert link'),
    '#suffix' => '<a id="linkit-cancel" href="#">' . t('Cancel') . '</a>',
    '#weight' => 100,
  );
  return $form;
}