aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-17 10:44:26 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-17 10:44:26 +0000
commitaf2e2ae369e0ab13a99b83a928363f6d7f48f715 (patch)
tree373850213656c96cb07a726f00509f2c5e774f7f
parentddbe1c9698031a8017e073048bc48d5268129c78 (diff)
downloadelgg-af2e2ae369e0ab13a99b83a928363f6d7f48f715.tar.gz
elgg-af2e2ae369e0ab13a99b83a928363f6d7f48f715.tar.bz2
Closes #160
git-svn-id: https://code.elgg.org/elgg/trunk@1452 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/entities.php42
-rw-r--r--engine/lib/extender.php5
-rw-r--r--services/export/handler.php4
3 files changed, 50 insertions, 1 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index c93b1c2c7..57578362c 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1289,6 +1289,45 @@
return true;
}
+
+ /**
+ * A plugin hook to get certain volitile (generated on the fly) attributes about an entity in order to export them.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params The parameters, passed 'guid' and 'varname'
+ * @return unknown
+ */
+ function volatile_data_export_plugin_hook($hook, $entity_type, $returnvalue, $params)
+ {
+ $guid = (int)$params['guid'];
+ $variable_name = sanitise_string($params['varname']);
+
+ if (($hook == 'volatile') && ($entity_type == 'metadata'))
+ {
+ if (($guid) && ($variable_name))
+ {
+ switch ($variable_name)
+ {
+ case 'renderedentity' :
+ elgg_set_viewtype('default');
+ $view = elgg_view_entity(get_entity($guid));
+ elgg_set_viewtype();
+
+ $tmp = new ElggMetadata();
+ $tmp->type = 'volatile';
+ $tmp->name = 'renderedentity';
+ $tmp->value = $view;
+ $tmp->entity_guid = $guid;
+
+ return $tmp;
+
+ break;
+ }
+ }
+ }
+ }
/**
* Handler called by trigger_plugin_hook on the "export" event.
@@ -1563,6 +1602,9 @@
/** Register the hook, ensuring entities are serialised first */
register_plugin_hook("export", "all", "export_entity_plugin_hook", 0);
+ /** Hook to get certain named bits of volatile data about an entity */
+ register_plugin_hook('volatile', 'metadata', 'volatile_data_export_plugin_hook');
+
/** Register init system event **/
register_elgg_event_handler('init','system','entities_init');
diff --git a/engine/lib/extender.php b/engine/lib/extender.php
index b2482cd80..85908d62a 100644
--- a/engine/lib/extender.php
+++ b/engine/lib/extender.php
@@ -123,7 +123,10 @@
public function export()
{
$type = $this->attributes['type'];
- $uuid = guid_to_uuid($this->entity_guid). $type . "/{$this->id}/";
+ if ($type == 'volatile')
+ $uuid = guid_to_uuid($this->entity_guid). $type . "/{$this->name}/";
+ else
+ $uuid = guid_to_uuid($this->entity_guid). $type . "/{$this->id}/";
$meta = new ODDMetadata($uuid, guid_to_uuid($this->entity_guid), $this->attributes['name'], $this->attributes['value'], $type, guid_to_uuid($this->owner_guid));
$meta->setAttribute('published', date("r", $this->time_created));
diff --git a/services/export/handler.php b/services/export/handler.php
index 2318e4ea8..b6e5edc1b 100644
--- a/services/export/handler.php
+++ b/services/export/handler.php
@@ -78,6 +78,10 @@
case 'relationship' :
$r = get_relationship($id_or_name);
break;
+ case 'volatile' :
+ error_log("******************* ID NAME $id_or_name $uuid");
+ $m = trigger_plugin_hook('volatile', 'metadata', array('guid' => $guid, 'varname' => $id_or_name));
+ break;
default :
throw new InvalidParameterException(sprintf(elgg_echo('InvalidParameterException:CanNotExportType'), $type));