]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
added support for group albums
authorCash Costello <cash.costello@gmail.com>
Wed, 23 Nov 2011 23:46:41 +0000 (18:46 -0500)
committerCash Costello <cash.costello@gmail.com>
Wed, 23 Nov 2011 23:46:41 +0000 (18:46 -0500)
pages/photos/album/view.php
start.php
views/default/object/album.php
views/default/object/album/gallery.php [moved from views/default/object/album/summary.php with 100% similarity]
views/default/object/album/list.php [new file with mode: 0644]
views/default/photos/group_module.php [new file with mode: 0644]

index aafcf14bc043e5f007a75ffb22b23c83b7af1bc4..39816b299ecbdd1ef33a25e86ed12815ea0cf6ec 100644 (file)
@@ -23,7 +23,11 @@ $title = elgg_echo($album->getTitle());
 
 // set up breadcrumbs
 elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
-elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+if (elgg_instanceof($owner, 'group')) {
+       elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+} else {
+       elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+}
 elgg_push_breadcrumb($album->getTitle());
 
 $content = elgg_view_entity($album, array('full_view' => true));
index 1c548b90b5003b852a4b0028b9a8dba40bf9e586..b57ffb73e631a0c8744a30544532fd3155b562da 100644 (file)
--- a/start.php
+++ b/start.php
@@ -43,10 +43,11 @@ function tidypics_init() {
        // Register for the entity menu
        elgg_register_plugin_hook_handler('register', 'menu:entity', 'tidypics_entity_menu_setup');
 
-/*
-       // Extend hover-over and profile menu
-       elgg_extend_view('profile/menu/links','tidypics/hover_menu');
+       // Add group option
+       add_group_tool_option('photos', elgg_echo('tidypics:enablephotos'), true);
+       elgg_extend_view('groups/tool_latest', 'photos/group_module');
 
+/*
        //group view  ** psuedo widget view for group pages**
        elgg_extend_view('groups/right_column','tidypics/groupprofile_albums');
 
@@ -57,16 +58,11 @@ function tidypics_init() {
 
        // register for menus
        //register_elgg_event_handler('pagesetup', 'system', 'tidypics_submenus');
-       register_elgg_event_handler('pagesetup', 'system', 'tidypics_adminmenu');
 
        // Add a new tidypics widget
        add_widget_type('album_view', elgg_echo("tidypics:widget:albums"), elgg_echo("tidypics:widget:album_descr"), 'profile');
        add_widget_type('latest_photos', elgg_echo("tidypics:widget:latest"), elgg_echo("tidypics:widget:latest_descr"), 'profile');
 
-       // Register a URL handler for files
-       register_entity_url_handler('tidypics_image_url', 'object', 'image');
-       register_entity_url_handler('tidypics_album_url', 'object', 'album');
-
        add_group_tool_option('photos', elgg_echo('tidypics:enablephotos'), true);
 
        if (get_plugin_setting('grp_perm_override', 'tidypics') != "disabled") {
@@ -224,17 +220,6 @@ function tidypics_submenus() {
 
 }
 
-/**
- * Sets up tidypics admin menu. Triggered on pagesetup.
- */
-function tidypics_adminmenu() {
-       global $CONFIG;
-
-       if (get_context() == 'admin' && isadminloggedin()) {
-               add_submenu_item(elgg_echo('tidypics:administration'), $CONFIG->url . "pg/photos/admin/");
-       }
-}
-
 /**
  * Sets up submenus for tidypics most viewed pages
  */
@@ -500,28 +485,6 @@ function tidypics_notify_message($hook, $type, $result, $params) {
        return null;
 }
 
-/**
- * Populates the ->getUrl() method for file objects
- * Registered in the init function
- *
- * @param ElggEntity $entity album/image entity
- * @return string File URL
- */
-function tidypics_image_url($entity) {
-       global $CONFIG;
-       $title = $entity->title;
-       $title = friendly_title($title);
-       return $CONFIG->url . "pg/photos/view/" . $entity->getGUID() . "/" . $title;
-}
-
-function tidypics_album_url($entity) {
-       global $CONFIG;
-       $title = $entity->title;
-       $title = friendly_title($title);
-       return $CONFIG->url . "pg/photos/album/" . $entity->getGUID() . "/" . $title;
-}
-
-
 /**
  * Catch the plugin hook and add the default album slideshow
  *
index 51b25b7da92937992aa6f07124ece0a80dc5c9d5..bfcfd96d29874e6273ce9689f851c7395a500387 100644 (file)
@@ -14,5 +14,9 @@ $full_view = elgg_extract('full_view', $vars, false);
 if ($full_view) {
        echo elgg_view('object/album/full', $vars);
 } else {
-       echo elgg_view('object/album/summary', $vars);
+       if (elgg_in_context('widgets')) {
+               echo elgg_view('object/album/list', $vars);
+       } else {
+               echo elgg_view('object/album/gallery', $vars);
+       }
 }
diff --git a/views/default/object/album/list.php b/views/default/object/album/list.php
new file mode 100644 (file)
index 0000000..ccbd01c
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Display an album as an item in a list
+ *
+ * @uses $vars['entity'] TidypicsAlbum
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$album = elgg_extract('entity', $vars);
+$owner = $album->getOwnerEntity();
+
+$owner_link = elgg_view('output/url', array(
+       'href' => "photos/owner/$owner->username",
+       'text' => $owner->name,
+       'is_trusted' => true,
+));
+$author_text = elgg_echo('byline', array($owner_link));
+$date = elgg_view_friendly_time($album->time_created);
+$categories = elgg_view('output/categories', $vars);
+
+$subtitle = "$author_text $date $categories";
+
+$title = elgg_view('output/url', array(
+       'text' => $album->getTitle(),
+       'href' => $album->getURL(),
+));
+
+$params = array(
+       'entity' => $album,
+       'title' => $title,
+       'metadata' => null,
+       'subtitle' => $subtitle,
+       'tags' => elgg_view('output/tags', array('tags' => $album->tags)),
+);
+$params = $params + $vars;
+$summary = elgg_view('object/elements/summary', $params);
+
+$cover = elgg_view('output/img', array(
+       'src' => $album->getCoverImageURL('thumb'),
+       'alt' => $album->getTitle(),
+       'class' => 'elgg-photo',
+));
+$icon = elgg_view('output/url', array(
+       'text' => $cover,
+       'href' => $album->getURL(),
+       'encode_text' => false,
+       'is_trusted' => true,
+));
+
+echo $header = elgg_view_image_block($icon, $summary);
diff --git a/views/default/photos/group_module.php b/views/default/photos/group_module.php
new file mode 100644 (file)
index 0000000..aa0e7b3
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Group blog module
+ */
+
+$group = elgg_get_page_owner_entity();
+
+if ($group->photos_enable == "no") {
+       return true;
+}
+
+$all_link = elgg_view('output/url', array(
+       'href' => "photos/group/$group->guid/all",
+       'text' => elgg_echo('link:view:all'),
+       'is_trusted' => true,
+));
+
+elgg_push_context('widgets');
+$options = array(
+       'type' => 'object',
+       'subtype' => 'album',
+       'container_guid' => elgg_get_page_owner_guid(),
+       'limit' => 6,
+       'full_view' => false,
+       'pagination' => false,
+);
+$content = elgg_list_entities($options);
+elgg_pop_context();
+
+if (!$content) {
+       $content = '<p>' . elgg_echo('tidypics:none') . '</p>';
+}
+
+$new_link = elgg_view('output/url', array(
+       'href' => "photos/add/$group->guid",
+       'text' => elgg_echo('photos:add'),
+       'is_trusted' => true,
+));
+
+echo elgg_view('groups/profile/module', array(
+       'title' => elgg_echo('photos:group'),
+       'content' => $content,
+       'all_link' => $all_link,
+       'add_link' => $new_link,
+));