You are here

function freelinking_nodetitle_settings in Freelinking 6.3

Same name and namespace in other branches
  1. 7.3 plugins/freelinking_nodetitle.inc \freelinking_nodetitle_settings()

Nodetitle Settings Callback

File

plugins/freelinking_nodetitle.inc, line 47

Code

function freelinking_nodetitle_settings() {
  $extra_description = '';

  // Restrict nodetitle plugin to search specified content type
  $form['freelinking_nodetitle_searchcontenttype'] = array(
    '#title' => t('Restrict freelinks to this content type'),
    '#type' => 'select',
    '#options' => array_merge(array(
      'none' => t('No restriction'),
    ), node_get_types('names')),
    '#default_value' => variable_get('freelinking_nodetitle_searchcontenttype', 'none'),
    '#description' => t('Lookup by title to find a freelink will be restricted to this content type only.'),
  );
  $failover_option['none'] = t('Do nothing');
  $failover_option['showtext'] = t('Show text (remove markup)');

  // if Create Node plugin is available, it's an option!
  if (module_exists('freelinking_prepopulate')) {
    $failover_option['create'] = t('Add a link to create content. (Without Permission: Access Denied)');
  }
  else {
    $extra_description = '<br />' . t('Note: Enable the <strong>Freelinking Prepopulate</strong> submodule to add a content creation failover option.');
  }

  // if search is available, have a search failover
  if (module_exists('search')) {
    $failover_option['search'] = t('Add a link to Search Content');
  }
  else {
    $extra_description .= '<br /><strong>' . t('Note: Enable the %module module for internal search option.', array(
      '%module' => 'Search',
    )) . '</strong>';

    // if search is unavailable offer it's own (applicable)search fallback. [Google, etc]
    if (($search_plugin = variable_get('freelinking_search_failover', 'error')) != 'error') {
      $failover_option['search'] = t('Add a link to %search Search Content.', array(
        '%search' => drupal_ucfirst($search_plugin),
      ));
    }
  }
  $failover_option['error'] = t('Insert an error message');
  $form['freelinking_nodetitle_failover'] = array(
    '#title' => t('If a suitable content is not found'),
    '#type' => 'select',
    '#options' => $failover_option,
    '#default_value' => variable_get('freelinking_nodetitle_failover', _freelinking_nodetitle_default_failover()),
    '#description' => t('What should freelinking do when the page is not found?') . $extra_description,
  );
  return $form;
}