aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/views/default
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-05 21:38:36 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-05 21:38:36 +0000
commit79128c747888ac2f586f6679e1af78b4aa1b711a (patch)
tree5508e5583b9b3a0807be92f69c842a5ff1e48b9d /mod/blog/views/default
parent9f543bb8999de2db20e71f9d5c7e1fdda13f29a8 (diff)
downloadelgg-79128c747888ac2f586f6679e1af78b4aa1b711a.tar.gz
elgg-79128c747888ac2f586f6679e1af78b4aa1b711a.tar.bz2
blog plugin now uses the new elgg_view_form() function
git-svn-id: http://code.elgg.org/elgg/trunk@7540 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/blog/views/default')
-rw-r--r--mod/blog/views/default/blog/forms/edit.php318
-rw-r--r--mod/blog/views/default/forms/blog/save.php157
-rw-r--r--mod/blog/views/default/js/blog/save_draft.php97
3 files changed, 254 insertions, 318 deletions
diff --git a/mod/blog/views/default/blog/forms/edit.php b/mod/blog/views/default/blog/forms/edit.php
deleted file mode 100644
index 8900fed25..000000000
--- a/mod/blog/views/default/blog/forms/edit.php
+++ /dev/null
@@ -1,318 +0,0 @@
-<?php
-/**
- * Edit blog form
- *
- * @package Blog
- */
-
-// input names => defaults
-$values = array(
- 'title' => NULL,
- 'description' => NULL,
- 'status' => 'published',
- '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 = '';
-$delete_link = '';
-$draft_warning = '';
-
-// if entity is set, we're editing.
-if (isset ($vars['entity'])) {
- $blog = $vars['entity'];
-
- if (elgg_instanceof($blog, 'object', 'blog')) {
- // 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 = '<span class="message warning">'
- . elgg_echo('blog:messages:warning:draft')
- . '</span>';
- }
-
- //}
- } else {
- echo elgg_echo('blog:error:post_not_found');
- return FALSE;
- }
-
- // add a delete button if editing
- $delete_url = "action/blog/delete?guid={$blog->getGUID()}";
- $delete_link = elgg_view('output/confirmlink', array(
- 'href' => $delete_url,
- 'text' => elgg_echo('delete'),
- 'class' => 'action-button disabled'
- ));
-}
-
-$save_button = elgg_view('input/submit', array('value' => elgg_echo('save')));
-$action_buttons = $save_button . $delete_link;
-
-$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_input = elgg_view('input/text', array(
- 'internalname' => 'excerpt',
- 'internalid' => 'blog_excerpt',
- 'value' => html_entity_decode($values['excerpt'], ENT_COMPAT, 'UTF-8')
-));
-
-$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');
-if ($values['publish_date']) {
- $saved = date('F j, Y @ H:i', $values['publish_date']);
-} else {
- $saved = elgg_echo('blog: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:status:draft'),
- 'published' => elgg_echo('blog:status:published')
- )
-));
-
-$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');
-$access_input = elgg_view('input/access', array(
- 'internalname' => 'access_id',
- 'internalid' => 'blog_access_id',
- 'value' => $values['access_id']
-));
-
-$publish_date_label = elgg_echo('blog:publish_date');
-$publish_date_input = elgg_view('input/datetime', array(
- 'internalname' => 'publish_date',
- 'internalid' => 'blog_publish_date',
- 'value' => $values['publish_date']
-));
-
-$categories_input = elgg_view('categories', $vars);
-
-// 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));
-
-// editing or creating.
-if (isset($values['guid'])) {
- $page_title = elgg_echo('blog:edit') . ": \"{$values['title']}\"";
-} else {
- $page_title = elgg_echo('blog:new');
-}
-
-// 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
-<h2>$page_title</h2>
-
-$draft_warning
-
-<p class="margin-top">
- <label for="blog_title">$title_label</label>
- $title_input
-</p>
-
-<p>
- <label for="blog_excerpt">$excerpt_label</label>
-$excerpt_input
-</p>
-
-<label for="blog_description">$body_label</label>
-$body_input
-<br />
-
-<p>
- <label for="blog_tags">$tags_label</label>
- $tags_input
-</p>
-
-<p>
- <label for="blog_comments_on">$comments_label</label>
- $comments_input
-</p>
-
-<p>
- <label for="blog_access_id">$access_label</label>
- $access_input
-</p>
-
-<p>
- <label for="blog_status">$status_label</label>
- $status_input
-</p>
-
-$categories_input
-
-<div class="divider"></div>
-<p class="margin-none margin-top entity-subtext">
- $save_status <span class="blog-save-status-time">$saved</span>
-</p>
-
-$guid_input
-$container_guid_input
-$forward_input
-
-$action_buttons
-
-___END;
-
-echo elgg_view('input/form', array(
- 'internalid' => 'blog-post-edit',
- 'internalname' => 'blog_post',
- 'action' => "action/blog/save",
- 'body' => $form_body
-));
-
-elgg_clear_sticky_form('blog');
-
-?>
-
-<script type="text/javascript">
- setInterval("blogSaveDraft()", 60000);
-
- /*
- * Attempt to save and update the input with the guid.
- */
- function blogSaveDraftCallback(data, textStatus, XHR) {
- if (textStatus == 'success' && data.success == true) {
- var form = $('form[name=blog_post]');
-
- // update the guid input element for new posts that now have a guid
- form.find('input[name=guid]').val(data.guid);
-
- oldDescription = form.find('textarea[name=description]').val();
-
- var d = new Date();
- var mins = d.getMinutes() + '';
- if (mins.length == 1) {
- mins = '0' + mins;
- }
- $(".blog-save-status-time").html(d.toLocaleDateString() + " @ " + d.getHours() + ":" + mins);
- } else {
- $(".blog-save-status-time").html("<?php echo elgg_echo('error'); ?>");
- }
- }
-
- function blogSaveDraft() {
- if (typeof(tinyMCE) != 'undefined') {
- tinyMCE.triggerSave();
- }
-
- // only save on changed content
- var form = $('form[name=blog_post]');
- var description = form.find('textarea[name=description]').val();
- var title = form.find('input[name=title]').val();
-
- if (!(description && title) || (description == oldDescription)) {
- return false;
- }
-
- var draftURL = "<?php echo elgg_get_site_url(); ?>action/blog/auto_save_revision";
- var postData = form.serializeArray();
-
- // force draft status
- $(postData).each(function(i, e) {
- if (e.name == 'status') {
- e.value = 'draft';
- }
- });
-
- $.post(draftURL, postData, blogSaveDraftCallback, 'json');
- }
-
- $(document).ready(function() {
- // get a copy of the body to compare for auto save
- oldDescription = $('form[name=blog_post]').find('textarea[name=description]').val();
-
-/* we don't seems to be using the text counter anymore�
- $('#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);
-
- });
- });
-*/
- });
-
-</script> \ No newline at end of file
diff --git a/mod/blog/views/default/forms/blog/save.php b/mod/blog/views/default/forms/blog/save.php
new file mode 100644
index 000000000..022473e9d
--- /dev/null
+++ b/mod/blog/views/default/forms/blog/save.php
@@ -0,0 +1,157 @@
+<?php
+/**
+ * Edit blog form
+ *
+ * @package Blog
+ */
+
+$forward = $_SERVER['HTTP_REFERER'];
+
+$draft_warning = $vars['draft_warning'];
+if ($draft_warning) {
+ $draft_warning = '<span class="message warning">' . $draft_warning . '</span>';
+}
+
+$action_buttons = '';
+$delete_link = '';
+
+if ($vars['guid']) {
+ // add a delete button if editing
+ $delete_url = "action/blog/delete?guid={$vars['guid']}";
+ $delete_link = elgg_view('output/confirmlink', array(
+ 'href' => $delete_url,
+ 'text' => elgg_echo('delete'),
+ 'class' => 'action-button disabled'
+ ));
+}
+
+$save_button = elgg_view('input/submit', array('value' => elgg_echo('save')));
+$action_buttons = $save_button . $delete_link;
+
+$title_label = elgg_echo('title');
+$title_input = elgg_view('input/text', array(
+ 'internalname' => 'title',
+ 'internalid' => 'blog_title',
+ 'value' => $vars['title']
+));
+
+$excerpt_label = elgg_echo('blog:excerpt');
+$excerpt_input = elgg_view('input/text', array(
+ 'internalname' => 'excerpt',
+ 'internalid' => 'blog_excerpt',
+ 'value' => html_entity_decode($vars['excerpt'], ENT_COMPAT, 'UTF-8')
+));
+
+$body_label = elgg_echo('blog:body');
+$body_input = elgg_view('input/longtext', array(
+ 'internalname' => 'description',
+ 'internalid' => 'blog_description',
+ 'value' => $vars['description']
+));
+
+$save_status = elgg_echo('blog:save_status');
+if ($vars['publish_date']) {
+ $saved = date('F j, Y @ H:i', $vars['publish_date']);
+} else {
+ $saved = elgg_echo('blog:never');
+}
+
+$status_label = elgg_echo('blog:status');
+$status_input = elgg_view('input/pulldown', array(
+ 'internalname' => 'status',
+ 'internalid' => 'blog_status',
+ 'value' => $vars['status'],
+ 'options_values' => array(
+ 'draft' => elgg_echo('blog:status:draft'),
+ 'published' => elgg_echo('blog:status:published')
+ )
+));
+
+$comments_label = elgg_echo('comments');
+$comments_input = elgg_view('input/pulldown', array(
+ 'internalname' => 'comments_on',
+ 'internalid' => 'blog_comments_on',
+ 'value' => $vars['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' => $vars['tags']
+));
+
+$access_label = elgg_echo('access');
+$access_input = elgg_view('input/access', array(
+ 'internalname' => 'access_id',
+ 'internalid' => 'blog_access_id',
+ 'value' => $vars['access_id']
+));
+
+$publish_date_label = elgg_echo('blog:publish_date');
+$publish_date_input = elgg_view('input/datetime', array(
+ 'internalname' => 'publish_date',
+ 'internalid' => 'blog_publish_date',
+ 'value' => $vars['publish_date']
+));
+
+$categories_input = elgg_view('categories', $vars);
+
+// hidden inputs
+//$container_guid_input = elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $vars['container_guid']));
+$guid_input = elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $vars['guid']));
+$forward_input = elgg_view('input/hidden', array('internalname' => 'forward', 'value' => $forward));
+
+
+echo <<<___HTML
+
+$draft_warning
+
+<p class="mtm">
+ <label for="blog_title">$title_label</label>
+ $title_input
+</p>
+
+<p>
+ <label for="blog_excerpt">$excerpt_label</label>
+ $excerpt_input
+</p>
+
+<label for="blog_description">$body_label</label>
+$body_input
+<br />
+
+<p>
+ <label for="blog_tags">$tags_label</label>
+ $tags_input
+</p>
+
+<p>
+ <label for="blog_comments_on">$comments_label</label>
+ $comments_input
+</p>
+
+<p>
+ <label for="blog_access_id">$access_label</label>
+ $access_input
+</p>
+
+<p>
+ <label for="blog_status">$status_label</label>
+ $status_input
+</p>
+
+$categories_input
+
+<p class="ptm pbm mbn entity-subtext elgg_hrt">
+ $save_status <span class="blog-save-status-time">$saved</span>
+</p>
+
+$guid_input
+$container_guid_input
+$forward_input
+
+$action_buttons
+
+___HTML;
diff --git a/mod/blog/views/default/js/blog/save_draft.php b/mod/blog/views/default/js/blog/save_draft.php
new file mode 100644
index 000000000..177ecc1df
--- /dev/null
+++ b/mod/blog/views/default/js/blog/save_draft.php
@@ -0,0 +1,97 @@
+<?php
+/**
+ * Save draft through ajax
+ *
+ * @package Blog
+ */
+?>
+
+<script type="text/javascript">
+ setInterval("blogSaveDraft()", 60000);
+
+ /*
+ * Attempt to save and update the input with the guid.
+ */
+ function blogSaveDraftCallback(data, textStatus, XHR) {
+ if (textStatus == 'success' && data.success == true) {
+ var form = $('form[name=blog_post]');
+
+ // update the guid input element for new posts that now have a guid
+ form.find('input[name=guid]').val(data.guid);
+
+ oldDescription = form.find('textarea[name=description]').val();
+
+ var d = new Date();
+ var mins = d.getMinutes() + '';
+ if (mins.length == 1) {
+ mins = '0' + mins;
+ }
+ $(".blog-save-status-time").html(d.toLocaleDateString() + " @ " + d.getHours() + ":" + mins);
+ } else {
+ $(".blog-save-status-time").html("<?php echo elgg_echo('error'); ?>");
+ }
+ }
+
+ function blogSaveDraft() {
+ if (typeof(tinyMCE) != 'undefined') {
+ tinyMCE.triggerSave();
+ }
+
+ // only save on changed content
+ var form = $('form[name=blog_post]');
+ var description = form.find('textarea[name=description]').val();
+ var title = form.find('input[name=title]').val();
+
+ if (!(description && title) || (description == oldDescription)) {
+ return false;
+ }
+
+ var draftURL = "<?php echo elgg_get_site_url(); ?>action/blog/auto_save_revision";
+ var postData = form.serializeArray();
+
+ // force draft status
+ $(postData).each(function(i, e) {
+ if (e.name == 'status') {
+ e.value = 'draft';
+ }
+ });
+
+ $.post(draftURL, postData, blogSaveDraftCallback, 'json');
+ }
+
+ $(document).ready(function() {
+ // get a copy of the body to compare for auto save
+ oldDescription = $('form[name=blog_post]').find('textarea[name=description]').val();
+
+/* we don't seems to be using the text counter anymore�
+ $('#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);
+
+ });
+ });
+*/
+ });
+
+</script>