You are here

function printfriendly_admin_settings in PrintFriendly & PDF 7

Same name and namespace in other branches
  1. 7.5 printfriendly.admin.inc \printfriendly_admin_settings()
  2. 7.2 printfriendly.admin.inc \printfriendly_admin_settings()
  3. 7.3 printfriendly.admin.inc \printfriendly_admin_settings()
  4. 7.4 printfriendly.admin.inc \printfriendly_admin_settings()

Menu callback administration settings for general options.

1 string reference to 'printfriendly_admin_settings'
printfriendly_menu in ./printfriendly.module
Implements hook_menu().

File

./printfriendly.admin.inc, line 11
Administrative page callbacks for Service Links module.

Code

function printfriendly_admin_settings() {
  if (substr($_SERVER['REMOTE_ADDR'], 0, 4) == '127.' || $_SERVER['REMOTE_ADDR'] == '::1') {
    drupal_set_message(t('It appears that your site is running on a local
    server. PrintFriendly service requires a remotely-accessible web site
    to function.'), 'warning', FALSE);
  }
  $form['printfriendly_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content Types'),
    '#description' => t('Configure where the printfriendly button should appear.'),
    '#options' => node_type_get_names(),
    '#default_value' => variable_get('printfriendly_types', array()),
  );
  $form['printfriendly_display'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Button display'),
    '#description' => t('Select content displays that the button should appear.'),
    '#options' => array(
      'teaser' => t('Teaser'),
      'full' => t('Full content page'),
    ),
    '#default_value' => array_filter(variable_get('printfriendly_display', array())),
  );
  $img_path = drupal_get_path('module', 'printfriendly') . '/images';
  $results = file_scan_directory($img_path, '/^.*\\.(gif|png|jpg|GIF|PNG|JPG)$/');
  $options = array();
  foreach ($results as $image) {
    $options[$image->filename] = theme('image', array(
      'path' => $image->uri,
    ));
  }
  ksort($options);
  $options['_text_'] = t('Text link');
  $form['printfriendly_image'] = array(
    '#type' => 'radios',
    '#title' => t('Choose button'),
    '#options' => $options,
    '#default_value' => variable_get('printfriendly_image', 'button-print-grnw20.png'),
  );
  $form['printfriendly_text'] = array(
    '#type' => 'textfield',
    '#title' => t('PrintFriendly text link title'),
    '#default_value' => variable_get('printfriendly_text', t('Print this page')),
    '#description' => t('This text will be used instead of the image button. You can further style the link by adding custom CSS.'),
    '#states' => array(
      'visible' => array(
        ':input[name="printfriendly_image"]' => array(
          'value' => '_text_',
        ),
      ),
    ),
  );
  $form['support-link'] = array(
    '#markup' => t('Need help or have suggestions? !support-email.', array(
      '!support-email' => l(t('Support@PrintFriendly.com'), 'mailto:support@printfriendly.com', array(
        'absolute' => TRUE,
        'query' => array(
          'subject' => 'Support for PrintFriendly Drupal module',
        ),
      )),
    )),
    '#weight' => 1000,
  );
  return system_settings_form($form);
}