aboutsummaryrefslogtreecommitdiff
path: root/mod/messageboard/views/default
diff options
context:
space:
mode:
Diffstat (limited to 'mod/messageboard/views/default')
-rw-r--r--mod/messageboard/views/default/forms/messageboard/add.php20
-rw-r--r--mod/messageboard/views/default/messageboard/css.php10
-rw-r--r--mod/messageboard/views/default/messageboard/js.php56
-rw-r--r--mod/messageboard/views/default/river/object/messageboard/create.php12
-rw-r--r--mod/messageboard/views/default/widgets/messageboard/content.php35
-rw-r--r--mod/messageboard/views/default/widgets/messageboard/edit.php22
6 files changed, 155 insertions, 0 deletions
diff --git a/mod/messageboard/views/default/forms/messageboard/add.php b/mod/messageboard/views/default/forms/messageboard/add.php
new file mode 100644
index 000000000..b219fd800
--- /dev/null
+++ b/mod/messageboard/views/default/forms/messageboard/add.php
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Elgg Message board add form body
+ *
+ * @package ElggMessageBoard
+ */
+
+echo elgg_view('input/plaintext', array(
+ 'name' => 'message_content',
+ 'class' => 'messageboard-input mbs'
+));
+
+echo elgg_view('input/hidden', array(
+ 'name' => 'owner_guid',
+ 'value' => elgg_get_page_owner_guid()
+));
+
+echo elgg_view('input/submit', array(
+ 'value' => elgg_echo('post')
+));
diff --git a/mod/messageboard/views/default/messageboard/css.php b/mod/messageboard/views/default/messageboard/css.php
new file mode 100644
index 000000000..b3cfab957
--- /dev/null
+++ b/mod/messageboard/views/default/messageboard/css.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Elgg Messageboard CSS view
+ *
+ */
+?>
+
+.messageboard-input {
+ height: 100px;
+}
diff --git a/mod/messageboard/views/default/messageboard/js.php b/mod/messageboard/views/default/messageboard/js.php
new file mode 100644
index 000000000..79472069d
--- /dev/null
+++ b/mod/messageboard/views/default/messageboard/js.php
@@ -0,0 +1,56 @@
+//<script>
+elgg.provide('elgg.messageboard');
+
+elgg.messageboard.init = function() {
+ var form = $('form[name=elgg-messageboard]');
+ form.find('input[type=submit]').live('click', elgg.messageboard.submit);
+
+ // remove the default binding for confirmation since we're doing extra stuff.
+ // @todo remove if we add a hook to the requires confirmation callback
+ form.parent().find('a.elgg-requires-confirmation')
+ .click(elgg.messageboard.deletePost)
+
+ // double whammy for in case the load order changes.
+ .unbind('click', elgg.ui.requiresConfirmation)
+ .removeClass('elgg-requires-confirmation');
+};
+
+elgg.messageboard.submit = function(e) {
+ var form = $(this).parents('form');
+ var data = form.serialize();
+
+ elgg.action('messageboard/add', {
+ data: data,
+ success: function(json) {
+ // the action always returns the full ul and li wrapped annotation.
+ var ul = form.next('ul.elgg-list-annotation');
+
+ if (ul.length < 1) {
+ form.parent().append(json.output);
+ } else {
+ ul.prepend($(json.output).find('li:first'));
+ };
+ form.find('textarea').val('');
+ }
+ });
+
+ e.preventDefault();
+};
+
+elgg.messageboard.deletePost = function(e) {
+ var link = $(this);
+ var confirmText = link.attr('title') || elgg.echo('question:areyousure');
+
+ if (confirm(confirmText)) {
+ elgg.action($(this).attr('href'), {
+ success: function() {
+ var item = $(link).closest('.elgg-item');
+ item.remove();
+ }
+ });
+ }
+
+ e.preventDefault();
+};
+
+elgg.register_hook_handler('init', 'system', elgg.messageboard.init);
diff --git a/mod/messageboard/views/default/river/object/messageboard/create.php b/mod/messageboard/views/default/river/object/messageboard/create.php
new file mode 100644
index 000000000..ac10a55c1
--- /dev/null
+++ b/mod/messageboard/views/default/river/object/messageboard/create.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Messageboard river view
+ */
+
+$messageboard = $vars['item']->getAnnotation();
+$excerpt = elgg_get_excerpt($messageboard->value);
+
+echo elgg_view('river/elements/layout', array(
+ 'item' => $vars['item'],
+ 'message' => $excerpt,
+));
diff --git a/mod/messageboard/views/default/widgets/messageboard/content.php b/mod/messageboard/views/default/widgets/messageboard/content.php
new file mode 100644
index 000000000..35954e7a3
--- /dev/null
+++ b/mod/messageboard/views/default/widgets/messageboard/content.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Elgg messageboard widget view
+ *
+ */
+
+$owner = elgg_get_page_owner_entity();
+
+$num_display = $vars['entity']->num_display;
+
+if (elgg_is_logged_in()) {
+ echo elgg_view_form('messageboard/add', array('name' => 'elgg-messageboard'));
+}
+
+$options = array(
+ 'annotations_name' => 'messageboard',
+ 'guid' => $owner->getGUID(),
+ 'limit' => $num_display,
+ 'pagination' => false,
+ 'reverse_order_by' => true,
+);
+
+echo elgg_list_annotations($options);
+
+if ($owner instanceof ElggGroup) {
+ $url = "messageboard/group/$owner->guid/all";
+} else {
+ $url = "messageboard/owner/$owner->username";
+}
+
+echo elgg_view('output/url', array(
+ 'href' => $url,
+ 'text' => elgg_echo('messageboard:viewall'),
+ 'is_trusted' => true,
+)); \ No newline at end of file
diff --git a/mod/messageboard/views/default/widgets/messageboard/edit.php b/mod/messageboard/views/default/widgets/messageboard/edit.php
new file mode 100644
index 000000000..74848f832
--- /dev/null
+++ b/mod/messageboard/views/default/widgets/messageboard/edit.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Messageboard widget edit view
+ */
+
+// set default value
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 5;
+}
+
+$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('messageboard:num_display'); ?>:
+ <?php echo $dropdown; ?>
+</div>