Update requests with query string in Vue JS api client and Items Grid Gutenberg Block to the new shorter URLs format. (#93)
This commit is contained in:
parent
e739385118
commit
e63fc6b8eb
|
@ -103,6 +103,7 @@
|
|||
margin: 94px auto 0 auto;
|
||||
position: relative;
|
||||
overflow-y: hidden;
|
||||
overflow-x: hidden;
|
||||
height: calc(100% - 94px);
|
||||
|
||||
@media screen and (max-width: 769px) {
|
||||
|
|
|
@ -4,15 +4,7 @@
|
|||
:is-full-page="false"
|
||||
:active.sync="isLoading"
|
||||
:can-cancel="false"/>
|
||||
<button
|
||||
id="metadata-column-compress-button"
|
||||
@click="isMetadataColumnCompressed = !isMetadataColumnCompressed">
|
||||
<span class="icon">
|
||||
<i
|
||||
:class="{ 'tainacan-icon-arrowleft' : isMetadataColumnCompressed, 'tainacan-icon-arrowright' : !isMetadataColumnCompressed }"
|
||||
class="tainacan-icon tainacan-icon-20px"/>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<div class="tainacan-page-title">
|
||||
<h1 v-if="isCreatingNewItem">
|
||||
<span
|
||||
|
@ -43,9 +35,7 @@
|
|||
class="tainacan-form"
|
||||
label-width="120px">
|
||||
<div class="columns">
|
||||
<div
|
||||
:class="{ 'is-12': isMetadataColumnCompressed, 'is-5-5': !isMetadataColumnCompressed }"
|
||||
class="column">
|
||||
<div class="column is-5">
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
|
@ -360,9 +350,7 @@
|
|||
</template>
|
||||
|
||||
</div>
|
||||
<div
|
||||
class="column is-4-5"
|
||||
v-show="!isMetadataColumnCompressed">
|
||||
<div class="column is-7">
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
|
@ -658,7 +646,6 @@ export default {
|
|||
isOnSequenceEdit: false,
|
||||
sequenceRightDirection: false,
|
||||
isLoading: false,
|
||||
isMetadataColumnCompressed: false,
|
||||
metadatumCollapses: [],
|
||||
collapseAll: true,
|
||||
visibility: 'publish',
|
||||
|
@ -958,11 +945,8 @@ export default {
|
|||
});
|
||||
},
|
||||
deleteAttachment(attachment) {
|
||||
console.log(attachment)
|
||||
this.removeAttachmentFromItem(attachment.id)
|
||||
.then(() => {
|
||||
console.log(this.attachmentsList)
|
||||
})
|
||||
.then(() => { })
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
});
|
||||
|
@ -1217,28 +1201,6 @@ export default {
|
|||
|
||||
@import '../../scss/_variables.scss';
|
||||
|
||||
#metadata-column-compress-button {
|
||||
position: absolute;
|
||||
z-index: 99;
|
||||
right: 0;
|
||||
top: 148px;
|
||||
max-width: 36px;
|
||||
height: 36px;
|
||||
width: 36px;
|
||||
border: none;
|
||||
background-color: $gray2;
|
||||
color: $secondary;
|
||||
padding: 0px;
|
||||
border-top-left-radius: 2px;
|
||||
border-bottom-left-radius: 2px;
|
||||
cursor: pointer;
|
||||
|
||||
.icon {
|
||||
margin-top: 2px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.page-container {
|
||||
padding: 25px 0px;
|
||||
|
||||
|
@ -1290,32 +1252,24 @@ export default {
|
|||
}
|
||||
}
|
||||
|
||||
.column.is-12 {
|
||||
.column.is-5 {
|
||||
padding-left: $page-side-padding;
|
||||
padding-right: $page-side-padding;
|
||||
}
|
||||
|
||||
.column.is-5-5 {
|
||||
max-width: 55%;
|
||||
padding-left: $page-side-padding;
|
||||
padding-right: $page-side-padding;
|
||||
transition: width 0.6s;
|
||||
|
||||
@media screen and (max-width: 769px) {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
.column.is-4-5 {
|
||||
max-width: 45%;
|
||||
padding-left: $page-side-padding;
|
||||
.column.is-7 {
|
||||
padding-left: 0;
|
||||
padding-right: $page-side-padding;
|
||||
transition: all 0.6s;
|
||||
|
||||
.field {
|
||||
padding: 10px 0px 10px 60px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 769px) {
|
||||
padding-left: $page-side-padding;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
|
@ -1406,14 +1360,12 @@ export default {
|
|||
|
||||
.file-item-control {
|
||||
position: absolute;
|
||||
background-color: $gray2;
|
||||
background-color: $gray1;
|
||||
width: 112px;
|
||||
margin: 15px;
|
||||
bottom: 0px;
|
||||
padding: 2px 8px 4px 8px;
|
||||
text-align: right;
|
||||
border-bottom-right-radius: 5px;
|
||||
border-bottom-left-radius: 5px;
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
|
@ -1447,7 +1399,7 @@ export default {
|
|||
min-width: 30px !important;
|
||||
padding: 0 !important;
|
||||
z-index: 99;
|
||||
margin-left: 10px !important;
|
||||
margin-left: 12px !important;
|
||||
|
||||
.icon {
|
||||
display: inherit;
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
type="checkbox">
|
||||
<span class="check" />
|
||||
<span class="control-label">
|
||||
<span class="checkbox-label-text">{{ `${ limitChars(option.label) }` }}</span>
|
||||
<span class="checkbox-label-text">{{ `${ (option.label? limitChars(option.label) : '') }` }}</span>
|
||||
<span
|
||||
v-if="isFilter && option.total_items != undefined"
|
||||
class="has-text-gray"> {{ "(" + option.total_items + ")" }}</span>
|
||||
|
@ -217,7 +217,7 @@
|
|||
type="checkbox">
|
||||
<span class="check" />
|
||||
<span class="control-label">
|
||||
<span class="checkbox-label-text">{{ `${ option.name ? limitChars(option.name) : limitChars(option.label) }` }}</span>
|
||||
<span class="checkbox-label-text">{{ `${ option.name ? limitChars(option.name) : (option.label ? limitChars(option.label) : '') }` }}</span>
|
||||
<span
|
||||
v-if="isFilter && option.total_items != undefined"
|
||||
class="has-text-gray">
|
||||
|
@ -229,7 +229,7 @@
|
|||
v-else
|
||||
v-model="selected"
|
||||
:native-value="option.id ? (isNaN(Number(option.id)) ? option.id : Number(option.value)) : (isNaN(Number(option.value)) ? option.value : Number(option.value))">
|
||||
{{ `${ option.name ? limitChars(option.name) : limitChars(option.label) }` }}
|
||||
{{ `${ option.name ? limitChars(option.name) : (option.label ? limitChars(option.label) : '') }` }}
|
||||
<span
|
||||
v-if="isFilter && option.total_items != undefined"
|
||||
class="has-text-gray">
|
||||
|
@ -372,7 +372,6 @@
|
|||
if (label.length > this.maxTextToShow){
|
||||
return label.slice(0, this.maxTextToShow)+'...';
|
||||
}
|
||||
|
||||
return label;
|
||||
},
|
||||
beforePage(){
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
:style="{ 'max-width': size != undefined ? size + 'px' : '112px' }"
|
||||
v-if="showName && file.title != undefined">{{ file.title.rendered }}</figcaption>
|
||||
<div
|
||||
:class="{ 'rounded': showName }"
|
||||
:style="{ 'width': size != undefined ? size + 'px' : '112px', 'height': size != undefined ? size + 'px' : '112px' }"
|
||||
class="image-wrapper">
|
||||
<div
|
||||
|
@ -100,17 +99,15 @@ export default {
|
|||
.image, .file-placeholder {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
figcaption {
|
||||
background-color: $gray1;
|
||||
}
|
||||
}
|
||||
.image-wrapper {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
|
||||
&.rounded {
|
||||
border-bottom-left-radius: 5px;
|
||||
border-bottom-right-radius: 5px;
|
||||
}
|
||||
|
||||
.image {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
@ -138,9 +135,7 @@ export default {
|
|||
}
|
||||
|
||||
figcaption {
|
||||
background-color: $gray1;
|
||||
border-top-left-radius: 5px;
|
||||
border-top-right-radius: 5px;
|
||||
background-color: white;
|
||||
padding: 8px 15px;
|
||||
font-size: 9px;
|
||||
width: 100%;
|
||||
|
|
|
@ -4,15 +4,7 @@
|
|||
<b-loading
|
||||
:active.sync="isLoading"
|
||||
:can-cancel="false"/>
|
||||
<button
|
||||
id="metadata-column-compress-button"
|
||||
@click="isMetadataColumnCompressed = !isMetadataColumnCompressed">
|
||||
<span class="icon">
|
||||
<i
|
||||
:class="{ 'tainacan-icon-arrowleft' : isMetadataColumnCompressed, 'tainacan-icon-arrowright' : !isMetadataColumnCompressed }"
|
||||
class="tainacan-icon tainacan-icon-20px"/>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<div class="tainacan-page-title">
|
||||
<h1>
|
||||
<span
|
||||
|
@ -30,9 +22,7 @@
|
|||
</div>
|
||||
<div class="tainacan-form">
|
||||
<div class="columns">
|
||||
<div
|
||||
:class="{ 'is-12': isMetadataColumnCompressed, 'is-5-5': !isMetadataColumnCompressed }"
|
||||
class="column">
|
||||
<div class="column is-5">
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
|
@ -131,7 +121,7 @@
|
|||
disabled/>
|
||||
</b-field>
|
||||
<!-- Exposers --------------------------------------------- -->
|
||||
<div>
|
||||
<!-- <div>
|
||||
<b-loading :active.sync="isLoadingMetadatumMappers"/>
|
||||
<div v-if="!isLoadingMetadatumMappers">
|
||||
<b-collapse :open="false">
|
||||
|
@ -193,7 +183,7 @@
|
|||
</div>
|
||||
</b-collapse>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
|
@ -206,13 +196,7 @@
|
|||
</template>
|
||||
|
||||
</div>
|
||||
<!--<b-tabs v-model="activeTab">-->
|
||||
<!--<b-tab-item-->
|
||||
<!--style="margin: 0 -1rem 0 -1rem !important;"-->
|
||||
<!--:label="$i18n.get('title_item_page')">-->
|
||||
<div
|
||||
v-show="!isMetadataColumnCompressed"
|
||||
class="column is-4-5">
|
||||
<div class="column is-7">
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
|
@ -312,11 +296,6 @@
|
|||
v-html="formHooks['view-item']['end-right'].join('')"/>
|
||||
</template>
|
||||
</div>
|
||||
<!--</b-tab-item>-->
|
||||
<!--<b-tab-item :label="$i18n.get('activities')">-->
|
||||
<!--<activites-page/>-->
|
||||
<!--</b-tab-item>-->
|
||||
<!--</b-tabs>-->
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="form-submission-footer">
|
||||
|
@ -353,7 +332,6 @@
|
|||
itemId: Number,
|
||||
isLoading: false,
|
||||
isLoadingMetadatumMappers: false,
|
||||
isMetadataColumnCompressed: false,
|
||||
open: true,
|
||||
collectionName: '',
|
||||
thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png',
|
||||
|
@ -478,28 +456,6 @@
|
|||
|
||||
@import '../../scss/_variables.scss';
|
||||
|
||||
#metadata-column-compress-button {
|
||||
position: absolute;
|
||||
z-index: 99;
|
||||
right: 0;
|
||||
top: 148px;
|
||||
max-width: 36px;
|
||||
height: 36px;
|
||||
width: 36px;
|
||||
border: none;
|
||||
background-color: $gray2;
|
||||
color: $secondary;
|
||||
padding: 0;
|
||||
border-top-left-radius: 2px;
|
||||
border-bottom-left-radius: 2px;
|
||||
cursor: pointer;
|
||||
|
||||
.icon {
|
||||
margin-top: 2px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.page-container {
|
||||
padding: 25px 0;
|
||||
|
||||
|
@ -555,28 +511,24 @@
|
|||
margin-bottom: 70px;
|
||||
}
|
||||
|
||||
.column.is-5-5 {
|
||||
width: 45.833333333%;
|
||||
.column.is-5 {
|
||||
padding-left: $page-side-padding;
|
||||
padding-right: $page-side-padding;
|
||||
transition: width 0.6s;
|
||||
|
||||
@media screen and (max-width: 769px) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.column.is-4-5 {
|
||||
width: 37.5%;
|
||||
padding-left: $page-side-padding;
|
||||
.column.is-7 {
|
||||
padding-left: 0;
|
||||
padding-right: $page-side-padding;
|
||||
transition: all 0.6s;
|
||||
|
||||
.field {
|
||||
padding: 10px 0 10px 30px;
|
||||
|
||||
}
|
||||
|
||||
@media screen and (max-width: 769px) {
|
||||
padding-left: $page-side-padding;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
@ -653,7 +605,6 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section-status{
|
||||
padding-bottom: 16px;
|
||||
font-size: 0.75rem;
|
||||
|
@ -667,7 +618,6 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section-attachments {
|
||||
border: 1px solid $gray2;
|
||||
height: 250px;
|
||||
|
@ -675,9 +625,7 @@
|
|||
resize: vertical;
|
||||
overflow: auto;
|
||||
|
||||
p {
|
||||
margin: 4px 15px
|
||||
}
|
||||
p { margin: 4px 15px }
|
||||
}
|
||||
|
||||
.uploaded-files {
|
||||
|
|
|
@ -9,17 +9,26 @@ class CSV extends Exporter {
|
|||
public function __construct($attributes = array()) {
|
||||
parent::__construct($attributes);
|
||||
$this->set_accepted_mapping_methods('any'); // set all method to mapping
|
||||
//$this->set_accepted_mapping_methods('list', [ "dublin-core" => "Tainacan\\Exposers\\Mappers\\Dublin_Core" ]); // set specific list of methods to mapping
|
||||
//todo create list only slug
|
||||
$this->accept_no_mapping = true;
|
||||
//$this->set_accepted_mapping_methods('list', [ "dublin-core" ]); // set specific list of methods to mapping
|
||||
$this->set_default_options([
|
||||
'delimiter' => ',',
|
||||
'multivalued_delimiter' => '||',
|
||||
'enclosure' => '"'
|
||||
]);
|
||||
}
|
||||
|
||||
public function filter_multivalue_separator($separator) {
|
||||
return $this->get_option('multivalued_delimiter');
|
||||
}
|
||||
|
||||
public function process_item( $processed_item ) {
|
||||
|
||||
|
||||
$mapper = $this->get_current_mapper();
|
||||
error_log(json_encode($mapper));
|
||||
$line = [];
|
||||
|
||||
add_filter('tainacan-item-metadata-get-multivalue-separator', [$this, 'filter_multivalue_separator']);
|
||||
|
||||
foreach ($processed_item as $meta_key => $meta) {
|
||||
|
||||
if (!$meta) {
|
||||
|
@ -31,12 +40,13 @@ class CSV extends Exporter {
|
|||
|
||||
}
|
||||
|
||||
$line_string = $this->str_putcsv($line, ',', '"');
|
||||
remove_filter('tainacan-item-metadata-get-multivalue-separator', [$this, 'filter_multivalue_separator']);
|
||||
|
||||
$line_string = $this->str_putcsv($line, $this->get_option('delimiter'), $this->get_option('enclosure'));
|
||||
|
||||
|
||||
$this->append_to_file('exporter', $line_string."\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function output_header() {
|
||||
|
@ -63,7 +73,7 @@ class CSV extends Exporter {
|
|||
}
|
||||
}
|
||||
|
||||
$line_string = $this->str_putcsv($line, ',', '"');
|
||||
$line_string = $this->str_putcsv($line, $this->get_option('delimiter'), $this->get_option('enclosure'));
|
||||
|
||||
$this->append_to_file('exporter', $line_string."\n");
|
||||
|
||||
|
@ -107,7 +117,7 @@ class CSV extends Exporter {
|
|||
</div>
|
||||
</span>
|
||||
<div class="control is-clearfix">
|
||||
<input class="input" type="text" name="delimiter" value="<?php echo $this->get_option('delimiter'); ?>">
|
||||
<input class="input" type="text" name="delimiter" maxlength="1" value="<?php echo $this->get_option('delimiter'); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -151,36 +161,11 @@ class CSV extends Exporter {
|
|||
</div>
|
||||
</span>
|
||||
<div class="control is-clearfix">
|
||||
<input class="input" type="text" name="enclosure" value="<?php echo $this->get_option('enclosure'); ?>">
|
||||
<input class="input" type="text" name="enclosure" value="<?php echo esc_attr($this->get_option('enclosure')); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label"><?php _e('File Encoding', 'tainacan'); ?></label>
|
||||
<span class="help-wrapper">
|
||||
<a class="help-button has-text-secondary">
|
||||
<span class="icon is-small">
|
||||
<i class="mdi mdi-help-circle-outline" ></i>
|
||||
</span>
|
||||
</a>
|
||||
<div class="help-tooltip">
|
||||
<div class="help-tooltip-header">
|
||||
<h5><?php _e('File Encoding', 'tainacan'); ?></h5>
|
||||
</div>
|
||||
<div class="help-tooltip-body">
|
||||
<p><?php _e('The encoding of the CSV file.', 'tainacan'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
<div class="control is-clearfix">
|
||||
<div class="select">
|
||||
<select name="encode">
|
||||
<option value="utf8" <?php selected($this->get_option('encode'), 'utf8'); ?> >UTF-8</option>
|
||||
<option value="iso88591" <?php selected($this->get_option('encode'), 'iso88591'); ?> >ISO-88591</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
|
|
|
@ -72,12 +72,7 @@ abstract class CommunImportExport {
|
|||
* Example of the structure of this propery for one collection:
|
||||
* 0 => [
|
||||
* 'id' => 12,
|
||||
* 'mapping' => [
|
||||
* 30 => 'column1'
|
||||
* 31 => 'column2'
|
||||
* ],
|
||||
* 'total_items' => 1234,
|
||||
* 'source_id' => 55
|
||||
* ],
|
||||
*
|
||||
* use add_collection() and remove_collection() to interact with thiis array.
|
||||
|
@ -104,6 +99,16 @@ abstract class CommunImportExport {
|
|||
}
|
||||
}
|
||||
|
||||
public function update_collection($index, $collection_definition) {
|
||||
if (isset($this->collections[$index]))
|
||||
$this->collections[$index] = $collection_definition;
|
||||
}
|
||||
|
||||
public function update_current_collection($collection_definition) {
|
||||
$current_collection = $this->get_current_collection();
|
||||
return $this->update_collection($current_collection, $collection_definition);
|
||||
}
|
||||
|
||||
public function next_item() {
|
||||
$current_collection = $this->get_current_collection();
|
||||
$current_collection_item = $this->get_current_collection_item();
|
||||
|
@ -484,6 +489,7 @@ class Exporter extends CommunImportExport {
|
|||
private $send_email = null;
|
||||
protected $mapping_list = [];
|
||||
public $mapping_selected = "";
|
||||
protected $accept_no_mapping = true;
|
||||
|
||||
protected $steps = [
|
||||
[
|
||||
|
@ -502,7 +508,13 @@ class Exporter extends CommunImportExport {
|
|||
];
|
||||
|
||||
public function __construct($attributess = array()) {
|
||||
$this->array_attributes = array_merge($this->array_attributes, ['current_collection_item', 'current_collection']);
|
||||
$this->array_attributes = array_merge($this->array_attributes, [
|
||||
'mapping_selected',
|
||||
'current_collection_item',
|
||||
'current_collection',
|
||||
'output_files',
|
||||
'send_email'
|
||||
]);
|
||||
parent::__construct();
|
||||
$_SESSION['tainacan_exporter'][$this->get_id()] = $this;
|
||||
if (!empty($attributess)) {
|
||||
|
@ -526,14 +538,11 @@ class Exporter extends CommunImportExport {
|
|||
global $Tainacan_Exporter_Handler;
|
||||
$exporter_definition = $Tainacan_Exporter_Handler->get_exporter_by_object($this);
|
||||
|
||||
$return['mapping_selected'] = $this->get_mapping_selected();
|
||||
$return['output_files'] = $this->output_files;
|
||||
$return['send_email'] = $this->send_email;
|
||||
|
||||
if ($short === false) {
|
||||
$return['manual_collection'] = $exporter_definition['manual_collection'];
|
||||
$return['mapping_accept'] = $this->mapping_accept;
|
||||
$return['mapping_list'] = $this->mapping_list;
|
||||
$return['accept_no_mapping'] = $this->accept_no_mapping;
|
||||
$return['options_form'] = $this->options_form();
|
||||
}
|
||||
|
||||
|
@ -541,59 +550,19 @@ class Exporter extends CommunImportExport {
|
|||
}
|
||||
|
||||
public function add_collection(array $collection) {
|
||||
if (!isset($collection['total_items'])) {
|
||||
$collection['total_items'] = 10;
|
||||
}
|
||||
// if (!isset($collection['total_items'])) {
|
||||
// $collection['total_items'] = 10;
|
||||
// }
|
||||
parent::add_collection($collection);
|
||||
|
||||
$this->update_collections_mapping();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current mapper object, if one was chosen by the user, false Otherwise
|
||||
*/
|
||||
public function get_current_mapper() {
|
||||
return \Tainacan\Mappers_Handler::get_instance()->get_mapper($this->get_mapping_selected());
|
||||
}
|
||||
|
||||
private function update_collections_mapping() {
|
||||
$mapper_handler = Tainacan\Mappers_Handler::get_instance();
|
||||
$collection_repo = Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
foreach ($this->get_collections() as $index => $col) {
|
||||
|
||||
$collection_id = $col['id'];
|
||||
|
||||
$collection = $collection_repo->fetch((int)$collection_id);
|
||||
|
||||
if ( ! $collection instanceof \Tainacan\Entities\Collection ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$metas = $collection->get_metadata();
|
||||
|
||||
$mapping = [];
|
||||
$current_mapping = isset($col['mapping']) ? $col['mapping'] : [];
|
||||
|
||||
if ( $mapper = $mapper_handler->get_mapper($this->get_mapping_selected()) ) {
|
||||
|
||||
foreach ($metas as $meta) {
|
||||
|
||||
$metadatum_mapping = $meta->get_exposer_mapping();
|
||||
//var_dump($metadatum_mapping);
|
||||
|
||||
if(array_key_exists($mapper->slug, $metadatum_mapping)) {
|
||||
$mapping[$meta->get_name()] = $metadatum_mapping[$mapper->slug];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$col['mapping'] = $mapping;
|
||||
if ($col['mapping'] !== $current_mapping) {
|
||||
$this->add_collection($col);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method implemented by child importer/exporter to return the HTML of the Options Form to be rendered in the Importer page
|
||||
|
@ -665,6 +634,13 @@ class Exporter extends CommunImportExport {
|
|||
|
||||
$this->add_log('Proccessing item index ' . $index . ' in collection ' . $collection_definition['id'] );
|
||||
$items = $tainacan_items->fetch($filters, $collection_id, 'WP_Query');
|
||||
|
||||
if ( !isset($collection_definition['total_items']) ) {
|
||||
$collection_definition['total_items'] = $items->found_posts;
|
||||
$this->update_current_collection($collection_definition);
|
||||
}
|
||||
|
||||
|
||||
$data = [];
|
||||
while ($items->have_posts()) {
|
||||
$items->the_post();
|
||||
|
@ -681,6 +657,12 @@ class Exporter extends CommunImportExport {
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an Item as input and return an array of ItemMetadataObjects
|
||||
* If a mapper is selected, the array keys will be the slugs of the metadata
|
||||
* declared by the mapper, in the same order.
|
||||
* Note that if one of the metadata is not mapped, this array item will be null
|
||||
*/
|
||||
private function map_item_metadata(\Tainacan\Entities\Item $item) {
|
||||
|
||||
$mapper = $this->get_current_mapper();
|
||||
|
@ -765,7 +747,6 @@ class Exporter extends CommunImportExport {
|
|||
|
||||
public function set_mapping_selected($mapping_selected) {
|
||||
$this->mapping_selected = $mapping_selected;
|
||||
$this->update_collections_mapping();
|
||||
}
|
||||
|
||||
public function get_mapping_selected() {
|
||||
|
@ -775,11 +756,20 @@ class Exporter extends CommunImportExport {
|
|||
public function set_send_email($email) {
|
||||
$this->send_email = $email;
|
||||
}
|
||||
public function get_send_email() {
|
||||
return $this->send_email;
|
||||
}
|
||||
|
||||
public function finished() {
|
||||
if($this->send_email != null) {
|
||||
$msg = 'export completed successfully';
|
||||
wp_mail($this->send_email, __('Finished export.', 'tainacan'), __($msg, 'tainacan'));
|
||||
if($this->get_send_email() == 1) {
|
||||
$author = $this->get_transient('author');
|
||||
$user = get_userdata( (int) $author );
|
||||
if ($user instanceof \WP_User) {
|
||||
$msg = __('export completed successfully', 'tainacan');
|
||||
$this->add_log('Sending email to ' . $user->user_email);
|
||||
wp_mail($user->user_email, __('Finished export.', 'tainacan'), $msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -794,6 +784,9 @@ class Exporter extends CommunImportExport {
|
|||
private function set_output_files($output_files) {
|
||||
$this->output_files = $output_files;
|
||||
}
|
||||
private function get_output_files() {
|
||||
return $this->output_files;
|
||||
}
|
||||
/**
|
||||
* runs one iteration
|
||||
*/
|
||||
|
|
|
@ -222,7 +222,7 @@ class CSV extends Importer {
|
|||
</div>
|
||||
</span>
|
||||
<div class="control is-clearfix">
|
||||
<input class="input" type="text" name="delimiter" value="<?php echo $this->get_option('delimiter'); ?>">
|
||||
<input class="input" type="text" name="delimiter" value="<?php echo esc_attr($this->get_option('delimiter')); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue