You are here

printfriendly.admin.inc in PrintFriendly & PDF 7.2

Administrative page callbacks for Service Links module.

File

printfriendly.admin.inc
View source
<?php

/**
 * @file
 * Administrative page callbacks for Service Links module.
 */

/**
 * Menu callback administration settings for general options.
 */
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_',
        ),
      ),
    ),
  );
  $print_settings = variable_get('printfriendly_options', array(
    'pfdisableClickToDel' => 0,
    'pfHideImages' => 0,
    'pfImageDisplayStyle' => 'right',
    'pfDisableEmail' => 0,
    'pfDisablePDF' => 0,
    'pfDisablePrint' => 0,
  ));
  $options = array(
    'allow' => array(
      0 => t('Allow'),
      1 => t('Not Allow'),
    ),
    'include' => array(
      0 => t('Include'),
      1 => t('Exclude'),
    ),
    'align' => array(
      'right' => t('Align Right'),
      'left' => t('Align Left'),
      'none' => t('Align None'),
      'block' => t('Center/Block'),
    ),
  );
  $settings = array(
    1 => array(
      t('Click-to-delete'),
      'pfdisableClickToDel',
      'allow',
    ),
    3 => array(
      t('Images'),
      'pfHideImages',
      'include',
    ),
    5 => array(
      t('Image style'),
      'pfImageDisplayStyle',
      'align',
    ),
    7 => array(
      t('Email'),
      'pfDisableEmail',
      'allow',
    ),
    9 => array(
      t('PDF'),
      'pfDisablePDF',
      'allow',
    ),
    11 => array(
      t('Print'),
      'pfDisablePrint',
      'allow',
    ),
  );
  $form['printfriendly_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Print & PDF options'),
    '#tree' => TRUE,
    '#collapsible' => TRUE,
  );
  foreach ($settings as $weight => $setting_item) {
    $form['printfriendly_options'][$setting_item[1]] = array(
      '#type' => 'select',
      '#weight' => $weight,
      '#title' => $setting_item[0],
      '#options' => $options[$setting_item[2]],
      '#required' => TRUE,
      '#default_value' => $print_settings[$setting_item[1]],
    );
  }
  $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);
}

Functions

Namesort descending Description
printfriendly_admin_settings Menu callback administration settings for general options.