Merges with develop and solves conflicts.

This commit is contained in:
Mateus Machado Luna 2019-04-02 15:19:00 -03:00
commit 1f19f90b4c
69 changed files with 10741 additions and 352 deletions

View File

@ -10,6 +10,9 @@ Assuming:
* $BUILD_PATH is where the plugin is condigured to buid
* $SVN_PATH is where the WordPress.org SVN repo is
## Pre-release
Before we publish a new version, we always release one or more Release Candidates so the community have time to test and make sure the new version of Tainacan is clean and ready to reach the world.
### Start in the git repository
@ -19,10 +22,22 @@ git checkout develop
git pull
```
### Create a new Release branch
Create a new `release/$NEW_VERSION` branch. If using git flow:
```
git flow release start $NEW_VERSION
```
### Edit version numbers
Edit `src/readme.txt` and `src/tainacan.php` and change the version numbers to `$NEW_VERSION`.
When releasing a RC version, append RC (number) to the version.
Also increase the `Tested Up` version, if applicable.
### Set build to production mode
Edit `webpack.config.js` to set production mode.
@ -34,6 +49,62 @@ Edit `webpack.config.js` to set production mode.
cd $BUILD_PATH
rm -r admin/scss/.sass-cache
```
### Set build to development mode
```
cd $GIT_PATH
git checkout webpack.config.js
```
### Publish the RC
Create a ZIP package with the built plugin and publish a blog post calling for tests.
Commit and push to Git!
### Test
Using the Test guide as a resource, test every feature of the plugin, including importers and exporters. With time, we can build more detailed test scripts and distribute tests among people in the community.
### Fix and publish new RC, or finish
If bugs are found, fix them and commit to the release branch. Publish a new RC, following the steps above, until we have a stable version we feel confident to release.
## Release
The plugin is ready to go. We have published one or more RCs and the community have tested it. Lets get it live to the world!
### Finish version number
Back to the git repository, make sure everything is up to date:
```
cd $GIT_PATH
git checkout release/$NEW_VERSION
git pull
```
Edit `src/readme.txt` and `src/tainacan.php` and change the version numbers to `$NEW_VERSION`.
Commit and push.
### Set build to production mode
Edit `webpack.config.js` to set production mode.
### Build and cleanup
```
./build.sh
cd $BUILD_PATH
rm -r admin/scss/.sass-cache
```
### Set build to development mode
```
cd $GIT_PATH
git checkout webpack.config.js
```
### Prepare SVN repo
@ -98,17 +169,14 @@ Check if everything is ok.
Once the release is tested and confirmed, commit and create the tag on git.
Don't forget to undo the changes to `webpack.config.js`, setting production mode to false again.
Merge the release branch into master and develop branches and create a tag.
Using git flow:
```
cd $GIT_PATH
git checkout webpack.config.js
git commit -am "Releasing verion $NEW_VERSION"
git tag $NEW_VERSION
git checkout master
git merge develop
git flow release finish $NEW_VERSION
git push --all
git push --tags
```

View File

@ -35,8 +35,7 @@
"babel-loader": "^8.0.4",
"cross-env": "^5.2.0",
"css-loader": "^1.0.0",
"element-theme-chalk": "^2.4.8",
"eslint": "^5.14.1",
"eslint": "^4.0.0",
"eslint-loader": "^2.1.1",
"eslint-plugin-vue": "^4.7.1",
"file-loader": "^2.0.0",

View File

@ -10,7 +10,7 @@
label-width="120px">
<div class="columns">
<div class="column is-4">
<div class="column is-5">
<!-- Name -------------------------------- -->
<b-field
@ -253,7 +253,6 @@
</template>
</div>
<div class="column is-1" />
<div class="column">
<!-- Status -------------------------------- -->
@ -939,9 +938,10 @@ export default {
@import "../../scss/_variables.scss";
.column {
padding-left: 0;
padding-right: 0;
@media screen and (max-width: 1024px) {
.column:last-of-type {
padding-left: $page-side-padding !important;
}
}
.field {

View File

@ -296,7 +296,18 @@ export default {
this.$router.go(-2);
},
checkIfMetadatumIsAvailable(metadatumId) {
return this.mappedCollection['mapping'][metadatumId] != undefined;
if ( this.mappedCollection['mapping'][metadatumId] != undefined &&
this.importerSourceInfo != undefined &&
this.importerSourceInfo != null){
let val = this.mappedCollection['mapping'][metadatumId];
const { source_metadata } = this.importerSourceInfo;
if(source_metadata && source_metadata.indexOf(val) >= 0) {
return true;
}
}
return false;
},
checkCurrentSelectedCollectionMetadatum(sourceMetadatum) {
for (let key in this.mappedCollection['mapping']) {

View File

@ -198,6 +198,7 @@
<div class="control">
<button
id="button-submit-text-content-writing"
type="submit"
@click.prevent="confirmTextWriting()"
class="button is-success">
{{ $i18n.get('save') }}</button>
@ -1067,9 +1068,13 @@ export default {
// Initializes Media Frames now that itemId exists
this.initializeMediaFrames();
this.fetchItem(this.itemId).then(res => {
this.fetchItem({ itemId: this.itemId, contextEdit: true }).then(res => {
this.item = res;
// Checks if user has permission to edit
if (!this.item.current_user_can_edit)
this.$router.push(this.$routerHelper.getCollectionPath(this.collectionId));
// Updates Collection BreadCrumb
if (this.isOnSequenceEdit) {
this.$root.$emit('onCollectionBreadCrumbUpdate', [

View File

@ -135,7 +135,7 @@
<!-- <span class="menu-text">{{ $i18n.get('items') }}</span> -->
</router-link>
</li>
<li>
<li v-if="collection.current_user_can_edit">
<router-link
tag="a"
:to="{ path: $routerHelper.getCollectionEditPath(collection.id) }"

View File

@ -40,6 +40,49 @@
</div>
</div>
<div class="table-wrapper">
<!-- Context menu for right click selection -->
<div
v-if="cursorPosY > 0 && cursorPosX > 0"
class="context-menu">
<!-- Backdrop for escaping context menu -->
<div
@click.left="clearContextMenu()"
@click.right="clearContextMenu()"
class="context-menu-backdrop" />
<b-dropdown
inline
:style="{ top: cursorPosY + 'px', left: cursorPosX + 'px' }">
<b-dropdown-item
@click="openCollection()"
v-if="!isOnTrash">
{{ $i18n.getFrom('collections', 'view_item') }}
</b-dropdown-item>
<b-dropdown-item
@click="openCollectionOnNewTab()"
v-if="!isOnTrash">
{{ $i18n.get('label_open_collection_new_tab') }}
</b-dropdown-item>
<b-dropdown-item
@click="selectCollection()"
v-if="contextMenuIndex != null">
{{ !selectedCollections[contextMenuIndex] ? $i18n.get('label_select_collection') : $i18n.get('label_unselect_collection') }}
</b-dropdown-item>
<b-dropdown-item
@click="goToCollectionEditPage(contextMenuCollection)"
v-if="contextMenuCollection != null">
{{ $i18n.getFrom('collections', 'edit_item') }}
</b-dropdown-item>
<b-dropdown-item
@click="deleteOneCollection(contextMenuCollection)"
v-if="contextMenuCollection != null">
{{ $i18n.get('label_delete_collection') }}
</b-dropdown-item>
</b-dropdown>
</div>
<table class="tainacan-table">
<thead>
<tr>
@ -94,7 +137,8 @@
<!-- Thumbnail -->
<td
class="thumbnail-cell column-default-width"
@click="onClickCollection($event, collection.id, index)"
@click.left="onClickCollection($event, collection.id, index)"
@click.right="onRightClickCollection($event, collection.id, index)"
:label="$i18n.get('label_thumbnail')"
:aria-label="$i18n.get('label_thumbnail')">
<span>
@ -107,7 +151,8 @@
<!-- Name -->
<td
class="column-default-width column-main-content"
@click="onClickCollection($event, collection.id, index)"
@click.left="onClickCollection($event, collection.id, index)"
@click.right="onRightClickCollection($event, collection.id, index)"
:label="$i18n.get('label_name')"
:aria-label="$i18n.get('label_name') + ': ' + collection.name">
<p
@ -125,7 +170,8 @@
<!-- Description -->
<td
class="column-large-width"
@click="onClickCollection($event, collection.id, index)"
@click.left="onClickCollection($event, collection.id, index)"
@click.right="onRightClickCollection($event, collection.id, index)"
:label="$i18n.get('label_description')"
:aria-label="$i18n.get('label_description') + ': ' + (collection.description != undefined && collection.description != '') ? collection.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_informed') + `</span>`">
<p
@ -142,7 +188,8 @@
</td>
<!-- Creation Date -->
<td
@click="onClickCollection($event, collection.id, index)"
@click.left="onClickCollection($event, collection.id, index)"
@click.right="onRightClickCollection($event, collection.id, index)"
class="table-creation column-default-width"
:label="$i18n.get('label_creation_date')"
:aria-label="$i18n.get('label_creation_date') + ': ' + collection.creation_date">
@ -160,7 +207,8 @@
</td>
<!-- Created by -->
<td
@click="onClickCollection($event, collection.id, index)"
@click.left="onClickCollection($event, collection.id, index)"
@click.right="onRightClickCollection($event, collection.id, index)"
class="table-creation column-default-width"
:label="$i18n.get('label_created_by')"
:aria-label="$i18n.get('label_created_by') + ': ' + collection.author_name">
@ -178,7 +226,8 @@
</td>
<!-- Total items -->
<td
@click="onClickCollection($event, collection.id, index)"
@click.left="onClickCollection($event, collection.id, index)"
@click.right="onRightClickCollection($event, collection.id, index)"
class="column-small-width column-align-right"
:label="$i18n.get('label_total_items')"
v-if="collection.total_items != undefined"
@ -196,13 +245,14 @@
v-html="getTotalItems(collection.total_items)" />
</td>
<!-- Actions -->
<td
<td
@click="onClickCollection($event, collection.id, index)"
class="actions-cell column-default-width"
:label="$i18n.get('label_actions')">
<div class="actions-container">
<a
id="button-edit"
v-if="collection.current_user_can_edit"
:aria-label="$i18n.getFrom('collections','edit_item')"
@click.prevent.stop="goToCollectionEditPage(collection.id)">
<span class="icon">
@ -210,7 +260,8 @@
</span>
</a>
<a
id="button-delete"
id="button-delete"
v-if="collection.current_user_can_delete"
:aria-label="$i18n.get('label_button_delete')"
@click.prevent.stop="deleteOneCollection(collection.id)">
<span class="icon">
@ -239,7 +290,11 @@ export default {
selectedCollections: [],
allCollectionsOnPageSelected: false,
isSelectingCollections: false,
thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png'
thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png',
cursorPosX: -1,
cursorPosY: -1,
contextMenuIndex: null,
contextMenuCollection: null
}
},
props: {
@ -316,6 +371,7 @@ export default {
}
});
this.clearContextMenu();
},
deleteSelectedCollections() {
this.$modal.open({
@ -355,6 +411,25 @@ export default {
}
});
},
openCollection() {
if (this.contextMenuCollection != null) {
this.$router.push(this.$routerHelper.getCollectionPath(this.contextMenuCollection));
}
this.clearContextMenu();
},
openCollectionOnNewTab() {
if (this.contextMenuCollection != null) {
let routeData = this.$router.resolve(this.$routerHelper.getCollectionPath(this.contextMenuCollection));
window.open(routeData.href, '_blank');
}
this.clearContextMenu();
},
selectCollection() {
if (this.contextMenuIndex != null) {
this.$set(this.selectedCollections, this.contextMenuIndex, !this.selectedCollections[this.contextMenuIndex]);
}
this.clearContextMenu();
},
onClickCollection($event, collectionId, index) {
if ($event.ctrlKey) {
this.$set(this.selectedCollections, index, !this.selectedCollections[index]);
@ -364,6 +439,20 @@ export default {
},
goToCollectionEditPage(collectionId) {
this.$router.push(this.$routerHelper.getCollectionEditPath(collectionId));
},
onRightClickCollection($event, collectionId, index) {
$event.preventDefault();
this.cursorPosX = $event.clientX;
this.cursorPosY = $event.clientY;
this.contextMenuCollection = collectionId;
this.contextMenuIndex = index;
},
clearContextMenu() {
this.cursorPosX = -1;
this.cursorPosY = -1;
this.contextMenuCollection = null;
this.contextMenuIndex = null;
}
},
mounted() {
@ -433,6 +522,23 @@ export default {
.total-items-header {
text-align: right;
}
.context-menu {
.dropdown {
position: fixed;
z-index: 99999999999;
}
.context-menu-backdrop {
position: fixed;
top: 0;
right: 0;
left: 0;
border: 0;
width: 100%;
height: 100vh;
z-index: 9999999;
}
}
</style>

View File

@ -90,7 +90,7 @@
<b-dropdown-item
@click="openItem()"
v-if="!isOnTrash">
{{ $i18n.get('label_open_item') }}
{{ $i18n.getFrom('items','view_item') }}
</b-dropdown-item>
<b-dropdown-item
@click="openItemOnNewTab()"
@ -105,7 +105,7 @@
<b-dropdown-item
@click="goToItemEditPage(contextMenuItem)"
v-if="contextMenuItem != null && contextMenuItem.current_user_can_edit">
{{ $i18n.get('title_edit_item') }}
{{ $i18n.getFrom('items','edit_item') }}
</b-dropdown-item>
<b-dropdown-item
@click="deleteOneItem(contextMenuItem.id)"
@ -913,6 +913,7 @@ export default {
message: this.$i18n.get('info_warning_remove_item_from_trash'),
onConfirm: () => {
this.isLoading = true;
this.$emit('updateIsLoading', this.isLoading);
this.createEditGroup({
collectionID: this.collectionId,
@ -941,6 +942,7 @@ export default {
message: this.isOnTrash ? this.$i18n.get('info_warning_item_delete') : this.$i18n.get('info_warning_item_trash'),
onConfirm: () => {
this.isLoading = true;
this.$emit('updateIsLoading', this.isLoading);
this.deleteItem({
itemId: itemId,
@ -951,6 +953,7 @@ export default {
}
}
});
this.clearContextMenu();
},
untrashSelectedItems(){
this.$modal.open({
@ -962,6 +965,7 @@ export default {
message: this.$i18n.get('info_warning_selected_items_remove_from_trash'),
onConfirm: () => {
this.isLoading = true;
this.$emit('updateIsLoading', this.isLoading);
this.createEditGroup({
collectionID: this.collectionId,
@ -990,6 +994,7 @@ export default {
message: this.isOnTrash ? this.$i18n.get('info_warning_selected_items_delete') : this.$i18n.get('info_warning_selected_items_trash'),
onConfirm: () => {
this.isLoading = true;
this.$emit('updateIsLoading', this.isLoading);
this.createEditGroup({
collectionID: this.collectionId,

View File

@ -180,7 +180,8 @@
return {
selected: [],
allOnPageSelected: false,
isSelecting: false
isSelecting: false,
adminUrl: tainacan_plugin.admin_url
}
},
props: {
@ -304,7 +305,7 @@
let htmlList = '';
for (let i = 0; i < collections.length; i++) {
htmlList += `<a target="_blank" href=${collections[i].url}>${collections[i].name}</a>`;
htmlList += `<a target="_blank" href=${ this.adminUrl + 'admin.php?page=tainacan_admin#' + this.$routerHelper.getCollectionPath(collections[i].id)}>${collections[i].name}</a>`;
if (collections.length > 2 && i > 0 && i < collections.length - 1) {
if (i < collections.length - 2)
htmlList += ', '

View File

@ -70,6 +70,7 @@
</b-tooltip>
</li>
<li
v-if="currentUserCanEdit"
:class="activeRoute == 'CollectionEditionForm' ? 'is-active':''"
class="level-item">
<b-tooltip
@ -88,6 +89,7 @@
</b-tooltip>
</li>
<li
v-if="currentUserCanEdit"
:class="activeRoute == 'MetadataList' ? 'is-active':''"
class="level-item">
<b-tooltip
@ -105,6 +107,7 @@
</b-tooltip>
</li>
<li
v-if="currentUserCanEdit"
:class="activeRoute == 'FiltersList' ? 'is-active':''"
class="level-item">
<b-tooltip
@ -163,6 +166,7 @@ export default {
},
props: {
id: Number,
currentUserCanEdit: Boolean
},
watch: {
'$route' (to, from) {

View File

@ -7,6 +7,7 @@
<h2>{{ this.$i18n.get('exporters') }}</h2>
<hr>
</header>
<section class="tainacan-form">
<p>{{ $i18n.get('instruction_select_an_exporter_type') }}</p>
<div

View File

@ -299,14 +299,17 @@ export default {
availableExposers() {
let exposers = this.getAvailableExposers();
exposers.unshift({
accept_no_mapper: true,
class_name: 'API',
mappers: [],
name: this.$i18n.get('label_tainacan_api'),
description: this.$i18n.get('info_tainacan_api'),
slug: 'tainacan-api'
});
let tainacanApiExposerIndex = exposers.findIndex((aExposer) => aExposer.slug == 'tainacan-api');
if (tainacanApiExposerIndex < 0) {
exposers.unshift({
accept_no_mapper: true,
class_name: 'API',
mappers: [],
name: this.$i18n.get('label_tainacan_api'),
description: this.$i18n.get('info_tainacan_api'),
slug: 'tainacan-api'
});
}
return exposers;
}
},
@ -416,7 +419,7 @@ export default {
this.isLoading = false;
});
if (!this.collectionId != undefined) {
if (this.collectionId != undefined) {
this.fetchCollectionNameAndURL(this.collectionId);
}
}

View File

@ -75,6 +75,10 @@
font-size: 0.75rem;
margin-bottom: -0.375rem;
@media only screen and (max-width: 768px) {
padding-top: 1rem;
}
&.is-inline-flex {
flex-wrap: wrap;
justify-content: flex-start;

View File

@ -6,7 +6,6 @@
import Vue from 'vue';
import Buefy from 'buefy';
import VTooltip from 'v-tooltip';
// import { VueHammer } from 'vue2-hammer';
import VueMasonry from 'vue-masonry-css';
import draggable from 'vuedraggable';
import VueTheMask from 'vue-the-mask';
@ -49,7 +48,6 @@ import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin, UserCap
// Configure and Register Plugins
Vue.use(Buefy);
Vue.use(VTooltip);
// Vue.use(VueHammer);
Vue.use(VueMasonry);
Vue.use(I18NPlugin);
Vue.use(UserPrefsPlugin);

View File

@ -2,7 +2,6 @@
import Vue from 'vue';
import Buefy from 'buefy';
import VTooltip from 'v-tooltip';
// import { VueHammer } from 'vue2-hammer';
import VueMasonry from 'vue-masonry-css';
// Custom elements
@ -48,7 +47,6 @@ import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin } from '
// Configure and Register Plugins
Vue.use(Buefy);
Vue.use(VTooltip);
// Vue.use(VueHammer);
Vue.use(VueMasonry);
Vue.use(I18NPlugin);
Vue.use(UserPrefsPlugin);

View File

@ -168,7 +168,7 @@ export default {
loadCollections() {
this.cleanCollections();
this.isLoadingCollections = true;
this.fetchCollections({ 'page': 1, 'collectionsPerPage': 5 })
this.fetchCollections({ page: 1, collectionsPerPage: 5, status: undefined, contextEdit: true })
.then(() => {
this.isLoadingCollections = false;
})

View File

@ -1,10 +1,4 @@
<template>
<!-- <div <IF WE USE HAMMERJS>
v-hammer:swipe="onSwipeFiltersMenu"
:class="{
'repository-level-page': isRepositoryLevel,
'is-fullscreen': registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen
}"> -->
<div
:class="{
'repository-level-page': isRepositoryLevel,
@ -512,7 +506,7 @@
<button
class="button is-white"
:aria-label="$i18n.get('label_urls')"
:disabled="this.totalItems == undefined || this.totalItems <= 0"
:disabled="totalItems == undefined || totalItems <= 0"
@click="openExposersModal()">
<span class="gray-icon">
<i class="tainacan-icon tainacan-icon-20px tainacan-icon-url"/>
@ -679,7 +673,8 @@
:total-items="totalItems"
:is-loading="isLoadingItems"
:is-on-trash="status == 'trash'"
:view-mode="adminViewMode"/>
:view-mode="adminViewMode"
@updateIsLoading="newIsLoading => isLoadingItems = newIsLoading"/>
<!-- Theme View Modes -->
<div
@ -705,7 +700,7 @@
<!-- Empty Placeholder (only used in Admin) -->
<section
v-if="!isOnTheme && !isLoadingItems && totalItems <= 0"
v-if="!isOnTheme && !isLoadingItems && totalItems == 0"
class="section">
<div class="content has-text-grey has-text-centered">
<p>
@ -1227,7 +1222,6 @@
}
}
}
let creationDateMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[1] != null) : true;
@ -1292,20 +1286,32 @@
display: authorNameMetadatumDisplay
});
}
// Loads only basic attributes necessary to view modes that do not allow custom meta
} else {
this.$eventBusSearch.addFetchOnly('thumbnail,creation_date,author_name,title,description', true, '');
this.sortingMetadata.push({
name: this.$i18n.get('label_title'),
metadatum: 'row_title',
metadata_type_object: {core: true, related_mapped_prop: 'title'},
metadata_type: undefined,
slug: 'title',
id: undefined,
display: true
});
if (this.isRepositoryLevel) {
this.sortingMetadata.push({
name: this.$i18n.get('label_title'),
metadatum: 'row_title',
metadata_type_object: {core: true, related_mapped_prop: 'title'},
metadata_type: undefined,
slug: 'title',
id: undefined,
display: true
});
}
for (let metadatum of this.metadata) {
if (metadatum.display !== 'never' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship') {
this.sortingMetadata.push(metadatum);
}
}
this.sortingMetadata.push({
name: this.$i18n.get('label_creation_date'),
@ -1351,7 +1357,7 @@
this.hasAnOpenModal = false;
},
hideCancel: true,
showNeverShowAgainOption: true,
showNeverShowAgainOption: tainacan_plugin.user_caps != undefined && tainacan_plugin.user_caps.length != undefined && tainacan_plugin.user_caps.length > 0,
messageKeyForUserPrefs: 'ItemsHiddenDueSorting'
}
});
@ -1401,7 +1407,7 @@
});
this.$eventBusSearch.$on('hasToPrepareMetadataAndFilters', (to) => {
/* This condition is to prevent a incorrect fetch by filter or metadata when we coming from items
/* This condition is to prevent an incorrect fetch by filter or metadata when we coming from items
* at collection level to items page at repository level
*/
@ -1421,7 +1427,6 @@
},
mounted() {
this.prepareFilters();
this.prepareMetadata();
this.localDisplayedMetadata = JSON.parse(JSON.stringify(this.displayedMetadata));

View File

@ -1,10 +1,5 @@
<template>
<!-- <div <IF WE USE HAMMER JS>
v-hammer:swipe="onSwipeFiltersMenu"
:class="{
'repository-level-page': isRepositoryLevel,
'is-fullscreen': registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen
}"> -->
<div
:class="{
'repository-level-page': isRepositoryLevel,
@ -497,7 +492,7 @@
<button
class="button is-white"
:aria-label="$i18n.get('label_urls')"
:disabled="this.totalItems == undefined || this.totalItems <= 0"
:disabled="totalItems == undefined || totalItems <= 0"
@click="openExposersModal()">
<span class="gray-icon">
<i class="tainacan-icon tainacan-icon-20px tainacan-icon-url"/>
@ -657,7 +652,8 @@
:total-items="totalItems"
:is-loading="isLoadingItems"
:is-on-trash="status == 'trash'"
:view-mode="adminViewMode"/>
:view-mode="adminViewMode"
@updateIsLoading="newIsLoading => isLoadingItems = newIsLoading"/>
<!-- Theme View Modes -->
<div
@ -683,7 +679,7 @@
<!-- Empty Placeholder (only used in Admin) -->
<section
v-if="!isOnTheme && !isLoadingItems && totalItems <= 0"
v-if="!isOnTheme && !isLoadingItems && totalItems == 0"
class="section">
<div class="content has-text-grey has-text-centered">
<p>
@ -1257,16 +1253,27 @@
} else {
this.$eventBusSearch.addFetchOnly('thumbnail,creation_date,author_name,title,description', true, '');
this.sortingMetadata.push({
name: this.$i18n.get('label_title'),
metadatum: 'row_title',
metadata_type_object: {core: true, related_mapped_prop: 'title'},
metadata_type: undefined,
slug: 'title',
id: undefined,
display: true
});
if (this.isRepositoryLevel) {
this.sortingMetadata.push({
name: this.$i18n.get('label_title'),
metadatum: 'row_title',
metadata_type_object: {core: true, related_mapped_prop: 'title'},
metadata_type: undefined,
slug: 'title',
id: undefined,
display: true
});
}
for (let metadatum of this.metadata) {
if (metadatum.display !== 'never' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship') {
this.sortingMetadata.push(metadatum);
}
}
this.sortingMetadata.push({
name: this.$i18n.get('label_creation_date'),
@ -1304,7 +1311,7 @@
this.hasAnOpenModal = false;
},
hideCancel: true,
showNeverShowAgainOption: true,
showNeverShowAgainOption: tainacan_plugin.user_caps != undefined && tainacan_plugin.user_caps.length != undefined && tainacan_plugin.user_caps.length > 0,
messageKeyForUserPrefs: 'ItemsHiddenDueSorting'
}
});
@ -1360,7 +1367,7 @@
});
this.$eventBusSearch.$on('hasToPrepareMetadataAndFilters', (to) => {
/* This condition is to prevent a incorrect fetch by filter or metadata when we come from items
/* This condition is to prevent an incorrect fetch by filter or metadata when we come from items
* at collection level to items page at repository level
*/

View File

@ -1,7 +1,9 @@
<template>
<div class="columns is-fullheight">
<section class="column is-secondary-content">
<tainacan-collection-subheader :id="collectionId"/>
<tainacan-collection-subheader
:current-user-can-edit="currentUserCanEdit"
:id="collectionId"/>
<router-view
id="collection-page-container"
@ -13,20 +15,32 @@
<script>
import TainacanCollectionSubheader from '../../components/navigation/tainacan-collection-subheader.vue';
import { mapActions } from 'vuex';
export default {
name: 'CollectionPage',
data(){
return {
collectionId: Number
collectionId: Number,
currentUserCanEdit: Boolean
}
},
components: {
TainacanCollectionSubheader
},
methods: {
...mapActions('collection', [
'fetchCollectionUserCanEdit'
])
},
created(){
this.collectionId = parseInt(this.$route.params.collectionId);
this.$eventBusSearch.setCollectionId(this.collectionId);
},
mounted() {
this.fetchCollectionUserCanEdit(this.collectionId).then((caps) => {
this.currentUserCanEdit = caps;
}).catch((error) => this.$console.error(error));
}
}
</script>

View File

@ -336,6 +336,7 @@
<div class="footer">
<div class="form-submission-footer">
<router-link
v-if="item.current_user_can_edit"
class="button is-secondary"
:to="{ path: $routerHelper.getItemEditPath(collectionId, itemId)}">
{{ $i18n.getFrom('items','edit_item') }}
@ -464,7 +465,7 @@
});
// Obtains Item
this.fetchItem(this.itemId).then((item) => {
this.fetchItem({ itemId: this.itemId, contextEdit: true }).then((item) => {
this.$root.$emit('onCollectionBreadCrumbUpdate', [
{path: this.$routerHelper.getCollectionPath(this.collectionId), label: this.$i18n.get('items')},
{path: '', label: item.title}

View File

@ -78,4 +78,5 @@ button.link-style:active {
.button:not(.is-small):not(.is-medium):not(.is-large) {
height: 1.875rem !important;
font-size: 0.875rem !important;
line-height: 1.5rem;
}

View File

@ -2,6 +2,12 @@
.modal .animation-content {
width: 100%;
}
.modal .modal-close {
z-index: 99999;
@media only screen and (max-width: 768px) {
&:before, &:after { background-color: #298596; }
}
}
.tainacan-modal-title {
display: flex;
@ -37,7 +43,8 @@
background-color: white;
padding: 40px 50px;
position: relative;
max-height: 100vh;
max-height: 86%;
max-height: 86vh;
overflow-y: auto;
overflow-x: hidden;
@ -52,6 +59,11 @@
.form-submit {
padding: 40px 0em 0.4em 0em !important;
}
@media only screen and (max-width: 768px) {
max-height: 100%;
max-height: 100vh;
}
}
// Bulma modals customized for Tainacan (custom-dialog.vue)
.dialog {

View File

@ -18,22 +18,29 @@
background-color: $blue5 !important;
color: white !important;
}
.has-text-primary, .has-text-primary:hover, .is-has-text-primary:focus {
color: $blue4 !important;
.dropdown .dropdown-menu .dropdown-content a.dropdown-item:hover {
color: black !important;
}
.has-text-primary,
.has-text-primary:hover,
.is-has-text-primary:focus,
a:not(.has-text-danger):not(.disabled),
a:hover:not(.has-text-danger):not(.disabled),
.has-text-secondary,
.has-text-secondary:hover,
.is-has-text-secondary:focus {
color: $blue3 !important;
color: $blue4 !important;
}
a.button.is-secondary {
a.button.is-secondary,
a.button.is-secondary:hover {
color: white !important;
}
.tainacan-page-title hr{
background-color: $blue3 !important;
}
button.link-style, button.link-style:focus button.link-style:active {
color: $blue4;
}
.button[disabled]:not(.is-white), .button:hover[disabled]:not(.is-white) {
border: none !important;
cursor: not-allowed !important;

View File

@ -83,6 +83,7 @@
// background-blend-mode
.skeleton {
background: #fff;
color: transparent !important;
}
}

View File

@ -19,7 +19,7 @@
<div class="wrap">
<h1><?php _e('Tainacan System Check', 'tainacan'); ?></h1>
<p><?php _e('This page checks your system against the Tainacan requirements. It helps you to find out wether your server is properly configured.', 'tainacan'); ?></p>
<p><?php _e('This page checks your system against the Tainacan requirements. It helps you to find out whether your server is properly configured.', 'tainacan'); ?></p>
<p><?php printf( __('If you want to have a more complete diagnosis of your current WordPress instance, we recommend you to install the %1$sHealth Check & Troubleshooting%2$s plugin.', 'tainacan'), '<a href="https://wordpress.org/plugins/health-check/" target="_blank">', '</a>' ); ?></p>

View File

@ -101,7 +101,7 @@ class System_Check {
if ( $time < $min ) {
$class = 'error';
$text = sprintf(
__('Your current configuratino is %ds. This is too little. Please increase it to at least 30s', 'tainacan'),
__('Your current configuration is %ds. This is too little. Please increase it to at least 30s', 'tainacan'),
$time
);
} elseif ( $time < $rec ) {
@ -113,7 +113,7 @@ class System_Check {
} else {
$class = 'good';
$text = sprintf(
__('Your current configuratino is %ds. This is excellent.', 'tainacan'),
__('Your current configuration is %ds. This is excellent.', 'tainacan'),
$time
);
}

View File

@ -6,7 +6,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'is_equal_to' => __( 'Equal', 'tainacan' ),
'is_not_equal_to' => __( 'Not equal', 'tainacan' ),
'contains' => __( 'Contains', 'tainacan' ),
'not_contains' => __( 'Not contains', 'tainacan' ),
'not_contains' => __( 'Do not contain', 'tainacan' ),
'greater_than' => __( 'Greater than', 'tainacan' ),
'less_than' => __( 'Less than', 'tainacan' ),
'greater_than_or_equal_to' => __( 'Greater than or equal to', 'tainacan' ),
@ -323,7 +323,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_show_filters' => __( 'Show filters menu', 'tainacan' ),
'label_select_all_items' => __( 'Select all items', 'tainacan' ),
'label_select_all' => __( 'Select all', 'tainacan' ),
'label_untrash_selected_items' => __( 'Recover from trash', 'tainacan' ),
'label_untrash_selected_items' => __( 'Restore from trash', 'tainacan' ),
'label_value_not_informed' => __( 'Value not informed.', 'tainacan' ),
'label_description_not_informed' => __( 'Description not informed.', 'tainacan' ),
'label_save_goto_metadata' => __( 'Save and Go to Metadata', 'tainacan' ),
@ -371,11 +371,14 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_tainacan_api' => __( 'Tainacan API', 'tainacan' ),
'label_filter_type_preview' => __( 'Filter type preview', 'tainacan' ),
'label_metadatum_type_preview' => __( 'Metadatum type preview', 'tainacan' ),
'label_open_item' => __( 'Open item', 'tainacan' ),
'label_open_item_new_tab' => __( 'Open item in a new tab', 'tainacan' ),
'label_open_collection_new_tab' => __( 'Open collection in a new tab', 'tainacan' ),
'label_select_item' => __( 'Select item', 'tainacan' ),
'label_unselect_item' => __( 'Unselect item', 'tainacan' ),
'label_select_collection' => __( 'Select collection', 'tainacan' ),
'label_unselect_collection' => __( 'Unselect collection', 'tainacan' ),
'label_delete_item' => __( 'Delete item', 'tainacan' ),
'label_delete_collection' => __( 'Delete collection', 'tainacan' ),
'label_no_collections_using_taxonomy' => __( 'There is no collection using this taxonomy', 'tainacan' ),
'label_collections_using' => __( 'Collections using', 'tainacan' ),
'label_select_all_%s_items' => __( 'Select all %s items', 'tainacan' ),
@ -412,7 +415,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'instruction_insert_mapper_metadatum_info' => __( 'Insert the new mapper\'s metadatum info', 'tainacan' ),
'instruction_select_max_options_to_show' => __( 'Select max options to show', 'tainacan' ),
'instruction_select_collection_fetch_items' => __( 'Select a collection to fetch items', 'tainacan' ),
'instruction_select_a_action' => __( 'Select a action', 'tainacan' ),
'instruction_select_a_action' => __( 'Select an action', 'tainacan' ),
'instruction_parent_term' => __( 'Type to search a Parent Term to choose.', 'tainacan' ),
'instruction_type_existing_term' => __( 'Type to add an existing term...', 'tainacan' ),
'instruction_select_an_exporter_type' => __( 'Select an exporter from the options below:', 'tainacan'),

View File

@ -58,7 +58,7 @@ class REST_Background_Processes_Controller extends REST_Controller {
],
'recent' => [
'type' => 'bool',
'description' => __( 'Return only processes created or updated recently', 'tainacan' ),
'description' => __( 'Returns only processes created or updated recently', 'tainacan' ),
],
],
),

View File

@ -181,6 +181,7 @@ class REST_Collections_Controller extends REST_Controller {
$item_arr['moderators'] = $moderators;
$item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete();
}
unset($item_arr['moderators_ids']);
@ -200,6 +201,7 @@ class REST_Collections_Controller extends REST_Controller {
if ( $request['context'] === 'edit' ) {
$item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete();
}
$item_arr['url'] = get_permalink( $item_arr['id'] );

View File

@ -23,7 +23,7 @@ class REST_Filter_Types_Controller extends REST_Controller {
'permission_callback' => array($this, 'get_items_permissions_check'),
'args' => [
'filter-type' => [
'description' => __('The structure of objects returned.'),
'description' => __('Returns the structure of the objects.'),
'items' => [
'className' => [
'type' => 'string'

View File

@ -326,6 +326,7 @@ class REST_Filters_Controller extends REST_Controller {
if($request['context'] === 'edit'){
$item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete();
$item_arr['enabled'] = $item->get_enabled_for_collection();
}

View File

@ -100,6 +100,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
if($request['context'] === 'edit'){
$item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete();
}
return $item_arr;

View File

@ -161,6 +161,7 @@ class REST_Items_Controller extends REST_Controller {
if ( $request['context'] === 'edit' ) {
$item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete();
}
$img_size = 'large';
@ -206,6 +207,7 @@ class REST_Items_Controller extends REST_Controller {
if ( $request['context'] === 'edit' ) {
$item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete();
}
$item_arr['url'] = get_permalink( $item_arr['id'] );

View File

@ -295,6 +295,7 @@ class REST_Metadata_Controller extends REST_Controller {
if($request['context'] === 'edit'){
$item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete();
ob_start();
$item->get_metadata_type_object()->form();
$form = ob_get_clean();

View File

@ -23,7 +23,7 @@ class REST_Metadata_Types_Controller extends REST_Controller {
'permission_callback' => array($this, 'get_items_permissions_check'),
'args' => [
'metadata-type' => [
'description' => __('The structure of objects returned.'),
'description' => __('Returns the structure of the objects.'),
'items' => [
'errors' => [
'type' => 'string'

View File

@ -100,6 +100,7 @@ class REST_Taxonomies_Controller extends REST_Controller {
if ( $request['context'] === 'edit' ) {
$item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete();
$item_arr['collections'] = [];
if ( is_array($tax_collections = $item->get_collections()) ) {
foreach ($tax_collections as $tax_collection) {

View File

@ -261,6 +261,7 @@ class REST_Terms_Controller extends REST_Controller {
if ( $request['context'] === 'edit' ) {
$item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete();
}
$children = get_terms([

View File

@ -55,13 +55,22 @@
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
justify-content: center; }
right: -14px;
top: 0px;
justify-content: center;
z-index: 999; }
.wp-block-tainacan-terms-list ul.terms-list-edit li.term-list-item:hover button {
visibility: visible;
background-color: white !important;
opacity: 1;
right: 0px;
right: -8px;
top: -8px;
border: 1px solid #cbcbcb;
border-radius: 12px;
transition: opacity linear 0.15s, right linear 0.15s; }
.wp-block-tainacan-terms-list ul.terms-list-edit li.term-list-item:hover button:hover {
background-color: white !important;
border: 1px solid #cbcbcb !important; }
@media only screen and (max-width: 498px) {
.wp-block-tainacan-terms-list ul.terms-list.terms-layout-grid,
.wp-block-tainacan-terms-list ul.terms-list-edit.terms-layout-grid {
@ -106,23 +115,6 @@
.wp-block-tainacan-terms-list ul.terms-list-edit.terms-layout-list li.term-list-item:hover a {
color: #454647;
text-decoration: none; }
.wp-block-tainacan-terms-list ul.terms-list-edit li.term-list-item button {
position: absolute !important;
background-color: rgba(255, 255, 255, 0.75);
color: #454647;
padding: 2px;
margin-left: 5px;
min-width: 14px;
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
justify-content: center; }
.wp-block-tainacan-terms-list ul.terms-list-edit li.term-list-item:hover button {
visibility: visible;
opacity: 1;
right: 0px;
transition: opacity linear 0.15s, right linear 0.15s; }
@media only screen and (max-width: 1600px) {
.wp-block-tainacan-terms-list ul.terms-list.terms-layout-list li.term-list-item,
.wp-block-tainacan-terms-list ul.terms-list-edit.terms-layout-list li.term-list-item {
@ -211,13 +203,22 @@
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
justify-content: center; }
right: -14px;
top: 0px;
justify-content: center;
z-index: 999; }
.wp-block-tainacan-items-list ul.items-list-edit li.item-list-item:hover button {
visibility: visible;
background-color: white !important;
opacity: 1;
right: 0px;
right: -8px;
top: -8px;
border: 1px solid #cbcbcb;
border-radius: 12px;
transition: opacity linear 0.15s, right linear 0.15s; }
.wp-block-tainacan-items-list ul.items-list-edit li.item-list-item:hover button:hover {
background-color: white !important;
border: 1px solid #cbcbcb !important; }
@media only screen and (max-width: 498px) {
.wp-block-tainacan-items-list ul.items-list.items-layout-grid,
.wp-block-tainacan-items-list ul.items-list-edit.items-layout-grid {
@ -262,38 +263,6 @@
.wp-block-tainacan-items-list ul.items-list-edit.items-layout-list li.item-list-item:hover a {
color: #454647;
text-decoration: none; }
.wp-block-tainacan-items-list ul.items-list-edit li.item-list-item button {
position: absolute !important;
background-color: rgba(255, 255, 255, 0.75);
color: #454647;
padding: 2px;
margin-left: 5px;
min-width: 14px;
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
justify-content: center; }
.wp-block-tainacan-items-list ul.items-list-edit li.item-list-item:hover button {
visibility: visible;
opacity: 1;
right: 0px;
transition: opacity linear 0.15s, right linear 0.15s; }
@media only screen and (max-width: 1600px) {
.wp-block-tainacan-items-list ul.items-list.items-layout-list li.item-list-item,
.wp-block-tainacan-items-list ul.items-list-edit.items-layout-list li.item-list-item {
min-width: 30%;
width: 30%; } }
@media only screen and (max-width: 1024px) {
.wp-block-tainacan-items-list ul.items-list.items-layout-list li.item-list-item,
.wp-block-tainacan-items-list ul.items-list-edit.items-layout-list li.item-list-item {
min-width: 45%;
width: 45%; } }
@media only screen and (max-width: 768px) {
.wp-block-tainacan-items-list ul.items-list.items-layout-list li.item-list-item,
.wp-block-tainacan-items-list ul.items-list-edit.items-layout-list li.item-list-item {
min-width: 100%;
width: 100%; } }
.wp-block-tainacan-collections-list {
margin: 2rem 0px; }
@ -367,13 +336,22 @@
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
justify-content: center; }
right: -14px;
top: 0px;
justify-content: center;
z-index: 999; }
.wp-block-tainacan-collections-list ul.collections-list-edit li.collection-list-item:hover button {
visibility: visible;
background-color: white !important;
opacity: 1;
right: 0px;
right: -8px;
top: -8px;
border: 1px solid #cbcbcb;
border-radius: 12px;
transition: opacity linear 0.15s, right linear 0.15s; }
.wp-block-tainacan-collections-list ul.collections-list-edit li.collection-list-item:hover button:hover {
background-color: white !important;
border: 1px solid #cbcbcb !important; }
@media only screen and (max-width: 498px) {
.wp-block-tainacan-collections-list ul.collections-list.collections-layout-grid,
.wp-block-tainacan-collections-list ul.collections-list-edit.collections-layout-grid {
@ -418,23 +396,6 @@
.wp-block-tainacan-collections-list ul.collections-list-edit.collections-layout-list li.collection-list-item:hover a {
color: #454647;
text-decoration: none; }
.wp-block-tainacan-collections-list ul.collections-list-edit li.collection-list-item button {
position: absolute !important;
background-color: rgba(255, 255, 255, 0.75);
color: #454647;
padding: 2px;
margin-left: 5px;
min-width: 14px;
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
justify-content: center; }
.wp-block-tainacan-collections-list ul.collections-list-edit li.collection-list-item:hover button {
visibility: visible;
opacity: 1;
right: 0px;
transition: opacity linear 0.15s, right linear 0.15s; }
@media only screen and (max-width: 1600px) {
.wp-block-tainacan-collections-list ul.collections-list.collections-layout-list li.collection-list-item,
.wp-block-tainacan-collections-list ul.collections-list-edit.collections-layout-list li.collection-list-item {

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@ class Core_Description extends Metadata_Type {
$this->set_related_mapped_prop('description');
$this->set_component('tainacan-textarea');
$this->set_name( __('Core Description', 'tainacan') );
$this->set_description( __('The fixed "Description" metadatum automatically created to all collection. This is the default description displayed in items lists and where basic search features will look', 'tainacan') );
$this->set_description( __('The "Core Description" is a compulsory metadata automatically created for all collections by default. This is the main description displayed in items lists and where the basic research tools will do their searches.', 'tainacan') );
}
/**

View File

@ -20,7 +20,7 @@ class Core_Title extends Metadata_Type {
$this->set_related_mapped_prop('title');
$this->set_component('tainacan-text');
$this->set_name( __('Core Description', 'tainacan') );
$this->set_description( __('The fixed "Title" metadatum automatically created to all collection. This is the default title displayed in items lists and where basic search features will look', 'tainacan') );
$this->set_description( __('The "Core Title" is a compulsory metadata automatically created for all collections by default. It is the main metadatum of the item and where the basic research tools will do their searches.', 'tainacan') );
}
/**
@ -45,7 +45,7 @@ class Core_Title extends Metadata_Type {
}
/**
* Title core Metadatum type is stored as the item title
* Core title metadatum type is stored as the item title
*
* Lets validate it as the item title
*

View File

@ -171,7 +171,7 @@
this.loadingMetadata = true;
this.hasMetadata = false;
axios.get('/collection/' + value + '/metadata/')
axios.get('/collection/' + value + '/metadata/?nopaging=1')
.then((res) => {
this.loadingMetadata = false;
let metadata = res.data;

View File

@ -55,8 +55,8 @@ class Relationship extends Metadata_Type {
'description' => __( 'Select the collection to fetch items', 'tainacan' ),
],
'search' => [
'title' => __( 'Metadata for search', 'tainacan' ),
'description' => __( 'Select the metadata to help the search', 'tainacan' ),
'title' => __( 'Metadata to search', 'tainacan' ),
'description' => __( 'Select the metadata to use as search criteria in the target collection', 'tainacan' ),
],
'repeated' => [
'title' =>__( 'Allow repeated items', 'tainacan' ),
@ -92,6 +92,13 @@ class Relationship extends Metadata_Type {
'collection_id' => __('The related collection is required','tainacan')
];
}
if ( !is_array($this->get_option('search')) ) {
return [
'search' => __('Search option must be an array','tainacan')
];
}
return true;
}

View File

@ -199,7 +199,7 @@ class Collections extends Repository {
'map' => 'comment_status',
'title' => __( 'Comment Status', 'tainacan' ),
'type' => 'string',
'description' => __( 'The status of collection comment, if is "open" the comments are allowed, or is "closed" for deny comments.', 'tainacan' ),
'description' => __( 'Collection comment status: "open" means comments are allowed, "closed" means comments are not allowed.', 'tainacan' ),
'default' => get_default_comment_status(Entities\Collection::get_post_type()),
'validation' => v::optional(v::stringType()->in( [ 'open', 'closed' ] )),
],
@ -207,7 +207,7 @@ class Collections extends Repository {
'map' => 'meta',
'title' => __( 'Allow Items Comments', 'tainacan' ),
'type' => 'string',
'description' => __( 'Collection items comment is allowed, if is "open" the comments are allowed for collection items, or is "closed" for deny comments to items.', 'tainacan' ),
'description' => __( 'Collection items comment status: "open" means comments are allowed, "closed" means comments are not allowed.', 'tainacan' ),
'default' => 'open',
'validation' => v::optional(v::stringType()->in( [ 'open', 'closed' ] )),
]

View File

@ -111,7 +111,7 @@ class Items extends Repository {
'map' => 'comment_status',
'title' => __( 'Comment Status', 'tainacan' ),
'type' => 'string',
'description' => __( 'The status of item comment, if is "open" the comments are allowed to item, or is "closed" for deny comments to item.', 'tainacan' ),
'description' => __( 'Item comment status: "open" means comments are allowed, "closed" means comments are not allowed.', 'tainacan' ),
'default' => get_default_comment_status(Entities\Collection::get_post_type()),
'validation' => v::optional(v::stringType()->in( [ 'open', 'closed' ] )),
]

View File

@ -1042,7 +1042,7 @@ class Metadata extends Repository {
}
$query = "SELECT DISTINCT t.name, tt.term_taxonomy_id, tt.parent $base_query $pagination";
$query = "SELECT DISTINCT t.name, t.term_id, tt.term_taxonomy_id, tt.parent $base_query $pagination";
$total_query = "SELECT COUNT(DISTINCT tt.term_taxonomy_id) $base_query";
@ -1056,15 +1056,15 @@ class Metadata extends Repository {
$args['include'] = array_map(function($t) { return (int) $t; }, $args['include']);
$include_ids = implode(',', $args['include']);
$query_to_include = "SELECT DISTINCT t.name, tt.term_taxonomy_id, tt.parent FROM $wpdb->term_taxonomy tt
$query_to_include = "SELECT DISTINCT t.name, t.term_id, tt.term_taxonomy_id, tt.parent FROM $wpdb->term_taxonomy tt
INNER JOIN $wpdb->terms t ON tt.term_id = t.term_id
WHERE
tt.term_taxonomy_id IN ($include_ids)";
t.term_id IN ($include_ids)";
$to_include = $wpdb->get_results($query_to_include);
// remove terms that will be included at the begining
$results = array_filter($results, function($t) use($args) { return !in_array($t->term_taxonomy_id, $args['include']); });
$results = array_filter($results, function($t) use($args) { return !in_array($t->term_id, $args['include']); });
$results = array_merge($to_include, $results);
@ -1082,7 +1082,7 @@ class Metadata extends Repository {
$values = [];
foreach ($results as $r) {
$count_query = $wpdb->prepare("SELECT COUNT(term_id) FROM $wpdb->term_taxonomy WHERE parent = %d", $r->term_taxonomy_id);
$count_query = $wpdb->prepare("SELECT COUNT(term_id) FROM $wpdb->term_taxonomy WHERE parent = %d", $r->term_id);
$total_children = $wpdb->get_var($count_query);
$label = $r->name;
@ -1096,7 +1096,7 @@ class Metadata extends Repository {
}
$count_items_query['tax_query'][] = [
'taxonomy' => $taxonomy_slug,
'terms' => $r->term_taxonomy_id
'terms' => $r->term_id
];
$count_items_results = $itemsRepo->fetch($count_items_query, $args['collection_id']);
$total_items = $count_items_results->found_posts;
@ -1106,7 +1106,7 @@ class Metadata extends Repository {
}
$values[] = [
'value' => $r->term_taxonomy_id,
'value' => $r->term_id,
'label' => $label,
'total_children' => $total_children,
'taxonomy' => $taxonomy_slug,

View File

@ -274,14 +274,14 @@ class Terms extends Repository {
/**
* Check if a term already exists
*
* @param string $term_name The term name
* @param string $searched_term The term name (string) or term_id (integer). If term id is passed, parent is not considered.
* @param mixed $taxonomy The taxonomy ID, slug or Entity.
* @param int $parent The ID of the parent term to look for children or null to look for terms in any hierarchical position. Default is null
* @param bool $return_term wether to return the term object if it exists. default is to false
*
* @return bool|WP_Term return boolean indicating if term exists. If $return_term is true and term exists, return WP_Term object
*/
public function term_exists($name, $taxonomy, $parent = null, $return_term = false) {
public function term_exists($searched_term, $taxonomy, $parent = null, $return_term = false) {
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
@ -293,36 +293,39 @@ class Terms extends Repository {
$taxonomy_slug = $taxonomy->get_db_identifier();
}
if(is_numeric($name)){
$args = [
'id' => (int) $name,
'taxonomy' => $taxonomy_slug,
'parent' => $parent,
'hide_empty' => 0,
'suppress_filter' => true
];
if(is_int($searched_term)){
$term = get_term_by( 'id', $searched_term, $taxonomy_slug );
if ( ! $term ) {
return false;
}
} else {
$args = [
'name' => $name,
'name' => $searched_term,
'taxonomy' => $taxonomy_slug,
'parent' => $parent,
'hide_empty' => 0,
'suppress_filter' => true
];
}
if (is_null($parent)) {
unset($args['parent']);
}
$terms = get_terms($args);
if (empty($terms)) {
return false;
if (is_null($parent)) {
unset($args['parent']);
}
$terms = get_terms($args);
if (empty($terms)) {
return false;
}
$term = $terms[0];
}
if ($return_term) {
return $terms[0];
return $term;
}
return true;

View File

@ -88,16 +88,26 @@
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
right: -14px;
top: 0px;
justify-content: center;
z-index: 999
}
&:hover button {
visibility: visible;
background-color: rgba(255, 255, 255, 1) !important;
opacity: 1;
right: 0px;
right: -8px;
top: -8px;
border: 1px solid #cbcbcb;
border-radius: 12px;
transition: opacity linear 0.15s, right linear 0.15s;
}
&:hover button:hover {
background-color: rgba(255, 255, 255, 1) !important;
border: 1px solid #cbcbcb !important;
}
}
@media only screen and (max-width: 498px) {
@ -156,30 +166,6 @@
}
}
}
ul.collections-list-edit li.collection-list-item {
button {
position: absolute !important;
background-color: rgba(255, 255, 255, 0.75);
color: #454647;
padding: 2px;
margin-left: 5px;
min-width: 14px;
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
justify-content: center;
}
&:hover button {
visibility: visible;
opacity: 1;
right: 0px;
transition: opacity linear 0.15s, right linear 0.15s;
}
}
@media only screen and (max-width: 1600px) {
ul.collections-list.collections-layout-list li.collection-list-item,

View File

@ -172,7 +172,7 @@ registerBlockType('tainacan/items-list', {
html: false,
},
edit({ attributes, setAttributes, className, isSelected }){
let {
let {
selectedItemsObject,
selectedItemsHTML,
temporarySelectedItems,

View File

@ -88,16 +88,26 @@
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
right: -14px;
top: 0px;
justify-content: center;
z-index: 999;
}
&:hover button {
visibility: visible;
background-color: rgba(255, 255, 255, 1) !important;
opacity: 1;
right: 0px;
right: -8px;
top: -8px;
border: 1px solid #cbcbcb;
border-radius: 12px;
transition: opacity linear 0.15s, right linear 0.15s;
}
&:hover button:hover {
background-color: rgba(255, 255, 255, 1) !important;
border: 1px solid #cbcbcb !important;
}
}
@media only screen and (max-width: 498px) {
@ -156,53 +166,4 @@
}
}
}
ul.items-list-edit li.item-list-item {
button {
position: absolute !important;
background-color: rgba(255, 255, 255, 0.75);
color: #454647;
padding: 2px;
margin-left: 5px;
min-width: 14px;
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
justify-content: center;
}
&:hover button {
visibility: visible;
opacity: 1;
right: 0px;
transition: opacity linear 0.15s, right linear 0.15s;
}
}
@media only screen and (max-width: 1600px) {
ul.items-list.items-layout-list li.item-list-item,
ul.items-list-edit.items-layout-list li.item-list-item {
min-width: 30%;
width: 30%;
}
}
@media only screen and (max-width: 1024px) {
ul.items-list.items-layout-list li.item-list-item,
ul.items-list-edit.items-layout-list li.item-list-item {
min-width: 45%;
width: 45%;
}
}
@media only screen and (max-width: 768px) {
ul.items-list.items-layout-list li.item-list-item,
ul.items-list-edit.items-layout-list li.item-list-item {
min-width: 100%;
width: 100%;
}
}
}

View File

@ -70,16 +70,26 @@
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
right: -14px;
top: 0px;
justify-content: center;
z-index: 999
}
&:hover button {
visibility: visible;
background-color: rgba(255, 255, 255, 1) !important;
opacity: 1;
right: 0px;
right: -8px;
top: -8px;
border: 1px solid #cbcbcb;
border-radius: 12px;
transition: opacity linear 0.15s, right linear 0.15s;
}
&:hover button:hover {
background-color: rgba(255, 255, 255, 1) !important;
border: 1px solid #cbcbcb !important;
}
}
@media only screen and (max-width: 498px) {
@ -138,31 +148,7 @@
}
}
}
ul.terms-list-edit li.term-list-item {
button {
position: absolute !important;
background-color: rgba(255, 255, 255, 0.75);
color: #454647;
padding: 2px;
margin-left: 5px;
min-width: 14px;
visibility: hidden;
position: relative;
opacity: 0;
right: -12px;
justify-content: center;
}
&:hover button {
visibility: visible;
opacity: 1;
right: 0px;
transition: opacity linear 0.15s, right linear 0.15s;
}
}
@media only screen and (max-width: 1600px) {
ul.terms-list.terms-layout-list li.term-list-item,
ul.terms-list-edit.terms-layout-list li.term-list-item {

View File

@ -53,8 +53,8 @@ class Importer_Handler {
]);
$this->register_importer([
'name' => 'OAI PMH',
'description' => __('Import structure from a OAI PMH repository', 'tainacan'),
'name' => 'OAI-PMH (Experimental)',
'description' => __('Import items from an OAI-PMH data source', 'tainacan'),
'slug' => 'oaipmh_importer',
'class_name' => '\Tainacan\Importer\Oaipmh_Importer',
'manual_collection' => false,

View File

@ -19,6 +19,7 @@ class Oaipmh_Importer extends Importer {
],
];
protected $NAME_FOR_SETS = 'Sets';
protected $tainacan_api_address, $wordpress_api_address, $actual_collection;
/**
@ -53,7 +54,7 @@ class Oaipmh_Importer extends Importer {
if( $index === 0 ){
if( $collection_id['source_id'] !== 'taxonomies' ){
if( $collection_id['source_id'] !== 'sets' ){
$info = $this->requester( $this->get_url() . "?verb=ListRecords&metadataPrefix=oai_dc&set=" . $collection_id['source_id'] );
$this->add_log('fetching ' . $this->get_url() . "?verb=ListRecords&metadataPrefix=oai_dc&set=" . $collection_id['source_id']);
} else {
@ -95,6 +96,18 @@ class Oaipmh_Importer extends Importer {
while ( isset($xml->ListRecords->record[$j]) ) {
$record = $record = $xml->ListRecords->record[$j];
$dc = $record->metadata->children("http://www.openarchives.org/OAI/2.0/oai_dc/");
$header = $record->header;
$is_inserted = $this->get_transient($header->identifier);
if( $is_inserted ){
continue;
}
if( $this->get_option('using_set') == 'taxonomy' && ( isset($header) && isset($header->setSpec) ) ){
foreach ($header->setSpec as $item ) {
$record_processed['sets'][] = (string) $item;
}
}
if ($record->metadata->Count() > 0 ) {
$metadata = $dc->children('http://purl.org/dc/elements/1.1/');
@ -134,11 +147,11 @@ class Oaipmh_Importer extends Importer {
$this->add_log('Creating collections');
$collection_xml = $this->fetch_collections();
if( isset($collection_xml->ListSets) ){
if( $collection_xml ){
if( !$this->get_option('using_set') || $this->get_option('using_set') == 'collection' ){
foreach ($collection_xml->ListSets->set as $set) {
foreach ($collection_xml as $set ) {
$setSpec = (string) $set->setSpec;
$setName = (string) $set->setName;
@ -159,17 +172,44 @@ class Oaipmh_Importer extends Importer {
}
} else if( $this->get_option('using_set') == 'taxonomy') {
$collection = $this->create_collection( 'set', $this->getRepoName() );
$metadata_map = $this->create_collection_metadata($collection);
$total = intval( $this->get_total_items_from_source(false) );
$this->add_log('total in collection: ' . $total);
$this->add_log('collection id ' . (string) $collection->get_id());
$tax = new Entities\Taxonomy();
$tax->set_name( 'Sets' );
$tax->set_name( $this->NAME_FOR_SETS );
$tax->set_allow_insert('yes');
$tax->set_status('publish');
if ($tax->validate()) {
$tax = $this->tax_repo->insert($tax);
$is_tax_created = $this->get_transient('set_taxonomy_id');
if( $is_tax_created ){
$tax = new Entities\Taxonomy( $is_tax_created );
} else {
$tax = $this->tax_repo->insert($tax);
$this->add_transient('set_taxonomy_id', $tax->get_id());
}
$metadatum_set_id = $this->create_set_metadata( $collection->get_id(), $tax->get_id() );
if( $metadatum_set_id ){
$this->add_transient('set_metadatum_id', $metadatum_set_id);
$this->add_collection([
'id' => $collection->get_id(),
'mapping' => $metadata_map,
'total_items' =>ceil( $total / 100 ),
'source_id' => 'sets',
'metadatum_id' => $metadatum_set_id
]);
}
$this->add_log('Taxonomy ' . $tax->get_name() . ' created' );
foreach ($collection_xml->ListSets->set as $set) {
foreach ($collection_xml as $set) {
$setSpec = (string)$set->setSpec;
$setName = (string)$set->setName;
@ -187,7 +227,14 @@ class Oaipmh_Importer extends Importer {
}
return false;
$resumptionToken = $this->get_transient('collection_resump');
if( $resumptionToken !== ''){
return 1;
} else {
return false;
}
}
/**
@ -217,10 +264,33 @@ class Oaipmh_Importer extends Importer {
if( $record && $item->validate() ){
$insertedItem = $this->items_repo->insert( $item );
if( isset($record['sets']) ){
$terms = [];
$metadatum_set_id = $this->get_transient('set_metadatum_id');
foreach ($record['sets'] as $set) {
$term_id = $this->get_transient($set);
if( $term_id ) $terms[] = $term_id;
}
if( $metadatum_set_id && $terms ){
$newMetadatum = new Entities\Metadatum($metadatum_set_id);
$item_metadata = new Entities\Item_Metadata_Entity( $insertedItem, $newMetadatum );
$item_metadata->set_value($terms);
if( $item_metadata->validate() ){
$this->item_metadata_repo->insert( $item_metadata );
}
}
unset($record['sets']);
}
foreach ( $record as $index => $value ){
$this->add_log( $index . ' ' . serialize($map) );
$this->add_log( $insertedItem->get_id() );
$this->add_log( 'inserting metadata ' . $index );
if( in_array( $index, $map ) && $insertedItem->get_id()){
$metadatum_id = array_search($index, $map );
$newMetadatum = new Entities\Metadatum($metadatum_id);
@ -275,7 +345,11 @@ class Oaipmh_Importer extends Importer {
* @return int
*/
public function get_total_items_from_source( $setSpec ) {
$info = $this->requester( $this->get_url() . "?verb=ListRecords&metadataPrefix=oai_dc&set=" . $setSpec);
if($setSpec)
$info = $this->requester( $this->get_url() . "?verb=ListRecords&metadataPrefix=oai_dc&set=" . $setSpec);
else
$info = $this->requester( $this->get_url() . "?verb=ListRecords&metadataPrefix=oai_dc");
if( !isset($info['body']) ){
$this->add_log('ERROR');
@ -315,6 +389,12 @@ class Oaipmh_Importer extends Importer {
* @return Entities\Collection
*/
protected function create_collection( $setSpec, $setName ){
$is_created = $this->get_transient('collection_' . $setSpec. '_name');
if( $is_created ){
$new_collection = new Entities\Collection( $is_created );
return $new_collection;
}
$new_collection = new Entities\Collection();
$new_collection->set_name($setName);
$new_collection->set_status('publish');
@ -395,8 +475,14 @@ class Oaipmh_Importer extends Importer {
if($metadatum->validate()){
$new_metadata = $Tainacan_Metadata->insert($metadatum);
$array_metadata[$new_metadata->get_id()] = $slug;
$metadatum_id_created = $this->get_transient('collection_' . $id . '_' . $slug );
if( $metadatum_id_created ){
$array_metadata[$metadatum_id_created] = $slug;
} else {
$new_metadata = $Tainacan_Metadata->insert($metadatum);
$array_metadata[$new_metadata->get_id()] = $slug;
}
}
}
}
@ -410,9 +496,30 @@ class Oaipmh_Importer extends Importer {
*/
protected function fetch_collections(){
$collections_link = $this->get_url() . "?verb=ListSets";
$collections_array = [];
// block terms with same set spec
$resumptionToken = $this->get_transient('collection_resump');
if( $resumptionToken ){
$collections_link = $this->get_url() . "?verb=ListSets&resumptionToken=" . $resumptionToken;
} else {
$collections_link = $this->get_url() . "?verb=ListSets";
}
$collections = $this->requester($collections_link);
$collections_array = $this->decode_request($collections, $collections_link);
$xml = $this->decode_request($collections, $collections_link);
if( isset($xml->ListSets->set) ) {
foreach ($xml->ListSets->set as $set) {
$collections_array[] = $set;
}
}
if( isset($xml->ListSets) && isset($xml->ListSets->resumptionToken) ){
$this->add_transient('collection_resump',(string) $xml->ListSets->resumptionToken);
} else {
$this->add_transient('collection_resump', (string) $xml->ListSets->resumptionToken);
}
// TODO: verify if exists resumption token
@ -542,6 +649,67 @@ class Oaipmh_Importer extends Importer {
return false;
}
/**
* @param $collection_id
* @param $taxonomy_id
* @return bool|int
* @throws \Exception
*/
public function create_set_metadata( $collection_id, $taxonomy_id ){
$newMetadatum = new Entities\Metadatum();
$name = $this->NAME_FOR_SETS;
$type = 'Taxonomy';
$newMetadatum->set_name($name);
$newMetadatum->set_metadata_type('Tainacan\Metadata_Types\\'.$type);
$newMetadatum->set_collection_id( (isset($collection_id)) ? $collection_id : 'default');
$newMetadatum->set_status('publish');
$newMetadatum->set_metadata_type_options(['taxonomy_id' => $taxonomy_id ]);
$newMetadatum->set_multiple('yes');
if($newMetadatum->validate()){
$is_meta_created = $this->get_transient('set_metadatum_id');
if( $is_meta_created ){
$inserted_metadata = new Entities\Metadatum($is_meta_created);
$this->add_log('Metadata get: ' . $inserted_metadata->get_name());
} else {
$inserted_metadata = $this->metadata_repo->insert( $newMetadatum );
$this->add_log('Metadata created: ' . $inserted_metadata->get_name());
}
return $inserted_metadata->get_id();
} else{
return false;
}
}
public function getRepoName(){
$info = $this->requester( $this->get_url() . "?verb=Identify");
if( !isset($info['body']) ){
$this->add_log('ERROR on get repo name');
$this->add_error_log('Error in fetch remote total items');
$this->abort();
return __('Imported Repo');
} else {
try {
$xml = new \SimpleXMLElement($info['body']);
if( isset($xml->Identify) && isset($xml->Identify->repositoryName) ){
return (string) $xml->Identify->repositoryName;
}
} catch (Exception $e) {
return __('Imported Repo');
}
return __('Imported Repo');
}
}
public function options_form(){
ob_start();
@ -565,7 +733,11 @@ class Oaipmh_Importer extends Importer {
</span>
<div class="control is-clearfix">
<div class="select">
<<<<<<< HEAD
<select disabled name="using_set">
=======
<select name="using_set">
>>>>>>> develop
<option value="collection" <?php selected($this->get_option('using_set'), 'collection'); ?> ><?php _e('Collections', 'tainacan'); ?></option>
<option value="taxonomy" <?php selected($this->get_option('using_set'), 'taxonomy'); ?> ><?php _e('Taxonomies', 'tainacan'); ?></option>
</select>

View File

@ -272,6 +272,9 @@ export default {
this.$store.dispatch('search/setStatus', status);
this.updateURLQueries();
},
setTotalItems(totalItems) {
this.$store.dispatch('search/setTotalItems', totalItems);
},
setSearchQuery(searchQuery) {
this.$store.dispatch('search/setSearchQuery', searchQuery);
this.updateURLQueries();
@ -351,6 +354,7 @@ export default {
},
setCollectionId(collectionId) {
this.setTotalItems(null);
this.collectionId = collectionId;
},
setTerm(termId, taxonomy) {

View File

@ -92,8 +92,7 @@ export const cleanProcesses = ({ commit }) => {
export const deleteProcess = ({ commit }, id) => {
return new Promise((resolve, reject) => {
axios.tainacan.delete('/bg-process/' + id)
.then( res => {
axios.tainacan.delete('/bg-process/' + id).then( res => {
commit('deleteProcess', { id: id });
resolve( res );
}).catch((error) => {

View File

@ -210,6 +210,20 @@ export const fetchCollectionName = ({ commit }, id) => {
});
};
export const fetchCollectionUserCanEdit = ({ commit }, id) => {
return new Promise ((resolve, reject) => {
axios.tainacan.get('/collections/' + id + '?context=edit&fetch_only=current_user_can_edit')
.then(res => {
let caps = res.data.current_user_can_edit;
resolve( caps );
})
.catch(error => {
reject(error);
})
});
};
export const fetchCollectionTotalItems = ({ commit }, id) => {
return new Promise ((resolve, reject) => {

View File

@ -62,10 +62,10 @@ export const setLastUpdated = ({ commit}, value) => {
};
// Actions directly related to Item
export const fetchItem = ({ commit }, item_id) => {
export const fetchItem = ({ commit }, { itemId, contextEdit } ) => {
commit('cleanItem')
return new Promise((resolve, reject) => {
axios.tainacan.get('/items/'+item_id)
axios.tainacan.get('/items/'+ itemId + (contextEdit ? '?context=edit' : ''))
.then(res => {
let item = res.data;
commit('setItem', item);

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,9 @@
Contributors: andrebenedito, daltonmartins, fabianobn, jacsonp, leogermani, weryques, wetah, eduardohumberto, ravipassos, jessicafpx, marinagiolo, omarceloavila
Tags: museums, libraries, archives, GLAM, collections, repository
Requires at least: 4.8
Tested up to: 5.0.2
Tested up to: 5.1.1
Requires PHP: 5.6
Stable tag: 0.7
Stable tag: 0.8
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

View File

@ -4,7 +4,7 @@ Plugin Name: Tainacan
Plugin URI: https://tainacan.org/
Description: powerfull and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional respository platform.
Author: Media Lab / UFG
Version: 0.7
Version: 0.8
Text Domain: tainacan
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

View File

@ -378,6 +378,9 @@ function tainacan_get_initials($string, $one = false) {
if (empty($string)) {
return '';
}
$string = remove_accents($string);
if (strlen($string) == 1) {
return strtoupper($string);
}

View File

@ -141,9 +141,7 @@
</button>
<div
class="slide-main-content">
<!-- <div <IF WE USE HAMMER JS>
class="slide-main-content"
v-hammer:swipe.prevent="onSwipeFiltersMenu"> -->
<transition
mode="out-in"
:name="goingRight ? 'slide-right' : 'slide-left'" >
@ -559,7 +557,7 @@ export default {
this.$nextTick(() => this.isLoadingItem = false);
} else {
// Loads current item
this.fetchItem(this.slideItems[this.slideIndex].id)
this.fetchItem({ itemId: this.slideItems[this.slideIndex].id, contextEdit: true })
.then(() => {
this.isLoadingItem = false;
})

View File

@ -240,6 +240,139 @@ class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase {
}
function test_relate_taxonomy_match() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'test',
'status' => 'publish',
),
true
);
$collection2 = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'test2',
'status' => 'publish',
),
true
);
$tax = $this->tainacan_entity_factory->create_entity(
'taxonomy',
array(
'name' => 'tax_test',
'status' => 'publish',
),
true
);
$tax2 = $this->tainacan_entity_factory->create_entity(
'taxonomy',
array(
'name' => 'tax_test2',
'status' => 'publish',
),
true
);
$tax3 = $this->tainacan_entity_factory->create_entity(
'taxonomy',
array(
'name' => 'tax_test3',
'status' => 'publish',
),
true
);
$metadatum = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'meta',
'description' => 'description',
'collection' => $collection,
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
'status' => 'publish',
'metadata_type_options' => [
'taxonomy_id' => $tax->get_id(),
'allow_new_terms' => false
]
),
true
);
$metadatum2 = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'meta2',
'description' => 'description',
'collection' => $collection,
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
'status' => 'publish',
'metadata_type_options' => [
'taxonomy_id' => $tax2->get_id(),
'allow_new_terms' => false
]
),
true
);
$metadatum3 = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'meta3',
'description' => 'description',
'collection' => $collection2,
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
'status' => 'publish',
'metadata_type_options' => [
'taxonomy_id' => $tax2->get_id(),
'allow_new_terms' => false
]
),
true
);
$metadatum4 = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'meta4',
'description' => 'description',
'collection' => $collection2,
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
'status' => 'publish',
'metadata_type_options' => [
'taxonomy_id' => $tax3->get_id(),
'allow_new_terms' => false
]
),
true
);
$checkTax = $Tainacan_Taxonomies->fetch($tax->get_id());
$checkTax2 = $Tainacan_Taxonomies->fetch($tax2->get_id());
$checkTax3 = $Tainacan_Taxonomies->fetch($tax3->get_id());
$this->assertEquals( sizeof($checkTax->get_collections_ids()), sizeof($checkTax->get_collections()) );
$this->assertEquals( sizeof($checkTax2->get_collections_ids()), sizeof($checkTax2->get_collections()) );
$this->assertEquals( sizeof($checkTax3->get_collections_ids()), sizeof($checkTax3->get_collections()) );
$this->assertNotContains($checkTax3->get_db_identifier(), get_object_taxonomies($collection->get_db_identifier()), 'Collection must be added to taxonomy when metadatum is created');
$this->assertContains($checkTax->get_db_identifier(), get_object_taxonomies($collection->get_db_identifier()), 'Collection must be added to taxonomy when metadatum is created');
$this->assertContains($checkTax2->get_db_identifier(), get_object_taxonomies($collection->get_db_identifier()), 'Collection must be added to taxonomy when metadatum is created');
$this->assertNotContains($checkTax->get_db_identifier(), get_object_taxonomies($collection2->get_db_identifier()), 'Collection must be added to taxonomy when metadatum is created');
$this->assertContains($checkTax3->get_db_identifier(), get_object_taxonomies($collection2->get_db_identifier()), 'Collection must be added to taxonomy when metadatum is created');
$this->assertContains($checkTax2->get_db_identifier(), get_object_taxonomies($collection2->get_db_identifier()), 'Collection must be added to taxonomy when metadatum is created');
$this->assertEquals(2, sizeof( get_object_taxonomies($collection2->get_db_identifier()) ));
$this->assertEquals(2, sizeof( get_object_taxonomies($collection->get_db_identifier()) ));
}
/**

View File

@ -174,7 +174,7 @@ class Taxonomies extends TAINACAN_UnitTestCase {
// testing passing taxonomy object
$this->assertTrue( $Tainacan_Terms->term_exists('Rock', $taxonomy) );
// testing passing ID
// testing passing taxonomy ID
$this->assertTrue( $Tainacan_Terms->term_exists('Rock', $taxonomy->get_id()) );
// testing via Taxonomy object
@ -189,6 +189,20 @@ class Taxonomies extends TAINACAN_UnitTestCase {
$this->assertFalse( $Tainacan_Terms->term_exists('Child', $taxonomy->get_db_identifier(), 0) ); // parent 0
$this->assertTrue( $Tainacan_Terms->term_exists('Child', $taxonomy->get_db_identifier(), $parent->get_id()) ); // parent
// test with ID
$this->assertTrue( $Tainacan_Terms->term_exists($term->get_id(), $taxonomy->get_id()) );
// test get term
$test_term = $Tainacan_Terms->term_exists($term->get_id(), $taxonomy->get_id(), null, true);
$this->assertEquals($term->get_id(), $test_term->term_id);
$test_term = $Tainacan_Terms->term_exists('Rock', $taxonomy->get_id(), null, true);
$this->assertEquals($term->get_id(), $test_term->term_id);
$test_term = $Tainacan_Terms->term_exists('Parent', $taxonomy->get_id(), null, true);
$this->assertEquals($parent->get_id(), $test_term->term_id);
}
function test_term_validation() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 35 KiB