aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-06-24 18:12:47 -0700
committerCash Costello <cash.costello@gmail.com>2011-06-24 18:12:47 -0700
commit8565bdf9a471e541af576201a756b9da58e1c81b (patch)
treedbca4467b0b3dd21ce746b196b392ec99da3f61c
parentf0c01363ac796a5b11490c6570db9827360f3118 (diff)
parent0594a363ae77c5427eb96a8753e644897fdc5491 (diff)
downloadelgg-8565bdf9a471e541af576201a756b9da58e1c81b.tar.gz
elgg-8565bdf9a471e541af576201a756b9da58e1c81b.tar.bz2
Merge pull request #49 from cash/dry_group_modules
Fixes #3139 DRYs up group modules
-rw-r--r--mod/blog/views/default/blog/group_module.php22
-rw-r--r--mod/bookmarks/views/default/bookmarks/group_module.php21
-rw-r--r--mod/file/views/default/file/group_module.php22
-rw-r--r--mod/groups/views/default/discussion/group_module.php22
-rw-r--r--mod/groups/views/default/groups/profile/activity_module.php11
-rw-r--r--mod/groups/views/default/groups/profile/module.php20
-rw-r--r--mod/pages/views/default/pages/group_module.php21
7 files changed, 76 insertions, 63 deletions
diff --git a/mod/blog/views/default/blog/group_module.php b/mod/blog/views/default/blog/group_module.php
index 6cfe6c98e..d769fbd59 100644
--- a/mod/blog/views/default/blog/group_module.php
+++ b/mod/blog/views/default/blog/group_module.php
@@ -14,10 +14,6 @@ $all_link = elgg_view('output/url', array(
'text' => elgg_echo('link:view:all'),
));
-$header = "<span class=\"groups-widget-viewall\">$all_link</span>";
-$header .= '<h3>' . elgg_echo('blog:group') . '</h3>';
-
-
elgg_push_context('widgets');
$options = array(
'type' => 'object',
@@ -34,12 +30,14 @@ if (!$content) {
$content = '<p>' . elgg_echo('blog:none') . '</p>';
}
-if ($group->canWriteToContainer()) {
- $new_link = elgg_view('output/url', array(
- 'href' => "blog/add/$group->guid",
- 'text' => elgg_echo('blog:write'),
- ));
- $content .= "<span class='elgg-widget-more'>$new_link</span>";
-}
+$new_link = elgg_view('output/url', array(
+ 'href' => "blog/add/$group->guid",
+ 'text' => elgg_echo('blog:write'),
+));
-echo elgg_view_module('info', '', $content, array('header' => $header));
+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/bookmarks/views/default/bookmarks/group_module.php b/mod/bookmarks/views/default/bookmarks/group_module.php
index 3166fc0f0..3797de010 100644
--- a/mod/bookmarks/views/default/bookmarks/group_module.php
+++ b/mod/bookmarks/views/default/bookmarks/group_module.php
@@ -16,9 +16,6 @@ $all_link = elgg_view('output/url', array(
'text' => elgg_echo('link:view:all'),
));
-$header = "<span class=\"groups-widget-viewall\">$all_link</span>";
-$header .= '<h3>' . elgg_echo('bookmarks:group') . '</h3>';
-
elgg_push_context('widgets');
$options = array(
'type' => 'object',
@@ -35,12 +32,14 @@ if (!$content) {
$content = '<p>' . elgg_echo('bookmarks:none') . '</p>';
}
-if ($group->canWriteToContainer()) {
- $new_link = elgg_view('output/url', array(
- 'href' => "bookmarks/add/$group->guid",
- 'text' => elgg_echo('bookmarks:add'),
- ));
- $content .= "<span class='elgg-widget-more'>$new_link</span>";
-}
+$new_link = elgg_view('output/url', array(
+ 'href' => "bookmarks/add/$group->guid",
+ 'text' => elgg_echo('bookmarks:add'),
+));
-echo elgg_view_module('info', '', $content, array('header' => $header));
+echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('bookmarks:group'),
+ 'content' => $content,
+ 'all_link' => $all_link,
+ 'add_link' => $new_link,
+));
diff --git a/mod/file/views/default/file/group_module.php b/mod/file/views/default/file/group_module.php
index 830b1096c..c37b13927 100644
--- a/mod/file/views/default/file/group_module.php
+++ b/mod/file/views/default/file/group_module.php
@@ -14,10 +14,6 @@ $all_link = elgg_view('output/url', array(
'text' => elgg_echo('link:view:all'),
));
-$header = "<span class=\"groups-widget-viewall\">$all_link</span>";
-$header .= '<h3>' . elgg_echo('file:group') . '</h3>';
-
-
elgg_push_context('widgets');
$options = array(
'type' => 'object',
@@ -34,12 +30,14 @@ if (!$content) {
$content = '<p>' . elgg_echo('file:none') . '</p>';
}
-if ($group->canWriteToContainer()) {
- $new_link = elgg_view('output/url', array(
- 'href' => "file/add/$group->guid",
- 'text' => elgg_echo('file:add'),
- ));
- $content .= "<span class='elgg-widget-more'>$new_link</span>";
-}
+$new_link = elgg_view('output/url', array(
+ 'href' => "file/add/$group->guid",
+ 'text' => elgg_echo('file:add'),
+));
-echo elgg_view_module('info', '', $content, array('header' => $header));
+echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('file:group'),
+ 'content' => $content,
+ 'all_link' => $all_link,
+ 'add_link' => $new_link,
+));
diff --git a/mod/groups/views/default/discussion/group_module.php b/mod/groups/views/default/discussion/group_module.php
index 165d9b1be..3a46e336e 100644
--- a/mod/groups/views/default/discussion/group_module.php
+++ b/mod/groups/views/default/discussion/group_module.php
@@ -17,10 +17,6 @@ $all_link = elgg_view('output/url', array(
'text' => elgg_echo('link:view:all'),
));
-$header = "<span class=\"groups-widget-viewall\">$all_link</span>";
-$header .= '<h3>' . elgg_echo('discussion:group') . '</h3>';
-
-
elgg_push_context('widgets');
$options = array(
'type' => 'object',
@@ -37,12 +33,14 @@ if (!$content) {
$content = '<p>' . elgg_echo('grouptopic:notcreated') . '</p>';
}
-if ($group->canWriteToContainer()) {
- $new_link = elgg_view('output/url', array(
- 'href' => "discussion/add/" . $group->getGUID(),
- 'text' => elgg_echo('groups:addtopic'),
- ));
- $content .= "<span class='elgg-widget-more'>$new_link</span>";
-}
+$new_link = elgg_view('output/url', array(
+ 'href' => "discussion/add/" . $group->getGUID(),
+ 'text' => elgg_echo('groups:addtopic'),
+));
-echo elgg_view_module('info', '', $content, array('header' => $header));
+echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('discussion:group'),
+ 'content' => $content,
+ 'all_link' => $all_link,
+ 'add_link' => $new_link,
+)); \ No newline at end of file
diff --git a/mod/groups/views/default/groups/profile/activity_module.php b/mod/groups/views/default/groups/profile/activity_module.php
index 4ea97cad6..5e557b443 100644
--- a/mod/groups/views/default/groups/profile/activity_module.php
+++ b/mod/groups/views/default/groups/profile/activity_module.php
@@ -21,16 +21,13 @@ $all_link = elgg_view('output/url', array(
'text' => elgg_echo('link:view:all'),
));
-$header = "<span class=\"groups-widget-viewall\">$all_link</span>";
-$header .= '<h3>' . elgg_echo('groups:activity') . '</h3>';
-
elgg_push_context('widgets');
$db_prefix = elgg_get_config('dbprefix');
$content = elgg_list_river(array(
'limit' => 4,
'pagination' => false,
- 'joins' => array("join {$db_prefix}entities e1 on e1.guid = rv.object_guid"),
+ 'joins' => array("JOIN {$db_prefix}entities e1 ON e1.guid = rv.object_guid"),
'wheres' => array("(e1.container_guid = $group->guid)"),
));
elgg_pop_context();
@@ -39,4 +36,8 @@ if (!$content) {
$content = '<p>' . elgg_echo('groups:activity:none') . '</p>';
}
-echo elgg_view_module('info', '', $content, array('header' => $header));
+echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('groups:activity'),
+ 'content' => $content,
+ 'all_link' => $all_link,
+));
diff --git a/mod/groups/views/default/groups/profile/module.php b/mod/groups/views/default/groups/profile/module.php
new file mode 100644
index 000000000..69854e59b
--- /dev/null
+++ b/mod/groups/views/default/groups/profile/module.php
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Group module (also called a group widget)
+ *
+ * @uses $vars['title'] The title of the module
+ * @uses $vars['content'] The module content
+ * @uses $vars['all_link'] A link to list content
+ * @uses $vars['add_link'] A link to create content
+ */
+
+$group = elgg_get_page_owner_entity();
+
+$header = "<span class=\"groups-widget-viewall\">{$vars['all_link']}</span>";
+$header .= '<h3>' . $vars['title'] . '</h3>';
+
+if ($group->canWriteToContainer() && isset($vars['add_link'])) {
+ $vars['content'] .= "<span class='elgg-widget-more'>{$vars['add_link']}</span>";
+}
+
+echo elgg_view_module('info', '', $vars['content'], array('header' => $header));
diff --git a/mod/pages/views/default/pages/group_module.php b/mod/pages/views/default/pages/group_module.php
index 1d3437e18..7e2656ca3 100644
--- a/mod/pages/views/default/pages/group_module.php
+++ b/mod/pages/views/default/pages/group_module.php
@@ -17,9 +17,6 @@ $all_link = elgg_view('output/url', array(
'text' => elgg_echo('link:view:all'),
));
-$header = "<span class=\"groups-widget-viewall\">$all_link</span>";
-$header .= '<h3>' . elgg_echo('pages:group') . '</h3>';
-
elgg_push_context('widgets');
$options = array(
@@ -37,12 +34,14 @@ if (!$content) {
$content = '<p>' . elgg_echo('pages:none') . '</p>';
}
-if ($group->canWriteToContainer()) {
- $new_link = elgg_view('output/url', array(
- 'href' => "pages/add/$group->guid",
- 'text' => elgg_echo('pages:add'),
- ));
- $content .= "<span class='elgg-widget-more'>$new_link</span>";
-}
+$new_link = elgg_view('output/url', array(
+ 'href' => "pages/add/$group->guid",
+ 'text' => elgg_echo('pages:add'),
+));
-echo elgg_view_module('info', '', $content, array('header' => $header));
+echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('pages:group'),
+ 'content' => $content,
+ 'all_link' => $all_link,
+ 'add_link' => $new_link,
+));