You are here

function theme_print_ui_format_link in Printer, email and PDF versions 7.2

Format the Printer-friendly link.

Return value

array An associative array containing:

  • text: The content of the link
  • html: TRUE if the text contains HTML tags, FALSE if it's plain text
  • attributes: several attributes of the link tag (title, class, target, onclick, rel)

See also

_print_ui_fill_attributes()

Related topics

3 theme calls to theme_print_ui_format_link()
print_ui_insert_link in print_ui/print_ui.module
Auxiliary function to display a formatted Printer-friendly link.
print_ui_node_view in print_ui/print_ui.module
Implements hook_node_view().
print_ui_node_view_alter in print_ui/print_ui.module
Implements hook_node_view_alter().

File

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

Code

function theme_print_ui_format_link($vars) {
  $format = $vars['format'];
  foreach (module_implements('print_link') as $module) {
    $function = $module . '_print_link';
    if (function_exists($function)) {
      $link = call_user_func_array($function, array());
      if ($link['format'] == $format) {
        $link_class = variable_get('print_' . $link['format'] . '_link_class', $link['class']);
        $new_window = FALSE;
        $func = $module . '_print_new_window_alter';
        if (function_exists($func)) {
          $func($new_window, $link['format']);
        }
        $show_link = variable_get('print_' . $link['format'] . '_show_link', PRINT_UI_SHOW_LINK_DEFAULT);
        $link_text = filter_xss(variable_get('print_' . $link['format'] . '_link_text', $link['text']));
        $text = '';
        if ($show_link >= 2) {
          $img = drupal_get_path('module', $module) . '/icons/' . $link['icon'];
          switch ($show_link) {
            case 2:
              $text = theme('image', array(
                'path' => $img,
                'width' => '16px',
                'height' => '16px',
                'alt' => $link_text,
                'title' => $link_text,
                'attributes' => array(
                  'class' => array(
                    'print-icon',
                  ),
                ),
              ));
              break;
            case 3:
              $text = theme('image', array(
                'path' => $img,
                'width' => '16px',
                'height' => '16px',
                'alt' => $link_text,
                'title' => $link_text,
                'attributes' => array(
                  'class' => array(
                    'print-icon',
                    'print-icon-margin',
                  ),
                ),
              )) . $link_text;
              break;
          }
          $html = TRUE;
        }
        else {
          $text = $link_text;
          $html = FALSE;
        }
        return array(
          'text' => $text,
          'html' => $html,
          'attributes' => _print_ui_fill_attributes($link['description'], strip_tags($link_class), $new_window),
        );
      }
    }
  }
  return array();
}