Skip to content

Commit

Permalink
Merge branch 'stage'
Browse files Browse the repository at this point in the history
  • Loading branch information
ekate committed Apr 13, 2020
2 parents 7830b9f + c6b2350 commit c6c244a
Show file tree
Hide file tree
Showing 11 changed files with 315 additions and 92 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
# Ignore Intellij/PHPStorm/WebStorm files
*.iml

node_modules
js/node_modules
*.sql
*.json

# Ignore editor backup files
*~
Expand Down
18 changes: 16 additions & 2 deletions dlts_viewer.module
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function dlts_viewer_preprocess_html(&$vars) {
// see html.tpl.php
$vars['pane_metadata_hidden'] = '';
/** The Viewer sets language direction in the markup */
$vars['language_dir'] = dlts_viewer_viewer_language($vars);
$vars['language_dir'] = dlts_viewer_viewer_language($vars);
/** we are not in admin page, default Viewer HTML template */
$vars['theme_hook_suggestions'][] = 'html__viewer';
$vars['classes_array'][] = 'yui3-skin-sam';
Expand All @@ -138,6 +138,17 @@ function dlts_viewer_preprocess_html(&$vars) {
else {
$vars['classes_array'][] = 'not_mobile';
}

// See: https://jira.nyu.edu/jira/browse/DLTSVIEWER-81
$language_default = language_default();
$vars['resource_language_code'] = $language_default->language;
// We have access to $resource_language_code in the global context
// if the resource exist.
// See: dlts_viewer_dispatcher()
$resource_language_code = dlts_viewer_resource_language_code();
if ($resource_language_code) {
$vars['resource_language_code'] = $resource_language_code;
}

/**
* We use Drupal to render objects from MongoDB that don't have a record register
Expand Down Expand Up @@ -272,7 +283,10 @@ function dlts_viewer_flush_caches() {
t('PDF');
t('High-resolution');
t('Low-resolution');
t('Vol.');
t('Vol.');
t('Download');
t('High-resolution PDF');
t('Low-resolution PDF ');
}

// here we need to make sure we delete the record from Apache Solr
Expand Down
8 changes: 4 additions & 4 deletions drush/inc/create.dlts_book.inc
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,10 @@ function create_dlts_book_from_json($books, $cretePages = FALSE, $legacy = FALSE
// do we have a valid extension
if (!in_array($ext,$valid_extensions)) continue;
if (strpos($pdf_file, '_hi')) {
$pdf_files[] = array('file' => $pdf_file, 'label' => 'High resolution');
$pdf_files[] = array('file' => $pdf_file, 'label' => 'High-resolution');
}
elseif (strpos($pdf_file, '_lo')) {
$pdf_files[] = array('file' => $pdf_file, 'label' => 'Low resolution');
$pdf_files[] = array('file' => $pdf_file, 'label' => 'Low-resolution');
}
else {
$pdf_files[] = array('file' => $pdf_file);
Expand All @@ -648,10 +648,10 @@ function create_dlts_book_from_json($books, $cretePages = FALSE, $legacy = FALSE
// check that the URI is not bigger than the allowed MySQL size for varchar with index
if (strlen($pdf_uri) > 255) continue;
if (strpos($pdf_uri, '_hi')) {
$pdf_files[] = array('file' => $pdf_uri, 'label' => 'High resolution');
$pdf_files[] = array('file' => $pdf_uri, 'label' => 'High-resolution');
}
elseif (strpos($pdf_uri, '_lo')) {
$pdf_files[] = array('file' => $pdf_uri, 'label' => 'Low resolution');
$pdf_files[] = array('file' => $pdf_uri, 'label' => 'Low-resolution');
}
else {
$pdf_files[] = array('file' => $pdf_uri);
Expand Down
7 changes: 3 additions & 4 deletions drush/inc/create.dlts_multivol_book.inc
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,10 @@ function create_dlts_multivol_book($node) {
$multivol_exist = multivol_nid($node->isPartOf->identifier);
}


if ($multivol_exist) {
$ewrapper->field_multivol->set($multivol_exist);
}
if ($multivol_exist) {
$ewrapper->field_multivol->set($multivol_exist);

$ewrapper->field_multivol->set($multivol_exist);
}

$ewrapper->save();
Expand Down
9 changes: 8 additions & 1 deletion drush/inc/create.dlts_series_book.inc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ function create_dlts_series_book($node) {
$ewrapper->field_book->set($book_exist);
}
}
$series_exist = series_nid($node->isPartOf->identifier);

if (is_array($node->isPartOf)) {
$series_exist = series_nid($node->isPartOf[0]->identifier);
}
else {
$series_exist = series_nid($node->isPartOf->identifier);
}


if ($series_exist) {
$ewrapper->field_series->set($series_exist);
Expand Down
12 changes: 7 additions & 5 deletions inc/themes.inc
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,11 @@ function theme_field__field_pdf_file (&$variables) {

if ($variables['element']['#view_mode'] == 'metadata') {
$out .= '<div dir="' . $dir . '" class="field field-name-field-pdf clearfix">';
$out .= '<div dir="' . $dir . '" class="field-label">Download:</div>';
$out .= '<div dir="' . $dir . '" class="field-label">' . locale('Download', NULL, $variables['element']['#object']->language) . ':</div>';
foreach ($variables['items'] as $key => $item) {
$out .= '<div class="pdf-items" dir="' . $dir . '">';
$out .= '<div class="pdf-item" dir="' . $dir . '"><a href="' . $variables['items'][$key]['#attributes']['href'] . '" class="' . implode(' ', $variables['items'][$key]['#attributes']['class']) . '">';
$out .= '<div class="pdf-item" dir="' . $dir . '">
<a href="' . $variables['items'][$key]['#attributes']['href'] . '" class="' . implode(' ', $variables['items'][$key]['#attributes']['class']) . '">';
$out .= '<span class="icon" aria-hidden="true" role="presentation">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" fill="#9f2226" width="14" height="17" viewBox="0 0 30 40" style="enable-background:new 0 0 30 40;" xml:space="preserve">
<path d="M14.2,20c-0.4-1.2-0.4-3.7-0.2-3.7C14.7,16.3,14.6,19.2,14.2,20z M14.1,23.7c-0.6,1.6-1.4,3.4-2.2,4.9
Expand All @@ -491,10 +492,11 @@ function theme_field__field_pdf_file (&$variables) {
c2.3,0,2.4-2.5,1.5-3.4C23.4,25.4,20.3,25.7,18.8,25.9z M29.5,8.2l-7.7-7.7C21.4,0.2,21,0,20.5,0H20v10h10V9.5
C30,9,29.8,8.6,29.5,8.2z M23.7,28.1c0.3-0.2-0.2-0.9-3.3-0.7C23.2,28.7,23.7,28.1,23.7,28.1z"></path>
</svg></span>';
$out .= $variables['items'][$key]['#value'] . ' PDF ';


$out .= locale($variables['items'][$key]['#value'], NULL, $variables['element']['#object']->language) . ' ' . locale('PDF', NULL, $variables['element']['#object']->language);

if (dlts_viewer_pdf_is_searchable()) {
$out .= ' <span class="is-searchable" dir="' . $dir . '">(searchable)</span>';
$out .= ' <span class="is-searchable" dir="' . $dir . '">(' . locale('searchable', NULL, $variables['element']['#object']->language) . ')</span>';
}
$out .= '</a></div></div>';
}
Expand Down
38 changes: 21 additions & 17 deletions inc/types/book.inc
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ function _language_field(&$entity)
$languages = $languages[1];
$entity->lang_dir = (!isset($languages[$entity->language]->direction) || isset($languages[$entity->language]->direction) && $languages[$entity->language]->direction == 0) ? 'ltr' : 'rtl';
$entity->lang_language = isset($languages[$entity->language]->language) ? $languages[$entity->language]->language : 'en';
$entity->lang_name = isset($languages[$entity->language]->name) ? $languages[$entity->language]->name : 'English';
$entity->lang_name = isset($languages[$entity->language]->name) ? $languages[$entity->language]->name : t('English');
$translations = translation_path_get_translations('node/' . $entity->nid);
if (count($translations) > 1) {
$entity->lang_options = array('#type' => 'markup', '#prefix' => '<select class="language" aria-label="Choose Language for Metadata">', '#suffix' => '</select>', '#markup' => '');
$entity->lang_options = array('#type' => 'markup', '#prefix' => '<select class="language" aria-label="' . t('Choose Language for Metadata') . '">', '#suffix' => '</select>', '#markup' => '');
foreach ($translations as $key => $index) {
$url = url('books/' . $entity->identifier . '/display', array('absolute' => true, 'query' => array('lang' => $key)));
$markup = array(
Expand Down Expand Up @@ -171,7 +171,11 @@ function dlts_viewer_dispatcher($entity, $arg)
$pdf_is_searchable = dlts_viewer_pdf_is_searchable($entity);
// test if resource
$is_resource = dlts_viewer_is_resource();
// check request type

if ($is_resource) {
dlts_viewer_resource_language_code($entity);
}
// check request type
$is_pjax = dlts_viewer_is_pjax();
// check for mobile devices
$is_mobile = dlts_viewer_is_mobile();
Expand All @@ -188,20 +192,20 @@ function dlts_viewer_dispatcher($entity, $arg)
// change entity title
$entity->title = t('@title @volume', array('@title' => $multivolume_book->title, '@volume' => $volume_number_str));
}
// check if this books is part of a series
// $series_book = dlts_viewer_is_series_book($entity);
// not sure if this is right. the book can part of multiple series book
// figure out the right way to pick the title
// maybe we can do something along the lines of: Book Title (also known as Series book title 1, Series book title 2)
//if ($entity->isSeriesBook) {
//dpm($entity->seriesBook);
//foreach ($entity->seriesBook as $series_book) {
// for now just get the last one (since we just have one for now)
// talk about this with the group and fix later.
//$entity->title = $series_book['volume_label'];
//}
//}
// set entity title

// check if this books is part of a series
// $series_book = dlts_viewer_is_series_book($entity);
// not sure if this is right. the book can part of multiple series book
// figure out the right way to pick the title
// maybe we can do something along the lines of: Book Title (also known as Series book title 1, Series book title 2)
//if ($entity->isSeriesBook) {
//foreach ($entity->seriesBook as $series_book) {
// for now just get the last one (since we just have one for now)
// talk about this with the group and fix later.
//$entity->title = $series_book['volume_label'];
//}
//}
// set entity title
drupal_set_title($entity->title);
// wrapp book entity with Entity API wrapper
$book_wrapper = entity_metadata_wrapper('node', $entity);
Expand Down
Loading

0 comments on commit c6c244a

Please sign in to comment.