Fix importing tags #233
This commit is contained in:
parent
aba95ef923
commit
a621d65f20
|
@ -346,7 +346,10 @@ class Flickr_Importer extends Importer {
|
|||
|
||||
if ( isset( $item->tags ) && isset( $item->tags->tag ) && is_array( $item->tags->tag ) ) {
|
||||
foreach ( $item->tags->tag as $tag ) {
|
||||
$tags[] = $tag->raw;
|
||||
if (isset($tag->raw)) {
|
||||
$tags[] = $tag->raw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,7 +406,7 @@ class Flickr_Importer extends Importer {
|
|||
}
|
||||
|
||||
$metadatum = new \Tainacan\Entities\Metadatum($metadatum_id);
|
||||
$processedItem[$raw_metadatum] = ($metadatum->is_multiple()) ? [$value] : $value;
|
||||
$processedItem[$raw_metadatum] = ( $metadatum->is_multiple() && !is_array($value) ) ? [$value] : $value;
|
||||
}
|
||||
|
||||
$this->add_transient( 'insertedId', $item->id );
|
||||
|
@ -484,7 +487,11 @@ class Flickr_Importer extends Importer {
|
|||
foreach( $collection['mapping'] as $metadatum_id => $header ){
|
||||
|
||||
if( !is_numeric($metadatum_id) ) {
|
||||
$metadatum = $this->create_new_metadata( $header, $collection['id']);
|
||||
$create_string = $header;
|
||||
if ($header == 'tags') {
|
||||
$create_string = 'Tags|taxonomy|multiple';
|
||||
}
|
||||
$metadatum = $this->create_new_metadata( $create_string, $collection['id']);
|
||||
|
||||
if( is_object($metadatum) ){
|
||||
unset($collection['mapping'][$metadatum_id]);
|
||||
|
|
|
@ -942,7 +942,7 @@ abstract class Importer {
|
|||
$newMetadatum->set_collection_id( (isset($collection_id)) ? $collection_id : 'default');
|
||||
$newMetadatum->set_status('publish');
|
||||
|
||||
if( strcmp($type, "Taxonomy") === 0 ){
|
||||
if( strcmp(strtolower($type), "taxonomy") === 0 ){
|
||||
$taxonomy = new Entities\Taxonomy();
|
||||
$taxonomy->set_name($name);
|
||||
$taxonomy->set_status('publish');
|
||||
|
@ -952,7 +952,7 @@ abstract class Importer {
|
|||
$inserted_tax = $taxonomy_repo->insert( $taxonomy );
|
||||
$newMetadatum->set_metadata_type_options([
|
||||
'taxonomy_id' => $inserted_tax->get_id(),
|
||||
'allow_new_terms' => true,
|
||||
'allow_new_terms' => 'yes',
|
||||
'input_type' => 'tainacan-taxonomy-checkbox'
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue