diff --git a/CREDITS.txt b/CREDITS.txt index 62846f2..ae11fb7 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1,5 +1,5 @@ -This module was created by Matt Westgate -Maintained up to version 4.6 by Karsten Mueller -Maintained up to version 4.7 by Peter John Hartman -Some bug fixes by David Kent Norman on Dec 20, 2005 -and is currently maintained by Joao Ventura . +This module was created by Matt Westgate +Maintained up to version 4.6 by Karsten Mueller +Maintained up to version 4.7 by Peter John Hartman +Some bug fixes by David Kent Norman on Dec 20, 2005 +and is currently maintained by Joao Ventura . diff --git a/README.txt b/README.txt index f8e37ad..5c6ea92 100644 --- a/README.txt +++ b/README.txt @@ -42,7 +42,8 @@ CONFIGURATION comments via the "Show printer-friendly version link in individual comments" checkbox. (default: disabled) - Administration > Configuration > User interface > Printer, email and PDF versions (admin/config/user-interface/print) + Administration > Configuration > User interface > Printer, + email and PDF versions (admin/config/user-interface/print) This is where all the module-specific configuration options can be set. - To modify the template of printer friendly pages, simply edit the @@ -121,4 +122,3 @@ ACKNOWLEDGMENTS --------------- The print, pdf and mail icons are copyright Plone Foundation. Thanks for letting me use them! - diff --git a/css/print.css b/css/print.css index 10ff31c..c46c439 100644 --- a/css/print.css +++ b/css/print.css @@ -42,13 +42,9 @@ a:visited img { img.print-logo { border: 0; } -.print-site_name { -} .print-breadcrumb { font-size: x-small; } -.print-title { -} .print-submitted { font-size: small; } @@ -61,8 +57,6 @@ img.print-logo { .print-taxonomy li { display: inline; } -.print-content { -} .print-hr { border: 0; height: 1px; diff --git a/includes/print.drush.inc b/includes/print.drush.inc index e936a81..431f1dc 100644 --- a/includes/print.drush.inc +++ b/includes/print.drush.inc @@ -31,7 +31,8 @@ function _print_drush_download_lib($library, $url) { // Warn about an existing dir. if (is_dir($library)) { - drush_log(dt('An existing @library was overwritten at @path', array('@library' => $library, '@path' => $path . '/' . $library)), 'notice'); + drush_log(dt('An existing @library was overwritten at @path', + array('@library' => $library, '@path' => $path . '/' . $library)), 'notice'); } if (preg_match('!api.github.com/repos/.*/releases/latest!', $url)) { @@ -45,7 +46,8 @@ function _print_drush_download_lib($library, $url) { if ($extract_ret) { // Remove the archive. drush_op('unlink', $filename); - drush_log(dt('@file has been downloaded and extracted in @path', array('@file' => $filename, '@path' => $path)), 'success'); + drush_log(dt('@file has been downloaded and extracted in @path', + array('@file' => $filename, '@path' => $path)), 'success'); } else { drush_log(dt('@file has been downloaded to @path, but extract failed. Check that you have the necessary program installed, and if necessary extract it manually.', @@ -53,7 +55,8 @@ function _print_drush_download_lib($library, $url) { } } else { - drush_log(dt('Drush was unable to download @library to @path', array('@library' => $library, '@path' => $path)), 'error'); + drush_log(dt('Drush was unable to download @library to @path', + array('@library' => $library, '@path' => $path)), 'error'); } // Set working directory back to the previous working directory. diff --git a/includes/print.inc b/includes/print.inc index 66e7519..68b4efc 100644 --- a/includes/print.inc +++ b/includes/print.inc @@ -82,7 +82,7 @@ function _print_replace_spaces($matches) { * converted file names */ function _print_access_images_via_file($html, $images_via_file) { - global $base_url, $language; + global $base_url; $dom = new DOMDocument(); // Suppress warnings for invalid HTML. @@ -91,7 +91,7 @@ function _print_access_images_via_file($html, $images_via_file) { $image_tags = $dom->getElementsByTagName('img'); foreach ($image_tags as $image_tag) { $image_relative_tag_src = str_replace($base_url, '', $image_tag->getAttribute('src')); - $file_private_path = variable_get('file_private_path', ''); + // $file_private_path = variable_get('file_private_path', ''); $is_private_file = (strpos($image_relative_tag_src, '/system/files') === 0); if ($is_private_file) { diff --git a/print.admin.inc b/print.admin.inc index eee2040..ebfadb8 100644 --- a/print.admin.inc +++ b/print.admin.inc @@ -39,10 +39,10 @@ function print_main_settings() { '#size' => 60, '#maxlength' => 250, '#description' => t('The path to your custom print cascading stylesheet, if any. The path provided must be relative to the base path. When none is specified, the default module CSS file is used.') . '
' . - t('Macros: %t (path to theme: "%theme")', array( - '%theme' => drupal_get_path('theme', variable_get('theme_default', 'bartik')), - )) . '
' . - t('Requires the Administer site configuration permission.'), + t('Macros: %t (path to theme: "%theme")', array( + '%theme' => drupal_get_path('theme', variable_get('theme_default', 'bartik')), + )) . '
' . + t('Requires the Administer site configuration permission.'), '#disabled' => !user_access('administer site configuration'), ); @@ -58,9 +58,9 @@ function print_main_settings() { '#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.') . '
' . - 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/structure/types'), - )), + 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/structure/types'), + )), ); $form['settings']['print_urls_anchors'] = array( @@ -87,7 +87,10 @@ function print_main_settings() { $form['settings']['print_newwindow'] = array( '#type' => 'radios', '#title' => t('New window method'), - '#options' => array(t('Use HTML target (does not validate as XHTML Strict)'), t('Use Javascript (requires browser support)')), + '#options' => array( + t('Use HTML target (does not validate as XHTML Strict)'), + t('Use Javascript (requires browser support)'), + ), '#default_value' => variable_get('print_newwindow', PRINT_NEWWINDOW_DEFAULT), '#description' => t('Choose the method used to open pages in a new window/tab.'), ); diff --git a/print.module b/print.module index 33a2cb9..8412997 100644 --- a/print.module +++ b/print.module @@ -189,7 +189,7 @@ function print_variable_info($options) { 'title' => t('Printer-friendly version'), 'description' => t('Text used in the link to the printer-friendly version.'), 'type' => 'string', - 'default' => t($link['text']), + 'default' => ($link['text']), ); return $variable; @@ -220,7 +220,8 @@ function print_block_view($delta = '') { foreach ($result as $obj) { $items[] = l(_print_get_title($obj->path), $obj->path); } - $block['content'] = theme('item_list', array('items' => $items, 'type' => 'ul')); + $block['content'] = theme('item_list', + array('items' => $items, 'type' => 'ul')); } break; } @@ -277,8 +278,8 @@ For Link options.
This includes options for link style and position.

format is either html, mail or pdf, and type is Drupal's node content type e.g. article, page etc.

For more information, consult the !documentlink at www.drupal.org and see the README.txt and INSTALL.txt files.

", -array('!documentlink' => l(t('Print module documentation'), 'http://drupal.org/node/190171'))); - } + array('!documentlink' => l(t('Print module documentation'), 'http://drupal.org/node/190171'))); + } return $ret; } diff --git a/print.pages.inc b/print.pages.inc index 20e3545..cd0e4ed 100644 --- a/print.pages.inc +++ b/print.pages.inc @@ -183,13 +183,16 @@ function print_preprocess_print(&$variables) { $variables['scripts'] = drupal_get_js(); $variables['footer_scripts'] = drupal_get_js('footer'); $variables['sourceurl_enabled'] = variable_get('print_sourceurl_enabled', PRINT_SOURCEURL_ENABLED_DEFAULT); - $variables['url'] = url($path, array('absolute' => TRUE, 'query' => $variables['query'])); + $variables['url'] = url($path, array( + 'absolute' => TRUE, + 'query' => $variables['query'], + )); $variables['source_url'] = url(variable_get('print_sourceurl_forcenode', PRINT_SOURCEURL_FORCENODE_DEFAULT) ? drupal_get_normal_path($path) : $path, array( 'alias' => TRUE, 'absolute' => TRUE, 'query' => $variables['query'], )); - $variables['cid'] = isset($node->cid) ? $node->cid : NULL; + $variables['cid'] = $node->cid ?? NULL; $variables['print_title'] = html_entity_decode(check_plain($node->title)); $variables['head'] = drupal_get_html_head(); $variables['robots_meta'] = _print_robots_meta_generator(); @@ -325,7 +328,7 @@ function theme_print_sourceurl($vars) { $output .= ')'; } $new_url = explode($base_url, $url); - $output .= ':' ."". $url . ''; + $output .= ':' . "" . $url . ''; return $output; } @@ -354,7 +357,7 @@ function theme_print_url_list($vars) { foreach ($urls as $key => $url) { drupal_alter('print_url_list', $url); $new_url = explode($base_url, $url); - $url_list .= "". '[' . ($key + 1) . '] ' . check_plain($url) . "\n"; + $url_list .= "" . '[' . ($key + 1) . '] ' . check_plain($url) . "\n"; } if (!empty($url_list)) { return "

" . t('Links') . "
$url_list

"; @@ -584,11 +587,11 @@ function _print_url_list_enabled($node, $format) { $node_urllist = variable_get('print_' . $format . '_display_sys_urllist', PRINT_TYPE_SYS_URLLIST_DEFAULT); } else { - $node_urllist = isset($node->{'print_' . $format . '_display_urllist'}) ? $node->{'print_' . $format . '_display_urllist'} : variable_get('print_' . $format . '_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT); + $node_urllist = $node->{'print_' . $format . '_display_urllist'} ?? variable_get('print_' . $format . '_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT); } // Get value of Printer-friendly URLs setting. - return (variable_get('print_urls', PRINT_URLS_DEFAULT) && ($node_urllist)); + return (variable_get('print_urls', $_print_urls) && ($node_urllist)); } /** diff --git a/print.tpl.php b/print.tpl.php index 8c95a9f..f9a3f47 100644 --- a/print.tpl.php +++ b/print.tpl.php @@ -76,7 +76,8 @@ <?php print $print_title; ?> - + ' type='image/x-icon' /> @@ -102,7 +103,11 @@ diff --git a/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.module b/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.module index 6de22da..66c1c15 100644 --- a/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.module +++ b/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.module @@ -7,6 +7,8 @@ * @ingroup print */ +use PHPePub\Core\EPub; + /** * Find out the version of the PHPePub library. * @@ -22,7 +24,7 @@ function _print_epub_phpepub_version($epub_tool) { $phpepub_version_4_plus = strpos($epub_tool, 'autoload.php') !== FALSE; if ($phpepub_version_4_plus) { - return \PHPePub\Core\EPub::VERSION; + return EPub::VERSION; } else { if (class_exists('EPub')) { diff --git a/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.pages.inc b/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.pages.inc index 0ff6e01..cd275c9 100644 --- a/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.pages.inc +++ b/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.pages.inc @@ -10,6 +10,8 @@ * @ingroup print */ +use PHPePub\Core\EPub; + /** * Implements hook_print_epub_generate(). */ @@ -36,7 +38,7 @@ function print_epub_phpepub_print_epub_generate($html, $meta, $filename = NULL) // Set document information. if (version_compare($version, '4.0.0', '>=')) { - $epub = new \PHPePub\Core\EPub(); + $epub = new EPub(); } else { $epub = new EPub(); diff --git a/print_epub/print_epub.install b/print_epub/print_epub.install index 9c55286..cdf6130 100644 --- a/print_epub/print_epub.install +++ b/print_epub/print_epub.install @@ -47,7 +47,6 @@ function print_epub_uninstall() { } } - /** * Implements hook_requirements(). */ diff --git a/print_epub/print_epub.module b/print_epub/print_epub.module index 853e5b6..5415be7 100644 --- a/print_epub/print_epub.module +++ b/print_epub/print_epub.module @@ -84,7 +84,7 @@ function print_epub_variable_info($options) { 'title' => t('EPUB version'), 'description' => t('Text used in the link to the EPUB version.'), 'type' => 'string', - 'default' => t($link['text']), + 'default' => ($link['text']), ); return $variable; @@ -114,7 +114,10 @@ function print_epub_block_view($delta = 0) { foreach ($result as $obj) { $items[] = l(_print_get_title($obj->path), $obj->path); } - $block['content'] = theme('item_list', array('items' => $items, 'type' => 'ul')); + $block['content'] = theme('item_list', array( + 'items' => $items, + 'type' => 'ul', + )); } break; } diff --git a/print_mail/print_mail.inc b/print_mail/print_mail.inc index e4edf94..abaf37f 100644 --- a/print_mail/print_mail.inc +++ b/print_mail/print_mail.inc @@ -169,13 +169,19 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us if (!empty($title)) { // To prevent useless translation strings, translate only non-node titles. if (drupal_substr($path, 0, 5) != 'node/') { - $title = t($title); + $title = ($title); } $form['fld_title'] = array( '#type' => 'item', '#title' => t('Page to be sent'), - '#markup' => l($title, $path, array('attributes' => array('title' => t('View page')), 'query' => $query)), + '#markup' => l($title, $path, array( + 'attributes' => array( + 'title' => t('View page'), + ), + 'query' => $query, + ) + ), ); } $form['txt_message'] = array( @@ -393,7 +399,7 @@ function print_mail_form_submit($form, &$form_state) { module_load_include('inc', 'print', 'includes/print'); $link = print_mail_print_link(); - $cid = isset($form_state['values']['cid']) ? $form_state['values']['cid'] : NULL; + $cid = $form_state['values']['cid'] ?? NULL; $view_mode = $form_state['values']['chk_teaser'] ? 'teaser' : PRINT_VIEW_MODE; $node = print_controller($form_state['values']['path'], $link['format'], $cid, $view_mode); @@ -402,8 +408,11 @@ function print_mail_form_submit($form, &$form_state) { $params = array(); $params['subject'] = $form_state['values']['fld_subject']; - $params['message'] = t('Message from sender') . ':

' . nl2br(check_plain($form_state['values']['txt_message'])) . ''; - $params['link'] = url($form_state['values']['path'], array('absolute' => TRUE, 'query' => $form_state['values']['query'])); + $params['message'] = ('Message from sender') . ':

' . nl2br(check_plain($form_state['values']['txt_message'])) . ''; + $params['link'] = url($form_state['values']['path'], array( + 'absolute' => TRUE, + 'query' => $form_state['values']['query'], + )); $params['title'] = $form_state['values']['title']; // If a name is provided, make From: in the format Common Name
. diff --git a/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.admin.inc b/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.admin.inc index 5da7aec..ae1cac5 100644 --- a/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.admin.inc +++ b/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.admin.inc @@ -26,7 +26,7 @@ function print_pdf_dompdf_settings() { '#title' => t("Use dompdf's Unicode Mode"), '#default_value' => variable_get('print_pdf_dompdf_unicode', PRINT_PDF_DOMPDF_UNICODE_DEFAULT), '#description' => t("If enabled, dompdf's Unicode mode is used. If not, the module will attempt to convert some non-ASCII chars to ISO-8859-1.") - . ' ' . t('For dompdf 0.7 and higher, Unicode Mode is fully supported and always active, so this option has no effect.'), + . ' ' . t('For dompdf 0.7 and higher, Unicode Mode is fully supported and always active, so this option has no effect.'), ); $form['settings']['print_pdf_dompdf_font_subsetting'] = array( '#type' => 'checkbox', diff --git a/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.pages.inc b/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.pages.inc index 11f1caf..14522db 100644 --- a/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.pages.inc +++ b/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.pages.inc @@ -10,6 +10,8 @@ * @ingroup print */ +use Dompdf\Dompdf; + /** * Implements hook_print_pdf_generate(). */ @@ -73,7 +75,7 @@ function print_pdf_dompdf_print_pdf_generate($html, $meta, $paper_size = NULL, $ throw new Exception("Configured PDF tool does not exist, unable to generate PDF."); } - $dompdf = new \Dompdf\Dompdf(); + $dompdf = new Dompdf(); $unicode = TRUE; if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) { diff --git a/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.module b/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.module index df7040f..c2b0ec1 100644 --- a/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.module +++ b/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.module @@ -7,6 +7,8 @@ * @ingroup print */ +use Mpdf\Mpdf; + /** * Implements hook_pdf_tool_info(). */ @@ -40,14 +42,14 @@ function print_pdf_mpdf_pdf_tool_version($pdf_tool) { include_once DRUPAL_ROOT . '/' . $pdf_tool; } - // Version 5.x and 6.x + // Version 5.x and 6.x. if (defined('mPDF_VERSION')) { return mPDF_VERSION; } - // Version >= 7.0 + // Version >= 7.0. else { if (class_exists('\Mpdf\Mpdf')) { - $version = \Mpdf\Mpdf::VERSION; + $version = Mpdf::VERSION; if (!empty($version)) { return $version; } diff --git a/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.pages.inc b/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.pages.inc index 1980e2b..c3a3c94 100644 --- a/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.pages.inc +++ b/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.pages.inc @@ -10,6 +10,8 @@ * @ingroup print */ +use Mpdf\Mpdf; + /** * Implements hook_print_pdf_generate(). */ @@ -63,7 +65,7 @@ function print_pdf_mpdf_print_pdf_generate($html, $meta, $paper_size = NULL, $pa if ($mpdf_version_7_plus) { $config['mode'] = 'utf-8'; $config['format'] = $format; - $mpdf = new \Mpdf\Mpdf($config); + $mpdf = new Mpdf($config); } else { $mpdf = new mPDF('UTF-8', $format); @@ -96,7 +98,20 @@ function print_pdf_mpdf_print_pdf_generate($html, $meta, $paper_size = NULL, $pa } drupal_alter('print_pdf_mpdf', $mpdf, $html, $meta); - $mpdf->WriteHTML($html); + $css_file_path = variable_get('print_css', PRINT_CSS_DEFAULT); + if (!empty($css_file_path)) { + $css_file_path = DRUPAL_ROOT . '/' . strtr($css_file_path, array( + '%t' => drupal_get_path('theme', variable_get('theme_default', 'garland')), + )); + if (!is_file($css_file_path) || !is_readable($css_file_path)) { + drupal_set_message(t("File %file is not readable by the web server.", array('%file' => $css_file_path)), 'warning', FALSE); + } + $stylesheet = file_get_contents($css_file_path); + $mpdf->WriteHTML($stylesheet, 1); + } + + // $mpdf->WriteHTML($html); + $mpdf->WriteHTML($html, 2); // Try to recover from any warning/error. ob_clean(); diff --git a/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.admin.inc b/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.admin.inc index 1b39000..a2aa921 100644 --- a/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.admin.inc +++ b/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.admin.inc @@ -28,7 +28,7 @@ function print_pdf_tcpdf_settings() { '#size' => 60, '#maxlength' => 250, '#description' => t('Set the font family to be used. Examples: %examples.', array('%examples' => 'helvetica, times, courier, dejavusans, dejavuserif, freesans, freeserif, freemono')) . '
' . - 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."), + 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( '#type' => 'textfield', diff --git a/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.class.inc b/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.class.inc index d31655e..91efa01 100644 --- a/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.class.inc +++ b/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.class.inc @@ -9,6 +9,9 @@ * @ingroup print */ +/** + * + */ class PrintTCPDF extends TCPDF { public $footer; diff --git a/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.module b/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.module index 5a6437d..21bc36c 100644 --- a/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.module +++ b/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.module @@ -82,7 +82,7 @@ function print_pdf_tcpdf_menu() { function print_pdf_tcpdf_pdf_tool_version($pdf_tool) { if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) { // Prevent TCPDF default configs. - define('K_TCPDF_EXTERNAL_CONFIG', TRUE); + define('PRINT_PDF_TCPDF_K_TCPDF_EXTERNAL_CONFIG', TRUE); } if (file_exists(DRUPAL_ROOT . '/' . $pdf_tool)) { include_once DRUPAL_ROOT . '/' . $pdf_tool; diff --git a/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.pages.inc b/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.pages.inc index 494a584..3d3077f 100644 --- a/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.pages.inc +++ b/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.pages.inc @@ -64,7 +64,9 @@ function print_pdf_tcpdf_print_pdf_generate($html, $meta, $paper_size = NULL, $p // Decode HTML entities in image filenames. $pattern = "!]*?src\s*?=\s*?['\"]?{$base_url}[^>]*?>!is"; - $html = preg_replace_callback($pattern, function ($matches) { return html_entity_decode($matches[0], ENT_QUOTES); }, $html); + $html = preg_replace_callback($pattern, function ($matches) { + return html_entity_decode($matches[0], ENT_QUOTES); + }, $html); // Remove queries from the image URL. $pattern = "!(]*?src\s*?=\s*?['\"]?{$base_url}[^>]*?)(?:%3F|\?)[^\s'\"]+([^>]*?>)!is"; $html = preg_replace($pattern, '$1$2', $html); @@ -307,7 +309,10 @@ function theme_print_pdf_tcpdf_footer2($vars) { $pdf->writeHTMLCell(0, 15, 15, $pdf->getPageHeight() - 15, $pdf->footer); $ormargins = $pdf->getOriginalMargins(); - $pagenumtxt = t('Page !n of !total', array('!n' => $pdf->PageNo(), '!total' => $pdf->getAliasNbPages())); + $pagenumtxt = t('Page !n of !total', array( + '!n' => $pdf->PageNo(), + '!total' => $pdf->getAliasNbPages(), + )); // Print page number. if ($pdf->getRTL()) { $pdf->SetX($ormargins['right']); diff --git a/print_pdf/print_pdf.install b/print_pdf/print_pdf.install index 333c5ac..ea116a5 100644 --- a/print_pdf/print_pdf.install +++ b/print_pdf/print_pdf.install @@ -215,7 +215,10 @@ function print_pdf_requirements($phase) { $requirements['print_pdf_tool_' . $dir] = array( 'title' => $t('%lib directory', array('%lib' => $info['name'])), 'value' => $t('Non-writable permissions'), - 'description' => $t('You must change the %libdir permissions to be writable, as %lib requires write-access to that directory.', array('%lib' => $info['name'], '%libdir' => $dir)), + 'description' => $t('You must change the %libdir permissions to be writable, as %lib requires write-access to that directory.', array( + '%lib' => $info['name'], + '%libdir' => $dir, + )), 'severity' => REQUIREMENT_ERROR, ); } diff --git a/print_pdf/print_pdf.module b/print_pdf/print_pdf.module index 5975d4a..556805e 100644 --- a/print_pdf/print_pdf.module +++ b/print_pdf/print_pdf.module @@ -70,7 +70,10 @@ function print_pdf_init() { $real_directory_path = $wrapper->getDirectoryPath() . "/" . file_uri_target($directory); $result = file_prepare_directory($real_directory_path, FILE_CREATE_DIRECTORY); if (!$result) { - watchdog('print_pdf', 'Failed to create directory "%dir" for %tool.', array('%dir' => $directory, '%tool' => $tool[0]), WATCHDOG_CRITICAL); + watchdog('print_pdf', 'Failed to create directory "%dir" for %tool.', array( + '%dir' => $directory, + '%tool' => $tool[0], + ), WATCHDOG_CRITICAL); } } } @@ -141,7 +144,7 @@ function print_pdf_variable_info($options) { 'title' => t('PDF version'), 'description' => t('Text used in the link to the PDF version.'), 'type' => 'string', - 'default' => t($link['text']), + 'default' => ($link['text']), ); return $variable; @@ -171,7 +174,10 @@ function print_pdf_block_view($delta = 0) { foreach ($result as $obj) { $items[] = l(_print_get_title($obj->path), $obj->path); } - $block['content'] = theme('item_list', array('items' => $items, 'type' => 'ul')); + $block['content'] = theme('item_list', array( + 'items' => $items, + 'type' => 'ul', + )); } break; } @@ -243,9 +249,10 @@ function print_pdf_node_update($node) { ->execute(); } - //For a book page, not only delete the PDF file for the page but also delete the caching PDF file for the entire book. + // For a book page, not only delete the PDF file for the + // page but also delete the caching PDF file for the entire book. if (isset($node->book) && isset($node->book['bid'])) { - //Delete the book PDF file. + // Delete the book PDF file. print_pdf_cache_delete($node->book['bid']); } @@ -299,8 +306,8 @@ function print_pdf_form_alter(&$form, &$form_state, $form_id) { } else { $node = $form['#node']; - $form['print']['print_' . $link['format']][$size]['#default_value'] = isset($node->{$size}) ? $node->{$size} : variable_get($size . '_' . $node->type); - $form['print']['print_' . $link['format']][$orientation]['#default_value'] = isset($node->{$orientation}) ? $node->{$orientation} : variable_get($orientation . '_' . $node->type); + $form['print']['print_' . $link['format']][$size]['#default_value'] = $node->{$size} ?? variable_get($size . '_' . $node->type); + $form['print']['print_' . $link['format']][$orientation]['#default_value'] = $node->{$orientation} ?? variable_get($orientation . '_' . $node->type); } } } diff --git a/print_pdf/print_pdf.pages.inc b/print_pdf/print_pdf.pages.inc index d438d41..69e07de 100644 --- a/print_pdf/print_pdf.pages.inc +++ b/print_pdf/print_pdf.pages.inc @@ -117,7 +117,7 @@ function print_pdf_generate_path($path, $query = NULL, $cid = NULL, $pdf_filenam $function = $pdf_tool[0] . '_pdf_tool_info'; $info = function_exists($function) ? $function() : array(); - $expand = isset($info['expand_css']) ? $info['expand_css'] : FALSE; + $expand = $info['expand_css'] ?? FALSE; $html = theme('print', array( 'node' => $node, @@ -147,8 +147,8 @@ function print_pdf_generate_path($path, $query = NULL, $cid = NULL, $pdf_filenam $meta['title'] = $node->title; } - $paper_size = isset($node->print_pdf_size) ? $node->print_pdf_size : NULL; - $page_orientation = isset($node->print_pdf_orientation) ? $node->print_pdf_orientation : NULL; + $paper_size = $node->print_pdf_size ?? NULL; + $page_orientation = $node->print_pdf_orientation ?? NULL; $pdf = ''; $cachemiss = FALSE; diff --git a/print_ui/print_ui.admin.inc b/print_ui/print_ui.admin.inc index 0e80e1b..192015b 100644 --- a/print_ui/print_ui.admin.inc +++ b/print_ui/print_ui.admin.inc @@ -93,9 +93,12 @@ function print_ui_settings() { $form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility'] = array( '#type' => 'radios', '#title' => t('Show link in system (non-content) pages'), - '#description' => 'Any page that is not a Drupal node. Usually pages generated by Drupal or a module such as Views or Panels.', + '#description' => t('Any page that is not a Drupal node. Usually pages generated by Drupal or a module such as Views or Panels.'), '#default_value' => variable_get('print_' . $format . '_sys_link_visibility', PRINT_UI_SYS_LINK_VISIBILITY_DEFAULT), - '#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')), + '#options' => array( + t('Show on every page except the listed pages.'), + t('Show on only the listed pages.'), + ), ); $form['settings']['adv_link']['sys_link_pages']['print_' . $format . '_sys_link_pages'] = array( @@ -103,19 +106,25 @@ function print_ui_settings() { '#default_value' => variable_get('print_' . $format . '_sys_link_pages', PRINT_UI_SYS_LINK_PAGES_DEFAULT), '#rows' => 3, '#description' => t('Setting this option will add a link on pages created by Drupal or the enabled modules.') . '
' . - 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' => '', - )), + 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' => '', + )), ); if (module_exists('php')) { $access = user_access('use PHP for settings'); if ($form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility']['#default_value'] == 2 && !$access) { - $form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility'] = array('#type' => 'value', '#value' => 2); - $form['settings']['adv_link']['sys_link_pages']['print_' . $format . '_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_' . $format . '_sys_link_pages']['#default_value']); + $form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility'] = array( + '#type' => 'value', + '#value' => 2, + ); + $form['settings']['adv_link']['sys_link_pages']['print_' . $format . '_sys_link_pages'] = array( + '#type' => 'value', + '#value' => $form['settings']['adv_link']['print_' . $format . '_sys_link_pages']['#default_value'], + ); } elseif ($access) { $form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns TRUE (PHP-mode, experts only).'); @@ -184,11 +193,14 @@ function theme_print_ui_settings($variables) { // Start row, fill title and description. $row_desc = array( '#type' => 'item', - '#markup' => isset($item['#title']) ? $item['#title'] : '', - '#description' => isset($item['#description']) ? $item['#description'] : '', + '#markup' => $item['#title'] ?? '', + '#description' => $item['#description'] ?? '', ); - $row[] = array('data' => drupal_render($row_desc), 'class' => array('')); + $row[] = array( + 'data' => drupal_render($row_desc), + 'class' => array(''), + ); } $item['#title_display'] = 'invisible'; @@ -196,7 +208,10 @@ function theme_print_ui_settings($variables) { $class = ($item['#type'] == 'checkbox') ? 'checkbox' : ''; - $row[] = array('data' => drupal_render($item), 'class' => array($class)); + $row[] = array( + 'data' => drupal_render($item), + 'class' => array($class), + ); } } $rows[] = $row; diff --git a/print_ui/print_ui.module b/print_ui/print_ui.module index e4af40b..cdd0e0d 100644 --- a/print_ui/print_ui.module +++ b/print_ui/print_ui.module @@ -109,7 +109,10 @@ function print_ui_block_view($delta = '') { $link_pos = variable_get('print_' . $link['format'] . '_link_pos', drupal_json_decode(PRINT_UI_LINK_POS_DEFAULT)); if (!(empty($link_pos['block']))) { - $links = print_ui_insert_link($link, array('node' => $node, 'location' => 'block')); + $links = print_ui_insert_link($link, array( + 'node' => $node, + 'location' => 'block', + )); if (!empty($links)) { $block['content'] .= $links; } @@ -165,7 +168,10 @@ function print_ui_node_view_alter(&$build) { $link_pos = variable_get('print_html_link_pos', drupal_json_decode(PRINT_UI_LINK_POS_DEFAULT)); if (!empty($link_pos['link'])) { - $format = theme('print_ui_format_link', array('format' => 'html', 'location' => 'link')); + $format = theme('print_ui_format_link', array( + 'format' => 'html', + 'location' => 'link', + )); $path = ''; switch ($book_link) { @@ -226,7 +232,10 @@ function print_ui_node_view($node, $view_mode) { if ($allowed_type) { drupal_add_css(drupal_get_path('module', 'print_ui') . '/css/print_ui.theme.css'); $links = array(); - $format = theme('print_ui_format_link', array('format' => $link['format'], 'location' => 'link')); + $format = theme('print_ui_format_link', array( + 'format' => $link['format'], + 'location' => 'link', + )); // Show book link. if ($allowed_type === PRINT_UI_ALLOW_BOOK_LINK) { @@ -437,9 +446,9 @@ function print_ui_form_alter(&$form, &$form_state, $form_id) { } else { $node = $form['#node']; - $form['print']['print_' . $link['format']][$display]['#default_value'] = isset($node->{$display}) ? $node->{$display} : variable_get($display . '_' . $node->type, PRINT_UI_TYPE_SHOW_LINK_DEFAULT); - $form['print']['print_' . $link['format']][$display_comment]['#default_value'] = isset($node->{$display_comment}) ? $node->{$display_comment} : variable_get($display_comment . '_' . $node->type, PRINT_UI_TYPE_COMMENT_LINK_DEFAULT); - $form['print']['print_' . $link['format']][$display_urllist]['#default_value'] = isset($node->{$display_urllist}) ? $node->{$display_urllist} : variable_get($display_urllist . '_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT); + $form['print']['print_' . $link['format']][$display]['#default_value'] = $node->{$display} ?? variable_get($display . '_' . $node->type, PRINT_UI_TYPE_SHOW_LINK_DEFAULT); + $form['print']['print_' . $link['format']][$display_comment]['#default_value'] = $node->{$display_comment} ?? variable_get($display_comment . '_' . $node->type, PRINT_UI_TYPE_COMMENT_LINK_DEFAULT); + $form['print']['print_' . $link['format']][$display_urllist]['#default_value'] = $node->{$display_urllist} ?? variable_get($display_urllist . '_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT); } } } @@ -548,7 +557,12 @@ function theme_print_ui_format_link($vars) { 'height' => '16px', 'alt' => $link_text, 'title' => $link_text, - 'attributes' => array('class' => array('print-icon', 'print-icon-margin')), + 'attributes' => array( + 'class' => array( + 'print-icon', + 'print-icon-margin', + ), + ), )) . $link_text; break; } @@ -577,7 +591,7 @@ function theme_print_ui_format_link($vars) { * their defined pages/blocks. * * @param array $link - * Array returned by the hook_print_link() call. + * Array returned by the hook_print_link() call. * @param array $args * Array of optional arguments: * - node: node object, to be used in checking node access. If the path @@ -591,9 +605,9 @@ function theme_print_ui_format_link($vars) { * string with the HTML link to the printer-friendly page */ function print_ui_insert_link($link, $args = array()) { - $node = isset($args['node']) ? $args['node'] : NULL; - $path = isset($args['path']) ? $args['path'] : NULL; - $location = isset($args['location']) ? $args['location'] : ''; + $node = $args['node'] ?? NULL; + $path = $args['path'] ?? NULL; + $location = $args['location'] ?? ''; if ($node !== NULL) { $nid = $node->nid; @@ -633,7 +647,10 @@ function print_ui_insert_link($link, $args = array()) { $query = NULL; } drupal_add_css(drupal_get_path('module', 'print_ui') . '/css/print_ui.theme.css'); - $format = theme('print_ui_format_link', array('format' => $link['format'], 'location' => $location)); + $format = theme('print_ui_format_link', array( + 'format' => $link['format'], + 'location' => $location, + )); return '' . l($format['text'], $path, array( 'attributes' => $format['attributes'], 'query' => $query,