Commit 6b36ac09 authored by jcnventura's avatar jcnventura

Coder tough love fixes

parent b8e059be
......@@ -27,12 +27,12 @@ function print_main_settings() {
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Common Settings'),
'#title' => t('Common settings'),
);
$form['settings']['print_css'] = array(
'#type' => 'textfield',
'#title' => t('Custom Stylesheet'),
'#title' => t('Custom stylesheet'),
'#default_value' => $print_css,
'#size' => 60,
'#maxlength' => 250,
......@@ -365,7 +365,7 @@ function print_html_settings() {
}
/**
* Menu callback for the Printer-friendly pages module text strings settings form.
* Menu callback for the common print module text strings settings form
*
* @ingroup forms
*/
......@@ -415,7 +415,7 @@ function print_main_strings_settings_delete() {
}
/**
* Menu callback for the Printer-friendly pages module text strings settings form.
* Menu callback for the printer-friendly version text strings settings form
*
* @ingroup forms
*/
......
......@@ -13,7 +13,7 @@
function print_install() {
$t = get_t();
drupal_set_message($t('Printer-friendly Page settings are available under !link',
array( '!link' => l($t('Administration > Configuration > User interface > Printer, email and PDF versions'), 'admin/config/user-interface/print' ) )
array('!link' => l($t('Administration > Configuration > User interface > Printer, email and PDF versions'), 'admin/config/user-interface/print'))
));
}
......@@ -21,8 +21,6 @@ function print_install() {
* Implements hook_enable().
*/
function print_enable() {
$t = get_t();
// Module weight
db_update('system')
->fields(array(
......
......@@ -146,7 +146,7 @@ function print_preprocess_print(&$variables) {
$variables['page']['#show_messages'] = FALSE;
//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'])) {
......@@ -211,6 +211,7 @@ function print_menu() {
);
$items['admin/config/user-interface/print/html/strings'] = array(
'title' => 'Text strings',
'description' => 'Override the user-facing strings used in the printer-friendly version.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_html_strings_settings'),
'access arguments' => array('administer print'),
......@@ -220,6 +221,7 @@ function print_menu() {
);
$items['admin/config/user-interface/print/common'] = array(
'title' => 'Settings',
'description' => 'Settings for the common functionalities for all the print sub-modules.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_main_settings'),
'access arguments' => array('administer print'),
......@@ -234,6 +236,7 @@ function print_menu() {
);
$items['admin/config/user-interface/print/common/strings'] = array(
'title' => 'Text strings',
'description' => 'Override the user-facing strings used by the print module.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_main_strings_settings'),
'access arguments' => array('administer print'),
......@@ -559,7 +562,9 @@ function _print_get_title($path) {
}
/**
* Update the print_node_conf table to reflect the given attributes
* Modify the print_node_conf_table
*
* Update the print_node_conf table to reflect the given attributes.
* If updating to the default values, delete the record.
*
* @param $nid
......@@ -743,7 +748,7 @@ function print_insert_link($path = NULL, $node = NULL) {
}
/**
* Determine if the provided page is enabled according to the visibility settings
* Check if the provided page is enabled according to the visibility settings
*
* @param $visibility
* current visibility settings:
......@@ -778,7 +783,7 @@ function _print_page_match($visibility, $path, $pages) {
}
/**
* Determine a the link to the PF version is allowed depending on all possible settings
* Check if the link to the PF version is allowed depending on the settings
*
* @param $args
* array containing the possible parameters:
......@@ -865,6 +870,7 @@ function print_link_allowed($args) {
/**
* Parse an array into a valid urlencoded query string.
*
* Modified from drupal_query_string_encode to prevent re-encoding of
* encoded original. (see #301192)
*
......
......@@ -228,7 +228,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
break;
}
$site_name = variable_get('site_name', 'Drupal');
$print['logo'] = $logo_url ? "<img class='print-logo' src='" . check_url($logo_url) . "' alt='$site_name' id='logo' />\n" : '';
$print['logo'] = $logo_url ? theme('image', array('path' => $logo_url, 'alt' => $site_name, 'attributes' => array('class' => 'print-logo', 'id' => 'logo'))) : '';
switch ($print_footer_options) {
case 0: // none
......@@ -513,7 +513,7 @@ function _print_generate_node($nid, $cid = NULL, $format = PRINT_HTML_FORMAT, $t
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
......@@ -530,7 +530,7 @@ function _print_generate_node($nid, $cid = NULL, $format = PRINT_HTML_FORMAT, $t
$print_comments = variable_get('print_comments', PRINT_COMMENTS_DEFAULT);
if (function_exists('comment_node_page_additions') && (($cid != NULL) || ($print_comments))) {
//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);
unset($comments['comment_form']);
......@@ -554,7 +554,7 @@ function _print_generate_node($nid, $cid = NULL, $format = PRINT_HTML_FORMAT, $t
$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';
......@@ -562,7 +562,7 @@ function _print_generate_node($nid, $cid = NULL, $format = PRINT_HTML_FORMAT, $t
$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
......@@ -628,7 +628,7 @@ function _print_generate_path($path, $format = PRINT_HTML_FORMAT, $teaser = FALS
// Delete any links area
$node->body = preg_replace('!\s*<div class="links">.*?</div>!sim', '', $node->body);
//Check URL list settings
// Check URL list settings
$_print_urls = _print_url_list_enabled($node, $format);
// Convert the a href elements
......@@ -674,7 +674,7 @@ function _print_generate_book($nid, $format = PRINT_HTML_FORMAT, $teaser = FALSE
$tree = book_menu_subtree_data($node->book);
$node->body = 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
......
......@@ -214,25 +214,25 @@ function print_mail_strings_settings() {
);
$form['print_mail_text']['print_mail_text_subject'] = array(
'#type' => 'textfield',
'#title' => t('Message Subject'),
'#title' => t('Message subject'),
'#default_value' => variable_get('print_mail_text_subject', t('!user has sent you a message from !site')),
'#description' => t("email subject line. The sender's name will appear in place of !user in the subject. The web site name will be inserted in place of !site. The page title replaces !title."),
);
$form['print_mail_text']['print_mail_text_message'] = array(
'#type' => 'textarea',
'#title' => t('Message Preamble'),
'#title' => t('Message preamble'),
'#default_value' => variable_get('print_mail_text_message', t('Message from sender')),
'#description' => t('email message preamble. The sender will be able to add their own message after this.'),
);
$form['print_mail_text']['print_mail_text_content'] = array(
'#type' => 'textarea',
'#title' => t('Message Content'),
'#title' => t('Message content'),
'#default_value' => variable_get('print_mail_text_content', ''),
'#description' => t('Set the default contents of the message.'),
);
$form['print_mail_text']['print_mail_text_confirmation'] = array(
'#type' => 'textfield',
'#title' => t('Thank You Message'),
'#title' => t('Thank you message'),
'#default_value' => variable_get('print_mail_text_confirmation', t('Thank you for spreading the word about !site.')),
'#description' => t('This message will be displayed after the user successfully submits the form.'),
);
......
......@@ -10,7 +10,7 @@
define('PRINTMAIL_PATH', 'printmail');
// Defined in print.module
//define('PRINT_MAIL_FORMAT', 'mail');
// define('PRINT_MAIL_FORMAT', 'mail');
define('PRINT_MAIL_LINK_POS_DEFAULT', 'link');
define('PRINT_MAIL_LINK_TEASER_DEFAULT', 0);
......@@ -79,6 +79,7 @@ function print_mail_menu() {
);
$items['admin/config/user-interface/print/email'] = array(
'title' => 'email',
'description' => 'Configure the settings of the send by email functionality.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_mail_settings'),
'access arguments' => array('administer print'),
......@@ -93,6 +94,7 @@ function print_mail_menu() {
);
$items['admin/config/user-interface/print/email/strings'] = array(
'title' => 'Text strings',
'description' => 'Override the user-facing strings used in the send by email version.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_mail_strings_settings'),
'access arguments' => array('administer print'),
......@@ -355,6 +357,7 @@ function _print_mail_access($permission) {
/**
* Update the print_mail_node_conf table to reflect the given attributes
*
* If updating to the default values, delete the record.
*
* @param $nid
......@@ -465,7 +468,7 @@ function print_mail_insert_link($path = NULL, $node = NULL) {
}
/**
* Determine a the link to send by email is allowed depending on all possible settings
* Check if the link to send by email is allowed depending on the settings
*
* @param $args
* array containing the possible parameters:
......@@ -615,6 +618,7 @@ function print_mail_views_data_alter(&$data) {
/**
* Implements hook_rules_action_info().
*
* @ingroup rules
*/
function print_mail_rules_action_info() {
......@@ -637,6 +641,7 @@ function print_mail_rules_action_info() {
/**
* Action handler for the print_mail_action_submit
*
* @ingroup rules
*/
function print_mail_action_submit($node, $settings) {
......
......@@ -191,7 +191,7 @@ function print_pdf_settings() {
);
$form['settings']['print_pdf_font_family'] = array(
'#type' => 'textfield',
'#title' => t('Font Family'),
'#title' => t('Font family'),
'#default_value' => variable_get('print_pdf_font_family', PRINT_PDF_FONT_FAMILY_DEFAULT),
'#size' => 60,
'#maxlength' => 250,
......@@ -200,7 +200,7 @@ function print_pdf_settings() {
);
$form['settings']['print_pdf_font_size'] = array(
'#type' => 'textfield',
'#title' => t('Font Size'),
'#title' => t('Font size'),
'#default_value' => variable_get('print_pdf_font_size', PRINT_PDF_FONT_SIZE_DEFAULT),
'#size' => 2,
'#maxlength' => 3,
......@@ -229,14 +229,14 @@ function print_pdf_settings() {
$form['settings']['print_pdf_filename'] = array(
'#type' => 'textfield',
'#title' => t('PDF File Name'),
'#title' => t('PDF filename'),
'#default_value' => variable_get('print_pdf_filename', PRINT_PDF_FILENAME_DEFAULT),
'#description' => t("If left empty the generated filename defaults to the node's path. Tokens may be used to build the filename (see following list). The .pdf extension will be appended automatically."),
);
if (module_exists('token')) {
$form['settings']['print_pdf_filename_patterns'] = array(
'#type' => 'fieldset',
'#title' => t('Replacement Patterns'),
'#title' => t('Replacement patterns'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
......
......@@ -12,12 +12,12 @@
class PrintTCPDF extends TCPDF {
public $footer;
//Page footer data
// Page footer data
public function SetFooterData($arg = '') {
$this->footer = $arg;
}
//Page footer
// Page footer
public function Footer() {
theme('print_pdf_tcpdf_footer2', array('pdf' => $this));
}
......
......@@ -169,8 +169,9 @@ function _drush_print_pdf_download_extract($filename) {
}
/**
* Download a file using wget or curl.
* Adapted from a function in drush/includes/drush.inc to support 302 redirects
* 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
......
......@@ -10,7 +10,7 @@
define('PRINTPDF_PATH', 'printpdf');
// Defined in print.module
//define('PRINT_PDF_FORMAT', 'pdf');
// define('PRINT_PDF_FORMAT', 'pdf');
define('PRINT_PDF_LIB_PATH', 'sites/all/libraries');
......@@ -102,6 +102,7 @@ function print_pdf_menu() {
);
$items['admin/config/user-interface/print/pdf'] = array(
'title' => 'PDF',
'description' => 'Configure the settings of the PDF generation functionality.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_pdf_settings'),
'access arguments' => array('administer print'),
......@@ -116,6 +117,7 @@ function print_pdf_menu() {
);
$items['admin/config/user-interface/print/pdf/strings'] = array(
'title' => 'Text strings',
'description' => 'Override the user-facing strings used in the PDF version.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_pdf_strings_settings'),
'access arguments' => array('administer print'),
......@@ -171,7 +173,7 @@ function print_pdf_requirements($phase) {
$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 <a href="@url">PDF settings page</a>.', array('@url' => url('admin/config/user-interface/print/pdf'))),
'description' => $t('Please configure it in the !url.', array('!url' => l($t('PDF settings page'), 'admin/config/user-interface/print/pdf'))),
'severity' => REQUIREMENT_ERROR,
);
}
......@@ -202,7 +204,7 @@ function print_pdf_requirements($phase) {
$requirements['print_pdf_tool'] = array(
'title' => $t('Printer, email and PDF versions - PDF generation library'),
'value' => $t('Unsupported TCPDF version'),
'description' => $t('The currently selected version of TCPDF (@version) is not supported. Please update to a <a href="@url">newer version</a>.', array('@version' => $version, '@url' => url('http://sourceforge.net/projects/tcpdf/files/latest'))),
'description' => $t('The currently selected version of TCPDF (@version) is not supported. Please update to a !url.', array('@version' => $version, '!url' => l($t('newer version'), 'http://sourceforge.net/projects/tcpdf/files/latest'))),
'severity' => REQUIREMENT_ERROR,
);
}
......@@ -240,7 +242,7 @@ function print_pdf_requirements($phase) {
$requirements['print_pdf_tool'] = array(
'title' => $t('Printer, email and PDF versions - PDF generation library'),
'value' => $t('Unsupported wkhtmltopdf version'),
'description' => $t('The currently selected version of wkhtmltopdf (@version) is not supported. Please update to a <a href="@url">newer version</a>.', array('@version' => $version, '@url' => url('http://code.google.com/p/wkhtmltopdf/'))),
'description' => $t('The currently selected version of wkhtmltopdf (@version) is not supported. Please update to a !url.', array('@version' => $version, '!url' => l($t('newer version'), 'http://code.google.com/p/wkhtmltopdf/'))),
'severity' => REQUIREMENT_ERROR,
);
}
......@@ -430,6 +432,7 @@ function print_pdf_form_alter(&$form, &$form_state, $form_id) {
/**
* Update the print_pdf_node_conf table to reflect the given attributes
*
* If updating to the default values, delete the record.
*
* @param $nid
......@@ -541,7 +544,7 @@ function print_pdf_insert_link($path = NULL, $node = NULL) {
}
/**
* Determine a the link to the PDF version is allowed depending on all possible settings
* Check if the link to the PDF version is allowed depending on the settings
*
* @param $args
* array containing the possible parameters:
......
......@@ -135,7 +135,7 @@ function _print_pdf_file_access_images($html) {
global $base_url, $language;
$print_pdf_images_via_file = variable_get('print_pdf_images_via_file', PRINT_PDF_IMAGES_VIA_FILE_DEFAULT);
// TODO: This needs to be rewritten from scratch for Drupal 7
// @todo This needs to be rewritten from scratch for Drupal 7
$lang = '';
/*
TODO
......@@ -232,7 +232,7 @@ function _print_pdf_dompdf($print, $html, $filename = NULL) {
$html = htmlspecialchars_decode(htmlentities($html, ENT_NOQUOTES, 'ISO-8859-1'), ENT_NOQUOTES);
}
//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);
......@@ -332,7 +332,7 @@ function _print_pdf_tcpdf($print, $html, $filename = NULL) {
ob_clean();
if ($filename) {
//Close and output PDF document
// Close and output PDF document
$output_dest = ($print_pdf_content_disposition == 2) ? 'D' : 'I';
$pdf->Output($filename, $output_dest);
return TRUE;
......@@ -405,7 +405,7 @@ function _print_pdf_wkhtmltopdf($print, $html, $filename = NULL) {
if (!empty($pdf)) {
if ($filename) {
if (headers_sent()) {
die("Unable to stream pdf: headers already sent");
exit("Unable to stream pdf: headers already sent");
}
header("Cache-Control: private");
header("Content-Type: application/pdf");
......@@ -600,12 +600,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
// 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');
......
......@@ -52,7 +52,7 @@ class PrintBasicTest extends DrupalWebTestCase {
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
require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'print') . '/print.pages.inc');
$_print_urls = TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment