From 94ccaa1a5f6c927674698f1788f95241dce5bc29 Mon Sep 17 00:00:00 2001 From: brettp Date: Thu, 18 Mar 2010 21:45:48 +0000 Subject: 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 --- mod/blog/views/default/blog/forms/edit.php | 90 ++++++++++++++++------- mod/blog/views/default/blog/sidebar_edit.php | 65 ++++++++++++++++ mod/blog/views/default/blog/sidebar_menu.php | 6 -- mod/blog/views/default/blog/sidebar_revisions.php | 70 ++++++++++++++++++ mod/blog/views/default/object/blog.php | 25 ++++--- 5 files changed, 214 insertions(+), 42 deletions(-) create mode 100644 mod/blog/views/default/blog/sidebar_edit.php create mode 100644 mod/blog/views/default/blog/sidebar_revisions.php (limited to 'mod/blog/views/default') diff --git a/mod/blog/views/default/blog/forms/edit.php b/mod/blog/views/default/blog/forms/edit.php index b19898573..83ee8208e 100644 --- a/mod/blog/views/default/blog/forms/edit.php +++ b/mod/blog/views/default/blog/forms/edit.php @@ -9,11 +9,12 @@ * @link http://elgg.org/ */ +// input names => defaults $values = array( 'title' => NULL, 'description' => NULL, - 'status' => 'final', - //'publish_date' => NULL, + 'status' => 'published', + 'publish_date' => NULL, 'access_id' => ACCESS_DEFAULT, 'comments_on' => 'On', 'excerpt' => NULL, @@ -25,17 +26,42 @@ $values = array( $forward = $_SERVER['HTTP_REFERER']; $action_buttons = ''; -$guid_input = ''; $delete_link = ''; +$draft_warning = ''; // if entity is set, we're editing. if (isset ($vars['entity'])) { $blog = $vars['entity']; if ($blog && ($blog instanceof ElggObject) && ($blog->getSubtype() == 'blog')) { - foreach (array_keys($values) as $field) { - $values[$field] = $blog->$field; - } + // passed in values override sticky values in input views + // if in a sticky form, don't send the overrides and let the view figure it out. + //if (!elgg_is_sticky_form()) { + foreach (array_keys($values) as $field) { + $values[$field] = $blog->$field; + } + + // load the revision annotation if requested + if (isset($vars['revision']) && $vars['revision'] instanceof ElggAnnotation && $vars['revision']->entity_guid == $blog->getGUID()) { + $revision = $vars['revision']; + $values['description'] = $vars['revision']->value; + } + + // display a notice if there's an autosaved annotation + // and we're not editing it. + if ($auto_save_annotations = $blog->getAnnotations('blog_auto_save', 1)) { + $auto_save = $auto_save_annotations[0]; + } else { + $auto_save == FALSE; + } + + if ($auto_save && $auto_save->id != $revision->id) { + $draft_warning = '' + . elgg_echo('blog:messages:warning:draft') + . ''; + } + + //} } else { echo elgg_echo('blog:error:post_not_found'); return FALSE; @@ -48,8 +74,6 @@ if (isset ($vars['entity'])) { 'text' => elgg_echo('delete'), 'class' => 'action_button disabled' )); - - $guid_input = elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $values['guid'])); } $save_button = elgg_view('input/submit', array('value' => elgg_echo('save'), 'class' => 'submit_button')); @@ -77,7 +101,7 @@ $body_input = elgg_view('input/longtext', array( )); $save_status = elgg_echo('blog:save_status'); -$never = elgg_echo('never'); +$never = elgg_echo('blog:never'); $status_label = elgg_echo('blog:status'); $status_input = elgg_view('input/pulldown', array( @@ -85,8 +109,8 @@ $status_input = elgg_view('input/pulldown', array( 'internalid' => 'blog_status', 'value' => $values['status'], 'options_values' => array( - 'draft' => elgg_echo('blog:draft'), - 'final' => elgg_echo('blog:final') + 'draft' => elgg_echo('blog:status:draft'), + 'published' => elgg_echo('blog:status:published') ) )); @@ -121,12 +145,20 @@ $publish_date_input = elgg_view('input/datepicker', array( // hidden inputs //$container_guid_input = elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $values['container_guid'])); +$guid_input = elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $values['guid'])); $forward_input = elgg_view('input/hidden', array('internalname' => 'forward', 'value' => $forward)); -$page_title = elgg_echo('blog:edit')." ".$values['title']; +$page_title = elgg_echo('blog:edit') . " " . $values['title']; + +// display notice if editing an old revision +if (isset($vars['revision']) && $vars['revision'] instanceof ElggAnnotation) { + $page_title .= ' ' . elgg_echo('blog:edit_revision_notice'); +} $form_body = <<<___END

$page_title

+$draft_warning +

$title_input @@ -137,13 +169,12 @@ $form_body = <<<___END $excerpt_input

-

- - $body_input -

+ +$body_input +

- $save_status:$never + $save_status $never

@@ -190,6 +221,8 @@ echo elgg_view('input/form', array( 'body' => $form_body )); +elgg_clear_sticky_form('blog'); + ?>