aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-07-06 20:41:07 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-07-06 20:41:07 +0000
commitc5628aeb49123fcddeb8ce3f7bd315b3f7369530 (patch)
treec68011d227c556fb05c27bcae4434c171ee62775
parent60e96102050d1ccc4913753ffda50af0cd9337b7 (diff)
downloadelgg-c5628aeb49123fcddeb8ce3f7bd315b3f7369530.tar.gz
elgg-c5628aeb49123fcddeb8ce3f7bd315b3f7369530.tar.bz2
Added embed support to file plugin.
git-svn-id: http://code.elgg.org/elgg/trunk@6645 36083f99-b078-4883-b0ff-0f9b5a30f544
-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