From 36abf69637671a1cf65101212596118d155ef54a Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 12 Mar 2010 02:12:47 +0000 Subject: Rough first version of a new blog plugin. git-svn-id: http://code.elgg.org/elgg/trunk@5370 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/blog/views/default/blog/forms/edit.php | 489 +++++++++++++++-------------- 1 file changed, 252 insertions(+), 237 deletions(-) (limited to 'mod/blog/views/default/blog/forms/edit.php') diff --git a/mod/blog/views/default/blog/forms/edit.php b/mod/blog/views/default/blog/forms/edit.php index 28a0980a4..3c9912daa 100644 --- a/mod/blog/views/default/blog/forms/edit.php +++ b/mod/blog/views/default/blog/forms/edit.php @@ -1,257 +1,272 @@ - title); - $action = "blog/edit"; - $title = $vars['entity']->title; - $body = $vars['entity']->description; - $tags = $vars['entity']->tags; - if ($vars['entity']->comments_on == 'Off') - $comments_on = false; - else - $comments_on = true; - $access_id = $vars['entity']->access_id; - $show_excerpt = $vars['entity']->show_excerpt; - if($show_excerpt) - $excerpt = $vars['entity']->excerpt; - else - $excerpt = ""; - $page_title = elgg_view_title(elgg_echo('blog:editpost')); -}else{ - $title = elgg_echo("blog:addpost"); - $action = "blog/add"; - $tags = ""; - $title = ""; - $comments_on = true; - $description = ""; - $excerpt = ""; - $show_excerpt = ''; - $page_title = elgg_view_title(elgg_echo('blog:addpost')); - if(page_owner_entity() instanceof ElggGroup){ - //if in a group, set the access level to default to the group - $access_id = page_owner_entity()->group_acl; - }else{ - $access_id = $loggedin_user_access; - } - $container = $vars['container_guid'] ? elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $vars['container_guid'])) : ""; -} + * Edit blog form + * + * @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/ + */ + +$values = array( + 'title' => NULL, + 'description' => NULL, + 'status' => 'final', + //'publish_date' => NULL, + 'access_id' => ACCESS_DEFAULT, + 'comments_on' => 'On', + 'excerpt' => NULL, + 'tags' => NULL, + 'container_guid' => NULL, + 'guid' => NULL +); + +$forward = $_SERVER['HTTP_REFERER']; + +$action_buttons = ''; +$guid_input = ''; -//Just in case we have some cached details -if (empty($body)) { - $body = $vars['user']->blogbody; - if (!empty($body)) { - $title = $vars['user']->blogtitle; - $tags = $vars['user']->blogtags; +// 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; + } + } else { + echo elgg_echo('blog:error:post_not_found'); + return FALSE; } + + // add a delete button if editing + $delete_url = "{$vars['url']}action/blog/delete?guid={$blog->getGUID()}"; + $delete_link = elgg_view('output/confirmlink', array( + 'href' => $delete_url, + 'text' => elgg_echo('delete'), + 'class' => 'action_button' + )); + + $action_buttons = $delete_link; + + $guid_input = elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $values['guid'])); } -//set the required input fields -$title_label = elgg_echo('blog:title'); -$title_textbox = elgg_view('input/text', array('internalname' => 'blogtitle', 'value' => $title)); -$text_label = elgg_echo('blog:text'); -$text_textarea = elgg_view('input/longtext', array('internalname' => 'blogbody', 'value' => $body)); +$save_button = elgg_view('input/submit', array('value' => elgg_echo('save'), 'class' => 'action_button')); +$action_buttons .= $save_button; + +$title_label = elgg_echo('title'); +$title_input = elgg_view('input/text', array( + 'internalname' => 'title', + 'internalid' => 'blog_title', + 'value' => $values['title'] +)); + $excerpt_label = elgg_echo('blog:excerpt'); -$excerpt_counter = "
"; -$excerpt_textarea = elgg_view('input/text', array('internalname' => 'blogexcerpt', 'internalid' => 'excerpt', 'class' => 'excerpt input_textarea', 'value' => $excerpt)); -$excerpt_desc = elgg_echo('blog:excerptdesc'); -$show_excerpt_field = elgg_view('input/hidden', array('internalname' => 'show_excerpt', 'value' => $show_excerpt)); -$tag_label = elgg_echo('tags'); -$tag_input = elgg_view('input/tags', array('internalname' => 'blogtags', 'value' => $tags)); +$excerpt_input = elgg_view('input/text', array( + 'internalname' => 'excerpt', + 'internalid' => 'blog_excerpt', + 'value' => $values['excerpt'] +)); + +$body_label = elgg_echo('blog:body'); +$body_input = elgg_view('input/longtext', array( + 'internalname' => 'description', + 'internalid' => 'blog_description', + 'value' => $values['description'] +)); + +$save_status = elgg_echo('blog:save_status'); +$never = elgg_echo('never'); + +$status_label = elgg_echo('blog:status'); +$status_input = elgg_view('input/pulldown', array( + 'internalname' => 'status', + 'internalid' => 'blog_status', + 'value' => $values['status'], + 'options_values' => array( + 'draft' => elgg_echo('blog:draft'), + 'final' => elgg_echo('blog:final') + ) +)); + +$comments_label = elgg_echo('comments'); +$comments_input = elgg_view('input/pulldown', array( + 'internalname' => 'comments_on', + 'internalid' => 'blog_comments_on', + 'value' => $values['comments_on'], + 'options_values' => array('On' => elgg_echo('on'), 'Off' => elgg_echo('off')) +)); + +$tags_label = elgg_echo('tags'); +$tags_input = elgg_view('input/tags', array( + 'internalname' => 'tags', + 'internalid' => 'blog_tags', + 'value' => $values['tags'] +)); + $access_label = elgg_echo('access'); -if($comments_on) - $comments_on_switch = "checked=\"checked\""; -else - $comment_on_switch = ""; -//if it is a group, pull out the group access view -if(page_owner_entity() instanceof ElggGroup){ - $options = group_access_options(page_owner_entity()); -}else{ - $options = ''; -} -$access_input = elgg_view('input/access', array('internalname' => 'access_id', 'value' => $access_id, 'options' => $options)); -$submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('publish'))); -$conversation = elgg_echo('Conversation'); -$publish = elgg_echo('publish'); -$cat = elgg_echo('categories'); -$preview = elgg_echo('blog:preview'); -$privacy = elgg_echo('access'); -$savedraft = elgg_echo('blog:draft:save'); -$draftsaved = elgg_echo('blog:draft:saved'); -$never = elgg_echo('blog:never'); -$allowcomments = elgg_echo('blog:comments:allow'); -$user_default_access = elgg_echo('blog:defaultaccess'); -$ownerblock = elgg_view('blog/ownerblock', array('entity' => $vars['entity'])); -if($vars['entity']){ - $deletepage = elgg_view('output/confirmlink',array( - 'href' => $vars['url'] . "action/blog/delete?blogpost=" . $vars['entity']->getGUID(), - 'text' => elgg_echo("delete"), - 'confirm' => elgg_echo("blog:delete:confirm"), - 'class' => "Action_Button Disabled")); -}else{ - $deletepage = ""; -} +$access_input = elgg_view('input/access', array( + 'internalname' => 'access_id', + 'internalid' => 'blog_access_id', + 'value' => $values['access_id'] +)); -//INSERT EXTRAS HERE -$extras = elgg_view('categories',$vars); -if (!empty($extras)) $extras = '
' .$cat .'
'. $extras . '
'; - -?> +$publish_date_label = elgg_echo('blog:publish_date'); +$publish_date_input = elgg_view('input/datepicker', array( + 'internalname' => 'publish_date', + 'internalid' => 'blog_publish_date', + 'value' => $vars['publish_date'] +)); + +// hidden inputs +//$container_guid_input = elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $values['container_guid'])); +$forward_input = elgg_view('input/hidden', array('internalname' => 'forward', 'value' => $forward)); + +$form_body = <<<___END +

+ + $title_input +

+ +

+ +$excerpt_input +

+ +

+ + $body_input +

+ +

+ $save_status:$never +

+ +

+ + $publish_date_input +

+ + +

+ + $tags_input +

+ +

+ + $comments_input +

+ +

+ + $access_input +

+ + + +

+ + $status_input +

+ +$guid_input +$container_guid_input +$forward_input + +$action_buttons + + + +___END; + +echo elgg_view('input/form', array( + 'internalname' => 'blog_post', + 'action' => "{$vars['url']}action/blog/save", + 'body' => $form_body +)); - - {$ownerblock} -
-

{$publish}

- -
- -
-

{$privacy}: {$access_input}

-
-
{$user_default_access}
{$user_acl}
-
- -
-
- -
-
- -
- -
-
- {$draftsaved}: {$never} - {$savedraft} -
- - {$submit_input} -
-
-
- - {$extras} - {$container} - - - -
- - - - - - - -
-EOT; - -if (isset($vars['entity'])) - $entity_hidden = elgg_view('input/hidden', array('internalname' => 'blogpost', 'value' => $vars['entity']->getGUID())); -else - $entity_hidden = ''; - -$form_body .= <<
$title_textbox

-

- $text_textarea -

-
-
$excerpt_desc $excerpt_counter
- $excerpt_textarea -
-


$tag_input

-

$entity_hidden

- $show_excerpt_field -
-
-
-EOT; - -//display the form -echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body, 'internalid' => 'blogPostForm')); ?> + + $(document).ready(function(){ + $('#excerpt.excerpt').each(function(){ + var allowed = 200; + + // set the initial value + $('#countervalue').text(allowed); + + // bind on key up event + $(this).keyup(function(){ + var counter_value = ((allowed - ($(this).val().length))); + + $("#countervalue").removeClass(); + + if ((counter_value > 10)) { + $("#countervalue").addClass("positive"); + } + else if ((counter_value <= 10) && (counter_value >= 0)) { + $("#countervalue").addClass("gettingclose"); + } + else if ((counter_value < 0)) { + $("#countervalue").addClass("negative"); + } + + // insert new length + $('#countervalue').text(counter_value); + + }); + }); + }); + + \ No newline at end of file -- cgit v1.2.3