Merge branch 'develop' of https://github.com/tainacan/tainacan into develop

This commit is contained in:
weryques 2018-06-12 13:04:07 -03:00
commit 64c7e29370
111 changed files with 1217 additions and 1575 deletions

View File

@ -7,6 +7,8 @@ php:
matrix:
allow_failures:
fast_finish: true
allow_failures:
- php: 5.6
addons:
- ssh_know_hosts:
- "$ssh_host"
@ -31,7 +33,10 @@ install:
true
- composer install
- sudo mkdir /tmp/wordpress/wordpress-test/wp-content/uploads
script: phpunit
- sudo wget https://phar.phpunit.de/phpunit-6.5.7.phar -P /tmp
- sudo chmod +x /tmp/phpunit-6.5.7.phar
- sudo mv /tmp/phpunit-6.5.7.phar /usr/local/bin/phpunit
script: /usr/local/bin/phpunit # phpunit
before_deploy:
- echo "Seção executada antes do deploy!"
- openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv

View File

@ -189,15 +189,15 @@ class Admin {
'taxonomies' => $Tainacan_Taxonomies->get_map(),
];
$metadatum_types = $Tainacan_Metadata->fetch_metadatum_types();
$metadata_types = $Tainacan_Metadata->fetch_metadata_types();
foreach( $maps as $type => $map ){
foreach ( $map as $metadatum => $details){
$settings['i18n']['helpers_label'][$type][$metadatum] = [ 'title' => $details['title'], 'description' => $details['description'] ];
}
}
foreach ( $metadatum_types as $index => $metadatum_type){
$class = new $metadatum_type;
foreach ( $metadata_types as $index => $metadata_type){
$class = new $metadata_type;
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
}

View File

@ -19,7 +19,6 @@
:title="$i18n.getHelperTitle('categories', 'name')"
:message="$i18n.getHelperMessage('categories', 'name')"/>
<b-input
:class="{'has-content': form.name != undefined && form.name != ''}"
id="tainacan-text-name"
v-model="form.name"
@focus="clearErrors('name')"
@ -36,7 +35,6 @@
:title="$i18n.getHelperTitle('categories', 'description')"
:message="$i18n.getHelperMessage('categories', 'description')"/>
<b-input
:class="{'has-content': form.description != undefined && form.description != ''}"
id="tainacan-text-description"
type="textarea"
v-model="form.description"
@ -77,7 +75,6 @@
:message="$i18n.getHelperMessage('categories', 'slug')"/>
<b-icon :class="{'is-loading': isUpdatingSlug}"/>
<b-input
:class="{'has-content': form.slug != undefined && form.slug != ''}"
@input="updateSlug()"
id="tainacan-text-slug"
v-model="form.slug"

View File

@ -8,13 +8,42 @@
class="tainacan-form"
label-width="120px">
<div class="columns is-variable is-8">
<div class="column is-narrow">
<!-- Header Page -------------------------------- -->
<b-field :addons="false">
<label class="section-label">{{ $i18n.get('label_header_image') }}</label>
<div class="header-field">
<a
class="button is-rounred is-secondary"
id="button-edit-header-image"
:aria-label="$i18n.get('label_button_edit_header_image')"
@click="headerImageMediaFrame.openFrame($event)">
<b-icon icon="pencil" />
</a>
<figure class="image">
<span
v-if="collection.header_image == undefined || collection.header_image == false"
class="image-placeholder">{{ $i18n.get('label_empty_header_image') }}</span>
<img
:alt="$i18n.get('label_thumbnail')"
:src="(collection.header_image == undefined || collection.header_image == false) ? headerPlaceholderPath : collection.header_image">
</figure>
<div class="header-buttons-row">
<a
id="button-delete"
:aria-label="$i18n.get('label_button_delete_thumb')"
@click="deleteHeaderImage()">
<b-icon icon="delete" />
</a>
</div>
</div>
</b-field>
<div class="columns">
<div class="column">
<!-- Thumbnail -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_thumbnail')">
<b-field :addons="false">
<label class="section-label">{{ $i18n.get('label_thumbnail') }}</label>
<div class="thumbnail-field">
<a
class="button is-rounred is-secondary"
@ -23,7 +52,7 @@
@click.prevent="thumbnailMediaFrame.openFrame($event)">
<b-icon icon="pencil" />
</a>
<figure class="image is-128x128">
<figure class="image">
<span
v-if="collection.thumbnail.thumb == undefined || collection.thumbnail.thumb == false"
class="image-placeholder">{{ $i18n.get('label_empty_thumbnail') }}</span>
@ -42,94 +71,6 @@
</div>
</div>
</b-field>
<!-- Header Page -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_header_image')">
<div class="thumbnail-field">
<a
class="button is-rounred is-secondary"
id="button-edit-header-image"
:aria-label="$i18n.get('label_button_edit_header_image')"
@click="headerImageMediaFrame.openFrame($event)">
<b-icon icon="pencil" />
</a>
<figure class="image is-128x128">
<span
v-if="collection.header_image == undefined || collection.header_image == false"
class="image-placeholder">{{ $i18n.get('label_empty_header_image') }}</span>
<img
:alt="$i18n.get('label_thumbnail')"
:src="(collection.header_image == undefined || collection.header_image == false) ? headerPlaceholderPath : collection.header_image">
</figure>
<div class="thumbnail-buttons-row">
<a
id="button-delete"
:aria-label="$i18n.get('label_button_delete_thumb')"
@click="deleteHeaderImage()">
<b-icon icon="delete" />
</a>
</div>
</div>
</b-field>
</div>
<div class="column">
<!-- Status -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_status')"
:type="editFormErrors['status'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['status'] != undefined ? editFormErrors['status'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'status')"
:message="$i18n.getHelperMessage('collections', 'status')"/>
<b-select
id="tainacan-select-status"
v-model="form.status"
@focus="clearErrors('status')"
:placeholder="$i18n.get('instruction_select_a_status')">
<option
v-for="statusOption in statusOptions"
:key="statusOption.value"
:value="statusOption.value"
:disabled="statusOption.disabled">{{ statusOption.label }}
</option>
</b-select>
</b-field>
<!-- Name -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_name')"
:type="editFormErrors['name'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['name'] != undefined ? editFormErrors['name'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'name')"
:message="$i18n.getHelperMessage('collections', 'name')"/>
<b-input
:class="{'has-content': form.name != undefined && form.name != ''}"
id="tainacan-text-name"
v-model="form.name"
@focus="clearErrors('name')"/>
</b-field>
<!-- Description -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_description')"
:type="editFormErrors['description'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['description'] != undefined ? editFormErrors['description'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'description')"
:message="$i18n.getHelperMessage('collections', 'description')"/>
<b-input
:class="{'has-content': form.description != undefined && form.description != ''}"
id="tainacan-text-description"
type="textarea"
v-model="form.description"
@focus="clearErrors('description')"/>
</b-field>
<!-- Enable Cover Page -------------------------------- -->
<div class="field">
@ -192,90 +133,6 @@
</div>
</b-field>
<!-- Moderators List -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_moderators')"
:type="editFormErrors['moderators'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['moderators'] != undefined ? editFormErrors['moderators'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'moderators_ids')"
:message="$i18n.getHelperMessage('collections', 'moderators_ids')"/>
<b-autocomplete
id="tainacan-text-moderators-input"
:placeholder="$i18n.get('instruction_moderators')"
:data="users"
@select="onAddModerator($event)"
:loading="isFetchingModerators"
@input="fecthModerators($event)"
@focus="clearErrors('moderators')">
<template slot-scope="props">
{{ props.option.name }}
</template>
<template slot="empty">{{ $i18n.get('info_no_user_found') }}</template>
</b-autocomplete>
<ul
class="selected-list-box"
v-if="moderators != undefined && moderators.length > 0">
<li
:key="index"
v-for="(moderator, index) of moderators">
<b-tag
attached
closable
@close="removeModerator(index)">
{{ moderator.name }}
</b-tag>
</li>
</ul>
<div
class="moderators-empty-list"
v-else>
{{ $i18n.get('info_no_moderator_on_collection') }}
</div>
</b-field>
<!-- Slug -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_slug')"
:type="editFormErrors['slug'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['slug'] != undefined ? editFormErrors['slug'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'slug')"
:message="$i18n.getHelperMessage('collections', 'slug')"/>
<b-input
:class="{'has-content': form.slug != undefined && form.slug != ''}"
id="tainacan-text-slug"
v-model="form.slug"
@focus="clearErrors('slug')"/>
</b-field>
<!-- Parent Collection -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_parent_collection')"
:type="editFormErrors['parent'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['parent'] != undefined ? editFormErrors['parent'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'parent')"
:message="$i18n.getHelperMessage('collections', 'parent')"/>
<b-select
id="tainacan-select-parent"
v-model="form.parent"
@focus="clearErrors('parent')"
:loading="isFetchingCollections"
:placeholder="$i18n.get('instruction_select_a_parent_collection')">
<option value="0">{{ $i18n.get('label_no_parent_collection') }}</option>
<option
v-if="collection.id != anotherCollection.id"
v-for="anotherCollection of collections"
:key="anotherCollection.id"
:value="anotherCollection.id">{{ anotherCollection.name }}
</option>
</b-select>
</b-field>
<!-- Enabled View Modes ------------------------------- -->
<div class="field">
<label class="label">{{ $i18n.get('label_view_modes_available') }}</label>
@ -333,7 +190,145 @@
</option>
</b-select>
</b-field>
</div>
<div class="column">
<!-- Status -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_status')"
:type="editFormErrors['status'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['status'] != undefined ? editFormErrors['status'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'status')"
:message="$i18n.getHelperMessage('collections', 'status')"/>
<b-select
id="tainacan-select-status"
v-model="form.status"
@focus="clearErrors('status')"
:placeholder="$i18n.get('instruction_select_a_status')">
<option
v-for="statusOption in statusOptions"
:key="statusOption.value"
:value="statusOption.value"
:disabled="statusOption.disabled">{{ statusOption.label }}
</option>
</b-select>
</b-field>
<!-- Name -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_name')"
:type="editFormErrors['name'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['name'] != undefined ? editFormErrors['name'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'name')"
:message="$i18n.getHelperMessage('collections', 'name')"/>
<b-input
id="tainacan-text-name"
v-model="form.name"
@focus="clearErrors('name')"/>
</b-field>
<!-- Description -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_description')"
:type="editFormErrors['description'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['description'] != undefined ? editFormErrors['description'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'description')"
:message="$i18n.getHelperMessage('collections', 'description')"/>
<b-input
id="tainacan-text-description"
type="textarea"
v-model="form.description"
@focus="clearErrors('description')"/>
</b-field>
<!-- Moderators List -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_moderators')"
:type="editFormErrors['moderators'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['moderators'] != undefined ? editFormErrors['moderators'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'moderators_ids')"
:message="$i18n.getHelperMessage('collections', 'moderators_ids')"/>
<b-autocomplete
id="tainacan-text-moderators-input"
:placeholder="$i18n.get('instruction_moderators')"
:data="users"
@select="onAddModerator($event)"
:loading="isFetchingModerators"
@input="fecthModerators($event)"
@focus="clearErrors('moderators')">
<template slot-scope="props">
{{ props.option.name }}
</template>
<template slot="empty">{{ $i18n.get('info_no_user_found') }}</template>
</b-autocomplete>
<ul
class="selected-list-box"
v-if="moderators != undefined && moderators.length > 0">
<li
:key="index"
v-for="(moderator, index) of moderators">
<b-tag
attached
closable
@close="removeModerator(index)">
{{ moderator.name }}
</b-tag>
</li>
</ul>
<div
class="moderators-empty-list"
v-else>
{{ $i18n.get('info_no_moderator_on_collection') }}
</div>
</b-field>
<!-- Slug -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_slug')"
:type="editFormErrors['slug'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['slug'] != undefined ? editFormErrors['slug'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'slug')"
:message="$i18n.getHelperMessage('collections', 'slug')"/>
<b-input
id="tainacan-text-slug"
v-model="form.slug"
@focus="clearErrors('slug')"/>
</b-field>
<!-- Parent Collection -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_parent_collection')"
:type="editFormErrors['parent'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['parent'] != undefined ? editFormErrors['parent'] : ''">
<help-button
:title="$i18n.getHelperTitle('collections', 'parent')"
:message="$i18n.getHelperMessage('collections', 'parent')"/>
<b-select
id="tainacan-select-parent"
v-model="form.parent"
@focus="clearErrors('parent')"
:loading="isFetchingCollections"
:placeholder="$i18n.get('instruction_select_a_parent_collection')">
<option value="0">{{ $i18n.get('label_no_parent_collection') }}</option>
<option
v-if="collection.id != anotherCollection.id"
v-for="anotherCollection of collections"
:key="anotherCollection.id"
:value="anotherCollection.id">{{ anotherCollection.name }}
</option>
</b-select>
</b-field>
</div>
</div>
@ -734,7 +729,7 @@ export default {
if (this.$route.fullPath.split("/").pop() != "new") {
document.getElementById('collection-page-container').addEventListener('scroll', ($event) => {
this.$emit('onShrinkHeader', ($event.originalTarget.scrollTop > 53));
this.$emit('onShrinkHeader', ($event.target.scrollTop > 53));
});
}
}
@ -750,10 +745,37 @@ export default {
.field {
position: relative;
}
.section-label {
font-size: 16px !important;
font-weight: 500 !important;
color: $tertiary !important;
line-height: 1.2em;
}
#button-edit-thumbnail, #button-edit-header-image {
border-radius: 100px !important;
height: 40px !important;
width: 40px !important;
bottom: -40px;
z-index: 99;
.icon {
display: inherit;
padding: 0;
margin: 0;
margin-top: 1px;
}
}
.header-field {
img {
padding: 20px;
}
}
.thumbnail-field {
max-height: 128px;
margin-bottom: 96px;
max-height: 208px;
margin-bottom: 180px;
margin-top: -20px;
.content {
@ -761,7 +783,11 @@ export default {
font-size: 0.8em;
}
img {
border-radius: 100px;
position: absolute;
height: 178px;
width: 178px;
padding: 20px;
}
.image-placeholder {
position: absolute;
@ -774,34 +800,20 @@ export default {
text-align: center;
color: gray;
}
#button-edit-thumbnail, #button-edit-header-image {
border-radius: 100px !important;
height: 40px !important;
width: 40px !important;
bottom: -20px;
left: -20px;
z-index: 99;
.icon {
display: inherit;
padding: 0;
margin: 0;
margin-top: 1px;
}
}
.thumbnail-buttons-row {
display: none;
visibility: hidden;
display: inline-block;
position: relative;
top: -20px;
background-color: rgba(255, 255, 255, 0.9);
padding: 2px 8px;
border-radius: 0px 0px 0px 4px;
left: 88px;
}
&:hover {
.thumbnail-buttons-row {
display: inline-block;
position: relative;
top: -128px;
background-color: rgba(255, 255, 255, 0.9);
padding: 2px 8px;
border-radius: 0px 0px 0px 4px;
left: 88px;
visibility: visible;
}
}
}

View File

@ -17,7 +17,6 @@
:message="$i18n.getHelperMessage('filters', 'name')"/>
</label>
<b-input
:class="{'has-content': editForm.name != undefined && editForm.name != ''}"
v-model="editForm.name"
name="name"
@focus="clearErrors('name')"/>
@ -34,7 +33,6 @@
:message="$i18n.getHelperMessage('filters', 'description')"/>
</label>
<b-input
:class="{'has-content': editForm.description != undefined && editForm.description != ''}"
type="textarea"
name="description"
v-model="editForm.description"

View File

@ -168,7 +168,6 @@
<hr>
</div>
<b-input
:class="{'has-content': textContent != undefined && textContent != ''}"
type="textarea"
v-model="textContent"/>
@ -203,9 +202,7 @@
<h2>{{ $i18n.get('instruction_insert_url') }}</h2>
<hr>
</div>
<b-input
:class="{'has-content': urlLink != undefined && urlLink != ''}"
v-model="urlLink"/>
<b-input v-model="urlLink"/>
<div class="field is-grouped form-submit">
<div class="control">
@ -671,7 +668,7 @@ export default {
},
mounted() {
document.getElementById('collection-page-container').addEventListener('scroll', ($event) => {
this.$emit('onShrinkHeader', ($event.originalTarget.scrollTop > 53));
this.$emit('onShrinkHeader', ($event.target.scrollTop > 53));
});
},
beforeRouteLeave ( to, from, next ) {

View File

@ -18,7 +18,6 @@
:message="$i18n.getHelperMessage('metadata', 'name')"/>
</label>
<b-input
:class="{'has-content': editForm.name != undefined && editForm.name != ''}"
v-model="editForm.name"
name="name"
@focus="clearErrors('name')"/>
@ -35,7 +34,6 @@
:message="$i18n.getHelperMessage('metadata', 'description')"/>
</label>
<b-input
:class="{'has-content': editForm.description != undefined && editForm.description != ''}"
type="textarea"
name="description"
v-model="editForm.description"
@ -145,7 +143,7 @@
</b-field>
<b-field
v-if="!originalMetadatum.metadatum_type_object.core"
v-if="!originalMetadatum.metadata_type_object.core"
:type="formErrors['multiple'] != undefined ? 'is-danger' : ''"
:message="formErrors['multiple'] != undefined ? formErrors['multiple'] : ''">
<b-checkbox
@ -183,11 +181,11 @@
</b-field>
<component
:errors="formErrors['metadatum_type_options']"
v-if="(editForm.metadatum_type_object && editForm.metadatum_type_object.form_component) || editForm.edit_form == ''"
:is="editForm.metadatum_type_object.form_component"
:errors="formErrors['metadata_type_options']"
v-if="(editForm.metadata_type_object && editForm.metadata_type_object.form_component) || editForm.edit_form == ''"
:is="editForm.metadata_type_object.form_component"
:metadatum="editForm"
v-model="editForm.metadatum_type_options"/>
v-model="editForm.metadata_type_options"/>
<div
v-html="editForm.edit_form"
v-else/>
@ -259,7 +257,7 @@
]),
saveEdition(metadatum) {
if ((metadatum.metadatum_type_object && metadatum.metadatum_type_object.form_component) || metadatum.edit_form == '') {
if ((metadatum.metadata_type_object && metadatum.metadata_type_object.form_component) || metadatum.edit_form == '') {
this.updateMetadatum({
collectionId: this.collectionId,

View File

@ -61,7 +61,6 @@
:message="$i18n.get('info_help_term_name')"/>
</label>
<b-input
:class="{'has-content': editForm.name != undefined && editForm.name != ''}"
v-model="editForm.name"
name="name"
@focus="clearErrors({ name: 'name', repeated: 'repeated' })"/>
@ -78,7 +77,6 @@
:message="$i18n.get('info_help_term_description')"/>
</label>
<b-input
:class="{'has-content': editForm.description != undefined && editForm.description != ''}"
type="textarea"
name="description"
v-model="editForm.description"

View File

@ -462,7 +462,7 @@ export default {
mounted() {
if (!this.isRepositoryLevel) {
document.getElementById('collection-page-container').addEventListener('scroll', ($event) => {
this.$emit('onShrinkHeader', ($event.originalTarget.scrollTop > 53));
this.$emit('onShrinkHeader', ($event.target.scrollTop > 53));
});
}
}

View File

@ -59,7 +59,7 @@
<p
v-for="(column, index) in tableMetadata"
:key="index"
v-if="column.display && column.metadatum_type_object != undefined && (column.metadatum_type_object.related_mapped_prop == 'title')"
v-if="column.display && column.metadata_type_object != undefined && (column.metadata_type_object.related_mapped_prop == 'title')"
class="metadata-title"
@click="goToItemPage(item)"
v-html="item.metadata != undefined ? renderMetadata(item.metadata, column) : ''"/>
@ -120,7 +120,7 @@
<p
v-for="(column, index) in tableMetadata"
:key="index"
v-if="column.display && column.metadatum_type_object != undefined && (column.metadatum_type_object.related_mapped_prop == 'title')"
v-if="column.display && column.metadata_type_object != undefined && (column.metadata_type_object.related_mapped_prop == 'title')"
class="metadata-title"
@click="goToItemPage(item)"
v-html="item.metadata != undefined ? renderMetadata(item.metadata, column) : ''" />
@ -162,7 +162,7 @@
<span
v-for="(column, index) in tableMetadata"
:key="index"
v-if="column.display && column.slug != 'thumbnail' && column.metadatum_type_object != undefined && (column.metadatum_type_object.related_mapped_prop != 'title')">
v-if="column.display && column.slug != 'thumbnail' && column.metadata_type_object != undefined && (column.metadata_type_object.related_mapped_prop != 'title')">
<h3 class="metadata-label">{{ column.name }}</h3>
<p
v-html="item.metadata != undefined ? renderMetadata(item.metadata, column) : ''"
@ -193,9 +193,13 @@
class="column-default-width"
:class="{
'thumbnail-cell': column.metadatum == 'row_thumbnail',
'column-small-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Date' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Numeric') : false,
'column-medium-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Selectbox' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Category' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Compound') : false,
'column-large-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Textarea') : false,
'column-small-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'date' ||
column.metadata_type_object.primitive_type == 'float' ||
column.metadata_type_object.primitive_type == 'int') : false,
'column-medium-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'term' ||
column.metadata_type_object.primitive_type == 'item' ||
column.metadata_type_object.primitive_type == 'compound') : false,
'column-large-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'long_string' || column.metadata_type_object.related_mapped_prop == 'description') : false,
}"
:custom-key="column.slug">
<div class="th-wrap">{{ column.name }}</div>
@ -229,11 +233,16 @@
class="column-default-width"
:class="{
'thumbnail-cell': column.metadatum == 'row_thumbnail',
'column-main-content' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.related_mapped_prop == 'title') : false,
'column-needed-width column-align-right' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Numeric') : false,
'column-small-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Date' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Numeric') : false,
'column-medium-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Selectbox' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Category' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Compound') : false,
'column-large-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Textarea') : false,
'column-main-content' : column.metadata_type_object != undefined ? (column.metadata_type_object.related_mapped_prop == 'title') : false,
'column-needed-width column-align-right' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'float' ||
column.metadata_type_object.primitive_type == 'int' ) : false,
'column-small-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'date' ||
column.metadata_type_object.primitive_type == 'int' ||
column.metadata_type_object.primitive_type == 'float') : false,
'column-medium-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'item' ||
column.metadata_type_object.primitive_type == 'term' ||
column.metadata_type_object.primitive_type == 'compound') : false,
'column-large-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'long_string' || column.metadata_type_object.related_mapped_prop == 'description') : false,
}"
@click="goToItemPage(item)">

View File

@ -54,7 +54,7 @@
<span
v-if="metadatum.id != undefined"
class="label-details">
({{ $i18n.get(metadatum.metadatum_type_object.component) }}) <em>{{ (metadatum.collection_id != collectionId) ? $i18n.get('label_inherited') : '' }}</em>
({{ $i18n.get(metadatum.metadata_type_object.component) }}) <em>{{ (metadatum.collection_id != collectionId) ? $i18n.get('label_inherited') : '' }}</em>
<span
class="not-saved"
v-if="(editForms[metadatum.id] != undefined && editForms[metadatum.id].saved != true) || metadatum.status == 'auto-draft'">
@ -84,8 +84,8 @@
<a
:style="{ visibility:
metadatum.collection_id != collectionId ||
metadatum.metadatum_type == 'Tainacan\\Metadatum_Types\\Core_Title' ||
metadatum.metadatum_type == 'Tainacan\\Metadatum_Types\\Core_Description'
metadatum.metadata_type_object.related_mapped_prop == 'title' ||
metadatum.metadata_type_object.related_mapped_prop == 'description'
? 'hidden' : 'visible'
}"
@click.prevent="removeMetadatum(metadatum)">
@ -112,7 +112,7 @@
<div class="column available-metadata-area" >
<div class="field">
<h3 class="label">{{ $i18n.get('label_available_metadatum_types') }}</h3>
<h3 class="label">{{ $i18n.get('label_available_metadata_types') }}</h3>
<draggable
v-model="availableMetadatumList"
:options="{
@ -346,7 +346,7 @@ export default {
mounted() {
if (!this.isRepositoryLevel) {
document.getElementById('collection-page-container').addEventListener('scroll', ($event) => {
this.$emit('onShrinkHeader', ($event.originalTarget.scrollTop > 53));
this.$emit('onShrinkHeader', ($event.target.scrollTop > 53));
});
}
}

View File

@ -8,17 +8,17 @@ import Buefy from 'buefy';
import VTooltip from 'v-tooltip'
// Custom elements
import Text from '../../classes/metadatum-types/text/Text.vue';
import Textarea from '../../classes/metadatum-types/textarea/Textarea.vue';
import Selectbox from '../../classes/metadatum-types/selectbox/Selectbox.vue';
import Numeric from '../../classes/metadatum-types/numeric/Numeric.vue';
import Date from '../../classes/metadatum-types/date/Date.vue';
import Relationship from '../../classes/metadatum-types/relationship/Relationship.vue';
import Category from '../../classes/metadatum-types/category/Category.vue';
import Text from '../../classes/metadata-types/text/Text.vue';
import Textarea from '../../classes/metadata-types/textarea/Textarea.vue';
import Selectbox from '../../classes/metadata-types/selectbox/Selectbox.vue';
import Numeric from '../../classes/metadata-types/numeric/Numeric.vue';
import Date from '../../classes/metadata-types/date/Date.vue';
import Relationship from '../../classes/metadata-types/relationship/Relationship.vue';
import Category from '../../classes/metadata-types/category/Category.vue';
import FormRelationship from '../../classes/metadatum-types/relationship/FormRelationship.vue';
import FormCategory from '../../classes/metadatum-types/category/FormCategory.vue';
import FormSelectbox from '../../classes/metadatum-types/selectbox/FormSelectbox.vue';
import FormRelationship from '../../classes/metadata-types/relationship/FormRelationship.vue';
import FormCategory from '../../classes/metadata-types/category/FormCategory.vue';
import FormSelectbox from '../../classes/metadata-types/selectbox/FormSelectbox.vue';
import FilterCustomInterval from '../../classes/filter-types/custom-interval/CustomInterval.vue';
import FilterSelectbox from '../../classes/filter-types/selectbox/Selectbox.vue';
@ -30,7 +30,7 @@ import FilterCategoryCheckbox from '../../classes/filter-types/category/Checkbox
import FilterCategoryTaginput from '../../classes/filter-types/category/Taginput.vue';
import FilterCategorySelectbox from '../../classes/filter-types/category/Selectbox.vue';
import TainacanFormItem from '../../classes/metadatum-types/tainacan-form-item.vue';
import TainacanFormItem from '../../classes/metadata-types/tainacan-form-item.vue';
import TainacanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue';
// Remaining imports

View File

@ -4,17 +4,17 @@ import Buefy from 'buefy';
import VTooltip from 'v-tooltip'
// Custom elements
import Text from '../../classes/metadatum-types/text/Text.vue';
import Textarea from '../../classes/metadatum-types/textarea/Textarea.vue';
import Selectbox from '../../classes/metadatum-types/selectbox/Selectbox.vue';
import Numeric from '../../classes/metadatum-types/numeric/Numeric.vue';
import Date from '../../classes/metadatum-types/date/Date.vue';
import Relationship from '../../classes/metadatum-types/relationship/Relationship.vue';
import Category from '../../classes/metadatum-types/category/Category.vue';
import Text from '../../classes/metadata-types/text/Text.vue';
import Textarea from '../../classes/metadata-types/textarea/Textarea.vue';
import Selectbox from '../../classes/metadata-types/selectbox/Selectbox.vue';
import Numeric from '../../classes/metadata-types/numeric/Numeric.vue';
import Date from '../../classes/metadata-types/date/Date.vue';
import Relationship from '../../classes/metadata-types/relationship/Relationship.vue';
import Category from '../../classes/metadata-types/category/Category.vue';
import FormRelationship from '../../classes/metadatum-types/relationship/FormRelationship.vue';
import FormCategory from '../../classes/metadatum-types/category/FormCategory.vue';
import FormSelectbox from '../../classes/metadatum-types/selectbox/FormSelectbox.vue';
import FormRelationship from '../../classes/metadata-types/relationship/FormRelationship.vue';
import FormCategory from '../../classes/metadata-types/category/FormCategory.vue';
import FormSelectbox from '../../classes/metadata-types/selectbox/FormSelectbox.vue';
import FilterCustomInterval from '../../classes/filter-types/custom-interval/CustomInterval.vue';
import FilterSelectbox from '../../classes/filter-types/selectbox/Selectbox.vue';
@ -26,7 +26,7 @@ import FilterCategoryCheckbox from '../../classes/filter-types/category/Checkbox
import FilterCategoryTaginput from '../../classes/filter-types/category/Taginput.vue';
import FilterCategorySelectbox from '../../classes/filter-types/category/Selectbox.vue';
import TaincanFormItem from '../../classes/metadatum-types/tainacan-form-item.vue';
import TaincanFormItem from '../../classes/metadata-types/tainacan-form-item.vue';
import TaincanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue';
import ItemsPage from '../pages/lists/items-page.vue';
import TableViewMode from '../../theme-helper/table-view-mode.vue';

View File

@ -148,7 +148,7 @@
if (!this.isRepositoryLevel) {
document.getElementById('collection-page-container').addEventListener('scroll', ($event) => {
this.$emit('onShrinkHeader', ($event.originalTarget.scrollTop > 53));
this.$emit('onShrinkHeader', ($event.target.scrollTop > 53));
});
}
}

View File

@ -187,11 +187,11 @@
metadatum.id === 'creation_date' ||
metadatum.id === 'author_name' || (
metadatum.id !== undefined &&
metadatum.metadatum_type_object &&
metadatum.metadatum_type_object.related_mapped_prop !== 'description' &&
metadatum.metadatum_type_object.primitive_type !== 'term' &&
metadatum.metadatum_type_object.primitive_type !== 'item' &&
metadatum.metadatum_type_object.primitive_type !== 'compound'
metadatum.metadata_type_object &&
metadatum.metadata_type_object.related_mapped_prop !== 'description' &&
metadatum.metadata_type_object.primitive_type !== 'term' &&
metadatum.metadata_type_object.primitive_type !== 'item' &&
metadatum.metadata_type_object.primitive_type !== 'compound'
)"
:value="metadatum"
:key="metadatum.id">
@ -587,7 +587,7 @@
metadata.push({
name: this.$i18n.get('label_thumbnail'),
metadatum: 'row_thumbnail',
metadatum_type: undefined,
metadata_type: undefined,
slug: 'thumbnail',
id: undefined,
display: true
@ -610,8 +610,8 @@
name: metadatum.name,
metadatum: metadatum.description,
slug: metadatum.slug,
metadatum_type: metadatum.metadatum_type,
metadatum_type_object: metadatum.metadatum_type_object,
metadata_type: metadatum.metadata_type,
metadata_type_object: metadatum.metadata_type_object,
id: metadatum.id,
display: display
}
@ -624,7 +624,7 @@
metadata.push({
name: this.$i18n.get('label_creation_date'),
metadatum: 'row_creation',
metadatum_type: undefined,
metadata_type: undefined,
slug: 'creation_date',
id: undefined,
display: true
@ -632,7 +632,7 @@
metadata.push({
name: this.$i18n.get('label_created_by'),
metadatum: 'row_author',
metadatum_type: undefined,
metadata_type: undefined,
slug: 'author_name',
id: undefined,
display: true
@ -667,6 +667,7 @@
this.isRepositoryLevel = (this.collectionId === undefined);
this.$eventBusSearch.setCollectionId(this.collectionId);
this.$eventBusSearch.updateStoreFromURL();
this.$eventBusSearch.$on('isLoadingItems', isLoadingItems => {
this.isLoadingItems = isLoadingItems;
@ -703,7 +704,7 @@
// Watch Scroll for shrinking header, only on Admin at collection level
if (!this.isRepositoryLevel && !this.isOnTheme) {
document.getElementById('items-list-area').addEventListener('scroll', ($event) => {
this.isHeaderShrinked = ($event.originalTarget.scrollTop > 53);
this.isHeaderShrinked = ($event.target.scrollTop > 53);
this.$emit('onShrinkHeader', this.isHeaderShrinked);
});
}
@ -774,18 +775,13 @@
.control {
width: 100%;
input {
height: 27px;
font-size: 11px;
color: $gray-light;
}
.icon {
pointer-events: all;
cursor: pointer;
color: $tertiary;
height: 27px;
font-size: 18px !important;
height: 2rem !important;
}
margin-bottom: 5px;
}

View File

@ -5,7 +5,7 @@
:class="{ 'is-shrink': shouldShrinkHeader }"
:id="collectionId"/>
<router-view
@onShrinkHeader="shouldShrinkHeader = $event"
@onShrinkHeader="onUpdateShrinkHeader($event)"
id="collection-page-container"
:collection-id="collectionId"
class="page-container page-container-small"
@ -32,7 +32,11 @@ export default {
this.collectionId = parseInt(this.$route.params.collectionId);
this.$eventBusSearch.setCollectionId(this.collectionId);
},
mounted() {
methods: {
onUpdateShrinkHeader(event) {
if (this.shouldShrinkHeader != event)
this.shouldShrinkHeader = event;
}
}
}

View File

@ -19,6 +19,8 @@
font-size: 14px;
display: inline-block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.required-metadatum-asterisk {
color: $gray;
@ -38,12 +40,6 @@
}
.control{
&.has-content {
.input, .textarea {
background-color: white;
border: 1px solid $tainacan-input-background;
}
}
&.has-icons-right {
.icon {
height: 2.0em;

View File

@ -65,7 +65,7 @@ $header-height: 53px;
$subheader-height: 82px;
$side-menu-width: 180px;
$filter-menu-width: 200px;
$filter-menu-width-theme: 270px;
$filter-menu-width-theme: 20.833333333%;
$page-height: calc(100% - 53px);
// Overall Pages padding:

View File

@ -126,7 +126,7 @@ return apply_filters('tainacan-admin-i18n',[
'label_items_per_page' => __( 'Items per Page:', 'tainacan' ),
'label_active_metadata' => __( 'Active Metadata', 'tainacan' ),
'label_available_metadata' => __( 'Available Metadata', 'tainacan' ),
'label_available_metadatum_types' => __( 'Available Metadata Types', 'tainacan' ),
'label_available_metadata_types' => __( 'Available Metadata Types', 'tainacan' ),
'label_active_filters' => __( 'Active Filters', 'tainacan' ),
'label_filter_type' => __( 'Filter Type', 'tainacan' ),
'label_available_filters' => __( 'Available Filters', 'tainacan' ),

View File

@ -287,7 +287,11 @@ export default {
min-width: $filter-menu-width-theme;
background-color: unset;
border-right: 0;
padding: 25px 25px 25px 4.1666667%;
padding: 25px 12px 25px 4.1666667%;
.columns {
display: flex;
}
}
.search-control {

View File

@ -247,13 +247,13 @@ class REST_Controller extends \WP_REST_Controller {
// handle core metadatum
if( is_array($a) && array_key_exists("key", $a) ){
$metadatum = new \Tainacan\Entities\Metadatum($a['key']);
if( strpos( $metadatum->get_metadatum_type(), 'Core_Title') !== false ){
if( strpos( $metadatum->get_metadata_type(), 'Core_Title') !== false ){
$args[ 'post_title_in' ] = [
'relation' => ( isset( $request_meta_query['relation']) ) ? $request_meta_query['relation'] : 'AND' ,
'value' => ( is_array( $a['value'] ) ) ? $a['value'] : [$a['value']]
];
continue;
} else if( strpos( $metadatum->get_metadatum_type(), 'Core_Description') !== false ) {
} else if( strpos( $metadatum->get_metadata_type(), 'Core_Description') !== false ) {
$args[ 'post_content_in' ] = [
'relation' => ( isset( $request_meta_query['relation']) ) ? $request_meta_query['relation'] : 'AND' ,
'value' => ( is_array( $a['value'] ) ) ? $a['value'] : [$a['value']]

View File

@ -121,7 +121,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
foreach ($items_metadata as $item_metadata){
$index = array_push($prepared_item, $this->prepare_item_for_response($item_metadata, $request));
$prepared_item[$index-1]['metadatum']['metadatum_type_object'] = $this->prepare_item_for_response( $item_metadata->get_metadatum()->get_metadatum_type_object(), $request);
$prepared_item[$index-1]['metadatum']['metadata_type_object'] = $this->prepare_item_for_response( $item_metadata->get_metadatum()->get_metadata_type_object(), $request);
}
return new \WP_REST_Response(apply_filters('tainacan-rest-response', $prepared_item, $request), 200);
@ -146,7 +146,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
$metadatum = $item_metadata->get_metadatum();
if($metadatum->get_id() == $metadatum_id) {
$prepared_item = $this->prepare_item_for_response($item_metadata, $request);
$prepared_item['metadatum']['metadatum_type_object'] = $this->prepare_item_for_response( $metadatum->get_metadatum_type_object(), $request);
$prepared_item['metadatum']['metadata_type_object'] = $this->prepare_item_for_response( $metadatum->get_metadata_type_object(), $request);
}
}
@ -205,7 +205,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
$metadatum_updated = $this->item_metadata_repository->update( $item_metadata );
$prepared_item = $this->prepare_item_for_response($metadatum_updated, $request);
$prepared_item['metadatum']['metadatum_type_object'] = $this->prepare_item_for_response($metadatum_updated->get_metadatum()->get_metadatum_type_object(), $request);
$prepared_item['metadatum']['metadata_type_object'] = $this->prepare_item_for_response($metadatum_updated->get_metadatum()->get_metadata_type_object(), $request);
}
elseif($metadatum->get_accept_suggestion()) {
$log = $this->item_metadata_repository->suggest( $item_metadata );

View File

@ -117,7 +117,7 @@ class REST_Items_Controller extends REST_Controller {
$item_metadata_array = $me->_toArray();
$item_array['metadata'][ $slug ]['name'] = $metadatum->get_name();
if($metadatum->get_metadatum_type_object()->get_primitive_type() === 'date') {
if($metadatum->get_metadata_type_object()->get_primitive_type() === 'date') {
$item_array['metadata'][ $slug ]['date_i18n'] = $item_metadata_array['date_i18n'];
} else {
$item_array['metadata'][ $slug ]['value'] = $item_metadata_array['value'];

View File

@ -297,12 +297,12 @@ class REST_Metadata_Controller extends REST_Controller {
if(!empty($item)){
$item_arr = $item->_toArray();
$item_arr['metadatum_type_object'] = $item->get_metadatum_type_object()->_toArray();
$item_arr['metadata_type_object'] = $item->get_metadata_type_object()->_toArray();
if($request['context'] === 'edit'){
$item_arr['current_user_can_edit'] = $item->can_edit();
ob_start();
$item->get_metadatum_type_object()->form();
$item->get_metadata_type_object()->form();
$form = ob_get_clean();
$item_arr['edit_form'] = $form;
$item_arr['enabled'] = $item->get_enabled_for_collection();

View File

@ -4,13 +4,13 @@ namespace Tainacan\API\EndPoints;
use \Tainacan\API\REST_Controller;
class REST_Metadatum_Types_Controller extends REST_Controller {
class REST_Metadata_Types_Controller extends REST_Controller {
/**
* REST_Metadatum_Types_Controller constructor.
* REST_Metadata_Types_Controller constructor.
*/
public function __construct() {
$this->rest_base = 'metadatum-types';
$this->rest_base = 'metadata-types';
parent::__construct();
}
@ -22,7 +22,7 @@ class REST_Metadatum_Types_Controller extends REST_Controller {
'callback' => array($this, 'get_items'),
'permission_callback' => array($this, 'get_items_permissions_check'),
'args' => [
'metadatum-type' => [
'metadata-type' => [
'description' => __('The structure of objects returned.'),
'items' => [
'errors' => [
@ -67,10 +67,10 @@ class REST_Metadatum_Types_Controller extends REST_Controller {
* @return mixed|\WP_Error|\WP_REST_Response
*/
public function prepare_item_for_response( $item, $request ) {
$name = "\Tainacan\Metadatum_Types\\$item";
$metadatum_type = new $name();
$name = "\Tainacan\Metadata_Types\\$item";
$metadata_type = new $name();
$metadatum_arr = $metadatum_type->_toArray();
$metadatum_arr = $metadata_type->_toArray();
$metadatum_arr['name'] = $item;
return $metadatum_arr;
@ -84,11 +84,11 @@ class REST_Metadatum_Types_Controller extends REST_Controller {
public function get_items( $request ) {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$metadatum_types = $Tainacan_Metadata->fetch_metadatum_types('NAME');
$metadata_types = $Tainacan_Metadata->fetch_metadata_types('NAME');
$prepared = [];
foreach ($metadatum_types as $metadatum_type){
array_push($prepared, $this->prepare_item_for_response($metadatum_type, $request));
foreach ($metadata_types as $metadata_type){
array_push($prepared, $this->prepare_item_for_response($metadata_type, $request));
}
return new \WP_REST_Response($prepared, 200);

View File

@ -11,7 +11,7 @@ $rest_terms_controller = new \Tainacan\API\EndPoints\REST_Terms_Contro
$rest_filters_controller = new \Tainacan\API\EndPoints\REST_Filters_Controller();
$rest_item_metadata_controller = new \Tainacan\API\EndPoints\REST_Item_Metadata_Controller();
$rest_logs_controller = new \Tainacan\API\EndPoints\REST_Logs_Controller();
$rest_metadatum_types_controller = new \Tainacan\API\EndPoints\REST_Metadatum_Types_Controller();
$rest_metadata_types_controller = new \Tainacan\API\EndPoints\REST_Metadata_Types_Controller();
$rest_filter_types_controller = new \Tainacan\API\EndPoints\REST_Filter_Types_Controller();
new \Tainacan\API\EndPoints\REST_Export_Controller();
new \Tainacan\API\EndPoints\REST_Metadatum_Mappers_Controller();

View File

@ -234,6 +234,7 @@ abstract class Background_Process extends \WP_Background_Process {
$this->dispatch();
} else {
$this->complete();
$this->write_log($batch->key, ['Process Finished']);
}
wp_die();

View File

@ -465,8 +465,8 @@ class Collection extends Entity {
return $repo->fetch_by_collection($this, [
'meta_query' => [
[
'key' => 'metadatum_type',
'value' => ['Tainacan\Metadatum_Types\Core_Title', 'Tainacan\Metadatum_Types\Core_Description'],
'key' => 'metadata_type',
'value' => ['Tainacan\Metadata_Types\Core_Title', 'Tainacan\Metadata_Types\Core_Description'],
'compare' => 'IN'
]
]
@ -484,8 +484,8 @@ class Collection extends Entity {
$results = $repo->fetch_by_collection($this, [
'meta_query' => [
[
'key' => 'metadatum_type',
'value' => 'Tainacan\Metadatum_Types\Core_Title',
'key' => 'metadata_type',
'value' => 'Tainacan\Metadata_Types\Core_Title',
]
],
'posts_per_page' => 1
@ -508,8 +508,8 @@ class Collection extends Entity {
$results = $repo->fetch_by_collection($this, [
'meta_query' => [
[
'key' => 'metadatum_type',
'value' => 'Tainacan\Metadatum_Types\Core_Description',
'key' => 'metadata_type',
'value' => 'Tainacan\Metadata_Types\Core_Description',
]
],
'posts_per_page' => 1

View File

@ -54,7 +54,7 @@ class Item_Metadata_Entity extends Entity {
$metadatum = $this->get_metadatum();
if (is_object($metadatum)) {
$fto = $metadatum->get_metadatum_type_object();
$fto = $metadatum->get_metadata_type_object();
if (is_object($fto)) {
if ( method_exists($fto, 'get_value_as_html') ) {
@ -143,7 +143,7 @@ class Item_Metadata_Entity extends Entity {
$as_array['value_as_html'] = $this->get_value_as_html();
$as_array['value_as_string'] = $this->get_value_as_string();
if($this->get_metadatum()->get_metadatum_type_object()->get_primitive_type() === 'date'){
if($this->get_metadatum()->get_metadata_type_object()->get_primitive_type() === 'date'){
$as_array['date_i18n'] = $this->get_date_i18n($this->get_value_as_string());
}
@ -321,11 +321,11 @@ class Item_Metadata_Entity extends Entity {
return false;
}
$classMetadatumType = $metadatum->get_metadatum_type_object();
$classMetadatumType = $metadatum->get_metadata_type_object();
if( is_object( $classMetadatumType ) ){
if( method_exists ( $classMetadatumType , 'validate' ) ){
if( ! $classMetadatumType->validate( $this ) ) {
$this->add_error('metadatum_type_error', $classMetadatumType->get_errors() );
$this->add_error('metadata_type_error', $classMetadatumType->get_errors() );
return false;
}
}

View File

@ -385,7 +385,7 @@ class Item extends Entity {
foreach ( $arrayItemMetadata as $itemMetadata ) {
// skip validation for Compound Metadata
if ( $itemMetadata->get_metadatum()->get_metadatum_type() == 'Tainacan\Metadatum_Types\Compound' ) {
if ( $itemMetadata->get_metadatum()->get_metadata_type() == 'Tainacan\Metadata_Types\Compound' ) {
continue;
}
@ -582,7 +582,7 @@ class Item extends Entity {
foreach ( $metadata as $item_meta ) {
$fto = $item_meta->get_metadatum()->get_metadatum_type_object();
$fto = $item_meta->get_metadatum()->get_metadata_type_object();
if ( $fto->get_core() ) {
if ( $args['exclude_core'] ) {

View File

@ -21,8 +21,8 @@ class Metadatum extends Entity {
$collection_key,
$mask,
$default_value,
$metadatum_type,
$metadatum_type_options;
$metadata_type,
$metadata_type_options;
// Collection getter and setter declared here
use \Tainacan\Traits\Entity_Collection_Relation;
@ -166,14 +166,14 @@ class Metadatum extends Entity {
}
/**
* Return the an object child of \Tainacan\metadatum_Types\Metadatum_Type with options
* Return the an object child of \Tainacan\metadatum_Types\Metadata_Type with options
*
* @return \Tainacan\Metadatum_Types\Metadatum_Type The metadatum type class with filled options
* @return \Tainacan\Metadata_Types\Metadata_Type The metadatum type class with filled options
*/
function get_metadatum_type_object(){
$class_name = $this->get_metadatum_type();
function get_metadata_type_object(){
$class_name = $this->get_metadata_type();
$object_type = new $class_name();
$object_type->set_options( $this->get_metadatum_type_options() );
$object_type->set_options( $this->get_metadata_type_options() );
return $object_type;
}
@ -182,8 +182,8 @@ class Metadatum extends Entity {
*
* @return string The
*/
function get_metadatum_type(){
return $this->get_mapped_property('metadatum_type');
function get_metadata_type(){
return $this->get_mapped_property('metadata_type');
}
/**
@ -191,8 +191,8 @@ class Metadatum extends Entity {
*
* @return array Configurations for the metadatum type object
*/
function get_metadatum_type_options(){
return $this->get_mapped_property('metadatum_type_options');
function get_metadata_type_options(){
return $this->get_mapped_property('metadata_type_options');
}
/**
@ -330,10 +330,10 @@ class Metadatum extends Entity {
/**
* set the metadatum type class name
*
* @param string | \Tainacan\Metadatum_Types\Metadatum_Type $value The name of the class or the instance
* @param string | \Tainacan\Metadata_Types\Metadata_Type $value The name of the class or the instance
*/
public function set_metadatum_type( $value ){
$this->set_mapped_property('metadatum_type', ( is_object( $value ) ) ? get_class( $value ) : $value ) ; // Encode to avoid backslaches removal
public function set_metadata_type( $value ){
$this->set_mapped_property('metadata_type', ( is_object( $value ) ) ? get_class( $value ) : $value ) ; // Encode to avoid backslaches removal
}
/**
@ -350,8 +350,8 @@ class Metadatum extends Entity {
* @param [string || integer] $value
* @return void
*/
function set_metadatum_type_options( $value ){
$this->set_mapped_property('metadatum_type_options', $value);
function set_metadata_type_options( $value ){
$this->set_mapped_property('metadata_type_options', $value);
}
/**
@ -423,26 +423,26 @@ class Metadatum extends Entity {
// You cant have a multiple metadatum inside a compound metadatum (except category)
if ($this->get_parent() > 0) {
if ( $this->is_multiple() && $this->get_metadatum_type_object()->get_primitive_type() != 'term') {
if ( $this->is_multiple() && $this->get_metadata_type_object()->get_primitive_type() != 'term') {
$this->add_error($this->get_id(), __('Compound metadata do not support metadata with multiple values (except categories)', 'tainacan'));
return false;
}
}
// You cant have a category metadatum inside a multiple compound metadatum
if ( $this->get_parent() > 0 && $this->get_metadatum_type_object()->get_primitive_type() == 'term' ) {
if ( $this->get_parent() > 0 && $this->get_metadata_type_object()->get_primitive_type() == 'term' ) {
$parent_metadatum = new \Tainacan\Entities\Metadatum($this->get_parent());
if ( $parent_metadatum->is_multiple() ) {
$this->add_error($this->get_id(), __('Taxonomy metadata can not be used inside Compound metadata with multiple values', 'tainacan'));
return false;
}
}
if ( $this->get_metadatum_type() == 'Tainacan\Metadatum_Types\Compound' && $this->is_multiple() ) {
if ( $this->get_metadata_type() == 'Tainacan\Metadata_Types\Compound' && $this->is_multiple() ) {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$children = $Tainacan_Metadata->fetch(
[
'parent' => $this->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Category',
'metadata_type' => 'Tainacan\Metadata_Types\Category',
'post_status' => 'any'
]
, 'OBJECT');
@ -453,7 +453,7 @@ class Metadatum extends Entity {
}
}
$fto = $this->get_metadatum_type_object();
$fto = $this->get_metadata_type_object();
if (is_object($fto)) {
$is_valid = $fto->validate_options($this);
@ -469,7 +469,7 @@ class Metadatum extends Entity {
throw new \Exception( "Return of validate_options metadatum type method should be an Array in case of error" );
}
$this->add_error('metadatum_type_options', $is_valid);
$this->add_error('metadata_type_options', $is_valid);
return false;

View File

@ -60,9 +60,9 @@
axios.get(in_route)
.then( res => {
let result = res.data;
if( result && result.metadatum_type ){
if( result && result.metadata_type ){
vm.metadatum_object = result;
vm.type = result.metadatum_type;
vm.type = result.metadata_type;
vm.selectedValues();
}
})
@ -105,9 +105,9 @@
search( query ){
let promise = null;
this.options = [];
if ( this.type === 'Tainacan\\Metadatum_Types\\Relationship' ) {
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadatum_type_options.collection_id ) ?
this.metadatum_object.metadatum_type_options.collection_id : this.collection_id;
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' ) {
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadata_type_options.collection_id ) ?
this.metadatum_object.metadata_type_options.collection_id : this.collection_id;
promise = this.getValuesRelationship( collectionTarget );
} else {
@ -129,11 +129,11 @@
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key === this.metadatum );
if ( index >= 0){
let metadata = this.query.metaquery[ index ];
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadatum_type_options.collection_id ) ?
this.metadatum_object.metadatum_type_options.collection_id : this.collection_id;
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadata_type_options.collection_id ) ?
this.metadatum_object.metadata_type_options.collection_id : this.collection_id;
if ( this.type === 'Tainacan\\Metadatum_Types\\Relationship' ) {
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' ) {
let query = qs.stringify({ postin: metadata.value });
axios.get('/collection/' + collectionTarget + '/items?' + query)

View File

@ -9,7 +9,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
class Autocomplete extends Filter_Type {
function __construct(){
$this->set_supported_types(['string','item']);
$this->set_supported_types(['string','long_string','item']);
$this->set_component('tainacan-filter-autocomplete');
}
@ -21,7 +21,7 @@ class Autocomplete extends Filter_Type {
public function render( $filter ){
return '<tainacan-filter-autocomplete name="'.$filter->get_name().'"
collection_id="'.$filter->get_collection_id().'"
filter_type="'.$filter->get_metadatum()->get_metadatum_type().'"
filter_type="'.$filter->get_metadatum()->get_metadata_type().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-autocomplete>';
}
}

View File

@ -21,7 +21,7 @@
created(){
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id ;
this.type = ( this.filter_type ) ? this.filter_type : this.filter.metadatum.metadatum_type;
this.type = ( this.filter_type ) ? this.filter_type : this.filter.metadatum.metadata_type;
this.loadOptions();
},
data(){
@ -72,7 +72,7 @@
axios.get('/collection/'+ this.collection +'/metadata/' + this.metadatum)
.then( res => {
let metadatum = res.data;
promise = this.getValuesCategory( metadatum.metadatum_type_options.taxonomy_id );
promise = this.getValuesCategory( metadatum.metadata_type_options.taxonomy_id );
promise.then( () => {
this.isLoading = false;

View File

@ -24,7 +24,7 @@
created(){
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id ;
this.type = ( this.filter_type ) ? this.filter_type : this.filter.metadatum.metadatum_type;
this.type = ( this.filter_type ) ? this.filter_type : this.filter.metadatum.metadata_type;
this.loadOptions();
},
data(){
@ -74,7 +74,7 @@
axios.get('/collection/'+ this.collection +'/metadata/' + this.metadatum)
.then( res => {
let metadatum = res.data;
promise = this.getValuesCategory( metadatum.metadatum_type_options.taxonomy_id );
promise = this.getValuesCategory( metadatum.metadata_type_options.taxonomy_id );
promise.then( () => {
this.isLoading = false;

View File

@ -20,7 +20,7 @@
created(){
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id ;
this.type = ( this.filter_type ) ? this.filter_type : this.filter.metadatum.metadatum_type;
this.type = ( this.filter_type ) ? this.filter_type : this.filter.metadatum.metadata_type;
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum;
@ -31,7 +31,7 @@
axios.get(in_route)
.then( res => {
let metadatum = res.data;
this.selectedValues( metadatum.metadatum_type_options.taxonomy_id );
this.selectedValues( metadatum.metadata_type_options.taxonomy_id );
});
},
data(){
@ -88,7 +88,7 @@
axios.get(endpoint)
.then( res => {
let metadatum = res.data;
promise = this.getValuesCategory( metadatum.metadatum_type_options.taxonomy_id, q );
promise = this.getValuesCategory( metadatum.metadata_type_options.taxonomy_id, q );
this.isLoading = true;
promise.then( () => {
this.isLoading = false;

View File

@ -20,7 +20,7 @@ class CategoryCheckbox extends Filter_Type {
public function render( $filter ){
return '<tainacan-filter-category-checkbox name="'.$filter->get_name().'"
filter_type="'.$filter->get_metadatum()->get_metadatum_type().'"
filter_type="'.$filter->get_metadatum()->get_metadata_type().'"
collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-checkbox>';
}

View File

@ -20,7 +20,7 @@ class CategorySelectbox extends Filter_Type {
public function render( $filter ){
return '<tainacan-filter-category-selectbox name="'.$filter->get_name().'"
filter_type="'.$filter->get_metadatum()->get_metadatum_type().'"
filter_type="'.$filter->get_metadatum()->get_metadata_type().'"
collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-selectbox>';
}

View File

@ -20,7 +20,7 @@ class CategoryTaginput extends Filter_Type {
public function render( $filter ){
return '<tainacan-filter-category-taginput name="'.$filter->get_name().'"
filter_type="'.$filter->get_metadatum()->get_metadatum_type().'"
filter_type="'.$filter->get_metadatum()->get_metadata_type().'"
collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-taginput>';
}

View File

@ -31,9 +31,9 @@
axios.get(in_route)
.then( res => {
let result = res.data;
if( result && result.metadatum_type ){
if( result && result.metadata_type ){
vm.metadatum_object = result;
vm.type = result.metadatum_type;
vm.type = result.metadata_type;
vm.loadOptions();
}
})
@ -67,9 +67,9 @@
let promise = null;
this.isLoading = true;
if ( this.type === 'Tainacan\\Metadatum_Types\\Relationship' ) {
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadatum_type_options.collection_id ) ?
this.metadatum_object.metadatum_type_options.collection_id : this.collection_id;
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' ) {
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadata_type_options.collection_id ) ?
this.metadatum_object.metadata_type_options.collection_id : this.collection_id;
promise = this.getValuesRelationship( collectionTarget );
} else {

View File

@ -9,7 +9,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
class Checkbox extends Filter_Type {
function __construct(){
$this->set_supported_types(['string','item']);
$this->set_supported_types(['string','long_string','item']);
$this->set_component('tainacan-filter-checkbox');
}
@ -20,7 +20,7 @@ class Checkbox extends Filter_Type {
public function render( $filter ){
return '<tainacan-filter-checkbox name="'.$filter->get_name().'"
filter_type="'.$filter->get_metadatum()->get_metadatum_type().'"
filter_type="'.$filter->get_metadatum()->get_metadata_type().'"
collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-selectbox>';
}

View File

@ -75,9 +75,9 @@
axios.get(in_route)
.then( res => {
let result = res.data;
if( result && result.metadatum_type ){
if( result && result.metadata_type ){
vm.metadatum_object = result;
vm.type = ( result.metadatum_type === 'Tainacan\\Metadatum_Types\\Date') ? 'date' : 'numeric';
vm.type = ( result.metadata_type === 'Tainacan\\Metadata_Types\\Date') ? 'date' : 'numeric';
vm.selectedValues();
}
})

View File

@ -20,7 +20,7 @@ class Custom_Interval extends Filter_Type {
* @internal param $metadatum
*/
public function render( $filter ){
$type = ( $filter->get_metadatum()->get_metadatum_type() === 'Tainacan\Metadatum_Types\Date' ) ? 'date' : 'numeric';
$type = ( $filter->get_metadatum()->get_metadata_type() === 'Tainacan\Metadata_Types\Date' ) ? 'date' : 'numeric';
return '<tainacan-filter-custom-interval
name="'.$filter->get_name().'"
typeRange="'.$type.'"

View File

@ -1,7 +1,7 @@
<?php
namespace Tainacan\Filter_Types;
use Tainacan\Metadatum_Types;
use Tainacan\Metadata_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
@ -78,13 +78,13 @@ abstract class Filter_Type {
* @throws \Exception
*/
public function validate_options(\Tainacan\Entities\Filter $filter) {
$metadatum_type = $filter->get_metadatum()->get_metadatum_type();
$metadata_type = $filter->get_metadatum()->get_metadata_type();
//if there is no metadatum to validate
if( !$metadatum_type ){
if( !$metadata_type ){
return true;
}
$class = ( is_object( $metadatum_type ) ) ? $metadatum_type : new $metadatum_type();
$class = ( is_object( $metadata_type ) ) ? $metadata_type : new $metadata_type();
if(in_array( $class->get_primitive_type(), $this->supported_types )){
return true;

View File

@ -37,9 +37,9 @@
axios.get(in_route)
.then( res => {
let result = res.data;
if( result && result.metadatum_type ){
if( result && result.metadata_type ){
vm.metadatum_object = result;
vm.type = result.metadatum_type;
vm.type = result.metadata_type;
vm.loadOptions();
}
})

View File

@ -9,7 +9,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
class Selectbox extends Filter_Type {
function __construct(){
$this->set_supported_types(['string']);
$this->set_supported_types(['string', 'long_string']);
$this->set_component('tainacan-filter-selectbox');
}
@ -20,7 +20,7 @@ class Selectbox extends Filter_Type {
public function render( $filter ){
return '<tainacan-filter-selectbox name="'.$filter->get_name().'"
filter_type="'.$filter->get_metadatum()->get_metadatum_type().'"
filter_type="'.$filter->get_metadatum()->get_metadata_type().'"
collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-selectbox>';
}

View File

@ -33,9 +33,9 @@
axios.get(in_route)
.then( res => {
let result = res.data;
if( result && result.metadatum_type ){
if( result && result.metadata_type ){
vm.metadatum_object = result;
vm.type = result.metadatum_type;
vm.type = result.metadata_type;
vm.selectedValues();
}
})
@ -81,9 +81,9 @@
search( query ){
let promise = null;
this.options = [];
if ( this.type === 'Tainacan\\Metadatum_Types\\Relationship' ) {
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadatum_type_options.collection_id ) ?
this.metadatum_object.metadatum_type_options.collection_id : this.collection_id;
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' ) {
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadata_type_options.collection_id ) ?
this.metadatum_object.metadata_type_options.collection_id : this.collection_id;
promise = this.getValuesRelationship( collectionTarget, query );
} else {
@ -105,11 +105,11 @@
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key === this.metadatum );
if ( index >= 0){
let metadata = this.query.metaquery[ index ];
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadatum_type_options.collection_id ) ?
this.metadatum_object.metadatum_type_options.collection_id : this.collection_id;
let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadata_type_options.collection_id ) ?
this.metadatum_object.metadata_type_options.collection_id : this.collection_id;
if ( this.type === 'Tainacan\\Metadatum_Types\\Relationship' ) {
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' ) {
let query = qs.stringify({ postin: metadata.value });
axios.get('/collection/' + collectionTarget + '/items?' + query)

View File

@ -9,7 +9,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
class Taginput extends Filter_Type {
function __construct(){
$this->set_supported_types(['string','item']);
$this->set_supported_types(['string','long_string','item']);
$this->set_component('tainacan-filter-taginput');
}
@ -20,7 +20,7 @@ class Taginput extends Filter_Type {
public function render( $filter ){
return '<tainacan-filter-taginput name="'.$filter->get_name().'"
filter_type="'.$filter->get_metadatum()->get_metadatum_type().'"
filter_type="'.$filter->get_metadatum()->get_metadata_type().'"
collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-taginput>';
}

View File

@ -201,6 +201,7 @@
font-weight: normal;
font-size: 14px;
display: inline-flex;
width: 100%;
}
.input, .textarea, .taginput-container {

View File

@ -27,15 +27,15 @@
export default {
created(){
let metadatum_type_options = this.metadatum.metadatum.metadatum_type_options;
this.component = ( metadatum_type_options && metadatum_type_options.input_type )
? this.metadatum.metadatum.metadatum_type_options.input_type : this.componentAttribute
let metadata_type_options = this.metadatum.metadatum.metadata_type_options;
this.component = ( metadata_type_options && metadata_type_options.input_type )
? this.metadatum.metadatum.metadata_type_options.input_type : this.componentAttribute
this.collectionId = this.metadatum.metadatum.collection_id;
this.taxonomy = metadatum_type_options.taxonomy_id;
this.taxonomy = metadata_type_options.taxonomy_id;
if( metadatum_type_options && metadatum_type_options.allow_new_terms ){
this.allowNew = metadatum_type_options.allow_new_terms === 'yes'
if( metadata_type_options && metadata_type_options.allow_new_terms ){
this.allowNew = metadata_type_options.allow_new_terms === 'yes'
}
this.getTermsFromTaxonomy();
this.getTermsId();
@ -77,8 +77,8 @@
methods: {
getComponent(){
if( this.metadatum.metadatum
&& this.metadatum.metadatum.metadatum_type_options && this.metadatum.metadatum.metadatum_type_options.input_type ){
return this.metadatum.metadatum.metadatum_type_options.input_type;
&& this.metadatum.metadatum.metadata_type_options && this.metadatum.metadatum.metadata_type_options.input_type ){
return this.metadatum.metadatum.metadata_type_options.input_type;
}
},
getTermsFromTaxonomy(){

View File

@ -38,7 +38,7 @@
</label>
<b-select
v-if="listInputType"
name="metadatum_type_options[component_type]"
name="metadata_type_options[component_type]"
placeholder="Select the input type for the category metadatum"
@input="emitValues()"
v-model="input_type">
@ -51,7 +51,7 @@
</b-select>
<b-select
name="metadatum_type_options[input_type]"
name="metadata_type_options[input_type]"
placeholder="Select the input type for the category metadatum"
v-model="input_type"
@input="emitValues()"

View File

@ -1,6 +1,6 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
use Tainacan\Entities\Metadatum;
use Tainacan\Entities\Item_Metadata_Entity;
@ -11,7 +11,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Category extends Metadatum_Type {
class Category extends Metadata_Type {
function __construct(){
// call metadatum type constructor
@ -73,11 +73,11 @@ class Category extends Metadatum_Type {
$category_metadata = $Tainacan_Metadata->fetch([
'collection_id' => $metadatum->get_collection_id(),
'metadatum_type' => 'Tainacan\\Metadatum_Types\\Category'
'metadata_type' => 'Tainacan\\Metadata_Types\\Category'
], 'OBJECT');
$category_metadata = array_map(function ($metadatum_map) {
$fto = $metadatum_map->get_metadatum_type_object();
$fto = $metadatum_map->get_metadata_type_object();
return [ $metadatum_map->get_id() => $fto->get_option('taxonomy_id') ];
}, $category_metadata);

View File

@ -1,6 +1,6 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
use Tainacan\Entities\Metadatum;
use Tainacan\Entities\Item_Metadata_Entity;
@ -10,7 +10,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Compound extends Metadatum_Type {
class Compound extends Metadata_Type {
function __construct(){
// call metadatum type constructor

View File

@ -1,6 +1,6 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
use Tainacan\Entities\Metadatum;
@ -9,7 +9,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Core_Description extends Metadatum_Type {
class Core_Description extends Metadata_Type {
function __construct(){
// call metadatum type constructor

View File

@ -1,6 +1,6 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
use Tainacan\Entities\Metadatum;
@ -10,7 +10,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Core_Title extends Metadatum_Type {
class Core_Title extends Metadata_Type {
function __construct(){
// call metadatum type constructor

View File

@ -1,6 +1,6 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
@ -8,7 +8,7 @@ use Tainacan\Helpers;
/**
* Class TainacanMetadatumType
*/
class Date extends Metadatum_Type {
class Date extends Metadata_Type {
function __construct(){
// call metadatum type constructor

View File

@ -1,13 +1,13 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
abstract class Metadatum_Type {
abstract class Metadata_Type {
/**
@ -24,7 +24,7 @@ abstract class Metadatum_Type {
private $primitive_type;
/**
* Array of options specific to this metadatum type. Stored in metadatum_type_options property of the Metadatum object
* Array of options specific to this metadatum type. Stored in metadata_type_options property of the Metadatum object
* @var array
*/
private $options = [];

View File

@ -1,13 +1,13 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Numeric extends Metadatum_Type {
class Numeric extends Metadata_Type {
function __construct(){
// call metadatum type constructor

View File

@ -12,7 +12,7 @@
:message="$i18n.getHelperMessage('tainacan-relationship', 'collection_id')"/>
</label>
<b-select
name="metadatum_type_relationship[collection_id]"
name="metadata_type_relationship[collection_id]"
placeholder="Select the collection to fetch items"
v-model="collection"
@change.native="emitValues()"
@ -47,7 +47,7 @@
:key="index"
class="field">
<b-checkbox
name="metadatum_type_relationship[search][]"
name="metadata_type_relationship[search][]"
v-model="modelSearch"
:native-value="option.id">
{{ option.name }}
@ -183,7 +183,7 @@
this.metadata = [];
for( let metadatum of metadata ){
if( metadatum.metadatum_type !== "Tainacan\\Metadatum_Types\\Relationship"){
if( metadatum.metadata_type !== "Tainacan\\Metadata_Types\\Relationship"){
this.metadata.push( metadatum );
this.hasMetadata = true;
this.checkMetadata()

View File

@ -21,7 +21,7 @@
export default {
created(){
let collectionId = ( this.metadatum && this.metadatum.metadatum.metadatum_type_options.collection_id ) ? this.metadatum.metadatum.metadatum_type_options.collection_id : this.collection_id;
let collectionId = ( this.metadatum && this.metadatum.metadatum.metadata_type_options.collection_id ) ? this.metadatum.metadatum.metadata_type_options.collection_id : this.collection_id;
if( this.metadatum.value ){
let query = qs.stringify({ postin: ( Array.isArray( this.metadatum.value ) ) ? this.metadatum.value : [ this.metadatum.value ] });
@ -36,12 +36,12 @@
});
}
if( this.metadatum.metadatum.metadatum_type_options
&& this.metadatum.metadatum.metadatum_type_options.search.length > 0){
if( this.metadatum.metadatum.metadata_type_options
&& this.metadatum.metadatum.metadata_type_options.search.length > 0){
axios.get('/collection/'+ collectionId +'/metadata?context=edit')
.then( res => {
for (let item of res.data) {
if( this.metadatum.metadatum.metadatum_type_options.search.indexOf( item.id ) >= 0 )
if( this.metadatum.metadatum.metadata_type_options.search.indexOf( item.id ) >= 0 )
this.searchMetadata.push( item );
}
})
@ -103,7 +103,7 @@
let metaquery = this.mountQuery( query );
this.loading = true;
this.options = [];
let collectionId = ( this.metadatum && this.metadatum.metadatum.metadatum_type_options.collection_id ) ? this.metadatum.metadatum.metadatum_type_options.collection_id : this.collection_id;
let collectionId = ( this.metadatum && this.metadatum.metadatum.metadata_type_options.collection_id ) ? this.metadatum.metadatum.metadata_type_options.collection_id : this.collection_id;
axios.get('/collection/'+collectionId+'/items?' + qs.stringify( metaquery ))
.then( res => {
this.loading = false;

View File

@ -1,13 +1,13 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Relationship extends Metadatum_Type {
class Relationship extends Metadata_Type {
function __construct(){
// call metadatum type constructor

View File

@ -44,8 +44,8 @@
if ( this.options && this.options !== '' ){
return this.options.split("\n");
}
else if ( this.metadatum && this.metadatum.metadatum.metadatum_type_options.options ) {
const metadata = this.metadatum.metadatum.metadatum_type_options.options;
else if ( this.metadatum && this.metadatum.metadatum.metadata_type_options.options ) {
const metadata = this.metadatum.metadatum.metadata_type_options.options;
return ( metadata ) ? metadata.split("\n") : [];
}
return [];

View File

@ -1,13 +1,13 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Selectbox extends Metadatum_Type {
class Selectbox extends Metadata_Type {
function __construct(){
// call metadatum type constructor

View File

@ -14,17 +14,17 @@
v-if="metadatum.metadatum.required == 'yes'"
class="required-metadatum-asterisk"
:class="metadatumTypeMessage">*</span>
<span class="metadatum-type">({{ $i18n.get(metadatum.metadatum.metadatum_type_object.component) }})</span>
<span class="metadata-type">({{ $i18n.get(metadatum.metadatum.metadata_type_object.component) }})</span>
<help-button
:title="metadatum.metadatum.name"
:message="metadatum.metadatum.description"/>
</span>
<div
v-show="isCollapsed || metadatumTypeMessage == 'is-danger'"
v-if="isTextInputComponent( metadatum.metadatum.metadatum_type_object.component )">
v-if="isTextInputComponent( metadatum.metadatum.metadata_type_object.component )">
<component
:id="metadatum.metadatum.metadatum_type_object.component + '-' + metadatum.metadatum.slug"
:is="metadatum.metadatum.metadatum_type_object.component"
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
:is="metadatum.metadatum.metadata_type_object.component"
v-model="inputs[0]"
:metadatum="metadatum"
@blur="changeValue()"/>
@ -35,8 +35,8 @@
:key="index"
class="multiple-inputs">
<component
:id="metadatum.metadatum.metadatum_type_object.component + '-' + metadatum.metadatum.slug"
:is="metadatum.metadatum.metadatum_type_object.component"
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
:is="metadatum.metadatum.metadata_type_object.component"
v-model="inputs[index]"
:metadatum="metadatum"
@blur="changeValue()"/><a
@ -53,8 +53,8 @@
v-show="isCollapsed"
v-else>
<component
:id="metadatum.metadatum.metadatum_type_object.component + '-' + metadatum.metadatum.slug"
:is="metadatum.metadatum.metadatum_type_object.component"
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
:is="metadatum.metadatum.metadata_type_object.component"
v-model="inputs"
:metadatum="metadatum"
@blur="changeValue()"/>
@ -156,7 +156,7 @@
margin-left: 18px;
margin-bottom: 0.5em;
}
.metadatum-type {
.metadata-type {
font-size: 13px;
font-weight: 400;
color: $gray;

View File

@ -1,13 +1,13 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Text extends Metadatum_Type {
class Text extends Metadata_Type {
function __construct(){
// call metadatum type constructor

View File

@ -1,18 +1,18 @@
<?php
namespace Tainacan\Metadatum_Types;
namespace Tainacan\Metadata_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Textarea extends Metadatum_Type {
class Textarea extends Metadata_Type {
function __construct(){
// call metadatum type constructor
parent::__construct();
$this->set_primitive_type('string');
$this->set_primitive_type('long_string');
$this->set_component('tainacan-textarea');
}

View File

@ -47,12 +47,18 @@ class Item_Metadata extends Repository {
$unique = !$item_metadata->is_multiple();
$metadatum_type = $item_metadata->get_metadatum()->get_metadatum_type_object();
if ($metadatum_type->get_core()) {
$metadata_type = $item_metadata->get_metadatum()->get_metadata_type_object();
if ($metadata_type->get_core()) {
$this->save_core_metadatum_value($item_metadata);
} elseif ($metadatum_type->get_primitive_type() == 'term') {
// Core metadata are also stored as regular metadata (in the code following below)
// This is usefull to create queries via filters, advanced search or apis
// si you can search for title and content with meta_query as if they were regular metadata
}
if ($metadata_type->get_primitive_type() == 'term') {
$this->save_terms_metadatum_value($item_metadata);
} elseif ($metadatum_type->get_primitive_type() == 'compound') {
} elseif ($metadata_type->get_primitive_type() == 'compound') {
// do nothing. Compound values are updated when its child metadata are updated
return $item_metadata;
} else {
@ -115,10 +121,10 @@ class Item_Metadata extends Repository {
public function delete($item_metadata){}
public function save_core_metadatum_value(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$metadatum_type = $item_metadata->get_metadatum()->get_metadatum_type_object();
if ($metadatum_type->get_core()) {
$metadata_type = $item_metadata->get_metadatum()->get_metadata_type_object();
if ($metadata_type->get_core()) {
$item = $item_metadata->get_item();
$set_method = 'set_' . $metadatum_type->get_related_mapped_prop();
$set_method = 'set_' . $metadata_type->get_related_mapped_prop();
$value = $item_metadata->get_value();
$item->$set_method( is_array( $value ) ? $value[0] : $value );
if ($item->validate_core_metadata()) {
@ -131,10 +137,10 @@ class Item_Metadata extends Repository {
}
public function save_terms_metadatum_value($item_metadata) {
$metadatum_type = $item_metadata->get_metadatum()->get_metadatum_type_object();
if ($metadatum_type->get_primitive_type() == 'term') {
$metadata_type = $item_metadata->get_metadatum()->get_metadata_type_object();
if ($metadata_type->get_primitive_type() == 'term') {
$new_terms = $item_metadata->get_value();
$taxonomy = new Entities\Taxonomy( $metadatum_type->get_option('taxonomy_id') );
$taxonomy = new Entities\Taxonomy( $metadata_type->get_option('taxonomy_id') );
if( $taxonomy ){
$old = $item_metadata;
@ -222,17 +228,17 @@ class Item_Metadata extends Repository {
public function get_value(Entities\Item_Metadata_Entity $item_metadata) {
$unique = ! $item_metadata->is_multiple();
$metadatum_type = $item_metadata->get_metadatum()->get_metadatum_type_object();
if ($metadatum_type->get_core()) {
$metadata_type = $item_metadata->get_metadatum()->get_metadata_type_object();
if ($metadata_type->get_core()) {
$item = $item_metadata->get_item();
$get_method = 'get_' . $metadatum_type->get_related_mapped_prop();
$get_method = 'get_' . $metadata_type->get_related_mapped_prop();
return $item->$get_method();
} elseif ($metadatum_type->get_primitive_type() == 'term') {
} elseif ($metadata_type->get_primitive_type() == 'term') {
if( is_numeric( $metadatum_type->get_option('taxonomy_id') ) ){
$taxonomy = new Entities\Taxonomy( $metadatum_type->get_option('taxonomy_id') );
if( is_numeric( $metadata_type->get_option('taxonomy_id') ) ){
$taxonomy = new Entities\Taxonomy( $metadata_type->get_option('taxonomy_id') );
if( $taxonomy ){
$taxonomy_slug = $taxonomy->get_db_identifier();
} else {
@ -262,7 +268,7 @@ class Item_Metadata extends Repository {
return $terms;
} elseif ($metadatum_type->get_primitive_type() == 'compound') {
} elseif ($metadata_type->get_primitive_type() == 'compound') {
global $wpdb;
$rows = $wpdb->get_results(

View File

@ -274,7 +274,7 @@ class Items extends Repository {
*/
public function fetch_ids( $args = [], $collections = [] ) {
$args['metadata'] = 'ids';
$args['fields'] = 'ids';
return $this->fetch( $args, $collections )->get_posts();
}

View File

@ -293,9 +293,9 @@ class Logs extends Repository {
}
if ( $new_value instanceof Entities\Metadatum ) {
$type = $new_value->get_metadatum_type();
$type = $new_value->get_metadata_type();
if ( $type === 'Tainacan\Metadatum_Types\Core_Title' || $type === 'Tainacan\Metadatum_Types\Core_Description' ) {
if ( $type === 'Tainacan\Metadata_Types\Core_Title' || $type === 'Tainacan\Metadata_Types\Core_Description' ) {
return false;
}
}

View File

@ -13,11 +13,11 @@ class Metadata extends Repository {
public $entities_type = '\Tainacan\Entities\Metadatum';
protected $default_metadata = 'default';
public $metadatum_types = [];
public $metadata_types = [];
public $core_metadata = [
'Tainacan\Metadatum_Types\Core_Title',
'Tainacan\Metadatum_Types\Core_Description'
'Tainacan\Metadata_Types\Core_Title',
'Tainacan\Metadata_Types\Core_Description'
];
private static $instance = null;
@ -82,7 +82,7 @@ class Metadata extends Repository {
//'on_error' => __('The description should be a text value', 'tainacan'),
//'validation' => v::stringType()->notEmpty(),
],
'metadatum_type' => [
'metadata_type' => [
'map' => 'meta',
'title' => __( 'Type', 'tainacan' ),
'type' => 'string',
@ -141,7 +141,7 @@ class Metadata extends Repository {
'type' => 'string',
'description' => __( 'The default value for the metadata', 'tainacan' ),
],
'metadatum_type_options' => [ // not showed in form
'metadata_type_options' => [ // not showed in form
'map' => 'meta',
'title' => __( 'Metadata type options', 'tainacan' ),
'type' => 'array/object/string',
@ -249,7 +249,7 @@ class Metadata extends Repository {
*
* @param $class_name string | object The class name or the instance
*/
public function register_metadatum_type( $class_name ){
public function register_metadata_type( $class_name ){
// TODO: we shoud not allow registration of metadatum types of retricted core metadatum types (e.g. compound, term) by plugins
@ -257,8 +257,8 @@ class Metadata extends Repository {
$class_name = get_class( $class_name );
}
if(!in_array( $class_name, $this->metadatum_types)){
$this->metadatum_types[] = $class_name;
if(!in_array( $class_name, $this->metadata_types)){
$this->metadata_types[] = $class_name;
}
}
@ -267,14 +267,14 @@ class Metadata extends Repository {
*
* @param $class_name string | object The class name or the instance
*/
public function unregister_metadatum_type( $class_name ){
public function unregister_metadata_type( $class_name ){
if( is_object( $class_name ) ){
$class_name = get_class( $class_name );
}
$key = array_search( $class_name, $this->metadatum_types );
$key = array_search( $class_name, $this->metadata_types );
if($key !== false){
unset( $this->metadatum_types[$key] );
unset( $this->metadata_types[$key] );
}
}
@ -478,22 +478,22 @@ class Metadata extends Repository {
* NAME - return an Array of the names of metadatum types registered
*
* @param $output string CLASS | NAME
* @return array of Entities\Metadatum_Types\Metadatum_Type classes path name
* @return array of Entities\Metadata_Types\Metadata_Type classes path name
*/
public function fetch_metadatum_types( $output = 'CLASS'){
public function fetch_metadata_types( $output = 'CLASS'){
$return = [];
do_action('register_metadatum_types');
do_action('register_metadata_types');
if( $output === 'NAME' ){
foreach ($this->metadatum_types as $metadatum_type) {
$return[] = str_replace('Tainacan\Metadatum_Types\\','', $metadatum_type);
foreach ($this->metadata_types as $metadata_type) {
$return[] = str_replace('Tainacan\Metadata_Types\\','', $metadata_type);
}
return $return;
}
return $this->metadatum_types;
return $this->metadata_types;
}
/**
@ -513,7 +513,7 @@ class Metadata extends Repository {
'name' => 'Description',
'description' => 'description',
'collection_id' => $collection->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Core_Description',
'metadata_type' => 'Tainacan\Metadata_Types\Core_Description',
'status' => 'publish',
'exposer_mapping' => [
'dublin-core' => 'description'
@ -523,7 +523,7 @@ class Metadata extends Repository {
'name' => 'Title',
'description' => 'title',
'collection_id' => $collection->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Core_Title',
'metadata_type' => 'Tainacan\Metadata_Types\Core_Title',
'status' => 'publish',
'exposer_mapping' => [
'dublin-core' => 'title'
@ -541,7 +541,7 @@ class Metadata extends Repository {
} else {
$exists = false;
foreach ( $metadata as $metadatum ){
if ( $metadatum->get_metadatum_type() === $data_core_metadatum['metadatum_type'] ) {
if ( $metadatum->get_metadata_type() === $data_core_metadatum['metadata_type'] ) {
$exists = true;
}
}
@ -565,7 +565,7 @@ class Metadata extends Repository {
public function disable_delete_core_metadata( $before, $post ){
$metadatum = $this->fetch( $post->ID );
if ( $metadatum && in_array( $metadatum->get_metadatum_type(), $this->core_metadata ) && is_numeric($metadatum->get_collection_id()) ) {
if ( $metadatum && in_array( $metadatum->get_metadata_type(), $this->core_metadata ) && is_numeric($metadatum->get_collection_id()) ) {
return false;
}
}
@ -584,7 +584,7 @@ class Metadata extends Repository {
public function force_delete_core_metadata( $before, $post, $force_delete ){
$metadatum = $this->fetch( $post->ID );
if ( $metadatum && in_array( $metadatum->get_metadatum_type(), $this->core_metadata ) && is_numeric($metadatum->get_collection_id()) ) {
if ( $metadatum && in_array( $metadatum->get_metadata_type(), $this->core_metadata ) && is_numeric($metadatum->get_collection_id()) ) {
return false;
}
}
@ -607,7 +607,7 @@ class Metadata extends Repository {
'compare' => 'IN',
),
array(
'key' => 'metadatum_type',
'key' => 'metadata_type',
'value' => $this->core_metadata,
'compare' => 'IN',
)
@ -665,14 +665,14 @@ class Metadata extends Repository {
$metadatum = new Entities\Metadatum( $metadatum_id );
// handle core titles
if( strpos( $metadatum->get_metadatum_type(), 'Core') !== false ){
if( strpos( $metadatum->get_metadata_type(), 'Core') !== false ){
$collection = new Entities\Collection( $collection_id );
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$items = $Tainacan_Items->fetch( ['s' => $search], $collection, 'OBJECT');
$return = [];
foreach ($items as $item) {
if( strpos( $metadatum->get_metadatum_type(), 'Core_Title') !== false ){
if( strpos( $metadatum->get_metadata_type(), 'Core_Title') !== false ){
$title = $item->get_title();
if(!empty($search) && stristr($title, $search) !== false) {
@ -819,13 +819,13 @@ class Metadata extends Repository {
*
*/
private function pre_update_category_metadatum($metadatum) {
$metadatum_type = $metadatum->get_metadatum_type_object();
$metadata_type = $metadatum->get_metadata_type_object();
$current_tax = '';
if ($metadatum_type->get_primitive_type() == 'term') {
if ($metadata_type->get_primitive_type() == 'term') {
$options = $this->get_mapped_property($metadatum, 'metadatum_type_options');
$metadatum_type->set_options($options);
$current_tax = $metadatum_type->get_option('taxonomy_id');
$options = $this->get_mapped_property($metadatum, 'metadata_type_options');
$metadata_type->set_options($options);
$current_tax = $metadata_type->get_option('taxonomy_id');
}
$this->current_taxonomy = $current_tax;
}
@ -841,11 +841,11 @@ class Metadata extends Repository {
* @return void [type] [description]
*/
private function update_category_metadatum($metadatum) {
$metadatum_type = $metadatum->get_metadatum_type_object();
$metadata_type = $metadatum->get_metadata_type_object();
$new_tax = '';
if ($metadatum_type->get_primitive_type() == 'term') {
$new_tax = $metadatum_type->get_option('taxonomy_id');
if ($metadata_type->get_primitive_type() == 'term') {
$new_tax = $metadata_type->get_option('taxonomy_id');
}
if ($new_tax != $this->current_taxonomy) {
@ -864,10 +864,10 @@ class Metadata extends Repository {
private function delete_category_metadatum($metadatum_id) {
$metadatum = $this->fetch($metadatum_id);
$metadatum_type = $metadatum->get_metadatum_type_object();
$metadata_type = $metadatum->get_metadata_type_object();
if ($metadatum_type->get_primitive_type() == 'term') {
$removed_tax = $metadatum_type->get_option('taxonomy_id');
if ($metadata_type->get_primitive_type() == 'term') {
$removed_tax = $metadata_type->get_option('taxonomy_id');
$collection = $metadatum->get_collection();

View File

@ -1,7 +1,7 @@
<?php
const TAINACAN_ENTITIES_DIR = __DIR__ . '/entities/';
const TAINACAN_METADATUM_TYPES_DIR = __DIR__ . '/metadatum-types/';
const TAINACAN_METADATA_TYPES_DIR = __DIR__ . '/metadata-types/';
const TAINACAN_FILTER_TYPES_DIR = __DIR__ . '/filter-types/';
const TAINACAN_REPOSITORIES_DIR = __DIR__ . '/repositories/';
const TAINACAN_TRAITS_DIR = __DIR__ . '/traits/';
@ -14,7 +14,7 @@ const TAINACAN_EXPOSERS_DIR = __DIR__ . '/../exposers/';
const DIRS = [
TAINACAN_CLASSES_DIR,
TAINACAN_ENTITIES_DIR,
TAINACAN_METADATUM_TYPES_DIR,
TAINACAN_METADATA_TYPES_DIR,
TAINACAN_FILTER_TYPES_DIR,
TAINACAN_REPOSITORIES_DIR,
TAINACAN_TRAITS_DIR,
@ -71,7 +71,7 @@ function tainacan_autoload($class_name){
$dir = TAINACAN_CLASSES_DIR;
}
if( in_array('Metadatum_Types', $class_path) || in_array('Filter_Types', $class_path) ){
if( in_array('Metadata_Types', $class_path) || in_array('Filter_Types', $class_path) ){
$exceptions = ['categorytaginput','categorycheckbox','categoryselectbox'];
if( in_array( strtolower( $class_name ), $exceptions) ){
$dir.= 'category/';
@ -95,14 +95,14 @@ $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
//register metadatum types
$Tainacan_Metadata->register_metadatum_type('Tainacan\Metadatum_Types\Text');
$Tainacan_Metadata->register_metadatum_type('Tainacan\Metadatum_Types\Textarea');
$Tainacan_Metadata->register_metadatum_type('Tainacan\Metadatum_Types\Date');
$Tainacan_Metadata->register_metadatum_type('Tainacan\Metadatum_Types\Numeric');
$Tainacan_Metadata->register_metadatum_type('Tainacan\Metadatum_Types\Selectbox');
$Tainacan_Metadata->register_metadatum_type('Tainacan\Metadatum_Types\Relationship');
$Tainacan_Metadata->register_metadatum_type('Tainacan\Metadatum_Types\Category');
$Tainacan_Metadata->register_metadatum_type('Tainacan\Metadatum_Types\Compound');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Text');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Textarea');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Date');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Numeric');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Selectbox');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Relationship');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Category');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Compound');
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();

View File

@ -175,10 +175,10 @@ class DevInterface {
( isset( $value ) ) ? $value : '',
'tnc_prop_metadatum'
) ?>
<?php elseif ($prop == 'metadatum_type_options' || $prop == 'filter_type_options'): ?>
<?php elseif ($prop == 'metadata_type_options' || $prop == 'filter_type_options'): ?>
<?php echo $value; ?>
<?php elseif ($prop == 'metadatum_type'): ?>
<?php echo $this->metadatum_type_dropdown($post->ID,$value); ?>
<?php elseif ($prop == 'metadata_type'): ?>
<?php echo $this->metadata_type_dropdown($post->ID,$value); ?>
<?php elseif ($prop == 'filter_type'): ?>
<?php echo $this->filter_type_dropdown($post->ID,$value); ?>
<?php else: ?>
@ -332,7 +332,7 @@ class DevInterface {
</td>
<td>
<?php //echo '<tainacan-text name="'.$item_meta->get_metadatum()->get_name().'"></tainacan-text>'; ?>
<?php echo $item_meta->get_metadatum()->get_metadatum_type_object()->render( $item_meta ); ?>
<?php echo $item_meta->get_metadatum()->get_metadata_type_object()->render( $item_meta ); ?>
</td>
</tr>
@ -347,26 +347,26 @@ class DevInterface {
}
function metadatum_type_dropdown($id,$selected) {
function metadata_type_dropdown($id,$selected) {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$class = ( class_exists( $selected ) ) ? new $selected() : '';
if(is_object( $class )){
$selected = str_replace('Tainacan\Metadatum_Types\\','', get_class( $class ) );
$selected = str_replace('Tainacan\Metadata_Types\\','', get_class( $class ) );
}
$metadatum_types = $Tainacan_Metadata->fetch_metadatum_types('NAME');
$metadata_types = $Tainacan_Metadata->fetch_metadata_types('NAME');
?>
<select name="tnc_prop_metadatum_type">
<?php foreach ($metadatum_types as $metadatum_type): ?>
<option value="<?php echo $metadatum_type; ?>" <?php selected($metadatum_type, $selected) ?>><?php echo $metadatum_type; ?></option>
<select name="tnc_prop_metadata_type">
<?php foreach ($metadata_types as $metadata_type): ?>
<option value="<?php echo $metadata_type; ?>" <?php selected($metadata_type, $selected) ?>><?php echo $metadata_type; ?></option>
<?php endforeach; ?>
</select>
<?php
if( $class ){
$options = get_post_meta($id,'metadatum_type_options',true);
$options = get_post_meta($id,'metadata_type_options',true);
$class->set_options($options);
echo $class->form();
}
@ -454,12 +454,12 @@ class DevInterface {
if ($entity->validate_prop($prop)) {
// we cannot user repository->insert here, it would create an infinite loop
if ($prop == 'metadatum_type') {
if ($prop == 'metadata_type') {
//TODO: This can be better
$class = '\Tainacan\Metadatum_Types\\'.$value;
update_post_meta($post_id, 'metadatum_type_options', $_POST['metadatum_type_'.strtolower( $value ) ] );
update_post_meta($post_id, 'metadatum_type', wp_slash( get_class( new $class() ) ) );
} elseif($prop == 'metadatum_type_options' || $prop == 'filter_type_options') {
$class = '\Tainacan\Metadata_Types\\'.$value;
update_post_meta($post_id, 'metadata_type_options', $_POST['metadata_type_'.strtolower( $value ) ] );
update_post_meta($post_id, 'metadata_type', wp_slash( get_class( new $class() ) ) );
} elseif($prop == 'metadata_type_options' || $prop == 'filter_type_options') {
continue;
} elseif ($prop == 'filter_type') {
$class = str_replace('\\\\','\\','\Tainacan\Filter_Types\\'.$value );
@ -510,7 +510,7 @@ class DevInterface {
foreach ($metalist as $meta) {
$item_meta = new \Tainacan\Entities\Item_Metadata_Entity($entity, $meta);
$pos = strpos($item_meta->get_metadatum()->get_metadatum_type(), 'Core');
$pos = strpos($item_meta->get_metadatum()->get_metadata_type(), 'Core');
if( $pos !== false ){
continue;
}

View File

@ -317,13 +317,13 @@ class Exposers {
$metadatum = new \Tainacan\Entities\Metadatum();
if(
array_key_exists('metadatum_type', $mapper_metadatum) &&
$mapper_metadatum['metadatum_type'] != false &&
class_exists($mapper_metadatum['metadatum_type'])
array_key_exists('metadata_type', $mapper_metadatum) &&
$mapper_metadatum['metadata_type'] != false &&
class_exists($mapper_metadatum['metadata_type'])
) {
$metadatum->set_metadatum_type($mapper_metadatum['metadatum_type']);
$metadatum->set_metadata_type($mapper_metadatum['metadata_type']);
} else {
$metadatum->set_metadatum_type('Tainacan\Metadatum_Types\Text');
$metadatum->set_metadata_type('Tainacan\Metadata_Types\Text');
}
$metadatum->set_name($mapper_metadatum['label']);
$metadatum->set_description($mapper_metadatum['URI']);

View File

@ -30,7 +30,7 @@ class Dublin_Core extends Mapper {
'date' => [
'URI' => 'http://purl.org/dc/elements/1.1/date',
'label' => 'Date',
'metadatum_type' => 'date'
'metadata_type' => 'date'
],
'description' => [
'URI' => 'http://purl.org/dc/elements/1.1/description',

View File

@ -13,12 +13,12 @@ abstract class Mapper {
* ['slug'] => [
* 'URI' => 'http://...', // URI of the metadatum description
* 'label' => 'Label', // Label to show on UI
* 'metadatum_type' => 'date', // Tainacan recomended metadatum type, default text
* 'metadata_type' => 'date', // Tainacan recomended metadatum type, default text
* 'core_metadatum' => 'description' // if have a core tainacan metadatum, what?
* ['date' => [
* 'URI' => 'http://purl.org/dc/elements/1.1/date',
* 'label' => 'Date',
* 'metadatum_type' => 'date'
* 'metadata_type' => 'date'
* ],
* 'description' => [
* 'URI' => 'http://purl.org/dc/elements/1.1/description',

View File

@ -19,6 +19,10 @@ class Background_Importer extends Background_Process {
$this->write_log($key, $object->get_log());
$this->write_error_log($key, $object->get_error_log());
if (true === $object->get_abort()) {
throw new \Exception('Process aborted by Importer');
}
if (false === $runned) {
return false;
}

View File

@ -148,6 +148,12 @@ abstract class Importer {
private $error_log = [];
/**
* Wether to abort importer execution.
* @var bool
*/
private $abort = false;
/**
* List of attributes that are saved in DB and that are used to
* reconstruct the object
@ -505,6 +511,30 @@ abstract class Importer {
return false;
}
/**
* Cancel Scheduled abortion at the end of run()
* @return void
*/
protected function cancel_abort() {
$this->abort = false;
}
/**
* Schedule importer abortion at the end of run()
* @return void
*/
protected function abort() {
$this->abort = true;
}
/**
* Return wether importer should abort execution or not
* @return bool
*/
public function get_abort() {
return $this->abort;
}
///////////////////////////////
@ -559,11 +589,13 @@ abstract class Importer {
$collection_definition = isset($collections[$current_collection]) ? $collections[$current_collection] : false;
$current_collection_item = $this->get_current_collection_item();
$this->add_log('Processing item ' . $current_collection_item);
$processed_item = $this->process_item( $current_collection_item, $collection_definition );
if( $processed_item) {
$this->add_log('Inserting item ' . $current_collection_item);
$this->insert( $processed_item, $current_collection );
} else {
$this->add_error_log('failed on item '. $start );
$this->add_error_log('failed on item '. $current_collection_item );
}
return $this->next_item();
@ -628,6 +660,8 @@ abstract class Importer {
*
* @param array $processed_item Associative array with metadatum source's as index with
* its value or values
* @param integet $collection_index The index in the $this->collections array of the collection the item is beeing inserted into
*
* @return Tainacan\Entities\Item Item inserted
*/
public function insert( $processed_item, $collection_index ) {
@ -657,7 +691,9 @@ abstract class Importer {
$singleItemMetadata = new Entities\Item_Metadata_Entity( $item, $metadatum); // *empty item will be replaced by inserted in the next foreach
$singleItemMetadata->set_value( $values );
$itemMetadataArray[] = $singleItemMetadata;
}
} else {
$this->add_error_log('Metadata ' . $metadatum_source . ' not found');
}
}
}
@ -668,7 +704,8 @@ abstract class Importer {
if( $item->validate() ){
$insertedItem = $Tainacan_Items->insert( $item );
} else {
$this->add_error_log( 'Item ' . $index . ': ' ); // TODO add the $item->get_errors() array
$this->add_error_log( 'Error inserting item' );
$this->add_error_log( $item->get_errors() );
return false;
}
@ -678,18 +715,18 @@ abstract class Importer {
if( $itemMetadata->validate() ){
$result = $Tainacan_Item_Metadata->insert( $itemMetadata );
} else {
$this->add_error_log( 'Item ' . $insertedItem->get_id() . ' on metadatum '. $itemMetadata->get_metadatum()->get_name()
.' has error ' . $itemMetadata->get_errors() );
$this->add_error_log('Error saving value for ' . $itemMetadata->get_metadatum()->get_name());
$this->add_error_log($itemMetadata->get_errors());
continue;
}
if( $result ){
$values = ( is_array( $itemMetadata->get_value() ) ) ? implode( PHP_EOL, $itemMetadata->get_value() ) : $itemMetadata->get_value();
$this->add_log( 'Item ' . $insertedItem->get_id() .
' has inserted the values: ' . $values . ' on metadatum: ' . $itemMetadata->get_metadatum()->get_name() );
} else {
$this->add_error_log( 'Item ' . $insertedItem->get_id() . ' has an error' );
}
//if( $result ){
// $values = ( is_array( $itemMetadata->get_value() ) ) ? implode( PHP_EOL, $itemMetadata->get_value() ) : $itemMetadata->get_value();
// $this->add_log( 'Item ' . $insertedItem->get_id() .
// ' has inserted the values: ' . $values . ' on metadata: ' . $itemMetadata->get_metadatum()->get_name() );
//} else {
// $this->add_error_log( 'Item ' . $insertedItem->get_id() . ' has an error' );
//}
}
$insertedItem->set_status('publish' );
@ -697,8 +734,8 @@ abstract class Importer {
if($insertedItem->validate()) {
$insertedItem = $Tainacan_Items->update( $insertedItem );
} else {
//error_log(print_r($insertedItem->get_errors(), true));
//$this->add_error_log( 'Item ' . $index . ': ' . $insertedItem->get_errors()[0]['title'] ); // TODO add the $item->get_errors() array
$this->add_error_log( 'Error publishing Item' );
$this->add_error_log( $insertedItem->get_errors() );
return false;
}

File diff suppressed because it is too large Load Diff

View File

@ -72,8 +72,24 @@ class Test_Importer extends Importer {
$tax1->set_name('Color');
$tax1->set_allow_insert('yes');
$tax1->set_status('publish');
$tax1->validate();
$tax1 = $this->tax_repo->insert($tax1);
if ($tax1->validate()) {
$tax1 = $this->tax_repo->insert($tax1);
} else {
/**
* In these set up steps, if we have an error adding
* a taxonomy, collection or metadatum, there is no point
* in continuing running the importer. So we throw an exception
* to abort it, because an error here would cause errors in the next
* steps anyway.
*/
$this->add_error_log('Error creating taxonomy Color');
$this->add_error_log($tax1->get_errors());
$this->abort();
return false;
}
$this->add_transient('tax_1_id', $tax1->get_id());
@ -81,8 +97,15 @@ class Test_Importer extends Importer {
$tax2->set_name('Quality');
$tax2->set_allow_insert('yes');
$tax2->set_status('publish');
$tax2->validate();
$tax2 = $this->tax_repo->insert($tax2);
if ($tax2->validate()) {
$tax2 = $this->tax_repo->insert($tax2);
} else {
$this->add_error_log('Error creating taxonomy Quality');
$this->add_error_log($tax2->get_errors());
$this->abort();
return false;
}
$this->add_transient('tax_2_id', $tax2->get_id());
@ -93,16 +116,31 @@ class Test_Importer extends Importer {
public function create_collections() {
$col1 = new Entities\Collection();
$col1->set_name('Collection 1');
$col1->set_name('Collection 11');
$col1->set_status('publish');
$col1->validate();
$col1 = $this->col_repo->insert($col1);
if ($col1->validate()) {
$col1 = $this->col_repo->insert($col1);
} else {
$this->add_error_log('Error creating Collection 1');
$this->add_error_log($col1->get_errors());
$this->abort();
return false;
}
$col2 = new Entities\Collection();
$col2->set_name('Collection 2');
$col2->set_name('Collection 22');
$col2->set_status('publish');
$col2->validate();
$col2 = $this->col_repo->insert($col2);
if ($col2->validate()) {
$col2 = $this->col_repo->insert($col2);
} else {
$this->add_error_log('Error creating Collection 2');
$this->add_error_log($col2->get_errors());
$this->abort();
return false;
}
$col1_map = [];
$col2_map = [];
@ -112,37 +150,49 @@ class Test_Importer extends Importer {
// core metadata
$col1_core_title = $col1->get_core_title_metadatum();
$col1_core_description = $col1->get_core_description_metadatum();
$col1_map[$col1_core_title->get_id()] = 'metadatum1';
$col1_map[$col1_core_description->get_id()] = 'metadatum2';
$col1_map[$col1_core_title->get_id()] = 'field1';
$col1_map[$col1_core_description->get_id()] = 'field2';
$metadatum = new Entities\Metadatum();
$metadatum->set_name('Color');
$metadatum->set_name('Colora');
$metadatum->set_collection($col1);
$metadatum->set_metadatum_type('Tainacan\Metadatum_Types\Category');
$metadatum->set_metadatum_type_options([
$metadatum->set_metadata_type('Tainacan\Metadata_Types\Category');
$metadatum->set_metadata_type_options([
'taxonomy_id' => $this->get_transient('tax_1_id'),
'allow_new_terms' => true
]);
$metadatum->set_status('publish');
$metadatum->validate();
$metadatum = $this->metadata_repo->insert($metadatum);
$col1_map[$metadatum->get_id()] = 'metadatum3';
$this->add_transient('tax_1_metadatum', $metadatum->get_id());
if ($metadatum->validate()) {
$metadatum = $this->metadata_repo->insert($metadatum);
} else {
$this->add_error_log('Error creating field3');
$this->add_error_log($metadatum->get_errors());
$this->abort();
return false;
}
$col1_map[$metadatum->get_id()] = 'field3';
$this->add_transient('tax_1_field', $metadatum->get_id());
$metadatum = new Entities\Metadatum();
$metadatum->set_name('Quality');
$metadatum->set_name('Qualitya');
$metadatum->set_collection($col1);
$metadatum->set_metadatum_type('Tainacan\Metadatum_Types\Category');
$metadatum->set_metadatum_type_options([
$metadatum->set_metadata_type('Tainacan\Metadata_Types\Category');
$metadatum->set_metadata_type_options([
'taxonomy_id' => $this->get_transient('tax_2_id'),
'allow_new_terms' => true
]);
$metadatum->set_status('publish');
$metadatum->validate();
$metadatum = $this->metadata_repo->insert($metadatum);
$col1_map[$metadatum->get_id()] = 'metadatum4';
$this->add_transient('tax_2_metadatum', $metadatum->get_id());
if ($metadatum->validate()) {
$metadatum = $this->metadata_repo->insert($metadatum);
} else {
$this->add_error_log('Error creating field4');
$this->add_error_log($metadatum->get_errors());
$this->abort();
return false;
}
$col1_map[$metadatum->get_id()] = 'field4';
$this->add_transient('tax_2_field', $metadatum->get_id());
$this->add_collection([
'id' => $col1->get_id(),
@ -155,17 +205,24 @@ class Test_Importer extends Importer {
// core metadata
$col2_core_title = $col2->get_core_title_metadatum();
$col2_core_description = $col2->get_core_description_metadatum();
$col2_map[$col2_core_title->get_id()] = 'metadatum1';
$col2_map[$col2_core_description->get_id()] = 'metadatum2';
$col2_map[$col2_core_title->get_id()] = 'field1';
$col2_map[$col2_core_description->get_id()] = 'field2';
$metadatum = new Entities\Metadatum();
$metadatum->set_name('Test Metadatum');
$metadatum->set_collection($col2);
$metadatum->set_metadatum_type('Tainacan\Metadatum_Types\Text');
$metadatum->set_metadata_type('Tainacan\Metadata_Types\Text');
$metadatum->set_status('publish');
$metadatum->validate();
$metadatum = $this->metadata_repo->insert($metadatum);
$col2_map[$metadatum->get_id()] = 'metadatum3';
if ($metadatum->validate()) {
$metadatum = $this->metadata_repo->insert($metadatum);
} else {
$this->add_error_log('Error creating field3');
$this->add_error_log($metadatum->get_errors());
$this->abort();
return false;
}
$col2_map[$metadatum->get_id()] = 'field3';
$this->add_collection([
'id' => $col2->get_id(),
@ -182,28 +239,48 @@ class Test_Importer extends Importer {
$tax1 = $this->tax_repo->fetch( $this->get_transient('tax_1_id') );
$tax1->set_allow_insert('no');
$tax1->validate();
$tax1 = $this->tax_repo->insert($tax1);
if ($tax1->validate()) {
$tax1 = $this->tax_repo->insert($tax1);
} else {
/**
* This is an example of an error that
* we just want to log, but dont want to abort the process.
*/
$this->add_error_log('Error closing ' . $tax1->get_name());
$this->add_error_log($tax1->get_errors());
}
$tax2 = $this->tax_repo->fetch( $this->get_transient('tax_2_id') );
$tax2->set_allow_insert('no');
$tax2->validate();
$tax2 = $this->tax_repo->insert($tax2);
if ($tax2->validate()) {
$tax2 = $this->tax_repo->insert($tax2);
} else {
$this->add_error_log('Error closing ' . $tax2->get_name());
$this->add_error_log($tax2->get_errors());
}
$metadatum1 = $this->metadata_repo->fetch( $this->get_transient('tax_1_metadatum') );
$options = $metadatum1->get_metadatum_type_options();
$options = $metadatum1->get_metadata_type_options();
$options['allow_new_terms'] = false;
$metadatum1->set_metadatum_type_options($options);
$metadatum1->validate();
$this->metadata_repo->insert($metadatum1);
$metadatum1->set_metadata_type_options($options);
if ($metadatum1->validate()) {
$this->metadata_repo->insert($metadatum1);
} else {
$this->add_error_log('Error closing ' . $metadatum1->get_name());
$this->add_error_log($metadatum1->get_errors());
}
$metadatum2 = $this->metadata_repo->fetch( $this->get_transient('tax_2_metadatum') );
$options = $metadatum2->get_metadatum_type_options();
$options = $metadatum2->get_metadata_type_options();
$options['allow_new_terms'] = false;
$metadatum2->set_metadatum_type_options($options);
$metadatum2->validate();
$this->metadata_repo->insert($metadatum2);
$metadatum2->set_metadata_type_options($options);
if ($metadatum2->validate()) {
$this->metadata_repo->insert($metadatum2);
} else {
$this->add_error_log('Error closing ' . $metadatum2->get_name());
$this->add_error_log($metadatum2->get_errors());
}
}
@ -256,17 +333,17 @@ class Test_Importer extends Importer {
];
return [
'metadatum1' => 'Title ' . $index,
'metadatum2' => 'Description ' . $index,
'metadatum3' => $terms1[array_rand($terms1)],
'metadatum4' => $terms2[array_rand($terms2)],
'field1' => 'Title ' . $index,
'field2' => 'Description ' . $index,
'field3' => $terms1[array_rand($terms1)],
'field4' => $terms2[array_rand($terms2)],
];
}
public function get_col2_item($index) {
return [
'metadatum1' => 'Collection 2 item ' . $index,
'metadatum2' => 'Collection 2 item description ' . $index,
'metadatum3' => 'Collection 2 whatever ' . $index,
'field1' => 'Collection 2 item ' . $index,
'field2' => 'Collection 2 item description ' . $index,
'field3' => 'Collection 2 whatever ' . $index,
];
}

View File

@ -10,14 +10,14 @@ Vue.use(Buefy);
Vue.use(VueCustomElement);
import Text from '../classes/metadatum-types/text/Text.vue';
import Textarea from '../classes/metadatum-types/textarea/Textarea.vue';
import Selectbox from '../classes/metadatum-types/selectbox/Selectbox.vue';
import Numeric from '../classes/metadatum-types/numeric/Numeric.vue';
import Date from '../classes/metadatum-types/date/Date.vue';
import Relationship from '../classes/metadatum-types/relationship/Relationship.vue';
import Text from '../classes/metadata-types/text/Text.vue';
import Textarea from '../classes/metadata-types/textarea/Textarea.vue';
import Selectbox from '../classes/metadata-types/selectbox/Selectbox.vue';
import Numeric from '../classes/metadata-types/numeric/Numeric.vue';
import Date from '../classes/metadata-types/date/Date.vue';
import Relationship from '../classes/metadata-types/relationship/Relationship.vue';
import FormRelationship from '../classes/metadatum-types/relationship/FormRelationship.vue';
import FormRelationship from '../classes/metadata-types/relationship/FormRelationship.vue';
import FilterCustomInterval from '../classes/filter-types/custom-interval/CustomInterval.vue';
import FilterSelectbox from '../classes/filter-types/selectbox/Selectbox.vue';

View File

@ -35,7 +35,7 @@ export const sendMetadatum = ({commit}, {collectionId, name, metadatumType, stat
endpoint = '/metadata/';
axios.tainacan.post(endpoint + '?context=edit', {
name: name,
metadatum_type: metadatumType,
metadata_type: metadatumType,
status: status
})
.then(res => {
@ -113,7 +113,7 @@ export const updateCollectionMetadataOrder = ({ dispatch }, {collectionId, metad
export const fetchMetadatumTypes = ({commit}) => {
return new Promise((resolve, reject) => {
axios.tainacan.get('/metadatum-types')
axios.tainacan.get('/metadata-types')
.then((res) => {
let metadatumTypes = res.data;
commit('setMetadatumTypes', metadatumTypes);

View File

@ -77,15 +77,15 @@ export const setOrderBy = ({ commit }, orderBy ) => {
commit('setPostQueryAttribute', { attr: 'orderby', value: 'date' } );
} else if (orderBy.id == 'author_name') {
commit('setPostQueryAttribute', { attr: 'orderby', value: 'author_name' } );
} else if (orderBy.metadatum_type_object.primitive_type == 'float' || orderBy.metadatum_type_object.primitive_type == 'int') {
} else if (orderBy.metadata_type_object.primitive_type == 'float' || orderBy.metadata_type_object.primitive_type == 'int') {
commit('setPostQueryAttribute', { attr: 'meta_key', value: orderBy.id } );
commit('setPostQueryAttribute', { attr: 'orderby', value: 'meta_value_num' } );
} else if (orderBy.metadatum_type_object.primitive_type == 'date') {
} else if (orderBy.metadata_type_object.primitive_type == 'date') {
commit('setPostQueryAttribute', { attr: 'meta_key', value: orderBy.id } );
commit('setPostQueryAttribute', { attr: 'meta_type', value: 'DATETIME' } );
commit('setPostQueryAttribute', { attr: 'orderby', value: 'meta_value' } );
} else if (orderBy.metadatum_type_object.core) {
commit('setPostQueryAttribute', { attr: 'orderby', value: orderBy.metadatum_type_object.related_mapped_prop } );
} else if (orderBy.metadata_type_object.core) {
commit('setPostQueryAttribute', { attr: 'orderby', value: orderBy.metadata_type_object.related_mapped_prop } );
} else {
commit('setPostQueryAttribute', { attr: 'meta_key', value: orderBy.id } );
commit('setPostQueryAttribute', { attr: 'orderby', value: 'meta_value' } );

View File

@ -561,20 +561,20 @@ msgid "Approved"
msgstr "Aprovado"
#: admin/tainacan-admin-i18n.php:130
#: classes/metadatum-types/category/class-tainacan-category.php:35
#: classes/metadatum-types/relationship/class-tainacan-relationship.php:26
#: classes/metadata-types/category/class-tainacan-category.php:35
#: classes/metadata-types/relationship/class-tainacan-relationship.php:26
msgid "Collection Related"
msgstr "Coleção relacionada"
#: admin/tainacan-admin-i18n.php:131
#: classes/metadatum-types/relationship/class-tainacan-relationship.php:30
#: classes/metadata-types/relationship/class-tainacan-relationship.php:30
#, fuzzy
#| msgid "Metadata for search"
msgid "Metadata for search"
msgstr "Metadados para busca"
#: admin/tainacan-admin-i18n.php:132
#: classes/metadatum-types/relationship/class-tainacan-relationship.php:34
#: classes/metadata-types/relationship/class-tainacan-relationship.php:34
msgid "Allow repeated items"
msgstr "Permitir itens repetidos"
@ -585,12 +585,12 @@ msgid "Select taxonomy"
msgstr "Categoria pai"
#: admin/tainacan-admin-i18n.php:134
#: classes/metadatum-types/category/class-tainacan-category.php:39
#: classes/metadata-types/category/class-tainacan-category.php:39
msgid "Input type"
msgstr "Tipo de entrada"
#: admin/tainacan-admin-i18n.php:135
#: classes/metadatum-types/category/class-tainacan-category.php:43
#: classes/metadata-types/category/class-tainacan-category.php:43
msgid "Allow new terms"
msgstr "Permitir termos novos"
@ -1433,7 +1433,7 @@ msgstr ""
msgid "Limits the result set to collections with a specific name"
msgstr "Limita o conjunto de resultados a coleções com um nome específico"
#: api/endpoints/class-tainacan-rest-metadatum-types-controller.php:26
#: api/endpoints/class-tainacan-rest-metadata-types-controller.php:26
#: api/endpoints/class-tainacan-rest-filter-types-controller.php:26
#, fuzzy
msgid "The structure of objects returned."
@ -1649,26 +1649,26 @@ msgstr "Novo termo de gênero"
msgid "You can not have two terms with the same name at the same level"
msgstr "Você não pode ter dois termos com o mesmo nome em um mesmo nível"
#: classes/metadatum-types/category/class-tainacan-category.php:36
#: classes/metadatum-types/relationship/class-tainacan-relationship.php:27
#: classes/metadata-types/category/class-tainacan-category.php:36
#: classes/metadata-types/relationship/class-tainacan-relationship.php:27
msgid "Select the collection to fetch items"
msgstr "Selecione a coleção para buscar itens"
#: classes/metadatum-types/category/class-tainacan-category.php:40
#: classes/metadata-types/category/class-tainacan-category.php:40
msgid "The html type of the terms list "
msgstr "O tipo de html utilizado na lista de termos"
#: classes/metadatum-types/category/class-tainacan-category.php:44
#: classes/metadata-types/category/class-tainacan-category.php:44
msgid "Allows to create new terms"
msgstr "Permite a criação de novos termos"
#: classes/metadatum-types/category/class-tainacan-category.php:70
#: classes/metadata-types/category/class-tainacan-category.php:70
#, fuzzy
#| msgid "Please select a category"
msgid "Please select a taxonomy"
msgstr "Por favor, selecione uma taxonomia."
#: classes/metadatum-types/category/class-tainacan-category.php:88
#: classes/metadata-types/category/class-tainacan-category.php:88
#, fuzzy
#| msgid ""
#| "You can not have 2 taxonomy metadata using the same taxonomy in a "
@ -1679,18 +1679,18 @@ msgstr ""
"Você não pode ter 2 metadados de taxonomia utilizando a mesma taxonomia em "
"uma coleção."
#: classes/metadatum-types/core-description/class-tainacan-core-description.php:71
#: classes/metadatum-types/core-title/class-tainacan-core-title.php:72
#: classes/metadata-types/core-description/class-tainacan-core-description.php:71
#: classes/metadata-types/core-title/class-tainacan-core-title.php:72
msgid "Core Metadata can not accept multiple values"
msgstr "Metadados fixos (Core) não podem aceitar valores múltiplos"
#: classes/metadatum-types/relationship/class-tainacan-relationship.php:31
#: classes/metadata-types/relationship/class-tainacan-relationship.php:31
#, fuzzy
#| msgid "Select the metadata to help the search"
msgid "Select the metadata to help the search"
msgstr "Selecione os metadados que irão auxiliar na busca"
#: classes/metadatum-types/relationship/class-tainacan-relationship.php:35
#: classes/metadata-types/relationship/class-tainacan-relationship.php:35
#, fuzzy
#| msgid "Allow different items with the same item selected"
msgid ""
@ -1700,23 +1700,23 @@ msgstr ""
"Permite que itens diferentes sejam relacionados ao um mesmo item selecionado "
"de outra coleção"
#: classes/metadatum-types/relationship/class-tainacan-relationship.php:60
#: classes/metadata-types/relationship/class-tainacan-relationship.php:60
#, fuzzy
#| msgid "The collection ID"
msgid "Invalid collection ID"
msgstr "O ID da coleção"
#: classes/metadatum-types/relationship/class-tainacan-relationship.php:64
#: classes/metadata-types/relationship/class-tainacan-relationship.php:64
#, fuzzy
#| msgid "The metadatum Collection related is required"
msgid "The related collection is required"
msgstr "O metadado Coleção é requerido"
#: classes/metadatum-types/selectbox/class-tainacan-selectbox.php:26
#: classes/metadata-types/selectbox/class-tainacan-selectbox.php:26
msgid "Options"
msgstr "Opções"
#: classes/metadatum-types/selectbox/class-tainacan-selectbox.php:27
#: classes/metadata-types/selectbox/class-tainacan-selectbox.php:27
#, fuzzy
#| msgid "Create the options for the select, hit enter to add new one"
msgid "Creates options for what is selected. Hit <enter> to add a new one."
@ -1725,7 +1725,7 @@ msgstr ""
"uma nova opção."
# DESCOBRIR O CONTEXTO DESSA “REQUISIÇAO”
#: classes/metadatum-types/selectbox/class-tainacan-selectbox.php:56
#: classes/metadata-types/selectbox/class-tainacan-selectbox.php:56
#, fuzzy
#| msgid "Required"
msgid "Required options"

View File

@ -24,66 +24,130 @@ function tainacan_migrate_post_type_field_to_metadatum(){
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_key' => 'metadatum_type'],
['meta_key' => 'metadata_type'],
['meta_key' => 'field_type'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_key' => 'metadatum_type_options'],
['meta_key' => 'metadata_type_options'],
['meta_key' => 'field_type_options'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_key' => 'metadata_type'],
['meta_key' => 'metadatum_type'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_key' => 'metadata_type_options'],
['meta_key' => 'metadatum_type_options'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadatum_Types\Core_Description'],
['meta_value' => 'Tainacan\Metadata_Types\Core_Description'],
['meta_value' => 'Tainacan\Field_Types\Core_Description'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadatum_Types\Core_Title'],
['meta_value' => 'Tainacan\Metadata_Types\Core_Title'],
['meta_value' => 'Tainacan\Field_Types\Core_Title'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadatum_Types\Text'],
['meta_value' => 'Tainacan\Metadata_Types\Text'],
['meta_value' => 'Tainacan\Field_Types\Text'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadatum_Types\Textarea'],
['meta_value' => 'Tainacan\Metadata_Types\Textarea'],
['meta_value' => 'Tainacan\Field_Types\Textarea'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadatum_Types\Date'],
['meta_value' => 'Tainacan\Metadata_Types\Date'],
['meta_value' => 'Tainacan\Field_Types\Date'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadatum_Types\Numeric'],
['meta_value' => 'Tainacan\Metadata_Types\Numeric'],
['meta_value' => 'Tainacan\Field_Types\Numeric'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadatum_Types\Selectbox'],
['meta_value' => 'Tainacan\Metadata_Types\Selectbox'],
['meta_value' => 'Tainacan\Field_Types\Selectbox'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadatum_Types\Relationship'],
['meta_value' => 'Tainacan\Metadata_Types\Relationship'],
['meta_value' => 'Tainacan\Field_Types\Relationship'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadatum_Types\Category'],
['meta_value' => 'Tainacan\Metadata_Types\Category'],
['meta_value' => 'Tainacan\Field_Types\Category'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadatum_Types\Compound'],
['meta_value' => 'Tainacan\Metadata_Types\Compound'],
['meta_value' => 'Tainacan\Field_Types\Compound'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadata_Types\Core_Description'],
['meta_value' => 'Tainacan\Metadatum_Types\Core_Description'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadata_Types\Core_Title'],
['meta_value' => 'Tainacan\Metadatum_Types\Core_Title'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadata_Types\Text'],
['meta_value' => 'Tainacan\Metadatum_Types\Text'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadata_Types\Textarea'],
['meta_value' => 'Tainacan\Metadatum_Types\Textarea'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadata_Types\Date'],
['meta_value' => 'Tainacan\Metadatum_Types\Date'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadata_Types\Numeric'],
['meta_value' => 'Tainacan\Metadatum_Types\Numeric'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadata_Types\Selectbox'],
['meta_value' => 'Tainacan\Metadatum_Types\Selectbox'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadata_Types\Relationship'],
['meta_value' => 'Tainacan\Metadatum_Types\Relationship'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadata_Types\Category'],
['meta_value' => 'Tainacan\Metadatum_Types\Category'],
'%s', '%s');
$wpdb->update($wpdb->postmeta,
['meta_value' => 'Tainacan\Metadata_Types\Compound'],
['meta_value' => 'Tainacan\Metadatum_Types\Compound'],
'%s', '%s');
}
?>

View File

@ -11,10 +11,14 @@
v-if="column.display"
class="column-default-width"
:class="{
'thumbnail-cell': column.metadatum == 'row_thumbnail',
'column-small-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Date' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Numeric') : false,
'column-medium-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Selectbox' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Category' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Compound') : false,
'column-large-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Textarea') : false,
'thumbnail-cell': column.metadatum == 'row_thumbnail',
'column-small-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'date' ||
column.metadata_type_object.primitive_type == 'float' ||
column.metadata_type_object.primitive_type == 'int') : false,
'column-medium-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'term' ||
column.metadata_type_object.primitive_type == 'item' ||
column.metadata_type_object.primitive_type == 'compound') : false,
'column-large-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'long_string' || column.metadata_type_object.related_mapped_prop == 'description') : false,
}"
:custom-key="column.slug">
<div class="th-wrap">{{ column.name }}</div>
@ -37,11 +41,16 @@
class="column-default-width"
:class="{
'thumbnail-cell': column.metadatum == 'row_thumbnail',
'column-main-content' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.related_mapped_prop == 'title') : false,
'column-needed-width column-align-right' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Numeric') : false,
'column-small-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Date' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Numeric') : false,
'column-medium-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Selectbox' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Category' || column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Compound') : false,
'column-large-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Textarea') : false,
'column-main-content' : column.metadata_type_object != undefined ? (column.metadata_type_object.related_mapped_prop == 'title') : false,
'column-needed-width column-align-right' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'float' ||
column.metadata_type_object.primitive_type == 'int' ) : false,
'column-small-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'date' ||
column.metadata_type_object.primitive_type == 'int' ||
column.metadata_type_object.primitive_type == 'float') : false,
'column-medium-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'item' ||
column.metadata_type_object.primitive_type == 'term' ||
column.metadata_type_object.primitive_type == 'compound') : false,
'column-large-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'long_string' || column.metadata_type_object.related_mapped_prop == 'description') : false,
}"
@click="goToItemPage(item)">

View File

@ -4,7 +4,7 @@ namespace Tainacan\Tests\Factories;
class Metadatum_Factory {
private $metadatum;
protected $metadatum_type;
protected $metadata_type;
public function create_metadatum($type, $primitive_type = []){
if(empty($type)){
@ -15,8 +15,8 @@ class Metadatum_Factory {
$type = ucwords(strtolower($type), '_');
}
$this->metadatum_type = "\Tainacan\Metadatum_Types\\$type";
$this->metadatum = new $this->metadatum_type(/* Here goes the primitive type */);
$this->metadata_type = "\Tainacan\Metadata_Types\\$type";
$this->metadatum = new $this->metadata_type(/* Here goes the primitive type */);
return $this->metadatum;
}

View File

@ -26,7 +26,7 @@ class TAINACAN_REST_Export_Controller extends TAINACAN_UnitApiTestCase {
'name' => 'teste_Export',
'description' => 'descricao',
'collection' => $collection,
'metadatum_type' => $type,
'metadata_type' => $type,
'exposer_mapping' => [
'dublin-core' => 'language'
]

View File

@ -29,7 +29,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
'name' => 'teste_Expose',
'description' => 'descricao',
'collection' => $collection,
'metadatum_type' => $type,
'metadata_type' => $type,
'exposer_mapping' => [
'dublin-core' => 'language'
]

View File

@ -24,7 +24,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
'name' => 'Metadata filtered',
'description' => 'Is filtered',
'collection_id' => $collection->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Numeric',
'metadata_type' => 'Tainacan\Metadata_Types\Numeric',
),
true,
true
@ -185,7 +185,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
'name' => 'Metadatum filtered',
'description' => 'Is filtered',
'collection_id' => $collection->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Numeric'
'metadata_type' => 'Tainacan\Metadata_Types\Numeric'
),
true
);
@ -196,7 +196,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
'name' => 'Other filtered',
'description' => 'Is filtered',
'collection_id' => $collection->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Numeric'
'metadata_type' => 'Tainacan\Metadata_Types\Numeric'
),
true
);
@ -273,7 +273,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
'name' => 'Metadatum filtered',
'description' => 'Is filtered',
'collection_id' => $collection->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Text'
'metadata_type' => 'Tainacan\Metadata_Types\Text'
),
true
);
@ -284,7 +284,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
'name' => 'Metadatum filtered',
'description' => 'Is filtered',
'collection_id' => 'default',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text'
'metadata_type' => 'Tainacan\Metadata_Types\Text'
),
true
);

View File

@ -29,7 +29,7 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_UnitApiTestCase {
'name' => 'teste_metadado',
'description' => 'descricao',
'collection' => $collection,
'metadatum_type' => $type,
'metadata_type' => $type,
'accept_suggestion' => true
),
true,

Some files were not shown because too many files have changed in this diff Show More