Commit c0bede24 authored by jcnventura's avatar jcnventura

Add option to use URL alias in the link

parent 6fea4d6b
......@@ -231,6 +231,13 @@ function print_html_settings() {
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>')),
);
$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']['print_html_book_link'] = array(
'#type' => 'checkbox',
'#title' => t('Take control of the book module printer-friendly link'),
......
......@@ -27,6 +27,7 @@ define('PRINT_HTML_NODE_LINK_PAGES_DEFAULT', '');
define('PRINT_HTML_LINK_CLASS_DEFAULT', 'print-page');
define('PRINT_HTML_SYS_LINK_VISIBILITY_DEFAULT', 1);
define('PRINT_HTML_SYS_LINK_PAGES_DEFAULT', '');
define('PRINT_HTML_LINK_USE_ALIAS_DEFAULT', 0);
define('PRINT_HTML_BOOK_LINK_DEFAULT', 1);
define('PRINT_HTML_NEW_WINDOW_DEFAULT', 0);
define('PRINT_HTML_SENDTOPRINTER_DEFAULT', 0);
......@@ -110,6 +111,7 @@ function print_menu() {
*/
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));
$print_html_link_use_alias = variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_link_allowed(array('type' => $type, 'node' => $node, 'teaser' => $teaser));
if (($allowed_type === PRINT_ALLOW_NORMAL_LINK) && !empty($print_html_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
......@@ -123,7 +125,14 @@ function print_link($type, $node = NULL, $teaser = FALSE) {
$query = print_query_string_encode($query_arr, array('q'));
if (empty($query)) $query = NULL;
$links['print'] = array('href' => PRINT_PATH .'/'. $node->nid,
if ($print_html_link_use_alias) {
$path = drupal_get_path_alias('node/'. $node->nid);
}
else {
$path = $node->nid;
}
$links['print'] = array('href' => PRINT_PATH .'/'. $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
......@@ -363,7 +372,15 @@ function theme_print_text() {
function print_insert_link($path = NULL) {
if (user_access('access print')) {
if ($path === NULL) {
$path = PRINT_PATH .'/'. preg_replace('!^node/!', '', $_GET['q']);
$print_html_link_use_alias = variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT);
if ($print_html_link_use_alias) {
$path = drupal_get_path_alias($_GET['q']);
}
else {
$path = preg_replace('!^node/!', '', $_GET['q']);
}
$path = PRINT_PATH .'/'. $path;
$query = print_query_string_encode($_GET, array('q'));
if (empty($query)) {
$query = NULL;
......
......@@ -81,6 +81,13 @@ function print_mail_settings() {
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>')),
);
$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']['print_mail_book_link'] = array(
'#type' => 'checkbox',
'#title' => t('Show link in book nodes'),
......
......@@ -15,6 +15,7 @@ define('PRINT_MAIL_NODE_LINK_PAGES_DEFAULT', '');
define('PRINT_MAIL_LINK_CLASS_DEFAULT', 'print-mail');
define('PRINT_MAIL_SYS_LINK_VISIBILITY_DEFAULT', 1);
define('PRINT_MAIL_SYS_LINK_PAGES_DEFAULT', '');
define('PRINT_MAIL_LINK_USE_ALIAS_DEFAULT', 0);
define('PRINT_MAIL_BOOK_LINK_DEFAULT', 1);
define('PRINT_MAIL_HOURLY_THRESHOLD', 3);
define('PRINT_MAIL_TEASER_DEFAULT_DEFAULT', 1);
......@@ -64,6 +65,7 @@ function print_mail_menu() {
*/
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));
$print_mail_link_use_alias = variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_mail_link_allowed(array('type' => $type, 'node' => $node, 'teaser' => $teaser));
if (($allowed_type) && !empty($print_mail_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
......@@ -87,7 +89,14 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
}
$query = print_query_string_encode($query_arr, array('q'));
$links['print_mail'] = array('href' => PRINTMAIL_PATH .'/'. $node->nid,
if ($print_mail_link_use_alias) {
$path = drupal_get_path_alias('node/'. $node->nid);
}
else {
$path = $node->nid;
}
$links['print_mail'] = array('href' => PRINTMAIL_PATH .'/'. $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
......@@ -197,7 +206,15 @@ function theme_print_mail_format_link() {
function print_mail_insert_link($path = NULL) {
if (user_access('access print')) {
if ($path === NULL) {
$path = PRINTMAIL_PATH .'/'. preg_replace('!^node/!', '', $_GET['q']);
$print_mail_link_use_alias = variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT);
if ($print_mail_link_use_alias) {
$path = drupal_get_path_alias($_GET['q']);
}
else {
$path = preg_replace('!^node/!', '', $_GET['q']);
}
$path = PRINTMAIL_PATH .'/'. $path;
$query = print_query_string_encode($_GET, array('q'));
if (empty($query)) {
$query = NULL;
......
......@@ -94,6 +94,13 @@ function print_pdf_settings() {
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>')),
);
$form['settings']['adv_link']['print_pdf_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
'#default_value' => variable_get('print_pdf_link_use_alias', PRINT_PDF_LINK_USE_ALIAS_DEFAULT),
'#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
);
$form['settings']['print_pdf_book_link'] = array(
'#type' => 'checkbox',
'#title' => t('Show link in book nodes'),
......
......@@ -15,6 +15,7 @@ define('PRINT_PDF_NODE_LINK_PAGES_DEFAULT', '');
define('PRINT_PDF_LINK_CLASS_DEFAULT', 'print-pdf');
define('PRINT_PDF_SYS_LINK_VISIBILITY_DEFAULT', 1);
define('PRINT_PDF_SYS_LINK_PAGES_DEFAULT', '');
define('PRINT_PDF_LINK_USE_ALIAS_DEFAULT', 0);
define('PRINT_PDF_BOOK_LINK_DEFAULT', 1);
define('PRINT_PDF_PDF_TOOL_DEFAULT', 0);
define('PRINT_PDF_CONTENT_DISPOSITION_DEFAULT', 2);
......@@ -103,6 +104,7 @@ function print_pdf_requirements($phase) {
*/
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));
$print_pdf_link_use_alias = variable_get('print_pdf_link_use_alias', PRINT_PDF_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_pdf_link_allowed(array('type' => $type, 'node' => $node, 'teaser' => $teaser));
if (($allowed_type) && !empty($print_pdf_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
......@@ -126,7 +128,14 @@ function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
}
$query = print_query_string_encode($query_arr, array('q'));
$links['print_pdf'] = array('href' => PRINTPDF_PATH .'/'. $node->nid,
if ($print_pdf_link_use_alias) {
$path = drupal_get_path_alias('node/'. $node->nid);
}
else {
$path = $node->nid;
}
$links['print_pdf'] = array('href' => PRINTPDF_PATH .'/'. $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
......@@ -237,7 +246,15 @@ function theme_print_pdf_format_link() {
function print_pdf_insert_link($path = NULL) {
if (user_access('access print')) {
if ($path === NULL) {
$path = PRINTPDF_PATH .'/'. preg_replace('!^node/!', '', $_GET['q']);
$print_pdf_link_use_alias = variable_get('print_pdf_link_use_alias', PRINT_PDF_LINK_USE_ALIAS_DEFAULT);
if ($print_pdf_link_use_alias) {
$path = drupal_get_path_alias($_GET['q']);
}
else {
$path = preg_replace('!^node/!', '', $_GET['q']);
}
$path = PRINTPDF_PATH .'/'. $path;
$query = print_query_string_encode($_GET, array('q'));
if (empty($query)) {
$query = NULL;
......
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