diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-18 21:45:48 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-18 21:45:48 +0000 |
commit | 94ccaa1a5f6c927674698f1788f95241dce5bc29 (patch) | |
tree | ec666baad142c7aea5644aa0f386e161ee0511f8 /mod/blog/views/default/blog/sidebar_edit.php | |
parent | a12e51d597b5ca22af44609b778eca66ca681492 (diff) | |
download | elgg-94ccaa1a5f6c927674698f1788f95241dce5bc29.tar.gz elgg-94ccaa1a5f6c927674698f1788f95241dce5bc29.tar.bz2 |
Updated blog to support multiple revisions and automatic saving of drafts.
git-svn-id: http://code.elgg.org/elgg/trunk@5437 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/blog/views/default/blog/sidebar_edit.php')
-rw-r--r-- | mod/blog/views/default/blog/sidebar_edit.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/mod/blog/views/default/blog/sidebar_edit.php b/mod/blog/views/default/blog/sidebar_edit.php new file mode 100644 index 000000000..d75c28aad --- /dev/null +++ b/mod/blog/views/default/blog/sidebar_edit.php @@ -0,0 +1,65 @@ +<?php +/** + * Blog sidebar menu for editing / creating a blog post. + * + * @package Blog + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.org/ + */ + +//If editing a post, show the previous revisions and drafts. +$blog_guid = isset($vars['blog_guid']) ? $vars['blog_guid'] : FALSE; +$blog = get_entity($blog_guid); + +if (elgg_instanceof($blog, 'object', 'blog') && $blog->canEdit()) { + $revisions = array(); + if ($auto_save_annotations = $blog->getAnnotations('blog_auto_save', 1)) { + $revisions[] = $auto_save_annotations[0]; + } + + // count(FALSE) == 1! AHHH!!! + if ($saved_revisions = $blog->getAnnotations('blog_revision', 10, 0, 'time_created DESC')) { + $revision_count = count($saved_revisions); + } else { + $revision_count = 0; + } + + $revisions = array_merge($revisions, $saved_revisions); +} + +if ($revisions) { + echo '<ul class="blog_revisions">'; + $load_base_url = "{$vars['url']}pg/blog/{$owner->username}/edit/{$blog->getGUID()}/"; + + foreach ($revisions as $revision) { + $time = friendly_time($revision->time_created); + $load = elgg_view('output/url', array( + 'href' => $load_base_url . $revision->id, + 'text' => elgg_echo('load') + )); + + + if ($revision->name == 'blog_auto_save') { + $name = elgg_echo('blog:auto_saved_revision'); + $text = "$name: $time $load"; + $class = 'class="auto_saved"'; + } else { + $name = elgg_echo('blog:revision'); + $text = "$name: $time $load"; + $class = 'class="auto_saved"'; + + $revision_count--; + } + + echo <<<___END +<li $class> +$text +</li> + +___END; + } + + echo '</ul>'; +}
\ No newline at end of file |