You are here

function print_link_alter in Printer, email and PDF versions 6

Same name and namespace in other branches
  1. 5.4 print.module \print_link_alter()
  2. 5.2 print.module \print_link_alter()
  3. 5.3 print.module \print_link_alter()
  4. 5.x print.module \print_link_alter()

Implementation of hook_link_alter().

File

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

Code

function print_link_alter(&$links, $node) {
  foreach ($links as $module => $link) {
    if (strpos($module, 'book_printer') !== FALSE) {
      $print_html_book_link = variable_get('print_html_book_link', PRINT_HTML_BOOK_LINK_DEFAULT);
      if ($print_html_book_link) {
        $print_html_link_pos = variable_get('print_html_link_pos', unserialize(PRINT_HTML_LINK_POS_DEFAULT));
        if (!empty($print_html_link_pos['link'])) {
          $format = theme('print_format_link');
          switch ($print_html_book_link) {
            case 1:
              $path = $link['href'];
              break;
            case 2:
              $print_html_link_use_alias = variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT);
              $path = $print_html_link_use_alias && isset($node->path) ? $node->path : $node->nid;
              break;
          }
          $links[$module] = array(
            'href' => PRINT_PATH . '/' . $path,
            'title' => $format['text'],
            'attributes' => $format['attributes'],
            'html' => $format['html'],
          );
        }
        else {
          unset($links[$module]);
        }
      }
    }
  }
}