diff --git a/package-lock.json b/package-lock.json
index 3c52f450d..26e74dbb7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4293,9 +4293,9 @@
"integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA=="
},
"json5": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
- "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
+ "version": "2.2.3",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
+ "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"dev": true
},
"jsprim": {
diff --git a/src/classes/api/endpoints/class-tainacan-rest-items-controller.php b/src/classes/api/endpoints/class-tainacan-rest-items-controller.php
index 6f2ad158e..fa82fb78a 100644
--- a/src/classes/api/endpoints/class-tainacan-rest-items-controller.php
+++ b/src/classes/api/endpoints/class-tainacan-rest-items-controller.php
@@ -423,6 +423,9 @@ class REST_Items_Controller extends REST_Controller {
foreach($tax_query as $tax) {
+ if ( !isset($tax['taxonomy']) || !isset($tax['terms']) )
+ continue;
+
$taxonomy = $tax['taxonomy'];
$taxonomy_id = $this->taxonomies_repository->get_id_by_db_identifier($taxonomy);
$terms_id = is_array($tax['terms']) ? $tax['terms']: [$tax['terms']];
diff --git a/src/classes/class-tainacan-elastic-press.php b/src/classes/class-tainacan-elastic-press.php
index b68d2f7b6..f5e6b3d9e 100644
--- a/src/classes/class-tainacan-elastic-press.php
+++ b/src/classes/class-tainacan-elastic-press.php
@@ -274,6 +274,8 @@ class Elastic_Press {
if( isset($args['tax_query']) ) {
foreach( $args['tax_query'] as $taxquery ) {
+ if ( !isset($tax['taxonomy']) || !isset($tax['terms']) )
+ continue;
if( $taxquery['taxonomy'] === $taxonomy_slug ) {
$include = is_array($taxquery['terms']) ? $taxquery['terms'] : [$taxquery['terms']];
}
@@ -288,6 +290,8 @@ class Elastic_Press {
if( isset($args['meta_query']) ) {
foreach( $args['meta_query'] as $metaquery ) {
+ if ( !isset($meta['key']) || !isset($meta['value']) )
+ continue;
if( isset($metaquery['key']) && $metaquery['key'] == $metadatum_id ){
$include = is_array($metaquery['value']) ? $metaquery['value'] : [$metaquery['value']];
}
diff --git a/src/classes/importer/class-tainacan-csv.php b/src/classes/importer/class-tainacan-csv.php
index 349d0acb0..5f0537967 100644
--- a/src/classes/importer/class-tainacan-csv.php
+++ b/src/classes/importer/class-tainacan-csv.php
@@ -545,7 +545,7 @@ class CSV extends Importer {
$id = $TainacanMedia->insert_attachment_from_file($server_path_files . $correct_value, $item_inserted->get_id());
if(!$id) {
- $this->add_error_log('Error in Document file imported from server ' . $correct_value);
+ $this->add_error_log('Error in Document file imported from server ' . $server_path_files . $correct_value);
return false;
}
@@ -604,7 +604,7 @@ class CSV extends Importer {
$id = $TainacanMedia->insert_attachment_from_file($server_path_files . $attachment, $item_inserted->get_id());
if(!$id) {
- $this->add_log('Error in Attachment file imported from server ' . $attachment);
+ $this->add_log('Error in Attachment file imported from server ' . $server_path_files . $attachment);
continue;
}
diff --git a/src/classes/importer/class-tainacan-flickr-importer.php b/src/classes/importer/class-tainacan-flickr-importer.php
index 920c212ff..6b5f164a0 100644
--- a/src/classes/importer/class-tainacan-flickr-importer.php
+++ b/src/classes/importer/class-tainacan-flickr-importer.php
@@ -5,542 +5,542 @@ use Tainacan\Entities;
class Flickr_Importer extends Importer {
- protected $endPoint = 'https://api.flickr.com/services/rest/?';
- protected $method = 'method=flickr.';
- protected $apiKey = '&api_key=';
- protected $perPage = '&per_page=1';
- protected $format = '&format=json&nojsoncallback=1';
- protected $apiKeyValue = '59dcf7e8e317103416c529b476f44fab';
-
- protected $steps = [
- [
- 'name' => 'Identify URL',
- 'progress_label' => 'Identify URL',
- 'callback' => 'identify_url'
- ],
- [
- 'name' => 'Import Items',
- 'progress_label' => 'Import Items',
- 'callback' => 'process_collections',
- 'total' => 2
- ],
- ];
-
- /**
- * constructor
- */
- public function __construct($attributes = array()) {
- parent::__construct($attributes);
-
- $this->col_repo = \Tainacan\Repositories\Collections::get_instance();
- $this->items_repo = \Tainacan\Repositories\Items::get_instance();
- $this->metadata_repo = \Tainacan\Repositories\Metadata::get_instance();
- $this->item_metadata_repo = \Tainacan\Repositories\Item_Metadata::get_instance();
- $this->tax_repo = \Tainacan\Repositories\Taxonomies::get_instance();
- $this->term_repo = \Tainacan\Repositories\Terms::get_instance();
-
- $this->remove_import_method('file');
- $this->add_import_method('url');
-
- }
-
- /**
- * @inheritdoc
- */
- public function get_source_metadata() {
- $details = $this->identify_url(true);
- $this->apiKeyValue = $this->get_option('api_id');
-
-
- if( $details && $this->apiKeyValue ){
-
- return [
- 'title',
- 'ownername',
- 'tags',
- 'description',
- 'owner',
- 'date_upload',
- 'url',
- 'id',
- 'type',
- 'views',
- 'image_thumbnail',
- 'image_medium',
- 'image_large',
- ];
- } else {
- return [];
- }
- }
-
- /**
- * Method implemented by the child importer class to proccess each item
- * @return array
- */
- public function process_item( $index, $collection_definition ){
- $items_json = $this->get_list_items();
-
- $type = $this->get_transient('url_type');
-
- switch ($type) {
-
- case 'album':
- return $this->process_item_album_request( $items_json, $index, $collection_definition );
-
- case 'user':
- return $this->process_item_user_request( $items_json, $index, $collection_definition );
-
- case 'singlephoto':
- return $this->process_item_single_request( $items_json, $index, $collection_definition );
-
- default:
- return [];
- }
- }
-
- /**
- * method responsible for identify the type of url
- *
- * @param bool $showDetails
- * @return array|bool
- */
- public function identify_url( $showDetails = false ){
- $url = $this->get_url();
- $details = [];
- $matches = [];
-
- $preg_entities = [
- 'album' => 'albums\/(([^\/])+)',
- 'singlephoto' => '(([^\/])+?)\/in\/',
- 'user' => 'photos\/(([^\/])+)', //match YouTube user from url
- ];
-
-
- foreach ( $preg_entities as $key => $preg_entity ) {
- //var_dump(preg_match( $preg_entity, $url, $matches ));
- if ( preg_match( '/' . $preg_entity . '/', $url, $matches ) ) {
- if ( isset( $matches[1] ) ) {
- $details = [
- 'type' => $key,
- 'id' => $matches[1],
- ];
- break;
- }
- }
- }
-
- if( !$details ) {
- $this->add_error_log('None url from flickr has found');
- $this->abort();
- return false;
- } else {
- $this->add_transient( 'url_type', $details['type'] );
- $this->add_transient( 'flickr_id', $details['id'] );
- return ( !$showDetails ) ? false : $details;
- }
-
- }
-
- /**
- * @inheritdoc
- */
- public function get_source_number_of_items() {
- $type = $this->get_transient('url_type');
-
- switch ($type) {
- case 'singlephoto':
- return 1;
- break;
-
- default:
- $json = $this->get_list_items();
-
- if( isset( $json->photos ) && isset( $json->photos->total ) ){
- return $json->photos->total;
- } else if( isset( $json->photoset ) && isset( $json->photoset->total ) ){
- return $json->photoset->total;
- }
- break;
- }
-
- return 0;
- }
-
- /**
- * return the list of items for the different types of url
- *
- * @return array|mixed
- */
- private function get_list_items() {
- $type = $this->get_transient('url_type');
- $id = $this->get_transient('flickr_id');
- $pageToken = $this->get_transient('pageToken');
-
- switch ($type) {
-
- case 'album':
- $api_url = $this->endPoint .
- $this->method . 'photosets.getPhotos' .
- $this->apiKey . $this->apiKeyValue . '&photoset_id=' . $id .
- '&extras=license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_o' .
- $this->perPage . '&page=' . $pageToken . $this->format;
-
- $this->add_log('url ' . $api_url);
-
- $response = wp_remote_get( $api_url );
- $body = wp_remote_retrieve_body( $response );
- $json = json_decode($body);
- if( $json && isset($json->photoset) ){
- return $json;
- }
- break;
-
- case 'user':
- $api_url = $this->endPoint .
- $this->method . 'photos.search' .
- $this->apiKey . $this->apiKeyValue . '&user_id=' . $id .
- '&sort=date-posted-asc&content_type=1&extras=license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_o' .
- $this->perPage . '&page=' . $pageToken . $this->format;
-
- $this->add_log('url ' . $api_url);
-
- $response = wp_remote_get( $api_url );
- $body = wp_remote_retrieve_body( $response );
- $json = json_decode($body);
-
- if( $json && isset($json->photos) ){
- return $json;
-
- }
- break;
-
- case 'singlephoto':
- $api_url = $this->endPoint .
- $this->method . 'photos.getInfo' .
- $this->apiKey . $this->apiKeyValue . '&extras=license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_o&photo_id='
- . $id . $this->format;
-
- $this->add_log('url ' . $api_url);
-
- $response = wp_remote_get( $api_url );
- $body = wp_remote_retrieve_body( $response );
- $json = json_decode($body);
- if( $json && isset($json->photo) ){
- return $json;
-
- }
- break;
-
- default:
- return [];
- break;
- }
-
- return [];
- }
-
- /**
- * get raw user request and return data from specific index
- *
- * @param $items_json
- * @param $index
- * @param $collection_definition
- * @return array
- * @throws \Exception
- */
- private function process_item_user_request( $items_json, $index, $collection_definition ){
- $processedItem = [];
-
- if ( $items_json && $items_json->photos ) {
- $item = $items_json->photos->photo[0];
-
- $id = $this->get_transient('insertedId');
-
- if ($id && $id === $item->id ) {
- return false;
- }
-
- $items_json_from_item = $this->get_item_data( $item->id );
- $processedItem = $this->process_item_single_request( $items_json_from_item, $index, $collection_definition );
-
- $token = $index + 2;
- $this->add_log('nextToken ' . $token);
- if ( $token ) {
- $this->add_transient( 'pageToken', $token );
- }
-
- $this->add_transient( 'insertedId', $item->id );
- }
-
- return $processedItem;
- }
-
- /**
- * get raw album request and return data from specific index
- *
- * @param $items_json
- * @param $index
- * @param $collection_definition
- * @return array
- * @throws \Exception
- */
- private function process_item_album_request( $items_json, $index, $collection_definition ){
- $processedItem = [];
-
- if ( $items_json && $items_json->photoset ) {
- $item = $items_json->photoset->photo[0];
-
- $id = $this->get_transient('insertedId');
-
- if ($id && $id === $item->id ) {
- return false;
- }
-
- $items_json_from_item = $this->get_item_data( $item->id );
- $processedItem = $this->process_item_single_request( $items_json_from_item, $index, $collection_definition );
-
- $token = $index + 2;
- $this->add_log('nextToken ' . $token);
- if ( $token ) {
- $this->add_transient( 'pageToken', $token );
- }
-
- $this->add_transient( 'insertedId', $item->id );
- }
-
- return $processedItem;
- }
-
- /**
- * get raw item request and return data from specific index
- *
- * @param $items_json
- * @param $index
- * @param $collection_definition
- * @return array
- * @throws \Exception
- */
- private function process_item_single_request( $items_json, $index, $collection_definition ){
- $processedItem = [];
-
- if ( $items_json && $items_json->photo ) {
- $item = $items_json->photo;
-
- $id = $this->get_transient('insertedId');
-
- if ($id && $id === $item->id ) {
- return false;
- }
-
- $url_image = 'https://farm' . $item->farm . '.staticflickr.com/' . $item->server . '/' . $item->id . '_' . $item->secret . '_b.jpg';
- $this->add_transient('image_url', $url_image);
-
- foreach ($collection_definition['mapping'] as $metadatum_id => $raw_metadatum) {
- $value = '';
-
- switch ($raw_metadatum) {
- case 'title':
- $value = $item->title->_content;
- break;
-
- case 'ownername':
- $value = $item->owner->username;
- break;
-
- case 'tags':
- $tags = [];
-
- if ( isset( $item->tags ) && isset( $item->tags->tag ) && is_array( $item->tags->tag ) ) {
- foreach ( $item->tags->tag as $tag ) {
- if (isset($tag->raw)) {
+ protected $endPoint = 'https://api.flickr.com/services/rest/?';
+ protected $method = 'method=flickr.';
+ protected $apiKey = '&api_key=';
+ protected $perPage = '&per_page=1';
+ protected $format = '&format=json&nojsoncallback=1';
+ protected $apiKeyValue = '59dcf7e8e317103416c529b476f44fab';
+
+ protected $steps = [
+ [
+ 'name' => 'Identify URL',
+ 'progress_label' => 'Identify URL',
+ 'callback' => 'identify_url'
+ ],
+ [
+ 'name' => 'Import Items',
+ 'progress_label' => 'Import Items',
+ 'callback' => 'process_collections',
+ 'total' => 2
+ ],
+ ];
+
+ /**
+ * constructor
+ */
+ public function __construct($attributes = array()) {
+ parent::__construct($attributes);
+
+ $this->col_repo = \Tainacan\Repositories\Collections::get_instance();
+ $this->items_repo = \Tainacan\Repositories\Items::get_instance();
+ $this->metadata_repo = \Tainacan\Repositories\Metadata::get_instance();
+ $this->item_metadata_repo = \Tainacan\Repositories\Item_Metadata::get_instance();
+ $this->tax_repo = \Tainacan\Repositories\Taxonomies::get_instance();
+ $this->term_repo = \Tainacan\Repositories\Terms::get_instance();
+
+ $this->remove_import_method('file');
+ $this->add_import_method('url');
+
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_source_metadata() {
+ $details = $this->identify_url(true);
+ $this->apiKeyValue = $this->get_option('api_id');
+
+
+ if( $details && $this->apiKeyValue ){
+
+ return [
+ 'title',
+ 'ownername',
+ 'tags',
+ 'description',
+ 'owner',
+ 'date_upload',
+ 'url',
+ 'id',
+ 'type',
+ 'views',
+ 'image_thumbnail',
+ 'image_medium',
+ 'image_large',
+ ];
+ } else {
+ return [];
+ }
+ }
+
+ /**
+ * Method implemented by the child importer class to proccess each item
+ * @return array
+ */
+ public function process_item( $index, $collection_definition ){
+ $items_json = $this->get_list_items();
+
+ $type = $this->get_transient('url_type');
+
+ switch ($type) {
+
+ case 'album':
+ return $this->process_item_album_request( $items_json, $index, $collection_definition );
+
+ case 'user':
+ return $this->process_item_user_request( $items_json, $index, $collection_definition );
+
+ case 'singlephoto':
+ return $this->process_item_single_request( $items_json, $index, $collection_definition );
+
+ default:
+ return [];
+ }
+ }
+
+ /**
+ * method responsible for identify the type of url
+ *
+ * @param bool $showDetails
+ * @return array|bool
+ */
+ public function identify_url( $showDetails = false ){
+ $url = $this->get_url();
+ $details = [];
+ $matches = [];
+
+ $preg_entities = [
+ 'album' => 'albums\/(([^\/])+)',
+ 'singlephoto' => '(([^\/])+?)\/in\/',
+ 'user' => 'photos\/(([^\/])+)', //match YouTube user from url
+ ];
+
+
+ foreach ( $preg_entities as $key => $preg_entity ) {
+ //var_dump(preg_match( $preg_entity, $url, $matches ));
+ if ( preg_match( '/' . $preg_entity . '/', $url, $matches ) ) {
+ if ( isset( $matches[1] ) ) {
+ $details = [
+ 'type' => $key,
+ 'id' => $matches[1],
+ ];
+ break;
+ }
+ }
+ }
+
+ if( !$details ) {
+ $this->add_error_log('None url from flickr has found');
+ $this->abort();
+ return false;
+ } else {
+ $this->add_transient( 'url_type', $details['type'] );
+ $this->add_transient( 'flickr_id', $details['id'] );
+ return ( !$showDetails ) ? false : $details;
+ }
+
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_source_number_of_items() {
+ $type = $this->get_transient('url_type');
+
+ switch ($type) {
+ case 'singlephoto':
+ return 1;
+ break;
+
+ default:
+ $json = $this->get_list_items();
+
+ if( isset( $json->photos ) && isset( $json->photos->total ) ){
+ return $json->photos->total;
+ } else if( isset( $json->photoset ) && isset( $json->photoset->total ) ){
+ return $json->photoset->total;
+ }
+ break;
+ }
+
+ return 0;
+ }
+
+ /**
+ * return the list of items for the different types of url
+ *
+ * @return array|mixed
+ */
+ private function get_list_items() {
+ $type = $this->get_transient('url_type');
+ $id = $this->get_transient('flickr_id');
+ $pageToken = $this->get_transient('pageToken');
+
+ switch ($type) {
+
+ case 'album':
+ $api_url = $this->endPoint .
+ $this->method . 'photosets.getPhotos' .
+ $this->apiKey . $this->apiKeyValue . '&photoset_id=' . $id .
+ '&extras=license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_o' .
+ $this->perPage . '&page=' . $pageToken . $this->format;
+
+ $this->add_log('url ' . $api_url);
+
+ $response = wp_remote_get( $api_url );
+ $body = wp_remote_retrieve_body( $response );
+ $json = json_decode($body);
+ if( $json && isset($json->photoset) ){
+ return $json;
+ }
+ break;
+
+ case 'user':
+ $api_url = $this->endPoint .
+ $this->method . 'photos.search' .
+ $this->apiKey . $this->apiKeyValue . '&user_id=' . $id .
+ '&sort=date-posted-asc&content_type=1&extras=license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_o' .
+ $this->perPage . '&page=' . $pageToken . $this->format;
+
+ $this->add_log('url ' . $api_url);
+
+ $response = wp_remote_get( $api_url );
+ $body = wp_remote_retrieve_body( $response );
+ $json = json_decode($body);
+
+ if( $json && isset($json->photos) ){
+ return $json;
+
+ }
+ break;
+
+ case 'singlephoto':
+ $api_url = $this->endPoint .
+ $this->method . 'photos.getInfo' .
+ $this->apiKey . $this->apiKeyValue . '&extras=license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_o&photo_id='
+ . $id . $this->format;
+
+ $this->add_log('url ' . $api_url);
+
+ $response = wp_remote_get( $api_url );
+ $body = wp_remote_retrieve_body( $response );
+ $json = json_decode($body);
+ if( $json && isset($json->photo) ){
+ return $json;
+
+ }
+ break;
+
+ default:
+ return [];
+ break;
+ }
+
+ return [];
+ }
+
+ /**
+ * get raw user request and return data from specific index
+ *
+ * @param $items_json
+ * @param $index
+ * @param $collection_definition
+ * @return array
+ * @throws \Exception
+ */
+ private function process_item_user_request( $items_json, $index, $collection_definition ){
+ $processedItem = [];
+
+ if ( $items_json && $items_json->photos ) {
+ $item = $items_json->photos->photo[0];
+
+ $id = $this->get_transient('insertedId');
+
+ if ($id && $id === $item->id ) {
+ return false;
+ }
+
+ $items_json_from_item = $this->get_item_data( $item->id );
+ $processedItem = $this->process_item_single_request( $items_json_from_item, $index, $collection_definition );
+
+ $token = $index + 2;
+ $this->add_log('nextToken ' . $token);
+ if ( $token ) {
+ $this->add_transient( 'pageToken', $token );
+ }
+
+ $this->add_transient( 'insertedId', $item->id );
+ }
+
+ return $processedItem;
+ }
+
+ /**
+ * get raw album request and return data from specific index
+ *
+ * @param $items_json
+ * @param $index
+ * @param $collection_definition
+ * @return array
+ * @throws \Exception
+ */
+ private function process_item_album_request( $items_json, $index, $collection_definition ){
+ $processedItem = [];
+
+ if ( $items_json && $items_json->photoset ) {
+ $item = $items_json->photoset->photo[0];
+
+ $id = $this->get_transient('insertedId');
+
+ if ($id && $id === $item->id ) {
+ return false;
+ }
+
+ $items_json_from_item = $this->get_item_data( $item->id );
+ $processedItem = $this->process_item_single_request( $items_json_from_item, $index, $collection_definition );
+
+ $token = $index + 2;
+ $this->add_log('nextToken ' . $token);
+ if ( $token ) {
+ $this->add_transient( 'pageToken', $token );
+ }
+
+ $this->add_transient( 'insertedId', $item->id );
+ }
+
+ return $processedItem;
+ }
+
+ /**
+ * get raw item request and return data from specific index
+ *
+ * @param $items_json
+ * @param $index
+ * @param $collection_definition
+ * @return array
+ * @throws \Exception
+ */
+ private function process_item_single_request( $items_json, $index, $collection_definition ){
+ $processedItem = [];
+
+ if ( $items_json && $items_json->photo ) {
+ $item = $items_json->photo;
+
+ $id = $this->get_transient('insertedId');
+
+ if ($id && $id === $item->id ) {
+ return false;
+ }
+
+ $url_image = 'https://farm' . $item->farm . '.staticflickr.com/' . $item->server . '/' . $item->id . '_' . $item->secret . '_b.jpg';
+ $this->add_transient('image_url', $url_image);
+
+ foreach ($collection_definition['mapping'] as $metadatum_id => $raw_metadatum) {
+ $value = '';
+
+ switch ($raw_metadatum) {
+ case 'title':
+ $value = $item->title->_content;
+ break;
+
+ case 'ownername':
+ $value = $item->owner->username;
+ break;
+
+ case 'tags':
+ $tags = [];
+
+ if ( isset( $item->tags ) && isset( $item->tags->tag ) && is_array( $item->tags->tag ) ) {
+ foreach ( $item->tags->tag as $tag ) {
+ if (isset($tag->raw)) {
$tags[] = $tag->raw;
}
- }
- }
+ }
+ }
- $value = ( $tags ) ? $tags : [];
- break;
+ $value = ( $tags ) ? $tags : [];
+ break;
- case 'id':
- $value = $item->id;
- break;
+ case 'id':
+ $value = $item->id;
+ break;
- case 'description':
- $value = $item->description->_content;
- break;
+ case 'description':
+ $value = $item->description->_content;
+ break;
- case 'owner':
- $value = $item->owner->nsid;
- break;
+ case 'owner':
+ $value = $item->owner->nsid;
+ break;
- case 'url':
+ case 'url':
- if ( isset( $item->urls->url ) && !empty( $item->urls->url ) ) {
- $url = $item->urls->url[0];
- $value = $url->_content;
- } else {
- $value = $url_image;
- }
+ if ( isset( $item->urls->url ) && !empty( $item->urls->url ) ) {
+ $url = $item->urls->url[0];
+ $value = $url->_content;
+ } else {
+ $value = $url_image;
+ }
- break;
+ break;
- case 'date_upload':
- $value = date('Y-m-d', $item->dateuploaded );
- break;
+ case 'date_upload':
+ $value = date('Y-m-d', $item->dateuploaded );
+ break;
- case 'image_thumbnail':
- $value = 'https://farm' . $item->farm . '.staticflickr.com/' . $item->server . '/' . $item->id . '_' . $item->secret . '_t.jpg';
- break;
+ case 'image_thumbnail':
+ $value = 'https://farm' . $item->farm . '.staticflickr.com/' . $item->server . '/' . $item->id . '_' . $item->secret . '_t.jpg';
+ break;
- case 'image_medium':
- $value = 'https://farm' . $item->farm . '.staticflickr.com/' . $item->server . '/' . $item->id . '_' . $item->secret . '.jpg';
- break;
+ case 'image_medium':
+ $value = 'https://farm' . $item->farm . '.staticflickr.com/' . $item->server . '/' . $item->id . '_' . $item->secret . '.jpg';
+ break;
- case 'image_large':
- $value = 'https://farm' . $item->farm . '.staticflickr.com/' . $item->server . '/' . $item->id . '_' . $item->secret . '_c.jpg';
- break;
+ case 'image_large':
+ $value = 'https://farm' . $item->farm . '.staticflickr.com/' . $item->server . '/' . $item->id . '_' . $item->secret . '_c.jpg';
+ break;
- case 'views':
- $value = $item->views;
- break;
+ case 'views':
+ $value = $item->views;
+ break;
- case 'type':
- $value = $this->get_image_mime_type( $url_image );
- break;
- }
+ case 'type':
+ $value = $this->get_image_mime_type( $url_image );
+ break;
+ }
- $metadatum = new \Tainacan\Entities\Metadatum($metadatum_id);
- $processedItem[$raw_metadatum] = ( $metadatum->is_multiple() && !is_array($value) ) ? [$value] : $value;
- }
+ $metadatum = new \Tainacan\Entities\Metadatum($metadatum_id);
+ $processedItem[$raw_metadatum] = ( $metadatum->is_multiple() && !is_array($value) ) ? [$value] : $value;
+ }
- $this->add_transient( 'insertedId', $item->id );
- }
+ $this->add_transient( 'insertedId', $item->id );
+ }
- return $processedItem;
- }
+ return $processedItem;
+ }
- /**
- * method responsible to get data from a unique photo
- *
- * @param $id
- * @return mixed
- */
- private function get_item_data( $id ){
- $api_url = $this->endPoint .
- $this->method . 'photos.getInfo' .
- $this->apiKey . $this->apiKeyValue . '&extras=license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_o&photo_id='
- . $id . $this->format;
+ /**
+ * method responsible to get data from a unique photo
+ *
+ * @param $id
+ * @return mixed
+ */
+ private function get_item_data( $id ){
+ $api_url = $this->endPoint .
+ $this->method . 'photos.getInfo' .
+ $this->apiKey . $this->apiKeyValue . '&extras=license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_o&photo_id='
+ . $id . $this->format;
- $this->add_log('url ' . $api_url);
- $response = wp_remote_get( $api_url );
- $body = wp_remote_retrieve_body( $response );
- $json = json_decode($body);
- if( $json && isset($json->photo) ){
- return $json;
+ $this->add_log('url ' . $api_url);
+ $response = wp_remote_get( $api_url );
+ $body = wp_remote_retrieve_body( $response );
+ $json = json_decode($body);
+ if( $json && isset($json->photo) ){
+ return $json;
- }
- }
+ }
+ }
- /**
- * @inheritdoc
- */
- public function after_inserted_item( $inserted_item, $collection_index ) {
- $image_url = $this->get_transient('image_url');
+ /**
+ * @inheritdoc
+ */
+ public function after_inserted_item( $inserted_item, $collection_index ) {
+ $image_url = $this->get_transient('image_url');
- if( isset( $image_url ) && $image_url ){
- $TainacanMedia = \Tainacan\Media::get_instance();
- $id = $TainacanMedia->insert_attachment_from_url( $image_url, $inserted_item->get_id() );
- $inserted_item->set__thumbnail_id( $id );
+ if( isset( $image_url ) && $image_url ){
+ $TainacanMedia = \Tainacan\Media::get_instance();
+ $id = $TainacanMedia->insert_attachment_from_url( $image_url, $inserted_item->get_id() );
+ $inserted_item->set__thumbnail_id( $id );
- $inserted_item->set_document( $id );
- $inserted_item->set_document_type( 'attachment' );
- }
+ $inserted_item->set_document( $id );
+ $inserted_item->set_document_type( 'attachment' );
+ }
- if( $inserted_item->validate() )
- $this->items_repo->update($inserted_item);
- }
+ if( $inserted_item->validate() )
+ $this->items_repo->update($inserted_item);
+ }
- /**
- * @param $collection_id int the collection id
- * @param $mapping array the headers-metadata mapping
- */
- public function save_mapping( $collection_id, $mapping ){
- update_post_meta( $collection_id, 'metadata_mapping', $mapping );
- }
+ /**
+ * @param $collection_id int the collection id
+ * @param $mapping array the headers-metadata mapping
+ */
+ public function save_mapping( $collection_id, $mapping ){
+ update_post_meta( $collection_id, 'metadata_mapping', $mapping );
+ }
- /**
- * @param $collection_id
- *
- * @return array/bool false if has no mapping or associated array with metadata id and header
- */
- public function get_mapping( $collection_id ){
- $mapping = get_post_meta( $collection_id, 'metadata_mapping', true );
- return ( $mapping ) ? $mapping : false;
- }
+ /**
+ * @param $collection_id
+ *
+ * @return array/bool false if has no mapping or associated array with metadata id and header
+ */
+ public function get_mapping( $collection_id ){
+ $mapping = get_post_meta( $collection_id, 'metadata_mapping', true );
+ return ( $mapping ) ? $mapping : false;
+ }
- /**
- * @inheritdoc
- *
- * allow save mapping
- */
- public function add_collection(array $collection) {
- if (isset($collection['id'])) {
+ /**
+ * @inheritdoc
+ *
+ * allow save mapping
+ */
+ public function add_collection(array $collection) {
+ if (isset($collection['id'])) {
- if( isset($collection['mapping']) && is_array($collection['mapping']) ){
+ if( isset($collection['mapping']) && is_array($collection['mapping']) ){
- foreach( $collection['mapping'] as $metadatum_id => $header ){
+ foreach( $collection['mapping'] as $metadatum_id => $header ){
- if( !is_numeric($metadatum_id) ) {
- $create_string = $header;
+ if( !is_numeric($metadatum_id) ) {
+ $create_string = $header;
if ($header == 'tags') {
$create_string = 'Tags|taxonomy|multiple';
}
$metadatum = $this->create_new_metadata( $create_string, $collection['id']);
- if( is_object($metadatum) ){
- unset($collection['mapping'][$metadatum_id]);
- $collection['mapping'][$metadatum->get_id()] = $header;
- }
+ if( is_object($metadatum) ){
+ unset($collection['mapping'][$metadatum_id]);
+ $collection['mapping'][$metadatum->get_id()] = $header;
+ }
- }
- }
+ }
+ }
- $this->save_mapping( $collection['id'], $collection['mapping'] );
- }
+ $this->save_mapping( $collection['id'], $collection['mapping'] );
+ }
- $this->remove_collection($collection['id']);
- $this->collections[] = $collection;
- }
- }
+ $this->remove_collection($collection['id']);
+ $this->collections[] = $collection;
+ }
+ }
- /**
- * @param $image_path
- * @return bool|mixed
- */
- private function get_image_mime_type($image_path) {
- $mimes = array(
- IMAGETYPE_GIF => "image/gif",
- IMAGETYPE_JPEG => "image/jpg",
- IMAGETYPE_PNG => "image/png",
- IMAGETYPE_SWF => "image/swf",
- IMAGETYPE_PSD => "image/psd",
- IMAGETYPE_BMP => "image/bmp",
- IMAGETYPE_TIFF_II => "image/tiff",
- IMAGETYPE_TIFF_MM => "image/tiff",
- IMAGETYPE_JPC => "image/jpc",
- IMAGETYPE_JP2 => "image/jp2",
- IMAGETYPE_JPX => "image/jpx",
- IMAGETYPE_JB2 => "image/jb2",
- IMAGETYPE_SWC => "image/swc",
- IMAGETYPE_IFF => "image/iff",
- IMAGETYPE_WBMP => "image/wbmp",
- IMAGETYPE_XBM => "image/xbm",
- IMAGETYPE_ICO => "image/ico");
+ /**
+ * @param $image_path
+ * @return bool|mixed
+ */
+ private function get_image_mime_type($image_path) {
+ $mimes = array(
+ IMAGETYPE_GIF => "image/gif",
+ IMAGETYPE_JPEG => "image/jpg",
+ IMAGETYPE_PNG => "image/png",
+ IMAGETYPE_SWF => "image/swf",
+ IMAGETYPE_PSD => "image/psd",
+ IMAGETYPE_BMP => "image/bmp",
+ IMAGETYPE_TIFF_II => "image/tiff",
+ IMAGETYPE_TIFF_MM => "image/tiff",
+ IMAGETYPE_JPC => "image/jpc",
+ IMAGETYPE_JP2 => "image/jp2",
+ IMAGETYPE_JPX => "image/jpx",
+ IMAGETYPE_JB2 => "image/jb2",
+ IMAGETYPE_SWC => "image/swc",
+ IMAGETYPE_IFF => "image/iff",
+ IMAGETYPE_WBMP => "image/wbmp",
+ IMAGETYPE_XBM => "image/xbm",
+ IMAGETYPE_ICO => "image/ico");
if (function_exists('exif_imagetype')) {
if ( $image_type = exif_imagetype($image_path)
@@ -549,58 +549,58 @@ class Flickr_Importer extends Importer {
}
}
- return false;
-
- }
+ return false;
+
+ }
- public function options_form(){
- ob_start();
- ?>
-
-
-
-
-
- ', __('https://www.flickr.com/services/api/misc.api_keys.html', 'tainacan') ),
- ''
- ); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- https://www.flickr.com/photos/username
-
- -
- https://www.flickr.com/photos/username/albums/123456
-
- -
- https://www.flickr.com/photos/username/123456
-
-
-
-
-
-
-
+
+
+
+
+
+ ', __('https://www.flickr.com/services/api/misc.api_keys.html', 'tainacan') ),
+ ''
+ ); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ https://www.flickr.com/photos/username
+
+ -
+ https://www.flickr.com/photos/username/albums/123456
+
+ -
+ https://www.flickr.com/photos/username/123456
+
+
+
+
+
+
+
+
+
+ {{ $i18n.get('info_item_submission_draft_status') }}
+
+
diff --git a/src/views/admin/components/lists/metadata-types-list.vue b/src/views/admin/components/lists/metadata-types-list.vue
index f582d72b6..b595122ef 100644
--- a/src/views/admin/components/lists/metadata-types-list.vue
+++ b/src/views/admin/components/lists/metadata-types-list.vue
@@ -14,7 +14,7 @@
drag-class="sortable-drag">
+
+
+
+
+
@@ -159,6 +173,7 @@
taxonomy: '',
loading: false,
allow_new_terms: 'yes',
+ hide_hierarchy_path: 'no',
link_filtered_by_collections: [],
visible_options_list: false,
input_type: 'tainacan-taxonomy-radio',
@@ -230,6 +245,7 @@
this.taxonomy_id = this.value.taxonomy_id;
this.allow_new_terms = ( this.value.allow_new_terms ) ? this.value.allow_new_terms : 'no';
+ this.hide_hierarchy_path = ( this.value.hide_hierarchy_path ) ? this.value.hide_hierarchy_path : 'no';
if (this.metadatum && this.metadatum.multiple === 'no') {
let types = Object.keys( this.single_types );
@@ -296,6 +312,7 @@
allow_new_terms: this.allow_new_terms,
visible_options_list: this.visible_options_list,
link_filtered_by_collections: this.link_filtered_by_collections,
+ hide_hierarchy_path: this.hide_hierarchy_path,
taxonomy: this.taxonomy
})
},
diff --git a/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php b/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php
index 02c8c677c..4fab7a1da 100644
--- a/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php
+++ b/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php
@@ -23,6 +23,7 @@ class Taxonomy extends Metadata_Type {
'allow_new_terms' => 'no',
'link_filtered_by_collections' => [],
'input_type' => 'tainacan-taxonomy-radio',
+ 'hide_hierarchy_path' => 'no'
]);
$this->set_form_component('tainacan-form-taxonomy');
@@ -101,6 +102,10 @@ class Taxonomy extends Metadata_Type {
'link_filtered_by_collections' => [
'title' => __( 'Link filtered by collections', 'tainacan' ),
'description' => __( 'Links to term items list filtered by certain collections instead of repository level term items page.', 'tainacan' ),
+ ],
+ 'hide_hierarchy_path' => [
+ 'title' => __( 'Hide hierarchy path', 'tainacan' ),
+ 'description' => __( 'Display only the current child term when showing values that belong to a term hierarchy.', 'tainacan' ),
]
];
}
@@ -191,6 +196,15 @@ class Taxonomy extends Metadata_Type {
$readable_option_value = __( 'None', 'tainacan' );
break;
+ case 'hide_hierarchy_path':
+ if ($option_value == 'yes')
+ $readable_option_value = __('Yes', 'tainacan');
+ else if ($option_value == 'no')
+ $readable_option_value = __('No', 'tainacan');
+ else
+ $readable_option_value = $option_value;
+ break;
+
default:
$readable_option_value = $option_value;
}
@@ -334,7 +348,7 @@ class Taxonomy extends Metadata_Type {
public function get_value_as_html(Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
$return = '';
-
+
if ( $item_metadata->is_multiple() ) {
$count = 1;
$total = sizeof($value);
@@ -369,6 +383,10 @@ class Taxonomy extends Metadata_Type {
}
private function get_term_hierarchy_html( \Tainacan\Entities\Term $term ) {
+
+ if ( $this->get_option('hide_hierarchy_path') == 'yes' )
+ return $this->term_to_html($term);
+
$terms = [];
$terms[] = $this->term_to_html($term);
diff --git a/src/views/admin/components/other/item-metadatum-errors-tooltip.vue b/src/views/admin/components/other/item-metadatum-errors-tooltip.vue
index 70902d94e..e3dba9bf2 100644
--- a/src/views/admin/components/other/item-metadatum-errors-tooltip.vue
+++ b/src/views/admin/components/other/item-metadatum-errors-tooltip.vue
@@ -14,7 +14,7 @@
- {{ $i18n.get('instruction_click_error_to_go_to_metadata') }}
+ {{ $i18n.get('instruction_click_error_to_go_to_metadata') }}
-
-
+
+
diff --git a/src/views/admin/js/event-bus-search.js b/src/views/admin/js/event-bus-search.js
index aaae137e6..98c53e2cb 100644
--- a/src/views/admin/js/event-bus-search.js
+++ b/src/views/admin/js/event-bus-search.js
@@ -67,7 +67,7 @@ export default {
if (this.$route.query.order == undefined || to.params.collectionId != from.params.collectionId) {
let orderKey = (this.collectionId != undefined ? 'order_' + this.collectionId : 'order');
let orderValue = this.$userPrefs.get(orderKey) ? this.$userPrefs.get(orderKey) : this.defaultOrder;
-
+
if (orderValue)
this.$route.query.order = orderValue;
else {
@@ -80,7 +80,7 @@ export default {
if (this.$route.query.orderby == undefined || to.params.collectionId != from.params.collectionId) {
let orderByKey = (this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by');
let orderBy = this.$userPrefs.get(orderByKey) ? this.$userPrefs.get(orderByKey) : this.defaultOrderBy;
-
+
if (orderBy && orderBy != 'name') {
// Previously was stored as a metadata object, now it is a orderby object
diff --git a/src/views/admin/js/store/modules/metadata/actions.js b/src/views/admin/js/store/modules/metadata/actions.js
index 48ce7b87e..1f6528a34 100644
--- a/src/views/admin/js/store/modules/metadata/actions.js
+++ b/src/views/admin/js/store/modules/metadata/actions.js
@@ -94,7 +94,7 @@ export const sendMetadatum = ({commit}, {collectionId, name, metadatumType, stat
.then(res => {
let metadatum = res.data;
- if (sectionId != undefined && sectionId != false)
+ if (sectionId != undefined && sectionId != false && !isRepositoryLevel)
commit('updateMetadatumInsideSectionMetadata', { metadatum: metadatum, index: newIndex, sectionId: sectionId })
else
commit('setSingleMetadatum', { metadatum: metadatum, index: newIndex, isRepositoryLevel: isRepositoryLevel });
@@ -129,8 +129,8 @@ export const updateMetadatum = ({commit}, {collectionId, metadatumId, isReposito
axios.tainacan.put(endpoint, options)
.then(res => {
let metadatum = res.data;
-
- if (sectionId !== null && sectionId !== undefined)
+
+ if (sectionId !== null && sectionId !== undefined && !isRepositoryLevel)
commit('updateMetadatumInsideSectionMetadata', { metadatum: metadatum, index: index, sectionId: sectionId });
else
commit('setSingleMetadatum', { metadatum: metadatum, index: index, isRepositoryLevel: isRepositoryLevel });
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/block.json b/src/views/gutenberg-blocks/blocks/faceted-search/block.json
index 6b9b6fb53..68c8d2818 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/block.json
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/block.json
@@ -13,176 +13,204 @@
},
"attributes": {
"termId": {
- "type": "String",
+ "type": "string",
"default": null
},
"taxonomyId": {
- "type": "String",
+ "type": "string",
"default": null
},
"collectionId": {
- "type": "String",
+ "type": "string",
"default": null
},
"defaultViewMode": {
- "type": "String",
+ "type": "string",
"default": "masonry"
},
"enabledViewModes": {
- "type": "Array",
+ "type": "array",
"default": null
},
"collectionDefaultViewMode": {
- "type": "String",
+ "type": "string",
"default": "masonry"
},
"collectionEnabledViewModes": {
- "type": "Array",
+ "type": "array",
"default": []
},
"hideFilters": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"hideHideFiltersButton": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"hideSearch": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"hideAdvancedSearch": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"hideDisplayedMetadataButton": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"hideSortingArea": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"hideSortByButton": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"hideItemsThumbnail": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"hideExposersButton": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"hideItemsPerPageButton": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"defaultItemsPerPage": {
- "type": "Number",
+ "type": "number",
"default": 12
},
"hideGoToPageButton": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"hidePaginationArea": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"showFiltersButtonInsideSearchControl": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"startWithFiltersHidden": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"filtersAsModal": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"showInlineViewModeOptions": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"showFullscreenWithViewModes": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"listType": {
- "type": "String",
+ "type": "string",
"default": ""
},
"isCollectionModalOpen": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"isTermModalOpen": {
- "type": "Boolean",
+ "type": "boolean",
"default": false
},
"backgroundColor": {
- "type": "String",
+ "type": "string",
"default": "#ffffff"
},
"baseFontSize": {
- "type": "Number",
+ "type": "number",
"default": 16
},
"filtersAreaWidth": {
- "type": "Number",
+ "type": "number",
"default": 20
},
"inputColor": {
- "type": "String",
+ "type": "string",
"default": "#1d1d1d"
},
"inputBackgroundColor": {
- "type": "String",
+ "type": "string",
"default": "#ffffff"
},
"inputBorderColor": {
- "type": "String",
+ "type": "string",
"default": "#dbdbdb"
},
"labelColor": {
- "type": "String",
+ "type": "string",
"default": "#454647"
},
"infoColor": {
- "type": "String",
+ "type": "string",
"default": "#555758"
},
"headingColor": {
- "type": "String",
+ "type": "string",
"default": "#000000"
},
"skeletonColor": {
- "type": "String",
+ "type": "string",
"default": "#eeeeee"
},
"itemBackgroundColor": {
- "type": "String",
+ "type": "string",
"default": "#ffffff"
},
"itemHoverBackgroundColor": {
- "type": "String",
+ "type": "string",
"default": "#f2f2f2"
},
"itemHeadingHoverBackgroundColor": {
- "type": "String",
+ "type": "string",
"default": "#dbdbdb"
},
"primaryColor": {
- "type": "String",
+ "type": "string",
"default": "#d9eced"
},
"secondaryColor": {
- "type": "String",
+ "type": "string",
"default": "#298596"
+ },
+ "order": {
+ "type": "string",
+ "default": "ASC"
+ },
+ "orderBy": {
+ "type": "string",
+ "default": "date"
+ },
+ "orderByMeta": {
+ "type": "string",
+ "default": ""
+ },
+ "orderByType": {
+ "type": "string",
+ "default": ""
+ },
+ "collectionOrderBy": {
+ "type": "string",
+ "default": "date"
+ },
+ "collectionOrderByMeta": {
+ "type": "string",
+ "default": ""
+ },
+ "collectionOrderByType": {
+ "type": "string",
+ "default": ""
}
},
"supports": {
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/collection-modal.js b/src/views/gutenberg-blocks/blocks/faceted-search/collection-modal.js
index 39da35823..12a8c7bad 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/collection-modal.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/collection-modal.js
@@ -13,17 +13,25 @@ export default class CollectionModal extends React.Component {
// Initialize state
this.state = {
+ collectionDefaultOrderBy: 'date',
+ collectionDefaultOrder: 'ASC',
+ collectionDefaultOrderByMeta: '',
+ collectionDefaultOrderByType: '',
collectionViewModes: [],
collectionsPerPage: 24,
collectionId: undefined,
isLoadingCollections: false,
modalCollections: [],
totalModalCollections: 0,
- collectionPage: 1,
- collectionOrderBy: 'date-desc',
+ collectionsPage: 1,
+ collectionsOrderBy: 'date-desc',
temporaryCollectionId: '',
temporaryCollectionDefaultViewMode: '',
temporaryCollectionEnabledViewModes: [],
+ temporaryCollectionDefaultOrderBy: 'date',
+ temporaryCollectionDefaultOrderByMeta: '',
+ temporaryCollectionDefaultOrderByType: '',
+ temporaryCollectionDefaultOrder: 'ASC',
searchCollectionName: '',
collections: [],
collectionsRequestSource: undefined
@@ -43,7 +51,11 @@ export default class CollectionModal extends React.Component {
temporaryCollectionId: this.props.existingCollectionId,
temporaryCollectionDefaultViewMode: this.props.existingCollectionDefaultViewMode,
temporaryCollectionEnabledViewModes: this.props.existingCollectionEnabledViewModes,
- collectionPage: 1
+ temporaryCollectionDefaultOrder: this.props.existingCollectionDefaultOrder,
+ temporaryCollectionDefaultOrderBy: this.props.existingCollectionDefaultOrderBy,
+ temporaryCollectionDefaultOrderByMeta: this.props.existingCollectionDefaultOrderByMeta,
+ temporaryCollectionDefaultOrderByType: this.props.existingCollectionDefaultOrderByType,
+ collectionsPage: 1
});
this.fetchModalCollections();
@@ -62,12 +74,12 @@ export default class CollectionModal extends React.Component {
fetchModalCollections() {
let someModalCollections = this.state.modalCollections;
- if (this.state.collectionPage <= 1)
+ if (this.state.collectionsPage <= 1)
someModalCollections = [];
let query = {
perpage: this.state.collectionsPerPage,
- paged: this.state.collectionPage
+ paged: this.state.collectionsPage
}
if (this.props.filterOptionsBy && Object.keys(this.props.filterOptionsBy).length !== 0) {
@@ -84,18 +96,18 @@ export default class CollectionModal extends React.Component {
let endpoint = '/collections/?' + qs.stringify(query);
- if (this.state.collectionOrderBy == 'date')
+ if (this.state.collectionsOrderBy == 'date')
endpoint += '&orderby=date&order=asc';
- else if (this.state.collectionOrderBy == 'date-desc')
+ else if (this.state.collectionsOrderBy == 'date-desc')
endpoint += '&orderby=date&order=desc';
- else if (this.state.collectionOrderBy == 'title')
+ else if (this.state.collectionsOrderBy == 'title')
endpoint += '&orderby=title&order=asc';
- else if (this.state.collectionOrderBy == 'title-desc')
+ else if (this.state.collectionsOrderBy == 'title-desc')
endpoint += '&orderby=title&order=desc';
this.setState({
isLoadingCollections: true,
- collectionPage: this.state.collectionPage + 1,
+ collectionsPage: this.state.collectionsPage + 1,
modalCollections: someModalCollections
});
@@ -108,7 +120,9 @@ export default class CollectionModal extends React.Component {
name: collection.name,
id: collection.id,
default_view_mode: collection.default_view_mode,
- enabled_view_modes: collection.enabled_view_modes
+ enabled_view_modes: collection.enabled_view_modes,
+ default_orderby: collection.default_orderby,
+ default_order: collection.default_order
});
}
@@ -125,10 +139,10 @@ export default class CollectionModal extends React.Component {
});
}
- selectCollection({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes }) {
+ selectCollection({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes, collectionDefaultOrder, collectionDefaultOrderBy, collectionDefaultOrderByMeta, collectionDefaultOrderByType }) {
collectionId = collectionId;
this.setState({ collectionId: collectionId });
- this.props.onSelectCollection({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes });
+ this.props.onSelectCollection({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes, collectionDefaultOrder, collectionDefaultOrderBy, collectionDefaultOrderByMeta, collectionDefaultOrderByType });
}
fetchCollections(name) {
@@ -146,7 +160,7 @@ export default class CollectionModal extends React.Component {
let query = {
perpage: this.state.collectionsPerPage,
- paged: this.state.collectionPage
+ paged: this.state.collectionsPage
}
if (this.props.filterOptionsBy && Object.keys(this.props.filterOptionsBy).length !== 0) {
@@ -166,13 +180,13 @@ export default class CollectionModal extends React.Component {
if (name != undefined && name != '')
endpoint += '&search=' + name;
- if (this.state.collectionOrderBy == 'date')
+ if (this.state.collectionsOrderBy == 'date')
endpoint += '&orderby=date&order=asc';
- else if (this.state.collectionOrderBy == 'date-desc')
+ else if (this.state.collectionsOrderBy == 'date-desc')
endpoint += '&orderby=date&order=desc';
- else if (this.state.collectionOrderBy == 'title')
+ else if (this.state.collectionsOrderBy == 'title')
endpoint += '&orderby=title&order=asc';
- else if (this.state.collectionOrderBy == 'title-desc')
+ else if (this.state.collectionsOrderBy == 'title-desc')
endpoint += '&orderby=title&order=desc';
tainacan.get(endpoint, { cancelToken: aCollectionRequestSource.token })
@@ -181,7 +195,9 @@ export default class CollectionModal extends React.Component {
name: collection.name,
id: collection.id + '',
default_view_mode: collection.default_view_mode,
- enabled_view_modes: collection.enabled_view_modes
+ enabled_view_modes: collection.enabled_view_modes,
+ default_orderby: collection.default_orderby,
+ default_order: collection.default_order
}));
this.setState({
@@ -200,7 +216,7 @@ export default class CollectionModal extends React.Component {
this.setState({
collectionId: null,
- collectionPage: 1,
+ collectionsPage: 1,
modalCollections: []
});
this.fetchModalCollections();
@@ -227,19 +243,19 @@ export default class CollectionModal extends React.Component {
}}/>
{
- this.state.collectionOrderBy = aCollectionOrderBy;
- this.state.collectionPage = 1;
+ onChange={ ( acollectionsOrderBy ) => {
+ this.state.collectionsOrderBy = acollectionsOrderBy;
+ this.state.collectionsPage = 1;
this.setState({
- collectionOrderBy: this.state.collectionOrderBy,
- collectionPage: this.state.collectionPage
+ collectionsOrderBy: this.state.collectionsOrderBy,
+ collectionsPage: this.state.collectionsPage
});
if (this.state.searchCollectionName && this.state.searchCollectionName != '') {
this.fetchCollections(this.state.searchCollectionName);
@@ -267,9 +283,17 @@ export default class CollectionModal extends React.Component {
this.state.temporaryCollectionId = aCollectionId;
this.state.temporaryCollectionDefaultViewMode = selectedCollection.default_view_mode;
this.state.temporaryCollectionEnabledViewModes = selectedCollection.enabled_view_modes;
+ this.state.temporaryCollectionDefaultOrder = selectedCollection.default_order;
+ this.state.temporaryCollectionDefaultOrderBy = selectedCollection.default_orderby.orderby ? selectedCollection.default_orderby.orderby : selectedCollection.default_orderby;
+ this.state.temporaryCollectionDefaultOrderByMeta = selectedCollection.default_orderby.metakey ? selectedCollection.default_orderby.metakey : '';
+ this.state.temporaryCollectionDefaultOrderByType = selectedCollection.default_orderby.metatype ? selectedCollection.default_orderby.metatype : '';
this.setState({ temporaryCollectionId: aCollectionId });
this.setState({ temporaryCollectionDefaultViewMode: selectedCollection.default_view_mode });
this.setState({ temporaryCollectionEnabledViewModes: selectedCollection.enabled_view_modes });
+ this.setState({ temporaryCollectionDefaultOrder: selectedCollection.default_order });
+ this.setState({ temporaryCollectionDefaultOrderBy: selectedCollection.default_orderby.orderby ? selectedCollection.default_orderby.orderby : selectedCollection.default_orderby });
+ this.setState({ temporaryCollectionDefaultOrderByMeta: selectedCollection.default_orderby.metakey ? selectedCollection.default_orderby.metakey : '' });
+ this.setState({ temporaryCollectionDefaultOrderByType: selectedCollection.default_orderby.metatype ? selectedCollection.default_orderby.metatype : '' });
} } />
}
@@ -299,9 +323,19 @@ export default class CollectionModal extends React.Component {
this.state.temporaryCollectionId = aCollectionId;
this.state.temporaryCollectionDefaultViewMode = selectedCollection.default_view_mode;
this.state.temporaryCollectionEnabledViewModes = selectedCollection.enabled_view_modes;
+ this.state.temporaryCollectionDefaultOrder = selectedCollection.default_order;
+ this.state.temporaryCollectionDefaultOrderBy = selectedCollection.default_orderby;
+ this.state.temporaryCollectionDefaultOrderBy = selectedCollection.default_orderby.orderby ? selectedCollection.default_orderby.orderby : selectedCollection.default_orderby;
+ this.state.temporaryCollectionDefaultOrderByMeta = selectedCollection.default_orderby.metakey ? selectedCollection.default_orderby.metakey : '';
+ this.state.temporaryCollectionDefaultOrderByType = selectedCollection.default_orderby.metatype ? selectedCollection.default_orderby.metatype : '';
this.setState({ temporaryCollectionId: aCollectionId });
this.setState({ temporaryCollectionDefaultViewMode: selectedCollection.default_view_mode });
this.setState({ temporaryCollectionEnabledViewModes: selectedCollection.enabled_view_modes });
+ this.setState({ temporaryCollectionDefaultOrder: selectedCollection.default_order });
+ this.setState({ temporaryCollectionDefaultOrderBy: selectedCollection.default_orderby });
+ this.setState({ temporaryCollectionDefaultOrderBy: selectedCollection.default_orderby.orderby ? selectedCollection.default_orderby.orderby : selectedCollection.default_orderby });
+ this.setState({ temporaryCollectionDefaultOrderByMeta: selectedCollection.default_orderby.metakey ? selectedCollection.default_orderby.metakey : '' });
+ this.setState({ temporaryCollectionDefaultOrderByType: selectedCollection.default_orderby.metatype ? selectedCollection.default_orderby.metatype : '' });
} } />
}
@@ -336,7 +370,11 @@ export default class CollectionModal extends React.Component {
onClick={ () => this.selectCollection({
collectionId: this.state.temporaryCollectionId,
collectionDefaultViewMode: this.state.temporaryCollectionDefaultViewMode,
- collectionEnabledViewModes: this.state.temporaryCollectionEnabledViewModes
+ collectionEnabledViewModes: this.state.temporaryCollectionEnabledViewModes,
+ collectionDefaultOrder: this.state.temporaryCollectionDefaultOrder,
+ collectionDefaultOrderBy: this.state.temporaryCollectionDefaultOrderBy,
+ collectionDefaultOrderByMeta: this.state.temporaryCollectionDefaultOrderByMeta,
+ collectionDefaultOrderByType: this.state.temporaryCollectionDefaultOrderByType
}) }>
{__('Use selected Collection', 'tainacan')}
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/deprecated.js b/src/views/gutenberg-blocks/blocks/faceted-search/deprecated.js
index 975c1c8ff..fda47f41f 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/deprecated.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/deprecated.js
@@ -1,4 +1,289 @@
export default [
+ /* Deprecated in version 0.19.4 due to add of orderby, orderbymeta and orderbykey */
+ {
+ attributes: {
+ "termId": {
+ "type": "String",
+ "default": null
+ },
+ "taxonomyId": {
+ "type": "String",
+ "default": null
+ },
+ "collectionId": {
+ "type": "String",
+ "default": null
+ },
+ "defaultViewMode": {
+ "type": "String",
+ "default": "masonry"
+ },
+ "enabledViewModes": {
+ "type": "Array",
+ "default": null
+ },
+ "collectionDefaultViewMode": {
+ "type": "String",
+ "default": "masonry"
+ },
+ "collectionEnabledViewModes": {
+ "type": "Array",
+ "default": []
+ },
+ "hideFilters": {
+ "type": "Boolean",
+ "default": false
+ },
+ "hideHideFiltersButton": {
+ "type": "Boolean",
+ "default": false
+ },
+ "hideSearch": {
+ "type": "Boolean",
+ "default": false
+ },
+ "hideAdvancedSearch": {
+ "type": "Boolean",
+ "default": false
+ },
+ "hideDisplayedMetadataButton": {
+ "type": "Boolean",
+ "default": false
+ },
+ "hideSortingArea": {
+ "type": "Boolean",
+ "default": false
+ },
+ "hideSortByButton": {
+ "type": "Boolean",
+ "default": false
+ },
+ "hideItemsThumbnail": {
+ "type": "Boolean",
+ "default": false
+ },
+ "hideExposersButton": {
+ "type": "Boolean",
+ "default": false
+ },
+ "hideItemsPerPageButton": {
+ "type": "Boolean",
+ "default": false
+ },
+ "defaultItemsPerPage": {
+ "type": "Number",
+ "default": 12
+ },
+ "hideGoToPageButton": {
+ "type": "Boolean",
+ "default": false
+ },
+ "hidePaginationArea": {
+ "type": "Boolean",
+ "default": false
+ },
+ "showFiltersButtonInsideSearchControl": {
+ "type": "Boolean",
+ "default": false
+ },
+ "startWithFiltersHidden": {
+ "type": "Boolean",
+ "default": false
+ },
+ "filtersAsModal": {
+ "type": "Boolean",
+ "default": false
+ },
+ "showInlineViewModeOptions": {
+ "type": "Boolean",
+ "default": false
+ },
+ "showFullscreenWithViewModes": {
+ "type": "Boolean",
+ "default": false
+ },
+ "listType": {
+ "type": "String",
+ "default": ""
+ },
+ "isCollectionModalOpen": {
+ "type": "Boolean",
+ "default": false
+ },
+ "isTermModalOpen": {
+ "type": "Boolean",
+ "default": false
+ },
+ "backgroundColor": {
+ "type": "String",
+ "default": "#ffffff"
+ },
+ "baseFontSize": {
+ "type": "Number",
+ "default": 16
+ },
+ "filtersAreaWidth": {
+ "type": "Number",
+ "default": 20
+ },
+ "inputColor": {
+ "type": "String",
+ "default": "#1d1d1d"
+ },
+ "inputBackgroundColor": {
+ "type": "String",
+ "default": "#ffffff"
+ },
+ "inputBorderColor": {
+ "type": "String",
+ "default": "#dbdbdb"
+ },
+ "labelColor": {
+ "type": "String",
+ "default": "#454647"
+ },
+ "infoColor": {
+ "type": "String",
+ "default": "#555758"
+ },
+ "headingColor": {
+ "type": "String",
+ "default": "#000000"
+ },
+ "skeletonColor": {
+ "type": "String",
+ "default": "#eeeeee"
+ },
+ "itemBackgroundColor": {
+ "type": "String",
+ "default": "#ffffff"
+ },
+ "itemHoverBackgroundColor": {
+ "type": "String",
+ "default": "#f2f2f2"
+ },
+ "itemHeadingHoverBackgroundColor": {
+ "type": "String",
+ "default": "#dbdbdb"
+ },
+ "primaryColor": {
+ "type": "String",
+ "default": "#d9eced"
+ },
+ "secondaryColor": {
+ "type": "String",
+ "default": "#298596"
+ }
+ },
+ supports: {
+ align: ['full', 'wide'],
+ html: true,
+ multiple: false
+ },
+ save({ attributes, className }) {
+ const {
+ termId,
+ taxonomyId,
+ collectionId,
+ defaultViewMode,
+ enabledViewModes,
+ collectionDefaultViewMode,
+ collectionEnabledViewModes,
+ hideDisplayedMetadataButton,
+ hideSortingArea,
+ hideFilters,
+ hideHideFiltersButton,
+ hideSearch,
+ hideAdvancedSearch,
+ hideSortByButton,
+ hideItemsThumbnail,
+ hidePaginationArea,
+ hideExposersButton,
+ hideItemsPerPageButton,
+ defaultItemsPerPage,
+ hideGoToPageButton,
+ showFiltersButtonInsideSearchControl,
+ startWithFiltersHidden,
+ filtersAsModal,
+ showInlineViewModeOptions,
+ showFullscreenWithViewModes,
+ listType,
+ backgroundColor,
+ baseFontSize,
+ filtersAreaWidth,
+ inputColor,
+ inputBackgroundColor,
+ inputBorderColor,
+ labelColor,
+ infoColor,
+ headingColor,
+ skeletonColor,
+ itemBackgroundColor,
+ itemHoverBackgroundColor,
+ itemHeadingHoverBackgroundColor,
+ primaryColor,
+ secondaryColor
+ } = attributes;
+
+ let updatedListType = '' + listType;
+
+ if (updatedListType === '' && collectionId)
+ updatedListType = 'collection';
+ else if (updatedListType === '' && termId && taxonomyId)
+ updatedListType = 'term';
+
+ return
+
+
+
+ }
+ },
/* Deprecated in version 0.18.4 due to WP 5.8 support */
{
attributes: {
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/edit.js b/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
index 2f0d5961a..af0ed908e 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
@@ -2,7 +2,6 @@ const { __ } = wp.i18n;
const {
Button,
- ColorPalette,
BaseControl,
CheckboxControl,
RangeControl,
@@ -70,7 +69,14 @@ export default function({ attributes, setAttributes, className, isSelected, clie
itemHoverBackgroundColor,
itemHeadingHoverBackgroundColor,
primaryColor,
- secondaryColor
+ secondaryColor,
+ order,
+ orderBy,
+ orderByMeta,
+ orderByType,
+ collectionOrderBy,
+ collectionOrderByMeta,
+ collectionOrderByType
} = attributes;
let registeredViewModesEntries = [];
@@ -411,6 +417,50 @@ export default function({ attributes, setAttributes, className, isSelected, clie
}
/>
+
+ {
+ order = anOrder;
+ setAttributes({ order: anOrder });
+ } }
+ />
+
+
+ { listType != 'collection' ?
+
+ {
+ orderBy = anOrderBy;
+ setAttributes({ orderBy: anOrderBy });
+ } }
+ />
+
+ : null }
+
{
+ onSelectCollection={ ({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes, collectionDefaultOrder, collectionDefaultOrderBy, collectionDefaultOrderByMeta, collectionDefaultOrderByType }) => {
collectionId = collectionId;
collectionDefaultViewMode = collectionDefaultViewMode ? collectionDefaultViewMode : defaultViewMode;
collectionEnabledViewModes = collectionEnabledViewModes && collectionEnabledViewModes.length ? collectionEnabledViewModes : enabledViewModes;
+ order = collectionDefaultOrder ? collectionDefaultOrder : 'ASC';
+ collectionOrderBy = collectionDefaultOrderBy ? collectionDefaultOrderBy : 'date';
+ collectionOrderByMeta = collectionDefaultOrderByMeta ? collectionDefaultOrderByMeta : '';
+ collectionOrderByType = collectionDefaultOrderByType ? collectionDefaultOrderByType : '';
+ console.log(collectionDefaultOrderByMeta)
setAttributes({
collectionId: collectionId,
collectionDefaultViewMode: collectionDefaultViewMode,
defaultViewMode: collectionDefaultViewMode,
collectionEnabledViewModes: collectionEnabledViewModes,
enabledViewModes: collectionEnabledViewModes,
+ order: order,
+ collectionOrderBy, collectionOrderBy,
+ collectionOrderByMeta: collectionOrderByMeta,
+ collectionOrderByType: collectionOrderByType,
isCollectionModalOpen: false
});
}}
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/save.js b/src/views/gutenberg-blocks/blocks/faceted-search/save.js
index 62174a6de..a59ebb152 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/save.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/save.js
@@ -40,7 +40,14 @@ export default function({ attributes, className }) {
itemHoverBackgroundColor,
itemHeadingHoverBackgroundColor,
primaryColor,
- secondaryColor
+ secondaryColor,
+ order,
+ orderBy,
+ orderByMeta,
+ orderByType,
+ collectionOrderBy,
+ collectionOrderByMeta,
+ collectionOrderByType
} = attributes;
let updatedListType = '' + listType;
@@ -88,7 +95,6 @@ export default function({ attributes, className }) {
hide-sorting-area = { hideSortingArea.toString() }
hide-items-thumbnail = { hideItemsThumbnail ? hideItemsThumbnail.toString() : 'false' }
hide-sort-by-button = { hideSortByButton.toString() }
- hide-pagination-area = { hidePaginationArea.toString() }
hide-exposers-button = { hideExposersButton.toString() }
hide-items-per-page-button = { hideItemsPerPageButton.toString() }
default-items-per-page = { defaultItemsPerPage }
@@ -97,7 +103,11 @@ export default function({ attributes, className }) {
start-with-filters-hidden = { startWithFiltersHidden.toString() }
filters-as-modal = { filtersAsModal.toString() }
show-inline-view-mode-options = { showInlineViewModeOptions.toString() }
- show-fullscreen-with-view-modes = { showFullscreenWithViewModes.toString() } >
+ show-fullscreen-with-view-modes = { showFullscreenWithViewModes.toString() }
+ default-order = { order ? order : 'ASC' }
+ default-orderby = { updatedListType == 'collection' ? (collectionOrderBy ? collectionOrderBy : 'date') : (orderBy ? orderBy : 'date') }
+ default-orderby-meta = { updatedListType == 'collection' ? (collectionOrderByMeta ? collectionOrderByMeta : '') : (orderByMeta ? orderByMeta : '') }
+ default-orderby-type = { updatedListType == 'collection' ? (collectionOrderByType ? collectionOrderByType : '') : (orderByType ? orderByType : '') } >
};
\ No newline at end of file
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/theme-items-page.vue b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/theme-items-page.vue
index 792b9cbd0..a85842377 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/theme-items-page.vue
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/theme-items-page.vue
@@ -728,6 +728,8 @@
// Other Tweaks
defaultOrder: 'ASC',
defaultOrderBy: 'date',
+ defaultOrderByMeta: '',
+ defaultOrderByType: '',
defaultItemsPerPage: Number,
showFiltersButtonInsideSearchControl: false,
startWithFiltersHidden: false,
@@ -767,7 +769,7 @@
},
computed: {
isSortingByCustomMetadata() {
- return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'date');
+ return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'date' && this.orderBy != 'modified');
},
items() {
return this.getItems();
@@ -855,10 +857,33 @@
this.$eventBusSearch.setCollectionId(this.collectionId);
if (this.termId != undefined && this.termId != null)
this.$eventBusSearch.setTerm(this.termId, this.taxonomy);
- if (this.defaultOrder != undefined)
+ if (this.defaultOrder != undefined) {
this.$eventBusSearch.setDefaultOrder(this.defaultOrder);
+ if (!this.$route.query.order)
+ this.$eventBusSearch.setOrder(this.defaultOrder);
+ }
if (this.defaultOrderBy != undefined) {
- this.$eventBusSearch.setDefaultOrderBy(this.defaultOrderBy);
+ if (this.defaultOrderByMeta || this.defaultOrderByType) {
+
+ let orderByObject = { orderby: this.defaultOrderBy }
+
+ if (this.defaultOrderByMeta)
+ orderByObject['metakey'] = this.defaultOrderByMeta;
+
+ if (this.defaultOrderByType)
+ orderByObject['metatype'] = this.defaultOrderByType;
+
+ this.$eventBusSearch.setDefaultOrderBy(orderByObject);
+
+ if (!this.$route.query.orderby)
+ this.$eventBusSearch.setOrderBy(orderByObject);
+
+ } else {
+ this.$eventBusSearch.setDefaultOrderBy(this.defaultOrderBy);
+
+ if (!this.$route.query.orderby)
+ this.$eventBusSearch.setOrderBy(this.defaultOrderBy);
+ }
}
this.$eventBusSearch.updateStoreFromURL();
@@ -999,6 +1024,7 @@
},
methods: {
...mapGetters('collection', [
+ 'getCollection',
'getItems',
'getItemsListTemplate'
]),
@@ -1062,10 +1088,10 @@
if (filterTagsAfterFiltersCollection)
this.hooks['filter_tags_after'] = filterTagsAfterFiltersCollection;
- const itemsListAreaBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_items_area_list_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_items_area_list_before`, '');
- const itemsListAreaBeforeFiltersCollection = (wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_area_list_before`) || itemsListAreaBeforeFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_area_list_before`, itemsListAreaBeforeFilters);
+ const itemsListAreaBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_items_list_area_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_items_list_area_before`, '');
+ const itemsListAreaBeforeFiltersCollection = (wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_list_area_before`) || itemsListAreaBeforeFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_list_area_before`, itemsListAreaBeforeFilters);
if (itemsListAreaBeforeFiltersCollection)
- this.hooks['items_area_list_before'] = itemsListAreaBeforeFiltersCollection;
+ this.hooks['items_list_area_before'] = itemsListAreaBeforeFiltersCollection;
const itemsListBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_items_list_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_items_list_before`, '');
const itemsListBeforeFiltersCollection = (wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_list_before`) || itemsListBeforeFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_list_before`, itemsListBeforeFilters);
@@ -1087,10 +1113,10 @@
if (paginationAfterFiltersCollection)
this.hooks['pagination_after'] = paginationAfterFiltersCollection;
- const itemsListAreaAfterFilters = wp.hooks.hasFilter(`tainacan_faceted_search_items_area_list_after`) && wp.hooks.applyFilters(`tainacan_faceted_search_items_area_list_after`, '');
- const itemsListAreaAfterFiltersCollection = (wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_area_list_after`) || itemsListAreaAfterFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_area_list_after`, itemsListAreaAfterFilters);
+ const itemsListAreaAfterFilters = wp.hooks.hasFilter(`tainacan_faceted_search_items_list_area_after`) && wp.hooks.applyFilters(`tainacan_faceted_search_items_list_area_after`, '');
+ const itemsListAreaAfterFiltersCollection = (wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_list_area_after`) || itemsListAreaAfterFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_list_area_after`, itemsListAreaAfterFilters);
if (itemsListAreaAfterFiltersCollection)
- this.hooks['items_area_list_after'] = itemsListAreaAfterFiltersCollection;
+ this.hooks['items_list_area_after'] = itemsListAreaAfterFiltersCollection;
}
},
openExposersModal() {
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
index 931e7cb59..c3e1c2f7b 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
@@ -175,6 +175,8 @@ export default (element) => {
defaultViewMode: '',
defaultOrder: 'ASC',
defaultOrderBy: 'date',
+ defaultOrderByMeta: '',
+ defaultOrderByType: '',
isForcedViewMode: false,
enabledViewModes: {},
defaultItemsPerPage: '',
@@ -230,7 +232,11 @@ export default (element) => {
this.defaultOrder = this.$el.attributes['default-order'].value;
if (this.$el.attributes['default-orderby'] != undefined)
this.defaultOrderBy = this.maybeConvertFromJSON(this.$el.attributes['default-orderby'].value);
-
+ if (this.$el.attributes['default-orderby-meta'] != undefined)
+ this.defaultOrderByMeta = this.$el.attributes['default-orderby-meta'].value;
+ if (this.$el.attributes['default-orderby-type'] != undefined)
+ this.defaultOrderByType = this.maybeConvertFromJSON(this.$el.attributes['default-orderby-type'].value);
+
// Options related to hidding elements
if (this.$el.attributes['hide-filters'] != undefined)
this.hideFilters = this.isParameterTrue('hide-filters');
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
index 7cdb2cd47..2c8d80493 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
@@ -9,6 +9,8 @@
:is-forced-view-mode="$root.isForcedViewMode"
:default-order="$root.defaultOrder"
:default-order-by="$root.defaultOrderBy"
+ :default-order-by-meta="$root.defaultOrderByMeta"
+ :default-order-by-type="$root.defaultOrderByType"
:default-items-per-page="$root.defaultItemsPerPage"
:hide-filters="$root.hideFilters ? $root.hideFilters : false"
:hide-hide-filters-button="$root.hideHideFiltersButton ? $root.hideHideFiltersButton : false"
diff --git a/src/views/gutenberg-blocks/blocks/item-submission-form/item-submission/item-submission-form.vue b/src/views/gutenberg-blocks/blocks/item-submission-form/item-submission/item-submission-form.vue
index 965fb506d..7809c2b05 100644
--- a/src/views/gutenberg-blocks/blocks/item-submission-form/item-submission/item-submission-form.vue
+++ b/src/views/gutenberg-blocks/blocks/item-submission-form/item-submission/item-submission-form.vue
@@ -579,7 +579,8 @@
+ class="section"
+ id="submission-form-processing">
@@ -587,9 +588,17 @@
-
{{ $i18n.get('label_sending_form') }}
-
{{ $i18n.get('info_submission_processing') }}
-
{{ $i18n.get('info_submission_uploading') }}
+
+
+ {{ $i18n.get('info_submission_processing') }}
+
+
+ {{ $i18n.get('info_submission_uploading') }}
+
@@ -597,7 +606,8 @@
+ class="section"
+ id="submission-form-sent">
@@ -605,16 +615,28 @@
-
{{ sentFormHeading }}
-
{{ sentFormMessage }}
-
-
- {{ itemLinkButtonLabel }}
-
-
+
diff --git a/src/views/gutenberg-blocks/class-tainacan-gutenberg-block.php b/src/views/gutenberg-blocks/class-tainacan-gutenberg-block.php
index f9fc0ee31..d5a54915c 100644
--- a/src/views/gutenberg-blocks/class-tainacan-gutenberg-block.php
+++ b/src/views/gutenberg-blocks/class-tainacan-gutenberg-block.php
@@ -7,16 +7,16 @@ const TAINACAN_BLOCKS = [
'items-list' => [],
'collections-list' => [],
'search-bar' => [],
- 'facets-list' => [],
- 'dynamic-items-list' => [],
- 'carousel-items-list' => [],
- 'carousel-terms-list' => [],
- 'carousel-collections-list' => [],
+ 'facets-list' => [ 'set_script_translations' => true ],
+ 'dynamic-items-list' => [ 'set_script_translations' => true ],
+ 'carousel-items-list' => [ 'set_script_translations' => true ],
+ 'carousel-terms-list' => [ 'set_script_translations' => true ],
+ 'carousel-collections-list' => [ 'set_script_translations' => true ],
'related-items-list' => [],
'terms-list' => [],
'faceted-search' => [],
'item-submission-form' => [],
- 'item-gallery' => ['render_callback' => 'tainacan_blocks_render_items_gallery'],
+ 'item-gallery' => [ 'set_script_translations' => true, 'render_callback' => 'tainacan_blocks_render_items_gallery' ],
'item-metadata-sections' => ['render_callback' => 'tainacan_blocks_render_metadata_sections'],
'item-metadata-section' => ['render_callback' => 'tainacan_blocks_render_metadata_section'],
'item-metadata' => ['render_callback' => 'tainacan_blocks_render_item_metadata'],
@@ -135,6 +135,7 @@ function tainacan_blocks_register_block($block_slug, $options = []) {
$editor_script_deps,
$TAINACAN_VERSION
);
+ wp_set_script_translations( $block_slug, 'tainacan' );
$register_params['editor_script'] = $block_slug;
// Passes global variables to the blocks editor side
@@ -152,6 +153,18 @@ function tainacan_blocks_register_block($block_slug, $options = []) {
);
$register_params['style'] = $block_slug;
+ // Makes sure translations that use wp.i18n work with our lazy loading strategy
+ if ( isset($options['set_script_translations']) && $options['set_script_translations'] ) {
+ wp_register_script(
+ 'tainacan-chunks-' . $block_slug . '-theme',
+ $TAINACAN_BASE_URL . '/assets/js/tainacan-chunks-' . $block_slug . '-theme.js',
+ array('wp-i18n'),
+ $TAINACAN_VERSION
+ );
+ wp_set_script_translations( 'tainacan-chunks-' . $block_slug . '-theme', 'tainacan' );
+ wp_add_inline_script( 'wp-i18n', wp_scripts()->print_translations('tainacan-chunks-' . $block_slug . '-theme', false) );
+ }
+
// Registers the new block
if (function_exists('register_block_type')) {
if ( version_compare( $wp_version, '5.8-RC', '>=') )
@@ -226,6 +239,8 @@ function tainacan_blocks_add_common_theme_scripts() {
$TAINACAN_VERSION
);
+ wp_set_script_translations( 'tainacan-blocks-common-scripts', 'tainacan' );
+
$block_settings = tainacan_blocks_get_plugin_js_settings();
$plugin_settings = \Tainacan\Admin::get_instance()->get_admin_js_localization_params();
diff --git a/src/views/gutenberg-blocks/tainacan-blocks-common-scripts.js b/src/views/gutenberg-blocks/tainacan-blocks-common-scripts.js
index 362b9f877..dff7a92ff 100644
--- a/src/views/gutenberg-blocks/tainacan-blocks-common-scripts.js
+++ b/src/views/gutenberg-blocks/tainacan-blocks-common-scripts.js
@@ -67,7 +67,7 @@ performWhenDocumentIsLoaded(() => {
moduleImport: name => import(
/* webpackMode: "lazy" */
/* webpackInclude: /theme\.js$/ */
- /* webpackChunkName: "tainacan-chunks-" */
+ /* webpackChunkName: "tainacan-chunks-[request]" */
`${name}`
)
.catch((error) => {
diff --git a/src/views/tainacan-i18n.php b/src/views/tainacan-i18n.php
index 792f62801..08ab4da2a 100644
--- a/src/views/tainacan-i18n.php
+++ b/src/views/tainacan-i18n.php
@@ -1001,6 +1001,7 @@ return apply_filters( 'tainacan-i18n', [
'info_try_enabling_search_by_word' => __( 'Try enabling the search by words.', 'tainacan' ),
'info_try_disabling_search_by_word' => __( 'Try disabling the search by words, to search for the complete phrase.', 'tainacan' ),
'info_details_about_search_by_word' => __( 'They may be located on different metadata and order, but you will still be able to use quotes to group them.', 'tainacan' ),
+ 'info_item_submission_draft_status' => __( 'Warning: draft items may be submitted even without filling all required metadata.', 'tainacan' ),
'info_empty_geocoordinate_metadata_list' => __( 'No geocoordinate metadata was found. Try enabling it in the "displayed metadata" dropdown.', 'tainacan' ),
'info_non_located_item' => __( 'This item does not have any location based on this metadata.', 'tainacan' ),
diff --git a/src/views/tainacan-pages-common-scripts.js b/src/views/tainacan-pages-common-scripts.js
index 2e22830fd..97566a114 100644
--- a/src/views/tainacan-pages-common-scripts.js
+++ b/src/views/tainacan-pages-common-scripts.js
@@ -28,7 +28,7 @@ performWhenDocumentIsLoaded(() => {
moduleImport: name => import(
/* webpackMode: "lazy" */
/* webpackInclude: /main\.js$/ */
- /* webpackChunkName: "tainacan-chunks-" */
+ /* webpackChunkName: "tainacan-chunks-[request]" */
`${name}`
)
.catch((error) => {
diff --git a/webpack.common.js b/webpack.common.js
index f8b008f6b..26a3c8ba6 100644
--- a/webpack.common.js
+++ b/webpack.common.js
@@ -34,7 +34,8 @@ module.exports = {
output: {
path: path.resolve(__dirname, './src/assets/js/'),
publicPath: './wp-content/plugins/tainacan/assets/js/',
- filename: '[name].js'
+ filename: '[name].js',
+ chunkFilename: `[name].js?ver=[contenthash]`
},
module: {
rules: [