aboutsummaryrefslogtreecommitdiff
path: root/start.php
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-15 14:58:59 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-15 14:58:59 -0300
commit31354451ce2c236c9c963064652c39fe54be4afd (patch)
tree6203d2ba3f7e29518291e2e3999d9fa89892b417 /start.php
downloadelgg-31354451ce2c236c9c963064652c39fe54be4afd.tar.gz
elgg-31354451ce2c236c9c963064652c39fe54be4afd.tar.bz2
Squashed 'mod/elgg-favorites/' content from commit d96e69b
git-subtree-dir: mod/elgg-favorites git-subtree-split: d96e69bd1365c3e3c4d998e72d9941ea1ea2278b
Diffstat (limited to 'start.php')
-rw-r--r--start.php83
1 files changed, 83 insertions, 0 deletions
diff --git a/start.php b/start.php
new file mode 100644
index 000000000..77b7ff8bc
--- /dev/null
+++ b/start.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Elgg Lorea Favorites Plugin
+ */
+
+elgg_register_event_handler('init','system','favorites_init');
+
+function favorites_init(){
+
+ elgg_register_page_handler('favorites','favorites_page_handler');
+ elgg_extend_view("js/elgg", "js/favorites");
+ elgg_extend_view("page/elements/sidebar", "favorites/sidebar");
+
+ if ( elgg_is_logged_in() ) {
+ elgg_register_menu_item(
+ 'site',
+ array(
+ 'name' => 'favorites',
+ 'text' => elgg_echo('favorites:menu'),
+ 'href' => "favorites/view/"
+ )
+ );
+ }
+
+ $plugin_path = elgg_get_plugins_path();
+
+ elgg_register_action(
+ "favorites/add",
+ $plugin_path . "favorites/actions/favorites/add.php"
+ );
+
+ elgg_register_action(
+ "favorites/remove",
+ $plugin_path . "favorites/actions/favorites/remove.php"
+ );
+
+ elgg_register_plugin_hook_handler(
+ 'register',
+ 'menu:entity',
+ 'favorites_entity_menu_setup'
+ );
+ elgg_register_widget_type(
+ 'favorites',
+ elgg_echo('favorites:widget:title'),
+ elgg_echo('favorites:widget:description')
+ );
+}
+
+function favorites_page_handler($page) {
+ echo elgg_view_page(
+ elgg_echo("favorites:items"),
+ elgg_view_layout(
+ 'one_sidebar',
+ array(
+ 'title' => elgg_echo("favorites:items"),
+ 'content' => elgg_view('favorites/view'),
+ 'sidebar' => elgg_view('favorites/sidebar'),
+ )
+ )
+ );
+ return true;
+}
+
+function favorites_entity_menu_setup($hook, $type, $return, $params) {
+ if (elgg_in_context('widgets')) {
+ return $return;
+ }
+ if ( elgg_is_logged_in() ) {
+
+ $entity = $params['entity'];
+
+ if ($entity instanceof ElggEntity) {
+ $options = array(
+ 'name' => 'favorite',
+ 'text' => elgg_view('favorites/button', array('entity' => $entity)),
+ 'is_action' => true,
+ 'is_trusted' => true
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+ }
+ return $return;
+}