You are here

function theme_document_info in Document 8.x

Same name and namespace in other branches
  1. 6 document.module \theme_document_info()
  2. 7 document.module \theme_document_info()

A custom theme function.

By using this function to format our node-specific information, themes can override this presentation if they wish. We also wrap the default presentation in a CSS class that is prefixed by the module name. This way, style sheets can modify the output without requiring theme code.

1 theme call to theme_document_info()
document_view in ./document.module
Implementation of hook_view().

File

./document.module, line 493

Code

function theme_document_info($variables) {
  $node = $variables['node'];
  $output = '<div class="document_info">';
  $output .= '<div class="document_info_type"><b>' . t('Type') . '</b>: %s</div>';
  $output .= '<div class="document_info_abstract"><b>' . t('Abstract') . '</b>: %s</div>';
  $output .= '<div class="document_info_author"><b>' . t('Author') . '</b>: %s</div>';
  $output .= '<div class="document_info_year"><b>' . t('Year of Publishing') . '</b>: %d</div>';
  $output .= '<div class="document_info_keywords"><b>' . t('Keywords') . '</b>: %s</div>';
  $output .= '<div class="document_info_download">%s</div>';
  $output .= '</div>';
  $fileurl = explode(":", $node->document_url, 2);
  if ($fileurl[0] == 'http' or $fileurl[0] == 'https') {
    $fileurl = explode("files/", $node->document_url);
    $uri = 'public://' . $fileurl[1];
  }
  else {
    $uri = 'public://' . $node->document_url;
  }
  $path = file_create_url($uri);
  $download_access = user_access('download document');
  if ($download_access) {
    $url = l(t('Download'), $path, array(
      'attributes' => array(
        'target' => '_blank',
      ),
    ));
  }
  else {
    $path = explode("/sites", $path);
    $path = $path[0];
    $url = l(t('Download'), $path, array(
      'attributes' => array(
        'onclick' => 'return alert("You must login to download")',
      ),
    ));
  }
  $output = sprintf($output, check_plain($node->document_type), check_plain($node->document_abstract), check_plain($node->document_author), $node->document_year, check_plain($node->document_keywords), $url);
  return $output;
}