You are here

function _print_var_generator in Printer, email and PDF versions 5.2

Same name and namespace in other branches
  1. 5.4 print.pages.inc \_print_var_generator()
  2. 5.3 print.pages.inc \_print_var_generator()
  3. 6 print.pages.inc \_print_var_generator()
  4. 7 print.pages.inc \_print_var_generator()
  5. 5.x print.pages.inc \_print_var_generator()

Generates the HTML to insert in the template file

Return value

string

3 calls to _print_var_generator()
print_generate_book in ./print.module
Outputs a printer-friendly page. Used for book pages
print_generate_node in ./print.module
Outputs a printer-friendly page. Used for content types
print_generate_path in ./print.module
Outputs a printer-friendly page. Used for drupal core pages.

File

./print.module, line 407
Display printer-friendly versions of Drupal pages

Code

function _print_var_generator($node, $cid = NULL) {
  global $base_url;

  // print module settings
  $print_settings = variable_get('print_settings', print_settings_default());
  $print_sourceurl_settings = variable_get('print_sourceurl_settings', print_sourceurl_settings_default());
  $print["language"] = $GLOBALS['locale'];
  $print["title"] = $node->title;
  $print["robots_meta"] = _print_robots_meta_generator();

  //  $print["base_href"] = "<base href=\"".$base_url."/node/".$node->nid."\" />\n";
  $print["base_href"] = "<base href=\"" . url("node/{$node->nid}", NULL, NULL, TRUE) . "\" />\n";
  $print["head"] = drupal_get_html_head();
  $print["favicon"] = theme_get_setting("toggle_favicon") ? "<link rel=\"shortcut icon\" href=\"" . theme_get_setting("favicon") . "\" type=\"image/x-icon\"/>\n" : "";
  if (!empty($print_settings['css'])) {
    $print["css"] = "<style type=\"text/css\">@import \"" . $print_settings['css'] . "\";</style>\n";
  }
  else {
    ob_start();
    include_once drupal_get_path('module', 'print') . "/print.css";
    $print["css"] = "<style type=\"text/css\">" . ob_get_contents() . "</style>\n";
    ob_end_clean();
  }
  $print["sendtoprinter"] = $print_settings['sendtoprinter'] ? " onload=\"window.print();\"" : "";
  $print["logo"] = !empty($print_settings['logo_url']) ? $print_settings['logo_url'] : theme_get_setting('logo');
  $print["logo"] = $print["logo"] ? "<img class=\"print-logo\" src=\"" . $print["logo"] . "\" alt=\"\" />\n" : "";

  /* Grab and format the src URL */
  if ($print_sourceurl_settings['enabled'] == 1) {
    if (empty($print_sourceurl_settings['forcenode'])) {
      $print["source_url"] = url("node/{$node->nid}", NULL, NULL, TRUE);
    }
    else {
      $print["source_url"] = $base_url . '/' . ((bool) variable_get('clean_url', '0') ? '' : '?q=') . 'node/' . $node->nid;
    }
    if ($cid) {
      $print["source_url"] .= "#comment-{$cid}";
    }
    $print["printdate"] = $print_sourceurl_settings['date'] ? " (" . t("retrieved on") . " " . format_date(time(), 'small') . ")" : "";
    $print["source_url"] = "<strong>" . t('Source URL') . $print["printdate"] . ":</strong> <a href=\"" . $print["source_url"] . "\">" . $print["source_url"] . "</a>";
  }
  else {
    $print["source_url"] = "";
  }
  $print["site_name"] = variable_get('site_name', 0) ? t('Published on') . " " . variable_get('site_name', 0) . " (" . l($base_url, $base_url) . ")" : "";
  $print["submitted"] = theme_get_setting("toggle_node_info_{$node->type}") ? t('By') . " " . $node->name : "";
  $print["created"] = theme_get_setting("toggle_node_info_{$node->type}") ? t('Created') . " " . format_date($node->created, 'small') : "";

  // Display the collected links at the bottom of the page. Code once taken from Kjartan Mannes' project.module
  if (!empty($print_settings['urls'])) {
    $urls = print_friendly_urls();
    $max = count($urls);
    if ($max) {
      $print["pfp_links"] = '';
      for ($i = 0; $i < $max; $i++) {
        $print["pfp_links"] .= '[' . ($i + 1) . '] ' . $urls[$i] . "<br />\n";
      }
      $print["pfp_links"] = "<p><strong>" . t('Links:') . "</strong><br />" . $print["pfp_links"] . "</p>";
    }
  }
  $print["footer_message"] = filter_xss_admin(variable_get('site_footer', FALSE)) . "\n" . theme('blocks', 'footer');
  return $print;
}