re-refactor metadata types name

This commit is contained in:
Leo Germani 2018-06-11 14:57:50 -03:00
parent d5def1b539
commit 83eada31c4
95 changed files with 539 additions and 475 deletions

View File

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

View File

@ -145,7 +145,7 @@
</b-field> </b-field>
<b-field <b-field
v-if="!originalMetadatum.metadatum_type_object.core" v-if="!originalMetadatum.metadata_type_object.core"
:type="formErrors['multiple'] != undefined ? 'is-danger' : ''" :type="formErrors['multiple'] != undefined ? 'is-danger' : ''"
:message="formErrors['multiple'] != undefined ? formErrors['multiple'] : ''"> :message="formErrors['multiple'] != undefined ? formErrors['multiple'] : ''">
<b-checkbox <b-checkbox
@ -183,11 +183,11 @@
</b-field> </b-field>
<component <component
:errors="formErrors['metadatum_type_options']" :errors="formErrors['metadata_type_options']"
v-if="(editForm.metadatum_type_object && editForm.metadatum_type_object.form_component) || editForm.edit_form == ''" v-if="(editForm.metadata_type_object && editForm.metadata_type_object.form_component) || editForm.edit_form == ''"
:is="editForm.metadatum_type_object.form_component" :is="editForm.metadata_type_object.form_component"
:metadatum="editForm" :metadatum="editForm"
v-model="editForm.metadatum_type_options"/> v-model="editForm.metadata_type_options"/>
<div <div
v-html="editForm.edit_form" v-html="editForm.edit_form"
v-else/> v-else/>
@ -259,7 +259,7 @@
]), ]),
saveEdition(metadatum) { 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({ this.updateMetadatum({
collectionId: this.collectionId, collectionId: this.collectionId,

View File

@ -319,7 +319,7 @@ export default {
for (let filter of this.filterTypes) { for (let filter of this.filterTypes) {
for (let supportedType of filter['supported_types']) { for (let supportedType of filter['supported_types']) {
if (choosenMetadatum.metadatum_type_object.primitive_type == supportedType) if (choosenMetadatum.metadata_type_object.primitive_type == supportedType)
this.allowedFilterTypes.push(filter); this.allowedFilterTypes.push(filter);
} }
} }

View File

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

View File

@ -54,7 +54,7 @@
<span <span
v-if="metadatum.id != undefined" v-if="metadatum.id != undefined"
class="label-details"> 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 <span
class="not-saved" class="not-saved"
v-if="(editForms[metadatum.id] != undefined && editForms[metadatum.id].saved != true) || metadatum.status == 'auto-draft'"> v-if="(editForms[metadatum.id] != undefined && editForms[metadatum.id].saved != true) || metadatum.status == 'auto-draft'">
@ -84,8 +84,8 @@
<a <a
:style="{ visibility: :style="{ visibility:
metadatum.collection_id != collectionId || metadatum.collection_id != collectionId ||
metadatum.metadatum_type == 'Tainacan\\Metadatum_Types\\Core_Title' || metadatum.metadata_type == 'Tainacan\\Metadata_Types\\Core_Title' ||
metadatum.metadatum_type == 'Tainacan\\Metadatum_Types\\Core_Description' metadatum.metadata_type == 'Tainacan\\Metadata_Types\\Core_Description'
? 'hidden' : 'visible' ? 'hidden' : 'visible'
}" }"
@click.prevent="removeMetadatum(metadatum)"> @click.prevent="removeMetadatum(metadatum)">
@ -112,7 +112,7 @@
<div class="column available-metadata-area" > <div class="column available-metadata-area" >
<div class="field"> <div class="field">
<h3 class="label">{{ $i18n.get('label_available_metadatum_types') }}</h3> <h3 class="label">{{ $i18n.get('label_available_metadata_types') }}</h3>
<draggable <draggable
v-model="availableMetadatumList" v-model="availableMetadatumList"
:options="{ :options="{

View File

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

View File

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

View File

@ -187,11 +187,11 @@
metadatum.id === 'creation_date' || metadatum.id === 'creation_date' ||
metadatum.id === 'author_name' || ( metadatum.id === 'author_name' || (
metadatum.id !== undefined && metadatum.id !== undefined &&
metadatum.metadatum_type_object && metadatum.metadata_type_object &&
metadatum.metadatum_type_object.related_mapped_prop !== 'description' && metadatum.metadata_type_object.related_mapped_prop !== 'description' &&
metadatum.metadatum_type_object.primitive_type !== 'term' && metadatum.metadata_type_object.primitive_type !== 'term' &&
metadatum.metadatum_type_object.primitive_type !== 'item' && metadatum.metadata_type_object.primitive_type !== 'item' &&
metadatum.metadatum_type_object.primitive_type !== 'compound' metadatum.metadata_type_object.primitive_type !== 'compound'
)" )"
:value="metadatum" :value="metadatum"
:key="metadatum.id"> :key="metadatum.id">
@ -587,7 +587,7 @@
metadata.push({ metadata.push({
name: this.$i18n.get('label_thumbnail'), name: this.$i18n.get('label_thumbnail'),
metadatum: 'row_thumbnail', metadatum: 'row_thumbnail',
metadatum_type: undefined, metadata_type: undefined,
slug: 'thumbnail', slug: 'thumbnail',
id: undefined, id: undefined,
display: true display: true
@ -610,8 +610,8 @@
name: metadatum.name, name: metadatum.name,
metadatum: metadatum.description, metadatum: metadatum.description,
slug: metadatum.slug, slug: metadatum.slug,
metadatum_type: metadatum.metadatum_type, metadata_type: metadatum.metadata_type,
metadatum_type_object: metadatum.metadatum_type_object, metadata_type_object: metadatum.metadata_type_object,
id: metadatum.id, id: metadatum.id,
display: display display: display
} }
@ -624,7 +624,7 @@
metadata.push({ metadata.push({
name: this.$i18n.get('label_creation_date'), name: this.$i18n.get('label_creation_date'),
metadatum: 'row_creation', metadatum: 'row_creation',
metadatum_type: undefined, metadata_type: undefined,
slug: 'creation_date', slug: 'creation_date',
id: undefined, id: undefined,
display: true display: true
@ -632,7 +632,7 @@
metadata.push({ metadata.push({
name: this.$i18n.get('label_created_by'), name: this.$i18n.get('label_created_by'),
metadatum: 'row_author', metadatum: 'row_author',
metadatum_type: undefined, metadata_type: undefined,
slug: 'author_name', slug: 'author_name',
id: undefined, id: undefined,
display: true display: true

View File

@ -126,7 +126,7 @@ return apply_filters('tainacan-admin-i18n',[
'label_items_per_page' => __( 'Items per Page:', 'tainacan' ), 'label_items_per_page' => __( 'Items per Page:', 'tainacan' ),
'label_active_metadata' => __( 'Active Metadata', 'tainacan' ), 'label_active_metadata' => __( 'Active Metadata', 'tainacan' ),
'label_available_metadata' => __( 'Available 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_active_filters' => __( 'Active Filters', 'tainacan' ),
'label_filter_type' => __( 'Filter Type', 'tainacan' ), 'label_filter_type' => __( 'Filter Type', 'tainacan' ),
'label_available_filters' => __( 'Available Filters', 'tainacan' ), 'label_available_filters' => __( 'Available Filters', 'tainacan' ),

View File

@ -247,13 +247,13 @@ class REST_Controller extends \WP_REST_Controller {
// handle core metadatum // handle core metadatum
if( is_array($a) && array_key_exists("key", $a) ){ if( is_array($a) && array_key_exists("key", $a) ){
$metadatum = new \Tainacan\Entities\Metadatum($a['key']); $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' ] = [ $args[ 'post_title_in' ] = [
'relation' => ( isset( $request_meta_query['relation']) ) ? $request_meta_query['relation'] : 'AND' , 'relation' => ( isset( $request_meta_query['relation']) ) ? $request_meta_query['relation'] : 'AND' ,
'value' => ( is_array( $a['value'] ) ) ? $a['value'] : [$a['value']] 'value' => ( is_array( $a['value'] ) ) ? $a['value'] : [$a['value']]
]; ];
continue; 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' ] = [ $args[ 'post_content_in' ] = [
'relation' => ( isset( $request_meta_query['relation']) ) ? $request_meta_query['relation'] : 'AND' , 'relation' => ( isset( $request_meta_query['relation']) ) ? $request_meta_query['relation'] : 'AND' ,
'value' => ( is_array( $a['value'] ) ) ? $a['value'] : [$a['value']] '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){ foreach ($items_metadata as $item_metadata){
$index = array_push($prepared_item, $this->prepare_item_for_response($item_metadata, $request)); $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); 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(); $metadatum = $item_metadata->get_metadatum();
if($metadatum->get_id() == $metadatum_id) { if($metadatum->get_id() == $metadatum_id) {
$prepared_item = $this->prepare_item_for_response($item_metadata, $request); $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 ); $metadatum_updated = $this->item_metadata_repository->update( $item_metadata );
$prepared_item = $this->prepare_item_for_response($metadatum_updated, $request); $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()) { elseif($metadatum->get_accept_suggestion()) {
$log = $this->item_metadata_repository->suggest( $item_metadata ); $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_metadata_array = $me->_toArray();
$item_array['metadata'][ $slug ]['name'] = $metadatum->get_name(); $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']; $item_array['metadata'][ $slug ]['date_i18n'] = $item_metadata_array['date_i18n'];
} else { } else {
$item_array['metadata'][ $slug ]['value'] = $item_metadata_array['value']; $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)){ if(!empty($item)){
$item_arr = $item->_toArray(); $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'){ if($request['context'] === 'edit'){
$item_arr['current_user_can_edit'] = $item->can_edit(); $item_arr['current_user_can_edit'] = $item->can_edit();
ob_start(); ob_start();
$item->get_metadatum_type_object()->form(); $item->get_metadata_type_object()->form();
$form = ob_get_clean(); $form = ob_get_clean();
$item_arr['edit_form'] = $form; $item_arr['edit_form'] = $form;
$item_arr['enabled'] = $item->get_enabled_for_collection(); $item_arr['enabled'] = $item->get_enabled_for_collection();

View File

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

View File

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

View File

@ -54,7 +54,7 @@ class Item_Metadata_Entity extends Entity {
$metadatum = $this->get_metadatum(); $metadatum = $this->get_metadatum();
if (is_object($metadatum)) { if (is_object($metadatum)) {
$fto = $metadatum->get_metadatum_type_object(); $fto = $metadatum->get_metadata_type_object();
if (is_object($fto)) { if (is_object($fto)) {
if ( method_exists($fto, 'get_value_as_html') ) { 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_html'] = $this->get_value_as_html();
$as_array['value_as_string'] = $this->get_value_as_string(); $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()); $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; return false;
} }
$classMetadatumType = $metadatum->get_metadatum_type_object(); $classMetadatumType = $metadatum->get_metadata_type_object();
if( is_object( $classMetadatumType ) ){ if( is_object( $classMetadatumType ) ){
if( method_exists ( $classMetadatumType , 'validate' ) ){ if( method_exists ( $classMetadatumType , 'validate' ) ){
if( ! $classMetadatumType->validate( $this ) ) { if( ! $classMetadatumType->validate( $this ) ) {
$this->add_error('metadatum_type_error', $classMetadatumType->get_errors() ); $this->add_error('metadata_type_error', $classMetadatumType->get_errors() );
return false; return false;
} }
} }

View File

@ -385,7 +385,7 @@ class Item extends Entity {
foreach ( $arrayItemMetadata as $itemMetadata ) { foreach ( $arrayItemMetadata as $itemMetadata ) {
// skip validation for Compound Metadata // 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; continue;
} }
@ -582,7 +582,7 @@ class Item extends Entity {
foreach ( $metadata as $item_meta ) { 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 ( $fto->get_core() ) {
if ( $args['exclude_core'] ) { if ( $args['exclude_core'] ) {

View File

@ -21,8 +21,8 @@ class Metadatum extends Entity {
$collection_key, $collection_key,
$mask, $mask,
$default_value, $default_value,
$metadatum_type, $metadata_type,
$metadatum_type_options; $metadata_type_options;
// Collection getter and setter declared here // Collection getter and setter declared here
use \Tainacan\Traits\Entity_Collection_Relation; 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(){ function get_metadata_type_object(){
$class_name = $this->get_metadatum_type(); $class_name = $this->get_metadata_type();
$object_type = new $class_name(); $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; return $object_type;
} }
@ -182,8 +182,8 @@ class Metadatum extends Entity {
* *
* @return string The * @return string The
*/ */
function get_metadatum_type(){ function get_metadata_type(){
return $this->get_mapped_property('metadatum_type'); return $this->get_mapped_property('metadata_type');
} }
/** /**
@ -191,8 +191,8 @@ class Metadatum extends Entity {
* *
* @return array Configurations for the metadatum type object * @return array Configurations for the metadatum type object
*/ */
function get_metadatum_type_options(){ function get_metadata_type_options(){
return $this->get_mapped_property('metadatum_type_options'); return $this->get_mapped_property('metadata_type_options');
} }
/** /**
@ -330,10 +330,10 @@ class Metadatum extends Entity {
/** /**
* set the metadatum type class name * 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 ){ public function set_metadata_type( $value ){
$this->set_mapped_property('metadatum_type', ( is_object( $value ) ) ? get_class( $value ) : $value ) ; // Encode to avoid backslaches removal $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 * @param [string || integer] $value
* @return void * @return void
*/ */
function set_metadatum_type_options( $value ){ function set_metadata_type_options( $value ){
$this->set_mapped_property('metadatum_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) // You cant have a multiple metadatum inside a compound metadatum (except category)
if ($this->get_parent() > 0) { 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')); $this->add_error($this->get_id(), __('Compound metadata do not support metadata with multiple values (except categories)', 'tainacan'));
return false; return false;
} }
} }
// You cant have a category metadatum inside a multiple compound metadatum // 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()); $parent_metadatum = new \Tainacan\Entities\Metadatum($this->get_parent());
if ( $parent_metadatum->is_multiple() ) { if ( $parent_metadatum->is_multiple() ) {
$this->add_error($this->get_id(), __('Taxonomy metadata can not be used inside Compound metadata with multiple values', 'tainacan')); $this->add_error($this->get_id(), __('Taxonomy metadata can not be used inside Compound metadata with multiple values', 'tainacan'));
return false; 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(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$children = $Tainacan_Metadata->fetch( $children = $Tainacan_Metadata->fetch(
[ [
'parent' => $this->get_id(), 'parent' => $this->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Category', 'metadata_type' => 'Tainacan\Metadata_Types\Category',
'post_status' => 'any' 'post_status' => 'any'
] ]
, 'OBJECT'); , '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)) { if (is_object($fto)) {
$is_valid = $fto->validate_options($this); $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" ); 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; return false;

View File

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

View File

@ -21,7 +21,7 @@ class Autocomplete extends Filter_Type {
public function render( $filter ){ public function render( $filter ){
return '<tainacan-filter-autocomplete name="'.$filter->get_name().'" return '<tainacan-filter-autocomplete name="'.$filter->get_name().'"
collection_id="'.$filter->get_collection_id().'" 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>'; metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-autocomplete>';
} }
} }

View File

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

View File

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

View File

@ -20,7 +20,7 @@
created(){ created(){
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id; 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.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; let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum;
@ -31,7 +31,7 @@
axios.get(in_route) axios.get(in_route)
.then( res => { .then( res => {
let metadatum = res.data; let metadatum = res.data;
this.selectedValues( metadatum.metadatum_type_options.taxonomy_id ); this.selectedValues( metadatum.metadata_type_options.taxonomy_id );
}); });
}, },
data(){ data(){
@ -88,7 +88,7 @@
axios.get(endpoint) axios.get(endpoint)
.then( res => { .then( res => {
let metadatum = res.data; 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; this.isLoading = true;
promise.then( () => { promise.then( () => {
this.isLoading = false; this.isLoading = false;

View File

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

View File

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

View File

@ -20,7 +20,7 @@ class Checkbox extends Filter_Type {
public function render( $filter ){ public function render( $filter ){
return '<tainacan-filter-checkbox name="'.$filter->get_name().'" 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().'" collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-selectbox>'; metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-selectbox>';
} }

View File

@ -75,9 +75,9 @@
axios.get(in_route) axios.get(in_route)
.then( res => { .then( res => {
let result = res.data; let result = res.data;
if( result && result.metadatum_type ){ if( result && result.metadata_type ){
vm.metadatum_object = result; 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(); vm.selectedValues();
} }
}) })

View File

@ -20,7 +20,7 @@ class Custom_Interval extends Filter_Type {
* @internal param $metadatum * @internal param $metadatum
*/ */
public function render( $filter ){ 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 return '<tainacan-filter-custom-interval
name="'.$filter->get_name().'" name="'.$filter->get_name().'"
typeRange="'.$type.'" typeRange="'.$type.'"

View File

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

View File

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

View File

@ -20,7 +20,7 @@ class Selectbox extends Filter_Type {
public function render( $filter ){ public function render( $filter ){
return '<tainacan-filter-selectbox name="'.$filter->get_name().'" 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().'" collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-selectbox>'; metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-selectbox>';
} }

View File

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

View File

@ -20,7 +20,7 @@ class Taginput extends Filter_Type {
public function render( $filter ){ public function render( $filter ){
return '<tainacan-filter-taginput name="'.$filter->get_name().'" 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().'" collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-taginput>'; metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-taginput>';
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,13 +1,13 @@
<?php <?php
namespace Tainacan\Metadatum_Types; namespace Tainacan\Metadata_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/** /**
* Class TainacanMetadatumType * Class TainacanMetadatumType
*/ */
abstract class Metadatum_Type { abstract class Metadata_Type {
/** /**
@ -24,7 +24,7 @@ abstract class Metadatum_Type {
private $primitive_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 * @var array
*/ */
private $options = []; private $options = [];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -47,12 +47,12 @@ class Item_Metadata extends Repository {
$unique = !$item_metadata->is_multiple(); $unique = !$item_metadata->is_multiple();
$metadatum_type = $item_metadata->get_metadatum()->get_metadatum_type_object(); $metadata_type = $item_metadata->get_metadatum()->get_metadata_type_object();
if ($metadatum_type->get_core()) { if ($metadata_type->get_core()) {
$this->save_core_metadatum_value($item_metadata); $this->save_core_metadatum_value($item_metadata);
} elseif ($metadatum_type->get_primitive_type() == 'term') { } elseif ($metadata_type->get_primitive_type() == 'term') {
$this->save_terms_metadatum_value($item_metadata); $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 // do nothing. Compound values are updated when its child metadata are updated
return $item_metadata; return $item_metadata;
} else { } else {
@ -115,10 +115,10 @@ class Item_Metadata extends Repository {
public function delete($item_metadata){} public function delete($item_metadata){}
public function save_core_metadatum_value(\Tainacan\Entities\Item_Metadata_Entity $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(); $metadata_type = $item_metadata->get_metadatum()->get_metadata_type_object();
if ($metadatum_type->get_core()) { if ($metadata_type->get_core()) {
$item = $item_metadata->get_item(); $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(); $value = $item_metadata->get_value();
$item->$set_method( is_array( $value ) ? $value[0] : $value ); $item->$set_method( is_array( $value ) ? $value[0] : $value );
if ($item->validate_core_metadata()) { if ($item->validate_core_metadata()) {
@ -131,10 +131,10 @@ class Item_Metadata extends Repository {
} }
public function save_terms_metadatum_value($item_metadata) { public function save_terms_metadatum_value($item_metadata) {
$metadatum_type = $item_metadata->get_metadatum()->get_metadatum_type_object(); $metadata_type = $item_metadata->get_metadatum()->get_metadata_type_object();
if ($metadatum_type->get_primitive_type() == 'term') { if ($metadata_type->get_primitive_type() == 'term') {
$new_terms = $item_metadata->get_value(); $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 ){ if( $taxonomy ){
$old = $item_metadata; $old = $item_metadata;
@ -222,17 +222,17 @@ class Item_Metadata extends Repository {
public function get_value(Entities\Item_Metadata_Entity $item_metadata) { public function get_value(Entities\Item_Metadata_Entity $item_metadata) {
$unique = ! $item_metadata->is_multiple(); $unique = ! $item_metadata->is_multiple();
$metadatum_type = $item_metadata->get_metadatum()->get_metadatum_type_object(); $metadata_type = $item_metadata->get_metadatum()->get_metadata_type_object();
if ($metadatum_type->get_core()) { if ($metadata_type->get_core()) {
$item = $item_metadata->get_item(); $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(); 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') ) ){ if( is_numeric( $metadata_type->get_option('taxonomy_id') ) ){
$taxonomy = new Entities\Taxonomy( $metadatum_type->get_option('taxonomy_id') ); $taxonomy = new Entities\Taxonomy( $metadata_type->get_option('taxonomy_id') );
if( $taxonomy ){ if( $taxonomy ){
$taxonomy_slug = $taxonomy->get_db_identifier(); $taxonomy_slug = $taxonomy->get_db_identifier();
} else { } else {
@ -262,7 +262,7 @@ class Item_Metadata extends Repository {
return $terms; return $terms;
} elseif ($metadatum_type->get_primitive_type() == 'compound') { } elseif ($metadata_type->get_primitive_type() == 'compound') {
global $wpdb; global $wpdb;
$rows = $wpdb->get_results( $rows = $wpdb->get_results(

View File

@ -293,9 +293,9 @@ class Logs extends Repository {
} }
if ( $new_value instanceof Entities\Metadatum ) { 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; return false;
} }
} }

View File

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

View File

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

View File

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

View File

@ -317,13 +317,13 @@ class Exposers {
$metadatum = new \Tainacan\Entities\Metadatum(); $metadatum = new \Tainacan\Entities\Metadatum();
if( if(
array_key_exists('metadatum_type', $mapper_metadatum) && array_key_exists('metadata_type', $mapper_metadatum) &&
$mapper_metadatum['metadatum_type'] != false && $mapper_metadatum['metadata_type'] != false &&
class_exists($mapper_metadatum['metadatum_type']) class_exists($mapper_metadatum['metadata_type'])
) { ) {
$metadatum->set_metadatum_type($mapper_metadatum['metadatum_type']); $metadatum->set_metadata_type($mapper_metadatum['metadata_type']);
} else { } 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_name($mapper_metadatum['label']);
$metadatum->set_description($mapper_metadatum['URI']); $metadatum->set_description($mapper_metadatum['URI']);

View File

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

View File

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

View File

@ -342,14 +342,14 @@ class Old_Tainacan extends Importer{
$type = $this->define_type($type); $type = $this->define_type($type);
$newMetadatum->set_name($name); $newMetadatum->set_name($name);
$newMetadatum->set_metadatum_type('Tainacan\Metadatum_Types\\'.$type); $newMetadatum->set_metadata_type('Tainacan\Metadata_Types\\'.$type);
if(strcmp($type, "Category") === 0) if(strcmp($type, "Category") === 0)
{ {
$taxonomy_id = $meta->metadata->taxonomy; $taxonomy_id = $meta->metadata->taxonomy;
if(isset($created_categories[$taxonomy_id])) if(isset($created_categories[$taxonomy_id]))
{ {
$new_category_id = $created_categories[$taxonomy_id]['new_id']; $new_category_id = $created_categories[$taxonomy_id]['new_id'];
$newMetadatum->set_metadatum_type_options(['taxonomy_id' => $new_category_id]); $newMetadatum->set_metadata_type_options(['taxonomy_id' => $new_category_id]);
} }
}else if(strcmp($type, "Relationship") === 0) }else if(strcmp($type, "Relationship") === 0)
{ {
@ -358,7 +358,7 @@ class Old_Tainacan extends Importer{
if(isset($relationships[$taxonomy_id])) if(isset($relationships[$taxonomy_id]))
{ {
$new_collection_id = $relationships[$taxonomy_id]['new_id']; $new_collection_id = $relationships[$taxonomy_id]['new_id'];
$newMetadatum->set_metadatum_type_options(['collection_id' => $new_collection_id]); $newMetadatum->set_metadata_type_options(['collection_id' => $new_collection_id]);
} }
}else if(strcmp($type, "Compound") === 0) }else if(strcmp($type, "Compound") === 0)
{ {
@ -770,7 +770,7 @@ class Old_Tainacan extends Importer{
$newMetadatum->set_name($meta_name); $newMetadatum->set_name($meta_name);
$newMetadatum->set_metadatum_type('Tainacan\Metadatum_Types\\'.$type); $newMetadatum->set_metadata_type('Tainacan\Metadata_Types\\'.$type);
$newMetadatum->set_collection($this->actual_collection); $newMetadatum->set_collection($this->actual_collection);
$newMetadatum->validate(); // there is no user input here, so we can be sure it will validate. $newMetadatum->validate(); // there is no user input here, so we can be sure it will validate.

View File

@ -156,8 +156,8 @@ class Test_Importer extends Importer {
$metadatum = new Entities\Metadatum(); $metadatum = new Entities\Metadatum();
$metadatum->set_name('Colora'); $metadatum->set_name('Colora');
$metadatum->set_collection($col1); $metadatum->set_collection($col1);
$metadatum->set_metadatum_type('Tainacan\Metadatum_Types\Category'); $metadatum->set_metadata_type('Tainacan\Metadata_Types\Category');
$metadatum->set_metadatum_type_options([ $metadatum->set_metadata_type_options([
'taxonomy_id' => $this->get_transient('tax_1_id'), 'taxonomy_id' => $this->get_transient('tax_1_id'),
'allow_new_terms' => true 'allow_new_terms' => true
]); ]);
@ -177,8 +177,8 @@ class Test_Importer extends Importer {
$metadatum = new Entities\Metadatum(); $metadatum = new Entities\Metadatum();
$metadatum->set_name('Qualitya'); $metadatum->set_name('Qualitya');
$metadatum->set_collection($col1); $metadatum->set_collection($col1);
$metadatum->set_metadatum_type('Tainacan\Metadatum_Types\Category'); $metadatum->set_metadata_type('Tainacan\Metadata_Types\Category');
$metadatum->set_metadatum_type_options([ $metadatum->set_metadata_type_options([
'taxonomy_id' => $this->get_transient('tax_2_id'), 'taxonomy_id' => $this->get_transient('tax_2_id'),
'allow_new_terms' => true 'allow_new_terms' => true
]); ]);
@ -211,7 +211,7 @@ class Test_Importer extends Importer {
$metadatum = new Entities\Metadatum(); $metadatum = new Entities\Metadatum();
$metadatum->set_name('Test Metadatum'); $metadatum->set_name('Test Metadatum');
$metadatum->set_collection($col2); $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->set_status('publish');
if ($metadatum->validate()) { if ($metadatum->validate()) {
@ -261,9 +261,9 @@ class Test_Importer extends Importer {
$metadatum1 = $this->metadata_repo->fetch( $this->get_transient('tax_1_metadatum') ); $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; $options['allow_new_terms'] = false;
$metadatum1->set_metadatum_type_options($options); $metadatum1->set_metadata_type_options($options);
if ($metadatum1->validate()) { if ($metadatum1->validate()) {
$this->metadata_repo->insert($metadatum1); $this->metadata_repo->insert($metadatum1);
} else { } else {
@ -272,9 +272,9 @@ class Test_Importer extends Importer {
} }
$metadatum2 = $this->metadata_repo->fetch( $this->get_transient('tax_2_metadatum') ); $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; $options['allow_new_terms'] = false;
$metadatum2->set_metadatum_type_options($options); $metadatum2->set_metadata_type_options($options);
if ($metadatum2->validate()) { if ($metadatum2->validate()) {
$this->metadata_repo->insert($metadatum2); $this->metadata_repo->insert($metadatum2);
} else { } else {

View File

@ -10,14 +10,14 @@ Vue.use(Buefy);
Vue.use(VueCustomElement); Vue.use(VueCustomElement);
import Text from '../classes/metadatum-types/text/Text.vue'; import Text from '../classes/metadata-types/text/Text.vue';
import Textarea from '../classes/metadatum-types/textarea/Textarea.vue'; import Textarea from '../classes/metadata-types/textarea/Textarea.vue';
import Selectbox from '../classes/metadatum-types/selectbox/Selectbox.vue'; import Selectbox from '../classes/metadata-types/selectbox/Selectbox.vue';
import Numeric from '../classes/metadatum-types/numeric/Numeric.vue'; import Numeric from '../classes/metadata-types/numeric/Numeric.vue';
import Date from '../classes/metadatum-types/date/Date.vue'; import Date from '../classes/metadata-types/date/Date.vue';
import Relationship from '../classes/metadatum-types/relationship/Relationship.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 FilterCustomInterval from '../classes/filter-types/custom-interval/CustomInterval.vue';
import FilterSelectbox from '../classes/filter-types/selectbox/Selectbox.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/'; endpoint = '/metadata/';
axios.tainacan.post(endpoint + '?context=edit', { axios.tainacan.post(endpoint + '?context=edit', {
name: name, name: name,
metadatum_type: metadatumType, metadata_type: metadatumType,
status: status status: status
}) })
.then(res => { .then(res => {
@ -113,7 +113,7 @@ export const updateCollectionMetadataOrder = ({ dispatch }, {collectionId, metad
export const fetchMetadatumTypes = ({commit}) => { export const fetchMetadatumTypes = ({commit}) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.tainacan.get('/metadatum-types') axios.tainacan.get('/metadata-types')
.then((res) => { .then((res) => {
let metadatumTypes = res.data; let metadatumTypes = res.data;
commit('setMetadatumTypes', metadatumTypes); commit('setMetadatumTypes', metadatumTypes);

View File

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

View File

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

View File

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

@ -12,9 +12,9 @@
class="column-default-width" class="column-default-width"
:class="{ :class="{
'thumbnail-cell': column.metadatum == 'row_thumbnail', '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-small-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.className == 'Tainacan\\Metadata_Types\\Date' || column.metadata_type_object.className == 'Tainacan\\Metadata_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-medium-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.className == 'Tainacan\\Metadata_Types\\Selectbox' || column.metadata_type_object.className == 'Tainacan\\Metadata_Types\\Category' || column.metadata_type_object.className == 'Tainacan\\Metadata_Types\\Compound') : false,
'column-large-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Textarea') : false, 'column-large-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.className == 'Tainacan\\Metadata_Types\\Textarea') : false,
}" }"
:custom-key="column.slug"> :custom-key="column.slug">
<div class="th-wrap">{{ column.name }}</div> <div class="th-wrap">{{ column.name }}</div>
@ -37,11 +37,11 @@
class="column-default-width" class="column-default-width"
:class="{ :class="{
'thumbnail-cell': column.metadatum == 'row_thumbnail', 'thumbnail-cell': column.metadatum == 'row_thumbnail',
'column-main-content' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.related_mapped_prop == 'title') : 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.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Numeric') : false, 'column-needed-width column-align-right' : column.metadata_type_object != undefined ? (column.metadata_type_object.className == 'Tainacan\\Metadata_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-small-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.className == 'Tainacan\\Metadata_Types\\Date' || column.metadata_type_object.className == 'Tainacan\\Metadata_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-medium-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.className == 'Tainacan\\Metadata_Types\\Selectbox' || column.metadata_type_object.className == 'Tainacan\\Metadata_Types\\Category' || column.metadata_type_object.className == 'Tainacan\\Metadata_Types\\Compound') : false,
'column-large-width' : column.metadatum_type_object != undefined ? (column.metadatum_type_object.className == 'Tainacan\\Metadatum_Types\\Textarea') : false, 'column-large-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.className == 'Tainacan\\Metadata_Types\\Textarea') : false,
}" }"
@click="goToItemPage(item)"> @click="goToItemPage(item)">

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,7 +24,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
array( array(
'name' => 'Moeda', 'name' => 'Moeda',
'description' => 'Descreve campo moeda.', 'description' => 'Descreve campo moeda.',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
) )
); );
@ -60,7 +60,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
'description' => 'Descreve valor do campo data.', 'description' => 'Descreve valor do campo data.',
'collection' => $collection, 'collection' => $collection,
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), true ), true
); );
@ -79,7 +79,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
array( array(
'name' => 'Ano de Publicação', 'name' => 'Ano de Publicação',
'description' => 'Uma data no formato dd/mm/aaaa.', 'description' => 'Uma data no formato dd/mm/aaaa.',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
) )
); );
@ -115,7 +115,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
'description' => 'Descreve valor do campo data.', 'description' => 'Descreve valor do campo data.',
'collection' => $collection, 'collection' => $collection,
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), true ), true
); );
@ -126,7 +126,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
'description' => 'Descreve valor do campo data.', 'description' => 'Descreve valor do campo data.',
'collection_id' => 'default', 'collection_id' => 'default',
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), true ), true
); );
@ -171,7 +171,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
'description' => 'Descreve valor do campo data.', 'description' => 'Descreve valor do campo data.',
'collection' => $collection, 'collection' => $collection,
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -244,7 +244,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
'description' => 'Descreve o dado do campo data.', 'description' => 'Descreve o dado do campo data.',
'collection' => $collection, 'collection' => $collection,
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'multiple' => 'yes' 'multiple' => 'yes'
), ),
true true
@ -322,7 +322,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
'description' => 'No Statement', 'description' => 'No Statement',
'collection' => $collection, 'collection' => $collection,
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'multiple' => 'yes' 'multiple' => 'yes'
), ),
true true
@ -350,7 +350,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
'description' => 'No Statement', 'description' => 'No Statement',
'collection_id' => 'default', 'collection_id' => 'default',
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'multiple' => 'yes' 'multiple' => 'yes'
), ),
true true
@ -378,7 +378,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
'description' => 'No Statement', 'description' => 'No Statement',
'collection_id' => 'default', 'collection_id' => 'default',
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'multiple' => 'no' 'multiple' => 'no'
), ),
true true
@ -446,7 +446,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
'description' => 'Descreve valor do campo data.', 'description' => 'Descreve valor do campo data.',
'collection' => $collection, 'collection' => $collection,
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );

View File

@ -5,11 +5,11 @@ namespace Tainacan\Tests;
/** /**
* @group api * @group api
*/ */
class TAINACAN_REST_Metadatum_Types_Controller extends TAINACAN_UnitApiTestCase { class TAINACAN_REST_Metadata_Types_Controller extends TAINACAN_UnitApiTestCase {
public function test_get_metadatum_types(){ public function test_get_metadata_types(){
$ftype_request = new \WP_REST_Request('GET', $this->namespace . '/metadatum-types'); $ftype_request = new \WP_REST_Request('GET', $this->namespace . '/metadata-types');
$ftype_response = $this->server->dispatch($ftype_request); $ftype_response = $this->server->dispatch($ftype_request);
@ -17,12 +17,12 @@ class TAINACAN_REST_Metadatum_Types_Controller extends TAINACAN_UnitApiTestCase
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$metadatum_types = $Tainacan_Metadata->fetch_metadatum_types('NAME'); $metadata_types = $Tainacan_Metadata->fetch_metadata_types('NAME');
$this->assertEquals(count($metadatum_types), count($data)); $this->assertEquals(count($metadata_types), count($data));
foreach ($data as $ftype){ foreach ($data as $ftype){
$this->assertContains($ftype['name'], $metadatum_types); $this->assertContains($ftype['name'], $metadata_types);
} }
} }
} }

View File

@ -106,7 +106,7 @@ class TAINACAN_REST_Queries extends TAINACAN_UnitApiTestCase {
// Create Metadata and Metadatum Type // Create Metadata and Metadatum Type
$metadatum_type = $this->tainacan_metadatum_factory->create_metadatum('text'); $metadata_type = $this->tainacan_metadatum_factory->create_metadatum('text');
$metadatumA1 = $this->tainacan_entity_factory->create_entity( $metadatumA1 = $this->tainacan_entity_factory->create_entity(
'metadatum', 'metadatum',
@ -115,7 +115,7 @@ class TAINACAN_REST_Queries extends TAINACAN_UnitApiTestCase {
'description' => 'Simple metadatum in collection A', 'description' => 'Simple metadatum in collection A',
'status' => 'publish', 'status' => 'publish',
'collection' => $collectionA, 'collection' => $collectionA,
'metadatum_type' => $metadatum_type 'metadata_type' => $metadata_type
], ],
true true
); );
@ -127,7 +127,7 @@ class TAINACAN_REST_Queries extends TAINACAN_UnitApiTestCase {
'description' => 'Simple metadatum in collection A', 'description' => 'Simple metadatum in collection A',
'status' => 'publish', 'status' => 'publish',
'collection' => $collectionA, 'collection' => $collectionA,
'metadatum_type' => $metadatum_type 'metadata_type' => $metadata_type
], ],
true true
); );
@ -139,7 +139,7 @@ class TAINACAN_REST_Queries extends TAINACAN_UnitApiTestCase {
'description' => 'Multiple metadatum in a collection A', 'description' => 'Multiple metadatum in a collection A',
'status' => 'publish', 'status' => 'publish',
'collection' => $collectionA, 'collection' => $collectionA,
'metadatum_type' => $metadatum_type, 'metadata_type' => $metadata_type,
'multiple' => 'yes' 'multiple' => 'yes'
], ],
true true

View File

@ -16,7 +16,7 @@ use Tainacan\Entities;
class CategoryMetadatumTypes extends TAINACAN_UnitTestCase { class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
function test_category_metadatum_types() { function test_category_metadata_types() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
@ -45,9 +45,9 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta', 'name' => 'meta',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Category', 'metadata_type' => 'Tainacan\Metadata_Types\Category',
'status' => 'publish', 'status' => 'publish',
'metadatum_type_options' => [ 'metadata_type_options' => [
'taxonomy_id' => $tax->get_id(), 'taxonomy_id' => $tax->get_id(),
'allow_new_terms' => false 'allow_new_terms' => false
] ]
@ -72,7 +72,7 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta2', 'name' => 'meta2',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Category', 'metadata_type' => 'Tainacan\Metadata_Types\Category',
'status' => 'draft', 'status' => 'draft',
), ),
true true
@ -104,9 +104,9 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
$this->assertFalse($item_metadata->validate(), 'item metadata should not validate because it does not allow new terms'); $this->assertFalse($item_metadata->validate(), 'item metadata should not validate because it does not allow new terms');
// Lets change it // Lets change it
$options = $metadatum->get_metadatum_type_options(); $options = $metadatum->get_metadata_type_options();
$options['allow_new_terms'] = true; $options['allow_new_terms'] = true;
$metadatum->set_metadatum_type_options($options); $metadatum->set_metadata_type_options($options);
$metadatum->validate(); $metadatum->validate();
$metadatum = $Tainacan_Metadata->insert($metadatum); $metadatum = $Tainacan_Metadata->insert($metadatum);
@ -123,7 +123,7 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
$this->assertEquals('Tainacan\Entities\Term', get_class($check_item_metadata->get_value())); $this->assertEquals('Tainacan\Entities\Term', get_class($check_item_metadata->get_value()));
// test 2 metadata with same category // test 2 metadata with same category
$metadatum2->set_metadatum_type_options([ $metadatum2->set_metadata_type_options([
'taxonomy_id' => $tax->get_id(), 'taxonomy_id' => $tax->get_id(),
]); ]);
$metadatum2->set_status('publish'); $metadatum2->set_status('publish');
@ -131,7 +131,7 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
$this->assertFalse($metadatum2->validate(), 'Category Metadatum should not validate when using a category in use by another metadatum in the same collection'); $this->assertFalse($metadatum2->validate(), 'Category Metadatum should not validate when using a category in use by another metadatum in the same collection');
$errors = $metadatum2->get_errors(); $errors = $metadatum2->get_errors();
$this->assertInternalType('array', $errors); $this->assertInternalType('array', $errors);
$this->assertArrayHasKey('taxonomy_id', $errors[0]['metadatum_type_options']); $this->assertArrayHasKey('taxonomy_id', $errors[0]['metadata_type_options']);
} }
function test_relate_taxonomy() { function test_relate_taxonomy() {
@ -168,9 +168,9 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta', 'name' => 'meta',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Category', 'metadata_type' => 'Tainacan\Metadata_Types\Category',
'status' => 'publish', 'status' => 'publish',
'metadatum_type_options' => [ 'metadata_type_options' => [
'taxonomy_id' => $tax->get_id(), 'taxonomy_id' => $tax->get_id(),
'allow_new_terms' => false 'allow_new_terms' => false
] ]
@ -181,7 +181,7 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
$checkTax = $Tainacan_Taxonomies->fetch($tax->get_id()); $checkTax = $Tainacan_Taxonomies->fetch($tax->get_id());
$this->assertContains($collection->get_id(), $checkTax->get_collections_ids(), 'Collection must be added to taxonomy when metadatum is created'); $this->assertContains($collection->get_id(), $checkTax->get_collections_ids(), 'Collection must be added to taxonomy when metadatum is created');
$metadatum->set_metadatum_type_options([ $metadatum->set_metadata_type_options([
'taxonomy_id' => $tax2->get_id(), 'taxonomy_id' => $tax2->get_id(),
'allow_new_terms' => false 'allow_new_terms' => false
]); ]);
@ -243,9 +243,9 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta', 'name' => 'meta',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Category', 'metadata_type' => 'Tainacan\Metadata_Types\Category',
'status' => 'publish', 'status' => 'publish',
'metadatum_type_options' => [ 'metadata_type_options' => [
'taxonomy_id' => $tax->get_id(), 'taxonomy_id' => $tax->get_id(),
'allow_new_terms' => true 'allow_new_terms' => true
] ]

View File

@ -16,7 +16,7 @@ use Tainacan\Entities;
class CompoundMetadatumTypes extends TAINACAN_UnitTestCase { class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
function test_compound_metadatum_types() { function test_compound_metadata_types() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
@ -36,7 +36,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta', 'name' => 'meta',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Compound', 'metadata_type' => 'Tainacan\Metadata_Types\Compound',
'status' => 'publish', 'status' => 'publish',
), ),
true true
@ -48,7 +48,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta2', 'name' => 'meta2',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish', 'status' => 'publish',
'parent' => $metadatum->get_id(), 'parent' => $metadatum->get_id(),
), ),
@ -61,7 +61,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta3', 'name' => 'meta3',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish', 'status' => 'publish',
'parent' => $metadatum->get_id(), 'parent' => $metadatum->get_id(),
), ),
@ -115,7 +115,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
} }
function test_multiple_compound_metadatum_types() { function test_multiple_compound_metadata_types() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
@ -135,7 +135,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta', 'name' => 'meta',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Compound', 'metadata_type' => 'Tainacan\Metadata_Types\Compound',
'status' => 'publish', 'status' => 'publish',
'multiple' => 'yes' 'multiple' => 'yes'
), ),
@ -148,7 +148,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta2', 'name' => 'meta2',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish', 'status' => 'publish',
'parent' => $metadatum->get_id(), 'parent' => $metadatum->get_id(),
), ),
@ -161,7 +161,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta3', 'name' => 'meta3',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish', 'status' => 'publish',
'parent' => $metadatum->get_id(), 'parent' => $metadatum->get_id(),
), ),
@ -266,7 +266,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta', 'name' => 'meta',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Compound', 'metadata_type' => 'Tainacan\Metadata_Types\Compound',
'status' => 'publish', 'status' => 'publish',
'multiple' => 'yes' 'multiple' => 'yes'
), ),
@ -275,12 +275,12 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
$newMetadatum = new \Tainacan\Entities\Metadatum(); $newMetadatum = new \Tainacan\Entities\Metadatum();
$newMetadatum->set_name('test_multiple'); $newMetadatum->set_name('test_multiple');
$newMetadatum->set_metadatum_type('Tainacan\Metadatum_Types\Category'); $newMetadatum->set_metadata_type('Tainacan\Metadata_Types\Category');
$newMetadatum->set_parent($metadatum->get_id()); $newMetadatum->set_parent($metadatum->get_id());
$this->assertFalse($newMetadatum->validate(), 'You cant add a category metadatum inside a multiple compound metadatum'); $this->assertFalse($newMetadatum->validate(), 'You cant add a category metadatum inside a multiple compound metadatum');
$newMetadatum->set_metadatum_type('Tainacan\Metadatum_Types\Text'); $newMetadatum->set_metadata_type('Tainacan\Metadata_Types\Text');
$this->assertTrue($newMetadatum->validate()); $this->assertTrue($newMetadatum->validate());
@ -304,7 +304,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta', 'name' => 'meta',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Compound', 'metadata_type' => 'Tainacan\Metadata_Types\Compound',
'status' => 'publish', 'status' => 'publish',
'multiple' => 'no' 'multiple' => 'no'
), ),
@ -313,7 +313,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
$newMetadatum = new \Tainacan\Entities\Metadatum(); $newMetadatum = new \Tainacan\Entities\Metadatum();
$newMetadatum->set_name('test_multiple'); $newMetadatum->set_name('test_multiple');
$newMetadatum->set_metadatum_type('Tainacan\Metadatum_Types\Category'); $newMetadatum->set_metadata_type('Tainacan\Metadata_Types\Category');
$newMetadatum->set_parent($metadatum->get_id()); $newMetadatum->set_parent($metadatum->get_id());
$this->assertTrue($newMetadatum->validate(), 'You can add a category metadatum inside a not multiple compound metadatum'); $this->assertTrue($newMetadatum->validate(), 'You can add a category metadatum inside a not multiple compound metadatum');
@ -344,7 +344,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'meta', 'name' => 'meta',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Compound', 'metadata_type' => 'Tainacan\Metadata_Types\Compound',
'status' => 'publish', 'status' => 'publish',
'multiple' => 'no' 'multiple' => 'no'
), ),
@ -354,7 +354,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
$newMetadatum = new \Tainacan\Entities\Metadatum(); $newMetadatum = new \Tainacan\Entities\Metadatum();
$newMetadatum->set_name('test_multiple'); $newMetadatum->set_name('test_multiple');
$newMetadatum->set_multiple('yes'); $newMetadatum->set_multiple('yes');
$newMetadatum->set_metadatum_type('Tainacan\Metadatum_Types\Text'); $newMetadatum->set_metadata_type('Tainacan\Metadata_Types\Text');
$newMetadatum->set_parent($metadatum->get_id()); $newMetadatum->set_parent($metadatum->get_id());
$this->assertFalse($newMetadatum->validate(), 'You cant add a multiple metadatum inside a compound metadatum'); $this->assertFalse($newMetadatum->validate(), 'You cant add a multiple metadatum inside a compound metadatum');

View File

@ -16,7 +16,7 @@ use Tainacan\Entities;
class CoreMetadatumTypes extends TAINACAN_UnitTestCase { class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
function test_core_metadatum_types() { function test_core_metadata_types() {
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance(); $Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
@ -35,7 +35,7 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'metadado', 'name' => 'metadado',
'description' => 'title', 'description' => 'title',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Core_Title' 'metadata_type' => 'Tainacan\Metadata_Types\Core_Title'
), ),
true true
); );
@ -46,7 +46,7 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'metadado_desc', 'name' => 'metadado_desc',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Core_Description' 'metadata_type' => 'Tainacan\Metadata_Types\Core_Description'
), ),
true true
); );
@ -120,7 +120,7 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
$metadata = $Tainacan_Metadata->fetch_by_collection( $collection, [], 'OBJECT' ) ; $metadata = $Tainacan_Metadata->fetch_by_collection( $collection, [], 'OBJECT' ) ;
foreach ( $metadata as $index => $metadatum ){ foreach ( $metadata as $index => $metadatum ){
if ( $metadatum->get_metadatum_type_object()->get_core() && $metadatum->get_metadatum_type_object()->get_related_mapped_prop() == 'title') { if ( $metadatum->get_metadata_type_object()->get_core() && $metadatum->get_metadata_type_object()->get_related_mapped_prop() == 'title') {
$core_title = $metadatum; $core_title = $metadatum;
} }
} }
@ -155,10 +155,10 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
$metadata = $Tainacan_Metadata->fetch_by_collection( $collection, [], 'OBJECT' ) ; $metadata = $Tainacan_Metadata->fetch_by_collection( $collection, [], 'OBJECT' ) ;
foreach ( $metadata as $index => $metadatum ){ foreach ( $metadata as $index => $metadatum ){
if ( $metadatum->get_metadatum_type_object()->get_core() && $metadatum->get_metadatum_type_object()->get_related_mapped_prop() == 'title') { if ( $metadatum->get_metadata_type_object()->get_core() && $metadatum->get_metadata_type_object()->get_related_mapped_prop() == 'title') {
$core_title = $metadatum; $core_title = $metadatum;
} }
if ( $metadatum->get_metadatum_type_object()->get_core() && $metadatum->get_metadatum_type_object()->get_related_mapped_prop() == 'description') { if ( $metadatum->get_metadata_type_object()->get_core() && $metadatum->get_metadata_type_object()->get_related_mapped_prop() == 'description') {
$core_description = $metadatum; $core_description = $metadatum;
} }
} }
@ -189,7 +189,7 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
'name' => 'just to confuse', 'name' => 'just to confuse',
'description' => 'description', 'description' => 'description',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text' 'metadata_type' => 'Tainacan\Metadata_Types\Text'
), ),
true true
); );
@ -198,16 +198,16 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
$this->assertEquals(2, sizeof($core_metadata)); $this->assertEquals(2, sizeof($core_metadata));
$this->assertNotEquals('Tainacan\Metadatum_Types\Text', $core_metadata[0]->get_metadatum_type()); $this->assertNotEquals('Tainacan\Metadata_Types\Text', $core_metadata[0]->get_metadata_type());
$this->assertNotEquals('Tainacan\Metadatum_Types\Text', $core_metadata[1]->get_metadatum_type()); $this->assertNotEquals('Tainacan\Metadata_Types\Text', $core_metadata[1]->get_metadata_type());
$title = $collection->get_core_title_metadatum(); $title = $collection->get_core_title_metadatum();
$this->assertEquals('Tainacan\Metadatum_Types\Core_Title', $title->get_metadatum_type()); $this->assertEquals('Tainacan\Metadata_Types\Core_Title', $title->get_metadata_type());
$description = $collection->get_core_description_metadatum(); $description = $collection->get_core_description_metadatum();
$this->assertEquals('Tainacan\Metadatum_Types\Core_Description', $description->get_metadatum_type()); $this->assertEquals('Tainacan\Metadata_Types\Core_Description', $description->get_metadata_type());
} }

View File

@ -59,7 +59,7 @@ class Filters extends TAINACAN_UnitTestCase {
array( array(
'name' => 'metadado', 'name' => 'metadado',
'collection_id' => $collection->get_id(), 'collection_id' => $collection->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'description' => 'descricao', 'description' => 'descricao',
), ),
true true
@ -125,7 +125,7 @@ class Filters extends TAINACAN_UnitTestCase {
array( array(
'name' => 'Other filtered', 'name' => 'Other filtered',
'description' => 'Is filtered', 'description' => 'Is filtered',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'collection_id' => $collection->get_id() 'collection_id' => $collection->get_id()
), ),
true true

View File

@ -36,7 +36,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
'name' => 'metadado', 'name' => 'metadado',
'description' => 'descricao', 'description' => 'descricao',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -90,7 +90,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
'description' => 'descricao', 'description' => 'descricao',
'collection' => $collection, 'collection' => $collection,
'required' => 'yes', 'required' => 'yes',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -144,7 +144,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
'description' => 'descricao', 'description' => 'descricao',
'collection' => $collection, 'collection' => $collection,
'collection_key' => 'yes', 'collection_key' => 'yes',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -212,7 +212,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
'description' => 'descricao', 'description' => 'descricao',
'collection' => $collection, 'collection' => $collection,
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );

View File

@ -98,7 +98,7 @@ class Items extends TAINACAN_UnitTestCase {
'name' => 'metadado', 'name' => 'metadado',
'status' => 'publish', 'status' => 'publish',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -109,7 +109,7 @@ class Items extends TAINACAN_UnitTestCase {
'name' => 'metadado2', 'name' => 'metadado2',
'status' => 'publish', 'status' => 'publish',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -120,7 +120,7 @@ class Items extends TAINACAN_UnitTestCase {
'name' => 'metadado3', 'name' => 'metadado3',
'status' => 'publish', 'status' => 'publish',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );

View File

@ -1,7 +1,7 @@
<?php <?php
namespace Tainacan\Tests; namespace Tainacan\Tests;
use Tainacan\Metadatum_Types; use Tainacan\Metadata_Types;
/** /**
* Class Metadatum * Class Metadatum
* *
@ -35,7 +35,7 @@ class Metadata extends TAINACAN_UnitTestCase {
'description' => 'descricao', 'description' => 'descricao',
'collection' => $collection, 'collection' => $collection,
'accept_suggestion' => true, 'accept_suggestion' => true,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -68,7 +68,7 @@ class Metadata extends TAINACAN_UnitTestCase {
'name' => 'metadado', 'name' => 'metadado',
'description' => 'descricao', 'description' => 'descricao',
'collection_id' => $collection->get_id(), 'collection_id' => $collection->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -77,8 +77,8 @@ class Metadata extends TAINACAN_UnitTestCase {
$this->assertEquals($test->get_name(), 'metadado'); $this->assertEquals($test->get_name(), 'metadado');
$this->assertEquals($test->get_collection_id(), $collection->get_id()); $this->assertEquals($test->get_collection_id(), $collection->get_id());
$this->assertEquals('Tainacan\Metadatum_Types\Text', $test->get_metadatum_type()); $this->assertEquals('Tainacan\Metadata_Types\Text', $test->get_metadata_type());
$this->assertEquals($test->get_metadatum_type(), 'Tainacan\Metadatum_Types\Text'); $this->assertEquals($test->get_metadata_type(), 'Tainacan\Metadata_Types\Text');
} }
/** /**
@ -92,7 +92,7 @@ class Metadata extends TAINACAN_UnitTestCase {
array( array(
'name' => 'metadatum default', 'name' => 'metadatum default',
'collection_id' => $Tainacan_Metadata->get_default_metadata_attribute(), 'collection_id' => $Tainacan_Metadata->get_default_metadata_attribute(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish' 'status' => 'publish'
), ),
true true
@ -111,7 +111,7 @@ class Metadata extends TAINACAN_UnitTestCase {
array( array(
'name' => 'metadatum grandfather', 'name' => 'metadatum grandfather',
'collection_id' => $collection_grandfather->get_id(), 'collection_id' => $collection_grandfather->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish' 'status' => 'publish'
), ),
true true
@ -131,7 +131,7 @@ class Metadata extends TAINACAN_UnitTestCase {
array( array(
'name' => 'metadatum father', 'name' => 'metadatum father',
'collection_id' => $collection_father->get_id(), 'collection_id' => $collection_father->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish' 'status' => 'publish'
), ),
true true
@ -154,7 +154,7 @@ class Metadata extends TAINACAN_UnitTestCase {
array( array(
'name' => 'metadatum son', 'name' => 'metadatum son',
'collection_id' => $collection_son->get_id(), 'collection_id' => $collection_son->get_id(),
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish' 'status' => 'publish'
), ),
true true
@ -192,9 +192,9 @@ class Metadata extends TAINACAN_UnitTestCase {
/** /**
* test if the defaults types are registered * test if the defaults types are registered
*/ */
function test_metadata_metadatum_type(){ function test_metadata_metadata_type(){
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$this->assertEquals( 8, sizeof( $Tainacan_Metadata->fetch_metadatum_types() ) ); $this->assertEquals( 8, sizeof( $Tainacan_Metadata->fetch_metadata_types() ) );
} }
@ -219,7 +219,7 @@ class Metadata extends TAINACAN_UnitTestCase {
'name' => 'metadatum1', 'name' => 'metadatum1',
'description' => 'descricao', 'description' => 'descricao',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish' 'status' => 'publish'
), ),
true true
@ -231,7 +231,7 @@ class Metadata extends TAINACAN_UnitTestCase {
'name' => 'metadatum2', 'name' => 'metadatum2',
'description' => 'metadatum2', 'description' => 'metadatum2',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish' 'status' => 'publish'
), ),
true true
@ -244,7 +244,7 @@ class Metadata extends TAINACAN_UnitTestCase {
'name' => 'metadatum3', 'name' => 'metadatum3',
'description' => 'metadatum3', 'description' => 'metadatum3',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
'status' => 'publish' 'status' => 'publish'
), ),
true true
@ -278,7 +278,7 @@ class Metadata extends TAINACAN_UnitTestCase {
'description' => 'adasdasdsa', 'description' => 'adasdasdsa',
'slug' => 'duplicated_slug', 'slug' => 'duplicated_slug',
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -290,7 +290,7 @@ class Metadata extends TAINACAN_UnitTestCase {
'description' => 'adasdasdsa', 'description' => 'adasdasdsa',
'slug' => 'duplicated_slug', 'slug' => 'duplicated_slug',
'status' => 'publish', 'status' => 'publish',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -304,7 +304,7 @@ class Metadata extends TAINACAN_UnitTestCase {
'name' => 'teste', 'name' => 'teste',
'description' => 'adasdasdsa', 'description' => 'adasdasdsa',
'slug' => 'duplicated_slug', 'slug' => 'duplicated_slug',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -315,7 +315,7 @@ class Metadata extends TAINACAN_UnitTestCase {
'name' => 'teste', 'name' => 'teste',
'description' => 'adasdasdsa', 'description' => 'adasdasdsa',
'slug' => 'duplicated_slug', 'slug' => 'duplicated_slug',
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -334,7 +334,7 @@ class Metadata extends TAINACAN_UnitTestCase {
} }
function test_validation_of_metadatum_types() { function test_validation_of_metadata_types() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
@ -350,8 +350,8 @@ class Metadata extends TAINACAN_UnitTestCase {
$validMetadatum->set_name('test'); $validMetadatum->set_name('test');
$validMetadatum->set_description('test'); $validMetadatum->set_description('test');
$validMetadatum->set_collection($collection); $validMetadatum->set_collection($collection);
$validMetadatum->set_metadatum_type('Tainacan\Metadatum_Types\Relationship'); $validMetadatum->set_metadata_type('Tainacan\Metadata_Types\Relationship');
$validMetadatum->set_metadatum_type_options(['collection_id' => 12]); $validMetadatum->set_metadata_type_options(['collection_id' => 12]);
$this->assertTrue($validMetadatum->validate()); $this->assertTrue($validMetadatum->validate());
@ -360,8 +360,8 @@ class Metadata extends TAINACAN_UnitTestCase {
$invalidMetadatum->set_description('test'); $invalidMetadatum->set_description('test');
$invalidMetadatum->set_collection($collection); $invalidMetadatum->set_collection($collection);
$invalidMetadatum->set_status('publish'); $invalidMetadatum->set_status('publish');
$invalidMetadatum->set_metadatum_type('Tainacan\Metadatum_Types\Relationship'); $invalidMetadatum->set_metadata_type('Tainacan\Metadata_Types\Relationship');
$invalidMetadatum->set_metadatum_type_options(['collection_id' => 'string']); $invalidMetadatum->set_metadata_type_options(['collection_id' => 'string']);
$this->assertFalse($invalidMetadatum->validate()); $this->assertFalse($invalidMetadatum->validate());
@ -371,7 +371,7 @@ class Metadata extends TAINACAN_UnitTestCase {
/** /**
* Class TainacanMetadatumType * Class TainacanMetadatumType
*/ */
class RandomType extends Metadatum_Types\Metadatum_Type { class RandomType extends Metadata_Types\Metadata_Type {
function __construct(){ function __construct(){
parent::__construct(); parent::__construct();

View File

@ -51,7 +51,7 @@ class Objects extends TAINACAN_UnitTestCase {
'name' => 'metadado', 'name' => 'metadado',
'status' => 'publish', 'status' => 'publish',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -62,7 +62,7 @@ class Objects extends TAINACAN_UnitTestCase {
'name' => 'metadado2', 'name' => 'metadado2',
'status' => 'publish', 'status' => 'publish',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );
@ -73,7 +73,7 @@ class Objects extends TAINACAN_UnitTestCase {
'name' => 'metadado3', 'name' => 'metadado3',
'status' => 'publish', 'status' => 'publish',
'collection' => $collection, 'collection' => $collection,
'metadatum_type' => 'Tainacan\Metadatum_Types\Text', 'metadata_type' => 'Tainacan\Metadata_Types\Text',
), ),
true true
); );