]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added filtering by archive date.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 23 Mar 2010 21:38:14 +0000 (21:38 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 23 Mar 2010 21:38:14 +0000 (21:38 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@5490 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/blog/blog_lib.php
mod/blog/languages/en.php
mod/blog/start.php
mod/blog/views/default/blog/sidebar_menu.php

index 6f52e53ec91b6153ab776ae2d3383e9f7df46b4f..7f83d0dc3a6c6e85eed21114159c2ba2ee9e00b3 100644 (file)
@@ -97,6 +97,72 @@ function blog_get_page_content_edit($guid, $revision = NULL) {
        return array('content' => $content, 'sidebar' => $sidebar);
 }
 
+/**
+ * Show blogs with publish dates between $lower and $upper
+ *
+ * @param unknown_type $owner_guid
+ * @param unknown_type $lower
+ * @param unknown_type $upper
+ */
+function blog_get_page_content_archive($owner_guid, $lower, $upper) {
+       $now = time();
+
+       $content = elgg_view('page_elements/content_header', array('context' => $context, 'type' => 'blog'));
+
+       if ($lower) {
+               $lower = (int)$lower;
+       }
+
+       if ($upper) {
+               $upper = (int)$upper;
+       }
+
+       $options = array(
+               'type' => 'object',
+               'subtype' => 'blog',
+               'full_view' => FALSE,
+               'order_by_metadata' => array('name'=>'publish_date', 'direction'=>'DESC', 'as'=>'int'),
+       );
+
+       if ($owner_guid) {
+               $options['owner_guid'] = $owner_guid;
+       }
+
+       // admin / owners can see any posts
+       // everyone else can only see published posts
+       if (!(isadminloggedin() || (isloggedin() && $owner_guid == get_loggedin_userid()))) {
+               if ($upper > $now) {
+                       $upper = $now;
+               }
+
+               $options['metadata_name_value_pairs'] = array(
+                       array('name' => 'status', 'value' => 'published')
+               );
+       }
+
+       if ($lower) {
+               $options['metadata_name_value_pairs'][] = array(
+                       'name' => 'publish_date',
+                       'operand' => '>',
+                       'value' => $lower
+               );
+       }
+
+       if ($upper) {
+               $options['metadata_name_value_pairs'][] = array(
+                       'name' => 'publish_date',
+                       'operand' => '<',
+                       'value' => $upper
+               );
+       }
+
+       $content .= elgg_list_entities_from_metadata($options);
+
+       return array(
+               'content' => $content
+       );
+}
+
 /**
  * Returns an appropriate excerpt for a blog.
  *
index 8a7f7d8dc6d66428e6ce9f0291cb2c7f2fa1b755..f98cc60599136b111d11e92e939be7a117bd156d 100644 (file)
@@ -9,6 +9,7 @@ $english = array(
        'blog:blogs' => 'Blogs',
        'blog:owned_blogs' => '%s blogs',
        'blog:revisions' => 'Revisions',
+       'blog:archives' => 'Archives',
 
        'blog:blog' => 'Blog',
        'blog:yours' => 'Your blog',
index d0c4c515743105af2991dd00b84b852d141d7d96..3c497088a42c7c7ed937ab5805642586d604dbda 100644 (file)
@@ -128,12 +128,12 @@ function blog_page_handler($page) {
                                $content_info = blog_get_page_content_edit($page2, $page3);
                                break;
 
-                       case 'archives':
-                               $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog'));
-                               $content .= blog_get_page_content_archive($user->getGUID(), $page2, $page3);
+                       case 'archive':
+                               $content_info = blog_get_page_content_archive($user->getGUID(), $page2, $page3);
                                break;
 
                        case 'friends':
+                               //@todo make it go
                                $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog'));
                                $content .= blog_get_page_content_archive($user->getGUID());
                                break;
index d4f67ec986a02a005121c93d20c0007b0e5464ed..bd348c7e678bb2c1e87572b948eb35a3494507b5 100644 (file)
@@ -23,23 +23,43 @@ All blogs:
 
 Owned blogs;
        Archives
-
-
-
 */
 
 $loggedin_user = get_loggedin_user();
 $page_owner = page_owner_entity();
 
-       // include a view for plugins to extend
-       echo elgg_view("blogs/sidebar", array("object_type" => 'blog'));
+// include a view for plugins to extend
+echo elgg_view("blogs/sidebar", array("object_type" => 'blog'));
+
+// fetch & display latest comments on all blog posts
+$comments = get_annotations(0, "object", "blog", "generic_comment", "", 0, 4, 0, "desc");
+echo elgg_view('annotation/latest_comments', array('comments' => $comments));
+
+if ($dates = get_entity_dates('object', 'blog', page_owner())) {
+       echo elgg_view_title(elgg_echo('blog:archives'));
+
+       echo '<ul>';
+       foreach($dates as $date) {
+               $timestamplow = mktime(0,0,0,substr($date,4,2),1,substr($date,0,4));
+               $timestamphigh = mktime(0,0,0,((int) substr($date,4,2)) + 1,1,substr($date,0,4));
+
+               if (!isset($page_owner)) $page_owner = page_owner_entity();
+               $link = $CONFIG->wwwroot . 'pg/blog/' . $page_owner->username . '/archive/' . $timestamplow . '/' . $timestamphigh;
+               //add_submenu_item(sprintf(elgg_echo('date:month:' . substr($date,4,2)), substr($date, 0, 4)), $link, 'filter');
+               $month = sprintf(elgg_echo('date:month:' . substr($date,4,2)), substr($date, 0, 4));
+               echo "<li><a href=\"$link\" title=\"$month\">$month</a><li>";
+       }
+
+       echo '</ul>';
+}
+
 
-       // fetch & display latest comments on all blog posts
-       $comments = get_annotations(0, "object", "blog", "generic_comment", "", 0, 4, 0, "desc");
-       echo elgg_view('annotation/latest_comments', array('comments' => $comments));
+// temporarily force tag-cloud display
+$tags = display_tagcloud(0, 100, 'tags');
+echo <<<___END
+<h3>Tagcloud</h3>
+<div class="tagcloud sidebar">$tags</div>
+<a href="{$vars['url']}mod/tagcloud/tagcloud.php">All site tags</a>
+___END;
 
-       // temporarily force tag-cloud display
-       echo "<h3>Tagcloud</h3>";
-       echo "<div class='tagcloud sidebar'>".display_tagcloud(0, 100, 'tags')."</div>";
-       echo "<a href=\"{$vars['url']}mod/tagcloud/tagcloud.php\">All site tags</a>";
-?>
+?>
\ No newline at end of file