function get_label() { $mc = net_nemein_tag_tag_dba::new_collector('id', $this->tag); $tag_guids = $mc->get_values('tag'); foreach ($tag_guids as $guid) { return net_nemein_tag_handler::tag_link2tagname($guid, $this->value, $this->context); } return $this->guid; }
/** * Gets list of tags linked to the object arranged by context * * @return array list of contexts containing arrays of tags and urls, tag is key, url is value */ public static function get_object_tags_by_contexts(&$object) { $tags = array(); $link_mc = net_nemein_tag_link::new_collector('fromGuid', $object->guid); $link_mc->set_key_property('tag'); $link_mc->add_value_property('value'); $link_mc->add_value_property('context'); $link_mc->add_order('context'); $link_mc->add_order('tag.tag'); $link_mc->execute(); $links = $link_mc->list_keys(); if (!$links) { return $tags; } $mc = net_nemein_tag_tag_dba::new_collector('metadata.deleted', false); $mc->add_value_property('tag'); $mc->add_value_property('url'); $mc->add_value_property('id'); $mc->add_constraint('id', 'IN', array_keys($links)); $mc->execute(); $tag_guids = $mc->list_keys(); if (!$tag_guids) { return $tags; } foreach ($tag_guids as $tag_guid => $value) { $context = $link_mc->get_subkey($tag_guid, 'context'); if (empty($context)) { $context = 0; } if (!array_key_exists($context, $tags)) { $tags[$context] = array(); } $tag = $mc->get_subkey($tag_guid, 'tag'); $url = $mc->get_subkey($tag_guid, 'url'); $value = $link_mc->get_subkey($mc->get_subkey($tag_guid, 'id'), 'value'); $tagname = self::tag_link2tagname($tag, $value, $context); $tags[$context][$tagname] = $url; } return $tags; }