Commit 0c1fab80 authored by jcnventura's avatar jcnventura

Unify the link admin settings.

Separate each pdf lib settings into sub-pages.
parent b4f03de7
......@@ -205,86 +205,6 @@ function print_html_settings() {
'#description' => t('Text used in the link to the printer-friendly version.'),
);
$form['settings']['print_html_link_pos'] = array(
'#type' => 'checkboxes',
'#title' => t('Printer-friendly page link'),
'#default_value' => variable_get('print_html_link_pos', array(PRINT_HTML_LINK_POS_DEFAULT => PRINT_HTML_LINK_POS_DEFAULT)),
'#options' => array('link' => t('Links area'), 'corner' => t('Content corner')),
'#description' => t('Choose the location of the link(s) to the printer-friendly page. The Links area is usually below the node content, whereas the Content corner is placed in the upper-right corner of the node content. Unselect all options to disable the link. Even if the link is disabled, you can still view the print version of a node by going to !path/nid where nid is the numeric id of the node.', array('!path' => PRINT_PATH)),
);
$form['settings']['print_html_link_teaser'] = array(
'#type' => 'checkbox',
'#title' => t('Display printer-friendly link in teaser'),
'#default_value' => variable_get('print_html_link_teaser', PRINT_HTML_LINK_TEASER_DEFAULT),
'#description' => t('Enabling this will display the link in teaser mode.'),
);
$form['settings']['adv_link'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced link options'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['settings']['adv_link']['print_html_show_link'] = array(
'#type' => 'radios',
'#title' => t('Link style'),
'#default_value' => variable_get('print_html_show_link', PRINT_HTML_SHOW_LINK_DEFAULT),
'#options' => array(1 => t('Text only'), 2 => t('Icon only'), 3 => t('Icon and Text')),
'#description' => t('Select the visual style of the link.'),
);
$form['settings']['adv_link']['print_html_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
'#default_value' => variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT),
'#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
);
$form['settings']['adv_link']['print_html_link_class'] = array(
'#type' => 'textfield',
'#title' => t('Link class'),
'#default_value' => variable_get('print_html_link_class', PRINT_HTML_LINK_CLASS_DEFAULT),
'#size' => 60,
'#maxlength' => 250,
'#description' => t('This can be used by themers to change the link style or by jQuery modules to open in a new window (e.g. greybox or thickbox). Multiple classes can be specified, separated by spaces.'),
);
$form['settings']['adv_link']['print_html_sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
'#description' => 'Any page that is not a Drupal node. Usually pages generated by Drupal or a module such as Views or Panels.',
'#default_value' => variable_get('print_html_sys_link_visibility', PRINT_HTML_SYS_LINK_VISIBILITY_DEFAULT),
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['settings']['adv_link']['print_html_sys_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => variable_get('print_html_sys_link_pages', PRINT_HTML_SYS_LINK_PAGES_DEFAULT),
'#rows' => 3,
'#description' => t('Setting this option will add a printer-friendly version page link on pages created by Drupal or the enabled modules.') . '<br />' .
t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
if (module_exists('php')) {
if ($form['settings']['adv_link']['print_html_sys_link_visibility']['#default_value'] == 2 && !$access) {
$form['settings']['adv_link']['print_html_sys_link_visibility'] = array('#type' => 'value', '#value' => 2);
$form['settings']['adv_link']['print_html_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_html_sys_link_pages']['#default_value']);
}
elseif ($access) {
$form['settings']['adv_link']['print_html_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$form['settings']['adv_link']['print_html_sys_link_pages']['#description'] .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
}
}
$form['settings']['adv_link']['print_html_book_link'] = array(
'#type' => 'radios',
'#title' => t('Link in book hierarchy nodes'),
'#default_value' => variable_get('print_html_book_link', PRINT_HTML_BOOK_LINK_DEFAULT),
'#options' => array(t('Book module link not modified'), t('Current page and sub-pages'), t('Current page only')),
);
$form['settings']['print_html_new_window'] = array(
'#type' => 'checkbox',
'#title' => t('Open the printer-friendly version in a new window'),
......@@ -317,7 +237,7 @@ function print_html_settings() {
'#type' => 'fieldset',
'#title' => t('Robots META tags'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#collapsed' => FALSE,
);
$form['settings']['print_robots_settings']['print_robots_noindex'] = array(
......
......@@ -31,86 +31,6 @@ function print_mail_settings() {
'#description' => t('Text used in the link to the send by-email form.'),
);
$form['settings']['print_mail_link_pos'] = array(
'#type' => 'checkboxes',
'#title' => t('Send by email link'),
'#default_value' => variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT)),
'#options' => array('link' => t('Links area'), 'corner' => t('Content corner')),
'#description' => t('Choose the location of the link(s) to the send by email page. The Links area is usually below the node content, whereas the Content corner is placed in the upper-right corner of the node content. Unselect all options to disable the link. Even if the link is disabled, you can still send a node by email by going to !path/nid where nid is the numeric id of the node.', array('!path' => PRINTMAIL_PATH)),
);
$form['settings']['print_mail_link_teaser'] = array(
'#type' => 'checkbox',
'#title' => t('Display send by email link in teaser'),
'#default_value' => variable_get('print_mail_link_teaser', PRINT_MAIL_LINK_TEASER_DEFAULT),
'#description' => t('Enabling this will display the link in teaser mode.'),
);
$form['settings']['adv_link'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced link options'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['settings']['adv_link']['print_mail_show_link'] = array(
'#type' => 'radios',
'#title' => t('Link style'),
'#default_value' => variable_get('print_mail_show_link', PRINT_MAIL_SHOW_LINK_DEFAULT),
'#options' => array(1 => t('Text only'), 2 => t('Icon only'), 3 => t('Icon and Text')),
'#description' => t('Select the visual style of the link.'),
);
$form['settings']['adv_link']['print_mail_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
'#default_value' => variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT),
'#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
);
$form['settings']['adv_link']['print_mail_link_class'] = array(
'#type' => 'textfield',
'#title' => t('Link class'),
'#default_value' => variable_get('print_mail_link_class', PRINT_MAIL_LINK_CLASS_DEFAULT),
'#size' => 60,
'#maxlength' => 250,
'#description' => t('This can be used by themers to change the link style or by jQuery modules to open in a new window (e.g. greybox or thickbox). Multiple classes can be specified, separated by spaces.'),
);
$form['settings']['adv_link']['print_mail_sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
'#description' => 'Any page that is not a Drupal node. Usually pages generated by Drupal or a module such as Views or Panels.',
'#default_value' => variable_get('print_mail_sys_link_visibility', PRINT_MAIL_SYS_LINK_VISIBILITY_DEFAULT),
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['settings']['adv_link']['print_mail_sys_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => variable_get('print_mail_sys_link_pages', PRINT_MAIL_SYS_LINK_PAGES_DEFAULT),
'#rows' => 3,
'#description' => t('Setting this option will add a send by email link on pages created by Drupal or the enabled modules.') . '<br />' .
t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
if (module_exists('php')) {
if ($form['settings']['adv_link']['print_mail_sys_link_visibility']['#default_value'] == 2 && !$access) {
$form['settings']['adv_link']['print_mail_sys_link_visibility'] = array('#type' => 'value', '#value' => 2);
$form['settings']['adv_link']['print_mail_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_mail_sys_link_pages']['#default_value']);
}
elseif ($access) {
$form['settings']['adv_link']['print_mail_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$form['settings']['adv_link']['print_mail_sys_link_pages']['#description'] .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
}
}
$form['settings']['adv_link']['print_mail_book_link'] = array(
'#type' => 'radios',
'#title' => t('Link in book hierarchy nodes'),
'#default_value' => variable_get('print_mail_book_link', PRINT_MAIL_BOOK_LINK_DEFAULT),
'#options' => array(t('No link'), t('Current page and sub-pages'), t('Current page only')),
);
$form['settings']['print_mail_hourly_threshold'] = array(
'#type' => 'select',
'#title' => t('Hourly threshold'),
......
This diff is collapsed.
......@@ -116,6 +116,38 @@ function print_pdf_menu() {
'type' => MENU_LOCAL_TASK,
'file' => 'print_pdf.admin.inc',
);
$items['admin/config/user-interface/print/pdf/options'] = array(
'title' => 'Options',
'weight' => -1,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/config/user-interface/print/pdf/tcpdf'] = array(
'title' => 'TCPDF',
'description' => 'Configure the TCPDF options.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_pdf_tcpdf_settings'),
'access arguments' => array('administer print'),
'type' => MENU_LOCAL_TASK,
'file' => 'print_pdf.admin.inc',
);
$items['admin/config/user-interface/print/pdf/dompdf'] = array(
'title' => 'dompdf',
'description' => 'Configure the dompdf options.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_pdf_dompdf_settings'),
'access arguments' => array('administer print'),
'type' => MENU_LOCAL_TASK,
'file' => 'print_pdf.admin.inc',
);
$items['admin/config/user-interface/print/pdf/wkhtmltopdf'] = array(
'title' => 'wkhtmltopdf',
'description' => 'Configure the wkhtmltopdf options.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_pdf_wkhtmltopdf_settings'),
'access arguments' => array('administer print'),
'type' => MENU_LOCAL_TASK,
'file' => 'print_pdf.admin.inc',
);
return $items;
}
......
<?php
/**
* @file
* Contains the administrative functions of the print UI module.
*
* This file is included by the print UI module, and includes the
* settings form.
*
* @ingroup print
*/
/**
* Menu callback for the send by email module settings form.
*
* @ingroup forms
*/
function print_ui_settings() {
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Link options'),
);
foreach (module_implements('print_link') as $module) {
$function = $module . '_print_link';
if (function_exists($function)) {
$link = call_user_func_array($function, array());
$format = $link['format'];
$form['settings']['checkboxes']['link_pos']['print_' . $format . '_link_pos'] = array(
'#type' => 'checkboxes',
'#title' => t('Link location'),
'#default_value' => variable_get('print_' . $format . '_link_pos', array(PRINT_UI_LINK_POS_DEFAULT => PRINT_UI_LINK_POS_DEFAULT)),
'#options' => array('link' => t('Links area'), 'corner' => t('Content corner'), 'block' => t('Block')),
'#description' => t('Choose the location of the link(s) to the printer-friendly version pages. The Links area is usually below the node content, whereas the Content corner is placed in the upper-right corner of the node content. Unselect all options to disable the link. Even if the link is disabled, you can still go to %path where nid is the numeric id of the node.', array('%path' => PRINT_PATH . '/nid')),
);
$form['settings']['checkboxes']['link_teaser']['print_' . $format . '_link_teaser'] = array(
'#type' => 'checkbox',
'#title' => t('Display link in teaser'),
'#default_value' => variable_get('print_' . $format . '_link_teaser', PRINT_UI_LINK_TEASER_DEFAULT),
'#description' => t('Enabling this will display the link in teaser mode.'),
);
}
}
$form['settings']['adv_link'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced link options'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
foreach (module_implements('print_link') as $module) {
$function = $module . '_print_link';
if (function_exists($function)) {
$link = call_user_func_array($function, array());
$format = $link['format'];
$form['settings']['adv_link']['show_link']['print_' . $format . '_show_link'] = array(
'#type' => 'radios',
'#title' => t('Link style'),
'#default_value' => variable_get('print_' . $format . '_show_link', PRINT_UI_SHOW_LINK_DEFAULT),
'#options' => array(1 => t('Text only'), 2 => t('Icon only'), 3 => t('Icon and Text')),
'#description' => t('Select the visual style of the link.'),
);
$form['settings']['adv_link']['link_use_alias']['print_' . $format . '_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
'#default_value' => variable_get('print_' . $format . '_link_use_alias', PRINT_UI_LINK_USE_ALIAS_DEFAULT),
'#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
);
$form['settings']['adv_link']['link_class']['print_' . $format . '_link_class'] = array(
'#type' => 'textfield',
'#title' => t('Link class'),
'#default_value' => variable_get('print_' . $format . '_link_class', $link['class']),
'#size' => 20,
'#maxlength' => 250,
'#description' => t('This can be used by themers to change the link style or by jQuery modules to open in a new window (e.g. greybox or thickbox). Multiple classes can be specified, separated by spaces.'),
);
$form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
'#description' => 'Any page that is not a Drupal node. Usually pages generated by Drupal or a module such as Views or Panels.',
'#default_value' => variable_get('print_' . $format . '_sys_link_visibility', PRINT_UI_SYS_LINK_VISIBILITY_DEFAULT),
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['settings']['adv_link']['sys_link_pages']['print_' . $format . '_sys_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => variable_get('print_' . $format . '_sys_link_pages', PRINT_UI_SYS_LINK_PAGES_DEFAULT),
'#rows' => 3,
'#description' => t('Setting this option will add a link on pages created by Drupal or the enabled modules.') . '<br />' .
t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
if (module_exists('php')) {
$access = user_access('use PHP for settings');
if ($form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility']['#default_value'] == 2 && !$access) {
$form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility'] = array('#type' => 'value', '#value' => 2);
$form['settings']['adv_link']['sys_link_pages']['print_' . $format . '_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_' . $format . '_sys_link_pages']['#default_value']);
}
elseif ($access) {
$form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$form['settings']['adv_link']['sys_link_pages']['print_' . $format . '_sys_link_pages']['#description'] .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
}
}
$form['settings']['adv_link']['book_link']['print_' . $format . '_book_link'] = array(
'#type' => 'radios',
'#title' => t('Link in book hierarchy nodes'),
'#default_value' => variable_get('print_' . $format . '_book_link', PRINT_UI_BOOK_LINK_DEFAULT),
'#options' => array(t('No link'), t('Current page and sub-pages'), t('Current page only')),
);
}
}
$form['#theme'] = 'print_ui_settings';
return system_settings_form($form);
}
/**
* Returns HTML for the link settings page.
*
* @param $variables
* An associative array containing:
* - form: A render element representing the form.
*
* @ingroup themeable
*/
function theme_print_ui_settings($variables) {
$form = $variables['form'];
$header = array('');
foreach (module_implements('print_link') as $module) {
$function = $module . '_print_link';
if (function_exists($function)) {
$link = call_user_func_array($function, array());
$header[] = array('data' => $link['format'], 'class' => 'checkbox');
}
}
foreach (element_children($form['settings']) as $group) {
$rows = array();
foreach (element_children($form['settings'][$group]) as $elem) {
$row = array();
foreach (module_implements('print_link') as $module) {
$function = $module . '_print_link';
if (function_exists($function)) {
$link = call_user_func_array($function, array());
$format = $link['format'];
$item = $form['settings'][$group][$elem]['print_' . $format . '_' . $elem];
if (empty($row)) {
// Start row, fill title and description
$row_desc = array(
'#type' => 'item',
'#markup' => isset($item['#title']) ? $item['#title'] : '',
'#description' => isset($item['#description']) ? $item['#description'] : '',
);
$row[] = array('data' => drupal_render($row_desc), 'class' => array(''));
}
$item['#title_display'] = 'invisible';
$item['#description'] = '';
$class = ($item['#type'] == 'checkbox') ? 'checkbox' : '';
$row[] = array('data' => drupal_render($item), 'class' => array($class));
}
}
$rows[] = $row;
}
$form['settings'][$group]['#children'] = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions')));
}
$output = drupal_render_children($form);
return $output;
}
......@@ -3,4 +3,5 @@ description = "Handles the links to the printer-friendly versions."
core=7.x
package = "Printer, email and PDF versions"
files[] = print_ui.module
configure = admin/config/user-interface/print_ui
files[] = print_ui.admin.inc
configure = admin/config/user-interface/print/ui
......@@ -79,6 +79,10 @@ function print_ui_theme() {
'print_ui_format_link' => array(
'variables' => array('format' => ''),
),
'print_ui_settings' => array(
'render element' => 'form',
'file' => 'print_ui.admin.inc',
),
);
}
......@@ -87,6 +91,16 @@ function print_ui_theme() {
*/
function print_ui_menu() {
$items = array();
$items['admin/config/user-interface/print/ui'] = array(
'title' => 'Links',
'description' => 'Configure the print module links.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_ui_settings'),
'access arguments' => array('administer print'),
'weight' => 9,
'type' => MENU_LOCAL_TASK,
'file' => 'print_ui.admin.inc',
);
return $items;
}
......@@ -614,7 +628,7 @@ function print_ui_link_allowed($link, $args) {
// Cache this statically to avoid duplicate queries for every comment.
static $res = array();
if (!isset($res[$node->nid])) {
$res[$node->nid] = db_query("SELECT comments FROM {' . $link['module'] . '_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
$res[$node->nid] = db_query("SELECT comments FROM {" . $link['module'] . "_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
->fetch();
}
$display_comment = $res ? intval($res[$node->nid]->comments) : variable_get($link['module'] . '_display_comment_' . $node_type, PRINT_UI_TYPE_COMMENT_LINK_DEFAULT);
......@@ -648,8 +662,8 @@ function print_ui_link_allowed($link, $args) {
}
else {
// 'System' page
$sys_link_visibility = variable_get('print_' . $format . '_sys_link_visibility', PRINT_UI_SYS_LINK_VISIBILITY_DEFAULT);
$sys_link_pages = variable_get('print_' . $format . '_sys_link_pages', PRINT_UI_SYS_LINK_PAGES_DEFAULT);
$sys_link_visibility = variable_get('print_' . $link['format'] . '_sys_link_visibility', PRINT_UI_SYS_LINK_VISIBILITY_DEFAULT);
$sys_link_pages = variable_get('print_' . $link['format'] . '_sys_link_pages', PRINT_UI_SYS_LINK_PAGES_DEFAULT);
return _print_ui_page_match($sys_link_visibility, $_GET['q'], $sys_link_pages);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment