You are here

function readmorecontrol_formatting_settings_form in Read More Control 7

2 calls to readmorecontrol_formatting_settings_form()
readmorecontrol_admin_settings_form in ./readmorecontrol.admin.inc
Menu callback to configure the default behaviour of the module.
_readmorecontrol_form_field_ui_display_overview_form_alter in ./readmorecontrol.admin.inc
Internal implementation of hook_form_FORM_ID_alter().

File

./readmorecontrol.admin.inc, line 45
Contains form alter callback bodies.

Code

function readmorecontrol_formatting_settings_form($entity_type, $entity_info, $settings, $key) {
  $subform['#attached']['css'] = array(
    drupal_get_path('module', 'readmorecontrol') . '/readmorecontrol.css',
  );
  $subform['enabled'] = array(
    '#type' => 'radios',
    '#title' => t('Enable custom link processing'),
    '#default_value' => $settings['enabled'],
    '#options' => array(
      'global' => t('Inherit default format settings'),
      'none' => t('Do not modify'),
      'custom' => t('Custom settings'),
    ),
  );
  $states = array(
    'visible' => array(
      ':input[name$="' . $key . '[enabled]"]' => array(
        'value' => 'custom',
      ),
    ),
  );
  $subform['text'] = array(
    '#type' => 'textfield',
    '#title' => t('Link text'),
    '#default_value' => $settings['text'],
    '#states' => $states,
    '#description' => t('Defaults to: "<em>Read more&lt;span class="element-invisible"&gt; about @title&lt;/span&gt;</em>".<br/>Replace "@title with" corresponding token, eg: "[node:title]"'),
    '#attributes' => array(
      'class' => array(
        'readmorecontrol',
      ),
    ),
  );
  $subform['href'] = array(
    '#type' => 'textfield',
    '#title' => t('URL'),
    '#default_value' => $settings['href'],
    '#states' => $states,
    '#prefix' => '<div class="clearfix"><div class="readmorecontrol-inline">',
    '#suffix' => '</div>',
    '#size' => 50,
    '#description' => t('Default links to content. e.g. "<em>node/1</em>".<br/>Use "<em>&lt;none&gt;</em>" to remove link and just show the text.'),
    '#attributes' => array(
      'class' => array(
        'readmorecontrol',
      ),
    ),
  );
  $subform['query'] = array(
    '#type' => 'textfield',
    '#title' => t('Query'),
    '#default_value' => $settings['query'],
    '#states' => $states,
    '#field_prefix' => '&nbsp;?&nbsp;',
    '#prefix' => '<div class="readmorecontrol-inline">',
    '#suffix' => '</div>',
    '#size' => 20,
    '#attributes' => array(
      'class' => array(
        'readmorecontrol',
      ),
    ),
  );
  $subform['fragment'] = array(
    '#type' => 'textfield',
    '#title' => t('Fragment'),
    '#default_value' => $settings['fragment'],
    '#states' => $states,
    '#field_prefix' => '&nbsp;#&nbsp;',
    '#prefix' => '<div class="readmorecontrol-inline">',
    '#suffix' => '</div></div>',
    '#size' => 20,
    '#attributes' => array(
      'class' => array(
        'readmorecontrol',
      ),
    ),
  );
  $subform['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Link title (hover) text'),
    '#default_value' => $settings['title'],
    '#states' => $states,
    '#field_prefix' => 'title = "',
    '#field_suffix' => '"',
    '#attributes' => array(
      'class' => array(
        'readmorecontrol',
      ),
    ),
  );
  $subform['class'] = array(
    '#type' => 'textfield',
    '#title' => t('Additional classes'),
    '#default_value' => $settings['class'],
    '#field_prefix' => 'class = "',
    '#field_suffix' => '"',
    '#states' => $states,
    '#attributes' => array(
      'class' => array(
        'readmorecontrol',
      ),
    ),
  );
  $subform['rel'] = array(
    '#type' => 'textfield',
    '#title' => t('Rel attribute'),
    '#description' => t('When output, this link will have this rel attribute. The most common usage is <a href="http://en.wikipedia.org/wiki/Nofollow">rel=&quot;nofollow&quot;</a> which prevents some search engines from spidering links.'),
    '#default_value' => $settings['rel'],
    '#field_prefix' => 'rel = "',
    '#field_suffix' => '"',
    '#states' => $states,
    '#attributes' => array(
      'class' => array(
        'readmorecontrol',
      ),
    ),
  );
  $subform['target'] = array(
    '#type' => 'radios',
    '#title' => t('Link target'),
    '#default_value' => $settings['target'],
    '#options' => array(
      '' => t('Default (no target attribute)'),
      '_blank' => t('Opens the linked document in a new window or tab'),
      '_top' => t('Opens the linked document in the top window frame'),
    ),
    '#states' => $states,
  );
  $subform['placement'] = array(
    '#type' => 'radios',
    '#title' => t('Link placement'),
    '#options' => array(
      'none' => t("Don't move (rendered in links element)"),
      'body_inline' => t('Inline on body field'),
      'body_append' => t('Append on new line after body field'),
      'text_inline' => t('Inline on final long text field'),
      'text_append' => t('Append on new line after final long text field'),
      'field_inline' => t('Inline on final field'),
      'field_append' => t('Append on new line after final field'),
      'append' => t('Append on new line after final field or addition field'),
    ),
    '#default_value' => $settings['placement'],
    '#states' => $states,
  );
  $subform['help'] = array(
    '#type' => 'fieldset',
    '#title' => t('Help'),
    '#states' => $states,
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $subform['help']['general'] = array(
    '#markup' => t('<p>Leave fields empty to use the system defaults. Tokens can be used in all text fields for the current %entity.</p>', array(
      '%entity' => $entity_info['label'],
    )),
  );
  if (module_exists('token')) {
    $subform['help']['tokens'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array(
        $entity_type,
      ),
      '#recursion_limit' => 2,
    );
  }
  return $subform;
}