aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/views
diff options
context:
space:
mode:
Diffstat (limited to 'mod/blog/views')
-rw-r--r--mod/blog/views/default/blog/css.php14
-rw-r--r--mod/blog/views/default/blog/group_module.php46
-rw-r--r--mod/blog/views/default/blog/sidebar.php30
-rw-r--r--mod/blog/views/default/blog/sidebar/archives.php37
-rw-r--r--mod/blog/views/default/blog/sidebar/revisions.php79
-rw-r--r--mod/blog/views/default/forms/blog/save.php166
-rw-r--r--mod/blog/views/default/js/blog/save_draft.php67
-rw-r--r--mod/blog/views/default/object/blog.php99
-rw-r--r--mod/blog/views/default/river/object/blog/create.php15
-rw-r--r--mod/blog/views/default/widgets/blog/content.php30
-rw-r--r--mod/blog/views/default/widgets/blog/edit.php22
11 files changed, 605 insertions, 0 deletions
diff --git a/mod/blog/views/default/blog/css.php b/mod/blog/views/default/blog/css.php
new file mode 100644
index 000000000..12ac4df2a
--- /dev/null
+++ b/mod/blog/views/default/blog/css.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Blog CSS
+ *
+ * @package Blog
+*/
+?>
+
+/* Blog Plugin */
+
+/* force tinymce input height for a more useful editing / blog creation area */
+form#blog-post-edit #description_parent #description_ifr {
+ height:400px !important;
+}
diff --git a/mod/blog/views/default/blog/group_module.php b/mod/blog/views/default/blog/group_module.php
new file mode 100644
index 000000000..6082cdafd
--- /dev/null
+++ b/mod/blog/views/default/blog/group_module.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Group blog module
+ */
+
+$group = elgg_get_page_owner_entity();
+
+if ($group->blog_enable == "no") {
+ return true;
+}
+
+$all_link = elgg_view('output/url', array(
+ 'href' => "blog/group/$group->guid/all",
+ 'text' => elgg_echo('link:view:all'),
+ 'is_trusted' => true,
+));
+
+elgg_push_context('widgets');
+$options = array(
+ 'type' => 'object',
+ 'subtype' => 'blog',
+ 'container_guid' => elgg_get_page_owner_guid(),
+ 'metadata_name_value_pairs' => array('name' => 'status', 'value' => 'published'),
+ 'limit' => 6,
+ 'full_view' => false,
+ 'pagination' => false,
+);
+$content = elgg_list_entities_from_metadata($options);
+elgg_pop_context();
+
+if (!$content) {
+ $content = '<p>' . elgg_echo('blog:none') . '</p>';
+}
+
+$new_link = elgg_view('output/url', array(
+ 'href' => "blog/add/$group->guid",
+ 'text' => elgg_echo('blog:write'),
+ 'is_trusted' => true,
+));
+
+echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('blog:group'),
+ 'content' => $content,
+ 'all_link' => $all_link,
+ 'add_link' => $new_link,
+));
diff --git a/mod/blog/views/default/blog/sidebar.php b/mod/blog/views/default/blog/sidebar.php
new file mode 100644
index 000000000..0ae2b431c
--- /dev/null
+++ b/mod/blog/views/default/blog/sidebar.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Blog sidebar
+ *
+ * @package Blog
+ */
+
+// fetch & display latest comments
+if ($vars['page'] == 'all') {
+ echo elgg_view('page/elements/comments_block', array(
+ 'subtypes' => 'blog',
+ ));
+} elseif ($vars['page'] == 'owner') {
+ echo elgg_view('page/elements/comments_block', array(
+ 'subtypes' => 'blog',
+ 'owner_guid' => elgg_get_page_owner_guid(),
+ ));
+}
+
+// only users can have archives at present
+if ($vars['page'] == 'owner' || $vars['page'] == 'group') {
+ echo elgg_view('blog/sidebar/archives', $vars);
+}
+
+if ($vars['page'] != 'friends') {
+ echo elgg_view('page/elements/tagcloud_block', array(
+ 'subtypes' => 'blog',
+ 'owner_guid' => elgg_get_page_owner_guid(),
+ ));
+}
diff --git a/mod/blog/views/default/blog/sidebar/archives.php b/mod/blog/views/default/blog/sidebar/archives.php
new file mode 100644
index 000000000..6529887d4
--- /dev/null
+++ b/mod/blog/views/default/blog/sidebar/archives.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Blog archives
+ */
+
+$page_owner = elgg_get_page_owner_entity();
+
+if (!$page_owner) {
+ return true;
+}
+
+if (elgg_instanceof($page_owner, 'user')) {
+ $url_segment = 'blog/archive/' . $page_owner->username;
+} else {
+ $url_segment = 'blog/group/' . $page_owner->getGUID() . '/archive';
+}
+
+// This is a limitation of the URL schema.
+if ($page_owner && $vars['page'] != 'friends') {
+ $dates = array_reverse(get_entity_dates('object', 'blog', $page_owner->getGUID()));
+
+ if ($dates) {
+ $title = elgg_echo('blog:archives');
+ $content = '<ul class="blog-archives">';
+ foreach ($dates as $date) {
+ $timestamplow = mktime(0, 0, 0, substr($date,4,2) , 1, substr($date, 0, 4));
+ $timestamphigh = mktime(0, 0, 0, ((int) substr($date, 4, 2)) + 1, 1, substr($date, 0, 4));
+
+ $link = elgg_get_site_url() . $url_segment . '/' . $timestamplow . '/' . $timestamphigh;
+ $month = elgg_echo('date:month:' . substr($date, 4, 2), array(substr($date, 0, 4)));
+ $content .= "<li><a href=\"$link\" title=\"$month\">$month</a></li>";
+ }
+ $content .= '</ul>';
+
+ echo elgg_view_module('aside', $title, $content);
+ }
+}
diff --git a/mod/blog/views/default/blog/sidebar/revisions.php b/mod/blog/views/default/blog/sidebar/revisions.php
new file mode 100644
index 000000000..cd2e7f3d8
--- /dev/null
+++ b/mod/blog/views/default/blog/sidebar/revisions.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Blog sidebar menu showing revisions
+ *
+ * @package Blog
+ */
+
+//If editing a post, show the previous revisions and drafts.
+$blog = elgg_extract('entity', $vars, FALSE);
+
+if (elgg_instanceof($blog, 'object', 'blog') && $blog->canEdit()) {
+ $owner = $blog->getOwnerEntity();
+ $revisions = array();
+
+ $auto_save_annotations = $blog->getAnnotations('blog_auto_save', 1);
+ if ($auto_save_annotations) {
+ $revisions[] = $auto_save_annotations[0];
+ }
+
+ // count(FALSE) == 1! AHHH!!!
+ $saved_revisions = $blog->getAnnotations('blog_revision', 10, 0, 'time_created DESC');
+ if ($saved_revisions) {
+ $revision_count = count($saved_revisions);
+ } else {
+ $revision_count = 0;
+ }
+
+ $revisions = array_merge($revisions, $saved_revisions);
+
+ if ($revisions) {
+ $title = elgg_echo('blog:revisions');
+
+ $n = count($revisions);
+ $body = '<ul class="blog-revisions">';
+
+ $load_base_url = "blog/edit/{$blog->getGUID()}";
+
+ // show the "published revision"
+ if ($blog->status == 'published') {
+ $load = elgg_view('output/url', array(
+ 'href' => $load_base_url,
+ 'text' => elgg_echo('blog:status:published'),
+ 'is_trusted' => true,
+ ));
+
+ $time = "<span class='elgg-subtext'>"
+ . elgg_view_friendly_time($blog->time_created) . "</span>";
+
+ $body .= "<li>$load : $time</li>";
+ }
+
+ foreach ($revisions as $revision) {
+ $time = "<span class='elgg-subtext'>"
+ . elgg_view_friendly_time($revision->time_created) . "</span>";
+
+ if ($revision->name == 'blog_auto_save') {
+ $revision_lang = elgg_echo('blog:auto_saved_revision');
+ } else {
+ $revision_lang = elgg_echo('blog:revision') . " $n";
+ }
+ $load = elgg_view('output/url', array(
+ 'href' => "$load_base_url/$revision->id",
+ 'text' => $revision_lang,
+ 'is_trusted' => true,
+ ));
+
+ $text = "$load: $time";
+ $class = 'class="auto-saved"';
+
+ $n--;
+
+ $body .= "<li $class>$text</li>";
+ }
+
+ $body .= '</ul>';
+
+ echo elgg_view_module('aside', $title, $body);
+ }
+} \ 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..f825acca1
--- /dev/null
+++ b/mod/blog/views/default/forms/blog/save.php
@@ -0,0 +1,166 @@
+<?php
+/**
+ * Edit blog form
+ *
+ * @package Blog
+ */
+
+$blog = get_entity($vars['guid']);
+$vars['entity'] = $blog;
+
+$draft_warning = $vars['draft_warning'];
+if ($draft_warning) {
+ $draft_warning = '<span class="mbm elgg-text-help">' . $draft_warning . '</span>';
+}
+
+$action_buttons = '';
+$delete_link = '';
+$preview_button = '';
+
+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' => 'elgg-button elgg-button-delete float-alt'
+ ));
+}
+
+// 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(
+ 'name' => 'title',
+ 'id' => 'blog_title',
+ 'value' => $vars['title']
+));
+
+$excerpt_label = elgg_echo('blog:excerpt');
+$excerpt_input = elgg_view('input/text', array(
+ 'name' => 'excerpt',
+ 'id' => 'blog_excerpt',
+ 'value' => _elgg_html_decode($vars['excerpt'])
+));
+
+$body_label = elgg_echo('blog:body');
+$body_input = elgg_view('input/longtext', array(
+ 'name' => 'description',
+ 'id' => 'blog_description',
+ 'value' => $vars['description']
+));
+
+$save_status = elgg_echo('blog:save_status');
+if ($vars['guid']) {
+ $entity = get_entity($vars['guid']);
+ $saved = date('F j, Y @ H:i', $entity->time_created);
+} else {
+ $saved = elgg_echo('blog:never');
+}
+
+$status_label = elgg_echo('blog:status');
+$status_input = elgg_view('input/dropdown', array(
+ 'name' => 'status',
+ 'id' => '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/dropdown', array(
+ 'name' => 'comments_on',
+ 'id' => '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(
+ 'name' => 'tags',
+ 'id' => 'blog_tags',
+ 'value' => $vars['tags']
+));
+
+$access_label = elgg_echo('access');
+$access_input = elgg_view('input/access', array(
+ 'name' => 'access_id',
+ 'id' => 'blog_access_id',
+ 'value' => $vars['access_id']
+));
+
+$categories_input = elgg_view('input/categories', $vars);
+
+// hidden inputs
+$container_guid_input = elgg_view('input/hidden', array('name' => 'container_guid', 'value' => elgg_get_page_owner_guid()));
+$guid_input = elgg_view('input/hidden', array('name' => 'guid', 'value' => $vars['guid']));
+
+
+echo <<<___HTML
+
+$draft_warning
+
+<div>
+ <label for="blog_title">$title_label</label>
+ $title_input
+</div>
+
+<div>
+ <label for="blog_excerpt">$excerpt_label</label>
+ $excerpt_input
+</div>
+
+<div>
+ <label for="blog_description">$body_label</label>
+ $body_input
+</div>
+
+<div>
+ <label for="blog_tags">$tags_label</label>
+ $tags_input
+</div>
+
+$categories_input
+
+<div>
+ <label for="blog_comments_on">$comments_label</label>
+ $comments_input
+</div>
+
+<div>
+ <label for="blog_access_id">$access_label</label>
+ $access_input
+</div>
+
+<div>
+ <label for="blog_status">$status_label</label>
+ $status_input
+</div>
+
+<div class="elgg-foot">
+ <div class="elgg-subtext mbm">
+ $save_status <span class="blog-save-status-time">$saved</span>
+ </div>
+
+ $guid_input
+ $container_guid_input
+
+ $action_buttons
+</div>
+
+___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..8cd07ff5d
--- /dev/null
+++ b/mod/blog/views/default/js/blog/save_draft.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Save draft through ajax
+ *
+ * @package Blog
+ */
+?>
+elgg.provide('elgg.blog');
+
+/*
+ * Attempt to save and update the input with the guid.
+ */
+elgg.blog.saveDraftCallback = function(data, textStatus, XHR) {
+ if (textStatus == 'success' && data.success == true) {
+ var form = $('form[id=blog-post-edit]');
+
+ // 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(elgg.echo('error'));
+ }
+};
+
+elgg.blog.saveDraft = function() {
+ if (typeof(tinyMCE) != 'undefined') {
+ tinyMCE.triggerSave();
+ }
+
+ // only save on changed content
+ var form = $('form[id=blog-post-edit]');
+ 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 = elgg.config.wwwroot + "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, elgg.blog.saveDraftCallback, 'json');
+};
+
+elgg.blog.init = function() {
+ // get a copy of the body to compare for auto save
+ oldDescription = $('form[id=blog-post-edit]').find('textarea[name=description]').val();
+
+ setInterval(elgg.blog.saveDraft, 60000);
+};
+
+elgg.register_hook_handler('init', 'system', elgg.blog.init); \ No newline at end of file
diff --git a/mod/blog/views/default/object/blog.php b/mod/blog/views/default/object/blog.php
new file mode 100644
index 000000000..4403a6006
--- /dev/null
+++ b/mod/blog/views/default/object/blog.php
@@ -0,0 +1,99 @@
+<?php
+/**
+ * View for blog objects
+ *
+ * @package Blog
+ */
+
+$full = elgg_extract('full_view', $vars, FALSE);
+$blog = elgg_extract('entity', $vars, FALSE);
+
+if (!$blog) {
+ return TRUE;
+}
+
+$owner = $blog->getOwnerEntity();
+$container = $blog->getContainerEntity();
+$categories = elgg_view('output/categories', $vars);
+$excerpt = $blog->excerpt;
+if (!$excerpt) {
+ $excerpt = elgg_get_excerpt($blog->description);
+}
+
+$owner_icon = elgg_view_entity_icon($owner, 'tiny');
+$owner_link = elgg_view('output/url', array(
+ 'href' => "blog/owner/$owner->username",
+ 'text' => $owner->name,
+ 'is_trusted' => true,
+));
+$author_text = elgg_echo('byline', array($owner_link));
+$date = elgg_view_friendly_time($blog->time_created);
+
+// The "on" status changes for comments, so best to check for !Off
+if ($blog->comments_on != 'Off') {
+ $comments_count = $blog->countComments();
+ //only display if there are commments
+ if ($comments_count != 0) {
+ $text = elgg_echo("comments") . " ($comments_count)";
+ $comments_link = elgg_view('output/url', array(
+ 'href' => $blog->getURL() . '#blog-comments',
+ 'text' => $text,
+ 'is_trusted' => true,
+ ));
+ } else {
+ $comments_link = '';
+ }
+} else {
+ $comments_link = '';
+}
+
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $vars['entity'],
+ 'handler' => 'blog',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+));
+
+$subtitle = "$author_text $date $comments_link $categories";
+
+// do not show the metadata and controls in widget view
+if (elgg_in_context('widgets')) {
+ $metadata = '';
+}
+
+if ($full) {
+
+ $body = elgg_view('output/longtext', array(
+ 'value' => $blog->description,
+ 'class' => 'blog-post',
+ ));
+
+ $params = array(
+ 'entity' => $blog,
+ 'title' => false,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ );
+ $params = $params + $vars;
+ $summary = elgg_view('object/elements/summary', $params);
+
+ echo elgg_view('object/elements/full', array(
+ 'summary' => $summary,
+ 'icon' => $owner_icon,
+ 'body' => $body,
+ ));
+
+} else {
+ // brief view
+
+ $params = array(
+ 'entity' => $blog,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ 'content' => $excerpt,
+ );
+ $params = $params + $vars;
+ $list_body = elgg_view('object/elements/summary', $params);
+
+ echo elgg_view_image_block($owner_icon, $list_body);
+}
diff --git a/mod/blog/views/default/river/object/blog/create.php b/mod/blog/views/default/river/object/blog/create.php
new file mode 100644
index 000000000..b808f1bdc
--- /dev/null
+++ b/mod/blog/views/default/river/object/blog/create.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Blog river view.
+ */
+
+$object = $vars['item']->getObjectEntity();
+
+$excerpt = $object->excerpt ? $object->excerpt : $object->description;
+$excerpt = strip_tags($excerpt);
+$excerpt = elgg_get_excerpt($excerpt);
+
+echo elgg_view('river/elements/layout', array(
+ 'item' => $vars['item'],
+ 'message' => $excerpt,
+));
diff --git a/mod/blog/views/default/widgets/blog/content.php b/mod/blog/views/default/widgets/blog/content.php
new file mode 100644
index 000000000..330171662
--- /dev/null
+++ b/mod/blog/views/default/widgets/blog/content.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * User blog widget display view
+ */
+
+$num = $vars['entity']->num_display;
+
+$options = array(
+ 'type' => 'object',
+ 'subtype' => 'blog',
+ 'container_guid' => $vars['entity']->owner_guid,
+ 'limit' => $num,
+ 'full_view' => FALSE,
+ 'pagination' => FALSE,
+);
+$content = elgg_list_entities($options);
+
+echo $content;
+
+if ($content) {
+ $blog_url = "blog/owner/" . elgg_get_page_owner_entity()->username;
+ $more_link = elgg_view('output/url', array(
+ 'href' => $blog_url,
+ 'text' => elgg_echo('blog:moreblogs'),
+ 'is_trusted' => true,
+ ));
+ echo "<span class=\"elgg-widget-more\">$more_link</span>";
+} else {
+ echo elgg_echo('blog:noblogs');
+}
diff --git a/mod/blog/views/default/widgets/blog/edit.php b/mod/blog/views/default/widgets/blog/edit.php
new file mode 100644
index 000000000..30c3b2e73
--- /dev/null
+++ b/mod/blog/views/default/widgets/blog/edit.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * User blog widget edit view
+ */
+
+// set default value
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 4;
+}
+
+$params = array(
+ 'name' => 'params[num_display]',
+ 'value' => $vars['entity']->num_display,
+ 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
+);
+$dropdown = elgg_view('input/dropdown', $params);
+
+?>
+<div>
+ <?php echo elgg_echo('blog:numbertodisplay'); ?>:
+ <?php echo $dropdown; ?>
+</div>