summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--print.admin.inc15
-rw-r--r--print.module5
-rw-r--r--print.pages.inc12
3 files changed, 12 insertions, 20 deletions
diff --git a/print.admin.inc b/print.admin.inc
index 4611c27..a144844 100644
--- a/print.admin.inc
+++ b/print.admin.inc
@@ -24,12 +24,12 @@ function print_main_settings() {
$form['settings']['print_css'] = array(
'#type' => 'textfield',
- '#title' => t('Stylesheet URL'),
+ '#title' => t('Custom Stylesheet'),
'#default_value' => variable_get('print_css', PRINT_CSS_DEFAULT),
'#size' => 60,
'#maxlength' => 250,
- '#description' => t('The URL to your custom print cascading stylesheet, if any. When none is specified, the default module CSS file is used.') . '<br />' .
- t('Macros: %b (base path: "%base"), %t (path to theme: "%theme")', array('%base' => base_path(), '%theme' => path_to_theme())) . '<br />' .
+ '#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' => path_to_theme())) . '<br />' .
t('Requires the <em>administer site configuration</em> permission.'),
'#disabled' => !user_access('administer site configuration'),
);
@@ -172,11 +172,10 @@ function _print_main_settings_validate($form, &$form_state) {
}
}
- // Check that the stylesheet URL is a local URL, if it is an absolute URL, then it must start with the site's base URL
- if (preg_match('!^http://.*!', $form_state['values']['print_css'], $matches)) {
- if (!preg_match("!^$base_url/!", $matches[0])) {
- form_set_error('print_css', t("Stylesheet URL must be a relative path or start with the site's base URL"));
- }
+ // Check that the stylesheet path is indeed valid and relative to base_path()
+ $print_css = realpath($_SERVER["DOCUMENT_ROOT"].base_path()) .'/'. strtr($form_state['values']['print_css'], array('%t' => path_to_theme()));
+ if (!is_file($print_css) || !is_readable($print_css)) {
+ form_set_error('print_css', t("File %file is not readable by the web server.", array('%file' => $print_css)));
}
}
diff --git a/print.module b/print.module
index 963713e..1f91fe4 100644
--- a/print.module
+++ b/print.module
@@ -125,6 +125,7 @@ function print_theme() {
*/
function print_theme_registry_alter(&$theme_registry) {
// $theme_registry['print_node']['theme path'] += $theme_registry['node']['theme path'];
+// $theme_registry['print_page']['theme path'] += $theme_registry['page']['theme path'];
}
/**
@@ -134,7 +135,6 @@ function print_preprocess_print_node(&$vars) {
$format = $vars['type'];
$type = $vars['node']->type;
template_preprocess_node($vars);
-
$variables['theme_hook_suggestions'][] = "node";
$variables['theme_hook_suggestions'][] = "node__$type";
$variables['theme_hook_suggestions'][] = "print_node";
@@ -148,6 +148,9 @@ function print_preprocess_print_node(&$vars) {
function print_preprocess_print_page(&$vars) {
$format = $vars['type'];
$type = $vars['node']->type;
+ $vars['show_blocks'] = FALSE;
+ $vars['show_messages'] = FALSE;
+ template_preprocess_page($vars);
$variables['theme_hook_suggestions'][] = "print";
$variables['theme_hook_suggestions'][] = "print.node__$type";
$variables['theme_hook_suggestions'][] = "print_$format";
diff --git a/print.pages.inc b/print.pages.inc
index 0cf1d6c..0309319 100644
--- a/print.pages.inc
+++ b/print.pages.inc
@@ -180,8 +180,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
$print['favicon'] = theme_get_setting('toggle_favicon') ? "<link rel='shortcut icon' href='" . theme_get_setting('favicon') . "' type='image/x-icon' />\n" : '';
if (!empty($print_css)) {
- $replace_pairs = array('%b' => base_path(), '%t' => path_to_theme());
- $user_css = check_url(strtr($print_css, $replace_pairs));
+ drupal_add_css(strtr($print_css, array('%t' => path_to_theme())));
}
else {
drupal_add_css(drupal_get_path('module', 'print') . '/css/print.css');
@@ -198,11 +197,6 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
if (!empty($message)) {
$style = '';
$css_files = array_keys($drupal_css);
- if (!empty($print_css)) {
- // Convert to a local path, by removing the base_path
- $pattern = '!^' . base_path() . '!';
- $css_files[] = preg_replace($pattern, '', $user_css);
- }
foreach ($css_files as $filename) {
$res = file_exists($filename) ? file_get_contents($filename, TRUE) : FALSE;
if ($res != FALSE) {
@@ -213,10 +207,6 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
}
else {
$print['css'] = drupal_get_css($drupal_css);
- if (!empty($print_css)) {
- $query_string = '?' . substr(variable_get('css_js_query_string', '0'), 0, 1);
- $print['css'] .= "<link type='text/css' rel='stylesheet' media='all' href='${user_css}${query_string}' />\n";
- }
}
$window_close = ($print_html_new_window && $print_html_windowclose) ? 'window.close();' : '';