From c5628aeb49123fcddeb8ce3f7bd315b3f7369530 Mon Sep 17 00:00:00 2001 From: brettp Date: Tue, 6 Jul 2010 20:41:07 +0000 Subject: Added embed support to file plugin. git-svn-id: http://code.elgg.org/elgg/trunk@6645 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/file/start.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'mod/file/start.php') diff --git a/mod/file/start.php b/mod/file/start.php index b8a26fab5..f3da33caf 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -61,6 +61,10 @@ // Register entity type register_entity_type('object','file'); + + // embed support + register_plugin_hook('embed_get_sections', 'all', 'file_embed_get_sections'); + register_plugin_hook('embed_get_items', 'file', 'file_embed_get_items'); } /** @@ -212,6 +216,54 @@ } + /** + * Register file as an embed type. + * + * @param unknown_type $hook + * @param unknown_type $type + * @param unknown_type $value + * @param unknown_type $params + */ + function file_embed_get_sections($hook, $type, $value, $params) { + $value['file'] = array( + 'name' => elgg_echo('file:files'), + 'layout' => 'list', + 'icon_size' => 'medium', + ); + + return $value; + } + + /** + * Return a list of files for embedding + * + * @param unknown_type $hook + * @param unknown_type $type + * @param unknown_type $value + * @param unknown_type $params + */ + function file_embed_get_items($hook, $type, $value, $params) { + $options = array( + 'owner_guid' => get_loggedin_userid(), + 'type_subtype_pair' => array('object' => 'file'), + 'count' => TRUE + ); + + if ($count = elgg_get_entities($options)) { + $value['count'] += $count; + + unset($options['count']); + $options['offset'] = $params['offset']; + $options['limit'] = $params['limit']; + + $items = elgg_get_entities($options); + + $value['items'] = array_merge($items, $value['items']); + } + + return $value; + } + /** * Populates the ->getUrl() method for file objects * -- cgit v1.2.3