Index: contributions/modules/print/print.module =================================================================== RCS file: /cvs/drupal/contributions/modules/print/print.module,v retrieving revision 1.14 diff -w -u -F^F -r1.14 print.module --- contributions/modules/print/print.module 30 Mar 2006 03:03:57 -0000 1.14 +++ contributions/modules/print/print.module 6 Jan 2007 02:33:32 -0000 @@ -25,15 +25,38 @@ */ function print_menu($may_cache) { $items = array(); - if (!$may_cache) { - $items[] = array('path' => 'node/'. arg(1) .'/print', 'title' => t('printer friendly'), - 'callback' => 'print_node_controller', 'access' => user_access('access content'), - 'type' => MENU_CALLBACK); + $items[] = array( + 'path' => 'admin/content/print', + 'title' => t('Printer Friendly'), + 'description' => t('Printer Friendly settings.'), + 'callback' => 'drupal_get_form', + 'callback arguments' => 'print_settings', + 'access' => user_access('administer content'), + ); $items[] = array('path' => 'print', 'title' => t('printer friendly'), 'callback' => 'print_controller', 'access' => user_access('access content'), 'type' => MENU_CALLBACK); + + $pQuery = explode('/',$_GET['q']); + $pQueryArgs = count($pQuery); + if ( $pQueryArgs >= 2) { + $pQueryArgs -=1; + if ( $pQuery[$pQueryArgs] == 'print') { + array_pop($pQuery); + $printPath = implode('/',$pQuery); // Path without '/print' + $internalPath = drupal_lookup_path('source',$printPath); // Is there an alias? + if ($internalPath || $pQuery[0] == 'node') { + if ( $internalPath ) { + $pQuery = explode('/',$internalPath); // Break down internal path if exists + } + $items[] = array('path' => $printPath.'/print', 'title' => t('printer friendly'), + 'callback' => 'print_node_controller', 'callback arguments' => array($pQuery[1]), + 'access' => user_access('access content'), 'type' => MENU_CALLBACK); + } + } + } } return $items; @@ -54,7 +77,11 @@ } if ($type == 'node' && !isset($node->parent) && variable_get('print_show_link', 1) && $main == 0) { - $links[] = theme('print_link', $node); + $links['print_link'] = array( + 'title' => t("printer friendly"), + 'href' => url("node/$node->nid",NULL,NULL,TRUE)."/print", + 'attributes' => array('title' => t("Display a printer friendly version of this article.")), + ); } return $links; @@ -142,17 +169,17 @@ '#description' => t('Non-standard tag to instruct search engines to not show a "Cached" link for your printer friendly pages') ); - return $form; + return system_settings_form($form); } /******************************************************************** * Module Functions :: Controllers ********************************************************************/ -function print_node_controller() { - $nid = arg(1); - if (is_numeric($nid)) { - print_generate_node($nid); +function print_node_controller($pNode) { + //$nid = arg(1); + if (is_numeric($pNode)) { + print_generate_node($pNode); } }