From c4fd86c70c2427f49d35d88e7af3d86458bdd0b1 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Mon, 14 Oct 2019 12:18:56 -0300 Subject: [PATCH 01/85] Numeric filter update and tripple check for filter value. --- src/classes/filter-types/numeric/Numeric.vue | 9 +++++++-- src/classes/filter-types/tainacan-filter-item.vue | 2 +- src/js/event-bus-search.js | 8 +++++--- src/js/store/modules/search/actions.js | 3 ++- src/js/store/modules/search/mutations.js | 6 ++++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/classes/filter-types/numeric/Numeric.vue b/src/classes/filter-types/numeric/Numeric.vue index 8c84e7e53..92e2a6e13 100644 --- a/src/classes/filter-types/numeric/Numeric.vue +++ b/src/classes/filter-types/numeric/Numeric.vue @@ -101,6 +101,11 @@ } } }, + watch: { + 'query.metaquery'() { + this.selectedValues(); + } + }, methods: { selectedValues(){ if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) ) @@ -121,7 +126,7 @@ this.$emit('sendValuesToTags', { label: this.comparator + ' ' + this.value, value: this.value }); } else { - return false; + this.value = null; } }, @@ -130,7 +135,7 @@ if ( this.value === null || this.value === '') return; - + this.$emit('input', { filter: 'numeric', compare: this.comparator, diff --git a/src/classes/filter-types/tainacan-filter-item.vue b/src/classes/filter-types/tainacan-filter-item.vue index a6135f2e3..9be48ce58 100644 --- a/src/classes/filter-types/tainacan-filter-item.vue +++ b/src/classes/filter-types/tainacan-filter-item.vue @@ -72,7 +72,7 @@ this.$eventBusSearch.$on('hasFiltered', this.reloadFilter); }, methods: { - onInput(inputEvent){ + onInput(inputEvent) { this.$eventBusSearch.$emit('input', inputEvent); }, onSendValuesToTags($event) { diff --git a/src/js/event-bus-search.js b/src/js/event-bus-search.js index 80d4b07ed..abf9f9e9c 100644 --- a/src/js/event-bus-search.js +++ b/src/js/event-bus-search.js @@ -16,7 +16,7 @@ export default { }, created() { this.$on('input', data => { - console.log("inputei") + this.$store.dispatch('search/setPage', 1); if (data.taxonomy) this.addTaxquery(data); @@ -187,7 +187,7 @@ export default { if (filterTag.singleLabel != undefined || filterTag.label != undefined) { - if (filterTag.taxonomy) + if (filterTag.taxonomy) { this.$store.dispatch('search/remove_taxquery', { filterId: filterTag.filterId, label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label, @@ -195,7 +195,7 @@ export default { taxonomy: filterTag.taxonomy, value: filterTag.value }); - else + } else { this.$store.dispatch('search/remove_metaquery', { filterId: filterTag.filterId, label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label, @@ -203,6 +203,8 @@ export default { metadatum_id: filterTag.metadatumId, value: filterTag.value }); + } + this.$store.dispatch('search/removeFilterTag', filterTag); } this.updateURLQueries(); }, diff --git a/src/js/store/modules/search/actions.js b/src/js/store/modules/search/actions.js index 696604e5c..8acb7b7aa 100644 --- a/src/js/store/modules/search/actions.js +++ b/src/js/store/modules/search/actions.js @@ -14,7 +14,8 @@ export const set_advanced_query = ({commit}, advancedSearchQuery) => { // Meta Queries from filters export const add_metaquery = ( { commit }, filter ) => { - if (filter && (filter.value == undefined || filter.value == null || filter.value.length === 0 || filter.value == '')) { + console.log(filter) + if (filter && (filter.value === undefined || filter.value === null || filter.value.length === 0 || filter.value === '')) { commit('removeMetaQuery', filter ); } else { commit('addMetaQuery', filter ); diff --git a/src/js/store/modules/search/mutations.js b/src/js/store/modules/search/mutations.js index 69fceb5fd..892907ae4 100644 --- a/src/js/store/modules/search/mutations.js +++ b/src/js/store/modules/search/mutations.js @@ -22,7 +22,6 @@ export const addMetaQuery = ( state, filter ) => { state.postquery.metaquery = ( ! state.postquery.metaquery || state.postquery.metaquery.length == undefined ) ? [] : state.postquery.metaquery; let index = state.postquery.metaquery.findIndex( item => item.key === filter.metadatum_id); - if ( index >= 0 ){ Vue.set( state.postquery.metaquery, index, { key: filter.metadatum_id, @@ -37,6 +36,7 @@ export const addMetaQuery = ( state, filter ) => { compare: filter.compare, type: filter.type }); + console.log(state.postquery.metaquery); } }; @@ -94,6 +94,7 @@ export const removeMetaQuery = ( state, filter ) => { state.postquery.metaquery = ( ! state.postquery.metaquery ) ? [] : state.postquery.metaquery; let index = state.postquery.metaquery.findIndex( item => item.key == filter.metadatum_id); + if (index >= 0) { if (!filter.isMultiValue && Array.isArray(state.postquery.metaquery[index].value) && state.postquery.metaquery[index].value.length > 1) { let otherIndex = state.postquery.metaquery[index].value.findIndex(item => item == filter.value); @@ -158,8 +159,9 @@ export const setOrderByName = ( state, orderByName ) => { }; export const addFilterTag = ( state, filterTag ) => { - state.filter_tags = ( ! state.filter_tags) ? [] : state.filter_tags; + state.filter_tags = ( ! state.filter_tags) ? [] : state.filter_tags; let index = state.filter_tags.findIndex( tag => tag.filterId == filterTag.filterId); + if (index >= 0) Vue.set(state.filter_tags, index, filterTag); else From f5d8d2c80aee721eaadfdd1e60cfd9d2f2b87225 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Mon, 14 Oct 2019 12:39:14 -0300 Subject: [PATCH 02/85] Updates on Numeric Interval Filter. --- .../numeric-interval/NumericInterval.vue | 42 ++++++++++++++----- src/js/store/modules/search/actions.js | 1 - 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/classes/filter-types/numeric-interval/NumericInterval.vue b/src/classes/filter-types/numeric-interval/NumericInterval.vue index d0f8527a1..136bb096d 100644 --- a/src/classes/filter-types/numeric-interval/NumericInterval.vue +++ b/src/classes/filter-types/numeric-interval/NumericInterval.vue @@ -24,8 +24,8 @@ mixins: [ filterTypeMixin ], data(){ return { - valueInit: 0, - valueEnd: 10, + valueInit: null, + valueEnd: null, isValid: false, withError: false } @@ -33,15 +33,34 @@ mounted() { this.selectedValues(); }, + watch: { + 'query.metaquery'() { + this.selectedValues(); + } + }, methods: { // only validate if the first value is higher than first - validate_values: _.debounce( function (){ - if ( parseFloat( this.valueInit ) > parseFloat( this.valueEnd )) { - //this.valueEnd = parseFloat( this.valueInit ) + 1; - //this.withError = true; - + validate_values: _.debounce( function () { + if (this.valueInit == null || this.valueEnd == null) + return + + if (this.valueInit.constructor == Number) + this.valueInit = this.valueInit.valueOf(); + + if (this.valueEnd.constructor == Number) + this.valueEnd = this.valueEnd.valueOf(); + + this.valueInit = parseFloat(this.valueInit); + this.valueEnd = parseFloat(this.valueEnd); + + if (isNaN(this.valueInit) || isNaN(this.valueEnd)) + return + + if (this.valueInit > this.valueEnd) { + this.error_message(); return; } + //this.withError = false; this.emit(); }, 600), @@ -79,15 +98,16 @@ if ( index >= 0 ){ let metaquery = this.query.metaquery[ index ]; if ( metaquery.value && metaquery.value.length > 1 ) { - this.valueInit = metaquery.value[0]; - this.valueEnd = metaquery.value[1]; + this.valueInit = new Number(metaquery.value[0]); + this.valueEnd = new Number(metaquery.value[1]); } if (metaquery.value[0] != undefined && metaquery.value[1] != undefined) - this.$emit('sendValuesToTags', { label: this.valueInit + ' - ' + this.valueEnd, value: metaquery.values }); + this.$emit('sendValuesToTags', { label: this.valueInit + ' - ' + this.valueEnd, value: metaquery.value }); } else { - return false; + this.valueInit = null; + this.valueEnd = null; } }, } diff --git a/src/js/store/modules/search/actions.js b/src/js/store/modules/search/actions.js index 8acb7b7aa..497a07a7c 100644 --- a/src/js/store/modules/search/actions.js +++ b/src/js/store/modules/search/actions.js @@ -14,7 +14,6 @@ export const set_advanced_query = ({commit}, advancedSearchQuery) => { // Meta Queries from filters export const add_metaquery = ( { commit }, filter ) => { - console.log(filter) if (filter && (filter.value === undefined || filter.value === null || filter.value.length === 0 || filter.value === '')) { commit('removeMetaQuery', filter ); } else { From 3438dab8615b79c47e2d2ad92a252d76897e3ba9 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Mon, 14 Oct 2019 14:54:04 -0300 Subject: [PATCH 03/85] Updates on numeric interval list filter. --- src/admin/tainacan-admin-i18n.php | 1 + .../NumericListInterval.vue | 22 +++++++++++++------ src/js/store/modules/search/actions.js | 9 +++++--- src/js/store/modules/search/mutations.js | 2 +- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/admin/tainacan-admin-i18n.php b/src/admin/tainacan-admin-i18n.php index b2741f7fb..ed8cf711e 100644 --- a/src/admin/tainacan-admin-i18n.php +++ b/src/admin/tainacan-admin-i18n.php @@ -135,6 +135,7 @@ return apply_filters( 'tainacan-admin-i18n', [ // Labels (used mainly on Aria Labels and Inputs) 'label' => __( 'label', 'tainacan' ), 'label_clean' => __( 'Clear', 'tainacan' ), + 'label_none' => __( 'None', 'tainacan' ), 'label_clear_filters' => __( 'Clear filters', 'tainacan' ), 'label_and' => __( 'and', 'tainacan' ), 'label_selected' => __( 'Selected', 'tainacan' ), diff --git a/src/classes/filter-types/numeric-list-interval/NumericListInterval.vue b/src/classes/filter-types/numeric-list-interval/NumericListInterval.vue index 5e4930c8f..5017c1f37 100644 --- a/src/classes/filter-types/numeric-list-interval/NumericListInterval.vue +++ b/src/classes/filter-types/numeric-list-interval/NumericListInterval.vue @@ -1,11 +1,12 @@ diff --git a/src/admin/pages/home-page.vue b/src/admin/pages/home-page.vue index 98314670d..a1d43d274 100644 --- a/src/admin/pages/home-page.vue +++ b/src/admin/pages/home-page.vue @@ -140,7 +140,7 @@ {{ $i18n.getWithVariables('label_view_all_%s_collections', [collectionsTotal]) }} {{ $i18n.get('label_view_collections_list') }} diff --git a/src/admin/pages/lists/items-page.vue b/src/admin/pages/lists/items-page.vue index 2a0db1b5a..0a0459615 100644 --- a/src/admin/pages/lists/items-page.vue +++ b/src/admin/pages/lists/items-page.vue @@ -791,13 +791,20 @@

{{ $i18n.getFrom('items', 'add_new') }} + diff --git a/src/admin/tainacan-admin-i18n.php b/src/admin/tainacan-admin-i18n.php index 1035792a0..a63454c57 100644 --- a/src/admin/tainacan-admin-i18n.php +++ b/src/admin/tainacan-admin-i18n.php @@ -533,7 +533,7 @@ return apply_filters( 'tainacan-admin-i18n', [ 'info_no_terms_created_on_taxonomy' => __( 'No term was created for this taxonomy.', 'tainacan' ), 'info_no_terms_found' => __( 'No term was found here', 'tainacan' ), 'info_no_more_terms_found' => __( 'No more terms found', 'tainacan' ), - 'info_no_item_created' => __( 'No item was created in this collection.', 'tainacan' ), + 'info_no_item_created' => __( 'No item was created so far.', 'tainacan' ), 'info_no_page_found' => __( 'No page was found with this name.', 'tainacan' ), 'info_no_user_found' => __( 'No user was found with this name.', 'tainacan' ), 'info_no_item_found_filter' => __( 'No item was found here with these filters.', 'tainacan' ), @@ -583,7 +583,7 @@ return apply_filters( 'tainacan-admin-i18n', [ 'info_warning_taxonomy_not_saved' => __( 'Are you sure? The taxonomy is not saved, changes will be lost.', 'tainacan' ), 'info_warning_terms_not_saved' => __( 'Are you sure? There are terms not saved, changes will be lost.', 'tainacan' ), 'info_warning_orphan_terms' => __( 'Are you sure? This term is parent of other terms. These will be converted to root terms.', 'tainacan' ), - 'info_no_activities' => __( 'No activities', 'tainacan' ), + 'info_no_activities' => __( 'No activities yet.', 'tainacan' ), 'info_logs_before' => __( 'Before', 'tainacan' ), 'info_logs_after' => __( 'After', 'tainacan' ), 'info_there_is_no_metadatum' => __( 'There is no metadata here yet.', 'tainacan' ), From 21d5f9ed58033ff960df1bfeb31abb21fc0a567a Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Thu, 24 Oct 2019 16:00:11 -0300 Subject: [PATCH 70/85] fix name of class on catch --- .../relationship/class-tainacan-relationship.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/classes/metadata-types/relationship/class-tainacan-relationship.php b/src/classes/metadata-types/relationship/class-tainacan-relationship.php index 83b87b1b9..698d5d88a 100644 --- a/src/classes/metadata-types/relationship/class-tainacan-relationship.php +++ b/src/classes/metadata-types/relationship/class-tainacan-relationship.php @@ -148,8 +148,8 @@ class Relationship extends Metadata_Type { } - } catch (Exception $e) { - // item not found + } catch (\Exception $e) { + // item not found } } @@ -164,7 +164,7 @@ class Relationship extends Metadata_Type { $return .= $this->get_item_html($item); } - } catch (Exception $e) { + } catch (\Exception $e) { // item not found } From f494a0dc11c4372bb57b24a12ebfa0ce4f56a55d Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Wed, 23 Oct 2019 16:48:51 -0300 Subject: [PATCH 71/85] add test for object post type of the taxonomies --- tests/test-taxonomies.php | 167 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/tests/test-taxonomies.php b/tests/test-taxonomies.php index 6d13b6070..164e6b186 100644 --- a/tests/test-taxonomies.php +++ b/tests/test-taxonomies.php @@ -416,4 +416,171 @@ class Taxonomies extends TAINACAN_UnitTestCase { } + function test_metadata_taxonomy_term_count() { + $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); + $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); + + $collection_1 = $this->tainacan_entity_factory->create_entity( + 'collection', + array( 'name' => 'test-1' ), + true + ); + + $collection_2 = $this->tainacan_entity_factory->create_entity( + 'collection', + array( 'name' => 'test-2' ), + true + ); + + $tax = $this->tainacan_entity_factory->create_entity( + 'taxonomy', + array( + 'name' => 'tax_test', + 'status' => 'publish', + 'enabled_post_types' => [$collection_1->get_db_identifier(), $collection_2->get_db_identifier()] + ), + true + ); + + $tax_repository = $this->tainacan_entity_factory->create_entity( + 'taxonomy', + array( + 'name' => 'tax_test_repository', + 'status' => 'publish' + ), + true + ); + + $t1 = $this->tainacan_entity_factory->create_entity( + 'term', + array( + 'taxonomy' => $tax->get_db_identifier(), + 'name' => 'term', + 'user' => get_current_user_id(), + ), + true + ); + + $t2 = $this->tainacan_entity_factory->create_entity( + 'term', + array( + 'taxonomy' => $tax_repository->get_db_identifier(), + 'name' => 'term_repository' + ), + true + ); + + $metadatum_1 = $this->tainacan_entity_factory->create_entity( + 'metadatum', + array( + 'name' => 'meta-1', + 'description' => 'description-1', + 'collection' => $collection_1, + 'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy', + 'status' => 'publish', + 'metadata_type_options' => [ + 'taxonomy_id' => $tax->get_id(), + 'allow_new_terms' => 'no' + ] + ), + true + ); + + $metadatum_2 = $this->tainacan_entity_factory->create_entity( + 'metadatum', + array( + 'name' => 'meta-2', + 'description' => 'description-2', + 'collection' => $collection_2, + 'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy', + 'status' => 'publish', + 'metadata_type_options' => [ + 'taxonomy_id' => $tax->get_id(), + 'allow_new_terms' => 'no' + ] + ), + true + ); + + $metadatum_repository = $this->tainacan_entity_factory->create_entity( + 'metadatum', + array( + 'name' => 'meta-1', + 'description' => 'description-1', + 'collection_id' => $Tainacan_Metadata->get_default_metadata_attribute(), + 'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy', + 'status' => 'publish', + 'metadata_type_options' => [ + 'taxonomy_id' => $tax_repository->get_id(), + 'allow_new_terms' => 'no' + ] + ), + true + ); + + $i1 = $this->tainacan_entity_factory->create_entity( + 'item', + array( + 'title' => 'item teste', + 'description' => 'adasdasdsa', + 'collection' => $collection_1 + ), + true + ); + $itemMeta1 = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum_1); + $itemMeta1->set_value('term'); + $itemMeta1->validate(); + $Tainacan_Item_Metadata->insert($itemMeta1); + + $itemMeta1_repo = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum_repository); + $itemMeta1_repo->set_value('term_repository'); + $itemMeta1_repo->validate(); + $Tainacan_Item_Metadata->insert($itemMeta1_repo); + + + $i2 = $this->tainacan_entity_factory->create_entity( + 'item', + array( + 'title' => 'item teste', + 'description' => 'adasdasdsa', + 'collection' => $collection_2 + ), + true + ); + $itemMeta2 = new \Tainacan\Entities\Item_Metadata_Entity($i2, $metadatum_2); + $itemMeta2->set_value('term'); + $itemMeta2->validate(); + $Tainacan_Item_Metadata->insert($itemMeta2); + + $itemMeta2_repo = new \Tainacan\Entities\Item_Metadata_Entity($i2, $metadatum_repository); + $itemMeta2_repo->set_value('term_repository'); + $itemMeta2_repo->validate(); + $Tainacan_Item_Metadata->insert($itemMeta2_repo); + + $terms = get_terms([ + 'taxonomy' => $tax->get_db_identifier(), + //'hide_empty' => false, + ]); + $this->assertEquals(1, count($terms)); + + wp_update_term_count($t1->get_term_id(), $tax->get_db_identifier()); + wp_update_term_count($t2->get_term_id(), $tax_repository->get_db_identifier()); + + $term = get_term($t1->get_term_id()); + $term_repo = get_term($t2->get_term_id()); + $tax_used = get_object_taxonomies( [$collection_1->get_db_identifier(), $collection_2->get_db_identifier()]); + + $tax = get_taxonomy($tax->get_db_identifier()); + $tax_repository = get_taxonomy($tax_repository->get_db_identifier()); + + $this->assertContains($collection_1->get_db_identifier(), $tax->object_type); + $this->assertContains($collection_2->get_db_identifier(), $tax->object_type); + + $this->assertContains($collection_1->get_db_identifier(), $tax_repository->object_type); + $this->assertContains($collection_2->get_db_identifier(), $tax_repository->object_type); + + $this->assertEquals(2, $term->count); + $this->assertEquals(2, $term_repo->count); + } + } \ No newline at end of file From 678f69f26a09a0d4dc68cbd421eeaf0b161417a9 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Wed, 23 Oct 2019 16:55:27 -0300 Subject: [PATCH 72/85] remove `enabled_post_types` on declared taxonomy. --- tests/test-taxonomies.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-taxonomies.php b/tests/test-taxonomies.php index 164e6b186..8c2db54d2 100644 --- a/tests/test-taxonomies.php +++ b/tests/test-taxonomies.php @@ -437,7 +437,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { array( 'name' => 'tax_test', 'status' => 'publish', - 'enabled_post_types' => [$collection_1->get_db_identifier(), $collection_2->get_db_identifier()] + //'enabled_post_types' => [$collection_1->get_db_identifier(), $collection_2->get_db_identifier()] ), true ); From 56b9e76aa16dece7fc5e215ea100b26933cac4e7 Mon Sep 17 00:00:00 2001 From: leogermani Date: Wed, 23 Oct 2019 20:08:00 -0300 Subject: [PATCH 73/85] Make WP update terms count for all items #318 --- .../entities/class-tainacan-taxonomy.php | 53 +++--- tests/test-taxonomies.php | 176 +++++++++--------- 2 files changed, 116 insertions(+), 113 deletions(-) diff --git a/src/classes/entities/class-tainacan-taxonomy.php b/src/classes/entities/class-tainacan-taxonomy.php index af5c94265..dd11af5d2 100644 --- a/src/classes/entities/class-tainacan-taxonomy.php +++ b/src/classes/entities/class-tainacan-taxonomy.php @@ -22,28 +22,28 @@ class Taxonomy extends Entity { * @var string */ static $post_type = 'tainacan-taxonomy'; - + /** * {@inheritDoc} * @see \Tainacan\Entities\Entity::capability_type * @var string */ protected static $capability_type = ['tainacan-taxonomy', 'tainacan-taxonomies']; - + /** * {@inheritDoc} * @see \Tainacan\Entities\Entity::repository * @var string */ protected $repository = 'Taxonomies'; - + /** * Prefix used to create the db_identifier * * @var string */ static $db_identifier_prefix = 'tnc_tax_'; - + public function __toString(){ return apply_filters("tainacan-taxonomy-to-string", $this->get_name(), $this); } @@ -67,7 +67,7 @@ class Taxonomy extends Entity { 'new_item_name' => __( 'New Genre term', 'tainacan' ), 'menu_name' => $this->get_name(), ); - + $enabled_post_types = $this->get_enabled_post_types(); $enabled_post_types = sizeof($enabled_post_types) ? $enabled_post_types : null; $show_ui = is_array($enabled_post_types) ? true : false; @@ -80,21 +80,22 @@ class Taxonomy extends Entity { 'show_admin_column' => false, 'rewrite' => [ 'slug' => $this->get_slug() - ], + ], + 'update_count_callback' => '_update_generic_term_count' ); - + if (taxonomy_exists($this->get_db_identifier())){ unregister_taxonomy($this->get_db_identifier()); } - - - - register_taxonomy( - $this->get_db_identifier(), - $enabled_post_types, - $args + + + + register_taxonomy( + $this->get_db_identifier(), + $enabled_post_types, + $args ); - + return true; } @@ -135,7 +136,7 @@ class Taxonomy extends Entity { function get_slug() { return $this->get_mapped_property('slug'); } - + /** * Return the enabled post types * @@ -144,7 +145,7 @@ class Taxonomy extends Entity { function get_enabled_post_types() { return $this->get_mapped_property('enabled_post_types'); } - + // special Getters /** @@ -194,7 +195,7 @@ class Taxonomy extends Entity { function set_allow_insert($value) { $this->set_mapped_property('allow_insert', $value); } - + /** * Sets enabled post types * @@ -221,19 +222,19 @@ class Taxonomy extends Entity { return parent::validate(); } - + /** - * Check if a term already exists + * Check if a term already exists * - * @param string $term_name The term name - * @param int|null $parent The ID of the parent term to look for children or null to look for terms in any hierarchical position. Default is null - * @param bool $return_term wether to return the term object if it exists. default is to false - * - * @return bool|WP_Term return boolean indicating if term exists. If $return_term is true and term exists, return WP_Term object + * @param string $term_name The term name + * @param int|null $parent The ID of the parent term to look for children or null to look for terms in any hierarchical position. Default is null + * @param bool $return_term wether to return the term object if it exists. default is to false + * + * @return bool|WP_Term return boolean indicating if term exists. If $return_term is true and term exists, return WP_Term object */ function term_exists($term_name, $parent = null, $return_term = false) { $repo = $this->get_repository(); return $repo->term_exists($this, $term_name, $parent, $return_term); } -} \ No newline at end of file +} diff --git a/tests/test-taxonomies.php b/tests/test-taxonomies.php index 8c2db54d2..e30d6a5d7 100644 --- a/tests/test-taxonomies.php +++ b/tests/test-taxonomies.php @@ -69,9 +69,9 @@ class Taxonomies extends TAINACAN_UnitTestCase { $this->assertEquals( $test->get_name(), 'Rock' ); $this->assertEquals( $test->get_user(), 56 ); } - + function test_terms_of_draft_taxonomy() { - + $taxonomy = $this->tainacan_entity_factory->create_entity( 'taxonomy', array( @@ -82,14 +82,14 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance(); $terms = $Tainacan_Terms->fetch(['hide_empty' => false], $taxonomy->get_id()); - + $this->assertEquals(0, sizeof($terms), 'new auto draft taxonomy should return 0 terms'); - + $term = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -98,17 +98,17 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - - - + + + $terms = $Tainacan_Terms->fetch(['hide_empty' => false], $taxonomy->get_id()); - + $this->assertEquals(1, sizeof($terms), 'you should be able to create a term even if the taxonomy is still auto-draft'); - + } - + function test_term_exists() { - + $taxonomy = $this->tainacan_entity_factory->create_entity( 'taxonomy', array( @@ -119,10 +119,10 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance(); - + $term = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -131,7 +131,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $parent = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -140,7 +140,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $child = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -150,14 +150,14 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $this->assertFalse( $Tainacan_Terms->term_exists('Reggae', $taxonomy->get_db_identifier()) ); $this->assertTrue( $Tainacan_Terms->term_exists('Rock', $taxonomy->get_db_identifier()) ); - + //var_dump( $Tainacan_Terms->term_exists('Rock', $taxonomy->get_db_identifier(), 0, true) ); - - // test extreme case - + + // test extreme case + $term_2 = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -167,49 +167,49 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $this->assertFalse( $Tainacan_Terms->term_exists('test 123', $taxonomy->get_db_identifier(), 0) ); // parent 0 $this->assertTrue( $Tainacan_Terms->term_exists('test 123', $taxonomy->get_db_identifier(), $term->get_id()) ); // spaces in between - - // testing passing taxonomy object + + // testing passing taxonomy object $this->assertTrue( $Tainacan_Terms->term_exists('Rock', $taxonomy) ); - + // testing passing taxonomy ID $this->assertTrue( $Tainacan_Terms->term_exists('Rock', $taxonomy->get_id()) ); - + // testing via Taxonomy object $this->assertTrue( $taxonomy->term_exists('Rock') ); - - // testing retrieving the term + + // testing retrieving the term $this->assertTrue( $taxonomy->term_exists('Rock', 0, true) instanceof \WP_Term ); $this->assertEquals( $term->get_id(), $taxonomy->term_exists('Rock', 0, true)->term_taxonomy_id ); - - // test parent + + // test parent $this->assertTrue( $Tainacan_Terms->term_exists('Child', $taxonomy->get_db_identifier()) ); // parent null $this->assertFalse( $Tainacan_Terms->term_exists('Child', $taxonomy->get_db_identifier(), 0) ); // parent 0 - $this->assertTrue( $Tainacan_Terms->term_exists('Child', $taxonomy->get_db_identifier(), $parent->get_id()) ); // parent - - // test with ID + $this->assertTrue( $Tainacan_Terms->term_exists('Child', $taxonomy->get_db_identifier(), $parent->get_id()) ); // parent + + // test with ID $this->assertTrue( $Tainacan_Terms->term_exists($term->get_id(), $taxonomy->get_id()) ); - - // test get term + + // test get term $test_term = $Tainacan_Terms->term_exists($term->get_id(), $taxonomy->get_id(), null, true); $this->assertEquals($term->get_id(), $test_term->term_id); - + $test_term = $Tainacan_Terms->term_exists('Rock', $taxonomy->get_id(), null, true); $this->assertEquals($term->get_id(), $test_term->term_id); - + $test_term = $Tainacan_Terms->term_exists('Parent', $taxonomy->get_id(), null, true); $this->assertEquals($parent->get_id(), $test_term->term_id); - + // test brackets $test_term = $Tainacan_Terms->term_exists('[Rock]', $taxonomy->get_id(), null, true); $this->assertFalse($test_term); - + } - + function test_term_validation() { - + $taxonomy = $this->tainacan_entity_factory->create_entity( 'taxonomy', array( @@ -220,10 +220,10 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance(); - + $term = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -232,7 +232,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $parent = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -241,7 +241,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $child = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -251,27 +251,27 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $newTerm = new \Tainacan\Entities\Term(); $newTerm->set_name('Child'); $newTerm->set_taxonomy($taxonomy->get_db_identifier()); - + $this->assertTrue( $newTerm->validate() ); - + $newTerm->set_parent($parent->get_id()); - + $this->assertFalse( $newTerm->validate(), 'term should not validate because it has a duplicate in the same level' ); - + $child->set_description('changed'); - + $this->assertTrue( $child->validate(), 'child should validate'); - - - + + + } - + /** - * @group enabled + * @group enabled */ function test_enabled_post_types(){ $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); @@ -287,15 +287,15 @@ class Taxonomies extends TAINACAN_UnitTestCase { ); $taxonomy = $Tainacan_Taxonomies->insert($taxonomy); - + $pto = get_object_taxonomies('post'); $pages = get_object_taxonomies('page'); $this->assertContains($taxonomy->get_db_identifier(), $pto); $this->assertNotContains($taxonomy->get_db_identifier(), $pages); } - + function test_brackets() { - + $taxonomy = $this->tainacan_entity_factory->create_entity( 'taxonomy', array( @@ -306,10 +306,10 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance(); - + $term = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -318,7 +318,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $term2 = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -327,16 +327,16 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $terms = $Tainacan_Terms->fetch(['hide_empty' => false], $taxonomy); $this->assertEquals(2, sizeof($terms)); - + } - + function test_brackets_2() { - + $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); - + $collection = $this->tainacan_entity_factory->create_entity( 'collection', array( @@ -345,7 +345,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $taxonomy = $this->tainacan_entity_factory->create_entity( 'taxonomy', array( @@ -381,7 +381,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $i2 = $this->tainacan_entity_factory->create_entity( 'item', array( @@ -391,44 +391,44 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $itemMeta1 = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum); $itemMeta1->set_value('Rock'); $itemMeta1->validate(); $Tainacan_Item_Metadata->insert($itemMeta1); - + //$this->assertNotFalse(term_exists( 'Rock', $taxonomy->get_db_identifier() )); // term_exists() is not to be trusted //$this->assertFalse(term_exists( '[Rock]', $taxonomy->get_db_identifier() )); - + $itemMeta2 = new \Tainacan\Entities\Item_Metadata_Entity($i2, $metadatum); $itemMeta2->set_value('[Rock]'); $itemMeta2->validate(); $Tainacan_Item_Metadata->insert($itemMeta2); - + $itemMeta1_check = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum); $this->assertEquals('Rock', $itemMeta1_check->get_value()->get_name()); - + $itemMeta2_check = new \Tainacan\Entities\Item_Metadata_Entity($i2, $metadatum); $this->assertEquals('[Rock]', $itemMeta2_check->get_value()->get_name()); - - - + + + } - + function test_metadata_taxonomy_term_count() { $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); $collection_1 = $this->tainacan_entity_factory->create_entity( 'collection', - array( 'name' => 'test-1' ), + array( 'name' => 'test-1', 'status' => 'publish', ), true ); $collection_2 = $this->tainacan_entity_factory->create_entity( 'collection', - array( 'name' => 'test-2' ), + array( 'name' => 'test-2', 'status' => 'publish', ), true ); @@ -469,7 +469,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $metadatum_1 = $this->tainacan_entity_factory->create_entity( 'metadatum', array( @@ -523,7 +523,8 @@ class Taxonomies extends TAINACAN_UnitTestCase { array( 'title' => 'item teste', 'description' => 'adasdasdsa', - 'collection' => $collection_1 + 'collection' => $collection_1, + 'status' => 'publish' ), true ); @@ -531,7 +532,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { $itemMeta1->set_value('term'); $itemMeta1->validate(); $Tainacan_Item_Metadata->insert($itemMeta1); - + $itemMeta1_repo = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum_repository); $itemMeta1_repo->set_value('term_repository'); $itemMeta1_repo->validate(); @@ -543,7 +544,8 @@ class Taxonomies extends TAINACAN_UnitTestCase { array( 'title' => 'item teste', 'description' => 'adasdasdsa', - 'collection' => $collection_2 + 'collection' => $collection_2, + 'status' => 'private' ), true ); @@ -564,12 +566,12 @@ class Taxonomies extends TAINACAN_UnitTestCase { $this->assertEquals(1, count($terms)); wp_update_term_count($t1->get_term_id(), $tax->get_db_identifier()); - wp_update_term_count($t2->get_term_id(), $tax_repository->get_db_identifier()); + wp_update_term_count($t2->get_term_id(), $tax_repository->get_db_identifier()); $term = get_term($t1->get_term_id()); $term_repo = get_term($t2->get_term_id()); $tax_used = get_object_taxonomies( [$collection_1->get_db_identifier(), $collection_2->get_db_identifier()]); - + $tax = get_taxonomy($tax->get_db_identifier()); $tax_repository = get_taxonomy($tax_repository->get_db_identifier()); @@ -583,4 +585,4 @@ class Taxonomies extends TAINACAN_UnitTestCase { $this->assertEquals(2, $term_repo->count); } -} \ No newline at end of file +} From 5fb6451e553373f4584a2d3203bf7df2cc6f40a9 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Thu, 24 Oct 2019 17:19:59 -0300 Subject: [PATCH 74/85] save importer instance on get source info importer #313 --- src/api/endpoints/class-tainacan-rest-importers-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/endpoints/class-tainacan-rest-importers-controller.php b/src/api/endpoints/class-tainacan-rest-importers-controller.php index 2897bf72d..51dddbd92 100644 --- a/src/api/endpoints/class-tainacan-rest-importers-controller.php +++ b/src/api/endpoints/class-tainacan-rest-importers-controller.php @@ -267,7 +267,7 @@ class REST_Importers_Controller extends REST_Controller { if ( method_exists($importer, 'get_source_special_fields') ) { $response['source_special_fields'] = $importer->get_source_special_fields(); } - + $Tainacan_Importer_Handler->save_importer_instance($importer); return new \WP_REST_Response( $response, 200 ); } From 9ce5e0862718b6e627e8944d155b81c226ad1878 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Fri, 25 Oct 2019 10:49:24 -0300 Subject: [PATCH 75/85] Removal of unecessary computed property from Tainacan Form Item. First works on #320. --- .../metadata-types/tainacan-form-item.vue | 88 ++++++++----------- src/js/event-bus-web-components.js | 49 +++++------ 2 files changed, 59 insertions(+), 78 deletions(-) diff --git a/src/classes/metadata-types/tainacan-form-item.vue b/src/classes/metadata-types/tainacan-form-item.vue index 80228903a..2500b6dd0 100644 --- a/src/classes/metadata-types/tainacan-form-item.vue +++ b/src/classes/metadata-types/tainacan-form-item.vue @@ -46,7 +46,7 @@
0 && this.inputs[0].value){ - let terms = []; + if (this.inputs.length > 0 && this.inputs[0].value) { + let terms = this.inputs.map(term => term.value) + + if (this.metadatum.value instanceof Array){ + let equal = []; - for(let term of this.inputs){ - terms.push(term.value); - } - - if(this.metadatum.value instanceof Array){ - let eq = []; - - for(let meta of terms){ - let found = this.metadatum.value.find((element) => { - return meta == element.id; - }); - - if(found){ - eq.push(found); - } + for (let meta of terms) { + let foundIndex = this.metadatum.value.findIndex(element => meta == element.id); + if (foundIndex >= 0) + equal.push(this.metadatum.value[foundIndex]); } - if(eq.length == terms.length && this.metadatum.value.length <= eq.length){ + if (equal.length == terms.length && this.metadatum.value.length <= equal.length) return; - } - } - } else if(this.metadatum.value.constructor.name == 'Object'){ - if(this.metadatum.value.id == this.inputs){ + } + } else if (this.metadatum.value.constructor.name == 'Object') { + + if (this.metadatum.value.id == this.inputs) return; - } - } else if(this.metadatum.value instanceof Array){ - let eq = []; + + } else if (this.metadatum.value instanceof Array) { + let equal = []; - for(let meta of this.inputs){ - let found = this.metadatum.value.find((element) => { - return meta == element.id; - }); + for (let meta of this.inputs) { + let foundIndex = this.metadatum.value.findIndex(element => meta == element.id); - if(found){ - eq.push(found); - } + if (foundIndex >= 0) + equal.push(this.metadatum.value[foundIndex]); } - if(eq.length == this.inputs.length && this.metadatum.value.length <= eq.length){ + if (equal.length == this.inputs.length && this.metadatum.value.length <= equal.length) return; - } } eventBus.$emit('input', { item_id: this.metadatum.item.id, metadatum_id: this.metadatum.metadatum.id, values: this.inputs } ); @@ -198,9 +180,9 @@ if (this.metadatum.value instanceof Array) { this.inputs = this.metadatum.value.slice(0); - if (this.inputs.length === 0){ + if (this.inputs.length === 0) this.inputs.push(''); - } + } else { this.metadatum.value == null || this.metadatum.value == undefined ? this.inputs.push('') : this.inputs.push(this.metadatum.value); } @@ -213,11 +195,11 @@ this.inputs.splice(index, 1); this.changeValue(); }, - isTextInputComponent( component ){ + isTextInputComponent(component){ let array = ['tainacan-relationship','tainacan-taxonomy']; return !( array.indexOf( component ) >= 0 ); }, - setMetadatumTypeMessage( message ){ + setMetadatumTypeMessage(message){ this.metadatumTypeMessage = message; } } diff --git a/src/js/event-bus-web-components.js b/src/js/event-bus-web-components.js index 9306a7cb9..995e0d85f 100644 --- a/src/js/event-bus-web-components.js +++ b/src/js/event-bus-web-components.js @@ -19,42 +19,41 @@ export const eventBus = new Vue({ this.$emit('isUpdatingValue', true); - if ( data.item_id ){ + if (data.item_id) { - if(data.values.length > 0 && data.values[0].value){ + if (data.values.length > 0 && data.values[0].value) { let val = []; - for(let i of data.values){ + for (let i of data.values) val.push(i.value); - } - + data.values = val; } let values = ( Array.isArray( data.values[0] ) ) ? data.values[0] : data.values ; - const promisse = this.$store.dispatch('item/updateMetadata', - { item_id: data.item_id, metadatum_id: data.metadatum_id, values: values }); - promisse.then( () => { - this.$emit('isUpdatingValue', false); - let index = this.errors.findIndex( errorItem => errorItem.metadatum_id == data.metadatum_id ); - if ( index >= 0){ - this.errors.splice( index, 1); - } + this.$store.dispatch('item/updateMetadata', { + item_id: data.item_id, + metadatum_id: data.metadatum_id, + values: values }) - .catch((error) => { - this.$emit('isUpdatingValue', false); - let index = this.errors.findIndex( errorItem => errorItem.metadatum_id == data.metadatum_id ); - let messages = []; + .then(() => { + this.$emit('isUpdatingValue', false); + let index = this.errors.findIndex( errorItem => errorItem.metadatum_id == data.metadatum_id ); + if ( index >= 0) + this.errors.splice( index, 1); + }) + .catch((error) => { + this.$emit('isUpdatingValue', false); + let index = this.errors.findIndex( errorItem => errorItem.metadatum_id == data.metadatum_id ); + let messages = []; - for (let index in error) { - messages.push(error[index]); - } + for (let index in error) + messages.push(error[index]); - if ( index >= 0){ - Vue.set( this.errors, index, { metadatum_id: data.metadatum_id, errors: messages }); - } else { - this.errors.push( { metadatum_id: data.metadatum_id, errors: messages } ); - } + if ( index >= 0) + Vue.set( this.errors, index, { metadatum_id: data.metadatum_id, errors: messages }); + else + this.errors.push( { metadatum_id: data.metadatum_id, errors: messages } ); }); } }, From c79fd8897025a624b05c366de92adfea10fec8e2 Mon Sep 17 00:00:00 2001 From: leogermani Date: Fri, 25 Oct 2019 14:42:29 -0300 Subject: [PATCH 76/85] release RC2 --- src/tainacan.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tainacan.php b/src/tainacan.php index f6c3273ac..cc1627d40 100644 --- a/src/tainacan.php +++ b/src/tainacan.php @@ -4,13 +4,13 @@ Plugin Name: Tainacan Plugin URI: https://tainacan.org/ Description: powerfull and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional respository platform. Author: Tainacan.org -Version: 0.13RC +Version: 0.13RC2 Text Domain: tainacan License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html */ -const TAINACAN_VERSION = '0.13RC'; +const TAINACAN_VERSION = '0.13RC2'; defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); $TAINACAN_BASE_URL = plugins_url('', __FILE__); From 9a0d65219caccbcb205b98fbde6f64da438ae6eb Mon Sep 17 00:00:00 2001 From: leogermani Date: Mon, 28 Oct 2019 10:12:22 -0300 Subject: [PATCH 77/85] Fix bg process api endpoint. return all users processes --- ...n-rest-background-processes-controller.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/api/endpoints/class-tainacan-rest-background-processes-controller.php b/src/api/endpoints/class-tainacan-rest-background-processes-controller.php index e4b83aeb6..8e0f2264b 100644 --- a/src/api/endpoints/class-tainacan-rest-background-processes-controller.php +++ b/src/api/endpoints/class-tainacan-rest-background-processes-controller.php @@ -74,16 +74,16 @@ class REST_Background_Processes_Controller extends REST_Controller { ), )); register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P[0-9]+)', array( - + array( 'methods' => \WP_REST_Server::READABLE, 'callback' => array($this, 'get_item'), 'permission_callback' => array($this, 'bg_processes_permissions_check'), ), - + )); register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P[0-9]+)', array( - + array( 'methods' => \WP_REST_Server::EDITABLE, 'callback' => array($this, 'update_item'), @@ -99,24 +99,24 @@ class REST_Background_Processes_Controller extends REST_Controller { ] ], ), - + )); register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P[0-9]+)', array( - + array( 'methods' => \WP_REST_Server::DELETABLE, 'callback' => array($this, 'delete_item'), 'permission_callback' => array($this, 'bg_processes_permissions_check'), - + ), - + )); } - + /** * * @param \WP_REST_Request $request @@ -155,7 +155,7 @@ class REST_Background_Processes_Controller extends REST_Controller { $user_q = $wpdb->prepare("AND user_id = %d", $request['user_id']); } - if ( isset($user_q['all_users']) && $user_q['all_users'] ) { + if ( isset($request['all_users']) && $request['all_users'] ) { $user_q = ""; } } @@ -168,7 +168,7 @@ class REST_Background_Processes_Controller extends REST_Controller { $status_q = "AND done = 1"; } } - + $recent_q = ''; if ( isset($request['recent']) && $request['recent'] !== false ) { $recent_q = "AND (processed_last >= NOW() - INTERVAL 10 MINUTE OR queued_on >= NOW() - INTERVAL 10 MINUTE)"; @@ -194,7 +194,7 @@ class REST_Background_Processes_Controller extends REST_Controller { $rest_response->header('X-WP-Total', (int) $total_items); $rest_response->header('X-WP-TotalPages', (int) $max_pages); - + return $rest_response; } @@ -328,9 +328,9 @@ class REST_Background_Processes_Controller extends REST_Controller { public function get_log_url($id, $action, $type = '') { $suffix = $type ? '-' . $type : ''; - + $filename = 'bg-' . $action . '-' . $id . $suffix . '.log'; - + $upload_url = wp_upload_dir(); if (!file_exists( $upload_url['basedir'] . '/tainacan/' . $filename )) { @@ -339,7 +339,7 @@ class REST_Background_Processes_Controller extends REST_Controller { $upload_url = trailingslashit( $upload_url['baseurl'] ); $logs_url = $upload_url . 'tainacan/' . $filename; - + return $logs_url; } From fd9be5c44844f38eceb7585448783f36094ea455 Mon Sep 17 00:00:00 2001 From: leogermani Date: Mon, 28 Oct 2019 10:15:25 -0300 Subject: [PATCH 78/85] Fix private files on Windows servers --- src/classes/class-tainacan-private-files.php | 45 +++++++++++--------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/classes/class-tainacan-private-files.php b/src/classes/class-tainacan-private-files.php index 07a0a5dfc..bca6421cb 100644 --- a/src/classes/class-tainacan-private-files.php +++ b/src/classes/class-tainacan-private-files.php @@ -11,6 +11,8 @@ class Private_Files { private static $instance = null; + public $dir_separator; + public static function get_instance() { if(!isset(self::$instance)) { self::$instance = new self(); @@ -20,6 +22,11 @@ class Private_Files { } protected function __construct() { + + // Once upon a time I thought I had to worry about Windows and use DIRECTORY_SEPARATOR + // but this only gave me frustration and bugs. + $this->dir_separator = '/'; + add_filter('wp_handle_upload_prefilter', [$this, 'pre_upload']); add_filter('wp_handle_sideload_prefilter', [$this, 'pre_upload']); add_filter('wp_handle_upload', [$this, 'post_upload']); @@ -160,8 +167,8 @@ class Private_Files { $path['path'] = str_replace($path['subdir'], '', $path['path']); //remove default subdir (year/month) $path['url'] = str_replace($path['subdir'], '/' . $tainacan_basepath . '/' . $col_id_url . '/' . $item_id_url, $path['url']); - $path['path'] .= DIRECTORY_SEPARATOR . $tainacan_basepath . DIRECTORY_SEPARATOR . $col_id . DIRECTORY_SEPARATOR . $item_id; - $path['subdir'] = DIRECTORY_SEPARATOR . $tainacan_basepath . DIRECTORY_SEPARATOR . $col_id . DIRECTORY_SEPARATOR . $item_id; + $path['path'] .= $this->dir_separator . $tainacan_basepath . $this->dir_separator . $col_id . $this->dir_separator . $item_id; + $path['subdir'] = $this->dir_separator . $tainacan_basepath . $this->dir_separator . $col_id . $this->dir_separator . $item_id; } @@ -193,31 +200,31 @@ class Private_Files { $requested_uri = str_replace('/' . $this->get_private_folder_prefix(), '/', $requested_uri); - $file_path = \str_replace( '/', DIRECTORY_SEPARATOR, str_replace($base_upload_url, '', $requested_uri) ); + $file_path = \str_replace( '/', $this->dir_separator, str_replace($base_upload_url, '', $requested_uri) ); $file = $upload_dir['basedir'] . $file_path; $existing_file = false; - $file_dirs = explode(DIRECTORY_SEPARATOR, $file); + $file_dirs = explode($this->dir_separator, $file); $file_dirs_size = sizeof($file_dirs); $item_id = $file_dirs[$file_dirs_size-2]; $collection_id = $file_dirs[$file_dirs_size-3]; // private item - $prefixed_file = str_replace( DIRECTORY_SEPARATOR . $item_id . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR . $this->get_private_folder_prefix() . $item_id . DIRECTORY_SEPARATOR, $file); + $prefixed_file = str_replace( $this->dir_separator . $item_id . $this->dir_separator, $this->dir_separator . $this->get_private_folder_prefix() . $item_id . $this->dir_separator, $file); if ( \file_exists( $prefixed_file ) ) { $existing_file = $prefixed_file; } // private collection - $prefixed_collection = str_replace( DIRECTORY_SEPARATOR . $collection_id . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR . $this->get_private_folder_prefix() . $collection_id . DIRECTORY_SEPARATOR, $file); + $prefixed_collection = str_replace( $this->dir_separator . $collection_id . $this->dir_separator, $this->dir_separator . $this->get_private_folder_prefix() . $collection_id . $this->dir_separator, $file); if ( !$existing_file && \file_exists( $prefixed_collection ) ) { $existing_file = $prefixed_collection; } // private both - $prefixed_both = str_replace( DIRECTORY_SEPARATOR . $collection_id . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR . $this->get_private_folder_prefix() . $collection_id . DIRECTORY_SEPARATOR, $prefixed_file); + $prefixed_both = str_replace( $this->dir_separator . $collection_id . $this->dir_separator, $this->dir_separator . $this->get_private_folder_prefix() . $collection_id . $this->dir_separator, $prefixed_file); if ( !$existing_file && \file_exists( $prefixed_both ) ) { $existing_file = $prefixed_both; } @@ -255,7 +262,7 @@ class Private_Files { */ function image_get_intermediate_size($data, $post_id, $size) { - $data['path'] = str_replace(DIRECTORY_SEPARATOR . $this->get_private_folder_prefix(), DIRECTORY_SEPARATOR, $data['path']); + $data['path'] = str_replace($this->dir_separator . $this->get_private_folder_prefix(), $this->dir_separator, $data['path']); $data['url'] = str_replace('/' . $this->get_private_folder_prefix(), '/', $data['url']); return $data; @@ -278,8 +285,8 @@ class Private_Files { */ function update_item_and_collection($obj) { - $folder = DIRECTORY_SEPARATOR; - $check_folder = DIRECTORY_SEPARATOR; + $folder = $this->dir_separator; + $check_folder = $this->dir_separator; $check = false; if ( $obj instanceof \Tainacan\Entities\Collection ) { @@ -298,11 +305,11 @@ class Private_Files { $collection = $obj->get_collection(); $col_status_object = get_post_status_object($collection->get_status()); - $folder .= $col_status_object->public ? $collection->get_id() : $this->get_private_folder_prefix() . $collection->get_id() . DIRECTORY_SEPARATOR; - $check_folder .= $col_status_object->public ? $collection->get_id() : $this->get_private_folder_prefix() . $collection->get_id() . DIRECTORY_SEPARATOR; + $folder .= $col_status_object->public ? $collection->get_id() : $this->get_private_folder_prefix() . $collection->get_id() . $this->dir_separator; + $check_folder .= $col_status_object->public ? $collection->get_id() : $this->get_private_folder_prefix() . $collection->get_id() . $this->dir_separator; - $folder .= DIRECTORY_SEPARATOR; - $check_folder .= DIRECTORY_SEPARATOR; + $folder .= $this->dir_separator; + $check_folder .= $this->dir_separator; $status_obj = get_post_status_object($obj->get_status()); @@ -317,8 +324,8 @@ class Private_Files { $upload_dir = wp_get_upload_dir(); $base_dir = $upload_dir['basedir']; - $full_path = $base_dir . DIRECTORY_SEPARATOR . $this->get_items_uploads_folder() . $folder; - $full_path_check = $base_dir . DIRECTORY_SEPARATOR . $this->get_items_uploads_folder() . $check_folder; + $full_path = $base_dir . $this->dir_separator . $this->get_items_uploads_folder() . $folder; + $full_path_check = $base_dir . $this->dir_separator . $this->get_items_uploads_folder() . $check_folder; if (\file_exists($full_path_check)) { rename($full_path_check, $full_path); @@ -346,7 +353,7 @@ class Private_Files { $upload_dir = wp_get_upload_dir(); $base_dir = $upload_dir['basedir']; - $full_path = $base_dir . DIRECTORY_SEPARATOR . $this->get_items_uploads_folder() . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . $prefix; + $full_path = $base_dir . $this->dir_separator . $this->get_items_uploads_folder() . $this->dir_separator . '*' . $this->dir_separator . $prefix; foreach ($ids as $id) { $folder = $full_path . $id; @@ -355,9 +362,9 @@ class Private_Files { if (sizeof($found) == 1 && isset($found[0])) { if ($status_obj->public) { - $target = str_replace(DIRECTORY_SEPARATOR . $this->get_private_folder_prefix() . $id, DIRECTORY_SEPARATOR . $id, $found[0]); + $target = str_replace($this->dir_separator . $this->get_private_folder_prefix() . $id, $this->dir_separator . $id, $found[0]); } else { - $target = str_replace(DIRECTORY_SEPARATOR . $id, DIRECTORY_SEPARATOR . $this->get_private_folder_prefix() . $id, $found[0]); + $target = str_replace($this->dir_separator . $id, $this->dir_separator . $this->get_private_folder_prefix() . $id, $found[0]); } rename($found[0], $target); From 01beaf8729046a8f3bf26030c4125d05d4d20be4 Mon Sep 17 00:00:00 2001 From: leogermani Date: Mon, 28 Oct 2019 11:15:03 -0300 Subject: [PATCH 79/85] Load roboto font on admin --- src/admin/class-tainacan-admin.php | 61 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/admin/class-tainacan-admin.php b/src/admin/class-tainacan-admin.php index 8f9527454..a692af8af 100644 --- a/src/admin/class-tainacan-admin.php +++ b/src/admin/class-tainacan-admin.php @@ -41,14 +41,14 @@ class Admin { array( &$this, 'admin_page' ), plugin_dir_url( __FILE__ ) . 'images/tainacan_logo_symbol.svg' ); - - add_submenu_page( - $this->menu_slug, - __('System check', 'tainacan'), - __('System check', 'tainacan'), - 'manage_options', - 'tainacan_systemcheck', - array( &$this, 'systemcheck_page' ) + + add_submenu_page( + $this->menu_slug, + __('System check', 'tainacan'), + __('System check', 'tainacan'), + 'manage_options', + 'tainacan_systemcheck', + array( &$this, 'systemcheck_page' ) ); add_action( 'load-' . $page_suffix, array( &$this, 'load_admin_page' ) ); @@ -57,6 +57,7 @@ class Admin { function load_admin_page() { add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_css' ), 90 ); add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_js' ), 90 ); + add_action( 'admin_enqueue_scripts', array(&$this, 'add_theme_files') ); } @@ -74,18 +75,18 @@ class Admin { function add_theme_files() { global $TAINACAN_BASE_URL; - + // wp_enqueue_style( 'style', $TAINACAN_BASE_URL . '/assets/css/fonts/materialdesignicons.css' ); wp_enqueue_style( 'tainacan-fonts', $TAINACAN_BASE_URL . '/assets/css/fonts/tainacanicons.css', [], TAINACAN_VERSION ); wp_enqueue_style( 'roboto-fonts', 'https://fonts.googleapis.com/css?family=Roboto:400,400i,500,500i,700,700i', [], TAINACAN_VERSION ); wp_enqueue_script('underscore'); } - + function add_admin_css() { global $TAINACAN_BASE_URL; - + wp_enqueue_style( 'tainacan-admin-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-admin.css', [], TAINACAN_VERSION ); - + // $undesired_wp_styles = [ // 'admin-menu', // 'admin-bar', @@ -119,14 +120,14 @@ class Admin { // // wp_dequeue_style( $undesired_wp_styles ); // wp_deregister_style( $undesired_wp_styles ); - + } - + function add_admin_js() { global $TAINACAN_BASE_URL; wp_enqueue_script( 'tainacan-user-admin', $TAINACAN_BASE_URL . '/assets/user_admin-components.js', ['underscore', 'media-editor', 'media-views', 'customize-controls'], TAINACAN_VERSION, true ); - + $settings = $this->get_admin_js_localization_params(); wp_localize_script( 'tainacan-user-admin', 'tainacan_plugin', $settings ); @@ -134,23 +135,23 @@ class Admin { wp_enqueue_script('underscore'); wp_enqueue_script('jcrop'); wp_enqueue_script( 'customize-controls' ); - + do_action('tainacan-enqueue-admin-scripts'); - + } - + /** * Also used by DevInterface */ function get_admin_js_localization_params() { global $TAINACAN_BASE_URL, $TAINACAN_API_MAX_ITEMS_PER_PAGE; - + $Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance(); $Tainacan_Items = \Tainacan\Repositories\Items::get_instance(); $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); - + $tainacan_admin_i18n = require( 'tainacan-admin-i18n.php' ); $entities_labels = [ @@ -222,33 +223,33 @@ class Admin { } $filter_types = $Tainacan_Filters->fetch_filter_types(); - + foreach ( $filter_types as $index => $filter_type){ $class = new $filter_type; $settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels(); } - + $settings['form_hooks'] = Admin_Hooks::get_instance()->get_registered_hooks(); - + $wp_post_types = get_post_types(['show_ui' => true], 'objects'); if (isset($wp_post_types['attachment'])) { unset($wp_post_types['attachment']); } - + $wp_post_types = array_map(function($i) { return [ 'slug' => $i->name, 'label' => $i->label ]; }, $wp_post_types); - + $settings['wp_post_types'] = $wp_post_types; - + // add an alternative to enable select all items in all pages while we temporarly disable bulk edit for all (see #199) - $settings['enable_select_all_items_pages'] = defined('TAINACAN_ENABLE_SELECT_ALL_ITEMS_PAGES') ? TAINACAN_ENABLE_SELECT_ALL_ITEMS_PAGES : false; - + $settings['enable_select_all_items_pages'] = defined('TAINACAN_ENABLE_SELECT_ALL_ITEMS_PAGES') ? TAINACAN_ENABLE_SELECT_ALL_ITEMS_PAGES : false; + return $settings; - + } function admin_body_class( $classes ) { @@ -334,7 +335,7 @@ class Admin { wp_die(); } - + public function systemcheck_page() { require_once('system-check/class-tainacan-system-check.php'); $check = new System_Check(); From 109e857fe3d1b1ef44255be5ea4dd4c796bec8cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Nunes?= Date: Mon, 28 Oct 2019 16:41:03 -0300 Subject: [PATCH 80/85] change the field to on make query #90 --- src/classes/class-tainacan-elastic-press.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/class-tainacan-elastic-press.php b/src/classes/class-tainacan-elastic-press.php index 10104c2f9..70c9059f9 100644 --- a/src/classes/class-tainacan-elastic-press.php +++ b/src/classes/class-tainacan-elastic-press.php @@ -584,7 +584,7 @@ class Elastic_Press { } if($search != '') { - $formatted_args['query']['bool']['must'][] = ["wildcard"=>["$field.name.raw" => "*$search*"]]; + $formatted_args['query']['bool']['must'][] = ["wildcard"=>["$field.name.sortable" => "*$search*"]]; } } else { $aggs[$id] = [ From 0a742974ff96b14eaf9e1f90105197adcb5ffa31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Nunes?= Date: Mon, 28 Oct 2019 17:07:41 -0300 Subject: [PATCH 81/85] fix field `value.sortable` for metadata query #90 --- src/classes/class-tainacan-elastic-press.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/class-tainacan-elastic-press.php b/src/classes/class-tainacan-elastic-press.php index 70c9059f9..235dcf8d5 100644 --- a/src/classes/class-tainacan-elastic-press.php +++ b/src/classes/class-tainacan-elastic-press.php @@ -613,7 +613,7 @@ class Elastic_Press { $field_relationship_label = "$field_relationship_label[0].$field_relationship_label[1].relationship_label"; //$formatted_args['query']['bool']['must'][] = ["wildcard"=>["$field" => "*$search*"]]; $formatted_args['query']['bool']['must'][] = ["bool"=>["should"=>[ - ["wildcard"=>["$field"=>"*$search*"]], + ["wildcard"=>["$id.value.sortable"=>"*$search*"]], ["wildcard"=>["$field_relationship_label"=>"*$search*"]] //pega nome do metadado é melhor! ]]]; } From 6b40540a1286b672ca6882706a7d807dce05a0ca Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Tue, 29 Oct 2019 13:20:46 -0300 Subject: [PATCH 82/85] Disables skeleton when using autoPlay or loopSlides. --- .../carousel-collections-list-theme.vue | 2 +- .../carousel-items-list/carousel-items-list-theme.vue | 7 ++++--- .../carousel-terms-list/carousel-terms-list-theme.vue | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gutenberg-blocks/tainacan-collections/carousel-collections-list/carousel-collections-list-theme.vue b/src/gutenberg-blocks/tainacan-collections/carousel-collections-list/carousel-collections-list-theme.vue index 76db868a3..e87700aec 100644 --- a/src/gutenberg-blocks/tainacan-collections/carousel-collections-list/carousel-collections-list-theme.vue +++ b/src/gutenberg-blocks/tainacan-collections/carousel-collections-list/carousel-collections-list-theme.vue @@ -121,7 +121,7 @@
-
+
@@ -121,7 +122,7 @@
-
+ -
+
Date: Tue, 29 Oct 2019 13:58:04 -0300 Subject: [PATCH 83/85] releasing version 0.13 --- src/readme.txt | 188 +++++++++++++++++++++++------------------------ src/tainacan.php | 4 +- 2 files changed, 96 insertions(+), 96 deletions(-) diff --git a/src/readme.txt b/src/readme.txt index 5f2284e1c..626660e34 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -1,94 +1,94 @@ -=== Tainacan === -Contributors: andrebenedito, daltonmartins, fabianobn, jacsonp, leogermani, weryques, wetah, eduardohumberto, ravipassos, jessicafpx, marinagiolo, omarceloavila, vnmedeiros -Tags: museums, libraries, archives, GLAM, collections, repository -Requires at least: 4.8 -Tested up to: 5.2.3 -Requires PHP: 5.6 -Stable tag: 0.12 -License: GPLv2 or later -License URI: http://www.gnu.org/licenses/gpl-3.0.html - -Tainacan is a powerful and flexible repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. - -== Description == - -Tainacan is a powerful and flexible repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. - -= Features = - -* "Metadata and Filters": Use a metadata standard or choose whatever set of metadata you want to describe the items in your collections. Also, choose which metadata will be used as a filter when browsing collections. - -* "Faceted Search". Browse your collection (and let the public browse it) using a faceted search interface with the filters you have chosen. - -* "Manage Taxonomies": Manage vocabularies that can be used accross all your collections. - -* "Themes": The Tainacan plugin has its own default theme, which helps you to showcase your collections in a beautiful and effective manner. But it can also work with any WordPress theme, so interface developers can easyly add Tainacan specific features to an existing theme. - -* "API and Interoperability": Tainacan implements a RESTful API (read and write) to allow other applications to interact with your repository. That way, you can expose your collection in different formats, such as Json, JsonLD, OAI-PMH and others. If your collection has a specific set of metadata, you can map this metadata to match the patterns you want to use. - -* "Gutenberg blocks": Tell stories with your collections. Tainacan offers you several Gutenberg blocks so you can present your collections to the public in many different ways! - -== Getting Started == - -After installation, you will see a new menu item in your admin panel called "Tainacan". Click on it to open the Tainacan admin interface. - -To get an overview of the main concepts of Tainacan, please visit [this page](https://tainacan.github.io/tainacan-wiki//#/general-concepts). - -= Create a collection = - -Click "New Collection" to create a new collection, use a mapping standard or import using one of our importers. - -= Configure your collection = - -Navigate the top menu to set your collection up. Create the metadata that items in this collection will have, and choose, from these metadata, which ones are going to be used as a filter. - -= Add items = - -Back to the "Items" screen, click "Add new" to create a new item. - -= Manage and browse your collection = - -Through this admin interface you can manage your collection and browse its item using the faceted search interface or advanced search interface. - -If you want to visit your collections in the public side of your site, using your current theme, visit http://your-site/tainacan-collection and you will get the list of your collections. - -= Set up Taxonomies = - -You can also have metada as taxonomies, which you can configure with a set of hierarchical terms of your own vocabulary. - -= Add links to your menu = - -Edit your menu and links directly to your collections. Click "Screen options" at the top of the Menu edition page and enable "Collections". - -If you want to add a link to the list of collections, click "View all" tab on the Collections box on the left, and then add the first item named "Collections" to the menu. - -= Faceted search in your theme = - -We are still working in a way to enable faceted search in any theme. You can try it but it might not work very well depending on your theme. - -In order to do this, use the shortcode "tainacan-search" in any page of your site (we recommend a full width template page), informing the ID of the collection you want to display. - -Example: [tainacan-search collection-id=4] - -== Installation == - -Upload the files to the plugins directory and activate it. You can also install and activate directly from the your admin panel. - -If you have Imagick installed in your server, Tainacan will be able to automatically generate a thumbnail from your PDF files. This is desired but not required. - -== Screenshots == - -1. Manage your repository -2. Set up your collection -3. Choose the metadata and filters for your collection -4. Add items described by your metadata -5. Set up your item as a file, link or text and attach many type of documents -6. Browse your collections with a faceted search interface -7. Navigate through rich filtering interface -8. Explore more with Advanced Search -9. Set up Taxonomies to be used across your repository -10. Bulk edit as many items as you need quickly -11. Expose your collection using Tainacan default theme -12. Use Gutenberg blocks to display your collections in posts and pages -13. Choose which items will be displayed in your block -14. Items displayed using a Gutenberg block +=== Tainacan === +Contributors: andrebenedito, daltonmartins, fabianobn, jacsonp, leogermani, weryques, wetah, eduardohumberto, ravipassos, jessicafpx, marinagiolo, omarceloavila, vnmedeiros +Tags: museums, libraries, archives, GLAM, collections, repository +Requires at least: 4.8 +Tested up to: 5.2.4 +Requires PHP: 5.6 +Stable tag: 0.13 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-3.0.html + +Tainacan is a powerful and flexible repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. + +== Description == + +Tainacan is a powerful and flexible repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. + += Features = + +* "Metadata and Filters": Use a metadata standard or choose whatever set of metadata you want to describe the items in your collections. Also, choose which metadata will be used as a filter when browsing collections. + +* "Faceted Search". Browse your collection (and let the public browse it) using a faceted search interface with the filters you have chosen. + +* "Manage Taxonomies": Manage vocabularies that can be used accross all your collections. + +* "Themes": The Tainacan plugin has its own default theme, which helps you to showcase your collections in a beautiful and effective manner. But it can also work with any WordPress theme, so interface developers can easyly add Tainacan specific features to an existing theme. + +* "API and Interoperability": Tainacan implements a RESTful API (read and write) to allow other applications to interact with your repository. That way, you can expose your collection in different formats, such as Json, JsonLD, OAI-PMH and others. If your collection has a specific set of metadata, you can map this metadata to match the patterns you want to use. + +* "Gutenberg blocks": Tell stories with your collections. Tainacan offers you several Gutenberg blocks so you can present your collections to the public in many different ways! + +== Getting Started == + +After installation, you will see a new menu item in your admin panel called "Tainacan". Click on it to open the Tainacan admin interface. + +To get an overview of the main concepts of Tainacan, please visit [this page](https://tainacan.github.io/tainacan-wiki//#/general-concepts). + += Create a collection = + +Click "New Collection" to create a new collection, use a mapping standard or import using one of our importers. + += Configure your collection = + +Navigate the top menu to set your collection up. Create the metadata that items in this collection will have, and choose, from these metadata, which ones are going to be used as a filter. + += Add items = + +Back to the "Items" screen, click "Add new" to create a new item. + += Manage and browse your collection = + +Through this admin interface you can manage your collection and browse its item using the faceted search interface or advanced search interface. + +If you want to visit your collections in the public side of your site, using your current theme, visit http://your-site/tainacan-collection and you will get the list of your collections. + += Set up Taxonomies = + +You can also have metada as taxonomies, which you can configure with a set of hierarchical terms of your own vocabulary. + += Add links to your menu = + +Edit your menu and links directly to your collections. Click "Screen options" at the top of the Menu edition page and enable "Collections". + +If you want to add a link to the list of collections, click "View all" tab on the Collections box on the left, and then add the first item named "Collections" to the menu. + += Faceted search in your theme = + +We are still working in a way to enable faceted search in any theme. You can try it but it might not work very well depending on your theme. + +In order to do this, use the shortcode "tainacan-search" in any page of your site (we recommend a full width template page), informing the ID of the collection you want to display. + +Example: [tainacan-search collection-id=4] + +== Installation == + +Upload the files to the plugins directory and activate it. You can also install and activate directly from the your admin panel. + +If you have Imagick installed in your server, Tainacan will be able to automatically generate a thumbnail from your PDF files. This is desired but not required. + +== Screenshots == + +1. Manage your repository +2. Set up your collection +3. Choose the metadata and filters for your collection +4. Add items described by your metadata +5. Set up your item as a file, link or text and attach many type of documents +6. Browse your collections with a faceted search interface +7. Navigate through rich filtering interface +8. Explore more with Advanced Search +9. Set up Taxonomies to be used across your repository +10. Bulk edit as many items as you need quickly +11. Expose your collection using Tainacan default theme +12. Use Gutenberg blocks to display your collections in posts and pages +13. Choose which items will be displayed in your block +14. Items displayed using a Gutenberg block diff --git a/src/tainacan.php b/src/tainacan.php index cc1627d40..361e6bbf2 100644 --- a/src/tainacan.php +++ b/src/tainacan.php @@ -4,13 +4,13 @@ Plugin Name: Tainacan Plugin URI: https://tainacan.org/ Description: powerfull and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional respository platform. Author: Tainacan.org -Version: 0.13RC2 +Version: 0.13 Text Domain: tainacan License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html */ -const TAINACAN_VERSION = '0.13RC2'; +const TAINACAN_VERSION = '0.13'; defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); $TAINACAN_BASE_URL = plugins_url('', __FILE__); From d39c9d004f89a0dadc88e5f2535e4c5a3ef650c1 Mon Sep 17 00:00:00 2001 From: leogermani Date: Tue, 29 Oct 2019 14:10:30 -0300 Subject: [PATCH 84/85] removing useless folder from build --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index 2b75c8a86..57c66af03 100755 --- a/build.sh +++ b/build.sh @@ -73,6 +73,7 @@ rsync -axz --exclude='vendor/bin/phpc*' --exclude='vendor/squizlabs' --exclude=' --exclude='pdf-viewer/pdfjs-dist/web/compressed.tracemonkey-pldi-09.pdf' \ --exclude='vendor/tecnickcom/tcpdf/fonts' \ --exclude='vendor/smalot/pdfparser/src/Smalot/PdfParser/Tests/' \ + --exclude='vendor/tecnickcom/tcpdf/examples' \ src/* $wp_plugin_dir/ rm -rf $wp_plugin_dir/scss From 333aa976fd3bdeaa4ab6a04725fcf9a1d820e6d6 Mon Sep 17 00:00:00 2001 From: leogermani Date: Tue, 29 Oct 2019 15:01:38 -0300 Subject: [PATCH 85/85] fix after merge 0.13 --- src/classes/entities/class-tainacan-log.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/classes/entities/class-tainacan-log.php b/src/classes/entities/class-tainacan-log.php index 02ed6ba83..583c717b7 100644 --- a/src/classes/entities/class-tainacan-log.php +++ b/src/classes/entities/class-tainacan-log.php @@ -94,15 +94,6 @@ class Log extends Entity { function get_date() { return $this->get_mapped_property( 'date' ); } - - /** - * Return the log slug - * - * @return mixed|null - */ - function get_slug() { - return $this->get_mapped_property( 'slug' ); - } /** * Return the log slug @@ -113,7 +104,6 @@ class Log extends Entity { return $this->get_mapped_property( 'slug' ); } - /** * Return the Log description *