Commit a43c9735 authored by jcnventura's avatar jcnventura

Update changelog

Fix #349991 by moshe weitzman: Use node build_mode instead of custom property for customizing node fields
Fix #351043: Add specific permission to edit the node-specific settings
Fix #356073: Check for CSS file before expanding it and replace spaces with %20 in mails sent
Use integers as SQL int default values instead of strings
parent fc341830
January 14, 2009
Update changelog
Fix #349991 by moshe weitzman: Use node build_mode instead of custom property for customizing node fields
Fix #351043: Add specific permission to edit the node-specific settings
Fix #356073: Check for CSS file before expanding it and replace spaces with %20 in mails sent
Use integers as SQL int default values instead of strings
December 17, 2008
Add PHP visibility option
Move cache disabling code to print_controller() instead of print_pdf_init()
December 16, 2008
Fix #347518: nid is not yet set in node prepare
December 13, 2008
Remove AdSense module's ads from the output
Updated Spanish translation by gusgsm1
Updated Portuguese translation
December 12, 2008
Use new node_load argument interface
Simplify hook_mail
December 10, 2008
Update changelog
Update translations
......
......@@ -34,7 +34,8 @@ function print_main_settings() {
'#type' => 'checkbox',
'#title' => t('Printer-friendly URLs list'),
'#default_value' => variable_get('print_urls', PRINT_URLS_DEFAULT),
'#description' => t('If set, a list of the destination URLs for the page links will be displayed at the bottom of the page.'),
'#description' => t('If set, a list of the destination URLs for the page links will be displayed at the bottom of the page.') .'<br />'.
t('Note that you can enable/disable the URL list for each content type individually from the !url.', array('!url' => l(t('Content Types page'),'admin/build/types'))),
);
$form['settings']['print_comments'] = array(
......
......@@ -81,21 +81,21 @@ function print_schema() {
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'default' => 1,
'size' => 'tiny',
),
'comments' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'default' => 1,
'size' => 'tiny',
),
'url_list' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'default' => 1,
'size' => 'tiny',
),
),
......
......@@ -62,6 +62,10 @@ function print_perm() {
'title' => t('Administer the module'),
'description' => t('Perform maintenance tasks for the print module.'),
),
'node-specific print configuration' => array(
'title' => t('Node-specific configuration'),
'description' => t('Enable access to the per-node settings.'),
),
'use PHP for link visibility' => array(
'title' => t('Use PHP for link visibility'),
'description' => t('Enables the use of PHP code to configure the link visibility.'),
......@@ -320,7 +324,8 @@ function print_nodeapi_delete(&$node, $teaser, $page) {
*/
function print_form_alter(&$form, $form_state, $form_id) {
// Add the node-type settings option to activate the printer-friendly version link
if (($form_id == 'node_type_form') || !empty($form['#node_edit_form'])) {
if ((user_access('administer print') || user_access('node-specific print configuration')) &&
(($form_id == 'node_type_form') || !empty($form['#node_edit_form']))) {
$form['print'] = array(
'#type' => 'fieldset',
'#title' => t('Printer, e-mail and PDF versions'),
......@@ -743,3 +748,52 @@ function print_query_string_encode($query, $exclude = array(), $parent = '') {
return implode('&', $params);
}
/**
* Implementation of hook_content_build_modes()
*
* @return
* An array describing the build modes used by the module.
* They are grouped by secondary tabs on CCK's 'Display fields' screens.
*
* Expected format:
* array(
* // The first level keys (tab1_url, tab2_url) will be used to generate
* // the url of the tab: admin/content/node-type/[type_name]/display/[tab1_url]
* // A module can add its render modes to a tab defined by another module.
* // In this case, there's no need to provide a 'title' for this tab.
* 'tab1_url' => array(
* 'title' => t('The human-readable title of the tab'),
* 'build modes' => array(
* // The keys of the 'context' array are the values used in $node->build_mode.
* 'mymodule_mode1' => array(
* 'title' => t('The human-readable name of the build mode'),
* // The 'views style' property determines if the render mode should be
* // available as an option in Views' 'node' row style (not implemented yet).
* 'views style' => TRUE,
* ),
* 'mymodule_mode2' => array(
* 'title' => t('Mode 2'),
* 'views style' => TRUE,
* ),
* ),
* ),
* 'tab2_url' => array(
* // ...
* ),
* );
*/
function print_content_build_modes() {
return array(
'print' => array(
'title' => t('Print'),
'build modes' => array(
'print' => array(
'title' => t('Print'),
'views style' => FALSE,
),
),
),
);
}
......@@ -201,7 +201,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
$css_files[] = preg_replace($pattern, '', $user_css);
}
foreach ($css_files as $filename) {
$res = file_get_contents($filename, TRUE);
$res = file_exists($filename) ? file_get_contents($filename, TRUE) : FALSE;
if ($res != FALSE) {
$style .= $res;
}
......@@ -555,7 +555,11 @@ function _print_generate_node($nid, $cid = NULL, $format = PRINT_HTML_FORMAT, $t
drupal_set_title($node->title, PASS_THROUGH);
//alert other modules that we are generating a printer-friendly page, so they can choose to show/hide info
// TODO: Remove this in favor of PRINT_BUILD_MODE
$node->printing = TRUE;
$node->build_mode = 'print';
// Turn off Pagination by the Paging module
unset($node->pages);
unset($node->page_count);
......
......@@ -21,7 +21,7 @@ function print_mail_form($form_state) {
$print_mail_hourly_threshold = variable_get('print_mail_hourly_threshold', PRINT_MAIL_HOURLY_THRESHOLD);
if (!flood_is_allowed('print_mail', $print_mail_hourly_threshold)) {
if (($user->uid != 1) && (!flood_is_allowed('print_mail', $print_mail_hourly_threshold))) {
$form['flood'] = array(
'#type' => 'markup',
'#markup' => '<p>'. t('You cannot send more than %number messages per hour. Please try again later.', array('%number' => $print_mail_hourly_threshold)) .'</p>',
......@@ -230,6 +230,11 @@ function print_mail_form_submit($form, &$form_state) {
$sender_message = $print_mail_text_message .':<br /><br /><em>'. nl2br($form_state['values']['txt_message']) .'</em>';
$print = print_controller($form_state['values']['path'], $cid, PRINT_MAIL_FORMAT, $form_state['values']['chk_teaser'], $sender_message);
// Spaces in img URLs must be replaced with %20
$pattern = '!<(img\s[^>]*?)>!is';
$print['content'] = preg_replace_callback($pattern, '_print_mail_encode_urls', $print['content']);
if ($print !== FALSE) {
$params = array();
$params['subject'] = $form_state['values']['fld_subject'];
......@@ -284,3 +289,39 @@ function print_mail_mail($key, &$message, $params) {
function print_mail_form_cancel($form, &$form_state) {
$form_state['redirect'] = preg_replace('!^book/export/html/!', 'node/', $form_state['values']['path']);
}
/**
* Callback function for the preg_replace_callback replacing spaces with %20
*
* Replace spaces in URLs with %20
*
* @param $matches
* array with the matched tag patterns, usually <a...>+text+</a>
* @return
* tag with re-written URL
*/
function _print_mail_encode_urls($matches) {
// first, split the html into the different tag attributes
$pattern = '!\s*(\w+\s*=\s*"(?:\\\"|[^"])*")\s*|\s*(\w+\s*=\s*\'(?:\\\\\'|[^\'])*\')\s*|\s*(\w+\s*=\s*\w+)\s*|\s+!';
$attribs = preg_split($pattern, $matches[1], -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
foreach ($attribs as $key => $value) {
$attribs[$key] = preg_replace('!(\w)\s*=\s*(.*)!', '$1=$2', $value);
}
$size = count($attribs);
for ($i=1; $i < $size; $i++) {
// If the attribute is href or src, we may need to rewrite the URL in the value
if (preg_match('!^(?:href|src)\s*?=(.*)!i', $attribs[$i], $urls) > 0) {
$url = trim($urls[1], " \t\n\r\0\x0B\"'");
$new_url = str_replace(' ', '%20', $url);
$matches[1] = str_replace($url, $new_url, $matches[1]);
}
}
$ret = '<'. $matches[1] .'>';
if (count($matches) == 4) {
$ret .= $matches[2] . $matches[3];
}
return $ret;
}
......@@ -57,21 +57,21 @@ function print_mail_schema() {
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'default' => 1,
'size' => 'tiny',
),
'comments' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'default' => 1,
'size' => 'tiny',
),
'url_list' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'default' => 1,
'size' => 'tiny',
),
),
......
......@@ -219,7 +219,8 @@ function print_mail_nodeapi_delete(&$node, $teaser, $page) {
*/
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') || !empty($form['#node_edit_form'])) {
if ((user_access('administer print') || user_access('node-specific print configuration')) &&
(($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>',
......
......@@ -58,21 +58,21 @@ function print_pdf_schema() {
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'default' => 1,
'size' => 'tiny',
),
'comments' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'default' => 1,
'size' => 'tiny',
),
'url_list' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '1',
'default' => 1,
'size' => 'tiny',
),
),
......
......@@ -260,7 +260,8 @@ function print_pdf_nodeapi_delete(&$node, $teaser, $page) {
*/
function print_pdf_form_alter(&$form, $form_state, $form_id) {
// Add the node-type settings option to activate the PDF version link
if (($form_id == 'node_type_form') || !empty($form['#node_edit_form'])) {
if ((user_access('administer print') || user_access('node-specific print configuration')) &&
(($form_id == 'node_type_form') || !empty($form['#node_edit_form']))) {
$form['print']['pdf_label'] = array(
'#type' => 'markup',
'#markup' => '<p><strong>'. t('PDF version') .'</strong></p>',
......
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