You are here

function freelinking_nodetitle_settings in Freelinking 7.3

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

Nodetitle Settings Callback

File

plugins/freelinking_nodetitle.inc, line 60

Code

function freelinking_nodetitle_settings() {

  // Restrict nodetitle plugin to search specified content type
  $form['freelinking_nodetitle_linkcontenttype'] = array(
    '#title' => t('Only link to nodes belonging to the following content types:'),
    '#type' => 'checkboxes',
    '#options' => node_type_get_names(),
    '#default_value' => variable_get('freelinking_nodetitle_linkcontenttype', array()),
    '#description' => t('Lookup by title to will be restricted to this content type or these content types.'),
  );
  $failover_option['none'] = t('Do nothing');
  $failover_option['showtext'] = t('Show text (remove markup)');
  $extra_description = '';

  // 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;
}