From 48b89736151931ce753bb5511e0e95b02273c325 Mon Sep 17 00:00:00 2001 From: Ulrich Christensen Date: Wed, 15 Aug 2012 14:14:10 +0200 Subject: [PATCH 01/40] ding2 -> ding2tal --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index f754fe0..3cee89e 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -4,10 +4,10 @@ core = 7.x ; Ding! projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" -projects[ding_provider][download][url] = "git@github.com:ding2/ding_provider.git" +projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" projects[ding_provider][download][tag] = "7.x-0.13" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" -projects[ding_entity][download][url] = "git@github.com:ding2/ding_entity.git" +projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" projects[ding_entity][download][tag] = "7.x-0.7" From 66bb6306212f19533cb984a8b0f25fc882448084 Mon Sep 17 00:00:00 2001 From: Ulrich Christensen Date: Mon, 27 Aug 2012 10:01:46 -0500 Subject: [PATCH 02/40] tag -> branch --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index 3cee89e..03b6377 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -5,9 +5,9 @@ core = 7.x projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][tag] = "7.x-0.13" +projects[ding_provider][download][branch] = "development" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][tag] = "7.x-0.7" +projects[ding_entity][download][branch] = "development" From 337565e368c53e61dcb2e8da63719f384693c940 Mon Sep 17 00:00:00 2001 From: wiredloose Date: Mon, 11 Feb 2013 13:56:26 +0100 Subject: [PATCH 03/40] Hiding the branch selector of the reserve form on periodical issues --- ding_periodical_reservation/ding_periodical_reservation.module | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ding_periodical_reservation/ding_periodical_reservation.module b/ding_periodical_reservation/ding_periodical_reservation.module index eccf7f0..3aec300 100644 --- a/ding_periodical_reservation/ding_periodical_reservation.module +++ b/ding_periodical_reservation/ding_periodical_reservation.module @@ -4,7 +4,8 @@ * */ function ding_periodical_reservation_button($id, $volume, $issue, $entity) { - return drupal_render(ding_provider_get_form('ding_reservation_reserve_form', new DingPeriodicalReservable($id, $volume, $issue, $entity))); + // Setting 3rd argument to TRUE in ding_provider_get_form hides the branch selector, which we do not want when displaying periodical issues + return drupal_render(ding_provider_get_form('ding_reservation_reserve_form', new DingPeriodicalReservable($id, $volume, $issue, $entity), TRUE)); } /** From dc4ca64a65fc0bd3ffd5ffba01a14eb2cf427003 Mon Sep 17 00:00:00 2001 From: wiredloose Date: Mon, 11 Feb 2013 15:28:29 +0100 Subject: [PATCH 04/40] adding availability classes to periodical issues --- ding_periodical.module | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/ding_periodical.module b/ding_periodical.module index d222543..14dcad1 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -28,12 +28,25 @@ function theme_ding_periodical_issues($variables) { foreach ($variables['elements']['#issues'] as $volume => $issues) { $iss = array(); foreach ($issues as $key => $availability) { - $issue = $key; - // check user - if ($availability['reservable'] && module_exists('ding_periodical_reservation')) { - $issue .= ' ' . ding_periodical_reservation_button($availability['local_id'], $volume, $key, $variables['elements']['#entity']); - } - $iss[] = $issue; + + // availability - if issue if reservable, it is also available + $issue_availibility = ($availability['reservable']) ? 'available' : 'unavailable'; + + $issue_data = $key; + + // check user + if ($availability['reservable'] && module_exists('ding_periodical_reservation')) { + $issue_data .= ' ' . ding_periodical_reservation_button($availability['local_id'], $volume, $key, $variables['elements']['#entity']); + } + + $issue_reservability = ($availability['reservable']) ? 'reservable' : 'not-reservable'; + + $issue = array( + 'data' => $issue_data, + 'class' => array('availability', $issue_availibility, $issue_reservability), + ); + + $iss[] = $issue; } $vol = From 553eaae37345a1d61705b9affd663f81af92f2b6 Mon Sep 17 00:00:00 2001 From: wiredloose Date: Mon, 11 Feb 2013 15:29:38 +0100 Subject: [PATCH 05/40] adding classes to indicate whether foldable periodical volumes are open or closed --- ding_periodical.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ding_periodical.js b/ding_periodical.js index 0de1407..20ef320 100644 --- a/ding_periodical.js +++ b/ding_periodical.js @@ -1,13 +1,15 @@ (function ($) { $(document).ready(function(){ $('.field-name-ding-periodical-issues li').children('.item-list').hide(); + $('.ding-periodical-fold').addClass('expand expand-more') }); Drupal.behaviors.dingPeriodicalIssueToggle = { attach: function (context, settings) { $('.field-name-ding-periodical-issues .ding-periodical-fold').click(function(){ - $(this).parent('.ding-periodical-foldable').children('.item-list').toggle(); + $(this).parent('.ding-periodical-foldable').children('.item-list').toggle(); + $(this).toggleClass('expand-more').toggleClass('expand-less'); }); } - } + } }(jQuery)); From 2b13206602fecc03621f738efa79640a2fbe7662 Mon Sep 17 00:00:00 2001 From: Rasmus Frey Date: Wed, 13 Mar 2013 11:20:44 +0100 Subject: [PATCH 06/40] Changed sort, need to push to test as I don' have issues info available on local --- ding_periodical.field.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ding_periodical.field.inc b/ding_periodical.field.inc index 337462d..00066af 100644 --- a/ding_periodical.field.inc +++ b/ding_periodical.field.inc @@ -77,7 +77,7 @@ function ding_periodical_field_formatter_view($entity_type, $entity, $field, $in foreach ($issues as $k => $v) { asort($v); } - ksort($issues); + krsort($issues); if ($issues) { $element[$delta] = array( From 705ec92ce13df222e724829958c083ffbf98e718 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 22 Mar 2013 13:12:00 +0100 Subject: [PATCH 07/40] Changed blackhold to virtual field --- ding_periodical.info | 2 +- ding_periodical.install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.info b/ding_periodical.info index 18eb5d7..baf6a9b 100644 --- a/ding_periodical.info +++ b/ding_periodical.info @@ -5,6 +5,6 @@ version = "7.x-1.9.4" core = 7.x files[] = ding_periodical.module scripts[] = ding_periodical.js -dependencies[] = blackhole +dependencies[] = virtual_field dependencies[] = ding_provider dependencies[] = ding_entity diff --git a/ding_periodical.install b/ding_periodical.install index cf020e7..49f21dc 100644 --- a/ding_periodical.install +++ b/ding_periodical.install @@ -14,7 +14,7 @@ function ding_periodical_ding_entity_fields() { 'field' => array( 'locked' => TRUE, 'storage' => array( - 'type' => 'blackhole', + 'type' => 'virtual_field', ), ), 'instance' => array( From 5c33beb2cf4b794a883d3ebb5a0d98cb869ab621 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 22 Mar 2013 14:24:12 +0100 Subject: [PATCH 08/40] Added update function from blackhole to virtual field --- ding_periodical.install | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ding_periodical.install b/ding_periodical.install index 49f21dc..b6e1d42 100644 --- a/ding_periodical.install +++ b/ding_periodical.install @@ -23,3 +23,17 @@ function ding_periodical_ding_entity_fields() { ), ); } + + +/** + * Convert blackhole field storage to virtual field. + */ +function ding_periodical_update_7000() { + return db_update('field_config') + ->fields(array( + 'storage_type' => 'virtual_field', + 'storage_module' => 'virtual_field', + )) + ->condition('module', 'ding_periodical') + ->execute(); +} \ No newline at end of file From 501112881ebbfd6ba1cf2bdcff3c6b611b2783ec Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 22 Apr 2013 17:25:08 +0200 Subject: [PATCH 09/40] Added virtual field module to the make file --- ding_periodical.make | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ding_periodical.make b/ding_periodical.make index 03b6377..cb31110 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -11,3 +11,6 @@ projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" projects[ding_entity][download][branch] = "development" + +projects[virtual_field][subdir] = contrib +projects[virtual_field][version] = "1.1" \ No newline at end of file From ad7585540d4b939a135ed502530cbed84afb2076 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 22 Apr 2013 20:34:45 +0200 Subject: [PATCH 10/40] Stream line of the make file --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index cb31110..9852c67 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -12,5 +12,5 @@ projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" projects[ding_entity][download][branch] = "development" -projects[virtual_field][subdir] = contrib -projects[virtual_field][version] = "1.1" \ No newline at end of file +projects[virtual_field][subdir] = "contrib" +projects[virtual_field][version] = "1.1" From 998e0bd358f3f2c80ca79ac634028b74e83937da Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 30 Apr 2013 16:42:01 +0200 Subject: [PATCH 11/40] Removed extra call to the provider and removed the use of sessions (prevented the use of reverse proxies) --- ding_periodical.field.inc | 8 +--- ding_periodical.module | 86 ++++++++++++++------------------------- 2 files changed, 33 insertions(+), 61 deletions(-) diff --git a/ding_periodical.field.inc b/ding_periodical.field.inc index 03ffb8d..b45d4a7 100644 --- a/ding_periodical.field.inc +++ b/ding_periodical.field.inc @@ -65,18 +65,13 @@ function ding_periodical_field_formatter_view($entity_type, $entity, $field, $in $element = array(); foreach ($items as $delta => $item) { - if ( !ding_provider_implements('availability', 'holdings') ) { + if (!ding_provider_implements('availability', 'holdings') ) { return $element; } $availability = ding_provider_invoke('availability', 'holdings', array($entity->provider_id)); if (isset($availability[$entity->provider_id])) { $issues = $availability[$entity->provider_id]['issues']; - // array_walk($issues, 'asort') complains about 'Notice: A non - // well formed numeric value encountered'. - foreach ($issues as $k => $v) { - asort($v); - } krsort($issues); if ($issues) { @@ -84,6 +79,7 @@ function ding_periodical_field_formatter_view($entity_type, $entity, $field, $in '#theme' => 'ding_periodical_issues', '#entity' => $entity, '#issues' => $issues, + '#availability' => $availability, ); } } diff --git a/ding_periodical.module b/ding_periodical.module index f644c74..3e74895 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -14,8 +14,11 @@ module_load_include('inc', 'ding_periodical', 'ding_periodical.field'); function ding_periodical_theme() { return array( 'ding_periodical_issues' => array( - // 'variables' => array('entity', 'issues'), - 'render element' => 'elements', + 'variables' => array( + 'entity' => NULL, + 'issues' => array(), + 'availability' => array(), + ), ), ); } @@ -26,7 +29,7 @@ function ding_periodical_theme() { function theme_ding_periodical_issues($variables) { $items = array(); - foreach ($variables['elements']['#issues'] as $volume => $issues) { + foreach ($variables['issues'] as $volume => $issues) { $iss = array(); $i = 0; @@ -35,42 +38,42 @@ function theme_ding_periodical_issues($variables) { $issue_id = $availability['local_id']; $normalized_id = md5($issue_id); - // @todo - // This is to be refactored to prevent segfaults. - if (!empty($issue_id) && module_exists('ding_periodical_reservation')) { - $_SESSION['ding_periodical_reservation'][$normalized_id] = array( - 'issue_id' => $issue_id, - 'volume' => $volume, - 'key' => $key, - 'entity' => $variables['elements']['#entity'], - ); - } - $local_id = $variables['elements']['#entity']->localId; - $holding_data = ding_periodical_holding_data($local_id, $volume, $issue); - $holding_data .= '
'; + // Build table with holding information for the current volume. + $holding_data = ding_periodical_build_table($availability); + + // Check if the volume is reservable and add reservation form. + if (!empty($issue_id)) { + $reservation = new DingPeriodicalReservable($issue_id, $volume, $key, $variables['entity']); + $form = ding_provider_get_form('ding_reservation_reserve_form', $reservation, TRUE); + $holding_data .= drupal_render($form); + } - $holding = array(array( - 'data' => '
' . $holding_data . '
', - )); + $holdings = array( + array( + 'data' => '
' . $holding_data . '
', + ) + ); // Normal behavior - periodicals, dc.type=tidsskrift. $iss[$i] = array( 'data' => '' . $issue . '', - 'children' => $holding, 'class' => array( drupal_html_class('ding-periodical-container'), ), ); - // Suppose we have dc.type=årbog - // Keys for those periodicals are empty. + // Suppose we have dc.type=årbog, where keys for those periodicals are + // empty. if (empty($issue)) { - $iss[$i]['data'] = $holding[0]['data']; + $iss[$i]['data'] = $holdings[0]['data']; $iss[$i]['class'][] = drupal_html_class('ding-periodical-no-issues'); $iss[$i]['class'][] = drupal_html_class('ding-reservable-periodical'); $iss[$i]['id'][] = drupal_html_id('periodical-id-' . $normalized_id); - unset($iss[$i]['children']); + } + else { + // Set children with holding information for periodicals. + $iss[$i]['children'] = $holdings; } $i++; @@ -88,33 +91,6 @@ function theme_ding_periodical_issues($variables) { return theme('item_list', array('items' => $items, 'attributes' => array('class' => drupal_html_class('ding_periodical_issues')))); } -/** - * Fetch periodical availability table. - * - * @param $item - * Ting object local id, parent of periodical. - * @param $periodical - * Periodical id. - * @return type - * HTML markup. - */ -function ding_periodical_holding_data($item = NULL, $volume = NULL, $issue = NULL) { - $availability_table = ''; - if (!empty($item)) { - $holdings = &drupal_static(__FUNCTION__, NULL); - if (!isset($holdings[$item])) { - $holdings = ding_provider_invoke('availability', 'holdings', array($item)); - } - - if (!empty($volume) && !empty($issue)) { - $issue = $holdings[$item]['issues'][$volume][$issue]; - $availability_table = ding_periodical_build_table($issue); - } - } - - return $availability_table; -} - /** * Build a markup for the availability table. * @@ -142,7 +118,7 @@ function ding_periodical_holding_data($item = NULL, $volume = NULL, $issue = NUL * @return * HTML markup for the availability table. */ -function ding_periodical_build_table($issue) { +function ding_periodical_build_table($availability) { $header = array( 'placement' => t('Placement'), 'copies' => t('Copies'), @@ -151,20 +127,20 @@ function ding_periodical_build_table($issue) { $rows = array(); - if ($issue['provider'] === 'alma') { + if ($availability['provider'] === 'alma') { $header['not_for_loan'] = t('Not for loan'); $header['checked_out'] = t('Checked out'); } $i = 0; - foreach ($issue['placement'] as $placement) { + foreach ($availability['placement'] as $placement) { $rows[$i] = array( $placement['location'], $placement['total_count'], $placement['available_count'], ); - if ($issue['provider'] === 'alma') { + if ($availability['provider'] === 'alma') { $rows[$i][] = $placement['reference_count']; $rows[$i][] = $placement['checked_out_count']; } From b434f5387640ae50252e8b01aa43e68db0bffb79 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 30 Apr 2013 16:45:08 +0200 Subject: [PATCH 12/40] Removed un-needed module ding periodical reservation --- .../ding_periodical_reservation.info | 8 -- .../ding_periodical_reservation.module | 126 ------------------ .../js/ding_periodical_reservation.scripts.js | 54 -------- 3 files changed, 188 deletions(-) delete mode 100644 ding_periodical_reservation/ding_periodical_reservation.info delete mode 100644 ding_periodical_reservation/ding_periodical_reservation.module delete mode 100644 ding_periodical_reservation/js/ding_periodical_reservation.scripts.js diff --git a/ding_periodical_reservation/ding_periodical_reservation.info b/ding_periodical_reservation/ding_periodical_reservation.info deleted file mode 100644 index ccd1c94..0000000 --- a/ding_periodical_reservation/ding_periodical_reservation.info +++ /dev/null @@ -1,8 +0,0 @@ -name = Ding periodical reservation -description = Handles reservation of issues on periodicals. -package = Ding! -version = 0.1+dbc.1 -core = 7.x -files[] = ding_periodical_reservation.module -dependencies[] = ding_periodical -dependencies[] = ding_reservation diff --git a/ding_periodical_reservation/ding_periodical_reservation.module b/ding_periodical_reservation/ding_periodical_reservation.module deleted file mode 100644 index 8f3c6ea..0000000 --- a/ding_periodical_reservation/ding_periodical_reservation.module +++ /dev/null @@ -1,126 +0,0 @@ - MENU_CALLBACK, - 'access arguments' => array('search content'), - 'page arguments' => array(2), - 'page callback' => 'ding_periodical_reservation_ajax_reserve', - 'delivery callback' => 'ajax_deliver', - ); - - return $items; -} - -/** - * Implements hook_init(). - */ -function ding_periodical_reservation_init() { - // We need those only for item landing page. - if (arg(0) == 'ting' && arg(1) == 'object') { - drupal_add_library('system', 'drupal.ajax'); - drupal_add_library('system', 'jquery.form'); - drupal_add_js(drupal_get_path('module', 'ding_periodical_reservation') . '/js/ding_periodical_reservation.scripts.js'); - } -} - -/** - * Ajax responder for periodical reservations. - * - * @param $id - * Reservable id. - * @return type - * Array, with ajax specific commands. - */ -function ding_periodical_reservation_ajax_reserve($id = '') { - $commands = array(); - - if (!empty($id)) { - $reservable = isset($_SESSION['ding_periodical_reservation'][$id]) ? $_SESSION['ding_periodical_reservation'][$id] : NULL; - - if (is_array($reservable)) { - $reservation_form = ding_periodical_reservation_button( - $reservable['issue_id'], - $reservable['volume'], - $reservable['key'], - $reservable['entity'] - ); - - $commands[] = ajax_command_append('html', $reservation_form); - $commands[] = ding_periodical_reservation_trigger_periodical_reservation($id); - } - } - - return array('#type' => 'ajax', '#commands' => $commands); -} - -/** - * Function wrapper for custom AJAX command. - * - * Command for triggering periodical reservation procedure, after a certain - * reservation form was created. - */ -function ding_periodical_reservation_trigger_periodical_reservation($entity_id = '') { - if (!empty($entity_id)) { - return array('command' => 'trigger_periodical_reservation', 'data' => $entity_id); - } -} - -/** - * A periodical reservation. - */ -class DingPeriodicalReservable extends DingReservationReservableEntity { - public function __construct($id, $volume, $issue, $entity) { - $this->id = $id; - $this->volume = $volume; - $this->issue = $issue; - $this->entity = $entity; - } - - public function getProviderId() { - // pjo 16-01-12 reservations did not work for alma-periodicals; - // switch on provider type - $type = ding_provider_get_provider_module_name('reservation'); - switch ($type) { - case 'openruth': - return array($this->entity->provider_id, $this->id); - case 'alma': - return $this->id; - default: - return $this->id; - } - } - - public function getEntity() { - return $this->entity; - } - - public function getTitle() { - $title = '@title, vol @volume'; - $title .= !empty($this->issue) ? ', issue @issue' : ''; - - return t($title, array('@title' => $this->entity->title, '@volume' => $this->volume, '@issue' => $this->issue)); - } -} diff --git a/ding_periodical_reservation/js/ding_periodical_reservation.scripts.js b/ding_periodical_reservation/js/ding_periodical_reservation.scripts.js deleted file mode 100644 index 4d28c4e..0000000 --- a/ding_periodical_reservation/js/ding_periodical_reservation.scripts.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file - * Script file for the periodical reservations. - */ -(function ($) { - Drupal.extractPeriodicalId = function(ele) { - classname = $(ele).attr('id'); - id = classname.match(/periodical-id-(.+)/); - - if (id != null) { - return id[1]; - } - else { - return false; - } - } - - trigger_periodical_reservation = function(ajax, response, status) { - var entity_id = response.data.replace(' ', '%20'); - var forms = $('form'); - var regex = new RegExp(entity_id, 'g'); - // Loop through all forms on a page, deeper filtering comes next. - forms.each(function() { - form = $(this); - // Wee seek for reservations forms, thus specific form whose item was clicked. - if (form.attr('id').match(/ding-reservation-reserve-form/g) && form.attr('action').match(regex)) { - form.hide(); - // Make sure we don't miss the form. - setTimeout(function() { - // Call mousedown(), since click() event is forbidden by #ajax['prevent']. - form.find('.form-submit').mousedown(); - }, 500); - } - }); - } - - Drupal.behaviors.ding_periodical_reservation = { - attach: function (context, settings) { - Drupal.ajax.prototype.commands.trigger_periodical_reservation = trigger_periodical_reservation; - $('.ding-reservable-periodical', context).once('ding-reservable-periodical', function() { - var id = Drupal.extractPeriodicalId($(this)); - if (id) { - var element_settings = {}; - element_settings.url = '/ding_periodical_reservation/reserve/' + id; - element_settings.event = 'click'; - element_settings.progress = { type: 'throbber' }; - base = $(this).attr('id'); - - Drupal.ajax[base] = new Drupal.ajax(base, $(this).parent().find('.periodical-reserve button'), element_settings); - } - }); - } - } -}(jQuery)); From c4ddc326159c38da156c5ef5c208405ac580e5c0 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 30 Apr 2013 16:48:36 +0200 Subject: [PATCH 13/40] Added the DingPeriodicalReservable class from the deprecated sub module --- ding_periodical.module | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ding_periodical.module b/ding_periodical.module index 3e74895..9f305bb 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -150,3 +150,40 @@ function ding_periodical_build_table($availability) { return theme('table', array('header' => $header, 'rows' => $rows)); } + +/** + * A periodical reservation. + */ +class DingPeriodicalReservable extends DingReservationReservableEntity { + public function __construct($id, $volume, $issue, $entity) { + $this->id = $id; + $this->volume = $volume; + $this->issue = $issue; + $this->entity = $entity; + } + + public function getProviderId() { + // pjo 16-01-12 reservations did not work for alma-periodicals; + // switch on provider type + $type = ding_provider_get_provider_module_name('reservation'); + switch ($type) { + case 'openruth': + return array($this->entity->provider_id, $this->id); + case 'alma': + return $this->id; + default: + return $this->id; + } + } + + public function getEntity() { + return $this->entity; + } + + public function getTitle() { + $title = '@title, vol @volume'; + $title .= !empty($this->issue) ? ', issue @issue' : ''; + + return t($title, array('@title' => $this->entity->title, '@volume' => $this->volume, '@issue' => $this->issue)); + } +} \ No newline at end of file From 86ec7adab9d8ec50454bb672dce64d34fd85e783 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 30 Apr 2013 16:50:05 +0200 Subject: [PATCH 14/40] Added dependency to ding reservation --- ding_periodical.info | 1 + 1 file changed, 1 insertion(+) diff --git a/ding_periodical.info b/ding_periodical.info index baf6a9b..23a157f 100644 --- a/ding_periodical.info +++ b/ding_periodical.info @@ -8,3 +8,4 @@ scripts[] = ding_periodical.js dependencies[] = virtual_field dependencies[] = ding_provider dependencies[] = ding_entity +dependencies[] = ding_reservation From 83e94ab685a3288b5e963fb6413168d396f1d2a6 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 2 May 2013 13:11:46 +0200 Subject: [PATCH 15/40] Optimized the filed formatter and started on new ajax formatter. * Move class into own file. * Only load JS on entities with the field. * Rewritten the JS to match markup. * Un-sticky headers for tables (create memory leak in FF) --- ding_periodical.field.inc | 64 +++++++++++++++++++------- ding_periodical.info | 2 +- ding_periodical.js | 23 ---------- ding_periodical.module | 50 +++++---------------- ding_periodical_reservable.class.inc | 67 ++++++++++++++++++++++++++++ js/ding_periodical.js | 16 +++++++ 6 files changed, 143 insertions(+), 79 deletions(-) delete mode 100644 ding_periodical.js create mode 100644 ding_periodical_reservable.class.inc create mode 100644 js/ding_periodical.js diff --git a/ding_periodical.field.inc b/ding_periodical.field.inc index b45d4a7..d414e5e 100644 --- a/ding_periodical.field.inc +++ b/ding_periodical.field.inc @@ -55,6 +55,12 @@ function ding_periodical_field_formatter_info() { 'ding_periodical_issues', ), ), + 'ding_periodical_issues_ajax' => array( + 'label' => t('Ajax load'), + 'field types' => array( + 'ding_periodical_issues', + ), + ), ); } @@ -63,26 +69,52 @@ function ding_periodical_field_formatter_info() { */ function ding_periodical_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); - foreach ($items as $delta => $item) { - - if (!ding_provider_implements('availability', 'holdings') ) { - return $element; - } - - $availability = ding_provider_invoke('availability', 'holdings', array($entity->provider_id)); - if (isset($availability[$entity->provider_id])) { - $issues = $availability[$entity->provider_id]['issues']; - krsort($issues); - - if ($issues) { + + // Check that the provider provides holdings information. + if (!ding_provider_implements('availability', 'holdings') ) { + return $element; + } + + // Switch over the different formatters. + switch ($display['type']) { + case 'ding_periodical_issues_ajax': + foreach ($items as $delta => $item) { $element[$delta] = array( - '#theme' => 'ding_periodical_issues', + '#theme' => 'ding_periodical_issues_ajax', '#entity' => $entity, - '#issues' => $issues, - '#availability' => $availability, ); } - } + break; + + default: + // Handles the default formatter. + foreach ($items as $delta => $item) { + $availability = ding_provider_invoke('availability', 'holdings', array($entity->provider_id)); + if (isset($availability[$entity->provider_id])) { + $issues = $availability[$entity->provider_id]['issues']; + krsort($issues); + + if ($issues) { + $element[$delta] = array( + '#theme' => 'ding_periodical_issues', + '#entity' => $entity, + '#issues' => $issues, + '#availability' => $availability, + ); + } + } + } + break; + } + + // Add script to collapsed the issue list, if any elements found. + if (!empty($element)) { + $element['#attached']['js'] = array( + array( + 'data' => drupal_get_path('module', 'ding_periodical') . '/js/ding_periodical.js', + ), + ); } + return $element; } diff --git a/ding_periodical.info b/ding_periodical.info index 23a157f..3bebfd8 100644 --- a/ding_periodical.info +++ b/ding_periodical.info @@ -4,7 +4,7 @@ package = Ding! version = "7.x-1.9.4" core = 7.x files[] = ding_periodical.module -scripts[] = ding_periodical.js +files[] = ding_periodical_reservable.class.inc dependencies[] = virtual_field dependencies[] = ding_provider dependencies[] = ding_entity diff --git a/ding_periodical.js b/ding_periodical.js deleted file mode 100644 index cbcf832..0000000 --- a/ding_periodical.js +++ /dev/null @@ -1,23 +0,0 @@ -(function ($) { - $(document).ready(function(){ - $('.field-name-ding-periodical-issues li').children('.item-list').hide(); - $('.ding-periodical-fold').addClass('expand expand-more') - }); - - Drupal.behaviors.ding_periodical = { - attach: function (context, settings) { - $('.field-name-ding-periodical-issues .ding-periodical-fold').toggle(function() { - $(this).next().show(); - $('.page-ting-object .panel-pane.pane-ting-object-ding-availability-holdings').addClass('holdings-collapsed'); - $('.page-ting-object .grid-3 .panel-pane.pane-ting-object-ding-entity-buttons').addClass('holdings-collapsed'); - $(this).next().toggleClass('expanded-periodicals'); - $(this).parent().toggleClass('expanded-periodicals-parent'); - }, - function () { - $(this).next().hide(); - $(this).next().toggleClass('expanded-periodicals'); - $(this).parent().toggleClass('expanded-periodicals-parent'); - }); - } - } -}(jQuery)); diff --git a/ding_periodical.module b/ding_periodical.module index 9f305bb..9c73a79 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -20,11 +20,18 @@ function ding_periodical_theme() { 'availability' => array(), ), ), + 'ding_periodical_issues_ajax' => array( + 'variables' => array( + 'entity' => NULL, + ), + ), ); } /** - * Theming function. + * Implements theme_ding_periodical_issues(). + * + * Create list of periodical issues order by year. */ function theme_ding_periodical_issues($variables) { $items = array(); @@ -148,42 +155,7 @@ function ding_periodical_build_table($availability) { $i++; } - return theme('table', array('header' => $header, 'rows' => $rows)); -} - -/** - * A periodical reservation. - */ -class DingPeriodicalReservable extends DingReservationReservableEntity { - public function __construct($id, $volume, $issue, $entity) { - $this->id = $id; - $this->volume = $volume; - $this->issue = $issue; - $this->entity = $entity; - } - - public function getProviderId() { - // pjo 16-01-12 reservations did not work for alma-periodicals; - // switch on provider type - $type = ding_provider_get_provider_module_name('reservation'); - switch ($type) { - case 'openruth': - return array($this->entity->provider_id, $this->id); - case 'alma': - return $this->id; - default: - return $this->id; - } - } - - public function getEntity() { - return $this->entity; - } - - public function getTitle() { - $title = '@title, vol @volume'; - $title .= !empty($this->issue) ? ', issue @issue' : ''; - - return t($title, array('@title' => $this->entity->title, '@volume' => $this->volume, '@issue' => $this->issue)); - } + // Note: If stikcy header is TRUE, it will keep adding the js in FF until the + // browser goes down. + return theme('table', array('header' => $header, 'rows' => $rows, 'sticky' => FALSE)); } \ No newline at end of file diff --git a/ding_periodical_reservable.class.inc b/ding_periodical_reservable.class.inc new file mode 100644 index 0000000..1c3bd85 --- /dev/null +++ b/ding_periodical_reservable.class.inc @@ -0,0 +1,67 @@ +id = $id; + $this->volume = $volume; + $this->issue = $issue; + $this->entity = $entity; + } + + /** + * Gets the provider id based on the provider. + * + * @return string + * The id for the issue. + */ + public function getProviderId() { + $type = ding_provider_get_provider_module_name('reservation'); + switch ($type) { + case 'openruth': + return array($this->entity->provider_id, $this->id); + default: + return $this->id; + } + } + + /** + * Returns the entity that repesents this issue. + * + * @return DingEntity + */ + public function getEntity() { + return $this->entity; + } + + /** + * The periodical title with volume and issue information. + * + * @return string + */ + public function getTitle() { + $title = '@title, vol @volume'; + $title .= !empty($this->issue) ? ', issue @issue' : ''; + + return t($title, array('@title' => $this->entity->title, '@volume' => $this->volume, '@issue' => $this->issue)); + } +} diff --git a/js/ding_periodical.js b/js/ding_periodical.js new file mode 100644 index 0000000..636b1a1 --- /dev/null +++ b/js/ding_periodical.js @@ -0,0 +1,16 @@ +(function ($) { + $(document).ready(function(){ + // Hide all elements. + $('.ding-periodical-issues li').children('.item-list').hide(); + + // Add class to style the list as being expandable. + $('.ding-periodical-fold').addClass('expand expand-more'); + + // Attach click event to fold in/out the issues. + $('.field-name-ding-periodical-issues .ding-periodical-fold').live("click", function() { + $(this).next().toggle(); + $(this).next().toggleClass('expanded-periodicals'); + $(this).parent().toggleClass('expanded-periodicals-parent'); + }); + }); +}(jQuery)); From 7118b96050c83f1992de600055e03c0cd6103591 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 2 May 2013 15:01:06 +0200 Subject: [PATCH 16/40] Added new formatter that load holdings information via ajax --- ding-periodical-issues.tpl.php | 3 ++ ding_periodical.field.inc | 28 ++++++++++++---- ding_periodical.module | 61 +++++++++++++++++++++++++++++++--- js/ding_periodical_ajax.js | 31 +++++++++++++++++ 4 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 ding-periodical-issues.tpl.php create mode 100644 js/ding_periodical_ajax.js diff --git a/ding-periodical-issues.tpl.php b/ding-periodical-issues.tpl.php new file mode 100644 index 0000000..6815f7d --- /dev/null +++ b/ding-periodical-issues.tpl.php @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/ding_periodical.field.inc b/ding_periodical.field.inc index d414e5e..febf456 100644 --- a/ding_periodical.field.inc +++ b/ding_periodical.field.inc @@ -69,19 +69,35 @@ function ding_periodical_field_formatter_info() { */ function ding_periodical_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); - + // Check that the provider provides holdings information. if (!ding_provider_implements('availability', 'holdings') ) { return $element; } - + // Switch over the different formatters. switch ($display['type']) { case 'ding_periodical_issues_ajax': foreach ($items as $delta => $item) { $element[$delta] = array( '#theme' => 'ding_periodical_issues_ajax', - '#entity' => $entity, + '#ding_entity_id' => $entity->ding_entity_id, + '#attached' => array( + 'js' => array( + array( + 'data' => drupal_get_path('module', 'ding_periodical') . '/js/ding_periodical_ajax.js', + ), + array( + 'data' => array( + 'ding_periodical' => array( + 'id' => drupal_html_class($entity->ding_entity_id), + 'ding_entity_id' => $entity->ding_entity_id, + ), + ), + 'type' => 'setting', + ), + ), + ), ); } break; @@ -106,12 +122,12 @@ function ding_periodical_field_formatter_view($entity_type, $entity, $field, $in } break; } - + // Add script to collapsed the issue list, if any elements found. - if (!empty($element)) { + if (!empty($element)) { $element['#attached']['js'] = array( array( - 'data' => drupal_get_path('module', 'ding_periodical') . '/js/ding_periodical.js', + 'data' => drupal_get_path('module', 'ding_periodical') . '/js/ding_periodical.js', ), ); } diff --git a/ding_periodical.module b/ding_periodical.module index 9c73a79..1a6ab9a 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -1,5 +1,4 @@ 'Periodical issue information', + 'page callback' => 'ding_periodical_issues_ajax', + 'page arguments' => array(2), + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + + return $items; +} + +/** + * Callback function that load holdings information for a periodical and returns + * the information as a HTML table in JSON. + * + * @param string $ding_entity_id + * Ding entity id for the periodical. + */ +function ding_periodical_issues_ajax($ding_entity_id) { + $output = array(); + + // Load the entity for the periodical. + $entity = ding_entity_load($ding_entity_id); + + // Get availability + $availability = ding_provider_invoke('availability', 'holdings', array($entity->provider_id)); + if (isset($availability[$entity->provider_id])) { + $issues = $availability[$entity->provider_id]['issues']; + krsort($issues); + + if ($issues) { + $output = array( + '#theme' => 'ding_periodical_issues', + '#entity' => $entity, + '#issues' => $issues, + '#availability' => $availability, + ); + } + } + + // Render the output to HTML an return it. + drupal_json_output(array( + 'html' => empty($output) ? '' : render($output), + )); +} + /** * Implements hook_theme(). */ @@ -22,15 +74,16 @@ function ding_periodical_theme() { ), 'ding_periodical_issues_ajax' => array( 'variables' => array( - 'entity' => NULL, + 'ding_entity_id' => NULL, ), + 'template' => 'ding-periodical-issues' ), ); } /** * Implements theme_ding_periodical_issues(). - * + * * Create list of periodical issues order by year. */ function theme_ding_periodical_issues($variables) { @@ -95,7 +148,7 @@ function theme_ding_periodical_issues($variables) { $items[] = $vol; } - return theme('item_list', array('items' => $items, 'attributes' => array('class' => drupal_html_class('ding_periodical_issues')))); + return theme('item_list', array('items' => $items, 'attributes' => array('class' => 'ding-periodical-issues'))); } /** diff --git a/js/ding_periodical_ajax.js b/js/ding_periodical_ajax.js new file mode 100644 index 0000000..881cd1f --- /dev/null +++ b/js/ding_periodical_ajax.js @@ -0,0 +1,31 @@ +(function ($) { + $(document).ready(function(){ + var ids = Drupal.settings.ding_periodical; + $(ids).each(function (index, info){ + // Make ajax call to get holdings table (opt. use the information fetched + // by availability for the entity). + $.ajax({ + type: 'GET', + url: '/ding_periodical/issues/' + info.ding_entity_id + }).done(function(data) { + var div = $('.ding-periodical-issues-ajax.' + info.id); + if (!data.html || 0 === data.html.length) { + // No informtion found. + div.html('

' + Drupal.t('No periodical issue information found.') + '

'); + } + else { + // Insert the information. + div.parent().html(data.html); + + // Hide all elements. + $('.ding-periodical-issues li').children('.item-list').hide(); + + // Add class to style the list as being expandable. + $('.ding-periodical-fold').addClass('expand expand-more'); + } + }); + + // Insert tabelles on succes and hide label on failure. + }); + }); +}(jQuery)); From dfc3283840f5fb034326762ee436c0c2a480dccc Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 2 May 2013 15:15:35 +0200 Subject: [PATCH 17/40] Only display reservation button for issues that has copies available --- ding_periodical.module | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ding_periodical.module b/ding_periodical.module index 1a6ab9a..b941768 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -103,7 +103,7 @@ function theme_ding_periodical_issues($variables) { $holding_data = ding_periodical_build_table($availability); // Check if the volume is reservable and add reservation form. - if (!empty($issue_id)) { + if (!empty($issue_id) && ding_periodical_has_copies($issues[$key])) { $reservation = new DingPeriodicalReservable($issue_id, $volume, $key, $variables['entity']); $form = ding_provider_get_form('ding_reservation_reserve_form', $reservation, TRUE); $holding_data .= drupal_render($form); @@ -117,7 +117,7 @@ function theme_ding_periodical_issues($variables) { // Normal behavior - periodicals, dc.type=tidsskrift. $iss[$i] = array( - 'data' => '' . $issue . '', + 'data' => '' . $issue . '', 'class' => array( drupal_html_class('ding-periodical-container'), ), @@ -211,4 +211,21 @@ function ding_periodical_build_table($availability) { // Note: If stikcy header is TRUE, it will keep adding the js in FF until the // browser goes down. return theme('table', array('header' => $header, 'rows' => $rows, 'sticky' => FALSE)); +} + +/** + * Check if a given issue of a periodical have any copies on the libraries. + * + * @param array $issue + * An periodical isssue form the provider. + * @return boolean + * If a copy exists it return TRUE else FALSE. + */ +function ding_periodical_has_copies($issue) { + foreach ($issue['placement'] as $placement) { + if ($placement['total_count']) { + return TRUE; + } + } + return FALSE; } \ No newline at end of file From 69bb30f45259871ee888ed819dd130b14f8d2ad8 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 6 May 2013 11:27:57 +0200 Subject: [PATCH 18/40] Changed makefile to point to ding2 on github --- ding_periodical.make | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index 9852c67..c6fe1d1 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -4,13 +4,13 @@ core = 7.x ; Ding! projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" -projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][branch] = "development" +projects[ding_provider][download][url] = "git@github.com:ding2/ding_provider.git" +projects[ding_provider][download][branch] = "master" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" -projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][branch] = "development" +projects[ding_entity][download][url] = "git@github.com:ding2/ding_entity.git" +projects[ding_entity][download][branch] = "master" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From db0808a36c2883f4fc2e67f72421abd344f076e5 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 4 Jun 2013 12:15:30 +0200 Subject: [PATCH 19/40] Added missing new lines --- ding-periodical-issues.tpl.php | 2 +- ding_periodical.module | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ding-periodical-issues.tpl.php b/ding-periodical-issues.tpl.php index 6815f7d..7ed84c3 100644 --- a/ding-periodical-issues.tpl.php +++ b/ding-periodical-issues.tpl.php @@ -1,3 +1,3 @@
-
\ No newline at end of file + diff --git a/ding_periodical.module b/ding_periodical.module index b941768..67e734b 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -228,4 +228,4 @@ function ding_periodical_has_copies($issue) { } } return FALSE; -} \ No newline at end of file +} From 0e62917d2bc811e1e8728ed4233a71b43c70b6a3 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 4 Jun 2013 12:16:49 +0200 Subject: [PATCH 20/40] Updated makefile to point to ding2tal --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index c6fe1d1..d74732f 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -4,12 +4,12 @@ core = 7.x ; Ding! projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" -projects[ding_provider][download][url] = "git@github.com:ding2/ding_provider.git" +projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" projects[ding_provider][download][branch] = "master" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" -projects[ding_entity][download][url] = "git@github.com:ding2/ding_entity.git" +projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" projects[ding_entity][download][branch] = "master" projects[virtual_field][subdir] = "contrib" From b7c78bd5613ba7019044ac8fff962fbfeb41b7d5 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 24 Jun 2013 14:59:22 +0200 Subject: [PATCH 21/40] Changed makefile to use development branch --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index d74732f..9852c67 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -5,12 +5,12 @@ core = 7.x projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][branch] = "master" +projects[ding_provider][download][branch] = "development" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][branch] = "master" +projects[ding_entity][download][branch] = "development" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From ee2672daf45705db5337cd61721c9ce97be9b5ca Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 3 Jul 2013 13:35:38 +0200 Subject: [PATCH 22/40] Updated makefile to point to development branch and ding2tal --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index d74732f..9852c67 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -5,12 +5,12 @@ core = 7.x projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][branch] = "master" +projects[ding_provider][download][branch] = "development" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][branch] = "master" +projects[ding_entity][download][branch] = "development" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From 401cd2b724b7b013f9e422487564b74b540734d5 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 30 Oct 2013 18:12:34 +0100 Subject: [PATCH 23/40] Removed provider dependent code and match holdings information to that of other material types --- ding_periodical.field.inc | 6 ++--- ding_periodical.module | 56 ++++++++++++++++----------------------- 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/ding_periodical.field.inc b/ding_periodical.field.inc index febf456..e0d9d53 100644 --- a/ding_periodical.field.inc +++ b/ding_periodical.field.inc @@ -71,7 +71,7 @@ function ding_periodical_field_formatter_view($entity_type, $entity, $field, $in $element = array(); // Check that the provider provides holdings information. - if (!ding_provider_implements('availability', 'holdings') ) { + if (!ding_provider_implements('availability', 'holdings')) { return $element; } @@ -90,8 +90,8 @@ function ding_periodical_field_formatter_view($entity_type, $entity, $field, $in array( 'data' => array( 'ding_periodical' => array( - 'id' => drupal_html_class($entity->ding_entity_id), - 'ding_entity_id' => $entity->ding_entity_id, + 'id' => drupal_html_class($entity->ding_entity_id), + 'ding_entity_id' => $entity->ding_entity_id, ), ), 'type' => 'setting', diff --git a/ding_periodical.module b/ding_periodical.module index 67e734b..df8f731 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -30,7 +30,7 @@ function ding_periodical_menu() { * the information as a HTML table in JSON. * * @param string $ding_entity_id - * Ding entity id for the periodical. + * Ding entity id for the periodical. */ function ding_periodical_issues_ajax($ding_entity_id) { $output = array(); @@ -38,7 +38,7 @@ function ding_periodical_issues_ajax($ding_entity_id) { // Load the entity for the periodical. $entity = ding_entity_load($ding_entity_id); - // Get availability + // Get availability. $availability = ding_provider_invoke('availability', 'holdings', array($entity->provider_id)); if (isset($availability[$entity->provider_id])) { $issues = $availability[$entity->provider_id]['issues']; @@ -76,7 +76,7 @@ function ding_periodical_theme() { 'variables' => array( 'ding_entity_id' => NULL, ), - 'template' => 'ding-periodical-issues' + 'template' => 'ding-periodical-issues', ), ); } @@ -112,7 +112,7 @@ function theme_ding_periodical_issues($variables) { $holdings = array( array( 'data' => '
' . $holding_data . '
', - ) + ), ); // Normal behavior - periodicals, dc.type=tidsskrift. @@ -154,7 +154,7 @@ function theme_ding_periodical_issues($variables) { /** * Build a markup for the availability table. * - * @param $issue + * @param array $availability * Issue array, with keys: * - local_id: Periodical identifier. * - provider: Provider identifier, 'alma' here. @@ -167,15 +167,7 @@ function theme_ding_periodical_issues($variables) { * - available_count * - reservable * - * Keys checked_out_count, reference_count, ordered_count - * appear only in alma. - * - * @todo - * This table DOES NOT contain the reservations count, - * since this number comes as a separate value, for the whole - * ting item, not the periodicals. - * - * @return + * @return $string * HTML markup for the availability table. */ function ding_periodical_build_table($availability) { @@ -187,39 +179,37 @@ function ding_periodical_build_table($availability) { $rows = array(); - if ($availability['provider'] === 'alma') { - $header['not_for_loan'] = t('Not for loan'); - $header['checked_out'] = t('Checked out'); - } - $i = 0; - foreach ($availability['placement'] as $placement) { + foreach ($availability['placement'] as $data) { + $home = isset($data['available_count']) ? (int) $data['available_count'] : 0; + $home += isset($data['reference_count']) ? (int) $data['reference_count'] : 0; + $rows[$i] = array( - $placement['location'], - $placement['total_count'], - $placement['available_count'], + $data['location'], + $data['total_count'], + $home, ); - if ($availability['provider'] === 'alma') { - $rows[$i][] = $placement['reference_count']; - $rows[$i][] = $placement['checked_out_count']; - } - $i++; } // Note: If stikcy header is TRUE, it will keep adding the js in FF until the - // browser goes down. - return theme('table', array('header' => $header, 'rows' => $rows, 'sticky' => FALSE)); + // browser goes down. + return theme('table', array( + 'header' => $header, + 'rows' => $rows, + 'sticky' => FALSE, + )); } /** * Check if a given issue of a periodical have any copies on the libraries. * * @param array $issue - * An periodical isssue form the provider. - * @return boolean - * If a copy exists it return TRUE else FALSE. + * An periodical issue form the provider. + * + * @return bool + * If a copy exists it return TRUE else FALSE. */ function ding_periodical_has_copies($issue) { foreach ($issue['placement'] as $placement) { From 219d3b307cb7c4343833cda96a8f477b86d4bc72 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 30 Oct 2013 22:36:40 +0100 Subject: [PATCH 24/40] Fixed reservation buttons for periodicals --- ding_periodical.module | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ding_periodical.module b/ding_periodical.module index df8f731..fe52fd1 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -103,10 +103,11 @@ function theme_ding_periodical_issues($variables) { $holding_data = ding_periodical_build_table($availability); // Check if the volume is reservable and add reservation form. - if (!empty($issue_id) && ding_periodical_has_copies($issues[$key])) { + if (!empty($issue_id) && ding_periodical_is_reservable($issues[$key])) { $reservation = new DingPeriodicalReservable($issue_id, $volume, $key, $variables['entity']); $form = ding_provider_get_form('ding_reservation_reserve_form', $reservation, TRUE); - $holding_data .= drupal_render($form); + $form['#attributes']['class'] = array('reservable'); + $holding_data .= render($form); } $holdings = array( @@ -124,7 +125,7 @@ function theme_ding_periodical_issues($variables) { ); // Suppose we have dc.type=årbog, where keys for those periodicals are - // empty. + // empty or 0. Move the layout out. if (empty($issue)) { $iss[$i]['data'] = $holdings[0]['data']; $iss[$i]['class'][] = drupal_html_class('ding-periodical-no-issues'); @@ -211,11 +212,14 @@ function ding_periodical_build_table($availability) { * @return bool * If a copy exists it return TRUE else FALSE. */ -function ding_periodical_has_copies($issue) { +function ding_periodical_is_reservable($issue) { foreach ($issue['placement'] as $placement) { - if ($placement['total_count']) { + if ($placement['reservable']) { + // Found on placement that had a reservable copy. return TRUE; } } + + // No placements found with reservable copy. return FALSE; } From 42f185d1fdaa844c3fbfd504e1689156547a2b2b Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 4 Nov 2013 21:21:32 +0100 Subject: [PATCH 25/40] Updated makefile to point to tag 7.x-1.0-beta2 --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index 9852c67..5f93517 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -5,12 +5,12 @@ core = 7.x projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][branch] = "development" +projects[ding_provider][download][tag] = "7.x-1.0-beta2" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][branch] = "development" +projects[ding_entity][download][tag] = "7.x-1.0-beta2" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From d680865b4ed07b224b1deb9ffec3124735067a3b Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 26 Nov 2013 12:45:41 +0100 Subject: [PATCH 26/40] Updated makefile to point to tag 7.x-1.0-beta3 --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index 5f93517..1e37af1 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -5,12 +5,12 @@ core = 7.x projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][tag] = "7.x-1.0-beta2" +projects[ding_provider][download][tag] = "7.x-1.0-beta3" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][tag] = "7.x-1.0-beta2" +projects[ding_entity][download][tag] = "7.x-1.0-beta3" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From d8889c6bf468ddba6c5f30aa36c79c95c2a952c5 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 12 Dec 2013 13:13:03 +0100 Subject: [PATCH 27/40] Updated makefile to point to tag 7.x-1.0-beta4 --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index 1e37af1..75b022e 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -5,12 +5,12 @@ core = 7.x projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][tag] = "7.x-1.0-beta3" +projects[ding_provider][download][tag] = "7.x-1.0-beta4" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][tag] = "7.x-1.0-beta3" +projects[ding_entity][download][tag] = "7.x-1.0-beta4" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From dcdc1695fd7d193ecf2bb20e919dd4b792ce0510 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 18 Dec 2013 05:03:03 +0100 Subject: [PATCH 28/40] Updated makefile to point to tag 7.x-1.0-beta5 --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index 75b022e..735ccbd 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -5,12 +5,12 @@ core = 7.x projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][tag] = "7.x-1.0-beta4" +projects[ding_provider][download][tag] = "7.x-1.0-beta5" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][tag] = "7.x-1.0-beta4" +projects[ding_entity][download][tag] = "7.x-1.0-beta5" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From 0820d4ce822ecaa22947e167552783a5958750f2 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 20 Dec 2013 15:39:17 +0100 Subject: [PATCH 29/40] Updated makefile to point to tag 7.x-1.0-rc1 --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index 735ccbd..f344e23 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -5,12 +5,12 @@ core = 7.x projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][tag] = "7.x-1.0-beta5" +projects[ding_provider][download][tag] = "7.x-1.0-rc1" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][tag] = "7.x-1.0-beta5" +projects[ding_entity][download][tag] = "7.x-1.0-rc1" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From 06df02dfe10652728d8d3ece0a182a2fd29c75ec Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 8 Jan 2014 21:57:40 +0100 Subject: [PATCH 30/40] Updated makefile to point to tag 7.x-1.0-rc2 --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index f344e23..3d1f8f6 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -5,12 +5,12 @@ core = 7.x projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][tag] = "7.x-1.0-rc1" +projects[ding_provider][download][tag] = "7.x-1.0-rc2" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][tag] = "7.x-1.0-rc1" +projects[ding_entity][download][tag] = "7.x-1.0-rc2" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From 18059b528c99360d0db544d5b7e7115b393eb171 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 20 Jan 2014 12:25:15 +0100 Subject: [PATCH 31/40] Updated makefile to point to tag 7.x-1.0-rc3 --- ding_periodical.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index 3d1f8f6..dfcb488 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -5,12 +5,12 @@ core = 7.x projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][tag] = "7.x-1.0-rc2" +projects[ding_provider][download][tag] = "7.x-1.0-rc3" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][tag] = "7.x-1.0-rc2" +projects[ding_entity][download][tag] = "7.x-1.0-rc3" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From 0475774abdbbcb2fe64781da33b3859be0d26305 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 3 Feb 2014 13:34:03 +0100 Subject: [PATCH 32/40] Updated makefile to point to ding2 master branches --- ding_periodical.make | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index dfcb488..c6fe1d1 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -4,13 +4,13 @@ core = 7.x ; Ding! projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" -projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][tag] = "7.x-1.0-rc3" +projects[ding_provider][download][url] = "git@github.com:ding2/ding_provider.git" +projects[ding_provider][download][branch] = "master" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" -projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][tag] = "7.x-1.0-rc3" +projects[ding_entity][download][url] = "git@github.com:ding2/ding_entity.git" +projects[ding_entity][download][branch] = "master" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From ef6d246219ccaa2d9d83d03b5f5d6adbb2fa237d Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 26 Feb 2014 16:05:14 +0100 Subject: [PATCH 33/40] Changed the reservation button to use ajax link and not forms --- ding_periodical.module | 63 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/ding_periodical.module b/ding_periodical.module index fe52fd1..01e1429 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -22,12 +22,43 @@ function ding_periodical_menu() { 'type' => MENU_CALLBACK, ); + // Ajax link reservation callback (with local_id, volume and issue). + $items['ting/object/%ting_object/reserve/%/%/%'] = array( + 'page callback' => 'ding_periodical_reserve_ajax', + 'page arguments' => array(2, 4, 5, 6), + 'delivery callback' => 'ajax_deliver', + 'access arguments' => array('access content'), + ); + return $items; } /** - * Callback function that load holdings information for a periodical and returns - * the information as a HTML table in JSON. + * Ajax reservation callback. + * + * @param TingEntity $entity + * Ting entity for the periodical. + * @param string $local_id + * Local library id (faust) for the issue. + * @param string $volume + * Volume number (for year books the year). + * @param string $issue + * The issue in the volume to reserve. + * + * @return array + * Render array with Ajax commands. + */ +function ding_periodical_reserve_ajax($entity, $local_id, $volume, $issue) { + $reservable = new DingPeriodicalReservable($local_id, $volume, $issue, $entity); + + // Use ding reservation logic to create the reservation and ajax commands. + return ding_reservation_reserve_ajax($entity, $reservable); +} + +/** + * Callback function that load holdings information for a periodical. + * + * The information returned is a HTML table JSON encoded. * * @param string $ding_entity_id * Ding entity id for the periodical. @@ -102,12 +133,32 @@ function theme_ding_periodical_issues($variables) { // Build table with holding information for the current volume. $holding_data = ding_periodical_build_table($availability); - // Check if the volume is reservable and add reservation form. + // Check if the volume is reservable and add reservation button. if (!empty($issue_id) && ding_periodical_is_reservable($issues[$key])) { $reservation = new DingPeriodicalReservable($issue_id, $volume, $key, $variables['entity']); - $form = ding_provider_get_form('ding_reservation_reserve_form', $reservation, TRUE); - $form['#attributes']['class'] = array('reservable'); - $holding_data .= render($form); + $path = array($issue_id, $volume, $key); + $button = array( + array( + '#theme' => 'link', + '#text' => t('Reserve'), + '#path' => 'ting/object/' . $variables['entity']->id . '/reserve/' . implode('/', $path), + '#options' => array( + 'attributes' => array( + 'class' => array( + 'action-button', + 'reserve-button', + 'reservable', + 'use-ajax', + ), + 'id' => 'reservation-' . $issue_id, + ), + 'html' => FALSE, + ), + ), + ); + + // @todo This should first be render in the template layer. + $holding_data .= drupal_render($button); } $holdings = array( From c8f8d384f97bb8566eee183b7ae6b9dbb1b09cf2 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 26 Feb 2014 16:09:18 +0100 Subject: [PATCH 34/40] Fixed function documentation in reservation object --- ding_periodical.module | 1 - ding_periodical_reservable.class.inc | 25 ++++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ding_periodical.module b/ding_periodical.module index 01e1429..ac0fb41 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -135,7 +135,6 @@ function theme_ding_periodical_issues($variables) { // Check if the volume is reservable and add reservation button. if (!empty($issue_id) && ding_periodical_is_reservable($issues[$key])) { - $reservation = new DingPeriodicalReservable($issue_id, $volume, $key, $variables['entity']); $path = array($issue_id, $volume, $key); $button = array( array( diff --git a/ding_periodical_reservable.class.inc b/ding_periodical_reservable.class.inc index 1c3bd85..07b7941 100644 --- a/ding_periodical_reservable.class.inc +++ b/ding_periodical_reservable.class.inc @@ -12,14 +12,14 @@ class DingPeriodicalReservable extends DingReservationReservableEntity { /** * Default constructor. * - * @param type $id - * Id for the periodical issue from the provider. - * @param type $volume - * The volume the issue is belonging to. - * @param type $issue - * The issue from the provider - * @param type $entity - * The ding entity that repesents the periodical. + * @param string $id + * Id for the periodical issue from the provider. + * @param string $volume + * The volume the issue is belonging to. + * @param string $issue + * The issue from the provider + * @param string $entity + * The ding entity that represents the periodical. */ public function __construct($id, $volume, $issue, $entity) { $this->id = $id; @@ -32,22 +32,24 @@ class DingPeriodicalReservable extends DingReservationReservableEntity { * Gets the provider id based on the provider. * * @return string - * The id for the issue. + * The id for the issue. */ public function getProviderId() { $type = ding_provider_get_provider_module_name('reservation'); switch ($type) { case 'openruth': return array($this->entity->provider_id, $this->id); + default: return $this->id; } } /** - * Returns the entity that repesents this issue. + * Returns the entity that represents this issue. * * @return DingEntity + * The entity for the reservation. */ public function getEntity() { return $this->entity; @@ -56,7 +58,8 @@ class DingPeriodicalReservable extends DingReservationReservableEntity { /** * The periodical title with volume and issue information. * - * @return string + * @return string + * Formatted string with issue and volume information. */ public function getTitle() { $title = '@title, vol @volume'; From 6bd6e918c58db8a96518a7b8ae79fa9df60681cc Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 6 May 2014 12:23:38 +0200 Subject: [PATCH 35/40] Updated virtual field to version 1.2 --- ding_periodical.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ding_periodical.make b/ding_periodical.make index 9852c67..6f72c6b 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -13,4 +13,4 @@ projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" projects[ding_entity][download][branch] = "development" projects[virtual_field][subdir] = "contrib" -projects[virtual_field][version] = "1.1" +projects[virtual_field][version] = "1.2" From 37a19079c4dd30610212eeea38a05dc67620819d Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 6 Oct 2014 13:34:54 +0200 Subject: [PATCH 36/40] Updated make file to point to development branch --- ding_periodical.make | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index 55560d3..6f72c6b 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -4,13 +4,13 @@ core = 7.x ; Ding! projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" -projects[ding_provider][download][url] = "git@github.com:ding2/ding_provider.git" -projects[ding_provider][download][branch] = "master" +projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" +projects[ding_provider][download][branch] = "development" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" -projects[ding_entity][download][url] = "git@github.com:ding2/ding_entity.git" -projects[ding_entity][download][branch] = "master" +projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" +projects[ding_entity][download][branch] = "development" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.2" From 177552123a9ae2b7fc934af6588771f978955e7b Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 7 Oct 2014 08:18:20 +0200 Subject: [PATCH 37/40] Updated make file to point to master branch --- ding_periodical.make | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ding_periodical.make b/ding_periodical.make index 6f72c6b..55560d3 100644 --- a/ding_periodical.make +++ b/ding_periodical.make @@ -4,13 +4,13 @@ core = 7.x ; Ding! projects[ding_provider][type] = "module" projects[ding_provider][download][type] = "git" -projects[ding_provider][download][url] = "git@github.com:ding2tal/ding_provider.git" -projects[ding_provider][download][branch] = "development" +projects[ding_provider][download][url] = "git@github.com:ding2/ding_provider.git" +projects[ding_provider][download][branch] = "master" projects[ding_entity][type] = "module" projects[ding_entity][download][type] = "git" -projects[ding_entity][download][url] = "git@github.com:ding2tal/ding_entity.git" -projects[ding_entity][download][branch] = "development" +projects[ding_entity][download][url] = "git@github.com:ding2/ding_entity.git" +projects[ding_entity][download][branch] = "master" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.2" From e700a9b9df794730623261d871d3eda0322e7052 Mon Sep 17 00:00:00 2001 From: Thomas Fini Hansen Date: Sat, 17 Oct 2015 21:04:46 +0200 Subject: [PATCH 38/40] Issue 1454 by xendk: Add reservable class to reserve link. --- ding_periodical.module | 1 + 1 file changed, 1 insertion(+) diff --git a/ding_periodical.module b/ding_periodical.module index ac0fb41..91441ac 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -147,6 +147,7 @@ function theme_ding_periodical_issues($variables) { 'action-button', 'reserve-button', 'reservable', + 'available', 'use-ajax', ), 'id' => 'reservation-' . $issue_id, From 4f105e6802c3835a1b853a0384d827b7a2720f71 Mon Sep 17 00:00:00 2001 From: amd_k8 Date: Wed, 18 Nov 2015 12:55:46 +0200 Subject: [PATCH 39/40] Issue #1337 by Inlead: Encode periodical id into a uniform string. --- ding_periodical.module | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ding_periodical.module b/ding_periodical.module index ac0fb41..ec5cd7b 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -23,9 +23,9 @@ function ding_periodical_menu() { ); // Ajax link reservation callback (with local_id, volume and issue). - $items['ting/object/%ting_object/reserve/%/%/%'] = array( + $items['ting/object/%ting_object/reserve/%'] = array( 'page callback' => 'ding_periodical_reserve_ajax', - 'page arguments' => array(2, 4, 5, 6), + 'page arguments' => array(2, 4), 'delivery callback' => 'ajax_deliver', 'access arguments' => array('access content'), ); @@ -38,17 +38,17 @@ function ding_periodical_menu() { * * @param TingEntity $entity * Ting entity for the periodical. - * @param string $local_id - * Local library id (faust) for the issue. - * @param string $volume - * Volume number (for year books the year). - * @param string $issue - * The issue in the volume to reserve. + * @param string $encoded_id + * Encoded string made of local id, volume and issue data of the item. + * Value base64 hash of each value, glued together using '$' delimiter + * and encoded again as whole. * * @return array * Render array with Ajax commands. */ -function ding_periodical_reserve_ajax($entity, $local_id, $volume, $issue) { +function ding_periodical_reserve_ajax($entity, $encoded_id) { + $id = base64_decode($encoded_id); + list($local_id, $volume, $issue) = array_map('base64_decode', explode('$', $id)); $reservable = new DingPeriodicalReservable($local_id, $volume, $issue, $entity); // Use ding reservation logic to create the reservation and ajax commands. @@ -135,12 +135,14 @@ function theme_ding_periodical_issues($variables) { // Check if the volume is reservable and add reservation button. if (!empty($issue_id) && ding_periodical_is_reservable($issues[$key])) { - $path = array($issue_id, $volume, $key); + $item_id = array($issue_id, $volume, $key); + $item_id = array_map('base64_encode', $item_id); + $button = array( array( '#theme' => 'link', '#text' => t('Reserve'), - '#path' => 'ting/object/' . $variables['entity']->id . '/reserve/' . implode('/', $path), + '#path' => 'ting/object/' . $variables['entity']->id . '/reserve/' . base64_encode(implode('$', $item_id)), '#options' => array( 'attributes' => array( 'class' => array( From c73d86eb9c4c66d9429066590b0e2d4239cce1ed Mon Sep 17 00:00:00 2001 From: AM Date: Wed, 25 Nov 2015 14:56:03 +0200 Subject: [PATCH 40/40] Issue #1337 by Inlead: Do not encode imploded item id chunks. --- ding_periodical.module | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ding_periodical.module b/ding_periodical.module index ec5cd7b..75649e2 100644 --- a/ding_periodical.module +++ b/ding_periodical.module @@ -23,9 +23,9 @@ function ding_periodical_menu() { ); // Ajax link reservation callback (with local_id, volume and issue). - $items['ting/object/%ting_object/reserve/%'] = array( + $items['ting/object/%ting_object/reserve/%/%/%'] = array( 'page callback' => 'ding_periodical_reserve_ajax', - 'page arguments' => array(2, 4), + 'page arguments' => array(2, 4, 5, 6), 'delivery callback' => 'ajax_deliver', 'access arguments' => array('access content'), ); @@ -38,18 +38,18 @@ function ding_periodical_menu() { * * @param TingEntity $entity * Ting entity for the periodical. - * @param string $encoded_id - * Encoded string made of local id, volume and issue data of the item. - * Value base64 hash of each value, glued together using '$' delimiter - * and encoded again as whole. + * @param string $local_id + * Local library id (faust) for the issue (base64 encoded). + * @param string $volume + * Volume number (for year books the year, base64 encoded). + * @param string $issue + * The issue in the volume to reserve (base64_encoded). * * @return array * Render array with Ajax commands. */ -function ding_periodical_reserve_ajax($entity, $encoded_id) { - $id = base64_decode($encoded_id); - list($local_id, $volume, $issue) = array_map('base64_decode', explode('$', $id)); - $reservable = new DingPeriodicalReservable($local_id, $volume, $issue, $entity); +function ding_periodical_reserve_ajax($entity, $local_id, $volume, $issue) { + $reservable = new DingPeriodicalReservable(base64_decode($local_id), base64_decode($volume), base64_decode($issue), $entity); // Use ding reservation logic to create the reservation and ajax commands. return ding_reservation_reserve_ajax($entity, $reservable); @@ -142,7 +142,7 @@ function theme_ding_periodical_issues($variables) { array( '#theme' => 'link', '#text' => t('Reserve'), - '#path' => 'ting/object/' . $variables['entity']->id . '/reserve/' . base64_encode(implode('$', $item_id)), + '#path' => 'ting/object/' . $variables['entity']->id . '/reserve/' . implode('/', $item_id), '#options' => array( 'attributes' => array( 'class' => array(