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/actions/blog/auto_save_revision.php | 89 +++++++++ mod/blog/actions/blog/save.php | 217 +++++----------------- mod/blog/actions/blog/save_draft.php | 146 --------------- mod/blog/blog_lib.php | 78 +++++--- mod/blog/languages/en.php | 7 + mod/blog/start.php | 71 ++----- 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 ++- 11 files changed, 427 insertions(+), 437 deletions(-) create mode 100644 mod/blog/actions/blog/auto_save_revision.php delete mode 100644 mod/blog/actions/blog/save_draft.php 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') diff --git a/mod/blog/actions/blog/auto_save_revision.php b/mod/blog/actions/blog/auto_save_revision.php new file mode 100644 index 000000000..fa9010e90 --- /dev/null +++ b/mod/blog/actions/blog/auto_save_revision.php @@ -0,0 +1,89 @@ +canEdit()) { + $blog = $entity; + } else { + $error = elgg_echo('blog:error:post_not_found'); + } + } else { + $blog = new ElggObject(); + $blog->subtype = 'blog'; + + // force draft and private for autosaves. + $blog->status = 'unsaved_draft'; + $blog->access_id = ACCESS_PRIVATE; + $blog->title = $title; + $blog->description = $description; + $blog->excerpt = blog_make_excerpt($excerpt); + // must be present or doesn't show up when metadata sorting. + $blog->publish_date = time(); + if (!$blog->save()) { + $error = elgg_echo('blog:error:cannot_save'); + } + } + + // creat draft annotation + if (!$error) { + // annotations don't have a "time_updated" so + // we have to delete everything or the times are wrong. + + // don't save if nothing changed + if ($auto_save_annotations = $blog->getAnnotations('blog_auto_save', 1)) { + $auto_save = $auto_save_annotations[0]; + } else { + $auto_save == FALSE; + } + + if (!$auto_save) { + $annotation_id = $blog->annotate('blog_auto_save', $description); + } elseif ($auto_save instanceof ElggAnnotation && $auto_save->value != $description) { + $blog->clearAnnotations('blog_auto_save'); + $annotation_id = $blog->annotate('blog_auto_save', $description); + } elseif ($auto_save instanceof ElggAnnotation && $auto_save->value == $description) { + // this isn't an error because we have an up to date annotation. + $annotation_id = $auto_save->id; + } + + if (!$annotation_id) { + $error = elgg_echo('blog:error:cannot_auto_save'); + } + } +} else { + $error = elgg_echo('blog:error:missing:description'); +} + +if ($error) { + $json = array('success' => FALSE, 'message' => $error); + echo json_encode($json); +} else { + $msg = elgg_echo('blog:message:saved'); + $json = array('success' => TRUE, 'message' => $msg, 'guid' => $blog->getGUID()); + echo json_encode($json); +} \ No newline at end of file diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index eade7cad8..0ca063496 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -9,16 +9,16 @@ * @link http://elgg.org/ */ -elgg_make_sticky_form(); - -// edit or create a new entity -$guid = get_input('guid'); -$user = get_loggedin_user(); -$ajax = get_input('ajax'); +// start a new sticky form session in case of failure +//elgg_make_sticky_form(); // store errors to pass along $error = FALSE; $error_forward_url = $_SERVER['HTTP_REFERER']; +$user = get_loggedin_user(); + +// edit or create a new entity +$guid = get_input('guid'); if ($guid) { $entity = get_entity($guid); @@ -29,10 +29,15 @@ if ($guid) { forward(get_input('forward', $_SERVER['HTTP_REFERER'])); } $success_forward_url = get_input('forward', $blog->getURL()); + + // save some data for revisions once we save the new edit + $revision_value = $blog->description; + $new_post = FALSE; } else { $blog = new ElggObject(); $blog->subtype = 'blog'; $success_forward_url = get_input('forward'); + $new_post = TRUE; } // set defaults and required values. @@ -40,7 +45,7 @@ $values = array( 'title' => '', 'description' => '', 'status' => 'draft', - //'publish_date' => time(), + 'publish_date' => time(), 'access_id' => ACCESS_DEFAULT, 'comments_on' => 'On', 'excerpt' => '', @@ -48,13 +53,9 @@ $values = array( 'container_guid' => '' ); +// fail if a required entity isn't set $required = array('title', 'description'); -foreach ($values as $name => $default) { - $values[$name] = get_input($name, $default); -} - - // load from POST and do sanity and access checking foreach ($values as $name => $default) { $value = get_input($name, $default); @@ -77,17 +78,16 @@ foreach ($values as $name => $default) { break; case 'excerpt': - // restrict to 300 chars if ($value) { - $value = substr(strip_tags($value), 0, 300); + $value = blog_make_excerpt($value); } else { - $value = substr(strip_tags($values['description']), 0, 300); + $value = blog_make_excerpt($values['description']); } $values[$name] = $value; break; case 'container_guid': - // this can't be empty. + // this can't be empty or saving the base entity fails if (!empty($value)) { if (can_write_to_container($user->getGUID(), $value)) { $values[$name] = $value; @@ -99,6 +99,13 @@ foreach ($values as $name => $default) { } break; + case 'publish_date': + if (empty($value)) { + $value = time(); + } + $values[$name] = $value; + break; + // don't try to set the guid case 'guid': unset($values['guid']); @@ -113,170 +120,44 @@ foreach ($values as $name => $default) { // assign values to the entity, stopping on error. if (!$error) { foreach ($values as $name => $value) { - if (!$blog->$name = $value) { - $error = elgg_echo('blog:error:cannot_save1' . $name); + if (FALSE === ($blog->$name = $value)) { + $error = elgg_echo('blog:error:cannot_save' . "$name=$value"); break; } } } // only try to save base entity if no errors -if (!$error && !$blog->save()) { - $error = elgg_echo('blog:error:cannot_save'); -} - -// forward with success or failure -if ($ajax) { - if ($error) { - $json = array('success' => FALSE, 'message' => $error); - echo json_encode($json); - } else { - $msg = elgg_echo('blog:message:saved'); - $json = array('success' => TRUE, 'message' => $msg, 'guid' => $blog->getGUID()); - echo json_encode($json); - } -} else { - if ($error) { - register_error($error); - forward($error_forward_url); - } else { - system_message(elgg_echo('blog:message:saved')); - forward($success_forward_url); - } -} - - - -/* - * This might have been a good idea. - * It's not. +if (!$error) { + if ($blog->save()) { + // remove sticky form entries + elgg_clear_sticky_form(); -// edit or create a new entity -$guid = get_input('guid'); -$user = get_loggedin_user(); -$ajax = get_input('ajax', FALSE); + // remove autosave draft if exists + $blog->clearAnnotations('blog_auto_save'); -// store errors to pass along -$error = FALSE; -$error_forward_url = $_SERVER['HTTP_REFERER']; + // if this was an edit, create a revision + if (!$new_post && $revision_value) { + // create a revision annotation + $blog->annotate('blog_revision', $revision_value); + } -if ($guid) { - $entity = get_entity($guid); - if (elgg_instanceof($entity, 'object', 'blog') && $entity->canEdit()) { - $blog = $entity; + system_message(elgg_echo('blog:message:saved')); + forward($success_forward_url); } else { - register_error(elgg_echo('blog:error:post_not_found')); - forward(get_input('forward', $_SERVER['HTTP_REFERER'])); - } - $success_forward_url = get_input('forward', $blog->getURL()); -} else { - $blog = new ElggObject(); - $blog->subtype = 'blog'; - $success_forward_url = get_input('forward'); -} - -// set defaults and required values. -$values = array( - 'title' => '', - 'description' => '', - 'access_id' => ACCESS_DEFAULT, - 'comments_on' => 'On', - 'excerpt' => '', - 'tags' => '', - 'container_guid' => '' -); - -$required = array('title', 'description'); - -foreach ($values as $name => $default) { - $values[$name] = get_input($name, $default); -} - - -// load from POST and do sanity and access checking -foreach ($values as $name => $default) { - - if ($error) { - break; - } - - $value = get_input($name, $default); - - if (in_array($name, $required) && empty($value)) { - register_error(elgg_echo("blog:error:missing:$name")); + register_error(elgg_echo('blog:error:cannot_save')); forward($error_forward_url); } - - switch ($name) { - case 'tags': - $values[$name] = string_to_tag_array($value); - break; - - case 'excerpt': - // restrict to 300 chars - if ($value) { - $value = substr(strip_tags($value), 0, 300); - } else { - $value = substr(strip_tags($values['description']), 0, 300); - } - $values[$name] = $value; - break; - - case 'container_guid': - // this can't be empty. - if (!empty($value)) { - if (can_write_to_container($user->getGUID(), $value)) { - $values[$name] = $value; - } else { - $error = elgg_echo("blog:error:cannot_write_to_container"); - } - } else { - unset($values[$name]); - } - break; - - // don't try to set the guid - case 'guid': - unset($values['guid']); - break; - - default: - $values[$name] = $value; - break; - } -} - -// assign values to the entity, stopping on error. -foreach ($values as $name => $value) { - if (!$blog->$name = $value) { - $error = elgg_echo('blog:error:cannot_save'); - break; - } -} - -// only try to save base entity if no errors -if (!$error && !$blog->save()) { - $error = elgg_echo('blog:error:cannot_save'); -} - -// forward or return ajax data. -if ($ajax) { - if ($error) { - $json = array('success' => FALSE, 'message' => $error); - echo json_encode($json); - } else { - $msg = elgg_echo('blog:message:saved'); - $json = array('success' => TRUE, 'message' => $msg); - echo json_encode($json); - } } else { - if ($error) { - register_error($error); - forward($error_forward_url); - } else { - system_message(elgg_echo('blog:message:saved')); - forward($success_forward_url); - } + register_error($error); + forward($error_forward_url); } -*/ \ No newline at end of file +// forward with success or failure +if ($error) { + register_error($error); + forward($error_forward_url); +} else { + system_message(elgg_echo('blog:message:saved')); + forward($success_forward_url); +} \ No newline at end of file diff --git a/mod/blog/actions/blog/save_draft.php b/mod/blog/actions/blog/save_draft.php deleted file mode 100644 index 64a79c667..000000000 --- a/mod/blog/actions/blog/save_draft.php +++ /dev/null @@ -1,146 +0,0 @@ -canEdit()) { - $blog = $entity; - } else { - register_error(elgg_echo('blog:error:post_not_found')); - forward(get_input('forward', $_SERVER['HTTP_REFERER'])); - } - $success_forward_url = get_input('forward', $blog->getURL()); -} else { - $blog = new ElggObject(); - $blog->subtype = 'blog'; - $success_forward_url = get_input('forward'); -} - -// set defaults and required values. -$values = array( - 'title' => '', - 'description' => '', - 'status' => 'draft', - //'publish_date' => '', - 'access_id' => ACCESS_DEFAULT, - 'comments_on' => 'On', - 'excerpt' => '', - 'tags' => '', - 'container_guid' => '' -); - -$required = array('title', 'description'); - -foreach ($values as $name => $default) { - $values[$name] = get_input($name, $default); -} - - -// load from POST and do sanity and access checking -foreach ($values as $name => $default) { - $value = get_input($name, $default); - - if (in_array($name, $required) && empty($value)) { - $error = elgg_echo("blog:error:missing:$name"); - } - - if ($error) { - break; - } - - switch ($name) { - case 'tags': - if ($value) { - $values[$name] = string_to_tag_array($value); - } else { - unset ($values[$name]); - } - break; - - case 'excerpt': - // restrict to 300 chars - if ($value) { - $value = substr(strip_tags($value), 0, 300); - } else { - $value = substr(strip_tags($values['description']), 0, 300); - } - $values[$name] = $value; - break; - - case 'container_guid': - // this can't be empty. - if (!empty($value)) { - if (can_write_to_container($user->getGUID(), $value)) { - $values[$name] = $value; - } else { - $error = elgg_echo("blog:error:cannot_write_to_container"); - } - } else { - unset($values[$name]); - } - break; - - // don't try to set the guid - case 'guid': - unset($values['guid']); - break; - - default: - $values[$name] = $value; - break; - } -} - -// assign values to the entity, stopping on error. -if (!$error) { - foreach ($values as $name => $value) { - if (!$blog->$name = $value) { - $error = elgg_echo('blog:error:cannot_save'); - break; - } - } -} - -// only try to save base entity if no errors -if (!$error && !$blog->save()) { - $error = elgg_echo('blog:error:cannot_save'); -} - -// forward with success or failure -if ($ajax) { - if ($error) { - $json = array('success' => FALSE, 'message' => $error); - echo json_encode($json); - } else { - $msg = elgg_echo('blog:message:saved'); - $json = array('success' => TRUE, 'message' => $msg, 'guid' => $blog->getGUID()); - echo json_encode($json); - } -} else { - if ($error) { - register_error($error); - forward($error_forward_url); - } else { - system_message(elgg_echo('blog:message:saved')); - forward($success_forward_url); - } -} \ No newline at end of file diff --git a/mod/blog/blog_lib.php b/mod/blog/blog_lib.php index 0fe1b80d4..993728dcc 100644 --- a/mod/blog/blog_lib.php +++ b/mod/blog/blog_lib.php @@ -16,54 +16,85 @@ * @param int $guid of a blog entity. * @return string html */ -function blog_get_page_content_read($owner_guid, $guid) { +function blog_get_page_content_read($owner_guid = NULL, $guid = NULL) { + $content = elgg_view('page_elements/content_header', array('context' => $context, 'type' => 'blog')); + if ($guid) { $blog = get_entity($guid); if (!elgg_instanceof($blog, 'object', 'blog') && $blog->status == 'final') { - $content = elgg_echo('blog:error:post_not_found'); + $content .= elgg_echo('blog:error:post_not_found'); } else { elgg_push_breadcrumb($blog->title, $blog->getURL()); - $content = elgg_view_entity($blog, TRUE); + $content .= elgg_view_entity($blog, TRUE); } } else { - $content = elgg_list_entities_from_metadata(array( + $options = array( 'type' => 'object', 'subtype' => 'blog', - 'owner_guid' => $owner_guid, 'full_view' => FALSE, - 'metadata_name_value_pair' => array('name' => 'status', 'value' => 'final') - )); + 'order_by_metadata' => array('name'=>'publish_date', 'direction'=>'DESC', 'as'=>'int') + ); + + if ($owner_guid) { + $options['owner_guid'] = $owner_guid; + } + + // show all posts for admin or users looking at their own blogs + // show only published posts for other users. + if (!(isadminloggedin() || (isloggedin() && $owner_guid == get_loggedin_userid()))) { + $options['metadata_name_value_pairs'] = array( + array('name' => 'status', 'value' => 'published'), + array('name' => 'publish_date', 'operand' => '<', 'value' => time()) + ); + } + + $content .= elgg_list_entities_from_metadata($options); } - return $content; + return array('content' => $content); } /** * Returns HTML to edit a blog post. * * @param int $guid + * @param int annotation id optional revision to edit * @return string html */ -function blog_get_page_content_edit($guid) { +function blog_get_page_content_edit($guid, $revision = NULL) { $vars = array(); if ($guid) { - $blog = get_entity($guid); - $vars['entity'] = $blog; + $blog = get_entity((int)$guid); + + if (elgg_instanceof($blog, 'object', 'blog') && $blog->canEdit()) { + $vars['entity'] = $blog; + + if ($revision) { + $revision = get_annotation((int)$revision); + $vars['revision'] = $revision; + + if (!$revision || !($revision->entity_guid == $guid)) { + $content = elgg_echo('blog:error:revision_not_found'); + } + } + + elgg_push_breadcrumb($blog->title, $blog->getURL()); + elgg_push_breadcrumb(elgg_echo('edit')); - if (!elgg_instanceof($blog, 'object', 'blog') || !$blog->canEdit()) { + $content = elgg_view('blog/forms/edit', $vars); + $sidebar = elgg_view('blog/sidebar_revisions', array('entity' => $blog)); + //$sidebar .= elgg_view('blog/sidebar_related'); + } else { $content = elgg_echo('blog:error:post_not_found'); } - - elgg_push_breadcrumb($blog->title, $blog->getURL()); - elgg_push_breadcrumb(elgg_echo('edit')); } else { elgg_push_breadcrumb(elgg_echo('blog:new')); + $content = elgg_view('blog/forms/edit', $vars); + //$sidebar = elgg_view('blog/sidebar_related'); } - $content = elgg_view('blog/forms/edit', $vars); - - return $content; + return array('content' => $content, 'sidebar' => $sidebar); } /** @@ -175,7 +206,12 @@ function blog_save_blog($info) { return $return; } - -class ElggBlog extends ElggObject { - +/** + * Returns an appropriate excerpt for a blog. + * + * @param string $text + * @return string + */ +function blog_make_excerpt($text) { + return substr(strip_tags($text), 0, 300); } \ No newline at end of file diff --git a/mod/blog/languages/en.php b/mod/blog/languages/en.php index e8db1716e..4d448856e 100644 --- a/mod/blog/languages/en.php +++ b/mod/blog/languages/en.php @@ -6,6 +6,9 @@ $english = array( 'item:object:blog' => 'Blog', + 'blog:blogs' => 'Blogs', + 'blog:owned_blogs' => '%s blogs', + 'blog:revisions' => 'Revisions', 'blog:blog' => 'Blog', 'blog:yours' => 'Your blog', @@ -27,11 +30,15 @@ $english = array( 'blog:status:published' => 'Published', 'blog:revision' => 'Revision', + 'blog:auto_saved_revision' => 'Auto Saved Revision', // messages 'blog:message:saved' => 'Blog post saved.', 'blog:error:cannot_save' => 'Cannot save blog post.', 'blog:error:cannot_write_to_container' => 'Insufficient access to save blog to group.', + 'blog:messages:warning:draft' => 'There is an unsaved draft of this post!', + 'blog:edit_revision_notice' => '(Old version)', + ); add_translation('en', $english); \ No newline at end of file diff --git a/mod/blog/start.php b/mod/blog/start.php index b3a8e32ee..bf0d3fb56 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -39,7 +39,6 @@ function blog_init() { elgg_extend_view('css', 'blog/css'); register_page_handler('blog', 'blog_page_handler'); - register_page_handler('blog_ajax', 'blog_ajax_page_handler'); register_entity_url_handler('blog_url_handler', 'object', 'blog'); @@ -60,6 +59,7 @@ function blog_init() { $action_path = dirname(__FILE__) . '/actions/blog'; register_action('blog/save', FALSE, "$action_path/save.php"); + register_action('blog/auto_save_revision', FALSE, "$action_path/auto_save_revision.php"); register_action('blog/delete', FALSE, "$action_path/delete.php"); } @@ -111,13 +111,13 @@ function blog_page_handler($page) { switch ($action) { case 'read': $title = sprintf(elgg_echo('blog:title:user_blogs'), $user->name); - $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog')); - $content .= blog_get_page_content_read($user->getGUID(), $page2); + $content_info = blog_get_page_content_read($user->getGUID(), $page2); break; case 'new': case 'edit': - $content = blog_get_page_content_edit($page2); + //$sidebar = elgg_view('blog/sidebar_edit', array('blog_guid' => $page2)); + $content_info = blog_get_page_content_edit($page2, $page3); break; case 'archives': @@ -136,69 +136,20 @@ function blog_page_handler($page) { } } else { $title = elgg_echo('blog:title:all_blogs'); - $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog')); - $content .= elgg_list_entities_from_metadata(array( - 'type' => 'object', - 'subtype' => 'blog', - 'full_view' => FALSE, - 'metadata_name_value_pair' => array('name' => 'status', 'value' => 'final') - )); + $content_info = blog_get_page_content_read(); } - $sidebar = elgg_view('blog/sidebar_menu'); - $content = elgg_view('navigation/breadcrumbs') . $content; + $sidebar .= elgg_view('blog/sidebar_menu'); + if (isset($content_info['sidebar'])) { + $sidebar .= $content_info['sidebar']; + } + $content = elgg_view('navigation/breadcrumbs') . $content_info['content']; $body = elgg_view_layout('one_column_with_sidebar', $content, $sidebar); page_draw($title, $body); } -/** - * Handles ajax calls for blog. - * - * @param array $page - */ -function blog_ajax_page_handler($page) { - $action = isset($page[0]) ? $page[0] : FALSE; - - var_dump($page); - - switch ($action) { - case 'save_draft': - // @todo recycle the save action - $values = array( - 'title' => '', - 'description' => '', - 'status' => 'draft', - 'access_id' => ACCESS_DEFAULT, - 'comments_on' => 'On', - 'excerpt' => '', - 'tags' => '', - 'container_guid' => '', - 'guid' => '' - ); - - foreach ($values as $name => $default) { - $values[$name] = get_input($name, $default); - } - - - - /* - If a title and body, create a blog post marked as a draft and update the - GUID - */ - break; - - default: - $content = 0; - break; - } - - exit; -} - - /** * Format and return the correct URL for blogs. * @@ -220,4 +171,4 @@ function blog_url_handler($entity) { } -register_elgg_event_handler('init', 'system', 'blog_init'); \ No newline at end of file +register_elgg_event_handler('init', 'system', 'blog_init'); 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'); + ?>