diff --git a/src/admin/components/navigation/tainacan-header.vue b/src/admin/components/navigation/tainacan-header.vue index e49069195..6e19db1ad 100644 --- a/src/admin/components/navigation/tainacan-header.vue +++ b/src/admin/components/navigation/tainacan-header.vue @@ -80,20 +80,18 @@ export default { .level-item{ height: $header-height; - width: 184px; - transition: width 0.15s; - -webkit-transition: width linear 0.15s; + width: 180px; + transition: width 0.15s, background-color 0.2s; + -webkit-transition: width 0.15s background-color 0.2s; cursor: pointer; - - &:hover{ - background-color: #257787; - } + background-color: #257787; + &:focus { box-shadow: none; } .tainacan-logo { max-height: 22px; - padding: 0px 28px; + padding: 0px 24px; transition: padding 0.15s; -webkit-transition: padding linear 0.15s; } @@ -108,7 +106,7 @@ export default { color: $tertiary; } .search-area { - display: flex; + display: none;//display: flex; align-items: center; margin-right: 36px; @@ -140,6 +138,7 @@ export default { &.menu-compressed { .level-left .level-item { width: 220px; + background-color: $secondary; .tainacan-logo { padding: 0px 42px; } diff --git a/src/admin/components/search/search-control.vue b/src/admin/components/search/search-control.vue index a774276fa..c302abbc5 100644 --- a/src/admin/components/search/search-control.vue +++ b/src/admin/components/search/search-control.vue @@ -18,9 +18,9 @@ {{ $i18n.get('add_one_item') }} - {{ $i18n.get('add_items_bulk') }} + {{ $i18n.get('add_items_bulk') + ' (Not ready)' }} - {{ $i18n.get('add_items_external_source') }}
{{ $i18n.get() }}
+ {{ $i18n.get('add_items_external_source') + ' (Not ready)' }}
{{ $i18n.get() }}
diff --git a/src/admin/js/wp-media-frames.js b/src/admin/js/wp-media-frames.js index ec3e42500..e6d6ed7a4 100644 --- a/src/admin/js/wp-media-frames.js +++ b/src/admin/js/wp-media-frames.js @@ -13,16 +13,14 @@ export default { button: { text: this.params.button_labels.frame_button }, - library: { - uploadedTo: this.params.relatedPostId - }, states: [ new wp.media.controller.Library({ title: this.params.button_labels.frame_title, - library: wp.media.query({ type: this.params.mime_type }), + library: wp.media.query({ + uploadedTo: this.params.relatedPostId + }), multiple: true, - date: false, - uploadedTo: this.params.relatedPostId + date: false }) ] }); @@ -72,17 +70,17 @@ export default { text: l10n.select, close: false }, - library: { - type: 'image', - uploadedTo: this.params.relatedPostId - }, uploader: true, states: [ new wp.media.controller.Library({ title: this.params.button_labels.frame_title, - library: wp.media.query({ type: 'image' }), + library: wp.media.query({ + type: 'image', + uploadedTo: this.params.relatedPostId + }), multiple: false, date: false, + filterable: true, priority: 20, suggestedWidth: this.params.width, suggestedHeight: this.params.height, @@ -130,21 +128,19 @@ export default { text: l10n.select, close: false }, - library: { - type: 'image', - uploadedTo: this.params.relatedPostId - }, uploader: true, states: [ new wp.media.controller.Library({ title: this.params.button_labels.frame_title, - library: wp.media.query({ type: 'image' }), + library: wp.media.query({ + type: 'image', + uploadedTo: this.params.relatedPostId + }), multiple: false, date: false, priority: 20, suggestedWidth: this.params.width, - suggestedHeight: this.params.height, - uploadedTo: this.params.relatedPostId + suggestedHeight: this.params.height }), new wp.media.controller.CustomizeImageCropper({ imgSelectOptions: this.calculateImageSelectOptions, @@ -182,13 +178,12 @@ export default { button: { text: this.params.button_labels.frame_button }, - library: { - uploadedTo: this.params.relatedPostId - }, states: [ new wp.media.controller.Library({ title: this.params.button_labels.frame_title, - library: wp.media.query({ type: this.params.mime_type }), + library: wp.media.query({ + uploadedTo: this.params.relatedPostId + }), multiple: false, date: false, uploadedTo: this.params.relatedPostId diff --git a/src/importer/class-tainacan-old-tainacan.php b/src/importer/class-tainacan-old-tainacan.php index 82b7f0a8a..f59c2037c 100644 --- a/src/importer/class-tainacan-old-tainacan.php +++ b/src/importer/class-tainacan-old-tainacan.php @@ -92,6 +92,10 @@ class Old_Tainacan extends Importer $Tainacan_Taxonomies->insert($taxonomy); $inserted_taxonomy = $Tainacan_Taxonomies->fetch($taxonomy->get_id()); + + /*Insert old tainacan id*/ + add_post_meta($inserted_taxonomy->get_id(), 'old_tainacan_category_id', $category->term_id); + if(isset($category->children) && $inserted_taxonomy) { $this->add_all_terms($inserted_taxonomy, $category->children); @@ -122,6 +126,9 @@ class Old_Tainacan extends Importer $inserted_term = $Tainacan_Terms->insert($new_term); + /*Insert old tainacan id*/ + add_term_meta($inserted_term->get_id(), 'old_tainacan_category_id', $term->term_id ); + if(isset($term->children)) { $this->add_all_terms($taxonomy_father, $term->children, $inserted_term); @@ -151,11 +158,71 @@ class Old_Tainacan extends Importer public function create_collections() { + $collections_link = $this->get_url() . $this->tainacan_api_address . "/collections"; + $collections = wp_remote_get($collections_link); + + $collections_array = $this->verify_process_result($collections); + if($collections_array) + { + foreach ($collections_array as $collection) + { + $new_collection = new \Tainacan\Entities\Collection(); + $new_collection->set_name($collection->post_title); + $new_collection->set_status('publish'); + $new_collection->validate(); + $new_collection = \Tainacan\Repositories\Collections::get_instance()->insert($new_collection); + + /*Add old id*/ + add_post_meta($new_collection->get_id(), "old_tainacan_collection_id", $collection->ID); + } + } + return false; } public function create_repo_meta() { + $repository_meta_link = $this->get_url() . $this->tainacan_api_address . "/repository/metadata"; + $repo_meta = wp_remote_get($repository_meta_link); + + $repo_meta_array = $this->verify_process_result($repo_meta); + if($repo_meta_array) + { + $Fields_Repository = \Tainacan\Repositories\Fields::get_instance(); + foreach ($repo_meta_array as $meta) + { + $avoid = [ + 'socialdb_property_fixed_title', + 'socialdb_property_fixed_description', + 'socialdb_property_fixed_content', + 'socialdb_property_fixed_thumbnail', + 'socialdb_property_fixed_attachments', + 'stars', + 'item', + 'tree', + 'compound' + ]; + + $special = [ + 'socialdb_property_fixed_type' + ]; + + if(!in_array($meta->slug, $avoid) && !in_array($meta->type, $avoid)) + { + $newField = new \Tainacan\Entities\Field(); + + $type = $this->define_type($meta->type); + $newField->set_name($meta->name); + + $newField->set_field_type('Tainacan\Field_Types\\'.$type); + + $newField->set_collection_id('default'); + $newField->validate(); // there is no user input here, so we can be sure it will validate. + + $Fields_Repository->insert($newField); + } + } + } return false; } @@ -166,6 +233,7 @@ class Old_Tainacan extends Importer public function create_collection_items() { + /*Use standard method*/ return false; } @@ -376,11 +444,23 @@ class Old_Tainacan extends Importer $type = strtolower($type); $tainacan_types = ['text', 'textarea', 'numeric', 'date']; - $types_to_work = ['item', 'tree']; if(in_array($type, $tainacan_types)) { $type = ucfirst($type); - }else $type = 'Text'; + }else if(strcmp($type, 'autoincrement') === 0) + { + $type = "Numeric"; + }else if(strcmp($type, 'item')) + { + $type = "Relationship"; + }else if(strcmp($type, 'tree')) + { + $type = "Category"; + }else if(strcmp($type, 'compound')) + { + $type = "Compound"; + } + else $type = 'Text'; return $type; } diff --git a/tests/test-importer.php b/tests/test-importer.php index c3fbc7156..9d65356c3 100644 --- a/tests/test-importer.php +++ b/tests/test-importer.php @@ -39,16 +39,26 @@ class ImporterTests extends TAINACAN_UnitTestCase { $_SESSION['tainacan_importer'][$id]->set_items_per_step(50); -// if(!copy('./tests/attachment/json_old_tainacan_base.txt', './tests/attachment/json_old_tainacan.txt')) -// { -// return false; -// } + //if(!copy('./tests/attachment/json_old_tainacan_base.txt', './tests/attachment/json_old_tainacan.txt')) + //{ + //return false; + //} //$_SESSION['tainacan_importer'][$id]->set_file( './tests/attachment/json_old_tainacan.txt' ); $url = 'http://localhost/'; $_SESSION['tainacan_importer'][$id]->set_url($url); + // One run for each step + //Create categories $_SESSION['tainacan_importer'][$id]->run(); + + //Create empty collections + $_SESSION['tainacan_importer'][$id]->run(); + + //Create repository metadata + $_SESSION['tainacan_importer'][$id]->run(); + + $this->assertTrue(true); }*/ /*public function test_file_old_tainacan () { @@ -242,7 +252,7 @@ class ImporterTests extends TAINACAN_UnitTestCase { public function test_fetch_file(){ $csv_importer = new Importer\CSV(); $id = $csv_importer->get_id(); - /*$_SESSION['tainacan_importer'][$id]->fetch_from_remote( 'http://localhost/wordpress-test/wp-json' ); - $this->assertTrue( isset( $_SESSION['tainacan_importer'][$id]->tmp_file ) );*/ + $_SESSION['tainacan_importer'][$id]->fetch_from_remote( 'http://localhost/wordpress-test/wp-json' ); + $this->assertTrue( isset( $_SESSION['tainacan_importer'][$id]->tmp_file ) ); } } \ No newline at end of file