Browse Source

updated print

Bachir Soussi Chiadmi 5 years ago
parent
commit
b764ef206e
73 changed files with 1787 additions and 1987 deletions
  1. 3 0
      sites/all/modules/contrib/admin/print/.gitignore
  2. 0 899
      sites/all/modules/contrib/admin/print/CHANGELOG.txt
  3. 6 2
      sites/all/modules/contrib/admin/print/css/print-rtl.css
  4. 66 24
      sites/all/modules/contrib/admin/print/css/print.css
  5. 59 25
      sites/all/modules/contrib/admin/print/includes/print.drush.inc
  6. 14 14
      sites/all/modules/contrib/admin/print/includes/print.inc
  7. 28 6
      sites/all/modules/contrib/admin/print/print.admin.inc
  8. 2 2
      sites/all/modules/contrib/admin/print/print.api.php
  9. 3 4
      sites/all/modules/contrib/admin/print/print.info
  10. 12 7
      sites/all/modules/contrib/admin/print/print.install
  11. 30 17
      sites/all/modules/contrib/admin/print/print.module
  12. 156 128
      sites/all/modules/contrib/admin/print/print.pages.inc
  13. 3 7
      sites/all/modules/contrib/admin/print/print.views.inc
  14. 4 4
      sites/all/modules/contrib/admin/print/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.drush.inc
  15. 3 4
      sites/all/modules/contrib/admin/print/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.info
  16. 38 0
      sites/all/modules/contrib/admin/print/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.install
  17. 23 33
      sites/all/modules/contrib/admin/print/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.module
  18. 23 9
      sites/all/modules/contrib/admin/print/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.pages.inc
  19. 2 7
      sites/all/modules/contrib/admin/print/print_epub/print_epub.admin.inc
  20. 6 6
      sites/all/modules/contrib/admin/print/print_epub/print_epub.api.php
  21. 9 5
      sites/all/modules/contrib/admin/print/print_epub/print_epub.drush.inc
  22. 3 4
      sites/all/modules/contrib/admin/print/print_epub/print_epub.info
  23. 46 7
      sites/all/modules/contrib/admin/print/print_epub/print_epub.install
  24. 16 46
      sites/all/modules/contrib/admin/print/print_epub/print_epub.module
  25. 32 23
      sites/all/modules/contrib/admin/print/print_epub/print_epub.pages.inc
  26. 3 6
      sites/all/modules/contrib/admin/print/print_epub/print_epub.views.inc
  27. 17 6
      sites/all/modules/contrib/admin/print/print_join_page_counter.inc
  28. 5 3
      sites/all/modules/contrib/admin/print/print_mail/print_mail.admin.inc
  29. 107 50
      sites/all/modules/contrib/admin/print/print_mail/print_mail.inc
  30. 3 4
      sites/all/modules/contrib/admin/print/print_mail/print_mail.info
  31. 38 10
      sites/all/modules/contrib/admin/print/print_mail/print_mail.install
  32. 30 48
      sites/all/modules/contrib/admin/print/print_mail/print_mail.module
  33. 3 6
      sites/all/modules/contrib/admin/print/print_mail/print_mail.views.inc
  34. 13 10
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/INSTALL.txt
  35. 4 5
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.drush.inc
  36. 3 4
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.info
  37. 30 0
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.install
  38. 47 20
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.module
  39. 79 30
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.pages.inc
  40. 8 0
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_mpdf/INSTALL.txt
  41. 4 5
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.drush.inc
  42. 3 4
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.info
  43. 31 7
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.module
  44. 49 17
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.pages.inc
  45. 6 1
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.admin.inc
  46. 18 5
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.class.inc
  47. 3 4
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.drush.inc
  48. 3 4
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.info
  49. 6 4
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.module
  50. 91 54
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.pages.inc
  51. 7 9
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/INSTALL.txt
  52. 9 7
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.admin.inc
  53. 16 12
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.drush.inc
  54. 3 4
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.info
  55. 33 0
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.install
  56. 47 42
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.module
  57. 54 12
      sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.pages.inc
  58. 12 8
      sites/all/modules/contrib/admin/print/print_pdf/print_pdf.admin.inc
  59. 12 12
      sites/all/modules/contrib/admin/print/print_pdf/print_pdf.api.php
  60. 9 5
      sites/all/modules/contrib/admin/print/print_pdf/print_pdf.drush.inc
  61. 3 4
      sites/all/modules/contrib/admin/print/print_pdf/print_pdf.info
  62. 109 15
      sites/all/modules/contrib/admin/print/print_pdf/print_pdf.install
  63. 102 144
      sites/all/modules/contrib/admin/print/print_pdf/print_pdf.module
  64. 45 37
      sites/all/modules/contrib/admin/print/print_pdf/print_pdf.pages.inc
  65. 3 6
      sites/all/modules/contrib/admin/print/print_pdf/print_pdf.views.inc
  66. 4 1
      sites/all/modules/contrib/admin/print/print_ui/css/print_ui.theme-rtl.css
  67. 4 1
      sites/all/modules/contrib/admin/print/print_ui/css/print_ui.theme.css
  68. 6 1
      sites/all/modules/contrib/admin/print/print_ui/print_ui.admin.inc
  69. 6 11
      sites/all/modules/contrib/admin/print/print_ui/print_ui.api.php
  70. 3 4
      sites/all/modules/contrib/admin/print/print_ui/print_ui.info
  71. 1 1
      sites/all/modules/contrib/admin/print/print_ui/print_ui.install
  72. 88 51
      sites/all/modules/contrib/admin/print/print_ui/print_ui.module
  73. 20 10
      sites/all/modules/contrib/admin/print/tests/print_basic.test

+ 3 - 0
sites/all/modules/contrib/admin/print/.gitignore

@@ -0,0 +1,3 @@
+lib/*
+
+.idea

+ 0 - 899
sites/all/modules/contrib/admin/print/CHANGELOG.txt

@@ -1,899 +0,0 @@
-August 22, 2010
-        Update CHANGELOG
-        Updated Polish translation by dargod
-        Update translations
-        Coder fixes
-August 20, 2010
-        Use theme_token_tree to generate token list
-August 18, 2010
-        Fix #884936: Check if the select PDF tool is accessible and executable (wkhtmltopdf)
-        Fix #886766: Make unreadable custom CSS file a warning and not an error when submitting the settings form
-        Remove some PHP warnings in non-content pages
-        Fix #883952: Put base href at the top of the print template
-August 15, 2010
-        Fix #883086: blank CSS file field caused form validation failure in settings
-August 14, 2010
-        Fix #881074 by ceme: use SCRIPT_FILENAME instead of DOCUMENT_ROOT when replacing image paths for local access
-August 12, 2010
-        Fix #880954: Enable translation of 'send page as' options
-        Fix #880400: document alternative sites/all/libraries path in INSTALL.txt
-August 11, 2010
-        SA-CONTRIB-2010-TBD: disable local file access with wkhtmltopdf
-        Update CHANGELOG
-August 9, 2010
-        Convert to local file access only for TCPDF and dompdf
-August 5, 2010
-        Fix #869014: Support content type template suggestions
-August 1, 2010
-        Coder fixes
-July 30, 2010
-        rename vars to variables in MODULE_preprocess_HOOK functions
-July 27, 2010
-        Convert class attributes to array
-        Fix #850844: Use drupal_add_css for the custom CSS
-July 25, 2010
-        Fix #726082: Remove dependency on allow_url_fopen by converting all image URLs to local files
-July 24, 2010
-        Add option to set default mail sending format
-July 22, 2010
-        Use correct custom date token format
-        Use textual block deltas
-        Fix #763810: Configure module weights to ensure that the core module is always called before the others
-July 20, 2010
-        Fix PDF generation using TCPDF by using D7 theme arguments syntax
-        Provide missing info on the arguments of print_pdf theme functions
-        Fix send by-email to work in D7
-        Use type-default settings if a node is being created/updated leaving them unspecified
-July 17, 2010
-        Misc D7 updates
-        Misc D7 updates
-July 16, 2010
-        Fix #803580: Add alt text to printer-friendly page logo
-        Fix #771300: warn the site admin if dompdf's lib/fonts is not writable
-        Fix #733582: Support in-core D7 tokens
-        Fix #715800: type-specific settings act as default settings only, not as a type-wide configuration switch
-July 15, 2010
-        Make PDF module work again in Drupal 7
-        Make basic printer-friendly version work again in drupal 7
-        Fix #358838: use template_preprocess_node() to initialize node.tpl.php variables
-July 14, 2010
-        LANGUAGE_RTL is always defined in Drupal
-        Fix #764204: align source url and links on the left side for RTL languages
-        Fix #358838 by EugenMayer: Use theme preprocess functions for the template suggestions
-July 13, 2010
-        Fix #608518 by ISPTraderChris: Option to send e-mail as link only or as attachments
-        Fix #321128 by AndyF: add option to display PF links in teaser mode
-        Fix #726146 by marrch_caat: node-specific settings ain't saved on node creation
-        Fix #835814 and #451408 by kingandy: use #prefix and #suffix for the content corner span
-        Fix #785364: solve incompatibility with PHP 5.3 when using TCPDF
-        Fix #696318 by JamesK: move body onload javascript into Drupal.behaviors
-        Fix #735260: Disable named anchors in URL list by default
-July 12, 2010
-        Fix #835470 by adrien.gibrat: Transliterate generated PDF filenames if transliteration module is enabled
-        Fix #631150 by smk-ka: wkhtmltopdf on windows can use the output pipe again
-        Fix #257896: Add support for dompdf 0.6+ Unicode mode
-        Fix #684678: Support dompdf 0.6 adding some required defines
-July 10, 2010
-        Fix #639420, #697616 and #700566: remove use of Xvfb server with wkhtmltopdf
-        Remove use of Xvfb by wkhtmltopdf
-        Fix #842462 by sbatman: Use proper hook_theme() arguments format
-July 9, 2010
-        Fix #707534 by truecms.net.au: use Form API for required fields in send e-mail form
-June 1, 2010
-        Fix #704480 by marrch_caat: TCDPF outputs empty PDF
-January 11, 2010
-        Fix #623712: Remove unnecessary urldecode() calls and check URLs using html_entity_decode()
-        Proper fix for #480916: only use cached node type when processing comments also for mail and pdf links
-        Fix #665820: handle wkhtmltopdf executable filename finishing in -i386 or -amd64
-        Fix #631760: add query string to user-specified print.css to force browser reload after cache is cleared
-        Fix #658208 by Dave Reid: Vertical tabify the print fieldsets
-        Fix #646544: use correct block cache settings
-November 19, 2009
-        #244351 by seals: Minor update of Swedish translation.
-        #244351 by seals: Updated Swedish translation
-November 1, 2009
-        Correct typo/bug in the fix for #521776
-        Fix #552646: don't add the page to be sent title field in the send-by-email form when the title is empty
-        Fix #610878: enlarge the wkhtmltopdf and Xvfb options fields
-        Fix #617888: fix anchor links in pages located in sub-directories
-October 15, 2009
-        Remove XSS vulnerability in PF URLs list and unauthorized access to node titles
-        Update changelog
-October 13, 2009
-        Use admin/config instead of admin/settings
-        Fix #521776: support wkhtmltopdf in Windows
-        Fix #599840: use the real page path and not the current URL when determining link visibility
-October 8, 2009
-        Fix #552882: register dompdf's autoload function to prevent fatal errors
-October 7, 2009
-        Fix #578990: enable tokens in the wkhtmltopdf options string
-October 3, 2009
-        Fix #582360: don't complain about missing e-mail addresses when there's a blank line at the end
-        Fix #582104: look for PDF libraries in sites/all/libraries
-        Fix #572848 by aether: Use theme_username() for print_mail_form defaults
-        Fix #566138: add setting to close the window when both the new window and send to printer are enabled
-September 3, 2009
-        SA-CONTRIB-2009-052: remove multiple XSS vulnerabilities
-        Several updates to comply with current D7
-July 15, 2009
-        Fix #519320: typo in setting non-blocking wkhtmltopdf pipes
-        Fix #517828: replace the euro sign with an HTML entity
-July 9, 2009
-        Delete 6.x update functions
-        Stop using @mainpage in API documentation comments
-July 3, 2009
-        Fix #495814: remove the word core from .info file
-        Fix #495898: handle node/nid/tab paths correctly
-        Fix #480916: only use cached node type when processing comments
-        Fix #495386: make local anchor links navigable inside the PDF
-June 15, 2009
-        Fix #484926: Increase stylesheet URL max field size to 250
-        Update dompdf download URL
-June 7, 2009
-        Fix #472920: deny access to paths starting with print/print
-June 5, 2009
-        Fix #481350: Don't show book link in links area when only that option is disabled
-        Fix #478196: use CSS instead of break tags to arrange block links vertically
-May 28, 2009
-        Fix #468342: Add mail and PDF-specific access permissions
-May 21, 2009
-        Update check for non-validation when pressing the mail cancel button
-        Fix #469458: Web version passes XML 1.0 Strict validation test
-        Replace old 'use PHP for link visibility' permission with core's 'use PHP for settings'
-May 20, 2009
-        Add some help text to content-type settings to explain that the module-wide settings must be enabled.
-        Add option to auto-configure the TCPDF library (on by default)
-        Only remove queries from img URLs which TCPDF will try to access locally
-May 17, 2009
-        Updated German translation by Frank Tartler
-        Updated Hungarian translation by Zoltan Balogh
-        Use image scale 1 with TCPDF >= 4.6.002
-May 14, 2009
-        drupal_eval was replace with php_eval
-        Move title after the meta content-type tag to prevent XSS attacks
-May 13, 2009
-        Update translations and .pot to current code
-        Update changelog
-        Coder fixes
-        Fix #457528: When using TCPDF remove queries from the image URL
-May 11, 2009
-        Disable corner link span when empty
-        Add CCK's print_cck_build_modes hook
-        Update module to Drupal 7 current code
-May 6, 2009
-        Forgot quotes around UTF-8 in fix for #435578
-        Fix #451036: don't call drupal_get_title when the non-node path was not found
-        Don't try to use URL aliases when the node doesn't have one
-May 4, 2009
-        Last part of the fix for the last part of #435578
-        Fix #420460: When using TCPDF remove imagefield/filefield numerical query from image filenames
-        Fix #449446 by rsantiag: Use the job_queue module to send emails during the cron run
-May 2, 2009
-        Fix another part of #435578: decode HTML entities in TCPDF title
-April 29, 2009
-        Fix #441770: Footer was placed at top of page in TCPDF => 4.6
-April 27, 2009
-        Improve wkhtmltopdf documentation, configuration and add a directory to place external libraries
-        Fix #385994: Printer-friendly pages do not inherit organic group membership from original page
-April 23, 2009
-        Prevent PHP from blocking in the wkhtmltopdf code
-        Use cyclical numbering for the X display instead of random
-        Coder fixes
-        Re-enable use of NODE_BUILD_PRINT in the D7 branch
-April 22, 2009
-        Fix #283950: clean the output buffer to recover from any TCPDF warning/error
-        Fix #440376 by rsantiag: add hooks before and after the email sending action
-        Use Drupal log for wkhtmltopdf errors
-        Fix #429054: decode html entities in image URLs passed to TCPDF
-        Fix a notice with undefined node->type when printing system pages
-        Remove some dead code for an untested fix to #254863
-        Fix #435578: for now, don't use build_mode as CCK is not ready for it yet
-April 21, 2009
-        Updated German translation by rastatt
-        Fix #419296 by noelbush: ** Use wkhtmltopdf for PDF generation **
-        Fix #439314: use better pattern matching for TCPDF's paragraph replacement
-April 20, 2009
-        Fix #437128 by florin: add some bottom padding to the corner link
-April 16, 2009
-        Fix #435386 by rhys: accept recepient lists with consecutive separators \(newlines or commas\)
-April 15, 2009
-        Fix #428024: use build_mode in hook_nodeapi and elsewhere
-        Hide TCPDF notices
-        Filter node titles using check_plain
-March 27, 2009
-        Expand the advanced link options by default (too many users couldn't see it) and move the book link inside the fieldset
-        Fix #391790: display CCK fields (and labels) better in PDFs generated with TCPDF
-        Try to fix #414910 by using a smaller default weight
-        Fix #404052: allow node tabs pages to display the links for system pages
-        Fix #405564: display the content corner links above the content
-        Try to use other functions to convert from UTF-8 to ISO-8859-1 for the PDF generation with dompdf
-        Add the install files to the .info file
-March 24, 2009
-        Fix #408238 by chris.cohen: improve PHP in the default print template
-        Updated Italian translation by fabrizioprocopio
-        Updated French translation by xmacinfo
-March 18, 2009
-        Print module can be used as a spam relay
-March 17, 2009
-        Make tests successful again
-        Coder fixes
-March 12, 2009
-        Fix #303506 partly by joostvdl: remove the country code from paths to private image files used in generating PDFs
-        Use hook_node_* instead of hook_nodeapi_* in line with changes to Drupal 7
-        Simpler fix to #388008: Use a 'heavier' weight even in the absense of the CCK module
-March 10, 2009
-        Fix #388008: implement CCK's hook_cck_extra_fields to manage the order of the per-content type settings
-March 5, 2009
-        Fix #384294 by ron_s: use padding instead of margin in icons
-        Fix #381586 by Fleshgrinder: add space at the end of the reset button in the send mail form
-        Fix #372250: Add page title to send mail form and the ability to use the !title token
-        Improvements to the API index.php
-        Updated slovak translation by etki
-February 20, 2009
-        Fix #371455: Convert all links in the PDF to absolute
-        by Zoltan Balogh: Updated Hungarian translation
-        Better fix for #371388: handle tbody tags with attributes
-        Fix #375892: Don't validate mail send form when pressing cancel
-        Improved Turkish translation by drupalhizmetleri
-        Document print_[format].tpl better in the README.txt
-February 10, 2009
-        Update changelog
-        Move things around a bit
-February 9, 2009
-        Current mimemail 6.x-1.x-dev no longer causes problems for the mail function, so remove the warnings
-        Fix #371388 by victorkane and gurubert: delete tbody tags since dompdf can't handle them
-        Fix #370870: do not delete node-specific settings when users without permission to change them edit a node
-February 5, 2009
-        Update changelog
-        Add warning for incompatible mimemail settings
-        Update last patch to Drupal 7 form API fields
-        Fix for #364535: add some warnings about incompatibility of custom strings and the localization mechanism
-        Add explanation of the relation between the type- and node-specific print settings
-        Updated all translations (Dutch 100% thanks to joostvdl)
-February 2, 2009
-        Fix #365041: node-specific settings not initialized when adding new content
-        Fix #364535: move custom text strings to separate form to prevent conflicts with the translation mechanism
-        Fix #366835: support RTL languages in TCPDF generated PDFs
-January 21, 2009
-        Updated french translation by remi
-        Fix #361107: Ensure that per-node configurations are available for block view use
-        Revert #349991 until the cause of #359343 can be determined
-January 16, 2009
-        Coder fixes
-        Update to new hook_block_list and hook_block_view
-        Moved link code to hook_nodeapi_view and removal of hook_link
-January 14, 2009
-        Add configuration for a default sender message
-        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
-        Minor coder fixes
-December 8, 2008
-        Fix #344036 by eMPee584: generated PDF filename configurable via tokens (requires the token module)
-        Fix #343985 by eMPee584: improve removal of comment form and links
-        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
-December 1, 2008
-        Disable footer in dompdf
-        Fix #336860 by Limiting Factor: use realpath for the path replacement when using private files
-        Fix #339111: Disable caching for PDF files
-November 25, 2008
-        Fix #336065: change nodeapi content weight to make sure that the content area link is rendered first
-November 14, 2008
-        Handle unclean URLs when using private files
-November 7, 2008
-        Use link format and icon options also in book links.
-        Fix #315204: Add options to show only the current page in book links
-        Fix #314521: Use file:// access when accessing images if private file system is enabled
-November 3, 2008
-        Support latest hook_perm() implementation
-October 28, 2008
-        Use Pass Through in D7's drupal_set_title
-October 22, 2008
-        coder fixes
-        Improved UTF-8 conversion for dompdf
-October 21, 2008
-        Since dompdf can't handle Unicode, decode it to ISO-8859-1
-October 18, 2008
-        Don't validate the PDF settings when the form is empty
-October 17, 2008
-        Improve handling of no PDF tool installed
-October 16, 2008
-        Change PF link class from print to print_html
-        Fix #319529: Use referer URL if no path is provided
-        Fix #321451: Use reset button on email form
-        Update translations
-October 15, 2008
-        Minor coder fixes
-        Use file_unmanaged_copy
-        Use DRUPAL_ROOT when including files
-October 14, 2008
-        Fix #258095: Add block with links to PF versions
-        Fix #318939: Add title tag to icons
-October 3, 2008
-        Fix #315014: redirect back to original page after sending email from book node
-October 2, 2008
-        Set query to NULL when the link doesn't contain a query
-September 25, 2008
-        Verify print_controller return value to avoid PHP warnings
-        Add option to use URL alias in the link
-September 23, 2008
-        Update to current Drupal 7 dev
-        Avoid system CSS conflict with dompdf
-September 22, 2008
-        Fix #311270: Use node_not_found() instead of node_access_denied() when appropriate
-        Make the code closer to Drupal's node_view()
-September 20, 2008
-        Fix #310703 by eMPee584: remove undefined teaser notice
-September 19, 2008
-        Remove file fields from hook_theme calls
-September 18, 2008
-        Fix #300277: don't break tables when modifying TCPDF's input
-September 18, 2008
-        Fix #309084 by gl0tzk0wski: use addslashes in the dompdf footer function
-        Fix #308620 by robertDouglass: cast cid to int
-        Fix #308478 by Obsidiandh: avoid mod_security error in print_mail settings form
-September 13, 2008
-        Vietnamese translation by thehong
-        Remove default front page mail and PDF links
-        Remove PHP4 file from the API index
-        Removed useless redirect of pdf theming functions
-        Make HEAD compatible with Drupal 7
-September 11, 2008
-        Updated german translation
-        Update changelog
-        Update translations with current .pot
-September 10, 2008
-        Update documentation
-        Remove some more notices
-        Use module's CSS files
-September 8, 2008
-        Footer can now be choice between none, site or user-defined
-        Add footer to the dompdf generation (themeable).
-September 7, 2008
-        Display normal link in pages of type book that are not in books
-September 5, 2008
-        Slightly better API index
-September 4, 2008
-        Repair type-specific link settings
-September 3, 2008
-        Fix wrong fix to #299123
-        Improve documentation
-September 2, 2008
-        Remove some more PHP notices
-        Fix #298654: Drupal's theme function doesn't handle references when using PHP4
-        Fix fix for #301192: don't use drupal_query_string_encode for recursive calls
-        Use quotes around sender's name
-        Force menu rebuild after upgrade
-        Updated german translation
-        Use better system of detecting TCPDF's PHP version being used
-September 1, 2008
-        Fix #301192: handle arrays in queries correctly
-        Fix #299123 and #299133: remove PHP notices
-August 22, 2008
-        index.php for the API module
-August 21, 2008
-        Fix use of TCPDF versions later than 4.0.018
-        Fix use of TCPDF theming with PHP4
-        Fix #297198: Use SCRIPT_FILENAME instead of DOCUMENT_ROOT to determine Drupal's location in the file-system
-        Updated german translation (thanks rastatt)
-August 14, 2008
-        Organize everything in folders before the 1.0 release
-        Some minor coder corrections and updated print.pot
-August 13, 2008
-        Prevent setting of font size to 0 or negative
-        Font family and size in PDFs generated by TCPDF can now be user-configured
-August 9, 2008
-        Updated german translation. Thanks rastatt
-        Added the TCPDF footer layout to the themeable functions
-        Code documentation
-        Misc changes to comply with the coder module
-August 8, 2008
-        Enable theming of the TCPDF output
-August 7, 2008
-        Only use logo in TCPDF if the temporary file copy was successful
-        Use the template some more when using TCPDF
-        Add the links CSS file for the normal link
-        Add the logo to the TCPDF page
-August 6, 2008
-        Fix #291816: Use CCK's 6.x release path for its CSS file
-        Update simpletest test for the 6.x-2.x series (compatible with Drupal 7)
-        Fix bug with visibility where the link was shown when no page was specified but the 'show only in listed pages' was selected
-        Minor fixes
-August 5, 2008
-        Use more accurate pattern matching in the URL rewrite function
-        Add some simpletest unit tests
-        Fix bug where legal characters were being trimmed from the edges of URLS
-        Delete new variables when uninstalling
-        Update translations
-        Prepare _print_friendly_urls for simpletest testing
-August 4, 2008
-        Enable flood control of the send by e-mail functionality
-        Fix #290262 by Asif99: sys pages starting with 2 or 3 would return error 404
-        Fix #290587: When send to printer was enabled, the generated PDF was empty
-August 2, 2008
-        Update Hungarian translation by aries
-August 1, 2008
-        Simplify settings form by using more collapsible fieldsets
-        Added RTL link CSS
-        Remove some coder warnings
-July 30, 2008
-        Fix #282385: Add CSS margin between icon and text
-        Fix #288064: Large books sometimes resulted in blank PDFs
-        Fix #261338: Enable selection of none, theme or user-defined logo. Added also capability to upload logo directly from the settings form.
-        Fix PDF bug that prevented correct PDF generation introduced in the last patch.
-        Move the setting form elements back to the defined fieldsets.
-        Fix #280949: Add macros to the CSS input
-        Fix #285496: prevent re-encoding of the encoded query
-        Fix some minor coder warnings
-        Add some TCPDF calls for better quality output
-July 29, 2008
-        Add option to select location of the links
-July 28, 2008
-        Further improvements to the link enabled detection routines
-        Fix print*_insert_link functions to point to print*/nn and not print*/node/nn
-July 27, 2008
-        Improve link enabled detection routines
-July 25, 2008
-        Prepare a new link area in the upper right corner of the content
-        Replaced all inline styles with a core-loaded CSS file
-        Updated German translation
-July 24, 2008
-        Fix visibility so that it works both with the internal and the aliased paths
-July 23, 2008
-        Re-engineer the variables to no longer use the #tree hierarchy
-July 22, 2008
-        Increase mail form label width to avoid line wrapping
-        Enable translation of mail form buttons text
-July 21, 2008
-        Fix obscure pattern matching bug for sites that still use index.php in the URL
-        Moved taxonomy to lower right corner
-        Remove DOS CR+LF
-July 17, 2008
-        Slightly better current path discovery in the PDF and Web mods
-        Fix #283799: Allow icons in book links
-July 16, 2008
-        Fix #283423: correct the CSS path inclusion when sending by mail
-        Vietnamese translation by thehong.
-        Updated all translations
-        Misc fixes from the coder module
-July 15, 2008
-        Fix #282385: Remove whitespace between icon and text, use margin instead
-July 9, 2008
-        To make the job easier for themers, added access to the $node var inside the template
-        Fix #278922: Add support to the RTL languages
-        Fix #276627: Accept paths of the form node/nnn/args
-June 17, 2008
-        Self configure TCPDF
-June 16, 2008
-        With the new agreement between the major search engines, robots=nocache is obsolete
-        Set PDF version to 1.6 (Acrobat 7.x)
-        Use own panel in node type edit form, instead of workflow and comment panels.
-June 13, 2008
-        Fix #270095 by suit4: prevent validation error when the class field is empty
-June 6, 2008
-        Add path-based visibility options to all modules
-        Minor code documentation fixes
-June 4, 2008
-        Fix #257900: Add capability to use different templates for PDF, mail, etc.
-        Simplify CSS inclusion code a bit.
-        Fix #266186 by aaustin: Use drupal_get_title to obtain the page title
-        Fix #266318 by sun: Use theme_image for the icons (also fix #262900)
-June 3, 2008
-        Added capability to send a user-defined message with the send by e-mail function.
-        Streamlined the look of the send mail form.
-June 2, 2008
-        Change sys link option to list of paths on which to show the link.
-        Add option to choose to send only the message teaser.
-May 30, 2008
-        Fix #263349: Add CCK's CSS file to properly display inlined fields
-May 29, 2008
-        Working implementation of the mail sending code
-May 26, 2008
-        Initial send by e-mail support
-        Fix #262853: Use unicode-enabled fonts in TCPDF
-        Completed the Turkish translation based on the print.pot version 1.7 (by serkan.arikusu)
-May 24, 2008
-        Completed the Turkish translation based on the print.pot version 1.7 (by serkan.arikusu)
-May 23, 2008
-        Small improvements to the PDF admin functions
-        Separate open in new window option, so that PDF and web versions can have different settings
-        Use the template a bit more when using the TCPDF tool.
-        Make the title in the template be a heading 1.
-May 22, 2008
-        Add ability to configure PDF paper size and page orientation
-        Misc changes to PDF processing
-        Add aux vars print['node'] and print['url']
-        Misc improvements
-May 21, 2008
-        Fix the 'Show book link' option in the PDF version module
-        Fix the display of links to PF pages and PDF in individual comments
-May 20, 2008
-        Correct display of README.txt in the help
-        Restore the print_fill_attributes function
-        Remove the greybox and thickbox selection
-        Add ability to specify customised classes to the PF links
-May 19, 2008
-        Fix #258689: remove some undefined var warnings
-May 13, 2008
-        Add capability to open PDFs inline or to a save dialog
-        Added Danish translation. Thanks topsys!
-        Update Changelog for 6.x-1.0-rc3
-May 12, 2008
-        Slightly better template vars handling
-May 11, 2008
-        Improve translability of template strings
-May 10, 2008
-        Improve the documentation
-May 9, 2008
-        Revert back the last patch
-May 8, 2008
-        Remove what seems to be unnecessary code in print_link
-May 7, 2008
-        Small changes to sync better with the 5.x version
-May 6, 2008
-        Changes to comply with http://www.drupaltoughlove.com/review/printer-friendly-pages
-April 22, 2008
-        Add Printer-friendly module group
-April 21, 2008
-        Added Indonesian translation. Thanks SepedaTua!
-        Added Slovak translation. Thanks empError!
-        Fix #249526: correct German translation
-        Try to fix #230013: only call preg_replace with comment author link if there's anything to replace
-April 17, 2008
-        Remove PDF admin pages dependecy on PHP5.
-        Added Polish translation. Thanks sir_kula!
-        Added Swedish translation. Thanks seals!
-April 3, 2008
-        Add thickbox module support.
-        Fix #239896: Make sure drupal_get_title() returns the original page's title
-April 2, 2008
-        Added Turkish translation. Thanks turkyilmaz1963
-March 27, 2008
-        Remove hard-coding of the greybox class name, now changes to what greybox uses (#233203)
-March 24, 2008
-        Updated Romanian translation. Thanks Andrei
-March 21, 2008
-        Updated translation files to match current code
-March 19, 2008
-        Remove some more PHP warnings
-March 14, 2008
-        Fix #233203: Add option to open in new window using the jQuery Greybox Redux module
-March 11, 2008
-        Some more misc changes by zuriel
-March 7, 2008
-        Some misc changes suggested by zuriel
-March 5, 2008
-        Fix #230318 by shaisachs: include page query in PF link
-March 4, 2008
-        Improve the theme_print_format_link functions
-        Update changelog for release 6.x-1.0-rc1
-        Better fix for #227127: use number of patterns instead of comparing to a
-        Separation of the configuration variables for the HTML and common sections
-        Ability to configure use of text, icon or both in the PF links
-February 28, 2008
-        Adding icons. Thanks to the Plone Foundation
-        Fix #227625: add print['url'] var with absolute source url
-        Add PDF module settings
-February 27, 2008
-        Handle uppercase 'a' tags
-February 26, 2008
-        Properly document the PDF tools installation steps
-        Rename the print_fill_attributes function back to the previous name
-        Correct the support for the PDF per-node-type settings
-        Support print.node-.tpl.php filenames
-February 22, 2008
-        Auto-discovery of the PDF generation tools
-February 21, 2008
-        Make CSS path a full URL so that dompdf can find it
-        Add PDF support
-February 16, 2008
-        Fix #222234: Use Drupal 6 language var
-February 15, 2008
-        Correct print vars when using the printable engine
-February 14, 2008
-        Better support for Drupal 6.x (performance enhancements via include files and new translation I/F)
-        Add current page title to printed breadcrumb
-        Fix #216728 better: if first link was duplicate a new ref was generated
-February 9, 2008
-        Better support for Drupal sites that do not reside in the server root.
-        Fix the 'printable' engine to display the page title.
-        Cleanup code (ran latest coder module)
-February 8, 2008
-        Replace module CSS import with an @import statement
-February 5, 2008
-        Fix 217928: add default value to variable_get('anonymous')
-February 4, 2008
-        Fix #217439: Add defined javascript to the PF page
-        Fix #198688: remove added %20
-        Remove whitespace immediately before and after the '=' sign
-        Fix #216728 by jpereza: Don't show duplicate URLs in the URL list
-        Fix #216716: do not process hreflang attributes
-January 25, 2008
-        Add rel=nofollow tag to PF link (#213951)
-        Add taxonomy terms to the PF page (#214081)
-        Small fixes to 6.x
-January 24, 2008
-        Sync 5.x to 6.x
-        Remove comment forms from PF page (fix for #213425)
-January 23, 2008
-        Fix wrong Paginate hack (replace pages_count with page_count)
-January 22, 2008
-        Added ability to change the output strings through theming (as per #206365)
-        Slightly better solution to #211349.
-        Added Portuguese (Brazil) translation (thanks psychopath_mind!)
-January 21, 2008
-        Fix #211349: Add current query params to PF link
-January 8, 2008
-        Update changelog
-January 5, 2008
-        Add div tags around the logo image (fix for #206568)
-January 2, 2008
-        Fix #202243: Use the anonymous setting for pages with a blank author variable
-December 14, 2007
-        Added ability to theme the print_format_link function (fix for #198397)
-        Added access check to the print_insert_link function
-December 4, 2007
-        Minor fix to #192855, use full base_url if it does not include subdirs
-December 3, 2007
-        Sync print 5.x to 4.7.x
-        Sync 5.x to 6.x
-        Proper fix to the book_node_visitor_html_pre which was incorrectly committed with 'print' instead of 'view'
-        Fix #195917: Use correct module check in hook_link_alter
-December 2, 2007
-        Add replacement book_node_visitor_html_pre so that CCK pages in book nodes print correctly
-November 22, 2007
-        Fix #192855: If relative links start with '/' just append them to the server name (commit to 5.x-3.x-dev)
-        Fix #192855: If relative links start with '/' just append them to the server name
-November 19, 2007
-        Sync print 5.x to 4.7.x
-        Sync print 5.x to 4.7.x
-        Update changelog
-        Complete Spanish translation. Thanks gustz!
-        Complete French translation. Thanks rondev!
-November 17, 2007
-        Complete versions of the Hungarian and German translations. Thanks hinger and hailstorm!
-        Try to solve #192855, by checking also for index.php in relative links
-November 15, 2007
-        Sync print 5.x to 6.x
-        Sync print 5.x to 4.7.x
-        Final translation to russian. Thanks VladSavitsky!
-        Remove TODOs in the .po files
-        Updated Norwegian translation to final. Thanks stenjo!
-        Added (partial) Italian translation. Thanks ccattaneo74!
-        Added (partial) Ukrainian translation. Thanks artem_sokolov!
-        Added (partial) Romanian translation. Thanks baudolino!
-November 15, 2007
-        Added (partial) Romanian translation. Thanks baudolino!
-November 13, 2007
-        Make anchor tags (#id) links usable in the PF version again (after the base href fix broke it).
-        Add setting to control the book PF link via this module
-        Update all .po files to the latest print.pot from the potx module
-November 9, 2007
-        Add the capability to handle book's PF link via this module
-November 8, 2007
-        Enable choice of method to open the new window via radio boxes (now possible to select a Javascript XHTML Strict compliant method)
-November 7, 2007
-        Correct fix for the duplicate PF link in book pages
-        Sync documentation in HEAD with the 5.x version
-        Russian translation by VladSavitsky. Thanks!
-        Remove duplicate PF link in book pages
-November 6, 2007
-        Updated the installation instructions (INSTALL.txt)
-        Update documentation (README, CREDITS and CHANGELOG)
-October 31, 2007
-        Fix #172100: use drupal_get_html_head to starting building the head section
-October 30, 2007
-        Backport of version 5.x-2.x-dev into Drupal 4.7
-        Minor changes
-        Minor changes
-        Minor changes
-October 29, 2007
-        Sync HEAD with latest print-5.x-2.x-dev
-        Changes to work with drupal 6.x
-October 28, 2007
-        Add an inactive line for an XHTML Strict compliant way of opening the PF page in a new window.
-        Fixed small code details raised by the coder module.
-        Updated Norwegian and Hungarian translation. Thanks stenjo and hinger!
-October 27, 2007
-        Added Portuguese (Portugal) translation. Thanks jcnventura :)
-        Fixed settings description bug in the URL list still describing the old link deactivation feature.
-        Remove link area in system pages
-        Update print.pot to current version (and the fr, de, hu and no .po files)
-        Fix problem with printing pages if printing comments is enabled, but the comments module is disabled.
-        Move the print/ path to a constant for easier modification of this hard-coded setting.
-October 25, 2007
-        Fix some issues with the book detection routine and check for access rights for system pages
-        Make the print_insert_link parameter optional.
-        Configure the display of the link for non-node types.
-        Prevent display of the link in book types.
-        Finish comment printing functions (configuration settings and print all comments with node contents capability). Solve #135089
-        Add print_insert_link function for use by content writers to position link anywhere in the content. Solves #186216 and (maybe) #180975
-        Support templates for specific content types and location of templates in both tthe theme directory (checked first) and the module directory. Solves #181458 and #171172
-        Support for printing individual comments
-October 24, 2007
-        Support printer-friendly pages everywhere in Drupal (adapted from printable module)
-October 23, 2007
-        Fix #184776 by deviantintegral: <a> tag rewrite affected <address>
-        No need to transalate spaces and paranthesis on " (retrieved on "
-        Changed print.pot to use string locations in print.module and not print.node.tpl.php
-        German translation by hailstorm
-        Norwegian translation by stenjo
-October 9, 2007
-        Re-structure template and code by moving all the printer-friendly-specific output processing to a dedicated function
-October 6, 2007
-        Hungarian translation by hinger.. Thanks!
-October 1, 2007
-        French translation by rondev
-        Fix #178596 and #178743 by Waldemar: Fix base URL, CSS import and logo code problems with IE 6/7
-September 24, 2007
-        Fixed bug in url alias destination nid, get it from the dst string now
-        Fix #174983: if clean urls is disabled use url() only if it is an a link that does not start with =q?
-        Fix #128049: also accept print/url_alias
-September 13, 2007
-        Try to fix #174983: handling of URLs with Drupal's ?q=
-September 12, 2007
-        Added $node->printing flag to alert other modules.
-        Fix #60817, #74949, #171146, #117236, #172252, #173244.
-        Fixed buggy link in comments, removed service links and fivestar modules output and removed Paginate's module pagination.
-        Correctly handle spaces in filenames and URLs.
-August 30, 2007
-        Fix #171039. urldecode() the input URL before calling url(/) so that unicode chars are processed correctly
-August 28, 2007
-        Fix bug of printer-friendly link being displayed for teasers
-        Fix bug where anchor tags were not correctly converted to absolute and the anchor destination was marked with '[Array]'
-        Made anchor links still navigable when the print urls option is selected
-        Fix bug of string parsing for t() calls in print.node.tpl.php
-        Regenerate po/print.pot with potx module
-August 27, 2007
-        File containing the default CSS styles
-        Changed the render method to behave more like node_view
-        Added the ability to enable/disable the printer-friendly like in the content type form
-        Configuration options regarding the Source URL and the ability to open the page in a new window and print it
-        New URL re-writing method
-        Overall definition of CSS classes and style
-        Hyphenated the words "printer-friendly"
-August 26, 2007
-        New URL rewriting engine; Definition of new CSS classes and styles; Configuration options regarding the Source URL and the ability to open the page in a new window and print it
-August 24, 2007
-        Sync with HEAD
-        Sync with HEAD
-        Profile printing is not working. Since utility is not clear, I am removing itfor now
-        Try to fix #71391 and try to display other node types through the use of the drupal render engine
-        Change maintainer information
-        Fix links to relative/internal URLs (#58100)
-        Fix #129535. Use ->url instead of
-        Fix #49794 and #89724. Use print/nid instead of node/nid/print
-        #60334 by the greenman. Handle 'a name' tags
-        Apply to CVS HEAD Andy Kirkham's DRUPAL-SA-2007-014: fixing access bypass bug for private issues
-August 23, 2007
-        Add current time/date before the Source URL
-        Make the printer friendly page XHTML Strict compliant.
-July 10, 2007
-        DRUPAL-SA-2007-014: fixing access bypass bug for private issues
-        DRUPAL-SA-2007-014: fixing access bypass bug for private issues
-March 26, 2007
-        clean up menu.
-        clean up menu.
-        remove dead code.
-        remove dead code.
-        adding .info file.
-        #88162 -- update to 5.0. patch by hunmonk, diggersf.
-October 23, 2006
-        French translation of print.module Drupal 4.7
-August 2, 2006
-        updated Dutch translation
-July 15, 2006
-        Czech translation of print.module
-March 30, 2006
-        issue #54997: extra slash in URLs
-        issue #54997: extra slash in URLs
-        issue #50299: missing t()
-        issue #50299: missing t()
-January 15, 2006
-        backport of semi-fix for issue #33909
-        backport of issue #42857
-December 31, 2005
-        Added init_theme to fix bug with logo.
-        http://drupal.org/node/42857
-December 30, 2005
-        update stable to HEAD
-        put some bug fixes from HEAD into DRUPAL-4-7
-        Fixed bug: http://drupal.org/node/25437
-        Fixed print url friendly (http://drupal.org/node/18716)
-        Updated to DRUPAL-4-7
-December 21, 2005
-        update version requirements
-        summarize tonight's changes
-        contrib by Markus Petrux for Drupal 4.6
-        remove hardcode print.css location, let robots meta work for print_generate_profile(), update users table query for Drupal 4.7, and fix an error missing parameter to variable_get()
-December 21, 2005
-        default settings point to a css file and it makes a lot of 404 errors to not have one to match
-        work on forms API compatability, and fixes towards issues #33909, #28265, #17322, #25437
-        bug fix #17317
-December 20, 2005
-        bug fixes #33909, #25275, #31715, #17317
-        fix bug #18716
-        Updated with patch for 4.7.
-        Updated for 4.
-August 24, 2005
-        Added missing word.
-        Added missing word.
-July 27, 2005
-        * Renamed file to print.node.tpl.php
-        * Created a general print controller to allow modules to generate printer friendly views.
-        * Printer friendly profile pages. See INSTALL.txt for details.
-        * Renamed the node print template from print.tpl.php to print.node.tpl.php
-July 14, 2005
-        Commited my patch from
-          http://drupal.org/node/25458
-        with permission of the maintainer.
-June 21, 2005
-        Added German translation.
-June 1, 2005
-        - Brazilian Portuguese Translation of print.module
-        - Added print.tpl.php strings
-April 26, 2005
-        Updated print.pot file.
-February 14, 2005
-        km - corrected printing of source URL
-        km - changed the syntax of some lines to pass code-style.pl checks
-January 28, 2005
-        km - removed hint on site logo
-        km - changed strings back to 'printer friendly page'
-January 28, 2005
-        km - introduced printer friendly icon
-January 26, 2005
-        km - changed line numbers and added strings from print.tpl.php
-        km - changed strings, added strings from print.tpl.php
-        km - included changes from HEAD
-        km - changed link
-        km - improved layout and localized strings
-January 25, 2005
-        km - honor themes' global settings for "Display post information"
-        km - print_link() checks if page is a book
-        km - changed maintainer
-November 25, 2004
-        * Made CSS import work
-November 15, 2004
-        created pot-file with extractor.php and added dutch translation
-November 12, 2004
-        added CUSTOMIZATION
-November 5, 2004
-        Taking over maintainance
-October 30, 2004
-        * Created a print.tpl.php template file to give site admins control of what node parts this module renders and how the pages are structured. This feature, combined with the custom print stylesheet option, gives max freedom in rendering print friendly pages.
-        * Created a print.tpl.php template file to give site admins control of what node parts this module renders and how the pages are structured. This feature, combined with the custom print stylesheet option, gives max freedom in rendering print friendly pages.
-October 28, 2004
-        * Generate printer friendly pages for all node types.  Features include the ability to list $node->body URL references at the end of the page, custom print stylesheet and choosing which node elements to display.
-January 9, 2002
-      print.module- initial commit.
-      - attempted to fix the bugs with the chatbox module. Feedback requested.
-      - need some installation instructions. Anyone?
-      file print.module was initially added on branch DRUPAL-3-0.
-October 19, 2001
-      file LICENSE was initially added on branch DRUPAL-3-0.

+ 6 - 2
sites/all/modules/contrib/admin/print/css/print-rtl.css

@@ -1,5 +1,9 @@
-body {direction: rtl;}
-th {text-align: right;}
+body {
+  direction: rtl;
+}
+th {
+  text-align: right;
+}
 .print-links,
 .print-source_url,
 .print-taxonomy {

+ 66 - 24
sites/all/modules/contrib/admin/print/css/print.css

@@ -8,36 +8,78 @@ th {
   color: #006;
   border-bottom: 1px solid #ccc;
 }
-tr.odd {background-color: #ddd;}
-tr.even {background-color: #fff;}
-td {padding: 5px;}
-#menu {visibility: hidden;}
-#main {margin: 1em;}
-a:link {color: #000;}
-a:visited {color: #000;}
-a:hover {color: #00f;}
-a:link img, a:visited img {border: 0;}
-.print-footnote {font-size: xx-small;}
-img.print-logo {border: 0;}
-.print-site_name {}
-.print-breadcrumb {font-size: x-small;}
-.print-title {}
-.print-submitted {font-size: small;}
-.print-created {font-size: small;}
-.print-taxonomy {text-align: right;}
-.print-taxonomy li {display: inline;}
-.print-content {}
+tr.odd {
+  background-color: #ddd;
+}
+tr.even {
+  background-color: #fff;
+}
+td {
+  padding: 5px;
+}
+#menu {
+  visibility: hidden;
+}
+#main {
+  margin: 1em;
+}
+a:link {
+  color: #000;
+}
+a:visited {
+  color: #000;
+}
+a:hover {
+  color: #00f;
+}
+a:link img,
+a:visited img {
+  border: 0;
+}
+.print-footnote {
+  font-size: xx-small;
+}
+img.print-logo {
+  border: 0;
+}
+.print-site_name {
+}
+.print-breadcrumb {
+  font-size: x-small;
+}
+.print-title {
+}
+.print-submitted {
+  font-size: small;
+}
+.print-created {
+  font-size: small;
+}
+.print-taxonomy {
+  text-align: right;
+}
+.print-taxonomy li {
+  display: inline;
+}
+.print-content {
+}
 .print-hr {
   border: 0;
   height: 1px;
   width: 100%;
-  color: #9E9E9E;
-  background-color: #9E9E9E;
+  color: #9e9e9e;
+  background-color: #9e9e9e;
 }
 .print-message {
   border: medium dotted blue;
   padding: 1em;
 }
-.print-source_url {font-size: small;}
-.print-links {font-size: small;}
-.print-footer {text-align: center;}
+.print-source_url {
+  font-size: small;
+}
+.print-links {
+  font-size: small;
+}
+.print-footer {
+  text-align: center;
+}

+ 59 - 25
sites/all/modules/contrib/admin/print/includes/print.drush.inc

@@ -2,21 +2,21 @@
 
 /**
  * @file
- * common drush functions for the print submodules.
+ * Common drush functions for the print submodules.
  */
 
 /**
- * Download and extract the lib
+ * Download and extract the lib.
  *
  * @param string $library
- *   library to download.
+ *   Library to download.
  * @param string $url
- *   URL of the file to download
+ *   URL of the file to download.
  */
 function _print_drush_download_lib($library, $url) {
   $path = drush_get_option('path');
   if (empty($path)) {
-    $path = drush_get_context('DRUSH_DRUPAL_ROOT') . '/sites/all/libraries';
+    $path = drush_get_context('DRUSH_DRUPAL_ROOT') . '/sites/all/libraries/' . $library;
   }
 
   // Create the path if it does not exist.
@@ -29,18 +29,21 @@ function _print_drush_download_lib($library, $url) {
   $olddir = getcwd();
   drush_op('chdir', $path);
 
-  // Warn about an existing dir
+  // Warn about an existing dir.
   if (is_dir($library)) {
-    // drush_op('rmdir', $library); // Directory must be empty for the php rmdir to work..
     drush_log(dt('An existing @library was overwritten at @path', array('@library' => $library, '@path' => $path . '/' . $library)), 'notice');
   }
 
-  // Download the archive
+  if (preg_match('!api.github.com/repos/.*/releases/latest!', $url)) {
+    $url = _print_drush_github_latest_url($url);
+  }
+
+  // Download the archive.
   $filename = _print_drush_download_file($url);
   if ($filename) {
     $extract_ret = _print_drush_download_extract($filename);
     if ($extract_ret) {
-      // Remove the archive
+      // Remove the archive.
       drush_op('unlink', $filename);
       drush_log(dt('@file has been downloaded and extracted in @path', array('@file' => $filename, '@path' => $path)), 'success');
     }
@@ -58,23 +61,47 @@ function _print_drush_download_lib($library, $url) {
 }
 
 /**
- * Download a file using wget or curl
+ * Get filename of latest from github.
+ *
+ * @param string $github_url
+ *   The github URL to the latest project release.
+ *
+ * @return string
+ *   The URL to the latest file release.
+ */
+function _print_drush_github_latest_url($github_url) {
+  $filename = _print_drush_download_file($github_url);
+  $contents = file_get_contents($filename);
+  drush_op('unlink', $filename);
+  $json = json_decode($contents);
+  if (isset($json->assets[0])) {
+    $download_url = $json->assets[0]->browser_download_url;
+  }
+  else {
+    // Try the zipball_url.
+    $download_url = $json->zipball_url;
+  }
+
+  return $download_url;
+}
+
+/**
+ * Download a file using wget or curl.
  *
  * Adapted from a function in drush/includes/drush.inc to support 302 redirects.
  *
  * @param string $download_url
- *   The path to the file to download
+ *   The path to the file to download.
  *
  * @return string
  *   The filename that was downloaded, or NULL if the file could not be
  *   downloaded.
  */
 function _print_drush_download_file($download_url) {
-  $wget_ret = drush_shell_exec("wget -nv --trust-server-names %s", $download_url);
-
   if (!drush_get_context('DRUSH_SIMULATE')) {
+    $wget_ret = drush_shell_exec("wget -nv --content-disposition %s", $download_url);
     if ($wget_ret) {
-      // Get the filename of the saved file from the output
+      // Get the filename of the saved file from the output.
       $wget_out = explode('"', array_shift(drush_shell_exec_output()));
       $filename = $wget_out[1];
     }
@@ -83,13 +110,12 @@ function _print_drush_download_file($download_url) {
 
       $curl_ret = drush_shell_exec("curl -s -L -o %s %s -w '%%{url_effective}'", $tempnam, $download_url);
       if ($curl_ret) {
-        // File was donwloaded with the tempname
-
-        // Find the effective name
+        // File was downloaded with the temporary name.
+        // Find the effective name.
         $filename = explode('/', array_shift(drush_shell_exec_output()));
         $filename = array_pop($filename);
 
-        // Rename file from tempname to effective name
+        // Rename file from tempname to effective name.
         if (!drush_op('rename', $tempnam, './' . $filename)) {
           $filename = $tempnam;
         }
@@ -110,7 +136,7 @@ function _print_drush_download_file($download_url) {
  * Helper to extract the downloaded zip/tar archive.
  *
  * @param string $filename
- *   filename of the file to extract
+ *   Filename of the file to extract.
  *
  * @return bool
  *   TRUE on success, FALSE on failure
@@ -119,28 +145,36 @@ function _print_drush_download_extract($filename) {
   $arch_ret = FALSE;
 
   if (drush_op('is_file', $filename)) {
-    switch (drush_op('mime_content_type', $filename)) {
+    $mime_type = drush_op('mime_content_type', $filename);
+    switch ($mime_type) {
       case 1:
         $arch_ret = TRUE;
         break;
+
       case 'application/zip':
-        // Decompress the zip archive
+        // Decompress the zip archive.
         $arch_ret = drush_shell_exec('unzip -qq -o %s', $filename);
-        // ZIP archives usually get the access rights wrong
+        // ZIP archives usually get the access rights wrong.
         drush_log(dt('@filename is a Zip file. Check the access permissions of the extracted files.', array('@filename' => $filename)), 'warning');
         break;
+
       case 'application/x-gzip':
-        // Decompress the tar gz archive
+        // Decompress the tar gz archive.
         $arch_ret = drush_shell_exec('tar xzf %s', $filename);
         break;
+
       case 'application/x-bzip2':
-        // Decompress the tar bz2 archive
+        // Decompress the tar bz2 archive.
         $arch_ret = drush_shell_exec('tar xjf %s', $filename);
         break;
+
       case 'application/x-xz':
-        // Decompress the tar xz archive
+        // Decompress the tar xz archive.
         $arch_ret = drush_shell_exec('tar xJf %s', $filename);
         break;
+
+      default:
+        drush_log(dt('Unknown MIME type: @type', array('@type' => $mime_type)), 'error');
     }
   }
   else {

+ 14 - 14
sites/all/modules/contrib/admin/print/includes/print.inc

@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Common functions used by several of the print modules
+ * Common functions used by several of the print modules.
  *
  * @ingroup print
  */
@@ -29,18 +29,18 @@ function _print_scan_libs($lib, $mask) {
 }
 
 /**
- * Callback function for the preg_replace_callback replacing spaces with %20
+ * Callback function for the preg_replace_callback replacing spaces with %20.
  *
  * Replace spaces in URLs with %20
  *
  * @param array $matches
- *   array with the matched tag patterns, usually <a...>+text+</a>
+ *   Array with the matched tag patterns, usually <a...>+text+</a>.
  *
  * @return string
  *   tag with re-written URL
  */
 function _print_replace_spaces($matches) {
-  // first, split the html into the different tag attributes
+  // 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) {
@@ -48,8 +48,8 @@ function _print_replace_spaces($matches) {
   }
 
   $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
+  for ($i = 1; $i < $size; $i++) {
+    // If the attribute is href or src, we 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);
@@ -66,7 +66,7 @@ function _print_replace_spaces($matches) {
 }
 
 /**
- * Convert image paths to the file:// protocol
+ * Convert image paths to the file:// protocol.
  *
  * In some Drupal setups, the use of the 'private' filesystem or Apache's
  * configuration prevent access to the images of the page. This function
@@ -74,9 +74,9 @@ function _print_replace_spaces($matches) {
  * filesystem.
  *
  * @param string $html
- *   contents of the post-processed template already with the node data
+ *   Contents of the post-processed template already with the node data.
  * @param bool $images_via_file
- *   if TRUE, convert also files in the 'public' filesystem to local paths
+ *   If TRUE, convert also files in the 'public' filesystem to local paths.
  *
  * @return string
  *   converted file names
@@ -86,13 +86,13 @@ function _print_access_images_via_file($html, $images_via_file) {
 
   $lang = (function_exists('language_negotiation_get_any') && language_negotiation_get_any('locale-url')) ? $language->language : '';
 
-  // Always convert private to local paths
-  $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?system/files/([^>]*?>)!is";
-  $replacement = '$1file://' . realpath(variable_get('file_private_path', '')) . '/$2';
+  // Always convert private to local paths.
+  $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?system/files/([^>\?]*)(?:\?itok=[a-zA-Z0-9\-_]{8})?([^>]*?>)!is";
+  $replacement = '$1file://' . realpath(variable_get('file_private_path', '')) . '/$2$3';
   $html = preg_replace($pattern, $replacement, $html);
   if ($images_via_file) {
-    $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?([^>]*?>)!is";
-    $replacement = '$1file://' . dirname($_SERVER['SCRIPT_FILENAME']) . '/$2';
+    $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?([^>\?]*)(?:\?itok=[a-zA-Z0-9\-_]{8})?([^>]*?>)!is";
+    $replacement = '$1file://' . DRUPAL_ROOT . '/$2$3';
     $html = preg_replace($pattern, $replacement, $html);
   }
 

+ 28 - 6
sites/all/modules/contrib/admin/print/print.admin.inc

@@ -19,7 +19,9 @@ function print_main_settings() {
   $print_css = variable_get('print_css', PRINT_CSS_DEFAULT);
   // Check that the stylesheet path is indeed valid and relative to base_path()
   if (!empty($print_css) && empty($_POST)) {
-    $css_path = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . strtr($print_css, array('%t' => drupal_get_path('theme', variable_get('theme_default', 'garland'))));
+    $css_path = DRUPAL_ROOT . '/' . strtr($print_css, array(
+      '%t' => drupal_get_path('theme', variable_get('theme_default', 'garland')),
+    ));
     if (!is_file($css_path) || !is_readable($css_path)) {
       drupal_set_message(t("File %file is not readable by the web server.", array('%file' => $css_path)), 'warning', FALSE);
     }
@@ -37,8 +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.') . '<br />' .
-                      t('Macros: %t (path to theme: "%theme")', array('%theme' => drupal_get_path('theme', variable_get('theme_default', 'bartik')))) . '<br />' .
-                      t('Requires the <em>Administer site configuration</em> permission.'),
+      t('Macros: %t (path to theme: "%theme")', array(
+        '%theme' => drupal_get_path('theme', variable_get('theme_default', 'bartik')),
+      )) . '<br />' .
+      t('Requires the <em>Administer site configuration</em> permission.'),
     '#disabled' => !user_access('administer site configuration'),
   );
 
@@ -54,7 +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.') . '<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/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(
@@ -71,6 +77,13 @@ function print_main_settings() {
     '#description' => t('When this option is active, user comments are also included in the printer-friendly version. Requires the comment module.'),
   );
 
+  $form['settings']['print_node_router'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Consult menu router for node display handler'),
+    '#default_value' => variable_get('print_node_router', PRINT_NODE_ROUTER_DEFAULT),
+    '#description' => t('When this option is active, print module will check the menu router for the handler to consult for page contents at node/%node.'),
+  );
+
   $form['settings']['print_newwindow'] = array(
     '#type' => 'radios',
     '#title' => t('New window method'),
@@ -89,7 +102,11 @@ function print_main_settings() {
   $form['settings']['logo']['print_logo_options'] = array(
     '#type' => 'radios',
     '#title' => t('Logo type'),
-    '#options' => array(t('None (Disabled)'), t("Current theme's logo"), t('User-specified')),
+    '#options' => array(
+      t('None (Disabled)'),
+      t("Current theme's logo"),
+      t('User-specified'),
+    ),
     '#default_value' => variable_get('print_logo_options', PRINT_LOGO_OPTIONS_DEFAULT),
     '#description' => t("Select the type of logo to display on the printer-friendly version. In case of a user-specified location, insert the path or URL below."),
   );
@@ -120,7 +137,11 @@ function print_main_settings() {
   $form['settings']['footer']['print_footer_options'] = array(
     '#type' => 'radios',
     '#title' => t('Footer type'),
-    '#options' => array(t('None (Disabled)'), t("Site's footer"), t('User-specified')),
+    '#options' => array(
+      t('None (Disabled)'),
+      t("Site's footer"),
+      t('User-specified'),
+    ),
     '#default_value' => variable_get('print_footer_options', PRINT_FOOTER_OPTIONS_DEFAULT),
     '#description' => t("Select the type of footer to display on the printer-friendly version. In case of a user-specified footer, insert it below."),
   );
@@ -179,6 +200,7 @@ function _print_main_settings_validate($form, &$form_state) {
     // files table as a temporary file. We'll make a copy and let the garbage
     // collector delete the original upload.
     if ($filename = file_unmanaged_copy($file->uri)) {
+      /** @var DrupalStreamWrapperInterface $wrapper */
       $wrapper = file_stream_wrapper_get_instance_by_uri($filename);
 
       $form_state['values']['print_logo_options'] = 2;

+ 2 - 2
sites/all/modules/contrib/admin/print/print.api.php

@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Main API entry point for the Printer, email and PDF versions
+ * Main API entry point for the Printer, email and PDF versions.
  *
  * @ingroup print
  */
@@ -109,7 +109,7 @@
  * etc.).
  *
  * @param string $url
- *   the url to be modified.
+ *   The url to be modified.
  *
  * @ingroup print_hooks
  */

+ 3 - 4
sites/all/modules/contrib/admin/print/print.info

@@ -6,9 +6,8 @@ files[] = print_join_page_counter.inc
 dependencies[] = node
 configure = admin/config/user-interface/print
 
-; Information added by Drupal.org packaging script on 2014-04-02
-version = "7.x-2.0"
+; Information added by Drupal.org packaging script on 2018-10-05
+version = "7.x-2.2"
 core = "7.x"
 project = "print"
-datestamp = "1396426766"
-
+datestamp = "1538760185"

+ 12 - 7
sites/all/modules/contrib/admin/print/print.install

@@ -21,7 +21,7 @@ function print_install() {
  * Implements hook_enable().
  */
 function print_enable() {
-  // Module weight
+  // Module weight.
   db_update('system')
     ->fields(array(
       'weight' => 0,
@@ -146,7 +146,7 @@ function print_schema() {
 }
 
 /**
- * Remove hardcoded numeric deltas from all blocks
+ * Remove hardcoded numeric deltas from all blocks.
  */
 function print_update_7000(&$sandbox) {
   $renamed_deltas = array(
@@ -160,14 +160,14 @@ function print_update_7000(&$sandbox) {
 }
 
 /**
- * Enable the print UI module
+ * Enable the print UI module.
  */
 function print_update_7199(&$sandbox) {
   module_enable(array('print_ui'), FALSE);
 }
 
 /**
- * Delete old variables
+ * Delete old variables.
  */
 function print_update_7200(&$sandbox) {
   variable_del('print_settings');
@@ -193,7 +193,7 @@ function print_update_7200(&$sandbox) {
 }
 
 /**
- * Enable block and help area links
+ * Enable block and help area links.
  */
 function print_update_7202(&$sandbox) {
   $link_pos = variable_get('print_html_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
@@ -203,11 +203,16 @@ function print_update_7202(&$sandbox) {
 }
 
 /**
- * Increase size of the path field in the print_page_counter table
+ * Increase size of the path field in the print_page_counter table.
  */
 function print_update_7203(&$sandbox) {
   db_drop_primary_key('print_page_counter');
   db_change_field('print_page_counter', 'path', 'path',
-    array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Page path'),
+    array(
+      'type' => 'varchar',
+      'length' => 255,
+      'not null' => TRUE,
+      'description' => 'Page path',
+    ),
     array('primary key' => array('path')));
 }

+ 30 - 17
sites/all/modules/contrib/admin/print/print.module

@@ -21,6 +21,7 @@ define('PRINT_KEEP_THEME_CSS_DEFAULT', 0);
 define('PRINT_URLS_DEFAULT', 1);
 define('PRINT_URLS_ANCHORS_DEFAULT', 0);
 define('PRINT_COMMENTS_DEFAULT', 0);
+define('PRINT_NODE_ROUTER_DEFAULT', 0);
 define('PRINT_NEWWINDOW_DEFAULT', 1);
 
 define('PRINT_TYPE_URLLIST_DEFAULT', 1);
@@ -85,7 +86,13 @@ function print_permission() {
 function print_theme() {
   return array(
     'print' => array(
-      'variables' => array('node' => NULL, 'query' => NULL, 'format' => '', 'expand_css' => FALSE, 'message' => ''),
+      'variables' => array(
+        'node' => NULL,
+        'query' => NULL,
+        'format' => '',
+        'expand_css' => FALSE,
+        'message' => '',
+      ),
       'template' => 'print',
       'file' => 'print.pages.inc',
     ),
@@ -207,7 +214,7 @@ function print_block_view($delta = '') {
     case 'print-top':
       $block['subject'] = t('Most printed');
       $result = db_query_range("SELECT path FROM {print_page_counter} LEFT JOIN {node} n ON path = CONCAT('node/', n.nid) WHERE status <> 0 OR status IS NULL ORDER BY totalcount DESC", 0, 3)
-                  ->fetchAll();
+        ->fetchAll();
       if (count($result)) {
         $items = array();
         foreach ($result as $obj) {
@@ -224,11 +231,13 @@ function print_block_view($delta = '') {
  * Implements hook_help().
  */
 function print_help($path, $arg) {
+  $ret = '';
   switch ($path) {
     case 'admin/help#print':
-      // Return a line-break version of the module README
-      return _filter_autop(file_get_contents(drupal_get_path('module', 'print') . '/README.txt'));
+      // Return a line-break version of the module README.
+      $ret = _filter_autop(file_get_contents(drupal_get_path('module', 'print') . '/README.txt'));
   }
+  return $ret;
 }
 
 /**
@@ -251,7 +260,7 @@ function print_entity_info_alter(&$info) {
       'custom settings' => FALSE,
     ),
   );
-  // Add the 'Print' view mode for field_collections
+  // Add the 'Print' view mode for field_collections.
   if (module_exists('field_collection')) {
     $info['field_collection_item']['view modes'] += array(
       PRINT_VIEW_MODE => array(
@@ -263,10 +272,10 @@ function print_entity_info_alter(&$info) {
 }
 
 /**
- * Auxiliary function to discover a given page's title
+ * Auxiliary function to discover a given page's title.
  *
  * @param string $path
- *   path of the page being identified
+ *   Path of the page being identified.
  *
  * @return string
  *   string with the page's title
@@ -276,16 +285,16 @@ function _print_get_title($path) {
   $nid = preg_replace('!^node/!', '', $path);
   if (ctype_digit($nid)) {
     return db_query("SELECT title FROM {node} WHERE nid = :nid", array(':nid' => $nid))
-              ->fetchField();
+      ->fetchField();
   }
   else {
-    // Not a node, try to get title from the menu system
+    // Not a node, try to get title from the menu system.
     $menu_item = menu_get_item($path);
     if (!empty($menu_item['title'])) {
       return $menu_item['title'];
     }
     elseif (drupal_substr($menu_item['page_callback'], 0, 6) == 'views_') {
-      // It's a view, load the view to have access to the title
+      // It's a view, load the view to have access to the title.
       $view = views_get_view($menu_item['page_arguments']['0']);
       return $view->get_title();
     }
@@ -296,7 +305,7 @@ function _print_get_title($path) {
 }
 
 /**
- * Auxiliary function to display a formatted Printer-friendly link
+ * Auxiliary function to display a formatted Printer-friendly link.
  *
  * Function made available so that developers may call this function from
  * their defined pages/blocks.
@@ -307,7 +316,7 @@ function _print_get_title($path) {
  *   node object, to be used in checking node access. If the path argument is
  *   not provided, the path used will be node/nid.
  * @param string $location
- *   where in the page where the link is being inserted ('link', 'corner',
+ *   Where in the page where the link is being inserted ('link', 'corner',
  *   'block', 'help').
  *
  * @return string
@@ -317,7 +326,11 @@ function _print_get_title($path) {
  */
 function print_insert_link($path = NULL, $node = NULL, $location = '') {
   if (function_exists('print_ui_insert_link')) {
-    return print_ui_insert_link(print_print_link(), array('path' => $path, 'node' => $node, 'location' => $location));
+    return print_ui_insert_link(print_print_link(), array(
+      'path' => $path,
+      'node' => $node,
+      'location' => $location,
+    ));
   }
   else {
     return FALSE;
@@ -325,11 +338,11 @@ function print_insert_link($path = NULL, $node = NULL, $location = '') {
 }
 
 /**
- * Check if the link to the PF version is allowed depending on the settings
+ * Check if the link to the PF version is allowed depending on the settings.
  *
  * @param array $args
- *   array containing the possible parameters:
- *    view_mode, node, type, path
+ *   Array containing the possible parameters:
+ *    view_mode, node, type, path.
  *
  * @return bool
  *   FALSE if not allowed, TRUE otherwise
@@ -342,7 +355,7 @@ function print_link_allowed($args) {
  * Implements hook_contextual_links_view_alter().
  */
 function print_contextual_links_view_alter(&$element, $items) {
-  // Hide all contextual links
+  // Hide all contextual links.
   if (preg_match('!^print!', $_GET['q'])) {
     unset($element['#links']);
   }

+ 156 - 128
sites/all/modules/contrib/admin/print/print.pages.inc

@@ -14,30 +14,34 @@
 $_print_urls = PRINT_URLS_DEFAULT;
 
 /**
- * Generate an HTML version of the printer-friendly page
+ * Generate an HTML version of the printer-friendly page.
  *
  * @see print_controller()
  */
 function print_controller_html() {
   $args = func_get_args();
   $path = filter_xss(implode('/', $args));
-  $cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
+  $cid = isset($_GET['comment']) ? (int) $_GET['comment'] : NULL;
   $link = print_print_link();
 
   $node = print_controller($path, $link['format'], $cid);
   if ($node) {
-    // Handle the query
+    // Handle the query.
     $query = $_GET;
     unset($query['q']);
 
-    $html = theme('print', array('node' => $node, 'query' => $query, 'format' => $link['format']));
+    $html = theme('print', array(
+      'node' => $node,
+      'query' => $query,
+      'format' => $link['format'],
+    ));
     drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
     drupal_send_headers();
     print $html;
 
     $nodepath = (isset($node->nid)) ? 'node/' . $node->nid : drupal_get_normal_path($path);
     db_merge('print_page_counter')
-      ->key(array('path' => $nodepath))
+      ->key(array('path' => substr($nodepath, 0, 255)))
       ->fields(array(
         'totalcount' => 1,
         'timestamp' => REQUEST_TIME,
@@ -48,19 +52,19 @@ function print_controller_html() {
 }
 
 /**
- * Select the print generator function based on the page type
+ * Select the print generator function based on the page type.
  *
  * Depending on the type of node, this functions chooses the appropriate
  * generator function.
  *
  * @param string $path
- *   path of the original page
+ *   Path of the original page.
  * @param string $format
- *   format of the page being generated
+ *   Format of the page being generated.
  * @param int $cid
- *   comment ID of the individual comment to be rendered
+ *   Comment ID of the individual comment to be rendered.
  * @param string $view_mode
- *   (optional) view mode to be used when rendering the content
+ *   (Optional) view mode to be used when rendering the content.
  *
  * @return object
  *   node-like object to be used in the print template
@@ -72,7 +76,7 @@ function print_controller_html() {
  */
 function print_controller($path, $format, $cid = NULL, $view_mode = PRINT_VIEW_MODE) {
   if (empty($path)) {
-    // If no path was provided, let's try to generate a page for the referer
+    // If no path was provided, let's try to generate a page for the referer.
     global $base_url;
 
     $ref = $_SERVER['HTTP_REFERER'];
@@ -83,27 +87,30 @@ function print_controller($path, $format, $cid = NULL, $view_mode = PRINT_VIEW_M
   }
   if ($alias = drupal_lookup_path('source', $path)) {
     // Indirect call with print/alias
-    // If there is a path alias with these arguments, generate a printer-friendly version for it
+    // If there is a path alias with these arguments, generate a
+    // printer-friendly version for it.
     $path = $alias;
   }
   $parts = explode('/', $path);
-  if (($parts[0] == 'node') && (count($parts) > 1) && ctype_digit($parts[1])) {
+  $node_router = variable_get('print_node_router', FALSE);
+  if (($parts[0] == 'node') && (count($parts) > 1) && ctype_digit($parts[1]) && !$node_router) {
     array_shift($parts);
     $path = implode('/', $parts);
   }
   $revision_view = preg_match('!^[\d]*/revisions/[\d]*/view$!', $path);
-  if (ctype_digit($parts[0]) && ((count($parts) == 1) || $revision_view)) {
+  if (ctype_digit($parts[0]) && ((count($parts) == 1) || $revision_view) && !$node_router) {
     $vid = $revision_view ? $parts[2] : NULL;
     $node = _print_generate_node($path, $format, $vid, $cid, $view_mode);
   }
   else {
     $ret = preg_match('!^book/export/html/(.*)!i', $path, $matches);
     if ($ret == 1) {
-      // This is a book PF page link, handle trough the book handling functions
+      // This is a book PF page link, handle trough the book handling functions.
       $node = _print_generate_book($matches[1], $format);
     }
     else {
-      // If no content node was found, handle the page printing with the 'printable' engine
+      // If no content node was found, handle the page printing with the
+      // 'printable' engine.
       $node = _print_generate_path($path, $format);
     }
   }
@@ -115,8 +122,6 @@ function print_controller($path, $format, $cid = NULL, $view_mode = PRINT_VIEW_M
  * Implements hook_preprocess_HOOK().
  */
 function print_preprocess_print(&$variables) {
-  global $language;
-
   $node = $variables['node'];
   $format = $variables['format'];
   $path = drupal_get_path_alias(empty($node->nid) ? $node->path : "node/$node->nid");
@@ -128,12 +133,12 @@ function print_preprocess_print(&$variables) {
   }
 
   $variables['page']['#show_messages'] = FALSE;
+  $variables['theme_hook_suggestions'] = array();
 
-  // Stolen from theme() so that ALL preprocess functions are called
+  // Stolen from theme() so that ALL preprocess functions are called.
   $hook = 'page';
   $info = $hooks[$hook];
   if (isset($info['preprocess functions']) || isset($info['process functions'])) {
-    $variables['theme_hook_suggestions'] = array();
     foreach (array('preprocess functions', 'process functions') as $phase) {
       if (!empty($info[$phase])) {
         foreach ($info[$phase] as $processor_function) {
@@ -149,41 +154,54 @@ function print_preprocess_print(&$variables) {
 
   $logo_url = FALSE;
   switch (variable_get('print_logo_options', PRINT_LOGO_OPTIONS_DEFAULT)) {
-    case 1: // theme's
+    // Theme logo.
+    case 1:
       $logo_url = theme_get_setting('logo');
       break;
-    case 2: // user-specifed
+
+    // User-specifed logo.
+    case 2:
       $logo_url = strip_tags(variable_get('print_logo_url', PRINT_LOGO_URL_DEFAULT));
       break;
   }
   $logo_url = preg_replace('!^' . base_path() . '!', '', $logo_url);
 
-  $variables['print_logo']                     = $logo_url ? theme('image', array('path' => $logo_url, 'alt' => variable_get('site_name', 'Drupal'), 'attributes' => array('class' => 'print-logo', 'id' => 'logo'))) : NULL;
-
-  $variables['print_node']                     = $node;
-  $variables['content']                  = $node->content;
-  $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['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['print_title']                    = check_plain($node->title);
-  $variables['head']                     = drupal_get_html_head();
-  $variables['robots_meta']              = _print_robots_meta_generator();
-  $variables['css']                      = _print_css_generator($variables['expand_css']);
+  $variables['print_logo'] = $logo_url ? theme('image', array(
+    'path' => $logo_url,
+    'alt' => variable_get('site_name', 'Drupal'),
+    'attributes' => array(
+      'class' => array('print-logo'),
+      'id' => 'logo',
+    ),
+  )) : NULL;
+
+  $variables['print_node'] = $node;
+  $variables['content'] = $node->content;
+  $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['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['print_title'] = check_plain($node->title);
+  $variables['head'] = drupal_get_html_head();
+  $variables['robots_meta'] = _print_robots_meta_generator();
+  $variables['css'] = _print_css_generator($variables['expand_css']);
 
   if (variable_get('print_html_sendtoprinter', PRINT_HTML_SENDTOPRINTER_DEFAULT) && ($format == 'html')) {
-    drupal_add_js('misc/drupal.js', array('weight' => JS_LIBRARY));
+    drupal_add_js('misc/drupal.js', array('group' => JS_LIBRARY));
 
-    $window_close = (variable_get('print_html_new_window', PRINT_HTML_NEW_WINDOW_DEFAULT) && variable_get('print_html_windowclose', PRINT_HTML_WINDOWCLOSE_DEFAULT)) ? 'window.close();' : '';
-    $variables['sendtoprinter'] = '<script type="text/javascript">(function ($) { Drupal.behaviors.print = {attach: function(context) {$(window).load(function() {window.print();' . $window_close . '})}}})(jQuery);</script>';
+    $window_close = (variable_get('print_html_new_window', PRINT_HTML_NEW_WINDOW_DEFAULT) && variable_get('print_html_windowclose', PRINT_HTML_WINDOWCLOSE_DEFAULT)) ? 'setTimeout(function(){window.close();}, 1);' : '';
+    $variables['sendtoprinter'] = '<script type="text/javascript">(function ($) { Drupal.behaviors.print = {attach: function() {$(window).load(function() {window.print();' . $window_close . '})}}})(jQuery);</script>';
   }
 
   $type = (isset($node->type)) ? $node->type : '';
   $nid = (isset($node->nid)) ? $node->nid : '';
 
-  $variables['theme_hook_suggestions'] = array();
   $variables['theme_hook_suggestions'][] = "print__node__{$type}";
   $variables['theme_hook_suggestions'][] = "print__node__{$type}__{$nid}";
   $variables['theme_hook_suggestions'][] = "print__{$format}";
@@ -195,7 +213,7 @@ function print_preprocess_print(&$variables) {
  * Returns HTML for the published line of the print template.
  *
  * @param array $vars
- *   An empty associative array
+ *   An empty associative array.
  *
  * @return string
  *   HTML text with the published line
@@ -215,7 +233,7 @@ function theme_print_published($vars) {
  *
  * @param array $vars
  *   An associative array containing:
- *   - $node: the node object
+ *   - $node: the node object.
  *
  * @return string
  *   HTML text with the breadcrumb
@@ -245,7 +263,7 @@ function theme_print_breadcrumb($vars) {
  * Returns HTML for the footer of the print template.
  *
  * @param array $vars
- *   An empty associative array
+ *   An empty associative array.
  *
  * @return string
  *   HTML text with the footer
@@ -257,15 +275,18 @@ function theme_print_footer($vars) {
   $footer = '';
 
   switch (variable_get('print_footer_options', PRINT_FOOTER_OPTIONS_DEFAULT)) {
-    case 1: // theme's
+    // Theme footer.
+    case 1:
       $footer_blocks = block_get_blocks_by_region('footer');
       $footer = variable_get('site_footer', FALSE) . "\n" . drupal_render($footer_blocks);
       break;
-    case 2: // user-specifed
+
+    // User-specified footer.
+    case 2:
       $footer = variable_get('print_footer_user', PRINT_FOOTER_USER_DEFAULT);
       break;
   }
-  // Delete the contextual links
+  // Delete the contextual links.
   $footer = preg_replace('!\s*<div class="contextual-links-wrapper">.*?</div>!sim', '', $footer);
 
   return filter_xss_admin($footer);
@@ -308,7 +329,7 @@ function theme_print_sourceurl($vars) {
  * Returns HTML for the URL list of the print template.
  *
  * @param array $vars
- *   An empty associative array
+ *   An empty associative array.
  *
  * @return string
  *   HTML text with the URL list
@@ -319,10 +340,10 @@ function theme_print_sourceurl($vars) {
 function theme_print_url_list($vars) {
   global $_print_urls;
 
-  // Display the collected links at the bottom of the page. Code once taken from Kjartan Mannes' project.module
+  // Display the collected links at the bottom of the page. Code once taken from
+  // Kjartan Mannes' project.module.
   if (!empty($_print_urls)) {
     $urls = _print_friendly_urls();
-    $max = count($urls);
     $url_list = '';
     foreach ($urls as $key => $url) {
       drupal_alter('print_url_list', $url);
@@ -331,15 +352,12 @@ function theme_print_url_list($vars) {
     if (!empty($url_list)) {
       return "<p><strong>" . t('Links') . "</strong><br />$url_list</p>";
     }
-    else {
-      return '';
-    }
   }
-
+  return '';
 }
 
 /**
- * Generates a robots meta tag to tell them what they may index
+ * Generates a robots meta tag to tell them what they may index.
  *
  * @return string
  *   meta robots tag
@@ -358,7 +376,7 @@ function _print_robots_meta_generator() {
   }
 
   if (count($robots_meta) > 0) {
-    return '<meta name="robots" content=' . implode(', ', $robots_meta) . ' />';
+    return '<meta name="robots" content="' . implode(', ', $robots_meta) . '" />';
   }
   else {
     return '';
@@ -366,7 +384,7 @@ function _print_robots_meta_generator() {
 }
 
 /**
- * Generates the CSS directive to include in the printer-friendly version
+ * Generates the CSS directive to include in the printer-friendly version.
  *
  * @param bool $expand
  *   If TRUE, the provided CSS will be expanded, instead of given as a list
@@ -388,13 +406,13 @@ function _print_css_generator($expand = FALSE) {
   if (!variable_get('print_keep_theme_css', PRINT_KEEP_THEME_CSS_DEFAULT)) {
     foreach ($drupal_css as $key => $css_file) {
       if ($css_file['group'] == CSS_THEME) {
-      // Unset the theme's CSS
+        // Unset the theme's CSS.
         unset($drupal_css[$key]);
       }
     }
   }
 
-  // Expand the CSS if requested
+  // Expand the CSS if requested.
   if ($expand) {
     $style = '';
     $css_files = array_keys($drupal_css);
@@ -411,13 +429,13 @@ function _print_css_generator($expand = FALSE) {
 }
 
 /**
- * Callback function for the preg_replace_callback for URL-capable patterns
+ * Callback function for the preg_replace_callback for URL-capable patterns.
  *
  * Manipulate URLs to make them absolute in the URLs list, and add a [n]
  * footnote marker.
  *
  * @param array $matches
- *   array with the matched tag patterns, usually <a...>+text+</a>
+ *   Array with the matched tag patterns, usually <a...>+text+</a>.
  *
  * @return string
  *   tag with re-written URL and, if applicable, the [n] index to the URL list
@@ -427,7 +445,7 @@ function _print_rewrite_urls($matches) {
 
   $include_anchors = variable_get('print_urls_anchors', PRINT_URLS_ANCHORS_DEFAULT);
 
-  // first, split the html into the different tag attributes
+  // 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) {
@@ -435,34 +453,38 @@ function _print_rewrite_urls($matches) {
   }
 
   $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
+  for ($i = 1; $i < $size; $i++) {
+    // If the attribute is href or src, 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\"'");
 
       if (empty($url)) {
-        // If URL is empty, use current_url
+        // If URL is empty, use current_url.
         $path = explode('/', $_GET['q']);
         unset($path[0]);
         $path = implode('/', $path);
         if (ctype_digit($path)) {
           $path = "node/$path";
         }
-        // Printer-friendly URLs is on, so we need to make it absolute
-        $newurl = url($path, array('fragment' => drupal_substr($url, 1), 'absolute' => TRUE));
+        // Printer-friendly URLs is on, so we need to make it absolute.
+        $newurl = url($path, array(
+          'fragment' => drupal_substr($url, 1),
+          'absolute' => TRUE,
+        ));
       }
       elseif (strpos(html_entity_decode($url), '://') || preg_match('!^mailto:.*?@.*?\..*?$!iu', html_entity_decode($url))) {
-        // URL is absolute, do nothing
+        // URL is absolute, do nothing.
         $newurl = $url;
       }
       elseif (strpos(html_entity_decode($url), '//') === 0) {
-        // URL is 'almost absolute', but it does not contain protocol; replace with base_path protocol
+        // URL is 'almost absolute', but it does not contain protocol; replace
+        // with base_path protocol.
         $newurl = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . ":" . $url;
         $matches[1] = str_replace($url, $newurl, $matches[1]);
       }
       else {
         if ($url[0] == '#') {
-          // URL is an anchor tag
+          // URL is an anchor tag.
           if ($include_anchors && (!empty($_print_urls))) {
             $path = explode('/', $_GET['q']);
             unset($path[0]);
@@ -470,21 +492,24 @@ function _print_rewrite_urls($matches) {
             if (ctype_digit($path)) {
               $path = "node/$path";
             }
-            // Printer-friendly URLs is on, so we need to make it absolute
-            $newurl = url($path, array('fragment' => drupal_substr($url, 1), 'absolute' => TRUE));
+            // Printer-friendly URLs is on, so we need to make it absolute.
+            $newurl = url($path, array(
+              'fragment' => drupal_substr($url, 1),
+              'absolute' => TRUE,
+            ));
           }
           // Because base href is the original page, change the link to
-          // still be usable inside the print page
+          // still be usable inside the print page.
           $matches[1] = str_replace($url, check_plain(base_path() . $_GET['q'] . $url), $matches[1]);
         }
         else {
-          // URL is relative, convert it into absolute URL
+          // URL is relative, convert it into absolute URL.
           if ($url[0] == '/') {
-            // If it starts with '/' just append it to the server name
+            // If it starts with '/' just append it to the server name.
             $newurl = $base_root . '/' . trim($url, '/');
           }
           elseif (preg_match('!^(?:index.php)?\?q=!i', $url)) {
-            // If it starts with ?q=, just prepend with the base URL
+            // If it starts with ?q=, just prepend with the base URL.
             $newurl = $base_url . '/' . trim($url, '/');
           }
           else {
@@ -510,10 +535,10 @@ function _print_rewrite_urls($matches) {
 /**
  * Auxiliary function to store the Printer-friendly URLs list as static.
  *
- * @param string $url
- *   absolute URL to be inserted in the list
+ * @param string|int $url
+ *   Absolute URL to be inserted in the list.
  *
- * @return array
+ * @return array|int
  *   list of URLs previously stored if $url is 0, or the current count
  *   otherwise.
  */
@@ -529,18 +554,20 @@ function _print_friendly_urls($url = 0) {
       return count($urls);
     }
   }
-  $ret = $urls;
-  $urls = array();
-  return $ret;
+  else {
+    $ret = $urls;
+    $urls = array();
+    return $ret;
+  }
 }
 
 /**
- * Check URL list settings for this node
+ * Check URL list settings for this node.
  *
- * @param object $node
- *   node object
+ * @param Object $node
+ *   Node object.
  * @param string $format
- *   format of the page being generated
+ *   Format of the page being generated.
  *
  * @return bool
  *   TRUE if URL list should be displayed, FALSE otherwise
@@ -553,25 +580,25 @@ function _print_url_list_enabled($node, $format) {
     $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);
   }
 
-  // Get value of Printer-friendly URLs setting
+  // Get value of Printer-friendly URLs setting.
   return (variable_get('print_urls', PRINT_URLS_DEFAULT) && ($node_urllist));
 }
 
 /**
- * Prepare a Printer-friendly-ready node body for content nodes
+ * Prepare a Printer-friendly-ready node body for content nodes.
  *
  * @param int $nid
- *   node ID of the node to be rendered into a printer-friendly page
+ *   Node ID of the node to be rendered into a printer-friendly page.
  * @param string $format
- *   format of the page being generated
+ *   Format of the page being generated.
  * @param int $vid
- *   (optional) revision ID of the node to use
+ *   (Optional) revision ID of the node to use.
  * @param int $cid
- *   (optional) comment ID of the individual comment to be rendered
+ *   (Optional) comment ID of the individual comment to be rendered.
  * @param string $view_mode
- *   (optional) view mode to be used when rendering the content
+ *   (Optional) view mode to be used when rendering the content.
  *
- * @return object
+ * @return object|bool
  *   filled node-like object to be used in the print template
  */
 function _print_generate_node($nid, $format, $vid = NULL, $cid = NULL, $view_mode = PRINT_VIEW_MODE) {
@@ -581,26 +608,27 @@ function _print_generate_node($nid, $format, $vid = NULL, $cid = NULL, $view_mod
     $langcode = $GLOBALS['language_content']->language;
   }
 
-  // We can take a node id
+  // We can take a node id.
   $node = node_load($nid, $vid);
   if (!$node) {
-    // Node not found
+    // Node not found.
     drupal_not_found();
-    return FALSE;
+    drupal_exit();
   }
   elseif (!node_access('view', $node)) {
-    // Access is denied
+    // Access is denied.
     drupal_access_denied();
-    return FALSE;
+    drupal_exit();
   }
   drupal_set_title($node->title);
 
+  $build = array();
   if ($cid === NULL) {
     // Adapted (simplified) version of node_view
-    // Render the node content
+    // Render the node content.
     node_build_content($node, $view_mode);
 
-    // Disable the links area
+    // Disable the links area.
     unset($node->content['links']);
 
     $build = $node->content;
@@ -609,8 +637,7 @@ function _print_generate_node($nid, $format, $vid = NULL, $cid = NULL, $view_mod
 
   if (function_exists('comment_node_page_additions') &&
       (($cid != NULL) || (variable_get('print_comments', PRINT_COMMENTS_DEFAULT)))) {
-    // Print only the requested comment (or if $cid is NULL, all of them)
-
+    // Print only the requested comment (or if $cid is NULL, all of them).
     $comments = comment_node_page_additions($node);
     if (!empty($comments)) {
       unset($comments['comment_form']);
@@ -642,7 +669,7 @@ function _print_generate_node($nid, $format, $vid = NULL, $cid = NULL, $view_mod
 
   $content = render($build);
 
-  // Get rid of any links before the content
+  // Get rid of any links before the content.
   $parts = explode('<div class="content', $content, 2);
   if (count($parts) == 2) {
     $pattern = '!(.*?)<a [^>]*?>(.*?)</a>(.*?)!mis';
@@ -650,10 +677,10 @@ function _print_generate_node($nid, $format, $vid = NULL, $cid = NULL, $view_mod
     $content = implode('<div class="content', $parts);
   }
 
-  // Check URL list settings
+  // Check URL list settings.
   $_print_urls = _print_url_list_enabled($node, $format);
 
-  // Convert the a href elements
+  // Convert the a href elements.
   $pattern = '!<(a\s[^>]*?)>(.*?)(</a>)!is';
   $content = preg_replace_callback($pattern, '_print_rewrite_urls', $content);
 
@@ -663,22 +690,22 @@ function _print_generate_node($nid, $format, $vid = NULL, $cid = NULL, $view_mod
 }
 
 /**
- * Prepare a Printer-friendly-ready node body for non-content pages
+ * Prepare a Printer-friendly-ready node body for non-content pages.
  *
  * @param string $path
- *   path of the node to be rendered into a printer-friendly page
+ *   Path of the node to be rendered into a printer-friendly page.
  * @param string $format
- *   format of the page being generated
+ *   Format of the page being generated.
  *
- * @return object
+ * @return object|bool
  *   filled node-like object to be used in the print template
  */
 function _print_generate_path($path, $format) {
   global $_print_urls;
 
-  // Handle node tabs
+  // Handle node tabs, or cases where the 'node_router' option is enabled.
   $parts = explode('/', $path);
-  if (ctype_digit($parts[0]) && (count($parts) > 1)) {
+  if (ctype_digit($parts[0]) && ((count($parts) > 1) || variable_get('print_node_router', FALSE))) {
     $path = 'node/' . $path;
   }
 
@@ -696,11 +723,12 @@ function _print_generate_path($path, $format) {
     switch ($node->content) {
       case MENU_NOT_FOUND:
         drupal_not_found();
-        return FALSE;
+        drupal_exit();
         break;
+
       case MENU_ACCESS_DENIED:
         drupal_access_denied();
-        return FALSE;
+        drupal_exit();
         break;
     }
   }
@@ -708,33 +736,33 @@ function _print_generate_path($path, $format) {
   $node->title = drupal_get_title();
   $node->path = $path;
   $node->changed = REQUEST_TIME;
+  $node->type = '';
 
-  // Delete any links area
+  // Delete any links area.
   $node->content = preg_replace('!\s*<div class="links">.*?</div>!sim', '', $node->content);
 
-  // Delete the contextual links also
+  // Delete the contextual links also.
   $node->content = preg_replace('!\s*<div class="contextual-links-wrapper">.*?</div>!sim', '', $node->content);
 
-  // Check URL list settings
+  // Check URL list settings.
   $_print_urls = _print_url_list_enabled($node, $format);
 
-  // Convert the a href elements
+  // Convert the a href elements.
   $pattern = '!<(a\s[^>]*?)>(.*?)(</a>)!is';
   $node->content = preg_replace_callback($pattern, '_print_rewrite_urls', $node->content);
 
   return $node;
 }
 
-
 /**
- * Prepare a Printer-friendly-ready node body for book pages
+ * Prepare a Printer-friendly-ready node body for book pages.
  *
  * @param int $nid
- *   node ID of the node to be rendered into a printer-friendly page
+ *   Node ID of the node to be rendered into a printer-friendly page.
  * @param string $format
- *   format of the page being generated
+ *   Format of the page being generated.
  *
- * @return object
+ * @return object|bool
  *   filled node-like object to be used in the print template
  */
 function _print_generate_book($nid, $format) {
@@ -742,23 +770,23 @@ function _print_generate_book($nid, $format) {
 
   $node = node_load($nid);
   if (!$node) {
-    // Node not found
+    // Node not found.
     drupal_not_found();
-    return FALSE;
+    drupal_exit();
   }
   elseif (!node_access('view', $node) || (!user_access('access printer-friendly version'))) {
-    // Access is denied
+    // Access is denied.
     drupal_access_denied();
-    return FALSE;
+    drupal_exit();
   }
 
   $tree = book_menu_subtree_data($node->book);
   $node->content = book_export_traverse($tree, 'book_node_export');
 
-  // Check URL list settings
+  // Check URL list settings.
   $_print_urls = _print_url_list_enabled($node, $format);
 
-  // Convert the a href elements
+  // Convert the a href elements.
   $pattern = '!<(a\s[^>]*?)>(.*?)(</a>)!is';
   $node->content = preg_replace_callback($pattern, '_print_rewrite_urls', $node->content);
 

+ 3 - 7
sites/all/modules/contrib/admin/print/print.views.inc

@@ -2,12 +2,11 @@
 
 /**
  * @file
- * Printer-friendly version Views integration
+ * Printer-friendly version Views integration.
  *
  * @ingroup print
  */
 
-
 /**
  * Implements hook_views_data().
  */
@@ -26,18 +25,16 @@ function print_views_data() {
     // 'field' is the foreign key in this table.
     'left_field' => 'nid',
     'field' => 'nid',
-//    'type' => 'INNER',
   );
   $data['print_page_counter']['table']['join']['node'] = array(
     // 'left_field' is the primary key in the referenced table.
     // 'field' is the foreign key in this table.
     'left_field' => 'nid',
     'field' => 'path',
-//    'type' => 'INNER',
     'handler' => 'print_join_page_counter',
   );
 
-  // print_node_conf fields
+  // print_node_conf fields.
   $data['print_node_conf']['link'] = array(
     'title' => t('Web: Show link'),
     'help' => t('Whether to show the printer-friendly version link.'),
@@ -87,8 +84,7 @@ function print_views_data() {
     ),
   );
 
-
-  // print_page_counter fields
+  // print_page_counter fields.
   $data['print_page_counter']['totalcount'] = array(
     'title' => t('Web: Number of page accesses'),
     'help' => t('Counter of accesses to the printer-friendly version for this node.'),

+ 4 - 4
sites/all/modules/contrib/admin/print/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.drush.inc

@@ -2,15 +2,15 @@
 
 /**
  * @file
- * drush integration for print_epub_phpepub module EPUB libraries download.
+ * Provides drush integration for print_epub_phpepub module.
  */
 
 /**
- * The EPUB project download URL
+ * The EPUB project download URL.
  */
 
-// URI to the the latest PHPePub version.. Hardcoded version unfortunately
-define('PHPEPUB_DOWNLOAD_URI', 'https://github.com/Grandt/PHPePub/tarball/2.04');
+// URI to the the latest PHPePub version.
+define('PHPEPUB_DOWNLOAD_URI', 'https://api.github.com/repos/Grandt/PHPePub/releases/latest');
 
 /**
  * Implements hook_drush_command().

+ 3 - 4
sites/all/modules/contrib/admin/print/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.info

@@ -4,9 +4,8 @@ core = 7.x
 package = "Printer, email and PDF versions"
 dependencies[] = print_epub
 
-; Information added by Drupal.org packaging script on 2014-04-02
-version = "7.x-2.0"
+; Information added by Drupal.org packaging script on 2018-10-05
+version = "7.x-2.2"
 core = "7.x"
 project = "print"
-datestamp = "1396426766"
-
+datestamp = "1538760185"

+ 38 - 0
sites/all/modules/contrib/admin/print/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.install

@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * @file
+ * Install, update and uninstall functions for the print_epub_phpepub module.
+ *
+ * @ingroup print
+ */
+
+/**
+ * Implements hook_requirements().
+ */
+function print_epub_phpepub_requirements($phase) {
+  $requirements = array();
+  $t = get_t();
+  switch ($phase) {
+    // At runtime, make sure that a EPUB generation tool is selected.
+    case 'runtime':
+      $print_epub_epub_tool = variable_get('print_epub_epub_tool', PRINT_EPUB_EPUB_TOOL_DEFAULT);
+
+      if (!empty($print_epub_epub_tool)) {
+        $tool = explode('|', $print_epub_epub_tool);
+
+        if (is_file($tool[1]) && is_readable($tool[1])) {
+          if (basename($tool[1]) == 'EPub.php') {
+            $version = _print_epub_phpepub_version($tool[1]);
+
+            $requirements['print_epub_tool_version'] = array(
+              'title' => $t('Printer, email and EPUB versions - EPUB generation library'),
+              'value' => $t('PHPePub') . ' ' . $version,
+            );
+          }
+        }
+      }
+      break;
+  }
+  return $requirements;
+}

+ 23 - 33
sites/all/modules/contrib/admin/print/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.module

@@ -8,37 +8,7 @@
  */
 
 /**
- * Implements hook_requirements().
- */
-function print_epub_phpepub_requirements($phase) {
-  $requirements = array();
-  $t = get_t();
-  switch ($phase) {
-    // At runtime, make sure that a EPUB generation tool is selected
-    case 'runtime':
-      $print_epub_epub_tool = variable_get('print_epub_epub_tool', PRINT_EPUB_EPUB_TOOL_DEFAULT);
-
-      if (!empty($print_epub_epub_tool)) {
-        $tool = explode('|', $print_epub_epub_tool);
-
-        if (is_file($tool[1]) && is_readable($tool[1])) {
-          if (basename($tool[1]) == 'EPub.php') {
-            $version = _print_epub_phpepub_version($tool[1]);
-
-            $requirements['print_epub_tool_version'] = array(
-              'title' => $t('Printer, email and EPUB versions - EPUB generation library'),
-              'value' => $t('PHPePub') . ' ' . $version,
-            );
-          }
-        }
-      }
-      break;
-  }
-  return $requirements;
-}
-
-/**
- * Find out the version of the PHPePub library
+ * Find out the version of the PHPePub library.
  *
  * @param string $epub_tool
  *   Filename of the tool to be analysed.
@@ -47,9 +17,21 @@ function print_epub_phpepub_requirements($phase) {
  *   version number of the library
  */
 function _print_epub_phpepub_version($epub_tool) {
-  require_once(DRUPAL_ROOT . '/' . $epub_tool);
+  if (file_exists(DRUPAL_ROOT . '/' . $epub_tool)) {
+    include_once DRUPAL_ROOT . '/' . $epub_tool;
+
+    $phpepub_version_4_plus = strpos($epub_tool, 'autoload.php') !== FALSE;
+    if ($phpepub_version_4_plus) {
+      return \PHPePub\Core\EPub::VERSION;
+    }
+    else {
+      if (class_exists('EPub')) {
+        return EPub::VERSION;
+      }
+    }
+  }
 
-  return EPub::VERSION;
+  return 'unknown';
 }
 
 /**
@@ -62,4 +44,12 @@ function print_epub_phpepub_print_epub_available_libs_alter(&$epub_tools) {
   foreach ($tools as $tool) {
     $epub_tools['print_epub_phpepub|' . $tool] = 'PHPePub (' . dirname($tool) . ')';
   }
+
+  // PHPePub >= 4.0 uses a composer autoloader.
+  $tools = _print_scan_libs('phpepub', '!^autoload.php$!');
+  foreach ($tools as $tool) {
+    if (preg_match('!PHPePub.*?/vendor/autoload.php$!i', $tool)) {
+      $epub_tools['print_epub_phpepub|' . $tool] = 'PHPePub (' . dirname(dirname($tool)) . ')';
+    }
+  }
 }

+ 23 - 9
sites/all/modules/contrib/admin/print/print_epub/lib_handlers/print_epub_phpepub/print_epub_phpepub.pages.inc

@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Generates the EPUB version using PHPePub
+ * Generates the EPUB version using PHPePub.
  *
  * This file is included by the print_epub_phpepub module and includes the
- * functions that interface with the PHPePub library
+ * functions that interface with the PHPePub library.
  *
  * @ingroup print
  */
@@ -21,16 +21,29 @@ function print_epub_phpepub_print_epub_generate($html, $meta, $filename = NULL)
   $epub_tool = explode('|', variable_get('print_epub_epub_tool', PRINT_EPUB_EPUB_TOOL_DEFAULT));
   $images_via_file = variable_get('print_epub_images_via_file', PRINT_EPUB_IMAGES_VIA_FILE_DEFAULT);
 
-  require_once(DRUPAL_ROOT . '/' . $epub_tool[1]);
+  $tool_path = DRUPAL_ROOT . '/' . $epub_tool[1];
+  if (file_exists($tool_path)) {
+    require_once $tool_path;
+  }
+  else {
+    watchdog('print_epub', 'Configured EPUB tool does not exist at path: %path', array('%path' => $tool_path), WATCHDOG_ERROR);
+    throw new Exception("Configured EPUB tool does not exist, unable to generate EPUB.");
+  }
 
-  // Try to use local file access for image files
+  // Try to use local file access for image files.
   $html = _print_access_images_via_file($html, $images_via_file);
+  $version = _print_epub_phpepub_version($epub_tool[1]);
 
-  // set document information
-  $epub = new EPub();
+  // Set document information.
+  if (version_compare($version, '4.0.0', '>=')) {
+    $epub = new \PHPePub\Core\EPub();
+  }
+  else {
+    $epub = new EPub();
+  }
 
   $epub->setTitle(html_entity_decode($meta['title'], ENT_QUOTES, 'UTF-8'));
-  $epub->setIdentifier($meta['url'], EPub::IDENTIFIER_URI);
+  $epub->setIdentifier($meta['url'], $epub::IDENTIFIER_URI);
   $epub->setLanguage($language->language);
   if (isset($meta['name'])) {
     $epub->setAuthor(strip_tags($meta['name']), strip_tags($meta['name']));
@@ -40,9 +53,10 @@ function print_epub_phpepub_print_epub_generate($html, $meta, $filename = NULL)
 
   @$epub->addChapter("Chapter", "epub.html", $html, FALSE);
 
-  $epub->finalize(); // Finalize the book, and build the archive.
+  // Finalize the book, and build the archive.
+  $epub->finalize();
 
-  // Close and output EPUB document
+  // Close and output EPUB document.
   $epub->sendBook(empty($filename) ? 'page' : $filename);
   return TRUE;
 }

+ 2 - 7
sites/all/modules/contrib/admin/print/print_epub/print_epub.admin.inc

@@ -23,7 +23,7 @@ function print_epub_settings() {
     $link = print_epub_print_link();
 
     $current_epub_tool = variable_get('print_epub_epub_tool', PRINT_EPUB_EPUB_TOOL_DEFAULT);
-    $epub_tool_default =  array_key_exists($current_epub_tool, $epub_tools) ? $current_epub_tool : PRINT_EPUB_EPUB_TOOL_DEFAULT;
+    $epub_tool_default = array_key_exists($current_epub_tool, $epub_tools) ? $current_epub_tool : PRINT_EPUB_EPUB_TOOL_DEFAULT;
 
     $form['settings'] = array(
       '#type' => 'fieldset',
@@ -53,14 +53,9 @@ function print_epub_settings() {
     );
     if (module_exists('token')) {
       $form['settings']['print_epub_filename_patterns'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Replacement patterns'),
-        '#collapsible' => TRUE,
-        '#collapsed' => TRUE,
-      );
-      $form['settings']['print_epub_filename_patterns']['descriptions'] = array(
         '#theme' => 'token_tree',
         '#token_types' => array('node'),
+        '#dialog' => TRUE,
       );
     }
 

+ 6 - 6
sites/all/modules/contrib/admin/print/print_epub/print_epub.api.php

@@ -14,17 +14,17 @@
  * Generate a EPUB version of the provided HTML.
  *
  * @param string $html
- *   HTML content of the EPUB
+ *   HTML content of the EPUB.
  * @param array $meta
  *   Meta information to be used in the EPUB
  *   - url: original URL
  *   - name: author's name
  *   - title: Page title
- *   - node: node object
+ *   - node: node object.
  * @param string $filename
- *   (optional) Filename of the generated EPUB
+ *   (optional) Filename of the generated EPUB.
  *
- * @return
+ * @return string|null
  *   generated EPUB page, or NULL in case of error
  *
  * @see print_epub_controller_html()
@@ -80,7 +80,7 @@ function hook_print_epub_available_libs_alter(&$epub_tools) {
  * '.epub' extension, as the module will do that automatically.
  *
  * @param string $epub_filename
- *   current value of the epub_filename variable, after processing tokens and
+ *   Current value of the epub_filename variable, after processing tokens and
  *   any transliteration steps.
  * @param string $path
  *   original alias/system path of the page being converted to EPUB.
@@ -88,7 +88,7 @@ function hook_print_epub_available_libs_alter(&$epub_tools) {
  * @ingroup print_hooks
  */
 function hook_print_epub_filename_alter(&$epub_filename, &$path) {
-  $epub_filename = 'foo';
+  $epub_filename = $path . '/foo';
 }
 
 /**

+ 9 - 5
sites/all/modules/contrib/admin/print/print_epub/print_epub.drush.inc

@@ -2,7 +2,7 @@
 
 /**
  * @file
- * drush integration for print_epub module EPUB libraries download.
+ * Provides drush integration for print_epub module EPUB libraries download.
  */
 
 /**
@@ -23,21 +23,25 @@ function print_epub_drush_command() {
       'path' => dt('A path to the download folder. If omitted Drush will use the default location (@path).', array('@path' => 'sites/all/libraries')),
     ),
     'aliases' => array('epubdl'),
-    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT, // No site or config needed.
+    // No site or config needed.
+    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
   );
 
   return $items;
 }
 
 /**
- * Implements of drush_hook_COMMAND_validate().
+ * Implements drush_hook_COMMAND_validate().
  */
 function drush_print_epub_download_validate($library = NULL) {
   if (is_null($library)) {
     $epub_libs = array();
     drush_command_invoke_all_ref('drush_epub_libs_alter', $epub_libs);
 
-    drush_set_error('DRUSH_EPUBDL_MISSING_ARG', dt("Usage: drush !cmd <library>\nWhere <library> is one of the following: !libs\n\nTry 'drush !cmd --help' for more information.", array('!cmd' => 'print-epub-download', '!libs' => implode(', ', array_keys($epub_libs)))));
+    drush_set_error('DRUSH_EPUBDL_MISSING_ARG', dt("Usage: drush !cmd <library>\nWhere <library> is one of the following: !libs\n\nTry 'drush !cmd --help' for more information.", array(
+      '!cmd' => 'print-epub-download',
+      '!libs' => implode(', ', array_keys($epub_libs)),
+    )));
   }
 }
 
@@ -45,7 +49,7 @@ function drush_print_epub_download_validate($library = NULL) {
  * Download and extract EPUB archive.
  *
  * @param string $library
- *   library to download
+ *   Library to download.
  */
 function drush_print_epub_download($library) {
   $epub_libs = array();

+ 3 - 4
sites/all/modules/contrib/admin/print/print_epub/print_epub.info

@@ -5,9 +5,8 @@ package = "Printer, email and PDF versions"
 dependencies[] = print
 configure = admin/config/user-interface/print/epub
 
-; Information added by Drupal.org packaging script on 2014-04-02
-version = "7.x-2.0"
+; Information added by Drupal.org packaging script on 2018-10-05
+version = "7.x-2.2"
 core = "7.x"
 project = "print"
-datestamp = "1396426766"
-
+datestamp = "1538760185"

+ 46 - 7
sites/all/modules/contrib/admin/print/print_epub/print_epub.install

@@ -11,9 +11,7 @@
  * Implements hook_enable().
  */
 function print_epub_enable() {
-  $t = get_t();
-
-  // Module weight
+  // Module weight.
   db_update('system')
     ->fields(array(
       'weight' => 4,
@@ -49,6 +47,42 @@ function print_epub_uninstall() {
   }
 }
 
+
+/**
+ * Implements hook_requirements().
+ */
+function print_epub_requirements($phase) {
+  $requirements = array();
+  $t = get_t();
+  switch ($phase) {
+    // At runtime, make sure that a EPUB generation tool is selected.
+    case 'runtime':
+      $print_epub_epub_tool = variable_get('print_epub_epub_tool', PRINT_EPUB_EPUB_TOOL_DEFAULT);
+      if (empty($print_epub_epub_tool)) {
+        $requirements['print_epub_tool'] = array(
+          'title' => $t('Printer, email and EPUB versions - EPUB generation library'),
+          'value' => $t('No EPUB tool selected'),
+          'description' => $t('Please configure it in the !url.', array('!url' => l($t('EPUB settings page'), 'admin/config/user-interface/print/epub'))),
+          'severity' => REQUIREMENT_ERROR,
+        );
+      }
+      else {
+        $tool = explode('|', $print_epub_epub_tool);
+
+        if (!is_file($tool[1]) || !is_readable($tool[1])) {
+          $requirements['print_epub_tool'] = array(
+            'title' => $t('Printer, email and EPUB versions - EPUB generation library'),
+            'value' => $t('File not found'),
+            'description' => $t('The currently selected EPUB generation library (%file) is no longer accessible.', array('%file' => $tool[1])),
+            'severity' => REQUIREMENT_ERROR,
+          );
+        }
+      }
+      break;
+  }
+  return $requirements;
+}
+
 /**
  * Implements hook_schema().
  */
@@ -122,7 +156,7 @@ function print_epub_schema() {
 }
 
 /**
- * Remove hardcoded numeric deltas from all blocks
+ * Remove hardcoded numeric deltas from all blocks.
  */
 function print_epub_update_7000(&$sandbox) {
   $renamed_deltas = array(
@@ -139,7 +173,7 @@ function print_epub_update_7000(&$sandbox) {
 }
 
 /**
- * Enable block and help area links
+ * Enable block and help area links.
  */
 function print_epub_update_7202(&$sandbox) {
   $link_pos = variable_get('print_epub_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
@@ -149,11 +183,16 @@ function print_epub_update_7202(&$sandbox) {
 }
 
 /**
- * Increase size of the path field in the print_epub_page_counter table
+ * Increase size of the path field in the print_epub_page_counter table.
  */
 function print_epub_update_7203(&$sandbox) {
   db_drop_primary_key('print_epub_page_counter');
   db_change_field('print_epub_page_counter', 'path', 'path',
-    array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Page path'),
+    array(
+      'type' => 'varchar',
+      'length' => 255,
+      'not null' => TRUE,
+      'description' => 'Page path',
+    ),
     array('primary key' => array('path')));
 }

+ 16 - 46
sites/all/modules/contrib/admin/print/print_epub/print_epub.module

@@ -103,11 +103,12 @@ function print_epub_block_info() {
  * Implements hook_block_view().
  */
 function print_epub_block_view($delta = 0) {
+  $block = array();
   switch ($delta) {
     case 'print_epub-top':
       $block['subject'] = t('Most EPUBd');
       $result = db_query_range("SELECT path FROM {print_epub_page_counter} LEFT JOIN {node} n ON path = CONCAT('node/', n.nid) WHERE status <> 0 OR status IS NULL ORDER BY totalcount DESC", 0, 3)
-                  ->fetchAll();
+        ->fetchAll();
       if (count($result)) {
         $items = array();
         foreach ($result as $obj) {
@@ -120,41 +121,6 @@ function print_epub_block_view($delta = 0) {
   return $block;
 }
 
-/**
- * Implements hook_requirements().
- */
-function print_epub_requirements($phase) {
-  $requirements = array();
-  $t = get_t();
-  switch ($phase) {
-    // At runtime, make sure that a EPUB generation tool is selected
-    case 'runtime':
-      $print_epub_epub_tool = variable_get('print_epub_epub_tool', PRINT_EPUB_EPUB_TOOL_DEFAULT);
-      if (empty($print_epub_epub_tool)) {
-        $requirements['print_epub_tool'] = array(
-          'title' => $t('Printer, email and EPUB versions - EPUB generation library'),
-          'value' => $t('No EPUB tool selected'),
-          'description' => $t('Please configure it in the !url.', array('!url' => l($t('EPUB settings page'), 'admin/config/user-interface/print/epub'))),
-          'severity' => REQUIREMENT_ERROR,
-        );
-      }
-      else {
-        $tool = explode('|', $print_epub_epub_tool);
-
-        if (!is_file($tool[1]) || !is_readable($tool[1])) {
-          $requirements['print_epub_tool'] = array(
-            'title' => $t('Printer, email and EPUB versions - EPUB generation library'),
-            'value' => $t('File not found'),
-            'description' => $t('The currently selected EPUB generation library (%file) is no longer accessible.', array('%file' => $tool[1])),
-            'severity' => REQUIREMENT_ERROR,
-          );
-        }
-      }
-      break;
-  }
-  return $requirements;
-}
-
 /**
  * Implements hook_node_delete().
  */
@@ -165,7 +131,7 @@ function print_epub_node_delete($node) {
 }
 
 /**
- * Auxiliary function to display a formatted EPUB version link
+ * Auxiliary function to display a formatted EPUB version link.
  *
  * Function made available so that developers may call this function from
  * their defined pages/blocks.
@@ -176,7 +142,7 @@ function print_epub_node_delete($node) {
  *   node object, to be used in checking node access. If the path argument is
  *   not provided, the path used will be node/nid.
  * @param string $location
- *   where in the page where the link is being inserted ('link', 'corner',
+ *   Where in the page where the link is being inserted ('link', 'corner',
  *   'block', 'help').
  *
  * @return bool
@@ -186,7 +152,11 @@ function print_epub_node_delete($node) {
  */
 function print_epub_insert_link($path = NULL, $node = NULL, $location = '') {
   if (function_exists('print_ui_insert_link')) {
-    return print_ui_insert_link(print_epub_print_link(), array('path' => $path, 'node' => $node, 'location' => $location));
+    return print_ui_insert_link(print_epub_print_link(), array(
+      'path' => $path,
+      'node' => $node,
+      'location' => $location,
+    ));
   }
   else {
     return FALSE;
@@ -194,11 +164,11 @@ function print_epub_insert_link($path = NULL, $node = NULL, $location = '') {
 }
 
 /**
- * Check if the link to the EPUB version is allowed depending on the settings
+ * Check if the link to the EPUB version is allowed depending on the settings.
  *
  * @param array $args
- *   array containing the possible parameters:
- *    view_mode, node, type, path
+ *   Array containing the possible parameters:
+ *    view_mode, node, type, path.
  *
  * @return bool
  *   FALSE if not allowed, TRUE otherwise
@@ -213,17 +183,17 @@ function print_epub_link_allowed($args) {
  * Generate a EPUB version of the provided HTML.
  *
  * @param string $html
- *   HTML content of the EPUB
+ *   HTML content of the EPUB.
  * @param array $meta
  *   Meta information to be used in the EPUB
  *   - url: original URL
  *   - name: author's name
  *   - title: Page title
- *   - node: node object
+ *   - node: node object.
  * @param string $filename
- *   (optional) Filename of the generated EPUB
+ *   (optional) Filename of the generated EPUB.
  *
- * @return
+ * @return string|null
  *   generated EPUB page, or NULL in case of error
  *
  * @see print_epub_controller()

+ 32 - 23
sites/all/modules/contrib/admin/print/print_epub/print_epub.pages.inc

@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Generates the EPUB versions of the pages
+ * Generates the EPUB versions of the pages.
  *
  * This file is included by the print_epub module and includes the
  * functions that interface with the EPUB generation packages.
@@ -13,32 +13,34 @@
 module_load_include('inc', 'print', 'print.pages');
 
 /**
- * Generate a EPUB version of the printer-friendly page
+ * Generate a EPUB version of the printer-friendly page.
  *
  * @see print_controller()
  * @see _print_epub_domepub()
  * @see _print_epub_tcepub()
  */
 function print_epub_controller() {
-  // Disable caching for generated EPUBs, as Drupal doesn't ouput the proper headers from the cache
+  // Disable caching for generated EPUBs, as Drupal doesn't ouput the proper
+  // headers from the cache.
   $GLOBALS['conf']['cache'] = FALSE;
 
   $args = func_get_args();
   $path = filter_xss(implode('/', $args));
-  $cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
+  $cid = isset($_GET['comment']) ? (int) $_GET['comment'] : NULL;
 
-  // Handle the query
+  // Handle the query.
   $query = $_GET;
   unset($query['q']);
 
+  $node = NULL;
   if (!empty($path)) {
     if ($alias = drupal_lookup_path('source', $path)) {
-      // Alias
+      // Alias.
       $path_arr = explode('/', $alias);
       $node = node_load($path_arr[1]);
     }
     elseif (ctype_digit($args[0])) {
-      // normal nid
+      // Normal nid.
       $node = node_load($args[0]);
     }
 
@@ -49,7 +51,7 @@ function print_epub_controller() {
     else {
       $epub_filename = token_replace($epub_filename, array('site'), array('clear' => TRUE));
       if (empty($epub_filename)) {
-        // If empty, use a fallback solution
+        // If empty, use a fallback solution.
         $epub_filename = str_replace('/', '_', $path);
       }
     }
@@ -72,10 +74,10 @@ function print_epub_controller() {
 
   $nodepath = (isset($node->nid)) ? 'node/' . $node->nid : drupal_get_normal_path($path);
   db_merge('print_epub_page_counter')
-    ->key(array('path' => $nodepath))
+    ->key(array('path' => substr($nodepath, 0, 255)))
     ->fields(array(
-        'totalcount' => 1,
-        'timestamp' => REQUEST_TIME,
+      'totalcount' => 1,
+      'timestamp' => REQUEST_TIME,
     ))
     ->expression('totalcount', 'totalcount + 1')
     ->execute();
@@ -87,36 +89,43 @@ function print_epub_controller() {
  * Gennerate a EPUB for a given Drupal path.
  *
  * @param string $path
- *   path of the page to convert to EPUB
+ *   path of the page to convert to EPUB.
  * @param array $query
- *   (optional) array of key/value pairs as used in the url() function for the
- *   query
+ *   (Optional) array of key/value pairs as used in the url() function for the
+ *   query.
  * @param int $cid
- *   (optional) comment ID of the comment to render.
+ *   (Optional) comment ID of the comment to render.
  * @param string $epub_filename
- *   (optional) filename of the generated EPUB
+ *   (Optional) filename of the generated EPUB.
  * @param string $view_mode
- *   (optional) view mode to be used when rendering the content
+ *   (Optional) view mode to be used when rendering the content.
  *
- * @return
+ * @return string|null
  *   generated EPUB page, or NULL in case of error
  *
  * @see print_epub_controller()
  */
 function print_epub_generate_path($path, $query = NULL, $cid = NULL, $epub_filename = NULL, $view_mode = PRINT_VIEW_MODE) {
-  global $base_url;
-
   $link = print_epub_print_link();
   $node = print_controller($path, $link['format'], $cid, $view_mode);
   if ($node) {
-    $html = theme('print', array('node' => $node, 'query' => $query, 'expand_css' => TRUE, 'format' => $link['format']));
+    $html = theme('print', array(
+      'node' => $node,
+      'query' => $query,
+      'expand_css' => TRUE,
+      'format' => $link['format'],
+    ));
 
     $meta = array(
       'node' => $node,
       'url' => url(drupal_get_path_alias(empty($node->nid) ? $node->path : "node/$node->nid"), array('absolute' => TRUE)),
     );
-    if (isset($node->name)) $meta['name'] = $node->name;
-    if (isset($node->title)) $meta['title'] = $node->title;
+    if (isset($node->name)) {
+      $meta['name'] = $node->name;
+    }
+    if (isset($node->title)) {
+      $meta['title'] = $node->title;
+    }
 
     return print_epub_generate_html($html, $meta, $epub_filename);
   }

+ 3 - 6
sites/all/modules/contrib/admin/print/print_epub/print_epub.views.inc

@@ -2,7 +2,7 @@
 
 /**
  * @file
- * EPUB Version Views integration
+ * EPUB Version Views integration.
  *
  * @ingroup print
  */
@@ -25,18 +25,16 @@ function print_epub_views_data() {
     // 'field' is the foreign key in this table.
     'left_field' => 'nid',
     'field' => 'nid',
-//    'type' => 'INNER',
   );
   $data['print_epub_page_counter']['table']['join']['node'] = array(
     // 'left_field' is the primary key in the referenced table.
     // 'field' is the foreign key in this table.
     'left_field' => 'nid',
     'field' => 'path',
-//    'type' => 'INNER',
     'handler' => 'print_join_page_counter',
   );
 
-  // print_epub_node_conf fields
+  // print_epub_node_conf fields.
   $data['print_epub_node_conf']['link'] = array(
     'title' => t('EPUB: Show link'),
     'help' => t('Whether to show the EPUB version link.'),
@@ -86,8 +84,7 @@ function print_epub_views_data() {
     ),
   );
 
-
-  // print_epub_page_counter fields
+  // print_epub_page_counter fields.
   $data['print_epub_page_counter']['totalcount'] = array(
     'title' => t('EPUB: Number of page accesses'),
     'help' => t('Counter of accesses to the EPUB version for this node.'),

+ 17 - 6
sites/all/modules/contrib/admin/print/print_join_page_counter.inc

@@ -2,24 +2,35 @@
 
 /**
  * @file
- * Custom Views integration join for the page counters
+ * Custom Views integration join for the page counters.
  *
  * @ingroup print
  */
 
+/**
+ * Class print_join_page_counter.
+ */
 class print_join_page_counter extends views_join {
-  // PHP 4 doesn't call constructors of the base class automatically from a
-  // constructor of a derived class. It is your responsibility to propagate
-  // the call to constructors upstream where appropriate.
-  function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') {
+
+  /**
+   * @inheritdoc
+   */
+  public function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') {
+    // PHP 4 doesn't call constructors of the base class automatically from a
+    // constructor of a derived class. It is your responsibility to propagate
+    // the call to constructors upstream where appropriate.
     parent::construct($table, $left_table, $left_field, $field, $extra, $type);
   }
 
-  function build_join($select_query, $table, $view_query) {
+  /**
+   * @inheritdoc
+   */
+  public function build_join($select_query, $table, $view_query) {
     if ($this->left_table) {
       $this->left_field = "CONCAT('node/', $this->left_table.$this->left_field)";
       $this->left_table = NULL;
     }
     parent::build_join($select_query, $table, $view_query);
   }
+
 }

+ 5 - 3
sites/all/modules/contrib/admin/print/print_mail/print_mail.admin.inc

@@ -10,8 +10,8 @@
  * @ingroup print
  */
 
-// Include MIME library
-@include_once('Mail/mime.php');
+// Include MIME library, if available.
+@include_once 'Mail/mime.php';
 
 /**
  * Form constructor for the send by email module settings form.
@@ -30,7 +30,9 @@ function print_mail_settings() {
     '#type' => 'select',
     '#title' => t('Hourly threshold'),
     '#default_value' => variable_get('print_mail_hourly_threshold', PRINT_MAIL_HOURLY_THRESHOLD),
-    '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)),
+    '#options' => drupal_map_assoc(
+      array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)
+    ),
     '#description' => t('The maximum number of emails a user can send per hour.'),
   );
 

+ 107 - 50
sites/all/modules/contrib/admin/print/print_mail/print_mail.inc

@@ -10,8 +10,8 @@
  * @ingroup print
  */
 
-// Include MIME library
-@include_once('Mail/mime.php');
+// Include MIME library, if available.
+@include_once 'Mail/mime.php';
 
 /**
  * Form constructor for the send by email form.
@@ -19,12 +19,12 @@
  * @ingroup forms
  */
 function print_mail_form($form, &$form_state) {
-  // Remove the printmail/ prefix
+  // Remove the printmail/ prefix.
   $path_arr = explode('/', $_GET['q']);
   unset($path_arr[0]);
   $path = filter_xss(implode('/', $path_arr));
   if (empty($path)) {
-    // If no path was provided, let's try to generate a page for the referer
+    // If no path was provided, let's try to generate a page for the referer.
     global $base_url;
     $link = print_mail_print_link();
 
@@ -37,11 +37,11 @@ function print_mail_form($form, &$form_state) {
   }
   elseif (ctype_digit($path_arr[1])) {
     if (drupal_lookup_path('source', $path)) {
-      // This is a numeric alias
+      // This is a numeric alias.
       $path = drupal_get_normal_path($path);
     }
     else {
-      // normal nid
+      // Normal nid.
       $path = 'node/' . $path;
     }
   }
@@ -49,7 +49,7 @@ function print_mail_form($form, &$form_state) {
     $path = drupal_get_normal_path($path);
   }
 
-  // Handle the query
+  // Handle the query.
   $query = $_GET;
   unset($query['q']);
 
@@ -59,6 +59,20 @@ function print_mail_form($form, &$form_state) {
 /**
  * Build email form for the page provided in the path argument.
  *
+ * @param array $form
+ *   Form.
+ * @param array $form_state
+ *   Form state.
+ * @param string $path
+ *   Path.
+ * @param array $query
+ *   Query.
+ * @param Object $user
+ *   Current user.
+ *
+ * @return array
+ *   Modified form.
+ *
  * @ingroup forms
  */
 function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $user = NULL) {
@@ -81,16 +95,16 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
   $print_mail_user_recipients_default = variable_get('print_mail_user_recipients', PRINT_MAIL_USER_RECIPIENTS_DEFAULT);
   $form = array();
 
-  $cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
+  $cid = isset($_GET['comment']) ? (int) $_GET['comment'] : NULL;
   $title = _print_get_title($path);
 
+  $options = array();
   if ($print_mail_user_recipients_default) {
-    $options = array();
     if (module_exists('realname')) {
-      $sql = "SELECT u.mail, r.realname AS name from {users} u LEFT JOIN {realname} r ON u.uid = r.uid WHERE u.uid <> :uid ORDER BY name ASC";
+      $sql = "SELECT u.mail, r.realname AS name from {users} u LEFT JOIN {realname} r ON u.uid = r.uid WHERE u.uid <> :uid AND status = 1 ORDER BY name ASC";
     }
     else {
-      $sql = "SELECT mail, name from {users} WHERE uid <> :uid ORDER BY name ASC";
+      $sql = "SELECT mail, name from {users} WHERE uid <> :uid AND status = 1 ORDER BY name ASC";
     }
     $recipients = db_query($sql, array(':uid' => drupal_anonymous_user()->uid));
     foreach ($recipients as $recipient) {
@@ -101,10 +115,10 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
   if (count($form_state['input']) == 0) {
     $nodepath = drupal_get_normal_path($path);
     db_merge('print_mail_page_counter')
-      ->key(array('path' => $nodepath))
+      ->key(array('path' => substr($nodepath, 0, 255)))
       ->fields(array(
-          'totalcount' => 1,
-          'timestamp' => REQUEST_TIME,
+        'totalcount' => 1,
+        'timestamp' => REQUEST_TIME,
       ))
       ->expression('totalcount', 'totalcount + 1')
       ->execute();
@@ -112,7 +126,7 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
 
   $form['path'] = array('#type' => 'value', '#value' => $path);
   $form['query'] = array('#type' => 'value', '#value' => $query);
-  $form['cid'] =  array('#type' => 'value', '#value' => $cid);
+  $form['cid'] = array('#type' => 'value', '#value' => $cid);
   $form['title'] = array('#type' => 'value', '#value' => $title);
 
   $form['fld_from_addr'] = array(
@@ -153,7 +167,7 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
     '#required' => TRUE,
   );
   if (!empty($title)) {
-    // To prevent useless translation strings, try to translate only non-node titles
+    // To prevent useless translation strings, translate only non-node titles.
     if (drupal_substr($path, 0, 5) != 'node/') {
       $title = t($title);
     }
@@ -182,12 +196,16 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
     $form['chk_teaser'] = array('#type' => 'value', '#value' => $print_mail_teaser_default);
   }
 
-  $form['btn_submit'] = array(
+  $form['actions'] = array(
+    '#type' => 'actions',
+  );
+
+  $form['actions']['submit'] = array(
     '#name' => 'submit',
     '#type' => 'submit',
     '#value' => t('Send email'),
   );
-  $form['btn_cancel'] = array(
+  $form['actions']['cancel'] = array(
     '#name' => 'cancel',
     '#type' => 'submit',
     '#value' => t('Cancel'),
@@ -204,8 +222,12 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
     $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, '!title' => $title));
-  $form['txt_message']['#default_value'] = t('');
+  $form['fld_subject']['#default_value'] = t('!user has sent you a message from !site', array(
+    '!user' => $user_name,
+    '!site' => $site_name,
+    '!title' => $title,
+  ));
+  $form['txt_message']['#default_value'] = '';
 
   return $form;
 }
@@ -216,8 +238,11 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
  * Adds a class to the form labels. This class is used to place the label on
  * the left of the input fields.
  *
- * @param array $form
- *   Form array
+ * @param array $variables
+ *   Theme variables including the form.
+ *
+ * @return string
+ *   Send by-email form HTML.
  *
  * @see print_mail_form()
  * @ingroup forms
@@ -250,8 +275,11 @@ function theme_print_mail_form($variables) {
  *
  * Allows themes and modules to override the default sendlink plain text format.
  *
- * @param $params
- *   $params as passed to print_mail_mail().
+ * @param array $params
+ *   Value of $params as passed to print_mail_mail().
+ *
+ * @return string
+ *   Plain text containing the message and a simple link to the content.
  *
  * @ingroup themeable
  * @ingroup print_themeable
@@ -265,8 +293,11 @@ function theme_print_mail_sendlink_plain($params) {
  *
  * Allows themes and modules to override the default sendlink HTML format.
  *
- * @param $params
- *   $params as passed to print_mail_mail().
+ * @param array $params
+ *   Value of $params as passed to print_mail_mail().
+ *
+ * @return string
+ *   HTML text containing the message and a simple link to the content.
  *
  * @ingroup themeable
  * @ingroup print_themeable
@@ -303,9 +334,9 @@ function print_mail_form_validate($form, &$form_state) {
   }
 
   if (!empty($form_state['values']['txt_to']['addrs'])) {
-    // All new-lines are replaced by commas
+    // All new-lines are replaced by commas.
     $to_addrs = preg_replace('![\r|\n|,]+!', ',', trim($form_state['values']['txt_to']['addrs']));
-    // Create an array from the string
+    // Create an array from the string.
     $to_array = array_merge($to_array, explode(',', $to_addrs));
   }
 
@@ -313,16 +344,16 @@ function print_mail_form_validate($form, &$form_state) {
     form_set_error('txt_to', t('You must specify at least one email address or user as a recipient.'));
   }
 
-  // Verify each element of the array
+  // Verify each element of the array.
   foreach ($to_array as $key => $address) {
     $address = trim($address);
     if (preg_match('/(.*?) <(.*)>/s', $address, $matches)) {
-      // Address is of the type User Name <user@domain.tld>
+      // Address is of the type User Name <user@domain.tld>.
       $test = user_validate_mail($matches[2]);
       $to_array[$key] = trim($matches[1]) . ' <' . $matches[2] . '>';
     }
     else {
-      // Address must be user@domain.tld
+      // Address must be user@domain.tld.
       $test = user_validate_mail($address);
     }
     if ($test) {
@@ -333,19 +364,19 @@ function print_mail_form_validate($form, &$form_state) {
   $print_mail_hourly_threshold = variable_get('print_mail_hourly_threshold', PRINT_MAIL_HOURLY_THRESHOLD);
 
   if ((!user_access('send unlimited emails')) && (!flood_is_allowed('print_mail', $print_mail_hourly_threshold - count($to_array) + 1))) {
-    form_set_error('txt_to',  t('You cannot send more than %number messages per hour. Please reduce the number of recipients.', array('%number' => $print_mail_hourly_threshold)));
+    form_set_error('txt_to', t('You cannot send more than %number messages per hour. Please reduce the number of recipients.', array('%number' => $print_mail_hourly_threshold)));
   }
 
-  // In all fields, prevent insertion of custom headers
+  // In all fields, prevent insertion of custom headers.
   foreach ($form_state['values'] as $key => $string) {
-    if ( (drupal_substr($key, 0, 4) == 'fld_') && ((strpos($string, "\n") !== FALSE) || (strpos($string, "\r") !== FALSE)) ) {
+    if ((drupal_substr($key, 0, 4) == 'fld_') && ((strpos($string, "\n") !== FALSE) || (strpos($string, "\r") !== FALSE))) {
       form_set_error($key, 'Found invalid character');
     }
   }
 
   $form_state['values']['fld_from_addr'] = $from_addr;
   $form_state['values']['fld_from_name'] = trim($form_state['values']['fld_from_name']);
-  // Re-create the string from the re-organized array
+  // Re-create the string from the re-organized array.
   $form_state['values']['txt_to']['addrs'] = implode(', ', $to_array);
 }
 
@@ -357,7 +388,7 @@ function print_mail_form_validate($form, &$form_state) {
  * @ingroup forms
  */
 function print_mail_form_submit($form, &$form_state) {
-  if (!array_key_exists('cancel', $form_state['values'])) {
+  if (!array_key_exists('cancel', $form_state['input'])) {
     module_load_include('inc', 'print', 'print.pages');
     module_load_include('inc', 'print', 'includes/print');
 
@@ -375,7 +406,7 @@ function print_mail_form_submit($form, &$form_state) {
       $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 <address>
+      // If a name is provided, make From: in the format Common Name <address>.
       if (!empty($form_state['values']['fld_from_name'])) {
         $from = '"' . mime_header_encode($form_state['values']['fld_from_name']) . '" <' . $form_state['values']['fld_from_addr'] . '>';
       }
@@ -383,43 +414,60 @@ function print_mail_form_submit($form, &$form_state) {
         $from = $form_state['values']['fld_from_addr'];
       }
 
-      // If using reply-to, move the From: info to the params array, so that it is passed to hook_mail later
+      // If using reply-to, move the From: info to the params array, so that it
+      // is passed to hook_mail later.
       if (variable_get('print_mail_use_reply_to', PRINT_MAIL_USE_REPLY_TO)) {
         $params['from'] = $from;
         $from = NULL;
       }
 
-      // Spaces in img URLs must be replaced with %20
+      // Spaces in img URLs must be replaced with %20.
       $pattern = '!<(img\s[^>]*?)>!is';
       $node->content = preg_replace_callback($pattern, '_print_replace_spaces', $node->content);
 
-      $params['body'] = theme('print', array('node' => $node, 'query' => $form_state['values']['query'], 'format' => $link['format'], 'expand_css' => TRUE, 'message' => $params['message']));
+      $params['body'] = theme('print', array(
+        'node' => $node,
+        'query' => $form_state['values']['query'],
+        'format' => $link['format'],
+        'expand_css' => TRUE,
+        'message' => $params['message'],
+      ));
 
-      // Img elements must be set to absolute
+      // Img elements must be set to absolute.
       $pattern = '!<(img\s[^>]*?)>!is';
       $params['body'] = preg_replace_callback($pattern, '_print_rewrite_urls', $params['body']);
 
-      // Convert the a href elements, to make sure no relative links remain
+      // Convert the a href elements, to make sure no relative links remain.
       $pattern = '!<(a\s[^>]*?)>!is';
       $params['body'] = preg_replace_callback($pattern, '_print_rewrite_urls', $params['body']);
 
-      // Enable support for third-party modules to alter the e-mail before it's sent
+      // Enable support for third-party modules to alter the e-mail before
+      // being sent.
       drupal_alter('print_mail', $params, $to);
 
       $ok = FALSE;
       $use_job_queue = variable_get('print_mail_job_queue', PRINT_MAIL_JOB_QUEUE_DEFAULT);
+      $queue = NULL;
       if ($use_job_queue) {
         $queue = DrupalQueue::get('print_mail_send');
       }
 
       $addresses = explode(', ', $form_state['values']['txt_to']['addrs']);
       foreach ($addresses as $to) {
+        $ret = array();
         if ($use_job_queue) {
-          // Use job queue to send mails during cron runs
-          $queue->createItem(array('module' => 'print_mail', 'key' => $print_mail_send_option_default, 'to' => $to, 'language' => language_default(), 'params' => $params, 'from' => $from));
+          // Use job queue to send mails during cron runs.
+          $queue->createItem(array(
+            'module' => 'print_mail',
+            'key' => $print_mail_send_option_default,
+            'to' => $to,
+            'language' => language_default(),
+            'params' => $params,
+            'from' => $from,
+          ));
         }
         else {
-          // Send mail immediately using Drupal's mail handler
+          // Send mail immediately using Drupal's mail handler.
           $ret = drupal_mail('print_mail', $print_mail_send_option_default, $to, language_default(), $params, $from);
         }
         if ($use_job_queue || $ret['result']) {
@@ -429,15 +477,20 @@ function print_mail_form_submit($form, &$form_state) {
       }
       if ($ok) {
         $query = empty($form_state['values']['query']) ? '' : '?' . rawurldecode(drupal_http_build_query($form_state['values']['query']));
-        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'] . $query, '%to' => $form_state['values']['txt_to']['addrs']));
+        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'] . $query,
+          '%to' => $form_state['values']['txt_to']['addrs'],
+        ));
         $site_name = variable_get('site_name', t('us'));
         drupal_set_message(check_plain(t('Thank you for spreading the word about !site.', array('!site' => $site_name))));
 
         $nodepath = drupal_get_normal_path($form_state['values']['path']);
         db_update('print_mail_page_counter')
           ->fields(array(
-              'sentcount' => 1,
-              'sent_timestamp' => REQUEST_TIME,
+            'sentcount' => 1,
+            'sent_timestamp' => REQUEST_TIME,
           ))
           ->condition('path', $nodepath, '=')
           ->expression('sentcount', 'sentcount + :inc', array(':inc' => count($addresses)))
@@ -446,5 +499,9 @@ function print_mail_form_submit($form, &$form_state) {
     }
   }
 
-  $form_state['redirect'] = array(preg_replace('!^book/export/html/!', 'node/', $form_state['values']['path']), array('query' => $form_state['values']['query']));
+  $form_state['redirect'] = array(
+    preg_replace('!^book/export/html/!', 'node/', $form_state['values']['path']), array(
+      'query' => $form_state['values']['query'],
+    ),
+  );
 }

+ 3 - 4
sites/all/modules/contrib/admin/print/print_mail/print_mail.info

@@ -5,9 +5,8 @@ package = "Printer, email and PDF versions"
 dependencies[] = print
 configure = admin/config/user-interface/print/email
 
-; Information added by Drupal.org packaging script on 2014-04-02
-version = "7.x-2.0"
+; Information added by Drupal.org packaging script on 2018-10-05
+version = "7.x-2.2"
 core = "7.x"
 project = "print"
-datestamp = "1396426766"
-
+datestamp = "1538760185"

+ 38 - 10
sites/all/modules/contrib/admin/print/print_mail/print_mail.install

@@ -11,9 +11,7 @@
  * Implements hook_enable().
  */
 function print_mail_enable() {
-  $t = get_t();
-
-  // Module weight
+  // Module weight.
   db_update('system')
     ->fields(array(
       'weight' => 1,
@@ -27,6 +25,31 @@ function print_mail_enable() {
   }
 }
 
+/**
+ * Implements hook_requirements().
+ */
+function print_mail_requirements($phase) {
+  $requirements = array();
+  $t = get_t();
+  switch ($phase) {
+    // At runtime, make sure that a PDF generation tool is selected.
+    case 'runtime':
+      if (module_exists('mailsystem')) {
+        $mail_system = mailsystem_get();
+        if (($mail_system['default-system'] != 'DefaultMailSystem') && (!isset($mail_system['print_mail']) || ($mail_system['print_mail'] != 'DefaultMailSystem'))) {
+          $requirements['print_mail_mailsystem'] = array(
+            'title' => $t('Printer, email and PDF versions - Send by email'),
+            'value' => $t('Incompatible Mail System setting detected'),
+            'description' => $t('The send by email module requires the use of the DefaultMailSystem, please configure it in the !url.', array('!url' => l($t('Mail System Settings page'), 'admin/config/system/mailsystem'))),
+            'severity' => REQUIREMENT_WARNING,
+          );
+        }
+      }
+  }
+
+  return $requirements;
+}
+
 /**
  * Implements hook_disable().
  */
@@ -154,7 +177,7 @@ function print_mail_schema() {
 }
 
 /**
- * Remove hardcoded numeric deltas from all blocks
+ * Remove hardcoded numeric deltas from all blocks.
  */
 function print_mail_update_7000(&$sandbox) {
   $renamed_deltas = array(
@@ -167,7 +190,7 @@ function print_mail_update_7000(&$sandbox) {
 }
 
 /**
- * Disable MimeMailSystem for now
+ * Disable MimeMailSystem for now.
  */
 function print_mail_update_7100(&$sandbox) {
   if (module_exists('mailsystem')) {
@@ -176,7 +199,7 @@ function print_mail_update_7100(&$sandbox) {
 }
 
 /**
- * Update permissions to new spellings
+ * Update permissions to new spellings.
  */
 function print_mail_update_7101(&$sandbox) {
   db_update('role_permission')
@@ -190,7 +213,7 @@ function print_mail_update_7101(&$sandbox) {
 }
 
 /**
- * Delete old variables
+ * Delete old variables.
  */
 function print_mail_update_7200(&$sandbox) {
   variable_del('print_mail_settings');
@@ -206,7 +229,7 @@ function print_mail_update_7200(&$sandbox) {
 }
 
 /**
- * Enable block and help area links
+ * Enable block and help area links.
  */
 function print_mail_update_7202(&$sandbox) {
   $link_pos = variable_get('print_mail_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
@@ -216,11 +239,16 @@ function print_mail_update_7202(&$sandbox) {
 }
 
 /**
- * Increase size of the path field in the print_mail_page_counter table
+ * Increase size of the path field in the print_mail_page_counter table.
  */
 function print_mail_update_7203(&$sandbox) {
   db_drop_primary_key('print_mail_page_counter');
   db_change_field('print_mail_page_counter', 'path', 'path',
-    array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Page path'),
+    array(
+      'type' => 'varchar',
+      'length' => 255,
+      'not null' => TRUE,
+      'description' => 'Page path',
+    ),
     array('primary key' => array('path')));
 }

+ 30 - 48
sites/all/modules/contrib/admin/print/print_mail/print_mail.module

@@ -115,31 +115,6 @@ function print_mail_variable_info($options) {
   return $variable;
 }
 
-/**
- * Implements hook_requirements().
- */
-function print_mail_requirements($phase) {
-  $requirements = array();
-  $t = get_t();
-  switch ($phase) {
-    // At runtime, make sure that a PDF generation tool is selected
-    case 'runtime':
-      if (module_exists('mailsystem')) {
-        $mail_system = mailsystem_get();
-        if (($mail_system['default-system'] != 'DefaultMailSystem') && (!isset($mail_system['print_mail']) || ($mail_system['print_mail'] != 'DefaultMailSystem'))) {
-          $requirements['print_mail_mailsystem'] = array(
-            'title' => $t('Printer, email and PDF versions - Send by email'),
-            'value' => $t('Incompatible Mail System setting detected'),
-            'description' => $t('The send by email module requires the use of the DefaultMailSystem, please configure it in the !url.', array('!url' => l($t('Mail System Settings page'), 'admin/config/system/mailsystem'))),
-            'severity' => REQUIREMENT_WARNING,
-          );
-        }
-      }
-  }
-
-  return $requirements;
-}
-
 /**
  * Implements hook_block_info().
  */
@@ -153,11 +128,12 @@ function print_mail_block_info() {
  * Implements hook_block_view().
  */
 function print_mail_block_view($delta = 0) {
+  $block = array();
   switch ($delta) {
     case 'print_mail-top':
       $block['subject'] = t('Most emailed');
       $result = db_query_range("SELECT path FROM {print_mail_page_counter} LEFT JOIN {node} n ON path = CONCAT('node/', n.nid) WHERE status <> 0 OR status IS NULL ORDER BY sentcount DESC", 0, 3)
-                  ->fetchAll();
+        ->fetchAll();
       if (count($result)) {
         $items = array();
         foreach ($result as $obj) {
@@ -217,62 +193,66 @@ function print_mail_mail($key, &$message, $params) {
     $message['headers']['Reply-To'] = $params['from'];
   }
 
+  $sendlink_plain = '';
+  $sendlink_html = '';
   switch ($key) {
     case 'sendpage':
       $message['body'][] = check_plain($params['body']);
       $message['headers']['Content-Type'] = 'text/html; charset=utf-8';
       break;
+
     case 'sendlink':
-      // Generate plain-text and html versions of message with link
+      // Generate plain-text and html versions of message with link.
       $sendlink_plain = theme('print_mail_sendlink_plain', $params);
       $sendlink_html = theme('print_mail_sendlink_html', $params);
 
-      // Send HTML-only version if MIME library not present
+      // Send HTML-only version if MIME library not present.
       if (!class_exists('Mail_mime')) {
         $message['body'][] = check_plain($sendlink_html);
         $message['headers']['Content-Type'] = 'text/html; charset=utf-8';
         break;
       }
-      // no break on purpose
+      // No break on purpose.
     case 'plain-attachment':
     case 'inline-attachment':
-      // Configure new MIME object
+      // Configure new MIME object.
       $mime = new Mail_mime("\n");
       $mime_params['html_encoding'] = '7bit';
       $mime_params['html_charset'] = 'utf-8';
       $mime_params['text_charset'] = 'utf-8';
 
-      // Pass message contents into MIME object
+      // Pass message contents into MIME object.
       switch ($key) {
         case 'sendlink':
           $mime->setTxtBody($sendlink_plain);
           $mime->setHTMLBody($sendlink_html);
           break;
+
         case 'inline-attachment':
           $mime->setHTMLBody($params['body']);
-          // no break on purpose
+          // No break on purpose.
         case 'plain-attachment':
           $mime->setTxtBody($params['message']);
           $mime->addAttachment($params['body'], 'text/html', 'Attachment.html', FALSE);
           break;
       }
 
-      // Store MIME message output in message array
+      // Store MIME message output in message array.
       $message['body'][] = check_plain($mime->get($mime_params));
       $message['headers'] = $mime->headers($message['headers']);
 
-      // Strip special characters from Content-Type header
-      // Required to prevent mime_header_encode() from disrupting Content-Type header
+      // Strip special characters from Content-Type header. Required to prevent
+      // mime_header_encode() from disrupting Content-Type header.
       $message['headers']['Content-Type'] = preg_replace('/[^\x20-\x7E]/', '', $message['headers']['Content-Type']);
       break;
   }
 }
 
 /**
- * Access callback to check a combination of user_acess() and page access
+ * Access callback to check a combination of user_acess() and page access.
  *
  * @param string $permission
- *   permission required to view the page
+ *   Permission required to view the page.
  *
  * @return bool
  *   TRUE if the user has permission to view the page, FALSE otherwise
@@ -287,18 +267,18 @@ function _print_mail_access($permission) {
       $path = implode('/', $parts);
       if (ctype_digit($parts[1])) {
         if (drupal_lookup_path('source', $path)) {
-          // This is a numeric alias
+          // This is a numeric alias.
           $path = drupal_get_normal_path($path);
         }
         else {
-          // normal nid
+          // Normal nid.
           $path = 'node/' . $path;
         }
       }
       else {
         $path = drupal_get_normal_path($path);
       }
-      // If the destination page is not accessible, don't show the form
+      // If the destination page is not accessible, don't show the form.
       if (!($router_item = menu_get_item($path)) || (!$router_item['access'])) {
         $page_access = FALSE;
       }
@@ -309,7 +289,7 @@ function _print_mail_access($permission) {
 }
 
 /**
- * Auxiliary function to display a formatted send by email link
+ * Auxiliary function to display a formatted send by email link.
  *
  * Function made available so that developers may call this function from
  * their defined pages/blocks.
@@ -320,7 +300,7 @@ function _print_mail_access($permission) {
  *   node object, to be used in checking node access. If the path argument is
  *   not provided, the path used will be node/nid.
  * @param string $location
- *   where in the page where the link is being inserted ('link', 'corner',
+ *   Where in the page where the link is being inserted ('link', 'corner',
  *   'block', 'help').
  *
  * @return string
@@ -330,7 +310,8 @@ function _print_mail_access($permission) {
  */
 function print_mail_insert_link($path = NULL, $node = NULL, $location = '') {
   if (function_exists('print_ui_insert_link')) {
-    return print_ui_insert_link(print_mail_print_link(), array('path' => $path, 'node' => $node, 'location' => $location));
+    return print_ui_insert_link(print_mail_print_link(),
+      array('path' => $path, 'node' => $node, 'location' => $location));
   }
   else {
     return FALSE;
@@ -338,14 +319,14 @@ function print_mail_insert_link($path = NULL, $node = NULL, $location = '') {
 }
 
 /**
- * Check if the link to send by email is allowed depending on the settings
+ * Check if the link to send by email is allowed depending on the settings.
  *
  * @param array $args
- *   array containing the possible parameters:
- *    view_mode, node, type, path
+ *   Array containing the possible parameters:
+ *    view_mode, node, type, path.
  *
  * @return bool
- *   FALSE if not allowed, TRUE otherwise
+ *   FALSE if not allowed, TRUE otherwise.
  */
 function print_mail_link_allowed($args) {
   return (user_access('access send by email'));
@@ -366,6 +347,7 @@ function print_mail_mollom_form_list() {
  * Implemenents hook_mollom_form_info().
  */
 function print_mail_mollom_form_info($form_id) {
+  $form_info = array();
   switch ($form_id) {
     case 'print_mail_form':
       $form_info = array(
@@ -426,7 +408,7 @@ function print_mail_rules_action_info() {
 }
 
 /**
- * Action handler for the print_mail_action_submit
+ * Action handler for the print_mail_action_submit.
  *
  * @ingroup rules
  */

+ 3 - 6
sites/all/modules/contrib/admin/print/print_mail/print_mail.views.inc

@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Send by email Views integration
+ * Send by email Views integration.
  *
  * @ingroup print
  */
@@ -25,18 +25,16 @@ function print_mail_views_data() {
     // 'field' is the foreign key in this table.
     'left_field' => 'nid',
     'field' => 'nid',
-//    'type' => 'INNER',
   );
   $data['print_mail_page_counter']['table']['join']['node'] = array(
     // 'left_field' is the primary key in the referenced table.
     // 'field' is the foreign key in this table.
     'left_field' => 'nid',
     'field' => 'path',
-//    'type' => 'INNER',
     'handler' => 'print_join_page_counter',
   );
 
-  // print_mail_node_conf fields
+  // print_mail_node_conf fields.
   $data['print_mail_node_conf']['link'] = array(
     'title' => t('Email: Show link'),
     'help' => t('Whether to show the send by email link.'),
@@ -86,8 +84,7 @@ function print_mail_views_data() {
     ),
   );
 
-
-  // print_mail_page_counter fields
+  // print_mail_page_counter fields.
   $data['print_mail_page_counter']['totalcount'] = array(
     'title' => t('Email: Number of page accesses'),
     'help' => t('Counter of accesses to the send by email form for this node.'),

+ 13 - 10
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/INSTALL.txt

@@ -2,17 +2,20 @@ dompdf support:
   The dompdf tool produces results that are more faithful to the HTML
   printer-friendly page. Good support of CSS 2.1 and partially CSS3.
 
-  1. Download dompdf from http://code.google.com/p/dompdf/downloads/list
+  1. Download dompdf from https://github.com/dompdf/dompdf/releases. Make
+  sure to download the full release zipfile. If you download only a source
+  code file, you will also need to download and install the php-font-lib.
   2. Extract the contents of the downloaded package into one of the
   supported paths.
-  3. Check if dompdf_config.inc.php fits your installation. In 99% of cases,
-  no changes are necessary, so just try to use it and only edit anything if
-  the PDF generation fails.
-  4. Grant write access to the lib/fonts directory to your webserver user.
-  5. If you're using dompdf-0.5.1, delete the dompdf.php file as it contains
-  a security vulnerability
-  6. If you're using dompdf-0.6 or later, you can try to enable the Unicode
-  support, but you'll need to add some Unicode fonts. See 
+  3. If using dompdf 0.6 or 0.5, check if dompdf_config.inc.php fits your
+  installation. In 99% of cases, no changes are necessary, so just try to use
+  it and only edit anything if the PDF generation fails.
+  4. If  using dompdf 0.6 or 0.5, delete the dompdf.php file as it contains a
+  security vulnerability. Delete also the index.php and www folder, as they are
+  not needed.
+  5. Grant write access to the lib/fonts directory to your webserver user.
+  6. If you're using dompdf 0.6, you can try to enable the Unicode support, but
+  you'll need to add some Unicode fonts. See
   http://groups.google.com/group/dompdf/browse_thread/thread/9f7bc0162b04d5cf
   for further info on this.
-  7. Check http://code.google.com/p/dompdf/ for further information.
+  7. Check https://dompdf.github.io/ for further information.

+ 4 - 5
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.drush.inc

@@ -2,15 +2,14 @@
 
 /**
  * @file
- * drush integration for print_pdf_dompdf module PDF libraries download.
+ * Provide drush integration for print_pdf_dompdf module PDF libraries download.
  */
 
 /**
- * The PDF project download URL
+ * The PDF project download URL.
  */
-
-// URI to the the latest dompdf version.. Hardcoded version unfortunately
-define('DOMPDF_DOWNLOAD_URI', 'https://github.com/dompdf/dompdf/releases/download/v0.6.1/dompdf-0.6.1.zip');
+// URI to the the latest dompdf version.
+define('DOMPDF_DOWNLOAD_URI', 'https://api.github.com/repos/dompdf/dompdf/releases/latest');
 
 /**
  * Implements hook_drush_command().

+ 3 - 4
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.info

@@ -5,9 +5,8 @@ package = "Printer, email and PDF versions"
 dependencies[] = print_pdf
 configure = admin/config/user-interface/print/pdf/dompdf
 
-; Information added by Drupal.org packaging script on 2014-04-02
-version = "7.x-2.0"
+; Information added by Drupal.org packaging script on 2018-10-05
+version = "7.x-2.2"
 core = "7.x"
 project = "print"
-datestamp = "1396426766"
-
+datestamp = "1538760185"

+ 30 - 0
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.install

@@ -14,3 +14,33 @@ function print_pdf_dompdf_uninstall() {
   variable_del('print_pdf_dompdf_unicode');
   variable_del('print_pdf_dompdf_font_subsetting');
 }
+
+/**
+ * Implements hook_requirements().
+ */
+function print_pdf_dompdf_requirements($phase) {
+  $requirements = array();
+  $t = get_t();
+  switch ($phase) {
+    // On status report page, make sure that a PDF generation tool is selected.
+    case 'runtime':
+      $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
+      $tool = explode('|', $print_pdf_pdf_tool);
+      if (is_array($tool) && ($tool[0] === 'print_pdf_dompdf')) {
+        $version = print_pdf_dompdf_pdf_tool_version($tool[1]);
+
+        // If version is older than 0.6.2, raise warning, except if if is
+        // disabled in config.
+        if ((version_compare($version, '0.6.2', '<')) && !variable_get('print_pdf_dompdf_secure_06', FALSE)) {
+          $requirements['print_pdf_dompdf'] = array(
+            'title' => $t('dompdf library'),
+            'value' => $t('Possibly insecure release'),
+            'description' => $t("dompdf versions prior to 0.6.2 are insecure. Make sure you run at least dompdf 0.6.2. If you are running dompdf 0.6.2, set print_pdf_dompdf_secure_06 to TRUE in settings.php to hide this warning."),
+            'severity' => REQUIREMENT_WARNING,
+          );
+        }
+      }
+      break;
+  }
+  return $requirements;
+}

+ 47 - 20
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.module

@@ -16,7 +16,7 @@ define('PRINT_PDF_DOMPDF_FONT_SUBSETTING_DEFAULT', FALSE);
 function print_pdf_dompdf_pdf_tool_info() {
   return array(
     'name' => 'dompdf',
-    'url' => 'http://code.google.com/p/dompdf/downloads/list',
+    'url' => 'https://github.com/dompdf/dompdf/releases/latest',
     'expand_css' => FALSE,
     'public_dirs' => array(
       'fonts',
@@ -59,27 +59,49 @@ function print_pdf_dompdf_menu() {
  * Implements hook_pdf_tool_version().
  */
 function print_pdf_dompdf_pdf_tool_version($pdf_tool) {
-  require_once(DRUPAL_ROOT . '/' . $pdf_tool);
-
-  // Poor man's way to find dompdf version
-  if (!defined('DOMPDF_DIR')) {
-    return 'unknown';
-  }
-  elseif (!defined('DOMPDF_CHROOT')) {
-    return '0.5.1';
-  }
-  elseif (!defined('DOMPDF_FONT_CACHE')) {
-    return '0.5.2';
+  if (file_exists(DRUPAL_ROOT . '/' . $pdf_tool)) {
+    include_once DRUPAL_ROOT . '/' . $pdf_tool;
   }
-  elseif (!defined('DOMPDF_LOG_OUTPUT_FILE')) {
-    return '0.6.0 beta1';
-  }
-  elseif (!defined('DOMPDF_ADMIN_USERNAME')) {
-    return '0.6.0 beta2';
+
+  if (basename($pdf_tool) == 'Dompdf.php') {
+    $dompdf_base = dirname(dirname($pdf_tool));
+    $version_file = $dompdf_base . '/VERSION';
+    if (file_exists($version_file)) {
+      // From 0.7.0 beta 3 onwards, there's a VERSION file.
+      return file_get_contents($version_file);
+    }
+    elseif (basename(dirname($pdf_tool)) === 'src') {
+      // The dompdf tool started using PSR-4 in 0.7.0 beta 2.
+      return '0.7.0 beta 2';
+    }
+    elseif (basename(dirname($pdf_tool)) === 'Dompdf') {
+      // In 0.7.0 beta 1, it was src/Dompdf/Dompdf.php.
+      return '0.7.0 beta 1';
+    }
   }
   else {
-    return '0.6.0 beta3';
+    // Poor man's way to find dompdf version pre 0.7.
+    if (defined('DOMPDF_ENABLE_AUTOLOAD')) {
+      // It is not possible to tell apart 0.6.0, 0.6.1 or 0.6.2.
+      return '0.6.0, or higher';
+    }
+    elseif (defined('DOMPDF_ADMIN_USERNAME')) {
+      return '0.6.0 beta3';
+    }
+    elseif (defined('DOMPDF_LOG_OUTPUT_FILE')) {
+      return '0.6.0 beta2';
+    }
+    elseif (defined('DOMPDF_FONT_CACHE')) {
+      return '0.6.0 beta1';
+    }
+    elseif (defined('DOMPDF_CHROOT')) {
+      return '0.5.2';
+    }
+    elseif (defined('DOMPDF_DIR')) {
+      return '0.5.1';
+    }
   }
+  return 'unknown';
 }
 
 /**
@@ -87,9 +109,14 @@ function print_pdf_dompdf_pdf_tool_version($pdf_tool) {
  */
 function print_pdf_dompdf_print_pdf_available_libs_alter(&$pdf_tools) {
   module_load_include('inc', 'print', 'includes/print');
-  $tools = _print_scan_libs('dompdf', '!^dompdf_config.inc.php$!');
+  $tools = _print_scan_libs('dompdf', '!^(dompdf_config.inc.php|Dompdf.php)$!');
 
   foreach ($tools as $tool) {
-    $pdf_tools['print_pdf_dompdf|' . $tool] = 'dompdf (' . dirname($tool) . ')';
+    if (basename($tool) == 'Dompdf.php') {
+      $pdf_tools['print_pdf_dompdf|' . $tool] = 'dompdf (' . dirname(dirname($tool)) . ')';
+    }
+    else {
+      $pdf_tools['print_pdf_dompdf|' . $tool] = 'dompdf (' . dirname($tool) . ')';
+    }
   }
 }

+ 79 - 30
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.pages.inc

@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Generates the PDF version using dompdf
+ * Generates the PDF version using dompdf.
  *
  * This file is included by the print_pdf_dompdf module and includes the
- * functions that interface with the dompdf library
+ * functions that interface with the dompdf library.
  *
  * @ingroup print
  */
@@ -23,35 +23,80 @@ function print_pdf_dompdf_print_pdf_generate($html, $meta, $paper_size = NULL, $
   if (empty($page_orientation)) {
     $page_orientation = variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT);
   }
-  $content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT);
   $images_via_file = variable_get('print_pdf_images_via_file', PRINT_PDF_IMAGES_VIA_FILE_DEFAULT);
   $unicode = TRUE;
 
   if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {
-    $unicode = variable_get('print_pdf_dompdf_unicode', PRINT_PDF_DOMPDF_UNICODE_DEFAULT);
     $font_subsetting = variable_get('print_pdf_dompdf_font_subsetting', PRINT_PDF_DOMPDF_FONT_SUBSETTING_DEFAULT);
+    $unicode = variable_get('print_pdf_dompdf_unicode', PRINT_PDF_DOMPDF_UNICODE_DEFAULT);
+
+    if (!defined('DOMPDF_ENABLE_PHP')) {
+      define('DOMPDF_ENABLE_PHP', FALSE);
+    }
+    if (!defined('DOMPDF_ENABLE_REMOTE')) {
+      define('DOMPDF_ENABLE_REMOTE', TRUE);
+    }
+    if (!defined('DOMPDF_TEMP_DIR')) {
+      define('DOMPDF_TEMP_DIR', file_directory_temp());
+    }
+    if (!defined('DOMPDF_UNICODE_ENABLED')) {
+      define('DOMPDF_UNICODE_ENABLED', $unicode);
+    }
+    if (!defined('DOMPDF_ENABLE_FONTSUBSETTING')) {
+      define('DOMPDF_ENABLE_FONTSUBSETTING', $font_subsetting);
+    }
+    if (!defined('DOMPDF_FONT_CACHE')) {
+      define('DOMPDF_FONT_CACHE', drupal_realpath('public://print_pdf/print_pdf_dompdf/fonts/'));
+    }
+  }
 
-    if (!defined('DOMPDF_ENABLE_PHP')) define('DOMPDF_ENABLE_PHP', FALSE);
-    if (!defined('DOMPDF_ENABLE_REMOTE')) define('DOMPDF_ENABLE_REMOTE', TRUE);
-    if (!defined('DOMPDF_TEMP_DIR')) define('DOMPDF_TEMP_DIR', file_directory_temp());
-    if (!defined('DOMPDF_UNICODE_ENABLED')) define('DOMPDF_UNICODE_ENABLED', $unicode);
-    if (!defined('DOMPDF_ENABLE_FONTSUBSETTING')) define('DOMPDF_ENABLE_FONTSUBSETTING', $font_subsetting);
-    if (!defined('DOMPDF_FONT_CACHE')) define('DOMPDF_FONT_CACHE', drupal_realpath('public://print_pdf/print_pdf_dompdf/fonts/'));
+  $version = print_pdf_dompdf_pdf_tool_version($pdf_tool[1]);
+  if (version_compare($version, '0.7', '<')) {
+    // Version of dompdf is 0.6.* or 0.5.*.
+    if (version_compare($version, '0.6', '<')) {
+      // Version of dompdf is 0.5.
+      spl_autoload_register('DOMPDF_autoload');
+    }
+    // Earlier dompdf versions could generate xml errors. Tell libxml to
+    // hide them.
+    libxml_use_internal_errors(TRUE);
+    $dompdf = new DOMPDF();
   }
+  else {
+    // Version of dompdf is >= 0.7.
+    $tool_path = dirname($pdf_tool[1]) . '/../autoload.inc.php';
+    if (file_exists($tool_path)) {
+      require_once $tool_path;
+    }
+    else {
+      watchdog('print_pdf', 'Configured PDF tool does not exist at path: %path', array('%path' => $tool_path), WATCHDOG_ERROR);
+      throw new Exception("Configured PDF tool does not exist, unable to generate PDF.");
+    }
+
+    $dompdf = new \Dompdf\Dompdf();
+    $unicode = TRUE;
 
-  require_once(DRUPAL_ROOT . '/' . $pdf_tool[1]);
-  spl_autoload_register('DOMPDF_autoload');
+    if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {
+      $dompdf->set_option('enable_php', FALSE);
+      $dompdf->set_option('enable_remote', TRUE);
+      $dompdf->set_option('temp_dir', file_directory_temp());
+      $dompdf->set_option('enable_font_subsetting', $font_subsetting);
+      $dompdf->set_option('font_cache', drupal_realpath('public://print_pdf/print_pdf_dompdf/fonts/'));
+    }
+  }
 
-  // Try to use local file access for image files
+  // Try to use local file access for image files.
   $html = _print_access_images_via_file($html, $images_via_file);
+  // Remove all scripts due to security concerns.
+  $html = preg_replace('!<script(.*?)>(.*?)</script>!is', '', $html);
 
-  // Spaces in img URLs must be replaced with %20, when using external access
+  // Spaces in img URLs must be replaced with %20, when using external access.
   if (!$images_via_file) {
     $pattern = '!<(img\s[^>]*?)>!is';
     $html = preg_replace_callback($pattern, '_print_replace_spaces', $html);
   }
 
-  // dompdf seems to have problems with something in system.css so let's not use it
+  // It seems dompdf has problems with something in system.css, don't use it.
   $html = preg_replace('!<link.*?modules/system/system.css.*?/>!', '', $html);
 
   $url_array = parse_url($meta['url']);
@@ -60,28 +105,31 @@ function print_pdf_dompdf_print_pdf_generate($html, $meta, $paper_size = NULL, $
   $host = $url_array['host'];
   $path = dirname($url_array['path']) . '/';
 
-  $dompdf = new DOMPDF();
   $dompdf->set_base_path($path);
   $dompdf->set_host($host);
   $dompdf->set_paper(drupal_strtolower($paper_size), $page_orientation);
   $dompdf->set_protocol($protocol);
 
-// dompdf can't handle footers cleanly, so disable the following
-//  $html = theme('print_pdf_dompdf_footer', array('html' => $html));
+  // It seems dompdf can't handle footers cleanly, so disable the following.
+  /*  $html = theme('print_pdf_dompdf_footer', array('html' => $html)); */
 
-  // If dompdf Unicode support is disabled, try to convert to ISO-8859-1 and then to HTML entities
+  // If dompdf Unicode support is disabled, try to convert to ISO-8859-1 and
+  // then to HTML entities.
   if (!$unicode) {
-    // Convert the euro sign to an HTML entity
+    // Convert the euro sign to an HTML entity.
     $html = str_replace('€', '&#0128;', $html);
 
-    // Convert from UTF-8 to ISO 8859-1 and then to HTML entities
+    // Convert from UTF-8 to ISO 8859-1 and then to HTML entities.
     if (function_exists('utf8_decode')) {
-    $html = utf8_decode($html);
+      $html = utf8_decode($html);
+    }
+    // iconv fails silently when it encounters something that it doesn't know,
+    // so don't use it.
+    /*
+    else if (function_exists('iconv')) {
+      $html = iconv('UTF-8', 'ISO-8859-1', $html);
     }
-    // iconv fails silently when it encounters something that it doesn't know, so don't use it
-//    else if (function_exists('iconv')) {
-//      $html = iconv('UTF-8', 'ISO-8859-1', $html);
-//    }
+     */
     elseif (function_exists('mb_convert_encoding')) {
       $html = mb_convert_encoding($html, 'ISO-8859-1', 'UTF-8');
     }
@@ -95,7 +143,7 @@ function print_pdf_dompdf_print_pdf_generate($html, $meta, $paper_size = NULL, $
     $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
   }
 
-  // Must get rid of tbody (dompdf goes into recursion)
+  // Must get rid of tbody (dompdf goes into recursion).
   $html = preg_replace('!<tbody[^>]*?>|</tbody>!i', '', $html);
 
   $dompdf->load_html($html);
@@ -105,11 +153,11 @@ function print_pdf_dompdf_print_pdf_generate($html, $meta, $paper_size = NULL, $
 }
 
 /**
- * Format the dompdf footer contents
+ * Format the dompdf footer contents.
  *
  * @param array $vars
  *   An associative array containing:
- *    - $html: contents of the body of the HTML from the original node
+ *    - $html: contents of the body of the HTML from the original node.
  *
  * @return string
  *   customized HTML text
@@ -152,7 +200,8 @@ function theme_print_pdf_dompdf_footer($vars) {
     </script>';
 
     return str_replace("<body>", "<body>" . $text, $html);
-  } else {
+  }
+  else {
     return $vars['html'];
   }
 }

+ 8 - 0
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_mpdf/INSTALL.txt

@@ -0,0 +1,8 @@
+mPDF support:
+
+  1. Download mPDF from https://github.com/mpdf/mpdf/releases.
+  2. Extract the contents of the downloaded package into one of the
+  supported paths.
+  3. If using mPDF 7.0 or later don't forget to run 'composer install' in the
+  mpdf directory.
+  4. Check https://mpdf.github.io/ for further information.

+ 4 - 5
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.drush.inc

@@ -2,15 +2,14 @@
 
 /**
  * @file
- * drush integration for print_pdf_mpdf module PDF libraries download.
+ * Provides drush integration for print_pdf_mpdf module PDF libraries download.
  */
 
 /**
- * The PDF project download URL
+ * The PDF project download URL.
  */
-
-// URI to the the latest mpdf version.. Hardcoded version unfortunately
-define('MPDF_DOWNLOAD_URI', 'http://mpdf1.com/repos/MPDF57.zip');
+// URI to the the latest mpdf version.
+define('MPDF_DOWNLOAD_URI', 'https://api.github.com/repos/mpdf/mpdf/releases/latest');
 
 /**
  * Implements hook_drush_command().

+ 3 - 4
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.info

@@ -4,9 +4,8 @@ core = 7.x
 package = "Printer, email and PDF versions"
 dependencies[] = print_pdf
 
-; Information added by Drupal.org packaging script on 2014-04-02
-version = "7.x-2.0"
+; Information added by Drupal.org packaging script on 2018-10-05
+version = "7.x-2.2"
 core = "7.x"
 project = "print"
-datestamp = "1396426766"
-
+datestamp = "1538760185"

+ 31 - 7
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.module

@@ -11,31 +11,47 @@
  * Implements hook_pdf_tool_info().
  */
 function print_pdf_mpdf_pdf_tool_info() {
-  return array(
+  $info = array(
     'name' => 'mPDF',
-    'url' => 'http://www.mpdf1.com/mpdf/download',
+    'url' => 'https://github.com/mpdf/mpdf/releases/latest',
     'expand_css' => FALSE,
     'public_dirs' => array(
       'ttfontdata',
       'tmp',
     ),
-    'tool_dirs' => array(
-      'graph_cache',
-    ),
   );
+
+  $pdf_tool = explode('|', variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT));
+  if (!isset($pdf_tool[1]) || print_pdf_mpdf_pdf_tool_version($pdf_tool[1]) !== '>= 7.x') {
+    $info['tool_dirs'] = array(
+      'graph_cache',
+    );
+  }
+  return $info;
 }
 
 /**
  * Implements hook_pdf_tool_version().
  */
 function print_pdf_mpdf_pdf_tool_version($pdf_tool) {
-  require_once(DRUPAL_ROOT . '/' . $pdf_tool);
+  if (file_exists(DRUPAL_ROOT . '/' . $pdf_tool)) {
+    include_once DRUPAL_ROOT . '/' . $pdf_tool;
+  }
 
   if (defined('mPDF_VERSION')) {
     return mPDF_VERSION;
   }
   else {
-    return 'unknown';
+    // Version 7 of the mpdf library uses a composer autoloader.
+    // Also there no longer is a way to truly detect the library version, so
+    // this seems like the best alternative.
+    $mpdf_version_7_plus = strpos($pdf_tool, 'autoload.php') !== FALSE;
+    if ($mpdf_version_7_plus) {
+      return '>= 7.x';
+    }
+    else {
+      return 'unknown';
+    }
   }
 }
 
@@ -49,4 +65,12 @@ function print_pdf_mpdf_print_pdf_available_libs_alter(&$pdf_tools) {
   foreach ($tools as $tool) {
     $pdf_tools['print_pdf_mpdf|' . $tool] = 'mPDF (' . dirname($tool) . ')';
   }
+
+  // mPDF >= 7.0 uses a composer autoloader.
+  $tools = _print_scan_libs('mpdf', '!^autoload.php$!');
+  foreach ($tools as $tool) {
+    if (preg_match('!mpdf.*?/vendor/autoload.php$!', $tool)) {
+      $pdf_tools['print_pdf_mpdf|' . $tool] = 'mPDF (' . dirname(dirname($tool)) . ')';
+    }
+  }
 }

+ 49 - 17
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_mpdf/print_pdf_mpdf.pages.inc

@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Generates the PDF version using mPDF
+ * Generates the PDF version using mPDF.
  *
  * This file is included by the print_pdf_mpdf module and includes the
- * functions that interface with the mPDF library
+ * functions that interface with the mPDF library.
  *
  * @ingroup print
  */
@@ -17,48 +17,80 @@ function print_pdf_mpdf_print_pdf_generate($html, $meta, $paper_size = NULL, $pa
   module_load_include('inc', 'print', 'includes/print');
 
   $pdf_tool = explode('|', variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT));
+  // Version 7 of the mpdf library uses a composer autoloader.
+  // Also there no longer is way to truly detect the library version, so this
+  // seems like the best alternative.
+  $mpdf_version_7_plus = strpos($pdf_tool[1], 'autoload.php') !== FALSE;
   if (empty($paper_size)) {
     $paper_size = variable_get('print_pdf_paper_size', PRINT_PDF_PAPER_SIZE_DEFAULT);
   }
   if (empty($page_orientation)) {
     $page_orientation = variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT);
   }
-  $content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT);
   $images_via_file = variable_get('print_pdf_images_via_file', PRINT_PDF_IMAGES_VIA_FILE_DEFAULT);
 
-  if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {
-    if (!defined('_MPDF_TTFONTDATAPATH')) define('_MPDF_TTFONTDATAPATH', drupal_realpath('public://print_pdf/print_pdf_mpdf/ttfontdata/'));
-    if (!defined('_MPDF_TEMP_PATH')) define('_MPDF_TEMP_PATH', drupal_realpath('public://print_pdf/print_pdf_mpdf/tmp/'));
+  $config = array();
+  if ($mpdf_version_7_plus) {
+    $config['tempDir'] = drupal_realpath('public://print_pdf/print_pdf_mpdf/');
+  }
+  else {
+    // Deprecated since mpdf v7.x.
+    if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {
+      if (!defined('_MPDF_TTFONTDATAPATH')) {
+        define('_MPDF_TTFONTDATAPATH', drupal_realpath('public://print_pdf/print_pdf_mpdf/ttfontdata/'));
+      }
+      if (!defined('_MPDF_TEMP_PATH')) {
+        define('_MPDF_TEMP_PATH', drupal_realpath('public://print_pdf/print_pdf_mpdf/tmp/'));
+      }
+    }
   }
 
-  require_once(DRUPAL_ROOT . '/' . $pdf_tool[1]);
+  $tool_path = DRUPAL_ROOT . '/' . $pdf_tool[1];
+  if (file_exists($tool_path)) {
+    require_once $tool_path;
+  }
+  else {
+    watchdog('print_pdf', 'Configured PDF tool does not exist at path: %path', array('%path' => $tool_path), WATCHDOG_ERROR);
+    throw new Exception("Configured PDF tool does not exist, unable to generate PDF.");
+  }
 
   $format = ($page_orientation == "landscape") ? $paper_size . "-L" : $paper_size;
 
-  // Try to use local file access for image files
+  // Try to use local file access for image files.
   $html = _print_access_images_via_file($html, $images_via_file);
 
-  // set document information
-  $mpdf = new mPDF('UTF-8', $format);
+  // Set document information.
+  if ($mpdf_version_7_plus) {
+    $config['mode'] = 'utf-8';
+    $config['format'] = $format;
+    $mpdf = new \Mpdf\Mpdf($config);
+  }
+  else {
+    $mpdf = new mPDF('UTF-8', $format);
+  }
 
-  $mpdf->SetAuthor(strip_tags($meta['name']));
+  if (isset($meta['name'])) {
+    $mpdf->SetAuthor(strip_tags($meta['name']));
+  }
   $mpdf->SetCreator(variable_get('site_name', 'Drupal'));
+  /*
   // Pulled from the HTML meta data
-  // $mpdf->SetTitle(html_entity_decode($meta['title'], ENT_QUOTES, 'UTF-8'));
+  $mpdf->SetTitle(html_entity_decode($meta['title'], ENT_QUOTES, 'UTF-8'));
 
-//  $keys = implode(' ', explode("\n", trim(strip_tags($print['taxonomy']))));
-//  $mpdf->SetKeywords($keys);
+  $keys = implode(' ', explode("\n", trim(strip_tags($print['taxonomy']))));
+  $mpdf->SetKeywords($keys);
 
   // Encrypt the file and grant permissions to the user to copy and print
   // No password is required to open the document
   // Owner has full rights using the password "MyPassword"
-  // $mpdf->SetProtection(array('copy', 'print'), '', 'MyPassword');
-  // $mpdf->SetProtection(array('copy', 'print', 'print-highres'), '', '');
+  $mpdf->SetProtection(array('copy', 'print'), '', 'MyPassword');
+  $mpdf->SetProtection(array('copy', 'print', 'print-highres'), '', '');
+   */
   drupal_alter('print_pdf_mpdf', $mpdf, $html, $meta);
 
   $mpdf->WriteHTML($html);
 
-  // try to recover from any warning/error
+  // Try to recover from any warning/error.
   ob_clean();
 
   return $mpdf->Output('', 'S');

+ 6 - 1
sites/all/modules/contrib/admin/print/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')) . '<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."),
+      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',
@@ -53,6 +53,11 @@ function print_pdf_tcpdf_settings() {
 /**
  * Form validation handler for print_pdf_tcpdf_settings().
  *
+ * @param array $form
+ *   Form.
+ * @param array $form_state
+ *   Form state.
+ *
  * @see print_pdf_tcpdf_settings()
  * @ingroup forms
  */

+ 18 - 5
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.class.inc

@@ -2,9 +2,9 @@
 
 /**
  * @file
- * Extend the TCPDF class to be able to customize the Footer
+ * Extend the TCPDF class to be able to customize the Footer.
  *
- * This file is included by the _print_pdf_tcpdf function
+ * This file is included by the _print_pdf_tcpdf function.
  *
  * @ingroup print
  */
@@ -12,18 +12,31 @@
 class PrintTCPDF extends TCPDF {
   public $footer;
 
-  // Display invisible link at the bottom of all pages.
+  /**
+   * Display invisible link at the bottom of all pages.
+   *
+   * @param string $tcpdflink
+   *   TCPDF link.
+   */
   public function setTcpdfLink($tcpdflink) {
     $this->tcpdflink = $tcpdflink;
   }
 
-  // Page footer data
+  /**
+   * Page footer data.
+   *
+   * @param string $arg
+   *   Footer contents.
+   */
   public function setFooterContent($arg = '') {
     $this->footer = $arg;
   }
 
-  // Page footer
+  /**
+   * Page footer.
+   */
   public function Footer() {
     theme('print_pdf_tcpdf_footer2', array('pdf' => $this));
   }
+
 }

+ 3 - 4
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.drush.inc

@@ -2,14 +2,13 @@
 
 /**
  * @file
- * drush integration for print_pdf_tcpdf module PDF libraries download.
+ * Provides drush integration for print_pdf_tcpdf module PDF libraries download.
  */
 
 /**
- * The PDF project download URL
+ * The PDF project download URL.
  */
-
-// TCPDF is in sourceforge, and nicely provides a link to the latest version
+// TCPDF is in sourceforge, and nicely provides a link to the latest version.
 define('TCPDF_DOWNLOAD_URI', 'http://sourceforge.net/projects/tcpdf/files/latest');
 
 /**

+ 3 - 4
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.info

@@ -6,9 +6,8 @@ dependencies[] = print_pdf
 files[] = print_pdf_tcpdf.class.inc
 configure = admin/config/user-interface/print/pdf/tcpdf
 
-; Information added by Drupal.org packaging script on 2014-04-02
-version = "7.x-2.0"
+; Information added by Drupal.org packaging script on 2018-10-05
+version = "7.x-2.2"
 core = "7.x"
 project = "print"
-datestamp = "1396426766"
-
+datestamp = "1538760185"

+ 6 - 4
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.module

@@ -7,7 +7,7 @@
  * @ingroup print
  */
 
-define('PRINT_PDF_TCPDF_FONT_FAMILY_DEFAULT', 'dejavusans');
+define('PRINT_PDF_TCPDF_FONT_FAMILY_DEFAULT', '');
 define('PRINT_PDF_TCPDF_FONT_SIZE_DEFAULT', 10);
 define('PRINT_PDF_TCPDF_FONT_SUBSETTING_DEFAULT', FALSE);
 
@@ -81,12 +81,14 @@ 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
+    // Prevent TCPDF default configs.
     define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
   }
-  require_once(DRUPAL_ROOT . '/' . $pdf_tool);
+  if (file_exists(DRUPAL_ROOT . '/' . $pdf_tool)) {
+    include_once DRUPAL_ROOT . '/' . $pdf_tool;
+  }
 
-  // Hide warnings, as some TCPDF constants may still be undefined
+  // Hide warnings, as some TCPDF constants may still be undefined.
   if (class_exists('TCPDF')) {
     @$pdf = new TCPDF();
 

+ 91 - 54
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.pages.inc

@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Generates the PDF version using TCPDF
+ * Generates the PDF version using TCPDF.
  *
  * This file is included by the print_pdf_tcpdf module and includes the
- * functions that interface with the TCPDF library
+ * functions that interface with the TCPDF library.
  *
  * @ingroup print
  */
@@ -25,47 +25,71 @@ function print_pdf_tcpdf_print_pdf_generate($html, $meta, $paper_size = NULL, $p
   if (empty($page_orientation)) {
     $page_orientation = variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT);
   }
-  $content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT);
   $images_via_file = variable_get('print_pdf_images_via_file', PRINT_PDF_IMAGES_VIA_FILE_DEFAULT);
 
   if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {
     $pdf_tool_path = realpath(dirname($pdf_tool[1]));
 
-    if (!defined('K_TCPDF_EXTERNAL_CONFIG')) define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
-    if (!defined('K_PATH_MAIN')) define('K_PATH_MAIN', dirname($_SERVER['SCRIPT_FILENAME']));
-    if (!defined('K_PATH_URL')) define('K_PATH_URL', $base_url);
-    if (!defined('K_PATH_FONTS')) define('K_PATH_FONTS', $pdf_tool_path . '/fonts/');
-    if (!defined('K_PATH_CACHE')) define('K_PATH_CACHE', drupal_realpath('public://print_pdf/print_pdf_tcpdf/cache') . '/');
-    if (!defined('K_PATH_IMAGES')) define('K_PATH_IMAGES', '');
-    if (!defined('K_BLANK_IMAGE')) define('K_BLANK_IMAGE', $pdf_tool_path . '/images/_blank.png');
-    if (!defined('K_CELL_HEIGHT_RATIO')) define('K_CELL_HEIGHT_RATIO', 1.25);
-    if (!defined('K_SMALL_RATIO')) define('K_SMALL_RATIO', 2/3);
+    if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
+      define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
+    }
+    if (!defined('K_PATH_MAIN')) {
+      define('K_PATH_MAIN', DRUPAL_ROOT);
+    }
+    if (!defined('K_PATH_URL')) {
+      define('K_PATH_URL', $base_url);
+    }
+    if (!defined('K_PATH_FONTS')) {
+      define('K_PATH_FONTS', $pdf_tool_path . '/fonts/');
+    }
+    if (!defined('K_PATH_CACHE')) {
+      define('K_PATH_CACHE', drupal_realpath('public://print_pdf/print_pdf_tcpdf/cache') . '/');
+    }
+    if (!defined('K_PATH_IMAGES')) {
+      define('K_PATH_IMAGES', '');
+    }
+    if (!defined('K_BLANK_IMAGE')) {
+      define('K_BLANK_IMAGE', $pdf_tool_path . '/images/_blank.png');
+    }
+    if (!defined('K_CELL_HEIGHT_RATIO')) {
+      define('K_CELL_HEIGHT_RATIO', 1.25);
+    }
+    if (!defined('K_SMALL_RATIO')) {
+      define('K_SMALL_RATIO', 2 / 3);
+    }
   }
 
-  // Try to use local file access for image files
+  // Try to use local file access for image files.
   $html = _print_access_images_via_file($html, $images_via_file);
 
-  // Decode HTML entities in image filenames
+  // Decode HTML entities in image filenames.
   $pattern = "!<img\s[^>]*?src\s*?=\s*?['\"]?{$base_url}[^>]*?>!is";
   $html = preg_replace_callback($pattern, create_function('$matches', 'return html_entity_decode($matches[0], ENT_QUOTES);'), $html);
-  // Remove queries from the image URL
+  // Remove queries from the image URL.
   $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?{$base_url}[^>]*?)(?:%3F|\?)[^\s'\"]+([^>]*?>)!is";
   $html = preg_replace($pattern, '$1$2', $html);
 
-  require_once(DRUPAL_ROOT . '/' . $pdf_tool[1]);
+  $tool_path = DRUPAL_ROOT . '/' . $pdf_tool[1];
+  if (file_exists($tool_path)) {
+    require_once $tool_path;
+  }
+  else {
+    watchdog('print_pdf', 'Configured PDF tool does not exist at path: %path', array('%path' => $tool_path), WATCHDOG_ERROR);
+    throw new Exception("Configured PDF tool does not exist, unable to generate PDF.");
+  }
   module_load_include('inc', 'print_pdf_tcpdf', 'print_pdf_tcpdf.class');
 
-  $font = Array(
+  $font = array(
     check_plain(variable_get('print_pdf_font_family', PRINT_PDF_TCPDF_FONT_FAMILY_DEFAULT)),
     '',
     check_plain(variable_get('print_pdf_font_size', PRINT_PDF_TCPDF_FONT_SIZE_DEFAULT)),
   );
   $orientation = drupal_strtoupper($page_orientation[0]);
 
-  // create new PDF document
-  $pdf = new PrintTCPDF($orientation , 'mm', $paper_size, TRUE);
+  // Create new PDF document.
+  $pdf = new PrintTCPDF($orientation, 'mm', $paper_size, TRUE);
 
-  // set document information
+  // Set document information.
   if (isset($meta['name'])) {
     $pdf->SetAuthor(strip_tags($meta['name']));
   }
@@ -73,35 +97,48 @@ function print_pdf_tcpdf_print_pdf_generate($html, $meta, $paper_size = NULL, $p
   $pdf->SetTitle(html_entity_decode($meta['title'], ENT_QUOTES, 'UTF-8'));
   $pdf->setPDFVersion('1.6');
   $pdf->setFontSubsetting(variable_get('print_pdf_font_subsetting', PRINT_PDF_TCPDF_FONT_SUBSETTING_DEFAULT));
-  $pdf->setTcpdfLink(false);
+  $pdf->setTcpdfLink(FALSE);
 
   if ($language->direction == LANGUAGE_RTL) {
     $pdf->setRTL(TRUE);
   }
 
-  $pdf = theme('print_pdf_tcpdf_header', array('pdf' => $pdf, 'html' => $html, 'font' => $font));
-  $pdf = theme('print_pdf_tcpdf_footer', array('pdf' => $pdf, 'html' => $html, 'font' => $font));
+  $pdf = theme('print_pdf_tcpdf_header', array(
+    'pdf' => $pdf,
+    'html' => $html,
+    'font' => $font,
+  ));
+  $pdf = theme('print_pdf_tcpdf_footer', array(
+    'pdf' => $pdf,
+    'html' => $html,
+    'font' => $font,
+  ));
   $pdf = theme('print_pdf_tcpdf_page', array('pdf' => $pdf));
 
-  // Enable third-party module to alter the pdf object, via hook_print_pdf_tcpdf_alter()
+  // Enable third-party module to alter the pdf object, via
+  // hook_print_pdf_tcpdf_alter().
   drupal_alter('print_pdf_tcpdf', $pdf, $html, $meta);
 
-  // add a page
+  // Add a page.
   $pdf->AddPage();
 
-  $pdf = theme('print_pdf_tcpdf_content', array('pdf' => $pdf, 'html' => $html, 'font' => $font));
+  $pdf = theme('print_pdf_tcpdf_content', array(
+    'pdf' => $pdf,
+    'html' => $html,
+    'font' => $font,
+  ));
 
-  // reset pointer to the last page
+  // Reset pointer to the last page.
   $pdf->lastPage();
 
-  // try to recover from any warning/error
+  // Try to recover from any warning/error.
   ob_clean();
 
   return $pdf = $pdf->Output('', 'S');
 }
 
 /**
- * Format the TCPDF header
+ * Format the TCPDF header.
  *
  * @param array $vars
  *   An associative array containing:
@@ -128,8 +165,8 @@ function theme_print_pdf_tcpdf_header($vars) {
   if (isset($tpl_logo[1]) && preg_match('!src\s*=\s*(?:"(.*?)"|\'(.*?)\'|([^\s]*))!i', $tpl_logo[1], $logo_url)) {
     $logo = $logo_url[1];
 
-    // Make logo relative again
-    $logo = preg_replace("!^$base_url(.*)!sm", dirname($_SERVER['SCRIPT_FILENAME']) . '$1', $logo);
+    // Make logo relative again.
+    $logo = preg_replace("!^$base_url(.*)!sm", DRUPAL_ROOT . '$1', $logo);
 
     if (!empty($logo)) {
       $size = getimagesize($logo);
@@ -137,22 +174,22 @@ function theme_print_pdf_tcpdf_header($vars) {
     }
   }
 
-  // set header font
+  // Set header font.
   $pdf->setHeaderFont($vars['font']);
-  // set header margin
+  // Set header margin.
   $pdf->setHeaderMargin(5);
-  // set header data
+  // Set header data.
   $pdf->setHeaderData($logo, 10 * $ratio, html_entity_decode($tpl_title[1], ENT_QUOTES, 'UTF-8'), html_entity_decode(strip_tags($tpl_site_name[1]), ENT_QUOTES, 'UTF-8'));
 
   return $pdf;
 }
 
 /**
- * Format the TCPDF page settings (margins, etc)
+ * Format the TCPDF page settings (margins, etc).
  *
  * @param array $vars
  *   An associative array containing:
- *   - $pdf: current TCPDF object
+ *   - $pdf: current TCPDF object.
  *
  * @return object
  *   modified PDF object
@@ -162,20 +199,20 @@ function theme_print_pdf_tcpdf_header($vars) {
  */
 function theme_print_pdf_tcpdf_page($vars) {
   $pdf = $vars['pdf'];
-  // set margins
+  // Set margins.
   $pdf->SetMargins(15, 20, 15);
-  // set auto page breaks
+  // Set auto page breaks.
   $pdf->SetAutoPageBreak(TRUE, 15);
-  // set image scale factor
+  // Set image scale factor.
   $pdf->setImageScale(1);
-  // set image compression quality
+  // Set image compression quality.
   $pdf->setJPEGQuality(100);
 
   return $pdf;
 }
 
 /**
- * Format the TCPDF page content
+ * Format the TCPDF page content.
  *
  * @param array $vars
  *   An associative array containing:
@@ -191,20 +228,20 @@ function theme_print_pdf_tcpdf_page($vars) {
  */
 function theme_print_pdf_tcpdf_content($vars) {
   $pdf = $vars['pdf'];
-  // set content font
+  // Set content font.
   $pdf->setFont($vars['font'][0], $vars['font'][1], $vars['font'][2]);
 
-  // Remove the logo, published, breadcrumb and footer from the main content
+  // Remove the logo, published, breadcrumb and footer from the main content.
   preg_match('!<body.*?>(.*)</body>!sim', $vars['html'], $matches);
   $pattern = '!(?:<div class="print-(?:logo|site_name|breadcrumb|footer)">.*?</div>|<hr class="print-hr" />)!si';
   $matches[1] = preg_replace($pattern, '', $matches[1]);
 
-  // Make CCK fields look better
+  // Make CCK fields look better.
   $matches[1] = preg_replace('!(<div class="field.*?>)\s*!sm', '$1', $matches[1]);
   $matches[1] = preg_replace('!(<div class="field.*?>.*?</div>)\s*!sm', '$1', $matches[1]);
   $matches[1] = preg_replace('!<div( class="field-label.*?>.*?)</div>!sm', '<strong$1</strong>', $matches[1]);
 
-  // Since TCPDF's writeHTML is so bad with <p>, do everything possible to make it look nice
+  // Since TCPDF's writeHTML is so bad with <p>, try to make it look nice.
   $matches[1] = preg_replace('!<(?:p(|\s+.*?)/?|/p)>!i', '<br$1 />', $matches[1]);
   $matches[1] = str_replace(array('<div', 'div>'), array('<span', 'span><br />'), $matches[1]);
   do {
@@ -218,7 +255,7 @@ function theme_print_pdf_tcpdf_content($vars) {
 }
 
 /**
- * Format the TCPDF footer contents
+ * Format the TCPDF footer contents.
  *
  * @param array $vars
  *   An associative array containing:
@@ -239,12 +276,12 @@ function theme_print_pdf_tcpdf_footer($vars) {
   if (isset($tpl_footer[1])) {
     $footer = trim(preg_replace('!</?div[^>]*?>!i', '', $tpl_footer[1]));
 
-    // set footer font
+    // Set footer font.
     $vars['font'][2] *= 0.8;
     $pdf->setFooterFont($vars['font']);
-    // set footer margin
+    // Set footer margin.
     $pdf->SetFooterMargin(10);
-    // set footer data
+    // Set footer data.
     $pdf->setFooterContent($footer);
   }
 
@@ -252,11 +289,11 @@ function theme_print_pdf_tcpdf_footer($vars) {
 }
 
 /**
- * Format the TCPDF footer layout
+ * Format the TCPDF footer layout.
  *
  * @param array $vars
  *   An associative array containing:
- *   - $pdf: current TCPDF object
+ *   - $pdf: current TCPDF object.
  *
  * @return object
  *   modified PDF object
@@ -266,12 +303,12 @@ function theme_print_pdf_tcpdf_footer($vars) {
  */
 function theme_print_pdf_tcpdf_footer2($vars) {
   $pdf = $vars['pdf'];
-  // Position at 1.5 cm from bottom
-  $pdf->writeHTMLCell(0, 15, 15, $pdf->getPageHeight()-15, $pdf->footer);
+  // Position at 1.5 cm from bottom.
+  $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()));
-  // Print page number
+  // Print page number.
   if ($pdf->getRTL()) {
     $pdf->SetX($ormargins['right']);
     $pdf->Cell(0, 10, $pagenumtxt, 'T', 0, 'L');

+ 7 - 9
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/INSTALL.txt

@@ -5,13 +5,11 @@ wkhtmltopdf support:
   libraries in your site, which may present problems in shared hosting
   environments.  The best, if you can run it.
 
-  1. Download wkhtmltopdf from
-  http://code.google.com/p/wkhtmltopdf/downloads/list. You can choose to
-  download the source and compile it or simply download the static binary,
-  which doesn't require you to compile anything. Note that the compiled
-  version may require a running X server (static uses patched libs that can
-  work without one).
-  2. Place the wkhtmltopdf executable into one of the supported paths. 
-  (usually sites/all/modules/print/lib).  You can also place a symbolic link
-  to the executable.
+  1. Download wkhtmltopdf from http://wkhtmltopdf.org/downloads.html. You can
+  choose to download the source and compile it or simply download the installer
+  for your OS. Note that the compiled version may require a running X server
+  (the installers use patched libs that can work without one).
+  2. Place a symbolic link to the executable in one of the supported paths
+  (usually sites/all/libraries/wkhtmltopdf). Or if you can also place the
+  wkhtmltopdf executable directly into that folder.
   3. Check http://code.google.com/p/wkhtmltopdf/ for further information.

+ 9 - 7
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.admin.inc

@@ -27,19 +27,21 @@ function print_pdf_wkhtmltopdf_settings() {
     '#size' => 60,
     '#maxlength' => 500,
     '#default_value' => variable_get('print_pdf_wkhtmltopdf_options', PRINT_PDF_WKHTMLTOPDF_OPTIONS),
-    '#description' => t('(wkhtmltopdf only) Set any additional options to be passed to the wkhtmltopdf executable. Tokens may be used in these options (see list below).'),
+    '#description' => t('Set any additional options to be passed to the wkhtmltopdf executable. Tokens may be used in these options (see list below).'),
+  );
+
+  $form['settings']['print_pdf_wkhtmltopdf_use_input_file'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use temporary input file'),
+    '#default_value' => variable_get('print_pdf_wkhtmltopdf_use_input_file', PRINT_PDF_WKHTMLTOPDF_USE_INPUT_FILE_DEFAULT),
+    '#description' => t('If you experience trouble when generating a PDF try to enable this feature to adjust the input handling.'),
   );
 
   if (module_exists('token')) {
     $form['settings']['print_pdf_filename_patterns'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Replacement patterns'),
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-    );
-    $form['settings']['print_pdf_filename_patterns']['descriptions'] = array(
       '#theme' => 'token_tree',
       '#token_types' => array('node'),
+      '#dialog' => TRUE,
     );
   }
 

+ 16 - 12
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.drush.inc

@@ -2,19 +2,19 @@
 
 /**
  * @file
- * drush integration for print_pdf_wkhtmltopdf module PDF libraries download.
+ * Provides drush integration for print_pdf_wkhtmltopdf module.
  */
 
 /**
- * The PDF project download URL
+ * The PDF project download URL.
  */
-
-// wkhtmltopdf is a binary, requiring a different download for each platform
-define('WKHTMLTOPDF_AMD64_DOWNLOAD_URI', 'http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.0/wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz');
-define('WKHTMLTOPDF_I386_DOWNLOAD_URI', 'http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.0/wkhtmltox-linux-i386_0.12.0-03c001d.tar.xz');
-define('WKHTMLTOPDF_WIN64_DOWNLOAD_URI', 'http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.0/wkhtmltox-win64_0.12.0-03c001d.exe');
-define('WKHTMLTOPDF_WIN_DOWNLOAD_URI', 'http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.0/wkhtmltox-win32_0.12.0-03c001d.exe');
-define('WKHTMLTOPDF_OSX_DOWNLOAD_URI', 'http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-OSX-0.10.0_rc2-static.tar.bz2');
+// Since wkhtmltopdf is a binary, a different URL is required for each platform.
+define('WKHTMLTOPDF_LNX64_DOWNLOAD_URI', 'https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz');
+define('WKHTMLTOPDF_LNX32_DOWNLOAD_URI', 'https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-i386.tar.xz');
+define('WKHTMLTOPDF_WIN64_DOWNLOAD_URI', 'https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.msvc2015-win64.exe');
+define('WKHTMLTOPDF_WIN32_DOWNLOAD_URI', 'https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.msvc2015-win32.exe');
+define('WKHTMLTOPDF_OSX64_DOWNLOAD_URI', 'https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.macos-cocoa.pkg');
+define('WKHTMLTOPDF_OSX32_DOWNLOAD_URI', 'https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.macos-carbon.pkg');
 
 /**
  * Implements hook_drush_command().
@@ -36,14 +36,18 @@ function _print_pdf_wkhtmltopdf_drush_download_url() {
 
   switch (drupal_substr(php_uname('s'), 0, 3)) {
     case 'Lin':
-      $ret = (php_uname('m') == 'x86_64') ? WKHTMLTOPDF_AMD64_DOWNLOAD_URI : WKHTMLTOPDF_I386_DOWNLOAD_URI;
+      drush_log(dt('Please note that generic Linux builds are no longer being generated. See https://wkhtmltopdf.org/downloads.html.'), 'warning');
+      $ret = (php_uname('m') == 'x86_64') ? WKHTMLTOPDF_LNX64_DOWNLOAD_URI : WKHTMLTOPDF_LNX32_DOWNLOAD_URI;
       break;
+
     case 'Win':
-      $ret = WKHTMLTOPDF_WIN_DOWNLOAD_URI;
+      $ret = WKHTMLTOPDF_WIN32_DOWNLOAD_URI;
       break;
+
     case 'Dar':
-      $ret = WKHTMLTOPDF_OSX_DOWNLOAD_URI;
+      $ret = (php_uname('m') == 'x86_64') ? WKHTMLTOPDF_OSX64_DOWNLOAD_URI : WKHTMLTOPDF_OSX32_DOWNLOAD_URI;
       break;
+
     default:
       drush_log(dt('wkhtmltopdf is not supported in this system, please choose another library.'), 'error');
       break;

+ 3 - 4
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.info

@@ -5,9 +5,8 @@ package = "Printer, email and PDF versions"
 dependencies[] = print_pdf
 configure = admin/config/user-interface/print/pdf/wkhtmltopdf
 
-; Information added by Drupal.org packaging script on 2014-04-02
-version = "7.x-2.0"
+; Information added by Drupal.org packaging script on 2018-10-05
+version = "7.x-2.2"
 core = "7.x"
 project = "print"
-datestamp = "1396426766"
-
+datestamp = "1538760185"

+ 33 - 0
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.install

@@ -12,4 +12,37 @@
  */
 function print_pdf_wkhtmltopdf_uninstall() {
   variable_del('print_pdf_wkhtmltopdf_options');
+  variable_del('print_pdf_wkhtmltopdf_use_input_file');
+  variable_del('print_pdf_wkhtmltopdf_version');
+}
+
+/**
+ * Implements hook_requirements().
+ */
+function print_pdf_wkhtmltopdf_requirements($phase) {
+  $requirements = array();
+  $t = get_t();
+  switch ($phase) {
+    // On status report page, make sure that a PDF generation tool is selected.
+    case 'runtime':
+      $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
+      if (!empty($print_pdf_pdf_tool)) {
+        $tool = explode('|', $print_pdf_pdf_tool);
+
+        if (is_file($tool[1]) && is_readable($tool[1])) {
+          if (drupal_substr(basename($tool[1], '.exe'), 0, 11) == 'wkhtmltopdf') {
+            if (function_exists('is_executable') && !is_executable($tool[1])) {
+              $requirements['print_pdf_wkhtmltopdf'] = array(
+                'title' => $t('wkhtmltopdf library'),
+                'value' => $t('Non-executable permissions'),
+                'description' => $t('You must modify the permissions of the wkhtmltopdf file (%file) to make it executable.', array('%file' => $tool[1])),
+                'severity' => REQUIREMENT_ERROR,
+              );
+            }
+          }
+        }
+      }
+      break;
+  }
+  return $requirements;
 }

+ 47 - 42
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.module

@@ -8,6 +8,8 @@
  */
 
 define('PRINT_PDF_WKHTMLTOPDF_OPTIONS', "--footer-font-size 7 --footer-right '[page]'");
+define('PRINT_PDF_WKHTMLTOPDF_VERSION_DEFAULT', '');
+define('PRINT_PDF_WKHTMLTOPDF_USE_INPUT_FILE_DEFAULT', FALSE);
 
 /**
  * Implements hook_pdf_tool_info().
@@ -16,7 +18,7 @@ function print_pdf_wkhtmltopdf_pdf_tool_info() {
   return array(
     'name' => 'wkhtmltopdf',
     'min_version' => '0.9.6',
-    'url' => 'http://code.google.com/p/wkhtmltopdf/downloads/list',
+    'url' => 'http://wkhtmltopdf.org/downloads.html',
     'expand_css' => FALSE,
   );
 }
@@ -41,54 +43,49 @@ function print_pdf_wkhtmltopdf_menu() {
 }
 
 /**
- * Implements hook_requirements().
+ * Implements hook_flush_caches().
  */
-function print_pdf_wkhtmltopdf_requirements($phase) {
-  $requirements = array();
-  $t = get_t();
-  switch ($phase) {
-    // At runtime, make sure that a PDF generation tool is selected
-    case 'runtime':
-      $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
-      if (!empty($print_pdf_pdf_tool)) {
-        $tool = explode('|', $print_pdf_pdf_tool);
-
-        if (is_file($tool[1]) && is_readable($tool[1])) {
-          if (drupal_substr(basename($tool[1], '.exe'), 0, 11) == 'wkhtmltopdf') {
-            if (function_exists('is_executable') && !is_executable($tool[1])) {
-              $requirements['print_pdf_wkhtmltopdf'] = array(
-                'title' => $t('wkhtmltopdf library'),
-                'value' => $t('Non-executable permissions'),
-                'description' => $t('You must modify the permissions of the wkhtmltopdf file (%file) to make it executable.', array('%file' => $tool[1])),
-                'severity' => REQUIREMENT_ERROR,
-              );
-            }
-          }
-        }
-      }
-      break;
-  }
-  return $requirements;
+function print_pdf_wkhtmltopdf_flush_caches() {
+  // Delete the cached version info during cache clear.
+  variable_del('print_pdf_wkhtmltopdf_version');
+  return array();
 }
 
 /**
  * Implements hook_pdf_tool_version().
  */
-function print_pdf_wkhtmltopdf_pdf_tool_version($pdf_tool) {
-  $descriptor = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
-
-  $cmd = '"' . realpath($pdf_tool) . '" --version';
-  $process = proc_open($cmd, $descriptor, $pipes, NULL, NULL);
-  if (is_resource($process)) {
-    $content = stream_get_contents($pipes[1]);
-    $out = preg_match('!.*?(\d+\.\d+\.\d+).*$!m', $content, $matches);
-    fclose($pipes[0]);
-    fclose($pipes[1]);
-    fclose($pipes[2]);
-    $retval = proc_close($process);
+function print_pdf_wkhtmltopdf_pdf_tool_version($pdf_tool, $reset = TRUE) {
+  $version = variable_get('print_pdf_wkhtmltopdf_version', PRINT_PDF_WKHTMLTOPDF_VERSION_DEFAULT);
+
+  if ($reset || empty($version)) {
+    // Ask the version information from the executable.
+    $descriptor = array(
+      0 => array('pipe', 'r'),
+      1 => array('pipe', 'w'),
+      2 => array('pipe', 'w'),
+    );
+
+    $cmd = '"' . realpath($pdf_tool) . '" --version';
+    $process = proc_open($cmd, $descriptor, $pipes, NULL, NULL);
+    if (is_resource($process)) {
+      $content = stream_get_contents($pipes[1]);
+      preg_match('!.*?(\d+\.\d+\.\d+).*$!m', $content, $matches);
+      fclose($pipes[0]);
+      fclose($pipes[1]);
+      fclose($pipes[2]);
+      proc_close($process);
+
+      // Cache the results of this expensive operation.
+      variable_set('print_pdf_wkhtmltopdf_version', $matches[1]);
+      return ($matches[1]);
+    }
+  }
+  else {
+    // For performance sake, usually use the cached value.
+    return $version;
   }
 
-  return ($matches[1]);
+  return 'unknown';
 }
 
 /**
@@ -98,8 +95,16 @@ function print_pdf_wkhtmltopdf_print_pdf_available_libs_alter(&$pdf_tools) {
   module_load_include('inc', 'print', 'includes/print');
   $tools = _print_scan_libs('wkhtmltopdf', '!^wkhtmltopdf!');
 
+  // See if there is a binary version of wkhtmltopdf available.
+  if (drupal_substr(php_uname('s'), 0, 3) !== 'Win') {
+    exec('export PATH="$PATH:/usr/local/bin" ; which wkhtmltopdf', $binary_output, $binary_status);
+    if (count($binary_output) > 0 && $binary_status == 0) {
+      $tools[] = $binary_output[0];
+    }
+  }
+
   foreach ($tools as $tool) {
-    $version = print_pdf_wkhtmltopdf_pdf_tool_version($tool);
+    $version = print_pdf_wkhtmltopdf_pdf_tool_version($tool, TRUE);
 
     $pdf_tools['print_pdf_wkhtmltopdf|' . $tool] = 'wkhtmltopdf ' . $version . ' (' . $tool . ')';
   }

+ 54 - 12
sites/all/modules/contrib/admin/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.pages.inc

@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Generates the PDF version using wkhtmltopdf
+ * Generates the PDF version using wkhtmltopdf.
  *
  * This file is included by the print_pdf_wkhtmltopdf module and includes the
- * functions that interface with the wkhtmltopdf library
+ * functions that interface with the wkhtmltopdf library.
  *
  * @ingroup print
  */
@@ -21,7 +21,6 @@ function print_pdf_wkhtmltopdf_print_pdf_generate($html, $meta, $paper_size = NU
   if (empty($page_orientation)) {
     $page_orientation = variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT);
   }
-  $content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT);
   $wkhtmltopdf_options = variable_get('print_pdf_wkhtmltopdf_options', PRINT_PDF_WKHTMLTOPDF_OPTIONS);
 
   $dpi = 96;
@@ -30,9 +29,24 @@ function print_pdf_wkhtmltopdf_print_pdf_generate($html, $meta, $paper_size = NU
     $wkhtmltopdf_options = token_replace($wkhtmltopdf_options, array('node' => $meta['node']), array('clear' => TRUE));
   }
 
-  $version = print_pdf_wkhtmltopdf_pdf_tool_version($pdf_tool[1]);
+  // Build array of single quoted parts, and the same escaped.
+  preg_match_all("!'.+?'!", $wkhtmltopdf_options, $matches);
+  $quoted = array();
+  foreach ($matches[0] as $match) {
+    $quoted[escapeshellcmd($match)] = $match;
+  }
+
+  // Prevent options that could result in execution of arbitrary commands.
+  $wkhtmltopdf_options = escapeshellcmd($wkhtmltopdf_options);
+
+  // Replace sections that were single quoted with original content.
+  foreach ($quoted as $search => $replace) {
+    $wkhtmltopdf_options = str_replace($search, $replace, $wkhtmltopdf_options);
+  }
 
-  // 0.10.0 beta2 identifies itself as 0.9.9
+  $version = print_pdf_wkhtmltopdf_pdf_tool_version($pdf_tool[1], FALSE);
+
+  // 0.10.0 beta2 identifies itself as 0.9.9.
   if (version_compare($version, '0.9.9', '>=')) {
     $wkhtmltopdf_options = '--disable-local-file-access ' . $wkhtmltopdf_options;
   }
@@ -44,19 +58,40 @@ function print_pdf_wkhtmltopdf_print_pdf_generate($html, $meta, $paper_size = NU
     exit;
   }
 
-  // use basic http authentication to fetch included CSS, etc
+  // Use basic http authentication to fetch included CSS, etc.
   if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
-    $wkhtmltopdf_options .= ' --username ' . check_plain($_SERVER['PHP_AUTH_USER']) . ' --password ' . check_plain($_SERVER['PHP_AUTH_PW']);
+    $wkhtmltopdf_options .= ' --username ' . escapeshellarg($_SERVER['PHP_AUTH_USER']) . ' --password ' . escapeshellarg($_SERVER['PHP_AUTH_PW']);
   }
 
-  $descriptor = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'a'));
-  $cmd = '"' . realpath($pdf_tool[1]) . "\" --page-size $paper_size --orientation $page_orientation --dpi $dpi $wkhtmltopdf_options - -";
+  $use_input_file = variable_get('print_pdf_wkhtmltopdf_use_input_file', PRINT_PDF_WKHTMLTOPDF_USE_INPUT_FILE_DEFAULT);
+  if ($use_input_file) {
+    $temp_html = file_unmanaged_save_data($html, drupal_tempnam('temporary://', 'c_html_') . '.html', FILE_EXISTS_RENAME);
+    if ($temp_html === FALSE) {
+      watchdog('print_pdf', 'wkhtmltopdf: could not create temporary html file: %file', array('%file' => $temp_html));
+      drupal_goto($meta['url']);
+      return NULL;
+    }
+    $html_input_parameter = drupal_realpath($temp_html);
+  }
+  else {
+    $temp_html = '';
+    $html_input_parameter = '-';
+  }
+
+  $descriptor = array(
+    0 => array('pipe', 'r'),
+    1 => array('pipe', 'w'),
+    2 => array('pipe', 'a'),
+  );
+  $cmd = '"' . realpath($pdf_tool[1]) . "\" -q --page-size $paper_size --orientation $page_orientation --dpi $dpi $wkhtmltopdf_options $html_input_parameter -";
 
   $process = proc_open($cmd, $descriptor, $pipes, NULL, NULL);
 
   if (is_resource($process)) {
-    fwrite($pipes[0], $html);
-    fclose($pipes[0]);
+    if (!$use_input_file) {
+      fwrite($pipes[0], $html);
+      fclose($pipes[0]);
+    }
 
     $pdf = stream_get_contents($pipes[1]);
     fclose($pipes[1]);
@@ -70,11 +105,18 @@ function print_pdf_wkhtmltopdf_print_pdf_generate($html, $meta, $paper_size = NU
       if (empty($error)) {
         $error = 'No stderr output available.';
       }
-      watchdog('print_pdf', 'wkhtmltopdf [%cmd] (returned %ret): %error', array('%cmd' => $cmd, '%ret' => $retval, '%error' => $error));
+      watchdog('print_pdf', 'wkhtmltopdf [%cmd] (returned %ret): %error',
+        array('%cmd' => $cmd, '%ret' => $retval, '%error' => $error));
     }
   }
+  if ($use_input_file) {
+    file_unmanaged_delete($temp_html);
+  }
 
   if (!empty($pdf)) {
+    // Remove anything before actual PDF content.
+    $pdf = substr($pdf, strpos($pdf, '%PDF-'));
+
     return $pdf;
   }
   else {

+ 12 - 8
sites/all/modules/contrib/admin/print/print_pdf/print_pdf.admin.inc

@@ -23,7 +23,7 @@ function print_pdf_settings() {
     $link = print_pdf_print_link();
 
     $current_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
-    $pdf_tool_default =  array_key_exists($current_pdf_tool, $pdf_tools) ? $current_pdf_tool : PRINT_PDF_PDF_TOOL_DEFAULT;
+    $pdf_tool_default = array_key_exists((string) $current_pdf_tool, $pdf_tools) ? $current_pdf_tool : PRINT_PDF_PDF_TOOL_DEFAULT;
 
     $form['settings'] = array(
       '#type' => 'fieldset',
@@ -41,7 +41,11 @@ function print_pdf_settings() {
     $form['settings']['print_pdf_content_disposition'] = array(
       '#type' => 'radios',
       '#title' => t('Open PDF in'),
-      '#options' => array(t('Same browser window'), t('New browser window'), t('Save dialog')),
+      '#options' => array(
+        t('Same browser window'),
+        t('New browser window'),
+        t('Save dialog'),
+      ),
       '#default_value' => variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT),
       '#description' => t("Select the desired method for opening the PDF in the user's browser."),
     );
@@ -111,14 +115,9 @@ function print_pdf_settings() {
     );
     if (module_exists('token')) {
       $form['settings']['print_pdf_filename_patterns'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Replacement patterns'),
-        '#collapsible' => TRUE,
-        '#collapsed' => TRUE,
-      );
-      $form['settings']['print_pdf_filename_patterns']['descriptions'] = array(
         '#theme' => 'token_tree',
         '#token_types' => array('node'),
+        '#dialog' => TRUE,
       );
     }
 
@@ -163,6 +162,11 @@ function print_pdf_settings() {
 /**
  * Form validation handler for print_pdf_settings().
  *
+ * @param array $form
+ *   Form.
+ * @param array $form_state
+ *   Form state.
+ *
  * @see print_pdf_settings()
  * @ingroup forms
  */

+ 12 - 12
sites/all/modules/contrib/admin/print/print_pdf/print_pdf.api.php

@@ -13,7 +13,7 @@
 /**
  * Provide some information on the needs of the PDF library.
  *
- * @return
+ * @return array
  *   Associative array with the following data:
  *   - name: name of the PDF library.
  *   - min_version: minimum version of the PDF library supported by the
@@ -47,7 +47,7 @@ function hook_pdf_tool_info() {
 }
 
 /**
- * Find out the version of the PDF library
+ * Find out the version of the PDF library.
  *
  * @param string $pdf_tool
  *   Filename of the tool to be analysed.
@@ -55,8 +55,8 @@ function hook_pdf_tool_info() {
  * @return string
  *   version number of the library
  */
-function hook_pdf_tool_version() {
-  require_once(DRUPAL_ROOT . '/' . $pdf_tool);
+function hook_pdf_tool_version($pdf_tool) {
+  require_once DRUPAL_ROOT . '/' . $pdf_tool;
 
   return '1.0';
 }
@@ -65,26 +65,26 @@ function hook_pdf_tool_version() {
  * Generate a PDF version of the provided HTML.
  *
  * @param string $html
- *   HTML content of the PDF
+ *   HTML content of the PDF.
  * @param array $meta
  *   Meta information to be used in the PDF
  *   - url: original URL
  *   - name: author's name
  *   - title: Page title
- *   - node: node object
+ *   - node: node object.
  * @param string $paper_size
- *   (optional) Paper size of the generated PDF
+ *   (optional) Paper size of the generated PDF.
  * @param string $page_orientation
- *   (optional) Page orientation of the generated PDF
+ *   (optional) Page orientation of the generated PDF.
  *
- * @return
+ * @return Object|null
  *   generated PDF page, or NULL in case of error
  *
  * @see print_pdf_controller_html()
  * @ingroup print_hooks
  */
 function hook_print_pdf_generate($html, $meta, $paper_size = NULL, $page_orientation = NULL) {
-  $pdf = new PDF();
+  $pdf = new PDF($meta, $paper_size, $page_orientation);
   $pdf->writeHTML($html);
 
   return $pdf->Output();
@@ -128,7 +128,7 @@ function hook_print_pdf_available_libs_alter(&$pdf_tools) {
  * '.pdf' extension, as the module will do that automatically.
  *
  * @param string $pdf_filename
- *   current value of the pdf_filename variable, after processing tokens and
+ *   Current value of the pdf_filename variable, after processing tokens and
  *   any transliteration steps.
  * @param string $path
  *   original alias/system path of the page being converted to PDF.
@@ -136,7 +136,7 @@ function hook_print_pdf_available_libs_alter(&$pdf_tools) {
  * @ingroup print_hooks
  */
 function hook_print_pdf_filename_alter(&$pdf_filename, &$path) {
-  $pdf_filename = 'foo';
+  $pdf_filename = $path . 'foo';
 }
 
 /**

+ 9 - 5
sites/all/modules/contrib/admin/print/print_pdf/print_pdf.drush.inc

@@ -2,7 +2,7 @@
 
 /**
  * @file
- * drush integration for print_pdf module PDF libraries download.
+ * Provide drush integration for print_pdf module PDF libraries download.
  */
 
 /**
@@ -23,21 +23,25 @@ function print_pdf_drush_command() {
       'path' => dt('A path to the download folder. If omitted Drush will use the default location (@path).', array('@path' => 'sites/all/libraries')),
     ),
     'aliases' => array('pdfdl'),
-    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT, // No site or config needed.
+    // No site or config needed.
+    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
   );
 
   return $items;
 }
 
 /**
- * Implements of drush_hook_COMMAND_validate().
+ * Implements drush_hook_COMMAND_validate().
  */
 function drush_print_pdf_download_validate($library = NULL) {
   if (is_null($library)) {
     $pdf_libs = array();
     drush_command_invoke_all_ref('drush_pdf_libs_alter', $pdf_libs);
 
-    drush_set_error('DRUSH_PDFDL_MISSING_ARG', dt("Usage: drush !cmd <library>\nWhere <library> is one of the following: !libs\n\nTry 'drush !cmd --help' for more information.", array('!cmd' => 'print-pdf-download', '!libs' => implode(', ', array_keys($pdf_libs)))));
+    drush_set_error('DRUSH_PDFDL_MISSING_ARG', dt("Usage: drush !cmd <library>\nWhere <library> is one of the following: !libs\n\nTry 'drush !cmd --help' for more information.", array(
+      '!cmd' => 'print-pdf-download',
+      '!libs' => implode(', ', array_keys($pdf_libs)),
+    )));
   }
 }
 
@@ -45,7 +49,7 @@ function drush_print_pdf_download_validate($library = NULL) {
  * Download and extract PDF archive.
  *
  * @param string $library
- *   library to download
+ *   Library to download.
  */
 function drush_print_pdf_download($library) {
   $pdf_libs = array();

+ 3 - 4
sites/all/modules/contrib/admin/print/print_pdf/print_pdf.info

@@ -5,9 +5,8 @@ package = "Printer, email and PDF versions"
 dependencies[] = print
 configure = admin/config/user-interface/print/pdf
 
-; Information added by Drupal.org packaging script on 2014-04-02
-version = "7.x-2.0"
+; Information added by Drupal.org packaging script on 2018-10-05
+version = "7.x-2.2"
 core = "7.x"
 project = "print"
-datestamp = "1396426766"
-
+datestamp = "1538760185"

+ 109 - 15
sites/all/modules/contrib/admin/print/print_pdf/print_pdf.install

@@ -11,9 +11,7 @@
  * Implements hook_enable().
  */
 function print_pdf_enable() {
-  $t = get_t();
-
-  // Module weight
+  // Module weight.
   db_update('system')
     ->fields(array(
       'weight' => 2,
@@ -139,7 +137,98 @@ function print_pdf_schema() {
 }
 
 /**
- * Remove hardcoded numeric deltas from all blocks
+ * Implements hook_requirements().
+ */
+function print_pdf_requirements($phase) {
+  $requirements = array();
+  $t = get_t();
+  switch ($phase) {
+    // At runtime, make sure that a PDF generation tool is selected.
+    case 'runtime':
+      $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
+      if (empty($print_pdf_pdf_tool)) {
+        $requirements['print_pdf_tool'] = array(
+          'title' => $t('Printer, email and PDF versions - PDF generation library'),
+          'value' => $t('No PDF tool selected'),
+          'description' => $t('Please configure it in the !url.', array('!url' => l($t('PDF settings page'), 'admin/config/user-interface/print/pdf'))),
+          'severity' => REQUIREMENT_ERROR,
+        );
+      }
+      else {
+        // Tool is defined, get some data from it's handler module.
+        $tool = explode('|', $print_pdf_pdf_tool);
+        $function = $tool[0] . '_pdf_tool_info';
+        $info = function_exists($function) ? $function() : array();
+
+        // Is the file there?
+        if (!is_file($tool[1]) || !is_readable($tool[1])) {
+          $requirements['print_pdf_tool'] = array(
+            'title' => $t('Printer, email and PDF versions - PDF generation library'),
+            'value' => $t('File not found'),
+            'description' => $t('The currently selected PDF generation library (%file) is no longer accessible.', array('%file' => $tool[1])),
+            'severity' => REQUIREMENT_ERROR,
+          );
+        }
+        else {
+          // Get the version number.
+          $function = $tool[0] . '_pdf_tool_version';
+          if (function_exists($function)) {
+            $version = $function($tool[1]);
+
+            if (isset($info['min_version']) && version_compare($version, $info['min_version'], '<')) {
+              $requirements['print_pdf_tool_version'] = array(
+                'title' => $t('Printer, email and PDF versions - PDF generation library'),
+                'value' => $t('Unsupported %lib version', array('%lib' => $info['name'])),
+                'description' => $t('The currently selected version of %lib (@version) is not supported. Please update to a !url.', array(
+                  '%lib' => $info['name'],
+                  '@version' => $version,
+                  '!url' => l($t('newer version'), $info['url']),
+                )),
+                'severity' => REQUIREMENT_ERROR,
+              );
+            }
+            else {
+              $requirements['print_pdf_tool_version'] = array(
+                'title' => $t('Printer, email and PDF versions - PDF generation library'),
+                'value' => $info['name'] . ' ' . $version,
+              );
+            }
+          }
+        }
+
+        // If auto-config is on, check for write access to the appropriate dirs.
+        if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {
+          $directories = array();
+          if (isset($info['public_dirs'])) {
+            foreach ($info['public_dirs'] as $dir) {
+              $directories[] = 'public://print_pdf/' . $tool[0] . '/' . $dir;
+            }
+          }
+          if (isset($info['tool_dirs'])) {
+            foreach ($info['tool_dirs'] as $dir) {
+              $directories[] = dirname($tool[1]) . '/' . $dir;
+            }
+          }
+
+          foreach ($directories as $dir) {
+            if (!is_dir($dir) || !is_writable($dir)) {
+              $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)),
+                'severity' => REQUIREMENT_ERROR,
+              );
+            }
+          }
+        }
+      }
+      break;
+  }
+  return $requirements;
+}
+
+/**
+ * Remove hardcoded numeric deltas from all blocks.
  */
 function print_pdf_update_7000(&$sandbox) {
   $renamed_deltas = array(
@@ -156,7 +245,7 @@ function print_pdf_update_7000(&$sandbox) {
 }
 
 /**
- * Delete old variables
+ * Delete old variables.
  */
 function print_pdf_update_7200(&$sandbox) {
   variable_del('print_pdf_settings');
@@ -166,13 +255,13 @@ function print_pdf_update_7200(&$sandbox) {
 }
 
 /**
- * Update pdf_tool variable to new module|path format
+ * Update pdf_tool variable to new module|path format.
  */
 function print_pdf_update_7201(&$sandbox) {
-  $tool =  explode('|', variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT));
+  $tool = explode('|', variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT));
 
   if (count($tool) == 1) {
-    // Not an array yet, update variable to new format
+    // Not an array yet, update variable to new format.
     if (preg_match('!dompdf_config.inc.php$!', $tool[0])) {
       $tool[0] = 'print_pdf_dompdf|' . $tool[0];
     }
@@ -191,7 +280,7 @@ function print_pdf_update_7201(&$sandbox) {
 }
 
 /**
- * Enable block and help area links
+ * Enable block and help area links.
  */
 function print_pdf_update_7202(&$sandbox) {
   $link_pos = variable_get('print_pdf_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
@@ -201,7 +290,7 @@ function print_pdf_update_7202(&$sandbox) {
 }
 
 /**
- * Add Size and Orientation fields for per content type Size and Orientation
+ * Add Size and Orientation fields for per content type Size and Orientation.
  */
 function print_pdf_update_7203(&$sandbox) {
   $spec = array(
@@ -219,11 +308,11 @@ function print_pdf_update_7203(&$sandbox) {
 }
 
 /**
- * Enable the PDF generation sub-module being used
+ * Enable the PDF generation sub-module being used.
  */
 function print_pdf_update_7204(&$sandbox) {
-  // Since update_7201 already has stored the correct module in the array, use that
-  $tool =  explode('|', variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT));
+  // Since update_7201 already stored the correct module in the array, use that.
+  $tool = explode('|', variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT));
 
   if (count($tool) == 2) {
     module_enable(array($tool[0]), FALSE);
@@ -231,11 +320,16 @@ function print_pdf_update_7204(&$sandbox) {
 }
 
 /**
- * Increase size of the path field in the print_pdf_page_counter table
+ * Increase size of the path field in the print_pdf_page_counter table.
  */
 function print_pdf_update_7205(&$sandbox) {
   db_drop_primary_key('print_pdf_page_counter');
   db_change_field('print_pdf_page_counter', 'path', 'path',
-    array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Page path'),
+    array(
+      'type' => 'varchar',
+      'length' => 255,
+      'not null' => TRUE,
+      'description' => 'Page path',
+    ),
     array('primary key' => array('path')));
 }

+ 102 - 144
sites/all/modules/contrib/admin/print/print_pdf/print_pdf.module

@@ -7,7 +7,7 @@
  * @ingroup print
  */
 
-define('PRINT_PDF_PDF_TOOL_DEFAULT', 0);
+define('PRINT_PDF_PDF_TOOL_DEFAULT', FALSE);
 define('PRINT_PDF_CONTENT_DISPOSITION_DEFAULT', 2);
 define('PRINT_PDF_PAPER_SIZE_DEFAULT', 'A4');
 define('PRINT_PDF_PAGE_ORIENTATION_DEFAULT', 'portrait');
@@ -15,7 +15,8 @@ define('PRINT_PDF_IMAGES_VIA_FILE_DEFAULT', 0);
 define('PRINT_PDF_AUTOCONFIG_DEFAULT', 1);
 define('PRINT_PDF_FILENAME_DEFAULT', '[site:name] - [node:title] - [node:changed:custom:Y-m-d]');
 define('PRINT_PDF_CACHE_ENABLED_DEFAULT', 0);
-define('PRINT_PDF_CACHE_LIFETIME_DEFAULT', 86400); // 1 day
+// 1 day.
+define('PRINT_PDF_CACHE_LIFETIME_DEFAULT', 86400);
 
 /**
  * Implements hook_print_link().
@@ -59,13 +60,12 @@ function print_pdf_init() {
     $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
     $tool = explode('|', $print_pdf_pdf_tool);
     $function = $tool[0] . '_pdf_tool_info';
-    if (function_exists($function)) {
-      $info = $function();
-    }
+    $info = function_exists($function) ? $function() : array();
 
     if (isset($info['public_dirs'])) {
       foreach ($info['public_dirs'] as $dir) {
         $directory = 'public://print_pdf/' . $tool[0] . '/' . $dir;
+        /** @var DrupalLocalStreamWrapper $wrapper */
         $wrapper = file_stream_wrapper_get_instance_by_uri($directory);
         $real_directory_path = $wrapper->getDirectoryPath() . "/" . file_uri_target($directory);
         $result = file_prepare_directory($real_directory_path, FILE_CREATE_DIRECTORY);
@@ -160,11 +160,12 @@ function print_pdf_block_info() {
  * Implements hook_block_view().
  */
 function print_pdf_block_view($delta = 0) {
+  $block = array();
   switch ($delta) {
     case 'print_pdf-top':
       $block['subject'] = t('Most PDFd');
       $result = db_query_range("SELECT path FROM {print_pdf_page_counter} LEFT JOIN {node} n ON path = CONCAT('node/', n.nid) WHERE status <> 0 OR status IS NULL ORDER BY totalcount DESC", 0, 3)
-                  ->fetchAll();
+        ->fetchAll();
       if (count($result)) {
         $items = array();
         foreach ($result as $obj) {
@@ -177,96 +178,6 @@ function print_pdf_block_view($delta = 0) {
   return $block;
 }
 
-/**
- * Implements hook_requirements().
- */
-function print_pdf_requirements($phase) {
-  $requirements = array();
-  $t = get_t();
-  switch ($phase) {
-    // At runtime, make sure that a PDF generation tool is selected
-    case 'runtime':
-      $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
-      if (empty($print_pdf_pdf_tool)) {
-        $requirements['print_pdf_tool'] = array(
-          'title' => $t('Printer, email and PDF versions - PDF generation library'),
-          'value' => $t('No PDF tool selected'),
-          'description' => $t('Please configure it in the !url.', array('!url' => l($t('PDF settings page'), 'admin/config/user-interface/print/pdf'))),
-          'severity' => REQUIREMENT_ERROR,
-        );
-      }
-      else {
-        // Tool is defined, get some data from it's handler module
-        $tool = explode('|', $print_pdf_pdf_tool);
-        $function = $tool[0] . '_pdf_tool_info';
-        if (function_exists($function)) {
-          $info = $function();
-        }
-
-        // Is the file there?
-        if (!is_file($tool[1]) || !is_readable($tool[1])) {
-          $requirements['print_pdf_tool'] = array(
-            'title' => $t('Printer, email and PDF versions - PDF generation library'),
-            'value' => $t('File not found'),
-            'description' => $t('The currently selected PDF generation library (%file) is no longer accessible.', array('%file' => $tool[1])),
-            'severity' => REQUIREMENT_ERROR,
-          );
-        }
-        else {
-          // Get the version number
-          $function = $tool[0] . '_pdf_tool_version';
-          if (function_exists($function)) {
-            $version = $function($tool[1]);
-
-            if (isset($info['min_version']) && version_compare($version, $info['min_version'], '<')) {
-              $requirements['print_pdf_tool_version'] = array(
-                'title' => $t('Printer, email and PDF versions - PDF generation library'),
-                'value' => $t('Unsupported %lib version', array('%lib' => $info['name'])),
-                'description' => $t('The currently selected version of %lib (@version) is not supported. Please update to a !url.',
-                                    array('%lib' => $info['name'], '@version' => $version, '!url' => l($t('newer version'), $info['url']))),
-                'severity' => REQUIREMENT_ERROR,
-              );
-            }
-            else {
-              $requirements['print_pdf_tool_version'] = array(
-                'title' => $t('Printer, email and PDF versions - PDF generation library'),
-                'value' => $info['name'] . ' ' . $version,
-              );
-            }
-          }
-        }
-
-        // If auto-config is on, check for write access to the appropriate dirs
-        if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {
-          $directories = array();
-          if (isset($info['public_dirs'])) {
-            foreach ($info['public_dirs'] as $dir) {
-              $directories[] = 'public://print_pdf/' . $tool[0] . '/' . $dir;
-            }
-          }
-          if (isset($info['tool_dirs'])) {
-            foreach ($info['tool_dirs'] as $dir) {
-              $directories[] = dirname($tool[1]) . '/' . $dir;
-            }
-          }
-
-          foreach ($directories as $dir) {
-            if (!is_dir($dir) || !is_writable($dir)) {
-              $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)),
-                'severity' => REQUIREMENT_ERROR,
-              );
-            }
-          }
-        }
-      }
-      break;
-  }
-  return $requirements;
-}
-
 /**
  * Implements hook_node_load().
  */
@@ -293,7 +204,7 @@ function print_pdf_node_load($nodes, $types) {
  * Implements hook_node_insert().
  */
 function print_pdf_node_insert($node) {
-  return print_pdf_node_update($node);
+  print_pdf_node_update($node);
 }
 
 /**
@@ -306,8 +217,12 @@ function print_pdf_node_update($node) {
     $size = 'print_' . $link['format'] . '_size';
     $orientation = 'print_' . $link['format'] . '_orientation';
 
-    if (!isset($node->{$size})) $node->{$size} = variable_get($size . '_' . $node->type);
-    if (!isset($node->{$orientation})) $node->{$orientation} = variable_get($orientation . '_' . $node->type);
+    if (!isset($node->{$size})) {
+      $node->{$size} = variable_get($size . '_' . $node->type);
+    }
+    if (!isset($node->{$orientation})) {
+      $node->{$orientation} = variable_get($orientation . '_' . $node->type);
+    }
 
     db_merge('print_pdf_node_conf')
       ->key(array('nid' => $node->nid))
@@ -336,7 +251,7 @@ function print_pdf_node_delete($node) {
  * Implements hook_form_alter().
  */
 function print_pdf_form_alter(&$form, &$form_state, $form_id) {
-  // Add the node-type settings option to activate the printer-friendly version link
+  // Add the node-type settings to activate the printer-friendly version link.
   if ((user_access('administer print') || user_access('node-specific print configuration')) &&
       (($form_id == 'node_type_form') || !empty($form['#node_edit_form']))) {
     $link = print_pdf_print_link();
@@ -354,7 +269,11 @@ function print_pdf_form_alter(&$form, &$form_state, $form_id) {
     $form['print']['print_' . $link['format']][$orientation] = array(
       '#type' => 'select',
       '#title' => t('Page orientation'),
-      '#options' => array('' => 'Unchanged', 'portrait' => t('Portrait'), 'landscape' => t('Landscape')),
+      '#options' => array(
+        '' => 'Unchanged',
+        'portrait' => t('Portrait'),
+        'landscape' => t('Landscape'),
+      ),
       '#description' => t('Choose the page orientation of the generated PDF.'),
     );
 
@@ -371,18 +290,18 @@ function print_pdf_form_alter(&$form, &$form_state, $form_id) {
 }
 
 /**
- * Auxiliary function to display a formatted PDF version link
+ * Auxiliary function to display a formatted PDF version link.
  *
  * Function made available so that developers may call this function from
  * their defined pages/blocks.
  *
  * @param string $path
- *   path to be used in the link. If not specified, the current URL is used.
+ *   Path to be used in the link. If not specified, the current URL is used.
  * @param object $node
- *   node object, to be used in checking node access. If the path argument is
+ *   Node object, to be used in checking node access. If the path argument is
  *   not provided, the path used will be node/nid.
  * @param string $location
- *   where in the page where the link is being inserted ('link', 'corner',
+ *   Where in the page where the link is being inserted ('link', 'corner',
  *   'block', 'help').
  *
  * @return bool
@@ -392,7 +311,11 @@ function print_pdf_form_alter(&$form, &$form_state, $form_id) {
  */
 function print_pdf_insert_link($path = NULL, $node = NULL, $location = '') {
   if (function_exists('print_ui_insert_link')) {
-    return print_ui_insert_link(print_pdf_print_link(), array('path' => $path, 'node' => $node, 'location' => $location));
+    return print_ui_insert_link(print_pdf_print_link(), array(
+      'path' => $path,
+      'node' => $node,
+      'location' => $location,
+    ));
   }
   else {
     return FALSE;
@@ -400,11 +323,11 @@ function print_pdf_insert_link($path = NULL, $node = NULL, $location = '') {
 }
 
 /**
- * Check if the link to the PDF version is allowed depending on the settings
+ * Check if the link to the PDF version is allowed depending on the settings.
  *
  * @param array $args
- *   array containing the possible parameters:
- *    view_mode, node, type, path
+ *   Array containing the possible parameters:
+ *    view_mode, node, type, path.
  *
  * @return bool
  *   FALSE if not allowed, TRUE otherwise
@@ -431,11 +354,11 @@ function print_pdf_cache_clean() {
   if ($lifetime > 0) {
     $files = file_scan_directory(print_pdf_cache_dir(), '!\d+\.pdf$!');
     foreach ($files as $file) {
-      // For all files in the cache directory, see when they were last accessed
+      // For all files in the cache directory, see when they were last accessed.
       $result = db_query("SELECT timestamp FROM {print_pdf_page_counter} WHERE path = :path", array(':path' => 'node/' . $file->name))
-                  ->fetchField();
+        ->fetchField();
 
-      // Keep the file only if the last access was within the cache max life value
+      // Keep the file only if last access was within the cache max life value.
       if (($result === FALSE) || ($result + $lifetime < REQUEST_TIME)) {
         print_pdf_cache_delete($file->name);
       }
@@ -450,17 +373,18 @@ function print_pdf_cache_clean() {
  *   The scheme://path of the cache directory
  */
 function print_pdf_cache_dir() {
+  global $language_url;
   $scheme = 'private';
   if (!file_stream_wrapper_valid_scheme($scheme)) {
     $scheme = 'temporary';
   }
-  return $scheme . '://print_pdf/cache';
+  return $scheme . '://print_pdf/cache/' . $language_url->language;
 }
 
 /**
  * Deletes one or more files from the PDF cache directory.
  *
- * @param int nid
+ * @param int $nid
  *   The node ID of the page for which the cached PDF should be deleted.
  *   If not provided, the entire cache directory will be deleted.
  */
@@ -485,9 +409,9 @@ function print_pdf_cache_delete($nid = NULL) {
  * Displays the PDF as inline or a downloadable file.
  *
  * @param string $pdf
- *   PDF content string
+ *   PDF content string.
  * @param string $filename
- *   Filename of the generated PDF
+ *   Filename of the generated PDF.
  *
  * @return string
  *   The disposed PDF file
@@ -500,7 +424,7 @@ function print_pdf_dispose_content($pdf, $filename) {
   header('Content-Type: application/pdf');
 
   $content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT);
-  $attachment =  ($content_disposition == 2) ?  'attachment' :  'inline';
+  $attachment = ($content_disposition == 2) ? 'attachment' : 'inline';
 
   header("Content-Disposition: $attachment; filename=\"$filename\"");
 
@@ -514,21 +438,21 @@ function print_pdf_dispose_content($pdf, $filename) {
  * Generate a PDF version of the provided HTML.
  *
  * @param string $html
- *   HTML content of the PDF
+ *   HTML content of the PDF.
  * @param array $meta
  *   Meta information to be used in the PDF
  *   - url: original URL
  *   - name: author's name
  *   - title: Page title
- *   - node: node object
+ *   - node: node object.
  * @param string $filename
- *   (optional) Filename of the generated PDF
+ *   (optional) Filename of the generated PDF.
  * @param string $paper_size
- *   (optional) Paper size of the generated PDF
+ *   (optional) Paper size of the generated PDF.
  * @param string $page_orientation
- *   (optional) Page orientation of the generated PDF
+ *   (optional) Page orientation of the generated PDF.
  *
- * @return
+ * @return string|null
  *   generated PDF page, or NULL in case of error
  *
  * @see print_pdf_controller()
@@ -541,9 +465,7 @@ function print_pdf_generate_html($html, $meta, $filename = NULL, $paper_size = N
   module_load_include('inc', $pdf_tool[0], $pdf_tool[0] . '.pages');
 
   $function = $pdf_tool[0] . '_print_pdf_generate';
-  if (function_exists($function)) {
-    $pdf = $function($html, $meta, $paper_size, $page_orientation);
-  }
+  $pdf = function_exists($function) ? $function($html, $meta, $paper_size, $page_orientation) : NULL;
   if ($filename) {
     return print_pdf_dispose_content($pdf, $filename);
   }
@@ -562,31 +484,67 @@ function print_pdf_views_api() {
 }
 
 /**
- * Lists all possible paper sizes
+ * Lists all possible paper sizes.
  *
- * @return
+ * @param bool $include_default
+ *   Flag indicating whether to include the tool's default value.
+ *
+ * @return array
  *   array of strings with the available paper sizes
  */
 function _print_pdf_paper_sizes($include_default = FALSE) {
-  $ret = array();
-
   $ret = ($include_default) ? array('' => 'Unchanged') : array();
 
   $ret += array(
-    '4A0' => '4A0', '2A0' => '2A0', 'A0' => 'A0',
-    'A1' => 'A1', 'A2' => 'A2', 'A3' => 'A3', 'A4' => 'A4',
-    'A5' => 'A5', 'A6' => 'A6', 'A7' => 'A7', 'A8' => 'A8',
-    'A9' => 'A9', 'A10' => 'A10', 'B0' => 'B0', 'B1' => 'B1',
-    'B2' => 'B2', 'B3' => 'B3', 'B4' => 'B4', 'B5' => 'B5',
-    'B6' => 'B6', 'B7' => 'B7', 'B8' => 'B8', 'B9' => 'B9',
-    'B10' => 'B10', 'C0' => 'C0', 'C1' => 'C1', 'C2' => 'C2',
-    'C3' => 'C3', 'C4' => 'C4', 'C5' => 'C5', 'C6' => 'C6',
-    'C7' => 'C7', 'C8' => 'C8', 'C9' => 'C9', 'C10' => 'C10',
-    'RA0' => 'RA0', 'RA1' => 'RA1', 'RA2' => 'RA2',
-    'RA3' => 'RA3', 'RA4' => 'RA4', 'SRA0' => 'SRA0',
-    'SRA1' => 'SRA1', 'SRA2' => 'SRA2', 'SRA3' => 'SRA3',
-    'SRA4' => 'SRA4', 'LETTER' => 'Letter', 'LEGAL' => 'Legal',
-    'EXECUTIVE' => 'Executive', 'FOLIO' => 'Folio',
+    '4A0' => '4A0',
+    '2A0' => '2A0',
+    'A0' => 'A0',
+    'A1' => 'A1',
+    'A2' => 'A2',
+    'A3' => 'A3',
+    'A4' => 'A4',
+    'A5' => 'A5',
+    'A6' => 'A6',
+    'A7' => 'A7',
+    'A8' => 'A8',
+    'A9' => 'A9',
+    'A10' => 'A10',
+    'B0' => 'B0',
+    'B1' => 'B1',
+    'B2' => 'B2',
+    'B3' => 'B3',
+    'B4' => 'B4',
+    'B5' => 'B5',
+    'B6' => 'B6',
+    'B7' => 'B7',
+    'B8' => 'B8',
+    'B9' => 'B9',
+    'B10' => 'B10',
+    'C0' => 'C0',
+    'C1' => 'C1',
+    'C2' => 'C2',
+    'C3' => 'C3',
+    'C4' => 'C4',
+    'C5' => 'C5',
+    'C6' => 'C6',
+    'C7' => 'C7',
+    'C8' => 'C8',
+    'C9' => 'C9',
+    'C10' => 'C10',
+    'RA0' => 'RA0',
+    'RA1' => 'RA1',
+    'RA2' => 'RA2',
+    'RA3' => 'RA3',
+    'RA4' => 'RA4',
+    'SRA0' => 'SRA0',
+    'SRA1' => 'SRA1',
+    'SRA2' => 'SRA2',
+    'SRA3' => 'SRA3',
+    'SRA4' => 'SRA4',
+    'LETTER' => 'Letter',
+    'LEGAL' => 'Legal',
+    'EXECUTIVE' => 'Executive',
+    'FOLIO' => 'Folio',
   );
 
   return $ret;

+ 45 - 37
sites/all/modules/contrib/admin/print/print_pdf/print_pdf.pages.inc

@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Generates the PDF versions of the pages
+ * Generates the PDF versions of the pages.
  *
  * This file is included by the print_pdf module and includes the
  * functions that interface with the PDF generation packages.
@@ -13,32 +13,34 @@
 module_load_include('inc', 'print', 'print.pages');
 
 /**
- * Generate a PDF version of the printer-friendly page
+ * Generate a PDF version of the printer-friendly page.
  *
  * @see print_controller()
  * @see _print_pdf_dompdf()
  * @see _print_pdf_tcpdf()
  */
 function print_pdf_controller() {
-  // Disable caching for generated PDFs, as Drupal doesn't ouput the proper headers from the cache
+  // Disable caching for generated PDFs, as Drupal doesn't output the proper
+  // headers from the cache.
   $GLOBALS['conf']['cache'] = FALSE;
 
   $args = func_get_args();
   $path = filter_xss(implode('/', $args));
-  $cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
+  $cid = isset($_GET['comment']) ? (int) $_GET['comment'] : NULL;
 
-  // Handle the query
+  // Handle the query.
   $query = $_GET;
   unset($query['q']);
 
+  $node = NULL;
   if (!empty($path)) {
     if ($alias = drupal_lookup_path('source', $path)) {
-      // Alias
+      // Alias.
       $path_arr = explode('/', $alias);
       $node = node_load($path_arr[1]);
     }
     elseif (ctype_digit($args[0])) {
-      // normal nid
+      // Normal nid.
       $node = node_load($args[0]);
     }
 
@@ -49,7 +51,7 @@ function print_pdf_controller() {
     else {
       $pdf_filename = token_replace($pdf_filename, array('site'), array('clear' => TRUE));
       if (empty($pdf_filename)) {
-        // If empty, use a fallback solution
+        // If empty, use a fallback solution.
         $pdf_filename = str_replace('/', '_', $path);
       }
     }
@@ -72,10 +74,10 @@ function print_pdf_controller() {
 
   $nodepath = (isset($node->nid)) ? 'node/' . $node->nid : drupal_get_normal_path($path);
   db_merge('print_pdf_page_counter')
-    ->key(array('path' => $nodepath))
+    ->key(array('path' => substr($nodepath, 0, 255)))
     ->fields(array(
-        'totalcount' => 1,
-        'timestamp' => REQUEST_TIME,
+      'totalcount' => 1,
+      'timestamp' => REQUEST_TIME,
     ))
     ->expression('totalcount', 'totalcount + 1')
     ->execute();
@@ -87,18 +89,18 @@ function print_pdf_controller() {
  * Gennerate a PDF for a given Drupal path.
  *
  * @param string $path
- *   path of the page to convert to PDF
+ *   path of the page to convert to PDF.
  * @param array $query
- *   (optional) array of key/value pairs as used in the url() function for the
- *   query
+ *   (Optional) array of key/value pairs as used in the url() function for the
+ *   query.
  * @param int $cid
- *   (optional) comment ID of the comment to render.
+ *   (Optional) comment ID of the comment to render.
  * @param string $pdf_filename
- *   (optional) filename of the generated PDF
+ *   (Optional) filename of the generated PDF.
  * @param string $view_mode
- *   (optional) view mode to be used when rendering the content
+ *   (Optional) view mode to be used when rendering the content.
  *
- * @return
+ * @return string|null
  *   generated PDF page, or NULL in case of error
  *
  * @see print_pdf_controller()
@@ -109,48 +111,56 @@ function print_pdf_generate_path($path, $query = NULL, $cid = NULL, $pdf_filenam
   $link = print_pdf_print_link();
   $node = print_controller($path, $link['format'], $cid, $view_mode);
   if ($node) {
-    // Call the current tool's hook_pdf_tool_info(), to see if we need to expand CSS
+    // Call the tool's hook_pdf_tool_info(), to see if CSS must be expanded.
     $pdf_tool = explode('|', variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT));
     $cache_enabled = variable_get('print_pdf_cache_enabled', PRINT_PDF_CACHE_ENABLED_DEFAULT);
 
     $function = $pdf_tool[0] . '_pdf_tool_info';
-    if (function_exists($function)) {
-      $info = $function();
-    }
+    $info = function_exists($function) ? $function() : array();
     $expand = isset($info['expand_css']) ? $info['expand_css'] : FALSE;
 
-    $html = theme('print', array('node' => $node, 'query' => $query, $expand, 'format' => $link['format']));
+    $html = theme('print', array(
+      'node' => $node,
+      'query' => $query,
+      'expand_css' => $expand,
+      'format' => $link['format'],
+    ));
 
-    // Img elements must be set to absolute
+    // Img elements must be set to absolute.
     $pattern = '!<(img\s[^>]*?)>!is';
     $html = preg_replace_callback($pattern, '_print_rewrite_urls', $html);
 
-    // Convert the a href elements, to make sure no relative links remain
+    // Convert the a href elements, to make sure no relative links remain.
     $pattern = '!<(a\s[^>]*?)>!is';
     $html = preg_replace_callback($pattern, '_print_rewrite_urls', $html);
-    // And make anchor links relative again, to permit in-PDF navigation
+    // And make anchor links relative again, to permit in-PDF navigation.
     $html = preg_replace("!${base_url}/" . $link['path'] . '/.*?#!', '#', $html);
 
     $meta = array(
       'node' => $node,
       'url' => url(drupal_get_path_alias(empty($node->nid) ? $node->path : "node/$node->nid"), array('absolute' => TRUE)),
     );
-    if (isset($node->name)) $meta['name'] = $node->name;
-    if (isset($node->title)) $meta['title'] = $node->title;
+    if (isset($node->name)) {
+      $meta['name'] = $node->name;
+    }
+    if (isset($node->title)) {
+      $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;
 
     $pdf = '';
     $cachemiss = FALSE;
+    $cachefile = '';
     if ($cache_enabled && isset($node->nid)) {
-      // See if the file exists in the cache
+      // See if the file exists in the cache.
       $cachefile = drupal_realpath(print_pdf_cache_dir()) . '/' . $node->nid . '.pdf';
       if (is_readable($cachefile)) {
-        // Get the PDF content from the cached file
+        // Get the PDF content from the cached file.
         $pdf = file_get_contents($cachefile);
         if ($pdf === FALSE) {
-          watchdog('print_pdf', 'Failed to read from cached file %file', array('%file' => $cached), WATCHDOG_ERROR);
+          watchdog('print_pdf', 'Failed to read from cached file %file', array('%file' => $cachefile), WATCHDOG_ERROR);
         }
       }
       else {
@@ -158,23 +168,21 @@ function print_pdf_generate_path($path, $query = NULL, $cid = NULL, $pdf_filenam
       }
     }
 
-    // If cache is off or file is not cached, generate one from scratch
+    // If cache is off or file is not cached, generate one from scratch.
     if (empty($pdf)) {
       $pdf = print_pdf_generate_html($html, $meta, NULL, $paper_size, $page_orientation);
     }
 
     if (!empty($pdf)) {
-      // A PDF was created, save it to cache if configured
+      // A PDF was created, save it to cache if configured.
       if ($cachemiss) {
         if (file_unmanaged_save_data($pdf, $cachefile, FILE_EXISTS_REPLACE) == FALSE) {
-          watchdog('print_pdf', 'Failed to write to "%f".', array('%f' => $filename), WATCHDOG_ERROR);
+          watchdog('print_pdf', 'Failed to write to "%f".', array('%f' => $cachefile), WATCHDOG_ERROR);
         }
       }
 
       return $pdf_filename ? print_pdf_dispose_content($pdf, $pdf_filename) : $pdf;
     }
   }
-  else {
-    return NULL;
-  }
+  return NULL;
 }

+ 3 - 6
sites/all/modules/contrib/admin/print/print_pdf/print_pdf.views.inc

@@ -2,7 +2,7 @@
 
 /**
  * @file
- * PDF Version Views integration
+ * PDF Version Views integration.
  *
  * @ingroup print
  */
@@ -25,18 +25,16 @@ function print_pdf_views_data() {
     // 'field' is the foreign key in this table.
     'left_field' => 'nid',
     'field' => 'nid',
-//    'type' => 'INNER',
   );
   $data['print_pdf_page_counter']['table']['join']['node'] = array(
     // 'left_field' is the primary key in the referenced table.
     // 'field' is the foreign key in this table.
     'left_field' => 'nid',
     'field' => 'path',
-//    'type' => 'INNER',
     'handler' => 'print_join_page_counter',
   );
 
-  // print_pdf_node_conf fields
+  // print_pdf_node_conf fields.
   $data['print_pdf_node_conf']['link'] = array(
     'title' => t('PDF: Show link'),
     'help' => t('Whether to show the PDF version link.'),
@@ -114,8 +112,7 @@ function print_pdf_views_data() {
     ),
   );
 
-
-  // print_pdf_page_counter fields
+  // print_pdf_page_counter fields.
   $data['print_pdf_page_counter']['totalcount'] = array(
     'title' => t('PDF: Number of page accesses'),
     'help' => t('Counter of accesses to the PDF version for this node.'),

+ 4 - 1
sites/all/modules/contrib/admin/print/print_ui/css/print_ui.theme-rtl.css

@@ -7,7 +7,10 @@
   */
 }
 
-.print_html, .print_mail, .print_pdf, .print_epub {
+.print_html,
+.print_mail,
+.print_pdf,
+.print_epub {
   margin-left: 0;
   margin-right: 1em;
 }

+ 4 - 1
sites/all/modules/contrib/admin/print/print_ui/css/print_ui.theme.css

@@ -15,7 +15,10 @@ div#block-print-ui-print-links span {
   display: block;
 }
 
-.print_html, .print_mail, .print_pdf, .print_epub {
+.print_html,
+.print_mail,
+.print_pdf,
+.print_epub {
   margin-left: 1em;
 }
 

File diff suppressed because it is too large
+ 6 - 1
sites/all/modules/contrib/admin/print/print_ui/print_ui.admin.inc


+ 6 - 11
sites/all/modules/contrib/admin/print/print_ui/print_ui.api.php

@@ -76,23 +76,18 @@ function hook_link_allowed($args) {
 }
 
 /**
- * Checks if the link is allowed according to the appropriate sub-module.
+ * Allows the user to change the new window behaviour.
  *
- * Normally checks if the user holds the required access permission, but can
- * be used for extra checks, such as the proper module configuration, etc.
- *
- * @param array $args
- *   An associative array containing:
- *   - path: path to the non-node page being displayed.
- *   - node: path to the node beign displayed.
- *   - view_mode: current view mode of the node being displayed.
- *   - type: 'node' or 'comment'.
+ * @param string $new_window
+ *   New window status.
+ * @param string $format
+ *   Format being processed.
  *
  * @ingroup print_hooks
  */
 function hook_print_new_window_alter(&$new_window, $format) {
   if ($format == 'foo') {
-    $new_window = variable_get('print_foo_new_windo',  FALSE);
+    $new_window = variable_get('print_foo_new_window', FALSE);
   }
 }
 

+ 3 - 4
sites/all/modules/contrib/admin/print/print_ui/print_ui.info

@@ -5,9 +5,8 @@ package = "Printer, email and PDF versions"
 dependencies[] = print
 configure = admin/config/user-interface/print/ui
 
-; Information added by Drupal.org packaging script on 2014-04-02
-version = "7.x-2.0"
+; Information added by Drupal.org packaging script on 2018-10-05
+version = "7.x-2.2"
 core = "7.x"
 project = "print"
-datestamp = "1396426766"
-
+datestamp = "1538760185"

+ 1 - 1
sites/all/modules/contrib/admin/print/print_ui/print_ui.install

@@ -11,7 +11,7 @@
  * Implements hook_enable().
  */
 function print_ui_enable() {
-  // Module weight
+  // Module weight.
   db_update('system')
     ->fields(array(
       'weight' => 1,

+ 88 - 51
sites/all/modules/contrib/admin/print/print_ui/print_ui.module

@@ -91,9 +91,9 @@ function print_ui_block_view($delta = '') {
       if (ctype_digit($nid)) {
         $node = node_load($nid);
         if (!node_access('view', $node)) {
-          // If the user doesn't have access to the node, don't show any links
+          // If the user doesn't have access to the node, don't show any links.
           $block['content'] = '';
-          return;
+          return array();
         }
       }
       else {
@@ -150,6 +150,7 @@ function print_ui_help($path, $arg) {
       }
     }
   }
+  return '';
 }
 
 /**
@@ -166,10 +167,12 @@ function print_ui_node_view_alter(&$build) {
       if (!empty($link_pos['link'])) {
         $format = theme('print_ui_format_link', array('format' => 'html', 'location' => 'link'));
 
+        $path = '';
         switch ($book_link) {
           case 1:
             $path = $build['links']['book']['#links']['book_printer']['href'];
             break;
+
           case 2:
             $link_use_alias = variable_get('print_html_link_use_alias', PRINT_UI_LINK_USE_ALIAS_DEFAULT);
             $path = ($link_use_alias && ($alias = drupal_lookup_path('alias', 'node/' . $build['#node']->nid))) ? $alias : $build['#node']->nid;
@@ -205,23 +208,27 @@ function print_ui_node_view($node, $view_mode) {
       $link_use_alias = variable_get('print_' . $link['format'] . '_link_use_alias', PRINT_UI_LINK_USE_ALIAS_DEFAULT);
 
       if (!preg_match('!^node/[\d]*/revisions/[\d]*/view$!', $_GET['q'])) {
-        // Not a revision, use node->nid to build the path
+        // Not a revision, use node->nid to build the path.
         $path = (($link_use_alias) && ($alias = drupal_lookup_path('alias', 'node/' . $node->nid))) ? $alias : $node->nid;
       }
       else {
-        // This is a node revision, replace only the node component
+        // This is a node revision, replace only the node component.
         $path = preg_replace('!^node/!', '', $_GET['q']);
       }
       $path = $link['path'] . '/' . $path;
 
       foreach (array('node', 'comment') as $type) {
-        $allowed_type = print_ui_link_allowed($link, array('type' => $type, 'node' => $node, 'view_mode' => $view_mode));
+        $allowed_type = print_ui_link_allowed($link, array(
+          'type' => $type,
+          'node' => $node,
+          'view_mode' => $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'));
 
-          // Show book link
+          // Show book link.
           if ($allowed_type === PRINT_UI_ALLOW_BOOK_LINK) {
             $path = $link['path'] . '/book/export/html/' . $node->nid;
 
@@ -238,7 +245,7 @@ function print_ui_node_view($node, $view_mode) {
               'title' => $format['text'],
               'attributes' => $format['attributes'],
               'html' => $format['html'],
-              'query' =>  _print_ui_query_string_encode($_GET, array('q')),
+              'query' => _print_ui_query_string_encode($_GET, array('q')),
             );
           }
 
@@ -248,7 +255,8 @@ function print_ui_node_view($node, $view_mode) {
             '#attributes' => array('class' => array('links', 'inline')),
           );
 
-          // If it's a node, and configured to show the link, but it's not the html version of a book then show it
+          // If it's a node, and configured to show the link, but it's not the
+          // html version of a book then show it.
           if (($type == 'node') && !empty($link_pos['link']) && !(isset($node->book) && ($link['format'] == 'html'))) {
             $node->content['links']['print_' . $link['format']] = $link_content;
           }
@@ -264,13 +272,17 @@ function print_ui_node_view($node, $view_mode) {
       }
 
       if (!empty($link_pos['corner'])) {
-        $corner_markup .= print_ui_insert_link($link, array('node' => $node, 'path' => $path, 'location' => 'corner'));
+        $corner_markup .= print_ui_insert_link($link, array(
+          'node' => $node,
+          'path' => $path,
+          'location' => 'corner',
+        ));
       }
     }
   }
 
   if (($view_mode == 'full') && (!empty($corner_markup))) {
-    // Insert content corner links
+    // Insert content corner links.
     $node->content['print_links'] = array(
       '#prefix' => '<span class="print-link">',
       '#markup' => $corner_markup,
@@ -296,7 +308,7 @@ function print_ui_node_load($nodes, $types) {
 
       $display = 'print_' . $link['format'] . '_display';
       $display_comment = 'print_' . $link['format'] . '_display_comment';
-      $display_urllist =  'print_' . $link['format'] . '_display_urllist';
+      $display_urllist = 'print_' . $link['format'] . '_display_urllist';
 
       $result = db_query('SELECT nid, link, comments, url_list FROM {' . $module . '_node_conf} WHERE nid IN (:nids)', array(':nids' => $ids))->fetchAllAssoc('nid');
 
@@ -313,7 +325,7 @@ function print_ui_node_load($nodes, $types) {
  * Implements hook_node_insert().
  */
 function print_ui_node_insert($node) {
-  return print_ui_node_update($node);
+  print_ui_node_update($node);
 }
 
 /**
@@ -328,7 +340,7 @@ function print_ui_node_update($node) {
 
         $display = 'print_' . $link['format'] . '_display';
         $display_comment = 'print_' . $link['format'] . '_display_comment';
-        $display_urllist =  'print_' . $link['format'] . '_display_urllist';
+        $display_urllist = 'print_' . $link['format'] . '_display_urllist';
 
         if (!isset($node->{$display}) || $node->{$display} === NULL) {
           $node->{$display} = variable_get($display . '_' . $node->type, PRINT_UI_TYPE_SHOW_LINK_DEFAULT);
@@ -360,7 +372,7 @@ function print_ui_node_delete($node) {
   foreach (module_implements('print_link') as $module) {
     $function = $module . '_print_link';
     if (function_exists($function)) {
-      $link = call_user_func_array($function, array());
+      call_user_func_array($function, array());
 
       db_delete($module . '_node_conf')
         ->condition('nid', $node->nid)
@@ -373,7 +385,8 @@ function print_ui_node_delete($node) {
  * Implements hook_form_alter().
  */
 function print_ui_form_alter(&$form, &$form_state, $form_id) {
-  // Add the node-type settings option to activate the printer-friendly version link
+  // Add the node-type settings option to activate the printer-friendly
+  // version link.
   if ((user_access('administer print') || user_access('node-specific print configuration')) &&
       (($form_id == 'node_type_form') || !empty($form['#node_edit_form']))) {
     $form['print'] = array(
@@ -398,7 +411,7 @@ function print_ui_form_alter(&$form, &$form_state, $form_id) {
 
         $display = 'print_' . $link['format'] . '_display';
         $display_comment = 'print_' . $link['format'] . '_display_comment';
-        $display_urllist =  'print_' . $link['format'] . '_display_urllist';
+        $display_urllist = 'print_' . $link['format'] . '_display_urllist';
 
         $form['print']['print_' . $link['format']][$display] = array(
           '#type' => 'checkbox',
@@ -430,14 +443,14 @@ function print_ui_form_alter(&$form, &$form_state, $form_id) {
 }
 
 /**
- * Auxiliary function to fill the Printer-friendly link attributes
+ * Auxiliary function to fill the Printer-friendly link attributes.
  *
  * @param string $title
- *   text to displayed by the link when hovering over it with the mouse
+ *   Text to displayed by the link when hovering over it with the mouse.
  * @param string $class
- *   class attribute to be used in the link
+ *   Class attribute to be used in the link.
  * @param bool $new_window
- *   if TRUE opens the target page in a new window
+ *   If TRUE opens the target page in a new window.
  *
  * @return array
  *   An associative array containing:
@@ -460,12 +473,13 @@ function _print_ui_fill_attributes($title = '', $class = '', $new_window = FALSE
 
   if ($new_window) {
     switch ($print_newwindow) {
-    case 0:
-      $attributes['target'] = '_blank';
-      break;
-    case 1:
-      $attributes['onclick'] = 'window.open(this.href); return false';
-      break;
+      case 0:
+        $attributes['target'] = '_blank';
+        break;
+
+      case 1:
+        $attributes['onclick'] = 'window.open(this.href); return false';
+        break;
     }
   }
   if (!empty($print_robots_noindex)) {
@@ -475,7 +489,7 @@ function _print_ui_fill_attributes($title = '', $class = '', $new_window = FALSE
 }
 
 /**
- * Format the Printer-friendly link
+ * Format the Printer-friendly link.
  *
  * @return array
  *   An associative array containing:
@@ -508,14 +522,30 @@ function theme_print_ui_format_link($vars) {
         $show_link = variable_get('print_' . $link['format'] . '_show_link', PRINT_UI_SHOW_LINK_DEFAULT);
         $link_text = filter_xss(variable_get('print_' . $link['format'] . '_link_text', $link['text']));
 
+        $text = '';
         if ($show_link >= 2) {
           $img = drupal_get_path('module', $module) . '/icons/' . $link['icon'];
           switch ($show_link) {
             case 2:
-              $text = theme('image', array('path' => $img, 'width' => '16px', 'height' => '16px', 'alt' => $link_text, 'title' => $link_text, 'attributes' => array('class' => array('print-icon'))));
+              $text = theme('image', array(
+                'path' => $img,
+                'width' => '16px',
+                'height' => '16px',
+                'alt' => $link_text,
+                'title' => $link_text,
+                'attributes' => array('class' => array('print-icon')),
+              ));
               break;
+
             case 3:
-              $text = theme('image', array('path' => $img, 'width' => '16px', 'height' => '16px', 'alt' => $link_text, 'title' => $link_text, 'attributes' => array('class' => array('print-icon', 'print-icon-margin')))) . $link_text;
+              $text = theme('image', array(
+                'path' => $img,
+                'width' => '16px',
+                'height' => '16px',
+                'alt' => $link_text,
+                'title' => $link_text,
+                'attributes' => array('class' => array('print-icon', 'print-icon-margin')),
+              )) . $link_text;
               break;
           }
           $html = TRUE;
@@ -533,16 +563,17 @@ function theme_print_ui_format_link($vars) {
       }
     }
   }
+  return array();
 }
 
 /**
- * Auxiliary function to display a formatted Printer-friendly link
+ * Auxiliary function to display a formatted Printer-friendly link.
  *
  * Function made available so that developers may call this function from
  * 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
@@ -599,7 +630,12 @@ function print_ui_insert_link($link, $args = array()) {
     }
     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));
-    return '<span class="print_' . $link['format'] . '">' . l($format['text'], $path, array('attributes' => $format['attributes'], 'query' => $query, 'absolute' => TRUE, 'html' => $format['html'])) . '</span>';
+    return '<span class="print_' . $link['format'] . '">' . l($format['text'], $path, array(
+      'attributes' => $format['attributes'],
+      'query' => $query,
+      'absolute' => TRUE,
+      'html' => $format['html'],
+    )) . '</span>';
   }
   else {
     return FALSE;
@@ -607,15 +643,15 @@ function print_ui_insert_link($link, $args = array()) {
 }
 
 /**
- * Check if the link to the PF version is allowed depending on the settings
+ * Check if the link to the PF version is allowed depending on the settings.
  *
  * @param array $link
- *    array returned by the hook_print_link() call.
+ *   Array returned by the hook_print_link() call.
  * @param array $args
- *   array containing the possible parameters:
- *    view_mode, node, type, path
+ *   Array containing the possible parameters:
+ *    view_mode, node, type, path.
  *
- * @return
+ * @return int
  *   FALSE if not allowed
  *   PRINT_UI_ALLOW_NORMAL_LINK if a normal link is allowed
  *   PRINT_UI_ALLOW_BOOK_LINK if a link is allowed in a book node
@@ -625,14 +661,14 @@ function print_ui_link_allowed($link, $args) {
     $view_mode = $args['view_mode'];
     if ((($view_mode == 'teaser') && !variable_get('print_' . $link['format'] . '_link_teaser', PRINT_UI_LINK_TEASER_DEFAULT))
       || !in_array($view_mode, array('full', 'teaser'))) {
-      // If the teaser link is disabled
+      // If the teaser link is disabled.
       return FALSE;
     }
   }
   $link_allowed_func = $link['module'] . '_link_allowed';
   if (function_exists($link_allowed_func)) {
     if (!$link_allowed_func($args)) {
-      // If the format-specific function disallows the link
+      // If the format-specific function disallows the link.
       return FALSE;
     }
   }
@@ -649,7 +685,7 @@ function print_ui_link_allowed($link, $args) {
     if (isset($node->type)) {
       $node_type = $node->type;
     }
-    // Node
+    // Node.
     if (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
       // Link is for a comment, return the configured setting
       // Cache this statically to avoid duplicate queries for every comment.
@@ -663,14 +699,14 @@ function print_ui_link_allowed($link, $args) {
       }
     }
     else {
-      // Node link
+      // Node link.
       $display = 'print_' . $link['format'] . '_display';
       if (isset($node->{$display}) && !$node->{$display}) {
-        // Link for this node is disabled
+        // Link for this node is disabled.
         return FALSE;
       }
       elseif (isset($node->book)) {
-        // Node is a book;
+        // Node is a book.
         $book_link = variable_get('print_' . $link['format'] . '_book_link', PRINT_UI_BOOK_LINK_DEFAULT);
         switch ($book_link) {
           case 1:
@@ -678,6 +714,7 @@ function print_ui_link_allowed($link, $args) {
               return PRINT_UI_ALLOW_BOOK_LINK;
             }
             break;
+
           case 2:
             return PRINT_UI_ALLOW_NORMAL_LINK;
         }
@@ -688,7 +725,7 @@ function print_ui_link_allowed($link, $args) {
     }
   }
   else {
-    // 'System' page
+    // 'System' page.
     $sys_link_visibility = variable_get('print_' . $link['format'] . '_sys_link_visibility', PRINT_UI_SYS_LINK_VISIBILITY_DEFAULT);
     $sys_link_pages = variable_get('print_' . $link['format'] . '_sys_link_pages', PRINT_UI_SYS_LINK_PAGES_DEFAULT);
 
@@ -698,16 +735,16 @@ function print_ui_link_allowed($link, $args) {
 }
 
 /**
- * Check if the provided page is enabled according to the visibility settings
+ * Check if the provided page is enabled according to the visibility settings.
  *
  * @param int $visibility
- *   current visibility settings:
+ *   Current visibility settings:
  *    0 for show on every page except the listed pages
- *    1 for show on only the listed pages
+ *    1 for show on only the listed pages.
  * @param string $path
- *   current path
+ *   Current path.
  * @param string $pages
- *   list of pages
+ *   List of pages.
  *
  * @return bool
  *   TRUE if it is enabled, FALSE otherwise
@@ -742,13 +779,13 @@ function _print_ui_page_match($visibility, $path, $pages) {
  * encoded original. (see #301192)
  *
  * @param array $query
- *   The array to be processed e.g. $_GET
+ *   The array to be processed e.g. $_GET.
  * @param array $exclude
  *   The array filled with keys to be excluded.
  * @param string $parent
  *   The be used in recursive calls.
  *
- * @return string
+ * @return array
  *   urlencoded string which can be appended to/as the URL query string
  */
 function _print_ui_query_string_encode($query, $exclude = array(), $parent = '') {

+ 20 - 10
sites/all/modules/contrib/admin/print/tests/print_basic.test

@@ -2,21 +2,24 @@
 
 /**
  * @file
- * print module simpletest tests
+ * Print module simpletest tests.
  *
  * This file includes the defined tests for the print module.
  *
  * @ingroup print
  */
 
+/**
+ * Class PrintBasicTest.
+ */
 class PrintBasicTest extends DrupalWebTestCase {
-  protected $web_user;
+  protected $webUser;
   protected $getq;
 
   /**
    * Implementation of getInfo().
    */
-  function getInfo() {
+  public function getInfo() {
     return array(
       'name' => t('Printer, email and PDF versions tests'),
       'description' => t('Unit tests for the print, print_mail and print_pdf modules.'),
@@ -27,14 +30,16 @@ class PrintBasicTest extends DrupalWebTestCase {
   /**
    * Implementation of setUp().
    */
-  function setUp() {
+  public function setUp() {
     parent::setUp();
 
     // User to set up print.
-//    $this->web_user = $this->drupalCreateUserRolePerm(array('administer print'));
+    /*
+    $this->webUser = $this->drupalCreateUserRolePerm(array('administer print'));
 
-//    $this->drupalGet('logout');
-//    $this->drupalLoginUser($this->web_user);
+    $this->drupalGet('logout');
+    $this->drupalLoginUser($this->webUser);
+     */
 
     $this->getq = $_GET['q'];
     $_GET['q'] = 'print/' . $_GET['q'];
@@ -43,16 +48,20 @@ class PrintBasicTest extends DrupalWebTestCase {
   /**
    * Implementation of tearDown().
    */
-  function tearDown() {
+  public function tearDown() {
     $_GET['q'] = $this->getq;
 
     parent::tearDown();
   }
 
-  function testPrintRewriteUrls() {
+  /**
+   * Test rewrite of URLs.
+   */
+  public function testPrintRewriteUrls() {
     global $base_url, $base_root, $_print_urls;
 
-    // Must require it, since this function gets called via Drupal's dynamic loading
+    // Must require it, since this function gets called via Drupal's dynamic
+    // loading.
     module_load_include('inc', 'print', 'print.pages');
 
     variable_set('print_urls_anchors', 1);
@@ -110,4 +119,5 @@ class PrintBasicTest extends DrupalWebTestCase {
       $this->assertEqual($urls[0], $abs_url[$i], t('Absolute URL (!url)', array('!url' => $abs_url[$i])));
     }
   }
+
 }

Some files were not shown because too many files changed in this diff