aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/entities.php7
-rw-r--r--engine/lib/metadata.php38
2 files changed, 43 insertions, 2 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index e344968a9..92b658ef2 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -117,8 +117,11 @@
{
$md = get_metadata_byname($this->getGUID(), $name);
- if ($md)
- return $md->value;
+ if ($md && !is_array($md)) {
+ return $md->value;
+ } else if ($md && is_array($md)) {
+ return metadata_array_to_values($md);
+ }
return null;
}
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 92b683789..37a89f09e 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -375,6 +375,44 @@
return $returnvalue;
}
+
+ /**
+ * Takes in a comma-separated string and returns an array of tags which have been trimmed and set to lower case
+ *
+ * @param string $string Comma-separated tag string
+ * @return array|false An array of strings, or false on failure
+ */
+ function string_to_tag_array($string) {
+
+ if (is_string($string)) {
+ $ar = explode(",",$string);
+ array_walk($ar,'trim');
+ array_walk($ar,'strtolower');
+ return $ar;
+ }
+ return false;
+
+ }
+
+ /**
+ * Takes a metadata array (which has all kinds of properties) and turns it into a simple array of strings
+ *
+ * @param array $array Metadata array
+ * @return array Array of strings
+ */
+ function metadata_array_to_values($array) {
+
+ $valuearray = array();
+
+ if (is_array($array)) {
+ foreach($array as $element) {
+ $valuearray[] = $element->value;
+ }
+ }
+
+ return $valuearray;
+
+ }
/** Register the hook */
register_plugin_hook("export", "all", "export_metadata_plugin_hook", 2);