You are here

function LinkitSearchPluginEntity::buildSettingsForm in Linkit 7.3

Overrides LinkitSearchPlugin::buildSettingsForm().

Overrides LinkitSearchPlugin::buildSettingsForm

3 calls to LinkitSearchPluginEntity::buildSettingsForm()
LinkitSearchPluginFile::buildSettingsForm in plugins/linkit_search/file.class.php
Overrides LinkitSearchPluginEntity::buildSettingsForm().
LinkitSearchPluginNode::buildSettingsForm in plugins/linkit_search/node.class.php
Overrides LinkitSearchPlugin::buildSettingsForm().
LinkitSearchPluginTaxonomy_term::buildSettingsForm in plugins/linkit_search/taxonomy_term.class.php
Overrides LinkitSearchPlugin::buildSettingsForm().
3 methods override LinkitSearchPluginEntity::buildSettingsForm()
LinkitSearchPluginFile::buildSettingsForm in plugins/linkit_search/file.class.php
Overrides LinkitSearchPluginEntity::buildSettingsForm().
LinkitSearchPluginNode::buildSettingsForm in plugins/linkit_search/node.class.php
Overrides LinkitSearchPlugin::buildSettingsForm().
LinkitSearchPluginTaxonomy_term::buildSettingsForm in plugins/linkit_search/taxonomy_term.class.php
Overrides LinkitSearchPlugin::buildSettingsForm().

File

plugins/linkit_search/entity.class.php, line 263
Define Linkit entity search plugin class.

Class

LinkitSearchPluginEntity
Represents a Linkit entity search 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[search_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 within the search result for each row.
  $form[$this->plugin['name']]['result_description'] = array(
    '#title' => t('Result description'),
    '#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 do 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' => 'markup',
    );
    $form[$this->plugin['name']]['token_help']['help'] = array(
      '#theme' => 'token_tree_link',
      '#token_types' => array(
        $this->plugin['entity_type'],
      ),
    );
  }

  // If there are 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,
    );
  }
  return $form;
}