You are here

function _print_ui_fill_attributes in Printer, email and PDF versions 7.2

Auxiliary function to fill the Printer-friendly link attributes.

Parameters

string $title: Text to displayed by the link when hovering over it with the mouse.

string $class: Class attribute to be used in the link.

bool $new_window: If TRUE opens the target page in a new window.

Return value

array An associative array containing:

  • title: text to be used when hovering over the link.
  • class: CSS class of the link tag.
  • target: used for opening a new window with the non-javascript method
  • onclick: open a new window, with the javascript method
  • rel: SEO-related attribute indicating that the printer-friendly version should not be indexed by search engine robots.
1 call to _print_ui_fill_attributes()
theme_print_ui_format_link in print_ui/print_ui.module
Format the Printer-friendly link.

File

print_ui/print_ui.module, line 468
Printer-friendly pages User Interface module.

Code

function _print_ui_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;
}