You are here

function recently_read_settings in Recently Read 7.3

Same name and namespace in other branches
  1. 6 recently_read.module \recently_read_settings()
  2. 7 recently_read.module \recently_read_settings()
  3. 7.2 recently_read.admin.inc \recently_read_settings()

Form builder; Configure recently read settings.

1 string reference to 'recently_read_settings'
recently_read_menu in ./recently_read.module
Implements hook_menu().

File

./recently_read.module, line 87
Recently read module file. Displays a history of recently read entities.

Code

function recently_read_settings($form, &$form_state) {
  $entities = entity_get_info();
  $form['#tree'] = TRUE;
  $form['rr_config'] = array(
    '#type' => 'fieldset',
    '#title' => t('Recently Read Config'),
  );
  $form['rr_config']['session_api_cfg'] = array(
    '#markup' => t('First, goto !link to config the session api Cookie expire time.', array(
      '!link' => l('Session Api', 'admin/config/development/session-api'),
    )),
  );
  $config = variable_get('rr_config', array());
  foreach ($entities as $entity_type => $entity) {
    if (!empty($entity['view modes']) && entity_type_supports($entity_type, 'view')) {
      $form['rr_config'][$entity_type] = array(
        '#type' => 'fieldset',
        '#title' => t('Recently Read ' . $entity['label'] . ' config'),
      );
      $form['rr_config'][$entity_type]['enable'] = array(
        '#type' => 'checkbox',
        '#title' => t('Enable'),
        '#default_value' => isset($config[$entity_type]['enable']) ? $config[$entity_type]['enable'] : FALSE,
      );
      $form['rr_config'][$entity_type]['max_record'] = array(
        '#type' => 'textfield',
        '#title' => t('Max Record for Recently Read @entity', array(
          '@entity' => $entity['label'],
        )),
        '#default_value' => isset($config[$entity_type]['max_record']) ? $config[$entity_type]['max_record'] : 10,
      );
      $form['rr_config'][$entity_type]['view_mode'] = array(
        '#type' => 'checkboxes',
        '#title' => t('View mode for track'),
        '#default_value' => isset($config[$entity_type]['view_mode']) ? $config[$entity_type]['view_mode'] : array(
          'full' => 'full',
        ),
        '#options' => isset($entity['view modes']) ? drupal_map_assoc(array_keys($entity['view modes'])) : array(),
      );
    }
  }
  return system_settings_form($form);
}