Index: print.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/print/print.module,v
retrieving revision 1.25.2.80
diff -u -r1.25.2.80 print.module
--- print.module	12 Jul 2010 15:57:51 -0000	1.25.2.80
+++ print.module	12 Jul 2010 23:50:53 -0000
@@ -94,10 +94,50 @@
     'print_format_link' => array(
       'arguments' => array(),
     ),
+    'print_node' => array(
+      'arguments' => array('node' => NULL, 'type' => ''),
+      'template' => 'print_node',
+    ),
+    'print_page' => array(
+      'arguments' => array('print' => NULL, 'type' => '', 'node' => NULL),
+      'template' => 'print',
+    ),
   );
 }
 
 /**
+ * Clones the node theme registry for print_node so that it works with existing node templates
+ */
+function print_theme_registry_alter(&$theme_registry) {
+  $theme_registry['print_node']['theme paths'] += $theme_registry['node']['theme paths'];
+}
+
+/**
+ * Renders the content of the node using the theme api
+ */
+function print_preprocess_print_node($vars) {
+  $format = $vars['type'];
+  $type = $vars['node']->type;
+  $vars['template_files'][] = "node";
+  $vars['template_files'][] = "node-$type";
+  $vars['template_files'][] = "print_node";
+  $vars['template_files'][] = "print_node_$format";
+  $vars['template_files'][] = "print_node_$format.node-$type";
+}
+
+/**
+ * Renders the print page, where the node content gets embedded
+ */
+function print_preprocess_print_page($vars) {
+  $format = $vars['type'];
+  $type = $vars['node']->type;
+  $vars['template_files'][] = "print";
+  $vars['template_files'][] = "print.node-$type";
+  $vars['template_files'][] = "print_$format";
+  $vars['template_files'][] = "print_$format.node-$type";
+}
+
+/**
  * Implementation of hook_menu().
  */
 function print_menu() {
Index: print.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/print/print.pages.inc,v
retrieving revision 1.1.2.59
diff -u -r1.1.2.59 print.pages.inc
--- print.pages.inc	11 Jan 2010 19:55:52 -0000	1.1.2.59
+++ print.pages.inc	12 Jul 2010 23:50:54 -0000
@@ -18,7 +18,6 @@
  * Generate an HTML version of the printer-friendly page
  *
  * @see print_controller()
- * @see _print_get_template()
  */
 function print_controller_html() {
   $args = func_get_args();
@@ -29,10 +28,7 @@
   if ($print !== FALSE) {
     $node = $print['node'];
 
-    ob_start();
-    include_once(_print_get_template(PRINT_HTML_FORMAT, $print['type']));
-    $html = ob_get_contents();
-    ob_end_clean();
+    $html = theme('print_page', $print, 'html', $node);
     $html = drupal_final_markup($html);
     print $html;
 
@@ -453,51 +449,6 @@
 }
 
 /**
- * Choose most appropriate template
- *
- * Auxiliary function to resolve the most appropriate template trying to find
- * a content specific template in the theme or module dir before falling back
- * on a generic template also in those dirs.
- *
- * @param format
- *   format of the PF page being rendered (html, pdf, etc.)
- * @param $type
- *   name of the node type being rendered in a PF page
- * @return
- *   filename of the most suitable template
- */
-function _print_get_template($format = NULL, $type = NULL) {
-  $filenames = array();
-  // First try to find a template defined both for the format and then the type
-  if (!empty($format) && !empty($type)) {
-    $filenames[] = "print_$format.node-$type.tpl.php";
-  }
-  // Then only for the format
-  if (!empty($format)) {
-    $filenames[] = "print_$format.tpl.php";
-  }
-  // If the node type is known, then try to find that type's template file
-  if (!empty($type)) {
-    $filenames[] = "print.node-$type.tpl.php";
-  }
-  // Finally search for a generic template file
-  $filenames[] = 'print.tpl.php';
-
-  foreach ($filenames as $value) {
-    // First in the theme directory
-    $file = drupal_get_path('theme', $GLOBALS['theme_key']) .'/'. $value;
-    if (file_exists($file)) {
-      return $file;
-    }
-    // Then in the module directory
-    $file = drupal_get_path('module', 'print') .'/'. $value;
-    if (file_exists($file)) {
-      return $file;
-    }
-  }
-}
-
-/**
  * Check URL list settings for this node
  *
  * @param node
@@ -629,6 +580,9 @@
 
   node_invoke_nodeapi($node, 'alter', $teaser, TRUE);
 
+  // $content = theme('print_node', $node, $format);
+  $content = theme('node', $node, $teaser, TRUE);
+
   if ($teaser) {
     $node->body = $node->teaser;
     unset($node->teaser);
Index: print_mail/print_mail.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/print/print_mail/print_mail.inc,v
retrieving revision 1.2.2.28
diff -u -r1.2.2.28 print_mail.inc
--- print_mail/print_mail.inc	9 Jul 2010 22:57:44 -0000	1.2.2.28
+++ print_mail/print_mail.inc	12 Jul 2010 23:50:54 -0000
@@ -253,10 +253,7 @@
       $params['subject'] = $form_state['values']['fld_subject'];
 
       $node = $print['node'];
-      ob_start();
-      include_once(_print_get_template(PRINT_MAIL_FORMAT, $print['type']));
-      $params['body'] = ob_get_contents();
-      ob_end_clean();
+      $params['body'] = theme('print_page', $print, 'email', $node);
       $params['body'] = drupal_final_markup($params['body']);
 
       $ok = FALSE;
Index: print_pdf/print_pdf.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/print/print_pdf/print_pdf.pages.inc,v
retrieving revision 1.3.2.67
diff -u -r1.3.2.67 print_pdf.pages.inc
--- print_pdf/print_pdf.pages.inc	12 Jul 2010 15:40:24 -0000	1.3.2.67
+++ print_pdf/print_pdf.pages.inc	12 Jul 2010 23:50:54 -0000
@@ -17,7 +17,6 @@
  * Generate a PDF version of the printer-friendly page
  *
  * @see print_controller()
- * @see _print_get_template()
  * @see _print_pdf_dompdf()
  * @see _print_pdf_tcpdf()
  */
@@ -65,10 +64,7 @@
   $print['sendtoprinter'] = '';
 
   $node = $print['node'];
-  ob_start();
-  include_once(_print_get_template(PRINT_PDF_FORMAT, $print['type']));
-  $html = ob_get_contents();
-  ob_end_clean();
+  $html = theme('print_page', $print, 'pdf', $node);
   $html = drupal_final_markup($html);
 
   // Convert the a href elements, to make sure no relative links remain
