Commit fe25f54b authored by jcnventura's avatar jcnventura

Coder fixes

parent dd0fda21
......@@ -8,7 +8,7 @@
// * @page module-print modules/print: Printer, e-mail and PDF versions
/**
/**
* @mainpage Printer, e-mail and PDF versions
* Welcome to the print module developer's documentation. The interesting
* functions for themers are those that start with 'theme_'.
......
......@@ -26,7 +26,7 @@ function print_main_settings() {
'#default_value' => variable_get('print_css', PRINT_CSS_DEFAULT),
'#size' => 60,
'#maxlength' => 64,
'#description' => t('The URL to your custom print cascading stylesheet, if any. When none is specified, the default module CSS file is used.') .'<br />'.
'#description' => t('The URL to your custom print cascading stylesheet, if any. When none is specified, the default module CSS file is used.') . '<br />' .
t('Macros: %b (base path: "%base"), %t (path to theme: "%theme")', array('%base' => base_path(), '%theme' => path_to_theme())),
);
......@@ -34,7 +34,7 @@ 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.') .'<br />'.
'#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'))),
);
......@@ -148,7 +148,7 @@ function _print_main_settings_validate($form, &$form_state) {
// Check for a new uploaded logo, and use that instead.
if ($file = file_save_upload('print_logo_upload', array('file_validate_is_image' => array()))) {
$parts = pathinfo($file->filename);
$filename = 'print_logo.'. drupal_strtolower($parts['extension']);
$filename = 'print_logo.' . drupal_strtolower($parts['extension']);
// The image was saved using file_save_upload() and was added to the
// files table as a temporary file. We'll make a copy and let the garbage
......@@ -232,7 +232,7 @@ function print_html_settings() {
}
elseif ($access) {
$form['settings']['adv_link']['print_html_node_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$form['settings']['adv_link']['print_html_node_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_node_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_sys_link_visibility'] = array(
......@@ -246,7 +246,7 @@ function print_html_settings() {
'#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 />'.
'#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>')),
);
......@@ -256,7 +256,7 @@ function print_html_settings() {
}
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_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']['print_html_book_link'] = array(
......
......@@ -148,7 +148,7 @@ function print_update_6003() {
$t = get_t();
foreach ($vars as $name => $default) {
if (variable_get($name,'') == $t($default)) {
if (variable_get($name, '') == $t($default)) {
variable_del($name);
}
}
......
This diff is collapsed.
......@@ -27,9 +27,14 @@ function print_controller_html() {
$print = print_controller($path, $cid, PRINT_HTML_FORMAT);
if ($print !== FALSE) {
$node = $print['node'];
include_once(DRUPAL_ROOT .'/'. _print_get_template(PRINT_HTML_FORMAT, $print['type']));
include_once(DRUPAL_ROOT . '/' . _print_get_template(PRINT_HTML_FORMAT, $print['type']));
$nodepath = drupal_get_normal_path($node->path);
if (is_numeric($path)) {
$nodepath = 'node/' . $path;
}
else {
$nodepath = drupal_get_normal_path($path);
}
db_merge('print_page_counter')
->key(array('path' => $nodepath))
->fields(array(
......@@ -170,15 +175,15 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
$print['scripts'] = drupal_get_js();
$print['robots_meta'] = _print_robots_meta_generator();
$print['url'] = url($path, array('absolute' => TRUE));
$print['base_href'] = "<base href='". $print['url'] ."' />\n";
$print['favicon'] = theme_get_setting('toggle_favicon') ? "<link rel='shortcut icon' href='". theme_get_setting('favicon') ."' type='image/x-icon' />\n" : '';
$print['base_href'] = "<base href='" . $print['url'] . "' />\n";
$print['favicon'] = theme_get_setting('toggle_favicon') ? "<link rel='shortcut icon' href='" . theme_get_setting('favicon') . "' type='image/x-icon' />\n" : '';
if (!empty($print_css)) {
$replace_pairs = array('%b' => base_path(), '%t' => path_to_theme());
$user_css = strip_tags(strtr($print_css, $replace_pairs));
}
else {
drupal_add_css(drupal_get_path('module', 'print') .'/css/print.css');
drupal_add_css(drupal_get_path('module', 'print') . '/css/print.css');
}
$drupal_css = drupal_add_css();
foreach ($drupal_css as $key => $types) {
......@@ -197,7 +202,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
}
if (!empty($print_css)) {
// Convert to a local path, by removing the base_path
$pattern = '!^'. base_path() .'!';
$pattern = '!^' . base_path() . '!';
$css_files[] = preg_replace($pattern, '', $user_css);
}
foreach ($css_files as $filename) {
......@@ -235,7 +240,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
$footer = '';
break;
case 1: // theme's
$footer = filter_xss_admin(variable_get('site_footer', FALSE)) ."\n". theme('blocks', 'footer');
$footer = filter_xss_admin(variable_get('site_footer', FALSE)) . "\n" . theme('blocks', 'footer');
$logo_url = theme_get_setting('logo');
break;
case 2: // user-specifed
......@@ -248,7 +253,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
if ($published_site) {
$print_text_published = variable_get('print_text_published', t('Published on %site_name'));
$published = t($print_text_published, array('%site_name' => $published_site));
$print['site_name'] = $published .' ('. l($base_url, $base_url) .')';
$print['site_name'] = $published . ' (' . l($base_url, $base_url) . ')';
}
else {
$print['site_name'] = '';
......@@ -260,7 +265,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
$url = $print['url'];
}
else {
$url = $base_url .'/'. (((bool)variable_get('clean_url', '0')) ? '' : '?q=') . $path;
$url = $base_url . '/' . (((bool)variable_get('clean_url', '0')) ? '' : '?q=') . $path;
}
if (is_int($cid)) {
$url .= '#comment-$cid';
......@@ -271,7 +276,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
$print['printdate'] = $print_sourceurl_date ? " ($retrieved)" : '';
$source_url = variable_get('print_text_source_url', t('Source URL'));
$print['source_url'] = '<strong>'. $source_url . $print['printdate'] .':</strong> '. l($url, $url);
$print['source_url'] = '<strong>' . $source_url . $print['printdate'] . ':</strong> ' . l($url, $url);
}
else {
$print['source_url'] = '';
......@@ -320,7 +325,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
$pfp_links = '';
if ($max) {
for ($i = 0; $i < $max; $i++) {
$pfp_links .= '['. ($i + 1) .'] '. $urls[$i] ."<br />\n";
$pfp_links .= '[' . ($i + 1) . '] ' . $urls[$i] . "<br />\n";
}
$links = variable_get('print_text_links', t('Links'));
$print['pfp_links'] = "<p><strong>$links:</strong><br />$pfp_links</p>";
......@@ -394,11 +399,11 @@ function _print_rewrite_urls($matches) {
// URL is relative, convert it into absolute URL
if ($url[0] == '/') {
// If it starts with '/' just append it to the server name
$newurl = $base_root .'/'. trim(urldecode($url), '/');
$newurl = $base_root . '/' . trim(urldecode($url), '/');
}
elseif (preg_match('!^(?:index.php)?\?q=!i', $url)) {
// If it starts with ?q=, just prepend with the base URL
$newurl = $base_url .'/'. trim(urldecode($url), '/');
$newurl = $base_url . '/' . trim(urldecode($url), '/');
}
else {
$newurl = url(trim(urldecode($url), '/'), array('absolute' => TRUE));
......@@ -409,11 +414,11 @@ function _print_rewrite_urls($matches) {
}
}
$ret = '<'. $matches[1] .'>';
$ret = '<' . $matches[1] . '>';
if (count($matches) == 4) {
$ret .= $matches[2] . $matches[3];
if ((!empty($_print_urls)) && (isset($newurl))) {
$ret .= ' <span class="print-footnote">['. _print_friendly_urls(trim(stripslashes($newurl))) .']</span>';
$ret .= ' <span class="print-footnote">[' . _print_friendly_urls(trim(stripslashes($newurl))) . ']</span>';
}
}
......@@ -479,12 +484,12 @@ function _print_get_template($format = NULL, $type = NULL) {
foreach ($filenames as $value) {
// First in the theme directory
$file = drupal_get_path('theme', $GLOBALS['theme_key']) .'/'. $value;
$file = drupal_get_path('theme', $GLOBALS['theme_key']) . '/' . $value;
if (file_exists($file)) {
return $file;
}
// Then in the module directory
$file = drupal_get_path('module', 'print') .'/'. $value;
$file = drupal_get_path('module', 'print') . '/' . $value;
if (file_exists($file)) {
return $file;
}
......@@ -509,18 +514,18 @@ function _print_url_list_enabled($node, $format = PRINT_HTML_FORMAT) {
break;
case PRINT_MAIL_FORMAT:
$node_urllist = isset($node->print_mail_display_urllist) ? $node->print_mail_display_urllist : TRUE;
$fmt = $format .'_';
$fmt = $format . '_';
break;
case PRINT_PDF_FORMAT:
$node_urllist = isset($node->print_pdf_display_urllist) ? $node->print_pdf_display_urllist : TRUE;
$fmt = $format .'_';
$fmt = $format . '_';
break;
}
if (!isset($node_urllist)) $node_urllist = TRUE;
// Get value of Printer-friendly URLs setting
return (variable_get('print_urls', PRINT_URLS_DEFAULT) && ($node_urllist) &&
variable_get('print_'. $fmt .'display_urllist_'. $node->type, PRINT_TYPE_URLLIST_DEFAULT));
variable_get('print_' . $fmt . 'display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT));
}
/**
......@@ -601,7 +606,7 @@ function _print_generate_node($nid, $cid = NULL, $format = PRINT_HTML_FORMAT, $t
//Remove the comment forms
$comments = preg_replace('!<form.*?id="comment-.*?">.*?</form>!sim', '', $comments);
//Remove the 'Post new comment' title
$comments = preg_replace('!<h2.*?>'. t('Post new comment') .'</h2>!', '', $comments);
$comments = preg_replace('!<h2.*?>' . t('Post new comment') . '</h2>!', '', $comments);
//Remove the comment title hyperlink
$comments = preg_replace('!(<h3.*?>.*?)<a.*?>(.*?)</a>(.*?</h3>)!i', '$1$2$3', $comments);
//Remove the comment author link
......
......@@ -81,7 +81,7 @@ function print_mail_settings() {
}
elseif ($access) {
$form['settings']['adv_link']['print_mail_node_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$form['settings']['adv_link']['print_mail_node_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_node_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_sys_link_visibility'] = array(
......@@ -95,7 +95,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 e-mail 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>')),
);
......@@ -105,7 +105,7 @@ function print_mail_settings() {
}
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_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']['print_mail_book_link'] = array(
......
......@@ -135,7 +135,7 @@ function print_mail_update_6003() {
$t = get_t();
foreach ($vars as $name => $default) {
if (variable_get($name,'') == $t($default)) {
if (variable_get($name, '') == $t($default)) {
variable_del($name);
}
}
......
......@@ -95,7 +95,7 @@ function print_mail_block_view($delta = 0) {
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'] .= '<li>' . l(_print_get_title($obj->path), $obj->path) . '</li>';
}
$block['content'] .= '</ul></div>';
}
......@@ -112,13 +112,13 @@ function print_mail_node_view($node, $teaser) {
$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' => 'node', 'node' => $node, 'teaser' => $teaser));
if (($allowed_type) && !empty($print_mail_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
drupal_add_css(drupal_get_path('module', 'print') . '/css/printlinks.css');
$links = array();
$format = theme('print_mail_format_link');
// Show book link
if ($allowed_type === PRINT_ALLOW_BOOK_LINK) {
$links['book_mail'] = array('href' => PRINTMAIL_PATH .'/book/export/html/'. $node->nid,
$links['book_mail'] = array('href' => PRINTMAIL_PATH . '/book/export/html/' . $node->nid,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
......@@ -133,13 +133,13 @@ function print_mail_node_view($node, $teaser) {
if (empty($query)) $query = NULL;
if ($print_mail_link_use_alias) {
$path = drupal_get_path_alias('node/'. $node->nid);
$path = drupal_get_path_alias('node/' . $node->nid);
}
else {
$path = $node->nid;
}
$links['print_mail'] = array('href' => PRINTMAIL_PATH .'/'. $path,
$links['print_mail'] = array('href' => PRINTMAIL_PATH . '/' . $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
......@@ -221,11 +221,11 @@ function print_mail_node_delete($node) {
*/
function print_mail_form_alter(&$form, $form_state, $form_id) {
// Add the node-type settings option to activate the mail version link
if ((user_access('administer print') || user_access('node-specific print configuration')) &&
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>',
'#markup' => '<p><strong>' . t('Send by e-mail') . '</strong></p>',
);
$form['print']['print_mail_display'] = array(
......@@ -242,9 +242,9 @@ function print_mail_form_alter(&$form, $form_state, $form_id) {
);
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);
$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 {
$node = $form['#node'];
......@@ -264,7 +264,7 @@ function print_mail_form_alter(&$form, $form_state, $form_id) {
function _print_mail_set_node_fields(&$node) {
if (isset($node->nid)) {
$res = db_query("SELECT link, comments, url_list FROM {print_mail_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
->fetch();
->fetch();
}
else {
$res = FALSE;
......@@ -318,7 +318,7 @@ function theme_print_mail_format_link() {
$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'));
$img = drupal_get_path('module', 'print') .'/icons/mail_icon.gif';
$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;
......@@ -348,7 +348,7 @@ function theme_print_mail_format_link() {
function print_mail_insert_link($path = NULL, $node = NULL) {
if ($node !== NULL) {
$nid = $node->nid;
$path = 'node/'. $nid;
$path = 'node/' . $nid;
$allowed_type = print_mail_link_allowed(array('node' => $node));
}
else {
......@@ -365,7 +365,7 @@ function print_mail_insert_link($path = NULL, $node = NULL) {
if ($allowed_type) {
if ($nid !== NULL) {
if ($allowed_type === PRINT_ALLOW_BOOK_LINK) {
$path = 'book/export/html/'. $nid;
$path = 'book/export/html/' . $nid;
}
else {
if (variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT)) {
......@@ -375,7 +375,7 @@ function print_mail_insert_link($path = NULL, $node = NULL) {
$path = $nid;
}
}
$path = PRINTMAIL_PATH .'/'. $path;
$path = PRINTMAIL_PATH . '/' . $path;
$query = print_query_string_encode($_GET, array('q'));
if (empty($query)) {
$query = NULL;
......@@ -384,9 +384,9 @@ function print_mail_insert_link($path = NULL, $node = NULL) {
else {
$query = NULL;
}
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
drupal_add_css(drupal_get_path('module', 'print') . '/css/printlinks.css');
$format = theme('print_mail_format_link');
return '<span class="print_mail">'. l($format['text'], $path, array('attributes' => $format['attributes'], 'query' => $query, 'absolute' => TRUE, 'html' => $format['html'])) .'</span>';
return '<span class="print_mail">' . l($format['text'], $path, array('attributes' => $format['attributes'], 'query' => $query, 'absolute' => TRUE, 'html' => $format['html'])) . '</span>';
}
else {
return FALSE;
......@@ -439,17 +439,17 @@ 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
$res = db_query("SELECT comments FROM {print_mail_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
->fetch();
->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)) {
variable_get('print_mail_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT)) {
return PRINT_ALLOW_NORMAL_LINK;
}
}
else {
// Node link
if ((!$node->print_mail_display) || (isset($node_type) &&
!variable_get('print_mail_display_'. $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT))) {
!variable_get('print_mail_display_' . $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT))) {
// Link for this node type is disabled
return FALSE;
}
......
......@@ -93,7 +93,7 @@ function print_pdf_settings() {
}
elseif ($access) {
$form['settings']['adv_link']['print_pdf_node_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$form['settings']['adv_link']['print_pdf_node_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_pdf_node_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_pdf_sys_link_visibility'] = array(
......@@ -107,7 +107,7 @@ function print_pdf_settings() {
'#type' => 'textarea',
'#default_value' => variable_get('print_pdf_sys_link_pages', PRINT_PDF_SYS_LINK_PAGES_DEFAULT),
'#rows' => 3,
'#description' => t('Setting this option will add a PDF version page link on pages created by Drupal or the enabled modules.') .'<br />'.
'#description' => t('Setting this option will add a PDF 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>')),
);
......@@ -117,7 +117,7 @@ function print_pdf_settings() {
}
elseif ($access) {
$form['settings']['adv_link']['print_pdf_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$form['settings']['adv_link']['print_pdf_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_pdf_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']['print_pdf_book_link'] = array(
......@@ -170,7 +170,7 @@ function print_pdf_settings() {
'#default_value' => variable_get('print_pdf_font_family', PRINT_PDF_FONT_FAMILY_DEFAULT),
'#size' => 60,
'#maxlength' => 250,
'#description' => t('(TCPDF only) Set the font family to be used. Examples: %examples.', array('%examples' => 'helvetica, times, courier, dejavusans, dejavuserif, freesans, freeserif, freemono')) .'<br />'.
'#description' => t('(TCPDF only) Set the font family to be used. Examples: %examples.', array('%examples' => 'helvetica, times, courier, dejavusans, dejavuserif, freesans, freeserif, freemono')) . '<br />' .
t("CAUTION: TCPDF embeds the complete font in the generated PDF. If you're not using Unicode, then helvetica or times are safe choices that will keep the PDF small. Unicode fonts can increase the size of the PDF to the 1MB region."),
);
$form['settings']['print_pdf_font_size'] = array(
......@@ -198,12 +198,12 @@ function print_pdf_settings() {
$tokens = token_get_list('node');
foreach ($tokens as $token) {
foreach ($token as $key => $val) {
$descriptions .= '<dt>['. $key .']</dt><dd>'. $val ."</dd>\n";
$descriptions .= '<dt>[' . $key . ']</dt><dd>' . $val . "</dd>\n";
}
}
$form['settings']['print_pdf_filename_patterns']['descriptions'] = array(
'#type' => 'markup',
'#markup' => "<dl>\n". $descriptions ."</dl>\n",
'#markup' => "<dl>\n" . $descriptions . "</dl>\n",
);
}
$form['#validate'][] = '_print_pdf_settings_validate';
......@@ -211,7 +211,7 @@ function print_pdf_settings() {
else {
$form['settings'] = array(
'#type' => 'markup',
'#markup' => '<p>'. t("No PDF generation tool found! Please dowload a supported PHP PDF generation tool. Check this module's INSTALL.txt for more details.") .'</p>',
'#markup' => '<p>' . t("No PDF generation tool found! Please dowload a supported PHP PDF generation tool. Check this module's INSTALL.txt for more details.") . '</p>',
);
}
......
......@@ -119,7 +119,7 @@ function print_pdf_update_6003() {
$t = get_t();
foreach ($vars as $name => $default) {
if (variable_get($name,'') == $t($default)) {
if (variable_get($name, '') == $t($default)) {
variable_del($name);
}
}
......
......@@ -113,7 +113,7 @@ function print_pdf_block_view($delta = 0) {
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'] .= '<li>' . l(_print_get_title($obj->path), $obj->path) . '</li>';
}
$block['content'] .= '</ul></div>';
}
......@@ -136,7 +136,7 @@ function print_pdf_requirements($phase) {
$requirements['print_pdf_tool'] = array(
'title' => $t('PDF version'),
'value' => $t('No PDF tool selected'),
'description' => $t('Please configure it in the <a href="@url">PDF settings page</a>.', array('@url' => url('admin/settings/print/pdf'))),
'description' => $t('Please configure it in the <a href="@url">PDF settings page</a>. ', array('@url' => url('admin/settings/print/pdf'))),
'severity' => REQUIREMENT_ERROR,
);
}
......@@ -153,13 +153,13 @@ function print_pdf_node_view($node, $teaser) {
$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' => 'node', 'node' => $node, 'teaser' => $teaser));
if (($allowed_type) && !empty($print_pdf_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
drupal_add_css(drupal_get_path('module', 'print') . '/css/printlinks.css');
$links = array();
$format = theme('print_pdf_format_link');
// Show book link
if ($allowed_type === PRINT_ALLOW_BOOK_LINK) {
$links['book_pdf'] = array('href' => PRINTPDF_PATH .'/book/export/html/'. $node->nid,
$links['book_pdf'] = array('href' => PRINTPDF_PATH . '/book/export/html/' . $node->nid,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
......@@ -174,13 +174,13 @@ function print_pdf_node_view($node, $teaser) {
if (empty($query)) $query = NULL;
if ($print_pdf_link_use_alias) {
$path = drupal_get_path_alias('node/'. $node->nid);
$path = drupal_get_path_alias('node/' . $node->nid);
}
else {
$path = $node->nid;
}
$links['print_pdf'] = array('href' => PRINTPDF_PATH .'/'. $path,
$links['print_pdf'] = array('href' => PRINTPDF_PATH . '/' . $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
......@@ -261,11 +261,11 @@ function print_pdf_node_delete($node) {
*/
function print_pdf_form_alter(&$form, $form_state, $form_id) {
// Add the node-type settings option to activate the PDF version link
if ((user_access('administer print') || user_access('node-specific print configuration')) &&
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>',
'#markup' => '<p><strong>' . t('PDF version') . '</strong></p>',
);
$form['print']['print_pdf_display'] = array(
......@@ -282,9 +282,9 @@ function print_pdf_form_alter(&$form, $form_state, $form_id) {
);
if ($form_id == 'node_type_form') {
$form['print']['print_pdf_display']['#default_value'] = variable_get('print_pdf_display_'. $form['#node_type']->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$form['print']['print_pdf_display_comment']['#default_value'] = variable_get('print_pdf_display_comment_'. $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$form['print']['print_pdf_display_urllist']['#default_value'] = variable_get('print_pdf_display_urllist_'. $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT);
$form['print']['print_pdf_display']['#default_value'] = variable_get('print_pdf_display_' . $form['#node_type']->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$form['print']['print_pdf_display_comment']['#default_value'] = variable_get('print_pdf_display_comment_' . $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$form['print']['print_pdf_display_urllist']['#default_value'] = variable_get('print_pdf_display_urllist_' . $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT);
}
else {
$node = $form['#node'];
......@@ -304,7 +304,7 @@ function print_pdf_form_alter(&$form, $form_state, $form_id) {
function _print_pdf_set_node_fields(&$node) {
if (isset($node->nid)) {
$res = db_query("SELECT link, comments, url_list FROM {print_pdf_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
->fetch();
->fetch();
}
else {
$res = FALSE;
......@@ -359,7 +359,7 @@ function theme_print_pdf_format_link() {
$print_pdf_show_link = variable_get('print_pdf_show_link', PRINT_PDF_SHOW_LINK_DEFAULT);
$print_pdf_link_text = variable_get('print_pdf_link_text', t('PDF version'));
$img = drupal_get_path('module', 'print') .'/icons/pdf_icon.gif';
$img = drupal_get_path('module', 'print') . '/icons/pdf_icon.gif';
$title = t('Display a PDF version of this page.');
$class = strip_tags($print_pdf_link_class);
$new_window = ($print_pdf_content_disposition == 1);
......@@ -389,7 +389,7 @@ function theme_print_pdf_format_link() {
function print_pdf_insert_link($path = NULL, $node = NULL) {
if ($node !== NULL) {
$nid = $node->nid;
$path = 'node/'. $nid;
$path = 'node/' . $nid;
$allowed_type = print_pdf_link_allowed(array('node' => $node));
}
else {
......@@ -406,7 +406,7 @@ function print_pdf_insert_link($path = NULL, $node = NULL) {
if ($allowed_type) {
if ($nid !== NULL) {
if ($allowed_type === PRINT_ALLOW_BOOK_LINK) {
$path = 'book/export/html/'. $nid;
$path = 'book/export/html/' . $nid;
}
else {
if (variable_get('print_pdf_link_use_alias', PRINT_PDF_LINK_USE_ALIAS_DEFAULT)) {
......@@ -416,7 +416,7 @@ function print_pdf_insert_link($path = NULL, $node = NULL) {
$path = $nid;
}
}
$path = PRINTPDF_PATH .'/'. $path;
$path = PRINTPDF_PATH . '/' . $path;
$query = print_query_string_encode($_GET, array('q'));
if (empty($query)) {
$query = NULL;
......@@ -425,9 +425,9 @@ function print_pdf_insert_link($path = NULL, $node = NULL) {
else {
$query = NULL;
}
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
drupal_add_css(drupal_get_path('module', 'print') . '/css/printlinks.css');
$format = theme('print_pdf_format_link');
return '<span class="print_pdf">'. l($format['text'], $path, array('attributes' => $format['attributes'], 'query' => $query, 'absolute' => TRUE, 'html' => $format['html'])) .'</span>';
return '<span class="print_pdf">' . l($format['text'], $path, array('attributes' => $format['attributes'], 'query' => $query, 'absolute' => TRUE, 'html' => $format['html'])) . '</span>';
}
else {
return FALSE;
......@@ -481,17 +481,17 @@ function print_pdf_link_allowed($args) {
elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
// Link is for a comment, return the configured setting
$res = db_query("SELECT comments FROM {print_pdf_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))
->fetch();
->fetch();
$print_display_comment = $res ? intval($res->comments) : PRINT_TYPE_COMMENT_LINK_DEFAULT;
if (($print_display_comment) ||
variable_get('print_pdf_display_comment_'. $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT)) {
variable_get('print_pdf_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT)) {
return PRINT_ALLOW_NORMAL_LINK;
}
}
else {
// Node link
if ((!$node->print_pdf_display) || (isset($node_type) &&
!variable_get('print_pdf_display_'. $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT))) {
!variable_get('print_pdf_display_' . $node_type, PRINT_TYPE_SHOW_LINK_DEFAULT))) {
// Link for this node type is disabled
return FALSE;
}
......
......@@ -9,7 +9,7 @@
* functions that interface with the PDF generation packages.
*/
require_once(DRUPAL_ROOT .'/'. drupal_get_path('module', 'print') .'/print.pages.inc');
require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'print') . '/print.pages.inc');
/**
* Generate a PDF version of the printer-friendly page
......@@ -55,7 +55,7 @@ function print_pdf_controller() {
break;
}
$pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?system/files(/[^>]*?>)!is";
$replacement = '$1file://'. realpath(file_directory_path()) .'$2';
$replacement = '$1file://' . realpath(file_directory_path()) . '$2';
$print['content'] = preg_replace($pattern, $replacement, $print['content']);
$print['logo'] = preg_replace($pattern, $replacement, $print['logo']);
$print['footer_message'] = preg_replace($pattern, $replacement, $print['footer_message']);
......@@ -63,7 +63,7 @@ function print_pdf_controller() {
$node = $print['node'];
ob_start();
include_once(DRUPAL_ROOT .'/'. _print_get_template(PRINT_PDF_FORMAT, $print['type']));
include_once(DRUPAL_ROOT . '/' . _print_get_template(PRINT_PDF_FORMAT, $print['type']));
$html = ob_get_contents();
ob_end_clean();
......@@ -73,10 +73,10 @@ function print_pdf_controller() {
$pdf_filename = variable_get('print_pdf_filename', PRINT_PDF_FILENAME_DEFAULT);
if (function_exists('token_replace') && !empty($pdf_filename)) {
$pdf_filename = token_replace($pdf_filename, 'node', $node) .'.pdf';
$pdf_filename = token_replace($pdf_filename, 'node', $node) . '.pdf';
}
else {
$pdf_filename = str_replace('/', '_', $path) .'.pdf';
$pdf_filename = str_replace('/', '_', $path) . '.pdf';
}
if (basename($print_pdf_pdf_tool) == 'dompdf_config.inc.php') {
_print_pdf_dompdf($print, $html, $pdf_filename);
......@@ -115,16 +115,16 @@ function _print_pdf_dompdf($print, $html, $filename) {
$print_pdf_paper_size = variable_get('print_pdf_paper_size', PRINT_PDF_PAPER_SIZE_DEFAULT);
$print_pdf_page_orientation = variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT);
$print_pdf_content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT);
require_once(DRUPAL_ROOT .'/'. $print_pdf_pdf_tool);
require_once(DRUPAL_ROOT . '/' . $print_pdf_pdf_tool);
// dompdf seems to have problems with something in system.css so let's not use it
$html = preg_replace('!<link.*?modules/system/system.css.*?/>!', '', $html);
$url_array = parse_url($print['url']);
$protocol = $url_array['scheme'] .'://';
$protocol = $url_array['scheme'] . '://';
$host = $url_array['host'];
$path = dirname($url_array['path']) .'/';
$path = dirname($url_array['path']) . '/';
$dompdf = new DOMPDF();
$dompdf->set_base_path($path);
......@@ -174,16 +174,16 @@ function _print_pdf_tcpdf($print, $html, $filename) {
define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
define('K_PATH_MAIN', dirname($_SERVER['SCRIPT_FILENAME']));
define('K_PATH_URL', $base_url);
define('K_PATH_FONTS', $pdf_tool_path .'/fonts/');
define('K_PATH_CACHE', $pdf_tool_path .'/cache/');
define('K_PATH_FONTS', $pdf_tool_path . '/fonts/');
define('K_PATH_CACHE', $pdf_tool_path . '/cache/');