diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-25 17:07:41 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-25 17:07:41 +0000 |
commit | 58bd19d7cf35e6159124716d0da48d91354d3a2f (patch) | |
tree | baf3133c13b2f5a38e7e16e182a208258069e4ef /mod/blog/views/default/blog/sidebar/revisions.php | |
parent | f6045914d7488c43cd7761ddaded55b3791ae950 (diff) | |
download | elgg-58bd19d7cf35e6159124716d0da48d91354d3a2f.tar.gz elgg-58bd19d7cf35e6159124716d0da48d91354d3a2f.tar.bz2 |
amtrak does not have wifi so here is one big commit with group blogs, blog widget, and improved blog sidebar
git-svn-id: http://code.elgg.org/elgg/trunk@7720 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/blog/views/default/blog/sidebar/revisions.php')
-rw-r--r-- | mod/blog/views/default/blog/sidebar/revisions.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/mod/blog/views/default/blog/sidebar/revisions.php b/mod/blog/views/default/blog/sidebar/revisions.php new file mode 100644 index 000000000..e3919648b --- /dev/null +++ b/mod/blog/views/default/blog/sidebar/revisions.php @@ -0,0 +1,77 @@ +<?php +/** + * Blog sidebar menu showing revisions + * + * @package Blog + */ + +//If editing a post, show the previous revisions and drafts. +$blog = elgg_get_array_value('entity', $vars, FALSE); + +if (elgg_instanceof($blog, 'object', 'blog') && $blog->canEdit()) { + $owner = $blog->getOwnerEntity(); + $revisions = array(); + + $auto_save_annotations = $blog->getAnnotations('blog_auto_save', 1); + if ($auto_save_annotations) { + $revisions[] = $auto_save_annotations[0]; + } + + // count(FALSE) == 1! AHHH!!! + $saved_revisions = $blog->getAnnotations('blog_revision', 10, 0, 'time_created DESC'); + if ($saved_revisions) { + $revision_count = count($saved_revisions); + } else { + $revision_count = 0; + } + + $revisions = array_merge($revisions, $saved_revisions); + + if ($revisions) { + $title = elgg_echo('blog:revisions'); + + $n = count($revisions); + $body = '<ul class="blog-revisions">'; + + $load_base_url = "pg/blog/edit/{$owner->username}/{$blog->getGUID()}/"; + + // show the "published revision" + if ($blog->status == 'published') { + $load = elgg_view('output/url', array( + 'href' => $load_base_url, + 'text' => elgg_echo('blog:status:published') + )); + + $time = "<span class='entity-subtext'>" + . elgg_view_friendly_time($blog->publish_date) . "</span>"; + + $body .= "<li>$load : $time</li>"; + } + + foreach ($revisions as $revision) { + $time = "<span class='entity-subtext'>" + . elgg_view_friendly_time($revision->time_created) . "</span>"; + + if ($revision->name == 'blog_auto_save') { + $revision_lang = elgg_echo('blog:auto_saved_revision'); + } else { + $revision_lang = elgg_echo('blog:revision') . " $n"; + } + $load = elgg_view('output/url', array( + 'href' => $load_base_url . $revision->id, + 'text' => $revision_lang + )); + + $text = "$load: $time"; + $class = 'class="auto-saved"'; + + $n--; + + $body .= "<li $class>$text</li>"; + } + + $body .= '</ul>'; + + echo elgg_view('layout/objects/module', array('title' => $title, 'body' => $body)); + } +}
\ No newline at end of file |