diff options
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/entities.php | 42 | ||||
-rw-r--r-- | engine/lib/extender.php | 5 |
2 files changed, 46 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)); |