You are here

function print_fill_attributes in Printer, email and PDF versions 7

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

Auxiliary function to fill the Printer-friendly link attributes

Parameters

$title: text to displayed by the link when hovering over it with the mouse

$class: class attribute to be used in the link

$new_window: if TRUE opens the target page in a new window

Return value

array of formatted attributes

3 calls to print_fill_attributes()
theme_print_format_link in ./print.module
Format the Printer-friendly link
theme_print_mail_format_link in print_mail/print_mail.module
Format the send by email link
theme_print_pdf_format_link in print_pdf/print_pdf.module
Format the PDF version link

File

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

Code

function print_fill_attributes($title = '', $class = '', $new_window = FALSE) {
  $print_newwindow = variable_get('print_newwindow', PRINT_NEWWINDOW_DEFAULT);
  $print_robots_noindex = variable_get('print_robots_noindex', PRINT_ROBOTS_NOINDEX_DEFAULT);
  $attributes = array();
  $attributes['title'] = $title;
  if (!empty($class)) {
    $attributes['class'] = array(
      $class,
    );
  }
  if ($new_window) {
    switch ($print_newwindow) {
      case 0:
        $attributes['target'] = '_blank';
        break;
      case 1:
        $attributes['onclick'] = 'window.open(this.href); return false';
        break;
    }
  }
  if (!empty($print_robots_noindex)) {
    $attributes['rel'] = 'nofollow';
  }
  return $attributes;
}