more minor spelling fixes

This commit is contained in:
Adrian 2021-11-11 00:48:10 +02:00
parent b669d3e879
commit e07d0a3b29
33 changed files with 346 additions and 346 deletions

View File

@ -265,7 +265,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
]; ];
} else { } else {
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('You mus specify items_ids OR use_query', 'tainacan'), 'error_message' => __('You must specify items_ids OR use_query', 'tainacan'),
], 400); ], 400);
} }
@ -352,7 +352,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
if ( !in_array($method, ['trash_items', 'untrash_items', 'delete_items']) ) { if ( !in_array($method, ['trash_items', 'untrash_items', 'delete_items']) ) {
if (empty($body)) { if (empty($body)) {
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Body can not be empty.', 'tainacan'), 'error_message' => __('Body cannot be empty.', 'tainacan'),
], 400); ], 400);
} }

View File

@ -87,7 +87,7 @@ class REST_Collections_Controller extends REST_Controller {
'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,
'validate_callback' => [$this, 'validate_filters_metadata_order'] 'validate_callback' => [$this, 'validate_filters_metadata_order']
] ]
@ -102,7 +102,7 @@ class REST_Collections_Controller extends REST_Controller {
'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,
'validate_callback' => [$this, 'validate_filters_metadata_order'] 'validate_callback' => [$this, 'validate_filters_metadata_order']
] ]
@ -353,7 +353,7 @@ class REST_Collections_Controller extends REST_Controller {
if(empty($body)){ if(empty($body)){
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Body can not be empty.', 'tainacan'), 'error_message' => __('Body cannot be empty.', 'tainacan'),
'collection' => $body 'collection' => $body
], 400); ], 400);
} }

View File

@ -637,7 +637,7 @@ class REST_Items_Controller extends REST_Controller {
if(empty($item)){ if(empty($item)){
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Body can not be empty.', 'tainacan'), 'error_message' => __('Body cannot be empty.', 'tainacan'),
'item' => $item 'item' => $item
], 400); ], 400);
} }
@ -964,7 +964,7 @@ class REST_Items_Controller extends REST_Controller {
if(empty($item) || empty($metadata)) { if(empty($item) || empty($metadata)) {
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Body can not be empty.', 'tainacan'), 'error_message' => __('Body cannot be empty.', 'tainacan'),
'item' => $item 'item' => $item
], 400); ], 400);
} }

View File

@ -266,7 +266,7 @@ class REST_Metadata_Controller extends REST_Controller {
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Body can not be empty.', 'tainacan'), 'error_message' => __('Body cannot be empty.', 'tainacan'),
'item' => $request->get_body() 'item' => $request->get_body()
], 400); ], 400);

View File

@ -167,7 +167,7 @@ class REST_Metadatum_Mappers_Controller extends REST_Controller {
} }
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Body can not be empty.', 'tainacan'), 'error_message' => __('Body cannot be empty.', 'tainacan'),
'item' => $request->get_body() 'item' => $request->get_body()
], 400); ], 400);
} }

View File

@ -104,7 +104,7 @@ class REST_Sequence_Edit_Controller extends REST_Controller {
} else { } else {
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('You mus specify items_ids OR use_query', 'tainacan'), 'error_message' => __('You must specify items_ids OR use_query', 'tainacan'),
], 400); ], 400);
} }

View File

@ -390,7 +390,7 @@ class REST_Taxonomies_Controller extends REST_Controller {
} }
} else { } else {
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Body can not be empty.', 'tainacan'), 'error_message' => __('Body cannot be empty.', 'tainacan'),
'body' => $body 'body' => $body
], 400); ], 400);
} }

View File

@ -450,12 +450,12 @@ class REST_Terms_Controller extends REST_Controller {
$endpoint_args['metadatum_id'] = [ $endpoint_args['metadatum_id'] = [
'required' => false, 'required' => false,
'type' => 'integer', 'type' => 'integer',
'description' => __('If term is being created in the context of a Taxonomy metadatum, inform its ID') 'description' => __('If term is being created in the context of a Taxonomy metadatum, specify its ID')
]; ];
$endpoint_args['item_id'] = [ $endpoint_args['item_id'] = [
'required' => false, 'required' => false,
'type' => 'integer', 'type' => 'integer',
'description' => __('If term is being created in the context of a Taxonomy metadatum, inform the ID of the item being edited') 'description' => __('If term is being created in the context of a Taxonomy metadatum, specify the ID of the item being edited')
]; ];
} }

View File

@ -362,7 +362,7 @@ class __Bulk_Edit {
} }
if ($new_value == $old_value) { if ($new_value == $old_value) {
return new \WP_Error( 'invalid_action', __( 'Old value and new value can not be the same', 'tainacan' ) ); return new \WP_Error( 'invalid_action', __( 'Old value and new value cannot be the same', 'tainacan' ) );
} }
$dummyItem = new Entities\Item(); $dummyItem = new Entities\Item();
@ -611,7 +611,7 @@ class __Bulk_Edit {
global $wpdb; global $wpdb;
if ($value == $newvalue) { if ($value == $newvalue) {
return new \WP_Error( 'error', __( 'New value and old value can not be the same', 'tainacan' ) ); return new \WP_Error( 'error', __( 'New value and old value cannot be the same', 'tainacan' ) );
} }
$taxRepo = Repositories\Taxonomies::get_instance(); $taxRepo = Repositories\Taxonomies::get_instance();

View File

@ -288,7 +288,7 @@ class Filter extends Entity {
if ($metadatum) { if ($metadatum) {
$metadatum_status_obj = get_post_status_object($metadatum->get_status()); $metadatum_status_obj = get_post_status_object($metadatum->get_status());
if ( ! $metadatum_status_obj->public ) { if ( ! $metadatum_status_obj->public ) {
$this->add_error('status', __('Filter can not be public because the related metadatum is private', 'tainacan')); $this->add_error('status', __('Filter cannot be public because the related metadatum is private', 'tainacan'));
return false; return false;
} }
} }

View File

@ -462,7 +462,7 @@ class Metadatum extends Entity {
if ( $this->get_parent() > 0 && $this->get_metadata_type_object()->get_primitive_type() == 'term' ) { if ( $this->get_parent() > 0 && $this->get_metadata_type_object()->get_primitive_type() == 'term' ) {
$parent_metadatum = new \Tainacan\Entities\Metadatum($this->get_parent()); $parent_metadatum = new \Tainacan\Entities\Metadatum($this->get_parent());
if ( $parent_metadatum->is_multiple() ) { if ( $parent_metadatum->is_multiple() ) {
$this->add_error($this->get_id(), __('Taxonomy metadata can not be used inside Compound metadata with multiple values', 'tainacan')); $this->add_error($this->get_id(), __('Taxonomy metadata cannot be used inside Compound metadata with multiple values', 'tainacan'));
return false; return false;
} }
} }
@ -478,7 +478,7 @@ class Metadatum extends Entity {
, 'OBJECT'); , 'OBJECT');
if ( sizeof($children_taxonomy) > 0 ) { if ( sizeof($children_taxonomy) > 0 ) {
$this->add_error($this->get_id(), __('Taxonomy metadata can not be used inside Compound metadata with multiple values', 'tainacan')); $this->add_error($this->get_id(), __('Taxonomy metadata cannot be used inside Compound metadata with multiple values', 'tainacan'));
return false; return false;
} }

View File

@ -237,7 +237,7 @@ class Term extends Entity {
if (false !== $term_exists) { if (false !== $term_exists) {
if ($this->get_id() != $term_exists->term_id) { if ($this->get_id() != $term_exists->term_id) {
$this->add_error( 'name', __('You can not have two terms with the same name at the same level', 'tainacan') ); $this->add_error( 'name', __('You cannot have two terms with the same name at the same level', 'tainacan') );
return false; return false;
} }
} }

View File

@ -115,7 +115,7 @@ class Term_Exporter extends Exporter {
<h5><?php _e('Source Taxonomy', 'tainacan'); ?></h5> <h5><?php _e('Source Taxonomy', 'tainacan'); ?></h5>
</div> </div>
<div class="help-tooltip-body"> <div class="help-tooltip-body">
<p><?php _e('Inform the taxonomy you want to export the terms from.', 'tainacan'); ?></p> <p><?php _e('Specify the taxonomy you want to export the terms from.', 'tainacan'); ?></p>
</div> </div>
</div> </div>
</span> </span>
@ -148,7 +148,7 @@ class Term_Exporter extends Exporter {
} }
/** /**
* *
*/ */
public function exporting_terms(){ public function exporting_terms(){
@ -195,4 +195,4 @@ class Term_Exporter extends Exporter {
} }
} }
} }
} }

View File

@ -435,7 +435,7 @@ class Bulk_Edit_Process extends Generic_Process {
} }
if ($new_value == $old_value) { if ($new_value == $old_value) {
$this->add_error_log( __( 'Old value and new value can not be the same', 'tainacan' ) ); $this->add_error_log( __( 'Old value and new value cannot be the same', 'tainacan' ) );
return false; return false;
} }

View File

@ -45,7 +45,7 @@ class CSV extends Importer {
$this->set_option('document_import_mode', 'replace'); $this->set_option('document_import_mode', 'replace');
$this->set_option('document_index', $index); $this->set_option('document_index', $index);
} else if( $rawColumn === 'special_attachments' || } else if( $rawColumn === 'special_attachments' ||
$rawColumn === 'special_attachments|APPEND' || $rawColumn === 'special_attachments|APPEND' ||
$rawColumn === 'special_attachments|REPLACE' ) { $rawColumn === 'special_attachments|REPLACE' ) {
$this->set_option('attachment_index', $index); $this->set_option('attachment_index', $index);
$attachment_type = explode('|', $rawColumn); $attachment_type = explode('|', $rawColumn);
@ -127,7 +127,7 @@ class CSV extends Importer {
return $header; return $header;
} }
return $header; return $header;
}, $this->raw_source_metadata()); }, $this->raw_source_metadata());
$item_line = (int) $index + 2; $item_line = (int) $index + 2;
@ -199,7 +199,7 @@ class CSV extends Importer {
$returnValue = []; $returnValue = [];
foreach($valueToInsert as $index => $metadatumValue) { foreach($valueToInsert as $index => $metadatumValue) {
$childrenHeaders = str_getcsv($compoundHeaders[$key], $this->get_option('delimiter'), $this->get_option('enclosure')); $childrenHeaders = str_getcsv($compoundHeaders[$key], $this->get_option('delimiter'), $this->get_option('enclosure'));
$childrenValue = $this->is_clear_value($metadatumValue) ? $childrenValue = $this->is_clear_value($metadatumValue) ?
array_fill(0, sizeof($childrenHeaders), $this->get_option('escape_empty_value') ) : array_fill(0, sizeof($childrenHeaders), $this->get_option('escape_empty_value') ) :
str_getcsv($metadatumValue, $this->get_option('delimiter'), $this->get_option('enclosure')); str_getcsv($metadatumValue, $this->get_option('delimiter'), $this->get_option('enclosure'));
@ -414,7 +414,7 @@ class CSV extends Importer {
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="columns"> <div class="columns">
@ -462,7 +462,7 @@ class CSV extends Importer {
<h5><?php _e('Server path', 'tainacan'); ?></h5> <h5><?php _e('Server path', 'tainacan'); ?></h5>
</div> </div>
<div class="help-tooltip-body"> <div class="help-tooltip-body">
<p><?php _e("When using CSV special field to add documents or attachments that you've uploaded to the server, inform the full path to the folder here (e.g. /home/user/files/)", 'tainacan'); ?></p> <p><?php _e("When using CSV special field to add documents or attachments that you've uploaded to the server, specify the full path to the folder here (e.g. /home/user/files/)", 'tainacan'); ?></p>
</div> </div>
</div> </div>
</span> </span>

View File

@ -179,7 +179,7 @@ class Oaipmh_Importer extends Importer {
$metadata_map = $this->create_collection_metadata($collection); $metadata_map = $this->create_collection_metadata($collection);
$total = intval($this->get_total_items_from_source($setSpec)); $total = intval($this->get_total_items_from_source($setSpec));
$this->add_log('total in collection: ' . $total); $this->add_log('total in collection: ' . $total);
$this->add_log('collection id ' . (string) $collection->get_id()); $this->add_log('collection ID ' . (string) $collection->get_id());
$this->add_collection([ $this->add_collection([
'id' => $collection->get_id(), 'id' => $collection->get_id(),
@ -194,7 +194,7 @@ class Oaipmh_Importer extends Importer {
$metadata_map = $this->create_collection_metadata($collection); $metadata_map = $this->create_collection_metadata($collection);
$total = intval( $this->get_total_items_from_source(false) ); $total = intval( $this->get_total_items_from_source(false) );
$this->add_log('total in collection: ' . $total); $this->add_log('total in collection: ' . $total);
$this->add_log('collection id ' . (string) $collection->get_id()); $this->add_log('collection ID ' . (string) $collection->get_id());
$tax = new Entities\Taxonomy(); $tax = new Entities\Taxonomy();
$tax->set_name( $this->NAME_FOR_SETS ); $tax->set_name( $this->NAME_FOR_SETS );
@ -869,4 +869,4 @@ class Oaipmh_Importer extends Importer {
return ob_get_clean(); return ob_get_clean();
} }
} }

View File

@ -33,7 +33,7 @@ class Old_Tainacan extends Importer{
'total' => 5 'total' => 5
] ]
]; ];
protected $tainacan_api_address, $wordpress_api_address, $actual_collection; protected $tainacan_api_address, $wordpress_api_address, $actual_collection;
/** /**
@ -48,7 +48,7 @@ class Old_Tainacan extends Importer{
$this->metadata_repo = \Tainacan\Repositories\Metadata::get_instance(); $this->metadata_repo = \Tainacan\Repositories\Metadata::get_instance();
$this->term_repo = \Tainacan\Repositories\Terms::get_instance(); $this->term_repo = \Tainacan\Repositories\Terms::get_instance();
$this->item_metadata_repo = \Tainacan\Repositories\Item_Metadata::get_instance(); $this->item_metadata_repo = \Tainacan\Repositories\Item_Metadata::get_instance();
$this->remove_import_method('file'); $this->remove_import_method('file');
$this->add_import_method('url'); $this->add_import_method('url');
$this->tainacan_api_address = "/wp-json/tainacan/v1"; $this->tainacan_api_address = "/wp-json/tainacan/v1";
@ -59,7 +59,7 @@ class Old_Tainacan extends Importer{
/** /**
* create taxonomies ( taxonomies in tainacan old in first level ) * create taxonomies ( taxonomies in tainacan old in first level )
* next create the terms * next create the terms
* *
*/ */
public function create_taxonomies() { public function create_taxonomies() {
if (!$this->get_url()) { if (!$this->get_url()) {
@ -67,20 +67,20 @@ class Old_Tainacan extends Importer{
$this->abort(); $this->abort();
return false; return false;
} }
$this->add_log('Creating taxonomies'); $this->add_log('Creating taxonomies');
foreach ($this->get_taxonomies() as $taxonomy) { foreach ($this->get_taxonomies() as $taxonomy) {
$tax = new Entities\Taxonomy(); $tax = new Entities\Taxonomy();
$tax->set_name( $taxonomy->name ); $tax->set_name( $taxonomy->name );
$tax->set_description( $taxonomy->description ); $tax->set_description( $taxonomy->description );
$tax->set_allow_insert('yes'); $tax->set_allow_insert('yes');
$tax->set_status('publish'); $tax->set_status('publish');
if ($tax->validate()) { if ($tax->validate()) {
$tax = $this->tax_repo->insert($tax); $tax = $this->tax_repo->insert($tax);
$this->add_log('Taxonomy ' . $tax->get_name() . ' created, id from Old'. $taxonomy->term_id ); $this->add_log('Taxonomy ' . $tax->get_name() . ' created, ID from Old'. $taxonomy->term_id );
$this->add_transient('tax_' . $taxonomy->term_id . '_id', $tax->get_id()); $this->add_transient('tax_' . $taxonomy->term_id . '_id', $tax->get_id());
$this->add_transient('tax_' . $taxonomy->term_id . '_name', $tax->get_name()); $this->add_transient('tax_' . $taxonomy->term_id . '_name', $tax->get_name());
@ -95,14 +95,14 @@ class Old_Tainacan extends Importer{
return false; return false;
} }
/** /**
* create the repository metadata which each collection inherits by default * create the repository metadata which each collection inherits by default
* *
*/ */
public function create_repo_metadata() { public function create_repo_metadata() {
$this->add_log('Creating repository metadata'); $this->add_log('Creating repository metadata');
foreach ($this->get_repo_metadata() as $metadata) { foreach ($this->get_repo_metadata() as $metadata) {
if (isset($metadata->slug) && strpos($metadata->slug, 'socialdb_property_fixed') === false) { if (isset($metadata->slug) && strpos($metadata->slug, 'socialdb_property_fixed') === false) {
$metadatum_id = $this->create_metadata( $metadata ); $metadatum_id = $this->create_metadata( $metadata );
@ -117,12 +117,12 @@ class Old_Tainacan extends Importer{
/** /**
* create all collections and its metadata * create all collections and its metadata
* *
*/ */
public function create_collections(){ public function create_collections(){
$this->add_log('Creating collections'); $this->add_log('Creating collections');
foreach ($this->fetch_collections() as $collection) { foreach ($this->fetch_collections() as $collection) {
$map = []; $map = [];
$this->add_log(memory_get_usage()); $this->add_log(memory_get_usage());
@ -136,16 +136,16 @@ class Old_Tainacan extends Importer{
$metadatum_id = $this->create_metadata( $metadatum_old, $collection_id ); $metadatum_id = $this->create_metadata( $metadatum_old, $collection_id );
if( $metadatum_id ){ if( $metadatum_id ){
$map[$metadatum_id] = $metadatum_old->id; $map[$metadatum_id] = $metadatum_old->id;
} }
} else if( isset($metadatum_old->slug) && strpos($metadatum_old->slug, 'socialdb_property_fixed_tags') !== false } else if( isset($metadatum_old->slug) && strpos($metadatum_old->slug, 'socialdb_property_fixed_tags') !== false
&& isset($metadatum_old->type) && strpos($metadatum_old->type, 'checkbox') !== false && isset($metadatum_old->type) && strpos($metadatum_old->type, 'checkbox') !== false
){ ){
$metadatum_id = $this->create_metadata( $metadatum_old, $collection_id ); $metadatum_id = $this->create_metadata( $metadatum_old, $collection_id );
$this->add_log('Creating tag'); $this->add_log('Creating tag');
if( $metadatum_id ){ if( $metadatum_id ){
$map[$metadatum_id] = $metadatum_old->id; $map[$metadatum_id] = $metadatum_old->id;
} }
} }
@ -177,17 +177,17 @@ class Old_Tainacan extends Importer{
if( $collections && is_array( $collections ) ){ if( $collections && is_array( $collections ) ){
foreach( $collections as $collection ){ // loop collections foreach( $collections as $collection ){ // loop collections
$map = $this->get_transient('collection_' . $collection->get_id() . '_relationships'); $map = $this->get_transient('collection_' . $collection->get_id() . '_relationships');
if(!$map){ if(!$map){
return false; return false;
} }
foreach( $map as $metadatum_id => $items ){ // all relations in collection foreach( $map as $metadatum_id => $items ){ // all relations in collection
$newMetadatum = new Entities\Metadatum($metadatum_id); $newMetadatum = new Entities\Metadatum($metadatum_id);
$first_index_id = key($items); $first_index_id = key($items);
$collection_id = $this->get_transient('item_' . $items[$first_index_id] . '_collection'); $collection_id = $this->get_transient('item_' . $items[$first_index_id] . '_collection');
$newMetadatum->set_metadata_type_options(['collection_id' => $collection_id ]); $newMetadatum->set_metadata_type_options(['collection_id' => $collection_id ]);
@ -198,7 +198,7 @@ class Old_Tainacan extends Importer{
reset($items); reset($items);
foreach( $items as $item_id => $value_old ){ // all values foreach( $items as $item_id => $value_old ){ // all values
$value_new = $this->get_transient('item_' . $value_old . '_id'); $value_new = $this->get_transient('item_' . $value_old . '_id');
$item = new Entities\Item($item_id); $item = new Entities\Item($item_id);
$item_metadata = new Entities\Item_Metadata_Entity( $item, $newMetadatum ); $item_metadata = new Entities\Item_Metadata_Entity( $item, $newMetadatum );
@ -226,15 +226,15 @@ class Old_Tainacan extends Importer{
'redirection' => 30, 'redirection' => 30,
); );
$page = intval( $index ) + 1; $page = intval( $index ) + 1;
$this->add_log('Proccess item index' . $index . ' in collection OLD ' . $collection_id['source_id'] ); $this->add_log('Proccess item index' . $index . ' in collection OLD ' . $collection_id['source_id'] );
$url_to_fetch = $this->get_url() . $this->tainacan_api_address . "/collections/". $url_to_fetch = $this->get_url() . $this->tainacan_api_address . "/collections/".
$collection_id['source_id']."/items?includeMetadata=1&filter[items_per_page]=1&filter[page]=" . $page $collection_id['source_id']."/items?includeMetadata=1&filter[items_per_page]=1&filter[page]=" . $page
. "&filter[order_by]=ID&filter[order]=ASC"; . "&filter[order_by]=ID&filter[order]=ASC";
$info = $this->requester( $url_to_fetch, $args ); $info = $this->requester( $url_to_fetch, $args );
$info = json_decode($info['body']); $info = json_decode($info['body']);
if( !isset( $info->items ) ){ if( !isset( $info->items ) ){
@ -248,7 +248,7 @@ class Old_Tainacan extends Importer{
$this->abort(); $this->abort();
return false; return false;
} }
$the_item = null; $the_item = null;
foreach( $info->items as $item ){ foreach( $info->items as $item ){
@ -257,7 +257,7 @@ class Old_Tainacan extends Importer{
if( isset($the_item) && isset($the_item->item) && !empty($the_item->item) ){ if( isset($the_item) && isset($the_item->item) && !empty($the_item->item) ){
$item_Old = $the_item; $item_Old = $the_item;
$this->add_log('item found ', $the_item->item->ID ); $this->add_log('item found ', $the_item->item->ID );
return [ 'item' => $item_Old, 'collection_definition' => $collection_id ]; return [ 'item' => $item_Old, 'collection_definition' => $collection_id ];
} else { } else {
$this->add_error_log('fetching remote ' . $url_to_fetch); $this->add_error_log('fetching remote ' . $url_to_fetch);
@ -273,7 +273,7 @@ class Old_Tainacan extends Importer{
* @param array $processed_item Associative array with metadatum source's as index with * @param array $processed_item Associative array with metadatum source's as index with
* its value or values * its value or values
* @param integet $collection_index The index in the $this->collections array of the collection the item is beeing inserted into * @param integet $collection_index The index in the $this->collections array of the collection the item is beeing inserted into
* *
* @return Tainacan\Entities\Item Item inserted * @return Tainacan\Entities\Item Item inserted
*/ */
public function insert( $processed_item, $collection_index ) { public function insert( $processed_item, $collection_index ) {
@ -336,7 +336,7 @@ class Old_Tainacan extends Importer{
$newMetadatum = new Entities\Metadatum($new_tainacanid); $newMetadatum = new Entities\Metadatum($new_tainacanid);
$item_metadata = new Entities\Item_Metadata_Entity( $item, $newMetadatum ); $item_metadata = new Entities\Item_Metadata_Entity( $item, $newMetadatum );
// avoid blank metadatum // avoid blank metadatum
if( isset($metadatum->empty) ){ if( isset($metadatum->empty) ){
@ -357,7 +357,7 @@ class Old_Tainacan extends Importer{
if( in_array($metadatum->type,['text', 'textarea', 'numeric', 'date']) ){ if( in_array($metadatum->type,['text', 'textarea', 'numeric', 'date']) ){
if($metadatum->type === 'date'){ if($metadatum->type === 'date'){
if(is_array($value)){ if(is_array($value)){
$values = []; $values = [];
@ -365,17 +365,17 @@ class Old_Tainacan extends Importer{
$v = explode('/',$day); $v = explode('/',$day);
$v[1]= ( $v[1] < 10 ) ? '0'.$v[1] : $v[1]; $v[1]= ( $v[1] < 10 ) ? '0'.$v[1] : $v[1];
$v[0]= ( $v[0] < 10 ) ? '0'.$v[0] : $v[0]; $v[0]= ( $v[0] < 10 ) ? '0'.$v[0] : $v[0];
$values[] = $v[2] . '-' . $v[1] . '-' . $v[0]; $values[] = $v[2] . '-' . $v[1] . '-' . $v[0];
} }
} else { } else {
$v = explode('/',$value); $v = explode('/',$value);
$v[1]= ( $v[1] < 10 ) ? '0'. $v[1] : $v[1]; $v[1]= ( $v[1] < 10 ) ? '0'. $v[1] : $v[1];
$v[0]= ( $v[0] < 10 ) ? '0'. $v[0] : $v[0]; $v[0]= ( $v[0] < 10 ) ? '0'. $v[0] : $v[0];
$values = $v[2] . '-' . $v[1] . '-' . $v[0]; $values = $v[2] . '-' . $v[1] . '-' . $v[0];
} }
@ -386,12 +386,12 @@ class Old_Tainacan extends Importer{
$item_metadata->set_value($value); $item_metadata->set_value($value);
} else if( $metadatum->type === 'item' ){ // RELATIONSHIPS } else if( $metadatum->type === 'item' ){ // RELATIONSHIPS
/** /**
* save the values to allow set the correct collection * save the values to allow set the correct collection
* in metadata option in next step * in metadata option in next step
*/ */
$relationships[$new_tainacanid][$item->get_id()] = $value; $relationships[$new_tainacanid][$item->get_id()] = $value;
} else { } else {
@ -403,7 +403,7 @@ class Old_Tainacan extends Importer{
if( $id ) if( $id )
$values[] = intval($id); $values[] = intval($id);
} }
} else { } else {
$id = $this->get_transient('term_' . $value . '_id'); $id = $this->get_transient('term_' . $value . '_id');
@ -456,7 +456,7 @@ class Old_Tainacan extends Importer{
} else { } else {
return 0; return 0;
} }
} }
/** /**
@ -469,17 +469,17 @@ class Old_Tainacan extends Importer{
$args = array( $args = array(
'timeout' => 30, 'timeout' => 30,
'redirection' => 30, 'redirection' => 30,
); );
$info = wp_remote_get( $this->get_url() . $this->tainacan_api_address . "/collections/".$collection_id."/items?includeMetadata=1&filter[page]=" . $page, $args );
$info = wp_remote_get( $this->get_url() . $this->tainacan_api_address . "/collections/".$collection_id."/items?includeMetadata=1&filter[page]=" . $page, $args );
if( !isset($info['body']) ){ if( !isset($info['body']) ){
$this->add_error_log($result->get_error_message()); $this->add_error_log($result->get_error_message());
$this->add_error_log('Error in fetch remote first page item'); $this->add_error_log('Error in fetch remote first page item');
$this->abort(); $this->abort();
return false; return false;
} }
$info = json_decode($info['body']); $info = json_decode($info['body']);
while( isset($info->items) && count( $info->items ) > 0 ){ while( isset($info->items) && count( $info->items ) > 0 ){
@ -489,7 +489,7 @@ class Old_Tainacan extends Importer{
} }
$page++; $page++;
$info = wp_remote_get( $this->get_url() . $this->tainacan_api_address . "/collections/".$collection_id."/items?includeMetadata=1&filter[page]=" . $page, $args ); $info = wp_remote_get( $this->get_url() . $this->tainacan_api_address . "/collections/".$collection_id."/items?includeMetadata=1&filter[page]=" . $page, $args );
$info = json_decode($info['body']); $info = json_decode($info['body']);
if( !isset($info['body']) ){ if( !isset($info['body']) ){
@ -498,8 +498,8 @@ class Old_Tainacan extends Importer{
$this->abort(); $this->abort();
return false; return false;
} }
} }
return $items; return $items;
} }
@ -593,7 +593,7 @@ class Old_Tainacan extends Importer{
} }
/** /**
* executes the request * executes the request
*/ */
protected function requester( $link ){ protected function requester( $link ){
$has_response = false; $has_response = false;
@ -609,13 +609,13 @@ class Old_Tainacan extends Importer{
$result = wp_remote_get($link, $args); $result = wp_remote_get($link, $args);
while( !$has_response ){ while( !$has_response ){
if (is_wp_error($result)) { if (is_wp_error($result)) {
$this->add_log($result->get_error_message()); $this->add_log($result->get_error_message());
$this->add_log('Error in fetch remote' . $url); $this->add_log('Error in fetch remote' . $url);
$this->add_log('request number ' . $requests); $this->add_log('request number ' . $requests);
} else if (isset($result['body'])){ } else if (isset($result['body'])){
$this->add_log('fetch OK '); $this->add_log('fetch OK ');
return $result; return $result;
@ -627,7 +627,7 @@ class Old_Tainacan extends Importer{
if( $requests > 3 ){ if( $requests > 3 ){
$this->add_log('taking a moment to breathe, waiting for ' . ( $requests * 10 ) . ' seconds ' ); $this->add_log('taking a moment to breathe, waiting for ' . ( $requests * 10 ) . ' seconds ' );
sleep( $requests * 10 ); sleep( $requests * 10 );
} }
$args = array( $args = array(
@ -635,14 +635,14 @@ class Old_Tainacan extends Importer{
'redirection' => 30, 'redirection' => 30,
'sslverify' => false 'sslverify' => false
); );
$result = wp_remote_get($link, $args); $result = wp_remote_get($link, $args);
$requests++; $requests++;
$this->add_log('going to ' . $requests ); $this->add_log('going to ' . $requests );
} }
$this->add_error_log('Error in fetch remote, expired the 10 requests limit ' . $url); $this->add_error_log('Error in fetch remote, expired the 10 requests limit ' . $url);
$this->abort(); $this->abort();
@ -653,7 +653,7 @@ class Old_Tainacan extends Importer{
* create recursively the terms from tainacan OLD * create recursively the terms from tainacan OLD
* *
* @param Entities\Taxonomy $taxonomy_father * @param Entities\Taxonomy $taxonomy_father
* @param array $children Array of taxonomies from tainacan old * @param array $children Array of taxonomies from tainacan old
* @param (optional) int $term_father the ID of father * @param (optional) int $term_father the ID of father
* *
* @return array * @return array
@ -661,7 +661,7 @@ class Old_Tainacan extends Importer{
protected function add_all_terms($taxonomy_father, $children, $term_father = null){ protected function add_all_terms($taxonomy_father, $children, $term_father = null){
$this->add_log('adding terms'); $this->add_log('adding terms');
foreach ($children as $term) { foreach ($children as $term) {
$new_term = new Entities\Term(); $new_term = new Entities\Term();
@ -672,27 +672,27 @@ class Old_Tainacan extends Importer{
if($term_father){ if($term_father){
$new_term->set_parent($term_father->get_id()); $new_term->set_parent($term_father->get_id());
} }
// block terms with same name and parent in taxonomy // block terms with same name and parent in taxonomy
if( get_term_by( 'name', $term->name, $taxonomy_father->get_db_identifier()) ){ if( get_term_by( 'name', $term->name, $taxonomy_father->get_db_identifier()) ){
continue; continue;
} }
if ($new_term->validate()) { if ($new_term->validate()) {
$inserted_term = $this->term_repo->insert($new_term); $inserted_term = $this->term_repo->insert($new_term);
} else { } else {
$this->add_log( implode(',', $new_term->get_errors()) ); $this->add_log( implode(',', $new_term->get_errors()) );
return false; return false;
} }
if (is_wp_error($inserted_term)) { if (is_wp_error($inserted_term)) {
$this->add_log($inserted_term->get_error_message()); $this->add_log($inserted_term->get_error_message());
} else { } else {
$this->add_log('Added term: ' . $inserted_term->get_name() . ' in tax: ' . $taxonomy_father->get_name()); $this->add_log('Added term: ' . $inserted_term->get_name() . ' in tax: ' . $taxonomy_father->get_name());
$this->add_log('Added term before id ' . $term->term_id ); $this->add_log('Added term before ID ' . $term->term_id );
} }
/*Insert old tainacan id*/ /*Insert old tainacan id*/
@ -709,8 +709,8 @@ class Old_Tainacan extends Importer{
/** /**
* create the a Metadatum in tainacan * create the a Metadatum in tainacan
* *
* @return int $metadatum_id * @return int $metadatum_id
*/ */
protected function create_metadata( $node_metadata_old, $collection_id = null){ protected function create_metadata( $node_metadata_old, $collection_id = null){
$this->add_log('Creating metadata' . $meta->name); $this->add_log('Creating metadata' . $meta->name);
@ -751,7 +751,7 @@ class Old_Tainacan extends Importer{
return false; return false;
} }
} else if(strcmp($type, "Compound") === 0){ } else if(strcmp($type, "Compound") === 0){
if( isset( $meta->metadata->children ) ){ if( isset( $meta->metadata->children ) ){
foreach( $meta->metadata->children as $child ){ foreach( $meta->metadata->children as $child ){
$this->create_metadata( $child, $collection_id); $this->create_metadata( $child, $collection_id);
@ -778,9 +778,9 @@ class Old_Tainacan extends Importer{
if($newMetadatum->validate()){ if($newMetadatum->validate()){
$inserted_metadata = $this->metadata_repo->insert( $newMetadatum ); $inserted_metadata = $this->metadata_repo->insert( $newMetadatum );
$this->add_log('Metadata created: ' . $inserted_metadata->get_name()); $this->add_log('Metadata created: ' . $inserted_metadata->get_name());
$this->add_transient('metadata_' . $inserted_metadata->get_id() . '_id', $inserted_metadata->get_id()); $this->add_transient('metadata_' . $inserted_metadata->get_id() . '_id', $inserted_metadata->get_id());
if(isset( $related_name) ){ if(isset( $related_name) ){
@ -788,48 +788,48 @@ class Old_Tainacan extends Importer{
} }
return $inserted_metadata->get_id(); return $inserted_metadata->get_id();
} else{ } else{
$this->add_log('Error creating metadata ' . $name . ' in collection ' . $collection_id); $this->add_log('Error creating metadata ' . $name . ' in collection ' . $collection_id);
$this->add_log($newMetadatum->get_errors()); $this->add_log($newMetadatum->get_errors());
return false; return false;
} }
} }
/** /**
* create the collection in tainacan * create the collection in tainacan
* *
* @return int $metadatum_id * @return int $metadatum_id
*/ */
protected function create_collection( $node_collection ){ protected function create_collection( $node_collection ){
$new_collection = new Entities\Collection(); $new_collection = new Entities\Collection();
$new_collection->set_name($node_collection->post_title); $new_collection->set_name($node_collection->post_title);
$new_collection->set_status('publish'); $new_collection->set_status('publish');
$new_collection->validate(); $new_collection->validate();
if($new_collection->validate()){ if($new_collection->validate()){
$new_collection =$this->col_repo->insert($new_collection); $new_collection =$this->col_repo->insert($new_collection);
$this->add_log('Collection created: ' . $new_collection->get_name()); $this->add_log('Collection created: ' . $new_collection->get_name());
if( $new_collection ) if( $new_collection )
$this->add_transient('collection_' . $node_collection->ID . '_name', $new_collection->get_id()); $this->add_transient('collection_' . $node_collection->ID . '_name', $new_collection->get_id());
return $new_collection->get_id(); return $new_collection->get_id();
} else{ } else{
$this->add_error_log('Error creating collection ' . $node_collection->post_title ); $this->add_error_log('Error creating collection ' . $node_collection->post_title );
$this->add_error_log($new_collection->get_errors()); $this->add_error_log($new_collection->get_errors());
$this->abort(); $this->abort();
return false; return false;
} }
} }
/** /**
* Define the class to create in new Tainacan * Define the class to create in new Tainacan
* *
* @param string $type The type from tainacan old * @param string $type The type from tainacan old
* *
* @return string the class name * @return string the class name
*/ */
private function define_type($type){ private function define_type($type){
@ -848,16 +848,16 @@ class Old_Tainacan extends Importer{
$type = "Compound"; $type = "Compound";
} else { } else {
$type = 'Text'; $type = 'Text';
} }
return $type; return $type;
} }
/** /**
* create attachments, document and thumb from old * create attachments, document and thumb from old
* *
* @param string $node_old * @param string $node_old
* *
* @return string the class name * @return string the class name
*/ */
private function insert_files( $node_old, $item ){ private function insert_files( $node_old, $item ){
@ -867,7 +867,7 @@ class Old_Tainacan extends Importer{
foreach( $types as $type){ foreach( $types as $type){
if( isset( $node_old->attachments->$type ) ){ if( isset( $node_old->attachments->$type ) ){
foreach( $node_old->attachments->$type as $attach){ foreach( $node_old->attachments->$type as $attach){
$TainacanMedia->insert_attachment_from_url($attach->url, $item->get_id()); $TainacanMedia->insert_attachment_from_url($attach->url, $item->get_id());
} }
@ -883,7 +883,7 @@ class Old_Tainacan extends Importer{
if( isset( $node_old->content_tainacan ) && $node_old->content_tainacan ){ if( isset( $node_old->content_tainacan ) && $node_old->content_tainacan ){
$TainacanMedia = \Tainacan\Media::get_instance(); $TainacanMedia = \Tainacan\Media::get_instance();
if( isset($node_old->content_tainacan->guid) ){ if( isset($node_old->content_tainacan->guid) ){
$id = $TainacanMedia->insert_attachment_from_url( $node_old->content_tainacan->guid, $item->get_id()); $id = $TainacanMedia->insert_attachment_from_url( $node_old->content_tainacan->guid, $item->get_id());
@ -891,13 +891,13 @@ class Old_Tainacan extends Importer{
$item->set_document( $id ); $item->set_document( $id );
$item->set_document_type( 'attachment' ); $item->set_document_type( 'attachment' );
$this->add_log('Document imported from ' . $node_old->content_tainacan->guid); $this->add_log('Document imported from ' . $node_old->content_tainacan->guid);
} }
} else if( isset($node_old->type_tainacan) && in_array( $node_old->type_tainacan, ['audio','video','image']) ){ } else if( isset($node_old->type_tainacan) && in_array( $node_old->type_tainacan, ['audio','video','image']) ){
$item->set_document( $node_old->content_tainacan ); $item->set_document( $node_old->content_tainacan );
$item->set_document_type( 'url' ); $item->set_document_type( 'url' );
$this->add_log('URL imported from ' . $node_old->content_tainacan); $this->add_log('URL imported from ' . $node_old->content_tainacan);
} }
} }
if( $item->validate() ) if( $item->validate() )

View File

@ -378,7 +378,7 @@ class Filters extends Repository {
$original_meta_q = isset( $args['meta_query'] ) ? $args['meta_query'] : []; $original_meta_q = isset( $args['meta_query'] ) ? $args['meta_query'] : [];
/** /**
* Since we introduced roles & capabalities management, we can not rely * Since we introduced roles & capabalities management, we cannot rely
* on WordPress behavior when handling default post status values. * on WordPress behavior when handling default post status values.
* WordPress checks if the current user can read_priva_posts, but this is * WordPress checks if the current user can read_priva_posts, but this is
* not enough for us. We have to handle this ourselves to mimic WordPress behavior * not enough for us. We have to handle this ourselves to mimic WordPress behavior
@ -476,7 +476,7 @@ class Filters extends Repository {
$original_meta_q = isset( $args['meta_query'] ) ? $args['meta_query'] : []; $original_meta_q = isset( $args['meta_query'] ) ? $args['meta_query'] : [];
/** /**
* Since we introduced roles & capabalities management, we can not rely * Since we introduced roles & capabalities management, we cannot rely
* on WordPress behavior when handling default post status values. * on WordPress behavior when handling default post status values.
* WordPress checks if the current user can read_priva_posts, but this is * WordPress checks if the current user can read_priva_posts, but this is
* not enough for us. We have to handle this ourselves to mimic WordPress behavior * not enough for us. We have to handle this ourselves to mimic WordPress behavior

View File

@ -165,7 +165,7 @@ class Item_Metadata extends Repository {
if ( $taxonomy ) { if ( $taxonomy ) {
// We can not simply use wp_set_object_terms() because it uses term_exists() which is not reliable // We cannot simply use wp_set_object_terms() because it uses term_exists() which is not reliable
// see https://core.trac.wordpress.org/ticket/45333 and https://core.trac.wordpress.org/ticket/47099 // see https://core.trac.wordpress.org/ticket/45333 and https://core.trac.wordpress.org/ticket/47099
// $success = wp_set_object_terms( $item_metadata->get_item()->get_id(), $new_terms, $taxonomy->get_db_identifier() ); // $success = wp_set_object_terms( $item_metadata->get_item()->get_id(), $new_terms, $taxonomy->get_db_identifier() );

View File

@ -265,7 +265,7 @@ class Items extends Repository {
$no_collection_set = false; $no_collection_set = false;
/** /**
* We can not use $collections->fetch() here because facets * We cannot use $collections->fetch() here because facets
* filter wp_query to just return the query and not the results * filter wp_query to just return the query and not the results
* See Repositories\Metadata::fetch_all_metadatum_values() * See Repositories\Metadata::fetch_all_metadatum_values()
* *

View File

@ -33,15 +33,15 @@ class Logs extends Repository {
parent::__construct(); parent::__construct();
add_action( 'tainacan-pre-insert', array( $this, 'pre_insert_entity' ) ); add_action( 'tainacan-pre-insert', array( $this, 'pre_insert_entity' ) );
add_action( 'tainacan-insert', array( $this, 'insert_entity' ) ); add_action( 'tainacan-insert', array( $this, 'insert_entity' ) );
add_action( 'tainacan-deleted', array( $this, 'delete_entity' ), 10, 2 ); add_action( 'tainacan-deleted', array( $this, 'delete_entity' ), 10, 2 );
add_action( 'tainacan-pre-delete', array( $this, 'pre_delete_entity' ), 10, 2 ); add_action( 'tainacan-pre-delete', array( $this, 'pre_delete_entity' ), 10, 2 );
add_action( 'add_attachment', array( $this, 'insert_attachment' ) ); add_action( 'add_attachment', array( $this, 'insert_attachment' ) );
add_action( 'delete_attachment', array( $this, 'pre_delete_attachment' ) ); add_action( 'delete_attachment', array( $this, 'pre_delete_attachment' ) );
add_action( 'delete_post', array( $this, 'delete_attachment' ) ); add_action( 'delete_post', array( $this, 'delete_attachment' ) );
add_filter('tainacan-log-set-title', [$this, 'filter_log_title']); add_filter('tainacan-log-set-title', [$this, 'filter_log_title']);
} }
@ -108,7 +108,7 @@ class Logs extends Repository {
'object_id' => [ 'object_id' => [
'map' => 'meta', 'map' => 'meta',
'title' => __( 'Log item relationship', 'tainacan' ), 'title' => __( 'Log item relationship', 'tainacan' ),
'description' => __( 'The id of the object that this log is related to', 'tainacan' ), 'description' => __( 'The ID of the object that this log is related to', 'tainacan' ),
], ],
'object_type' => [ 'object_type' => [
'map' => 'meta', 'map' => 'meta',
@ -117,7 +117,7 @@ class Logs extends Repository {
], ],
'old_value' => [ 'old_value' => [
'map' => 'meta', 'map' => 'meta',
'title' => __( 'Old Value', 'tainacan' ), 'title' => __( 'Old value', 'tainacan' ),
], ],
'new_value' => [ 'new_value' => [
'map' => 'meta', 'map' => 'meta',
@ -182,7 +182,7 @@ class Logs extends Repository {
* to learn all args accepted in the $args parameter (@see https://developer.wordpress.org/reference/classes/wp_query/) * to learn all args accepted in the $args parameter (@see https://developer.wordpress.org/reference/classes/wp_query/)
* You can also use a mapped property, such as name and description, as an argument and it will be mapped to the * You can also use a mapped property, such as name and description, as an argument and it will be mapped to the
* appropriate WP_Query argument * appropriate WP_Query argument
* *
* If a number is passed to $args, it will return a \Tainacan\Entities\Log object. But if the post is not found or * If a number is passed to $args, it will return a \Tainacan\Entities\Log object. But if the post is not found or
* does not match the entity post type, it will return an empty array * does not match the entity post type, it will return an empty array
* *
@ -193,7 +193,7 @@ class Logs extends Repository {
*/ */
public function fetch( $args = [], $output = null ) { public function fetch( $args = [], $output = null ) {
if ( is_numeric( $args ) ) { if ( is_numeric( $args ) ) {
$existing_post = get_post( $args ); $existing_post = get_post( $args );
if ( $existing_post instanceof \WP_Post ) { if ( $existing_post instanceof \WP_Post ) {
try { try {
@ -225,7 +225,7 @@ class Logs extends Repository {
public function update( $object, $new_values = null ) { public function update( $object, $new_values = null ) {
return $this->insert( $object ); return $this->insert( $object );
} }
/** /**
* Feth most recent log * Feth most recent log
* @return Entities\Log The most recent Log entity * @return Entities\Log The most recent Log entity
@ -255,11 +255,11 @@ class Logs extends Repository {
$entity = Repository::get_entity_by_post( $post ); $entity = Repository::get_entity_by_post( $post );
if ( $entity ) { // attached to a tainacan entity if ( $entity ) { // attached to a tainacan entity
$log = new Entities\Log(); $log = new Entities\Log();
$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 ) { if ( method_exists($entity, 'get_repository') && !$entity->get_repository()->use_logs ) {
return; return;
} }
@ -272,24 +272,24 @@ class Logs extends Repository {
$log->set_item_id($entity->get_id()); $log->set_item_id($entity->get_id());
$log->set_title( sprintf( __( 'New file was attached to Item "%s"', 'tainacan'), $entity->get_title() ) ); $log->set_title( sprintf( __( 'New file was attached to Item "%s"', 'tainacan'), $entity->get_title() ) );
} }
$object_type = get_class($entity); $object_type = get_class($entity);
$object_id = $entity->get_id(); $object_id = $entity->get_id();
$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');
$prepared = [ $prepared = [
'id' => $attachment->ID, 'id' => $attachment->ID,
'title' => $attachment->post_title, 'title' => $attachment->post_title,
'description' => $attachment->post_content, 'description' => $attachment->post_content,
'mime_type' => $attachment->post_mime_type, 'mime_type' => $attachment->post_mime_type,
]; ];
$log->set_new_value($prepared); $log->set_new_value($prepared);
if ( $log->validate() ) { if ( $log->validate() ) {
$this->insert($log); $this->insert($log);
} }
@ -298,28 +298,28 @@ class Logs extends Repository {
} }
} }
/** /**
* Callback to generate log when attachments attached to any Tainacan entity are deleted * Callback to generate log when attachments attached to any Tainacan entity are deleted
*/ */
public function pre_delete_attachment($attachment_id) { public function pre_delete_attachment($attachment_id) {
$attachment_post = get_post($attachment_id); $attachment_post = get_post($attachment_id);
$entity_post = get_post($attachment_post->post_parent); $entity_post = get_post($attachment_post->post_parent);
if ( $entity_post ) { if ( $entity_post ) {
try { try {
$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 ) { if ( method_exists($entity, 'get_repository') && !$entity->get_repository()->use_logs ) {
return; 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();
if ( $entity instanceof Entities\Collection ) { if ( $entity instanceof Entities\Collection ) {
$collection_id = $entity->get_id(); $collection_id = $entity->get_id();
$log->set_title( sprintf(__( 'File attached to Collection "%s" was removed', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf(__( 'File attached to Collection "%s" was removed', 'tainacan'), $entity->get_name() ) );
@ -328,32 +328,32 @@ class Logs extends Repository {
$log->set_item_id($entity->get_id()); $log->set_item_id($entity->get_id());
$log->set_title( sprintf( __( 'File attached to Item "%s" was removed' , 'tainacan'), $entity->get_title() ) ); $log->set_title( sprintf( __( 'File attached to Item "%s" was removed' , 'tainacan'), $entity->get_title() ) );
} }
$object_type = get_class($entity); $object_type = get_class($entity);
$object_id = $entity->get_id(); $object_id = $entity->get_id();
$preapred = [ $preapred = [
'id' => $attachment_id, 'id' => $attachment_id,
'title' => $attachment_post->post_title, 'title' => $attachment_post->post_title,
'description' => $attachment_post->post_content, 'description' => $attachment_post->post_content,
]; ];
$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_old_value($preapred); $log->set_old_value($preapred);
$log->set_action('delete-attachment'); $log->set_action('delete-attachment');
$this->current_attachment_delete_log = $log; $this->current_attachment_delete_log = $log;
} }
} catch (\Exception $e) { } catch (\Exception $e) {
error_log("[pre_delete_attachment]:" . $e->getMessage()); error_log("[pre_delete_attachment]:" . $e->getMessage());
} }
} }
} }
/** /**
* Callback to generate log when attachments attached to any Tainacan entity are deleted * Callback to generate log when attachments attached to any Tainacan entity are deleted
*/ */
@ -366,7 +366,7 @@ class Logs extends Repository {
} }
} }
} }
/** /**
* Compare two repository entities and sets the current_diff property to be used in the insert hook * Compare two repository entities and sets the current_diff property to be used in the insert hook
* *
@ -379,20 +379,20 @@ class Logs extends Repository {
if ( ! $unsaved->get_repository()->use_logs ) { if ( ! $unsaved->get_repository()->use_logs ) {
return; return;
} }
if ( $unsaved instanceof Entities\Item_Metadata_Entity ) { if ( $unsaved instanceof Entities\Item_Metadata_Entity ) {
return $this->prepare_item_metadata_diff($unsaved); return $this->prepare_item_metadata_diff($unsaved);
} }
// do not log a log // do not log a log
if ( ( method_exists( $unsaved, 'get_post_type' ) && $unsaved->get_post_type() === 'tainacan-log' ) || $unsaved->get_status() === 'auto-draft' ) { if ( ( method_exists( $unsaved, 'get_post_type' ) && $unsaved->get_post_type() === 'tainacan-log' ) || $unsaved->get_status() === 'auto-draft' ) {
return; return;
} }
$creating = true; $creating = true;
$old = null; $old = null;
if ( is_numeric( $unsaved->get_id() ) ) { if ( is_numeric( $unsaved->get_id() ) ) {
if ( $unsaved instanceof Entities\Term ) { if ( $unsaved instanceof Entities\Term ) {
$old = $unsaved->get_repository()->fetch( $unsaved->get_id(), $unsaved->get_taxonomy() ); $old = $unsaved->get_repository()->fetch( $unsaved->get_id(), $unsaved->get_taxonomy() );
@ -400,78 +400,78 @@ class Logs extends Repository {
$old = $unsaved->get_repository()->fetch( $unsaved->get_id() ); $old = $unsaved->get_repository()->fetch( $unsaved->get_id() );
} }
} }
if ( $old instanceof Entities\Entity ) { if ( $old instanceof Entities\Entity ) {
if ( $old->get_status() !== 'auto-draft' ) { if ( $old->get_status() !== 'auto-draft' ) {
$creating = false; $creating = false;
} }
} }
$diff = [ $diff = [
'old' => [], 'old' => [],
'new' => [] 'new' => []
]; ];
$has_diff = false; $has_diff = false;
if ( $creating ) { if ( $creating ) {
$diff['new'] = $unsaved->_toArray(); $diff['new'] = $unsaved->_toArray();
$has_diff = true; $has_diff = true;
} else { } else {
$map = $unsaved->get_repository()->get_map(); $map = $unsaved->get_repository()->get_map();
foreach ( $map as $prop => $mapped ) { foreach ( $map as $prop => $mapped ) {
if ( $old->get( $prop ) != $unsaved->get( $prop ) ) { if ( $old->get( $prop ) != $unsaved->get( $prop ) ) {
$diff['old'][$prop] = $old->get( $prop ); $diff['old'][$prop] = $old->get( $prop );
$diff['new'][$prop] = $unsaved->get( $prop ); $diff['new'][$prop] = $unsaved->get( $prop );
$has_diff = true; $has_diff = true;
} }
} }
} }
$diff = apply_filters( 'tainacan-entity-diff', $diff, $unsaved, $old ); $diff = apply_filters( 'tainacan-entity-diff', $diff, $unsaved, $old );
$this->current_diff = $has_diff ? $diff : false; $this->current_diff = $has_diff ? $diff : false;
$this->current_action = $creating ? 'create' : 'update'; $this->current_action = $creating ? 'create' : 'update';
} }
private function prepare_item_metadata_diff( Entities\Entity $unsaved ) { private function prepare_item_metadata_diff( Entities\Entity $unsaved ) {
$diff = [ $diff = [
'old' => [], 'old' => [],
'new' => [] 'new' => []
]; ];
$old = new Entities\Item_Metadata_Entity($unsaved->get_item(), $unsaved->get_metadatum()); $old = new Entities\Item_Metadata_Entity($unsaved->get_item(), $unsaved->get_metadatum());
add_filter('tainacan-item-metadata-get-multivalue-separator', [$this, '__temporary_multivalue_separator']); add_filter('tainacan-item-metadata-get-multivalue-separator', [$this, '__temporary_multivalue_separator']);
if ( $old instanceof Entities\Item_Metadata_Entity ) { if ( $old instanceof Entities\Item_Metadata_Entity ) {
$diff['old'] = \explode($this->__temporary_multivalue_separator(''), $old->get_value_as_string()); $diff['old'] = \explode($this->__temporary_multivalue_separator(''), $old->get_value_as_string());
} }
$diff['new'] = \explode($this->__temporary_multivalue_separator(''), $unsaved->get_value_as_string()); $diff['new'] = \explode($this->__temporary_multivalue_separator(''), $unsaved->get_value_as_string());
remove_filter('tainacan-item-metadata-get-multivalue-separator', [$this, '__temporary_multivalue_separator']); remove_filter('tainacan-item-metadata-get-multivalue-separator', [$this, '__temporary_multivalue_separator']);
$diff = apply_filters( 'tainacan-entity-diff', $diff, $unsaved, $old ); $diff = apply_filters( 'tainacan-entity-diff', $diff, $unsaved, $old );
$this->current_diff = $diff; $this->current_diff = $diff;
$this->current_action = 'update-metadata-value'; $this->current_action = 'update-metadata-value';
} }
public function __temporary_multivalue_separator($sep) { public function __temporary_multivalue_separator($sep) {
return '--xx--'; return '--xx--';
} }
/** /**
* Callback to generate log when Tainacan entities are edited * Callback to generate log when Tainacan entities are edited
*/ */
@ -480,31 +480,31 @@ class Logs extends Repository {
if ( ! $entity->get_repository()->use_logs ) { if ( ! $entity->get_repository()->use_logs ) {
return; return;
} }
if ( $entity instanceof Entities\Item_Metadata_Entity ) { if ( $entity instanceof Entities\Item_Metadata_Entity ) {
return $this->insert_item_metadata($entity); return $this->insert_item_metadata($entity);
} }
// do not log a log // do not log a log
if ( ( method_exists( $entity, 'get_post_type' ) && $entity->get_post_type() === 'tainacan-log' ) || $entity->get_status() === 'auto-draft' ) { if ( ( method_exists( $entity, 'get_post_type' ) && $entity->get_post_type() === 'tainacan-log' ) || $entity->get_status() === 'auto-draft' ) {
return false; return false;
} }
$log = new Entities\Log(); $log = new Entities\Log();
$log->set_action($this->current_action); $log->set_action($this->current_action);
$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';
$diff = $this->current_diff; $diff = $this->current_diff;
if (false === $diff) { if (false === $diff) {
return; return;
} }
if ( $entity instanceof Entities\Collection ) { if ( $entity instanceof Entities\Collection ) {
$collection_id = $entity->get_id(); $collection_id = $entity->get_id();
if ($this->current_action == 'update') { if ($this->current_action == 'update') {
if (isset($diff['new']['metadata_order'])) { if (isset($diff['new']['metadata_order'])) {
$log->set_title( sprintf( __( 'Collection "%s" metadata order was updated', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Collection "%s" metadata order was updated', 'tainacan'), $entity->get_name() ) );
@ -518,11 +518,11 @@ class Logs extends Repository {
} elseif ($this->current_action == 'create') { } elseif ($this->current_action == 'create') {
$log->set_title( sprintf( __( 'Collection "%s" was created', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Collection "%s" was created', 'tainacan'), $entity->get_name() ) );
} }
} elseif ( $entity instanceof Entities\Item ) { } elseif ( $entity instanceof Entities\Item ) {
$log->set_item_id($entity->get_id()); $log->set_item_id($entity->get_id());
if ($this->current_action == 'update') { if ($this->current_action == 'update') {
if (isset($diff['new']['document'])) { if (isset($diff['new']['document'])) {
$log->set_title( sprintf( __( 'Item "%s" document was updated', 'tainacan'), $entity->get_title() ) ); $log->set_title( sprintf( __( 'Item "%s" document was updated', 'tainacan'), $entity->get_title() ) );
@ -537,7 +537,7 @@ class Logs extends Repository {
$log->set_title( sprintf( __( 'Item "%1$s" was created with the ID %2$s', 'tainacan'), $entity->get_title(), $entity->get_id() ) ); $log->set_title( sprintf( __( 'Item "%1$s" was created with the ID %2$s', 'tainacan'), $entity->get_title(), $entity->get_id() ) );
} }
} elseif ( $entity instanceof Entities\Filter ) { } elseif ( $entity instanceof Entities\Filter ) {
if ( 'default' == $collection_id ) { if ( 'default' == $collection_id ) {
if ($this->current_action == 'update') { if ($this->current_action == 'update') {
$log->set_title( sprintf( __( 'Filter "%1$s" was updated in repository level', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Filter "%1$s" was updated in repository level', 'tainacan'), $entity->get_name() ) );
@ -551,9 +551,9 @@ class Logs extends Repository {
$log->set_title( sprintf( __( 'Filter "%1$s" was added to Collection "%2$s"', 'tainacan'), $entity->get_name(), $entity->get_collection()->get_name() ) ); $log->set_title( sprintf( __( 'Filter "%1$s" was added to Collection "%2$s"', 'tainacan'), $entity->get_name(), $entity->get_collection()->get_name() ) );
} }
} }
} elseif ( $entity instanceof Entities\Metadatum ) { } elseif ( $entity instanceof Entities\Metadatum ) {
if ( 'default' == $collection_id ) { if ( 'default' == $collection_id ) {
if ($this->current_action == 'update') { if ($this->current_action == 'update') {
$log->set_title( sprintf( __( 'Metadatum "%s" was updated in repository level', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Metadatum "%s" was updated in repository level', 'tainacan'), $entity->get_name() ) );
@ -567,99 +567,99 @@ class Logs extends Repository {
$log->set_title( sprintf( __( 'Metadatum "%1$s" was added to Collection "%2$s"', 'tainacan'), $entity->get_name(), $entity->get_collection()->get_name() ) ); $log->set_title( sprintf( __( 'Metadatum "%1$s" was added to Collection "%2$s"', 'tainacan'), $entity->get_name(), $entity->get_collection()->get_name() ) );
} }
} }
} elseif ( $entity instanceof Entities\Taxonomy ) { } elseif ( $entity instanceof Entities\Taxonomy ) {
if ($this->current_action == 'update') { if ($this->current_action == 'update') {
$log->set_title( sprintf( __( 'Taxonomy "%s" was updated', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Taxonomy "%s" was updated', 'tainacan'), $entity->get_name() ) );
} elseif ($this->current_action == 'create') { } elseif ($this->current_action == 'create') {
$log->set_title( sprintf( __( 'Taxonomy "%1$s" was created', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Taxonomy "%1$s" was created', 'tainacan'), $entity->get_name() ) );
} }
} elseif ( $entity instanceof Entities\Term ) { } elseif ( $entity instanceof Entities\Term ) {
$taxonomy = Taxonomies::get_instance()->fetch_by_db_identifier($entity->get_taxonomy()); $taxonomy = Taxonomies::get_instance()->fetch_by_db_identifier($entity->get_taxonomy());
$tax_name = ''; $tax_name = '';
if ($taxonomy instanceof Entities\Taxonomy) { if ($taxonomy instanceof Entities\Taxonomy) {
$tax_name = $taxonomy->get_name(); $tax_name = $taxonomy->get_name();
} }
if ($this->current_action == 'update') { if ($this->current_action == 'update') {
$log->set_title( sprintf( __( 'Term "%1$s" was updated in "%2$s" taxonomy', 'tainacan'), $entity->get_name(), $tax_name ) ); $log->set_title( sprintf( __( 'Term "%1$s" was updated in "%2$s" taxonomy', 'tainacan'), $entity->get_name(), $tax_name ) );
} elseif ($this->current_action == 'create') { } elseif ($this->current_action == 'create') {
$log->set_title( sprintf( __( 'Term "%1$s" was added to "%2$s" taxonomy', 'tainacan'), $entity->get_name(), $tax_name ) ); $log->set_title( sprintf( __( 'Term "%1$s" was added to "%2$s" taxonomy', 'tainacan'), $entity->get_name(), $tax_name ) );
} }
} }
$object_type = get_class($entity); $object_type = get_class($entity);
$object_id = $entity->get_id(); $object_id = $entity->get_id();
$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_old_value($diff['old']); $log->set_old_value($diff['old']);
$log->set_new_value($diff['new']); $log->set_new_value($diff['new']);
if ( $log->validate() ) { if ( $log->validate() ) {
$this->insert($log); $this->insert($log);
} }
} }
public function pre_delete_entity( Entities\Entity $entity, $permanent) { public function pre_delete_entity( Entities\Entity $entity, $permanent) {
if ( ! $entity->get_repository()->use_logs ) { if ( ! $entity->get_repository()->use_logs ) {
return; return;
} }
// do not log a log // do not log a log
if ( ( method_exists( $entity, 'get_post_type' ) && $entity->get_post_type() === 'tainacan-log' ) || $entity->get_status() === 'auto-draft' ) { if ( ( method_exists( $entity, 'get_post_type' ) && $entity->get_post_type() === 'tainacan-log' ) || $entity->get_status() === 'auto-draft' ) {
return false; return false;
} }
$this->current_deleting_entity = $entity->_toArray(); $this->current_deleting_entity = $entity->_toArray();
$this->current_action = $permanent ? 'delete' : 'trash'; $this->current_action = $permanent ? 'delete' : 'trash';
} }
public function delete_entity( Entities\Entity $entity, $permanent) { public function delete_entity( Entities\Entity $entity, $permanent) {
if ( ! $entity->get_repository()->use_logs ) { if ( ! $entity->get_repository()->use_logs ) {
return; return;
} }
// do not log a log // do not log a log
if ( ( method_exists( $entity, 'get_post_type' ) && $entity->get_post_type() === 'tainacan-log' ) || $entity->get_status() === 'auto-draft' ) { if ( ( method_exists( $entity, 'get_post_type' ) && $entity->get_post_type() === 'tainacan-log' ) || $entity->get_status() === 'auto-draft' ) {
return false; return false;
} }
$log = new Entities\Log(); $log = new Entities\Log();
$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 ( $entity instanceof Entities\Collection ) { if ( $entity instanceof Entities\Collection ) {
$collection_id = $entity->get_id(); $collection_id = $entity->get_id();
if ($this->current_action == 'delete') { if ($this->current_action == 'delete') {
$log->set_title( sprintf( __( 'Collection "%s" was permanently deleted', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Collection "%s" was permanently deleted', 'tainacan'), $entity->get_name() ) );
} elseif ($this->current_action == 'trash') { } elseif ($this->current_action == 'trash') {
$log->set_title( sprintf( __( 'Collection "%s" was moved to trash', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Collection "%s" was moved to trash', 'tainacan'), $entity->get_name() ) );
} }
} elseif ( $entity instanceof Entities\Item ) { } elseif ( $entity instanceof Entities\Item ) {
$log->set_item_id($entity->get_id()); $log->set_item_id($entity->get_id());
if ($this->current_action == 'delete') { if ($this->current_action == 'delete') {
$log->set_title( sprintf( __( 'Item "%1$s" (ID %2$s) was updated', 'tainacan'), $entity->get_title(), $entity->get_id() ) ); $log->set_title( sprintf( __( 'Item "%1$s" (ID %2$s) was updated', 'tainacan'), $entity->get_title(), $entity->get_id() ) );
} elseif ($this->current_action == 'trash') { } elseif ($this->current_action == 'trash') {
$log->set_title( sprintf( __( 'Item "%1$s" (ID %2$s) was moved to trash', 'tainacan'), $entity->get_title(), $entity->get_id() ) ); $log->set_title( sprintf( __( 'Item "%1$s" (ID %2$s) was moved to trash', 'tainacan'), $entity->get_title(), $entity->get_id() ) );
} }
} elseif ( $entity instanceof Entities\Filter ) { } elseif ( $entity instanceof Entities\Filter ) {
if ( 'default' == $collection_id ) { if ( 'default' == $collection_id ) {
if ($this->current_action == 'delete') { if ($this->current_action == 'delete') {
$log->set_title( sprintf( __( 'Filter "%s" was permanently deleted from the repository', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Filter "%s" was permanently deleted from the repository', 'tainacan'), $entity->get_name() ) );
@ -673,9 +673,9 @@ class Logs extends Repository {
$log->set_title( sprintf( __( 'Filter "%1$s" was moved to trash in Collection "%2$s"', 'tainacan'), $entity->get_name(), $entity->get_collection()->get_name() ) ); $log->set_title( sprintf( __( 'Filter "%1$s" was moved to trash in Collection "%2$s"', 'tainacan'), $entity->get_name(), $entity->get_collection()->get_name() ) );
} }
} }
} elseif ( $entity instanceof Entities\Metadatum ) { } elseif ( $entity instanceof Entities\Metadatum ) {
if ( 'default' == $collection_id ) { if ( 'default' == $collection_id ) {
if ($this->current_action == 'delete') { if ($this->current_action == 'delete') {
$log->set_title( sprintf( __( 'Metadatum "%s" was permanently deleted from the repository', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Metadatum "%s" was permanently deleted from the repository', 'tainacan'), $entity->get_name() ) );
@ -689,69 +689,69 @@ class Logs extends Repository {
$log->set_title( sprintf( __( 'Metadatum "%1$s" was moved to trash in Collection "%2$s"', 'tainacan'), $entity->get_name(), $entity->get_collection()->get_name() ) ); $log->set_title( sprintf( __( 'Metadatum "%1$s" was moved to trash in Collection "%2$s"', 'tainacan'), $entity->get_name(), $entity->get_collection()->get_name() ) );
} }
} }
} elseif ( $entity instanceof Entities\Taxonomy ) { } elseif ( $entity instanceof Entities\Taxonomy ) {
if ($this->current_action == 'delete') { if ($this->current_action == 'delete') {
$log->set_title( sprintf( __( 'Taxonomy "%s" was permanently deleted', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Taxonomy "%s" was permanently deleted', 'tainacan'), $entity->get_name() ) );
} elseif ($this->current_action == 'trash') { } elseif ($this->current_action == 'trash') {
$log->set_title( sprintf( __( 'Taxonomy "%1$s" was moved to trash', 'tainacan'), $entity->get_name() ) ); $log->set_title( sprintf( __( 'Taxonomy "%1$s" was moved to trash', 'tainacan'), $entity->get_name() ) );
} }
} elseif ( $entity instanceof Entities\Term ) { } elseif ( $entity instanceof Entities\Term ) {
$taxonomy = Taxonomies::get_instance()->fetch_by_db_identifier($entity->get_taxonomy()); $taxonomy = Taxonomies::get_instance()->fetch_by_db_identifier($entity->get_taxonomy());
$tax_name = ''; $tax_name = '';
if ($taxonomy instanceof Entities\Taxonomy) { if ($taxonomy instanceof Entities\Taxonomy) {
$tax_name = $taxonomy->get_name(); $tax_name = $taxonomy->get_name();
} }
if ($this->current_action == 'delete') { if ($this->current_action == 'delete') {
$log->set_title( sprintf( __( 'Term "%1$s" was permanently deleted from "%2$s" taxonomy', 'tainacan'), $entity->get_name(), $tax_name ) ); $log->set_title( sprintf( __( 'Term "%1$s" was permanently deleted from "%2$s" taxonomy', 'tainacan'), $entity->get_name(), $tax_name ) );
} elseif ($this->current_action == 'trash') { } elseif ($this->current_action == 'trash') {
$log->set_title( sprintf( __( 'Term "%1$s" was moved to trash in "%2$s" taxonomy', 'tainacan'), $entity->get_name(), $tax_name ) ); $log->set_title( sprintf( __( 'Term "%1$s" was moved to trash in "%2$s" taxonomy', 'tainacan'), $entity->get_name(), $tax_name ) );
} }
} }
$object_type = get_class($entity); $object_type = get_class($entity);
$object_id = $entity->get_id(); $object_id = $entity->get_id();
$diff = $this->current_diff; $diff = $this->current_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($this->current_action); $log->set_action($this->current_action);
if ( $permanent ) { if ( $permanent ) {
$log->set_old_value( $this->current_deleting_entity ); $log->set_old_value( $this->current_deleting_entity );
} else { } else {
$log->set_old_value( ['status' => $entity->get_status()] ); $log->set_old_value( ['status' => $entity->get_status()] );
$log->set_new_value( ['status' => 'trash'] ); $log->set_new_value( ['status' => 'trash'] );
} }
if ( $log->validate() ) { if ( $log->validate() ) {
$this->insert($log); $this->insert($log);
} }
} }
private function insert_item_metadata( Entities\Item_Metadata_Entity $entity ) { private function insert_item_metadata( Entities\Item_Metadata_Entity $entity ) {
if($this->current_diff == false) { if($this->current_diff == false) {
return; return;
} }
$log = new Entities\Log(); $log = new Entities\Log();
$item_id = $entity->get_item()->get_id(); $item_id = $entity->get_item()->get_id();
$collection_id = $entity->get_item()->get_collection_id(); $collection_id = $entity->get_item()->get_collection_id();
$object_type = get_class($entity); $object_type = get_class($entity);
$object_id = $entity->get_metadatum()->get_id(); $object_id = $entity->get_metadatum()->get_id();
$diff = $this->current_diff; $diff = $this->current_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);
@ -759,20 +759,20 @@ class Logs extends Repository {
$log->set_old_value($diff['old']); $log->set_old_value($diff['old']);
$log->set_new_value($diff['new']); $log->set_new_value($diff['new']);
$log->set_action($this->current_action); $log->set_action($this->current_action);
$meta_name = $entity->get_metadatum()->get_name(); $meta_name = $entity->get_metadatum()->get_name();
$item_title = $entity->get_item()->get_title(); $item_title = $entity->get_item()->get_title();
$title = sprintf( __( 'Value for %1$s metadatum was updated in item "%2$s"', 'tainacan' ), $meta_name, $item_title ); $title = sprintf( __( 'Value for %1$s metadatum was updated in item "%2$s"', 'tainacan' ), $meta_name, $item_title );
$log->set_title($title); $log->set_title($title);
if ( $log->validate() ) { if ( $log->validate() ) {
$this->insert($log); $this->insert($log);
} }
} }
public function filter_log_title($title) { public function filter_log_title($title) {
if (defined('TAINACAN_DOING_IMPORT') && true === TAINACAN_DOING_IMPORT) { if (defined('TAINACAN_DOING_IMPORT') && true === TAINACAN_DOING_IMPORT) {
$_title = __('Importer', 'tainacan'); $_title = __('Importer', 'tainacan');
@ -781,4 +781,4 @@ class Logs extends Repository {
return $title; return $title;
} }
} }

View File

@ -114,7 +114,7 @@ class Metadata extends Repository {
'title' => __( 'Unique value', 'tainacan' ), 'title' => __( 'Unique value', 'tainacan' ),
'type' => 'string', 'type' => 'string',
'description' => __( 'Metadata value should be unique accross all items in this collection', 'tainacan' ), 'description' => __( 'Metadata value should be unique accross all items in this collection', 'tainacan' ),
'on_error' => __( 'You can not have two items with the same value for this metadatum', 'tainacan' ), 'on_error' => __( 'You cannot have two items with the same value for this metadatum', 'tainacan' ),
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no 'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
'default' => 'no' 'default' => 'no'
], ],
@ -412,7 +412,7 @@ class Metadata extends Repository {
$original_meta_q = isset( $args['meta_query'] ) ? $args['meta_query'] : []; $original_meta_q = isset( $args['meta_query'] ) ? $args['meta_query'] : [];
/** /**
* Since we introduced roles & capabalities management, we can not rely * Since we introduced roles & capabalities management, we cannot rely
* on WordPress behavior when handling default post status values. * on WordPress behavior when handling default post status values.
* WordPress checks if the current user can read_priva_posts, but this is * WordPress checks if the current user can read_priva_posts, but this is
* not enough for us. We have to handle this ourselves to mimic WordPress behavior * not enough for us. We have to handle this ourselves to mimic WordPress behavior
@ -518,7 +518,7 @@ class Metadata extends Repository {
$original_meta_q = isset( $args['meta_query'] ) ? $args['meta_query'] : []; $original_meta_q = isset( $args['meta_query'] ) ? $args['meta_query'] : [];
/** /**
* Since we introduced roles & capabalities management, we can not rely * Since we introduced roles & capabalities management, we cannot rely
* on WordPress behavior when handling default post status values. * on WordPress behavior when handling default post status values.
* WordPress checks if the current user can read_priva_posts, but this is * WordPress checks if the current user can read_priva_posts, but this is
* not enough for us. We have to handle this ourselves to mimic WordPress behavior * not enough for us. We have to handle this ourselves to mimic WordPress behavior

View File

@ -407,7 +407,7 @@ class Theme_Helper {
* @type int $default_items_per_page Default number of items per page loaded * @type int $default_items_per_page Default number of items per page loaded
* @type bool $show_filters_button_inside_search_control Display the "hide filters" button inside of the search control instead of floating * @type bool $show_filters_button_inside_search_control Display the "hide filters" button inside of the search control instead of floating
* @type bool $start_with_filters_hidden Loads the filters list hidden from start * @type bool $start_with_filters_hidden Loads the filters list hidden from start
* @type bool $filters_as_modal Display the filters as a modal instead of a collapsable region on desktop * @type bool $filters_as_modal Display the filters as a modal instead of a collapsible region on desktop
* @type bool $show_inline_view_mode_options Display view modes as inline icon buttons instead of the dropdown * @type bool $show_inline_view_mode_options Display view modes as inline icon buttons instead of the dropdown
* @type bool $show_fullscreen_with_view_modes Lists fullscreen viewmodes alongside with other view modes istead of separatelly * @type bool $show_fullscreen_with_view_modes Lists fullscreen viewmodes alongside with other view modes istead of separatelly
* @type string $default_view_mode The default view mode * @type string $default_view_mode The default view mode

View File

@ -686,7 +686,7 @@ function tainacan_is_view_mode_enabled($view_mode_slug) {
* @type int $default_items_per_page Default number of items per page loaded * @type int $default_items_per_page Default number of items per page loaded
* @type bool $show_filters_button_inside_search_control Display the "hide filters" button inside of the search control instead of floating * @type bool $show_filters_button_inside_search_control Display the "hide filters" button inside of the search control instead of floating
* @type bool $start_with_filters_hidden Loads the filters list hidden from start * @type bool $start_with_filters_hidden Loads the filters list hidden from start
* @type bool $filters_as_modal Display the filters as a modal instead of a collapsable region on desktop * @type bool $filters_as_modal Display the filters as a modal instead of a collapsible region on desktop
* @type bool $show_inline_view_mode_options Display view modes as inline icon buttons instead of the dropdown * @type bool $show_inline_view_mode_options Display view modes as inline icon buttons instead of the dropdown
* @type bool $show_fullscreen_with_view_modes Lists fullscreen viewmodes alongside with other view modes istead of separatelly * @type bool $show_fullscreen_with_view_modes Lists fullscreen viewmodes alongside with other view modes istead of separatelly
* @type string $default_view_mode The default view mode * @type string $default_view_mode The default view mode

View File

@ -77,11 +77,11 @@
show: 500, show: 500,
hide: 300, hide: 300,
}, },
content: bgProcess.name ? bgProcess.name : $i18n.get('label_unamed_process'), content: bgProcess.name ? bgProcess.name : $i18n.get('label_unnamed_process'),
autoHide: false, classes: ['tainacan-tooltip', 'tooltip', 'repository-tooltip'], autoHide: false, classes: ['tainacan-tooltip', 'tooltip', 'repository-tooltip'],
placement: 'auto-start' placement: 'auto-start'
}"> }">
{{ bgProcess.name ? bgProcess.name : $i18n.get('label_unamed_process') }}</p> {{ bgProcess.name ? bgProcess.name : $i18n.get('label_unnamed_process') }}</p>
</span> </span>
<!-- Progress --> <!-- Progress -->
<span <span

View File

@ -62,7 +62,7 @@ class Core_Description extends Metadata_Type {
return true; return true;
if ( $metadatum->get_multiple() != 'no') { if ( $metadatum->get_multiple() != 'no') {
return ['multiple' => __('Core Metadata can not accept multiple values', 'tainacan')]; return ['multiple' => __('Core Metadata cannot accept multiple values', 'tainacan')];
} }
return true; return true;

View File

@ -75,7 +75,7 @@ class Core_Title extends Metadata_Type {
return true; return true;
if ( $metadatum->get_multiple() != 'no') { if ( $metadatum->get_multiple() != 'no') {
return ['multiple' => __('Core Metadata can not accept multiple values', 'tainacan')]; return ['multiple' => __('Core Metadata cannot accept multiple values', 'tainacan')];
} }
return true; return true;

View File

@ -51,7 +51,7 @@ abstract class Metadata_Type {
* Indicates whether this is a core Metadatum Type or not * Indicates whether this is a core Metadatum Type or not
* *
* Core metadatum types are used by Title, Description and Author metadata. These metadata: * Core metadatum types are used by Title, Description and Author metadata. These metadata:
* * Can only be used once, they belong to the repository and can not be deleted * * Can only be used once, they belong to the repository and cannot be deleted
* * Its values are saved in th wp_post table, and not as post_meta * * Its values are saved in th wp_post table, and not as post_meta
* *
*/ */

View File

@ -51,7 +51,7 @@
class="tainacan-icon tainacan-icon-18px" class="tainacan-icon tainacan-icon-18px"
:class="{ 'tainacan-icon-arrowdown': processesCollapses[index], 'tainacan-icon-arrowright': !processesCollapses[index] }" /> :class="{ 'tainacan-icon-arrowdown': processesCollapses[index], 'tainacan-icon-arrowright': !processesCollapses[index] }" />
</span> </span>
<p>{{ bgProcess.name ? bgProcess.name : $i18n.get('label_unamed_process') }}</p> <p>{{ bgProcess.name ? bgProcess.name : $i18n.get('label_unnamed_process') }}</p>
</div> </div>
<!-- <span <!-- <span
v-if="bgProcess.done <= 0 && bgProcess.status == 'closed'" v-if="bgProcess.done <= 0 && bgProcess.status == 'closed'"

View File

@ -18,7 +18,7 @@
} }
.button.is-primary, .button.is-secondary, .button.is-success { .button.is-primary, .button.is-secondary, .button.is-success {
.icon { .icon {
color: var(--taincan-background-color); color: var(--tainacan-background-color);
} }
} }
.dropdown.is-disabled { .dropdown.is-disabled {
@ -34,7 +34,7 @@
border: none; border: none;
z-index: 999991; z-index: 999991;
background-color: var(--tainacan-input-background-color); background-color: var(--tainacan-input-background-color);
.dropdown-content { .dropdown-content {
padding: 0px 0px 1px 0px; padding: 0px 0px 1px 0px;
border-radius: 0px !important; border-radius: 0px !important;
@ -67,7 +67,7 @@
.media { .media {
display: flex; display: flex;
align-items: center; align-items: center;
.media-left { .media-left {
margin-right: 0.5em; margin-right: 0.5em;
display: flex; display: flex;
@ -85,7 +85,7 @@
} }
} }
} }
} }
} }
&.is-mobile-modal { &.is-mobile-modal {
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
@ -97,7 +97,7 @@
.dropdown-item { .dropdown-item {
padding: 0.75em !important; padding: 0.75em !important;
} }
} }
} }
} }
} }
@ -137,8 +137,8 @@
&:focus, &:active { &:focus, &:active {
border: 1px solid transparent !important; border: 1px solid transparent !important;
} }
.input { .input {
margin-bottom: 0px !important; margin-bottom: 0px !important;
text-overflow: ellipsis; text-overflow: ellipsis;
background-color: var(--tainacan-input-background-color); background-color: var(--tainacan-input-background-color);
} }
@ -160,11 +160,11 @@
&::after { &::after {
height: 47% !important; height: 47% !important;
width: 1px !important; width: 1px !important;
} }
&::before { &::before {
width: 47% !important; width: 47% !important;
height: 1px !important; height: 1px !important;
} }
&:hover, &:focus { &:hover, &:focus {
background-color: var(--tainacan-background-color); background-color: var(--tainacan-background-color);
color: var(--tainacan-label-color); color: var(--tainacan-label-color);
@ -197,11 +197,11 @@
&::after { &::after {
height: 30% !important; height: 30% !important;
width: 1px !important; width: 1px !important;
} }
&::before { &::before {
width: 30% !important; width: 30% !important;
height: 1px !important; height: 1px !important;
} }
&:hover, &:focus { &:hover, &:focus {
background-color: var(--tainacan-background-color); background-color: var(--tainacan-background-color);
color: var(--tainacan-label-color); color: var(--tainacan-label-color);
@ -215,7 +215,7 @@
.datepicker-content { .datepicker-content {
height: auto; height: auto;
input { input {
height: auto; height: auto;
} }
@ -245,14 +245,14 @@
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
.field.has-addons { .field.has-addons {
font-size: 1.125em; font-size: 1.125em;
} }
} }
} }
.dropdown-menu { .dropdown-menu {
background: transparent; background: transparent;
border: none; border: none;
.dropdown-item { .dropdown-item {
background-color: var(--tainacan-background-color) !important; background-color: var(--tainacan-background-color) !important;
} }
@ -301,7 +301,7 @@
padding: 0; padding: 0;
margin: 0px; margin: 0px;
width: 100%; width: 100%;
.datepicker-cell { .datepicker-cell {
border: none !important; border: none !important;
padding: 0.5em 0.75em; padding: 0.5em 0.75em;
@ -343,11 +343,11 @@
margin-bottom: 0.5em; margin-bottom: 0.5em;
padding-top: 0.15em; padding-top: 0.15em;
padding-bottom: 0.5em; padding-bottom: 0.5em;
.pagination { .pagination {
font-size: 1.1em; font-size: 1.1em;
flex-wrap: wrap; flex-wrap: wrap;
.pagination-list { .pagination-list {
margin-bottom: 0.5em; margin-bottom: 0.5em;
@ -355,8 +355,8 @@
width: 100% !important; width: 100% !important;
.control { .control {
select { select {
border: none !important; border: none !important;
min-height: 26px; min-height: 26px;
} }
} }
@ -381,7 +381,7 @@
.pagination-next { .pagination-next {
margin: 0; margin: 0;
height: 1.5em; height: 1.5em;
padding: 0; padding: 0;
min-height: 24px; min-height: 24px;
margin-bottom: 0.35em; margin-bottom: 0.35em;
@ -401,7 +401,7 @@
.datepicker-table { .datepicker-table {
margin-bottom: 0px; margin-bottom: 0px;
} }
.select { .select {
select { select {
display: unset; display: unset;
@ -411,10 +411,10 @@
} }
} }
.dropdown-content { .dropdown-content {
border-radius: 2px !important; border-radius: 2px !important;
padding: 0px; padding: 0px;
max-height: inherit !important; max-height: inherit !important;
} }
} }
} }

View File

@ -1,6 +1,6 @@
const { __ } = wp.i18n; const { __ } = wp.i18n;
const { const {
Button, Button,
TextControl, TextControl,
TextareaControl, TextareaControl,
@ -91,7 +91,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
function openCollectionModal() { function openCollectionModal() {
isCollectionModalOpen = true; isCollectionModalOpen = true;
setAttributes( { setAttributes( {
isCollectionModalOpen: isCollectionModalOpen isCollectionModalOpen: isCollectionModalOpen
} ); } );
} }
@ -116,7 +116,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
isLoadingCollectionMetadata = false; isLoadingCollectionMetadata = false;
setAttributes({ setAttributes({
isLoadingCollectionMetadata : isLoadingCollectionMetadata, isLoadingCollectionMetadata : isLoadingCollectionMetadata,
collectionMetadata: collectionMetadata, collectionMetadata: collectionMetadata,
enabledMetadata: enabledMetadata enabledMetadata: enabledMetadata
@ -124,7 +124,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
}); });
} }
return collectionId == 'preview' ? return collectionId == 'preview' ?
<div className={className}> <div className={className}>
<img <img
width="100%" width="100%"
@ -133,13 +133,13 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
: ( : (
<div className={className}> <div className={className}>
{ collectionId ? { collectionId ?
<BlockControls> <BlockControls>
{ {
TainacanBlocksCompatToolbar({ TainacanBlocksCompatToolbar({
label: __('Change target collection', 'tainacan'), label: __('Change target collection', 'tainacan'),
icon: <svg icon: <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="-2 -2 12 12" viewBox="-2 -2 12 12"
height="24px" height="24px"
width="24px"> width="24px">
@ -183,10 +183,10 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
showItemLinkButton = isChecked; showItemLinkButton = isChecked;
setAttributes({ showItemLinkButton: isChecked }); setAttributes({ showItemLinkButton: isChecked });
} }
} }
/> />
{ showItemLinkButton ? { showItemLinkButton ?
<TextControl <TextControl
label={ __('Label for the item button', 'tainacan') } label={ __('Label for the item button', 'tainacan') }
value={ itemLinkButtonLabel } value={ itemLinkButtonLabel }
@ -240,18 +240,18 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
<PanelBody <PanelBody
title={__('Metadata Input', 'tainacan')} title={__('Metadata Input', 'tainacan')}
initialOpen={ true } > initialOpen={ true } >
{ !isLoadingCollectionMetadata ? { !isLoadingCollectionMetadata ?
<BaseControl <BaseControl
id="metadata-checkbox-list" id="metadata-checkbox-list"
label={ __('Metadata input shown on the list', 'tainacan') } label={ __('Metadata input shown on the list', 'tainacan') }
help={ __('Uncheck the metadata that you do not want to be shown on the form', 'tainacan') } help={ __('Uncheck the metadata that you do not want to be shown on the form', 'tainacan') }
> >
<ul id="metadata-checkbox-list"> <ul id="metadata-checkbox-list">
{ enabledMetadata.length ? { enabledMetadata.length ?
enabledMetadata.map((isMetadatumEnabled, index) => { enabledMetadata.map((isMetadatumEnabled, index) => {
return ( return (
<li> <li>
<CheckboxControl <CheckboxControl
label={ collectionMetadata[index].name + (collectionMetadata[index].required == 'yes' ? ' *' : '') } label={ collectionMetadata[index].name + (collectionMetadata[index].required == 'yes' ? ' *' : '') }
disabled={ collectionMetadata[index].required == 'yes' } disabled={ collectionMetadata[index].required == 'yes' }
checked={ isMetadatumEnabled ? true : false } checked={ isMetadatumEnabled ? true : false }
@ -262,9 +262,9 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
) )
}) })
: :
<p>{ __('No public metadata was found in this collection', 'tainacan') }</p> <p>{ __('No public metadata was found in this collection', 'tainacan') }</p>
} }
</ul> </ul>
</BaseControl> </BaseControl>
: <Spinner /> } : <Spinner /> }
</PanelBody> </PanelBody>
@ -280,7 +280,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
hideFileModalButton = isChecked; hideFileModalButton = isChecked;
setAttributes({ hideFileModalButton: isChecked }); setAttributes({ hideFileModalButton: isChecked });
} }
} }
/> />
<ToggleControl <ToggleControl
@ -290,7 +290,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
hideTextModalButton = isChecked; hideTextModalButton = isChecked;
setAttributes({ hideTextModalButton: isChecked }); setAttributes({ hideTextModalButton: isChecked });
} }
} }
/> />
<ToggleControl <ToggleControl
@ -300,7 +300,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
hideLinkModalButton = isChecked; hideLinkModalButton = isChecked;
setAttributes({ hideLinkModalButton: isChecked }); setAttributes({ hideLinkModalButton: isChecked });
} }
} }
/> />
<ToggleControl <ToggleControl
@ -310,7 +310,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
hideThumbnailSection = isChecked; hideThumbnailSection = isChecked;
setAttributes({ hideThumbnailSection: isChecked }); setAttributes({ hideThumbnailSection: isChecked });
} }
} }
/> />
<ToggleControl <ToggleControl
@ -320,7 +320,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
hideAttachmentsSection = isChecked; hideAttachmentsSection = isChecked;
setAttributes({ hideAttachmentsSection: isChecked }); setAttributes({ hideAttachmentsSection: isChecked });
} }
} }
/> />
<ToggleControl <ToggleControl
@ -330,17 +330,17 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
showAllowCommentsSection = isChecked; showAllowCommentsSection = isChecked;
setAttributes({ showAllowCommentsSection: isChecked }); setAttributes({ showAllowCommentsSection: isChecked });
} }
} }
/> />
<ToggleControl <ToggleControl
label={__('Hide the metadata collapses', 'tainacan')} label={__('Hide the metadata collapses', 'tainacan')}
help={ hideCollapses ? __('Do not show collapsable controls for each metadatum.', 'tainacan') : __('Toggle to show collapsable controls on each metadatum.', 'tainacan')} help={ hideCollapses ? __('Do not show collapsible controls for each metadatum.', 'tainacan') : __('Toggle to show collapsible controls on each metadatum.', 'tainacan')}
checked={ hideCollapses } checked={ hideCollapses }
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
hideCollapses = isChecked; hideCollapses = isChecked;
setAttributes({ hideCollapses: isChecked }); setAttributes({ hideCollapses: isChecked });
} }
} }
/> />
<ToggleControl <ToggleControl
@ -350,7 +350,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
hideHelpButtons = isChecked; hideHelpButtons = isChecked;
setAttributes({ hideHelpButtons: isChecked }); setAttributes({ hideHelpButtons: isChecked });
} }
} }
/> />
@ -361,7 +361,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
helpInfoBellowLabel = isChecked; helpInfoBellowLabel = isChecked;
setAttributes({ helpInfoBellowLabel: isChecked }); setAttributes({ helpInfoBellowLabel: isChecked });
} }
} }
/> />
<ToggleControl <ToggleControl
@ -371,7 +371,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
hideMetadataTypes = isChecked; hideMetadataTypes = isChecked;
setAttributes({ hideMetadataTypes: isChecked }); setAttributes({ hideMetadataTypes: isChecked });
} }
} }
/> />
</PanelBody> </PanelBody>
@ -385,7 +385,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onChange={ ( isChecked ) => { onChange={ ( isChecked ) => {
showTermsAgreementCheckbox = isChecked; showTermsAgreementCheckbox = isChecked;
setAttributes({ showTermsAgreementCheckbox: isChecked }); setAttributes({ showTermsAgreementCheckbox: isChecked });
} }
} }
/> />
</PanelBody> </PanelBody>
@ -525,8 +525,8 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
alt="Tainacan Logo"/> alt="Tainacan Logo"/>
)}> )}>
<p> <p>
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 10 10" viewBox="0 0 10 10"
height="24px" height="24px"
width="24px"> width="24px">
@ -542,15 +542,15 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
onClick={ () => openCollectionModal() }> onClick={ () => openCollectionModal() }>
{ __('Select a target Collection', 'tainacan')} { __('Select a target Collection', 'tainacan')}
</Button> </Button>
</Placeholder> </Placeholder>
) : ( ) : (
<div style={{ fontSize: (baseFontSize - 2) + 'px' }}> <div style={{ fontSize: (baseFontSize - 2) + 'px' }}>
<div class="preview-warning"> <div class="preview-warning">
{ __('Warning: this is just a demonstration. To see the submission form, either preview or publish your post.', 'tainacan') } { __('Warning: this is just a demonstration. To see the submission form, either preview or publish your post.', 'tainacan') }
</div> </div>
<div <div
style={{ style={{
'--tainacan-background-color': 'rgba(' + backgroundColor.r + ',' + backgroundColor.g + ',' + backgroundColor.b + ',' + backgroundColor.a + ')', '--tainacan-background-color': 'rgba(' + backgroundColor.r + ',' + backgroundColor.g + ',' + backgroundColor.b + ',' + backgroundColor.a + ')',
'--tainacan-input-color': inputColor, '--tainacan-input-color': inputColor,
@ -562,13 +562,13 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
'--tainacan-secondary': secondaryColor '--tainacan-secondary': secondaryColor
}} }}
class="item-submission-form-placeholder"> class="item-submission-form-placeholder">
<div> <div>
{ {
(!hideFileModalButton || !hideTextModalButton || !hideLinkModalButton) ? (!hideFileModalButton || !hideTextModalButton || !hideLinkModalButton) ?
( (
<div> <div>
{ documentSectionLabel ? { documentSectionLabel ?
<span> <span>
<span style={{ display: 'flex', alignItems: 'baseline', marginBottom: '5px' }}><span class="fake-text section-label"></span>{ !hideHelpButtons && !helpInfoBellowLabel ? <span class="fake-text fake-help-button"></span> : null }</span> <span style={{ display: 'flex', alignItems: 'baseline', marginBottom: '5px' }}><span class="fake-text section-label"></span>{ !hideHelpButtons && !helpInfoBellowLabel ? <span class="fake-text fake-help-button"></span> : null }</span>
{ (!hideHelpButtons && helpInfoBellowLabel) ? <div><span class="fake-text fake-text-help-description"></span></div> : null } { (!hideHelpButtons && helpInfoBellowLabel) ? <div><span class="fake-text fake-text-help-description"></span></div> : null }
@ -590,16 +590,16 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
(hideFileModalButton && hideTextModalButton && !hideLinkModalButton) ? (hideFileModalButton && hideTextModalButton && !hideLinkModalButton) ?
<span class="fake-input" style={{ width: '100%' }}></span> <span class="fake-input" style={{ width: '100%' }}></span>
: null : null
) )
) )
)} )}
</div> </div>
) : null ) : null
} }
{ !hideThumbnailSection ? { !hideThumbnailSection ?
( (
<div style={{ display: 'flex', flexDirection: 'column' }}> <div style={{ display: 'flex', flexDirection: 'column' }}>
{ !thumbnailSectionLabel ? { !thumbnailSectionLabel ?
<span> <span>
<span style={{ display: 'flex', alignItems: 'baseline' }}><span class="fake-text section-label"></span>{ !hideHelpButtons && !helpInfoBellowLabel ? <span class="fake-text fake-help-button"></span> : null }</span> <span style={{ display: 'flex', alignItems: 'baseline' }}><span class="fake-text section-label"></span>{ !hideHelpButtons && !helpInfoBellowLabel ? <span class="fake-text fake-help-button"></span> : null }</span>
{ (!hideHelpButtons && helpInfoBellowLabel) ? <div><span class="fake-text fake-text-help-description"></span></div> : null } { (!hideHelpButtons && helpInfoBellowLabel) ? <div><span class="fake-text fake-text-help-description"></span></div> : null }
@ -609,11 +609,11 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
</div> </div>
) : null ) : null
} }
{ !hideAttachmentsSection ? { !hideAttachmentsSection ?
( (
<div> <div>
{ !attachmentsSectionLabel ? { !attachmentsSectionLabel ?
<span <span
style={{ position: 'relative' }} style={{ position: 'relative' }}
class="fake-text section-label"> class="fake-text section-label">
<div class="fake-tooltip"><div class="fake-link"></div></div> <div class="fake-tooltip"><div class="fake-link"></div></div>
@ -623,10 +623,10 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
<div class="fake-image-uploader"></div> <div class="fake-image-uploader"></div>
</div> </div>
</div> </div>
) : null ) : null
} }
{ {
showAllowCommentsSection ? showAllowCommentsSection ?
( (
<div> <div>
<span style={{ display: 'flex', alignItems: 'baseline' }}><span class="fake-text section-label"></span>{ !hideHelpButtons && !helpInfoBellowLabel ? <span class="fake-text fake-help-button"></span> : null }</span> <span style={{ display: 'flex', alignItems: 'baseline' }}><span class="fake-text section-label"></span>{ !hideHelpButtons && !helpInfoBellowLabel ? <span class="fake-text fake-help-button"></span> : null }</span>
@ -641,9 +641,9 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
:null } :null }
{ !hideCollapses ? <div class="fake-link"></div> : null } { !hideCollapses ? <div class="fake-link"></div> : null }
<div class="metadata-section"> <div class="metadata-section">
{ enabledMetadata.length ? { enabledMetadata.length ?
enabledMetadata.map( (isEnabled) => { enabledMetadata.map( (isEnabled) => {
return isEnabled ? return isEnabled ?
<div class={ 'fake-metadata' + (!hideCollapses ? ' has-collapse' : '') }> <div class={ 'fake-metadata' + (!hideCollapses ? ' has-collapse' : '') }>
{ !hideCollapses ? <span class="fake-collapse-arrow"></span> : null } { !hideCollapses ? <span class="fake-collapse-arrow"></span> : null }
<span style={{ lineHeight: '0em' }}> <span style={{ lineHeight: '0em' }}>
@ -653,7 +653,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
<span class="fake-input"></span> <span class="fake-input"></span>
</div> </div>
: null : null
}) : }) :
Array(12).fill().map( () => { Array(12).fill().map( () => {
return <div class={ 'fake-metadata' + (!hideCollapses ? ' has-collapse' : '') }> return <div class={ 'fake-metadata' + (!hideCollapses ? ' has-collapse' : '') }>
{ !hideCollapses ? <span class="fake-collapse-arrow"></span> : null } { !hideCollapses ? <span class="fake-collapse-arrow"></span> : null }
@ -664,8 +664,8 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
} }
</div> </div>
</div> </div>
{ showTermsAgreementCheckbox ? { showTermsAgreementCheckbox ?
<div class="fake-checkbox-confirmation"> <div class="fake-checkbox-confirmation">
<span class="fake-checkbox"></span> <span class="fake-checkbox"></span>
<RichText <RichText
@ -673,12 +673,12 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
tagName="p" tagName="p"
value={ termsAgreementMessage } value={ termsAgreementMessage }
onChange={ ( inputContent ) => setAttributes( { termsAgreementMessage: inputContent } ) } onChange={ ( inputContent ) => setAttributes( { termsAgreementMessage: inputContent } ) }
placeholder={ __( 'Type here a message requiring the user to agree with certain conditions.' ) } placeholder={ __( 'Type a message requiring the user to agree with certain conditions.' ) }
/> />
</div> </div>
: null : null
} }
<div class="form-footer"> <div class="form-footer">
<span class="fake-button outline"><span class="fake-text"></span></span> <span class="fake-button outline"><span class="fake-text"></span></span>
<span class="fake-text"></span> <span class="fake-text"></span>
@ -686,11 +686,11 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
</div> </div>
</div> </div>
</div> </div>
) )
} }
{ isCollectionModalOpen ? { isCollectionModalOpen ?
<CollectionModal <CollectionModal
filterOptionsBy={ { allows_submission: 'yes' } } filterOptionsBy={ { allows_submission: 'yes' } }
existingCollectionId={ collectionId } existingCollectionId={ collectionId }
@ -702,10 +702,10 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
}); });
loadCollectionMetadata(collectionId); loadCollectionMetadata(collectionId);
}} }}
onCancelSelection={ () => setAttributes({ isCollectionModalOpen: false }) }/> onCancelSelection={ () => setAttributes({ isCollectionModalOpen: false }) }/>
: null : null
} }
</div> </div>
); );
}; };

View File

@ -280,9 +280,9 @@ return apply_filters( 'tainacan-i18n', [
'label_url' => __( 'URL', 'tainacan' ), 'label_url' => __( 'URL', 'tainacan' ),
'label_select_file' => __( 'Select file', 'tainacan' ), 'label_select_file' => __( 'Select file', 'tainacan' ),
'label_selected_file' => __( 'Selected file', 'tainacan' ), 'label_selected_file' => __( 'Selected file', 'tainacan' ),
/* translators: Label for collapsable, accordeon-like elements */ /* translators: Label for collapsible, accordeon-like elements */
'label_expand_all' => __( 'Expand all', 'tainacan' ), 'label_expand_all' => __( 'Expand all', 'tainacan' ),
/* translators: Label for collapsable, accordeon-like elements */ /* translators: Label for collapsible, accordeon-like elements */
'label_collapse_all' => __( 'Collapse all', 'tainacan' ), 'label_collapse_all' => __( 'Collapse all', 'tainacan' ),
'label_view_term' => __( 'View Term', 'tainacan' ), 'label_view_term' => __( 'View Term', 'tainacan' ),
/* translators: 'Published' here refers to the sum of public and private items, not including draft or trashed ones. The are visible to those with permission */ /* translators: 'Published' here refers to the sum of public and private items, not including draft or trashed ones. The are visible to those with permission */
@ -386,7 +386,7 @@ return apply_filters( 'tainacan-i18n', [
'label_delete_process' => __( 'Delete process', 'tainacan' ), 'label_delete_process' => __( 'Delete process', 'tainacan' ),
'label_process_failed' => __( 'Process failed', 'tainacan' ), 'label_process_failed' => __( 'Process failed', 'tainacan' ),
'label_max_options_to_show' => __( 'Max options to show', 'tainacan' ), 'label_max_options_to_show' => __( 'Max options to show', 'tainacan' ),
'label_unamed_process' => __( 'Unnamed process', 'tainacan' ), 'label_unnamed_process' => __( 'Unnamed process', 'tainacan' ),
'loading_processes' => __( 'Loading processes', 'tainacan' ), 'loading_processes' => __( 'Loading processes', 'tainacan' ),
'label_semantic_uri' => __( 'Semantic Uri', 'tainacan' ), 'label_semantic_uri' => __( 'Semantic Uri', 'tainacan' ),
'label_view_collection_on_website' => __( 'View collection on website', 'tainacan' ), 'label_view_collection_on_website' => __( 'View collection on website', 'tainacan' ),
@ -757,7 +757,7 @@ return apply_filters( 'tainacan-i18n', [
'info_no_capabilities_found' => __( 'No capabilities found.', 'tainacan' ), 'info_no_capabilities_found' => __( 'No capabilities found.', 'tainacan' ),
'info_no_role_associated_capability' => __( 'No role associated to this capability', 'tainacan' ), 'info_no_role_associated_capability' => __( 'No role associated to this capability', 'tainacan' ),
'info_associated_roles' => __( 'These are the roles that have this capability set. You may add or remove the capability to customize the role.', 'tainacan' ), 'info_associated_roles' => __( 'These are the roles that have this capability set. You may add or remove the capability to customize the role.', 'tainacan' ),
'info_inherited_roles' => __( 'These are the roles that have greater capabilities, which inherit this one. You can not edit this as it will not have precedence over the greater capability.', 'tainacan' ), 'info_inherited_roles' => __( 'These are the roles that have greater capabilities, which inherit this one. You cannot edit this as it will not have precedence over the greater capability.', 'tainacan' ),
'info_showing_terms' => __( 'Showing terms ', 'tainacan' ), 'info_showing_terms' => __( 'Showing terms ', 'tainacan' ),
'info_warning_remove_from_trash_first' => __( 'Remove this item from trash first' ), 'info_warning_remove_from_trash_first' => __( 'Remove this item from trash first' ),
/* translators: This is displayed before sentences like "Showing items 2 to 8 of 12 */ /* translators: This is displayed before sentences like "Showing items 2 to 8 of 12 */

View File

@ -164,8 +164,8 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
$core_title->set_multiple('yes'); $core_title->set_multiple('yes');
$core_description->set_multiple('yes'); $core_description->set_multiple('yes');
$this->assertFalse($core_title->validate(), 'Core metadata should not validate because it can not allow it to have multiple'); $this->assertFalse($core_title->validate(), 'Core metadata should not validate because it cannot allow it to have multiple');
$this->assertFalse($core_description->validate(), 'Core metadata should not validate because it can not allow it to have multiple'); $this->assertFalse($core_description->validate(), 'Core metadata should not validate because it cannot allow it to have multiple');
} }