Merge branch 'develop' of github.com:tainacan/tainacan into develop
This commit is contained in:
commit
e817d2761b
|
@ -0,0 +1,123 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="columns is-multiline tnc-advanced-search-container">
|
||||
|
||||
<div
|
||||
v-for="searchField in totalSearchMetadata"
|
||||
:key="searchField"
|
||||
class="field column is-12 tainacan-form">
|
||||
|
||||
<b-field
|
||||
class="columns"
|
||||
grouped>
|
||||
<b-field class="column is-one-fifth">
|
||||
<b-select
|
||||
@input="addToAdvancedSearchQuery">
|
||||
<option
|
||||
v-for="(metadata, key) in metadataList"
|
||||
v-if="metadata.enabled"
|
||||
:value="metadata.id"
|
||||
:key="key"
|
||||
>{{ metadata.name }}</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
<b-field class="column is-two-thirds">
|
||||
<b-input
|
||||
@input="addToAdvancedSearchQuery"/>
|
||||
</b-field>
|
||||
|
||||
<b-field class="column is-one-fifth">
|
||||
<b-select
|
||||
@input="addToAdvancedSearchQuery">
|
||||
<option
|
||||
v-for="(opt, key) in compare"
|
||||
:value="key"
|
||||
:key="key"
|
||||
>{{ opt }}</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
<div
|
||||
:style="{'padding-left': '25px !important'}"
|
||||
class="field column is-12">
|
||||
|
||||
<div class="is-inline">
|
||||
<b-icon
|
||||
icon="plus-circle"
|
||||
size="is-small"
|
||||
type="is-info"/>
|
||||
<a
|
||||
@click="addSearchMetadata"
|
||||
class="is-info is-small">
|
||||
Adicionar mais um campo de busca</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field is-grouped is-pulled-right">
|
||||
<p class="control">
|
||||
<button
|
||||
@click="clearSearch"
|
||||
class="button is-outlined">Limpar busca</button>
|
||||
</p>
|
||||
<p class="control">
|
||||
<button
|
||||
@click="searchAdvanced"
|
||||
class="button is-secondary">Buscar</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<pre>{{ metadataIds }} {{ toCompare }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "AdvancedSearch",
|
||||
props: {
|
||||
metadataList: Array,
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
compare: {'=':'Igual', '!=':'Diferente', 'IN':'Contém', 'NOT IN':'Não Contém'},
|
||||
totalSearchMetadata: 1,
|
||||
advancedSearchQuery: {},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addSearchMetadata(){
|
||||
this.totalSearchMetadata++;
|
||||
},
|
||||
clearSearch(){
|
||||
this.totalSearchMetadata = 1;
|
||||
},
|
||||
searchAdvanced(){
|
||||
|
||||
},
|
||||
addToAdvancedSearchQuery(optionValue){
|
||||
console.log(optionValue);
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@import '../../scss/_variables.scss';
|
||||
|
||||
.tnc-advanced-search-container {
|
||||
padding-top: 47px;
|
||||
padding-right: $page-side-padding;
|
||||
padding-left: $page-side-padding;
|
||||
padding-top: 47px;
|
||||
|
||||
.column {
|
||||
padding: 0 0.3rem 0.3rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
|
@ -195,14 +195,17 @@
|
|||
|
||||
if (formNotSaved) {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_category_not_saved'),
|
||||
onConfirm: () => {
|
||||
next();
|
||||
},
|
||||
cancelText: this.$i18n.get('cancel'),
|
||||
confirmText: this.$i18n.get('continue'),
|
||||
type: 'is-secondary'
|
||||
});
|
||||
onConfirm: () => {
|
||||
next();
|
||||
},
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
cancelText: this.$i18n.get('cancel'),
|
||||
confirmText: this.$i18n.get('continue'),
|
||||
type: 'is-success'
|
||||
});
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
|
|
@ -301,6 +301,7 @@
|
|||
class="control"
|
||||
custom>
|
||||
<b-checkbox
|
||||
v-if="registeredViewModes[viewMode] != undefined"
|
||||
@input="updateViewModeslist(viewMode)"
|
||||
:value="checkIfViewModeEnabled(viewMode)">
|
||||
{{ registeredViewModes[viewMode].label }}
|
||||
|
@ -326,6 +327,7 @@
|
|||
@focus="clearErrors('default_view_mode')">
|
||||
<option
|
||||
v-for="(viewMode, index) of form.enabled_view_modes"
|
||||
v-if="registeredViewModes[viewMode] != undefined"
|
||||
:key="index"
|
||||
:value="viewMode">{{ registeredViewModes[viewMode].label }}
|
||||
</option>
|
||||
|
|
|
@ -676,14 +676,17 @@ export default {
|
|||
beforeRouteLeave ( to, from, next ) {
|
||||
if (this.item.status == 'auto-draft') {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_item_not_saved'),
|
||||
onConfirm: () => {
|
||||
next();
|
||||
},
|
||||
cancelText: this.$i18n.get('cancel'),
|
||||
confirmText: this.$i18n.get('continue'),
|
||||
type: 'is-secondary'
|
||||
});
|
||||
onConfirm: () => {
|
||||
next();
|
||||
},
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
cancelText: this.$i18n.get('cancel'),
|
||||
confirmText: this.$i18n.get('continue'),
|
||||
type: 'is-success'
|
||||
});
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@
|
|||
},
|
||||
deleteOneCategory(categoryId) {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_category_delete'),
|
||||
onConfirm: () => {
|
||||
this.deleteCategory(categoryId)
|
||||
|
@ -205,11 +206,15 @@
|
|||
// queue: true
|
||||
// });
|
||||
});
|
||||
}
|
||||
},
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
type: 'is-success'
|
||||
});
|
||||
},
|
||||
deleteSelectedCategories() {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_selected_categories_delete'),
|
||||
onConfirm: () => {
|
||||
|
||||
|
@ -237,7 +242,10 @@
|
|||
}
|
||||
}
|
||||
this.allCategoriesOnPageSelected = false;
|
||||
}
|
||||
},
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
type: 'is-success'
|
||||
});
|
||||
},
|
||||
goToCategoryPage(categoryId) {
|
||||
|
|
|
@ -230,6 +230,7 @@ export default {
|
|||
},
|
||||
deleteOneCollection(collectionId) {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.isOnTrash ? this.$i18n.get('info_warning_collection_delete') : this.$i18n.get('info_warning_collection_trash'),
|
||||
onConfirm: () => {
|
||||
this.deleteCollection({ collectionId: collectionId, isPermanently: this.isOnTrash })
|
||||
|
@ -254,11 +255,15 @@ export default {
|
|||
// queue: true
|
||||
// })
|
||||
});
|
||||
}
|
||||
},
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
type: 'is-success'
|
||||
});
|
||||
},
|
||||
deleteSelectedCollections() {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.isOnTrash ? this.$i18n.get('info_warning_selected_collections_delete') : this.$i18n.get('info_warning_selected_collections_trash'),
|
||||
onConfirm: () => {
|
||||
|
||||
|
@ -286,7 +291,10 @@ export default {
|
|||
}
|
||||
}
|
||||
this.allCollectionsOnPageSelected = false;
|
||||
}
|
||||
},
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
type: 'is-success'
|
||||
});
|
||||
},
|
||||
goToCollectionPage(collectionId) {
|
||||
|
|
|
@ -195,15 +195,18 @@ export default {
|
|||
}
|
||||
if ((this.openedFieldId != '' && this.openedFieldId != undefined) || hasUnsavedForms ) {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_fields_not_saved'),
|
||||
onConfirm: () => {
|
||||
this.onEditionCanceled();
|
||||
next();
|
||||
},
|
||||
cancelText: this.$i18n.get('cancel'),
|
||||
confirmText: this.$i18n.get('continue'),
|
||||
type: 'is-secondary'
|
||||
});
|
||||
onConfirm: () => {
|
||||
this.onEditionCanceled();
|
||||
next();
|
||||
},
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
cancelText: this.$i18n.get('cancel'),
|
||||
confirmText: this.$i18n.get('continue'),
|
||||
type: 'is-success'
|
||||
});
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
|
|
@ -222,15 +222,18 @@ export default {
|
|||
}
|
||||
if ((this.openedFilterId != '' && this.openedFilterId != undefined) || hasUnsavedForms ) {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_filters_not_saved'),
|
||||
onConfirm: () => {
|
||||
this.onEditionCanceled();
|
||||
next();
|
||||
},
|
||||
cancelText: this.$i18n.get('cancel'),
|
||||
confirmText: this.$i18n.get('continue'),
|
||||
type: 'is-secondary'
|
||||
});
|
||||
onConfirm: () => {
|
||||
this.onEditionCanceled();
|
||||
next();
|
||||
},
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
cancelText: this.$i18n.get('cancel'),
|
||||
confirmText: this.$i18n.get('continue'),
|
||||
type: 'is-success'
|
||||
});
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
|
|
@ -214,6 +214,7 @@ export default {
|
|||
},
|
||||
deleteOneItem(itemId) {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.isOnTrash ? this.$i18n.get('info_warning_item_delete') : this.$i18n.get('info_warning_item_trash'),
|
||||
onConfirm: () => {
|
||||
this.deleteItem({ itemId: itemId, isPermanently: this.isOnTrash })
|
||||
|
@ -239,11 +240,15 @@ export default {
|
|||
// queue: true
|
||||
// })
|
||||
});
|
||||
}
|
||||
},
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
type: 'is-success'
|
||||
});
|
||||
},
|
||||
deleteSelectedItems() {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.isOnTrash ? this.$i18n.get('info_warning_selected_items_delete') : this.$i18n.get('info_warning_selected_items_trash'),
|
||||
onConfirm: () => {
|
||||
|
||||
|
@ -275,7 +280,10 @@ export default {
|
|||
}
|
||||
}
|
||||
this.allItemsOnPageSelected = false;
|
||||
}
|
||||
},
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
type: 'is-success'
|
||||
});
|
||||
},
|
||||
goToItemPage(item) {
|
||||
|
|
|
@ -213,13 +213,16 @@ export default {
|
|||
// Checks if user is deleting a term with unsaved info.
|
||||
if (term.id == 'new' || !term.saved || term.opened) {
|
||||
this.$dialog.confirm({
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_terms_not_saved'),
|
||||
onCancel: () => { return },
|
||||
onConfirm: () => { this.removeTerm(term);},
|
||||
cancelText: this.$i18n.get('cancel'),
|
||||
confirmText: this.$i18n.get('continue'),
|
||||
type: 'is-secondary'
|
||||
});
|
||||
onCancel: () => { return },
|
||||
onConfirm: () => { this.removeTerm(term); },
|
||||
icon: 'alert-circle',
|
||||
hasIcon: true,
|
||||
cancelText: this.$i18n.get('cancel'),
|
||||
confirmText: this.$i18n.get('continue'),
|
||||
type: 'is-success'
|
||||
});
|
||||
} else{
|
||||
this.removeTerm(term);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<div class="control has-icons-right is-small is-clearfix">
|
||||
<input
|
||||
autocomplete="on"
|
||||
:placeholder="$i18n.get('instruction_search_repository')"
|
||||
:placeholder="$i18n.get('instruction_search')"
|
||||
class="input is-small"
|
||||
type="search"
|
||||
v-model="searchTerm">
|
||||
|
@ -28,7 +28,7 @@
|
|||
<i class="mdi mdi-magnify" />
|
||||
</span>
|
||||
</div>
|
||||
<a href="">{{ $i18n.get('advanced_search') }}</a>
|
||||
<a @click.prevent="openAdvancedSearchComponent">{{ $i18n.get('advanced_search') }}</a>
|
||||
</span>
|
||||
<a
|
||||
class="level-item"
|
||||
|
@ -50,6 +50,13 @@ export default {
|
|||
searchTerm: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openAdvancedSearchComponent(){
|
||||
console.log('Called here', this.$route.meta);
|
||||
this.$set(this.$route.meta, 'openAdvancedSearch', !this.$route.meta.openAdvancedSearch);
|
||||
console.log('Called here', this.$route.meta);
|
||||
}
|
||||
},
|
||||
props: {
|
||||
isMenuCompressed: false
|
||||
}
|
||||
|
@ -105,7 +112,7 @@ export default {
|
|||
color: $tertiary;
|
||||
}
|
||||
.search-area {
|
||||
display: none;//display: flex;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 36px;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ const routes = [
|
|||
]
|
||||
},
|
||||
|
||||
{ path: '/items', name: 'ItemsPage', component: ItemsPage, meta: {title: i18nGet('title_items_page'), icon: 'file-multiple'} },
|
||||
{ path: '/items', name: 'ItemsPage', component: ItemsPage, meta: {title: i18nGet('title_items_page'), icon: 'file-multiple', openAdvancedSearch: false} },
|
||||
{ path: '/items/new', name: 'ItemCreationForm', component: ItemEditionForm, meta: {title: i18nGet('title_create_item'), icon: 'file-multiple'} },
|
||||
|
||||
{ path: '/filters', name: 'FiltersPage', component: FiltersPage, meta: {title: i18nGet('title_repository_filters_page'), icon: 'filter'} },
|
||||
|
|
|
@ -44,7 +44,9 @@
|
|||
</button>
|
||||
</p>
|
||||
</b-field>
|
||||
<!-- <a class="is-size-7 is-secondary is-pulled-right">Busca avançada</a> -->
|
||||
<a
|
||||
@click.prevent="openAdvancedSearchComponent"
|
||||
class="is-size-7 is-secondary is-pulled-right">{{ $i18n.get('advanced_search') }}</a>
|
||||
|
||||
<h3 class="has-text-weight-semibold">{{ $i18n.get('filters') }}</h3>
|
||||
<a
|
||||
|
@ -241,8 +243,10 @@
|
|||
</div>
|
||||
|
||||
|
||||
<!-- ADVANCED SEARCH
|
||||
<advanced-search /> -->
|
||||
<!-- ADVANCED SEARCH -->
|
||||
<advanced-search
|
||||
v-if="openAdvancedSearch"
|
||||
:metadata-list="fields" />
|
||||
|
||||
<!-- --------------- -->
|
||||
|
||||
|
@ -332,7 +336,7 @@
|
|||
import ItemsList from '../../components/lists/items-list.vue';
|
||||
import FiltersItemsList from '../../components/search/filters-items-list.vue';
|
||||
import Pagination from '../../components/search/pagination.vue'
|
||||
// import AdvancedSearch from '../../components/advanced-search/advanced-search.vue';
|
||||
import AdvancedSearch from '../../components/advanced-search/advanced-search.vue';
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
|
@ -361,6 +365,10 @@
|
|||
enabledViewModes: Object // Used only on theme
|
||||
},
|
||||
computed: {
|
||||
openAdvancedSearch(){
|
||||
console.log('Called here', this.$route.meta);
|
||||
return this.$route.meta.openAdvancedSearch;
|
||||
},
|
||||
items() {
|
||||
return this.getItems();
|
||||
},
|
||||
|
@ -396,7 +404,7 @@
|
|||
ItemsList,
|
||||
FiltersItemsList,
|
||||
Pagination,
|
||||
// AdvancedSearch,
|
||||
AdvancedSearch,
|
||||
},
|
||||
watch: {
|
||||
tableFields() {
|
||||
|
@ -428,6 +436,11 @@
|
|||
'getViewMode',
|
||||
'getTotalItems'
|
||||
]),
|
||||
openAdvancedSearchComponent(){
|
||||
console.log('Called here', this.$route.meta);
|
||||
this.$set(this.$route.meta, 'openAdvancedSearch', !this.$route.meta.openAdvancedSearch);
|
||||
console.log('Called here', this.$route.meta);
|
||||
},
|
||||
updateSearch() {
|
||||
this.$eventBusSearch.setSearchQuery(this.futureSearchQuery);
|
||||
},
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// Tainacan modals
|
||||
.tainacan-modal-title {
|
||||
h1, h2 {
|
||||
|
@ -35,9 +34,64 @@
|
|||
padding: 80px 0em 0.4em 0em !important;
|
||||
}
|
||||
}
|
||||
// Bulma modals customized for Tainacan
|
||||
.dialog{
|
||||
.modal-background {
|
||||
background-color: rgba(0, 0, 0, 0.70);
|
||||
}
|
||||
.modal-card {
|
||||
background-color: $modal-backgound-color;
|
||||
color: $secondary;
|
||||
border-radius: 10px;
|
||||
|
||||
.modal-background {
|
||||
background-color: rgba(0, 0, 0, 0.70);
|
||||
.modal-card-head, .modal-card-body, .modal-card-foot {
|
||||
background-color: $modal-backgound-color;
|
||||
color: $secondary;
|
||||
border: none;
|
||||
}
|
||||
.modal-card-head {
|
||||
p { color: $secondary; }
|
||||
font-weight: normal;
|
||||
padding: 30px 35px 0px 35px;
|
||||
}
|
||||
.modal-card-body {
|
||||
padding: 16px 35px;
|
||||
|
||||
i {
|
||||
color: white !important;
|
||||
&::before {
|
||||
background-color: $danger;
|
||||
border-radius: 55px;
|
||||
display: initial;
|
||||
}
|
||||
}
|
||||
}
|
||||
.modal-card-foot {
|
||||
justify-content: space-between;
|
||||
padding: 0px 35px 30px 35px;
|
||||
|
||||
.button {
|
||||
border-radius: 6px !important;
|
||||
font-weight: normal;
|
||||
padding: 2px 15px !important;
|
||||
margin-top: 0px !important;
|
||||
margin-bottom: 0px !important;
|
||||
height: inherit !important;
|
||||
box-shadow: none !important;
|
||||
display: inline-flex !important;
|
||||
cursor: pointer;
|
||||
font-size: 13px !important;
|
||||
}
|
||||
.button.is-success {
|
||||
border: none;
|
||||
}
|
||||
.button:not(.is-success) {
|
||||
background-color: white;
|
||||
color: $tertiary;
|
||||
border: 1px solid $gray-light;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WordPress Media Modal customization
|
||||
|
|
|
@ -18,6 +18,7 @@ $primary-darker: darken($primary-dark, 5%);
|
|||
$success: #25a189;
|
||||
$success-invert: findColorInvert($success);
|
||||
|
||||
$modal-backgound-color: #bfd8dd;
|
||||
$separator-color: #2b98a4;
|
||||
$tainacan-input-color: #1d1d1d;
|
||||
$tainacan-input-background: #e5e5e5;
|
||||
|
|
|
@ -197,6 +197,8 @@ return [
|
|||
'label_default_view_mode' => __( 'Default view mode', 'tainacan' ),
|
||||
'label_enabled_view_modes' => __( 'Enabled view modes', 'tainacan' ),
|
||||
'label_view_modes_available' => __( 'View modes available on theme', 'tainacan' ),
|
||||
'label_warning' => __( 'Warning', 'tainacan' ),
|
||||
'label_error' => __( 'Erro', 'tainacan' ),
|
||||
|
||||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||
|
|
|
@ -327,7 +327,7 @@ class REST_Filters_Controller extends REST_Controller {
|
|||
$item_arr['enabled'] = $item->get_enabled_for_collection();
|
||||
}
|
||||
|
||||
$item_arr['filter_type_object'] = $item->get_filter_type_object()->_toArray();
|
||||
$item_arr['filter_type_object'] = $item->get_filter_type_object() ? $item->get_filter_type_object()->_toArray() : $item->get_filter_type_object();
|
||||
|
||||
return $item_arr;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div v-if="type === 'date'">
|
||||
<b-datepicker
|
||||
:placeholder="$i18n.get('label_selectbox_init')"
|
||||
:class="{'has-content': date_init !== undefined && date_init !== ''}"
|
||||
:class="{'has-content': date_init != undefined && date_init != ''}"
|
||||
v-model="date_init"
|
||||
size="is-small"
|
||||
@focus="isTouched = true"
|
||||
|
@ -12,7 +12,7 @@
|
|||
icon="calendar-today"/>
|
||||
<b-datepicker
|
||||
:placeholder="$i18n.get('label_selectbox_init')"
|
||||
:class="{'has-content': date_end !== undefined && date_end !== ''}"
|
||||
:class="{'has-content': date_end != undefined && date_end != ''}"
|
||||
v-model="date_end"
|
||||
size="is-small"
|
||||
@input="validate_values()"
|
||||
|
@ -25,7 +25,7 @@
|
|||
class="columns"
|
||||
v-else>
|
||||
<b-input
|
||||
:class="{'has-content': value_init !== undefined && value_init !== ''}"
|
||||
:class="{'has-content': value_init != undefined && value_init != ''}"
|
||||
size="is-small"
|
||||
type="number"
|
||||
step="any"
|
||||
|
@ -33,7 +33,7 @@
|
|||
class="column"
|
||||
v-model="value_init"/>
|
||||
<b-input
|
||||
:class="{'has-content': value_end !== undefined && value_end !== ''}"
|
||||
:class="{'has-content': value_end != undefined && value_end != ''}"
|
||||
size="is-small"
|
||||
type="number"
|
||||
step="any"
|
||||
|
|
|
@ -264,7 +264,7 @@ abstract class Importer {
|
|||
*/
|
||||
public function fetch_from_remote( $url ){
|
||||
$tmp = wp_remote_get( $url );
|
||||
if( isset( $tmp['body'] ) ){
|
||||
if( !is_wp_error($tmp) && isset( $tmp['body'] ) ){
|
||||
$file = fopen( $this->get_id().'.txt', 'w' );
|
||||
fwrite( $file, $tmp['body'] );
|
||||
fclose( $file );
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
class ScriptTainacanOld {
|
||||
|
||||
var $step = 0;
|
||||
var $url = '';
|
||||
|
||||
/**
|
||||
* start the execution
|
||||
*/
|
||||
function __construct($argv) {
|
||||
|
||||
$this->parse_args($argv);
|
||||
$this->run();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* parse args from and set the attributs
|
||||
* 1 - Old Tainacan url (required)
|
||||
*/
|
||||
function parse_args($argv) {
|
||||
|
||||
if (!is_array($argv))
|
||||
return;
|
||||
|
||||
|
||||
if (isset($argv[1])) {
|
||||
|
||||
if (filter_var($argv[1], FILTER_VALIDATE_URL)) {
|
||||
$this->url = $argv[1];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($argv[2])) {
|
||||
|
||||
if (is_numeric($argv[2])) {
|
||||
$this->step = $argv[2];
|
||||
} else {
|
||||
$this->run = '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* echo message in prompt line
|
||||
*/
|
||||
function log($msg) {
|
||||
|
||||
echo $msg . PHP_EOL;
|
||||
|
||||
}
|
||||
|
||||
function run() {
|
||||
|
||||
$start = $partial = microtime(true);
|
||||
|
||||
// Avoid warnings
|
||||
$_SERVER['SERVER_PROTOCOL'] = "HTTP/1.1";
|
||||
$_SERVER['REQUEST_METHOD'] = "GET";
|
||||
|
||||
define( 'WP_USE_THEMES', false );
|
||||
define( 'SHORTINIT', false );
|
||||
require( dirname(__FILE__) . '/../../../../wp-blog-header.php' );
|
||||
|
||||
$old_tainacan = new \Tainacan\Importer\Old_Tainacan();
|
||||
$id = $old_tainacan->get_id();
|
||||
|
||||
$_SESSION['tainacan_importer'][$id]->set_url($url);
|
||||
$_SESSION['tainacan_importer'][$id]->set_repository();
|
||||
|
||||
while (!$_SESSION['tainacan_importer'][$id]->is_finished()){
|
||||
$_SESSION['tainacan_importer'][$id]->run();
|
||||
}
|
||||
|
||||
$scripttime = microtime(true) - $start;
|
||||
|
||||
$this->log("==========================================================");
|
||||
$this->log("==========================================================");
|
||||
$this->log("=== Fim do script. Tempo de execução {$scripttime}s");
|
||||
$this->log("==========================================================");
|
||||
$this->log("==========================================================");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$x = new ScriptTainacanOld($argv);
|
|
@ -55,6 +55,10 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
$_SESSION['tainacan_importer'][$id]->run();
|
||||
}
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
$this->assertEquals(3, $collections, 'total collection in this url does not match');
|
||||
|
||||
$this->assertTrue(true);
|
||||
}*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue