You are here

function _print_get_title in Printer, email and PDF versions 7.2

Same name and namespace in other branches
  1. 5.4 print.module \_print_get_title()
  2. 6 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

string $path: Path of the page being identified.

Return value

string string with the page's title

5 calls to _print_get_title()
print_block_view in ./print.module
Implements hook_block_view().
print_epub_block_view in print_epub/print_epub.module
Implements hook_block_view().
print_mail_block_view in print_mail/print_mail.module
Implements hook_block_view().
print_mail_form_for_path in print_mail/print_mail.inc
Build email form for the page provided in the path argument.
print_pdf_block_view in print_pdf/print_pdf.module
Implements hook_block_view().

File

./print.module, line 325
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)) {
    return db_query("SELECT title FROM {node} WHERE nid = :nid", array(
      ':nid' => $nid,
    ))
      ->fetchField();
  }
  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;
    }
  }
}