diff options
author | cash <cash.costello@gmail.com> | 2011-06-18 16:24:52 -0400 |
---|---|---|
committer | cash <cash.costello@gmail.com> | 2011-06-18 16:24:52 -0400 |
commit | 2b68a4d217c35a5587c462620789493cf2804ba2 (patch) | |
tree | a108205c3fa0b694d8ce0ebaafd259480d6b530a | |
parent | e6fd398eb26a9974c3f4be39d3148f6bb36e2b0e (diff) | |
download | elgg-2b68a4d217c35a5587c462620789493cf2804ba2.tar.gz elgg-2b68a4d217c35a5587c462620789493cf2804ba2.tar.bz2 |
Fixes #3580 adding blog preview button that uses save action
-rw-r--r-- | mod/blog/actions/blog/save.php | 10 | ||||
-rw-r--r-- | mod/blog/views/default/forms/blog/save.php | 19 |
2 files changed, 26 insertions, 3 deletions
diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 0720d6163..8be67ec6c 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -8,6 +8,9 @@ // start a new sticky form session in case of failure elgg_make_sticky_form('blog'); +// save or preview +$save = (bool)get_input('save'); + // store errors to pass along $error = FALSE; $error_forward_url = REFERER; @@ -106,6 +109,11 @@ foreach ($values as $name => $default) { } } +// if preview, force status to be draft +if ($save == false) { + $values['status'] = 'draft'; +} + // assign values to the entity, stopping on error. if (!$error) { foreach ($values as $name => $value) { @@ -154,7 +162,7 @@ if (!$error) { )); } - if ($blog->status == 'published') { + if ($blog->status == 'published' || $save == false) { forward($blog->getURL()); } else { forward("blog/edit/$blog->guid"); diff --git a/mod/blog/views/default/forms/blog/save.php b/mod/blog/views/default/forms/blog/save.php index 5b3a758ba..d99f45f01 100644 --- a/mod/blog/views/default/forms/blog/save.php +++ b/mod/blog/views/default/forms/blog/save.php @@ -5,6 +5,8 @@ * @package Blog */ +$blog = get_entity($vars['guid']); + $draft_warning = $vars['draft_warning']; if ($draft_warning) { $draft_warning = '<span class="message warning">' . $draft_warning . '</span>'; @@ -12,6 +14,7 @@ if ($draft_warning) { $action_buttons = ''; $delete_link = ''; +$preview_button = ''; if ($vars['guid']) { // add a delete button if editing @@ -23,8 +26,20 @@ if ($vars['guid']) { )); } -$save_button = elgg_view('input/submit', array('value' => elgg_echo('save'))); -$action_buttons = $save_button . $delete_link; +// published blogs do not get the preview button +if (!$vars['guid'] || ($blog && $blog->status != 'published')) { + $preview_button = elgg_view('input/submit', array( + 'value' => elgg_echo('preview'), + 'name' => 'preview', + 'class' => 'mls', + )); +} + +$save_button = elgg_view('input/submit', array( + 'value' => elgg_echo('save'), + 'name' => 'save', +)); +$action_buttons = $save_button . $preview_button . $delete_link; $title_label = elgg_echo('title'); $title_input = elgg_view('input/text', array( |