Commit 2026396d authored by Dries's avatar Dries
Browse files

- Commited some changes made by Kjartan.
parent b0b7e038
......@@ -135,7 +135,7 @@ function blog_feed_last() {
}
function blog_page_user($uid = 0, $date = 0) {
function blog_page_user($uid = 0, $date = 0, $all = 0) {
global $theme, $user;
if ($uid) {
......@@ -149,7 +149,7 @@ function blog_page_user($uid = 0, $date = 0) {
$date = time();
}
$result = db_query("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND created <= '$date' ORDER BY nid DESC");
$result = db_query("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND created <= '$date' ORDER BY nid DESC". ($all ? "" : " LIMIT 20"));
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">";
......@@ -157,34 +157,28 @@ function blog_page_user($uid = 0, $date = 0) {
$blog = node_load(array("nid" => $node->nid));
$links = array();
if ($date != date("dny", $blog->created)) {
$date = date("dny", $blog->created);
$output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&id=$blog->uid&date=". mktime(23, 59, 59, date("n", $blog->created), date("d", $blog->created), date("Y", $blog->created)) ."\" title=\"". t("Permanent link to this blog entry.") ."\">". format_date($blog->created, custom, "d M Y") .":</a></b></td></tr>";
}
if ($user->uid && $user->uid == $uid) {
$links[] = "<a href=\"module.php?mod=node&op=edit&id=$blog->nid\" title=\"". t("Make changes to your blog entry.") ."\">". t("edit") ."</a>";
}
if ($user->uid) {
$links[] = "<a href=\"module.php?mod=node&op=add&type=blog&nid=$blog->nid\" title=\"". t("Comment on this blog entry in your personal blog.") ."\">". t("blog it") ."</a>";
}
if ($blog->comment) {
$links[] = "<a href=\"node.php?id=$blog->nid\" title=\"". t("Read this posting and all of its comments.") ."\">". format_plural(comment_num_all($blog->nid), t("comment"), t("comments")) ."</a>";
}
$links = link_node($blog, 1);
$output .= "<tr><td><div style=\"margin-left: 20px;\"><b>". check_output($blog->title) ."</b></div></td><td align=\"right\">". $theme->links($links) ."</td></tr>";
$output .= "<tr><td colspan=\"2\"><div style=\"margin-left: 40px;\">". check_output($blog->body, 1) ."</div><br /></td></tr>";
$output .= "<tr><td colspan=\"2\"><div style=\"margin-left: 40px;\">". check_output($blog->teaser, 1) ."</div><br /></td></tr>";
}
$output .= "</table>";
$output .= "<a href=\"module.php?mod=blog&op=feed&id=$account->uid\" title=\"". t("Read the XML version of this page.") ."\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a>\n";
if (!$all) {
$output .= "<a href=\"module.php?mod=blog&op=view&id=$account->uid&all=1\" title=\"". t("Show all blogs by this user") ."\">". t("show all blogs") ."</a>";
}
else {
$output .= "<a href=\"module.php?mod=blog&op=view&id=$account->uid\" title=\"". t("Show recent blogs by this user") ."\">". t("show recent blogs") ."</a>";
}
$theme->box(sprintf(t("%s's blog"), $account->name), $output, "main");
$theme->box(sprintf(t("%s's blog"), $account->name), $output);
}
function blog_page_last() {
......@@ -197,24 +191,10 @@ function blog_page_last() {
while ($node = db_fetch_object($result)) {
$blog = node_load(array("nid" => $node->nid));
$links = array();
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$blog->uid\" title=\"". sprintf(t("Read %s's latest blog entries."), $blog->name) ."\">". sprintf("%s's blog", $blog->name) ."</a>";
if ($blog->uid == $user->uid) {
$links[] = "<a href=\"module.php?mod=node&op=edit&id=$blog->nid\" title=\"". t("Edit this blog entry.") ."\">". t("edit") ."</a>";
}
if ($user->uid) {
$links[] = "<a href=\"module.php?mod=node&op=add&type=blog&nid=$blog->nid\" title=\"". t("Comment on this blog entry in your personal blog.") ."\">". t("blog it") ."</a>";
}
if ($blog->comment) {
$links[] = "<a href=\"node.php?id=$blog->nid\" title=\"". t("Read the posted comments or add a new comment.") ."\">". format_plural(comment_num_all($blog->nid), t("comment"), t("comments")) ."</a>";
}
$links = link_node($blog, 1);
$output .= "<tr><td><b>". check_output($blog->title) ."</b></td><td align=\"right\">". $theme->links($links) ."</td></tr>";
$output .= "<tr><td colspan=\"2\"><div style=\"margin-left: 20px;\">". check_output($blog->body, 1) ."</div><br /></td></tr>";
$output .= "<tr><td colspan=\"2\"><div style=\"margin-left: 20px;\">". check_output($blog->teaser, 1) ."</div><br /></td></tr>";
}
......@@ -270,7 +250,7 @@ function blog_form(&$node, &$help, &$error) {
function blog_page() {
global $theme, $id, $op, $date;
global $theme, $id, $op, $date, $all;
if (user_access("access content")) {
switch ($op) {
......@@ -285,7 +265,7 @@ function blog_page() {
default:
$theme->header();
if ($id) {
blog_page_user($id, $date);
blog_page_user($id, $date, $all);
}
else {
blog_page_last();
......@@ -301,7 +281,7 @@ function blog_page() {
}
function blog_link($type, $node = 0) {
function blog_link($type, $node = 0, $main) {
global $user;
if ($type == "page" && user_access("access content")) {
......@@ -317,11 +297,12 @@ function blog_link($type, $node = 0) {
}
if ($type == "node" && $node->type == "blog") {
global $op;
if (blog_access("update", $node)) {
$links[] = "<a href=\"module.php?mod=node&op=edit&id=$node->nid\" title=\"". t("Edit this blog entry.") ."\">". t("edit this blog") ."</a>";
}
else {
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$node->uid\" title=\"". sprintf(t("Read %s's latest blog entries."), $node->name) ."\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>";
elseif ($op != "view") {
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$node->uid\" title=\"". sprintf(t("Read %s's latest blog entries."), $node->name) ."\">". sprintf("%s's blog", $node->name) ."</a>";
}
}
......
......@@ -135,7 +135,7 @@ function blog_feed_last() {
}
function blog_page_user($uid = 0, $date = 0) {
function blog_page_user($uid = 0, $date = 0, $all = 0) {
global $theme, $user;
if ($uid) {
......@@ -149,7 +149,7 @@ function blog_page_user($uid = 0, $date = 0) {
$date = time();
}
$result = db_query("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND created <= '$date' ORDER BY nid DESC");
$result = db_query("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND created <= '$date' ORDER BY nid DESC". ($all ? "" : " LIMIT 20"));
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">";
......@@ -157,34 +157,28 @@ function blog_page_user($uid = 0, $date = 0) {
$blog = node_load(array("nid" => $node->nid));
$links = array();
if ($date != date("dny", $blog->created)) {
$date = date("dny", $blog->created);
$output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&id=$blog->uid&date=". mktime(23, 59, 59, date("n", $blog->created), date("d", $blog->created), date("Y", $blog->created)) ."\" title=\"". t("Permanent link to this blog entry.") ."\">". format_date($blog->created, custom, "d M Y") .":</a></b></td></tr>";
}
if ($user->uid && $user->uid == $uid) {
$links[] = "<a href=\"module.php?mod=node&op=edit&id=$blog->nid\" title=\"". t("Make changes to your blog entry.") ."\">". t("edit") ."</a>";
}
if ($user->uid) {
$links[] = "<a href=\"module.php?mod=node&op=add&type=blog&nid=$blog->nid\" title=\"". t("Comment on this blog entry in your personal blog.") ."\">". t("blog it") ."</a>";
}
if ($blog->comment) {
$links[] = "<a href=\"node.php?id=$blog->nid\" title=\"". t("Read this posting and all of its comments.") ."\">". format_plural(comment_num_all($blog->nid), t("comment"), t("comments")) ."</a>";
}
$links = link_node($blog, 1);
$output .= "<tr><td><div style=\"margin-left: 20px;\"><b>". check_output($blog->title) ."</b></div></td><td align=\"right\">". $theme->links($links) ."</td></tr>";
$output .= "<tr><td colspan=\"2\"><div style=\"margin-left: 40px;\">". check_output($blog->body, 1) ."</div><br /></td></tr>";
$output .= "<tr><td colspan=\"2\"><div style=\"margin-left: 40px;\">". check_output($blog->teaser, 1) ."</div><br /></td></tr>";
}
$output .= "</table>";
$output .= "<a href=\"module.php?mod=blog&op=feed&id=$account->uid\" title=\"". t("Read the XML version of this page.") ."\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a>\n";
if (!$all) {
$output .= "<a href=\"module.php?mod=blog&op=view&id=$account->uid&all=1\" title=\"". t("Show all blogs by this user") ."\">". t("show all blogs") ."</a>";
}
else {
$output .= "<a href=\"module.php?mod=blog&op=view&id=$account->uid\" title=\"". t("Show recent blogs by this user") ."\">". t("show recent blogs") ."</a>";
}
$theme->box(sprintf(t("%s's blog"), $account->name), $output, "main");
$theme->box(sprintf(t("%s's blog"), $account->name), $output);
}
function blog_page_last() {
......@@ -197,24 +191,10 @@ function blog_page_last() {
while ($node = db_fetch_object($result)) {
$blog = node_load(array("nid" => $node->nid));
$links = array();
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$blog->uid\" title=\"". sprintf(t("Read %s's latest blog entries."), $blog->name) ."\">". sprintf("%s's blog", $blog->name) ."</a>";
if ($blog->uid == $user->uid) {
$links[] = "<a href=\"module.php?mod=node&op=edit&id=$blog->nid\" title=\"". t("Edit this blog entry.") ."\">". t("edit") ."</a>";
}
if ($user->uid) {
$links[] = "<a href=\"module.php?mod=node&op=add&type=blog&nid=$blog->nid\" title=\"". t("Comment on this blog entry in your personal blog.") ."\">". t("blog it") ."</a>";
}
if ($blog->comment) {
$links[] = "<a href=\"node.php?id=$blog->nid\" title=\"". t("Read the posted comments or add a new comment.") ."\">". format_plural(comment_num_all($blog->nid), t("comment"), t("comments")) ."</a>";
}
$links = link_node($blog, 1);
$output .= "<tr><td><b>". check_output($blog->title) ."</b></td><td align=\"right\">". $theme->links($links) ."</td></tr>";
$output .= "<tr><td colspan=\"2\"><div style=\"margin-left: 20px;\">". check_output($blog->body, 1) ."</div><br /></td></tr>";
$output .= "<tr><td colspan=\"2\"><div style=\"margin-left: 20px;\">". check_output($blog->teaser, 1) ."</div><br /></td></tr>";
}
......@@ -270,7 +250,7 @@ function blog_form(&$node, &$help, &$error) {
function blog_page() {
global $theme, $id, $op, $date;
global $theme, $id, $op, $date, $all;
if (user_access("access content")) {
switch ($op) {
......@@ -285,7 +265,7 @@ function blog_page() {
default:
$theme->header();
if ($id) {
blog_page_user($id, $date);
blog_page_user($id, $date, $all);
}
else {
blog_page_last();
......@@ -301,7 +281,7 @@ function blog_page() {
}
function blog_link($type, $node = 0) {
function blog_link($type, $node = 0, $main) {
global $user;
if ($type == "page" && user_access("access content")) {
......@@ -317,11 +297,12 @@ function blog_link($type, $node = 0) {
}
if ($type == "node" && $node->type == "blog") {
global $op;
if (blog_access("update", $node)) {
$links[] = "<a href=\"module.php?mod=node&op=edit&id=$node->nid\" title=\"". t("Edit this blog entry.") ."\">". t("edit this blog") ."</a>";
}
else {
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$node->uid\" title=\"". sprintf(t("Read %s's latest blog entries."), $node->name) ."\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>";
elseif ($op != "view") {
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$node->uid\" title=\"". sprintf(t("Read %s's latest blog entries."), $node->name) ."\">". sprintf("%s's blog", $node->name) ."</a>";
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment