You are here

function print_ui_insert_link in Printer, email and PDF versions 7.2

Auxiliary function to display a formatted Printer-friendly link.

Function made available so that developers may call this function from their defined pages/blocks.

Parameters

array $link: Array returned by the hook_print_link() call.

array $args: Array of optional arguments:

  • node: node object, to be used in checking node access. If the path argument is not provided, the path used will be node/nid.
  • path: path to be used in the link. If not specified, the current URL is used.
  • location: the location in the page where the link is being inserted ('link', 'corner', 'block', 'help').

Return value

string string with the HTML link to the printer-friendly page

7 calls to print_ui_insert_link()
print_epub_insert_link in print_epub/print_epub.module
Auxiliary function to display a formatted EPUB version link.
print_insert_link in ./print.module
Auxiliary function to display a formatted Printer-friendly link.
print_mail_insert_link in print_mail/print_mail.module
Auxiliary function to display a formatted send by email link.
print_pdf_insert_link in print_pdf/print_pdf.module
Auxiliary function to display a formatted PDF version link.
print_ui_block_view in print_ui/print_ui.module
Implements hook_block_view().

... See full list

4 string references to 'print_ui_insert_link'
print_epub_insert_link in print_epub/print_epub.module
Auxiliary function to display a formatted EPUB version link.
print_insert_link in ./print.module
Auxiliary function to display a formatted Printer-friendly link.
print_mail_insert_link in print_mail/print_mail.module
Auxiliary function to display a formatted send by email link.
print_pdf_insert_link in print_pdf/print_pdf.module
Auxiliary function to display a formatted PDF version link.

File

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

Code

function print_ui_insert_link($link, $args = array()) {
  $node = isset($args['node']) ? $args['node'] : NULL;
  $path = isset($args['path']) ? $args['path'] : NULL;
  $location = isset($args['location']) ? $args['location'] : '';
  if ($node !== NULL) {
    $nid = $node->nid;
    if ($path === NULL) {
      $path = 'node/' . $nid;
    }
    $allowed_type = print_ui_link_allowed($link, array(
      'node' => $node,
    ));
  }
  else {
    if ($path === NULL) {
      $nid = preg_replace('!^node/([\\d]+)!', '$1', $_GET['q']);
      $path = $_GET['q'];
    }
    else {
      $nid = NULL;
    }
    $allowed_type = print_ui_link_allowed($link, array(
      'path' => $path,
    ));
  }
  if ($allowed_type) {
    if ($nid !== NULL) {
      if ($allowed_type === PRINT_UI_ALLOW_BOOK_LINK) {
        $path = 'book/export/html/' . $nid;
      }
      else {
        if (variable_get('print_' . $link['format'] . '_link_use_alias', PRINT_UI_LINK_USE_ALIAS_DEFAULT) && ($alias = drupal_lookup_path('alias', $path))) {
          $path = $alias;
        }
        else {
          $path = $nid;
        }
      }
      $path = $link['path'] . '/' . $path;
      $query = _print_ui_query_string_encode($_GET, array(
        'q',
      ));
    }
    else {
      $query = NULL;
    }
    drupal_add_css(drupal_get_path('module', 'print_ui') . '/css/print_ui.theme.css');
    $format = theme('print_ui_format_link', array(
      'format' => $link['format'],
      'location' => $location,
    ));
    return '<span class="print_' . $link['format'] . '">' . l($format['text'], $path, array(
      'attributes' => $format['attributes'],
      'query' => $query,
      'absolute' => TRUE,
      'html' => $format['html'],
    )) . '</span>';
  }
  else {
    return FALSE;
  }
}