aboutsummaryrefslogtreecommitdiff
path: root/mod/elgg-favorites/views
diff options
context:
space:
mode:
Diffstat (limited to 'mod/elgg-favorites/views')
-rw-r--r--mod/elgg-favorites/views/default/favorites/button.php46
-rw-r--r--mod/elgg-favorites/views/default/favorites/sidebar.php13
-rw-r--r--mod/elgg-favorites/views/default/favorites/sidebar/groups.php24
-rw-r--r--mod/elgg-favorites/views/default/favorites/sidebar/users.php13
-rw-r--r--mod/elgg-favorites/views/default/favorites/view.php15
-rw-r--r--mod/elgg-favorites/views/default/js/favorites.php55
-rwxr-xr-xmod/elgg-favorites/views/default/widgets/favorites/content.php36
-rwxr-xr-xmod/elgg-favorites/views/default/widgets/favorites/edit.php17
8 files changed, 219 insertions, 0 deletions
diff --git a/mod/elgg-favorites/views/default/favorites/button.php b/mod/elgg-favorites/views/default/favorites/button.php
new file mode 100644
index 000000000..bc355d595
--- /dev/null
+++ b/mod/elgg-favorites/views/default/favorites/button.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Elgg Lorea Favorites Plugin
+ *
+ * @package ElggFavorites
+ */
+
+if (!isset($vars['entity'])) {
+ return true;
+}
+
+if (!elgg_is_logged_in()) {
+ return true;
+}
+
+$fav_entity_guid = $vars['entity']->getGUID();
+$fav_user_guid = elgg_get_logged_in_user_guid();
+
+if (!check_entity_relationship($fav_user_guid ,'flags_content', $fav_entity_guid)) {
+
+ $fav_url = elgg_get_site_url() . "action/favorites/add/?guid={$fav_entity_guid}";
+ $fav_params = array(
+ 'href' => $fav_url,
+ 'text' => elgg_view_icon('star-empty'),
+ 'title' => elgg_echo('favorites:add'),
+ 'class' => 'favorites-add',
+ 'is_action' => true,
+ 'is_trusted' => true,
+ );
+ $fav_button = elgg_view('output/url', $fav_params);
+
+} else {
+
+ $fav_url = elgg_get_site_url() . "action/favorites/remove/?guid={$fav_entity_guid}";
+ $fav_params = array(
+ 'href' => $fav_url,
+ 'text' => elgg_view_icon('star'),
+ 'title' => elgg_echo('favorites:remove'),
+ 'class' => 'favorites-remove',
+ 'is_action' => true,
+ 'is_trusted' => true,
+ );
+ $fav_button = elgg_view('output/url', $fav_params);
+}
+
+echo $fav_button;
diff --git a/mod/elgg-favorites/views/default/favorites/sidebar.php b/mod/elgg-favorites/views/default/favorites/sidebar.php
new file mode 100644
index 000000000..6e2e94f47
--- /dev/null
+++ b/mod/elgg-favorites/views/default/favorites/sidebar.php
@@ -0,0 +1,13 @@
+<?php
+if (elgg_is_logged_in()) {
+ if (elgg_get_context() == 'groups')
+ {
+ echo elgg_view("favorites/sidebar/groups", $vars);
+
+
+ }
+ elseif (elgg_get_context() == 'members') {
+ echo elgg_view('favorites/sidebar/users', $vars);
+ }
+}
+?>
diff --git a/mod/elgg-favorites/views/default/favorites/sidebar/groups.php b/mod/elgg-favorites/views/default/favorites/sidebar/groups.php
new file mode 100644
index 000000000..89d21b022
--- /dev/null
+++ b/mod/elgg-favorites/views/default/favorites/sidebar/groups.php
@@ -0,0 +1,24 @@
+<?php
+
+elgg_push_context('widgets');
+
+$fav_group_params = array(
+ 'type' => 'group',
+ 'relationship_guid' => elgg_get_logged_in_user_guid(),
+ 'relationship' => 'flags_content',
+ 'limit' => 0,
+ 'pagination' => false,
+ 'list_type' => 'gallery',
+ 'gallery_class' => 'elgg-gallery-groups',
+ 'full_view' => false
+);
+
+$fav_group_params['count'] = true;
+if(elgg_get_entities_from_relationship($fav_group_params) == 0) {
+ return true;
+}
+$fav_group_params['count'] = false;
+
+$fav_group_body = elgg_list_entities_from_relationship($fav_group_params);
+
+echo elgg_view_module('aside', elgg_echo('favorites:groups'), $fav_group_body);
diff --git a/mod/elgg-favorites/views/default/favorites/sidebar/users.php b/mod/elgg-favorites/views/default/favorites/sidebar/users.php
new file mode 100644
index 000000000..681a7728f
--- /dev/null
+++ b/mod/elgg-favorites/views/default/favorites/sidebar/users.php
@@ -0,0 +1,13 @@
+<?php
+
+$fav_user_body = elgg_list_entities_from_relationship(array(
+ 'relationship' => 'flags_content',
+ 'relationship_guid' => elgg_get_logged_in_user_guid(),
+ 'type' => 'user',
+ 'list_type' => 'gallery',
+ 'gallery_class' => 'elgg-gallery-users',
+ 'pagination' => false,
+));
+if ($fav_user_body) {
+ echo elgg_view_module('aside', elgg_echo('favorites:users'), $fav_user_body);
+}
diff --git a/mod/elgg-favorites/views/default/favorites/view.php b/mod/elgg-favorites/views/default/favorites/view.php
new file mode 100644
index 000000000..53e322f39
--- /dev/null
+++ b/mod/elgg-favorites/views/default/favorites/view.php
@@ -0,0 +1,15 @@
+<?php
+
+if (!elgg_is_logged_in()) {
+ return;
+}
+
+$fav_options = array(
+ 'type' => 'object',
+ 'relationship_guid' => elgg_get_logged_in_user_guid(),
+ 'relationship' => 'flags_content',
+ 'full_view' => FALSE,
+ 'view_type_toggle' => FALSE,
+);
+
+echo elgg_list_entities_from_relationship($fav_options);
diff --git a/mod/elgg-favorites/views/default/js/favorites.php b/mod/elgg-favorites/views/default/js/favorites.php
new file mode 100644
index 000000000..cc364f2ed
--- /dev/null
+++ b/mod/elgg-favorites/views/default/js/favorites.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Favorites JS.
+ */
+?>
+
+elgg.provide('elgg.favorites');
+
+elgg.favorites.init = function() {
+ $('.elgg-menu-item-favorite .favorites-add').live('click', elgg.favorites.add);
+ $('.elgg-menu-item-favorite .favorites-remove').live('click', elgg.favorites.remove);
+};
+
+elgg.favorites.add = function(event) {
+ event.preventDefault();
+ var $link = $(this);
+ var $actionParam = $link.attr("href").split("/").pop();
+ var $postGuid = $link.attr("href").match(/guid=([^&]+)/)[1];
+
+ elgg.action('favorites/add', {
+ data: {
+ guid: $postGuid
+ },
+ success: function(json) {
+ $link.attr('href', elgg.config.wwwroot + 'action/favorites/remove/' + $actionParam);
+ $link.attr('class', '.elgg-menu-item-favorite .favorites-remove');
+ $link.children('span').attr('class','elgg-icon elgg-icon-star');
+ $link.unbind('click');
+ $link.click(elgg.favorites.remove);
+ }
+ });
+};
+
+elgg.favorites.remove = function(event) {
+ event.preventDefault();
+ var $link = $(this);
+ var $actionParam = $link.attr("href").split("/").pop();
+ var $postGuid = $link.attr("href").match(/guid=([^&]+)/)[1];
+
+ elgg.action('favorites/remove', {
+ data: {
+ guid: $postGuid
+ },
+ success: function(json) {
+ $link.attr("href", elgg.config.wwwroot + 'action/favorites/add/' + $actionParam);
+ $link.attr('class', '.elgg-menu-item-favorite .favorites-add');
+ $link.children('span').attr('class','elgg-icon elgg-icon-star-empty');
+ $link.unbind('click');
+ $link.click(elgg.favorites.add);
+ }
+ });
+};
+
+elgg.register_hook_handler('init', 'system', elgg.favorites.init);
+
diff --git a/mod/elgg-favorites/views/default/widgets/favorites/content.php b/mod/elgg-favorites/views/default/widgets/favorites/content.php
new file mode 100755
index 000000000..32453b25c
--- /dev/null
+++ b/mod/elgg-favorites/views/default/widgets/favorites/content.php
@@ -0,0 +1,36 @@
+<?php
+
+$fav_pages_num = (int) $vars['entity']->pages_num;
+if (!$fav_pages_num) {
+ $fav_pages_num = 4;
+}
+
+$fav_user_guid = elgg_get_page_owner_guid();
+$fav_offset = 0;
+
+$fav_options = array(
+ 'relationship_guid' => $fav_user_guid,
+ 'relationship'=>'flags_content',
+ 'limit' => $fav_pages_num,
+ 'full_view' => FALSE,
+ 'view_type_toggle' => FALSE,
+ 'pagination' => FALSE,
+ 'order_by'=>'e.time_updated desc',
+ 'direction'=>'ASC',
+ 'offset'=>$fav_offset,
+ 'type'=>'object'
+);
+
+$fav_entities = elgg_get_entities_from_relationship($fav_options);
+$fav_count = elgg_get_entities_from_relationship_count($fav_options);
+$fav_title = elgg_view_title(elgg_echo("favorites:items"));
+
+echo elgg_view_entity_list(
+ $fav_entities,
+ $fav_count,
+ $fav_offset,
+ $fav_options['limit'],
+ $fav_options['full_view'],
+ $fav_options['view_type_toggle'],
+ $fav_options['pagination']
+);
diff --git a/mod/elgg-favorites/views/default/widgets/favorites/edit.php b/mod/elgg-favorites/views/default/widgets/favorites/edit.php
new file mode 100755
index 000000000..3394f22c2
--- /dev/null
+++ b/mod/elgg-favorites/views/default/widgets/favorites/edit.php
@@ -0,0 +1,17 @@
+<?php
+if (!isset($vars['entity']->pages_num)) {
+ $vars['entity']->pages_num = 4;
+}
+
+$params = array(
+ 'name' => 'params[pages_num]',
+ 'value' => $vars['entity']->pages_num,
+ 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
+);
+$dropdown = elgg_view('input/dropdown', $params);
+
+?>
+<div>
+ <?php echo elgg_echo('favorites:numbertodisplay'); ?>:
+ <?php echo $dropdown; ?>
+</div>