Commit 855b243a authored by jcnventura's avatar jcnventura

Fix #177358: Link options by node

Fix #247578: Print URLs by content type
Fix #298063: Most printed, emailed and PDFd blocks
Fix #333049 and #333957: Add ability to change user-visible strings in the settings pages
Use different teaser comparison
Try to fix #336865: also replace the opening <p>
Fix content corner problem and other minor fixes
Add ability to configure link text strings
Improve variable cleanup at uninstall
parent cc511103
......@@ -88,10 +88,6 @@ The following themeable functions are defined:
Returns an array of formatted attributes for the Printer-friendly
link.
* theme_print_text()
Returns an array of costumized text strings used in the printer-friendly
page.
* print_pdf_dompdf_footer($html)
Format the dompdf footer contents
......
......@@ -134,6 +134,38 @@ function print_main_settings() {
'#description' => t("Drupal will attempt to use the page's defined alias in case there is one. To force the use of the fixed URL, activate this option."),
);
$form['settings']['print_text'] = array(
'#type' => 'fieldset',
'#title' => t('Text strings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['settings']['print_text']['print_text_published'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_published', t('Published on %site_name')),
);
$form['settings']['print_text']['print_text_by'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_by', t('By %author')),
);
$form['settings']['print_text']['print_text_created'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_created', t('Created %date')),
);
$form['settings']['print_text']['print_text_source_url'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_source_url', t('Source URL')),
);
$form['settings']['print_text']['print_text_retrieved'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_retrieved', t('retrieved on %date')),
);
$form['settings']['print_text']['print_text_links'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_links', t('Links')),
);
$form['#attributes'] = array('enctype' => 'multipart/form-data');
$form['#validate'][] = '_print_main_settings_validate';
......@@ -193,6 +225,13 @@ function print_html_settings() {
'#description' => t('Select the visual style of the link.'),
);
$form['settings']['adv_link']['print_html_link_text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#default_value' => variable_get('print_html_link_text', t('Printer-friendly version')),
'#description' => t("Text used in the link to the printer-friendly version."),
);
$form['settings']['adv_link']['print_html_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
......
......@@ -10,6 +10,8 @@
* Implementation of hook_install().
*/
function print_install() {
drupal_install_schema('print');
$t = get_t();
drupal_set_message($t('Printer-friendly Page settings are available under !link',
array( '!link' => l('Administer > Site configuration > Printer-friendly Pages ', 'admin/settings/print' ) )
......@@ -20,6 +22,8 @@ function print_install() {
* Implementation of hook_uninstall().
*/
function print_uninstall() {
drupal_uninstall_schema('print');
variable_del('print_settings');
variable_del('print_sourceurl_settings');
variable_del('print_html_settings');
......@@ -46,65 +50,81 @@ function print_uninstall() {
variable_del('print_robots_noindex');
variable_del('print_robots_nofollow');
variable_del('print_robots_noarchive');
variable_del('print_footer_options');
variable_del('print_footer_user');
variable_del('print_html_link_text');
variable_del('print_html_link_use_alias');
variable_del('print_text_by');
variable_del('print_text_created');
variable_del('print_text_links');
variable_del('print_text_published');
variable_del('print_text_retrieved');
variable_del('print_text_source_url');
$settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_display\_%'");
while ($variable = db_fetch_object($settings)) {
foreach ($settings as $variable) {
variable_del($variable->name);
}
}
/**
* Update to version 6.x-1.0
* Implementation of hook_schema().
*/
function print_update_6000() {
global $conf;
function print_schema() {
$schema['print_node_conf'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'link' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'size' => 'tiny',
),
'comments' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'size' => 'tiny',
),
'url_list' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'size' => 'tiny',
),
),
'primary key' => array('nid'),
);
$ret = array();
if (isset($conf['print_settings'])) {
$print_settings = variable_get('print_settings', '');
variable_set('print_logo_options', ($print_settings['logo_url'] ? 2 : 1));
variable_set('print_logo_url', $print_settings['logo_url']);
variable_set('print_css', $print_settings['css']);
variable_set('print_urls', $print_settings['urls']);
variable_set('print_comments', $print_settings['comments']);
variable_set('print_newwindow', $print_settings['newwindow']);
variable_del('print_settings');
}
if (isset($conf['print_sourceurl_settings'])) {
$print_sourceurl_settings = variable_get('print_sourceurl_settings', '');
variable_set('print_sourceurl_enabled', $print_sourceurl_settings['enabled']);
variable_set('print_sourceurl_date', $print_sourceurl_settings['date']);
variable_set('print_sourceurl_forcenode', $print_sourceurl_settings['forcenode']);
variable_del('print_sourceurl_settings');
}
if (isset($conf['print_html_settings'])) {
$print_html_settings = variable_get('print_html_settings', '');
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']);
variable_set('print_html_sys_link_visibility', $print_html_settings['sys_link_visibility']);
variable_set('print_html_sys_link_pages', $print_html_settings['sys_link_pages']);
variable_set('print_html_book_link', $print_html_settings['book_link']);
variable_set('print_html_new_window', $print_html_settings['new_window']);
variable_set('print_html_sendtoprinter', $print_html_settings['sendtoprinter']);
variable_del('print_html_settings');
}
if (isset($conf['print_robot_settings'])) {
$print_robot_settings = variable_get('print_robot_settings', '');
variable_set('print_robots_noindex', $print_robot_settings['noindex']);
variable_set('print_robots_nofollow', $print_robot_settings['nofollow']);
variable_set('print_robots_noarchive', $print_robot_settings['noarchive']);
variable_del('print_robot_settings');
}
return $ret;
}
$schema['print_page_counter'] = array(
'fields' => array(
'path' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'totalcount' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'big',
),
'timestamp' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('path'),
);
/**
* Update to version 6.x-1.0
*/
function print_update_6001() {
$ret = array();
menu_rebuild();
return $ret;
return $schema;
}
This diff is collapsed.
This diff is collapsed.
......@@ -43,6 +43,13 @@ function print_mail_settings() {
'#description' => t('Select the visual style of the link.'),
);
$form['settings']['adv_link']['print_mail_link_text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#default_value' => variable_get('print_mail_link_text', t('Send to friend')),
'#description' => t("Text used in the link to the send by-email form."),
);
$form['settings']['adv_link']['print_mail_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
......@@ -84,7 +91,7 @@ function print_mail_settings() {
'#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 />'.
'#description' => t('Setting this option will add a send by e-mail 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>')),
);
......@@ -117,5 +124,31 @@ function print_mail_settings() {
'#description' => t('If checked, the user will be able to choose between sending the full content or only the teaser at send time.'),
);
$form['settings']['print_mail_text'] = array(
'#type' => 'fieldset',
'#title' => t('Text strings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['settings']['print_mail_text']['print_mail_text_subject'] = array(
'#type' => 'textfield',
'#title' => t('Message Subject'),
'#default_value' => variable_get('print_mail_text_subject', t('!user has sent you a message from !site')),
'#description' => t("e-mail subject line. The sender's name will appear in place of !user in the subject. The web site name will be inserted in place of !site."),
);
$form['settings']['print_mail_text']['print_mail_text_message'] = array(
'#type' => 'textfield',
'#title' => t('Message Preamble'),
'#default_value' => variable_get('print_mail_text_message', t('Message from sender')),
'#description' => t('e-mail message preamble. The sender will be able to add their own message after this.'),
);
$form['settings']['print_mail_text']['print_mail_text_confirmation'] = array(
'#type' => 'textfield',
'#title' => t('Thank You Message'),
'#default_value' => variable_get('print_mail_text_confirmation', t('Thank you for spreading the word about !site.')),
'#description' => t('This message will be displayed after the user successfully submits the form.'),
);
return system_settings_form($form);
}
......@@ -41,6 +41,19 @@ function print_mail_form($form_state) {
$path = 'node/'. $path;
}
$cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
if (count($form_state['post']) == 0) {
$nodepath = drupal_get_normal_path($path);
db_merge('print_mail_page_counter')
->key(array('path' => $nodepath))
->fields(array(
'totalcount' => 1,
'timestamp' => REQUEST_TIME,
))
->expression('totalcount', 'totalcount + :inc', array(':inc' => 1))
->execute();
}
$form['path'] = array('#type' => 'value', '#value' => $path);
$form['cid'] = array('#type' => 'value', '#value' => $cid);
......@@ -109,8 +122,8 @@ function print_mail_form($form_state) {
$user_name = t('Someone');
}
$site_name = variable_get('site_name', t('an interesting site'));
$form['fld_subject']['#default_value'] = t('!user has sent you a message from !site',
array('!user' => $user_name, '!site' => $site_name));
$print_mail_text_subject = variable_get('print_mail_text_subject', t('!user has sent you a message from !site'));
$form['fld_subject']['#default_value'] = t($print_mail_text_subject, array('!user' => $user_name, '!site' => $site_name));
return $form;
}
......@@ -223,7 +236,18 @@ function print_mail_form_submit($form, &$form_state) {
flood_register_event('print_mail');
watchdog('print_mail', '%name [%from] sent %page to [%to]', array('%name' => $form_state['values']['fld_from_name'], '%from' => $form_state['values']['fld_from_addr'], '%page' => $form_state['values']['path'], '%to' => $to));
$site_name = variable_get('site_name', t('us'));
drupal_set_message(t('Thank you for spreading the word about !site.', array('!site' => $site_name)));
$print_mail_text_confirmation = variable_get('print_mail_text_confirmation', t('Thank you for spreading the word about !site.'));
drupal_set_message(t($print_mail_text_confirmation, array('!site' => $site_name)));
$nodepath = drupal_get_normal_path($params['path']);
db_update('print_mail_page_counter')
->fields(array(
'sentcount' => 1,
'sent_timestamp' => REQUEST_TIME,
))
->condition('path', $nodepath, '=')
->expression('sentcount', 'sentcount + :inc', array(':inc' => count(split(',', $to))))
->execute();
}
$form_state['redirect'] = preg_replace('!^book/export/html/!', 'node/', $form_state['values']['path']);
}
......@@ -234,9 +258,10 @@ function print_mail_form_submit($form, &$form_state) {
function print_mail_mail($key, &$message, $params) {
switch ($key) {
case 'sendpage':
$sender_message = t('Message from sender:') .'<br /><br /><em>'. nl2br($params['message']) .'</em>';
$print_mail_text_message = variable_get('print_mail_text_message', t('Message from sender'));
$sender_message = $print_mail_text_message .':<br /><br /><em>'. nl2br($params['message']) .'</em>';
$print = print_controller($params['path'], $params['cid'], $params['teaser'], $sender_message);
$print = print_controller($params['path'], $params['cid'], PRINT_MAIL_FORMAT, $params['teaser'], $sender_message);
if ($print === FALSE) {
return;
}
......@@ -249,7 +274,7 @@ function print_mail_mail($key, &$message, $params) {
$node = $print['node'];
ob_start();
include_once(DRUPAL_ROOT .'/'. _print_get_template('mail', $print['type']));
include_once(DRUPAL_ROOT .'/'. _print_get_template(PRINT_MAIL_FORMAT, $print['type']));
$html = ob_get_contents();
ob_end_clean();
......
......@@ -6,10 +6,19 @@
* Install file of the print_mail module
*/
/**
* Implementation of hook_install().
*/
function print_mail_install() {
drupal_install_schema('print_mail');
}
/**
* Implementation of hook_uninstall().
*/
function print_mail_uninstall() {
drupal_uninstall_schema('print_mail');
variable_del('print_mail_settings');
variable_del('print_mail_show_link');
variable_del('print_mail_link_pos');
......@@ -22,32 +31,89 @@ function print_mail_uninstall() {
variable_del('print_mail_hourly_threshold');
variable_del('print_mail_teaser_default');
variable_del('print_mail_teaser_choice');
variable_del('print_mail_link_text');
variable_del('print_mail_link_use_alias');
variable_del('print_mail_text_confirmation');
variable_del('print_mail_text_message');
variable_del('print_mail_text_subject');
$settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_mail\_display\_%'");
while ($variable = db_fetch_object($settings)) {
foreach ($settings as $variable) {
variable_del($variable->name);
}
}
/**
* Update to version 6.x-1.0
* Implementation of hook_schema().
*/
function print_mail_update_6000() {
global $conf;
function print_mail_schema() {
$schema['print_mail_node_conf'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'link' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'size' => 'tiny',
),
'comments' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'size' => 'tiny',
),
'url_list' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'size' => 'tiny',
),
),
'primary key' => array('nid'),
);
$ret = array();
if (isset($conf['print_mail_settings'])) {
$print_mail_settings = variable_get('print_mail_settings', '');
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']);
variable_set('print_mail_sys_link_visibility', $print_mail_settings['sys_link_visibility']);
variable_set('print_mail_sys_link_pages', $print_mail_settings['sys_link_pages']);
variable_set('print_mail_book_link', $print_mail_settings['book_link']);
variable_set('print_mail_teaser_default', $print_mail_settings['teaser_default']);
variable_set('print_mail_teaser_choice', $print_mail_settings['teaser_choice']);
variable_del('print_mail_settings');
}
return $ret;
$schema['print_mail_page_counter'] = array(
'fields' => array(
'path' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'totalcount' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'big',
),
'timestamp' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'sentcount' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'big',
),
'sent_timestamp' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('path'),
);
return $schema;
}
......@@ -8,6 +8,8 @@
define('PRINTMAIL_PATH', 'printmail');
define('PRINT_MAIL_FORMAT', 'mail');
define('PRINT_MAIL_LINK_POS_DEFAULT', 'link');
define('PRINT_MAIL_SHOW_LINK_DEFAULT', 1);
define('PRINT_MAIL_NODE_LINK_VISIBILITY_DEFAULT', 0);
......@@ -60,6 +62,39 @@ function print_mail_menu() {
return $items;
}
/**
* Implementation of hook_block().
*/
function print_mail_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$block[0]['info'] = t('Most emailed');
return $block;
break;
case 'configure':
return '';
case 'save':
return;
case 'view':
switch ($delta) {
case 0:
$block['subject'] = t('Most emailed');
$result = db_query_range("SELECT path FROM {print_mail_page_counter} ORDER BY sentcount DESC", 0, 3)
->fetchAll();
if (count($result)) {
$block['content'] = '<div class="item-list"><ul>';
foreach ($result as $obj) {
$block['content'] .= '<li>'. l(_print_get_title($obj->path), $obj->path) .'</li>';
}
$block['content'] .= '</ul></div>';
}
break;
}
return $block;
break;
}
}
/**
* Implementation of hook_link().
*/
......@@ -136,6 +171,10 @@ function print_mail_help($path, $arg) {
* Implementation of hook_nodeapi_view().
*/
function print_mail_nodeapi_view(&$node, $teaser, $page) {
// Insert content corner links
if ($teaser === FALSE) {
_print_mail_set_node_fields($node);
}
$print_mail_link_pos = variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT));
if (($teaser === FALSE) && !empty($print_mail_link_pos['corner']) &&
(preg_match('!^print!i', $_GET['q']) == 0)) {
......@@ -149,24 +188,112 @@ function print_mail_nodeapi_view(&$node, $teaser, $page) {
}
}
/**
* Implementation of hook_nodeapi_prepare().
*/
function print_mail_nodeapi_prepare(&$node, $teaser, $page) {
_print_mail_set_node_fields($node);
}
/**
* Implementation of hook_nodeapi_update().
*/
function print_mail_nodeapi_update(&$node, $teaser, $page) {
_print_mail_node_conf_modify($node->nid, $node->print_mail_display, $node->print_mail_display_comment, $node->print_mail_display_urllist);
}
/**
* Implementation of hook_nodeapi_delete().
*/
function print_mail_nodeapi_delete(&$node, $teaser, $page) {
db_delete('print_mail_node_conf')
->condition('nid', $node->nid)
->execute();
db_delete('print_mail_page_counter')
->condition('path', $node->path)
->execute();
}
/**
* Implementation of hook_form_alter().
*/
function print_mail_form_alter(&$form, $form_state, $form_id) {
// Add the node-type settings option to activate the mail version link
if ($form_id == 'node_type_form') {
if (($form_id == 'node_type_form') || !empty($form['#node_edit_form'])) {
$form['print']['mail_label'] = array(
'#type' => 'markup',
'#markup' => '<p><strong>'. t('Send by e-mail') .'</strong></p>',
);
$form['print']['print_mail_display'] = array(
'#type' => 'checkbox',
'#title' => t('Show send by e-mail link'),
'#default_value' => variable_get('print_mail_display_'. $form['#node_type']->type, PRINT_TYPE_SHOW_LINK_DEFAULT),
'#description' => t('Displays a link to send the content by e-mail. Further configuration is available on the !settings.', array('!settings' => l(t('settings page'), 'admin/settings/print' ))),
'#title' => t('Show link'),
);
$form['print']['print_mail_display_comment'] = array(
'#type' => 'checkbox',
'#title' => t('Show send by e-mail link in individual comments'),
'#default_value' => variable_get('print_mail_display_comment_'. $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT),
'#description' => t('Displays a link to send the comment by e-mail. Further configuration is available on the !settings.', array('!settings' => l(t('settings page'), 'admin/settings/print' ))),
'#title' => t('Show link in individual comments'),
);
$form['print']['print_mail_display_urllist'] = array(
'#type' => 'checkbox',
'#title' => t('Show Printer-friendly URLs list'),
);
if ($form_id == 'node_type_form') {
$form['print']['print_mail_display']['#default_value'] = variable_get('print_mail_display_'. $form['#node_type']->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$form['print']['print_mail_display_comment']['#default_value'] = variable_get('print_mail_display_comment_'. $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$form['print']['print_mail_display_urllist']['#default_value'] = variable_get('print_mail_display_urllist_'. $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT);
}
else {
$form['print']['print_mail_display']['#default_value'] = $form['#node']->print_mail_display;
$form['print']['print_mail_display_comment']['#default_value'] = $form['#node']->print_mail_display_comment;
$form['print']['print_mail_display_urllist']['#default_value'] = $form['#node']->print_mail_display_urllist;
}
}
}
/**
* Auxiliary function to assign the per-node settings to the node object fields
*
* @param $node
* node to be modified
*/
function _print_mail_set_node_fields(&$node) {
$res = db_query("SELECT link, comments, url_list FROM {print_mail_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
->fetch();
$node->print_mail_display = $res ? intval($res->link) : PRINT_TYPE_SHOW_LINK_DEFAULT;
$node->print_mail_display_comment = $res ? intval($res->comments) : PRINT_TYPE_COMMENT_LINK_DEFAULT;
$node->print_mail_display_urllist = $res ? intval($res->url_list) : PRINT_TYPE_URLLIST_DEFAULT;
}
/**
* Update the print_mail_node_conf table to reflect the given attributes
* If updating to the default values, delete the record.
*
* @param $nid
* value of the nid field (primary key)
* @param $link
* value of the link field (0 or 1)
* @param $comments
* value of the comments field (0 or 1)
* @param $url_list
* value of the url_list field (0 or 1)
*/
function _print_mail_node_conf_modify($nid, $link, $comments, $url_list) {
if (($link == PRINT_TYPE_SHOW_LINK_DEFAULT) && ($comments == PRINT_TYPE_COMMENT_LINK_DEFAULT) &&
($url_list == PRINT_TYPE_URLLIST_DEFAULT)) {
db_delete('print_mail_node_conf')
->condition('nid', $nid)
->execute();
}
else {
db_merge('print_mail_node_conf')
->key(array('nid' => $nid))
->fields(array(
'link' => $link,
'comments' => $comments,
'url_list' => $url_list,
))
->execute();
}
}
......@@ -180,13 +307,13 @@ function print_mail_form_alter(&$form, $form_state, $form_id) {
function theme_print_mail_format_link() {
$print_mail_link_class = variable_get('print_mail_link_class', PRINT_MAIL_LINK_CLASS_DEFAULT);
$print_mail_show_link = variable_get('print_mail_show_link', PRINT_MAIL_SHOW_LINK_DEFAULT);
$print_mail_link_text = variable_get('print_mail_link_text', t('Send to friend'));
$text = t('Send to friend');
$img = drupal_get_path('module', 'print') .'/icons/mail_icon.gif';
$title = t('Send this page by e-mail.');
$class = strip_tags($print_mail_link_class);
$new_window = FALSE;
$format = _print_format_link_aux($print_mail_show_link, $text, $img);
$format = _print_format_link_aux($print_mail_show_link, $print_mail_link_text, $img);
return array('text' => $format['text'],
'html' => $format['html'],
......@@ -302,12 +429,18 @@ function print_mail_link_allowed($args) {
}
elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
// Link is for a comment, return the configured setting
return variable_get('print_mail_display_comment_'. $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$res = db_query("SELECT comments FROM {print_mail_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
->fetch();
$print_display_comment = $res ? intval($res->comments) : PRINT_TYPE_COMMENT_LINK_DEFAULT;
if (($print_display_comment) ||
variable_get('print_mail_display_comment_'. $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT)) {
return PRINT_ALLOW_NORMAL_LINK;
}
}
else {
// Node link
if (isset($node_type) &&
!variable_get('print_mail_display_'. $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT)) {
if ((!$node->print_mail_display) || (isset($node_type) &&
!variable_get('print_mail_display_'. $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT))) {
// Link for this node type is disabled
return FALSE;
}
......
......@@ -55,6 +55,13 @@ function print_pdf_settings() {
'#description' => t('Select the visual style of the link.'),
);
$form['settings']['adv_link']['print_pdf_link_text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#default_value' => variable_get('print_pdf_link_text', t('PDF version')),
'#description' => t("Text used in the link to the PDF version."),
);
$form['settings']['adv_link']['print_pdf_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
......
......@@ -6,10 +6,19 @@
* Install file of the print_pdf module
*/
/**
* Implementation of hook_install().
*/
function print_pdf_install() {
drupal_install_schema('print_pdf');
}
/**
* Implementation of hook_uninstall().
*/
function print_pdf_uninstall() {
drupal_uninstall_schema('print_pdf');
variable_del('print_pdf_settings');
variable_del('print_pdf_show_link'