You are here

function theme_certificate_certificate in Certificate 7.2

Same name and namespace in other branches
  1. 8.3 certificate.pages.inc \theme_certificate_certificate()
  2. 6.2 certificate.pages.inc \theme_certificate_certificate()
  3. 6 certificate.pages.inc \theme_certificate_certificate()
  4. 7.3 certificate.pages.inc \theme_certificate_certificate()
  5. 3.x certificate.pages.inc \theme_certificate_certificate()

Theme a single certificate.

Does token replace (new style [], and old style %)

Parameters

$account: The user account being viewed.

Return value

The certificate HTML with all tokens translated.

2 theme calls to theme_certificate_certificate()
certificate_preview in ./certificate.pages.inc
Preview certificate template as PDF.
certificate_single in ./certificate.pages.inc
Generate a single certificate.

File

./certificate.pages.inc, line 197
certificate.pages.inc Functions for generating certificates.

Code

function theme_certificate_certificate($variables) {
  $node = $variables['node'];
  $account = $variables['account'];
  $template = $variables['template'];
  $types = array(
    'global' => NULL,
    'node' => $node,
    'user' => $account,
  );
  $field_items = field_get_items('node', $template, 'body');
  $body = $field_items[0]['value'];

  // Invoke hook_certificate_body_alter() to allow all modules to alter the template body.
  drupal_alter('certificate_body', $body, $account, $node);
  if (module_exists('token')) {
    if (module_exists('purl')) {
      purl_disable(TRUE);
    }

    // Clear out un-replaced tokens and use a custom callback, so that we can
    // have HTML tokens render in the PDF. We probably do not need to sanitize
    // here as the output is PDF, but it doesn't hurt.
    $options = array();
    $options['clear'] = TRUE;
    $options['sanitize'] = FALSE;
    $options['callback'] = '_certificate_sanitize_tokens';
    $body = token_replace($body, $types, $options);
  }
  $format = $field_items[0]['format'];
  $body = check_markup($body, $format);
  return $body;
}