Merge remote-tracking branch 'origin/develop' into export

This commit is contained in:
Jacson Passold 2018-07-10 13:31:18 -03:00
commit 1d0fb3fa97
2 changed files with 46 additions and 42 deletions

View File

@ -30,7 +30,6 @@ return apply_filters( 'tainacan-admin-i18n', [
'terms' => __( 'Terms', 'tainacan' ),
'mapping' => __( 'Mapping', 'tainacan' ),
'importers' => __( 'Importers', 'tainacan' ),
'metadata' => __( 'metadata', 'tainacan' ),
// Actions
'edit' => __( 'Edit', 'tainacan' ),
@ -255,7 +254,6 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_update_draft' => __( 'Update draft', 'tainacan' ),
'label_return_to_draft' => __( 'Return to draft', 'tainacan' ),
'label_publish' => __( 'Publish', 'tainacan' ),
'label_send_to_trash' => __( 'Send to trash', 'tainacan' ),
'label_update' => __( 'Update', 'tainacan' ),
'label_mapper_metadata' => __( 'Mapper Metadata', 'tainacan' ),
'label_add_more_mapper_metadata' => __( 'Add more mapper\'s metadata', 'tainacan' ),
@ -283,7 +281,6 @@ return apply_filters( 'tainacan-admin-i18n', [
'instruction_search' => __( 'Search', 'tainacan' ),
'instruction_search_in_repository' => __( 'Search in repository', 'tainacan' ),
'instruction_select_a_target_collection' => __( 'Select a target collection', 'tainacan' ),
'instruction_select_a_metadatum' => __( 'Select a metadatum', 'tainacan' ),
'instruction_select_a_mapper' => __( 'Select a mapper', 'tainacan' ),
'instruction_select_an_importer_type' => __( 'Select an importer type from the options above:', 'tainacan' ),
'instruction_drop_file_or_click_to_upload' => __( 'Drop your source file or click here to upload.', 'tainacan' ),

View File

@ -8,19 +8,6 @@
* used to learn how to write an importer and to
* create test collections and items
*
* Example how to invoke it
*
* add_action('init', function() {
* if ( isset($_GET['run_test_importer']) && $_GET['run_test_importer'] == 'go' ) {
* global $Tainacan_Importer_Handler;
* $test = new \Tainacan\Importer\Test_Importer();
* $Tainacan_Importer_Handler->add_to_queue($test);
* }
* });
*
* Put this code somewhere and access any URL of your site with ?run_test_importer=go
*
* TODO: check validate() methods and write log & abort importer in case of error.
*/
namespace Tainacan\Importer;
@ -70,6 +57,26 @@ class Test_Importer extends Importer {
$this->items_repo = \Tainacan\Repositories\Items::get_instance();
$this->metadata_repo = \Tainacan\Repositories\Metadata::get_instance();
$this->remove_import_method('file');
$this->remove_import_method('url');
$this->set_default_options([
'items_col_1' => 20,
'items_col_2' => 20
]);
}
public function options_form() {
$form = '<label class="label">' . __('Number of items in collection 1', 'tainacan') . '</label>';
$form .= '<input type="text" class="input" name="items_col_1" value="' . $this->get_option('items_col_1') . '" />';
$form .= '<label class="label">' . __('Number of items in collection 2', 'tainacan') . '</label>';
$form .= '<input type="text" class="input" name="items_col_2" value="' . $this->get_option('items_col_2') . '" />';
return $form;
}
public function create_taxonomies() {
@ -324,10 +331,10 @@ class Test_Importer extends Importer {
* Here we are just returning random values
*/
public function get_col1_number_of_items() {
return 10;
return $this->get_option('items_col_1');
}
public function get_col2_number_of_items() {
return 20;
return $this->get_option('items_col_2');
}
public function get_col1_item($index) {