diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-12 22:23:38 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-12 22:23:38 +0000 |
commit | 9fbed88ef70966dd6075b40bd3a8ed4f609423e8 (patch) | |
tree | 95bfbeebc86761b0560bdd99065dde6813f6ced7 /engine/lib/entities.php | |
parent | 2d889a3cc9b92fdb1c000236e8953f9d16fe8840 (diff) | |
download | elgg-9fbed88ef70966dd6075b40bd3a8ed4f609423e8.tar.gz elgg-9fbed88ef70966dd6075b40bd3a8ed4f609423e8.tar.bz2 |
Closes #1506: Added elgg_register_tag_metadata_name(), elgg_get_registered_tag_metadata_names(), and ElggEntity::getTags(). Search on tags updated to use registered tag names instead of hard-coded 'tags' metadata name.
git-svn-id: http://code.elgg.org/elgg/trunk@3936 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r-- | engine/lib/entities.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 930772943..eb98d5949 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1121,6 +1121,32 @@ abstract class ElggEntity implements return $this->owner_guid; } + /** + * Returns tags for this entity using registered tag metadata names. + * + * @return array + */ + public function getTags() { + global $CONFIG; + + $valid_tags = elgg_get_registered_tag_metadata_names(); + $entity_tags = array(); + + foreach ($valid_tags as $tag_name) { + if ($tags = $this->$tag_name) { + // if a single tag, metadata returns a string. + // if multiple tags, metadata returns an array. + if (is_array($tags)) { + $entity_tags = array_merge($entity_tags, $tags); + } else { + $entity_tags[] = $tags; + } + } + } + + return $entity_tags; + } + // ITERATOR INTERFACE ////////////////////////////////////////////////////////////// /* * This lets an entity's attributes be displayed using foreach as a normal array. |