You are here

function LinkitPluginEntity::buildSettingsForm in Linkit 7.2

Generate a settings form for this handler. Uses the standard Drupal FAPI. The element will be attached to the "data" key.

Return value

An array containing any custom form elements to be displayed in the profile editing form

Overrides LinkitPlugin::buildSettingsForm

3 calls to LinkitPluginEntity::buildSettingsForm()
LinkitPluginFile::buildSettingsForm in plugins/linkit_plugins/linkit-plugin-file.class.php
Generate a settings form for this handler. Uses the standard Drupal FAPI. The element will be attached to the "data" key.
LinkitPluginNode::buildSettingsForm in plugins/linkit_plugins/linkit-plugin-node.class.php
Generate a settings form for this handler. Uses the standard Drupal FAPI. The element will be attached to the "data" key.
LinkitPluginTaxonomy_Term::buildSettingsForm in plugins/linkit_plugins/linkit-plugin-taxonomy_term.class.php
Settings for the term plugin.
3 methods override LinkitPluginEntity::buildSettingsForm()
LinkitPluginFile::buildSettingsForm in plugins/linkit_plugins/linkit-plugin-file.class.php
Generate a settings form for this handler. Uses the standard Drupal FAPI. The element will be attached to the "data" key.
LinkitPluginNode::buildSettingsForm in plugins/linkit_plugins/linkit-plugin-node.class.php
Generate a settings form for this handler. Uses the standard Drupal FAPI. The element will be attached to the "data" key.
LinkitPluginTaxonomy_Term::buildSettingsForm in plugins/linkit_plugins/linkit-plugin-taxonomy_term.class.php
Settings for the term plugin.

File

plugins/linkit_plugins/linkit-plugin-entity.class.php, line 265
Define Linkit entity plugin.

Class

LinkitPluginEntity
@file Define Linkit entity plugin.

Code

function buildSettingsForm() {
  $form[$this->plugin['name']] = array(
    '#type' => 'fieldset',
    '#title' => t('!type plugin settings', array(
      '!type' => $this
        ->ui_title(),
    )),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#tree' => TRUE,
    '#states' => array(
      'invisible' => array(
        'input[name="data[plugins][' . $this->plugin['name'] . '][enabled]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );

  // Get supported tokens for the entity type.
  $tokens = linkit_extract_tokens($this->plugin['entity_type']);

  // A short description in within the search result for each row.
  $form[$this->plugin['name']]['result_description'] = array(
    '#title' => t('Result format'),
    '#type' => 'textfield',
    '#default_value' => isset($this->conf['result_description']) ? $this->conf['result_description'] : '',
    '#size' => 120,
    '#maxlength' => 255,
    '#description' => t('Available tokens: %tokens.', array(
      '%tokens' => implode(', ', $tokens),
    )),
  );

  // If the token module is installed, lets make some fancy stuff with the
  // token chooser.
  if (module_exists('token')) {

    // Unset the regular description if token module is enabled.
    unset($form[$this->plugin['name']]['result_description']['#description']);

    // Display the user documentation of placeholders.
    $form[$this->plugin['name']]['token_help'] = array(
      '#title' => t('Replacement patterns'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form[$this->plugin['name']]['token_help']['help'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array(
        $this->plugin['entity_type'],
      ),
    );
  }

  // If there is bundles, add some default settings features.
  if (count($this->entity_info['bundles']) > 1) {
    $bundles = array();

    // Extract the bundle data.
    foreach ($this->entity_info['bundles'] as $bundle_name => $bundle) {
      $bundles[$bundle_name] = $bundle['label'];
    }

    // Filter the possible bundles to use if the entity has bundles.
    $form[$this->plugin['name']]['bundles'] = array(
      '#title' => t('Type filter'),
      '#type' => 'checkboxes',
      '#options' => $bundles,
      '#default_value' => isset($this->conf['bundles']) ? $this->conf['bundles'] : array(),
      '#description' => t('If left blank, all types will appear in autocomplete results.'),
    );

    // Group the results with this bundle.
    $form[$this->plugin['name']]['group_by_bundle'] = array(
      '#title' => t('Group by bundle'),
      '#type' => 'checkbox',
      '#default_value' => isset($this->conf['group_by_bundle']) ? $this->conf['group_by_bundle'] : 0,
    );
  }

  // Reverse menu trail.
  $form[$this->plugin['name']]['reverse_menu_trail'] = array(
    '#title' => t('Add reverse menu trail to description'),
    '#type' => 'checkbox',
    '#default_value' => isset($this->conf['reverse_menu_trail']) ? $this->conf['reverse_menu_trail'] : 0,
    '#description' => t('If the result has a menu item its menu trail will be added in reverse in the description.'),
  );
  return $form;
}