From b99d4d7a424bf52bc7a4e7908e1d0d1cfd0c7b87 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 14 Jul 2001 12:12:41 +0000 Subject: - theme system: + added $theme->images() - blog.module: + improved user-friendliness and rewrote most of the output routines + made quoted text /italic/ by default + integrated discussion system like it should + ... - marvin.theme: + small visual improvements --- modules/blog/blog.module | 135 ++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 84 deletions(-) (limited to 'modules/blog/blog.module') diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 5106da1f2..60fd9bb5d 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -22,86 +22,60 @@ function blog_perm() { return array("administer blogs", "access blogs", "post blogs"); } -function blog_page_all($num = 20) { - global $theme, $user; - - $result = db_query("SELECT n.timestamp, n.title, u.userid, n.nid, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id ORDER BY b.lid DESC LIMIT $num"); - - while ($blog = db_fetch_object($result)) { - $output .= blog_format_link($blog) ." "; - $output .= "userid) ."\">\"". "; - $output .= format_username($blog->userid) .", ". format_date($blog->timestamp, "small") .":
"; - $output .= "
". check_input($blog->title) ."
" . check_output($blog->body, 1) ."
\n"; - } - - $theme->header(); - $theme->box(t("Latest blogs"), $output); - $theme->footer(); +function blog_status() { + return array(dumped, posted); } -function blog_page_user($userid = 0, $date = 0) { +function blog_page_user($name = 0, $date = 0) { global $theme, $user; - $userid = $userid ? $userid : $user->userid; + $name = check_input($name ? $name : $user->userid); + $date = check_input($date ? $date : time()); - $theme->header(); - - if ($date) { - - /* - ** Displays today's blogs for this user: - */ - - blog_page_day($userid, $date); - } - else { - - /* - ** Display the last blogs for this user: - */ + $result = db_query("SELECT n.nid, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.userid = '$name' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 30"); - $result = db_query("SELECT n.nid, n.timestamp FROM node n LEFT JOIN users u ON u.id = n.author WHERE n.type = 'blog' AND u.userid = '". check_input($userid) ."' AND n.timestamp > ". (time() - 2592000) ." ORDER BY n.timestamp DESC LIMIT 20"); - while ($blog = db_fetch_object($result)) { - if ($date != date("ndy", $blog->timestamp)) { - $date = date("ndy", $blog->timestamp); - blog_page_day($userid, $blog->timestamp); + $output .= ""; + while ($blog = db_fetch_object($result)) { + if ($date != date("dny", $blog->timestamp)) { + $date = date("dny", $blog->timestamp); + if ($user->id && $user->userid == $name) { + $links = array("nid\">". t("edit") .""); + $output .= ""; + } + else { + $output .= ""; } } + $output .= ""; } + $output .= "
". format_date($blog->timestamp, custom, "d M Y") .":". $theme->links($links) ."
". format_date($blog->timestamp, custom, "d M Y") .":
". check_output($blog->body, 1) ."
"; + + $theme->header(); + $theme->box(strtr(t("%a's blog"), array("%a" => $name)), $output, "main"); $theme->footer(); } - -function blog_page_day($userid = 0, $date = 0) { +function blog_page_view($num = 20) { global $theme, $user; - $header .= "\n"; - $header .= " \n"; - $header .= " \n"; - $header .= " \n"; - $header .= " \n"; - $header .= "
". check_output($userid) ."'s ". t("blog") ."". format_date($date, custom, "d-M-Y") ."
\n"; - - $sdate = mktime(0, 0, 0, date("m", $date), date("d", $date), date("Y", $date)); - $edate = mktime(23, 59, 59, date("m", $date), date("d", $date), date("Y", $date)); - - $result = db_query("SELECT b.body, n.timestamp, n.nid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.userid = '". check_input($userid) ."' AND n.timestamp > '$sdate' AND n.timestamp < '$edate' ORDER BY b.lid DESC LIMIT 50"); + $result = db_query("SELECT n.timestamp, n.title, u.userid, n.nid, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id ORDER BY b.lid DESC LIMIT $num"); + $output .= ""; while ($blog = db_fetch_object($result)) { - if (!$first) $first = $blog->nid; - $output .= "

". blog_format_link($blog) . check_output($blog->body, 1) ."

\n"; - } + $links[] = "userid) ."\">". strtr(t("%a's blog"), array("%a" => $blog->userid)) .""; + $links[] = "nid\">". t("blog") .""; + $links[] = "nid\">". t("discuss") .""; - if ($user->id && $user->userid == $userid) { - $output .= "

[ ". t("edit") ." ]

"; + $output .= ""; + $output .= ""; + unset($links); } + $output .= "
$blog->title". $theme->links($links) ."
$blog->body
"; - $theme->box($header, $output); -} - -function blog_status() { - return array(dumped, posted); + $theme->header(); + $theme->box(t("User blogs"), $output, "main"); + $theme->footer(); } function blog_remove($nid) { @@ -124,20 +98,9 @@ function blog_format_link($blog) { } function blog_view($node, $main = 0) { - global $status, $theme; - - $userid = urlencode($node->userid); + global $theme; - $header .= ""; - $header .= " "; - $header .= " "; - $header .= " "; - $header .= " "; - $header .= "
". $node->userid ."'s ". t("blog") ."timestamp\">". format_date($node->timestamp, custom, "d-M-Y") ."
"; - - $output .= check_output($node->body, 1) ."

[ ". implode(" | ", link_node($node)) ." ]

"; - - $theme->box($header, $output); + $theme->node($node, $main); } function blog_form($edit = array()) { @@ -151,12 +114,12 @@ function blog_form($edit = array()) { else if ($type == "blog") { $item = node_get_object(array(type => "blog", nid => $id)); $edit["title"] = $item->title; - $edit["body"] = $item->body ." [userid) ."&date=$item->timestamp\">$item->userid]"; + $edit["body"] = "". $item->body ." [userid) ."&date=$item->timestamp\">$item->userid]"; } else if ($type == "import") { $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = '". check_input($id) ."' AND i.fid = f.fid")); $edit["title"] = $item->title; - $edit["body"] = "link\">$item->title - ". check_output($item->description) ." [flink\">$item->ftitle]\n"; + $edit["body"] = "link\">$item->title - ". check_output($item->description) ." [flink\">$item->ftitle]\n"; } if ($edit["title"]) { @@ -237,7 +200,7 @@ function blog_page() { blog_page_user($name, $date); } else { - blog_page_all(); + blog_page_view(); } } else { @@ -252,31 +215,31 @@ function blog_user() { switch ($op) { case "delete": blog_remove($id); - blog_page_day($user->userid, time()); + blog_page_user($user->userid, time()); break; case "edit": - $theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog")))); - $theme->box(t("Older blogs"), blog_edit_history($id)); + $theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog"))), "main"); + $theme->box(t("Older blogs"), blog_edit_history($id), "main"); break; case t("Preview"): - $theme->box(t("Preview Blog"), blog_form($edit)); + $theme->box(t("Preview Blog"), blog_form($edit), "main"); break; case t("Submit"): blog_save($edit); - blog_page_day($user->userid, time()); + blog_page_user($user->userid, time()); break; default: - $theme->box(t("Submit a blog"), blog_form($edit)); + $theme->box(t("Submit a blog"), blog_form($edit), "main"); } } } -function blog_link($type) { +function blog_link($type, $node = 0) { global $user; if ($type == "page" && user_access("access blogs")) { - $links[] = "". t("latest blogs") .""; + $links[] = "". t("user blogs") .""; } if ($type == "menu" && user_access("post blogs")) { @@ -284,6 +247,10 @@ function blog_link($type) { $links[] = "userid) ."\">". t("view your blog") .""; } + if ($type == "node" && $node) { + $links[] = "userid) ."\">". strtr(t("%a's blog"), array("%a" => $node->userid)) .""; + } + return $links ? $links : array(); } -- cgit v1.2.3