aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/metadata.php
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-01 17:15:12 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-01 17:15:12 +0000
commit4e08e618308d7dedfd3983d015950c81e7403e29 (patch)
treef4ae2137a46b23be2c712ee582c251ec3bd0f1f5 /engine/lib/metadata.php
parent205dcbf14c473fe64f89e5696cfbafea8fa5ab15 (diff)
downloadelgg-4e08e618308d7dedfd3983d015950c81e7403e29.tar.gz
elgg-4e08e618308d7dedfd3983d015950c81e7403e29.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Moved common functionality of metadata and annotations into superclass. git-svn-id: https://code.elgg.org/elgg/trunk@323 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/metadata.php')
-rw-r--r--engine/lib/metadata.php70
1 files changed, 14 insertions, 56 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 82ca71bdd..573ea8f4f 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -16,14 +16,9 @@
* This class describes metadata that can be attached to ElggEntities.
* @author Marcus Povey <marcus@dushka.co.uk>
*/
- class ElggMetadata implements Exportable
+ class ElggMetadata extends ElggExtender
{
- /**
- * This contains the site's main properties (id, etc)
- * @var array
- */
- private $attributes;
-
+
/**
* Construct a new site object, optionally from a given id value or row.
*
@@ -50,40 +45,11 @@
}
function __get($name) {
- if (isset($this->attributes[$name])) {
-
- // Sanitise value if necessary
- if ($name=='value')
- {
- switch ($this->attributes['value_type'])
- {
- case 'integer' : return (int)$this->attributes['value'];
- case 'tag' :
- case 'text' :
- case 'file' : return sanitise_string($this->attributes['value']);
-
- default : throw new InstallationException("Type {$this->attributes['value_type']} is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.");
- }
- }
-
- return $this->attributes[$name];
- }
- return null;
+ return $this->get($name);
}
function __set($name, $value) {
- $this->attributes[$name] = $value;
- return true;
- }
-
- /**
- * Return the owner of this metadata.
- *
- * @return mixed
- */
- function getOwner()
- {
- return get_user($this->owner_guid);
+ return $this->set($name, $value);
}
function save()
@@ -107,13 +73,6 @@
return delete_metadata($this->id);
}
- public function export()
- {
- $tmp = new stdClass;
- $tmp->attributes = $this->attributes;
- $tmp->attributes['owner_uuid'] = guid_to_uuid($this->owner_guid);
- return $tmp;
- }
}
@@ -394,22 +353,21 @@
if (!is_array($returnvalue))
throw new InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
-
- $guid = (int)$params['guid'];
- // Get the metadata for the entity
- $metadata = get_metadata_for_entity($guid);
+ $guid = (int)$params['guid'];
+ $name = $params['name'];
- if ($metadata)
+ $result = get_metadata_for_entity($guid);
+
+ if ($result)
{
- foreach ($metadata as $m)
- $returnvalue[] = $m;
- }
-
+ foreach ($result as $r)
+ $returnvalue[] = $r;
+ }
+
return $returnvalue;
}
- /** Register the hook, ensuring entities are serialised first */
+ /** Register the hook */
register_plugin_hook("export", "all", "export_metadata_plugin_hook", 2);
-
?> \ No newline at end of file