You are here

function _print_get_title in Printer, email and PDF versions 6

Same name and namespace in other branches
  1. 5.4 print.module \_print_get_title()
  2. 7.2 print.module \_print_get_title()
  3. 7 print.module \_print_get_title()
  4. 5.x print.module \_print_get_title()

Auxiliary function to discover a given page's title

Parameters

$path: path of the page being identified

Return value

string with the page's title

4 calls to _print_get_title()
print_block in ./print.module
Implementation of hook_block().
print_mail_block in print_mail/print_mail.module
Implementation of hook_block().
print_mail_form in print_mail/print_mail.inc
Menu callback for the send by email form.
print_pdf_block in print_pdf/print_pdf.module
Implementation of hook_block().

File

./print.module, line 564
Displays Printer-friendly versions of Drupal pages.

Code

function _print_get_title($path) {
  $path = drupal_get_normal_path($path);
  $nid = preg_replace('!^node/!', '', $path);
  if (ctype_digit($nid)) {
    $res = db_fetch_object(db_query("SELECT title FROM {node} WHERE nid = %d", $nid));
    return $res->title;
  }
  else {

    // Not a node, try to get title from the menu system
    $menu_item = menu_get_item($path);
    if (!empty($menu_item['title'])) {
      return $menu_item['title'];
    }
    elseif (drupal_substr($menu_item['page_callback'], 0, 6) == 'views_') {

      // It's a view, load the view to have access to the title
      $view = views_get_view($menu_item['page_arguments']['0']);
      return $view
        ->get_title();
    }
    else {
      return NULL;
    }
  }
}