From 34af20838bf107c0c9b2f482ff247e651699e989 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 22 Feb 2013 14:31:39 +0100 Subject: [PATCH 001/167] Fixed empty arrays when ting_entity don't have relations --- ting.module | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/ting.module b/ting.module index 7e7bcbe..e35aaf7 100644 --- a/ting.module +++ b/ting.module @@ -223,6 +223,8 @@ function ting_block_info() { * helper function - get relations for an ting_entity as an array ([$type] => array($relations)) */ function ting_get_relations($ting_entity) { + $relations = array(); + foreach( $ting_entity->relations as $relation ) { $relations[$relation->type][] = $relation; } @@ -232,7 +234,7 @@ function ting_get_relations($ting_entity) { $refs = module_invoke('ting_reference','get_relations','ting_object',$ting_entity); if( !empty($refs) ) { foreach( $refs as $ref ) { - $relations[$ref->relation_type][] = $ref; + $relations[$ref->relation_type][] = $ref; } } } @@ -249,25 +251,28 @@ function ting_block_view($delta = '') { $items = array(); if( $object = menu_get_object('ting_object',2) ) { $relations = ting_get_relations($object); - $relation_types = module_invoke_all('anchor_info'); - $block['subject'] = array( - '#markup' => t('About the material'), - '#prefix' => '
', - '#suffix' => '
', - ); - $block['subject'] = render($block['subject']); + if (!empty($relations)) { + $relation_types = module_invoke_all('anchor_info'); + $block['subject'] = array( + '#markup' => t('About the material'), + '#prefix' => '
', + '#suffix' => '
', + ); + $block['subject'] = render($block['subject']); - foreach( $relations as $key => $relation ) { - if( isset($relation_types[$key]) ) { - $items[] = l($relation_types[$key].' ('.count($relation).') ','#'.$key,array('external'=>TRUE)); + foreach( $relations as $key => $relation ) { + if( isset($relation_types[$key]) ) { + $items[] = l($relation_types[$key].' ('.count($relation).') ','#'.$key,array('external'=>TRUE)); + } } + $block['content'] = + array( + '#theme' => 'item_list', + '#items' => $items, + ); } - $block['content'] = - array( - '#theme' => 'item_list', - '#items' => $items, - ); } + break; case 'ting_collection_types': if ($collection = menu_get_object('ting_collection', 2)) { From f9d2473dde943a70fcc648b3f307d7c17d7af03e Mon Sep 17 00:00:00 2001 From: Brian Jensen Date: Tue, 12 Mar 2013 15:35:31 +0100 Subject: [PATCH 002/167] Added class button to see online link --- ting.module | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ting.module b/ting.module index e35aaf7..133337d 100644 --- a/ting.module +++ b/ting.module @@ -508,10 +508,8 @@ function ting_ding_entity_buttons($type, $entity) { $label = isset($settings[$type]) && $settings[$type] ? $settings[$type] : $settings['_default']; return array( array( - '#prefix' => '

', - '#suffix' => '

', '#type' => 'markup', - '#markup' => l($label, $entity->online_url, array('attributes'=>array('target'=>'_new'))) + '#markup' => l($label, $entity->online_url, array('attributes'=>array('target'=>'_new', 'class' => 'button'))) ), ); } From f1324028ca5d41f1337d754ff9d7cf63b6cb9240 Mon Sep 17 00:00:00 2001 From: Brian Jensen Date: Tue, 12 Mar 2013 15:45:23 +0100 Subject: [PATCH 003/167] Changed button class --- ting.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.module b/ting.module index 133337d..884766b 100644 --- a/ting.module +++ b/ting.module @@ -509,7 +509,7 @@ function ting_ding_entity_buttons($type, $entity) { return array( array( '#type' => 'markup', - '#markup' => l($label, $entity->online_url, array('attributes'=>array('target'=>'_new', 'class' => 'button'))) + '#markup' => l($label, $entity->online_url, array('attributes'=>array('target'=>'_new', 'class' => 'button-see-online'))) ), ); } From 9b27beb06ccde1e0140c635cc3daf9a57dac6f0c Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 22 Mar 2013 13:20:45 +0100 Subject: [PATCH 004/167] Changed blackhold to virtual field --- ting.install | 18 +++++++++--------- ting.make | 7 +++---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/ting.install b/ting.install index 5bc981b..30198ab 100644 --- a/ting.install +++ b/ting.install @@ -95,7 +95,7 @@ function ting_ding_entity_fields() { 'field' => array( 'locked' => TRUE, 'storage' => array( - 'type' => 'blackhole', + 'type' => 'virtual_field', ), ), 'instance' => array( @@ -106,7 +106,7 @@ function ting_ding_entity_fields() { 'field' => array( 'locked' => TRUE, 'storage' => array( - 'type' => 'blackhole', + 'type' => 'virtual_field', ), ), 'instance' => array( @@ -117,7 +117,7 @@ function ting_ding_entity_fields() { 'field' => array( 'locked' => TRUE, 'storage' => array( - 'type' => 'blackhole', + 'type' => 'virtual_field', ), ), 'instance' => array( @@ -128,7 +128,7 @@ function ting_ding_entity_fields() { 'field' => array( 'locked' => TRUE, 'storage' => array( - 'type' => 'blackhole', + 'type' => 'virtual_field', ), ), 'instance' => array( @@ -139,7 +139,7 @@ function ting_ding_entity_fields() { 'field' => array( 'locked' => TRUE, 'storage' => array( - 'type' => 'blackhole', + 'type' => 'virtual_field', ), ), 'instance' => array( @@ -150,7 +150,7 @@ function ting_ding_entity_fields() { 'field' => array( 'locked' => TRUE, 'storage' => array( - 'type' => 'blackhole', + 'type' => 'virtual_field', ), ), 'instance' => array( @@ -162,7 +162,7 @@ function ting_ding_entity_fields() { 'field' => array( 'locked' => TRUE, 'storage' => array( - 'type' => 'blackhole', + 'type' => 'virtual_field', ), ), 'instance' => array( @@ -174,7 +174,7 @@ function ting_ding_entity_fields() { 'field' => array( 'locked' => TRUE, 'storage' => array( - 'type' => 'blackhole', + 'type' => 'virtual_field', ), ), 'instance' => array( @@ -186,7 +186,7 @@ function ting_ding_entity_fields() { 'field' => array( 'locked' => TRUE, 'storage' => array( - 'type' => 'blackhole', + 'type' => 'virtual_field', ), ), 'instance' => array( diff --git a/ting.make b/ting.make index d620fb7..13a0e4d 100644 --- a/ting.make +++ b/ting.make @@ -6,10 +6,9 @@ core = 7.x projects[nanosoap][subdir] = contrib projects[nanosoap][version] = "1.0" -projects[blackhole][subdir] = contrib -projects[blackhole][version] = "1.1" -;projects[virtual_field][subdir] = contrib -;projects[virtual_field][version] = "1.0" +projects[virtual_field][subdir] = contrib +projects[virtual_field][version] = "1.1" + ; Libraries From 89d8bd0582d0a08a39488b0708c75432aecf00ec Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 22 Mar 2013 14:20:29 +0100 Subject: [PATCH 005/167] Added update function from blackhole to virtual field --- ting.install | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ting.install b/ting.install index 30198ab..f5608ca 100644 --- a/ting.install +++ b/ting.install @@ -196,3 +196,16 @@ function ting_ding_entity_fields() { ), ); } + +/** + * Convert blackhole field storage to virtual field. + */ +function ting_update_7000() { + return db_update('field_config') + ->fields(array( + 'storage_type' => 'virtual_field', + 'storage_module' => 'virtual_field', + )) + ->condition('module', 'ting') + ->execute(); +} From a913f5cf7d4d77521e5034c3359716250b6a1541 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 22 Mar 2013 14:29:08 +0100 Subject: [PATCH 006/167] Updated dependecy to virtual_field --- ting.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.info b/ting.info index 4aeebe0..ae4a8be 100644 --- a/ting.info +++ b/ting.info @@ -11,4 +11,4 @@ configure = admin/config/ting stylesheets[all][] = ting.css dependencies[] = ding_entity dependencies[] = nanosoap -dependencies[] = blackhole +dependencies[] = virtual_field From 81b4dde5f282a4cab6485782483b72f80d4f95d4 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 25 Mar 2013 16:32:35 +0100 Subject: [PATCH 007/167] Ensured that ting request is not asked for the same ids more than once in request --- ting.controllers.inc | 3 ++- ting.install | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ting.controllers.inc b/ting.controllers.inc index e286375..7468d53 100644 --- a/ting.controllers.inc +++ b/ting.controllers.inc @@ -94,7 +94,7 @@ class TingObjectController extends DrupalDefaultEntityController { $get_ids[] = $qe->ding_entity_id; } if ($get_ids && $load_ids = array_diff($get_ids, $cached_entity_ids)) { - $objects = ting_get_objects($load_ids); + $objects = ting_get_objects(array_unique($load_ids)); } // Not known locally. Create a proxy if it exists in the well. @@ -138,6 +138,7 @@ class TingObjectController extends DrupalDefaultEntityController { $entities += $queried_entities; } + // If entity supports cache. if ($this->cache) { // Add entities to the cache if we are not loading a revision. if (!empty($queried_entities) && !$revision_id) { diff --git a/ting.install b/ting.install index f5608ca..1fa37ba 100644 --- a/ting.install +++ b/ting.install @@ -9,6 +9,8 @@ * Implements hook_schema(). */ function ting_schema() { + $schema = array(); + $schema['ting_object'] = array( 'description' => 'Local proxy table for ting objects.', 'fields' => array( From bcfeab73f22865f262b462da9bd67b6ac0ca997c Mon Sep 17 00:00:00 2001 From: Rune Schjellerup Philosof Date: Fri, 15 Feb 2013 14:42:26 +0100 Subject: [PATCH 008/167] Load all the objects by stepping the webservice repeatedly. Yes, this will be slow for large lists! We might consider inserting a pager in the frontend. But it is nicer than the current loan lists missing some titles when the limit of 50 uncached objects are hit. opensearch limits stepValue to 50 (even though it doesn't say so in the documentation)... --- ting.client.inc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index 90b5370..1e317a4 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -109,7 +109,11 @@ function ting_get_objects($ids) { $query[] = 'rec.id=' . $id; } } - if (sizeof($query)) { + $i = 0; + do { + if (sizeof($query) == 0) { + break; + } $request = ting_get_request_factory()->getSearchRequest(); if ($agency = variable_get('ting_agency', FALSE)) { @@ -122,8 +126,8 @@ function ting_get_objects($ids) { } $request->setQuery(join(' OR ', $query)); - $request->setStart(1); - $request->setNumResults(1000); + $request->setStart($i * 50 + 1); + $request->setNumResults(50); $request->setAllObjects(TRUE); $result = ting_execute_cache($request); @@ -137,7 +141,8 @@ function ting_get_objects($ids) { } } } - } + $i++; + } while ($result->more); return $objects; } From b9ee8a72599ee191fd1f49c3b69f0db0be1f8cb2 Mon Sep 17 00:00:00 2001 From: Rune Schjellerup Philosof Date: Mon, 11 Mar 2013 15:56:46 +0100 Subject: [PATCH 009/167] Add a sprinkling of comments --- ting.client.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index 1e317a4..6b2dfe1 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -109,23 +109,25 @@ function ting_get_objects($ids) { $query[] = 'rec.id=' . $id; } } + // opensearch is limited to 50 results per call, so iterate until all have been fetched. $i = 0; do { + // I query is empty, then don't do it. + // Not necessary to do in each iteration, but it doesn't hurt much. if (sizeof($query) == 0) { break; } - $request = ting_get_request_factory()->getSearchRequest(); + $request = ting_get_request_factory()->getSearchRequest(); if ($agency = variable_get('ting_agency', FALSE)) { $request->setAgency($agency); } - $profile = variable_get('ting_search_profile', ''); if (!empty($profile) && method_exists($request, 'setProfile')) { $request->setProfile($profile); } - $request->setQuery(join(' OR ', $query)); + // Do it in steps of 50. $request->setStart($i * 50 + 1); $request->setNumResults(50); $request->setAllObjects(TRUE); From 3724df4835b235da574b67b1679615f9e1f0f341 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 25 Mar 2013 16:43:33 +0100 Subject: [PATCH 010/167] Fixed typo in comment --- ting.client.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index 6b2dfe1..8f75589 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -109,10 +109,11 @@ function ting_get_objects($ids) { $query[] = 'rec.id=' . $id; } } - // opensearch is limited to 50 results per call, so iterate until all have been fetched. + // Opensearch is limited to 50 results per call, so iterate until all results + // have been fetched. $i = 0; do { - // I query is empty, then don't do it. + // If the query is empty, then don't do it. // Not necessary to do in each iteration, but it doesn't hurt much. if (sizeof($query) == 0) { break; @@ -145,6 +146,7 @@ function ting_get_objects($ids) { } $i++; } while ($result->more); + return $objects; } From fb33aa9345cffa8f2a94a72b7ea8d74df3c80f25 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 17 Apr 2013 14:22:20 +0200 Subject: [PATCH 011/167] Patch: from https://github.com/ding2/ting/pull/7 adding series numbers --- ting.entities.inc | 24 ++++++++++++++++++------ ting.field.inc | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index aacf1b7..f0ecdea 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -33,6 +33,7 @@ class TingRelation extends DingEntityBase { */ class TingEntity extends DingEntity { public $type = DingEntityBase::NULL; + public $serieNumber = DingEntityBase::NULL; public $serieTitle = DingEntityBase::NULL; public $record = DingEntityBase::NULL; public $relations = DingEntityBase::NULL; @@ -115,16 +116,27 @@ class TingEntity extends DingEntity { return $title; } - function getSerieTitle() { - $serie_title = array(); + function getSerieNumber() { + $serie = $this->splitSerie(); + // Last part is the number. + if (empty($serie[1])) { + return FALSE; + } + return $serie[1]; + } + + private function splitSerie() { $serie = !empty($this->reply->record['dc:title']['dkdcplus:series'][0]) ? $this->reply->record['dc:title']['dkdcplus:series'][0] : ''; + return explode(';', $serie); + } - if (preg_match('/^([^;]+);/', $serie, $serie_title)) { - return isset($serie_title[1]) ? trim($serie_title[1]) : FALSE; - } - else { + function getSerieTitle() { + $serie = $this->splitSerie(); + // First part is the title. + if (empty($serie[0])) { return FALSE; } + return trim($serie[0]); } function getAbstract() { diff --git a/ting.field.inc b/ting.field.inc index 007150b..e810277 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -337,7 +337,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la if ($entity->serieTitle) { $element[$delta] = array( // should use phrase.title instead of dc.title but at the moment opensearch does not support the use of phrase.title - '#markup' => l(check_plain($entity->serieTitle), 'search/ting/' . variable_get('ting_admin_register_serie_title', 'dc.title') . '=' . drupal_strtolower($entity->serieTitle), array('attributes' => array('class' => array('series')))), + '#markup' => l(check_plain($entity->serieTitle), 'search/ting/' . variable_get('ting_admin_register_serie_title', 'dc.title') . '="' . drupal_strtolower($entity->serieTitle) . '"', array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), ); } break; From 734f97fb60999702b1473b7c781da80ce58868b7 Mon Sep 17 00:00:00 2001 From: Arni Date: Fri, 19 Apr 2013 14:25:20 +0200 Subject: [PATCH 012/167] Addes seriesdescription to ting.entities and used series description when there is no serietitle --- ting.entities.inc | 45 ++++++ ting.field.inc | 377 +++++++++++++++++++++++----------------------- 2 files changed, 233 insertions(+), 189 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index f0ecdea..98a0eb3 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -35,6 +35,7 @@ class TingEntity extends DingEntity { public $type = DingEntityBase::NULL; public $serieNumber = DingEntityBase::NULL; public $serieTitle = DingEntityBase::NULL; + public $serieDescription = DingEntityBase::NULL; public $record = DingEntityBase::NULL; public $relations = DingEntityBase::NULL; public $localId = DingEntityBase::NULL; @@ -138,6 +139,50 @@ class TingEntity extends DingEntity { } return trim($serie[0]); } + + function getSerieDescription() { + $serie = !empty($this->reply->record['dc:description']['dkdcplus:series'][0]) ? $this->reply->record['dc:description']['dkdcplus:series'][0] : ''; + return $this->process_series_description($serie); + } + + /** + * Process series information + * This could be handled more elegantly if we had better structured data. + * For now we have to work with what we got to convert titles to links + * Series information appear in the following formats: + * - Samhørende: [title 1] ; [title 2] ; [title 3] + * - [volumne number]. del af: [title] + */ + private function process_series_description($series) { + $result = ''; + $parts = explode(':', $series); + + if (is_array($parts) && count($parts >= 2)) { + $prefix = $parts[0] . ': '; + + if (stripos($prefix, 'del af:') !== FALSE) { + $title = $parts[1]; + $result = $prefix . l($title, 'search/ting/' . '"' . $title . '"'); + } else if (stripos($prefix, 'Samhørende:') !== FALSE) { + + $titles = $parts[1]; + // Multiple titles are separated by ' ; '. Explode to iterate over them + $titles = explode(' ; ', $titles); + foreach ($titles as &$title) { + $title = trim($title); + // Some title elements are actually volumne numbers. Do not convert these to links + if (!preg_match('/(nr.)? \d+/i', $title)) { + $title = l($title, 'search/ting/' . '"' . $title . '"'); + } + } + // Reassemple titles + $titles = implode(', ', $titles); + $result = $prefix . ' ' . $titles; + } + } + + return $result; + } function getAbstract() { return !empty($this->reply->record['dcterms:abstract'][''][0]) ? $this->reply->record['dcterms:abstract'][''][0] : FALSE; diff --git a/ting.field.inc b/ting.field.inc index e810277..ab99bb4 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -10,71 +10,71 @@ */ function ting_field_info() { return array( - // ting_object - 'ting_title' => array( - 'label' => t('Ting object title'), - 'description' => t('Ting object title'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_title_default', - 'no_ui' => TRUE, - ), - 'ting_type' => array( - 'label' => t('Ting object type'), - 'description' => t('Ting object type'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_type_default', - 'no_ui' => TRUE, - ), - 'ting_series' => array( - 'label' => t('Ting object series'), - 'description' => t('Ting object series'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_series_default', - 'no_ui' => TRUE, - ), - 'ting_abstract' => array( - 'label' => t('Ting object abstract'), - 'description' => t('Ting object abstract'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_abstract_default', - 'no_ui' => TRUE, - ), - 'ting_author' => array( - 'label' => t('Ting object author'), - 'description' => t('Ting object author'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_author_default', - 'no_ui' => TRUE, - ), - 'ting_subjects' => array( - 'label' => t('Ting object subjects'), - 'description' => t('Ting object subjects'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_subjects_default', - 'no_ui' => TRUE, - ), - // ting_collection - 'ting_primary_object' => array( - 'label' => t('Ting collection primary object'), - 'description' => t('Ting collection primary object'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_primary_object_default', - 'no_ui' => TRUE, - ), - 'ting_entities' => array( - 'label' => t('Ting collection listing'), - 'description' => t('Ting collection listing'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_entities_default', - 'no_ui' => TRUE, - ), - 'ting_collection_types' => array( - 'label' => t('Ting collection object types'), - 'description' => t('Ting collection object types'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_collection_types_default', - 'no_ui' => TRUE, - ), + // ting_object + 'ting_title' => array( + 'label' => t('Ting object title'), + 'description' => t('Ting object title'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_title_default', + 'no_ui' => TRUE, + ), + 'ting_type' => array( + 'label' => t('Ting object type'), + 'description' => t('Ting object type'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_type_default', + 'no_ui' => TRUE, + ), + 'ting_series' => array( + 'label' => t('Ting object series'), + 'description' => t('Ting object series'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_series_default', + 'no_ui' => TRUE, + ), + 'ting_abstract' => array( + 'label' => t('Ting object abstract'), + 'description' => t('Ting object abstract'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_abstract_default', + 'no_ui' => TRUE, + ), + 'ting_author' => array( + 'label' => t('Ting object author'), + 'description' => t('Ting object author'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_author_default', + 'no_ui' => TRUE, + ), + 'ting_subjects' => array( + 'label' => t('Ting object subjects'), + 'description' => t('Ting object subjects'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_subjects_default', + 'no_ui' => TRUE, + ), + // ting_collection + 'ting_primary_object' => array( + 'label' => t('Ting collection primary object'), + 'description' => t('Ting collection primary object'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_primary_object_default', + 'no_ui' => TRUE, + ), + 'ting_entities' => array( + 'label' => t('Ting collection listing'), + 'description' => t('Ting collection listing'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_entities_default', + 'no_ui' => TRUE, + ), + 'ting_collection_types' => array( + 'label' => t('Ting collection object types'), + 'description' => t('Ting collection object types'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_collection_types_default', + 'no_ui' => TRUE, + ), ); } @@ -84,14 +84,14 @@ function ting_field_info() { function ting_widget_info_alter(&$info) { if (isset($info['hidden'])) { $info['hidden']['field types'] += array( - 'ting_title', - 'ting_type', - 'ting_abstract', - 'ting_author', - 'ting_subjects', - 'ting_primary_object', - 'ting_entities', - 'ting_collection_types', + 'ting_title', + 'ting_type', + 'ting_abstract', + 'ting_author', + 'ting_subjects', + 'ting_primary_object', + 'ting_entities', + 'ting_collection_types', ); } } @@ -105,15 +105,14 @@ function ting_field_load($entity_type, $entities, $field, $instances, $langcode, foreach ($entities as $id => $entity) { foreach ($entity->entities as $ent) { $items[$id][] = array( - 'id' => $ent->id, + 'id' => $ent->id, ); } } - } - else { + } else { foreach ($entities as $id => $entity) { $items[$id][0] = array( - 'id' => $entity->id, + 'id' => $entity->id, ); } } @@ -124,70 +123,70 @@ function ting_field_load($entity_type, $entities, $field, $instances, $langcode, */ function ting_field_formatter_info() { return array( - 'ting_title_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_title', - ), - 'settings' => array( - 'link_type' => 'none', - ), - ), - 'ting_type_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_type', - ), - ), - 'ting_series_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_series', + 'ting_title_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_title', + ), + 'settings' => array( + 'link_type' => 'none', + ), ), - ), - 'ting_abstract_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_abstract', + 'ting_type_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_type', + ), ), - ), - 'ting_author_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_author', + 'ting_series_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_series', + ), ), - ), - 'ting_subjects_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_subjects', + 'ting_abstract_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_abstract', + ), ), - ), - 'ting_primary_object_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_primary_object', + 'ting_author_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_author', + ), ), - 'settings' => array( - 'view_mode' => 'teaser', + 'ting_subjects_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_subjects', + ), ), - ), - 'ting_entities_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_entities', + 'ting_primary_object_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_primary_object', + ), + 'settings' => array( + 'view_mode' => 'teaser', + ), ), - 'settings' => array( - 'hide_primary' => TRUE, - 'view_mode' => 'teaser', + 'ting_entities_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_entities', + ), + 'settings' => array( + 'hide_primary' => TRUE, + 'view_mode' => 'teaser', + ), ), - ), - 'ting_collection_types_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_collection_types', + 'ting_collection_types_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_collection_types', + ), ), - ), ); } @@ -202,22 +201,22 @@ function ting_field_formatter_settings_form($field, $instance, $view_mode, $form switch ($field['type']) { case 'ting_title': $element['link_type'] = array( - '#type' => 'radios', - '#title' => t('Link title to'), - '#options' => array( - 'none' => t("Don't link"), - 'object' => t('Object'), - 'collection' => t('Collection, if part of a collection'), - ), - '#default_value' => $settings['link_type'], + '#type' => 'radios', + '#title' => t('Link title to'), + '#options' => array( + 'none' => t("Don't link"), + 'object' => t('Object'), + 'collection' => t('Collection, if part of a collection'), + ), + '#default_value' => $settings['link_type'], ); break; case 'ting_entities': $element['hide_primary'] = array( - '#type' => 'checkbox', - '#title' => t('Hide primary'), - '#description' => t("Don't show the primary object as part of the list."), - '#default_value' => $settings['hide_primary'], + '#type' => 'checkbox', + '#title' => t('Hide primary'), + '#description' => t("Don't show the primary object as part of the list."), + '#default_value' => $settings['hide_primary'], ); case 'ting_primary_object': $entity_info = entity_get_info('ting_object'); @@ -227,12 +226,12 @@ function ting_field_formatter_settings_form($field, $instance, $view_mode, $form } $element['view_mode'] = array( - '#title' => t('View mode'), - '#type' => 'select', - '#default_value' => $settings['view_mode'], - '#options' => $view_modes, + '#title' => t('View mode'), + '#type' => 'select', + '#default_value' => $settings['view_mode'], + '#options' => $view_modes, ); - break; + break; } return $element; @@ -265,7 +264,6 @@ function ting_field_formatter_settings_summary($field, $instance, $view_mode) { return $summary; } - /** * Implements hook_field_formatter_view(). */ @@ -282,7 +280,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la foreach ($entity->types as $type) { $element[0][$type] = array( - '#prefix' => '

' . $type . '

', + '#prefix' => '

' . $type . '

', ); } foreach ($entities as $sub_entity) { @@ -303,47 +301,50 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la */ $type = 'ting_object'; if ($display['settings']['link_type'] == 'collection') { - // // Check if the cache contains an collection for this id. - // $x = ting_cache_get($entity->id); - // if ($x instanceof TingClientObjectCollection) { - $type = 'ting_collection'; - // } + // // Check if the cache contains an collection for this id. + // $x = ting_cache_get($entity->id); + // if ($x instanceof TingClientObjectCollection) { + $type = 'ting_collection'; + // } } if ($display['settings']['link_type'] != 'none') { $url = entity_uri($type, $entity); $title = l($entity->title, $url['path'], $url['options']); - } - else { + } else { $title = check_plain($entity->title); } $element[$delta] = array( - '#prefix' => '

', - '#suffix' => '

', - '#markup' => $title, + '#prefix' => '

', + '#suffix' => '

', + '#markup' => $title, ); break; case 'ting_type_default': $element[$delta] = array( - '#theme' => 'item_list', - '#items' => array( - array( - 'data' => $entity->type, - 'class' => array(drupal_html_class($entity->type)), - ) - ), + '#theme' => 'item_list', + '#items' => array( + array( + 'data' => $entity->type, + 'class' => array(drupal_html_class($entity->type)), + ) + ), ); break; case 'ting_series_default': if ($entity->serieTitle) { $element[$delta] = array( - // should use phrase.title instead of dc.title but at the moment opensearch does not support the use of phrase.title - '#markup' => l(check_plain($entity->serieTitle), 'search/ting/' . variable_get('ting_admin_register_serie_title', 'dc.title') . '="' . drupal_strtolower($entity->serieTitle) . '"', array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), - ); + // should use phrase.title instead of dc.title but at the moment opensearch does not support the use of phrase.title + '#markup' => l(check_plain($entity->serieTitle), 'search/ting/' . variable_get('ting_admin_register_serie_title', 'dc.title') . '="' . drupal_strtolower($entity->serieTitle) . '"', array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), + ); + }else if ($entity->serieDescription){ + $element[$delta] = array( + '#markup' => $entity->serieDescription, + ); } break; case 'ting_abstract_default': $element[$delta] = array( - '#markup' => check_plain($entity->abstract), + '#markup' => check_plain($entity->abstract), ); break; case 'ting_author_default': @@ -355,22 +356,20 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la if (count($creators)) { if ($entity->date != '') { $markup_string = t('By !author_link (@year)', array( - '!author_link' => implode(', ', $creators), - '@year' => $entity->date, // So wrong, but appears to - // be the way the data is. - )); - } - else { + '!author_link' => implode(', ', $creators), + '@year' => $entity->date, // So wrong, but appears to + // be the way the data is. + )); + } else { $markup_string = t('By !author_link', array( - '!author_link' => implode(', ', $creators), - )); + '!author_link' => implode(', ', $creators), + )); } + } elseif ($entity->date != '') { + $markup_string = t('(@year)', array('@year' => $entity->date)); } - elseif($entity->date != '') { - $markup_string = t('(@year)', array('@year'=>$entity->date)); - } $element[$delta] = array( - '#markup' => $markup_string, + '#markup' => $markup_string, ); break; case 'ting_subjects_default': @@ -380,7 +379,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la $subjects[] = l($subject, 'search/ting/dc.subject=' . $subject, array('attributes' => array('class' => array('subject')))); } $element[$delta] = array( - '#markup' => implode(' ', $subjects), + '#markup' => implode(' ', $subjects), ); } break; @@ -391,13 +390,13 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la $types = array(); foreach ($entity->types as $type) { $types[] = array( - 'data' => $type, - 'class' => array(drupal_html_class($type)), + 'data' => $type, + 'class' => array(drupal_html_class($type)), ); } $element[$delta] = array( - '#theme' => 'item_list', - '#items' => $types, + '#theme' => 'item_list', + '#items' => $types, ); break; } From f8f8452f59803d4ceab61d7c98800b83e5422184 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 19 Apr 2013 15:50:19 +0200 Subject: [PATCH 013/167] Fixed idention --- ting.field.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ting.field.inc b/ting.field.inc index e810277..7ec5b40 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -366,9 +366,9 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la )); } } - elseif($entity->date != '') { - $markup_string = t('(@year)', array('@year'=>$entity->date)); - } + elseif($entity->date != '') { + $markup_string = t('(@year)', array('@year'=>$entity->date)); + } $element[$delta] = array( '#markup' => $markup_string, ); From faef2c8d7881c47389657db9fa709df219da4a21 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 19 Apr 2013 16:32:02 +0200 Subject: [PATCH 014/167] Only link ting entity title if the entity is available in the datawell --- ting.field.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ting.field.inc b/ting.field.inc index 9ba2cf8..f56dcd6 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -307,7 +307,8 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la $type = 'ting_collection'; // } } - if ($display['settings']['link_type'] != 'none') { + // Only create the link if the object is available in the datawell. + if ($display['settings']['link_type'] != 'none' && !isset($entity->is_available)) { $url = entity_uri($type, $entity); $title = l($entity->title, $url['path'], $url['options']); } else { From 70525b7ffdf1a3638b44bdb35b108d7d326bdc76 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 22 Apr 2013 20:56:12 +0200 Subject: [PATCH 015/167] Stream line of make file --- ting.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.make b/ting.make index 13a0e4d..63be4d7 100644 --- a/ting.make +++ b/ting.make @@ -3,10 +3,10 @@ core = 7.x ; Contrib -projects[nanosoap][subdir] = contrib +projects[nanosoap][subdir] = "contrib" projects[nanosoap][version] = "1.0" -projects[virtual_field][subdir] = contrib +projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From 25d54c93a4d5f6aa6eb437fe6469a510cb4d4afa Mon Sep 17 00:00:00 2001 From: Arni Date: Tue, 30 Apr 2013 10:53:55 +0200 Subject: [PATCH 016/167] Fixed indention --- ting.field.inc | 355 ++++++++++++++++++++++++------------------------- 1 file changed, 177 insertions(+), 178 deletions(-) diff --git a/ting.field.inc b/ting.field.inc index f56dcd6..be038f3 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -10,71 +10,71 @@ */ function ting_field_info() { return array( - // ting_object - 'ting_title' => array( - 'label' => t('Ting object title'), - 'description' => t('Ting object title'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_title_default', - 'no_ui' => TRUE, - ), - 'ting_type' => array( - 'label' => t('Ting object type'), - 'description' => t('Ting object type'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_type_default', - 'no_ui' => TRUE, - ), - 'ting_series' => array( - 'label' => t('Ting object series'), - 'description' => t('Ting object series'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_series_default', - 'no_ui' => TRUE, - ), - 'ting_abstract' => array( - 'label' => t('Ting object abstract'), - 'description' => t('Ting object abstract'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_abstract_default', - 'no_ui' => TRUE, - ), - 'ting_author' => array( - 'label' => t('Ting object author'), - 'description' => t('Ting object author'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_author_default', - 'no_ui' => TRUE, - ), - 'ting_subjects' => array( - 'label' => t('Ting object subjects'), - 'description' => t('Ting object subjects'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_subjects_default', - 'no_ui' => TRUE, - ), - // ting_collection - 'ting_primary_object' => array( - 'label' => t('Ting collection primary object'), - 'description' => t('Ting collection primary object'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_primary_object_default', - 'no_ui' => TRUE, - ), - 'ting_entities' => array( - 'label' => t('Ting collection listing'), - 'description' => t('Ting collection listing'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_entities_default', - 'no_ui' => TRUE, - ), - 'ting_collection_types' => array( - 'label' => t('Ting collection object types'), - 'description' => t('Ting collection object types'), - 'default_widget' => 'hidden', - 'default_formatter' => 'ting_collection_types_default', - 'no_ui' => TRUE, - ), + // ting_object + 'ting_title' => array( + 'label' => t('Ting object title'), + 'description' => t('Ting object title'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_title_default', + 'no_ui' => TRUE, + ), + 'ting_type' => array( + 'label' => t('Ting object type'), + 'description' => t('Ting object type'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_type_default', + 'no_ui' => TRUE, + ), + 'ting_series' => array( + 'label' => t('Ting object series'), + 'description' => t('Ting object series'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_series_default', + 'no_ui' => TRUE, + ), + 'ting_abstract' => array( + 'label' => t('Ting object abstract'), + 'description' => t('Ting object abstract'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_abstract_default', + 'no_ui' => TRUE, + ), + 'ting_author' => array( + 'label' => t('Ting object author'), + 'description' => t('Ting object author'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_author_default', + 'no_ui' => TRUE, + ), + 'ting_subjects' => array( + 'label' => t('Ting object subjects'), + 'description' => t('Ting object subjects'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_subjects_default', + 'no_ui' => TRUE, + ), + // ting_collection + 'ting_primary_object' => array( + 'label' => t('Ting collection primary object'), + 'description' => t('Ting collection primary object'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_primary_object_default', + 'no_ui' => TRUE, + ), + 'ting_entities' => array( + 'label' => t('Ting collection listing'), + 'description' => t('Ting collection listing'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_entities_default', + 'no_ui' => TRUE, + ), + 'ting_collection_types' => array( + 'label' => t('Ting collection object types'), + 'description' => t('Ting collection object types'), + 'default_widget' => 'hidden', + 'default_formatter' => 'ting_collection_types_default', + 'no_ui' => TRUE, + ), ); } @@ -84,14 +84,14 @@ function ting_field_info() { function ting_widget_info_alter(&$info) { if (isset($info['hidden'])) { $info['hidden']['field types'] += array( - 'ting_title', - 'ting_type', - 'ting_abstract', - 'ting_author', - 'ting_subjects', - 'ting_primary_object', - 'ting_entities', - 'ting_collection_types', + 'ting_title', + 'ting_type', + 'ting_abstract', + 'ting_author', + 'ting_subjects', + 'ting_primary_object', + 'ting_entities', + 'ting_collection_types', ); } } @@ -105,14 +105,14 @@ function ting_field_load($entity_type, $entities, $field, $instances, $langcode, foreach ($entities as $id => $entity) { foreach ($entity->entities as $ent) { $items[$id][] = array( - 'id' => $ent->id, + 'id' => $ent->id, ); } } } else { foreach ($entities as $id => $entity) { $items[$id][0] = array( - 'id' => $entity->id, + 'id' => $entity->id, ); } } @@ -123,70 +123,70 @@ function ting_field_load($entity_type, $entities, $field, $instances, $langcode, */ function ting_field_formatter_info() { return array( - 'ting_title_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_title', - ), - 'settings' => array( - 'link_type' => 'none', - ), + 'ting_title_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_title', ), - 'ting_type_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_type', - ), + 'settings' => array( + 'link_type' => 'none', ), - 'ting_series_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_series', - ), + ), + 'ting_type_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_type', ), - 'ting_abstract_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_abstract', - ), + ), + 'ting_series_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_series', ), - 'ting_author_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_author', - ), + ), + 'ting_abstract_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_abstract', ), - 'ting_subjects_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_subjects', - ), + ), + 'ting_author_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_author', ), - 'ting_primary_object_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_primary_object', - ), - 'settings' => array( - 'view_mode' => 'teaser', - ), + ), + 'ting_subjects_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_subjects', ), - 'ting_entities_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_entities', - ), - 'settings' => array( - 'hide_primary' => TRUE, - 'view_mode' => 'teaser', - ), + ), + 'ting_primary_object_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_primary_object', ), - 'ting_collection_types_default' => array( - 'label' => t('Default'), - 'field types' => array( - 'ting_collection_types', - ), + 'settings' => array( + 'view_mode' => 'teaser', + ), + ), + 'ting_entities_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_entities', + ), + 'settings' => array( + 'hide_primary' => TRUE, + 'view_mode' => 'teaser', + ), + ), + 'ting_collection_types_default' => array( + 'label' => t('Default'), + 'field types' => array( + 'ting_collection_types', ), + ), ); } @@ -201,22 +201,22 @@ function ting_field_formatter_settings_form($field, $instance, $view_mode, $form switch ($field['type']) { case 'ting_title': $element['link_type'] = array( - '#type' => 'radios', - '#title' => t('Link title to'), - '#options' => array( - 'none' => t("Don't link"), - 'object' => t('Object'), - 'collection' => t('Collection, if part of a collection'), - ), - '#default_value' => $settings['link_type'], + '#type' => 'radios', + '#title' => t('Link title to'), + '#options' => array( + 'none' => t("Don't link"), + 'object' => t('Object'), + 'collection' => t('Collection, if part of a collection'), + ), + '#default_value' => $settings['link_type'], ); break; case 'ting_entities': $element['hide_primary'] = array( - '#type' => 'checkbox', - '#title' => t('Hide primary'), - '#description' => t("Don't show the primary object as part of the list."), - '#default_value' => $settings['hide_primary'], + '#type' => 'checkbox', + '#title' => t('Hide primary'), + '#description' => t("Don't show the primary object as part of the list."), + '#default_value' => $settings['hide_primary'], ); case 'ting_primary_object': $entity_info = entity_get_info('ting_object'); @@ -226,10 +226,10 @@ function ting_field_formatter_settings_form($field, $instance, $view_mode, $form } $element['view_mode'] = array( - '#title' => t('View mode'), - '#type' => 'select', - '#default_value' => $settings['view_mode'], - '#options' => $view_modes, + '#title' => t('View mode'), + '#type' => 'select', + '#default_value' => $settings['view_mode'], + '#options' => $view_modes, ); break; } @@ -280,7 +280,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la foreach ($entity->types as $type) { $element[0][$type] = array( - '#prefix' => '

' . $type . '

', + '#prefix' => '

' . $type . '

', ); } foreach ($entities as $sub_entity) { @@ -315,37 +315,37 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la $title = check_plain($entity->title); } $element[$delta] = array( - '#prefix' => '

', - '#suffix' => '

', - '#markup' => $title, + '#prefix' => '

', + '#suffix' => '

', + '#markup' => $title, ); break; case 'ting_type_default': $element[$delta] = array( - '#theme' => 'item_list', - '#items' => array( - array( - 'data' => $entity->type, - 'class' => array(drupal_html_class($entity->type)), - ) - ), + '#theme' => 'item_list', + '#items' => array( + array( + 'data' => $entity->type, + 'class' => array(drupal_html_class($entity->type)), + ) + ), ); break; case 'ting_series_default': if ($entity->serieTitle) { $element[$delta] = array( - // should use phrase.title instead of dc.title but at the moment opensearch does not support the use of phrase.title - '#markup' => l(check_plain($entity->serieTitle), 'search/ting/' . variable_get('ting_admin_register_serie_title', 'dc.title') . '="' . drupal_strtolower($entity->serieTitle) . '"', array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), - ); - }else if ($entity->serieDescription){ + // should use phrase.title instead of dc.title but at the moment opensearch does not support the use of phrase.title + '#markup' => l(check_plain($entity->serieTitle), 'search/ting/' . variable_get('ting_admin_register_serie_title', 'dc.title') . '="' . drupal_strtolower($entity->serieTitle) . '"', array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), + ); + } else if ($entity->serieDescription) { $element[$delta] = array( - '#markup' => $entity->serieDescription, - ); + '#markup' => $entity->serieDescription, + ); } break; case 'ting_abstract_default': $element[$delta] = array( - '#markup' => check_plain($entity->abstract), + '#markup' => check_plain($entity->abstract), ); break; case 'ting_author_default': @@ -357,21 +357,20 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la if (count($creators)) { if ($entity->date != '') { $markup_string = t('By !author_link (@year)', array( - '!author_link' => implode(', ', $creators), - '@year' => $entity->date, // So wrong, but appears to - // be the way the data is. - )); + '!author_link' => implode(', ', $creators), + '@year' => $entity->date, // So wrong, but appears to + // be the way the data is. + )); } else { $markup_string = t('By !author_link', array( - '!author_link' => implode(', ', $creators), - )); + '!author_link' => implode(', ', $creators), + )); } - } - else if ($entity->date != '') { + } else if ($entity->date != '') { $markup_string = t('(@year)', array('@year' => $entity->date)); } $element[$delta] = array( - '#markup' => $markup_string, + '#markup' => $markup_string, ); break; case 'ting_subjects_default': @@ -381,7 +380,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la $subjects[] = l($subject, 'search/ting/dc.subject=' . $subject, array('attributes' => array('class' => array('subject')))); } $element[$delta] = array( - '#markup' => implode(' ', $subjects), + '#markup' => implode(' ', $subjects), ); } break; @@ -392,13 +391,13 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la $types = array(); foreach ($entity->types as $type) { $types[] = array( - 'data' => $type, - 'class' => array(drupal_html_class($type)), + 'data' => $type, + 'class' => array(drupal_html_class($type)), ); } $element[$delta] = array( - '#theme' => 'item_list', - '#items' => $types, + '#theme' => 'item_list', + '#items' => $types, ); break; } From afecbbd63b95d9fd650c30786588c234827ad53d Mon Sep 17 00:00:00 2001 From: Arni Date: Tue, 30 Apr 2013 11:51:09 +0200 Subject: [PATCH 017/167] Series search made configurable --- ting.admin.inc | 4 ++-- ting.field.inc | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index f1446ee..436600d 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -366,8 +366,8 @@ function ting_admin_register_settings() { $form['ting_admin_register_serie_title'] = array( '#type' => 'textfield', '#title' => t('Serie title'), - '#description' => t('Specify the register to be used for searching against serie titles.'), - '#default_value' => variable_get('ting_admin_register_serie_title', 'bib.titleSeries') + '#description' => t('Specify the searchstring to be used for searching against serie titles. Use @serietitle as a placeholder for the serietitle'), + '#default_value' => variable_get('ting_admin_register_serie_title', 'bib.titleSeries="@serietitle" OR dc.description="@serietitle"') ); $form['#submit'][] = 'ting_search_extendform_admin_settings_submit'; diff --git a/ting.field.inc b/ting.field.inc index be038f3..bfb8328 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -333,9 +333,12 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la break; case 'ting_series_default': if ($entity->serieTitle) { + // The search string used is configurable because the datawell is not fully implemented regarding series. + // As default we search both in the serietitle register and the description field because many series only have data in the description field. + // This will problably change with new versions of the datawell. + $search_term = str_replace('@serietitle' , drupal_strtolower($entity->serieTitle),variable_get('ting_admin_register_serie_title', 'bib.titleSeries="@serietitle" OR dc.description="@serietitle"')); $element[$delta] = array( - // should use phrase.title instead of dc.title but at the moment opensearch does not support the use of phrase.title - '#markup' => l(check_plain($entity->serieTitle), 'search/ting/' . variable_get('ting_admin_register_serie_title', 'dc.title') . '="' . drupal_strtolower($entity->serieTitle) . '"', array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), + '#markup' => l(check_plain($entity->serieTitle), 'search/ting/' . $search_term , array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), ); } else if ($entity->serieDescription) { $element[$delta] = array( From e1afc1413013f3239bba3586c2e41279e05805a4 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 6 May 2013 11:28:29 +0200 Subject: [PATCH 018/167] Changed makefile to point to ding2 on github --- ting.make | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ting.make b/ting.make index 63be4d7..1bf6f74 100644 --- a/ting.make +++ b/ting.make @@ -13,12 +13,12 @@ projects[virtual_field][version] = "1.1" ; Libraries libraries[ting-client][download][type] = "git" -libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" +libraries[ting-client][download][url] = "git@github.com:ding2/ting-client.git" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules 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" From 0f377762dacb31c0dfb4c7b17eedb7d68142480d Mon Sep 17 00:00:00 2001 From: Arni Date: Wed, 15 May 2013 10:35:47 +0200 Subject: [PATCH 019/167] Fixed encoding issues for seriestitles --- ting.field.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.field.inc b/ting.field.inc index bfb8328..a72f308 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -338,7 +338,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la // This will problably change with new versions of the datawell. $search_term = str_replace('@serietitle' , drupal_strtolower($entity->serieTitle),variable_get('ting_admin_register_serie_title', 'bib.titleSeries="@serietitle" OR dc.description="@serietitle"')); $element[$delta] = array( - '#markup' => l(check_plain($entity->serieTitle), 'search/ting/' . $search_term , array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), + '#markup' => l($entity->serieTitle, 'search/ting/' . $search_term , array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), ); } else if ($entity->serieDescription) { $element[$delta] = array( From c9f72072475273626d68b7658ec60d2cb569752e Mon Sep 17 00:00:00 2001 From: Arni Date: Tue, 28 May 2013 11:45:49 +0200 Subject: [PATCH 020/167] Added collectiontype as parameter to Open Search request --- ting.client.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ting.client.inc b/ting.client.inc index 8f75589..e1cadee 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -168,6 +168,7 @@ function ting_get_objects($ids) { * - rank: The ranking type, as defined in the XSD. * - supportingTypes: Whether to include supporting types such as reviews. Default: false * - reply_only: Don't change the result objects to TingCollection objects. + * - collectionType: The type of results to return. Single manifestions(object) or works (collections). Possible values manifestion,work or work-1. Defaults to work. * @return TingClientSearchResult * The search result */ @@ -194,6 +195,9 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar if (isset($options['sort']) && $options['sort']) { $request->setSort($options['sort']); } + if (isset($options['collectionType'])) { + $request->setCollectionType($options['collectionType']); + } $request->setAllObjects(isset($options['allObjects']) ? $options['allObjects'] : FALSE); // Set search profile, if applicable. From d98971e7bddeba2a3ccfc243f7457b014222eafa Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 3 Jun 2013 15:41:58 +0200 Subject: [PATCH 021/167] Updated codeing style --- ting.field.inc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ting.field.inc b/ting.field.inc index bfb8328..ff95343 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -311,7 +311,8 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la if ($display['settings']['link_type'] != 'none' && !isset($entity->is_available)) { $url = entity_uri($type, $entity); $title = l($entity->title, $url['path'], $url['options']); - } else { + } + else { $title = check_plain($entity->title); } $element[$delta] = array( @@ -320,6 +321,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la '#markup' => $title, ); break; + case 'ting_type_default': $element[$delta] = array( '#theme' => 'item_list', @@ -331,6 +333,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la ), ); break; + case 'ting_series_default': if ($entity->serieTitle) { // The search string used is configurable because the datawell is not fully implemented regarding series. @@ -340,17 +343,20 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la $element[$delta] = array( '#markup' => l(check_plain($entity->serieTitle), 'search/ting/' . $search_term , array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), ); - } else if ($entity->serieDescription) { + } + else if ($entity->serieDescription) { $element[$delta] = array( '#markup' => $entity->serieDescription, ); } break; + case 'ting_abstract_default': $element[$delta] = array( '#markup' => check_plain($entity->abstract), ); break; + case 'ting_author_default': $creators = array(); foreach ($entity->creators as $i => $creator) { @@ -364,18 +370,21 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la '@year' => $entity->date, // So wrong, but appears to // be the way the data is. )); - } else { + } + else { $markup_string = t('By !author_link', array( '!author_link' => implode(', ', $creators), - )); + )); } - } else if ($entity->date != '') { + } + else if ($entity->date != '') { $markup_string = t('(@year)', array('@year' => $entity->date)); } $element[$delta] = array( '#markup' => $markup_string, ); break; + case 'ting_subjects_default': if (count($entity->subjects) == TRUE) { $subjects = array(); @@ -387,9 +396,11 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la ); } break; + case 'ting_primary_object_default': $element[$delta] = ting_object_view($entity->primary_object, $display['settings']['view_mode']); break; + case 'ting_collection_types_default': $types = array(); foreach ($entity->types as $type) { From 811d664f379f644d1b8c1ede0d921fc08de693b2 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 3 Jun 2013 15:58:16 +0200 Subject: [PATCH 022/167] Renamed hook_anchor_info() to hook_ding_anchor_info() --- ting.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.module b/ting.module index 884766b..02d28d0 100644 --- a/ting.module +++ b/ting.module @@ -252,7 +252,7 @@ function ting_block_view($delta = '') { if( $object = menu_get_object('ting_object',2) ) { $relations = ting_get_relations($object); if (!empty($relations)) { - $relation_types = module_invoke_all('anchor_info'); + $relation_types = module_invoke_all('ding_anchor_info'); $block['subject'] = array( '#markup' => t('About the material'), '#prefix' => '
', From 5c37c59de001efd273180ebf3a1f3fb6cfbfc10a Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 3 Jun 2013 15:59:30 +0200 Subject: [PATCH 023/167] Updated makefile to point to ding2tal --- ting.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.make b/ting.make index 1bf6f74..acee33d 100644 --- a/ting.make +++ b/ting.make @@ -13,12 +13,12 @@ projects[virtual_field][version] = "1.1" ; Libraries libraries[ting-client][download][type] = "git" -libraries[ting-client][download][url] = "git@github.com:ding2/ting-client.git" +libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules 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" From 547ec1f18f677209610a4e6d66df66231c83d230 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 5 Jun 2013 14:30:44 +0200 Subject: [PATCH 024/167] Fixed: trying to get non-object property when search is false --- ting.client.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ting.client.inc b/ting.client.inc index 8f75589..34508a8 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -144,6 +144,11 @@ function ting_get_objects($ids) { } } } + else { + // Result was false, hence the more property used in the while do not + // exists + break; + } $i++; } while ($result->more); From cf09a24430aa28a3187dcc6eb854810ce8419c9f Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 24 Jun 2013 15:03:20 +0200 Subject: [PATCH 025/167] Changed makefile to use development branch --- ting.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.make b/ting.make index acee33d..63be4d7 100644 --- a/ting.make +++ b/ting.make @@ -21,4 +21,4 @@ libraries[ting-client][destination] = "modules/ting/lib" 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" From 15a26d6b90173e63a91713d3ebbce226e96f682f Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 27 Jun 2013 11:13:16 +0200 Subject: [PATCH 026/167] Fixed ding_entity_id lenght (256 -> 255), so it do not break installation profile --- ting.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.install b/ting.install index 1fa37ba..e1a0e03 100644 --- a/ting.install +++ b/ting.install @@ -30,7 +30,7 @@ function ting_schema() { 'ding_entity_id' => array( 'description' => 'The ting object id.', 'type' => 'varchar', - 'length' => 256, + 'length' => 255, 'not null' => TRUE, 'default' => '', ), From a81c70a5d9855ee2f87cace8f45c174fba1b83bd Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 3 Jul 2013 13:36:02 +0200 Subject: [PATCH 027/167] Updated makefile to point to development branch and ding2tal --- ting.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.make b/ting.make index acee33d..63be4d7 100644 --- a/ting.make +++ b/ting.make @@ -21,4 +21,4 @@ libraries[ting-client][destination] = "modules/ting/lib" 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" From a1bf1d1464ca28184c606ee129877c8538fc6984 Mon Sep 17 00:00:00 2001 From: AnatolyMuntean Date: Wed, 7 Nov 2012 11:14:15 +0200 Subject: [PATCH 028/167] Resolved merge conflict in getClassification() --- ting.entities.inc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index 98a0eb3..636ac95 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -57,10 +57,21 @@ class TingEntity extends DingEntity { } function getClassification() { - $ret = (isset($this->reply->record['dc:subject']['dkdcplus:DK5'][0]) ? $this->reply->record['dc:subject']['dkdcplus:DK5'][0] : '' . - (isset($this->reply->record['dc:subject']['dkdcplus:DK5-Text']) ? ' (' . $this->reply->record['dc:subject']['dkdcplus:DK5-Text'][0] . ')' : '')); - if( strlen($ret) > 0 ) { - return $ret; + $dk5 = ''; + if (!empty($this->reply->record['dc:subject']['dkdcplus:DK5'][0])) { + $dk5 = $this->reply->record['dc:subject']['dkdcplus:DK5'][0]; + $dk5_text = ''; + + if (!empty($this->reply->record['dc:subject']['dkdcplus:DK5-Text'][0])) { + $dk5_text = $this->reply->record['dc:subject']['dkdcplus:DK5-Text'][0]; + } + + if ($dk5 == 'sk') { + return $dk5_text; + } + else { + return $dk5 . ' ' . $dk5_text; + } } return FALSE; } From 944bd050d19b0e3ce52de55acee7ceed98a1fc54 Mon Sep 17 00:00:00 2001 From: AnatolyMuntean Date: Fri, 9 Nov 2012 17:00:49 +0200 Subject: [PATCH 029/167] Resolved merge conflict in block view --- ting.module | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ting.module b/ting.module index 02d28d0..7e5120d 100644 --- a/ting.module +++ b/ting.module @@ -225,7 +225,10 @@ function ting_block_info() { function ting_get_relations($ting_entity) { $relations = array(); - foreach( $ting_entity->relations as $relation ) { + foreach ($ting_entity->relations as $k => $relation) { + if ($k == 'dbcaddi:hasOpenUrl' || $k == 'dbcaddi:hasOnlineAccess') { + continue; + } $relations[$relation->type][] = $relation; } @@ -265,11 +268,10 @@ function ting_block_view($delta = '') { $items[] = l($relation_types[$key].' ('.count($relation).') ','#'.$key,array('external'=>TRUE)); } } - $block['content'] = - array( + $block['content'] = array( '#theme' => 'item_list', '#items' => $items, - ); + ); } } From 8b9603bb7408b57121d4289825770ad479276e7f Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 17 Jul 2013 15:27:24 +0200 Subject: [PATCH 030/167] Corrected relations anchors --- ting.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.module b/ting.module index 7e5120d..34819d1 100644 --- a/ting.module +++ b/ting.module @@ -225,8 +225,8 @@ function ting_block_info() { function ting_get_relations($ting_entity) { $relations = array(); - foreach ($ting_entity->relations as $k => $relation) { - if ($k == 'dbcaddi:hasOpenUrl' || $k == 'dbcaddi:hasOnlineAccess') { + foreach ($ting_entity->relations as $relation) { + if ($relation->type == 'dbcaddi:hasOpenUrl' || $relation->type == 'dbcaddi:hasOnlineAccess') { continue; } $relations[$relation->type][] = $relation; From 984d181551f315cc8ed260f81f0c4e1750f2b222 Mon Sep 17 00:00:00 2001 From: Anatoly Muntean Date: Tue, 15 Jan 2013 12:36:55 +0200 Subject: [PATCH 031/167] case 2048 - Cleanup. --- ting.api.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/ting.api.php b/ting.api.php index 3bd05be..e119711 100644 --- a/ting.api.php +++ b/ting.api.php @@ -4,19 +4,3 @@ * @file * Hooks provided by the Ting module. */ - -/** - * @addtogroup hooks - * @{ - */ - -/** - * Modify ting objects online URL. - */ -function hook_ting_online_url_alter(&$url, $entity) { - -} - -/** - * @} End of "addtogroup hooks". - */ From 4fa249db04617549d88f5ead6bf7d149d0dbeb1c Mon Sep 17 00:00:00 2001 From: George Mihailov Date: Wed, 20 Feb 2013 16:37:22 +0200 Subject: [PATCH 032/167] case 2220 - Remove dk5-text beside material availability on materialdisplay. --- ting.entities.inc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index 636ac95..2a8d171 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -60,17 +60,9 @@ class TingEntity extends DingEntity { $dk5 = ''; if (!empty($this->reply->record['dc:subject']['dkdcplus:DK5'][0])) { $dk5 = $this->reply->record['dc:subject']['dkdcplus:DK5'][0]; - $dk5_text = ''; - - if (!empty($this->reply->record['dc:subject']['dkdcplus:DK5-Text'][0])) { - $dk5_text = $this->reply->record['dc:subject']['dkdcplus:DK5-Text'][0]; - } if ($dk5 == 'sk') { - return $dk5_text; - } - else { - return $dk5 . ' ' . $dk5_text; + return ''; } } return FALSE; From 89f28b064a5445bc46074413c8e6b4e88e7dd180 Mon Sep 17 00:00:00 2001 From: Alex Semeniuc Date: Fri, 5 Apr 2013 13:00:46 +0300 Subject: [PATCH 033/167] Resolved merge conflict in template_preprocess_ting_object() --- ting.theme.inc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ting.theme.inc b/ting.theme.inc index 6be71cf..2dcd35b 100644 --- a/ting.theme.inc +++ b/ting.theme.inc @@ -23,6 +23,15 @@ function template_preprocess_ting_object(&$variables) { $variables['content']['overview']['types'][] = $key; } } + + // Modify 'alt' attribute for list items. + if (!empty($variables['content']['ting_cover']) && !empty($variables['content']['group_collection_list'])) { + $variables['content']['ting_cover'][0]['#alt'] = implode(' ', array( + $variables['object']->title, + $variables['object']->type, + $variables['object']->date, + )); + } } /** From b82b3157f2b67d484ffbabd5abe71a6583253bb8 Mon Sep 17 00:00:00 2001 From: Alex Semeniuc Date: Thu, 18 Apr 2013 17:21:41 +0300 Subject: [PATCH 034/167] Case 2616 - Added ISBN to entity. --- ting.entities.inc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ting.entities.inc b/ting.entities.inc index 2a8d171..30ed843 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -51,6 +51,7 @@ class TingEntity extends DingEntity { public $isPartOf = DingEntityBase::NULL; public $extent = DingEntityBase::NULL; public $classification = DingEntityBase::NULL; + public $isbn = DingEntityBase::NULL; public function getExtent() { return !empty($this->reply->record['dcterms:extent'][''][0]) ? $this->reply->record['dcterms:extent'][''][0] : FALSE; @@ -273,6 +274,23 @@ class TingEntity extends DingEntity { function getDescription() { return !empty($this->reply->record['dc:description'][''][0]) ? $this->reply->record['dc:description'][''][0] : FALSE; } + + /** + * Get ISBN numbers of the object. + * + * @return array + */ + function getIsbn() { + $isbn = null; + if (!empty($this->reply->record['dc:identifier']['dkdcplus:ISBN'])) { + $isbn = $this->reply->record['dc:identifier']['dkdcplus:ISBN']; + foreach ($isbn as $k => $number) { + $isbn[$k] = str_replace(array(' ', '-'), '', $number); + } + rsort($isbn); + } + return $isbn; + } } /** From 836010c375224ef331ea651ca7f2ffbbee5f8e4b Mon Sep 17 00:00:00 2001 From: Alex Semeniuc Date: Fri, 19 Apr 2013 12:03:08 +0300 Subject: [PATCH 035/167] Case 2616 - Code review. --- ting.entities.inc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index 30ed843..b54451d 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -281,16 +281,22 @@ class TingEntity extends DingEntity { * @return array */ function getIsbn() { - $isbn = null; - if (!empty($this->reply->record['dc:identifier']['dkdcplus:ISBN'])) { - $isbn = $this->reply->record['dc:identifier']['dkdcplus:ISBN']; - foreach ($isbn as $k => $number) { - $isbn[$k] = str_replace(array(' ', '-'), '', $number); - } - rsort($isbn); + $isbn = array(); + + // Nothing to do. + if (empty($this->reply->record['dc:identifier']['dkdcplus:ISBN'])) { + return $isbn; } + + // Get ISBN numbers. + $isbn = $this->reply->record['dc:identifier']['dkdcplus:ISBN']; + foreach ($isbn as $k => $number) { + $isbn[$k] = str_replace(array(' ', '-'), '', $number); + } + rsort($isbn); return $isbn; } + } /** From fa44cea7d3984a6123ba472c827e141e700ed1ca Mon Sep 17 00:00:00 2001 From: Martin Cording Date: Fri, 19 Apr 2013 13:43:32 +0200 Subject: [PATCH 036/167] Stop spamming the dblog, please. --- ting.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.module b/ting.module index 34819d1..0760e34 100644 --- a/ting.module +++ b/ting.module @@ -525,7 +525,7 @@ function ting_ding_entity_buttons($type, $entity) { */ function ting_page_alter(&$page) { $calls = &drupal_static('ting_execute_cache'); - if (sizeof($calls) > 1) { + if (sizeof($calls) > 5) { $calls_str = array(); foreach ($calls as $call) { $calls_str[] = print_r($calls, TRUE); From 2cf9b4e5b89fa669c62e12fbe35f7e8b53b5bb53 Mon Sep 17 00:00:00 2001 From: Giannis Chionidis Date: Mon, 22 Apr 2013 16:22:16 +0200 Subject: [PATCH 037/167] case 2478 - Custom ranking available in dropdown, when custom ranking is chosen and at least one ranking field is defined. --- ting.client.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.client.inc b/ting.client.inc index 34508a8..b7ff8a5 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -208,7 +208,7 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar } // Apply custom ranking if enabled. - if (variable_get('ting_ranking_custom', FALSE)) { + if (variable_get('ting_ranking_custom', FALSE) && variable_get('ting_ranking_fields', array()) && !isset($options['sort'])) { $fields = array(); foreach (variable_get('ting_ranking_fields', array()) as $field) { $fields[] = array( From f639a67ab61bc2735a76458783901e5dd16da6e4 Mon Sep 17 00:00:00 2001 From: Alex Semeniuc Date: Tue, 23 Apr 2013 15:47:02 +0300 Subject: [PATCH 038/167] Resolved merge conflict in ting_execute() --- ting.api.php | 31 ++++++++++++++++++++++++++++++- ting.client.inc | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/ting.api.php b/ting.api.php index e119711..6636d5c 100644 --- a/ting.api.php +++ b/ting.api.php @@ -1,6 +1,35 @@ value pairs. Key is the name of the parameter. + */ +function hook_ting_pre_execute($request) { + return array('param_name' => 'value'); +} + +/** + * Set extra properties to resulting object. + * + * @param object $request + * ting_execute request. + * @param object $response + * ting_execute result. + * @param object $raw_response + * Raw response from ting. + * + * @return array + * Array containing key=>value pairs. Key is the name of the property. + */ +function hook_ting_post_execute($request, $response, $raw_response) { + return array('property name' => 'property value'); +} diff --git a/ting.client.inc b/ting.client.inc index b7ff8a5..5f7a0a2 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -277,7 +277,8 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar * * Executes the request and caches sub-objects. * - * @param $request the request. + * @param object $request + * The request. */ function ting_execute_cache($request) { $calls = &drupal_static(__FUNCTION__); @@ -348,6 +349,7 @@ function ting_execute_cache($request) { */ function ting_cache_get($id, $collection = FALSE) { $cid = 'ting-' . ($collection ? 'collection' : 'object') . ':' . $id; + if ($ttl = variable_get('ting_cache_lifetime', TING_DEFAULT_CACHE_LIFETIME)) { $cache = cache_get($cid); if ($cache && ($cache->expire > REQUEST_TIME)) { @@ -453,18 +455,40 @@ function ting_add_relations($request, $type = 'full') { } /** - * Perform a request against Ting and perform error handling if necessary + * Perform a request against Ting and perform error handling if necessary. + * + * @param object $request + * The request. * - * @param $request The request - * @return mixed Result of the request or false if an error occurs + * @return mixed + * Result of the request or false if an error occurs. */ function ting_execute($request) { + // Get additional parameters from other modules. + $params = module_invoke_all('ting_pre_execute', $request); + if (!empty($params)) { + $request->setParameters($params); + } + try { timer_start('ting'); $res = ting_get_client()->execute($request); timer_stop('ting'); - return $res; - } catch (TingClientException $e) { + + $response = $request->parseResponse($res); + + // Pass parsed results to other modules. + // @todo Check if it works for collection of items. + $props = module_invoke_all('ting_post_execute', $request, $response, $res); + if (!empty($props)) { + foreach ($props as $property => $value) { + $response->{$property} = $value; + } + } + + return $response; + } + catch (TingClientException $e) { timer_stop('ting'); watchdog('ting client', 'Error performing request: ' . $e->getMessage(), NULL, WATCHDOG_ERROR, 'http://' . $_SERVER["HTTP_HOST"] . request_uri()); return FALSE; From 576d54619a5b64938557856c7f59e97c28dd76d2 Mon Sep 17 00:00:00 2001 From: Alex Semeniuc Date: Thu, 25 Apr 2013 11:32:09 +0300 Subject: [PATCH 039/167] Case 2607 - Code review. --- ting.api.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ting.api.php b/ting.api.php index 6636d5c..9281c38 100644 --- a/ting.api.php +++ b/ting.api.php @@ -14,7 +14,8 @@ * Array containing key=>value pairs. Key is the name of the parameter. */ function hook_ting_pre_execute($request) { - return array('param_name' => 'value'); + // In case you need to add additional parameters to request. + return array('includeMarcXchange' => TRUE); } /** @@ -28,8 +29,9 @@ function hook_ting_pre_execute($request) { * Raw response from ting. * * @return array - * Array containing key=>value pairs. Key is the name of the property. + * Array containing key=>value pairs. Key is the name of the property. */ function hook_ting_post_execute($request, $response, $raw_response) { - return array('property name' => 'property value'); + // Add additional property to resulting object. + return array('marcexchange' => array('marcxchange data')); } From 8ff32926380b41ba8ac91035a714569d30c233d4 Mon Sep 17 00:00:00 2001 From: Giannis Chionidis Date: Mon, 13 May 2013 14:36:30 +0200 Subject: [PATCH 040/167] case 2758 - Replacing check_plain with htmlspecialchars. --- ting.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.module b/ting.module index 0760e34..5aab355 100644 --- a/ting.module +++ b/ting.module @@ -559,7 +559,7 @@ function ting_collection_page_view($object) { * Page title callback. */ function ting_page_title($object) { - return check_plain($object->title); + return htmlspecialchars($object->title, ENT_NOQUOTES, 'UTF-8' ); } /** From 679572fbe451d734999c8a9a8c151588d1b2bcc8 Mon Sep 17 00:00:00 2001 From: Giannis Chionidis Date: Mon, 13 May 2013 14:39:04 +0200 Subject: [PATCH 041/167] case 2758 - Removed space from function call. --- ting.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.module b/ting.module index 5aab355..724bd90 100644 --- a/ting.module +++ b/ting.module @@ -559,7 +559,7 @@ function ting_collection_page_view($object) { * Page title callback. */ function ting_page_title($object) { - return htmlspecialchars($object->title, ENT_NOQUOTES, 'UTF-8' ); + return htmlspecialchars($object->title, ENT_NOQUOTES, 'UTF-8'); } /** From bd47154a66dc2e2d6c2cefc957b3ed46e0f63d13 Mon Sep 17 00:00:00 2001 From: George Mihailov Date: Fri, 31 May 2013 13:28:18 +0300 Subject: [PATCH 042/167] Resolved merge conflict _ting_anchor_name() --- ting.module | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ting.module b/ting.module index 724bd90..2e5c308 100644 --- a/ting.module +++ b/ting.module @@ -940,3 +940,19 @@ function _ting_fetch_well_sources() { variable_set('ting_well_sources', $sources); } } + +/** + * Get anchor name from collection type. + * + * @param string $type + * Name of the anchor. + * @return string + * HTML safe name. + */ +function _ting_anchor_name($type) { + $name = str_replace(array('(', ')'), '', $type); + $name = str_replace(' ', '-', $name); + $name = str_replace(':', '', $name); + $name = strtolower($name); + return $name; +} \ No newline at end of file From cb8a2d397e949e6c98d48a7ee0f547daf93dd45f Mon Sep 17 00:00:00 2001 From: George Mihailov Date: Thu, 30 May 2013 12:04:11 +0300 Subject: [PATCH 043/167] Resolved merge conflict in _ting_anchor_name() --- ting.module | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ting.module b/ting.module index 2e5c308..f893f03 100644 --- a/ting.module +++ b/ting.module @@ -306,13 +306,13 @@ function ting_block_view($delta = '') { $items = array(); foreach ($collection->types as $type) { $uri = entity_uri('ting_collection', $collection); - $uri['options']['fragment'] = $type; + $uri['options']['fragment'] = _ting_anchor_name($type); $items[] = l($type . ' (' . $collection->types_count[$type] . ')', $uri['path'], $uri['options']); } $block['content'] = array( '#theme' => 'item_list', - '#items' => $items, + '#items' => count($collection) > 1 ? $items : array(), ); } break; @@ -955,4 +955,4 @@ function _ting_anchor_name($type) { $name = str_replace(':', '', $name); $name = strtolower($name); return $name; -} \ No newline at end of file +} From c544fc2edb9bac6d7f869c1aa8f45334301e5404 Mon Sep 17 00:00:00 2001 From: Giannis Chionidis Date: Fri, 21 Jun 2013 15:13:45 +0200 Subject: [PATCH 044/167] case 2941 - Restoring char "&" when encoded by htmlspecialchars() on title. --- ting.module | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ting.module b/ting.module index f893f03..0ef233f 100644 --- a/ting.module +++ b/ting.module @@ -557,9 +557,11 @@ function ting_collection_page_view($object) { /** * Page title callback. + * + * Strips chars '<' and '>' in order to avoid HTML injections. */ function ting_page_title($object) { - return htmlspecialchars($object->title, ENT_NOQUOTES, 'UTF-8'); + return str_replace('&', '&', htmlspecialchars($object->title, ENT_NOQUOTES, 'UTF-8')); } /** From 44462269cb438023a7b14556797e677630cd9cb3 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 18 Jul 2013 13:27:37 +0200 Subject: [PATCH 045/167] Fixed blocks with information about related materials and removed hardcoded html --- ting.module | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/ting.module b/ting.module index 0ef233f..6307899 100644 --- a/ting.module +++ b/ting.module @@ -248,27 +248,23 @@ function ting_get_relations($ting_entity) { * Implements hook_block_view(). */ function ting_block_view($delta = '') { - $block = array(); + $block = new stdClass(); + switch ($delta) { case 'ting_relation_anchors': $items = array(); - if( $object = menu_get_object('ting_object',2) ) { + if ($object = menu_get_object('ting_object',2)) { $relations = ting_get_relations($object); if (!empty($relations)) { $relation_types = module_invoke_all('ding_anchor_info'); - $block['subject'] = array( - '#markup' => t('About the material'), - '#prefix' => '
', - '#suffix' => '
', - ); - $block['subject'] = render($block['subject']); + $block->subject = t('About the material'); foreach( $relations as $key => $relation ) { if( isset($relation_types[$key]) ) { $items[] = l($relation_types[$key].' ('.count($relation).') ','#'.$key,array('external'=>TRUE)); } } - $block['content'] = array( + $block->content = array( '#theme' => 'item_list', '#items' => $items, ); @@ -276,33 +272,24 @@ function ting_block_view($delta = '') { } break; + case 'ting_collection_types': if ($collection = menu_get_object('ting_collection', 2)) { - $block['subject'] = array( - '#markup' => t('Types'), - '#prefix' => '
', - '#suffix' => '
', - ); - $block['subject'] = render($block['subject']); + $block->subject = t('Types'); $items = array(); foreach ($collection->types as $type) { $items[] = l($type . ' (' . $collection->types_count[$type] . ')', '#' . $type, array('external' => TRUE )); } - $block['content'] = array( + $block->content = array( '#theme' => 'item_list', '#items' => $items, ); } break; + case 'ting_object_types': - if (($object = menu_get_object('ting_object', 2)) && - ($collection = ting_collection_load($object->id))) { - $block['subject'] = array( - '#markup' => t('Other materialtypes'), - '#prefix' => '
', - '#suffix' => '
', - ); - $block['subject'] = render($block['subject']); + $object = menu_get_object('ting_object', 2); + if ($object && $collection = ting_collection_load($object->id)) { $items = array(); foreach ($collection->types as $type) { $uri = entity_uri('ting_collection', $collection); @@ -310,10 +297,14 @@ function ting_block_view($delta = '') { $items[] = l($type . ' (' . $collection->types_count[$type] . ')', $uri['path'], $uri['options']); } - $block['content'] = array( - '#theme' => 'item_list', - '#items' => count($collection) > 1 ? $items : array(), - ); + // Only display block if there are more than on item. + if ($items > 1) { + $block->subject = t('Other materialtypes'); + $block->content = array( + '#theme' => 'item_list', + '#items' => $items, + ); + } } break; } From b345aa17fcf243f127f4df8e8bcd160ebd857c84 Mon Sep 17 00:00:00 2001 From: Arni Date: Wed, 4 Sep 2013 15:48:39 +0200 Subject: [PATCH 046/167] clean up --- ting.client.inc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index 245e289..6b202a9 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -173,12 +173,10 @@ function ting_get_objects($ids) { * - rank: The ranking type, as defined in the XSD. * - supportingTypes: Whether to include supporting types such as reviews. Default: false * - reply_only: Don't change the result objects to TingCollection objects. - * - collectionType: The type of results to return. Single manifestions(object) or works (collections). Possible values manifestion,work or work-1. Defaults to work. * @return TingClientSearchResult * The search result */ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = array()) { - $request = ting_get_request_factory()->getSearchRequest(); $request->setQuery($query); if ($agency = variable_get('ting_agency', FALSE)) { @@ -200,9 +198,7 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar if (isset($options['sort']) && $options['sort']) { $request->setSort($options['sort']); } - if (isset($options['collectionType'])) { - $request->setCollectionType($options['collectionType']); - } + $request->setAllObjects(isset($options['allObjects']) ? $options['allObjects'] : FALSE); // Set search profile, if applicable. From 4aabcfc57b507284b42214d3aa53c83fb64feea2 Mon Sep 17 00:00:00 2001 From: Arni Date: Wed, 4 Sep 2013 15:49:40 +0200 Subject: [PATCH 047/167] Added support for collectiontype --- ting.client.inc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ting.client.inc b/ting.client.inc index 6b202a9..7aec32a 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -173,6 +173,7 @@ function ting_get_objects($ids) { * - rank: The ranking type, as defined in the XSD. * - supportingTypes: Whether to include supporting types such as reviews. Default: false * - reply_only: Don't change the result objects to TingCollection objects. + * - collectionType: The type of results to return. Single manifestions(object) or works (collections). Possible values manifestion,work or work-1. Defaults to work. * @return TingClientSearchResult * The search result */ @@ -198,7 +199,9 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar if (isset($options['sort']) && $options['sort']) { $request->setSort($options['sort']); } - + if (isset($options['collectionType'])) { + $request->setCollectionType($options['collectionType']); + } $request->setAllObjects(isset($options['allObjects']) ? $options['allObjects'] : FALSE); // Set search profile, if applicable. From 3578fdda9d51d1e6c11909270121371fff48fd0f Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 16 Sep 2013 11:32:29 +0200 Subject: [PATCH 048/167] Added reservation expire settings to the reservation admin form --- ting.admin.inc | 74 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index 436600d..bb1b9d1 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -130,7 +130,7 @@ function ting_admin_ranking_settings($form, &$form_state) { $form_state['ranking_field_count'] = count($field_data) + 1; } - // Wrapper, so that the AJAX callback have some place to put new elements + // Wrapper, so that the AJAX callback have some place to put new elements. $form['ting_ranking_fields'] = array( '#title' => t('Custom ranking fields'), '#type' => 'fieldset', @@ -203,7 +203,7 @@ function ting_admin_ranking_add_more_js($form, &$form_state) { function ting_admin_ranking_form_after_build($form, &$form_state) { $path = drupal_get_path('module', 'ting'); - drupal_add_css($path .'/css/ting_admin_ranking_form.css'); + drupal_add_css($path . '/css/ting_admin_ranking_form.css'); return $form; } @@ -223,18 +223,18 @@ function ting_admin_ranking_settings_submit($form, &$form_state) { } /** - * array_filter() callback to remove empty/deleted elements. + * Array_filter() callback to remove empty/deleted elements. */ function _ting_ranking_field_filter($element) { return !empty($element['field_name']); } /** - * usort() callback to remove empty/deleted elements. + * Usort() callback to remove empty/deleted elements. */ function _ting_ranking_field_sort($a, $b) { if ($a['weight'] == $b['weight']) { - return 0; + return 0; } return ($a['weight'] > $b['weight']) ? -1 : 1; } @@ -255,7 +255,7 @@ function ting_admin_boost_settings($form, &$form_state) { $form_state['boost_field_count'] = count($field_data); } - // Wrapper, so that the AJAX callback have some place to put new elements + // Wrapper, so that the AJAX callback have some place to put new elements. $form['ting_boost_fields'] = array( '#title' => t('Custom fields boost values'), '#type' => 'fieldset', @@ -322,7 +322,7 @@ function ting_admin_boost_add_more_js($form, &$form_state) { function ting_admin_boost_form_after_build($form, &$form_state) { $path = drupal_get_path('module', 'ting'); - drupal_add_css($path .'/css/ting_admin_boost_form.css'); + drupal_add_css($path . '/css/ting_admin_boost_form.css'); return $form; } @@ -340,29 +340,25 @@ function ting_admin_boost_settings_submit($form, &$form_state) { } /** - * array_filter() callback to remove empty/deleted elements. + * Array_filter() callback to remove empty/deleted elements. */ function _ting_boost_field_filter($element) { return !(empty($element['field_name']) || empty($element['field_value'])); } /** - * usort() callback to remove empty/deleted elements. + * Callback for usort() to remove empty/deleted elements. */ function _ting_boost_field_sort($a, $b) { if ($a['weight'] == $b['weight']) { - return 0; + return 0; } return ($a['weight'] > $b['weight']) ? -1 : 1; } -/** - * @brief Implementation of hook_menu() - * - * Felter: Forfatter, titel, emneord, - */ function ting_admin_register_settings() { - // should use phrase.title instead of dc.title but at the moment opensearch does not support the use of phrase.title + // Should use phrase.title instead of dc.title but at the moment open search + // does not support the use of phrase.title. $form['ting_admin_register_serie_title'] = array( '#type' => 'textfield', '#title' => t('Serie title'), @@ -413,7 +409,7 @@ function ting_admin_online_types_settings($form_state) { ); $types = variable_get('ting_well_types', array()); - + $form['ting_online'] = array( '#type' => 'fieldset', '#title' => t('Online types'), @@ -422,13 +418,13 @@ function ting_admin_online_types_settings($form_state) { '#collapsible' => TRUE, '#collapsed' => TRUE, ); - + $form['ting_online']['types'] = array( '#type' => 'checkboxes', '#options' => drupal_map_assoc(array_keys($types)), '#default_value' => variable_get('ting_online_types', _ting_default_online_types()), ); - + $settings = variable_get('ting_url_labels', _ting_default_url_labels()); $form['ting_url_labels'] = array( '#type' => 'fieldset', @@ -443,7 +439,7 @@ function ting_admin_online_types_settings($form_state) { '#description' => t('Default label used for types that is not specifically set below.'), ); - if (sizeof($types)) { + if (count($types)) { $form['ting_url_labels']['types'] = array( '#type' => 'fieldset', '#title' => t('Type specific labels'), @@ -470,7 +466,7 @@ function ting_admin_online_types_settings($form_state) { } /** - * Submit handler. Updates the list of known types from the datawell. + * Submit handler. Updates the list of known types from the data well. */ function ting_admin_online_types_settings_update_types($form, &$form_state) { _ting_fetch_well_types(); @@ -489,7 +485,7 @@ function ting_admin_reservable_settings($form_state) { $form['update'] = array( '#type' => 'fieldset', '#title' => t('Update from datawell'), - '#description' => t('Update the lists of known types and sources by asking the datawell for all types and sorces.') + '#description' => t('Update the lists of known types and sources by asking the datawell for all types and sorces.'), ); $form['update']['update'] = array( @@ -498,6 +494,36 @@ function ting_admin_reservable_settings($form_state) { '#submit' => array('ting_admin_reservable_settings_update'), ); + $form['reservation_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Reservation settings'), + '#tree' => FALSE, + ); + + $options = array(); + $intervals = array( + 86400, + 172800, + 259200, + 345600, + 432000, + 518400, + 604800, + 1209600, + 1814400, + ); + foreach ($intervals as $interval) { + $options[$interval] = format_interval($interval, 2); + } + + $form['reservation_settings']['reservation_expire'] = array( + '#type' => 'select', + '#title' => t('Reservation expire message'), + '#options' => $options, + '#default_value' => variable_get('reservation_expire', 604800), + '#description' => t('Time before an reservation expires that a message should be shown to the user.'), + ); + $types = variable_get('ting_well_types', array()); $sources = variable_get('ting_well_sources', array()); @@ -505,7 +531,7 @@ function ting_admin_reservable_settings($form_state) { '#type' => 'fieldset', '#title' => t('Reservation buttons'), '#tree' => FALSE, - '#description' => t("A Ting object will get a reservation button, if it's source and type is both selected ."), + '#description' => t("A Ting object will get a reservation button, if it's source and type is both selected."), ); $form['ting_reservable']['ting_reservable_sources'] = array( @@ -529,7 +555,7 @@ function ting_admin_reservable_settings($form_state) { /** * Submit handler. Updates the list of known types and sources from the - * datawell. + * data well. */ function ting_admin_reservable_settings_update($form, &$form_state) { _ting_fetch_well_types(); From c3a2f5351cfd23c71da2669017019eeda3c3c9e0 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 17 Sep 2013 10:37:56 +0200 Subject: [PATCH 049/167] Updated coding style in theme.inc --- ting.theme.inc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ting.theme.inc b/ting.theme.inc index 2dcd35b..aa6e51a 100644 --- a/ting.theme.inc +++ b/ting.theme.inc @@ -1,5 +1,4 @@ $val ) { + if (isset($variables['content']['entities'])) { + foreach ($variables['content']['entities'] as $key => $val) { $variables['content']['overview']['types'][] = $key; } } From 2ca15a9dedccfc7c4a88e3ff5db8ca3d932e39b6 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 17 Sep 2013 10:46:29 +0200 Subject: [PATCH 050/167] Removed encoding of online url --- ting.module | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ting.module b/ting.module index 6307899..03a0a25 100644 --- a/ting.module +++ b/ting.module @@ -500,9 +500,10 @@ function ting_ding_entity_buttons($type, $entity) { $type = drupal_strtolower($entity->type); $label = isset($settings[$type]) && $settings[$type] ? $settings[$type] : $settings['_default']; return array( + // The link can't use l() as it will encode the url from ting_proxy. array( '#type' => 'markup', - '#markup' => l($label, $entity->online_url, array('attributes'=>array('target'=>'_new', 'class' => 'button-see-online'))) + '#markup' => '' . $label . '', ), ); } From 8f6d985b0fe7e323dd08cd63a21def16310a91e9 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 17 Sep 2013 10:54:51 +0200 Subject: [PATCH 051/167] Updated coding style --- ting.module | 69 +++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/ting.module b/ting.module index 03a0a25..4b3dd53 100644 --- a/ting.module +++ b/ting.module @@ -10,7 +10,7 @@ define('TING_DEFAULT_CACHE_LIFETIME', 0); module_load_include('inc', 'ting', 'ting.field'); /** - * Implementation of hook_ctools_plugin_api(). + * Implements hook_ctools_plugin_api(). */ function ting_ctools_plugin_api($module, $api) { if ($module == 'page_manager' && $api == 'pages_default') { @@ -20,16 +20,19 @@ function ting_ctools_plugin_api($module, $api) { /** - * Implements hook_ctools_plugin_directory() to let the system know - * where our task and task_handler plugins are. + * Implements hook_ctools_plugin_directory(). + * + * Lets the system know where our task and task_handler plugins are. */ function ting_ctools_plugin_directory($owner, $plugin_type) { - return 'plugins/' . $plugin_type; + return 'plugins/' . $plugin_type; } /** - * Implements hook_ctools_plugin_type() to inform the plugin system that Page - * Manager owns task, task_handler, and page_wizard plugin types. + * Implements hook_ctools_plugin_type(). + * + * Informs the plugin system that Page Manager owns task, task_handler, and + * page_wizard plugin types. * * All of these are empty because the defaults all work. */ @@ -43,6 +46,7 @@ function ting_ctools_plugin_type() { 'contexts' => array(), ); } + /** * Implements hook_menu(). */ @@ -84,7 +88,7 @@ function ting_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('ting_admin_ting_settings'), 'access arguments' => array('administer ting settings'), - 'file' => 'ting.admin.inc' + 'file' => 'ting.admin.inc', ); $items['admin/config/ting/ranking'] = array( @@ -111,7 +115,7 @@ function ting_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('ting_admin_register_settings'), 'access arguments' => array('administer ting settings'), - 'file' => 'ting.admin.inc' + 'file' => 'ting.admin.inc', ); $items['admin/config/ting/online_types'] = array( @@ -120,7 +124,7 @@ function ting_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('ting_admin_online_types_settings'), 'access arguments' => array('administer ting settings'), - 'file' => 'ting.admin.inc' + 'file' => 'ting.admin.inc', ); $items['admin/config/ting/reservable'] = array( @@ -129,7 +133,7 @@ function ting_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('ting_admin_reservable_settings'), 'access arguments' => array('administer ting settings'), - 'file' => 'ting.admin.inc' + 'file' => 'ting.admin.inc', ); return $items; @@ -220,7 +224,7 @@ function ting_block_info() { } /** - * helper function - get relations for an ting_entity as an array ([$type] => array($relations)) + * Get relations for an ting_entity as an array ([$type] => array($relations)). */ function ting_get_relations($ting_entity) { $relations = array(); @@ -232,11 +236,11 @@ function ting_get_relations($ting_entity) { $relations[$relation->type][] = $relation; } - // get references from ting_reference - if( module_exists('ting_reference') ) { - $refs = module_invoke('ting_reference','get_relations','ting_object',$ting_entity); - if( !empty($refs) ) { - foreach( $refs as $ref ) { + // Get references from ting_reference. + if (module_exists('ting_reference')) { + $refs = module_invoke('ting_reference', 'get_relations', 'ting_object', $ting_entity); + if (!empty($refs)) { + foreach ($refs as $ref) { $relations[$ref->relation_type][] = $ref; } } @@ -253,15 +257,15 @@ function ting_block_view($delta = '') { switch ($delta) { case 'ting_relation_anchors': $items = array(); - if ($object = menu_get_object('ting_object',2)) { + if ($object = menu_get_object('ting_object', 2)) { $relations = ting_get_relations($object); if (!empty($relations)) { $relation_types = module_invoke_all('ding_anchor_info'); $block->subject = t('About the material'); - foreach( $relations as $key => $relation ) { - if( isset($relation_types[$key]) ) { - $items[] = l($relation_types[$key].' ('.count($relation).') ','#'.$key,array('external'=>TRUE)); + foreach ($relations as $key => $relation) { + if (isset($relation_types[$key])) { + $items[] = l($relation_types[$key] . ' (' . count($relation) . ') ', '#' . $key, array('external' => TRUE)); } } $block->content = array( @@ -278,7 +282,7 @@ function ting_block_view($delta = '') { $block->subject = t('Types'); $items = array(); foreach ($collection->types as $type) { - $items[] = l($type . ' (' . $collection->types_count[$type] . ')', '#' . $type, array('external' => TRUE )); + $items[] = l($type . ' (' . $collection->types_count[$type] . ')', '#' . $type, array('external' => TRUE)); } $block->content = array( '#theme' => 'item_list', @@ -361,7 +365,7 @@ function ting_ding_devel_timers() { 'ting_net' => array( 'title' => 'Ting net time was @time ms.', 'include in total' => FALSE, - ) + ), ); } @@ -492,7 +496,7 @@ function ting_ding_entity_is($object, $class) { } /** - * Implements hook_ding_entity_buttons() + * Implements hook_ding_entity_buttons(). */ function ting_ding_entity_buttons($type, $entity) { if ($entity instanceof TingEntity && $entity->online_url) { @@ -513,18 +517,20 @@ function ting_ding_entity_buttons($type, $entity) { * Implements hook_page_alter(). * * Log, and display if the devel module is active and the user has - * permissions, a warning if the datawell was queried more than once. + * permissions, a warning if the data well was queried more than once. */ function ting_page_alter(&$page) { $calls = &drupal_static('ting_execute_cache'); - if (sizeof($calls) > 5) { + if (count($calls) > 5) { $calls_str = array(); foreach ($calls as $call) { $calls_str[] = print_r($calls, TRUE); } - watchdog('ting', 'Warning, ting_execute called @x times:
"@queries"', array('@x' => sizeof($calls), '@queries' => join('" "', $calls_str)), WATCHDOG_WARNING); + + watchdog('ting', 'Warning, ting_execute called @x times:
"@queries"', array('@x' => count($calls), '@queries' => implode('" "', $calls_str)), WATCHDOG_WARNING); + if (function_exists('dpm') && user_access('access devel information')) { - drupal_set_message(t('Warning, ting_execute called @x times.', array('@x' => sizeof($calls))), 'error'); + drupal_set_message(t('Warning, ting_execute called @x times.', array('@x' => count($calls))), 'error'); dpm($calls, 'ting_execute queries:'); } } @@ -541,7 +547,7 @@ function ting_object_page_view($object) { * Page callback: Display a ting collection. */ function ting_collection_page_view($object) { - if (sizeof($object->entities) < 2) { + if (count($object->entities) < 2) { drupal_goto('ting/object/' . $object->id); } return ting_collection_view($object); @@ -676,12 +682,13 @@ function ting_collection_view($object, $view_mode = 'full', $langcode = NULL) { } /** - * Sorts the objects according to type and language, but maintains the order - * of types and languages in the original array. + * Sorts the objects according to type and language. + * + * But maintains the order of types and languages in the original array. */ function _ting_type_lang_sort($objects, &$return_types) { $types = array(); - $language = array(); + $languages = array(); $sorted = array(); // Sort the objects into type buckets containing language buckets. foreach ($objects as $object) { From 99e7bba7918d142372365ea80aa00c8dccda2e07 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 18 Sep 2013 21:55:56 +0200 Subject: [PATCH 052/167] Fixed online url, so it is correct for "filmstriben" and other online material --- ting.entities.inc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ting.entities.inc b/ting.entities.inc index b54451d..5a38293 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -260,8 +260,33 @@ class TingEntity extends DingEntity { } function getOnline_url() { + // Try to find the online url from relation data, which requires us to get + // relations. First check if relations are set; if not do another request + // to get relations + if (!isset($this->reply->relationsData)) { + $tingClientObject = ting_get_object_request($this->ding_entity_id); + if (isset($tingClientObject->relationsData)) { + $this->reply->relationsData = $tingClientObject->relationsData; + } + } + if (isset($this->reply->relationsData)) { + foreach ($this->reply->relationsData as $data) { + if ($data->relationType == 'dbcaddi:hasOnlineAccess') { + $url = preg_replace('/^\[URL\]/', '', $data->relationUri); + // Check for correct url - some uri is only an id. + if (stripos($url, 'http') === 0) { + // Give ting_proxy a change to rewrite the url. + drupal_alter('ting_online_url', $url, $this); + return $url; + } + } + } + } + + // No hasOnlineAccess found so fallback to dc:identifer. if (isset($this->reply->record['dc:identifier']['dcterms:URI'])) { $url = $this->reply->record['dc:identifier']['dcterms:URI'][0]; + // Give ting_proxy a change to rewrite the url. drupal_alter('ting_online_url', $url, $this); return $url; } From 05e82501ccf7bb3e77f1dedba9867156bd4e045e Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 19 Sep 2013 10:52:05 +0200 Subject: [PATCH 053/167] Added statement to handle doc-book and fulltext --- ting.client.inc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ting.client.inc b/ting.client.inc index 7aec32a..c2055cd 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -478,6 +478,14 @@ function ting_execute($request) { $res = ting_get_client()->execute($request); timer_stop('ting'); + // When the request is for fulltext (doc-book) the result is XML but the + // next part expect JSON only formatted input. So this hack simply return + // the XML for now as later on we have to work with open format and XML + // parsing. So for now simply return the result to fulltext. + if ($request instanceof TingClientObjectRequest && $request->getOutputType() == 'xml' && $request->getFormat() == 'docbook') { + return $res; + } + $response = $request->parseResponse($res); // Pass parsed results to other modules. From 34cbdc0c48cf7d983ba8fd09c217b799bbf48ebc Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 19 Sep 2013 15:21:13 +0200 Subject: [PATCH 054/167] Return series description when parseing fails --- ting.client.inc | 45 +++++++++++++++++++++++++++------------------ ting.entities.inc | 8 ++++++-- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index c2055cd..c45ecad 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -33,6 +33,7 @@ function ting_get_object_request($object_id) { * fetched collection won't trigger another backend request. * * @param $object_id The id to fetch. + * Object id. * @param $collection Whether to return a collection, if possible, or * an object. * @@ -59,10 +60,10 @@ function ting_get_object($object_id, $collection = FALSE) { $profile = variable_get('ting_search_profile', ''); if (!empty($profile) && method_exists($request, 'setProfile')) { - $request->setProfile($profile); + $request->setProfile($profile); } - $request->setAllObjects(false); + $request->setAllObjects(FALSE); $object = ting_execute_cache($request); } } @@ -88,7 +89,7 @@ function ting_get_object($object_id, $collection = FALSE) { */ function ting_get_objects($ids) { $objects = array(); - // Prefill from cache. + // Pre-fill from cache. foreach ($ids as $id) { $objects[$id] = ting_cache_get($id); if (isset($objects[$id]) && isset($objects[$id]->objects)) { @@ -115,7 +116,7 @@ function ting_get_objects($ids) { do { // If the query is empty, then don't do it. // Not necessary to do in each iteration, but it doesn't hurt much. - if (sizeof($query) == 0) { + if (count($query) == 0) { break; } @@ -127,7 +128,7 @@ function ting_get_objects($ids) { if (!empty($profile) && method_exists($request, 'setProfile')) { $request->setProfile($profile); } - $request->setQuery(join(' OR ', $query)); + $request->setQuery(implode(' OR ', $query)); // Do it in steps of 50. $request->setStart($i * 50 + 1); $request->setNumResults(50); @@ -137,7 +138,7 @@ function ting_get_objects($ids) { if ($result && is_array($result->collections)) { foreach ($result->collections as $collection) { - if (is_array($collection->objects) && sizeof($collection->objects)) { + if (is_array($collection->objects) && count($collection->objects)) { foreach ($collection->objects as $object) { $objects[$object->id] = $object; } @@ -146,7 +147,7 @@ function ting_get_objects($ids) { } else { // Result was false, hence the more property used in the while do not - // exists + // exists. break; } $i++; @@ -156,26 +157,34 @@ function ting_get_objects($ids) { } /** - * Performs a search agains the well + * Performs a search against the well. * * @param string $query - * The search query + * The search query * @param int $page - * The page number to retrieve search results for + * The page number to retrieve search results for * @param int $results_per_page - * The number of results to include per page + * The number of results to include per page * @param array $options - * Options to pass to the search. Possible options are: - * - facets: Array of facet names for which to return results. Default: facet.subject, facet.creator, facet.type, facet.date, facet.language + * Options to pass to the search. Possible options are: + * - facets: Array of facet names for which to return results. Default: + * facet.subject, facet.creator, facet.type, facet.date, facet.language * - numFacets: The number of terms to include with each facet. Default: 10 - * - enrich: Whether to include additional information and cover images with each object. Default: false - * - sort: The key to sort the results by. Default: "" (corresponds to relevance). The possible values are defined by the sortType type in the XSD. + * - enrich: Whether to include additional information and cover images with + * each object. Default: false + * - sort: The key to sort the results by. Default: "" (corresponds to + * relevance). The possible values are defined by the sortType type + * in the XSD. * - rank: The ranking type, as defined in the XSD. - * - supportingTypes: Whether to include supporting types such as reviews. Default: false + * - supportingTypes: Whether to include supporting types such as reviews. + * Default: false * - reply_only: Don't change the result objects to TingCollection objects. - * - collectionType: The type of results to return. Single manifestions(object) or works (collections). Possible values manifestion,work or work-1. Defaults to work. + * - collectionType: The type of results to return. Single + * manifestions(object) or works (collections). Possible values + * manifestion ,work or work-1. Defaults to work. + * * @return TingClientSearchResult - * The search result + * The search result. */ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = array()) { $request = ting_get_request_factory()->getSearchRequest(); diff --git a/ting.entities.inc b/ting.entities.inc index 5a38293..8d911a2 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -148,9 +148,10 @@ class TingEntity extends DingEntity { $serie = !empty($this->reply->record['dc:description']['dkdcplus:series'][0]) ? $this->reply->record['dc:description']['dkdcplus:series'][0] : ''; return $this->process_series_description($serie); } - + /** - * Process series information + * Process series information. + * * This could be handled more elegantly if we had better structured data. * For now we have to work with what we got to convert titles to links * Series information appear in the following formats: @@ -183,6 +184,9 @@ class TingEntity extends DingEntity { $titles = implode(', ', $titles); $result = $prefix . ' ' . $titles; } + else { + return $series; + } } return $result; From 2028d7f95cfec5fd7c2396da78e72ac400d92025 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 1 Oct 2013 12:57:08 +0200 Subject: [PATCH 055/167] Ensured that TingObjectController works with php 5.4 --- ting.controllers.inc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ting.controllers.inc b/ting.controllers.inc index 7468d53..55ce8fb 100644 --- a/ting.controllers.inc +++ b/ting.controllers.inc @@ -98,10 +98,10 @@ class TingObjectController extends DrupalDefaultEntityController { } // Not known locally. Create a proxy if it exists in the well. - if (sizeof($unknown)) { + if (count($unknown)) { $new_ids = array(); foreach ($unknown as $ding_entity_id) { - if (isset($objects[$ding_entity_id])){ + if (isset($objects[$ding_entity_id])) { // Insert a new local proxy row. $ting_object = array( 'ding_entity_id' => $ding_entity_id, @@ -158,6 +158,7 @@ class TingObjectController extends DrupalDefaultEntityController { } return $entities; } + /** * Gets entities from the static cache. * @@ -180,15 +181,16 @@ class TingObjectController extends DrupalDefaultEntityController { // Exclude any entities loaded from cache if they don't match $conditions. // This ensures the same behavior whether loading from memory or database. if ($conditions) { - foreach ($entities as $entity) { - $entity_values = (array) $entity; - $diffs = array_diff_assoc($conditions, $entity_values); - if ($diffs) { - if (array_keys($diffs) != array('ding_entity_id') || !in_array($entity_values['ding_entity_id'], $diffs['ding_entity_id'])) { + // Check that conditions has ding_entity_id key. + if (!empty($conditions['ding_entity_id'])) { + foreach ($entities as $entity) { + if (!in_array($entity->ding_entity_id, $conditions['ding_entity_id'])) { unset($entities[$entity->{$this->idKey}]); - }} + } + } } } + return $entities; } } From 594945667daed38ee9007cb0782b6aa474bb8ac7 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 9 Oct 2013 14:55:24 +0200 Subject: [PATCH 056/167] Updated coding style and missing function comments --- ting.client.inc | 118 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 27 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index c45ecad..102ac4f 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -4,7 +4,15 @@ * Wrapper functions for Ting client. */ - +/** + * Get ting object based on an object id. + * + * @param string $object_id + * Ting object id. + * + * @return TingClientObject + * The object requested. + */ function ting_get_object_request($object_id) { $request = ting_get_request_factory()->getObjectRequest(); if ($agency = variable_get('ting_agency', FALSE)) { @@ -32,12 +40,16 @@ function ting_get_object_request($object_id) { * result, and any sub-objects, so fetching objects from a recently * fetched collection won't trigger another backend request. * - * @param $object_id The id to fetch. - * Object id. - * @param $collection Whether to return a collection, if possible, or + * @param string $object_id + * The id to fetch. + * @param bool $collection + * Whether to return a collection, if possible, or * an object. * * @todo Should use getObject, but the ting-client lib doesn't implement that. + * + * @return TingClientObject + * Ting object. */ function ting_get_object($object_id, $collection = FALSE) { if (empty($object_id)) { @@ -110,7 +122,7 @@ function ting_get_objects($ids) { $query[] = 'rec.id=' . $id; } } - // Opensearch is limited to 50 results per call, so iterate until all results + // Open search is limited to 50 results per call, so iterate until all results // have been fetched. $i = 0; do { @@ -203,7 +215,16 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar } } - $request->setFacets((isset($options['facets'])) ? $options['facets'] : array('facet.subject', 'facet.creator', 'facet.type', 'facet.category', 'facet.language', 'facet.date', 'facet.acSource')); + $default_facets = array( + 'facet.subject', + 'facet.creator', + 'facet.type', + 'facet.category', + 'facet.language', + 'facet.date', + 'facet.acSource', + ); + $request->setFacets((isset($options['facets'])) ? $options['facets'] : $default_facets); $request->setNumFacets((isset($options['numFacets'])) ? $options['numFacets'] : ((sizeof($request->getFacets()) == 0) ? 0 : 10)); if (isset($options['sort']) && $options['sort']) { $request->setSort($options['sort']); @@ -291,6 +312,9 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar * * @param object $request * The request. + * + * @return object + * The search reply from the data well. */ function ting_execute_cache($request) { $calls = &drupal_static(__FUNCTION__); @@ -298,6 +322,7 @@ function ting_execute_cache($request) { $calls = array(); } $calls[] = $request->getRequest()->getParameters(); + $reply = ting_execute($request); // Cache any sub-objects (mostly true for collections). @@ -375,7 +400,8 @@ function ting_cache_get($id, $collection = FALSE) { if (!isset($cache)) { $cache = array(); } - // Using array_key_exists, as we might contain NULL values (which is !isset()). + // Using array_key_exists, as we might contain NULL values (which is + // !isset()). if (array_key_exists($cid, $cache)) { return $cache[$cid]; } @@ -394,7 +420,7 @@ function ting_cache_set($id, $value) { $cid .= ':' . $id; if ($ttl = variable_get('ting_cache_lifetime', TING_DEFAULT_CACHE_LIFETIME)) { - $cache = cache_set($cid, $value, 'cache', REQUEST_TIME + $ttl); + cache_set($cid, $value, 'cache', REQUEST_TIME + $ttl); } else { // Without proper caching, use a request cache. @@ -410,23 +436,29 @@ function ting_cache_set($id, $value) { * Get recommendations for a given ISBN. * * @param string $isbn - * ISBN number to get recommendations from. - * @param $numResults - * The number of results to return. + * ISBN number to get recommendations from. + * @param int $num_results + * The number of results to return. + * * @return array - * An array of TingClientObjectRecommendation objects. + * An array of TingClientObjectRecommendation objects. */ -function ting_get_object_recommendations($isbn, $numResults = 10) { +function ting_get_object_recommendations($isbn, $num_results = 10) { $request = ting_get_request_factory()->getObjectRecommendationRequest(); $request->setIsbn($isbn); - $request->setNumResults($numResults); + $request->setNumResults($num_results); return ting_execute($request); } /** * Retrieves an initialized Ting client request factory. * + * @throws TingClientException + * If there is no end-point url defined in the configuration this exception is + * thrown. + * * @return TingClientRequestFactory + * TingClientRequestFactory object. */ function ting_get_request_factory() { static $request_factory; @@ -460,6 +492,17 @@ function ting_get_request_factory() { return $request_factory; } +/** + * Add relation type to a search request object. + * + * @param TingClientSearchRequest $request + * The search request to add the relation to. + * @param string $type + * The type of relation add to the request. + * + * @return TingClientSearchRequest + * The request added the relation. + */ function ting_add_relations($request, $type = 'full') { $request->setAllRelations(TRUE); $request->setRelationData($type); @@ -516,9 +559,12 @@ function ting_execute($request) { } /** - * Retrieves an initialized Ting client with appropriate request adapter and logger + * Retrieves an initialized Ting client. + * + * The client returned is with appropriate request adapter and logger. * * @return TingClient + * The ting client object that can be used to communicate with the data well. */ function ting_get_client() { static $client; @@ -532,14 +578,21 @@ function ting_get_client() { } /** - * Use OpenScan to search for keyword, check - * http://oss.dbc.dk/twiki/bin/view/Databroend/OpenSearchDocIndexes - * for which phrase index to search, default is 'anyIndexes' + * Use OpenScan to search for keyword. + * + * See http://oss.dbc.dk/twiki/bin/view/Databroend/OpenSearchDocIndexes for + * information about which phrase index to search, default is 'anyIndexes'. * - * @param string $query The prefix to scan for - * @param string $phrase Which phrase index to search - * @param int $num_results The numver of results to return - * @return TingClientScanResult + * @param string $query + * The prefix to scan for + * @param string $phrase + * Which phrase index to search. + * @param int $num_results + * The number of results to return. + * + * @return mixed + * A TingClientScanResult object with the scan results found or FALSE if non + * found or connection failed. */ function ting_do_scan($query, $phrase = 'anyIndexes', $num_results = 10) { $request = ting_get_request_factory()->getScanRequest(); @@ -551,8 +604,13 @@ function ting_do_scan($query, $phrase = 'anyIndexes', $num_results = 10) { } /** - * @param object $request - The TingClient object + * Add agency to ting scan request. + * + * @param TingClientScanRequest $request + * The request to add agency to. + * * @return TingClientScanRequest + * The request with the added agency. */ function ting_add_agency(TingClientScanRequest $request) { if ($agency = variable_get('ting_agency', FALSE)) { @@ -562,9 +620,16 @@ function ting_add_agency(TingClientScanRequest $request) { } /** - * @param string $word The word to get spell suggestions for - * @param $num_results The number of results to return - * @return array An array of TingClientSpellSuggestion objects + * Get spell suggestions from the open spell service. + * + * @param string $word + * The word to get spell suggestions for. + * @param int $num_results + * The number of results to return. + * + * @return mixed + * Array with TingClientSpellSuggestion objects or FALSE if non found or + * connection failed. */ function ting_get_spell_suggestions($word, $num_results = 10) { $request = ting_get_request_factory()->getSpellRequest(); @@ -572,4 +637,3 @@ function ting_get_spell_suggestions($word, $num_results = 10) { $request->setNumResults($num_results); return ting_execute($request); } - From 96627619d30bc3361d8fe9e8be066d151b69a421 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 9 Oct 2013 15:26:16 +0200 Subject: [PATCH 057/167] Removed function to get ting object, as one allready exists --- ting.client.inc | 87 ++++++++++++++++++----------------------------- ting.entities.inc | 4 +-- 2 files changed, 36 insertions(+), 55 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index 102ac4f..bfd5c6f 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -4,35 +4,6 @@ * Wrapper functions for Ting client. */ -/** - * Get ting object based on an object id. - * - * @param string $object_id - * Ting object id. - * - * @return TingClientObject - * The object requested. - */ -function ting_get_object_request($object_id) { - $request = ting_get_request_factory()->getObjectRequest(); - if ($agency = variable_get('ting_agency', FALSE)) { - $request->setAgency($agency); - } - $request->setObjectId($object_id); - $request->setAllRelations(TRUE); - $request->setRelationData('full'); - - // Set search profile, if applicable. - $profile = variable_get('ting_search_profile', ''); - if (!empty($profile) && method_exists($request, 'setProfile')) { - $request->setProfile($profile); - } - - $object = ting_execute_cache($request); - - return $object; -} - /** * Get an ting object or collection. * @@ -43,55 +14,65 @@ function ting_get_object_request($object_id) { * @param string $object_id * The id to fetch. * @param bool $collection - * Whether to return a collection, if possible, or - * an object. + * Whether to return a collection, if possible, or an object. + * @param bool $with_relations + * Whether to return all relations. Defaults to FALSE. * * @todo Should use getObject, but the ting-client lib doesn't implement that. * * @return TingClientObject * Ting object. */ -function ting_get_object($object_id, $collection = FALSE) { - if (empty($object_id)) { - return FALSE; - } - - // Check the cache first. - $object = ting_cache_get($object_id, $collection); - if (!$object) { - // Put a negative reply in the cache. It will be overwritten by the - // object, or ensure that we won't try to fetch this id again. - ting_cache_set($object_id, NULL); - +function ting_get_object($object_id, $collection = FALSE, $with_relations = FALSE) { + if (!empty($object_id)) { + // Check the cache first. + $object = ting_cache_get($object_id, $collection); if (!$object) { + // Put a negative reply in the cache. It will be overwritten by the + // object, or ensure that we won't try to fetch this id again. + ting_cache_set($object_id, NULL); + + // Build request request and set object id. $request = ting_get_request_factory()->getCollectionRequest(); $request->setObjectId($object_id); + + // Set agency from the administration interface. if ($agency = variable_get('ting_agency', FALSE)) { $request->setAgency($agency); } + // Set search profile from the administration interface. $profile = variable_get('ting_search_profile', ''); if (!empty($profile) && method_exists($request, 'setProfile')) { $request->setProfile($profile); } + // Get all relations for the object. + if ($with_relations) { + $request->setAllRelations(TRUE); + $request->setRelationData('full'); + } + + // Execute the request. $request->setAllObjects(FALSE); $object = ting_execute_cache($request); } - } - // If not asking for a collection, and the object is, return the - // sub-object with the same id. - if (!$collection && isset($object->objects)) { - foreach ($object->objects as $sub_object) { - if ($sub_object->id == $object_id) { - return $sub_object; + // If not asking for a collection, and the object is, return the + // sub-object with the same id. + if (!$collection && isset($object->objects)) { + foreach ($object->objects as $sub_object) { + if ($sub_object->id == $object_id) { + return $sub_object; + } } + // No sub-object had the same id. Somethings broken. + return NULL; } - // No sub-object had the same id. Somethings broken. - return NULL; + return $object; } - return $object; + + return NULL; } /** diff --git a/ting.entities.inc b/ting.entities.inc index 8d911a2..f28c7a3 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -203,7 +203,7 @@ class TingEntity extends DingEntity { function getRelations() { // If relations are not set; do another request to get relations if( !isset($this->reply->relationsData) ) { - $tingClientObject = ting_get_object_request($this->ding_entity_id); + $tingClientObject = ting_get_object($this->ding_entity_id, FALSE, TRUE); if( isset($tingClientObject->relationsData) ) { $this->reply->relationsData = $tingClientObject->relationsData; } @@ -268,7 +268,7 @@ class TingEntity extends DingEntity { // relations. First check if relations are set; if not do another request // to get relations if (!isset($this->reply->relationsData)) { - $tingClientObject = ting_get_object_request($this->ding_entity_id); + $tingClientObject = ting_get_object($this->ding_entity_id, FALSE, TRUE); if (isset($tingClientObject->relationsData)) { $this->reply->relationsData = $tingClientObject->relationsData; } From b4899dd0512b50b7afa7dfdf25ae11ee93d6b56a Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 10 Oct 2013 08:53:39 +0200 Subject: [PATCH 058/167] Added better cache possibilities to the ting_execute_cache function and add missing documentation --- ting.client.inc | 150 +++++++++++++++++++++++++++++++----------------- ting.module | 6 ++ 2 files changed, 103 insertions(+), 53 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index bfd5c6f..9c68f10 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -26,7 +26,7 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALSE) { if (!empty($object_id)) { // Check the cache first. - $object = ting_cache_get($object_id, $collection); + $object = ting_cache_get($object_id, ($collection ? TING_CACHE_COLLECTION : TING_CACHE_TING_OBJECT)); if (!$object) { // Put a negative reply in the cache. It will be overwritten by the // object, or ensure that we won't try to fetch this id again. @@ -298,75 +298,104 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar * The search reply from the data well. */ function ting_execute_cache($request) { + $parms = $request->getRequest()->getParameters(); + + // Handle fulltext vs. dkabm caching of object. + $type = TING_CACHE_TING_OBJECT; + if ($parms['format'] == 'docbook') { + $type = TING_CACHE_TING_OBJECT_FULLTEXT; + } + + // User static cache to store request, used in another function to see if the + // same request is made more than once. $calls = &drupal_static(__FUNCTION__); if (!isset($calls)) { $calls = array(); } - $calls[] = $request->getRequest()->getParameters(); - - $reply = ting_execute($request); - - // Cache any sub-objects (mostly true for collections). - if (isset($reply->objects)) { - foreach ($reply->objects as $object) { - ting_cache_set($object->id, $object); - // Cache any relations. - if (isset($object->relations)) { - foreach ($object->relations as $relation) { - if (isset($relation->id)) { - ting_cache_set($relation->id, $relation); + $calls[] = $parms; + + // Check if the reply have been stored in cache. + $reply = ting_cache_get(md5(serialize($parms)), TING_CACHE_REPLY); + + if (!isset($reply)) { + // Reply for the request was not found, so we have to ask the data well. + $reply = ting_execute($request); + + // Cache any sub-objects (mostly true for collections). + if (isset($reply->objects)) { + foreach ($reply->objects as $object) { + ting_cache_set($object->id, $object, $type); + // Cache any relations. + if (isset($object->relations)) { + foreach ($object->relations as $relation) { + if (isset($relation->id)) { + ting_cache_set($relation->id, $relation); + } } } } } - // Cache the reply as the first object's id. This is for collections. - if (!isset($reply->id) and isset($reply->objects[0])) { - ting_cache_set($reply->objects[0]->id, $reply); - } - } - // Cache any collections. Done after objects to ensure that collections take - // precedence. - if (isset($reply->collections)) { - foreach ($reply->collections as &$collection) { - if (isset($collection->objects[0])) { - foreach ($collection->objects as $object) { - // Cache any relations. - if (isset($object->relations)) { - foreach ($object->relations as $relation) { - if (isset($relation->id)) { - ting_cache_set($relation->id, $relation); + // Cache any collections. Done after objects to ensure that collections take + // precedence. + if (isset($reply->collections)) { + foreach ($reply->collections as &$collection) { + if (isset($collection->objects[0])) { + foreach ($collection->objects as $object) { + // Cache any relations. + if (isset($object->relations)) { + foreach ($object->relations as $relation) { + if (isset($relation->id)) { + ting_cache_set($relation->id, $relation); + } } } + ting_cache_set($object->id, $object, $type); } - ting_cache_set($object->id, $object); + ting_cache_set($collection->objects[0]->id, $collection, TING_CACHE_COLLECTION); } - - ting_cache_set($collection->objects[0]->id, $collection); } } - } - // Cache any relations. - if (isset($reply->relations)) { - foreach ($reply->relations as $object) { - ting_cache_set($object->id, $object); + // Cache any relations. + if (isset($reply->relations)) { + foreach ($reply->relations as $relation) { + ting_cache_set($relation->id, $relation); + } } - } - // Lastly cache the reply itself if it has an id. - if (isset($reply->id)) { - ting_cache_set($reply->id, $reply); + // Store the reply for the request itself in the cache. + ting_cache_set(md5(serialize($parms)), $reply, TING_CACHE_REPLY); } return $reply; } /** - * Get item from static cache. + * Get cached version of a data well search. + * + * The cache can lookup ting objects, ting collections or even a replay from + * the data well. + * + * To retrieve an reply simple extract the params from the request object, + * serialize them and make a MD5 hash as id. + * + * @see ting_execute_cache() + * + * @param string $id + * Object id or the MD5 hash of the parameters used to execute a search + * against the date well. + * @param string $type + * The type of data to cache, which is used to set the cache id. It should be + * one off: TING_CACHE_TING_OBJECT, TING_CACHE_COLLECTION, + * TING_CACHE_TING_OBJECT_FULLTEXT or TING_CACHE_REPLY. + * + * @return mixed + * The cached item based on the $type and $id given. If non found in the cache + * NULL is returned. */ -function ting_cache_get($id, $collection = FALSE) { - $cid = 'ting-' . ($collection ? 'collection' : 'object') . ':' . $id; +function ting_cache_get($id, $type = TING_CACHE_TING_OBJECT) { + $cid = $type . ':' . $id; if ($ttl = variable_get('ting_cache_lifetime', TING_DEFAULT_CACHE_LIFETIME)) { $cache = cache_get($cid); @@ -391,20 +420,35 @@ function ting_cache_get($id, $collection = FALSE) { } /** - * Put item in the static cache. + * Store cached version of a data well search. + * + * The cache can store ting objects, ting collections or even a replay from + * the data well. + * + * To store an reply simple extract the params from the request object, + * serialize them and make a MD5 hash as id. + * + * @see ting_execute_cache() + * + * @param string $id + * Id that the item was cached under. + * @param mixed $value + * The value to store in the cache. + * @param string $type + * The type of data to cache, which is used to set the cache id. It should be + * one off: TING_CACHE_TING_OBJECT, TING_CACHE_COLLECTION, + * TING_CACHE_TING_OBJECT_FULLTEXT or TING_CACHE_REPLY. */ -function ting_cache_set($id, $value) { - $cid = 'ting-object'; - if ($value instanceof TingClientObjectCollection) { - $cid = 'ting-collection'; - } - $cid .= ':' . $id; +function ting_cache_set($id, $value, $type = TING_CACHE_TING_OBJECT) { + // Define the cache id. + $cid = $type . ':' . $id; if ($ttl = variable_get('ting_cache_lifetime', TING_DEFAULT_CACHE_LIFETIME)) { cache_set($cid, $value, 'cache', REQUEST_TIME + $ttl); } else { - // Without proper caching, use a request cache. + // Without proper caching, use a static cache that only works on pr. + // request. $cache = &drupal_static(__FUNCTION__); if (!isset($cache)) { $cache = array(); diff --git a/ting.module b/ting.module index 4b3dd53..3c7d9f0 100644 --- a/ting.module +++ b/ting.module @@ -4,7 +4,13 @@ * Enables integration with Ting. */ +// Define the different types of data that we cache in ting_set_cache and the +// default TTL. define('TING_DEFAULT_CACHE_LIFETIME', 0); +define('TING_CACHE_TING_OBJECT', 'ting-object'); +define('TING_CACHE_TING_OBJECT_FULLTEXT', 'ting-object-fulltext'); +define('TING_CACHE_COLLECTION', 'ting-collection'); +define('TING_CACHE_REPLY', 'ting-reply'); // Load Field module hooks. module_load_include('inc', 'ting', 'ting.field'); From c776b8c35b033cb3abbd236c06af8d0d301d1a89 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 10 Oct 2013 10:28:23 +0200 Subject: [PATCH 059/167] Added cache table for ting execute cache and drush support to clear the cache --- ting.client.inc | 4 ++-- ting.drush.inc | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ ting.install | 15 ++++++++++++- ting.module | 16 +++++++++++--- 4 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 ting.drush.inc diff --git a/ting.client.inc b/ting.client.inc index 9c68f10..f22dca8 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -398,7 +398,7 @@ function ting_cache_get($id, $type = TING_CACHE_TING_OBJECT) { $cid = $type . ':' . $id; if ($ttl = variable_get('ting_cache_lifetime', TING_DEFAULT_CACHE_LIFETIME)) { - $cache = cache_get($cid); + $cache = cache_get($cid, 'cache_ting'); if ($cache && ($cache->expire > REQUEST_TIME)) { return $cache->data; } @@ -444,7 +444,7 @@ function ting_cache_set($id, $value, $type = TING_CACHE_TING_OBJECT) { $cid = $type . ':' . $id; if ($ttl = variable_get('ting_cache_lifetime', TING_DEFAULT_CACHE_LIFETIME)) { - cache_set($cid, $value, 'cache', REQUEST_TIME + $ttl); + cache_set($cid, $value, 'cache_ting', REQUEST_TIME + $ttl); } else { // Without proper caching, use a static cache that only works on pr. diff --git a/ting.drush.inc b/ting.drush.inc new file mode 100644 index 0000000..e3b4796 --- /dev/null +++ b/ting.drush.inc @@ -0,0 +1,56 @@ + 'Local proxy table for ting objects.', 'fields' => array( @@ -85,6 +85,9 @@ function ting_schema() { ), ); + // Cache table used by ting_execute_cache. + $schema['cache_ting'] = drupal_get_schema_unprocessed('system', 'cache'); + return $schema; } @@ -211,3 +214,13 @@ function ting_update_7000() { ->condition('module', 'ting') ->execute(); } + +/** + * Add cache table to use with ting_execute_cache(). + */ +function ting_update_7001() { + $schema = ting_schema(); + $ret = array(); + $ret[] = db_create_table('cache_ting', $schema['cache_ting']); + return $ret; +} diff --git a/ting.module b/ting.module index 3c7d9f0..7578ad8 100644 --- a/ting.module +++ b/ting.module @@ -229,6 +229,13 @@ function ting_block_info() { ); } +/** + * Implements hook_flush_caches(). + */ +function ting_flush_caches() { + return array('cache_ting'); +} + /** * Get relations for an ting_entity as an array ([$type] => array($relations)). */ @@ -776,10 +783,13 @@ function ting_boost_field_element_process($element, $form_state) { return $element; } +/** + * Validate the boost form. + */ function boost_weight_validate($element, &$form_state) { - if ( !empty($element['#value']) && ($element['#value'] != (string)(int)$element['#value']) ) { - form_error($element, t('Boost weight is an integer.')); - } + if (!empty($element['#value']) && (is_int($element['#value']))) { + form_error($element, t('Boost weight is an integer.')); + } } /** From c2f9eb7d8a21af0681bca815389446d63ad6155b Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 10 Oct 2013 13:00:23 +0200 Subject: [PATCH 060/167] Added cron job to ensure that expire cache entries are removed --- ting.module | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ting.module b/ting.module index 7578ad8..9425b85 100644 --- a/ting.module +++ b/ting.module @@ -229,6 +229,15 @@ function ting_block_info() { ); } +/** + * Implements hook_cron(). + * + * Ensures that all expired entries are delete form the cache on cron runes. + */ +function ting_cron() { + cache_clear_all(NULL, 'cache_ting'); +} + /** * Implements hook_flush_caches(). */ From d430114173a5f775dedbf33e2eb958ff24f07ba9 Mon Sep 17 00:00:00 2001 From: Rune Schjellerup Philosof Date: Wed, 23 Oct 2013 16:00:51 +0200 Subject: [PATCH 061/167] Send smaller requests to avoid breaking opensearch. 188 or more record ids in the query seems to break opensearch. --- ting.client.inc | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index f22dca8..c62f83f 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -105,14 +105,9 @@ function ting_get_objects($ids) { } // Open search is limited to 50 results per call, so iterate until all results // have been fetched. - $i = 0; - do { - // If the query is empty, then don't do it. - // Not necessary to do in each iteration, but it doesn't hurt much. - if (count($query) == 0) { - break; - } - + // Also it has a limit on the size of the query (>187 rec.id= ORed together seems to break it). + $query_chunks = array_chunk($query, 50); + foreach ($query_chunks as $query_chunk) { $request = ting_get_request_factory()->getSearchRequest(); if ($agency = variable_get('ting_agency', FALSE)) { $request->setAgency($agency); @@ -121,9 +116,8 @@ function ting_get_objects($ids) { if (!empty($profile) && method_exists($request, 'setProfile')) { $request->setProfile($profile); } - $request->setQuery(implode(' OR ', $query)); - // Do it in steps of 50. - $request->setStart($i * 50 + 1); + $request->setQuery(implode(' OR ', $query_chunk)); + $request->setStart(1); $request->setNumResults(50); $request->setAllObjects(TRUE); @@ -138,13 +132,7 @@ function ting_get_objects($ids) { } } } - else { - // Result was false, hence the more property used in the while do not - // exists. - break; - } - $i++; - } while ($result->more); + } return $objects; } From 5578564dbaf09e5d9b4fec257623d6e2fc3eb46d Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 24 Oct 2013 22:04:12 +0200 Subject: [PATCH 062/167] Fixed the ting cache, now with relations --- ting.client.inc | 83 ++++++++++++++++++++++++++++++++++++++++++----- ting.entities.inc | 2 +- 2 files changed, 75 insertions(+), 10 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index f22dca8..a70d16a 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -4,6 +4,12 @@ * Wrapper functions for Ting client. */ +/** + * Used to indicate that a given cache entry have return no reply from the data + * well. + */ +define('TING_CACHE_EMPTY_ENTRY', '8e4f3ef1784c020bf7afa5b6dd69b421'); + /** * Get an ting object or collection. * @@ -26,11 +32,12 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALSE) { if (!empty($object_id)) { // Check the cache first. - $object = ting_cache_get($object_id, ($collection ? TING_CACHE_COLLECTION : TING_CACHE_TING_OBJECT)); - if (!$object) { + $type = ($collection ? TING_CACHE_COLLECTION : TING_CACHE_TING_OBJECT); + $object = ting_cache_get($object_id, $type, $with_relations); + if ($object != TING_CACHE_EMPTY_ENTRY && !$object) { // Put a negative reply in the cache. It will be overwritten by the // object, or ensure that we won't try to fetch this id again. - ting_cache_set($object_id, NULL); + ting_cache_set($object_id, TING_CACHE_EMPTY_ENTRY, $type); // Build request request and set object id. $request = ting_get_request_factory()->getCollectionRequest(); @@ -63,12 +70,22 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALS if (!$collection && isset($object->objects)) { foreach ($object->objects as $sub_object) { if ($sub_object->id == $object_id) { + // If not asking for a collection, and the object is, return the + // sub-object with the same id. + _ting_cache_no_relations($sub_object, $with_relations); return $sub_object; } } // No sub-object had the same id. Somethings broken. return NULL; } + + // If not asking for a collection, and the object is, return the + // sub-object with the same id. + if ($object == TING_CACHE_EMPTY_ENTRY) { + return NULL; + } + return $object; } @@ -99,7 +116,7 @@ function ting_get_objects($ids) { $query = array(); foreach ($objects as $id => $object) { - if (!isset($object)) { + if ($object === FALSE) { $query[] = 'rec.id=' . $id; } } @@ -317,7 +334,7 @@ function ting_execute_cache($request) { // Check if the reply have been stored in cache. $reply = ting_cache_get(md5(serialize($parms)), TING_CACHE_REPLY); - if (!isset($reply)) { + if (!$reply) { // Reply for the request was not found, so we have to ask the data well. $reply = ting_execute($request); @@ -365,9 +382,16 @@ function ting_execute_cache($request) { } // Store the reply for the request itself in the cache. + if (is_null($reply)) { + // Handle empty data well replies. + $reply = TING_CACHE_EMPTY_ENTRY; + } ting_cache_set(md5(serialize($parms)), $reply, TING_CACHE_REPLY); } + if ($reply == TING_CACHE_EMPTY_ENTRY) { + return NULL; + } return $reply; } @@ -389,20 +413,32 @@ function ting_execute_cache($request) { * The type of data to cache, which is used to set the cache id. It should be * one off: TING_CACHE_TING_OBJECT, TING_CACHE_COLLECTION, * TING_CACHE_TING_OBJECT_FULLTEXT or TING_CACHE_REPLY. + * @param bool $with_relations + * Is the object we are looking up with relations (addi posts). * * @return mixed * The cached item based on the $type and $id given. If non found in the cache * NULL is returned. */ -function ting_cache_get($id, $type = TING_CACHE_TING_OBJECT) { +function ting_cache_get($id, $type = TING_CACHE_TING_OBJECT, $with_relations = FALSE) { $cid = $type . ':' . $id; if ($ttl = variable_get('ting_cache_lifetime', TING_DEFAULT_CACHE_LIFETIME)) { $cache = cache_get($cid, 'cache_ting'); if ($cache && ($cache->expire > REQUEST_TIME)) { - return $cache->data; + $data = $cache->data; + // Check if cached version has relations, if request. If it's an empty + // array it have not been request by the server yet with relations, so + // return FALSE to trigger a data well request. + if ($with_relations && (isset($data->relations) && is_array($data->relations) && !count($data->relations))) { + return FALSE; + } + + // The data maybe NULL which means that the data well have been asked + // about this object and no where found. + return $data; } - return NULL; + return FALSE; } else { // Without proper caching, use a request cache. @@ -415,7 +451,7 @@ function ting_cache_get($id, $type = TING_CACHE_TING_OBJECT) { if (array_key_exists($cid, $cache)) { return $cache[$cid]; } - return NULL; + return FALSE; } } @@ -457,6 +493,35 @@ function ting_cache_set($id, $value, $type = TING_CACHE_TING_OBJECT) { } } +/** + * Mark the object in the cache as having no relations in the data well. + * + * This is need as object may have been cached without relations in a search + * request, but a get_object request may ask for the same object from cache with + * relations. So this FALSE value is used to ensure that the data well is only + * asked once for a object with relations even, if it do not have relations. + * + * Default value from the data well is an empty array, so if the array is empty + * the ting_cache_set, function will not return the cached if relations are + * requested. + * + * @param StdClass $object + * Ting data well object. + * @param bool $with_relations + * If TRUE relations will be marked. + */ +function _ting_cache_no_relations($object, $with_relations) { + if ($with_relations && $object instanceof TingClientObject) { + if (empty($object->relations)) { + // Mark this object as having no relations. + $object->relations = FALSE; + } + + // Update cache with the object. + ting_cache_set($object->id, $object); + } +} + /** * Get recommendations for a given ISBN. * diff --git a/ting.entities.inc b/ting.entities.inc index f28c7a3..0650515 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -202,7 +202,7 @@ class TingEntity extends DingEntity { function getRelations() { // If relations are not set; do another request to get relations - if( !isset($this->reply->relationsData) ) { + if (!isset($this->reply->relationsData)) { $tingClientObject = ting_get_object($this->ding_entity_id, FALSE, TRUE); if( isset($tingClientObject->relationsData) ) { $this->reply->relationsData = $tingClientObject->relationsData; From 17bebdcfe633387b7303270e7bc8fc8fa8f6419d Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 25 Oct 2013 14:25:08 +0200 Subject: [PATCH 063/167] Fixed relation and caching of the relations in ting cache --- ting.client.inc | 46 +++++++++++++++++++++++++++++----------------- ting.entities.inc | 2 +- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index a70d16a..f5ff142 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -40,7 +40,13 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALS ting_cache_set($object_id, TING_CACHE_EMPTY_ENTRY, $type); // Build request request and set object id. - $request = ting_get_request_factory()->getCollectionRequest(); + $request = ting_get_request_factory()->getObjectRequest(); + if ($collection) { + // If this is a collection we need to do a collection request, which is + // a search request. + $request = ting_get_request_factory()->getCollectionRequest(); + $request->setAllObjects(FALSE); + } $request->setObjectId($object_id); // Set agency from the administration interface. @@ -61,7 +67,6 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALS } // Execute the request. - $request->setAllObjects(FALSE); $object = ting_execute_cache($request); } @@ -80,6 +85,11 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALS return NULL; } + // Mark the object in cache as relations have been loaded. + if (!$collection) { + _ting_cache_no_relations($object, $with_relations); + } + // If not asking for a collection, and the object is, return the // sub-object with the same id. if ($object == TING_CACHE_EMPTY_ENTRY) { @@ -112,12 +122,26 @@ function ting_get_objects($ids) { // No sub-object had the same id. Somethings broken. $objects[$id] = NULL; } + + if ($objects[$id] == TING_CACHE_EMPTY_ENTRY) { + $objects[$id] = NULL; + } } + // Not all object are searchable, such as relation etc. So to get over this we + // split the request into to groups "own id's" and "others". Where the first + // is ensured to be searchable. + $agency = variable_get('ting_agency', FALSE); $query = array(); foreach ($objects as $id => $object) { if ($object === FALSE) { - $query[] = 'rec.id=' . $id; + if (preg_match('/^' . $agency . '/', $id)) { + $query[] = 'rec.id=' . $id; + } + else { + // Get objects. + $objects[$id] = ting_get_object($id); + } } } // Open search is limited to 50 results per call, so iterate until all results @@ -131,7 +155,7 @@ function ting_get_objects($ids) { } $request = ting_get_request_factory()->getSearchRequest(); - if ($agency = variable_get('ting_agency', FALSE)) { + if ($agency) { $request->setAgency($agency); } $profile = variable_get('ting_search_profile', ''); @@ -392,6 +416,7 @@ function ting_execute_cache($request) { if ($reply == TING_CACHE_EMPTY_ENTRY) { return NULL; } + return $reply; } @@ -440,19 +465,6 @@ function ting_cache_get($id, $type = TING_CACHE_TING_OBJECT, $with_relations = F } return FALSE; } - else { - // Without proper caching, use a request cache. - $cache = &drupal_static('ting_cache_set'); - if (!isset($cache)) { - $cache = array(); - } - // Using array_key_exists, as we might contain NULL values (which is - // !isset()). - if (array_key_exists($cid, $cache)) { - return $cache[$cid]; - } - return FALSE; - } } /** diff --git a/ting.entities.inc b/ting.entities.inc index 0650515..40a5ed6 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -204,7 +204,7 @@ class TingEntity extends DingEntity { // If relations are not set; do another request to get relations if (!isset($this->reply->relationsData)) { $tingClientObject = ting_get_object($this->ding_entity_id, FALSE, TRUE); - if( isset($tingClientObject->relationsData) ) { + if (isset($tingClientObject->relationsData)) { $this->reply->relationsData = $tingClientObject->relationsData; } } From bc4cf707da22fe1ae23c45a05836da481e251de2 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 4 Nov 2013 21:21:51 +0100 Subject: [PATCH 064/167] Updated makefile to point to tag 7.x-1.0-beta2 --- ting.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.make b/ting.make index 63be4d7..bcef6f3 100644 --- a/ting.make +++ b/ting.make @@ -21,4 +21,4 @@ libraries[ting-client][destination] = "modules/ting/lib" 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" From 5cb1397bd026cb5fedebea8d88b15bf1be0619d4 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 11 Nov 2013 12:58:19 +0100 Subject: [PATCH 065/167] Updated coding style --- ting.field.inc | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/ting.field.inc b/ting.field.inc index 228eb75..2c8de75 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -109,7 +109,8 @@ function ting_field_load($entity_type, $entities, $field, $instances, $langcode, ); } } - } else { + } + else { foreach ($entities as $id => $entity) { $items[$id][0] = array( 'id' => $entity->id, @@ -211,6 +212,7 @@ function ting_field_formatter_settings_form($field, $instance, $view_mode, $form '#default_value' => $settings['link_type'], ); break; + case 'ting_entities': $element['hide_primary'] = array( '#type' => 'checkbox', @@ -218,6 +220,7 @@ function ting_field_formatter_settings_form($field, $instance, $view_mode, $form '#description' => t("Don't show the primary object as part of the list."), '#default_value' => $settings['hide_primary'], ); + case 'ting_primary_object': $entity_info = entity_get_info('ting_object'); $view_modes = array(); @@ -248,8 +251,10 @@ function ting_field_formatter_settings_summary($field, $instance, $view_mode) { case 'ting_title': $summary .= t('Link type: @type', array('@type' => $settings['link_type'])); break; + case 'ting_entities': $summary .= $settings['hide_primary'] ? t("Don't show primary. ") : t("Include primary. "); + case 'ting_primary_object': $view_mode = $settings['view_mode']; $entity_info = entity_get_info('ting_object'); @@ -275,7 +280,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la $entities = $entity->entities; // Skip the first. if ($display['settings']['hide_primary']) { - $primary = array_shift($entities); + array_shift($entities); } foreach ($entity->types as $type) { @@ -301,13 +306,9 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la */ $type = 'ting_object'; if ($display['settings']['link_type'] == 'collection') { - // // Check if the cache contains an collection for this id. - // $x = ting_cache_get($entity->id); - // if ($x instanceof TingClientObjectCollection) { $type = 'ting_collection'; - // } } - // Only create the link if the object is available in the datawell. + // Only create the link if the object is available in the data well. if ($display['settings']['link_type'] != 'none' && !isset($entity->is_available)) { $url = entity_uri($type, $entity); $title = l($entity->title, $url['path'], $url['options']); @@ -329,22 +330,24 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la array( 'data' => $entity->type, 'class' => array(drupal_html_class($entity->type)), - ) + ), ), ); break; case 'ting_series_default': if ($entity->serieTitle) { - // The search string used is configurable because the datawell is not fully implemented regarding series. - // As default we search both in the serietitle register and the description field because many series only have data in the description field. - // This will problably change with new versions of the datawell. - $search_term = str_replace('@serietitle' , drupal_strtolower($entity->serieTitle),variable_get('ting_admin_register_serie_title', 'bib.titleSeries="@serietitle" OR dc.description="@serietitle"')); + // The search string used is configurable because the data well is not + // fully implemented regarding series. As default we search both in + // the series title register and the description field because many + // series only have data in the description field. This will probably + // change with new versions of the data well. + $search_term = str_replace('@serietitle', drupal_strtolower($entity->serieTitle), variable_get('ting_admin_register_serie_title', 'bib.titleSeries="@serietitle" OR dc.description="@serietitle"')); $element[$delta] = array( - '#markup' => l($entity->serieTitle, 'search/ting/' . $search_term , array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), + '#markup' => l($entity->serieTitle, 'search/ting/' . $search_term, array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), ); } - else if ($entity->serieDescription) { + elseif ($entity->serieDescription) { $element[$delta] = array( '#markup' => $entity->serieDescription, ); @@ -367,8 +370,8 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la if ($entity->date != '') { $markup_string = t('By !author_link (@year)', array( '!author_link' => implode(', ', $creators), - '@year' => $entity->date, // So wrong, but appears to - // be the way the data is. + // So wrong, but appears to be the way the data is. + '@year' => $entity->date, )); } else { @@ -377,7 +380,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la )); } } - else if ($entity->date != '') { + elseif ($entity->date != '') { $markup_string = t('(@year)', array('@year' => $entity->date)); } $element[$delta] = array( From 9396394f020bc368e8160d7ff9fc56d0d0cd7b05 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 11 Nov 2013 14:59:12 +0100 Subject: [PATCH 066/167] Added new property to TingEntity with collection types information --- ting.entities.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ting.entities.inc b/ting.entities.inc index 40a5ed6..293cffa 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -33,6 +33,7 @@ class TingRelation extends DingEntityBase { */ class TingEntity extends DingEntity { public $type = DingEntityBase::NULL; + public $collectionTypes = DingEntityBase::NULL; public $serieNumber = DingEntityBase::NULL; public $serieTitle = DingEntityBase::NULL; public $serieDescription = DingEntityBase::NULL; @@ -53,6 +54,10 @@ class TingEntity extends DingEntity { public $classification = DingEntityBase::NULL; public $isbn = DingEntityBase::NULL; + public function getCollectionTypes() { + return !empty($this->reply->collectionTypes[0]) ? $this->reply->collectionTypes : FALSE; + } + public function getExtent() { return !empty($this->reply->record['dcterms:extent'][''][0]) ? $this->reply->record['dcterms:extent'][''][0] : FALSE; } From bda18de6f85cf796a1a625d65ea9d3b8f81ef0ed Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 11 Nov 2013 14:59:37 +0100 Subject: [PATCH 067/167] Added new formatter option to ting titles to display type information in the title --- ting.field.inc | 46 ++++++++++++++++++++++++++++++++++++++++------ ting.make | 1 + 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/ting.field.inc b/ting.field.inc index 2c8de75..764cda2 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -131,6 +131,7 @@ function ting_field_formatter_info() { ), 'settings' => array( 'link_type' => 'none', + 'prefix_type' => 'no', ), ), 'ting_type_default' => array( @@ -211,6 +212,16 @@ function ting_field_formatter_settings_form($field, $instance, $view_mode, $form ), '#default_value' => $settings['link_type'], ); + + $element['prefix_type'] = array( + '#type' => 'radios', + '#title' => t('Prefix with "ting type"'), + '#options' => array( + 'no' => t('No'), + 'yes' => t('Yes'), + ), + '#default_value' => $settings['prefix_type'], + ); break; case 'ting_entities': @@ -249,7 +260,9 @@ function ting_field_formatter_settings_summary($field, $instance, $view_mode) { $summary = ''; switch ($field['type']) { case 'ting_title': - $summary .= t('Link type: @type', array('@type' => $settings['link_type'])); + $summary .= t('Link type: @type', array('@type' => $settings['link_type'])); + $summary .= '
'; + $summary .= t('Prefix with type: @type', array('@type' => $settings['prefix_type'])); break; case 'ting_entities': @@ -316,11 +329,32 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la else { $title = check_plain($entity->title); } - $element[$delta] = array( - '#prefix' => '

', - '#suffix' => '

', - '#markup' => $title, - ); + + // Check if element should be prefixed with type. + if ($display['settings']['prefix_type'] == 'yes') { + $ting_type = $entity->getType(); + if (count($entity->getCollectionTypes()) > 1) { + $ting_type = t('Material collection'); + } + + $element[$delta] = array( + '#prefix' => '

', + '#suffix' => '

', + 'title' => array( + // @todo: this could be moved into a theme function to be more + // generic. + '#prefix' => '' . $ting_type . ':', + '#markup' => $title, + ), + ); + } + else { + $element[$delta] = array( + '#prefix' => '

', + '#suffix' => '

', + '#markup' => $title, + ); + } break; case 'ting_type_default': diff --git a/ting.make b/ting.make index 63be4d7..aa3a556 100644 --- a/ting.make +++ b/ting.make @@ -14,6 +14,7 @@ projects[virtual_field][version] = "1.1" libraries[ting-client][download][type] = "git" libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" +libraries[ting-client][download][branch] = "development" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules From e430b8820c273402f9aaceaf58babe0dac8ae354 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 11 Nov 2013 15:18:11 +0100 Subject: [PATCH 068/167] Revert "Added new property to TingEntity with collection types information" as caching is not working with this solution. This reverts commit 9396394f020bc368e8160d7ff9fc56d0d0cd7b05. --- ting.entities.inc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index 293cffa..40a5ed6 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -33,7 +33,6 @@ class TingRelation extends DingEntityBase { */ class TingEntity extends DingEntity { public $type = DingEntityBase::NULL; - public $collectionTypes = DingEntityBase::NULL; public $serieNumber = DingEntityBase::NULL; public $serieTitle = DingEntityBase::NULL; public $serieDescription = DingEntityBase::NULL; @@ -54,10 +53,6 @@ class TingEntity extends DingEntity { public $classification = DingEntityBase::NULL; public $isbn = DingEntityBase::NULL; - public function getCollectionTypes() { - return !empty($this->reply->collectionTypes[0]) ? $this->reply->collectionTypes : FALSE; - } - public function getExtent() { return !empty($this->reply->record['dcterms:extent'][''][0]) ? $this->reply->record['dcterms:extent'][''][0] : FALSE; } From 24cba0f08ecf790e43a3f6a18df8bee18ecb133a Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 11 Nov 2013 15:25:12 +0100 Subject: [PATCH 069/167] Fixed ting title formatter type prefix --- ting.field.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ting.field.inc b/ting.field.inc index 764cda2..1f1680c 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -332,8 +332,9 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la // Check if element should be prefixed with type. if ($display['settings']['prefix_type'] == 'yes') { + $collction = ting_collection_load($entity->id); $ting_type = $entity->getType(); - if (count($entity->getCollectionTypes()) > 1) { + if (count($collction->types) > 1) { $ting_type = t('Material collection'); } From 8f95ef6479675125d8782957550c2a64865f25d8 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 18 Nov 2013 11:37:54 +0100 Subject: [PATCH 070/167] Fixed caching issues with collections --- ting.client.inc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index baf8f6b..d30bb3a 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -68,6 +68,12 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALS // Execute the request. $object = ting_execute_cache($request); + + // If this was a collection request store the collection reply to ensure + // that there is no empty cache entry. + if ($collection) { + ting_cache_set($object_id, $object, $type); + } } // If not asking for a collection, and the object is, return the @@ -111,7 +117,7 @@ function ting_get_objects($ids) { $objects = array(); // Pre-fill from cache. foreach ($ids as $id) { - $objects[$id] = ting_cache_get($id); + $objects[$id] = ting_cache_get($id, TING_CACHE_TING_OBJECT); if (isset($objects[$id]) && isset($objects[$id]->objects)) { foreach ($objects[$id]->objects as $sub_object) { if ($sub_object->id == $id) { @@ -136,17 +142,17 @@ function ting_get_objects($ids) { foreach ($objects as $id => $object) { if ($object === FALSE) { if (preg_match('/^' . $agency . '/', $id)) { - $query[] = 'rec.id=' . $id; - } - else { // Get objects. $objects[$id] = ting_get_object($id); } + else { + $query[] = 'rec.id=' . $id; + } } } // Open search is limited to 50 results per call, so iterate until all results - // have been fetched. - // Also it has a limit on the size of the query (>187 rec.id= ORed together seems to break it). + // have been fetched. It has a limit on the size of the query (>187 rec.id= + // ORed together seems to break it). $query_chunks = array_chunk($query, 50); foreach ($query_chunks as $query_chunk) { $request = ting_get_request_factory()->getSearchRequest(); @@ -235,7 +241,7 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar 'facet.acSource', ); $request->setFacets((isset($options['facets'])) ? $options['facets'] : $default_facets); - $request->setNumFacets((isset($options['numFacets'])) ? $options['numFacets'] : ((sizeof($request->getFacets()) == 0) ? 0 : 10)); + $request->setNumFacets((isset($options['numFacets'])) ? $options['numFacets'] : ((count($request->getFacets()) == 0) ? 0 : 10)); if (isset($options['sort']) && $options['sort']) { $request->setSort($options['sort']); } @@ -353,7 +359,7 @@ function ting_execute_cache($request) { // Cache any sub-objects (mostly true for collections). if (isset($reply->objects)) { foreach ($reply->objects as $object) { - ting_cache_set($object->id, $object, $type); + ting_cache_set($object->id, $object, TING_CACHE_TING_OBJECT); // Cache any relations. if (isset($object->relations)) { foreach ($object->relations as $relation) { @@ -389,7 +395,7 @@ function ting_execute_cache($request) { // Cache any relations. if (isset($reply->relations)) { foreach ($reply->relations as $relation) { - ting_cache_set($relation->id, $relation); + ting_cache_set($relation->id, $relation, TING_CACHE_TING_OBJECT); } } From a7e8c8f5b15ecac0b46c732277bbc846b7343c57 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 19 Nov 2013 09:24:45 +0100 Subject: [PATCH 071/167] Corrected get object logic and added comment --- ting.client.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index d30bb3a..4bac0a7 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -141,12 +141,14 @@ function ting_get_objects($ids) { $query = array(); foreach ($objects as $id => $object) { if ($object === FALSE) { + // So if the agency match lets search theme as that's faster then fetching + // them one by one. if (preg_match('/^' . $agency . '/', $id)) { - // Get objects. - $objects[$id] = ting_get_object($id); + $query[] = 'rec.id=' . $id; } else { - $query[] = 'rec.id=' . $id; + // Get objects as it was not local. + $objects[$id] = ting_get_object($id); } } } From a80c1bbd16aa77314f9055e3d481f32254e96963 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 26 Nov 2013 12:38:44 +0100 Subject: [PATCH 072/167] Updated makefile to point to tag 7.x-1.0-beta3 --- ting.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.make b/ting.make index d066e05..2e38b04 100644 --- a/ting.make +++ b/ting.make @@ -14,7 +14,7 @@ projects[virtual_field][version] = "1.1" libraries[ting-client][download][type] = "git" libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" -libraries[ting-client][download][branch] = "development" +libraries[ting-client][download][tag] = "7.x-1.0-beta3" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules From 8a86de933774cf2e82e593f2b8aee77c0b85c3c3 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 26 Nov 2013 12:46:03 +0100 Subject: [PATCH 073/167] Updated makefile to point to tag 7.x-1.0-beta3 --- ting.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.make b/ting.make index 2e38b04..ee1b3ce 100644 --- a/ting.make +++ b/ting.make @@ -22,4 +22,4 @@ libraries[ting-client][destination] = "modules/ting/lib" 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" From 929bc5abda680577f53fb8fa795e73c2be606d96 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 27 Nov 2013 17:24:09 +0100 Subject: [PATCH 074/167] Updated coding style in tpl --- ting_object.tpl.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ting_object.tpl.php b/ting_object.tpl.php index 1af702e..a063d58 100644 --- a/ting_object.tpl.php +++ b/ting_object.tpl.php @@ -1,8 +1,6 @@ Date: Thu, 28 Nov 2013 17:34:25 +0100 Subject: [PATCH 075/167] Update collection type title to match object type title --- ting.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.module b/ting.module index 9425b85..fea0a8a 100644 --- a/ting.module +++ b/ting.module @@ -301,7 +301,7 @@ function ting_block_view($delta = '') { case 'ting_collection_types': if ($collection = menu_get_object('ting_collection', 2)) { - $block->subject = t('Types'); + $block->subject = t('Other materialtypes'); $items = array(); foreach ($collection->types as $type) { $items[] = l($type . ' (' . $collection->types_count[$type] . ')', '#' . $type, array('external' => TRUE)); From c3d05912108db102e4326af09444d83200ea0e91 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 29 Nov 2013 15:35:29 +0100 Subject: [PATCH 076/167] Added search overlay to links in object/collection views --- js/ting.js | 27 +++++++++++++++++++++++ plugins/content_types/ting_collection.inc | 22 +++++++++++++----- plugins/content_types/ting_object.inc | 22 ++++++++++++++---- ting.module | 5 ++++- 4 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 js/ting.js diff --git a/js/ting.js b/js/ting.js new file mode 100644 index 0000000..d29a14b --- /dev/null +++ b/js/ting.js @@ -0,0 +1,27 @@ +/** + * @file + * Simple script to help display search overlay when links are clicked. + */ +(function($) { + "use strict"; + + $(document).ready(function() { + $('a.js-search-overlay').live('click', function() { + var link = $(this); + if (link.attr('href').charAt(0) !== '#') { + // Only show overlay for non-local links. + Drupal.TingSearchOverlay(); + } + }); + + // Ensure overlay on collection view links. + $('.ting-collection-wrapper a[href*="/ting/"]').live('click', function() { + Drupal.TingSearchOverlay(); + }); + + // Ensure overlay on object view links. + $('.ting-object-wrapper a[href*="/ting/"]').live('click', function() { + Drupal.TingSearchOverlay(); + }); + }); +}(jQuery)); diff --git a/plugins/content_types/ting_collection.inc b/plugins/content_types/ting_collection.inc index 3ec8abb..3be45cb 100644 --- a/plugins/content_types/ting_collection.inc +++ b/plugins/content_types/ting_collection.inc @@ -1,4 +1,8 @@ t('Ting collection'), @@ -10,18 +14,20 @@ $plugin = array( 'category' => t('Ting'), ); -function ting_ting_collection_content_type_edit_form($form, &$form_state) { - return $form; -} - +/** + * Implements hook_ID_content_type_render(). + */ function ting_collection_content_type_render($subtype, $conf, $args, $context) { $block = new stdClass(); $object = isset($context->data) ? ($context->data) : NULL; if ($object instanceOf TingCollection) { - if (sizeof($object->entities) < 2) { + if (count($object->entities) < 2) { drupal_goto('ting/object/' . $object->id); } + // Add search overlay trigger. + drupal_add_js(drupal_get_path('module', 'ting') . '/js/ting.js'); + $block->title = check_plain($object->title); $block->content = ting_collection_view($object); } @@ -29,3 +35,9 @@ function ting_collection_content_type_render($subtype, $conf, $args, $context) { return $block; } +/** + * Implements hook_ID_content_type_edit_form(). + */ +function ting_ting_collection_content_type_edit_form($form, &$form_state) { + return $form; +} diff --git a/plugins/content_types/ting_object.inc b/plugins/content_types/ting_object.inc index 5e4945f..2d4b0d2 100644 --- a/plugins/content_types/ting_object.inc +++ b/plugins/content_types/ting_object.inc @@ -1,4 +1,8 @@ t('Ting object'), @@ -10,17 +14,27 @@ $plugin = array( 'category' => t('Ting'), ); -function ting_ting_object_content_type_edit_form($form, &$form_state) { - return $form; -} - +/** + * Implements hook_ID_content_type_render(). + */ function ting_object_content_type_render($subtype, $conf, $args, $context) { $block = new stdClass(); $object = isset($context->data) ? ($context->data) : NULL; if ($object instanceOf TingEntity) { $block->title = check_plain($object->title); $block->content = ting_object_view($object); + + // Add search overlay trigger. + drupal_add_js(drupal_get_path('module', 'ting') . '/js/ting.js'); } return $block; } + +/** + * Implements hook_ID_content_type_edit_form(). + */ +function ting_ting_object_content_type_edit_form($form, &$form_state) { + return $form; +} + diff --git a/ting.module b/ting.module index fea0a8a..f7382f9 100644 --- a/ting.module +++ b/ting.module @@ -296,7 +296,6 @@ function ting_block_view($delta = '') { ); } } - break; case 'ting_collection_types': @@ -320,6 +319,7 @@ function ting_block_view($delta = '') { foreach ($collection->types as $type) { $uri = entity_uri('ting_collection', $collection); $uri['options']['fragment'] = _ting_anchor_name($type); + $uri['options']['attributes'] = array('class' => array('js-search-overlay')); $items[] = l($type . ' (' . $collection->types_count[$type] . ')', $uri['path'], $uri['options']); } @@ -330,6 +330,9 @@ function ting_block_view($delta = '') { '#theme' => 'item_list', '#items' => $items, ); + + // Add search overlay trigger. + drupal_add_js(drupal_get_path('module', 'ting') . '/js/ting.js'); } } break; From 26b7f3ca64fc14379846aab375cc5ac0d2b7a802 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 2 Dec 2013 13:24:50 +0100 Subject: [PATCH 077/167] Added the first update function to convert "ting_object" table into the new PID format --- ting.install | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ting.install b/ting.install index 625fe83..165dd7d 100644 --- a/ting.install +++ b/ting.install @@ -224,3 +224,21 @@ function ting_update_7001() { $ret[] = db_create_table('cache_ting', $schema['cache_ting']); return $ret; } + +/** + * Update ding_entity_id's to match new data well format (basis and katalog). + */ +function ting_update_7002() { + // Convert "katalog" PID's first. + $agency = variable_get('ting_agency', ''); + db_query("UPDATE ting_object + SET ding_entity_id = CONCAT(SUBSTRING_INDEX(ding_entity_id, ':', 1), '-katalog:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) + WHERE ding_entity_id LIKE '" . $agency . ":9%'") + ->execute(); + + // Convert basic PID's + db_query("UPDATE ting_object + SET ding_entity_id = CONCAT(SUBSTRING_INDEX(ding_entity_id, ':', 1), '-basis:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) + WHERE ding_entity_id LIKE '" . $agency . ":%'") + ->execute(); +} From 19b2237ba75208e6dbdb1f812ef6e822452d16cc Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 2 Dec 2013 14:34:37 +0100 Subject: [PATCH 078/167] Fixed cache issue with object without relations that is accessed directly --- ting.client.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ting.client.inc b/ting.client.inc index 4bac0a7..ad729e6 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -401,6 +401,11 @@ function ting_execute_cache($request) { } } + // Cache the object self + if ($reply instanceof TingClientObject) { + ting_cache_set($reply->id, $reply); + } + // Store the reply for the request itself in the cache. if (is_null($reply)) { // Handle empty data well replies. From bae78ceb072857bd571bf75227b8bb35cb1d2049 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 2 Dec 2013 14:33:31 +0100 Subject: [PATCH 079/167] Fixed cache issue with object without relations that is accessed directly and add data well 2 to 3 redirects --- ting.client.inc | 5 +++++ ting.module | 24 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index 4bac0a7..ad729e6 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -401,6 +401,11 @@ function ting_execute_cache($request) { } } + // Cache the object self + if ($reply instanceof TingClientObject) { + ting_cache_set($reply->id, $reply); + } + // Store the reply for the request itself in the cache. if (is_null($reply)) { // Handle empty data well replies. diff --git a/ting.module b/ting.module index f7382f9..b1a9e50 100644 --- a/ting.module +++ b/ting.module @@ -616,9 +616,19 @@ function ting_ting_object_load($objects) { /** * Load a ting object. * - * Don't use this, use ding_entity_load(). + * Don't use this, use ding_entity_load(). Default menu callback load of ting + * object. + * + * Handles redirect from data well version 2 to version 3. */ function ting_object_load($id) { + $agency = variable_get('ting_agency', FALSE); + if ($agency && preg_match('/^(\d{6}):(\w+)$/', $id, $matches)) { + // Matched to data well version 2, to redirect to version 3. + $id = ding_provider_build_entity_id($matches[2], $matches[1]); + drupal_goto('ting/object/' . $id, array(), 301); + } + return ding_entity_load($id, 'ting_object'); } @@ -634,9 +644,19 @@ function ting_object_load_multiple($ids) { /** * Load a ting collection. * - * Don't use this, use ding_collection_load(). + * Don't use this, use ding_collection_load(). Default menu callback load of + * ting collections. + * + * Handles redirect from data well version 2 to version 3. */ function ting_collection_load($id) { + $agency = variable_get('ting_agency', FALSE); + if ($agency && preg_match('/^(\d{6}):(\w+)$/', $id, $matches)) { + // Matched to data well version 2, to redirect to version 3. + $id = ding_provider_build_entity_id($matches[2], $matches[1]); + drupal_goto('ting/collection/' . $id, array(), 301); + } + return ding_entity_load($id, 'ting_collection'); } From f3c2c9c7e512554547ad75c849fc84d91350f9de Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 2 Dec 2013 15:26:42 +0100 Subject: [PATCH 080/167] Added missing dot to comment --- ting.client.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.client.inc b/ting.client.inc index ad729e6..0c33b08 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -401,7 +401,7 @@ function ting_execute_cache($request) { } } - // Cache the object self + // Cache the object self. if ($reply instanceof TingClientObject) { ting_cache_set($reply->id, $reply); } From 5f3bfc1f4d6858ebb14c7ca44d87480ead786c39 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 2 Dec 2013 17:28:31 +0100 Subject: [PATCH 081/167] Added update function to convert most of the v2 data well id's to v3 --- ting.install | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/ting.install b/ting.install index 165dd7d..5d0ff73 100644 --- a/ting.install +++ b/ting.install @@ -242,3 +242,46 @@ function ting_update_7002() { WHERE ding_entity_id LIKE '" . $agency . ":%'") ->execute(); } + +/** + * Update all other ding_entity_id's where possible to data well version 3. + */ +function ting_update_7003() { + $translation = array( + '150021' => '150021-bibliotek', + '150027' => '150021-fjern', + '150030' => '150030-spilmedier', + '870973' => '870973-anmeld', + '150039' => '150015-forlag', + '870976' => '870976-anmeld', + '150048' => '150048-basis', + '150028' => '150028-basis', + '150015' => '150015-basis', + '150033' => '150033-dandyr', + '150040' => '150040-verdyr', + '150018' => '150018-danhist', + '150032' => '150018-samfund', + '150034' => '150018-religion', + '150054' => '150018-biologi', + '150055' => '150018-fysikkemi', + '150056' => '150056-geografi', + '150008' => '150008-academic', + '150043' => '150043-atlas', + '150023' => '150023-sicref', + '150025' => '150008-public', + '150052' => '870970-basis', + '159002' => '159002-lokalbibl', + '150012' => '150012-leksikon', + ); + + foreach ($translation as $id => $new_id) { + db_query("UPDATE ting_object + SET ding_entity_id = CONCAT('" . $new_id . ":', SUBSTRING_INDEX(ding_entity_id, ':', -1)) + WHERE ding_entity_id LIKE '" . $id . ":%'") + ->execute(); + } +} + +/** + * Remove the last data well version 2 that could not be translated. + */ From e3287a31aaadef12e6ef73416086e7916df736db Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 5 Dec 2013 10:24:23 +0100 Subject: [PATCH 082/167] Added one more date well 3 update function --- ting.install | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/ting.install b/ting.install index 5d0ff73..e5e9c89 100644 --- a/ting.install +++ b/ting.install @@ -226,7 +226,7 @@ function ting_update_7001() { } /** - * Update ding_entity_id's to match new data well format (basis and katalog). + * Update own agency ding_entity_id's to match new data well format (basis and katalog). */ function ting_update_7002() { // Convert "katalog" PID's first. @@ -244,9 +244,25 @@ function ting_update_7002() { } /** - * Update all other ding_entity_id's where possible to data well version 3. + * Update other agencies ding_entity_id's to match new data well format (basis and katalog). */ function ting_update_7003() { + db_query("UPDATE ting_object + SET ding_entity_id = CONCAT(SUBSTRING_INDEX(ding_entity_id, ':', 1), '-katalog:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) + WHERE ding_entity_id LIKE '7%:9%'") + ->execute(); + + // Convert basic PID's + db_query("UPDATE ting_object + SET ding_entity_id = CONCAT(SUBSTRING_INDEX(ding_entity_id, ':', 1), '-basis:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) + WHERE ding_entity_id LIKE '7%:%'") + ->execute(); +} + +/** + * Update all other ding_entity_id's where possible to data well version 3. + */ +function ting_update_7004() { $translation = array( '150021' => '150021-bibliotek', '150027' => '150021-fjern', @@ -281,7 +297,3 @@ function ting_update_7003() { ->execute(); } } - -/** - * Remove the last data well version 2 that could not be translated. - */ From 35748cc9d071df6f6254145c55ef21c91113b45b Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 5 Dec 2013 11:01:11 +0100 Subject: [PATCH 083/167] Moved series setting in to ting_search --- ting.admin.inc | 31 +------------------------------ ting.module | 9 --------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index bb1b9d1..6764900 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -356,35 +356,6 @@ function _ting_boost_field_sort($a, $b) { return ($a['weight'] > $b['weight']) ? -1 : 1; } -function ting_admin_register_settings() { - // Should use phrase.title instead of dc.title but at the moment open search - // does not support the use of phrase.title. - $form['ting_admin_register_serie_title'] = array( - '#type' => 'textfield', - '#title' => t('Serie title'), - '#description' => t('Specify the searchstring to be used for searching against serie titles. Use @serietitle as a placeholder for the serietitle'), - '#default_value' => variable_get('ting_admin_register_serie_title', 'bib.titleSeries="@serietitle" OR dc.description="@serietitle"') - ); - - $form['#submit'][] = 'ting_search_extendform_admin_settings_submit'; - return system_settings_form($form); -} - -function ting_admin_register_settings_validate($form, &$form_state) { - $s = ''; - if (isset($form_state['values']['ting_admin_register_serie_title'])) { - $s = $form_state['values']['ting_admin_register_serie_title']; - } - - if ($s == '') { - form_set_error('ting_admin_register_serie_title', t('Please specify a register for serie titles.')); - } -} - -function ting_search_extendform_admin_settings_submit($form, $form_state) { - variable_set('ting_admin_register_serie_title', $form_state['values']['ting_admin_register_serie_title']); -} - /** * Form builder; Configure online resource types and their URL labels. * @@ -399,7 +370,7 @@ function ting_admin_online_types_settings($form_state) { $form['update'] = array( '#type' => 'fieldset', '#title' => t('Update from datawell'), - '#description' => t('Update the list of known types by asking the datawell for all types.') + '#description' => t('Update the list of known types by asking the datawell for all types.'), ); $form['update']['update'] = array( diff --git a/ting.module b/ting.module index b1a9e50..0e61dc0 100644 --- a/ting.module +++ b/ting.module @@ -115,15 +115,6 @@ function ting_menu() { 'file' => 'ting.admin.inc', ); - $items['admin/config/ting/registers'] = array( - 'title' => 'Open search register settings', - 'description' => 'Configure registers to use for specific open search searches.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('ting_admin_register_settings'), - 'access arguments' => array('administer ting settings'), - 'file' => 'ting.admin.inc', - ); - $items['admin/config/ting/online_types'] = array( 'title' => 'Online types and URL labels', 'description' => 'Define online resource types and their corresponding URL labels.', From 9ab473f4ddb663aa1a717ff7a24da40509777ef8 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 5 Dec 2013 11:06:58 +0100 Subject: [PATCH 084/167] Updated default ting series term to match data well 3 --- ting.field.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.field.inc b/ting.field.inc index 1f1680c..03a9345 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -377,7 +377,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la // the series title register and the description field because many // series only have data in the description field. This will probably // change with new versions of the data well. - $search_term = str_replace('@serietitle', drupal_strtolower($entity->serieTitle), variable_get('ting_admin_register_serie_title', 'bib.titleSeries="@serietitle" OR dc.description="@serietitle"')); + $search_term = str_replace('@serietitle', drupal_strtolower($entity->serieTitle), variable_get('ting_search_register_serie_title', 'dkcclphrase.lse="@serietitle" OR dkcclphrase.lso="@serietitle"')); $element[$delta] = array( '#markup' => l($entity->serieTitle, 'search/ting/' . $search_term, array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), ); From 8713abec614b889b2012bb8acde763dbfc41ba42 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 5 Dec 2013 11:14:00 +0100 Subject: [PATCH 085/167] Changed creator search index in links to phrase.creator --- ting.field.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.field.inc b/ting.field.inc index 03a9345..f2bf78b 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -398,7 +398,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la case 'ting_author_default': $creators = array(); foreach ($entity->creators as $i => $creator) { - $creators[] = l($creator, 'search/ting/dc.creator=' . $creator, array('attributes' => array('class' => array('author')))); + $creators[] = l($creator, 'search/ting/phrase.creator=' . $creator, array('attributes' => array('class' => array('author')))); } $markup_string = ''; if (count($creators)) { From 7eba758a2eafce87a46cc0e7bd9dd9fd953aeb4e Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 5 Dec 2013 11:42:42 +0100 Subject: [PATCH 086/167] Changed the subject search index to dkcclterm.em to match data well 3 --- ting.field.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.field.inc b/ting.field.inc index f2bf78b..886158c 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -427,7 +427,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la if (count($entity->subjects) == TRUE) { $subjects = array(); foreach ($entity->subjects as $subject) { - $subjects[] = l($subject, 'search/ting/dc.subject=' . $subject, array('attributes' => array('class' => array('subject')))); + $subjects[] = l($subject, 'search/ting/dkcclterm.em=' . $subject, array('attributes' => array('class' => array('subject')))); } $element[$delta] = array( '#markup' => implode(' ', $subjects), From e66a3b2d142b941cb58211aa6a74039afc655b49 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 5 Dec 2013 12:29:04 +0100 Subject: [PATCH 087/167] Updated default reservable sources to "bibliotekskatalog" --- ting.install | 7 +++++++ ting.module | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ting.install b/ting.install index e5e9c89..62b39ac 100644 --- a/ting.install +++ b/ting.install @@ -297,3 +297,10 @@ function ting_update_7004() { ->execute(); } } + +/** + * Update default ac.source from 'bibliotekets materialer' to 'bibliotekskatalog'. + */ +function ting_update_7005() { + variable_set('ting_reservable_sources', _ting_default_reservable_sources()); +} diff --git a/ting.module b/ting.module index 0e61dc0..2b7a3bc 100644 --- a/ting.module +++ b/ting.module @@ -892,7 +892,7 @@ function _ting_default_online_types() { */ function _ting_default_reservable_sources() { return array( - 'bibliotekets materialer', + 'bibliotekskatalog', ); } @@ -986,6 +986,7 @@ function _ting_fetch_well_sources() { * * @param string $type * Name of the anchor. + * * @return string * HTML safe name. */ From b6126439ea23bfa0e70da34913526806ca084813 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 5 Dec 2013 16:07:33 +0100 Subject: [PATCH 088/167] Fixed errors in update functions to new PIDs --- ting.install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.install b/ting.install index 62b39ac..70c6902 100644 --- a/ting.install +++ b/ting.install @@ -238,7 +238,7 @@ function ting_update_7002() { // Convert basic PID's db_query("UPDATE ting_object - SET ding_entity_id = CONCAT(SUBSTRING_INDEX(ding_entity_id, ':', 1), '-basis:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) + SET ding_entity_id = CONCAT('870970-basis:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) WHERE ding_entity_id LIKE '" . $agency . ":%'") ->execute(); } @@ -254,7 +254,7 @@ function ting_update_7003() { // Convert basic PID's db_query("UPDATE ting_object - SET ding_entity_id = CONCAT(SUBSTRING_INDEX(ding_entity_id, ':', 1), '-basis:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) + SET ding_entity_id = CONCAT('780970-basis:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) WHERE ding_entity_id LIKE '7%:%'") ->execute(); } From 81d967835c93917ec14d9144a2126a334559dced Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 5 Dec 2013 16:33:20 +0100 Subject: [PATCH 089/167] Fixed mapping to new data well 2 PIDs in update functions --- ting.install | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ting.install b/ting.install index 70c6902..e5d1f43 100644 --- a/ting.install +++ b/ting.install @@ -266,13 +266,13 @@ function ting_update_7004() { $translation = array( '150021' => '150021-bibliotek', '150027' => '150021-fjern', - '150030' => '150030-spilmedier', + '150030' => '870970-spilmedier', '870973' => '870973-anmeld', '150039' => '150015-forlag', '870976' => '870976-anmeld', - '150048' => '150048-basis', - '150028' => '150028-basis', - '150015' => '150015-basis', + '150048' => '870970-basis', + '150028' => '870970-basis', + '150015' => '870970-basis', '150033' => '150033-dandyr', '150040' => '150040-verdyr', '150018' => '150018-danhist', From df0a0906d1299edf07d649a8a6c43722dd6c4719 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 5 Dec 2013 16:58:06 +0100 Subject: [PATCH 090/167] Fixed typo in basis PID id --- ting.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.install b/ting.install index e5d1f43..206ba3c 100644 --- a/ting.install +++ b/ting.install @@ -254,7 +254,7 @@ function ting_update_7003() { // Convert basic PID's db_query("UPDATE ting_object - SET ding_entity_id = CONCAT('780970-basis:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) + SET ding_entity_id = CONCAT('870970-basis:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) WHERE ding_entity_id LIKE '7%:%'") ->execute(); } From 1ba1603f10905427c36830c73efb778f72385a4d Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 6 Dec 2013 11:42:39 +0100 Subject: [PATCH 091/167] Ensured that ting cache entries are not null --- ting.client.inc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index 0c33b08..1462761 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -72,6 +72,9 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALS // If this was a collection request store the collection reply to ensure // that there is no empty cache entry. if ($collection) { + if (is_null($object)) { + $object = TING_CACHE_EMPTY_ENTRY; + } ting_cache_set($object_id, $object, $type); } } @@ -143,7 +146,7 @@ function ting_get_objects($ids) { if ($object === FALSE) { // So if the agency match lets search theme as that's faster then fetching // them one by one. - if (preg_match('/^' . $agency . '/', $id)) { + if (preg_match('/^(890790-basis|' . $agency . '-katalog|' . $agency . ')/', $id)) { $query[] = 'rec.id=' . $id; } else { @@ -403,11 +406,13 @@ function ting_execute_cache($request) { // Cache the object self. if ($reply instanceof TingClientObject) { - ting_cache_set($reply->id, $reply); + if (!empty($reply->record)) { + ting_cache_set($reply->id, $reply); + } } // Store the reply for the request itself in the cache. - if (is_null($reply)) { + if (is_null($reply) || empty($reply->record)) { // Handle empty data well replies. $reply = TING_CACHE_EMPTY_ENTRY; } From 999fd7dec708aedd1a12972fdae6df1acedc66bc Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 6 Dec 2013 12:36:51 +0100 Subject: [PATCH 092/167] Fixed (once more) the PID updates function --- ting.install | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ting.install b/ting.install index 206ba3c..ce6ce94 100644 --- a/ting.install +++ b/ting.install @@ -232,7 +232,7 @@ function ting_update_7002() { // Convert "katalog" PID's first. $agency = variable_get('ting_agency', ''); db_query("UPDATE ting_object - SET ding_entity_id = CONCAT(SUBSTRING_INDEX(ding_entity_id, ':', 1), '-katalog:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) + SET ding_entity_id = CONCAT('" . $agency . "-katalog:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) WHERE ding_entity_id LIKE '" . $agency . ":9%'") ->execute(); @@ -249,13 +249,17 @@ function ting_update_7002() { function ting_update_7003() { db_query("UPDATE ting_object SET ding_entity_id = CONCAT(SUBSTRING_INDEX(ding_entity_id, ':', 1), '-katalog:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) - WHERE ding_entity_id LIKE '7%:9%'") + WHERE ding_entity_id LIKE '7%:9%' + AND ding_entity_id NOT LIKE '%-basis:%' + AND ding_entity_id NOT LIKE '%-katalog:%'") ->execute(); // Convert basic PID's db_query("UPDATE ting_object SET ding_entity_id = CONCAT('870970-basis:', SUBSTRING_INDEX(ding_entity_id, ':', -1)) - WHERE ding_entity_id LIKE '7%:%'") + WHERE ding_entity_id LIKE '7%:%' + AND ding_entity_id NOT LIKE '%-basis:%' + AND ding_entity_id NOT LIKE '%-katalog:%'") ->execute(); } From 35c687e66e322755e6deb808e39e5637f8a922c9 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 6 Dec 2013 13:49:57 +0100 Subject: [PATCH 093/167] Fixed empty replay records from the data well --- ting.client.inc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ting.client.inc b/ting.client.inc index 1462761..7462a2d 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -409,10 +409,13 @@ function ting_execute_cache($request) { if (!empty($reply->record)) { ting_cache_set($reply->id, $reply); } + else { + $reply = TING_CACHE_EMPTY_ENTRY; + } } // Store the reply for the request itself in the cache. - if (is_null($reply) || empty($reply->record)) { + if (is_null($reply)) { // Handle empty data well replies. $reply = TING_CACHE_EMPTY_ENTRY; } From 3e6b83e1f6bef9d90eadb9a5d963711ca49a0697 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 10 Dec 2013 18:13:12 +0100 Subject: [PATCH 094/167] Ensured links with target blank do not display search overlay --- js/ting.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/ting.js b/js/ting.js index d29a14b..964e0a5 100644 --- a/js/ting.js +++ b/js/ting.js @@ -16,12 +16,16 @@ // Ensure overlay on collection view links. $('.ting-collection-wrapper a[href*="/ting/"]').live('click', function() { - Drupal.TingSearchOverlay(); + if ($(this).not('[target="_blank"]').length) { + Drupal.TingSearchOverlay(); + } }); // Ensure overlay on object view links. $('.ting-object-wrapper a[href*="/ting/"]').live('click', function() { - Drupal.TingSearchOverlay(); + if ($(this).not('[target="_blank"]').length) { + Drupal.TingSearchOverlay(); + } }); }); }(jQuery)); From 2414ba338b6d82a57d71b06371e206059e8170d9 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 12 Dec 2013 13:13:24 +0100 Subject: [PATCH 095/167] Updated makefile to point to tag 7.x-1.0-beta4 --- ting.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.make b/ting.make index ee1b3ce..e4aad8e 100644 --- a/ting.make +++ b/ting.make @@ -14,7 +14,7 @@ projects[virtual_field][version] = "1.1" libraries[ting-client][download][type] = "git" libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" -libraries[ting-client][download][tag] = "7.x-1.0-beta3" +libraries[ting-client][download][tag] = "7.x-1.0-beta4" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules @@ -22,4 +22,4 @@ libraries[ting-client][destination] = "modules/ting/lib" 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" From 32cb1b1bd4190cd2f4ad11f7d6ba724ed7da290f Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 16 Dec 2013 11:45:55 +0100 Subject: [PATCH 096/167] Updated admin to show opensearch 3.0 in help text --- ting.admin.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.admin.inc b/ting.admin.inc index 6764900..48221a6 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -30,7 +30,7 @@ function ting_admin_ting_settings($form_state) { $form['ting']['ting_search_url'] = array( '#type' => 'textfield', '#title' => t('Search service URL'), - '#description' => t('URL to the Ting search webservice, e.g. http://opensearch.addi.dk/2.1/'), + '#description' => t('URL to the Ting search webservice, e.g. http://opensearch.addi.dk/3.0/'), '#required' => TRUE, '#default_value' => variable_get('ting_search_url', ''), ); From f2f67c47e85c15c87d8aa10ff57a2ff9d7d4d44d Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 16 Dec 2013 17:33:03 +0100 Subject: [PATCH 097/167] Fixed fetch date well type and sources --- ting.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.module b/ting.module index 2b7a3bc..4cb8b85 100644 --- a/ting.module +++ b/ting.module @@ -942,7 +942,7 @@ function _ting_fetch_well_types() { 'sort' => 'random', ); module_load_include('client.inc', 'ting'); - $result = ting_do_search("*=*", 0, 0, $options); + $result = ting_do_search("*", 0, 0, $options); $types = array(); foreach ($result->facets['facet.type']->terms as $term => $count) { @@ -968,7 +968,7 @@ function _ting_fetch_well_sources() { 'sort' => 'random', ); module_load_include('client.inc', 'ting'); - $result = ting_do_search("*=*", 0, 0, $options); + $result = ting_do_search("*", 0, 0, $options); $sources = array(); foreach ($result->facets['facet.acSource']->terms as $term => $count) { From 551900121d43c9e92c86a9b358b650fb5d15dcde Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 18 Dec 2013 05:03:27 +0100 Subject: [PATCH 098/167] Updated makefile to point to tag 7.x-1.0-beta5 --- ting.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.make b/ting.make index e4aad8e..6edf449 100644 --- a/ting.make +++ b/ting.make @@ -14,7 +14,7 @@ projects[virtual_field][version] = "1.1" libraries[ting-client][download][type] = "git" libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" -libraries[ting-client][download][tag] = "7.x-1.0-beta4" +libraries[ting-client][download][tag] = "7.x-1.0-beta5" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules @@ -22,4 +22,4 @@ libraries[ting-client][destination] = "modules/ting/lib" 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" From 1ab53fd2a359b15078d72b4245623c6772e9af60 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 19 Dec 2013 17:14:25 +0100 Subject: [PATCH 099/167] Fixed online types admin form --- ting.admin.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index 48221a6..beb5382 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -385,12 +385,12 @@ function ting_admin_online_types_settings($form_state) { '#type' => 'fieldset', '#title' => t('Online types'), '#description' => t('Ting objects defined as found online (not in the library collection).'), - '#tree' => TRUE, + '#tree' => FALSE, '#collapsible' => TRUE, '#collapsed' => TRUE, ); - $form['ting_online']['types'] = array( + $form['ting_online']['ting_online_types'] = array( '#type' => 'checkboxes', '#options' => drupal_map_assoc(array_keys($types)), '#default_value' => variable_get('ting_online_types', _ting_default_online_types()), From dd6c376269cc4ec346c280700438072f5687a70f Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 19 Dec 2013 17:19:32 +0100 Subject: [PATCH 100/167] Added e-node to default online types --- ting.module | 1 + 1 file changed, 1 insertion(+) diff --git a/ting.module b/ting.module index 4cb8b85..9f3516e 100644 --- a/ting.module +++ b/ting.module @@ -882,6 +882,7 @@ function _ting_default_online_types() { 'periodikum (net)', 'pc-spil (net)', 'avis (net)', + 'e-node', ); } From 3d22988f4d46073c9e4dbcd041a107c82935580a Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 20 Dec 2013 10:34:25 +0100 Subject: [PATCH 101/167] Fixed online url by using getOnlineUrl() method --- ting.module | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ting.module b/ting.module index 9f3516e..05a3ff8 100644 --- a/ting.module +++ b/ting.module @@ -520,10 +520,12 @@ function ting_ding_entity_buttons($type, $entity) { $type = drupal_strtolower($entity->type); $label = isset($settings[$type]) && $settings[$type] ? $settings[$type] : $settings['_default']; return array( - // The link can't use l() as it will encode the url from ting_proxy. + // The link can't use l() as it will encode the url from ting_proxy. Use + // get online as the dc:identifier in $entity->online is not always the + // correct url. array( '#type' => 'markup', - '#markup' => '' . $label . '', + '#markup' => '' . $label . '', ), ); } From bf9632e463a9cff799fc72ebf65a517efdbe4bc8 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 20 Dec 2013 15:39:41 +0100 Subject: [PATCH 102/167] Updated makefile to point to tag 7.x-1.0-rc1 --- ting.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.make b/ting.make index 6edf449..2b8dce9 100644 --- a/ting.make +++ b/ting.make @@ -14,7 +14,7 @@ projects[virtual_field][version] = "1.1" libraries[ting-client][download][type] = "git" libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" -libraries[ting-client][download][tag] = "7.x-1.0-beta5" +libraries[ting-client][download][tag] = "7.x-1.0-rc1" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules @@ -22,4 +22,4 @@ libraries[ting-client][destination] = "modules/ting/lib" 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" From 99702a22de21ced3fc967742dce5be320bf3ba26 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 8 Jan 2014 09:56:13 +0100 Subject: [PATCH 103/167] Set default ting cache expire to larger than zero to ensure that search work --- ting.admin.inc | 4 +--- ting.drush.inc | 1 - ting.install | 10 ++++++++++ ting.module | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index beb5382..6efd69b 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -78,10 +78,8 @@ function ting_admin_ting_settings($form_state) { 259200, 604800, ); - $options = array( - 0 => t('No caching'), - ); + $options = array(); foreach ($intervals as $interval) { $options[$interval] = format_interval($interval, 2); } diff --git a/ting.drush.inc b/ting.drush.inc index e3b4796..9d644a9 100644 --- a/ting.drush.inc +++ b/ting.drush.inc @@ -24,7 +24,6 @@ function ting_drush_cache_clear(&$types) { // Ting reply cache. $types['ting_reply'] = 'ting_reply_cache_clear'; - } /** diff --git a/ting.install b/ting.install index ce6ce94..ea0f8a2 100644 --- a/ting.install +++ b/ting.install @@ -308,3 +308,13 @@ function ting_update_7004() { function ting_update_7005() { variable_set('ting_reservable_sources', _ting_default_reservable_sources()); } + +/** + * Ensure default cache expire for the data-well is set correctly. + */ +function ting_update_7006() { + $ttl = variable_get('ting_cache_lifetime', TING_DEFAULT_CACHE_LIFETIME); + if ($ttl <= 0) { + variable_set('ting_cache_lifetime', 900); + } +} diff --git a/ting.module b/ting.module index 05a3ff8..8e8405a 100644 --- a/ting.module +++ b/ting.module @@ -6,7 +6,7 @@ // Define the different types of data that we cache in ting_set_cache and the // default TTL. -define('TING_DEFAULT_CACHE_LIFETIME', 0); +define('TING_DEFAULT_CACHE_LIFETIME', 900); define('TING_CACHE_TING_OBJECT', 'ting-object'); define('TING_CACHE_TING_OBJECT_FULLTEXT', 'ting-object-fulltext'); define('TING_CACHE_COLLECTION', 'ting-collection'); From ef56553bb8787e5ac2d5d908ab2c6e4d1c7e10fb Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 8 Jan 2014 21:58:04 +0100 Subject: [PATCH 104/167] Updated makefile to point to tag 7.x-1.0-rc2 --- ting.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.make b/ting.make index 2b8dce9..df4a3d2 100644 --- a/ting.make +++ b/ting.make @@ -14,7 +14,7 @@ projects[virtual_field][version] = "1.1" libraries[ting-client][download][type] = "git" libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" -libraries[ting-client][download][tag] = "7.x-1.0-rc1" +libraries[ting-client][download][tag] = "7.x-1.0-rc2" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules @@ -22,4 +22,4 @@ libraries[ting-client][destination] = "modules/ting/lib" 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" From af9f14316c78d433fcb0d3ad942efdcd5d295f26 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 9 Jan 2014 11:08:26 +0100 Subject: [PATCH 105/167] Updated openscan setting field description with new version --- ting.admin.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.admin.inc b/ting.admin.inc index 6efd69b..313f639 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -38,7 +38,7 @@ function ting_admin_ting_settings($form_state) { $form['ting']['ting_scan_url'] = array( '#type' => 'textfield', '#title' => t('Scan service URL'), - '#description' => t('URL to the Ting scan webservice, e.g. http://openscan.addi.dk/1.7/'), + '#description' => t('URL to the Ting scan webservice, e.g. http://openscan.addi.dk/2.0/'), '#required' => TRUE, '#default_value' => variable_get('ting_scan_url', ''), ); From 40a9c1a636fc7cdb0ac436d51e5321fbec834711 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 20 Jan 2014 12:25:39 +0100 Subject: [PATCH 106/167] Updated makefile to point to tag 7.x-1.0-rc3 --- ting.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.make b/ting.make index df4a3d2..17d40d7 100644 --- a/ting.make +++ b/ting.make @@ -14,7 +14,7 @@ projects[virtual_field][version] = "1.1" libraries[ting-client][download][type] = "git" libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" -libraries[ting-client][download][tag] = "7.x-1.0-rc2" +libraries[ting-client][download][tag] = "7.x-1.0-rc3" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules @@ -22,4 +22,4 @@ libraries[ting-client][destination] = "modules/ting/lib" 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" From b0a04a2e48474d07feae3d77236d5deddb1515bf Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 3 Feb 2014 16:01:57 +0100 Subject: [PATCH 107/167] Updated makefile to point to ding2 master branches --- ting.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.make b/ting.make index 17d40d7..6cda703 100644 --- a/ting.make +++ b/ting.make @@ -21,5 +21,5 @@ libraries[ting-client][destination] = "modules/ting/lib" 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" From edee769f4ee1a25c9748fcab5fe47c8be5c13a1f Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 28 Feb 2014 10:01:34 +0100 Subject: [PATCH 108/167] Updated ting series search registry --- ting.field.inc | 2 +- ting.install | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ting.field.inc b/ting.field.inc index 886158c..2bfb343 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -377,7 +377,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la // the series title register and the description field because many // series only have data in the description field. This will probably // change with new versions of the data well. - $search_term = str_replace('@serietitle', drupal_strtolower($entity->serieTitle), variable_get('ting_search_register_serie_title', 'dkcclphrase.lse="@serietitle" OR dkcclphrase.lso="@serietitle"')); + $search_term = str_replace('@serietitle', drupal_strtolower($entity->serieTitle), variable_get('ting_search_register_serie_title', 'phrase.titleSeries = "@serietitle"')); $element[$delta] = array( '#markup' => l($entity->serieTitle, 'search/ting/' . $search_term, array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), ); diff --git a/ting.install b/ting.install index ea0f8a2..2bead9b 100644 --- a/ting.install +++ b/ting.install @@ -318,3 +318,13 @@ function ting_update_7006() { variable_set('ting_cache_lifetime', 900); } } + +/** + * Update series title search registry setting. + */ +function ting_update_7007() { + // Only update if set else default value will be used. + if (variable_get('ting_search_register_serie_title', FALSE)) { + variable_set('ting_search_register_serie_title', 'phrase.titleSeries = "@serietitle"'); + } +} From 82227a14e0cd64611bdf743fe5cba5b8efca9f93 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 17 Mar 2014 14:25:25 +0100 Subject: [PATCH 109/167] Added patch to nano soap module to allow extra curl options --- ting.make | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ting.make b/ting.make index aa3a556..963b25c 100644 --- a/ting.make +++ b/ting.make @@ -3,8 +3,10 @@ core = 7.x ; Contrib +// The patch allows extra CURL parameters. projects[nanosoap][subdir] = "contrib" projects[nanosoap][version] = "1.0" +projects[nanosoap][patch][] = "http://drupal.org/files/nanosoap-curloptions-1943732.patch" projects[virtual_field][subdir] = "contrib" projects[virtual_field][version] = "1.1" From 244da4b8bd919d28f7504c048bcd4e4c5c1c2de4 Mon Sep 17 00:00:00 2001 From: Thomas Johansen Date: Tue, 18 Mar 2014 14:40:54 +0100 Subject: [PATCH 110/167] Added quotes for phrase.creator to solve () issue --- ting.field.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.field.inc b/ting.field.inc index 2bfb343..7fc4e4f 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -398,7 +398,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la case 'ting_author_default': $creators = array(); foreach ($entity->creators as $i => $creator) { - $creators[] = l($creator, 'search/ting/phrase.creator=' . $creator, array('attributes' => array('class' => array('author')))); + $creators[] = l($creator, 'search/ting/phrase.creator="' . $creator . '"', array('attributes' => array('class' => array('author')))); } $markup_string = ''; if (count($creators)) { From c7de6fe8c8616237e9ba9a7d550c8b08ced2a62e Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 21 Mar 2014 21:04:13 +0100 Subject: [PATCH 111/167] Tried to fix default reservation types and sources --- ting.admin.inc | 6 +++--- ting.module | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index 313f639..b4bc2c5 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -377,7 +377,7 @@ function ting_admin_online_types_settings($form_state) { '#submit' => array('ting_admin_online_types_settings_update_types'), ); - $types = variable_get('ting_well_types', array()); + $types = variable_get('ting_well_types', _ting_fetch_well_types()); $form['ting_online'] = array( '#type' => 'fieldset', @@ -493,8 +493,8 @@ function ting_admin_reservable_settings($form_state) { '#description' => t('Time before an reservation expires that a message should be shown to the user.'), ); - $types = variable_get('ting_well_types', array()); - $sources = variable_get('ting_well_sources', array()); + $types = variable_get('ting_well_types', _ting_fetch_well_types()); + $sources = variable_get('ting_well_sources', _ting_fetch_well_sources()); $form['ting_reservable'] = array( '#type' => 'fieldset', diff --git a/ting.module b/ting.module index 8e8405a..856ab77 100644 --- a/ting.module +++ b/ting.module @@ -934,6 +934,9 @@ function _ting_default_reservable_types() { /** * Fetch known types from the datawell. + * + * @return array + * Array with data well material types. */ function _ting_fetch_well_types() { // Get a list of types by executing a null query and look at the facets @@ -956,10 +959,15 @@ function _ting_fetch_well_types() { if (!empty($types)) { variable_set('ting_well_types', $types); } + + return $types; } /** * Fetch known sources from the datawell. + * + * @return array + * Array with the sources. */ function _ting_fetch_well_sources() { // Get a list of sources by executing a null query and look at the facets @@ -982,6 +990,8 @@ function _ting_fetch_well_sources() { if (!empty($sources)) { variable_set('ting_well_sources', $sources); } + + return $sources; } /** From 55b4d67d8f44dd930749ee29cdc808fe473b5e01 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 25 Mar 2014 15:17:14 +0100 Subject: [PATCH 112/167] Updated default reservation types --- ting.module | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/ting.module b/ting.module index 856ab77..3e35ee8 100644 --- a/ting.module +++ b/ting.module @@ -906,29 +906,43 @@ function _ting_default_reservable_sources() { */ function _ting_default_reservable_types() { return array( - 'billedbog', - 'blu-ray disc', 'bog', + 'node', + 'dvd', + 'billedbog', + 'cd (musik)', + 'lydbog (cd)', + 'lydbog (bånd)', + 'tegneserie', + 'lydbog (cd-mp3)', + 'sammensat materiale', 'cd', + 'bog stor skrift', + 'årbog', + 'video', + 'periodikum', + 'blu-ray', + 'tidsskrift', 'cd-rom', - 'diskette', - 'dvd', + 'pc-spil', + 'playstation 3', + 'xbox 360', + 'wii', + 'playstation 2', + 'playstation 4', + 'graphic novel ', + 'nintendo ds', 'dvd-rom', - 'film', + 'kort', + 'xbox', + 'gameboy advance', + 'wii u', 'grammofonplade', - 'kassettelydbånd', - 'lydbog (cd)', - 'lydbog (cd-mp3)', - 'playstation2-spil', - 'playstation3-spil', - 'playstation-spil', - 'puslespil', + 'playstation', + 'lydbog', 'spil', - 'tegneserie', - 'video', - 'wii-spil', - 'xbox-spil', - 'årbog', + 'puslespil ', + 'diskette', ); } From 740eee0f9273238bd36c878f51510ee445b7e2ea Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 25 Mar 2014 15:21:20 +0100 Subject: [PATCH 113/167] Removed periodikum and tidsskrift from default reservation types --- ting.module | 2 -- 1 file changed, 2 deletions(-) diff --git a/ting.module b/ting.module index 3e35ee8..5ac6a4a 100644 --- a/ting.module +++ b/ting.module @@ -920,9 +920,7 @@ function _ting_default_reservable_types() { 'bog stor skrift', 'årbog', 'video', - 'periodikum', 'blu-ray', - 'tidsskrift', 'cd-rom', 'pc-spil', 'playstation 3', From 88126f87e17f740366c51fe40182de83f258f008 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 25 Mar 2014 15:44:55 +0100 Subject: [PATCH 114/167] =?UTF-8?q?Removed=20=C3=A5rbog=20from=20default?= =?UTF-8?q?=20reservation=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ting.module | 1 - 1 file changed, 1 deletion(-) diff --git a/ting.module b/ting.module index 5ac6a4a..e152723 100644 --- a/ting.module +++ b/ting.module @@ -918,7 +918,6 @@ function _ting_default_reservable_types() { 'sammensat materiale', 'cd', 'bog stor skrift', - 'årbog', 'video', 'blu-ray', 'cd-rom', From 5dc7b471fc312b58db4fccce2c4058d29ed38783 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 26 Mar 2014 13:10:43 +0100 Subject: [PATCH 115/167] Updated default series register search string --- ting.install | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ting.install b/ting.install index 2bead9b..8b5e842 100644 --- a/ting.install +++ b/ting.install @@ -328,3 +328,13 @@ function ting_update_7007() { variable_set('ting_search_register_serie_title', 'phrase.titleSeries = "@serietitle"'); } } + +/** + * Update series title search registry setting. + */ +function ting_update_7008() { + // Only update if set else default value will be used. + if (variable_get('ting_search_register_serie_title', FALSE)) { + variable_set('ting_search_register_serie_title', 'phrase.titleSeries="@serietitle"'); + } +} From a68e85d131c653fdc3c8879907d8e644f3f39a3f Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 10 Apr 2014 10:05:52 +0200 Subject: [PATCH 116/167] Fixed default series title value, removed spaces --- ting.field.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.field.inc b/ting.field.inc index 7fc4e4f..fdfe9ec 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -377,7 +377,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la // the series title register and the description field because many // series only have data in the description field. This will probably // change with new versions of the data well. - $search_term = str_replace('@serietitle', drupal_strtolower($entity->serieTitle), variable_get('ting_search_register_serie_title', 'phrase.titleSeries = "@serietitle"')); + $search_term = str_replace('@serietitle', drupal_strtolower($entity->serieTitle), variable_get('ting_search_register_serie_title', 'phrase.titleSeries="@serietitle"')); $element[$delta] = array( '#markup' => l($entity->serieTitle, 'search/ting/' . $search_term, array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), ); From 35a2701862a961fe023fb77f6143bc9d827d93f6 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 11 Apr 2014 13:54:12 +0200 Subject: [PATCH 117/167] Fixed series title for "del af" series --- ting.entities.inc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index 40a5ed6..28d8be0 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -162,14 +162,15 @@ class TingEntity extends DingEntity { $result = ''; $parts = explode(':', $series); - if (is_array($parts) && count($parts >= 2)) { + if (is_array($parts) && count($parts) >= 2) { $prefix = $parts[0] . ': '; if (stripos($prefix, 'del af:') !== FALSE) { - $title = $parts[1]; - $result = $prefix . l($title, 'search/ting/' . '"' . $title . '"'); + $title = trim($parts[1]); + $path = str_replace('@serietitle', drupal_strtolower($title), variable_get('ting_search_register_serie_title', 'phrase.titleSeries="@serietitle"')); + $link = l($title, 'search/ting/' . $path, array('attributes' => array('class' => array('series')))); + $result = $prefix . $link; } else if (stripos($prefix, 'Samhørende:') !== FALSE) { - $titles = $parts[1]; // Multiple titles are separated by ' ; '. Explode to iterate over them $titles = explode(' ; ', $titles); From 99be2b27b0fe8373c9f9c3040a67bc5e1a208a8a Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Fri, 11 Apr 2014 13:58:42 +0200 Subject: [PATCH 118/167] Removed space in default reservalbe types --- ting.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.module b/ting.module index e152723..68c8007 100644 --- a/ting.module +++ b/ting.module @@ -927,7 +927,7 @@ function _ting_default_reservable_types() { 'wii', 'playstation 2', 'playstation 4', - 'graphic novel ', + 'graphic novel', 'nintendo ds', 'dvd-rom', 'kort', @@ -938,7 +938,7 @@ function _ting_default_reservable_types() { 'playstation', 'lydbog', 'spil', - 'puslespil ', + 'puslespil', 'diskette', ); } From 7363e14a1b8ab240d666521f8e19d879f8dc025c Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 6 May 2014 12:23:57 +0200 Subject: [PATCH 119/167] Updated virtual field to version 1.2 --- ting.make | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ting.make b/ting.make index 963b25c..ff24103 100644 --- a/ting.make +++ b/ting.make @@ -9,8 +9,7 @@ projects[nanosoap][version] = "1.0" projects[nanosoap][patch][] = "http://drupal.org/files/nanosoap-curloptions-1943732.patch" projects[virtual_field][subdir] = "contrib" -projects[virtual_field][version] = "1.1" - +projects[virtual_field][version] = "1.2" ; Libraries From afe4761ce9833068635d7fd1da6aecaf9c58c117 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 15 May 2014 11:03:17 +0200 Subject: [PATCH 120/167] Simple code clean up --- ting.client.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.client.inc b/ting.client.inc index 7462a2d..b2ae1fc 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -380,7 +380,7 @@ function ting_execute_cache($request) { // precedence. if (isset($reply->collections)) { foreach ($reply->collections as &$collection) { - if (isset($collection->objects[0])) { + if (is_array($collection->objects)) { foreach ($collection->objects as $object) { // Cache any relations. if (isset($object->relations)) { From aa28a9ce375d63bac45db2a21e5ce4a2516b841a Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 15 May 2014 12:54:29 +0200 Subject: [PATCH 121/167] Issue #373 cableman: Fixed loading of relations only when needed --- ting.entities.inc | 55 +++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index 28d8be0..973adbf 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -264,37 +264,50 @@ class TingEntity extends DingEntity { return !empty($this->reply->record['dc:date']) ? $this->reply->record['dc:date'][''][0] : FALSE; } - function getOnline_url() { - // Try to find the online url from relation data, which requires us to get - // relations. First check if relations are set; if not do another request - // to get relations - if (!isset($this->reply->relationsData)) { - $tingClientObject = ting_get_object($this->ding_entity_id, FALSE, TRUE); - if (isset($tingClientObject->relationsData)) { - $this->reply->relationsData = $tingClientObject->relationsData; + /** + * Try to find the online url. + * + * @param bool $get_relations + * If TRUE relations will be fetched from the data well else "dc:identifier" + * will be checked. + * + * @return mixed + * URL to the online resource or the empty string if note found. + */ + function getOnline_url($get_relations = TRUE) { + $url = ''; + if ($get_relations) { + // Try to find the online url from relation data, which requires us to get + // relations. First check if relations are set; if not do another request + // to get relations + if (!isset($this->reply->relationsData)) { + $tingClientObject = ting_get_object($this->ding_entity_id, FALSE, TRUE); + if (isset($tingClientObject->relationsData)) { + $this->reply->relationsData = $tingClientObject->relationsData; + } } - } - if (isset($this->reply->relationsData)) { - foreach ($this->reply->relationsData as $data) { - if ($data->relationType == 'dbcaddi:hasOnlineAccess') { - $url = preg_replace('/^\[URL\]/', '', $data->relationUri); - // Check for correct url - some uri is only an id. - if (stripos($url, 'http') === 0) { - // Give ting_proxy a change to rewrite the url. - drupal_alter('ting_online_url', $url, $this); - return $url; + if (isset($this->reply->relationsData)) { + foreach ($this->reply->relationsData as $data) { + if ($data->relationType == 'dbcaddi:hasOnlineAccess') { + $url = preg_replace('/^\[URL\]/', '', $data->relationUri); + // Check for correct url - some uri is only an id. + if (stripos($url, 'http') === 0) { + // Give ting_proxy a change to rewrite the url. + drupal_alter('ting_online_url', $url, $this); + } } } } } - // No hasOnlineAccess found so fallback to dc:identifer. - if (isset($this->reply->record['dc:identifier']['dcterms:URI'])) { + // No hasOnlineAccess found so fallback to dc:identifier. + if (empty($url) && isset($this->reply->record['dc:identifier']['dcterms:URI'])) { $url = $this->reply->record['dc:identifier']['dcterms:URI'][0]; // Give ting_proxy a change to rewrite the url. drupal_alter('ting_online_url', $url, $this); - return $url; } + + return $url; } function getAc_source() { From cd4e79066fbadeaa44ee31b87aa7a685540b7aa0 Mon Sep 17 00:00:00 2001 From: Martin Cording Date: Thu, 22 May 2014 15:40:18 +0200 Subject: [PATCH 122/167] Make the DK5 value available. --- ting.entities.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ting.entities.inc b/ting.entities.inc index 973adbf..87fd098 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -65,7 +65,10 @@ class TingEntity extends DingEntity { if ($dk5 == 'sk') { return ''; } + + return $dk5; } + return FALSE; } From 486d516e8b30c0aa9bfbd1901de1245c1a057be7 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 28 May 2014 15:03:31 +0200 Subject: [PATCH 123/167] Updated cache function name --- ting.client.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index b2ae1fc..c6606ce 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -86,7 +86,7 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALS if ($sub_object->id == $object_id) { // If not asking for a collection, and the object is, return the // sub-object with the same id. - _ting_cache_no_relations($sub_object, $with_relations); + _ting_cache_update_relations_status($sub_object, $with_relations); return $sub_object; } } @@ -96,7 +96,7 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALS // Mark the object in cache as relations have been loaded. if (!$collection) { - _ting_cache_no_relations($object, $with_relations); + _ting_cache_update_relations_status($object, $with_relations); } // If not asking for a collection, and the object is, return the @@ -531,7 +531,7 @@ function ting_cache_set($id, $value, $type = TING_CACHE_TING_OBJECT) { * @param bool $with_relations * If TRUE relations will be marked. */ -function _ting_cache_no_relations($object, $with_relations) { +function _ting_cache_update_relations_status($object, $with_relations = FALSE) { if ($with_relations && $object instanceof TingClientObject) { if (empty($object->relations)) { // Mark this object as having no relations. From 567d7f747f8898bc370c79cd62de4656cb4bdad0 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 28 May 2014 15:03:31 +0200 Subject: [PATCH 124/167] Updated cache function name --- ting.client.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index 7462a2d..46297bf 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -86,7 +86,7 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALS if ($sub_object->id == $object_id) { // If not asking for a collection, and the object is, return the // sub-object with the same id. - _ting_cache_no_relations($sub_object, $with_relations); + _ting_cache_update_relations_status($sub_object, $with_relations); return $sub_object; } } @@ -96,7 +96,7 @@ function ting_get_object($object_id, $collection = FALSE, $with_relations = FALS // Mark the object in cache as relations have been loaded. if (!$collection) { - _ting_cache_no_relations($object, $with_relations); + _ting_cache_update_relations_status($object, $with_relations); } // If not asking for a collection, and the object is, return the @@ -531,7 +531,7 @@ function ting_cache_set($id, $value, $type = TING_CACHE_TING_OBJECT) { * @param bool $with_relations * If TRUE relations will be marked. */ -function _ting_cache_no_relations($object, $with_relations) { +function _ting_cache_update_relations_status($object, $with_relations = FALSE) { if ($with_relations && $object instanceof TingClientObject) { if (empty($object->relations)) { // Mark this object as having no relations. From 169fe12dcfddfdb3fafd6153bf2034dd57ae63c6 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 24 Jun 2014 12:29:03 +0200 Subject: [PATCH 125/167] Issue #411 by cableman,hurlum: Fixed ting collection cache indexes --- ting.client.inc | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index c6606ce..4a855ca 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -32,8 +32,13 @@ define('TING_CACHE_EMPTY_ENTRY', '8e4f3ef1784c020bf7afa5b6dd69b421'); function ting_get_object($object_id, $collection = FALSE, $with_relations = FALSE) { if (!empty($object_id)) { // Check the cache first. - $type = ($collection ? TING_CACHE_COLLECTION : TING_CACHE_TING_OBJECT); - $object = ting_cache_get($object_id, $type, $with_relations); + $type = TING_CACHE_TING_OBJECT; + $cache_key = $object_id; + if ($collection) { + $type = TING_CACHE_COLLECTION; + $cache_key = ting_cache_collection_key($object_id); + } + $object = ting_cache_get($cache_key, $type, $with_relations); if ($object != TING_CACHE_EMPTY_ENTRY && !$object) { // Put a negative reply in the cache. It will be overwritten by the // object, or ensure that we won't try to fetch this id again. @@ -392,7 +397,7 @@ function ting_execute_cache($request) { } ting_cache_set($object->id, $object, $type); } - ting_cache_set($collection->objects[0]->id, $collection, TING_CACHE_COLLECTION); + ting_cache_set(ting_cache_collection_key($collection->objects[0]->id), $collection, TING_CACHE_COLLECTION); } } } @@ -514,6 +519,29 @@ function ting_cache_set($id, $value, $type = TING_CACHE_TING_OBJECT) { } } +/** + * Generates a cache id (cid) for ting collection cache. + * + * Collections have to be indexed in cache based on the facets selected as the + * collections changes content based on facets. This is all due to the fact that + * collections don't have unique id's. In fact we use the first object's id in + * the collection to id the collection. + * + * @param string $object_id + * Ting object ID also known as PID. + * + * @return string + * Cache key to retrieve and set data in the cache, + */ +function ting_cache_collection_key($object_id) { + $cache_key = $object_id; + if (!empty($_GET['facets'])) { + $cache_key .= ':' . md5(serialize($_GET['facets'])); + } + + return $cache_key; +} + /** * Mark the object in the cache as having no relations in the data well. * From 52a4aa57cc5a7d7f0b83c7e4a325da8dd0ccdf0a Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 19 Aug 2014 15:41:22 +0200 Subject: [PATCH 126/167] Issue #396 by cableman: Fixed user defined ranking to use the right indexes --- ting.module | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ting.module b/ting.module index 68c8007..2baa8af 100644 --- a/ting.module +++ b/ting.module @@ -779,12 +779,12 @@ function ting_boost_field_element_process($element, $form_state) { '#type' => 'select', '#options' => array( '' => '- ' . t('Choose') . ' -', - 'ac.source' => t('Source'), - 'dc.creator' => t('Author'), - 'dc.date' => t('Year of publish'), - 'dc.language' => t('Language'), - 'dc.type' => t('Material type'), - 'dc.identifier' => t('ISBN number'), + 'term.acSource' => t('Source'), + 'term.creator' => t('Author'), + 'term.date' => t('Year of publish'), + 'term.language' => t('Language'), + 'term.type' => t('Material type'), + 'term.identifier' => t('ISBN number'), ), '#default_value' => (isset($element['#value']['field_name'])) ? $element['#value']['field_name'] : NULL, '#attributes' => array('class' => array('field-name')), @@ -840,12 +840,12 @@ function ting_ranking_field_element_process($element, $form_state) { '#type' => 'select', '#options' => array( '' => '- ' . t('Choose') . ' -', - 'ac.source' => t('Source'), - 'dc.title' => t('Title'), - 'dc.creator' => t('Author'), - 'dc.subject' => t('Subject'), - 'dc.date' => t('Year of publish'), - 'dc.type' => t('Material type'), + 'term.acSource' => t('Source'), + 'term.title' => t('Title'), + 'term.creator' => t('Author'), + 'term.subject' => t('Subject'), + 'term.date' => t('Year of publish'), + 'term.type' => t('Material type'), ), '#default_value' => (isset($element['#value']['field_name'])) ? $element['#value']['field_name'] : NULL, '#attributes' => array('class' => array('field-name')), From a0152ab4bb0ca5e8ad82d8175c639f8e80e908d8 Mon Sep 17 00:00:00 2001 From: Martin Cording Date: Fri, 22 Aug 2014 17:51:51 +0200 Subject: [PATCH 127/167] Also show the DK5-Text. --- ting.entities.inc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ting.entities.inc b/ting.entities.inc index 87fd098..630e36e 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -72,6 +72,12 @@ class TingEntity extends DingEntity { return FALSE; } + function getClassificationText() { + $dk5_text = !empty($this->reply->record['dc:subject']['dkdcplus:DK5-Text'][0]) ? $this->reply->record['dc:subject']['dkdcplus:DK5-Text'][0] : ''; + + return $dk5_text; + } + function getIsPartOf() { $this->isPartOf = array(); if( !empty($this->reply->record['dcterms:isPartOf']) ) { From ed4af9ce9432952a061e80b65c3b4dd804c411bc Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 6 Oct 2014 14:00:11 +0200 Subject: [PATCH 128/167] Updated make file to point to development branch --- ting.make | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ting.make b/ting.make index 9d23c4b..171f161 100644 --- a/ting.make +++ b/ting.make @@ -15,12 +15,12 @@ projects[virtual_field][version] = "1.2" libraries[ting-client][download][type] = "git" libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" -libraries[ting-client][download][tag] = "7.x-1.0-rc3" +libraries[ting-client][download][tag] = "development" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules 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" From ff4d5945ad500c86f80ca7b99e5e168c66b07963 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 7 Oct 2014 08:43:06 +0200 Subject: [PATCH 129/167] Updated make file to point to master branch --- ting.make | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ting.make b/ting.make index 171f161..33a4de2 100644 --- a/ting.make +++ b/ting.make @@ -14,13 +14,13 @@ projects[virtual_field][version] = "1.2" ; Libraries libraries[ting-client][download][type] = "git" -libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" -libraries[ting-client][download][tag] = "development" +libraries[ting-client][download][url] = "git@github.com:ding2/ting-client.git" +libraries[ting-client][download][tag] = "master" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules 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" From 21fd2144a79ca63044416a877b9849da14760604 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 15 Oct 2014 12:50:18 +0200 Subject: [PATCH 130/167] Updated makefile to point to master branch not tag --- ting.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.make b/ting.make index 33a4de2..4f950d3 100644 --- a/ting.make +++ b/ting.make @@ -15,7 +15,7 @@ projects[virtual_field][version] = "1.2" libraries[ting-client][download][type] = "git" libraries[ting-client][download][url] = "git@github.com:ding2/ting-client.git" -libraries[ting-client][download][tag] = "master" +libraries[ting-client][download][branch] = "master" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules From daead9666b5b90dc8b5112b902217355896cd823 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 15 Oct 2014 12:50:58 +0200 Subject: [PATCH 131/167] Updated makefile to point to development branch not tag --- ting.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.make b/ting.make index 171f161..ff24103 100644 --- a/ting.make +++ b/ting.make @@ -15,7 +15,7 @@ projects[virtual_field][version] = "1.2" libraries[ting-client][download][type] = "git" libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" -libraries[ting-client][download][tag] = "development" +libraries[ting-client][download][branch] = "development" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules From 50a3ea5e1c1f48e799a0e779ddf36160923f034e Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 21 Oct 2014 13:21:33 +0200 Subject: [PATCH 132/167] Reviewed: Fixed spell error in function comment --- ting.entities.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.entities.inc b/ting.entities.inc index 973adbf..a91afd0 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -272,7 +272,7 @@ class TingEntity extends DingEntity { * will be checked. * * @return mixed - * URL to the online resource or the empty string if note found. + * URL to the online resource or the empty string if not found. */ function getOnline_url($get_relations = TRUE) { $url = ''; From 4f5af098a0d46c211c1ddb1d1da4e5ef4048fc58 Mon Sep 17 00:00:00 2001 From: pjohans Date: Mon, 27 Oct 2014 15:40:40 +0100 Subject: [PATCH 133/167] Issue #622 by Pjohans: cql.anyIndexes does not exist - use term.default when ranking. Weight must be higher for phrase - that makes most sense --- ting.client.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index 4a855ca..c3ed517 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -280,13 +280,13 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar if (!empty($fields)) { // Add the default anyIndex boosts. $fields[] = array( - 'fieldName' => 'cql.anyIndexes', + 'fieldName' => 'term.default', 'fieldType' => 'phrase', - 'weight' => 1, + 'weight' => 2, ); $fields[] = array( - 'fieldName' => 'cql.anyIndexes', + 'fieldName' => 'term.default', 'fieldType' => 'word', 'weight' => 1, ); From 6e401840a3dade3f7ef9a090bff26a34705def37 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 19 Jan 2015 13:37:50 +0100 Subject: [PATCH 134/167] Reviewed: Updated makefile to point to ding2 from ding2tal in makefile --- ting.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.make b/ting.make index 8559eb7..4f950d3 100644 --- a/ting.make +++ b/ting.make @@ -14,8 +14,8 @@ projects[virtual_field][version] = "1.2" ; Libraries libraries[ting-client][download][type] = "git" -libraries[ting-client][download][url] = "git@github.com:ding2tal/ting-client.git" -libraries[ting-client][download][branch] = "development" +libraries[ting-client][download][url] = "git@github.com:ding2/ting-client.git" +libraries[ting-client][download][branch] = "master" libraries[ting-client][destination] = "modules/ting/lib" ; Ding 2 modules From 1ec96448f14fc9de9c58a5a54bed6bf62e6ed861 Mon Sep 17 00:00:00 2001 From: JrgenGNielsen Date: Mon, 16 Feb 2015 16:46:21 +0100 Subject: [PATCH 135/167] Issue #467 by JrgenGNielsen: Add quotes around subject terms in search links --- ting.field.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.field.inc b/ting.field.inc index fdfe9ec..0e107fa 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -427,7 +427,7 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la if (count($entity->subjects) == TRUE) { $subjects = array(); foreach ($entity->subjects as $subject) { - $subjects[] = l($subject, 'search/ting/dkcclterm.em=' . $subject, array('attributes' => array('class' => array('subject')))); + $subjects[] = l($subject, 'search/ting/dkcclterm.em="' . $subject . '"', array('attributes' => array('class' => array('subject')))); } $element[$delta] = array( '#markup' => implode(' ', $subjects), From 4f24d516271cde3383a49a7e8f276905ae2197c5 Mon Sep 17 00:00:00 2001 From: pjohans Date: Tue, 17 Feb 2015 11:39:31 +0100 Subject: [PATCH 136/167] Issue 827 by Pjohans: take away boostField from parameters - it is no longer valid --- ting.client.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.client.inc b/ting.client.inc index c3ed517..eea534b 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -311,7 +311,7 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar 'weight' => $boost_field['weight'], ); } - $request->userDefinedBoost = array('boostField' => $uboosts); + $request->userDefinedBoost = $uboosts; } $search_result = ting_execute_cache($request); From 5b51d9092a7affb7bbbf75f96811ce1e6d98d6f6 Mon Sep 17 00:00:00 2001 From: pjohans Date: Tue, 24 Feb 2015 16:40:01 +0100 Subject: [PATCH 137/167] Issue 626 by pjohans: update ting_object table to allow multiple NULL values in vid-field --- ting.install | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ting.install b/ting.install index 8b5e842..2c4bae7 100644 --- a/ting.install +++ b/ting.install @@ -338,3 +338,19 @@ function ting_update_7008() { variable_set('ting_search_register_serie_title', 'phrase.titleSeries="@serietitle"'); } } + +/** + * Update ting_object table - set foreign key (vid) to ting_object_revision to be null by default thus allowing + * multiple NULL values in table + */ +function ting_update_7009() { + db_drop_unique_key('ting_object', 'vid'); + db_change_field('ting_object', 'vid', 'vid', array( + 'description' => 'The current {ting_obuect}.vid version identifier.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE, + 'default' => NULL, + )); + db_add_unique_key('ting_object', 'vid', array('vid')); +} \ No newline at end of file From 1b09283e534afc049b93862d72a647f4c4e1ea04 Mon Sep 17 00:00:00 2001 From: pjohans Date: Wed, 25 Feb 2015 09:23:23 +0100 Subject: [PATCH 138/167] Issue626 by Pjohans: update ting_schema for new installations --- ting.install | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ting.install b/ting.install index 2c4bae7..5b92bd9 100644 --- a/ting.install +++ b/ting.install @@ -21,11 +21,11 @@ function ting_schema() { 'not null' => TRUE, ), 'vid' => array( - 'description' => 'The current {ting_object_revision}.vid version identifier.', + 'description' => 'The current {ting_object}.vid version identifier.', 'type' => 'int', 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, + 'not null' => FALSE, + 'default' => NULL, ), 'ding_entity_id' => array( 'description' => 'The ting object id.', @@ -346,7 +346,7 @@ function ting_update_7008() { function ting_update_7009() { db_drop_unique_key('ting_object', 'vid'); db_change_field('ting_object', 'vid', 'vid', array( - 'description' => 'The current {ting_obuect}.vid version identifier.', + 'description' => 'The current {ting_object}.vid version identifier.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, From 81bb8628b3247e98c1b83de628a93a149c51fc81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Garn=C3=A6s?= Date: Wed, 25 Feb 2015 09:25:30 +0100 Subject: [PATCH 139/167] Add missing newline --- ting.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.install b/ting.install index 5b92bd9..e958ce4 100644 --- a/ting.install +++ b/ting.install @@ -353,4 +353,4 @@ function ting_update_7009() { 'default' => NULL, )); db_add_unique_key('ting_object', 'vid', array('vid')); -} \ No newline at end of file +} From 9ae471738c68f6eda9f8c874b01d1e3797cc126f Mon Sep 17 00:00:00 2001 From: pjohans Date: Tue, 24 Mar 2015 15:28:28 +0100 Subject: [PATCH 140/167] Issue1113 by Pjohans: Set and use default (best match) sort method from admin/config/ting/ranking --- ting.admin.inc | 22 +++++++++++++++++++++- ting.client.inc | 10 +++++----- ting.module | 20 ++++++++++++++++++++ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index b4bc2c5..0042472 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -162,6 +162,22 @@ function ting_admin_ranking_settings($form, &$form_state) { ), ); + + $ting_sort_value = variable_get('ting_sort_default', 'rank_frequency'); + $form['ting_sort_default'] = array( + '#title' => t('Default sort method (best match)'), + '#type' => 'fieldset', + '#prefix' => '
', + '#suffix' => '
', + '#tree' => TRUE, + ); + + $form['ting_sort_default']['fields'] = array( + '#type' => 'ting_sort_default', + '#default_value' => array('sort_type' => $ting_sort_value), + ); + + $form['buttons']['save'] = array( '#type' => 'submit', '#value' => t('Save changes'), @@ -200,7 +216,6 @@ function ting_admin_ranking_add_more_js($form, &$form_state) { */ function ting_admin_ranking_form_after_build($form, &$form_state) { $path = drupal_get_path('module', 'ting'); - drupal_add_css($path . '/css/ting_admin_ranking_form.css'); return $form; @@ -218,6 +233,11 @@ function ting_admin_ranking_settings_submit($form, &$form_state) { usort($fields, '_ting_ranking_field_sort'); variable_set('ting_ranking_fields', $fields); + + $default_sort = $form_state['values']['ting_sort_default']['fields']['sort_type']; + variable_set('ting_sort_default',$default_sort); + + drupal_set_message(t('Settings has been saved'), 'status'); } /** diff --git a/ting.client.inc b/ting.client.inc index eea534b..4ed30f5 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -255,6 +255,11 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar if (isset($options['sort']) && $options['sort']) { $request->setSort($options['sort']); } + else{ + $sort = variable_get('ting_sort_default','rank_frequency'); + $request->setSort($sort); + } + if (isset($options['collectionType'])) { $request->setCollectionType($options['collectionType']); } @@ -294,11 +299,6 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar $request->userDefinedRanking = array('tieValue' => 0.1, 'rankField' => $fields); } } - // Otherwise, use the ranking setting. - else { - $request->setRank((isset($options['rank']) && $options['rank']) ? $options['rank'] : 'rank_general'); - } - // Apply custom boosts if any. $boosts = variable_get('ting_boost_fields', array()); diff --git a/ting.module b/ting.module index 2baa8af..b66d5cb 100644 --- a/ting.module +++ b/ting.module @@ -350,9 +350,29 @@ function ting_element_info() { '#input' => TRUE, '#process' => array('ting_ranking_field_element_process'), ), + 'ting_sort_default' => array( + '#input' => TRUE, + '#process' => array('ting_sort_default'), + ) ); } +function ting_sort_default($element, $form_state){ + $element['#tree'] = TRUE; + + $element['sort_type'] = array( + '#title' => t('Type'), + '#type' => 'select', + '#options' => array( + 'rank_frequency' => t('rank_frequency'), + 'rank_general' => t('rank_general'), + 'rank_none' => t('rank_none'), + ), + '#default_value' => (isset($element['#value']['sort_type'])) ? $element['#value']['sort_type'] : 'rank_frequency', + ); + return $element; +} + /** * Implements hook_theme(). */ From 1b58149b75419448e580b8674776fa01905464ce Mon Sep 17 00:00:00 2001 From: pjohans Date: Thu, 26 Mar 2015 11:09:10 +0100 Subject: [PATCH 141/167] Issue796 by Pjohans: if ding_provider fails to translate an old pid - try to look it up via opensearch --- ting.module | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/ting.module b/ting.module index 2baa8af..8313dbe 100644 --- a/ting.module +++ b/ting.module @@ -619,12 +619,40 @@ function ting_object_load($id) { if ($agency && preg_match('/^(\d{6}):(\w+)$/', $id, $matches)) { // Matched to data well version 2, to redirect to version 3. $id = ding_provider_build_entity_id($matches[2], $matches[1]); + if($id === FALSE){ + $id = ting_lookup_and_translate($id); + } drupal_goto('ting/object/' . $id, array(), 301); } return ding_entity_load($id, 'ting_object'); } + +/** + * Try to lookup well3 pid via a search on the old pid. + * Search query is constructed from old pid eg. 870971:72966643 -> '870971 and 72966643' + * + * This is NOT foolproof - if more than one result is found the first is returned, and that might not + * be the correct one + * + * @param $old_pid ( eg 870971:72966643) + * @return bool|mixed; new pid (eg 870971-tsart:72966643 ) if found; else FALSE + */ +function ting_lookup_and_translate($old_pid){ + $query_elements = explode(':', $old_pid); + $query = implode(' and ', $query_elements); + + module_load_include('client.inc', 'ting'); + $result = ting_do_search($query,1,1,array('facets'=>array())); + if(isset($result->collections)) { + $id = key($result->collections); + return $id; + } + return FALSE; +} + + /** * Load multiple ting objects. * @@ -647,6 +675,9 @@ function ting_collection_load($id) { if ($agency && preg_match('/^(\d{6}):(\w+)$/', $id, $matches)) { // Matched to data well version 2, to redirect to version 3. $id = ding_provider_build_entity_id($matches[2], $matches[1]); + if($id === FALSE){ + $id = ting_lookup_and_translate($id); + } drupal_goto('ting/collection/' . $id, array(), 301); } From 43b129452c82c4f78eb101b2ca7fbdbdd14d83cd Mon Sep 17 00:00:00 2001 From: pjohans Date: Thu, 26 Mar 2015 11:34:33 +0100 Subject: [PATCH 142/167] Issue 796 by Pjohans: and do it the right way --- ting.module | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ting.module b/ting.module index 8313dbe..d954bb4 100644 --- a/ting.module +++ b/ting.module @@ -618,10 +618,13 @@ function ting_object_load($id) { $agency = variable_get('ting_agency', FALSE); if ($agency && preg_match('/^(\d{6}):(\w+)$/', $id, $matches)) { // Matched to data well version 2, to redirect to version 3. - $id = ding_provider_build_entity_id($matches[2], $matches[1]); - if($id === FALSE){ + $new_id = ding_provider_build_entity_id($matches[2], $matches[1]); + if($new_id === FALSE){ $id = ting_lookup_and_translate($id); } + else{ + $id = $new_id; + } drupal_goto('ting/object/' . $id, array(), 301); } @@ -674,10 +677,13 @@ function ting_collection_load($id) { $agency = variable_get('ting_agency', FALSE); if ($agency && preg_match('/^(\d{6}):(\w+)$/', $id, $matches)) { // Matched to data well version 2, to redirect to version 3. - $id = ding_provider_build_entity_id($matches[2], $matches[1]); - if($id === FALSE){ + $new_id = ding_provider_build_entity_id($matches[2], $matches[1]); + if($new_id === FALSE){ $id = ting_lookup_and_translate($id); } + else{ + $id = $new_id; + } drupal_goto('ting/collection/' . $id, array(), 301); } From 229eae3d5fe8b09a0913e9449d352421c0bacf01 Mon Sep 17 00:00:00 2001 From: pjohans Date: Fri, 27 Mar 2015 10:56:10 +0100 Subject: [PATCH 143/167] Issue 988 by Pjohans: A material can belong to more than one serie --- ting.entities.inc | 23 +++++++---------------- ting.field.inc | 11 +++++++---- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index 69d5f76..2860c66 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -130,27 +130,18 @@ class TingEntity extends DingEntity { return $title; } - function getSerieNumber() { - $serie = $this->splitSerie(); - // Last part is the number. - if (empty($serie[1])) { - return FALSE; - } - return $serie[1]; - } private function splitSerie() { - $serie = !empty($this->reply->record['dc:title']['dkdcplus:series'][0]) ? $this->reply->record['dc:title']['dkdcplus:series'][0] : ''; - return explode(';', $serie); + $series = !empty($this->reply->record['dc:title']['dkdcplus:series']) ? $this->reply->record['dc:title']['dkdcplus:series'] : array(); + $serie_titles = array(); + foreach ($series as $serie) { + $serie_titles[] = explode(';', $serie); + } + return $serie_titles; } function getSerieTitle() { - $serie = $this->splitSerie(); - // First part is the title. - if (empty($serie[0])) { - return FALSE; - } - return trim($serie[0]); + return $this->splitSerie(); } function getSerieDescription() { diff --git a/ting.field.inc b/ting.field.inc index 0e107fa..b4a8cdf 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -377,10 +377,13 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la // the series title register and the description field because many // series only have data in the description field. This will probably // change with new versions of the data well. - $search_term = str_replace('@serietitle', drupal_strtolower($entity->serieTitle), variable_get('ting_search_register_serie_title', 'phrase.titleSeries="@serietitle"')); - $element[$delta] = array( - '#markup' => l($entity->serieTitle, 'search/ting/' . $search_term, array('attributes' => array('class' => array('series')))) . ' : ' . check_plain($entity->serieNumber), - ); + foreach($entity->serieTitle as $title) { + $search_term = str_replace('@serietitle', drupal_strtolower($title[0]), variable_get('ting_search_register_serie_title', 'phrase.titleSeries="@serietitle"')); + $series_number = isset($title[1]) ? ' : ' . check_plain($title[1]) . ' ; ' : ' ; '; + $element[$delta][] = array( + '#markup' => l(trim($title[0]), 'search/ting/' . $search_term, array('attributes' => array('class' => array('series')))) . $series_number, + ); + } } elseif ($entity->serieDescription) { $element[$delta] = array( From d24ca9d4d93395ba62d32d46428c4a7ddecb9549 Mon Sep 17 00:00:00 2001 From: JrgenGNielsen Date: Tue, 14 Apr 2015 11:22:33 +0200 Subject: [PATCH 144/167] Issue #257 by JrgenGNielsen: Implement openSuggestion autocomplete, and remove openSpell and openScan --- ting.admin.inc | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index b4bc2c5..9305b2c 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -35,22 +35,6 @@ function ting_admin_ting_settings($form_state) { '#default_value' => variable_get('ting_search_url', ''), ); - $form['ting']['ting_scan_url'] = array( - '#type' => 'textfield', - '#title' => t('Scan service URL'), - '#description' => t('URL to the Ting scan webservice, e.g. http://openscan.addi.dk/2.0/'), - '#required' => TRUE, - '#default_value' => variable_get('ting_scan_url', ''), - ); - - $form['ting']['ting_spell_url'] = array( - '#type' => 'textfield', - '#title' => t('Spell service URL'), - '#description' => t('URL to the Ting spell webservice, e.g. http://openspell.addi.dk/1.2/'), - '#required' => TRUE, - '#default_value' => variable_get('ting_spell_url', ''), - ); - $form['ting']['ting_recommendation_url'] = array( '#type' => 'textfield', '#title' => t('Recommendation service URL'), From f379aeacaf5340f644c032b0b0cf3f048832feb6 Mon Sep 17 00:00:00 2001 From: JrgenGNielsen Date: Tue, 14 Apr 2015 13:01:01 +0200 Subject: [PATCH 145/167] Issue #257 by JrgenGNielsen: Implement openSuggestion autocomplete, and remove openSpell and openScan --- ting.client.inc | 64 +------------------------------------------------ ting.test | 2 -- 2 files changed, 1 insertion(+), 65 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index eea534b..0f1e0e9 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -605,11 +605,10 @@ function ting_get_request_factory() { if (!isset($request_factory)) { $url_variables = array( 'search' => 'ting_search_url', - 'scan' => 'ting_scan_url', 'object' => 'ting_search_url', 'collection' => 'ting_search_url', - 'spell' => 'ting_spell_url', 'recommendation' => 'ting_recommendation_url', + 'suggestion' => 'ting_suggestion_url', ); // TODO: This should probably be rethought. @@ -715,64 +714,3 @@ function ting_get_client() { return $client; } - -/** - * Use OpenScan to search for keyword. - * - * See http://oss.dbc.dk/twiki/bin/view/Databroend/OpenSearchDocIndexes for - * information about which phrase index to search, default is 'anyIndexes'. - * - * @param string $query - * The prefix to scan for - * @param string $phrase - * Which phrase index to search. - * @param int $num_results - * The number of results to return. - * - * @return mixed - * A TingClientScanResult object with the scan results found or FALSE if non - * found or connection failed. - */ -function ting_do_scan($query, $phrase = 'anyIndexes', $num_results = 10) { - $request = ting_get_request_factory()->getScanRequest(); - $request->setField('phrase.' . $phrase); - $request->setLower($query); - $request = ting_add_agency($request); - $request->setNumResults($num_results); - return ting_execute($request); -} - -/** - * Add agency to ting scan request. - * - * @param TingClientScanRequest $request - * The request to add agency to. - * - * @return TingClientScanRequest - * The request with the added agency. - */ -function ting_add_agency(TingClientScanRequest $request) { - if ($agency = variable_get('ting_agency', FALSE)) { - $request->setAgency($agency); - } - return $request; -} - -/** - * Get spell suggestions from the open spell service. - * - * @param string $word - * The word to get spell suggestions for. - * @param int $num_results - * The number of results to return. - * - * @return mixed - * Array with TingClientSpellSuggestion objects or FALSE if non found or - * connection failed. - */ -function ting_get_spell_suggestions($word, $num_results = 10) { - $request = ting_get_request_factory()->getSpellRequest(); - $request->setWord($word); - $request->setNumResults($num_results); - return ting_execute($request); -} diff --git a/ting.test b/ting.test index 0f90065..fc6c77a 100644 --- a/ting.test +++ b/ting.test @@ -18,8 +18,6 @@ class TingEntityTestCase extends DrupalWebTestCase { parent::setUp(array('ding_entity', 'ting', 'nanosoap')); variable_set('ting_agency', '100200'); variable_set('ting_search_url', 'http://opensearch.addi.dk/next_2.0/'); - variable_set('ting_scan_url', 'http://openscan.addi.dk/1.5/'); - variable_set('ting_spell_url', 'http://openspell.addi.dk/1.2/'); variable_set('ting_recommendation_url', 'http://openadhl.addi.dk/1.1/'); variable_set('ting_search_profile', 'opac'); } From 7466bd4733dbf4555de7e0d296c7499b5b56d8e3 Mon Sep 17 00:00:00 2001 From: pjohans Date: Tue, 21 Apr 2015 16:07:05 +0200 Subject: [PATCH 146/167] Issue 1113 by pjohans: changes due to codereview --- ting.admin.inc | 4 +--- ting.client.inc | 2 +- ting.module | 9 ++++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index 0042472..0152f75 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -167,8 +167,6 @@ function ting_admin_ranking_settings($form, &$form_state) { $form['ting_sort_default'] = array( '#title' => t('Default sort method (best match)'), '#type' => 'fieldset', - '#prefix' => '
', - '#suffix' => '
', '#tree' => TRUE, ); @@ -235,7 +233,7 @@ function ting_admin_ranking_settings_submit($form, &$form_state) { variable_set('ting_ranking_fields', $fields); $default_sort = $form_state['values']['ting_sort_default']['fields']['sort_type']; - variable_set('ting_sort_default',$default_sort); + variable_set('ting_sort_default', $default_sort); drupal_set_message(t('Settings has been saved'), 'status'); } diff --git a/ting.client.inc b/ting.client.inc index 4ed30f5..6ecaa9d 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -256,7 +256,7 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar $request->setSort($options['sort']); } else{ - $sort = variable_get('ting_sort_default','rank_frequency'); + $sort = variable_get('ting_sort_default', 'rank_frequency'); $request->setSort($sort); } diff --git a/ting.module b/ting.module index b66d5cb..3285ef5 100644 --- a/ting.module +++ b/ting.module @@ -357,6 +357,9 @@ function ting_element_info() { ); } +/** + * Processor for the ting_sort_default form element. + */ function ting_sort_default($element, $form_state){ $element['#tree'] = TRUE; @@ -364,9 +367,9 @@ function ting_sort_default($element, $form_state){ '#title' => t('Type'), '#type' => 'select', '#options' => array( - 'rank_frequency' => t('rank_frequency'), - 'rank_general' => t('rank_general'), - 'rank_none' => t('rank_none'), + 'rank_frequency' => t('Best match'), + 'rank_general' => t('General Rank'), + 'rank_none' => t('No rank'), ), '#default_value' => (isset($element['#value']['sort_type'])) ? $element['#value']['sort_type'] : 'rank_frequency', ); From 482964043ea2ade4ff961a238305b61ba67fa5a5 Mon Sep 17 00:00:00 2001 From: pjohans Date: Tue, 21 Apr 2015 16:53:59 +0200 Subject: [PATCH 147/167] Issue 796 by pjohans: changes due to review --- ting.module | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ting.module b/ting.module index d954bb4..a180b1c 100644 --- a/ting.module +++ b/ting.module @@ -573,8 +573,8 @@ function ting_collection_page_view($object) { /** * Page title callback. - * - * Strips chars '<' and '>' in order to avoid HTML injections. + * + * Strips chars '<' and '>' in order to avoid HTML injections. */ function ting_page_title($object) { return str_replace('&', '&', htmlspecialchars($object->title, ENT_NOQUOTES, 'UTF-8')); @@ -619,10 +619,10 @@ function ting_object_load($id) { if ($agency && preg_match('/^(\d{6}):(\w+)$/', $id, $matches)) { // Matched to data well version 2, to redirect to version 3. $new_id = ding_provider_build_entity_id($matches[2], $matches[1]); - if($new_id === FALSE){ + if ($new_id === FALSE) { $id = ting_lookup_and_translate($id); } - else{ + else { $id = $new_id; } drupal_goto('ting/object/' . $id, array(), 301); @@ -642,13 +642,13 @@ function ting_object_load($id) { * @param $old_pid ( eg 870971:72966643) * @return bool|mixed; new pid (eg 870971-tsart:72966643 ) if found; else FALSE */ -function ting_lookup_and_translate($old_pid){ +function ting_lookup_and_translate($old_pid) { $query_elements = explode(':', $old_pid); $query = implode(' and ', $query_elements); module_load_include('client.inc', 'ting'); - $result = ting_do_search($query,1,1,array('facets'=>array())); - if(isset($result->collections)) { + $result = ting_do_search($query, 1, 1, array('facets' => array())); + if (!empty($result->collections)) { $id = key($result->collections); return $id; } @@ -678,10 +678,10 @@ function ting_collection_load($id) { if ($agency && preg_match('/^(\d{6}):(\w+)$/', $id, $matches)) { // Matched to data well version 2, to redirect to version 3. $new_id = ding_provider_build_entity_id($matches[2], $matches[1]); - if($new_id === FALSE){ + if ($new_id === FALSE) { $id = ting_lookup_and_translate($id); } - else{ + else { $id = $new_id; } drupal_goto('ting/collection/' . $id, array(), 301); From 866cc72caa7389a57d27c3cbd443d20fe6ee42dd Mon Sep 17 00:00:00 2001 From: pjohans Date: Wed, 22 Apr 2015 09:36:35 +0200 Subject: [PATCH 148/167] Issue1113 by pjohans: changes due to review --- ting.admin.inc | 10 ++++++++-- ting.module | 22 ---------------------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index 0152f75..c4440e7 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -170,8 +170,14 @@ function ting_admin_ranking_settings($form, &$form_state) { '#tree' => TRUE, ); - $form['ting_sort_default']['fields'] = array( - '#type' => 'ting_sort_default', + $form['ting_sort_default']['fields']['sort_type'] = array( + '#title' => t('Type'), + '#type' => 'select', + '#options' => array( + 'rank_frequency' => t('Best match'), + 'rank_general' => t('General Rank'), + 'rank_none' => t('No rank'), + ), '#default_value' => array('sort_type' => $ting_sort_value), ); diff --git a/ting.module b/ting.module index 3285ef5..e2f5cc0 100644 --- a/ting.module +++ b/ting.module @@ -350,31 +350,9 @@ function ting_element_info() { '#input' => TRUE, '#process' => array('ting_ranking_field_element_process'), ), - 'ting_sort_default' => array( - '#input' => TRUE, - '#process' => array('ting_sort_default'), - ) ); } -/** - * Processor for the ting_sort_default form element. - */ -function ting_sort_default($element, $form_state){ - $element['#tree'] = TRUE; - - $element['sort_type'] = array( - '#title' => t('Type'), - '#type' => 'select', - '#options' => array( - 'rank_frequency' => t('Best match'), - 'rank_general' => t('General Rank'), - 'rank_none' => t('No rank'), - ), - '#default_value' => (isset($element['#value']['sort_type'])) ? $element['#value']['sort_type'] : 'rank_frequency', - ); - return $element; -} /** * Implements hook_theme(). From ea84e5c2a9bd6d270454b17b210591df25b3087a Mon Sep 17 00:00:00 2001 From: JrgenGNielsen Date: Mon, 4 May 2015 14:39:55 +0200 Subject: [PATCH 149/167] Issue #257 by JrgenGNielsen: openSuggestion autocomplete. No suports for SOAP/JSON --- ting.client.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/ting.client.inc b/ting.client.inc index 0f1e0e9..3c600e7 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -608,7 +608,6 @@ function ting_get_request_factory() { 'object' => 'ting_search_url', 'collection' => 'ting_search_url', 'recommendation' => 'ting_recommendation_url', - 'suggestion' => 'ting_suggestion_url', ); // TODO: This should probably be rethought. From 79b6d85fe40ecbb81243ea4452270dba5a2e792c Mon Sep 17 00:00:00 2001 From: pjohans Date: Wed, 17 Jun 2015 14:55:42 +0200 Subject: [PATCH 150/167] Issue #378 by pjohans: allow other modules (ting_infomedia) to alter infomedia url --- ting.entities.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ting.entities.inc b/ting.entities.inc index 69d5f76..4858f21 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -304,6 +304,7 @@ class TingEntity extends DingEntity { // Give ting_proxy a change to rewrite the url. drupal_alter('ting_online_url', $url, $this); } + } } } @@ -316,6 +317,10 @@ class TingEntity extends DingEntity { drupal_alter('ting_online_url', $url, $this); } + if(strpos($url, '[useraccessinfomedia]') === 0){ + drupal_alter('infomedia_url', $url, $this); + } + return $url; } From f995ce6595d7a428946b079f06e8dcc3ac293679 Mon Sep 17 00:00:00 2001 From: pjohans Date: Thu, 18 Jun 2015 09:19:11 +0200 Subject: [PATCH 151/167] Issue #429 by pjohans: Set user message if any --- ting.client.inc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index 90fff15..70e6bc4 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -662,6 +662,7 @@ function ting_execute($request) { $request->setParameters($params); } + try { timer_start('ting'); $res = ting_get_client()->execute($request); @@ -687,8 +688,10 @@ function ting_execute($request) { } return $response; - } - catch (TingClientException $e) { + } catch (TingClientException $e) { + if (isset($e->user_message)) { + drupal_set_message($e->user_message, 'warning'); + } timer_stop('ting'); watchdog('ting client', 'Error performing request: ' . $e->getMessage(), NULL, WATCHDOG_ERROR, 'http://' . $_SERVER["HTTP_HOST"] . request_uri()); return FALSE; From 4a69c36b6f43acd4006e7dee887d02bc42d98a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Garn=C3=A6s?= Date: Wed, 24 Jun 2015 21:18:15 +0200 Subject: [PATCH 152/167] Revert "Feature/257 opensuggestion" --- ting.admin.inc | 16 +++++++++++++ ting.client.inc | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ ting.test | 2 ++ 3 files changed, 81 insertions(+) diff --git a/ting.admin.inc b/ting.admin.inc index 035ff2d..c4440e7 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -35,6 +35,22 @@ function ting_admin_ting_settings($form_state) { '#default_value' => variable_get('ting_search_url', ''), ); + $form['ting']['ting_scan_url'] = array( + '#type' => 'textfield', + '#title' => t('Scan service URL'), + '#description' => t('URL to the Ting scan webservice, e.g. http://openscan.addi.dk/2.0/'), + '#required' => TRUE, + '#default_value' => variable_get('ting_scan_url', ''), + ); + + $form['ting']['ting_spell_url'] = array( + '#type' => 'textfield', + '#title' => t('Spell service URL'), + '#description' => t('URL to the Ting spell webservice, e.g. http://openspell.addi.dk/1.2/'), + '#required' => TRUE, + '#default_value' => variable_get('ting_spell_url', ''), + ); + $form['ting']['ting_recommendation_url'] = array( '#type' => 'textfield', '#title' => t('Recommendation service URL'), diff --git a/ting.client.inc b/ting.client.inc index 90fff15..6ecaa9d 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -605,8 +605,10 @@ function ting_get_request_factory() { if (!isset($request_factory)) { $url_variables = array( 'search' => 'ting_search_url', + 'scan' => 'ting_scan_url', 'object' => 'ting_search_url', 'collection' => 'ting_search_url', + 'spell' => 'ting_spell_url', 'recommendation' => 'ting_recommendation_url', ); @@ -713,3 +715,64 @@ function ting_get_client() { return $client; } + +/** + * Use OpenScan to search for keyword. + * + * See http://oss.dbc.dk/twiki/bin/view/Databroend/OpenSearchDocIndexes for + * information about which phrase index to search, default is 'anyIndexes'. + * + * @param string $query + * The prefix to scan for + * @param string $phrase + * Which phrase index to search. + * @param int $num_results + * The number of results to return. + * + * @return mixed + * A TingClientScanResult object with the scan results found or FALSE if non + * found or connection failed. + */ +function ting_do_scan($query, $phrase = 'anyIndexes', $num_results = 10) { + $request = ting_get_request_factory()->getScanRequest(); + $request->setField('phrase.' . $phrase); + $request->setLower($query); + $request = ting_add_agency($request); + $request->setNumResults($num_results); + return ting_execute($request); +} + +/** + * Add agency to ting scan request. + * + * @param TingClientScanRequest $request + * The request to add agency to. + * + * @return TingClientScanRequest + * The request with the added agency. + */ +function ting_add_agency(TingClientScanRequest $request) { + if ($agency = variable_get('ting_agency', FALSE)) { + $request->setAgency($agency); + } + return $request; +} + +/** + * Get spell suggestions from the open spell service. + * + * @param string $word + * The word to get spell suggestions for. + * @param int $num_results + * The number of results to return. + * + * @return mixed + * Array with TingClientSpellSuggestion objects or FALSE if non found or + * connection failed. + */ +function ting_get_spell_suggestions($word, $num_results = 10) { + $request = ting_get_request_factory()->getSpellRequest(); + $request->setWord($word); + $request->setNumResults($num_results); + return ting_execute($request); +} diff --git a/ting.test b/ting.test index fc6c77a..0f90065 100644 --- a/ting.test +++ b/ting.test @@ -18,6 +18,8 @@ class TingEntityTestCase extends DrupalWebTestCase { parent::setUp(array('ding_entity', 'ting', 'nanosoap')); variable_set('ting_agency', '100200'); variable_set('ting_search_url', 'http://opensearch.addi.dk/next_2.0/'); + variable_set('ting_scan_url', 'http://openscan.addi.dk/1.5/'); + variable_set('ting_spell_url', 'http://openspell.addi.dk/1.2/'); variable_set('ting_recommendation_url', 'http://openadhl.addi.dk/1.1/'); variable_set('ting_search_profile', 'opac'); } From e88961dc43dfcd094608be7ff341fd63d56b1468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Garn=C3=A6s?= Date: Wed, 24 Jun 2015 21:18:50 +0200 Subject: [PATCH 153/167] Revert "Revert "Feature/257 opensuggestion"" --- ting.admin.inc | 16 ------------- ting.client.inc | 63 ------------------------------------------------- ting.test | 2 -- 3 files changed, 81 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index c4440e7..035ff2d 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -35,22 +35,6 @@ function ting_admin_ting_settings($form_state) { '#default_value' => variable_get('ting_search_url', ''), ); - $form['ting']['ting_scan_url'] = array( - '#type' => 'textfield', - '#title' => t('Scan service URL'), - '#description' => t('URL to the Ting scan webservice, e.g. http://openscan.addi.dk/2.0/'), - '#required' => TRUE, - '#default_value' => variable_get('ting_scan_url', ''), - ); - - $form['ting']['ting_spell_url'] = array( - '#type' => 'textfield', - '#title' => t('Spell service URL'), - '#description' => t('URL to the Ting spell webservice, e.g. http://openspell.addi.dk/1.2/'), - '#required' => TRUE, - '#default_value' => variable_get('ting_spell_url', ''), - ); - $form['ting']['ting_recommendation_url'] = array( '#type' => 'textfield', '#title' => t('Recommendation service URL'), diff --git a/ting.client.inc b/ting.client.inc index 6ecaa9d..90fff15 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -605,10 +605,8 @@ function ting_get_request_factory() { if (!isset($request_factory)) { $url_variables = array( 'search' => 'ting_search_url', - 'scan' => 'ting_scan_url', 'object' => 'ting_search_url', 'collection' => 'ting_search_url', - 'spell' => 'ting_spell_url', 'recommendation' => 'ting_recommendation_url', ); @@ -715,64 +713,3 @@ function ting_get_client() { return $client; } - -/** - * Use OpenScan to search for keyword. - * - * See http://oss.dbc.dk/twiki/bin/view/Databroend/OpenSearchDocIndexes for - * information about which phrase index to search, default is 'anyIndexes'. - * - * @param string $query - * The prefix to scan for - * @param string $phrase - * Which phrase index to search. - * @param int $num_results - * The number of results to return. - * - * @return mixed - * A TingClientScanResult object with the scan results found or FALSE if non - * found or connection failed. - */ -function ting_do_scan($query, $phrase = 'anyIndexes', $num_results = 10) { - $request = ting_get_request_factory()->getScanRequest(); - $request->setField('phrase.' . $phrase); - $request->setLower($query); - $request = ting_add_agency($request); - $request->setNumResults($num_results); - return ting_execute($request); -} - -/** - * Add agency to ting scan request. - * - * @param TingClientScanRequest $request - * The request to add agency to. - * - * @return TingClientScanRequest - * The request with the added agency. - */ -function ting_add_agency(TingClientScanRequest $request) { - if ($agency = variable_get('ting_agency', FALSE)) { - $request->setAgency($agency); - } - return $request; -} - -/** - * Get spell suggestions from the open spell service. - * - * @param string $word - * The word to get spell suggestions for. - * @param int $num_results - * The number of results to return. - * - * @return mixed - * Array with TingClientSpellSuggestion objects or FALSE if non found or - * connection failed. - */ -function ting_get_spell_suggestions($word, $num_results = 10) { - $request = ting_get_request_factory()->getSpellRequest(); - $request->setWord($word); - $request->setNumResults($num_results); - return ting_execute($request); -} diff --git a/ting.test b/ting.test index 0f90065..fc6c77a 100644 --- a/ting.test +++ b/ting.test @@ -18,8 +18,6 @@ class TingEntityTestCase extends DrupalWebTestCase { parent::setUp(array('ding_entity', 'ting', 'nanosoap')); variable_set('ting_agency', '100200'); variable_set('ting_search_url', 'http://opensearch.addi.dk/next_2.0/'); - variable_set('ting_scan_url', 'http://openscan.addi.dk/1.5/'); - variable_set('ting_spell_url', 'http://openspell.addi.dk/1.2/'); variable_set('ting_recommendation_url', 'http://openadhl.addi.dk/1.1/'); variable_set('ting_search_profile', 'opac'); } From 1473c87894886fee01525d0c3cc2c31517bab022 Mon Sep 17 00:00:00 2001 From: JrgenGNielsen Date: Tue, 7 Jul 2015 13:37:34 +0200 Subject: [PATCH 154/167] Issue #28 by JrgenGNielsen: add getURI() and getType() to TingRelation --- ting.entities.inc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ting.entities.inc b/ting.entities.inc index 69d5f76..0041031 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -22,10 +22,17 @@ class TingRelation extends DingEntityBase { } } - public function getObject() { return $this->properties['object']; } + + public function getURI() { + return $this->properties['uri']; + } + + public function getType() { + return $this->properties['type']; + } } /** From 76b2135f3542b8fd11fdfd1c2fe6abb9c18ee8a8 Mon Sep 17 00:00:00 2001 From: JrgenGNielsen Date: Thu, 9 Jul 2015 17:04:26 +0200 Subject: [PATCH 155/167] Issue #429 by JrgenGNielsen: Start catch statement on a new line. --- ting.client.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ting.client.inc b/ting.client.inc index 70e6bc4..8099c2c 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -688,7 +688,8 @@ function ting_execute($request) { } return $response; - } catch (TingClientException $e) { + } + catch (TingClientException $e) { if (isset($e->user_message)) { drupal_set_message($e->user_message, 'warning'); } From 90bbd69ec5ac74678df8c4a823a30f8c25fb95a8 Mon Sep 17 00:00:00 2001 From: JrgenGNielsen Date: Thu, 9 Jul 2015 17:09:14 +0200 Subject: [PATCH 156/167] Issue #429 by JrgenGNielsen: Remode code from Issue #378. --- ting.entities.inc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index 4858f21..b157694 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -317,10 +317,6 @@ class TingEntity extends DingEntity { drupal_alter('ting_online_url', $url, $this); } - if(strpos($url, '[useraccessinfomedia]') === 0){ - drupal_alter('infomedia_url', $url, $this); - } - return $url; } From db546be7bb4f3aa3f7c4872f3bd6c15e72229386 Mon Sep 17 00:00:00 2001 From: JrgenGNielsen Date: Thu, 9 Jul 2015 17:13:35 +0200 Subject: [PATCH 157/167] Issue #429 by JrgenGNielsen: Remove extra newline. --- ting.entities.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/ting.entities.inc b/ting.entities.inc index b157694..69d5f76 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -304,7 +304,6 @@ class TingEntity extends DingEntity { // Give ting_proxy a change to rewrite the url. drupal_alter('ting_online_url', $url, $this); } - } } } From eae1ed58646a1b0f791b2444ec4806eb19f1d33f Mon Sep 17 00:00:00 2001 From: JrgenGNielsen Date: Thu, 9 Jul 2015 17:14:47 +0200 Subject: [PATCH 158/167] Issue #429 by JrgenGNielsen: Remove extra newline. --- ting.client.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/ting.client.inc b/ting.client.inc index 8099c2c..519922a 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -662,7 +662,6 @@ function ting_execute($request) { $request->setParameters($params); } - try { timer_start('ting'); $res = ting_get_client()->execute($request); From cf767fd4ac566df2b71c392b84a47db56504671c Mon Sep 17 00:00:00 2001 From: JrgenGNielsen Date: Fri, 10 Jul 2015 14:02:31 +0200 Subject: [PATCH 159/167] Issue #378 by JrgenGNielsen: Use ting_online_url as alter hook --- ting.entities.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index 69d5f76..d633847 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -300,8 +300,8 @@ class TingEntity extends DingEntity { if ($data->relationType == 'dbcaddi:hasOnlineAccess') { $url = preg_replace('/^\[URL\]/', '', $data->relationUri); // Check for correct url - some uri is only an id. - if (stripos($url, 'http') === 0) { - // Give ting_proxy a change to rewrite the url. + if (stripos($url, 'http') === 0 || strpos($url, '[useraccessinfomedia]') === 0) { + // Give ting_proxy and ting_infomedia a change to rewrite the url. drupal_alter('ting_online_url', $url, $this); } } From 05563045927c1a460ea3fceed8f8e6049cf62000 Mon Sep 17 00:00:00 2001 From: Kasper Garnaes Date: Fri, 10 Jul 2015 16:08:08 +0200 Subject: [PATCH 160/167] Support ting_online_url hook for all leading tokens. #378. --- ting.entities.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index d633847..750a8d8 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -299,9 +299,9 @@ class TingEntity extends DingEntity { foreach ($this->reply->relationsData as $data) { if ($data->relationType == 'dbcaddi:hasOnlineAccess') { $url = preg_replace('/^\[URL\]/', '', $data->relationUri); - // Check for correct url - some uri is only an id. - if (stripos($url, 'http') === 0 || strpos($url, '[useraccessinfomedia]') === 0) { - // Give ting_proxy and ting_infomedia a change to rewrite the url. + // Check for correct url or leading token - some uri is only an id. + if (stripos($url, 'http') === 0 || strpos($url, '[') === 0) { + // Give other modules a chance to rewrite the url. drupal_alter('ting_online_url', $url, $this); } } From 584ba35f6071bf8af50e84b5c332cdabe9fc98ed Mon Sep 17 00:00:00 2001 From: pjohans Date: Wed, 16 Sep 2015 15:45:59 +0200 Subject: [PATCH 161/167] Issue 1392 by Pjohans: Make a checkbox to activate filtering on libraries --- ting.admin.inc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ting.admin.inc b/ting.admin.inc index 035ff2d..567d192 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -35,6 +35,14 @@ function ting_admin_ting_settings($form_state) { '#default_value' => variable_get('ting_search_url', ''), ); + $form['ting']['ting_search_filter_holdingsitem']= array( + '#type' => 'checkbox', + '#title' => t('Filter search queries'), + '#description' => t('Filter searches by holdingsitem.agencyId. Only activate when opensearch uses data-well 3.5, and the provider is fbs'), + '#required' => FALSE, + '#default_value' => variable_get('ting_search_filter_holdingsitem',0), + ); + $form['ting']['ting_recommendation_url'] = array( '#type' => 'textfield', '#title' => t('Recommendation service URL'), From edf82cfef448914293201c66a86cd4e889893853 Mon Sep 17 00:00:00 2001 From: pjohans Date: Tue, 29 Sep 2015 11:18:33 +0200 Subject: [PATCH 162/167] Issue 1392 by Pjohans: fix whitespace --- ting.admin.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.admin.inc b/ting.admin.inc index 567d192..f0d9655 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -40,7 +40,7 @@ function ting_admin_ting_settings($form_state) { '#title' => t('Filter search queries'), '#description' => t('Filter searches by holdingsitem.agencyId. Only activate when opensearch uses data-well 3.5, and the provider is fbs'), '#required' => FALSE, - '#default_value' => variable_get('ting_search_filter_holdingsitem',0), + '#default_value' => variable_get('ting_search_filter_holdingsitem', 0), ); $form['ting']['ting_recommendation_url'] = array( From 0f77b343bfaccab5b68c665b39630deffd866f84 Mon Sep 17 00:00:00 2001 From: pjohans Date: Thu, 1 Oct 2015 12:26:48 +0200 Subject: [PATCH 163/167] Issue 1392 by Pjohans: pass ALL requests through TingSearchCqlDoctor --- ting.client.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ting.client.inc b/ting.client.inc index 519922a..cb538b6 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -226,6 +226,8 @@ function ting_get_objects($ids) { */ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = array()) { $request = ting_get_request_factory()->getSearchRequest(); + + $query = _ting_search_quote($query); $request->setQuery($query); if ($agency = variable_get('ting_agency', FALSE)) { $request->setAgency($agency); From 61d497e8745f9eced2e7303d82e7ea14a59ae15e Mon Sep 17 00:00:00 2001 From: pjohans Date: Thu, 1 Oct 2015 12:33:07 +0200 Subject: [PATCH 164/167] Issue 1392 by Pjohans: Changes due to review --- ting.admin.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ting.admin.inc b/ting.admin.inc index f0d9655..b3a481d 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -37,7 +37,7 @@ function ting_admin_ting_settings($form_state) { $form['ting']['ting_search_filter_holdingsitem']= array( '#type' => 'checkbox', - '#title' => t('Filter search queries'), + '#title' => t('Filter search queries on holdingsItem'), '#description' => t('Filter searches by holdingsitem.agencyId. Only activate when opensearch uses data-well 3.5, and the provider is fbs'), '#required' => FALSE, '#default_value' => variable_get('ting_search_filter_holdingsitem', 0), From 49f40bf2b59c1db1ee83b2612324c1eade02238b Mon Sep 17 00:00:00 2001 From: pjohans Date: Wed, 21 Oct 2015 12:44:41 +0200 Subject: [PATCH 165/167] Issue 1392 by Pjohans: Filter on local holdings if needed --- ting.admin.inc | 4 ++-- ting.client.inc | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ting.admin.inc b/ting.admin.inc index b3a481d..41004b6 100644 --- a/ting.admin.inc +++ b/ting.admin.inc @@ -35,12 +35,12 @@ function ting_admin_ting_settings($form_state) { '#default_value' => variable_get('ting_search_url', ''), ); - $form['ting']['ting_search_filter_holdingsitem']= array( + $form['ting']['ting_filter_by_local_holdings']= array( '#type' => 'checkbox', '#title' => t('Filter search queries on holdingsItem'), '#description' => t('Filter searches by holdingsitem.agencyId. Only activate when opensearch uses data-well 3.5, and the provider is fbs'), '#required' => FALSE, - '#default_value' => variable_get('ting_search_filter_holdingsitem', 0), + '#default_value' => variable_get('ting_filter_by_local_holdings', 0), ); $form['ting']['ting_recommendation_url'] = array( diff --git a/ting.client.inc b/ting.client.inc index cb538b6..c950343 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -228,6 +228,14 @@ function ting_do_search($query, $page = 1, $results_per_page = 10, $options = ar $request = ting_get_request_factory()->getSearchRequest(); $query = _ting_search_quote($query); + + $agency = variable_get('ting_agency', FALSE); + if ($agency && variable_get('ting_filter_by_local_holdings', 0)) { + // Limit the search to materials from the local library. From well 3.5 each + // library is no longer isolated. + $query = $query . '(' . $query . ') and holdingsitem.agencyid="' . $agency . '"'; + } + $request->setQuery($query); if ($agency = variable_get('ting_agency', FALSE)) { $request->setAgency($agency); From bc9ee55caa9eb106b62ed31e1fbd9b8233bfe360 Mon Sep 17 00:00:00 2001 From: Kasper Garnaes Date: Thu, 22 Oct 2015 09:02:42 +0200 Subject: [PATCH 166/167] Issue 1392 by kasperg: Do not quote query before performing search. Queries should already be quoted at this point. Programmatically generated queries should be quoted by the issuer. Calling code with user generated queries should ensure that the query is correctly quoted. Keeping this also creates a dependency to ting_search since this the module containing _ting_seach_quote(). --- ting.client.inc | 2 -- 1 file changed, 2 deletions(-) diff --git a/ting.client.inc b/ting.client.inc index c950343..dd40fe6 100644 --- a/ting.client.inc +++ b/ting.client.inc @@ -227,8 +227,6 @@ function ting_get_objects($ids) { function ting_do_search($query, $page = 1, $results_per_page = 10, $options = array()) { $request = ting_get_request_factory()->getSearchRequest(); - $query = _ting_search_quote($query); - $agency = variable_get('ting_agency', FALSE); if ($agency && variable_get('ting_filter_by_local_holdings', 0)) { // Limit the search to materials from the local library. From well 3.5 each From 8c62984e811fd868af941ab57377bdc2bd565c3a Mon Sep 17 00:00:00 2001 From: Thomas Fini Hansen Date: Thu, 22 Oct 2015 13:10:55 +0200 Subject: [PATCH 167/167] Issue #1408 by xendk: Only show normal title on collections. --- ting.entities.inc | 21 ++++++--------------- ting.field.inc | 23 ++++++++++++++++------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ting.entities.inc b/ting.entities.inc index a3d310c..f71da6b 100644 --- a/ting.entities.inc +++ b/ting.entities.inc @@ -159,7 +159,7 @@ class TingEntity extends DingEntity { } return trim($serie[0]); } - + function getSerieDescription() { $serie = !empty($this->reply->record['dc:description']['dkdcplus:series'][0]) ? $this->reply->record['dc:description']['dkdcplus:series'][0] : ''; return $this->process_series_description($serie); @@ -374,25 +374,17 @@ class TingCollection extends DingEntityCollection { function getTitle() { foreach ($this->reply->objects as &$object) { - // Find the title of the object that was used to fetch this collection. + // Find the title of the object that was used to fetch this collection. We + // don't look at dkdcplus:full as it might be too specific ("1Q84. Book 1" + // for instance). if ($object->id == $this->ding_entity_id && !empty($object->record['dc:title'])) { - if (isset($object->record['dc:title']['dkdcplus:full'])) { - return $object->record['dc:title']['dkdcplus:full'][0]; - } - else { - return $object->record['dc:title'][''][0]; - } + return $object->record['dc:title'][''][0]; } } // If we couldn't find the object, use the title of the first object. $title = FALSE; if (isset($this->reply->objects[0]->record['dc:title'])) { - if (isset($this->reply->objects[0]->record['dc:title']['dkdcplus:full'])) { - $title = $this->reply->objects[0]->record['dc:title']['dkdcplus:full'][''][0]; - } - else { - $title = $this->reply->objects[0]->record['dc:title'][''][0]; - } + $title = $this->reply->objects[0]->record['dc:title'][''][0]; } return $title; } @@ -453,4 +445,3 @@ class TingCollection extends DingEntityCollection { } } } - diff --git a/ting.field.inc b/ting.field.inc index 0e107fa..679c4b6 100644 --- a/ting.field.inc +++ b/ting.field.inc @@ -321,21 +321,30 @@ function ting_field_formatter_view($entity_type, $entity, $field, $instance, $la if ($display['settings']['link_type'] == 'collection') { $type = 'ting_collection'; } + + $link = FALSE; + $title = $entity->title; // Only create the link if the object is available in the data well. if ($display['settings']['link_type'] != 'none' && !isset($entity->is_available)) { - $url = entity_uri($type, $entity); - $title = l($entity->title, $url['path'], $url['options']); - } - else { - $title = check_plain($entity->title); + $link = TRUE; } // Check if element should be prefixed with type. if ($display['settings']['prefix_type'] == 'yes') { - $collction = ting_collection_load($entity->id); + $collection = ting_collection_load($entity->id); $ting_type = $entity->getType(); - if (count($collction->types) > 1) { + if (count($collection->types) > 1) { $ting_type = t('Material collection'); + // Replace title with the more generic collection title. + $title = $collection->title; + } + + if ($link) { + $url = entity_uri($type, $entity); + $title = l($title, $url['path'], $url['options']); + } + else { + $title = check_plain($title); } $element[$delta] = array(