aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/blog/blog_lib.php62
-rw-r--r--mod/blog/start.php35
-rw-r--r--views/default/content/filter.php43
-rw-r--r--views/default/content/footer.php8
-rw-r--r--views/default/content/header.php44
-rw-r--r--views/default/content/sidebar.php8
-rw-r--r--views/default/css/screen.php6
-rw-r--r--views/default/layouts/main_content.php53
8 files changed, 204 insertions, 55 deletions
diff --git a/mod/blog/blog_lib.php b/mod/blog/blog_lib.php
index adc888ce2..4db3effde 100644
--- a/mod/blog/blog_lib.php
+++ b/mod/blog/blog_lib.php
@@ -20,28 +20,23 @@ function blog_get_page_content_read($owner_guid = NULL, $guid = NULL) {
if ($guid) {
$blog = get_entity($guid);
+ // no header or tabs for viewing an individual blog
+ $return['filter'] = '';
+ $return['header'] = '';
+
if (!elgg_instanceof($blog, 'object', 'blog') || ($blog->status != 'published' && !$blog->canEdit())) {
- $return['body'] = elgg_echo('blog:error:post_not_found');
+ $return['content'] = elgg_echo('blog:error:post_not_found');
} else {
elgg_push_breadcrumb($blog->title, $blog->getURL());
- $return['body'] = elgg_view_entity($blog, TRUE);
+ $return['content'] = elgg_view_entity($blog, TRUE);
//check to see if comment are on
if ($blog->comments_on != 'Off') {
- $return['body'] .= elgg_view_comments($blog);
+ $return['content'] .= elgg_view_comments($blog);
}
}
} else {
- $params = array(
- 'type' => 'blog',
- );
- $return['header'] = elgg_view('page_elements/main_header', $params);
-
- $params = array(
- 'type' => 'blog',
- 'context' => $owner_guid ? 'mine' : 'everyone',
- );
- $return['body'] = elgg_view('page_elements/main_nav', $params);
+ $return['filter_context'] = $owner_guid ? 'mine' : 'everyone';
$options = array(
'type' => 'object',
@@ -50,20 +45,18 @@ function blog_get_page_content_read($owner_guid = NULL, $guid = NULL) {
//'order_by_metadata' => array('name'=>'publish_date', 'direction'=>'DESC', 'as'=>'int')
);
-/*
$loggedin_userid = get_loggedin_userid();
if ($owner_guid) {
$options['owner_guid'] = $owner_guid;
-
+/*
if ($owner_guid != $loggedin_userid) {
// do not show content header when viewing other users' posts
$content = elgg_view('page_elements/content_header_member', array('type' => 'blog'));
}
- }
- *
+ *
*/
+ }
-/*
// show all posts for admin or users looking at their own blogs
// show only published posts for other users.
if (!(isadminloggedin() || (isloggedin() && $owner_guid == $loggedin_userid))) {
@@ -72,13 +65,12 @@ function blog_get_page_content_read($owner_guid = NULL, $guid = NULL) {
//array('name' => 'publish_date', 'operand' => '<', 'value' => time())
);
}
-*/
$list = elgg_list_entities_from_metadata($options);
if (!$list) {
- $return['body'] .= elgg_echo('blog:none');
+ $return['content'] = elgg_echo('blog:none');
} else {
- $return['body'] .= $list;
+ $return['content'] = $list;
}
}
@@ -124,7 +116,12 @@ function blog_get_page_content_edit($guid, $revision = NULL) {
//$sidebar = elgg_view('blog/sidebar_related');
}
- return array('body' => $content, 'sidebar' => $sidebar);
+ return array(
+ 'content' => $content,
+ 'sidebar' => $sidebar,
+ 'header' => '',
+ 'filter' => '',
+ );
}
/**
@@ -197,7 +194,9 @@ function blog_get_page_content_archive($owner_guid, $lower=0, $upper=0) {
}
return array(
- 'content' => $content
+ 'content' => $content,
+ 'filter' => '',
+ 'header' => '',
);
}
@@ -212,14 +211,13 @@ function blog_get_page_content_friends($user_guid) {
elgg_push_breadcrumb(elgg_echo('friends'));
- $content = elgg_view('page_elements/content_header', array(
- 'context' => 'friends',
- 'type' => 'blog',
- 'all_link' => "pg/blog"
- ));
+ $return = array();
+
+ $return['filter_context'] = 'friends';
if (!$friends = get_user_friends($user_guid, ELGG_ENTITIES_ANY_VALUE, 0)) {
- $content .= elgg_echo('friends:none:you');
+ $return['content'] .= elgg_echo('friends:none:you');
+ return $return;
} else {
$options = array(
'type' => 'object',
@@ -246,13 +244,13 @@ function blog_get_page_content_friends($user_guid) {
$list = elgg_list_entities_from_metadata($options);
if (!$list) {
- $content .= elgg_echo('blog:none');
+ $return['content'] = elgg_echo('blog:none');
} else {
- $content .= $list;
+ $return['content'] = $list;
}
}
- return array('content' => $content);
+ return $return;
}
/**
diff --git a/mod/blog/start.php b/mod/blog/start.php
index b279de1a3..0d0c58ac8 100644
--- a/mod/blog/start.php
+++ b/mod/blog/start.php
@@ -92,13 +92,13 @@ function blog_runonce() {
function blog_page_handler($page) {
global $CONFIG;
+ // push breadcrumb
+ elgg_push_breadcrumb(elgg_echo('blog:blogs'), "pg/blog");
+
// see if we're showing all or just a user's
if (isset($page[0]) && !empty($page[0])) {
$username = $page[0];
- // push breadcrumb
- elgg_push_breadcrumb(elgg_echo('blog:blogs'), "pg/blog");
-
// forward away if invalid user.
if (!$user = get_user_by_username($username)) {
register_error('blog:error:unknown_username');
@@ -118,24 +118,24 @@ function blog_page_handler($page) {
switch ($action) {
case 'read':
$title = elgg_echo('blog:title:user_blogs', array($user->name));
- $content_info = blog_get_page_content_read($user->getGUID(), $page2);
+ $params = blog_get_page_content_read($user->getGUID(), $page2);
break;
case 'new':
case 'edit':
gatekeeper();
$title = elgg_echo('blog:edit');
- $content_info = blog_get_page_content_edit($page2, $page3);
+ $params = blog_get_page_content_edit($page2, $page3);
break;
case 'archive':
$title = elgg_echo('blog:archives');
- $content_info = blog_get_page_content_archive($user->getGUID(), $page2, $page3);
+ $params = blog_get_page_content_archive($user->getGUID(), $page2, $page3);
break;
case 'friends':
$title = elgg_echo('blog:title:friends');
- $content_info = blog_get_page_content_friends($user->getGUID());
+ $params = blog_get_page_content_friends($user->getGUID());
break;
default:
@@ -144,27 +144,16 @@ function blog_page_handler($page) {
}
} else {
$title = elgg_echo('blog:title:all_blogs');
- $content_info = blog_get_page_content_read();
+ $params = blog_get_page_content_read();
}
- $sidebar = isset($content_info['sidebar']) ? $content_info['sidebar'] : '';
-
- $sidebar .= elgg_view('blog/sidebar_menu', array(
+ $sidebar_menu = elgg_view('blog/sidebar_menu', array(
'page' => isset($page[1]) ? $page[1] : FALSE,
));
- $content = elgg_view('navigation/breadcrumbs');
- $params = array(
- 'header' => $content_info['header'],
- 'body' => $content_info['body'],
- );
- $content .= elgg_view('page_elements/main_module', $params);
-
- $params = array(
- 'content' => $content,
- 'sidebar' => $sidebar,
- );
- $body = elgg_view_layout('one_column_with_sidebar', $params);
+ $params['sidebar'] .= $sidebar_menu;
+
+ $body = elgg_view_layout('main_content', $params);
echo elgg_view_page($title, $body);
}
diff --git a/views/default/content/filter.php b/views/default/content/filter.php
new file mode 100644
index 000000000..b4d747cbf
--- /dev/null
+++ b/views/default/content/filter.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Main content filter
+ *
+ * Select between user, friends, and all content
+ *
+ * @uses $vars['filter_context'] Filter context: everyone, friends, mine
+ * @uses $vars['filter_override'] HTML for overriding the default filter (override)
+ * @uses $vars['context'] Page context (override)
+ */
+
+if (isset($vars['filter_override'])) {
+ echo $vars['filter_override'];
+ return true;
+}
+
+$context = elgg_get_array_value('context', $vars, elgg_get_context());
+
+if (isloggedin() && $context) {
+ $username = get_loggedin_user()->username;
+ $filter_context = elgg_get_array_value('filter_context', $vars, 'everyone');
+
+ // generate a list of default tabs
+ $tabs = array(
+ 'all' => array(
+ 'title' => elgg_echo('all'),
+ 'url' => (isset($vars['all_link'])) ? $vars['all_link'] : "pg/$context/",
+ 'selected' => ($filter_context == 'everyone'),
+ ),
+ 'mine' => array(
+ 'title' => elgg_echo('mine'),
+ 'url' => (isset($vars['mine_link'])) ? $vars['mine_link'] : "pg/$context/$username",
+ 'selected' => ($filter_context == 'mine'),
+ ),
+ 'friend' => array(
+ 'title' => elgg_echo('friends'),
+ 'url' => (isset($vars['friend_link'])) ? $vars['friend_link'] : "pg/$context/$username/friends",
+ 'selected' => ($filter_context == 'friends'),
+ ),
+ );
+
+ echo elgg_view('navigation/tabs', array('tabs' => $tabs));
+}
diff --git a/views/default/content/footer.php b/views/default/content/footer.php
new file mode 100644
index 000000000..66f5d3ff8
--- /dev/null
+++ b/views/default/content/footer.php
@@ -0,0 +1,8 @@
+<?php
+/**
+ * Main content footer
+ *
+ * @uses $vars['content'] The content for the footer
+ */
+
+echo $vars['content'];
diff --git a/views/default/content/header.php b/views/default/content/header.php
new file mode 100644
index 000000000..b28dc17c0
--- /dev/null
+++ b/views/default/content/header.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Main content header
+ *
+ * This includes a title and a new content button by default
+ *
+ * @uses $vars['header_override'] HTML for overriding the default header (override)
+ * @uses $vars['title'] Title text (override)
+ * @uses $vars['context'] Page context (override)
+ * @uses $vars['buttons'] Content header buttons (override)
+ */
+
+if (isset($vars['header_override'])) {
+ echo $vars['header_override'];
+ return true;
+}
+
+$context = elgg_get_array_value('context', $vars, elgg_get_context());
+if ($context) {
+ $title = elgg_get_array_value('title', $vars, '');
+ if (!$title) {
+ $title = elgg_echo($context);
+ }
+
+ if (isset($vars['buttons'])) {
+ $buttons = $vars['buttons'];
+ } else {
+ if (isloggedin() && $context) {
+ $username = get_loggedin_user()->username;
+ $new_link = elgg_get_array_value('new_link', $vars, "pg/$context/$username/new");
+ $params = array(
+ 'href' => $new_link = elgg_normalize_url($new_link),
+ 'text' => elgg_echo("$context:new"),
+ 'class' => 'action-button right',
+ );
+ $buttons = elgg_view('output/url', $params);
+ }
+ }
+ echo <<<HTML
+<div id="elgg-main-header" class="elgg-header clearfix">
+ <h2 class="elgg-module-heading">$title</h2>$buttons
+</div>
+HTML;
+}
diff --git a/views/default/content/sidebar.php b/views/default/content/sidebar.php
new file mode 100644
index 000000000..86ca8435f
--- /dev/null
+++ b/views/default/content/sidebar.php
@@ -0,0 +1,8 @@
+<?php
+/**
+ * Main content sidebar
+ *
+ * @uses $vars['content] The content for the sidebar
+ */
+
+echo $vars['content'];
diff --git a/views/default/css/screen.php b/views/default/css/screen.php
index 97303822c..18e4a0bad 100644
--- a/views/default/css/screen.php
+++ b/views/default/css/screen.php
@@ -294,6 +294,12 @@ h2 {
border-top:1px solid #DEDEDE;
}
+
+#elgg-main-header {
+ border-bottom: 1px solid #CCCCCC;
+ padding-bottom: 3px;
+}
+
#elgg-header-contents {
width:990px;
position: relative;
diff --git a/views/default/layouts/main_content.php b/views/default/layouts/main_content.php
new file mode 100644
index 000000000..7c42065b0
--- /dev/null
+++ b/views/default/layouts/main_content.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Main content area layout
+ *
+ * @uses $vars['content'] HTML of main content area
+ * @uses $vars['sidebar'] HTML of the sidebar
+ * @uses $vars['header'] HTML of the content area header (override)
+ * @uses $vars['nav'] HTML of the content area nav (override)
+ * @uses $vars['footer'] HTML of the content area footer
+ * @uses $vars['filter'] HTML of the content area filter (override)
+ * @uses $vars['title'] Title text (override)
+ * @uses $vars['context'] Page context (override)
+ * @uses $vars['buttons'] Content header buttons (override)
+ * @uses $vars['filter_context'] Filter context: everyone, friends, mine
+ */
+
+// give plugins an opportunity to add to content sidebars
+$sidebar_content = elgg_get_array_value('sidebar', $vars, '');
+$params = $vars;
+$params['content'] = $sidebar_content;
+$sidebar = elgg_view('content/sidebar', $params);
+
+// navigation defaults to breadcrumbs
+$nav = elgg_get_array_value('nav', $vars, elgg_view('navigation/breadcrumbs'));
+
+// allow page handlers to override the default header
+if (isset($vars['header'])) {
+ $vars['header_override'] = $vars['header'];
+}
+$header = elgg_view('content/header', $vars);
+
+// allow page handlers to override the default filter
+if (isset($vars['filter'])) {
+ $vars['filter_override'] = $vars['filter'];
+}
+$filter = elgg_view('content/filter', $vars);
+
+// the all important content
+$content = elgg_get_array_value('content', $vars, '');
+
+// optional footer for main content area
+$footer_content = elgg_get_array_value('footer', $vars, '');
+$params = $vars;
+$params['content'] = $footer_content;
+$footer = elgg_view('content/footer', $params);
+
+$body = $nav . $header . $filter . $content . $footer;
+
+$params = array(
+ 'content' => $body,
+ 'sidebar' => $sidebar,
+);
+echo elgg_view_layout('one_column_with_sidebar', $params);