You are here

function theme_epub_formatter_epubjs_reader in Epub 7

1 theme call to theme_epub_formatter_epubjs_reader()
epub_field_formatter_view in includes/epub.field.inc
Implements hook_field_formatter_view().

File

includes/epub.field.inc, line 356

Code

function theme_epub_formatter_epubjs_reader($variables) {
  global $base_url;
  $filename = $variables['file']->filename;
  $file_url = file_create_url($variables['file']->uri);
  $path = file_create_url('public://epub_content/' . $variables['file']->fid);
  if ($variables['unzipped']) {
    $epub = $base_url . '/' . libraries_get_path('epub.js') . '/reader/index.html?file=' . $path . '/';
  }
  else {
    $epub = $base_url . '/' . libraries_get_path('epub.js') . '/reader/index.html?file=' . $file_url;
  }
  $parameters = drupal_get_query_parameters();
  $link = l(t('Read it online'), 'file/' . $variables['file']->fid, array(
    'query' => array(
      'fullscreen' => TRUE,
    ),
    'attributes' => array(
      'target' => '_blank',
    ),
  ));
  if (module_exists('visitors')) {
    global $user;
    if ($user->uid == 1 || $user->uid == $variables['file']->uid) {
      $query = 'SELECT COUNT(DISTINCT visitors_uid) FROM {visitors} WHERE visitors_uid <> 0 AND visitors_title <> \'Access denied\' AND visitors_path = \'file/' . $variables['file']->fid . '\' AND visitors_url LIKE \'%?fullscreen=1%\'';
      $unique_visitors = db_query($query)
        ->fetchField();
      $link .= '<span> (' . $unique_visitors . ' readers)</span>';
    }
  }
  if (file_entity_access('download', $variables['file'])) {
    $link = '<div>' . $link . '</div><div>' . t('Download: ') . l($filename, $file_url) . '</div>';
  }
  return $link;
}