aboutsummaryrefslogtreecommitdiff
path: root/mod/file
diff options
context:
space:
mode:
Diffstat (limited to 'mod/file')
-rw-r--r--mod/file/start.php52
1 files changed, 52 insertions, 0 deletions
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');
}
/**
@@ -213,6 +217,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
*
* @param ElggEntity $entity File entity