iniciando atribuir valores nos metadados de item

This commit is contained in:
Eduardo humberto 2017-11-10 17:03:09 -02:00
parent fb7732b06c
commit 0230de0935
4 changed files with 50 additions and 5 deletions

View File

@ -65,6 +65,16 @@ class TainacanItem extends Entity {
return null;
}
function get_metadata(){
global $TainacanItems;
if(isset($this->metadata)) {
return $this->metadata;
}
return $TainacanItems->get_metadata( $this );
}
// Setters
//
@ -92,6 +102,10 @@ class TainacanItem extends Entity {
$this->set_collection_id($collection->get_id());
}
function set_metadata( $metadata ){
}
}

View File

@ -130,9 +130,9 @@ class TainacanCollections {
return new TainacanCollection($id);
}
function get_taxonomies(){
$array = get_taxonomies();
return ( is_array( $array ) ) ? $array : [];
function get_metadata( $collection ){
global $Tainacan_Metadatas;
return $Tainacan_Metadatas->get_collection_metadata( $collection );
}
}

View File

@ -21,10 +21,10 @@ class TainacanItems {
function register_post_types() {
global $TainacanCollections;
global $TainacanCollections, $Tainacan_Taxonomies;
$collections = $TainacanCollections->get_collections();
$taxonomies = $TainacanCollections->get_taxonomies();
$taxonomies = $Tainacan_Taxonomies->get_taxonomies();
$labels = array(
'name' => 'Item',
@ -123,6 +123,32 @@ class TainacanItems {
function get_item_by_id($id) {
return new TainacanItem($id);
}
function get_metadata( TainacanItem $item ){
global $TainacanCollections;
$values = [];
$collection_metadata = $TainacanCollections->get_metadata( $item->get_collection() );
foreach ($collection_metadata as $metadata) {
$values[] = [
'metadata_id' => $metadata->get_id(),
'value' => get_post_meta( $item->get_id(), $metadata->get_id()),
];
}
return $values;
}
function set_metadata( TainacanItem $item, $values){
global $TainacanCollections;
$collection_metadata = $TainacanCollections->get_metadata( $item->get_collection() );
foreach ($collection_metadata as $metadata) {
}
}
}

View File

@ -63,6 +63,11 @@ class Tainacan_Taxonomies {
register_post_type(self::POST_TYPE, $args);
}
function get_taxonomies(){
$array = get_taxonomies();
return ( is_array( $array ) ) ? $array : [];
}
function get_taxonomy_db_identifier($id) {
$meta = get_post_meta($id, self::DB_IDENTIFIER_META, true);