Merge branch 'develop' into feature/778

This commit is contained in:
mateuswetah 2023-04-11 09:33:32 -03:00
commit 3ca1411a6a
16 changed files with 173 additions and 240 deletions

View File

@ -19,17 +19,10 @@ class REST_Exporters_Controller extends REST_Controller {
*/
public function __construct() {
$this->rest_base = 'exporters';
if (session_status() == PHP_SESSION_NONE) {
@session_start(); // @ avoids Warnings when running phpunit tests
}
parent::__construct();
add_action('init', array(&$this, 'init_objects'), 11);
}
public function __destruct() {
session_write_close();
}
/**
* Initialize objects after post_type register
*/

View File

@ -11,8 +11,6 @@ use Tainacan\Entities;
*
* */
class REST_Importers_Controller extends REST_Controller {
private $collections_repository;
private $collection;
/**
* REST_Importers_Controller constructor.
@ -20,15 +18,9 @@ class REST_Importers_Controller extends REST_Controller {
*/
public function __construct(){
$this->rest_base = 'importers';
if (session_status() == PHP_SESSION_NONE) {
@session_start(); // @ avoids Warnings when running phpunit tests
}
parent::__construct();
}
public function __destruct() {
session_write_close();
}
/**
* Register the collections route and their endpoints
*/

View File

@ -1,89 +0,0 @@
<?php
class ScriptTainacanOld {
var $step = 0;
var $url = '';
/**
* start the execution
*/
function __construct($argv) {
$this->parse_args($argv);
$this->run();
}
/**
* parse args from and set the attributs
* 1 - Old Tainacan url (required)
*/
function parse_args($argv) {
if (!is_array($argv))
return;
if (isset($argv[1])) {
if (filter_var($argv[1], FILTER_VALIDATE_URL)) {
$this->url = $argv[1];
}
}
if (isset($argv[2])) {
if (is_numeric($argv[2])) {
$this->step = $argv[2];
} else {
$this->run = '';
}
}
}
/**
* echo message in prompt line
*/
function log($msg) {
echo $msg . PHP_EOL;
}
function run() {
$start = $partial = microtime(true);
// Avoid warnings
$_SERVER['SERVER_PROTOCOL'] = "HTTP/1.1";
$_SERVER['REQUEST_METHOD'] = "GET";
define( 'WP_USE_THEMES', false );
define( 'SHORTINIT', false );
// require( dirname(__FILE__) . '/../../../../wp-blog-header.php' );
$old_tainacan = new \Tainacan\Importer\Old_Tainacan();
$id = $old_tainacan->get_id();
$_SESSION['tainacan_importer'][$id]->set_url($this->url);
while (!$_SESSION['tainacan_importer'][$id]->is_finished()){
$_SESSION['tainacan_importer'][$id]->run();
}
$scripttime = microtime(true) - $start;
$this->log("==========================================================");
$this->log("==========================================================");
$this->log("=== Fim do script. Tempo de execução {$scripttime}s");
$this->log("==========================================================");
$this->log("==========================================================");
}
}
$x = new ScriptTainacanOld($argv);

View File

@ -4,7 +4,7 @@ Tags: museums, libraries, archives, GLAM, collections, repository
Requires at least: 5.0
Tested up to: 6.1
Requires PHP: 5.6
Stable tag: 0.20.1
Stable tag: 0.20.2
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: Open source, powerful 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 repository platform.
Author: Tainacan.org
Version: 0.20.1
Version: 0.20.2
Requires at least: 5.0
Tested up to: 6.1
Requires PHP: 5.6
@ -14,7 +14,7 @@ License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
const TAINACAN_VERSION = '0.20.1';
const TAINACAN_VERSION = '0.20.2';
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
$TAINACAN_BASE_URL = plugins_url('', __FILE__);

View File

@ -86,8 +86,33 @@
</template>
<script>
import TainacanFilterNumeric from './numeric/Numeric.vue';
import TainacanFilterDate from './date/Date.vue';
import TainacanFilterSelectbox from './selectbox/Selectbox.vue';
import TainacanFilterAutocomplete from './autocomplete/Autocomplete.vue';
import TainacanFilterCheckbox from './checkbox/Checkbox.vue';
import TainacanFilterTaginput from './taginput/Taginput.vue';
import TainacanFilterTaxonomyCheckbox from './taxonomy/Checkbox.vue';
import TainacanFilterTaxonomyTaginput from './taxonomy/Taginput.vue';
import TainacanFilterDateInterval from './date-interval/DateInterval.vue';
import TainacanFilterNumericInterval from './numeric-interval/NumericInterval.vue';
import TainacanFilterNumericListInterval from './numeric-list-interval/NumericListInterval.vue';
export default {
name: 'TainacanFilterItem',
components: {
TainacanFilterNumeric,
TainacanFilterDate,
TainacanFilterSelectbox,
TainacanFilterAutocomplete,
TainacanFilterCheckbox,
TainacanFilterTaginput,
TainacanFilterTaxonomyCheckbox,
TainacanFilterTaxonomyTaginput,
TainacanFilterDateInterval,
TainacanFilterNumericInterval,
TainacanFilterNumericListInterval
},
props: {
filter: Object,
query: Object,

View File

@ -229,6 +229,35 @@ class Compound extends Metadata_Type {
return "<div class='tainacan-compound-group'> {$return} </div>";
}
// /**
// * Return the value of an Item_Metadata_Entity using a metadatum of this metadatum type as a string
// * @param Item_Metadata_Entity $item_metadata
// * @return string The String representation of the value, containing one or multiple items names, linked to the item page
// */
public function get_value_as_string(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
$return = '';
if ( empty($value) )
return $return;
if ( $item_metadata->is_multiple() ) {
foreach ( $value as $compound_element ) {
if ( !empty($compound_element) ) {
foreach ( $compound_element as $meta_id => $meta ) {
$return .= $meta->get_value_as_string() . " ";
}
}
$return .= "\n";
}
} else {
foreach ( $value as $meta_id => $meta ) {
$return .= $meta->get_value_as_string() . " ";
}
}
return $return;
}
private function get_meta_html(Item_Metadata_Entity $meta) {
$html = '';
if ($meta instanceof Item_Metadata_Entity && !empty($meta->get_value_as_html())) {

View File

@ -292,10 +292,12 @@
<script>
import { mapGetters, mapActions } from 'vuex';
import TainacanFilterItem from '../filter-types/tainacan-filter-item.vue';
import FiltersTagsList from './filters-tags-list.vue';
export default {
components: {
TainacanFilterItem,
FiltersTagsList
},
props: {

View File

@ -55,19 +55,6 @@ import FormNumeric from '../components/metadata-types/numeric/FormNumeric.vue';
import FormUser from '../components/metadata-types/user/FormUser.vue';
import FormGeoCoordinate from '../components/metadata-types/geocoordinate/FormGeoCoordinate.vue';
import FilterNumeric from '../components/filter-types/numeric/Numeric.vue';
import FilterDate from '../components/filter-types/date/Date.vue';
import FilterSelectbox from '../components/filter-types/selectbox/Selectbox.vue';
import FilterAutocomplete from '../components/filter-types/autocomplete/Autocomplete.vue';
import FilterCheckbox from '../components/filter-types/checkbox/Checkbox.vue';
import FilterTaginput from '../components/filter-types/taginput/Taginput.vue';
import FilterNumericInterval from '../components/filter-types/numeric-interval/NumericInterval.vue';
import FilterDateInterval from '../components/filter-types/date-interval/DateInterval.vue';
import FilterNumericListInterval from '../components/filter-types/numeric-list-interval/NumericListInterval.vue';
import FilterTaxonomyCheckbox from '../components/filter-types/taxonomy/Checkbox.vue';
import FilterTaxonomyTaginput from '../components/filter-types/taxonomy/Taginput.vue';
// Term edition form must be imported here so that it is not necessary on item-submission bundle
import TermEditionForm from '../components/edition/term-edition-form.vue';
@ -80,7 +67,6 @@ import FormFilterNumericListInterval from '../components/filter-types/numeric-li
// import FormDate from '../../../classes/filter-types/date/FormDate.vue';
import TainacanFormItem from '../components/metadata-types/tainacan-form-item.vue';
import TainacanFiltersList from '../components/filter-types/tainacan-filter-item.vue';
// Remaining imports
import AdminPage from '../admin.vue'
@ -228,29 +214,14 @@ export default (element) => {
Vue.component('term-edition-form', TermEditionForm);
Vue.component('tainacan-form-geocoordinate', FormGeoCoordinate);
/* Filters */
Vue.component('tainacan-filter-numeric', FilterNumeric);
Vue.component('tainacan-filter-date', FilterDate);
Vue.component('tainacan-filter-selectbox', FilterSelectbox);
Vue.component('tainacan-filter-autocomplete', FilterAutocomplete);
Vue.component('tainacan-filter-checkbox', FilterCheckbox);
Vue.component('tainacan-filter-taginput', FilterTaginput);
Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox);
Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput);
Vue.component('tainacan-filter-numeric-interval', FilterNumericInterval);
Vue.component('tainacan-filter-numeric-list-interval', FilterNumericListInterval);
Vue.component('tainacan-filter-date-interval', FilterDateInterval);
/* Filter Metadata Option forms */
Vue.component('tainacan-filter-form-numeric', FormFilterNumeric);
Vue.component('tainacan-filter-form-numeric-interval', FormFilterNumericInterval);
Vue.component('tainacan-filter-form-numeric-list-interval', FormFilterNumericListInterval);
// Vue.component('tainacan-filter-form-date', FormDate);
// Filter and Metadadum parent containers
// Metadadum parent containers
Vue.component('tainacan-form-item', TainacanFormItem);
Vue.component('tainacan-filter-item', TainacanFiltersList);
/* Others */
Vue.component('recursive-term-item', RecursiveTermItem);

View File

@ -73,17 +73,30 @@
margin-right: 0.5em;
display: flex;
}
.media-content {
width: 100%;
display: flex;
width: 80%;
.ellipsed-text {
overflow-x: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 3px;
transition: white-space .3s ease, overflow .3s ease;
}
}
.media-left+.media-content {
width: calc(100% - 32px);
}
}
&:hover {
.ellipsed-text {
overflow-x: visible !important;
white-space: normal !important;
word-wrap: break-word;
}
}
}
}

View File

@ -316,7 +316,7 @@
placement: 'auto-start',
popperClass: ['tainacan-tooltip', 'tooltip']
}"
class="ellipsed-text">
class="ellipsed-name">
{{ metadatum.name }}
</span>
</label>

View File

@ -126,11 +126,11 @@
color: var(--tainacan-white);
span:not(.ellipsed-text) {
span:not(.ellipsed-name) {
margin-right: 5px;
margin-left: -5px;
}
.ellipsed-text {
.ellipsed-name {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;

View File

@ -687,7 +687,6 @@
<script>
import FiltersTagsList from '../../../../admin/components/search/filters-tags-list.vue';
import FiltersItemsList from '../../../../admin/components/search/filters-items-list.vue';
import Pagination from '../../../../admin/components/search/pagination.vue'
import AdvancedSearch from '../../../../admin/components/search/advanced-search.vue';
import ExposersModal from '../../../../admin/components/modals/exposers-modal.vue';
@ -698,7 +697,6 @@
name: 'ThemeItemsPage',
components: {
FiltersTagsList,
FiltersItemsList,
Pagination,
AdvancedSearch,
ExposersModal

View File

@ -27,32 +27,9 @@ import cssVars from 'css-vars-ponyfill';
import qs from 'qs';
import VueBlurHash from 'vue-blurhash';
// Filters
import FilterNumeric from '../../../admin/components/filter-types/numeric/Numeric.vue';
import FilterDate from '../../../admin/components/filter-types/date/Date.vue';
import FilterSelectbox from '../../../admin/components/filter-types/selectbox/Selectbox.vue';
import FilterAutocomplete from '../../../admin/components/filter-types/autocomplete/Autocomplete.vue';
import FilterCheckbox from '../../../admin/components/filter-types/checkbox/Checkbox.vue';
import FilterTaginput from '../../../admin/components/filter-types/taginput/Taginput.vue';
import FilterTaxonomyCheckbox from '../../../admin/components/filter-types/taxonomy/Checkbox.vue';
import FilterTaxonomyTaginput from '../../../admin/components/filter-types/taxonomy/Taginput.vue';
import FilterDateInterval from '../../../admin/components/filter-types/date-interval/DateInterval.vue';
import FilterNumericInterval from '../../../admin/components/filter-types/numeric-interval/NumericInterval.vue';
import FilterNumericListInterval from '../../../admin/components/filter-types/numeric-list-interval/NumericListInterval.vue';
import TaincanFiltersList from '../../../admin/components/filter-types/tainacan-filter-item.vue';
import ThemeItemsPage from './theme-search/theme-items-page.vue';
import ThemeSearch from './theme.vue';
// View Modes
import ViewModeTable from './theme-search/components/view-mode-table.vue';
import ViewModeCards from './theme-search/components/view-mode-cards.vue';
import ViewModeRecords from './theme-search/components/view-mode-records.vue';
import ViewModeMasonry from './theme-search/components/view-mode-masonry.vue';
import ViewModeSlideshow from './theme-search/components/view-mode-slideshow.vue';
import ViewModeList from './theme-search/components/view-mode-list.vue';
import ViewModeMap from './theme-search/components/view-mode-map.vue';
// Remaining imports
import store from '../../../admin/js/store/store';
import routerTheme from './theme-search/js/theme-router.js';
@ -135,33 +112,49 @@ export default (element) => {
}
}
Vue.component('tainacan-filter-item', TaincanFiltersList);
// Filters logic
let possibleHideFilters = false;
if ( blockElement.attributes['hide-filters'] != undefined ) {
const hideFiltersValue = blockElement.attributes['hide-filters'].value;
possibleHideFilters = ( hideFiltersValue == true || hideFiltersValue == 'true' || hideFiltersValue == '1' || hideFiltersValue == 1 ) ? true : false;
}
/* Filters */
Vue.component('tainacan-filter-numeric', FilterNumeric);
Vue.component('tainacan-filter-date', FilterDate);
Vue.component('tainacan-filter-selectbox', FilterSelectbox);
Vue.component('tainacan-filter-autocomplete', FilterAutocomplete);
Vue.component('tainacan-filter-checkbox', FilterCheckbox);
Vue.component('tainacan-filter-taginput', FilterTaginput);
Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox);
Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput);
Vue.component('tainacan-filter-date-interval', FilterDateInterval);
Vue.component('tainacan-filter-numeric-interval', FilterNumericInterval);
Vue.component('tainacan-filter-numeric-list-interval', FilterNumericListInterval);
if ( !possibleHideFilters ) {
import('../../../admin/components/search/filters-items-list.vue')
.then(importedModule => Vue.component('filters-items-list', importedModule.default))
.catch(error => console.log(error));
}
/* Main page component */
Vue.component('theme-items-page', ThemeItemsPage);
Vue.component('theme-search', ThemeSearch);
// Oficial view modes
Vue.component('view-mode-table', ViewModeTable);
Vue.component('view-mode-cards', ViewModeCards);
Vue.component('view-mode-records', ViewModeRecords);
Vue.component('view-mode-masonry', ViewModeMasonry);
Vue.component('view-mode-slideshow', ViewModeSlideshow);
Vue.component('view-mode-list', ViewModeList);
Vue.component('view-mode-map', ViewModeMap);
// View Modes Logic
const registeredViewModes =
( tainacan_plugin && tainacan_plugin.registered_view_modes && tainacan_plugin.registered_view_modes.lenght ) ?
tainacan_plugin.registered_view_modes :
[ 'table', 'cards', 'records', 'masonry', 'slideshow', 'list', 'map' ];
// At first, we consider that all registered view modes are included.
let possibleViewModes = registeredViewModes;
if ( blockElement.attributes['enabled-view-modes'] != undefined )
possibleViewModes = blockElement.attributes['enabled-view-modes'].value.split(',');
// View Mode settings
let possibleDefaultViewMode = 'masonry';
if ( blockElement.attributes['default-view-mode'] != undefined)
possibleDefaultViewMode = blockElement.attributes['default-view-mode'].value;
if ( possibleViewModes.indexOf(possibleDefaultViewMode) < 0 )
possibleViewModes.push(possibleDefaultViewMode);
// Logic for dynamic importing Tainacan oficial view modes only if they are necessary
possibleViewModes.forEach(viewModeSlug => {
if ( registeredViewModes.indexOf(viewModeSlug) >= 0 )
import('./theme-search/components/view-mode-' + viewModeSlug + '.vue')
.then(importedModule => Vue.component('view-mode-' + viewModeSlug, importedModule.default) )
.catch(error => console.log(error));
});
Vue.use(eventBusSearch, { store: store, router: routerTheme});
@ -215,18 +208,6 @@ export default (element) => {
if (this.$el.attributes['taxonomy'] != undefined)
this.taxonomy = this.$el.attributes['taxonomy'].value;
// View Mode settings
if (this.$el.attributes['default-view-mode'] != undefined)
this.defaultViewMode = this.$el.attributes['default-view-mode'].value;
else
this.defaultViewMode = 'cards';
if (this.$el.attributes['is-forced-view-mode'] != undefined)
this.isForcedViewMode = new Boolean(this.$el.attributes['is-forced-view-mode'].value);
if (this.$el.attributes['enabled-view-modes'] != undefined)
this.enabledViewModes = this.$el.attributes['enabled-view-modes'].value.split(',');
// Sorting options
if (this.$el.attributes['default-order'] != undefined)
this.defaultOrder = this.$el.attributes['default-order'].value;
@ -239,9 +220,15 @@ export default (element) => {
if (this.$el.attributes['default-orderby-type'] != undefined)
this.defaultOrderByType = this.maybeConvertFromJSON(this.$el.attributes['default-orderby-type'].value);
// View modes settings
if (this.$el.attributes['is-forced-view-mode'] != undefined)
this.isForcedViewMode = new Boolean(this.$el.attributes['is-forced-view-mode'].value);
this.defaultViewMode = possibleDefaultViewMode;
this.enabledViewModes = possibleViewModes;
// Options related to hidding elements
if (this.$el.attributes['hide-filters'] != undefined)
this.hideFilters = this.isParameterTrue('hide-filters');
this.hideFilters = possibleHideFilters;
if (this.$el.attributes['hide-hide-filters-button'] != undefined)
this.hideHideFiltersButton = this.isParameterTrue('hide-hide-filters-button');
if (this.$el.attributes['hide-search'] != undefined)

View File

@ -1,11 +1,11 @@
<template>
<li
class="facet-list-item"
:class="(!showImage ? 'facet-without-image' : '') + (nameInsideImage ? ' facet-with-name-inside-image' : '') + ((appendChildTerms && facet.total_children > 0) ? ' facet-term-with-children': '')">
:class="(!showImage ? 'facet-without-image' : '') + (nameInsideImage ? ' facet-with-name-inside-image' : '') + (isCollapseInsteadOfLink(facet) ? ' facet-term-with-children': '')">
<a
:id="isNaN(facetId) ? facetId : 'facet-id-' + facetId"
:href="(appendChildTerms && facet.total_children > 0) ? null : ((linkTermFacetsToTermPage && isMetadatumTypeTaxonomy) ? facet.term_url : facet.url)"
@click="() => { (appendChildTerms && facet.total_children > 0) ? displayChildTerms(facetId) : null }"
:href="isCollapseInsteadOfLink(facet) ? null : ((linkTermFacetsToTermPage && isMetadatumTypeTaxonomy) ? facet.term_url : facet.url)"
@click="() => { isCollapseInsteadOfLink(facet) ? displayChildTerms(facetId) : null }"
:style="{ fontSize: layout == 'cloud' && facet.total_items ? + (1 + (cloudRate/4) * Math.log(facet.total_items)) + 'em' : ''}">
<img
v-if="isMetadatumTypeTaxonomy"
@ -45,7 +45,7 @@
</template>
</span>
</div>
<template v-if="appendChildTerms && facet.total_children > 0">
<template v-if="appendChildTerms && facet.total_children > 0 && (!childFacetsObject[facet.id != undefined ? facet.id : facet.value] || childFacetsObject[facet.id != undefined ? facet.id : facet.value].facets.length)">
<svg
v-if="childFacetsObject[facetId] && childFacetsObject[facetId].visible"
xmlns="http://www.w3.org/2000/svg"
@ -154,6 +154,9 @@ export default {
displayChildTerms(facetId) {
this.$emit('on-display-child-terms', facetId)
},
isCollapseInsteadOfLink(facet) {
return (this.appendChildTerms && facet.total_children > 0 && (!this.childFacetsObject[facet.id != undefined ? facet.id : facet.value] || this.childFacetsObject[facet.id != undefined ? facet.id : facet.value].facets.length) );
},
getSkeletonHeight() {
switch(this.layout) {
case 'grid':

View File

@ -30,6 +30,15 @@ class ImporterTests extends TAINACAN_UnitTestCase {
this->assertEquals( $collection->get_id(), $_SESSION['tainacan_importer'][$id]->collection->get_id() );
}*/
public function __construct(){
parent::__construct();
@session_start();
}
public function __destruct() {
session_write_close();
}
public function test_automapping_old_tainacan()
{
//$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();