Commit a8222e12 authored by jcnventura's avatar jcnventura

Add option to select location of the links

parent dd92f6dd
......@@ -95,12 +95,20 @@ function print_html_settings() {
'#type' => 'fieldset',
);
$form['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['print_html_show_link'] = array(
'#type' => 'radios',
'#title' => t('Printer-friendly page link'),
'#title' => t('Link style'),
'#default_value' => variable_get('print_html_show_link', PRINT_HTML_SHOW_LINK_DEFAULT),
'#options' => array(t('None (Disabled)'), t('Text only'), t('Icon only'), t('Icon and Text')),
'#description' => t('Enable or disable the printer-friendly page link for each node. Even if the link is disabled, you can still view the print version of a node by going to print/nid where nid is the numeric id of the node.'),
'#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['print_html_node_link_visibility'] = array(
......
......@@ -75,7 +75,8 @@ function print_update_6000() {
}
if (isset($conf['print_html_settings'])) {
$print_html_settings = variable_get('print_html_settings', '');
variable_set('print_html_show_link', $print_html_settings['show_link']);
variable_set('print_html_link_pos', array('link' => ($print_html_settings['show_link'] ? 'link' : 0) ));
variable_set('print_html_show_link', max(1, $print_html_settings['show_link']));
variable_set('print_html_node_link_visibility', $print_html_settings['node_link_visibility']);
variable_set('print_html_node_link_pages', $print_html_settings['node_link_pages']);
variable_set('print_html_link_class', $print_html_settings['link_class']);
......
......@@ -17,6 +17,7 @@ define('PRINT_URLS_DEFAULT', 1);
define('PRINT_COMMENTS_DEFAULT', 0);
define('PRINT_NEWWINDOW_DEFAULT', 1);
define('PRINT_HTML_LINK_POS_DEFAULT', 'link');
define('PRINT_HTML_SHOW_LINK_DEFAULT', 1);
define('PRINT_HTML_NODE_LINK_VISIBILITY_DEFAULT', 0);
define('PRINT_HTML_NODE_LINK_PAGES_DEFAULT', '');
......@@ -105,8 +106,9 @@ function print_menu() {
* Implementation of hook_link().
*/
function print_link($type, $node = NULL, $teaser = FALSE) {
$print_html_link_pos = variable_get('print_html_link_pos', array(PRINT_HTML_LINK_POS_DEFAULT => PRINT_HTML_LINK_POS_DEFAULT));
$allowed_type = print_link_allowed(array('type' => $type, 'node' => $node, 'teaser' => $teaser));
if ($allowed_type === PRINT_ALLOW_NORMAL_LINK) {
if (($allowed_type === PRINT_ALLOW_NORMAL_LINK) && !empty($print_html_link_pos['link'])) {
$links = array();
$format = theme('print_format_link');
......@@ -161,7 +163,9 @@ function print_help($path, $arg) {
return filter_filter('process', 1, NULL, file_get_contents(drupal_get_path('module', 'print') .'/README.txt') );
}
if (print_link_allowed(array('path' => $path)) && (preg_match('!^node/!i', $path) == 0)) {
$print_html_link_pos = variable_get('print_html_link_pos', array(PRINT_HTML_LINK_POS_DEFAULT => PRINT_HTML_LINK_POS_DEFAULT));
if (print_link_allowed(array('path' => $path)) && (preg_match('!^node/!i', $path) == 0) &&
!(empty($print_html_link_pos['link']) && empty($print_html_link_pos['corner']))) {
static $output = FALSE;
if ($output === FALSE) {
......@@ -179,8 +183,10 @@ function print_help($path, $arg) {
function print_nodeapi(&$node, $op = 'view', $teaser, $page) {
switch ($op) {
case 'view':
$print_html_link_pos = variable_get('print_html_link_pos', array(PRINT_HTML_LINK_POS_DEFAULT => PRINT_HTML_LINK_POS_DEFAULT));
$allowed_type = print_link_allowed(array('node' => $node, 'teaser' => $teaser));
if (($allowed_type != FALSE) && (preg_match('!^print!i', $_GET['q']) == 0)) {
if (($allowed_type != FALSE) && !empty($print_html_link_pos['corner']) &&
(preg_match('!^print!i', $_GET['q']) == 0)) {
drupal_add_css(drupal_get_path('module', 'print') .'/printlinks.css');
if ($allowed_type === PRINT_ALLOW_BOOK_LINK) {
$path = PRINT_PATH .'/book/export/html/'. $node->nid;
......@@ -402,8 +408,7 @@ function _print_page_match($visibility, $pages) {
* PRINT_ALLOW_BOOK_LINK if a link is allowed in a book node
*/
function print_link_allowed($args) {
$print_html_show_link = variable_get('print_html_show_link', PRINT_HTML_SHOW_LINK_DEFAULT);
if ($args['teaser'] || !user_access('access print') || !$print_html_show_link) {
if ($args['teaser'] || !user_access('access print')) {
// If showing only the teaser or the user is not allowed or link is disabled
return FALSE;
}
......
......@@ -19,12 +19,20 @@ function print_mail_settings() {
'#type' => 'fieldset',
);
$form['print_mail_link_pos'] = array(
'#type' => 'checkboxes',
'#title' => t('Send by e-mail 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 e-mail 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 e-mail by going to !path/nid where nid is the numeric id of the node.', array('!path' => PRINTMAIL_PATH)),
);
$form['print_mail_show_link'] = array(
'#type' => 'radios',
'#title' => t('Send by e-mail link'),
'#title' => t('Link style'),
'#default_value' => variable_get('print_mail_show_link', PRINT_MAIL_SHOW_LINK_DEFAULT),
'#options' => array(t('None (Disabled)'), t('Text only'), t('Icon only'), t('Icon and Text')),
'#description' => t('Enable or disable the send by e-mail link for each node. Even if the link is disabled, you can still send a node by e-mail by going to printmail/nid where nid is the numeric id of the node.'),
'#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['print_mail_node_link_visibility'] = array(
......
......@@ -35,7 +35,8 @@ function print_mail_update_6000() {
$ret = array();
if (isset($conf['print_mail_settings'])) {
$print_mail_settings = variable_get('print_mail_settings', '');
variable_set('print_mail_show_link', $print_mail_settings['show_link']);
variable_set('print_mail_link_pos', array('link' => ($print_html_settings['show_link'] ? 'link' : 0) ));
variable_set('print_mail_show_link', max(1, $print_mail_settings['show_link']));
variable_set('print_mail_node_link_visibility', $print_mail_settings['node_link_visibility']);
variable_set('print_mail_node_link_pages', $print_mail_settings['node_link_pages']);
variable_set('print_mail_link_class', $print_mail_settings['link_class']);
......
......@@ -8,6 +8,7 @@
define('PRINTMAIL_PATH', 'printmail');
define('PRINT_MAIL_LINK_POS_DEFAULT', 'link');
define('PRINT_MAIL_SHOW_LINK_DEFAULT', 1);
define('PRINT_MAIL_NODE_LINK_VISIBILITY_DEFAULT', 0);
define('PRINT_MAIL_NODE_LINK_PAGES_DEFAULT', '');
......@@ -68,8 +69,9 @@ function print_mail_menu() {
* Implementation of hook_link().
*/
function print_mail_link($type, $node = NULL, $teaser = FALSE) {
$print_mail_link_pos = variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT));
$allowed_type = print_mail_link_allowed(array('type' => $type, 'node' => $node, 'teaser' => $teaser));
if ($allowed_type) {
if (($allowed_type) && !empty($print_mail_link_pos['link'])) {
$links = array();
$format = theme('print_mail_format_link');
// Show book link
......@@ -106,7 +108,9 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
* Implementation of hook_help().
*/
function print_mail_help($path, $arg) {
if (print_mail_link_allowed(array('path' => $path)) && (preg_match('!^node/!i', $path) == 0)) {
$print_mail_link_pos = variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT));
if (print_mail_link_allowed(array('path' => $path)) && (preg_match('!^node/!i', $path) == 0) &&
!(empty($print_mail_link_pos['link']) && empty($print_mail_link_pos['corner']))) {
static $output = FALSE;
if ($output === FALSE) {
......@@ -124,8 +128,10 @@ function print_mail_help($path, $arg) {
function print_mail_nodeapi(&$node, $op = 'view', $teaser, $page) {
switch ($op) {
case 'view':
$print_mail_link_pos = variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT));
$allowed_type = print_mail_link_allowed(array('node' => $node, 'teaser' => $teaser));
if (($allowed_type != FALSE) && (preg_match('!^print!i', $_GET['q']) == 0)) {
if (($allowed_type != FALSE) && !empty($print_mail_link_pos['corner']) &&
(preg_match('!^print!i', $_GET['q']) == 0)) {
drupal_add_css(drupal_get_path('module', 'print') .'/printlinks.css');
if ($allowed_type === PRINT_ALLOW_BOOK_LINK) {
$path = PRINTMAIL_PATH .'/book/export/html/'. $node->nid;
......@@ -215,8 +221,7 @@ function print_mail_insert_link($path = NULL) {
* PRINT_ALLOW_BOOK_LINK if a link is allowed in a book node
*/
function print_mail_link_allowed($args) {
$print_mail_show_link = variable_get('print_mail_show_link', PRINT_MAIL_SHOW_LINK_DEFAULT);
if ($args['teaser'] || !user_access('access print') || !$print_mail_show_link) {
if ($args['teaser'] || !user_access('access print')) {
// If showing only the teaser or the user is not allowed or link is disabled
return FALSE;
}
......
......@@ -32,12 +32,20 @@ function print_pdf_settings() {
'#required' => TRUE,
);
$form['print_pdf_link_pos'] = array(
'#type' => 'checkboxes',
'#title' => t('PDF version link'),
'#default_value' => variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT)),
'#options' => array('link' => t('Links area'), 'corner' => t('Content corner')),
'#description' => t('Choose the location of the link(s) to the PDF version. 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 PDF version of a node by going to !path/nid where nid is the numeric id of the node.', array('!path' => PRINTPDF_PATH)),
);
$form['print_pdf_show_link'] = array(
'#type' => 'radios',
'#title' => t('PDF version link'),
'#title' => t('Link style'),
'#default_value' => variable_get('print_pdf_show_link', PRINT_PDF_SHOW_LINK_DEFAULT),
'#options' => array(t('None (Disabled)'), t('Text only'), t('Icon only'), t('Icon and Text')),
'#description' => t('Enable or disable the PDF version link for each node. Even if the link is disabled, you can still view the PDF version of a node by going to printpdf/nid where nid is the numeric id of the node.'),
'#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['print_pdf_node_link_visibility'] = array(
......
......@@ -37,7 +37,8 @@ function print_pdf_update_6000() {
$ret = array();
if (isset($conf['print_pdf_settings'])) {
$print_pdf_settings = variable_get('print_pdf_settings', '');
variable_set('print_pdf_show_link', $print_pdf_settings['show_link']);
variable_set('print_pdf_link_pos', array('link' => ($print_pdf_settings['show_link'] ? 'link' : 0) ));
variable_set('print_pdf_show_link', max(1, $print_pdf_settings['show_link']));
variable_set('print_pdf_node_link_visibility', $print_pdf_settings['node_link_visibility']);
variable_set('print_pdf_node_link_pages', $print_pdf_settings['node_link_pages']);
variable_set('print_pdf_link_class', $print_pdf_settings['link_class']);
......
......@@ -8,6 +8,7 @@
define('PRINTPDF_PATH', 'printpdf');
define('PRINT_PDF_LINK_POS_DEFAULT', 'link');
define('PRINT_PDF_SHOW_LINK_DEFAULT', 1);
define('PRINT_PDF_NODE_LINK_VISIBILITY_DEFAULT', 0);
define('PRINT_PDF_NODE_LINK_PAGES_DEFAULT', '');
......@@ -87,8 +88,9 @@ function print_pdf_requirements($phase) {
* Implementation of hook_link().
*/
function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
$print_pdf_link_pos = variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT));
$allowed_type = print_pdf_link_allowed(array('type' => $type, 'node' => $node, 'teaser' => $teaser));
if ($allowed_type) {
if (($allowed_type) && !empty($print_pdf_link_pos['link'])) {
$links = array();
$format = theme('print_pdf_format_link');
// Show book link
......@@ -125,7 +127,9 @@ function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
* Implementation of hook_help().
*/
function print_pdf_help($path, $arg) {
if (print_pdf_link_allowed(array('path' => $path)) && (preg_match('!^node/!i', $path) == 0)) {
$print_pdf_link_pos = variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT));
if (print_pdf_link_allowed(array('path' => $path)) && (preg_match('!^node/!i', $path) == 0) &&
!(empty($print_pdf_link_pos['link']) && empty($print_pdf_link_pos['corner']))) {
static $output = FALSE;
if ($output === FALSE) {
......@@ -143,8 +147,10 @@ function print_pdf_help($path, $arg) {
function print_pdf_nodeapi(&$node, $op = 'view', $teaser, $page) {
switch ($op) {
case 'view':
$print_pdf_link_pos = variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT));
$allowed_type = print_pdf_link_allowed(array('node' => $node, 'teaser' => $teaser));
if (($allowed_type != FALSE) && (preg_match('!^print!i', $_GET['q']) == 0)) {
if (($allowed_type != FALSE) && !empty($print_pdf_link_pos['corner']) &&
(preg_match('!^print!i', $_GET['q']) == 0)) {
drupal_add_css(drupal_get_path('module', 'print') .'/printlinks.css');
if ($allowed_type === PRINT_ALLOW_BOOK_LINK) {
$path = PRINTPDF_PATH .'/book/export/html/'. $node->nid;
......@@ -235,8 +241,7 @@ function print_pdf_insert_link($path = NULL) {
* PRINT_ALLOW_BOOK_LINK if a link is allowed in a book node
*/
function print_pdf_link_allowed($args) {
$print_pdf_show_link = variable_get('print_pdf_show_link', PRINT_PDF_SHOW_LINK_DEFAULT);
if ($args['teaser'] || !user_access('access print') || !$print_pdf_show_link) {
if ($args['teaser'] || !user_access('access print')) {
// If showing only the teaser or the user is not allowed or link is disabled
return FALSE;
}
......
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