Merge branch 'develop' into feature/483

This commit is contained in:
vnmedeiros 2021-04-26 14:33:49 -03:00
commit 9961ce062b
104 changed files with 4086 additions and 1138 deletions

2
.gitignore vendored
View File

@ -36,3 +36,5 @@ src/assets/css/tainacan-reports.css.map
src/.DS_Store src/.DS_Store
src/assets/css/tainacan-gutenberg-block-dynamic-items-list.css src/assets/css/tainacan-gutenberg-block-dynamic-items-list.css
src/assets/css/tainacan-gutenberg-block-dynamic-items-list.css.map src/assets/css/tainacan-gutenberg-block-dynamic-items-list.css.map
tests/wordpress-test
tests/wordpress-tests-lib

View File

@ -20,17 +20,23 @@ Tainacan is a software solution for building, managing and publishing digital re
### Features ### Features
**Easy installation**. As a WordPress plugin, Tainacan can be easily installed on and integrated to an existing WordPress website. #### Easy install
- As a WordPress plugin, Tainacan can be easily installed on and integrated to an existing WordPress website.
**Metadata and filters**. Use a metadata standard or choose whatever set of metadata you want to describe the items in your collections. You can choose which metadata will be used as a filter when browsing the collection. #### Metadata and filters
- Use standard metadata or choose whatever set of metadata you want to describe the items in your collections. You can choose which metadata will be used as a filter when browsing the collection.
**Faceted search**. Browse your collection (and let the public browse it) using a faceted search interface with the filters you have chosen. #### Faceted search
- Browse (and let the public browse it) your collection using a faceted search interface with filters you have chosen.
**Manage taxonomies**. Manage vocabularies that can be used accross all your collections. #### Manage taxonomies
- Manage vocabularies that can be used accross all your collections.
**Themes**. Tainacan [has its own default theme](https://wordpress.org/themes/tainacan-interface/), which helps you present your collections in a beautiful and effective way as it is developed to incorporate all of Tainacan functionalities. However, it will also work with any WordPress theme. For developers, it will be easy to add Tainacan specific features to an existing theme. #### Themes
- Tainacan [has its own default theme](https://wordpress.org/themes/tainacan-interface/), which helps you present your collections in a beautiful and effective way as it is developed to incorporate all of Tainacan functionalities. However, it will also work with any WordPress theme. For developers, it will be easy to add Tainacan specific features to an existing theme.
**API and interoperability**. Tainacan implements a RESTful API (read and write) to allow other applications to interact with your repository. Expose you collection in different formats, such as JSON, JSON-LD and OAI-PMH. If your collection uses a custom standard, you can map it to well-known stardards such as DublinCore. #### API and interoperability
- Tainacan implements a RESTful API (read and write) to allow other applications to interact with your repository. Expose you collection in different formats, such as JSON, JSON-LD and OAI-PMH. If your collection uses a custom standard, you can map it to well-known stardards such as DublinCore.
### Showcases ### Showcases

View File

@ -3,5 +3,3 @@
return [ return [
'tests_dir' => '/tmp/wordpress-tests-lib', 'tests_dir' => '/tmp/wordpress-tests-lib',
]; ];
?>

View File

@ -1,12 +1,11 @@
#!/bin/bash #!/bin/bash
## Run the build script whenever there is a change in src folder ## Runs build script whenever there is a change in src folder
echo 'Watching changes on src/' echo 'Watching changes on src/'
current_OS=`uname` current_OS=`uname`
# For macOS (Darwin) is needed fsevents-tools installed (you can use homebrew install fsevents-tools) # For macOS (Darwin), you can install fsevents-tools via Homebrew: `brew install fsevents-tools`
if [ $current_OS == "Darwin" ]; then if [ $current_OS == "Darwin" ]; then
echo echo
notifyloop src ./build.sh notifyloop src ./build.sh

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
# Loads user-defined variables at build-config file
source build-config.cfg source build-config.cfg
## Only run npm build if there was a change in a .js or .vue file ## Only run npm build if there was a change in a .js or .vue file

View File

@ -2,44 +2,46 @@
# Executa o comando 'sass' para verificar se existe (veja http://stackoverflow.com/a/677212/329911) # Executa o comando 'sass' para verificar se existe (veja http://stackoverflow.com/a/677212/329911)
command -v sass >/dev/null 2>&1 || { command -v sass >/dev/null 2>&1 || {
echo >&2 "SASS parece não está disponivel."; echo >&2 "Sass parece não estar disponivel.";
exit 1; exit 1;
} }
# Define o caminho.
echo "Compilando Sass..." echo "Compilando Sass..."
sass -E 'UTF-8' --cache-location .tmp/sass-cache-1 src/views/admin/scss/tainacan-admin.scss:src/assets/css/tainacan-admin.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-1 src/views/admin/scss/tainacan-admin.scss:src/assets/css/tainacan-admin.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-2 src/views/roles/tainacan-roles.scss:src/assets/css/tainacan-roles.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-2 src/views/roles/tainacan-roles.scss:src/assets/css/tainacan-roles.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-3 src/views/reports/tainacan-reports.scss:src/assets/css/tainacan-reports.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-3 src/views/reports/tainacan-reports.scss:src/assets/css/tainacan-reports.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-4 src/views/gutenberg-blocks/tainacan-collections/collections-list/collections-list.scss:src/assets/css/tainacan-gutenberg-block-collections-list.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-4 src/views/media-component/media-component.scss:src/assets/css/media-component.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-5 src/views/gutenberg-blocks/tainacan-collections/carousel-collections-list/carousel-collections-list.scss:src/assets/css/tainacan-gutenberg-block-carousel-collections-list.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-5 src/views/gutenberg-blocks/tainacan-collections/collections-list/collections-list.scss:src/assets/css/tainacan-gutenberg-block-collections-list.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-6 src/views/gutenberg-blocks/tainacan-items/items-list/items-list.scss:src/assets/css/tainacan-gutenberg-block-items-list.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-6 src/views/gutenberg-blocks/tainacan-collections/carousel-collections-list/carousel-collections-list.scss:src/assets/css/tainacan-gutenberg-block-carousel-collections-list.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-7 src/views/gutenberg-blocks/tainacan-items/dynamic-items-list/dynamic-items-list.scss:src/assets/css/tainacan-gutenberg-block-dynamic-items-list.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-7 src/views/gutenberg-blocks/tainacan-items/items-list/items-list.scss:src/assets/css/tainacan-gutenberg-block-items-list.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-8 src/views/gutenberg-blocks/tainacan-items/search-bar/search-bar.scss:src/assets/css/tainacan-gutenberg-block-search-bar.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-8 src/views/gutenberg-blocks/tainacan-items/dynamic-items-list/dynamic-items-list.scss:src/assets/css/tainacan-gutenberg-block-dynamic-items-list.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-9 src/views/gutenberg-blocks/tainacan-items/carousel-items-list/carousel-items-list.scss:src/assets/css/tainacan-gutenberg-block-carousel-items-list.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-9 src/views/gutenberg-blocks/tainacan-items/search-bar/search-bar.scss:src/assets/css/tainacan-gutenberg-block-search-bar.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-10 src/views/gutenberg-blocks/tainacan-items/carousel-items-list/carousel-items-list.scss:src/assets/css/tainacan-gutenberg-block-carousel-items-list.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-10 src/views/gutenberg-blocks/tainacan-items/carousel-items-list/carousel-items-list.scss:src/assets/css/tainacan-gutenberg-block-carousel-items-list.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-11 src/views/gutenberg-blocks/tainacan-terms/terms-list/terms-list.scss:src/assets/css/tainacan-gutenberg-block-terms-list.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-12 src/views/gutenberg-blocks/tainacan-items/carousel-items-list/carousel-items-list.scss:src/assets/css/tainacan-gutenberg-block-carousel-items-list.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-12 src/views/gutenberg-blocks/tainacan-facets/facets-list/facets-list.scss:src/assets/css/tainacan-gutenberg-block-facets-list.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-12 src/views/gutenberg-blocks/tainacan-terms/terms-list/terms-list.scss:src/assets/css/tainacan-gutenberg-block-terms-list.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-13 src/views/gutenberg-blocks/tainacan-terms/carousel-terms-list/carousel-terms-list.scss:src/assets/css/tainacan-gutenberg-block-carousel-terms-list.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-13 src/views/gutenberg-blocks/tainacan-facets/facets-list/facets-list.scss:src/assets/css/tainacan-gutenberg-block-facets-list.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-14 src/views/gutenberg-blocks/tainacan-facets/faceted-search/faceted-search.scss:src/assets/css/tainacan-gutenberg-block-faceted-search.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-14 src/views/gutenberg-blocks/tainacan-terms/carousel-terms-list/carousel-terms-list.scss:src/assets/css/tainacan-gutenberg-block-carousel-terms-list.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-15 src/views/gutenberg-blocks/tainacan-items/item-submission-form/item-submission-form.scss:src/assets/css/tainacan-gutenberg-block-item-submission-form.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-15 src/views/gutenberg-blocks/tainacan-facets/faceted-search/faceted-search.scss:src/assets/css/tainacan-gutenberg-block-faceted-search.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-16 src/views/gutenberg-blocks/gutenberg-blocks-style.scss:src/assets/css/tainacan-gutenberg-block-common-styles.css sass -E 'UTF-8' --cache-location .tmp/sass-cache-16 src/views/gutenberg-blocks/tainacan-items/item-submission-form/item-submission-form.scss:src/assets/css/tainacan-gutenberg-block-item-submission-form.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-17 src/views/gutenberg-blocks/gutenberg-blocks-style.scss:src/assets/css/tainacan-gutenberg-block-common-styles.css
echo "Compilação do Sass Concluído!" echo "Compilação do Sass Concluído!"
exit 0 exit 0

57
package-lock.json generated
View File

@ -2385,11 +2385,11 @@
} }
}, },
"buefy": { "buefy": {
"version": "0.9.4", "version": "0.9.7",
"resolved": "https://registry.npmjs.org/buefy/-/buefy-0.9.4.tgz", "resolved": "https://registry.npmjs.org/buefy/-/buefy-0.9.7.tgz",
"integrity": "sha512-LRSIYVNrKTPQhmNRegASkntX+ObtZ7aSSA/3cybDKXzGtPNy8g8cl2tp79Rl8/LBVH/KkRT5rmmzJ21nxz9IcQ==", "integrity": "sha512-Fli0ZjNDgtFtHm0LItWmfhNJ1oLjDwPzUWccvwXXoo2mADXaH8JQxyhY+drUuUV5/GMu5PtwqQSqPgZy942VZg==",
"requires": { "requires": {
"bulma": "0.9.1" "bulma": "0.9.2"
} }
}, },
"buffer": { "buffer": {
@ -2428,9 +2428,9 @@
"dev": true "dev": true
}, },
"bulma": { "bulma": {
"version": "0.9.1", "version": "0.9.2",
"resolved": "https://registry.npmjs.org/bulma/-/bulma-0.9.1.tgz", "resolved": "https://registry.npmjs.org/bulma/-/bulma-0.9.2.tgz",
"integrity": "sha512-LSF69OumXg2HSKl2+rN0/OEXJy7WFEb681wtBlNS/ulJYR27J3rORHibdXZ6GVb/vyUzzYK/Arjyh56wjbFedA==" "integrity": "sha512-e14EF+3VSZ488yL/lJH0tR8mFWiEQVCMi/BQUMi2TGMBOk+zrDg4wryuwm/+dRSHJw0gMawp2tsW7X1JYUCE3A=="
}, },
"bytes": { "bytes": {
"version": "3.0.0", "version": "3.0.0",
@ -3531,18 +3531,32 @@
"dev": true "dev": true
}, },
"elliptic": { "elliptic": {
"version": "6.5.3", "version": "6.5.4",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"bn.js": "^4.4.0", "bn.js": "^4.11.9",
"brorand": "^1.0.1", "brorand": "^1.1.0",
"hash.js": "^1.0.0", "hash.js": "^1.0.0",
"hmac-drbg": "^1.0.0", "hmac-drbg": "^1.0.1",
"inherits": "^2.0.1", "inherits": "^2.0.4",
"minimalistic-assert": "^1.0.0", "minimalistic-assert": "^1.0.1",
"minimalistic-crypto-utils": "^1.0.0" "minimalistic-crypto-utils": "^1.0.1"
},
"dependencies": {
"bn.js": {
"version": "4.12.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==",
"dev": true
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true
}
} }
}, },
"emoji-regex": { "emoji-regex": {
@ -7557,6 +7571,11 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
}, },
"photoswipe": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-4.1.3.tgz",
"integrity": "sha512-89Z43IRUyw7ycTolo+AaiDn3W1EEIfox54hERmm9bI12IB9cvRfHSHez3XhAyU8XW2EAFrC+2sKMhh7SJwn0bA=="
},
"pify": { "pify": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
@ -12017,9 +12036,9 @@
"dev": true "dev": true
}, },
"y18n": { "y18n": {
"version": "4.0.0", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ=="
}, },
"yallist": { "yallist": {
"version": "2.1.2", "version": "2.1.2",

View File

@ -9,15 +9,16 @@
}, },
"dependencies": { "dependencies": {
"apexcharts": "^3.24.0", "apexcharts": "^3.24.0",
"countup.js": "^2.0.7",
"axios": "^0.21.1", "axios": "^0.21.1",
"blurhash": "^1.1.3", "blurhash": "^1.1.3",
"buefy": "^0.9.4", "buefy": "^0.9.7",
"bulma": "^0.9.1", "bulma": "^0.9.2",
"countup.js": "^2.0.7",
"css-vars-ponyfill": "^2.3.1", "css-vars-ponyfill": "^2.3.1",
"mdi": "^2.2.43", "mdi": "^2.2.43",
"moment": "^2.25.3", "moment": "^2.25.3",
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"photoswipe": "^4.1.3",
"qs": "^6.9.4", "qs": "^6.9.4",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
echo "Running unit tests in PHPUnit..." echo "Running all unit tests [PHPUnit] ..."
phpunit phpunit

View File

@ -0,0 +1,896 @@
/*! PhotoSwipe main CSS by Dmitry Semenov | photoswipe.com | MIT license */
/*
Styles for basic PhotoSwipe functionality (sliding area, open/close transitions)
*/
/* pswp = photoswipe */
.pswp {
display: none;
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
overflow: hidden;
-ms-touch-action: none;
touch-action: none;
z-index: 9999999;
-webkit-text-size-adjust: 100%;
/* create separate layer, to avoid paint on window.onscroll in webkit/blink */
-webkit-backface-visibility: hidden;
outline: none; }
.pswp * {
box-sizing: border-box; }
.pswp img {
max-width: none; }
/* style is added when JS option showHideOpacity is set to true */
.pswp--animate_opacity {
/* 0.001, because opacity:0 doesn't trigger Paint action, which causes lag at start of transition */
opacity: 0.001;
will-change: opacity;
/* for open/close transition */
transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); }
.pswp--open {
display: block; }
.pswp--zoom-allowed .pswp__img {
/* autoprefixer: off */
cursor: -webkit-zoom-in;
cursor: -moz-zoom-in;
cursor: zoom-in; }
.pswp--zoomed-in .pswp__img {
/* autoprefixer: off */
cursor: -webkit-grab;
cursor: -moz-grab;
cursor: grab; }
.pswp--dragging .pswp__img {
/* autoprefixer: off */
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
cursor: grabbing; }
/*
Background is added as a separate element.
As animating opacity is much faster than animating rgba() background-color.
*/
.pswp__bg {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
opacity: 0;
transform: translateZ(0);
-webkit-backface-visibility: hidden;
will-change: opacity; }
.pswp__scroll-wrap {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: hidden; }
.pswp__container,
.pswp__zoom-wrap {
-ms-touch-action: none;
touch-action: none;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0; }
/* Prevent selection and tap highlights */
.pswp__container,
.pswp__img {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-touch-callout: none; }
.pswp__zoom-wrap {
position: absolute;
width: 100%;
-webkit-transform-origin: left top;
-moz-transform-origin: left top;
-ms-transform-origin: left top;
transform-origin: left top;
/* for open/close transition */
transition: transform 333ms cubic-bezier(0.4, 0, 0.22, 1); }
.pswp__bg {
will-change: opacity;
/* for open/close transition */
transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); }
.pswp--animated-in .pswp__bg,
.pswp--animated-in .pswp__zoom-wrap {
-webkit-transition: none;
transition: none; }
.pswp__container,
.pswp__zoom-wrap {
-webkit-backface-visibility: hidden; }
.pswp__item {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
overflow: hidden; }
.pswp__img {
position: absolute;
width: auto;
height: auto;
top: 0;
left: 0; }
/*
stretched thumbnail or div placeholder element (see below)
style is added to avoid flickering in webkit/blink when layers overlap
*/
.pswp__img--placeholder {
-webkit-backface-visibility: hidden; }
/*
div element that matches size of large image
large image loads on top of it
*/
.pswp__img--placeholder--blank {
background: #222; }
.pswp--ie .pswp__img {
width: 100% !important;
height: auto !important;
left: 0;
top: 0; }
/*
Error message appears when image is not loaded
(JS option errorMsg controls markup)
*/
.pswp__error-msg {
position: absolute;
left: 0;
top: 50%;
width: 100%;
text-align: center;
font-size: 14px;
line-height: 16px;
margin-top: -8px;
color: #CCC; }
.pswp__error-msg a {
color: #CCC;
text-decoration: underline; }
/*! PhotoSwipe Default UI CSS by Dmitry Semenov | photoswipe.com | MIT license */
/*
Contents:
1. Buttons
2. Share modal and links
3. Index indicator ("1 of X" counter)
4. Caption
5. Loading indicator
6. Additional styles (root element, top bar, idle state, hidden state, etc.)
*/
/*
1. Buttons
*/
/* <button> css reset */
.pswp__button {
width: 44px;
height: 44px;
position: relative;
background: none;
cursor: pointer;
overflow: visible;
-webkit-appearance: none;
display: block;
border: 0;
padding: 0;
margin: 0;
float: right;
opacity: 0.75;
transition: opacity 0.2s;
box-shadow: none; }
.pswp__button:focus, .pswp__button:hover {
opacity: 1; }
.pswp__button:active {
outline: none;
opacity: 0.9; }
.pswp__button::-moz-focus-inner {
padding: 0;
border: 0; }
/* pswp__ui--over-close class it added when mouse is over element that should close gallery */
.pswp__ui--over-close .pswp__button--close {
opacity: 1; }
.pswp__button,
.pswp__button--arrow--left:before,
.pswp__button--arrow--right:before {
background: url(../images/default-skin.png) 0 0 no-repeat;
background-size: 264px 88px;
width: 44px;
height: 44px; }
@media (-webkit-min-device-pixel-ratio: 1.1), (min-resolution: 105dpi), (min-resolution: 1.1dppx) {
/* Serve SVG sprite if browser supports SVG and resolution is more than 105dpi */
.pswp--svg .pswp__button,
.pswp--svg .pswp__button--arrow--left:before,
.pswp--svg .pswp__button--arrow--right:before {
background-image: url(../images/default-skin.svg); }
.pswp--svg .pswp__button--arrow--left,
.pswp--svg .pswp__button--arrow--right {
background: none; } }
.pswp__button--close {
background-position: 0 -44px; }
.pswp__button--share {
background-position: -44px -44px; }
.pswp__button--fs {
display: none; }
.pswp--supports-fs .pswp__button--fs {
display: block; }
.pswp--fs .pswp__button--fs {
background-position: -44px 0; }
.pswp__button--zoom {
display: none;
background-position: -88px 0; }
.pswp--zoom-allowed .pswp__button--zoom {
display: block; }
.pswp--zoomed-in .pswp__button--zoom {
background-position: -132px 0; }
/* no arrows on touch screens */
.pswp--touch .pswp__button--arrow--left,
.pswp--touch .pswp__button--arrow--right {
visibility: hidden; }
/*
Arrow buttons hit area
(icon is added to :before pseudo-element)
*/
.pswp__button--arrow--left,
.pswp__button--arrow--right {
background: none;
top: 50%;
margin-top: -50px;
width: 70px;
height: 100px;
position: absolute; }
.pswp__button--arrow--left {
left: 0; }
.pswp__button--arrow--right {
right: 0; }
.pswp__button--arrow--left:before,
.pswp__button--arrow--right:before {
content: '';
top: 35px;
background-color: rgba(0, 0, 0, 0.3);
height: 30px;
width: 32px;
position: absolute; }
.pswp__button--arrow--left:before {
left: 6px;
background-position: -138px -44px; }
.pswp__button--arrow--right:before {
right: 6px;
background-position: -94px -44px; }
/*
2. Share modal/popup and links
*/
.pswp__counter,
.pswp__share-modal {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none; }
.pswp__share-modal {
display: block;
background: rgba(0, 0, 0, 0.5);
width: 100%;
height: 100%;
top: 0;
left: 0;
padding: 10px;
position: absolute;
z-index: 10000099;
opacity: 0;
transition: opacity 0.25s ease-out;
-webkit-backface-visibility: hidden;
will-change: opacity; }
.pswp__share-modal--hidden {
display: none; }
.pswp__share-tooltip {
z-index: 10000119;
position: absolute;
background: #FFF;
top: 56px;
border-radius: 2px;
display: block;
width: auto;
right: 44px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
transform: translateY(6px);
transition: transform 0.25s;
-webkit-backface-visibility: hidden;
will-change: transform; }
.pswp__share-tooltip a {
display: block;
padding: 8px 12px;
color: #000;
text-decoration: none;
font-size: 14px;
line-height: 18px; }
.pswp__share-tooltip a:hover {
text-decoration: none;
color: #000; }
.pswp__share-tooltip a:first-child {
/* round corners on the first/last list item */
border-radius: 2px 2px 0 0; }
.pswp__share-tooltip a:last-child {
border-radius: 0 0 2px 2px; }
.pswp__share-modal--fade-in {
opacity: 1; }
.pswp__share-modal--fade-in .pswp__share-tooltip {
transform: translateY(0); }
/* increase size of share links on touch devices */
.pswp--touch .pswp__share-tooltip a {
padding: 16px 12px; }
a.pswp__share--facebook:before {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
top: -12px;
right: 15px;
border: 6px solid rgba(0, 0, 0, 0);
border-bottom-color: #FFF;
-webkit-pointer-events: none;
-moz-pointer-events: none;
pointer-events: none; }
a.pswp__share--facebook:hover {
background: #3E5C9A;
color: #FFF; }
a.pswp__share--facebook:hover:before {
border-bottom-color: #3E5C9A; }
a.pswp__share--twitter:hover {
background: #55ACEE;
color: #FFF; }
a.pswp__share--pinterest:hover {
background: #CCC;
color: #CE272D; }
a.pswp__share--download:hover {
background: #DDD; }
/*
3. Index indicator ("1 of X" counter)
*/
.pswp__counter {
position: absolute;
left: 0;
top: 0;
height: 44px;
font-size: 13px;
line-height: 44px;
color: #FFF;
opacity: 0.75;
padding: 0 10px; }
/*
4. Caption
*/
.pswp__caption {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
min-height: 44px; }
.pswp__caption small {
font-size: 11px;
color: #BBB; }
.pswp__caption__center {
text-align: left;
max-width: 420px;
margin: 0 auto;
font-size: 13px;
padding: 10px;
line-height: 20px;
color: #CCC; }
.pswp__caption--empty {
display: none; }
/* Fake caption element, used to calculate height of next/prev image */
.pswp__caption--fake {
visibility: hidden; }
/*
5. Loading indicator (preloader)
You can play with it here - http://codepen.io/dimsemenov/pen/yyBWoR
*/
.pswp__preloader {
width: 44px;
height: 44px;
position: absolute;
top: 0;
left: 50%;
margin-left: -22px;
opacity: 0;
transition: opacity 0.25s ease-out;
will-change: opacity;
direction: ltr; }
.pswp__preloader__icn {
width: 20px;
height: 20px;
margin: 12px; }
.pswp__preloader--active {
opacity: 1; }
.pswp__preloader--active .pswp__preloader__icn {
/* We use .gif in browsers that don't support CSS animation */
background: url(../images/preloader.gif) 0 0 no-repeat; }
.pswp--css_animation .pswp__preloader--active {
opacity: 1; }
.pswp--css_animation .pswp__preloader--active .pswp__preloader__icn {
animation: clockwise 500ms linear infinite; }
.pswp--css_animation .pswp__preloader--active .pswp__preloader__donut {
animation: donut-rotate 1000ms cubic-bezier(0.4, 0, 0.22, 1) infinite; }
.pswp--css_animation .pswp__preloader__icn {
background: none;
opacity: 0.75;
width: 14px;
height: 14px;
position: absolute;
left: 15px;
top: 15px;
margin: 0; }
.pswp--css_animation .pswp__preloader__cut {
/*
The idea of animating inner circle is based on Polymer ("material") loading indicator
by Keanu Lee https://blog.keanulee.com/2014/10/20/the-tale-of-three-spinners.html
*/
position: relative;
width: 7px;
height: 14px;
overflow: hidden; }
.pswp--css_animation .pswp__preloader__donut {
box-sizing: border-box;
width: 14px;
height: 14px;
border: 2px solid #FFF;
border-radius: 50%;
border-left-color: transparent;
border-bottom-color: transparent;
position: absolute;
top: 0;
left: 0;
background: none;
margin: 0; }
@media screen and (max-width: 1024px) {
.pswp__preloader {
position: relative;
left: auto;
top: auto;
margin: 0;
float: right; } }
@keyframes clockwise {
0% {
transform: rotate(0deg); }
100% {
transform: rotate(360deg); } }
@keyframes donut-rotate {
0% {
transform: rotate(0); }
50% {
transform: rotate(-140deg); }
100% {
transform: rotate(0); } }
/*
6. Additional styles
*/
/* root element of UI */
.pswp__ui {
-webkit-font-smoothing: auto;
visibility: visible;
opacity: 1;
z-index: 10000049; }
/* top black bar with buttons and "1 of X" indicator */
.pswp__top-bar {
position: absolute;
left: 0;
top: 0;
height: 44px;
width: 100%; }
.pswp__caption,
.pswp__top-bar,
.pswp--has_mouse .pswp__button--arrow--left,
.pswp--has_mouse .pswp__button--arrow--right {
-webkit-backface-visibility: hidden;
will-change: opacity;
transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); }
/* pswp--has_mouse class is added only when two subsequent mousemove events occur */
.pswp--has_mouse .pswp__button--arrow--left,
.pswp--has_mouse .pswp__button--arrow--right {
visibility: visible; }
.pswp__top-bar,
.pswp__caption {
background-color: rgba(0, 0, 0, 0.5); }
/* pswp__ui--fit class is added when main image "fits" between top bar and bottom bar (caption) */
.pswp__ui--fit .pswp__top-bar,
.pswp__ui--fit .pswp__caption {
background-color: rgba(0, 0, 0, 0.3); }
/* pswp__ui--idle class is added when mouse isn't moving for several seconds (JS option timeToIdle) */
.pswp__ui--idle .pswp__top-bar {
opacity: 0; }
.pswp__ui--idle .pswp__button--arrow--left,
.pswp__ui--idle .pswp__button--arrow--right {
opacity: 0; }
/*
pswp__ui--hidden class is added when controls are hidden
e.g. when user taps to toggle visibility of controls
*/
.pswp__ui--hidden .pswp__top-bar,
.pswp__ui--hidden .pswp__caption,
.pswp__ui--hidden .pswp__button--arrow--left,
.pswp__ui--hidden .pswp__button--arrow--right {
/* Force paint & create composition layer for controls. */
opacity: 0.001; }
/* pswp__ui--one-slide class is added when there is just one item in gallery */
.pswp__ui--one-slide .pswp__button--arrow--left,
.pswp__ui--one-slide .pswp__button--arrow--right,
.pswp__ui--one-slide .pswp__counter {
display: none; }
.pswp__element--disabled {
display: none !important; }
.pswp--minimal--dark .pswp__top-bar {
background: none; }
.tainacan-media-component {
--swiper-theme-color: var(--tainacan-secondary, #298596);
--swiper-navigation-size: 44px;
--tainacan-media-background: var(--tainacan-background-color, #ffffff);
--tainacan-media-main-carousel-height: 60vh;
--tainacan-media-main-carousel-width: 100%;
--tainacan-media-thumbs-carousel-width: 100%;
--tainacan-media-thumbs-carousel-item-size: 136px;
width: 100%;
height: auto;
display: block;
background-color: var(--tainacan-media-background, #ffffff); }
/* Style valid for both cases of carousel, main and thumbs */
.tainacan-media-component__swiper-main .swiper-button-prev::after,
.tainacan-media-component__swiper-main .swiper-container-rtl .swiper-button-next::after,
.tainacan-media-component__swiper-thumbs .swiper-button-prev::after,
.tainacan-media-component__swiper-thumbs .swiper-container-rtl .swiper-button-next::after {
content: 'previous'; }
.tainacan-media-component__swiper-main .swiper-button-next::after,
.tainacan-media-component__swiper-main .swiper-button-prev::after,
.tainacan-media-component__swiper-thumbs .swiper-button-next::after,
.tainacan-media-component__swiper-thumbs .swiper-button-prev::after {
font-family: "TainacanIcons";
opacity: 0.7;
transition: opacity ease 0.2s; }
.tainacan-media-component__swiper-main:hover .swiper-button-next::after,
.tainacan-media-component__swiper-main:hover .swiper-button-prev::after,
.tainacan-media-component__swiper-thumbs:hover .swiper-button-next::after,
.tainacan-media-component__swiper-thumbs:hover .swiper-button-prev::after {
opacity: 1; }
.tainacan-media-component__swiper-main ul.swiper-wrapper,
.tainacan-media-component__swiper-thumbs ul.swiper-wrapper {
list-style: none;
padding: 0; }
.tainacan-media-component__swiper-main {
width: 100%;
max-width: var(--tainacan-media-main-carousel-width, 100%); }
.tainacan-media-component__swiper-main ul.swiper-wrapper {
display: flex;
align-items: center;
margin-bottom: 30px; }
.tainacan-media-component__swiper-main ul.swiper-wrapper[data-pswp-uid] li.swiper-slide img {
cursor: zoom-in !important; }
.tainacan-media-component__swiper-main li.swiper-slide {
height: 100%;
max-width: calc(100% - var(--swiper-navigation-size, 44px) - var(--swiper-navigation-size, 44px));
min-width: 100%;
padding: 0 var(--swiper-navigation-size, 44px);
opacity: 1.0;
transition: opacity 0.2s linear; }
.tainacan-media-component__swiper-main li.swiper-slide:not(.swiper-slide-active) {
opacity: 0.75; }
.tainacan-media-component__swiper-main li.swiper-slide .swiper-slide-metadata {
text-align: center; }
.tainacan-media-component__swiper-main li.swiper-slide .swiper-slide-metadata.hide-name .swiper-slide-metadata__name {
display: none;
visibility: hidden; }
.tainacan-media-component__swiper-main li.swiper-slide .swiper-slide-metadata.hide-description .swiper-slide-metadata__description {
display: none;
visibility: hidden; }
.tainacan-media-component__swiper-main li.swiper-slide .swiper-slide-metadata.hide-caption .swiper-slide-metadata__caption {
display: none;
visibility: hidden; }
.tainacan-media-component__swiper-main li.swiper-slide .swiper-slide-metadata__name {
font-size: 1em;
font-weight: bold;
color: var(--tainacan-label-color, #454647); }
.tainacan-media-component__swiper-main li.swiper-slide .swiper-slide-metadata__caption {
font-size: 0.9375em;
color: var(--tainacan-input-color, #1d1d1d); }
.tainacan-media-component__swiper-main li.swiper-slide .swiper-slide-metadata__caption {
font-size: 0.875em;
color: var(--tainacan-info-color, #555758); }
.tainacan-media-component__swiper-main .swiper-slide-content {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column; }
.tainacan-media-component__swiper-main .swiper-slide-content .tainacan-embed-container {
width: 100%;
height: auto; }
.tainacan-media-component__swiper-main .swiper-slide-content iframe {
max-height: var(--tainacan-media-main-carousel-height, 60vh);
width: 100%;
max-width: 100%;
border: none;
display: block;
background-image: url("../images/preloader.gif");
background-repeat: no-repeat;
background-position: center; }
.tainacan-media-component__swiper-main .swiper-slide-content a:first-of-type,
.tainacan-media-component__swiper-main .swiper-slide-content p:first-of-type {
z-index: 99;
background: var(--tainacan-media-background, #ffffff);
border-radius: 3px;
word-wrap: break-word; }
.tainacan-media-component__swiper-main .swiper-slide-content audio {
background: black;
min-height: 38px;
border-radius: 20px;
width: 100%;
height: auto;
max-height: var(--tainacan-media-main-carousel-height, 60vh); }
.tainacan-media-component__swiper-main .swiper-slide-content video {
min-height: 56px;
width: 100%;
height: auto;
max-height: var(--tainacan-media-main-carousel-height, 60vh); }
.tainacan-media-component__swiper-main .swiper-slide-content img {
width: auto;
max-height: var(--tainacan-media-main-carousel-height, 60vh); }
.tainacan-media-component__swiper-thumbs {
width: 100%;
max-width: var(--tainacan-media-thumbs-carousel-width, 100%); }
.tainacan-media-component__swiper-thumbs ul.swiper-wrapper {
max-width: calc(100% - var(--swiper-navigation-size, 44px) - var(--swiper-navigation-size, 44px));
margin: 0 var(--swiper-navigation-size, 44px);
margin-bottom: 30px; }
.tainacan-media-component__swiper-thumbs li.swiper-slide {
text-align: center;
vertical-align: top;
word-break: break-all;
font-size: 0.875em;
max-width: calc(var(--tainacan-media-thumbs-carousel-item-size, 136px) + 17px);
cursor: zoom-in; }
@media only screen and (max-width: 380px) {
.tainacan-media-component__swiper-thumbs li.swiper-slide {
margin: 10px 0; } }
.tainacan-media-component__swiper-thumbs li.swiper-slide img {
width: var(--tainacan-media-thumbs-carousel-item-size, 136px);
height: var(--tainacan-media-thumbs-carousel-item-size, 136px);
max-width: var(--tainacan-media-thumbs-carousel-item-size, 136px);
max-height: var(--tainacan-media-thumbs-carousel-item-size, 136px);
object-fit: cover;
object-position: center;
border-bottom-width: 6px;
border-bottom-style: solid;
background-color: var(--tainacan-media-background, #ffffff);
border-bottom-color: rgba(255, 255, 255, 0);
opacity: 0.85;
transition: opacity 0.3s ease, border-bottom-color 0.3s ease; }
.tainacan-media-component__swiper-thumbs li.swiper-slide img:focus, .tainacan-media-component__swiper-thumbs li.swiper-slide img:hover {
opacity: 0.95;
outline: none;
border-bottom-color: var(--swiper-theme-color, #298596); }
.tainacan-media-component__swiper-thumbs li.swiper-slide.swiper-slide-thumb-active .swiper-slide-metadata__name {
font-weight: bold; }
.tainacan-media-component__swiper-thumbs li.swiper-slide.swiper-slide-thumb-active img {
opacity: 1.0;
border-bottom-color: var(--swiper-theme-color, #298596); }
.tainacan-media-component__swiper-thumbs li.swiper-slide .swiper-slide-metadata__name {
font-size: 1em;
color: var(--tainacan-label-color, #454647); }
.tainacan-media-component__swiper-thumbs li.swiper-slide .swiper-slide-metadata__caption {
font-size: 0.9375em;
color: var(--tainacan-input-color, #1d1d1d); }
.tainacan-media-component__swiper-thumbs li.swiper-slide .swiper-slide-metadata__caption {
font-size: 0.875em;
color: var(--tainacan-info-color, #555758); }
.tainacan-media-component__swiper-thumbs li.swiper-slide .swiper-slide-metadata {
text-align: center;
display: block;
margin-top: 0.5rem; }
.tainacan-media-component__swiper-thumbs li.swiper-slide .swiper-slide-metadata.hide-name .swiper-slide-metadata__name {
display: none;
visibility: hidden; }
.tainacan-media-component__swiper-thumbs li.swiper-slide .swiper-slide-metadata.hide-description .swiper-slide-metadata__description {
display: none;
visibility: hidden; }
.tainacan-media-component__swiper-thumbs li.swiper-slide .swiper-slide-metadata.hide-caption .swiper-slide-metadata__caption {
display: none;
visibility: hidden; }
.tainacan-media-component__swiper-thumbs li.swiper-slide a {
width: 100%;
max-width: var(--tainacan-media-thumbs-carousel-item-size, 136px);
text-align: center;
word-break: break-word; }
.tainacan-media-component__swiper-thumbs li.swiper-slide a,
.tainacan-media-component__swiper-thumbs li.swiper-slide a:focus,
.tainacan-media-component__swiper-thumbs li.swiper-slide a:hover {
outline: none;
text-decoration: none;
color: var(--tainacan-gray5, #454647); }
.tainacan-media-component__swiper-thumbs .swiper-start-border {
position: absolute;
height: 100%;
width: calc(32px + var(--swiper-navigation-size, 44px));
background-image: linear-gradient(90deg, var(--tainacan-media-background, #ffffff) 25%, transparent);
top: 0;
left: 0;
z-index: 1; }
.tainacan-media-component__swiper-thumbs .swiper-end-border {
position: absolute;
height: 100%;
width: calc(32px + var(--swiper-navigation-size, 44px));
background-image: linear-gradient(90deg, transparent, var(--tainacan-media-background, #ffffff) 75%);
top: 0;
right: 0;
z-index: 1; }
.tainacan-media-component__swiper-main + .tainacan-media-component__swiper-thumbs li.swiper-slide {
cursor: pointer; }
.tainacan-photoswipe-layer .pswp__bg {
background-color: rgba(0, 0, 0, 0.85); }
.tainacan-photoswipe-layer .pswp__ui--fit .pswp__top-bar,
.tainacan-photoswipe-layer .pswp__ui--fit .pswp__caption {
background-color: rgba(0, 0, 0, 0.7); }
.tainacan-photoswipe-layer .pswp__button--arrow--left::before,
.tainacan-photoswipe-layer .pswp__button--arrow--right::before {
background-color: rgba(0, 0, 0, 0.5); }
.tainacan-photoswipe-layer .pswp__container {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center; }
.tainacan-photoswipe-layer .pswp__container .attachment-without-image {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center; }
.tainacan-photoswipe-layer .pswp__container .attachment-without-image.tainacan-embed-container:not(.tainacan-embed-without-iframe) {
padding: 0px; }
.tainacan-photoswipe-layer .pswp__container .attachment-without-image .tainacan-embed-container .twitter-tweet {
width: 100vw !important; }
.tainacan-photoswipe-layer .pswp__container iframe {
padding: 44px;
min-height: 90vh;
max-height: 90vh;
height: 100%;
width: 100%;
max-width: 100%;
margin: 0 auto;
border: none;
display: block;
background-image: url("../images/preloader.gif");
background-repeat: no-repeat;
background-position: center; }
.tainacan-photoswipe-layer .pswp__container a:first-of-type,
.tainacan-photoswipe-layer .pswp__container p:first-of-type,
.tainacan-photoswipe-layer .pswp__container article:first-of-type {
z-index: 99;
padding: 1rem 4.33337vw;
background: var(--tainacan-media-background, #ffffff);
border-radius: var(--borderRadius, 3px);
word-wrap: break-word; }
.tainacan-photoswipe-layer .pswp__container audio {
background: black;
min-height: 38px;
border-radius: 20px; }
.tainacan-photoswipe-layer .pswp__container video {
min-height: 56px; }
.tainacan-photoswipe-layer .pswp__top-bar .pswp__name {
color: white;
text-align: center;
font-size: 1.125em;
display: block;
height: 44px;
max-width: calc(100% - 240px);
width: 100%;
left: 44px;
position: absolute;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 44px;
padding: 0 10px; }
.tainacan-photoswipe-layer .pswp__figure_caption {
font-size: 0.875em;
font-style: italic; }
.tainacan-photoswipe-layer .pswp__description {
font-size: 0.9375em; }
.tainacan-photoswipe-layer .pswp__caption__center {
text-align: center;
font-size: 1em;
max-width: 800px; }
/*# sourceMappingURL=media-component.css.map */

File diff suppressed because one or more lines are too long

View File

@ -8,12 +8,36 @@
.tainacan-embed-container:not(.tainacan-embed-without-iframe) { .tainacan-embed-container:not(.tainacan-embed-without-iframe) {
padding-bottom: 56.25%; padding-bottom: 56.25%;
padding-top: 30px; padding-top: 30px;
width: 100%;
margin: auto;
}
.tainacan-embed-container .twitter-tweet {
margin: 0 auto;
}
.tainacan-embed-container iframe.wp-embedded-content {
display: flex !important;
align-items: center;
justify-content: center;
margin: auto !important;
width: auto !important;
top: 50%;
bottom: 50%;
}
@media screen and (max-width: 1024px) {
.tainacan-embed-container iframe.wp-embedded-content {
position: relative;
}
}
.tainacan-embed-container #tainacan-attachment-iframe { /* PDF */
width: 100%;
} }
.tainacan-embed-container iframe, .tainacan-embed-container iframe,
.tainacan-embed-container object, .tainacan-embed-container object,
.tainacan-embed-container embed { .tainacan-embed-container embed {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0;
bottom: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;

View File

@ -269,6 +269,8 @@
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999; } z-index: 999; }
.wp-block-tainacan-carousel-collections-list ul.collections-list-edit li.collection-list-item button .dashicon {
margin: 0px; }
.wp-block-tainacan-carousel-collections-list ul.collections-list-edit li.collection-list-item:hover button { .wp-block-tainacan-carousel-collections-list ul.collections-list-edit li.collection-list-item:hover button {
height: auto; height: auto;
visibility: visible; visibility: visible;

File diff suppressed because one or more lines are too long

View File

@ -242,6 +242,8 @@
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999; } z-index: 999; }
.wp-block-tainacan-carousel-items-list ul.items-list-edit li.item-list-item button .dashicon {
margin: 0px; }
.wp-block-tainacan-carousel-items-list ul.items-list-edit li.item-list-item:hover button { .wp-block-tainacan-carousel-items-list ul.items-list-edit li.item-list-item:hover button {
height: auto; height: auto;
visibility: visible; visibility: visible;

File diff suppressed because one or more lines are too long

View File

@ -270,6 +270,8 @@
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999; } z-index: 999; }
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item button .dashicon {
margin: 0px; }
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item:hover button { .wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item:hover button {
height: auto; height: auto;
visibility: visible; visibility: visible;

File diff suppressed because one or more lines are too long

View File

@ -79,6 +79,8 @@
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999; } z-index: 999; }
.wp-block-tainacan-collections-list ul.collections-list-edit li.collection-list-item button .dashicon {
margin: 0px; }
.wp-block-tainacan-collections-list ul.collections-list-edit li.collection-list-item:hover button { .wp-block-tainacan-collections-list ul.collections-list-edit li.collection-list-item:hover button {
height: auto; height: auto;
visibility: visible; visibility: visible;

View File

@ -1,6 +1,6 @@
{ {
"version": 3, "version": 3,
"mappings": "AAEA,mCAAoC;EAChC,MAAM,EAAE,QAAQ;EAGhB,uDAAoB;IAChB,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,CAAC;EAIZ;gGAC2D;IACvD,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,CAAC;EAId;8FACyD;IACrD,qBAAqB,EAAE,wBAAwB;IAC/C,eAAe,EAAE,iBAAiB;IAClC,kBAAkB,EAAE,eAAe;IAEnC;mGAAG;MACC,UAAU,EAAE,YAAY;MACxB,YAAY,EAAE,YAAY;MAC1B,WAAW,EAAE,YAAY;MACzB,MAAM,EAAE,gBAAgB;MAExB;yGAAI;QACA,MAAM,EAAE,gBAAgB;QACxB,aAAa,EAAE,cAAc;EAIzC;sFACiD;IAC7C,OAAO,EAAE,CAAC;ICtCd,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,IAAI;IDqCT,gBAAgB,EAAE,6BAA6B;IAC/C,qBAAqB,EAAE,wBAAwB;IAC/C,QAAQ,EAAE,GAAG;IACb,eAAe,EAAE,YAAY;IAC7B,eAAe,EAAE,IAAI;IAErB;gHAAwB;MACpB,QAAQ,EAAE,QAAQ;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MAG1B;sHAAI;QACA,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,GAAG;QACZ,YAAY,EAAE,IAAI;MAItB;iJAA+B;QAC3B,OAAO,EAAE,IAAI;MAGjB;0HAAU;QACN,KAAK,EAAE,oCAAmC;QAC1C,eAAe,EAAE,IAAI;MAGzB,0CAA2C;QAnC/C;oHAAwB;UAoChB,SAAS,EAAE,gBAAgB;UAC3B,KAAK,EAAE,gBAAgB;MAG3B,0CAA2C;QAxC/C;oHAAwB;UAyChB,SAAS,EAAE,oBAAoB;UAC/B,KAAK,EAAE,oBAAoB;MAG/B,yCAA0C;QA7C9C;oHAAwB;UA8ChB,SAAS,EAAE,gBAAgB;UAC3B,KAAK,EAAE,gBAAgB;MAG3B,yCAA0C;QAlD9C;oHAAwB;UAmDhB,SAAS,EAAE,iBAAiB;UAC5B,KAAK,EAAE,iBAAiB",
"sources": ["../../views/gutenberg-blocks/tainacan-collections/collections-list/collections-list.scss","../../views/gutenberg-blocks/gutenberg-blocks-variables.scss"], "sources": ["../../views/gutenberg-blocks/tainacan-collections/collections-list/collections-list.scss","../../views/gutenberg-blocks/gutenberg-blocks-variables.scss"],
"names": [], "names": [],
"file": "tainacan-gutenberg-block-collections-list.css" "file": "tainacan-gutenberg-block-collections-list.css"

View File

@ -83,6 +83,8 @@
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999; } z-index: 999; }
.wp-block-tainacan-items-list ul.items-list-edit li.item-list-item button .dashicon {
margin: 0px; }
.wp-block-tainacan-items-list ul.items-list-edit li.item-list-item:hover button { .wp-block-tainacan-items-list ul.items-list-edit li.item-list-item:hover button {
height: auto; height: auto;
visibility: visible; visibility: visible;

View File

@ -1,6 +1,6 @@
{ {
"version": 3, "version": 3,
"mappings": "AAEA,6BAA8B;EAC1B,MAAM,EAAE,QAAQ;EAGhB,iDAAoB;IAChB,QAAQ,EAAE,QAAQ;IAClB,KAAK,E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CV,SAAS,EAAE,gBAAgB;UAC3B,KAAK,EAAE,gBAAgB;MAG3B,yCAA0C;QAjD9C;4FAAkB;UAkDV,SAAS,EAAE,iBAAiB;UAC5B,KAAK,EAAE,iBAAiB",
"sources": ["../../views/gutenberg-blocks/tainacan-items/items-list/items-list.scss","../../views/gutenberg-blocks/gutenberg-blocks-variables.scss"], "sources": ["../../views/gutenberg-blocks/tainacan-items/items-list/items-list.scss","../../views/gutenberg-blocks/gutenberg-blocks-variables.scss"],
"names": [], "names": [],
"file": "tainacan-gutenberg-block-items-list.css" "file": "tainacan-gutenberg-block-items-list.css"

View File

@ -64,6 +64,8 @@
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999; } z-index: 999; }
.wp-block-tainacan-terms-list ul.terms-list-edit li.term-list-item button .dashicon {
margin: 0px; }
.wp-block-tainacan-terms-list ul.terms-list-edit li.term-list-item:hover button { .wp-block-tainacan-terms-list ul.terms-list-edit li.term-list-item:hover button {
height: auto; height: auto;
visibility: visible; visibility: visible;

View File

@ -1,6 +1,6 @@
{ {
"version": 3, "version": 3,
"mappings": "AAEA,6BAA8B;EAC1B,MAAM,EAAE,QAAQ;EAGhB,iDAAoB;IAChB,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,CAAC;EAIZ;8EAC+C;IAC3C,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,CAAC;EAId;oEACqC;IACjC,OAAO,EAAE,CAAC;ICpBd,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,IAAI;IDmBT,gBAAgB,EAAE,6BAA6B;IAC/C,qBAAqB,EAAE,wBAAwB;IAC/C,QAAQ,EAAE,GAAG;IACb,eAAe,EAAE,YAAY;IAC7B,eAAe,EAAE,IAAI;IAErB;wFAAkB;MACd,QAAQ,EAAE,QAAQ;MAClB,OAAO,EAAE,KAAK;MACd,MAAM,EAAE,mBAAm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C;QAvC/C;4FAAkB;UAwCV,SAAS,EAAE,oBAAoB;UAC/B,KAAK,EAAE,oBAAoB;MAG/B,yCAA0C;QA5C9C;4FAAkB;UA6CV,SAAS,EAAE,gBAAgB;UAC3B,KAAK,EAAE,gBAAgB;MAG3B,yCAA0C;QAjD9C;4FAAkB;UAkDV,SAAS,EAAE,iBAAiB;UAC5B,KAAK,EAAE,iBAAiB",
"sources": ["../../views/gutenberg-blocks/tainacan-terms/terms-list/terms-list.scss","../../views/gutenberg-blocks/gutenberg-blocks-variables.scss"], "sources": ["../../views/gutenberg-blocks/tainacan-terms/terms-list/terms-list.scss","../../views/gutenberg-blocks/gutenberg-blocks-variables.scss"],
"names": [], "names": [],
"file": "tainacan-gutenberg-block-terms-list.css" "file": "tainacan-gutenberg-block-terms-list.css"

View File

@ -16,7 +16,6 @@ body:not([class]) > iframe {
min-height: 80vh; min-height: 80vh;
border: none; border: none;
} }
body:not([class]) > audio,
body:not([class]) > video { body:not([class]) > video {
width: 100%; width: 100%;
height: auto; height: auto;
@ -25,6 +24,11 @@ body:not([class]) > video {
} }
body:not([class]) > audio { body:not([class]) > audio {
width: 100%; width: 100%;
height: auto;
border-radius: 20px;
background: black;
min-height: 38px;
max-height: 100%;
} }
body:not([class]) > a, body:not([class]) > a,
body:not([class]) > p { body:not([class]) > p {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg39"
version="1.1"
viewBox="0 0 264 88"
height="88"
width="264">
<metadata
id="metadata45">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>default-skin 2</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs43" />
<title
id="title2">default-skin 2</title>
<path
id="Shape"
d="m 67.002,59.5 v 3.768 C 60.695,64.108 57.818,69.018 57,73 59.22,70.17 62.564,67.902 67.002,67.902 V 71.5 L 73,65.585 Z"
style="fill:#ffffff;fill-rule:evenodd" />
<g
style="fill:#ffffff;fill-rule:evenodd"
id="g7">
<path
id="path5"
d="m 13,29 v -5 h 2 v 3 h 3 v 2 z m 0,-14 h 5 v 2 h -3 v 3 h -2 z m 18,0 v 5 h -2 v -3 h -3 v -2 z m 0,14 h -5 v -2 h 3 v -3 h 2 z" />
</g>
<g
style="fill:#ffffff;fill-rule:evenodd"
id="g11">
<path
id="path9"
d="m 62,24 v 5 h -2 v -3 h -3 v -2 z m 0,-4 h -5 v -2 h 3 v -3 h 2 z m 8,0 v -5 h 2 v 3 h 3 v 2 z m 0,4 h 5 v 2 h -3 v 3 h -2 z" />
</g>
<path
id="path13"
d="M 20.586,66 14.93,60.344 16.344,58.93 22,64.586 27.656,58.93 29.07,60.344 23.414,66 29.07,71.656 27.656,73.07 22,67.414 16.344,73.07 14.93,71.656 Z"
style="fill:#ffffff;fill-rule:evenodd" />
<path
id="path15"
d="m 108.09738,65.891437 -2.03999,-1.748574 c 1.38784,-1.589364 1.3957,-1.596523 4.44849,-5.142894 -2.91228,-3.313711 -2.89516,-3.3306 -4.44849,-5.142833 L 108.09738,52.179419 114.05739,59 Z"
style="fill:#ffffff;fill-rule:evenodd;stroke-width:1.14285851" />
<path
id="path17"
d="m 155.5635,65.896657 2.04,-1.748571 c -1.49112,-1.796968 -1.49059,-1.799812 -4.33482,-5.142858 3.02761,-3.609572 3.02493,-3.60229 4.33482,-5.142857 l -2.04,-1.677714 -5.96,6.820571 z"
style="fill:#ffffff;fill-rule:evenodd;stroke-width:1.14285719" />
<g
id="g23"
style="fill:none;fill-rule:evenodd">
<path
style="fill:#ffffff"
d="m 160.957,28.543 -3.25,-3.25 -1.413,1.414 3.25,3.25 z"
id="Rectangle-11" />
<path
style="stroke:#ffffff;stroke-width:1.5"
id="Oval-1"
d="m 152.5,27 c 3.038,0 5.5,-2.462 5.5,-5.5 0,-3.038 -2.462,-5.5 -5.5,-5.5 -3.038,0 -5.5,2.462 -5.5,5.5 0,3.038 2.462,5.5 5.5,5.5 z" />
<path
style="fill:#ffffff"
id="path21"
d="m 150,21 h 5 v 1 h -5 z" />
</g>
<g
id="g33"
style="fill:none;fill-rule:evenodd">
<path
style="fill:#ffffff"
id="path25"
d="m 116.957,28.543 -1.414,1.414 -3.25,-3.25 1.414,-1.414 z" />
<path
style="stroke:#ffffff;stroke-width:1.5"
id="path27"
d="m 108.5,27 c 3.038,0 5.5,-2.462 5.5,-5.5 0,-3.038 -2.462,-5.5 -5.5,-5.5 -3.038,0 -5.5,2.462 -5.5,5.5 0,3.038 2.462,5.5 5.5,5.5 z" />
<path
style="fill:#ffffff"
id="path29"
d="m 106,21 h 5 v 1 h -5 z" />
<path
style="fill:#ffffff"
id="path31"
d="m 109.043,19.008 -0.085,5 -1,-0.017 0.085,-5 z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

View File

@ -4,7 +4,6 @@ namespace Tainacan\API;
class REST_Controller extends \WP_REST_Controller { class REST_Controller extends \WP_REST_Controller {
/** /**
* REST_Controller constructor. * REST_Controller constructor.
*/ */
@ -624,7 +623,6 @@ class REST_Controller extends \WP_REST_Controller {
} }
function get_permissions_schema() { function get_permissions_schema() {
return [ return [
@ -655,5 +653,3 @@ class REST_Controller extends \WP_REST_Controller {
} }
} }
?>

View File

@ -231,7 +231,6 @@ class REST_Background_Processes_Controller extends REST_Controller {
$result = $this->prepare_item_for_response($result, $request); $result = $this->prepare_item_for_response($result, $request);
return new \WP_REST_Response( $result, 200 ); return new \WP_REST_Response( $result, 200 );
} }
public function prepare_item_for_response($item, $request) { public function prepare_item_for_response($item, $request) {
@ -309,8 +308,6 @@ class REST_Background_Processes_Controller extends REST_Controller {
$result = $this->prepare_item_for_response($result, $request); $result = $this->prepare_item_for_response($result, $request);
return new \WP_REST_Response( $result, 200 ); return new \WP_REST_Response( $result, 200 );
} }
public function delete_item( $request ) { public function delete_item( $request ) {
@ -334,7 +331,6 @@ class REST_Background_Processes_Controller extends REST_Controller {
// TODO: delete log files // TODO: delete log files
return new \WP_REST_Response( $result, 200 ); return new \WP_REST_Response( $result, 200 );
} }
public function get_log_url($id, $action, $type = '') { public function get_log_url($id, $action, $type = '') {
@ -352,7 +348,6 @@ class REST_Background_Processes_Controller extends REST_Controller {
$logs_url = $upload_url . 'tainacan/' . $filename; $logs_url = $upload_url . 'tainacan/' . $filename;
return $logs_url; return $logs_url;
} }
} }

View File

@ -13,79 +13,79 @@ use Tainacan\Entities\Collection;
* @uses Entities\Collection and Repositories\Collections * @uses Entities\Collection and Repositories\Collections
* */ * */
class REST_Collections_Controller extends REST_Controller { class REST_Collections_Controller extends REST_Controller {
private $collections_repository; private $collections_repository;
private $collection; private $collection;
/** /**
* REST_Collections_Controller constructor. * REST_Collections_Controller constructor.
* Define the namespace, rest base and instantiate your attributes. * Define the namespace, rest base and instantiate your attributes.
*/ */
public function __construct(){ public function __construct(){
$this->rest_base = 'collections'; $this->rest_base = 'collections';
parent::__construct(); parent::__construct();
add_action('init', array(&$this, 'init_objects'), 11); add_action('init', array(&$this, 'init_objects'), 11);
} }
/** /**
* Initialize objects after post_type register * Initialize objects after post_type register
*/ */
public function init_objects() { public function init_objects() {
$this->collections_repository = Repositories\Collections::get_instance(); $this->collections_repository = Repositories\Collections::get_instance();
$this->collection = new Entities\Collection(); $this->collection = new Entities\Collection();
} }
/** /**
* Register the collections route and their endpoints * Register the collections route and their endpoints
*/ */
public function register_routes(){ public function register_routes(){
register_rest_route($this->namespace, '/' . $this->rest_base, array( register_rest_route($this->namespace, '/' . $this->rest_base, array(
array( array(
'methods' => \WP_REST_Server::READABLE, 'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_items'), 'callback' => array($this, 'get_items'),
'permission_callback' => array($this, 'get_items_permissions_check'), 'permission_callback' => array($this, 'get_items_permissions_check'),
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE), 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE),
), ),
array( array(
'methods' => \WP_REST_Server::CREATABLE, 'methods' => \WP_REST_Server::CREATABLE,
'callback' => array($this, 'create_item'), 'callback' => array($this, 'create_item'),
'permission_callback' => array($this, 'create_item_permissions_check'), 'permission_callback' => array($this, 'create_item_permissions_check'),
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE), 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
), ),
'schema' => [$this, 'get_schema'], 'schema' => [$this, 'get_schema'],
)); ));
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<collection_id>[\d]+)', array( register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<collection_id>[\d]+)', array(
array( array(
'methods' => \WP_REST_Server::READABLE, 'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_item'), 'callback' => array($this, 'get_item'),
'permission_callback' => array($this, 'get_item_permissions_check'), 'permission_callback' => array($this, 'get_item_permissions_check'),
'args' => $this->get_wp_query_params(), 'args' => $this->get_wp_query_params(),
), ),
array( array(
'methods' => \WP_REST_Server::EDITABLE, 'methods' => \WP_REST_Server::EDITABLE,
'callback' => array($this, 'update_item'), 'callback' => array($this, 'update_item'),
'permission_callback' => array($this, 'update_item_permissions_check'), 'permission_callback' => array($this, 'update_item_permissions_check'),
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE), 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE),
), ),
array( array(
'methods' => \WP_REST_Server::DELETABLE, 'methods' => \WP_REST_Server::DELETABLE,
'callback' => array($this, 'delete_item'), 'callback' => array($this, 'delete_item'),
'permission_callback' => array($this, 'delete_item_permissions_check'), 'permission_callback' => array($this, 'delete_item_permissions_check'),
'args' => array( 'args' => array(
'permanently' => array( 'permanently' => array(
'description' => __('To delete permanently, you can pass \'permanently\' as 1. By default this will only trash collection'), 'description' => __('To delete permanently, you can pass \'permanently\' as 1. By default this will only trash collection'),
'default' => '0', 'default' => '0',
), ),
) )
), ),
'schema' => [$this, 'get_schema'], 'schema' => [$this, 'get_schema'],
)); ));
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<collection_id>[\d]+)/metadata_order', array( register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<collection_id>[\d]+)/metadata_order', array(
array( array(
'methods' => \WP_REST_Server::EDITABLE, 'methods' => \WP_REST_Server::EDITABLE,
'callback' => array($this, 'update_metadata_order'), 'callback' => array($this, 'update_metadata_order'),
'permission_callback' => array($this, 'update_metadata_order_permissions_check'), 'permission_callback' => array($this, 'update_metadata_order_permissions_check'),
'args' => [ 'args' => [
'metadata_order' => [ 'metadata_order' => [
'description' => __( 'The order of the metadata in the collection, an array of objects with integer id and bool enabled.', 'tainacan' ), 'description' => __( 'The order of the metadata in the collection, an array of objects with integer id and bool enabled.', 'tainacan' ),
'required' => true, 'required' => true,
@ -96,11 +96,11 @@ class REST_Collections_Controller extends REST_Controller {
'schema' => [$this, 'get_schema'], 'schema' => [$this, 'get_schema'],
)); ));
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<collection_id>[\d]+)/filters_order', array( register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<collection_id>[\d]+)/filters_order', array(
array( array(
'methods' => \WP_REST_Server::EDITABLE, 'methods' => \WP_REST_Server::EDITABLE,
'callback' => array($this, 'update_filters_order'), 'callback' => array($this, 'update_filters_order'),
'permission_callback' => array($this, 'update_filters_order_permissions_check'), 'permission_callback' => array($this, 'update_filters_order_permissions_check'),
'args' => [ 'args' => [
'filters_order' => [ 'filters_order' => [
'description' => __( 'The order of the filters in the collection, an array of objects with integer id and bool enabled.', 'tainacan' ), 'description' => __( 'The order of the filters in the collection, an array of objects with integer id and bool enabled.', 'tainacan' ),
'required' => true, 'required' => true,
@ -109,8 +109,8 @@ class REST_Collections_Controller extends REST_Controller {
], ],
), ),
'schema' => [$this, 'get_schema'], 'schema' => [$this, 'get_schema'],
)); ));
} }
/** /**
* Return a array of Collections objects in JSON * Return a array of Collections objects in JSON
@ -123,7 +123,7 @@ class REST_Collections_Controller extends REST_Controller {
public function get_items($request){ public function get_items($request){
$args = $this->prepare_filters($request); $args = $this->prepare_filters($request);
$collections = $this->collections_repository->fetch($args); $collections = $this->collections_repository->fetch($args);
$response = []; $response = [];
if($collections->have_posts()){ if($collections->have_posts()){
@ -141,17 +141,17 @@ class REST_Collections_Controller extends REST_Controller {
$total_collections = $collections->found_posts; $total_collections = $collections->found_posts;
$max_pages = ceil($total_collections / (int) $collections->query_vars['posts_per_page']); $max_pages = ceil($total_collections / (int) $collections->query_vars['posts_per_page']);
$rest_response = new \WP_REST_Response($response, 200); $rest_response = new \WP_REST_Response($response, 200);
$rest_response->header('X-WP-Total', (int) $total_collections); $rest_response->header('X-WP-Total', (int) $total_collections);
$rest_response->header('X-WP-TotalPages', (int) $max_pages); $rest_response->header('X-WP-TotalPages', (int) $max_pages);
$total_collections = wp_count_posts( 'tainacan-collection', 'readable' ); $total_collections = wp_count_posts( 'tainacan-collection', 'readable' );
if (isset($total_collections->publish) || if (isset($total_collections->publish) ||
isset($total_collections->private) || isset($total_collections->private) ||
isset($total_collections->trash) || isset($total_collections->trash) ||
isset($total_collections->draft)) { isset($total_collections->draft)) {
$rest_response->header('X-Tainacan-total-collections-trash', $total_collections->trash); $rest_response->header('X-Tainacan-total-collections-trash', $total_collections->trash);
$rest_response->header('X-Tainacan-total-collections-publish', $total_collections->publish); $rest_response->header('X-Tainacan-total-collections-publish', $total_collections->publish);
@ -159,8 +159,8 @@ class REST_Collections_Controller extends REST_Controller {
$rest_response->header('X-Tainacan-total-collections-private', $total_collections->private); $rest_response->header('X-Tainacan-total-collections-private', $total_collections->private);
} }
return $rest_response; return $rest_response;
} }
/** /**
* Return a Collection object in JSON * Return a Collection object in JSON
@ -170,13 +170,13 @@ class REST_Collections_Controller extends REST_Controller {
* @return \WP_Error|\WP_REST_Response * @return \WP_Error|\WP_REST_Response
*/ */
public function get_item($request){ public function get_item($request){
$collection_id = $request['collection_id']; $collection_id = $request['collection_id'];
$collection = $this->collections_repository->fetch($collection_id); $collection = $this->collections_repository->fetch($collection_id);
$response = $this->prepare_item_for_response($collection, $request ); $response = $this->prepare_item_for_response($collection, $request );
return new \WP_REST_Response($response, 200); return new \WP_REST_Response($response, 200);
} }
/** /**
* *
@ -188,14 +188,14 @@ class REST_Collections_Controller extends REST_Controller {
* @return mixed|string|void|\WP_Error|\WP_REST_Response * @return mixed|string|void|\WP_Error|\WP_REST_Response
*/ */
public function prepare_item_for_response($item, $request){ public function prepare_item_for_response($item, $request){
if(!empty($item)){ if(!empty($item)){
if(!isset($request['fetch_only'])) { if(!isset($request['fetch_only'])) {
$item_arr = $item->_toArray(); $item_arr = $item->_toArray();
if ( $request['context'] === 'edit' ) { if ( $request['context'] === 'edit' ) {
$item_arr['current_user_can_edit'] = $item->can_edit(); $item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete(); $item_arr['current_user_can_delete'] = $item->can_delete();
$collection_caps = \tainacan_roles()->get_collection_caps_slugs(); $collection_caps = \tainacan_roles()->get_collection_caps_slugs();
@ -208,24 +208,24 @@ class REST_Collections_Controller extends REST_Controller {
$item_arr[$cap_key] = current_user_can( $cap_check ); $item_arr[$cap_key] = current_user_can( $cap_check );
} }
} }
} else { } else {
$attributes_to_filter = $request['fetch_only']; $attributes_to_filter = $request['fetch_only'];
# Always returns id # Always returns id
if(is_array($attributes_to_filter)) { if(is_array($attributes_to_filter)) {
$attributes_to_filter[] = 'id'; $attributes_to_filter[] = 'id';
} elseif(!strstr($attributes_to_filter, ',')){ } elseif(!strstr($attributes_to_filter, ',')){
$attributes_to_filter = array($attributes_to_filter, 'id'); $attributes_to_filter = array($attributes_to_filter, 'id');
} else { } else {
$attributes_to_filter .= ',id'; $attributes_to_filter .= ',id';
} }
$item_arr = $this->filter_object_by_attributes($item, $attributes_to_filter); $item_arr = $this->filter_object_by_attributes($item, $attributes_to_filter);
if ( $request['context'] === 'edit' ) { if ( $request['context'] === 'edit' ) {
$item_arr['current_user_can_edit'] = $item->can_edit(); $item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete(); $item_arr['current_user_can_delete'] = $item->can_delete();
$collection_caps = \tainacan_roles()->get_collection_caps_slugs(); $collection_caps = \tainacan_roles()->get_collection_caps_slugs();
@ -307,10 +307,10 @@ class REST_Collections_Controller extends REST_Controller {
} }
return $item_arr; return $item_arr;
} }
return $item; return $item;
} }
/** /**
* *
@ -391,8 +391,8 @@ class REST_Collections_Controller extends REST_Controller {
* @throws \Exception * @throws \Exception
*/ */
public function create_item_permissions_check( $request ) { public function create_item_permissions_check( $request ) {
return current_user_can($this->collections_repository->get_capabilities()->edit_posts); return current_user_can($this->collections_repository->get_capabilities()->edit_posts);
} }
/** /**
* Prepare collection for insertion on database * Prepare collection for insertion on database
@ -408,8 +408,8 @@ class REST_Collections_Controller extends REST_Controller {
if(method_exists($this->collection, $set_)) $this->collection->$set_($value); if(method_exists($this->collection, $set_)) $this->collection->$set_($value);
} }
return $this->collection; return $this->collection;
} }
/** /**
* Delete a collection * Delete a collection
@ -424,9 +424,9 @@ class REST_Collections_Controller extends REST_Controller {
if(! $collection instanceof Entities\Collection) { if(! $collection instanceof Entities\Collection) {
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Collection with this ID was not found', 'tainacan' ), 'error_message' => __('Collection with this ID was not found', 'tainacan' ),
'collection_id' => $collection_id 'collection_id' => $collection_id
], 400); ], 400);
} }
if($permanently == true) { if($permanently == true) {
@ -438,7 +438,7 @@ class REST_Collections_Controller extends REST_Controller {
$prepared_collection = $this->prepare_item_for_response($collection, $request); $prepared_collection = $this->prepare_item_for_response($collection, $request);
return new \WP_REST_Response($prepared_collection, 200); return new \WP_REST_Response($prepared_collection, 200);
} }
/** /**
* Verify if current user has permission to delete a collection * Verify if current user has permission to delete a collection
@ -456,7 +456,7 @@ class REST_Collections_Controller extends REST_Controller {
} }
return false; return false;
} }
/** /**
* Update a collection * Update a collection
@ -466,48 +466,48 @@ class REST_Collections_Controller extends REST_Controller {
* @return string|\WP_Error|\WP_REST_Response * @return string|\WP_Error|\WP_REST_Response
*/ */
public function update_item( $request ) { public function update_item( $request ) {
$collection_id = $request['collection_id']; $collection_id = $request['collection_id'];
$body = json_decode($request->get_body(), true); $body = json_decode($request->get_body(), true);
if(!empty($body)){ if(!empty($body)){
$attributes = []; $attributes = [];
foreach ($body as $att => $value){ foreach ($body as $att => $value){
$attributes[$att] = $value; $attributes[$att] = $value;
} }
$collection = $this->collections_repository->fetch($collection_id); $collection = $this->collections_repository->fetch($collection_id);
if($collection) { if($collection) {
$prepared_collection = $this->prepare_item_for_updating( $collection, $attributes ); $prepared_collection = $this->prepare_item_for_updating( $collection, $attributes );
if ( $prepared_collection->validate() ) { if ( $prepared_collection->validate() ) {
$updated_collection = $this->collections_repository->update( $collection ); $updated_collection = $this->collections_repository->update( $collection );
$response = $this->prepare_item_for_response($updated_collection, $request); $response = $this->prepare_item_for_response($updated_collection, $request);
return new \WP_REST_Response( $response, 200 ); return new \WP_REST_Response( $response, 200 );
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('One or more values are invalid.', 'tainacan'), 'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $prepared_collection->get_errors(), 'errors' => $prepared_collection->get_errors(),
'collection' => $this->prepare_item_for_response($prepared_collection, $request) 'collection' => $this->prepare_item_for_response($prepared_collection, $request)
], 400); ], 400);
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Collection with this ID was not found', 'tainacan' ), 'error_message' => __('Collection with this ID was not found', 'tainacan' ),
'collection_id' => $collection_id 'collection_id' => $collection_id
], 400); ], 400);
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('The body could not be empty', 'tainacan'), 'error_message' => __('The body could not be empty', 'tainacan'),
'body' => $body 'body' => $body
], 400); ], 400);
} }
/** /**
@ -557,43 +557,43 @@ class REST_Collections_Controller extends REST_Controller {
* @return string|\WP_Error|\WP_REST_Response * @return string|\WP_Error|\WP_REST_Response
*/ */
public function update_metadata_order( $request ) { public function update_metadata_order( $request ) {
$collection_id = $request['collection_id']; $collection_id = $request['collection_id'];
$body = json_decode($request->get_body(), true); $body = json_decode($request->get_body(), true);
if( !empty($body) && isset($body['metadata_order']) ) { if( !empty($body) && isset($body['metadata_order']) ) {
$collection = $this->collections_repository->fetch($collection_id); $collection = $this->collections_repository->fetch($collection_id);
if( $collection instanceof Entities\Collection) { if( $collection instanceof Entities\Collection) {
$collection->set_metadata_order( $body['metadata_order'] ); $collection->set_metadata_order( $body['metadata_order'] );
if ( $collection->validate() ) { if ( $collection->validate() ) {
$updated_collection = $this->collections_repository->update( $collection ); $updated_collection = $this->collections_repository->update( $collection );
$response = $this->prepare_item_for_response($updated_collection, $request); $response = $this->prepare_item_for_response($updated_collection, $request);
return new \WP_REST_Response( $response, 200 ); return new \WP_REST_Response( $response, 200 );
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('One or more values are invalid.', 'tainacan'), 'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $collection->get_errors(), 'errors' => $collection->get_errors(),
'collection' => $this->prepare_item_for_response($collection, $request) 'collection' => $this->prepare_item_for_response($collection, $request)
], 400); ], 400);
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Collection with this ID was not found', 'tainacan' ), 'error_message' => __('Collection with this ID was not found', 'tainacan' ),
'collection_id' => $collection_id 'collection_id' => $collection_id
], 400); ], 400);
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('The body could not be empty', 'tainacan'), 'error_message' => __('The body could not be empty', 'tainacan'),
'body' => $body 'body' => $body
], 400); ], 400);
} }
/** /**
@ -622,43 +622,43 @@ class REST_Collections_Controller extends REST_Controller {
* @return string|\WP_Error|\WP_REST_Response * @return string|\WP_Error|\WP_REST_Response
*/ */
public function update_filters_order( $request ) { public function update_filters_order( $request ) {
$collection_id = $request['collection_id']; $collection_id = $request['collection_id'];
$body = json_decode($request->get_body(), true); $body = json_decode($request->get_body(), true);
if( !empty($body) && isset($body['filters_order']) ) { if( !empty($body) && isset($body['filters_order']) ) {
$collection = $this->collections_repository->fetch($collection_id); $collection = $this->collections_repository->fetch($collection_id);
if( $collection instanceof Entities\Collection) { if( $collection instanceof Entities\Collection) {
$collection->set_filters_order( $body['filters_order'] ); $collection->set_filters_order( $body['filters_order'] );
if ( $collection->validate() ) { if ( $collection->validate() ) {
$updated_collection = $this->collections_repository->update( $collection ); $updated_collection = $this->collections_repository->update( $collection );
$response = $this->prepare_item_for_response($updated_collection, $request); $response = $this->prepare_item_for_response($updated_collection, $request);
return new \WP_REST_Response( $response, 200 ); return new \WP_REST_Response( $response, 200 );
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('One or more values are invalid.', 'tainacan'), 'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $prepared_collection->get_errors(), 'errors' => $prepared_collection->get_errors(),
'collection' => $this->prepare_item_for_response($prepared_collection, $request) 'collection' => $this->prepare_item_for_response($prepared_collection, $request)
], 400); ], 400);
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Collection with this ID was not found', 'tainacan' ), 'error_message' => __('Collection with this ID was not found', 'tainacan' ),
'collection_id' => $collection_id 'collection_id' => $collection_id
], 400); ], 400);
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('The body could not be empty', 'tainacan'), 'error_message' => __('The body could not be empty', 'tainacan'),
'body' => $body 'body' => $body
], 400); ], 400);
} }
/** /**
@ -677,7 +677,7 @@ class REST_Collections_Controller extends REST_Controller {
} }
return false; return false;
} }
/** /**
* @param string $method * @param string $method
@ -688,17 +688,17 @@ class REST_Collections_Controller extends REST_Controller {
$endpoint_args = []; $endpoint_args = [];
if($method === \WP_REST_Server::READABLE) { if($method === \WP_REST_Server::READABLE) {
$endpoint_args['name'] = array( $endpoint_args['name'] = array(
'description' => __('Limits the result set to collections with a specific name'), 'description' => __('Limits the result set to collections with a specific name'),
'type' => 'string', 'type' => 'string',
); );
$endpoint_args = array_merge( $endpoint_args = array_merge(
$endpoint_args, $endpoint_args,
parent::get_wp_query_params(), parent::get_wp_query_params(),
parent::get_fetch_only_param(), parent::get_fetch_only_param(),
parent::get_meta_queries_params() parent::get_meta_queries_params()
); );
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) { } elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
$map = $this->collections_repository->get_map(); $map = $this->collections_repository->get_map();
@ -715,8 +715,8 @@ class REST_Collections_Controller extends REST_Controller {
$endpoint_args = $map; $endpoint_args = $map;
} }
return $endpoint_args; return $endpoint_args;
} }
function get_schema() { function get_schema() {
$schema = [ $schema = [

View File

@ -187,27 +187,21 @@ class REST_Item_Metadata_Controller extends REST_Controller {
public function update_item( $request ) { public function update_item( $request ) {
$body = json_decode( $request->get_body(), true ); $body = json_decode( $request->get_body(), true );
if($body) { if ($body) {
$item_id = $request['item_id'];
$item_id = $request['item_id']; $value = $body['values'];
$metadatum_id = $request['metadatum_id']; $metadatum_id = $request['metadatum_id'];
$value = $body['values'];
$parent_meta_id = isset( $body['parent_meta_id'] ) && $body['parent_meta_id'] > 0 ? $body['parent_meta_id'] : null; $parent_meta_id = isset( $body['parent_meta_id'] ) && $body['parent_meta_id'] > 0 ? $body['parent_meta_id'] : null;
$item = $this->item_repository->fetch( $item_id ); $item = $this->item_repository->fetch($item_id);
$metadatum = $this->metadatum_repository->fetch( $metadatum_id ); $metadatum = $this->metadatum_repository->fetch($metadatum_id);
$item_metadata = new Entities\Item_Metadata_Entity( $item, $metadatum, null, $parent_meta_id); $item_metadata = new Entities\Item_Metadata_Entity( $item, $metadatum, null, $parent_meta_id);
if($item_metadata->is_multiple()) { $value = $this->get_metadata_value($item_metadata->is_multiple(), $value);
$item_metadata->set_value( $value ); $item_metadata->set_value($value);
} elseif(is_array($value)) {
$item_metadata->set_value(implode(' ', $value));
} else {
$item_metadata->set_value($value);
}
if ( $item_metadata->validate() ) { if ($item_metadata->validate()) {
if($item->can_edit()) { if($item->can_edit()) {
$updated_item_metadata = $this->item_metadata_repository->update( $item_metadata ); $updated_item_metadata = $this->item_metadata_repository->update( $item_metadata );
@ -279,7 +273,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
$endpoint_args = array_merge( $endpoint_args = array_merge(
$endpoint_args, $endpoint_args,
$this->get_wp_query_params() $this->get_wp_query_params()
); );
} elseif ($method === \WP_REST_Server::EDITABLE) { } elseif ($method === \WP_REST_Server::EDITABLE) {
$endpoint_args['values'] = [ $endpoint_args['values'] = [
'type' => ['array', 'string', 'object', 'integer'], 'type' => ['array', 'string', 'object', 'integer'],
@ -378,6 +372,12 @@ class REST_Item_Metadata_Controller extends REST_Controller {
} }
} }
private function get_metadata_value($is_multiple, $value) {
if ($is_multiple) {
return $value;
} elseif (is_array($value)) {
return implode(' ', $value);
}
return $value;
}
} }
?>

View File

@ -708,10 +708,9 @@ class REST_Items_Controller extends REST_Controller {
*/ */
public function update_item( $request ) { public function update_item( $request ) {
$item_id = $request['item_id']; $item_id = $request['item_id'];
$body = json_decode($request->get_body(), true); $body = json_decode($request->get_body(), true);
if(!empty($body)){ if (!empty($body)) {
$attributes = []; $attributes = [];
foreach ($body as $att => $value){ foreach ($body as $att => $value){

View File

@ -9,7 +9,6 @@ use Tainacan\Repositories\Repository;
class REST_Logs_Controller extends REST_Controller { class REST_Logs_Controller extends REST_Controller {
private $logs_repository; private $logs_repository;
private $log;
/** /**
* REST_Logs_Controller constructor. * REST_Logs_Controller constructor.
@ -364,5 +363,3 @@ class REST_Logs_Controller extends REST_Controller {
return $schema; return $schema;
} }
} }
?>

View File

@ -191,6 +191,9 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
if ($status == 'finished') { if ($status == 'finished') {
$params['progress_label'] = __('Process completed','tainacan'); $params['progress_label'] = __('Process completed','tainacan');
$params['progress_value'] = 100; $params['progress_value'] = 100;
} else if ($status == 'finished-errors') {
$params['progress_label'] = __('Process completed with errors','tainacan');
$params['progress_value'] = 100;
} }
$wpdb->update( $wpdb->update(
$this->table, $this->table,
@ -279,16 +282,14 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
*/ */
protected function handle() { protected function handle() {
$this->lock_process(); $this->lock_process();
// while we are debugging performance
$newRequest = true;
$batch = $this->get_batch(); $batch = $this->get_batch();
if ($newRequest) { if($this->process_lock_in_time != get_site_transient( $this->identifier . '_process_lock' )) {
$this->write_log($batch->key, ['New Request']); $this->write_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'New request has ignored']]);
$newRequest = false; wp_die();
} }
$this->write_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'New Request']]);
register_shutdown_function(function() use($batch) { register_shutdown_function(function() use($batch) {
$error = error_get_last(); $error = error_get_last();
@ -308,8 +309,8 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
$this->debug('Shutdown with Fatal error captured'); $this->debug('Shutdown with Fatal error captured');
$this->debug($error_str); $this->debug($error_str);
$this->write_error_log($batch->key, ['Fatal Error: ' . $error_str]); $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Fatal Error: ' . $error_str]] );
$this->write_error_log($batch->key, ['Process aborted']); $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Process aborted']]);
$this->close( $batch->key, 'errored' ); $this->close( $batch->key, 'errored' );
$this->debug('Batch closed due to captured error'); $this->debug('Batch closed due to captured error');
$this->unlock_process(); $this->unlock_process();
@ -323,8 +324,8 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
$task = $this->task( $task ); $task = $this->task( $task );
} catch (\Exception $e) { } catch (\Exception $e) {
// TODO: Add Stacktrace // TODO: Add Stacktrace
$this->write_error_log($batch->key, ['Fatal Error: ' . $e->getMessage()]); $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Fatal Error: ' . $e->getMessage()]]);
$this->write_error_log($batch->key, ['Process aborted']); $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Process aborted']]);
$task = false; $task = false;
$close_status = 'errored'; $close_status = 'errored';
} }
@ -352,7 +353,7 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
} else { } else {
$this->debug('Complete'); $this->debug('Complete');
$this->complete(); $this->complete();
$this->write_log($batch->key, ['Process Finished']); $this->write_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Process Finished']] );
} }
$this->debug('dying'); $this->debug('dying');
@ -436,18 +437,21 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
private function recursive_stingify_log_array(array $log, $break = true) { private function recursive_stingify_log_array(array $log, $break = true) {
$return = ''; $return = '';
foreach ($log as $k => $l) { foreach ($log as $k => $l) {
$l_datetime = $l['datetime'];
$l_message = $l['message'];
$return .= "[$l_datetime] ";
if (!is_numeric($k)) { if (!is_numeric($k)) {
$return .= $k . ': '; $return .= $k . ': ';
} }
if (is_array($l)) { if (is_array($l_message)) {
//$return .= $this->recursive_stingify_log_array($l, false); //$return .= $this->recursive_stingify_log_array($l_message, false);
$return .= print_r($l, true); $return .= print_r($l_message, true);
} elseif (is_string($l)) { } elseif (is_string($l_message)) {
$return .= $l; $return .= $l_message;
} }
$return .="\n"; $return .="\n";
//$return .= $break ? "\n" : ', '; //$return .= $break ? "\n" : ', ';
} }
return $return; return $return;

View File

@ -764,7 +764,11 @@ class Elastic_Press {
$metadatadum = \Tainacan\Repositories\Metadata::get_instance()->fetch($metada_id); $metadatadum = \Tainacan\Repositories\Metadata::get_instance()->fetch($metada_id);
if ( isset($metadatadum->get_metadata_type_options()['collection_id'])) { if ( isset($metadatadum->get_metadata_type_options()['collection_id'])) {
$item = \Tainacan\Repositories\Items::get_instance()->fetch(intval($term['key'])); $item = \Tainacan\Repositories\Items::get_instance()->fetch(intval($term['key']));
$label = $item->get_title(); if( $item instanceof Entities\Item) {
$label = $item->get_title();
} else {
continue;
}
} }
} }
$fct = [ $fct = [
@ -855,7 +859,11 @@ class Elastic_Press {
$metadatadum = \Tainacan\Repositories\Metadata::get_instance()->fetch($metada_id); $metadatadum = \Tainacan\Repositories\Metadata::get_instance()->fetch($metada_id);
if ( isset($metadatadum->get_metadata_type_options()['collection_id'])) { if ( isset($metadatadum->get_metadata_type_options()['collection_id'])) {
$item = \Tainacan\Repositories\Items::get_instance()->fetch($term['key'][$key]); $item = \Tainacan\Repositories\Items::get_instance()->fetch($term['key'][$key]);
$label = $item->get_title(); if( $item instanceof Entities\Item) {
$label = $item->get_title();
} else {
continue;
}
} }
} }

View File

@ -21,8 +21,6 @@ class Media {
protected function __construct() { protected function __construct() {
add_action( 'init', [$this, 'add_attachment_page_rewrite_rule'] ); add_action( 'init', [$this, 'add_attachment_page_rewrite_rule'] );
add_action( 'admin_enqueue_scripts', array( &$this, 'add_css' ) );
add_action( 'wp_enqueue_scripts', array( &$this, 'add_css' ) );
add_filter( 'query_vars', [$this, 'attachment_page_add_var'] ); add_filter( 'query_vars', [$this, 'attachment_page_add_var'] );
add_action( 'template_redirect', [$this, 'attachment_page'] ); add_action( 'template_redirect', [$this, 'attachment_page'] );
@ -367,6 +365,7 @@ class Media {
$output .= $img; $output .= $img;
} else { } else {
$this->add_css();
wp_print_styles('tainacan-media-page'); wp_print_styles('tainacan-media-page');
global $wp_embed; global $wp_embed;

View File

@ -31,7 +31,6 @@ class Item_Metadata_Entity extends Entity {
* @param int $meta_id ID for a specific meta row * @param int $meta_id ID for a specific meta row
*/ */
function __construct(Item $item = null, Metadatum $metadatum = null, $meta_id = null, $parent_meta_id = null) { function __construct(Item $item = null, Metadatum $metadatum = null, $meta_id = null, $parent_meta_id = null) {
$this->set_item($item); $this->set_item($item);
$this->set_metadatum($metadatum); $this->set_metadatum($metadatum);
@ -136,17 +135,15 @@ class Item_Metadata_Entity extends Entity {
* Get the value as a HTML string, with markup and links * Get the value as a HTML string, with markup and links
* @return string * @return string
*/ */
public function get_value_as_html(){ public function get_value_as_html() {
$metadatum = $this->get_metadatum(); $metadatum = $this->get_metadatum();
if (is_object($metadatum)) { if (is_object($metadatum)) {
$fto = $metadatum->get_metadata_type_object(); $fto = $metadatum->get_metadata_type_object();
if (is_object($fto)) { if (is_object($fto)) {
if ( method_exists($fto, 'get_value_as_html') ) { if ( method_exists($fto, 'get_value_as_html') ) {
return $fto->get_value_as_html($this); return $fto->get_value_as_html($this);
} }
} }
} }
@ -155,7 +152,6 @@ class Item_Metadata_Entity extends Entity {
$return = ''; $return = '';
if ( $this->is_multiple() ) { if ( $this->is_multiple() ) {
$total = sizeof($value); $total = sizeof($value);
$count = 0; $count = 0;
$prefix = $this->get_multivalue_prefix(); $prefix = $this->get_multivalue_prefix();
@ -163,25 +159,19 @@ class Item_Metadata_Entity extends Entity {
$separator = $this->get_multivalue_separator(); $separator = $this->get_multivalue_separator();
foreach ($value as $v) { foreach ($value as $v) {
$return .= $prefix; $return .= $prefix;
$return .= (string) $v; $return .= (string) $v;
$return .= $suffix; $return .= $suffix;
$count ++; $count ++;
if ($count < $total) if ($count < $total)
$return .= $separator; $return .= $separator;
} }
} else { } else {
$return = (string) $value; $return = (string) $value;
} }
return $return; return $return;
} }
/** /**
@ -199,10 +189,9 @@ class Item_Metadata_Entity extends Entity {
public function get_value_as_array() { public function get_value_as_array() {
$value = $this->get_value(); $value = $this->get_value();
$primitive_type = $this->get_metadatum()->get_metadata_type_object()->get_primitive_type(); $primitive_type = $this->get_metadatum()->get_metadata_type_object()->get_primitive_type();
$return = [];
if ( $this->is_multiple() ) {
$return = []; if ($this->is_multiple()) {
foreach ($value as $v) { foreach ($value as $v) {
if( is_array($v) ) { if( is_array($v) ) {
$options = $this->get_metadatum()->get_metadata_type_object()->get_options(); $options = $this->get_metadatum()->get_metadata_type_object()->get_options();
@ -227,12 +216,8 @@ class Item_Metadata_Entity extends Entity {
$return[] = $v; $return[] = $v;
} }
} }
} else { } else {
if ($primitive_type === 'compound') {
$return = '';
if( $primitive_type === 'compound' ) {
$compounds = []; $compounds = [];
$compounds_not_ordinate = []; $compounds_not_ordinate = [];
$options = $this->get_metadatum()->get_metadata_type_object()->get_options(); $options = $this->get_metadatum()->get_metadata_type_object()->get_options();
@ -274,7 +259,6 @@ class Item_Metadata_Entity extends Entity {
} }
return $return; return $return;
} }
/** /**
@ -285,7 +269,7 @@ class Item_Metadata_Entity extends Entity {
* *
* @return array the representation of this object as an array * @return array the representation of this object as an array
*/ */
public function _toArray( $formatted_values = true, $cascade = false ){ public function _toArray( $formatted_values = true, $cascade = false ){
$as_array = []; $as_array = [];
$as_array['value'] = $this->get_value_as_array(); $as_array['value'] = $this->get_value_as_array();
@ -303,40 +287,40 @@ class Item_Metadata_Entity extends Entity {
$as_array['item'] = $this->get_item()->_toArray(); $as_array['item'] = $this->get_item()->_toArray();
$as_array['metadatum'] = $this->get_metadatum()->_toArray(); $as_array['metadatum'] = $this->get_metadatum()->_toArray();
} }
return apply_filters('tainacan-item-metadata-to-array', $as_array, $this); return apply_filters('tainacan-item-metadata-to-array', $as_array, $this);
} }
/** /**
* Define the item * Define the item
* *
* @param Item $item * @param Item $item
* @return void * @return void
*/ */
function set_item(Item $item = null) { function set_item(Item $item = null) {
$this->item = $item; $this->item = $item;
} }
/** /**
* Define the metadatum value * Define the metadatum value
* *
* @param [integer | string] $value * @param [integer | string] $value
* @return void * @return void
*/ */
function set_value($value) { function set_value($value) {
$this->value = $value; $this->value = $value;
} }
/** /**
* Define the metadatum * Define the metadatum
* *
* @param Metadatum $metadatum * @param Metadatum $metadatum
* @return void * @return void
*/ */
function set_metadatum(Metadatum $metadatum = null) { function set_metadatum(Metadatum $metadatum = null) {
$this->metadatum = $metadatum; $this->metadatum = $metadatum;
} }
/** /**
* Set the specific meta ID for this metadata. * Set the specific meta ID for this metadata.
@ -370,135 +354,128 @@ class Item_Metadata_Entity extends Entity {
} }
return false; return false;
} }
/**
* Return the item
*
* @return Item
*/
function get_item() {
return $this->item;
}
/**
* Return the metadatum
*
* @return Metadatum
*/
function get_metadatum() {
return $this->metadatum;
}
/** /**
* Return the meta_id * Return the item
* *
* @return Metadatum * @return Item
*/ */
function get_meta_id() { function get_item() {
return isset($this->meta_id) ? $this->meta_id : null; return $this->item;
} }
/** /**
* Return the meta_id * Return the metadatum
* *
* @return Metadatum * @return Metadatum
*/ */
function get_parent_meta_id() { function get_metadatum() {
return isset($this->parent_meta_id) ? $this->parent_meta_id : 0; return $this->metadatum;
} }
/**
* Return the metadatum value
*
* @return string | integer
*/
function get_value() {
if (isset($this->value))
return $this->value;
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
return $Tainacan_Item_Metadata->get_value($this);
}
/** /**
* Check wether the item has a value stored in the database or not * Return the meta_id
* *
* @return bool * @return Metadatum
*/ */
function has_value() { function get_meta_id() {
if (isset($this->has_value)) return isset($this->meta_id) ? $this->meta_id : null;
return $this->has_value; }
/**
* Return the meta_id
*
* @return Metadatum
*/
function get_parent_meta_id() {
return isset($this->parent_meta_id) ? $this->parent_meta_id : 0;
}
/**
* Return the metadatum value
*
* @return string|integer|Array
*/
function get_value() {
if (isset($this->value))
return $this->value;
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
return $Tainacan_Item_Metadata->get_value($this);
}
/**
* Check wether the item has a value stored in the database or not
*
* @return bool
*/
function has_value() {
if (isset($this->has_value))
return $this->has_value;
$value = $this->get_value(); $value = $this->get_value();
$this->has_value = (is_array($value)) ? !empty(array_filter($value)) : !empty($value); $this->has_value = (is_array($value)) ? !empty(array_filter($value)) : !empty($value);
return $this->has_value; return $this->has_value;
} }
/** /**
* Return true if metadatum is multiple, else return false * Return true if metadatum is multiple, else return false
* *
* @return boolean * @return boolean
*/ */
function is_multiple() { function is_multiple() {
return $this->get_metadatum()->is_multiple(); return $this->get_metadatum()->is_multiple();
} }
/** /**
* Return true if metadatum is key * Return true if metadatum is key
* *
* @return boolean * @return boolean
*/ */
function is_collection_key() { function is_collection_key() {
return $this->get_metadatum()->is_collection_key(); return $this->get_metadatum()->is_collection_key();
} }
/** /**
* Return true if metadatum is required * Return true if metadatum is required
* *
* @return boolean * @return boolean
*/ */
function is_required() { function is_required() {
return $this->get_metadatum()->is_required(); return $this->get_metadatum()->is_required();
} }
/** /**
* Validate attributes * Returns whether metadata value is valid
* *
* @return boolean * @return boolean
*/ */
function validate() { function validate() {
$value = $this->get_value(); $value = $this->get_value();
$metadatum = $this->get_metadatum(); $metadatum = $this->get_metadatum();
$item = $this->get_item(); $item = $this->get_item();
if( !isset($metadatum) ) { if (!isset($metadatum)) {
$this->add_error('not_found', ['metadatum not found'] ); $this->add_error('not_found', ['metadatum not found'] );
return false; return false;
} }
if (empty($value) && $this->is_required() && in_array( $item->get_status(), apply_filters( 'tainacan-status-require-validation', [ if (empty($value) && $value !== '0' && $value !== 0) {
'publish', if ($this->is_required()) {
'future', $validation_statuses = ['publish', 'future', 'private'];
'private' if (in_array($item->get_status(), apply_filters( 'tainacan-status-require-validation', $validation_statuses) )) {
] ) ) $this->add_error('required', $metadatum->get_name() . ' is required');
) { return false;
$this->add_error('required', $metadatum->get_name() . ' is required'); } else {
return false; return $this->set_as_valid();
} elseif (empty($value) && !$this->is_required()) { }
$this->set_as_valid(); } else {
return true; return $this->set_as_valid();
} elseif(empty($value) && $this->is_required() && !in_array( $item->get_status(), apply_filters( 'tainacan-status-require-validation', [ }
'publish',
'future',
'private'
] ) )) {
$this->set_as_valid();
return true;
} }
$classMetadatumType = $metadatum->get_metadata_type_object(); $classMetadatumType = $metadatum->get_metadata_type_object();
if( is_object( $classMetadatumType ) ){ if (is_object($classMetadatumType)) {
if( method_exists ( $classMetadatumType , 'validate' ) ){ if( method_exists ( $classMetadatumType , 'validate' ) ){
if( ! $classMetadatumType->validate( $this ) ) { if( ! $classMetadatumType->validate( $this ) ) {
$this->add_error('metadata_type_error', $classMetadatumType->get_errors() ); $this->add_error('metadata_type_error', $classMetadatumType->get_errors() );

View File

@ -500,26 +500,20 @@ class Item extends Entity {
public function _toHtml() { public function _toHtml() {
$return = ''; $return = '';
$id = $this->get_id(); $id = $this->get_id();
if ( $id ) { if ( $id ) {
$link = get_permalink( (int) $id ); $link = get_permalink( (int) $id );
if (is_string($link)) { if (is_string($link)) {
$return = "<a data-linkto='item' data-id='$id' href='$link'>"; $return = "<a data-linkto='item' data-id='$id' href='$link'>";
$return.= $this->get_title(); $return.= $this->get_title();
$return .= "</a>"; $return .= "</a>";
} }
} }
return $return; return $return;
} }
/** /**
@ -725,7 +719,7 @@ class Item extends Entity {
} }
$output .= $_embed; $output .= $_embed;
} elseif ( $type == 'text' ) { } elseif ( $type == 'text' ) {
$output .= $this->get_document(); $output .= '<article>' . $this->get_document() . '</article>';
} elseif ( $type == 'attachment' ) { } elseif ( $type == 'attachment' ) {
if ( wp_attachment_is_image($this->get_document()) ) { if ( wp_attachment_is_image($this->get_document()) ) {

View File

@ -168,7 +168,7 @@ class Metadatum extends Entity {
/** /**
* Return the an object child of \Tainacan\metadatum_Types\Metadata_Type with options * Return the an object child of \Tainacan\metadatum_Types\Metadata_Type with options
* *
* @return \Tainacan\Metadata_Types\Metadata_Type The metadatum type class with filled options * @return \Tainacan\Metadata_Types\Metadata_Type|Object The metadatum type class with filled options
*/ */
function get_metadata_type_object(){ function get_metadata_type_object(){
$class_name = $this->get_metadata_type(); $class_name = $this->get_metadata_type();

View File

@ -44,8 +44,8 @@ class Taxonomy extends Entity {
*/ */
static $db_identifier_prefix = 'tnc_tax_'; static $db_identifier_prefix = 'tnc_tax_';
public function __toString(){ public function __toString() {
return apply_filters("tainacan-taxonomy-to-string", $this->get_name(), $this); return (string) apply_filters("tainacan-taxonomy-to-string", $this->get_name(), $this);
} }
/** /**
@ -54,18 +54,19 @@ class Taxonomy extends Entity {
* @return bool * @return bool
*/ */
function tainacan_register_taxonomy() { function tainacan_register_taxonomy() {
$labels = array( $taxonomy_name = $this->get_name();
'name' => $this->get_name(), $labels = array(
'singular_name' => $this->get_name(), 'name' => $taxonomy_name,
'search_items' => __( sprintf('Search terms in %s', $this->get_name()), 'tainacan' ), 'singular_name' => $taxonomy_name,
'all_items' => __( sprintf('All terms in %s', $this->get_name()), 'tainacan' ), 'search_items' => __( sprintf('Search terms in %s', $taxonomy_name), 'tainacan' ),
'all_items' => __( sprintf('All terms in %s', $taxonomy_name), 'tainacan' ),
'parent_item' => __( 'Parent term', 'tainacan' ), 'parent_item' => __( 'Parent term', 'tainacan' ),
'parent_item_colon' => __( 'Parent term:', 'tainacan' ), 'parent_item_colon' => __( 'Parent term:', 'tainacan' ),
'edit_item' => __( 'Edit term', 'tainacan' ), 'edit_item' => __( 'Edit term', 'tainacan' ),
'update_item' => __( 'Update term', 'tainacan' ), 'update_item' => __( 'Update term', 'tainacan' ),
'add_new_item' => __( 'Add New term', 'tainacan' ), 'add_new_item' => __( 'Add New term', 'tainacan' ),
'new_item_name' => __( 'New Genre term', 'tainacan' ), 'new_item_name' => __( 'New Genre term', 'tainacan' ),
'menu_name' => $this->get_name(), 'menu_name' => $taxonomy_name,
); );
$enabled_post_types = $this->get_enabled_post_types(); $enabled_post_types = $this->get_enabled_post_types();
@ -88,8 +89,6 @@ class Taxonomy extends Entity {
unregister_taxonomy($this->get_db_identifier()); unregister_taxonomy($this->get_db_identifier());
} }
register_taxonomy( register_taxonomy(
$this->get_db_identifier(), $this->get_db_identifier(),
$enabled_post_types, $enabled_post_types,

View File

@ -51,11 +51,11 @@ class Term extends Entity {
} }
} }
public function __toString(){ public function __toString() {
return apply_filters("tainacan-term-to-string", $this->get_name(), $this); return (string) apply_filters("tainacan-term-to-string", $this->get_name(), $this);
} }
public function _toArray(){ public function _toArray() {
$term_array = parent::_toArray(); $term_array = parent::_toArray();
$term_id = $term_array['term_id']; $term_id = $term_array['term_id'];
@ -245,25 +245,19 @@ class Term extends Entity {
} }
public function _toHtml() { public function _toHtml() {
$return = ''; $return = '';
$id = $this->get_id(); $id = $this->get_id();
if ( $id ) { if ( $id ) {
$link = get_term_link( (int) $id ); $link = get_term_link( (int) $id );
if (is_string($link)) { if (is_string($link)) {
$return = "<a data-linkto='term' data-id='$id' href='$link'>"; $return = "<a data-linkto='term' data-id='$id' href='$link'>";
$return.= $this->get_name(); $return.= $this->get_name();
$return .= "</a>"; $return .= "</a>";
} }
} }
return apply_filters('tainacan-term-to-html', $return, $this); return apply_filters('tainacan-term-to-html', $return, $this);
} }
} }

View File

@ -60,6 +60,19 @@ class CSV extends Exporter {
$line[] = $rel; $line[] = $rel;
} elseif ($meta->get_metadatum()->get_metadata_type() == 'Tainacan\Metadata_Types\Compound') { } elseif ($meta->get_metadatum()->get_metadata_type() == 'Tainacan\Metadata_Types\Compound') {
$line[] = $this->get_compound_metadata_cell($meta); $line[] = $this->get_compound_metadata_cell($meta);
} elseif ($meta->get_metadatum()->get_metadata_type() == 'Tainacan\Metadata_Types\Date' ) {
$metadatum = $meta->get_metadatum();
$date_value = 'ERROR ON FORMATING DATE';
if (is_object($metadatum)) {
$fto = $metadatum->get_metadata_type_object();
if (is_object($fto)) {
if ( method_exists($fto, 'get_value_as_html') ) {
$fto->output_date_format = 'Y-m-d';
$date_value = $fto->get_value_as_html($meta);
}
}
}
$line[] = $date_value;
} else { } else {
$line[] = $meta->get_value_as_string(); $line[] = $meta->get_value_as_string();
} }

View File

@ -193,7 +193,8 @@ abstract class Exporter {
$current_collection_item = $this->get_current_collection_item(); $current_collection_item = $this->get_current_collection_item();
$collections = $this->get_collections(); $collections = $this->get_collections();
$collection = $collections[$current_collection]; $collection = $collections[$current_collection];
$current_collection_item ++; $length_items = $this->get_step_length_items();
$current_collection_item += $length_items;
$this->set_current_collection_item($current_collection_item); $this->set_current_collection_item($current_collection_item);
if ($current_collection_item >= $collection['total_items']) { if ($current_collection_item >= $collection['total_items']) {
return $this->next_collection(); return $this->next_collection();
@ -248,6 +249,10 @@ abstract class Exporter {
return $this->current_collection_item; return $this->current_collection_item;
} }
public function get_step_length_items() {
return apply_filters('exporter_step_length_items', 20, $this->get_current_step());
}
public function set_current_collection_item($value) { public function set_current_collection_item($value) {
$this->current_collection_item = $value; $this->current_collection_item = $value;
} }
@ -350,11 +355,11 @@ abstract class Exporter {
} }
public function add_log($message ) { public function add_log($message ) {
$this->log[] = $message; $this->log[] = ['datetime' => date("Y-m-d H:i:s"), 'message' => $message];
} }
public function add_error_log($message ) { public function add_error_log($message ) {
$this->error_log[] = $message; $this->error_log[] = ['datetime' => date("Y-m-d H:i:s"), 'message' => $message];
} }
public function is_finished() { public function is_finished() {
@ -562,20 +567,19 @@ abstract class Exporter {
$this->add_error_log('Collection misconfigured'); $this->add_error_log('Collection misconfigured');
return false; return false;
} }
$this->add_log('Processing item ' . $current_collection_item); $length_items = $this->get_step_length_items();
$this->add_log("Processing batch with $length_items items, starting from item $current_collection_item");
$this->process_header($current_collection_item, $collection_definition); $this->process_header($current_collection_item, $collection_definition);
$init = microtime(true);
$processed_items = $this->get_items($current_collection_item, $collection_definition); $processed_items = $this->get_items($current_collection_item, $collection_definition);
foreach ($processed_items as $processed_item) { foreach ($processed_items as $processed_item) {
$init = microtime(true);
$this->process_item( $processed_item['item'], $processed_item['metadata'] ); $this->process_item( $processed_item['item'], $processed_item['metadata'] );
$final = microtime(true);
$total = ($final - $init);
$time_log = sprintf( __('Processed in %f seconds', 'tainacan'), $total );
$this->add_log($time_log);
} }
$final = microtime(true);
$total = ($final - $init);
$time_log = sprintf( __('Processed in %f seconds', 'tainacan'), $total );
$this->add_log($time_log);
$this->process_footer($current_collection_item, $collection_definition); $this->process_footer($current_collection_item, $collection_definition);
return $this->next_item(); return $this->next_item();
@ -595,7 +599,7 @@ abstract class Exporter {
} }
private function process_footer($current_collection_item, $collection_definition) { private function process_footer($current_collection_item, $collection_definition) {
if ($current_collection_item == $collection_definition['total_items']-1) { if ($current_collection_item > $collection_definition['total_items']) {
$this->output_footer(); $this->output_footer();
} }
} }
@ -608,17 +612,18 @@ abstract class Exporter {
private function get_items($index, $collection_definition) { private function get_items($index, $collection_definition) {
$collection_id = $collection_definition['id']; $collection_id = $collection_definition['id'];
$tainacan_items = \Tainacan\Repositories\Items::get_instance(); $tainacan_items = \Tainacan\Repositories\Items::get_instance();
$per_page = $this->get_step_length_items();
$page = intdiv($index, $per_page) + 1;
$filters = [ $filters = [
'posts_per_page' => 1, 'posts_per_page' => $per_page,
'paged' => $index+1, 'paged' => $page,
'order' => 'DESC', 'order' => 'DESC',
'orderby' => 'ID' 'orderby' => 'ID'
]; ];
$this->add_log('Proccessing item index ' . $index . ' in collection ' . $collection_definition['id'] ); $this->add_log("Retrieving $per_page items on page index: $index, in collection " . $collection_definition['id'] );
$items = $tainacan_items->fetch($filters, $collection_id, 'WP_Query'); $items = $tainacan_items->fetch($filters, $collection_id, 'WP_Query');
if ( !isset($collection_definition['total_items']) ) { if ( !isset($collection_definition['total_items']) ) {
$collection_definition['total_items'] = $items->found_posts; $collection_definition['total_items'] = $items->found_posts;
$this->update_current_collection($collection_definition); $this->update_current_collection($collection_definition);
@ -805,7 +810,7 @@ abstract class Exporter {
if (method_exists($this, $method_name)) { if (method_exists($this, $method_name)) {
$author = $this->get_transient('author'); $author = $this->get_transient('author');
$this->add_log('User in process: ' . $author . ' (' . date("Y-m-d H:i:s") . ')'); $this->add_log('User in process: ' . $author);
wp_set_current_user($author); wp_set_current_user($author);
$result = $this->$method_name(); $result = $this->$method_name();
} else { } else {

View File

@ -146,11 +146,11 @@ abstract class Generic_Process {
} }
public function add_log($message ) { public function add_log($message ) {
$this->log[] = $message; $this->log[] = ['datetime' => date("Y-m-d H:i:s"), 'message' => $message];
} }
public function add_error_log($message ) { public function add_error_log($message ) {
$this->error_log[] = $message; $this->error_log[] = ['datetime' => date("Y-m-d H:i:s"), 'message' => $message];
} }
public function is_finished() { public function is_finished() {

View File

@ -12,7 +12,8 @@ class CSV extends Importer {
'delimiter' => ',', 'delimiter' => ',',
'multivalued_delimiter' => '||', 'multivalued_delimiter' => '||',
'encode' => 'utf8', 'encode' => 'utf8',
'enclosure' => '' 'enclosure' => '',
'escape_empty_value' => '[empty value]'
]); ]);
} }
@ -385,6 +386,31 @@ class CSV extends Importer {
</div> </div>
</div> </div>
</div> </div>
<div class="column">
<div class="field">
<label class="label"><?php _e('Empty value', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Empty value', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The string representing a value not informed for the metadata. (e.g. \EMPTY)', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="escape_empty_value" value="<?php echo $this->get_option('escape_empty_value'); ?>">
</div>
</div>
</div>
</div> </div>
<div class="columns"> <div class="columns">
@ -677,14 +703,13 @@ class CSV extends Importer {
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance(); $Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
// $Tainacan_Items->disable_logs();
// $Tainacan_Metadata->disable_logs();
// $Tainacan_Item_Metadata->disable_logs();
$itemMetadataArray = []; $itemMetadataArray = [];
$updating_item = false; $updating_item = false;
$Tainacan_Items->disable_logs();
$Tainacan_Metadata->disable_logs();
$Tainacan_Item_Metadata->disable_logs(); $Tainacan_Item_Metadata->disable_logs();
if ( is_numeric($this->get_transient('item_id')) ) { if ( is_numeric($this->get_transient('item_id')) ) {
$item = $Tainacan_Items->fetch( (int) $this->get_transient('item_id') ); $item = $Tainacan_Items->fetch( (int) $this->get_transient('item_id') );
@ -739,7 +764,9 @@ class CSV extends Importer {
if ($metadatum instanceof Entities\Metadatum) { if ($metadatum instanceof Entities\Metadatum) {
$singleItemMetadata = new Entities\Item_Metadata_Entity( $item, $metadatum); // *empty item will be replaced by inserted in the next foreach $singleItemMetadata = new Entities\Item_Metadata_Entity( $item, $metadatum); // *empty item will be replaced by inserted in the next foreach
if( $metadatum->get_metadata_type() == 'Tainacan\Metadata_Types\Taxonomy' ) { if ($this->is_clear_value($values)) {
$singleItemMetadata->set_value("");
} else if( $metadatum->get_metadata_type() == 'Tainacan\Metadata_Types\Taxonomy' ) {
if( !is_array( $values ) ) { if( !is_array( $values ) ) {
$tmp = $this->insert_hierarchy( $metadatum, $values); $tmp = $this->insert_hierarchy( $metadatum, $values);
if ($tmp !== false) { if ($tmp !== false) {
@ -787,7 +814,8 @@ class CSV extends Importer {
$this->add_error_log( $item->get_errors() ); $this->add_error_log( $item->get_errors() );
return false; return false;
} }
global $wpdb;
$wpdb->query( 'SET autocommit = 0;' );
foreach ( $itemMetadataArray as $itemMetadata ) { foreach ( $itemMetadataArray as $itemMetadata ) {
if($itemMetadata instanceof Entities\Item_Metadata_Entity ) { if($itemMetadata instanceof Entities\Item_Metadata_Entity ) {
$itemMetadata->set_item( $insertedItem ); // *I told you $itemMetadata->set_item( $insertedItem ); // *I told you
@ -826,6 +854,8 @@ class CSV extends Importer {
// $this->add_error_log( 'Item ' . $insertedItem->get_id() . ' has an error' ); // $this->add_error_log( 'Item ' . $insertedItem->get_id() . ' has an error' );
//} //}
} }
$wpdb->query( 'COMMIT;' );
$wpdb->query( 'SET autocommit = 1;' );
if ( ! $updating_item ) { if ( ! $updating_item ) {
$insertedItem->set_status('publish' ); $insertedItem->set_status('publish' );
@ -872,6 +902,16 @@ class CSV extends Importer {
} }
} }
/**
* @param $value
* @return bool
*/
private function is_clear_value($value) {
if( !empty($value) && is_array($value) )
return false;
return $this->get_option('escape_empty_value') == $value;
}
/** /**
* @param $metadatum the metadata * @param $metadatum the metadata
* @param $values the categories names * @param $values the categories names

View File

@ -344,11 +344,11 @@ abstract class Importer {
* @param $type * @param $type
* @param $messagelog * @param $messagelog
*/ */
public function add_log($message ){ public function add_log($message ) {
$this->log[] = $message; $this->log[] = ['datetime' => date("Y-m-d H:i:s"), 'message' => $message];
} }
public function add_error_log($message ){ public function add_error_log($message ) {
$this->error_log[] = $message; $this->error_log[] = ['datetime' => date("Y-m-d H:i:s"), 'message' => $message];
} }
public function add_collection(array $collection) { public function add_collection(array $collection) {
@ -893,7 +893,6 @@ abstract class Importer {
$author = $this->get_transient('author'); $author = $this->get_transient('author');
$this->add_log('---------------------------'); $this->add_log('---------------------------');
$this->add_log('Starting processing new item'); $this->add_log('Starting processing new item');
$this->add_log(date("Y-m-d H:i:s"));
$this->add_log('User in process: ' . $author); $this->add_log('User in process: ' . $author);
wp_set_current_user($author); wp_set_current_user($author);
$result = $this->$method_name(); $result = $this->$method_name();

View File

@ -226,6 +226,7 @@
$this->debug('process already running'); $this->debug('process already running');
return true; return true;
} }
$this->debug('process not already running');
return false; return false;
} }
@ -241,10 +242,11 @@
$this->debug('locking process: ' . $this->identifier); $this->debug('locking process: ' . $this->identifier);
$this->start_time = time(); // Set start time of current process. $this->start_time = time(); // Set start time of current process.
$max_execution_time = ini_get('max_execution_time'); $max_execution_time = ini_get('max_execution_time');
$lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : ( empty($max_execution_time) ? 60 : $max_execution_time ); // 1 minute $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : ( empty($max_execution_time) ? 60 : ($max_execution_time * 1.5) ); // 1 minute
$lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration ); $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
$this->process_lock_in_time = microtime();
set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); if(!$this->is_process_running())
set_site_transient( $this->identifier . '_process_lock', $this->process_lock_in_time, $lock_duration );
} }
/** /**

View File

@ -26,7 +26,7 @@ class Collections extends Repository {
* {@inheritDoc} * {@inheritDoc}
* @see \Tainacan\Repositories\Repository::get_map() * @see \Tainacan\Repositories\Repository::get_map()
*/ */
protected function _get_map() { protected function _get_map() {
return apply_filters( 'tainacan-get-map-' . $this->get_name(), [ return apply_filters( 'tainacan-get-map-' . $this->get_name(), [
'name' => [ 'name' => [
'map' => 'post_title', 'map' => 'post_title',
@ -303,10 +303,9 @@ class Collections extends Repository {
* @see \Tainacan\Repositories\Repository::insert() * @see \Tainacan\Repositories\Repository::insert()
*/ */
public function insert( $collection ) { public function insert( $collection ) {
$this->pre_process( $collection );
$this->pre_process( $collection );
$this->handle_parent_order_clone( $collection ); $this->handle_parent_order_clone( $collection );
$new_collection = parent::insert( $collection ); $new_collection = parent::insert( $collection );
$this->handle_core_metadata( $new_collection ); $this->handle_core_metadata( $new_collection );
@ -389,12 +388,9 @@ class Collections extends Repository {
} }
function pre_process( $collection ) { function pre_process( $collection ) {
$this->old_collection = $this->fetch( $collection->get_id() ); $this->old_collection = $this->fetch( $collection->get_id() );
$this->old_core_title = $collection->get_core_title_metadatum(); $this->old_core_title = $collection->get_core_title_metadatum();
$this->old_core_description = $collection->get_core_description_metadatum(); $this->old_core_description = $collection->get_core_description_metadatum();
} }
function handle_core_metadata( $collection ) { function handle_core_metadata( $collection ) {

View File

@ -25,7 +25,7 @@ class Item_Metadata extends Repository {
} }
/** /**
* @param Entities\Entity $item_metadata * @param Entities\Item_Metadata_Entity $item_metadata
* *
* @return Entities\Entity|Entities\Item_Metadata_Entity * @return Entities\Entity|Entities\Item_Metadata_Entity
* @throws \Exception * @throws \Exception
@ -40,8 +40,6 @@ class Item_Metadata extends Repository {
do_action( 'tainacan-pre-insert', $item_metadata ); do_action( 'tainacan-pre-insert', $item_metadata );
do_action( 'tainacan-pre-insert-Item_Metadata_Entity', $item_metadata ); do_action( 'tainacan-pre-insert-Item_Metadata_Entity', $item_metadata );
$new = $item_metadata->get_value();
$unique = ! $item_metadata->is_multiple(); $unique = ! $item_metadata->is_multiple();
$metadata_type = $item_metadata->get_metadatum()->get_metadata_type_object(); $metadata_type = $item_metadata->get_metadatum()->get_metadata_type_object();
@ -70,14 +68,14 @@ class Item_Metadata extends Repository {
return $item_metadata; return $item_metadata;
} else { } else {
if ( $unique ) { if ( $unique ) {
$item_metadata_value = $this->sanitize_value( $item_metadata->get_value() );
if ( !is_numeric($item_metadata->get_value()) && empty( $item_metadata->get_value() ) ) { if ( !is_numeric($item_metadata->get_value()) && empty( $item_metadata->get_value() ) ) {
if ( $item_metadata->get_metadatum()->get_parent() > 0 ) if ( $item_metadata->get_metadatum()->get_parent() > 0 )
delete_metadata_by_mid( 'post', $item_metadata->get_meta_id() ); delete_metadata_by_mid( 'post', $item_metadata->get_meta_id() );
else else
delete_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id() ); delete_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id() );
} elseif ( is_int( $item_metadata->get_meta_id() ) ) { } elseif ( is_int( $item_metadata->get_meta_id() ) ) {
update_metadata_by_mid( 'post', $item_metadata->get_meta_id(), $item_metadata->get_value() ); update_metadata_by_mid( 'post', $item_metadata->get_meta_id(), $item_metadata_value );
} else { } else {
/** /**
@ -87,10 +85,10 @@ class Item_Metadata extends Repository {
* and not update an existing. This is the case of a multiple compound metadatum. * and not update an existing. This is the case of a multiple compound metadatum.
*/ */
if ( $item_metadata->get_metadatum()->get_parent() > 0 && is_null( $item_metadata->get_meta_id() ) ) { if ( $item_metadata->get_metadatum()->get_parent() > 0 && is_null( $item_metadata->get_meta_id() ) ) {
$added_meta_id = add_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id(), wp_slash( $item_metadata->get_value() ) ); $added_meta_id = add_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id(), wp_slash( $item_metadata_value ) );
$added_compound = $this->add_compound_value( $item_metadata, $added_meta_id ); $added_compound = $this->add_compound_value( $item_metadata, $added_meta_id );
} else { } else {
update_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id(), wp_slash( $item_metadata->get_value() ) ); update_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id(), wp_slash( $item_metadata_value ) );
} }
} }
@ -105,7 +103,8 @@ class Item_Metadata extends Repository {
if ( !is_numeric($value) && empty($value) ) { if ( !is_numeric($value) && empty($value) ) {
continue; continue;
} }
add_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id(), wp_slash( $value ) ); $item_metadata_value = $this->sanitize_value( $value );
add_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id(), wp_slash( $item_metadata_value ) );
} }
} }
} }
@ -142,7 +141,7 @@ class Item_Metadata extends Repository {
$set_method = 'set_' . $metadata_type->get_related_mapped_prop(); $set_method = 'set_' . $metadata_type->get_related_mapped_prop();
$value = $item_metadata->get_value(); $value = $item_metadata->get_value();
$item->$set_method( is_array( $value ) ? $value[0] : $value ); $item->$set_method( $this->sanitize_value( is_array( $value ) ? $value[0] : $value ) );
if ( $item->validate_core_metadata() ) { if ( $item->validate_core_metadata() ) {
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance(); $Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
@ -185,6 +184,7 @@ class Item_Metadata extends Repository {
$insert[] = $exists->term_id; $insert[] = $exists->term_id;
} else { } else {
$create_term = new Entities\Term(); $create_term = new Entities\Term();
$new_term = $this->sanitize_value($new_term);
$create_term->set_name($new_term); $create_term->set_name($new_term);
$create_term->set_taxonomy( $taxonomy->get_db_identifier() ); $create_term->set_taxonomy( $taxonomy->get_db_identifier() );
if ($create_term->validate()) { // Item_Metadata Entity was validated before, so this should be fine if ($create_term->validate()) { // Item_Metadata Entity was validated before, so this should be fine

View File

@ -525,14 +525,14 @@ class Items extends Repository {
* @return bool * @return bool
*/ */
public function hook_comments_open($open_comment, $post_id) { public function hook_comments_open($open_comment, $post_id) {
$item = self::get_entity_by_post($post_id); $item = self::get_entity_by_post($post_id);
if($item != false && $item instanceof Entities\Item) { if($item != false && $item instanceof Entities\Item) {
$collection = $item->get_collection(); $collection = $item->get_collection();
if( $collection->get_allow_comments() !== 'open' ) return false; if( $collection != null && $collection->get_allow_comments() !== 'open' ) return false;
} }
return $open_comment; return $open_comment;
} }
/** /**

View File

@ -260,6 +260,10 @@ class Logs extends Repository {
$collection_id = method_exists($entity, 'get_collection_id') ? $entity->get_collection_id() : 'default'; $collection_id = method_exists($entity, 'get_collection_id') ? $entity->get_collection_id() : 'default';
if ( method_exists($entity, 'get_repository') && !$entity->get_repository()->use_logs ) {
return;
}
if ( $entity instanceof Entities\Collection ) { if ( $entity instanceof Entities\Collection ) {
$collection_id = $entity->get_id(); $collection_id = $entity->get_id();
$log->set_title( sprintf( __( 'New file was attached to Collection "%s"', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'New file was attached to Collection "%s"', 'tainacan'), $entity->get_name() ) );
@ -272,15 +276,11 @@ class Logs extends Repository {
$object_type = get_class($entity); $object_type = get_class($entity);
$object_id = $entity->get_id(); $object_id = $entity->get_id();
$diff = [];
$log->set_collection_id($collection_id); $log->set_collection_id($collection_id);
$log->set_object_type($object_type); $log->set_object_type($object_type);
$log->set_object_id($object_id); $log->set_object_id($object_id);
$log->set_action('new-attachment'); $log->set_action('new-attachment');
$title = __( sprintf('') , 'tainacan');
$prepared = [ $prepared = [
'id' => $attachment->ID, 'id' => $attachment->ID,
'title' => $attachment->post_title, 'title' => $attachment->post_title,
@ -313,7 +313,9 @@ class Logs extends Repository {
$entity = Repository::get_entity_by_post( $entity_post ); $entity = Repository::get_entity_by_post( $entity_post );
if ( $entity ) { if ( $entity ) {
if ( method_exists($entity, 'get_repository') && !$entity->get_repository()->use_logs ) {
return;
}
$collection_id = method_exists($entity, 'get_collection_id') ? $entity->get_collection_id() : 'default'; $collection_id = method_exists($entity, 'get_collection_id') ? $entity->get_collection_id() : 'default';
$log = new Entities\Log(); $log = new Entities\Log();

View File

@ -304,7 +304,6 @@ class Metadata extends Repository {
} }
} }
/** /**
* fetch metadatum based on ID or WP_Query args * fetch metadatum based on ID or WP_Query args
* *
@ -676,7 +675,6 @@ class Metadata extends Repository {
); );
} }
/** /**
* That function update the core metadatum meta key, in case of changing the collection parent * That function update the core metadatum meta key, in case of changing the collection parent
* *
@ -1001,7 +999,6 @@ class Metadata extends Repository {
return false; return false;
} }
/** /**
* create a metadatum entity and insert by an associative array ( attribute => value ) * create a metadatum entity and insert by an associative array ( attribute => value )
* *
@ -1026,7 +1023,6 @@ class Metadata extends Repository {
} }
} }
/** /**
* Return all possible values for a metadatum * Return all possible values for a metadatum
* *

View File

@ -6,7 +6,6 @@ use Tainacan\Entities;
use Tainacan\Entities\Entity; use Tainacan\Entities\Entity;
use Tainacan; use Tainacan;
use Tainacan\Repositories; use Tainacan\Repositories;
use \Respect\Validation\Validator as v;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
@ -122,17 +121,13 @@ abstract class Repository {
*/ */
public function insert( $obj ) { public function insert( $obj ) {
// validate // validate
if ( in_array( $obj->get_status(), apply_filters( 'tainacan-status-require-validation', [ $required_validation_statuses = ['publish', 'future', 'private'];
'publish', if (in_array( $obj->get_status(), apply_filters( 'tainacan-status-require-validation', $required_validation_statuses) ) && ! $obj->get_validated() ) {
'future',
'private'
] ) ) && ! $obj->get_validated() ) {
throw new \Exception( 'Entities must be validated before you can save them' ); throw new \Exception( 'Entities must be validated before you can save them' );
// TODO: Throw Warning saying you must validate object before insert() // TODO: Throw Warning saying you must validate object before insert()
} }
$is_update = false; $is_update = false;
$old = '';
$diffs = []; $diffs = [];
do_action( 'tainacan-pre-insert', $obj ); do_action( 'tainacan-pre-insert', $obj );
@ -141,8 +136,7 @@ abstract class Repository {
do_action( "tainacan-pre-insert-$obj_post_type", $obj ); do_action( "tainacan-pre-insert-$obj_post_type", $obj );
$map = $this->get_map(); $map = $this->get_map();
// First iterate through native post properties
// First iterate through the native post properties
foreach ( $map as $prop => $mapped ) { foreach ( $map as $prop => $mapped ) {
if ( $mapped['map'] != 'meta' && $mapped['map'] != 'meta_multi' ) { if ( $mapped['map'] != 'meta' && $mapped['map'] != 'meta_multi' ) {
$obj->WP_Post->{$mapped['map']} = $obj->get_mapped_property( $prop ); $obj->WP_Post->{$mapped['map']} = $obj->get_mapped_property( $prop );
@ -157,11 +151,15 @@ abstract class Repository {
$obj->WP_Post->post_status = 'publish'; $obj->WP_Post->post_status = 'publish';
} }
$sanitized_title = $this->sanitize_value($obj->get('name'));
$sanitized_desc = $this->sanitize_value($obj->get('description'));
if ( $obj instanceof Entities\Item ) { if ( $obj instanceof Entities\Item ) {
$sanitized_title = $this->sanitize_value($obj->get('title'));
// get collection to determine post type // get collection to determine post type
$collection = $obj->get_collection(); $collection = $obj->get_collection();
if ( ! $collection ) { if (!$collection) {
return false; return false;
} }
@ -171,8 +169,15 @@ abstract class Repository {
do_action( "tainacan-pre-insert-$obj_post_type", $obj ); do_action( "tainacan-pre-insert-$obj_post_type", $obj );
} }
// TODO verificar se salvou mesmo if ( ! $obj instanceof Entities\Log ) {
$obj->WP_Post->post_title = $sanitized_title;
$obj->WP_Post->post_content = $sanitized_desc;
}
$id = wp_insert_post( $obj->WP_Post ); $id = wp_insert_post( $obj->WP_Post );
if ($id instanceof \WP_Error || 0 === $id) {
return false;
}
// reset object // reset object
$obj->WP_Post = get_post( $id ); $obj->WP_Post = get_post( $id );
@ -250,10 +255,12 @@ abstract class Repository {
} }
function maybe_add_slashes( $value ) { function maybe_add_slashes( $value ) {
if ( is_string( $value ) && strpos( $value, '\\' ) !== false ) { if ( is_string( $value ) ) {
return wp_slash( $value ); if( strpos( $value, '\\' ) !== false ) {
return wp_slash( $this->sanitize_value($value) );
}
return $this->sanitize_value($value);
} }
return $value; return $value;
} }
@ -911,6 +918,16 @@ abstract class Repository {
} }
protected function sanitize_value($content) {
if (is_numeric($content) || empty($content) ) {
return $content;
}
$allowed_html = wp_kses_allowed_html('post');
unset($allowed_html["a"]);
return trim(wp_kses($content, $allowed_html));
}
} }
?>

View File

@ -141,7 +141,6 @@ class Taxonomies extends Repository {
* @return Entities\Entity * @return Entities\Entity
*/ */
public function insert( $taxonomy ) { public function insert( $taxonomy ) {
$new_taxonomy = parent::insert( $taxonomy ); $new_taxonomy = parent::insert( $taxonomy );
$new_taxonomy->tainacan_register_taxonomy(); $new_taxonomy->tainacan_register_taxonomy();
@ -168,7 +167,6 @@ class Taxonomies extends Repository {
* @return \WP_Query|Array an instance of wp query OR array of entities; * @return \WP_Query|Array an instance of wp query OR array of entities;
*/ */
public function fetch( $args = [], $output = null ) { public function fetch( $args = [], $output = null ) {
// TODO: Pegar taxonomias registradas via código // TODO: Pegar taxonomias registradas via código
if ( is_numeric( $args ) ) { if ( is_numeric( $args ) ) {

View File

@ -17,17 +17,11 @@ use \Tainacan\Repositories;
* Optional. Array or string of arguments. * Optional. Array or string of arguments.
* *
* @type mixed $metadata Metadatum object, ID or slug to retrieve only one metadatum. empty returns all metadata * @type mixed $metadata Metadatum object, ID or slug to retrieve only one metadatum. empty returns all metadata
*
* @type array $metadata__in Array of metadata IDs or Slugs to be retrieved. Default none * @type array $metadata__in Array of metadata IDs or Slugs to be retrieved. Default none
*
* @type array $metadata__not_in Array of metadata IDs (slugs not accepted) to excluded. Default none * @type array $metadata__not_in Array of metadata IDs (slugs not accepted) to excluded. Default none
*
* @type bool $exclude_title Exclude the Core Title Metadata from result. Default false * @type bool $exclude_title Exclude the Core Title Metadata from result. Default false
*
* @type bool $exclude_description Exclude the Core Description Metadata from result. Default false * @type bool $exclude_description Exclude the Core Description Metadata from result. Default false
*
* @type bool $exclude_core Exclude Core Metadata (title and description) from result. Default false * @type bool $exclude_core Exclude Core Metadata (title and description) from result. Default false
*
* @type bool $hide_empty Wether to hide or not metadata the item has no value to * @type bool $hide_empty Wether to hide or not metadata the item has no value to
* Default: true * Default: true
* @type string $before String to be added before each metadata block * @type string $before String to be added before each metadata block
@ -70,17 +64,54 @@ function tainacan_the_metadata($args = array()) {
* *
* Return the item document as a HTML string to be used as output. * Return the item document as a HTML string to be used as output.
* *
* @param int|string $item_id (Optional) The item ID. Default is the global $post * @param int|string $item_id (Optional) The item ID. Default is the global $post
* @param string $img_size (Optional) The image size, in case of an imagen document. Default is 'large'
* *
* @return string The HTML output * @return string The HTML output
*/ */
function tainacan_get_the_document($item_id = 0) { function tainacan_get_the_document($item_id = 0, $img_size = 'large') {
$item = tainacan_get_item($item_id); $item = tainacan_get_item($item_id);
if (!$item) if (!$item)
return; return;
return apply_filters('tainacan-get-the-document', $item->get_document_as_html(), $item); return apply_filters('tainacan-get-the-document', $item->get_document_as_html($item_id, $img_size), $item);
}
/**
* To be used inside The Loop
*
* Return the item document in raw form (ID if an Attachment, textual content if URL or Text)
*
* @param int|string $item_id (Optional) The item ID. Default is the global $post
*
* @return string The raw output
*/
function tainacan_get_the_document_raw($item_id = 0) {
$item = tainacan_get_item($item_id);
if (!$item)
return;
return apply_filters('tainacan_get_the_document_raw', $item->get_document($item_id), $item);
}
function tainacan_get_the_item_document_url($item_id = 0) {
$item = tainacan_get_item($item_id);
if (!$item)
return;
return apply_filters('tainacan_get_the_item_document_url', $item->get_document_download_url(), $item);
}
function tainacan_get_the_document_type($item_id = 0) {
$item = tainacan_get_item($item_id);
if (!$item)
return;
return apply_filters('tainacan_get_the_document_type', $item->get_document_type(), $item);
} }
function tainacan_the_item_document_download_link($item_id = 0) { function tainacan_the_item_document_download_link($item_id = 0) {
@ -112,10 +143,19 @@ function tainacan_the_document() {
echo tainacan_get_the_document(); echo tainacan_get_the_document();
} }
/**
* To be used inside The Loop
*
* echoes HTML display-ready version of an attachment
*/
function tainacan_get_single_attachment_as_html($attachment_id, $item_id = 0, $img_size = 'large') {
echo tainacan_get_attachment_as_html($attachment_id, $item_id, $img_size);
}
/** /**
* Return HTML display-ready version of an attachment * Return HTML display-ready version of an attachment
*/ */
function tainacan_get_single_attachment_as_html($attachment_id, $item_id = 0) { function tainacan_get_attachment_as_html($attachment_id, $item_id = 0, $img_size = 'large') {
$item = tainacan_get_item($item_id); $item = tainacan_get_item($item_id);
@ -123,7 +163,7 @@ function tainacan_get_single_attachment_as_html($attachment_id, $item_id = 0) {
return ''; return '';
} }
echo $item->get_attachment_as_html($attachment_id); return $item->get_attachment_as_html($attachment_id, $img_size);
} }
/** /**
@ -219,6 +259,335 @@ function tainacan_the_collection_description() {
echo tainacan_get_the_collection_description(); echo tainacan_get_the_collection_description();
} }
/**
* Tainacan Gallery component, used to render document, attachments and other files
*
* @return string
*/
function tainacan_the_media_component($media_id, $media_items_thumbs, $media_items_main, $args) {
echo tainacan_get_the_media_component($media_id, $media_items_thumbs, $media_items_main, $args);
}
/**
* Tainacan Media Gallery component, used to render document, attachments and other files
*
* @param string $media_id ID to be added to the gallery div. If both main and thumbnail items are passed, each div ID will be posfixed with '-main' or '-thumbs'.
* @param array $media_items_thumbs Array of media items to be rendered inside smaller the carousel. Default to empty array
* @param array $media_items_main Array of media items to be rendered inside main, bigger the carousel. Default to empty array
* @param array|string $args {
* Optional. Array of arguments.
* @type string before_main_div String to be added before the main gallery div
* @type string after_main_div String to be added after the main gallery div
* @type string before_thumbs_div String to be added before the thumbs gallery div
* @type string after_thumbs_div String to be added after the thumbs gallery div
* @type string before_main_ul String to be added before the main gallery ul
* @type string after_main_ul String to be added after the main gallery ul
* @type string before_thumbs_ul String to be added before the thumbs gallery ul
* @type string after_thumbs_ul String to be added after the thumbs gallery ul
* @type string class_main_div Class to be added to the main gallery div
* @type string class_main_ul Class to be added to the main gallery ul
* @type string class_main_li Class to be added to the main gallery li
* @type string class_thumbs_div Class to be added to the thumbs gallery div
* @type string class_thumbs_ul Class to be added to the thumbs gallery ul
* @type string class_thumbs_li Class to be added to the thumbs gallery li
* @type array swiper_main_options Object with SwiperJS options for the main gallery
* @type array swiper_thumbs_options Object with SwiperJS options for the thumb gallery
* @type bool show_share_button Shows share button on lightbox
* }
* @return string
*/
function tainacan_get_the_media_component(
$media_id = 'tainacan-media-component',
$media_items_thumbs = array(),
$media_items_main = array(),
$args = array()
) {
global $TAINACAN_BASE_URL;
$args = array_merge(array(
'before_main_div' => '',
'after_main_div' => '',
'before_thumbs_div' => '',
'after_thumbs_div' => '',
'before_main_ul' => '',
'after_main_ul' => '',
'before_thumbs_ul' => '',
'after_thumbs_ul' => '',
'class_main_div' => '',
'class_main_ul' => '',
'class_main_li' => '',
'class_thumbs_div' => '',
'class_thumbs_ul' => '',
'class_thumbs_li' => '',
'swiper_main_options' => [],
'swiper_thumbs_options' => [],
'show_share_button' => false
), $args);
$args['has_media_main'] = $media_items_main && is_array($media_items_main) && count($media_items_main);
$args['has_media_thumbs'] = $media_items_thumbs && is_array($media_items_thumbs) && count($media_items_thumbs);
$args['media_main_id'] = $media_id . '-main';
$args['media_thumbs_id'] = $media_id . '-thumbs';
$args['media_id'] = $media_id;
if ( $args['has_media_main'] || $args['has_media_thumbs'] ) :
// Modal lightbox layer for rendering photoswipe
add_action('wp_footer', 'tainacan_get_the_media_modal_layer');
wp_enqueue_style( 'tainacan-media-component', $TAINACAN_BASE_URL . '/assets/css/media-component.css', array(), TAINACAN_VERSION);
wp_enqueue_script( 'tainacan-media-component', $TAINACAN_BASE_URL . '/assets/js/media_component.js', ['tainacan-search','wp-i18n'], TAINACAN_VERSION, true );
?>
<div class="tainacan-media-component">
<?php if ( $args['has_media_main'] ) : ?>
<!-- Slider main container -->
<?php echo $args['before_main_div'] ?>
<div id="<?php echo $args['media_main_id'] ?>" class="tainacan-media-component__swiper-main swiper-container <?php echo $args['class_main_div'] ?>">
<!-- Additional required wrapper -->
<?php echo $args['before_main_ul'] ?>
<ul class="swiper-wrapper <?php echo $args['class_main_ul'] ?>">
<?php foreach($media_items_main as $media_item) { ?>
<li class="swiper-slide <?php echo $args['class_main_li'] ?>">
<?php echo $media_item ?>
</li>
<?php }; ?>
</ul>
<?php echo $args['before_main_ul'] ?>
<?php if ( $args['swiper_main_options'] && isset($args['swiper_main_options']['pagination']) ) : ?>
<!-- If we need pagination -->
<div class="swiper-pagination swiper-pagination_<?php echo $args['media_main_id'] ?>"></div>
<?php endif; ?>
<?php if ( $args['swiper_main_options'] && isset($args['swiper_main_options']['navigation']) ) : ?>
<!-- If we need navigation buttons -->
<div class="swiper-button-prev swiper-navigation-prev_<?php echo $args['media_main_id'] ?>"></div>
<div class="swiper-button-next swiper-navigation-next_<?php echo $args['media_main_id'] ?>"></div>
<?php endif; ?>
</div>
<?php echo $args['after_main_div'] ?>
<?php endif; ?>
<?php if ( $args['has_media_thumbs'] ) : ?>
<!-- Slider thumbs container -->
<?php echo $args['before_thumbs_div'] ?>
<div id="<?php echo $args['media_thumbs_id'] ?>" class="tainacan-media-component__swiper-thumbs swiper-container <?php echo $args['class_thumbs_div'] ?>">
<!-- Additional required wrapper -->
<?php echo $args['before_thumbs_ul'] ?>
<ul class="swiper-wrapper <?php echo $args['class_thumbs_ul'] ?>">
<?php foreach($media_items_thumbs as $media_item) { ?>
<li class="swiper-slide <?php echo $args['class_thumbs_li'] ?>">
<?php echo $media_item ?>
</li>
<?php }; ?>
</ul>
<?php echo $args['before_thumbs_ul'] ?>
<?php if ( $args['swiper_thumbs_options'] && isset($args['swiper_thumbs_options']['pagination']) ) : ?>
<!-- If we need pagination -->
<div class="swiper-paginations swiper-pagination_<?php echo $args['media_thumbs_id'] ?>"></div>
<?php endif; ?>
<?php if ( $args['swiper_thumbs_options'] && isset($args['swiper_thumbs_options']['navigation']) ) : ?>
<!-- If we need navigation buttons -->
<div class="swiper-button-prev swiper-navigation-prev_<?php echo $args['media_thumbs_id'] ?>"></div>
<div class="swiper-button-next swiper-navigation-next_<?php echo $args['media_thumbs_id'] ?>"></div>
<?php endif; ?>
<!-- These elements will create a gradient on the side of the carousel -->
<div class="swiper-start-border"></div>
<div class="swiper-end-border"></div>
</div>
<?php echo $args['after_thumbs_div'] ?>
<?php endif; ?>
</div>
<?php if ( isset( $_REQUEST['wp_customize'] ) ) : ?>
<script>
tainacan_plugin.tainacan_media_components = (typeof tainacan_plugin != undefined && typeof tainacan_plugin.tainacan_media_components != "undefined") ? tainacan_plugin.tainacan_media_components : {};
tainacan_plugin.tainacan_media_components['<?php echo $args['media_id'] ?>'] = <?php echo json_encode($args) ?>;
</script>
<?php else :
wp_add_inline_script( 'tainacan-media-component', '
tainacan_plugin.tainacan_media_components = (typeof tainacan_plugin != undefined && typeof tainacan_plugin.tainacan_media_components != "undefined") ? tainacan_plugin.tainacan_media_components : {};
tainacan_plugin.tainacan_media_components["' . $args['media_id'] . '"] = '. json_encode($args) . ';
', 'before' );
endif; ?>
<?php endif; ?> <!-- End of if ($args['has_media_main'] || $args['has_media_thumbs'] ) -->
<?php
}
/**
* Tainacan Media Item for the Media Gallery component, used to render a single link displayed in the carousel
*
* @param array|string $args {
* Optional. Array of arguments.
* @type string before_slide_content String to be added before the slide-content div or a tag
* @type string after_slide_content String to be added after the slide-content div or a tag
* @type string class_slide_content Class to be added to the slide-content div or a tag
* @type string before_slide_metadata String to be added before the slide-metadata div
* @type string after_slide_metadata String to be added after the slide-metadata div
* @type string class_slide_metadata Class to be added to the slide-metadata div
* @type string media_content The content of the slide itself, such as an image, audio, video or iframe tag. It may be wrapped by a link to the full content
* @type string media_content_full The media full content, either an image, an html
* @type string media_title The media title, if available
* @type string media_description The media description, if available
* @type string media_caption The media caption, if available
* @type string media_type The media type or mime_type, used to render an icon if media_content is empty
* }
* @return string
*/
function tainacan_get_the_media_component_slide( $args = array() ) {
$args = array_merge(array(
'before_slide_content' => '',
'after_slide_content' => '',
'class_slide_content' => '',
'before_slide_metadata' => '',
'after_slide_metadata' => '',
'class_slide_metadata' => '',
'media_content' => '',
'media_content_full' => '',
'media_title' => '',
'media_description' => '',
'media_caption' => '',
'media_type' => ''
), $args);
ob_start();
?>
<?php echo $args['before_slide_content'] ?>
<div class="swiper-slide-content <?php echo $args['class_slide_content'] ?>">
<?php if ( isset($args['media_content']) && !empty($args['media_content']) && $args['media_content'] !== false ) :?>
<?php echo $args['media_content'] ?>
<?php else: ?>
<img src="<?php echo tainacan_get_the_mime_type_icon($args['media_type']) ?>" alt="<?php echo ( !empty($args['media_title']) ? $args['media_title'] : __('File', 'tainacan') ) ?>" >
<?php endif; ?>
<?php echo $args['before_slide_metadata'] ?>
<?php if ( !empty($args['media_title']) || !empty($args['description']) || !empty($args['media_caption']) ) : ?>
<div class="swiper-slide-metadata <?php echo $args['class_slide_metadata'] ?>">
<?php if ( !empty($args['media_caption']) ) :?>
<span class="swiper-slide-metadata__caption">
<?php echo $args['media_caption'] ?>
<br>
</span>
<?php endif; ?>
<?php if ( !empty($args['media_title']) ) :?>
<span class="swiper-slide-metadata__name">
<?php echo $args['media_title'] ?>
</span>
<?php endif; ?>
<br>
<?php if ( !empty($args['media_description']) ) :?>
<span class="swiper-slide-metadata__description">
<?php echo $args['media_description'] ?>
</span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( !empty($args['media_content_full']) ) : ?>
<div class="media-full-content" style="display: none; position: absolute; visibility: hidden;"><?php echo $args['media_content_full'] ?></div>
<?php endif; ?>
<?php echo $args['after_slide_metadata'] ?>
</div>
<?php echo $args['after_slide_content'] ?>
<?php
$content = ob_get_contents();
ob_end_clean();
return $content;
}
/**
* Div with content necessay to render the photowipe modal
*
* @return string
*/
function tainacan_get_the_media_modal_layer() {
?>
<!-- Root element of PhotoSwipe lightbox. Must have class pswp. -->
<div class="tainacan-photoswipe-layer pswp" tabindex="-1" role="dialog" aria-hidden="true">
<!-- Background of PhotoSwipe.
It's a separate element, as animating opacity is faster than rgba(). -->
<div class="pswp__bg"></div>
<!-- Slides wrapper with overflow:hidden. -->
<div class="pswp__scroll-wrap">
<!-- Container that holds slides. PhotoSwipe keeps only 3 slides in DOM to save memory. -->
<!-- don't modify these 3 pswp__item elements, data is added later on. -->
<div class="pswp__container">
<div class="pswp__item"></div>
<div class="pswp__item"></div>
<div class="pswp__item"></div>
</div>
<!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
<div class="pswp__ui pswp__ui--hidden">
<div class="pswp__top-bar">
<!-- Controls are self-explanatory. Order can be changed. -->
<div class="pswp__counter"></div>
<div class="pswp__name"></div>
<button class="pswp__button pswp__button--close" title="<?php __('Close modal (Esc)', 'tainacan') ?>"></button>
<button class="pswp__button pswp__button--share" title="<?php __('Share', 'tainacan') ?>"></button>
<button class="pswp__button pswp__button--fs" title="<?php __('Toggle fullscreen', 'tainacan') ?>"></button>
<button class="pswp__button pswp__button--zoom" title="<?php __('Zoom in/out', 'tainacan') ?>"></button>
<!-- Preloader demo https://codepen.io/dimsemenov/pen/yyBWoR -->
<!-- element will get class pswp__preloader--active when preloader is running -->
<div class="pswp__preloader">
<div class="pswp__preloader__icn">
<div class="pswp__preloader__cut">
<div class="pswp__preloader__donut"></div>
</div>
</div>
</div>
</div>
<div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
<div class="pswp__share-tooltip"></div>
</div>
<button class="pswp__button pswp__button--arrow--left" title="<?php __('Next', 'tainacan') ?>"></button>
<button class="pswp__button pswp__button--arrow--right" title="<?php __('Previous', 'tainacan') ?>"></button>
<div class="pswp__caption">
<div class="pswp__caption__center"></div>
</div>
</div>
</div>
</div>
<?php
}
/** /**
* When visiting a collection archive or single, returns the collection url link * When visiting a collection archive or single, returns the collection url link
@ -545,3 +914,86 @@ function tainacan_get_initials($string, $one = false) {
$result = strtoupper($first . $second); $result = strtoupper($first . $second);
return apply_filters('tainacan-get-initials', $result, $string, $one); return apply_filters('tainacan-get-initials', $result, $string, $one);
} }
/**
* Gets the icon mime type using our custom plugin thumbnails
*
* @param string $mime_type The mime_type or type of the file
* @param string $image_size The image size
*
* @return string
*/
function tainacan_get_the_mime_type_icon($mime_type, $image_size = 'medium') {
global $TAINACAN_BASE_URL;
$images_path = $TAINACAN_BASE_URL . '/assets/images/';
$icon_file = '';
switch($image_size) {
case 'full':
case 'large':
case 'tainacan-large-full':
$image_size = '';
break;
case 'small':
case 'tainacan-small':
case 'thumbnail':
$image_size = '_small';
break;
case '':
case 'medium':
case 'tainacan-medium':
case 'tainacan-medium-full':
case 'medium_large':
default:
$image_size = '_medium';
}
switch($mime_type) {
case 'image':
case 'image/png':
case 'image/jpeg':
case 'image/gif':
case 'image/bmp':
case 'image/webp':
case 'image/svg+xml':
$icon_file = 'placeholder_image';
break;
case 'audio':
case 'audio/midi':
case 'audio/mpeg':
case 'audio/mp3':
case 'audio/webm':
case 'audio/ogg':
case 'audio/wav':
$icon_file = 'placeholder_audio';
break;
case 'text':
case 'text/plain':
case 'text/html':
case 'text/css':
case 'text/javascript':
case 'text/csv':
$icon_file = 'placeholder_text';
break;
case 'video':
case 'video/webm':
case 'video/ogg':
case 'video/mpeg':
case 'video/mp4':
$icon_file = 'placeholder_video';
break;
case 'url':
$icon_file = 'placeholder_url';
break;
case 'application/pdf':
$icon_file = 'placeholder_pdf';
break;
case 'attachment':
case 'empty':
default:
$icon_file = 'placeholder_attachment';
}
return $images_path . $icon_file . $image_size . '.png';
}

View File

@ -36,6 +36,19 @@ trait Entity_Collection_Relation {
if($this->collection instanceof Entities\Collection){ if($this->collection instanceof Entities\Collection){
return $this->collection; return $this->collection;
} }
} else {
$post = get_post($this->get_id());
if (!$post || !$post->post_type)
return null;
$post_type = $post->post_type;
$matches = array();
$regex = '/' . Collection::$db_identifier_prefix . '([a-zA-Z0-9_]*)' . Collection::$db_identifier_sufix . '/';
preg_match($regex, $post_type, $matches);
$collection_id = $matches[1];
if (is_numeric($collection_id)) {
$this->set_collection_id($collection_id);
return $this->get_collection();
}
} }
return null; return null;

View File

@ -1,5 +1,5 @@
=== Tainacan === === Tainacan ===
Contributors: andrebenedito, daltonmartins, fabianobn, jacsonp, leogermani, weryques, wetah, eduardohumberto, ravipassos, jessicafpx, marinagiolo, omarceloavila, vnmedeiros, tainacan Contributors: andrebenedito, daltonmartins, fabianobn, jacsonp, leogermani, weryques, wetah, eduardohumberto, ravipassos, jessicafpx, marinagiolo, omarceloavila, vnmedeiros, tainacan, r-guimaraes
Tags: museums, libraries, archives, GLAM, collections, repository Tags: museums, libraries, archives, GLAM, collections, repository
Requires at least: 4.8 Requires at least: 4.8
Tested up to: 5.6 Tested up to: 5.6

View File

@ -2,7 +2,7 @@
/* /*
Plugin Name: Tainacan Plugin Name: Tainacan
Plugin URI: https://tainacan.org/ Plugin URI: https://tainacan.org/
Description: Open source, 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. 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 Author: Tainacan.org
Version: 0.17.4 Version: 0.17.4
Text Domain: tainacan Text Domain: tainacan

View File

@ -63,6 +63,8 @@
v-if="filterTypeOptions.type == 'year'" v-if="filterTypeOptions.type == 'year'"
:placeholder="$i18n.get('instruction_type_value_year')" :placeholder="$i18n.get('instruction_type_value_year')"
:aria-labelledby="'filter-label-id-' + filter.id" :aria-labelledby="'filter-label-id-' + filter.id"
:aria-minus-label="$i18n.get('label_decrease')"
:aria-plus-label="$i18n.get('label_increase')"
size="is-small" size="is-small"
step="1" step="1"
@input="emitOnlyYear($event)" @input="emitOnlyYear($event)"

View File

@ -2,6 +2,8 @@
<div> <div>
<b-numberinput <b-numberinput
:aria-labelledby="'filter-label-id-' + filter.id" :aria-labelledby="'filter-label-id-' + filter.id"
:aria-minus-label="$i18n.get('label_decrease')"
:aria-plus-label="$i18n.get('label_increase')"
size="is-small" size="is-small"
@input="($event) => { resetPage(); validadeValues($event) }" @input="($event) => { resetPage(); validadeValues($event) }"
:step="filterTypeOptions.step" :step="filterTypeOptions.step"
@ -14,6 +16,8 @@
</p> </p>
<b-numberinput <b-numberinput
:aria-labelledby="'filter-label-id-' + filter.id" :aria-labelledby="'filter-label-id-' + filter.id"
:aria-minus-label="$i18n.get('label_decrease')"
:aria-plus-label="$i18n.get('label_increase')"
size="is-small" size="is-small"
@input="($event) => { resetPage(); validadeValues($event) }" @input="($event) => { resetPage(); validadeValues($event) }"
:step="filterTypeOptions.step" :step="filterTypeOptions.step"

View File

@ -62,6 +62,8 @@
<b-numberinput <b-numberinput
:aria-labelledby="'filter-label-id-' + filter.id" :aria-labelledby="'filter-label-id-' + filter.id"
:aria-minus-label="$i18n.get('label_decrease')"
:aria-plus-label="$i18n.get('label_increase')"
size="is-small" size="is-small"
:step="Number(filterTypeOptions.step)" :step="Number(filterTypeOptions.step)"
@input="($event) => { resetPage($event); emit($event); }" @input="($event) => { resetPage($event); emit($event); }"

View File

@ -196,35 +196,45 @@ class Compound extends Metadata_Type {
foreach ( $compound_element as $meta_id => $meta ) { foreach ( $compound_element as $meta_id => $meta ) {
$index = array_search( $meta_id, array_column( $order, 'id' ) ); $index = array_search( $meta_id, array_column( $order, 'id' ) );
if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) { if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) {
$html = $this->get_meta_html($meta);
if ( $index !== false ) { if ( $index !== false ) {
$metadata_value[$index] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>"; $metadata_value[$index] = $html;
} else { } else {
$metadata_value_not_ordinate[] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>"; $metadata_value_not_ordinate[] = $html;
} }
} }
} }
$elements[] = '<div class="tainacan-compound-metadatum">' . implode("\n", array_merge($metadata_value, $metadata_value_not_ordinate)) . "</div> \n" ; $elements[] = '<div class="tainacan-compound-metadatum">' . implode("\n", array_merge($metadata_value, $metadata_value_not_ordinate)) . "</div> \n" ;
} }
} }
$return = '<div class="tainacan-compound-group">' . implode($separator, $elements) . '</div>'; $return = implode($separator, $elements);
} else { } else {
$metadata_value = array_fill(0, count($value), null); $metadata_value = array_fill(0, count($value), null);
$metadata_value_not_ordinate = []; $metadata_value_not_ordinate = [];
foreach ( $value as $meta_id => $meta ) { foreach ( $value as $meta_id => $meta ) {
$index = array_search( $meta_id, array_column( $order, 'id' ) ); $index = array_search( $meta_id, array_column( $order, 'id' ) );
if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) { if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) {
$html = $this->get_meta_html($meta);
if ( $index !== false ) { if ( $index !== false ) {
$metadata_value[intval($index)] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>"; $metadata_value[intval($index)] = $html;
} else { } else {
$metadata_value_not_ordinate[] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>"; $metadata_value_not_ordinate[] = $html;
} }
} }
} }
$return = '<div class="tainacan-compound-group">' . implode("\n", array_merge($metadata_value, $metadata_value_not_ordinate)) . "</div> \n"; $return = implode("\n", array_merge($metadata_value, $metadata_value_not_ordinate));
} }
return $return; return "<div class='tainacan-compound-group'> {$return} </div>";
}
private function get_meta_html(Item_Metadata_Entity $meta) {
$html = '';
if ($meta instanceof Item_Metadata_Entity && !empty($meta->get_value_as_html())) {
$html = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>";
}
return $html;
} }
} }

View File

@ -11,56 +11,45 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
*/ */
class Date extends Metadata_Type { class Date extends Metadata_Type {
function __construct(){ function __construct() {
// call metadatum type constructor // call metadatum type constructor
parent::__construct(); parent::__construct();
$this->set_primitive_type('date'); $this->set_primitive_type('date');
$this->set_component('tainacan-date'); $this->set_component('tainacan-date');
$this->set_name( __('Date', 'tainacan') ); $this->set_name( __('Date', 'tainacan') );
$this->set_description( __('Exact date type, with day, month and year.', 'tainacan') ); $this->set_description( __('Exact date type, with day, month and year.', 'tainacan') );
$this->set_preview_template(' $this->set_preview_template('
<div> <div>
<div class="control is-inline"> <div class="control is-inline">
<input type="text" placeholder="' . __('mm/dd/yyyy') . '" class="input"></input> <input type="text" placeholder="' . __('mm/dd/yyyy') . '" class="input"></input>
</div> </div>
</div> </div>
'); ');
} $this->output_date_format = get_option('date_format');
}
public function validate( Item_Metadata_Entity $item_metadata) { public function validate( Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value(); $value = $item_metadata->get_value();
$format = 'Y-m-d'; $format = 'Y-m-d';
if (is_array($value)) { if (is_array($value)) {
foreach ($value as $date_value) { foreach ($value as $date_value) {
$d = \DateTime::createFromFormat($format, $date_value); $d = \DateTime::createFromFormat($format, $date_value);
if (!$d || $d->format($format) !== $date_value) { if (!$d || $d->format($format) !== $date_value) {
$this->add_error( $this->add_error($this->format_error_msg($date_value));
sprintf( return false;
__('Invalid date format. Expected format is YYYY-MM-DD, got %s.', 'tainacan'), }
$date_value }
) return true;
); }
return false;
} $d = \DateTime::createFromFormat($format, $value);
} if (!$d || $d->format($format) !== $value) {
return True; $this->add_error($this->format_error_msg($value));
} return false;
}
$d = \DateTime::createFromFormat($format, $value); return true;
}
if (!$d || $d->format($format) !== $value) {
$this->add_error(
sprintf(
__('Invalid date format. Expected format is YYYY-MM-DD, got %s.', 'tainacan'),
$value
)
);
return false;
}
return true;
}
/** /**
* Get the value as a HTML string with proper date format set in admin * Get the value as a HTML string with proper date format set in admin
@ -80,20 +69,30 @@ class Date extends Metadata_Type {
if( empty( $el ) ) if( empty( $el ) )
continue; continue;
$return .= $prefix; $return .= $prefix;
$return .= mysql2date(get_option('date_format'), ($el)); $return .= $this->format_date_value($el);
$return .= $suffix; $return .= $suffix;
$count ++; $count ++;
if ($count < $total) if ($count < $total)
$return .= $separator; $return .= $separator;
} }
} else { } else {
if( empty( $value ) ) $return = $this->format_date_value($value);
return "";
$return = mysql2date(get_option('date_format'), ($value));
} }
return $return; return $return;
} }
private function format_date_value($value) {
if (empty($value))
return "";
return mysql2date($this->output_date_format, ($value));
}
private function format_error_msg($value) {
return sprintf(
__('Invalid date format. Expected format is MM/DD/YYYY, got %s.', 'tainacan'),
$value
);
}
} }

View File

@ -37,5 +37,4 @@ class Numeric extends Metadata_Type {
] ]
]; ];
} }
} }

View File

@ -157,14 +157,11 @@ class Relationship extends Metadata_Type {
* @param Item_Metadata_Entity $item_metadata * @param Item_Metadata_Entity $item_metadata
* @return string The HTML representation of the value, containing one or multiple items names, linked to the item page * @return string The HTML representation of the value, containing one or multiple items names, linked to the item page
*/ */
public function get_value_as_html(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) { public function get_value_as_html(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value(); $value = $item_metadata->get_value();
$return = ''; $return = '';
if ( $item_metadata->is_multiple() ) { if ( $item_metadata->is_multiple() ) {
$count = 1; $count = 1;
$total = sizeof($value); $total = sizeof($value);
$prefix = $item_metadata->get_multivalue_prefix(); $prefix = $item_metadata->get_multivalue_prefix();
@ -172,66 +169,47 @@ class Relationship extends Metadata_Type {
$separator = $item_metadata->get_multivalue_separator(); $separator = $item_metadata->get_multivalue_separator();
foreach ( $value as $item_id ) { foreach ( $value as $item_id ) {
try { try {
//$item = new \Tainacan\Entities\Item($item_id);
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance(); $Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$item = $Tainacan_Items->fetch( (int) $item_id); $item = $Tainacan_Items->fetch( (int) $item_id);
$count++;
$count ++;
if ( $item instanceof \Tainacan\Entities\Item ) { if ( $item instanceof \Tainacan\Entities\Item ) {
$return .= $prefix; $return .= $prefix;
$return .= $this->get_item_html($item); $return .= $this->get_item_html($item);
$return .= $suffix; $return .= $suffix;
if ( $count <= $total ) { if ( $count <= $total ) {
$return .= $separator; $return .= $separator;
} }
} }
} catch (\Exception $e) { } catch (\Exception $e) {
// item not found // item not found
} }
} }
} else { } else {
try { try {
$item = new \Tainacan\Entities\Item($value); $item = new \Tainacan\Entities\Item($value);
if ( $item instanceof \Tainacan\Entities\Item ) { if ( $item instanceof \Tainacan\Entities\Item ) {
$return .= $this->get_item_html($item); $return .= $this->get_item_html($item);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
// item not found // item not found
} }
} }
return $return; return $return;
} }
private function get_item_html($item) { private function get_item_html($item) {
$return = ''; $return = '';
$id = $item->get_id(); $id = $item->get_id();
$search_meta_id = $this->get_option('search'); $search_meta_id = $this->get_option('search');
if ( $id && $search_meta_id ) { if ( $id && $search_meta_id ) {
$link = get_permalink( (int) $id ); $link = get_permalink( (int) $id );
$search_meta_id = $this->get_option('search'); $search_meta_id = $this->get_option('search');
@ -250,17 +228,13 @@ class Relationship extends Metadata_Type {
} }
if (is_string($link)) { if (is_string($link)) {
$return = "<a data-linkto='item' data-id='$id' href='$link'>"; $return = "<a data-linkto='item' data-id='$id' href='$link'>";
$return.= $label; $return.= $label;
$return .= "</a>"; $return .= "</a>";
} }
} }
return $return; return $return;
} }
/** /**
@ -268,7 +242,6 @@ class Relationship extends Metadata_Type {
* @return \Tainacan\Entities\Collection|false The Collection object or false * @return \Tainacan\Entities\Collection|false The Collection object or false
*/ */
public function get_collection() { public function get_collection() {
$collection_id = $this->get_option('collection_id'); $collection_id = $this->get_option('collection_id');
if ( is_numeric($collection_id) ) { if ( is_numeric($collection_id) ) {
@ -279,7 +252,6 @@ class Relationship extends Metadata_Type {
} }
return false; return false;
} }
/** /**

View File

@ -323,7 +323,6 @@ class Taxonomy extends Metadata_Type {
} }
return $valid; return $valid;
} }
/** /**
@ -332,13 +331,10 @@ class Taxonomy extends Metadata_Type {
* @return string The HTML representation of the value, containing one or multiple terms, separated by comma, linked to term page * @return string The HTML representation of the value, containing one or multiple terms, separated by comma, linked to term page
*/ */
public function get_value_as_html(Item_Metadata_Entity $item_metadata) { public function get_value_as_html(Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
$value = $item_metadata->get_value();
$return = ''; $return = '';
if ( $item_metadata->is_multiple() ) { if ( $item_metadata->is_multiple() ) {
$count = 1; $count = 1;
$total = sizeof($value); $total = sizeof($value);
$prefix = $item_metadata->get_multivalue_prefix(); $prefix = $item_metadata->get_multivalue_prefix();
@ -346,8 +342,7 @@ class Taxonomy extends Metadata_Type {
$separator = $item_metadata->get_multivalue_separator(); $separator = $item_metadata->get_multivalue_separator();
foreach ( $value as $term ) { foreach ( $value as $term ) {
$count++;
$count ++;
if ( is_integer($term) ) { if ( is_integer($term) ) {
$term = \Tainacan\Repositories\Terms::get_instance()->fetch($term, $this->get_option('taxonomy_id')); $term = \Tainacan\Repositories\Terms::get_instance()->fetch($term, $this->get_option('taxonomy_id'));
@ -355,35 +350,25 @@ class Taxonomy extends Metadata_Type {
if ( $term instanceof \Tainacan\Entities\Term ) { if ( $term instanceof \Tainacan\Entities\Term ) {
$return .= $prefix; $return .= $prefix;
$return .= $this->get_term_hierarchy_html($term); $return .= $this->get_term_hierarchy_html($term);
$return .= $suffix; $return .= $suffix;
if ( $count <= $total ) { if ( $count <= $total ) {
$return .= $separator; $return .= $separator;
} }
} }
} }
} else { } else {
if ( $value instanceof \Tainacan\Entities\Term ) { if ( $value instanceof \Tainacan\Entities\Term ) {
$return .= $this->get_term_hierarchy_html($value); $return .= $this->get_term_hierarchy_html($value);
} }
} }
return $return; return $return;
} }
private function get_term_hierarchy_html( \Tainacan\Entities\Term $term ) { private function get_term_hierarchy_html( \Tainacan\Entities\Term $term ) {
$terms = []; $terms = [];
$terms[] = $this->term_to_html($term); $terms[] = $this->term_to_html($term);
while ($term->get_parent() > 0) { while ($term->get_parent() > 0) {
@ -392,11 +377,9 @@ class Taxonomy extends Metadata_Type {
} }
$terms = \array_reverse($terms); $terms = \array_reverse($terms);
$glue = apply_filters('tainacan-terms-hierarchy-html-separator', '<span class="hierarchy-separator"> > </span>'); $glue = apply_filters('tainacan-terms-hierarchy-html-separator', '<span class="hierarchy-separator"> > </span>');
return \implode($glue, $terms); return \implode($glue, $terms);
} }
private function term_to_html($term) { private function term_to_html($term) {

View File

@ -50,6 +50,6 @@ class Text extends Metadata_Type {
} else { } else {
$return = $this->make_clickable_links($value); $return = $this->make_clickable_links($value);
} }
return $return; return force_balance_tags($return);
} }
} }

View File

@ -59,6 +59,6 @@ class Textarea extends Metadata_Type {
} else { } else {
$return = nl2br($this->make_clickable_links($value)); $return = nl2br($this->make_clickable_links($value));
} }
return $return; return force_balance_tags($return);
} }
} }

View File

@ -39,6 +39,8 @@
:label="$i18n.get('label_number_of_copies') + ':'"> :label="$i18n.get('label_number_of_copies') + ':'">
<b-numberinput <b-numberinput
ref="copy-count-numerbinput" ref="copy-count-numerbinput"
:aria-minus-label="$i18n.get('label_decrease')"
:aria-plus-label="$i18n.get('label_increase')"
min="1" min="1"
:value="copyCount" :value="copyCount"
step="1" step="1"
@ -49,7 +51,7 @@
<footer class="modal-card-foot form-submit"> <footer class="modal-card-foot form-submit">
<button <button
type="submit" type="submit"
class="button" class="button is-outlined"
:disabled="isLoading" :disabled="isLoading"
@click="onConfirm(newItems); $parent.close();"> @click="onConfirm(newItems); $parent.close();">
{{ hasCopied ? $i18n.get('label_return_to_list') : $i18n.get('cancel') }} {{ hasCopied ? $i18n.get('label_return_to_list') : $i18n.get('cancel') }}

View File

@ -3,7 +3,13 @@
<div <div
class="is-inline-flex" class="is-inline-flex"
v-if="filterTags != undefined && filterTags.length > 0"> v-if="filterTags != undefined && filterTags.length > 0">
<p style="margin-bottom: 0;"><strong>{{ totalItems }}</strong>{{ ' itens encontrados, ' }}<strong>{{ filterTags.length }}</strong>{{ ' filtros aplicados: ' }}&nbsp;&nbsp;</p> <p style="margin-bottom: 0;">
<strong>{{ totalItems }}</strong>
{{ ' ' + ( totalItems == 1 ? $i18n.get('info_item_found') : $i18n.get('info_items_found') ) + ', ' }}
<strong>{{ filterTags.length }}</strong>
{{ ' ' + ( filterTags.length == 1 ? $i18n.get('info_applied_filter') : $i18n.get('info_applied_filters') ) + ': ' }}
&nbsp;&nbsp;
</p>
<b-tag <b-tag
v-for="(filterTag, index) of filterTags" v-for="(filterTag, index) of filterTags"
:key="index" :key="index"

View File

@ -39,6 +39,7 @@ export const ThumbnailHelperFunctions = () => {
break; break;
case 'audio/midi': case 'audio/midi':
case 'audio/mpeg': case 'audio/mpeg':
case 'audio/mp3':
case 'audio/webm': case 'audio/webm':
case 'audio/ogg': case 'audio/ogg':
case 'audio/wav': case 'audio/wav':
@ -55,6 +56,7 @@ export const ThumbnailHelperFunctions = () => {
case 'video/webm': case 'video/webm':
case 'video/ogg': case 'video/ogg':
case 'video/mpeg': case 'video/mpeg':
case 'video/mp4':
imageSrc = 'placeholder_video'; imageSrc = 'placeholder_video';
break; break;
case 'url': case 'url':

View File

@ -281,6 +281,7 @@ class Admin {
'wp_ajax_url' => admin_url( 'admin-ajax.php' ), 'wp_ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : false, 'nonce' => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : false,
'components' => $components, 'components' => $components,
'classes' => array(),
'i18n' => $tainacan_admin_i18n, 'i18n' => $tainacan_admin_i18n,
'user_caps' => $user_caps, 'user_caps' => $user_caps,
'user_prefs' => $prefs, 'user_prefs' => $prefs,
@ -290,7 +291,7 @@ class Admin {
'theme_collection_list_url' => get_post_type_archive_link( 'tainacan-collection' ), 'theme_collection_list_url' => get_post_type_archive_link( 'tainacan-collection' ),
'custom_header_support' => get_theme_support('custom-header'), 'custom_header_support' => get_theme_support('custom-header'),
'registered_view_modes' => \Tainacan\Theme_Helper::get_instance()->get_registered_view_modes(), 'registered_view_modes' => \Tainacan\Theme_Helper::get_instance()->get_registered_view_modes(),
'exposer_mapper_param' => \Tainacan\Mappers_Handler::MAPPER_PARAM, 'exposer_mapper_param' => \Tainacan\Mappers_Handler::MAPPER_PARAM,
'exposer_type_param' => \Tainacan\Exposers_Handler::TYPE_PARAM, 'exposer_type_param' => \Tainacan\Exposers_Handler::TYPE_PARAM,
'repository_name' => get_bloginfo('name'), 'repository_name' => get_bloginfo('name'),
'api_max_items_per_page' => $TAINACAN_API_MAX_ITEMS_PER_PAGE, 'api_max_items_per_page' => $TAINACAN_API_MAX_ITEMS_PER_PAGE,
@ -309,13 +310,13 @@ class Admin {
$metadata_types = $Tainacan_Metadata->fetch_metadata_types(); $metadata_types = $Tainacan_Metadata->fetch_metadata_types();
foreach( $maps as $type => $map ){ foreach( $maps as $type => $map ){
foreach ( $map as $metadatum => $details){ foreach ( $map as $metadatum => $details){
$settings['i18n']['helpers_label'][$type][$metadatum] = [ 'title' => $details['title'], 'description' => $details['description'] ]; $settings['i18n']['helpers_label'][$type][$metadatum] = [ 'title' => $details['title'], 'description' => $details['description'] ];
} }
} }
foreach ( $metadata_types as $index => $metadata_type){ foreach ( $metadata_types as $index => $metadata_type){
$class = new $metadata_type; $class = new $metadata_type;
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels(); $settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
} }
$filter_types = $Tainacan_Filters->fetch_filter_types(); $filter_types = $Tainacan_Filters->fetch_filter_types();

View File

@ -8,31 +8,89 @@ function tainacan_blocks_initialize() {
global $wp_version; global $wp_version;
if (is_plugin_active('gutenberg/gutenberg.php') || $wp_version >= '5') { if (is_plugin_active('gutenberg/gutenberg.php') || $wp_version >= '5') {
tainacan_blocks_add_gutenberg_blocks_actions(); add_filter('block_categories', 'tainacan_blocks_register_categories', 10, 2);
add_action('init', 'tainacan_blocks_add_plugin_settings', 90);
add_action('init', 'tainacan_blocks_add_plugin_admin_settings', 90);
add_action('init', 'register_tainacan_blocks_add_gutenberg_blocks');
add_action('wp_enqueue_scripts', 'unregister_taiancan_blocks');
add_action('admin_enqueue_scripts', 'unregister_taiancan_blocks');
} }
} }
function tainacan_blocks_add_gutenberg_blocks_actions() { function register_tainacan_blocks_add_gutenberg_blocks() {
tainacan_blocks_get_common_styles();
tainacan_blocks_register_category_icon();
tainacan_blocks_register_tainacan_terms_list();
tainacan_blocks_register_tainacan_search_bar();
tainacan_blocks_register_tainacan_items_list();
tainacan_blocks_register_tainacan_facets_list();
tainacan_blocks_register_tainacan_faceted_search();
tainacan_blocks_register_tainacan_collections_list();
tainacan_blocks_register_tainacan_dynamic_items_list();
tainacan_blocks_register_tainacan_carousel_items_list();
tainacan_blocks_register_tainacan_carousel_terms_list();
tainacan_blocks_register_tainacan_item_submission_form();
tainacan_blocks_register_tainacan_carousel_collections_list();
}
add_action('init', 'tainacan_blocks_get_common_styles'); function unregister_taiancan_blocks() {
global $post;
if(!$post) return;
add_action('init', 'tainacan_blocks_register_tainacan_terms_list'); $not_allowed = apply_filters('posts-names-to-unregister-taiancan-blocks', []);
add_action('init', 'tainacan_blocks_register_tainacan_items_list'); $current_page = $post->post_name;
add_action('init', 'tainacan_blocks_register_tainacan_dynamic_items_list');
add_action('init', 'tainacan_blocks_register_tainacan_carousel_items_list');
add_action('init', 'tainacan_blocks_register_tainacan_carousel_terms_list');
add_action('init', 'tainacan_blocks_register_tainacan_search_bar');
add_action('init', 'tainacan_blocks_register_tainacan_faceted_search');
add_action('init', 'tainacan_blocks_register_tainacan_collections_list');
add_action('init', 'tainacan_blocks_register_tainacan_carousel_collections_list');
add_action('init', 'tainacan_blocks_register_tainacan_facets_list');
add_action('init', 'tainacan_blocks_register_tainacan_item_submission_form');
add_action('init', 'tainacan_blocks_add_plugin_settings', 90); if ( in_array($current_page, $not_allowed) ) {
add_action('init', 'tainacan_blocks_add_plugin_admin_settings', 90); wp_deregister_script('items-list');
wp_deregister_script('terms-list');
add_filter('block_categories', 'tainacan_blocks_register_categories', 10, 2); wp_deregister_script('facets-list');
add_action('init', 'tainacan_blocks_register_category_icon'); wp_deregister_script('search-bar');
wp_deregister_script('faceted-search');
wp_deregister_script('tainacan-search');
wp_deregister_script('collections-list');
wp_deregister_script('facets-list-theme');
wp_deregister_script('dynamic-items-list');
wp_deregister_script('carousel-items-list');
wp_deregister_script('carousel-terms-list');
wp_deregister_script('item-submission-form');
wp_deregister_script('google-recaptcha-script');
wp_deregister_script('search-bar-theme-script');
wp_deregister_script('tainacan-item-submission');
wp_deregister_script('dynamic-items-list-theme');
wp_deregister_script('carousel-collections-list');
wp_deregister_script('carousel-items-list-theme');
wp_deregister_script('carousel-terms-list-theme');
wp_deregister_script('carousel-collections-list-theme');
wp_deregister_script('tainacan-blocks-register-category-icon');
wp_deregister_style('terms-list');
wp_deregister_style('items-list');
wp_deregister_style('search-bar');
wp_deregister_style('facets-list');
wp_deregister_style('faceted-search');
wp_deregister_style('collections-list');
wp_deregister_style('dynamic-items-list');
wp_deregister_style('carousel-items-list');
wp_deregister_style('carousel-terms-list');
wp_deregister_style('item-submission-form');
wp_deregister_style('carousel-collections-list');
wp_deregister_style('tainacan-blocks-common-styles');
wp_deregister_style('tainacan-blocks-register-category-icon');
if (function_exists('unregister_block_type')) {
unregister_block_type('tainacan/terms-list');
unregister_block_type('tainacan/items-list');
unregister_block_type('tainacan/search-bar');
unregister_block_type('tainacan/facets-list');
unregister_block_type('tainacan/faceted-search');
unregister_block_type('tainacan/collections-list');
unregister_block_type('tainacan/dynamic-items-list');
unregister_block_type('tainacan/carousel-items-list');
unregister_block_type('tainacan/carousel-terms-list');
unregister_block_type('tainacan/item-submission-form');
unregister_block_type('tainacan/carousel-collections-list');
}
}
} }
function tainacan_blocks_register_categories($categories, $post){ function tainacan_blocks_register_categories($categories, $post){
@ -436,7 +494,7 @@ function tainacan_blocks_add_plugin_admin_settings() {
function tainacan_blocks_get_common_styles() { function tainacan_blocks_get_common_styles() {
global $TAINACAN_BASE_URL; global $TAINACAN_BASE_URL;
wp_enqueue_style( wp_enqueue_style(
'tainacan-blocks-common-styles', 'tainacan-blocks-common-styles',
$TAINACAN_BASE_URL . '/assets/css/tainacan-gutenberg-block-common-styles.css', $TAINACAN_BASE_URL . '/assets/css/tainacan-gutenberg-block-common-styles.css',
@ -452,4 +510,4 @@ function tainacan_blocks_register_category_icon() {
$TAINACAN_BASE_URL . '/assets/js/tainacan_blocks_category_icon.js', $TAINACAN_BASE_URL . '/assets/js/tainacan_blocks_category_icon.js',
array('wp-blocks') array('wp-blocks')
); );
} }

View File

@ -322,6 +322,8 @@
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999; z-index: 999;
.dashicon { margin: 0px; }
} }
&:hover button { &:hover button {

View File

@ -95,7 +95,9 @@
right: -14px; right: -14px;
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999 z-index: 999;
.dashicon { margin: 0px; }
} }
&:hover button { &:hover button {

View File

@ -121,7 +121,8 @@ registerBlockType('tainacan/collections-list', {
key={ collection.id } key={ collection.id }
className="collection-list-item" className="collection-list-item"
style={{ marginBottom: layout == 'grid' ? (showName ? gridMargin + 12 : gridMargin) + 'px' : ''}}> style={{ marginBottom: layout == 'grid' ? (showName ? gridMargin + 12 : gridMargin) + 'px' : ''}}>
{ tainacan_blocks.wp_version < '5.4' ? {
tainacan_blocks.wp_version < '5.4' ?
<IconButton <IconButton
onClick={ () => removeCollectionOfId(collection.id) } onClick={ () => removeCollectionOfId(collection.id) }
icon="no-alt" icon="no-alt"
@ -130,7 +131,8 @@ registerBlockType('tainacan/collections-list', {
<Button <Button
onClick={ () => removeCollectionOfId(collection.id) } onClick={ () => removeCollectionOfId(collection.id) }
icon="no-alt" icon="no-alt"
label={__('Remove', 'tainacan')}/> showTooltip={false}
label={__('Remove', 'tainacan')} />
} }
<a <a
id={ isNaN(collection.id) ? collection.id : 'collection-id-' + collection.id } id={ isNaN(collection.id) ? collection.id : 'collection-id-' + collection.id }
@ -156,7 +158,7 @@ registerBlockType('tainacan/collections-list', {
setAttributes({ setAttributes({
content: ( content: (
<ul <ul
style={{ gridTemplateColumns: layout == 'grid' ? 'repeat(auto-fill, ' + (gridMargin + (showName ? 220 : 185)) + 'px)' : 'inherit' }} style={{ gridTemplateColumns: layout == 'grid' ? ('repeat(auto-fill, ' + (gridMargin + (showName ? 220 : 185)) + 'px)') : 'inherit' }}
className={'collections-list collections-layout-' + layout + (!showName ? ' collections-list-without-margin' : '')}> className={'collections-list collections-layout-' + layout + (!showName ? ' collections-list-without-margin' : '')}>
{ selectedCollectionsHTML } { selectedCollectionsHTML }
</ul> </ul>
@ -353,7 +355,7 @@ registerBlockType('tainacan/collections-list', {
}, },
save({ attributes, className }){ save({ attributes, className }){
const { content } = attributes; const { content } = attributes;
return <div className={className}>{ content }</div> return <div className={ className }>{ content }</div>
}, },
deprecated: DeprecatedBlocks deprecated: DeprecatedBlocks
}); });

View File

@ -294,6 +294,8 @@
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999; z-index: 999;
.dashicon { margin: 0px; }
} }
&:hover button { &:hover button {

View File

@ -135,6 +135,7 @@ registerBlockType('tainacan/items-list', {
<Button <Button
onClick={ () => removeItemOfId(item.id) } onClick={ () => removeItemOfId(item.id) }
icon="no-alt" icon="no-alt"
showTooltip={false}
label={__('Remove', 'tainacan')}/> label={__('Remove', 'tainacan')}/>
} }
<a <a

View File

@ -101,6 +101,8 @@
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999; z-index: 999;
.dashicon { margin: 0px; }
} }
&:hover button { &:hover button {

View File

@ -241,6 +241,7 @@ export default class ItemsModal extends React.Component {
className="wp-block-tainacan-modal dynamic-modal" className="wp-block-tainacan-modal dynamic-modal"
title={ __('Select items to add on block', 'tainacan', 'tainacan')} title={ __('Select items to add on block', 'tainacan', 'tainacan')}
onRequestClose={ () => this.cancelSelection() } onRequestClose={ () => this.cancelSelection() }
shouldCloseOnClickOutside={ false }
contentLabel={ __('Select items that will be added on block', 'tainacan', 'tainacan')}> contentLabel={ __('Select items that will be added on block', 'tainacan', 'tainacan')}>
<iframe <iframe
id="itemsFrame" id="itemsFrame"

View File

@ -322,6 +322,8 @@
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999; z-index: 999;
.dashicon { margin: 0px; }
} }
&:hover button { &:hover button {

View File

@ -128,6 +128,7 @@ registerBlockType('tainacan/terms-list', {
<Button <Button
onClick={ () => removeTermOfId(term.id) } onClick={ () => removeTermOfId(term.id) }
icon="no-alt" icon="no-alt"
showTooltip={false}
label={__('Remove', 'tainacan')}/> label={__('Remove', 'tainacan')}/>
} }
<a <a

View File

@ -77,7 +77,9 @@
right: -14px; right: -14px;
top: 0px; top: 0px;
justify-content: center; justify-content: center;
z-index: 999 z-index: 999;
.dashicon { margin: 0px; }
} }
&:hover button { &:hover button {

View File

@ -0,0 +1,421 @@
// TAINACAN MEDIA COMPONENT --------------------------------------------------------
//
// Counts on some HMTL markup to make a list of media links be displayed
// as a carousel with a lightbox. Check examples in the end of the file
import PhotoSwipe from 'photoswipe/dist/photoswipe.min.js';
import PhotoSwipeUI_Default from 'photoswipe/dist/photoswipe-ui-default.min.js';
const { __ } = wp.i18n;
tainacan_plugin.classes.TainacanMediaGallery = class TainacanMediaGallery {
/**
* Constructor initializes the instance. Options are Snake Case because they come from PHP side
* @param {String} thumbs_gallery_selector html element to be queried containing the thumbnails list
* @param {String} main_gallery_selector html element to be queried containing the main list
* @param {Object} options several options to be tweaked
* @param {Object} options.swiper_thumbs_options object with SwiperJS options for the thumbnails list (https://swiperjs.com/swiper-api)
* @param {Object} options.swiper_main_options object with SwiperJS options for the main list
* @param {Boolean} options.show_share_button show share button on lightbox
*
* @return {Object} TainacanMediaGallery instance
*/
constructor(thumbs_gallery_selector, main_gallery_selector, options) {
this.thumbs_gallery_selector = thumbs_gallery_selector;
this.main_gallery_selector = main_gallery_selector;
this.thumbsSwiper = null;
this.mainSwiper = null;
this.options = options;
this.initializeSwiper();
if (this.main_gallery_selector)
this.initPhotoSwipeFromDOM(this.main_gallery_selector + " .swiper-wrapper");
else if (this.thumbs_gallery_selector)
this.initPhotoSwipeFromDOM(this.thumbs_gallery_selector + " .swiper-wrapper");
}
/* Initializes Swiper JS instances of carousels */
initializeSwiper() {
if (this.thumbs_gallery_selector) {
let thumbsSwiperOptions = {
spaceBetween: 12,
slidesPerView: 'auto',
navigation: {
nextEl: '.swiper-navigation-next_' + this.thumbs_gallery_selector,
prevEl: '.swiper-navigation-prev_' + this.thumbs_gallery_selector,
},
pagination: {
el: '.swiper-pagination_' + this.thumbs_gallery_selector
},
centerInsufficientSlides: true,
watchOverflow: true,
a11y: {
prevSlideMessage: __( 'Previous slide', 'tainacan'),
nextSlideMessage: __( 'Next slide', 'tainacan'),
firstSlideMessage: __('This is the first slide', 'tainacan'),
lastSlideMessage: __('This is the last slide', 'tainacan')
},
};
thumbsSwiperOptions = {...thumbsSwiperOptions, ...this.options.swiper_thumbs_options };
this.thumbsSwiper = new Swiper(this.thumbs_gallery_selector, thumbsSwiperOptions);
}
if (this.main_gallery_selector) {
let mainSwiperOptions = {
slidesPerView: 1,
slidesPerGroup: 1,
// navigation: {
// nextEl: '.swiper-navigation-next_' + this.main_gallery_selector,
// prevEl: '.swiper-navigation-prev_' + this.main_gallery_selector,
// },
// pagination: {
// el: '.swiper-pagination_' + this.main_gallery_selector
// },
watchOverflow: true,
a11y: {
prevSlideMessage: __( 'Previous slide', 'tainacan'),
nextSlideMessage: __( 'Next slide', 'tainacan'),
firstSlideMessage: __('This is the first slide', 'tainacan'),
lastSlideMessage: __('This is the last slide', 'tainacan')
},
};
if (this.thumbsSwiper) {
mainSwiperOptions.thumbs = {
swiper: this.thumbsSwiper,
autoScrollOffset: 3
}
}
mainSwiperOptions = {...mainSwiperOptions, ...this.options.swiper_main_options };
this.mainSwiper = new Swiper(this.main_gallery_selector, mainSwiperOptions);
}
if (this.thumbsMain && this.mainSwiper) {
this.mainSwiper.controller = {
control: this.thumbsSwiper,
by: 'slide'
}
}
}
initPhotoSwipeFromDOM (gallerySelector) {
// loop through all gallery elements and bind events
let galleryElement = document.querySelector(gallerySelector);
galleryElement.setAttribute("data-pswp-uid", this.options.media_id);
galleryElement.onclick = (event) => this.onThumbnailsClick(event, this);
// Parse URL and open gallery if it contains #&pid=3&gid=1
let hashData = this.photoswipeParseHash();
if (hashData.pid && hashData.gid)
this.openPhotoSwipe(hashData.pid, galleryElement, true, true);
}
// parse slide data (url, title, size ...) from DOM elements
// (children of gallerySelector)
parseThumbnailElements(el) {
let items = [];
const galleryElements = el.childNodes;
// Crossbrowser safe way to traverse nodeList
Array.prototype.forEach.call(galleryElements, (liElement) => {
// Include only element nodes
if (liElement.nodeType === 1) {
let item = {};
let fullContentElement = liElement.querySelectorAll('.media-full-content *');
if ( !fullContentElement.length ) {
item = {
html: fullContentElement.outerHTML ? fullContentElement.outerHTML : fullContentElement
}
} else {
if (fullContentElement[fullContentElement.length - 1].nodeName === 'IMG') {
fullContentElement = fullContentElement[fullContentElement.length - 1];
item = {
src: fullContentElement.src,
w: parseInt(fullContentElement.width),
h: parseInt(fullContentElement.height)
};
} else {
fullContentElement = fullContentElement[0];
item = {
html: fullContentElement.outerHTML ? fullContentElement.outerHTML : fullContentElement
}
}
}
let metadataElement = liElement.querySelector('.swiper-slide-metadata');
if (metadataElement) {
const name = metadataElement.querySelector('.swiper-slide-metadata__name');
const caption = metadataElement.querySelector('.swiper-slide-metadata__caption');
const description = metadataElement.querySelector('.swiper-slide-metadata__description');
item.title = {
name,
caption,
description
}
} else {
item.title = false;
}
item.el = liElement; // save link to element for getThumbBoundsFn
items.push(item);
}
});
return items;
};
openPhotoSwipe(
index,
galleryElement,
disableAnimation,
fromURL
) {
let pswpElement = document.querySelectorAll(".pswp")[0],
gallery,
options,
items;
items = this.parseThumbnailElements(galleryElement);
// Photoswipe options
// https://photoswipe.com/documentation/options.html //
options = {
showHideOpacity: true,
loop: false,
timeToIdle: 6000,
timeToIdleOutside: 3000,
closeEl: true,
captionEl: true,
fullscreenEl: true,
zoomEl: true,
counterEl: true,
arrowEl: true,
preloaderEl: true,
shareEl: this.options.show_share_button ? this.options.show_share_button : false,
bgOpacity: 1,
// define gallery index (for URL)
galleryUID: galleryElement.getAttribute("data-pswp-uid"),
getThumbBoundsFn: (index) => {
let thumbnail = items[index].el,
pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
rect = thumbnail.getBoundingClientRect();
return { x: rect.left, y: rect.top + pageYScroll, w: rect.width };
},
// Function builds caption markup
addCaptionHTMLFn: (item, captionEl, isFake) => {
// item - slide object
// captionEl - caption DOM element
// isFake - true when content is added to fake caption container
// (used to get size of next or previous caption)
captionEl.children[0].innerHTML = '';
if(!item.title)
return false;
if (item.title.caption)
captionEl.children[0].innerHTML += '<span class="pswp__figure_caption">' + item.title.caption.innerHTML + '</span>';
if (item.title.name && item.title.caption || (!item.title.name && item.title.caption && item.title.description) )
captionEl.children[0].innerHTML += '<br>';
if (item.title.name)
captionEl.children[0].innerHTML += '<span class="pswp__name">' + item.title.name.innerHTML + '</span>';
if (item.title.description && item.title.name)
captionEl.children[0].innerHTML += '<br>';
if (item.title.description)
captionEl.children[0].innerHTML += '<span class="pswp__description">' + item.title.description.innerHTML + '</span>';
return true;
},
};
// PhotoSwipe opened from URL
if (fromURL) {
if (options.galleryPIDs) {
// parse real index when custom PIDs are used
// http://photoswipe.com/documentation/faq.html#custom-pid-in-url
for (let j = 0; j < items.length; j++) {
if (items[j].pid == index) {
options.index = j;
break;
}
}
} else {
// in URL indexes start from 1
options.index = parseInt(index, 10) - 1;
}
} else {
options.index = parseInt(index, 10);
}
// exit if index not found
if (isNaN(options.index))
return;
if (disableAnimation)
options.showAnimationDuration = 0;
// Pass data to PhotoSwipe and initialize it
gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
gallery.init();
/* Updates PhotoSwiper instance from Swiper */
let swiperInstance = this.mainSwiper ? this.mainSwiper : this.thumbsSwiper;
gallery.listen("unbindEvents", () => {
// This is index of current photoswipe slide
let getCurrentIndex = gallery.getCurrentIndex();
// Update position of the slider
swiperInstance.slideTo(getCurrentIndex, 0, false);
// Start swiper autoplay (on close - if swiper autoplay is true)
if (swiperInstance.params && swiperInstance.params.autoplay && swiperInstance.params.autoplay.enabled)
swiperInstance.autoplay.start();
});
// Swiper autoplay stop when image zoom */
gallery.listen('initialZoomIn', () => {
if (swiperInstance.params && swiperInstance.params.autoplay && swiperInstance.params.autoplay.enabled && swiperInstance.autoplay.running)
swiperInstance.autoplay.stop();
});
};
// triggers when user clicks on thumbnail
onThumbnailsClick(e, self) {
e = e || window.event;
e.preventDefault ? e.preventDefault() : (e.returnValue = false);
let eTarget = e.target || e.srcElement;
// find root element of slide
let closest = function closest(el, fn) {
return el && (fn(el) ? el : closest(el.parentNode, fn));
};
let clickedListItem = closest(eTarget, function(el) {
return el.tagName && el.tagName.toUpperCase() === "LI";
});
if (!clickedListItem)
return;
// find index of clicked item by looping through all child nodes
// alternatively, you may define index via data- attribute
let clickedGallery = clickedListItem.parentNode,
childNodes = clickedListItem.parentNode.childNodes,
numChildNodes = childNodes.length,
nodeIndex = 0,
index;
for (let i = 0; i < numChildNodes; i++) {
if (childNodes[i].nodeType !== 1)
continue;
if (childNodes[i] === clickedListItem) {
index = nodeIndex;
break;
}
nodeIndex++;
}
// open PhotoSwipe if valid index found
if (index >= 0)
self.openPhotoSwipe(index, clickedGallery);
return false;
}
// parse picture index and gallery index from URL (#&pid=1&gid=2)
photoswipeParseHash() {
const hash = window.location.hash.substring(1),
params = {};
if (hash.length < 5)
return params;
const vars = hash.split("&");
for (let i = 0; i < vars.length; i++) {
if (!vars[i])
continue;
const pair = vars[i].split("=");
if (pair.length < 2)
continue;
params[pair[0]] = pair[1];
}
if (params.gid)
params.gid = parseInt(params.gid, 10);
return params;
}
}
/* Loads and instantiates media components passed to the global variable */
document.addEventListener('DOMContentLoaded', function() {
if (tainacan_plugin?.classes?.TainacanMediaGallery && tainacan_plugin?.tainacan_media_components) {
(Object.values(tainacan_plugin.tainacan_media_components) || []).forEach((component) => {
new tainacan_plugin.classes.TainacanMediaGallery(
component.has_media_thumbs ? '#' + component.media_thumbs_id : null,
component.has_media_main ? '#' + component.media_main_id : null,
component
);
});
}
});
/*
---- Carousel of thumbnails only ----------------------------------------
<div class="swiper-container-thumbs swiper-container">
<ul class="swiper-wrapper">
<li class="swiper-slide">
<a href="link-to-full-image-or-file">
<img href="link-to-thumbnail" alt..>
<span class="swiper-slide-name>File name</span>
</a>
</li>
</ul>
</div>
new TainacanMediaGallery(.swiper-container-thumbs, null, {...});
---- Carousel of thumbnails with main slider ----------------------------
<div class="swiper-container-main swiper-container">
<ul class="swiper-wrapper">
<li class="swiper-slide">
<a href="link-to-full-image-or-file">
<img href="link-to-medium-or-large" alt..>
<span class="swiper-slide-name>File name</span>
</a>
</li>
</ul>
</div>
<div class="swiper-container-thumbs swiper-container">
<ul class="swiper-wrapper">
<li class="swiper-slide">
<img href="link-to-thumbnail" alt..>
<span class="swiper-slide-name>File name</span>
</li>
</ul>
</div>
new TainacanMediaGallery(.swiper-container-thumbs, .swiper-container-main, {...});
*/

View File

@ -0,0 +1,381 @@
$pswp__show-hide-transition-duration: 333ms !default;
$pswp__controls-transition-duration: 333ms !default;
$pswp__background-color: rgba(0,0,0, 0.8) !default;
$pswp__placeholder-color: #222 !default;
$pswp__box-sizing-border-box: true !default; // disable .pswp * { box-sizing:border-box } (in case you already have it in your site css)
$pswp__root-z-index: 9999999 !default;
$pswp__assets-path: '../images/' !default; // path to skin assets folder (preloader, PNG and SVG sprite)
$pswp__error-text-color: #CCC !default; // "Image not loaded" text color
$pswp__include-minimal-style: true !default;
@import '../../../node_modules/photoswipe/src/css/main.scss';
@import '../../../node_modules/photoswipe/src/css/default-skin/default-skin.scss';
.tainacan-media-component {
--swiper-theme-color: var(--tainacan-secondary, #298596);
--swiper-navigation-size: 44px;
--tainacan-media-background: var(--tainacan-background-color, #ffffff);
--tainacan-media-main-carousel-height: 60vh;
--tainacan-media-main-carousel-width: 100%;
--tainacan-media-thumbs-carousel-width: 100%;
--tainacan-media-thumbs-carousel-item-size: 136px;
width: 100%;
height: auto;
display: block;
background-color: var(--tainacan-media-background, #ffffff);
}
/* Style valid for both cases of carousel, main and thumbs */
.tainacan-media-component__swiper-main,
.tainacan-media-component__swiper-thumbs {
.swiper-button-prev::after,
.swiper-container-rtl .swiper-button-next::after {
content: 'previous';
}
.swiper-button-next::after,
.swiper-button-prev::after {
font-family: "TainacanIcons";
opacity: 0.7;
transition: opacity ease 0.2s;
}
&:hover {
.swiper-button-next::after,
.swiper-button-prev::after {
opacity: 1;
}
}
ul.swiper-wrapper {
list-style: none;
padding: 0;
}
}
.tainacan-media-component__swiper-main {
width: 100%;
max-width: var(--tainacan-media-main-carousel-width, 100%);
ul.swiper-wrapper {
display: flex;
align-items: center;
margin-bottom: 30px;
&[data-pswp-uid] li.swiper-slide img {
cursor: zoom-in !important;
}
}
li.swiper-slide {
height: 100%;
max-width: calc(100% - var(--swiper-navigation-size, 44px) - var(--swiper-navigation-size, 44px));
min-width: 100%;
padding: 0 var(--swiper-navigation-size, 44px);
opacity: 1.0;
transition: opacity 0.2s linear;
&:not(.swiper-slide-active) {
opacity: 0.75;
}
.swiper-slide-metadata {
text-align: center;
&.hide-name .swiper-slide-metadata__name {
display: none;
visibility: hidden;
}
&.hide-description .swiper-slide-metadata__description {
display: none;
visibility: hidden;
}
&.hide-caption .swiper-slide-metadata__caption {
display: none;
visibility: hidden;
}
}
.swiper-slide-metadata__name {
font-size: 1em;
font-weight: bold;
color: var(--tainacan-label-color, #454647);
}
.swiper-slide-metadata__caption {
font-size: 0.9375em;
color: var(--tainacan-input-color, #1d1d1d);
}
.swiper-slide-metadata__caption {
font-size: 0.875em;
color: var(--tainacan-info-color, #555758);
}
}
.swiper-slide-content {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
.tainacan-embed-container {
width: 100%;
height: auto;
}
iframe {
max-height: var(--tainacan-media-main-carousel-height, 60vh);
width: 100%;
max-width: 100%;
border: none;
display: block;
background-image: url('../images/preloader.gif');
background-repeat: no-repeat;
background-position: center;
}
a:first-of-type,
p:first-of-type {
z-index: 99;
background: var(--tainacan-media-background, #ffffff);
border-radius: 3px;
word-wrap: break-word;
}
audio {
background: black;
min-height: 38px;
border-radius: 20px;
width: 100%;
height: auto;
max-height: var(--tainacan-media-main-carousel-height, 60vh);
}
video {
min-height: 56px;
width: 100%;
height: auto;
max-height: var(--tainacan-media-main-carousel-height, 60vh);
}
img {
width: auto;
max-height: var(--tainacan-media-main-carousel-height, 60vh);
}
}
}
.tainacan-media-component__swiper-thumbs {
width: 100%;
max-width: var(--tainacan-media-thumbs-carousel-width, 100%);
ul.swiper-wrapper {
max-width: calc(100% - var(--swiper-navigation-size, 44px) - var(--swiper-navigation-size, 44px));
margin: 0 var(--swiper-navigation-size, 44px);
margin-bottom: 30px;
}
li.swiper-slide {
text-align: center;
vertical-align: top;
word-break: break-all;
font-size: 0.875em;
max-width: calc(var(--tainacan-media-thumbs-carousel-item-size, 136px) + 17px);
cursor: zoom-in;
@media only screen and (max-width: 380px) {
margin: 10px 0;
}
img {
width: var(--tainacan-media-thumbs-carousel-item-size, 136px);
height: var(--tainacan-media-thumbs-carousel-item-size, 136px);
max-width: var(--tainacan-media-thumbs-carousel-item-size, 136px);
max-height: var(--tainacan-media-thumbs-carousel-item-size, 136px);
object-fit: cover;
object-position: center;
border-bottom-width: 6px;
border-bottom-style: solid;
background-color: var(--tainacan-media-background, #ffffff);
border-bottom-color: rgba(255,255,255, 0.0);
opacity: 0.85;
transition: opacity 0.3s ease, border-bottom-color 0.3s ease;
&:focus,
&:hover {
opacity: 0.95;
outline: none;
border-bottom-color: var(--swiper-theme-color, #298596);
}
}
&.swiper-slide-thumb-active {
.swiper-slide-metadata__name {
font-weight: bold;
}
img {
opacity: 1.0;
border-bottom-color: var(--swiper-theme-color, #298596);
}
}
.swiper-slide-metadata__name {
font-size: 1em;
color: var(--tainacan-label-color, #454647);
}
.swiper-slide-metadata__caption {
font-size: 0.9375em;
color: var(--tainacan-input-color, #1d1d1d);
}
.swiper-slide-metadata__caption {
font-size: 0.875em;
color: var(--tainacan-info-color, #555758);
}
.swiper-slide-metadata {
text-align: center;
display: block;
margin-top: 0.5rem;
&.hide-name .swiper-slide-metadata__name {
display: none;
visibility: hidden;
}
&.hide-description .swiper-slide-metadata__description {
display: none;
visibility: hidden;
}
&.hide-caption .swiper-slide-metadata__caption {
display: none;
visibility: hidden;
}
}
a {
width: 100%;
max-width: var(--tainacan-media-thumbs-carousel-item-size, 136px);
text-align: center;
word-break: break-word;
}
a,
a:focus,
a:hover {
outline: none;
text-decoration: none;
color: var(--tainacan-gray5, #454647);
}
}
.swiper-start-border {
position: absolute;
height: 100%;
width: calc(32px + var(--swiper-navigation-size, 44px));
background-image: linear-gradient(90deg, var(--tainacan-media-background, #ffffff) 25%, transparent);
top: 0;
left: 0;
z-index: 1;
}
.swiper-end-border {
position: absolute;
height: 100%;
width: calc(32px + var(--swiper-navigation-size, 44px));
background-image: linear-gradient(90deg, transparent, var(--tainacan-media-background, #ffffff) 75%);
top: 0;
right: 0;
z-index: 1;
}
}
.tainacan-media-component__swiper-main+.tainacan-media-component__swiper-thumbs {
li.swiper-slide {
cursor: pointer;
}
}
// Photoswip zoom ---------------------------------
.tainacan-photoswipe-layer {
.pswp__bg {
background-color: rgba(0, 0, 0, 0.85);
}
.pswp__ui--fit .pswp__top-bar,
.pswp__ui--fit .pswp__caption {
background-color: rgba(0, 0, 0, 0.7);
}
.pswp__button--arrow--left::before,
.pswp__button--arrow--right::before {
background-color: rgba(0, 0, 0, 0.5);
}
.pswp__container {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
.attachment-without-image {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
&.tainacan-embed-container:not(.tainacan-embed-without-iframe) {
padding: 0px;
}
.tainacan-embed-container .twitter-tweet {
width: 100vw !important;
}
}
iframe {
padding: 44px;
min-height: 90vh;
max-height: 90vh;
height: 100%;
width: 100%;
max-width: 100%;
margin: 0 auto;
border: none;
display: block;
background-image: url('../images/preloader.gif');
background-repeat: no-repeat;
background-position: center;
}
a:first-of-type,
p:first-of-type ,
article:first-of-type {
z-index: 99;
padding: 1rem 4.33337vw;
background: var(--tainacan-media-background, #ffffff);
border-radius: var(--borderRadius, 3px);
word-wrap: break-word;
}
audio {
background: black;
min-height: 38px;
border-radius: 20px;
}
video {
min-height: 56px;
}
}
.pswp__top-bar .pswp__name {
color: white;
text-align: center;
font-size: 1.125em;
display: block;
height: 44px;
max-width: calc(100% - 240px);
width: 100%;
left: 44px;
position: absolute;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 44px;
padding: 0 10px;
}
.pswp__figure_caption {
font-size: 0.875em;
font-style: italic;
}
.pswp__description {
font-size: 0.9375em;
}
.pswp__caption__center {
text-align: center;
font-size: 1em;
max-width: 800px;
}
}

View File

@ -574,7 +574,9 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_activitiy_per_user' => __( 'Activities per user', 'tainacan'), 'label_activitiy_per_user' => __( 'Activities per user', 'tainacan'),
'label_report_generated_on' => __( 'Report generated on', 'tainacan'), 'label_report_generated_on' => __( 'Report generated on', 'tainacan'),
'label_get_latest_report' => __( 'Get latest report', 'tainacan'), 'label_get_latest_report' => __( 'Get latest report', 'tainacan'),
'label_decrease' => __( 'Decrease', 'tainacan'),
'label_increase' => __( 'Increase', 'tainacan'),
// Instructions. More complex sentences to guide user and placeholders // Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ), 'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ), 'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ),
@ -855,6 +857,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'info_recaptcha_link_%s' => __( 'Remember to configure your website reCAPTCHA keys on <a href="%s" target="_blank">the item submission repository page</a>.', 'tainacan'), 'info_recaptcha_link_%s' => __( 'Remember to configure your website reCAPTCHA keys on <a href="%s" target="_blank">the item submission repository page</a>.', 'tainacan'),
'info_form_not_loaded' => __( 'There are probably not enought permissions to display it here.', 'tainacan'), 'info_form_not_loaded' => __( 'There are probably not enought permissions to display it here.', 'tainacan'),
'info_validating_slug' => __( 'Validating slug...', 'tainacan'), 'info_validating_slug' => __( 'Validating slug...', 'tainacan'),
'label_amount_of_metadata_of_type' => __( 'Amount of metadata of this type', 'tainacan'), 'label_amount_of_metadata_of_type' => __( 'Amount of metadata of this type', 'tainacan'),
'info_child_terms_chart' => __( 'Click on the term bar on the chart aside to see its child terms (if any) in this panel', 'tainacan' ), 'info_child_terms_chart' => __( 'Click on the term bar on the chart aside to see its child terms (if any) in this panel', 'tainacan' ),
@ -871,6 +874,10 @@ return apply_filters( 'tainacan-admin-i18n', [
'action_delete-attachment' => __( 'Deletion of Attachments', 'tainacan'), 'action_delete-attachment' => __( 'Deletion of Attachments', 'tainacan'),
'action_update-thumbnail' => __( 'Thumbnail Updates', 'tainacan'), 'action_update-thumbnail' => __( 'Thumbnail Updates', 'tainacan'),
'action_others' => __( 'Other Actions', 'tainacan'), 'action_others' => __( 'Other Actions', 'tainacan'),
'info_applied_filters' => __( 'filters applied', 'tainacan'),
'info_items_found' => __( 'items found', 'tainacan'),
'info_applied_filter' => __( 'filter applied', 'tainacan'),
'info_item_found' => __( 'item found', 'tainacan'),
// Datepicker months // Datepicker months
'datepicker_month_january' => __( 'January', 'tainacan' ), 'datepicker_month_january' => __( 'January', 'tainacan' ),

View File

@ -48,7 +48,7 @@ import {
ThumbnailHelperPlugin ThumbnailHelperPlugin
} from '../../admin/js/utilities'; } from '../../admin/js/utilities';
document.addEventListener("DOMContentLoaded", () => { function mountTainacanItemsListComponent() {
// Mount only if the div exists // Mount only if the div exists
if (document.getElementById('tainacan-items-page')) { if (document.getElementById('tainacan-items-page')) {
@ -247,4 +247,22 @@ document.addEventListener("DOMContentLoaded", () => {
// Options... // Options...
}); });
} }
}
// Checks if document is loaded
const performWhenDocumentIsLoaded = callback => {
if (/comp|inter|loaded/.test(document.readyState))
cb();
else
document.addEventListener('DOMContentLoaded', callback, false);
}
// Mounts when page is loaded
performWhenDocumentIsLoaded(() => {
mountTainacanItemsListComponent();
});
// Also if a theme or plugin requested a reset...
document.addEventListener("TainacanReloadItemsListComponent", () => {
mountTainacanItemsListComponent();
}); });

View File

@ -79,7 +79,7 @@
} }
} }
.filters-menu:not(.filters-menu-modal) { .filters-menu:not(.filters-menu-modal) {
z-index: 99999; z-index: 99;
float: left; float: left;
max-width: var(--tainacan-filter-menu-width-theme); max-width: var(--tainacan-filter-menu-width-theme);
min-width: 154px; min-width: 154px;
@ -96,6 +96,7 @@
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
padding: 0; padding: 0;
z-index: 99999;
.modal-content { .modal-content {
top: 0; top: 0;

View File

@ -1154,8 +1154,6 @@ class BulkEdit extends TAINACAN_UnitApiTestCase {
]); ]);
$this->assertEquals(7, $bulk->count_posts()); $this->assertEquals(7, $bulk->count_posts());
} }
/** /**
@ -1206,8 +1204,6 @@ class BulkEdit extends TAINACAN_UnitApiTestCase {
$item_id = $bulk->get_item_id_by_index(30); $item_id = $bulk->get_item_id_by_index(30);
$this->assertFalse($item_id); $this->assertFalse($item_id);
} }
function test_set_multiple_tax_meta() { function test_set_multiple_tax_meta() {
@ -1228,14 +1224,8 @@ class BulkEdit extends TAINACAN_UnitApiTestCase {
'collection_id' => $this->collection->get_id() 'collection_id' => $this->collection->get_id()
]); ]);
$bulk->set_value($this->category, ['super', 'dooper']); $bulk->set_value($this->category, ['super', 'dooper']);
$items = $Tainacan_Items->fetch([ $items = $Tainacan_Items->fetch([
'tax_query' => [ 'tax_query' => [
[ [
@ -1342,6 +1332,4 @@ class BulkEdit extends TAINACAN_UnitApiTestCase {
$this->assertEquals(5, $items->found_posts); $this->assertEquals(5, $items->found_posts);
} }
} }

View File

@ -16,7 +16,7 @@ SKIP_DB_CREATE=${7-false}
download() { download() {
if [ `which curl` ]; then if [ `which curl` ]; then
curl -s "$1" > "$2"; curl -s -L "$1" > "$2";
elif [ `which wget` ]; then elif [ `which wget` ]; then
wget -nv -O "$2" "$1" wget -nv -O "$2" "$1"
fi fi

View File

@ -2,13 +2,16 @@
namespace Tainacan\Tests\Factories; namespace Tainacan\Tests\Factories;
use InvalidArgumentException;
class Entity_Factory { class Entity_Factory {
/** /**
* *
* @var \Tainacan\Entities\Entity * @var \Tainacan\Entities\Entity
*/ */
private $entity; private $entity;
/** /**
* *
* @var \Tainacan\Repositories\Repository * @var \Tainacan\Repositories\Repository
@ -28,19 +31,18 @@ class Entity_Factory {
* *
* @param bool $publish * @param bool $publish
* *
* @throws InvalidArgumentException
*
* @return mixed * @return mixed
* @throws \ErrorException
*/ */
public function create_entity($type, $args = [], $is_validated_and_in_db = false, $publish = false){ public function create_entity($type, $args = [], $is_validated_and_in_db = false, $publish = false){
ini_set('display_errors', 1); ini_set('display_errors', 1);
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
try { try {
$type = trim($type); $type = trim($type);
if(empty($type)){ if(empty($type)){
throw new \InvalidArgumentException('The type can\'t be empty'); throw new InvalidArgumentException('The type can\'t be empty');
} elseif(!strrchr($type, '_')){ } elseif(!strrchr($type, '_')){
$type = ucfirst(strtolower($type)); $type = ucfirst(strtolower($type));
} else { } else {
@ -107,7 +109,7 @@ class Entity_Factory {
$this->entity->validate(); $this->entity->validate();
$this->entity = $this->repository->insert( $this->entity ); $this->entity = $this->repository->insert( $this->entity );
} else { } else {
throw new \InvalidArgumentException('One or more arguments are invalid.'); throw new InvalidArgumentException('One or more arguments are invalid.');
} }
} catch (\Exception $exception){ } catch (\Exception $exception){
echo "\n" . $exception->getMessage() . "\n"; echo "\n" . $exception->getMessage() . "\n";
@ -116,5 +118,3 @@ class Entity_Factory {
return $this->entity; return $this->entity;
} }
} }
?>

View File

@ -16,12 +16,10 @@ use Tainacan\Entities;
class BGProcess extends TAINACAN_UnitApiTestCase { class BGProcess extends TAINACAN_UnitApiTestCase {
function test_table() { function test_table() {
global $wpdb; global $wpdb;
$table_name = $wpdb->prefix . 'tnc_bg_process'; $table_name = $wpdb->prefix . 'tnc_bg_process';
$table_exists = $wpdb->get_var( "SHOW TABLES LIKE '".$table_name."'" ); $table_exists = $wpdb->get_var( "SHOW TABLES LIKE '".$table_name."'" );
$this->assertNotEquals(null, $table_exists); $this->assertNotEquals(null, $table_exists);
@ -29,10 +27,6 @@ class BGProcess extends TAINACAN_UnitApiTestCase {
$column_exists = $wpdb->get_var( "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '{$wpdb->prefix}tnc_bg_process' AND column_name = 'output'" ); $column_exists = $wpdb->get_var( "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '{$wpdb->prefix}tnc_bg_process' AND column_name = 'output'" );
$this->assertEquals('output', $column_exists, 'BG processes table misconfigured'); $this->assertEquals('output', $column_exists, 'BG processes table misconfigured');
} }
} }

View File

@ -79,10 +79,6 @@ class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase {
true true
); );
$term = $this->tainacan_entity_factory->create_entity( $term = $this->tainacan_entity_factory->create_entity(
'term', 'term',
array( array(
@ -237,10 +233,6 @@ class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase {
); );
$this->assertContains($tax3->get_db_identifier(), get_object_taxonomies($collection->get_db_identifier()), 'Taxonommy used by repository level metadatum must be assigned to all collections post types'); $this->assertContains($tax3->get_db_identifier(), get_object_taxonomies($collection->get_db_identifier()), 'Taxonommy used by repository level metadatum must be assigned to all collections post types');
} }
function test_relate_taxonomy_match() { function test_relate_taxonomy_match() {
@ -794,9 +786,6 @@ class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase {
$checkMeta = $Tainacan_Metadata->fetch( $metadatum->get_id() ); $checkMeta = $Tainacan_Metadata->fetch( $metadatum->get_id() );
$this->assertEquals('no', $checkMeta->get_metadata_type_options()['allow_new_terms']); $this->assertEquals('no', $checkMeta->get_metadata_type_options()['allow_new_terms']);
} }
} }

View File

@ -8,7 +8,7 @@ namespace Tainacan\Tests;
* @package Test_Tainacan * @package Test_Tainacan
*/ */
use Tainacan\Entities; use Tainacan\Entities\Item_Metadata_Entity;
/** /**
* Compound Metadatum Types test case. * Compound Metadatum Types test case.
@ -17,10 +17,7 @@ use Tainacan\Entities;
class CompoundMetadatumTypes extends TAINACAN_UnitTestCase { class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
function test_compound_metadata_types() { function test_compound_metadata_types() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',
@ -79,23 +76,21 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
true true
); );
$item_metadata1 = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatum_child1); $item_metadata1 = new Item_Metadata_Entity($i, $metadatum_child1);
$item_metadata1->set_value('Red'); $item_metadata1->set_value('Red');
$item_metadata1->validate(); $item_metadata1->validate();
$item_metadata1 = $Tainacan_Item_Metadata->insert($item_metadata1); $item_metadata1 = $Tainacan_Item_Metadata->insert($item_metadata1);
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatum_child2, null, $item_metadata1->get_parent_meta_id()); $item_metadata = new Item_Metadata_Entity($i, $metadatum_child2, null, $item_metadata1->get_parent_meta_id());
$item_metadata->set_value('Blue'); $item_metadata->set_value('Blue');
$item_metadata->validate(); $item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata); $item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
$compoundItem = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatum); $compoundItem = new Item_Metadata_Entity($i, $metadatum);
global $wpdb;
$compoundValue = $compoundItem->get_value(); $compoundValue = $compoundItem->get_value();
@ -105,17 +100,15 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
$this->assertTrue( isset($compoundValue[$metadatum_child1->get_id()]), 'First element of value must be set' ); $this->assertTrue( isset($compoundValue[$metadatum_child1->get_id()]), 'First element of value must be set' );
$this->assertTrue( isset($compoundValue[$metadatum_child2->get_id()]), 'Second element of value must be set' ); $this->assertTrue( isset($compoundValue[$metadatum_child2->get_id()]), 'Second element of value must be set' );
$this->assertTrue( $compoundValue[$metadatum_child1->get_id()] instanceof \Tainacan\Entities\Item_Metadata_Entity , 'First element of value should be an item metadata entity' ); $this->assertTrue( $compoundValue[$metadatum_child1->get_id()] instanceof Item_Metadata_Entity , 'First element of value should be an item metadata entity' );
$this->assertTrue( $compoundValue[$metadatum_child2->get_id()] instanceof \Tainacan\Entities\Item_Metadata_Entity , 'Second element of value should be an item metadata entity' ); $this->assertTrue( $compoundValue[$metadatum_child2->get_id()] instanceof Item_Metadata_Entity , 'Second element of value should be an item metadata entity' );
$this->assertEquals( 'Red', $compoundValue[$metadatum_child1->get_id()]->get_value() , 'First element of value should have "Red" value' ); $this->assertEquals( 'Red', $compoundValue[$metadatum_child1->get_id()]->get_value() , 'First element of value should have "Red" value' );
$this->assertEquals( 'Blue', $compoundValue[$metadatum_child2->get_id()]->get_value() , 'Second element of value should have "Blue" value' ); $this->assertEquals( 'Blue', $compoundValue[$metadatum_child2->get_id()]->get_value() , 'Second element of value should have "Blue" value' );
} }
function test_multiple_compound_metadata_types() { function test_multiple_compound_metadata_types() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',
@ -124,7 +117,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
), ),
true true
); );
$metadatum = $this->tainacan_entity_factory->create_entity( $metadatum = $this->tainacan_entity_factory->create_entity(
'metadatum', 'metadatum',
array( array(
@ -175,34 +168,30 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
true true
); );
global $wpdb;
// First Instance // First Instance
$item_metadata1 = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatum_child1); $item_metadata1 = new Item_Metadata_Entity($i, $metadatum_child1);
$item_metadata1->set_value('Red'); $item_metadata1->set_value('Red');
$item_metadata1->validate(); $item_metadata1->validate();
$item_metadata1 = $Tainacan_Item_Metadata->insert($item_metadata1); $item_metadata1 = $Tainacan_Item_Metadata->insert($item_metadata1);
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatum_child2, null, $item_metadata1->get_parent_meta_id()); $item_metadata = new Item_Metadata_Entity($i, $metadatum_child2, null, $item_metadata1->get_parent_meta_id());
$item_metadata->set_value('Blue'); $item_metadata->set_value('Blue');
$item_metadata->validate(); $item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata); $item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
// Second Instance // Second Instance
$item_metadata3 = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatum_child1); $item_metadata3 = new Item_Metadata_Entity($i, $metadatum_child1);
$item_metadata3->set_value('Green'); $item_metadata3->set_value('Green');
$item_metadata3->validate(); $item_metadata3->validate();
$item_metadata3 = $Tainacan_Item_Metadata->insert($item_metadata3); $item_metadata3 = $Tainacan_Item_Metadata->insert($item_metadata3);
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatum_child2, null, $item_metadata3->get_parent_meta_id()); $item_metadata = new Item_Metadata_Entity($i, $metadatum_child2, null, $item_metadata3->get_parent_meta_id());
$item_metadata->set_value('Yellow'); $item_metadata->set_value('Yellow');
$item_metadata->validate(); $item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata); $item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
$compoundItem = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatum); $compoundItem = new Item_Metadata_Entity($i, $metadatum);
//var_dump($wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = {$i->get_id()}"));
//var_dump($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE parent = {$metadatum->get_id()}"));
$compoundValue = $compoundItem->get_value(); $compoundValue = $compoundItem->get_value();
$this->assertTrue( is_array($compoundValue), 'value of a compound should return array' ); $this->assertTrue( is_array($compoundValue), 'value of a compound should return array' );
@ -214,8 +203,8 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
$this->assertTrue( isset($compoundValue[0][$metadatum_child1->get_id()]), 'First element of value must be set' ); $this->assertTrue( isset($compoundValue[0][$metadatum_child1->get_id()]), 'First element of value must be set' );
$this->assertTrue( isset($compoundValue[1][$metadatum_child2->get_id()]), 'Second element of value must be set' ); $this->assertTrue( isset($compoundValue[1][$metadatum_child2->get_id()]), 'Second element of value must be set' );
$this->assertTrue( $compoundValue[0][$metadatum_child1->get_id()] instanceof \Tainacan\Entities\Item_Metadata_Entity , 'First element of value should be an item metadata entity' ); $this->assertTrue( $compoundValue[0][$metadatum_child1->get_id()] instanceof Item_Metadata_Entity , 'First element of value should be an item metadata entity' );
$this->assertTrue( $compoundValue[1][$metadatum_child2->get_id()] instanceof \Tainacan\Entities\Item_Metadata_Entity , 'Second element of value should be an item metadata entity' ); $this->assertTrue( $compoundValue[1][$metadatum_child2->get_id()] instanceof Item_Metadata_Entity , 'Second element of value should be an item metadata entity' );
$this->assertEquals( 'Red', $compoundValue[0][$metadatum_child1->get_id()]->get_value() , 'First element of value should have "Red" value' ); $this->assertEquals( 'Red', $compoundValue[0][$metadatum_child1->get_id()]->get_value() , 'First element of value should have "Red" value' );
$this->assertEquals( 'Blue', $compoundValue[0][$metadatum_child2->get_id()]->get_value() , 'Second element of value should have "Blue" value' ); $this->assertEquals( 'Blue', $compoundValue[0][$metadatum_child2->get_id()]->get_value() , 'Second element of value should have "Blue" value' );
@ -224,7 +213,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
$this->assertEquals( 'Yellow', $compoundValue[1][$metadatum_child2->get_id()]->get_value() , 'Second element of value should have "Blue" value' ); $this->assertEquals( 'Yellow', $compoundValue[1][$metadatum_child2->get_id()]->get_value() , 'Second element of value should have "Blue" value' );
$item_metadata_removed = $Tainacan_Item_Metadata->remove_compound_value($i, $metadatum, $item_metadata3->get_parent_meta_id()); $item_metadata_removed = $Tainacan_Item_Metadata->remove_compound_value($i, $metadatum, $item_metadata3->get_parent_meta_id());
$compoundItem = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatum); $compoundItem = new Item_Metadata_Entity($i, $metadatum);
$compoundValue = $compoundItem->get_value(); $compoundValue = $compoundItem->get_value();
$this->assertTrue( is_array($compoundValue), 'value of a compound should return array' ); $this->assertTrue( is_array($compoundValue), 'value of a compound should return array' );
@ -232,13 +221,9 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
$this->assertEquals( 'Red', $compoundValue[0][$metadatum_child1->get_id()]->get_value() , 'First element of value should have "Red" value' ); $this->assertEquals( 'Red', $compoundValue[0][$metadatum_child1->get_id()]->get_value() , 'First element of value should have "Red" value' );
$this->assertEquals( 'Blue', $compoundValue[0][$metadatum_child2->get_id()]->get_value() , 'Second element of value should have "Blue" value' ); $this->assertEquals( 'Blue', $compoundValue[0][$metadatum_child2->get_id()]->get_value() , 'Second element of value should have "Blue" value' );
} }
function test_validations_taxonomy_in_multiple() { function test_validations_taxonomy_in_multiple() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',
array( array(
@ -308,9 +293,6 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
} }
function test_validations_multiple_metadata() { function test_validations_multiple_metadata() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',
array( array(
@ -343,14 +325,10 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
$newMetadatum->set_multiple('no'); $newMetadatum->set_multiple('no');
$this->assertTrue($newMetadatum->validate()); $this->assertTrue($newMetadatum->validate());
} }
function teste_validations_metadada_order() { function test_validations_metadada_order() {
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance(); $Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',

View File

@ -14,7 +14,7 @@ namespace Tainacan\Tests;
class Filters extends TAINACAN_UnitTestCase { class Filters extends TAINACAN_UnitTestCase {
function teste_add(){ function test_add(){
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance(); $Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(

View File

@ -0,0 +1,176 @@
<?php
namespace Tainacan\Tests;
/**
* Class TestCollections
*
* @package Test_Tainacan
*/
/**
* HTML INJECTION test case.
*/
class TAINACAN_HTML_Injection extends TAINACAN_UnitTestCase
{
// Evil attempts
private $link = "<a href='www.tainacan.org'>link</a>";
private $js = "<script>alert('XSS')</script>";
private $css = "my text along with some style <style>a { display: none }</style>";
private $iframe = "<iframe src='www.tainacan.org' title='Taiancan'></iframe>";
private $text_and_link = "";
private $text_and_iframe = "";
// Accepted formatting
private $strong = "I have some info to tell the world. And I can <strong> bold it </strong>";
private $html = "<div><h1>Main Info</h1><h3>sub title</h3><p>My structure description<p></p>and another paragraph</p></div>";
// Expected returns
private $expected_title = 'my very interesting name and link as well';
private $expected_desc = 'description item';
private $collection = null;
private $item = null;
private $metadatum = null;
private $taxonomy = null;
private $taxonomy_db = null;
public function setUp()
{
parent::setUp();
$link = $this->link;
$iframe = $this->iframe;
$this->text_and_link = "my very interesting name and $link as well";
$this->text_and_iframe = "description item $iframe";
$this->test_collections();
}
function test_collections() {
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'collection name <a href="www.tainacan.org">link <a href="link2.com.br"> link2 </a> </a>',
'description' => $this->text_and_iframe,
),
true
);
$collection = $Tainacan_Collections->fetch($collection->get_id());
$this->assertEquals($collection->get_name(), 'collection name link link2');
$this->assertEquals($collection->get_description(), $this->expected_desc);
$this->collection = $collection;
$this->test_items();
}
function test_items() {
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$item = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'title item <script>console.log("XSS")</script>',
'description' => $this->text_and_iframe,
'collection' => $this->collection
),
true
);
$item = $Tainacan_Items->fetch($item->get_id());
$this->assertEquals($item->get_title(), 'title item console.log("XSS")');
$this->assertEquals($item->get_description(), $this->expected_desc);
$this->item = $item;
$this->test_metadata();
}
function test_metadata() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$metadatum = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => $this->text_and_link,
'description' => 'metadatum description',
'collection' => $this->collection,
'metadata_type' => 'Tainacan\Metadata_Types\Text',
),
true
);
$metadatum = $Tainacan_Metadata->fetch($metadatum->get_id());
$this->assertEquals($metadatum->get_name(), $this->expected_title);
$this->metadatum = $metadatum;
$this->test_taxonomies();
}
function test_taxonomies() {
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$taxonomy = $this->tainacan_entity_factory->create_entity(
'taxonomy',
array(
'name' => $this->text_and_link,
'collections' => [$this->collection],
'description' => $this->text_and_iframe,
'status' => 'publish'
),
true
);
$tx = $Tainacan_Taxonomies->fetch($taxonomy->get_id());
$this->assertEquals($tx->get_name(), $this->expected_title);
$this->assertEquals($tx->get_description(), $this->expected_desc);
$this->taxonomy = $taxonomy;
$this->taxonomy_db = $taxonomy->get_db_identifier();
}
function test_terms() {
$Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance();
$term = $this->tainacan_entity_factory->create_entity(
'term',
array(
'taxonomy' => $this->taxonomy_db,
'name' => $this->css,
),
true
);
$t = $Tainacan_Terms->fetch($term->get_term_id(), $this->taxonomy);
$this->assertEquals($t->get_name(), 'my text along with some style');
}
function test_item_metadata() {
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($this->item, $this->metadatum);
$item_metadata->set_value($this->js);
$item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
$this->assertEquals($item_metadata->get_value(), "alert('XSS')");
$item_metadata->set_value($this->link);
$item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->update($item_metadata);
$this->assertEquals($item_metadata->get_value(), 'link');
$item_metadata->set_value($this->css);
$item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->update($item_metadata);
$this->assertEquals($item_metadata->get_value(), 'my text along with some style a { display: none }');
$item_metadata->set_value($this->iframe);
$item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->update($item_metadata);
$this->assertEquals($item_metadata->get_value(), '');
$item_metadata->set_value($this->strong);
$item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->update($item_metadata);
$this->assertEquals($item_metadata->get_value(), $this->strong);
$item_metadata->set_value($this->html);
$item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->update($item_metadata);
$this->assertEquals($item_metadata->get_value(), $this->html);
}
}

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