From 8043cb998f3325731bfab8d82251fa49639aec1d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 20 Apr 2002 11:52:50 +0000 Subject: - Applied Marco's big patch, including contributions from Moshe: + Changed the db_query() API. + Wrapped all links in l(), lm(), la(), ..., drupal_url() functions. + XHTML-ified some HTML. + Wrapped a lot of text in the administrative pages in a t() function. + Replaced all $REQUEST_URI/$PATH_INFOs by request_uri(). + Small bugfixes (eg. bug in book_export_html() and clean-ups (eg. RSS code). + Fixed some bugs in the taxonomy module (eg. tree making bug), added new functionality (eg. new APIs for use by other modules), included Moshe's taxonomy extensions, and some documentation udpates. + ... --- modules/blog.module | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'modules/blog.module') diff --git a/modules/blog.module b/modules/blog.module index fc9fc5bbf..09d588b8d 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -40,8 +40,6 @@ function blog_access($op, $node) { } function blog_save($op, $node) { - global $REQUEST_URI; - if ($op == "approve") { return array("promote" => 1); } @@ -102,13 +100,13 @@ function blog_feed_user($uid = 0, $date = 0) { $result = db_query("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = '$uid' AND n.created > '". ($date - 2592000) ."' ORDER BY n.nid DESC LIMIT 15"); while ($blog = db_fetch_object($result)) { - $items .= format_rss_item($blog->title, path_uri() ."node.php?id=$blog->nid", $blog->teaser); + $items .= format_rss_item($blog->title, path_uri() . drupal_url(array("id" => $blog->nid)), $blog->teaser); } $output .= "\n"; // $output .= "\n"; $output .= "\n"; - $output .= format_rss_channel("$account->name's blog", path_uri() ."module.php?mod=blog&op=view&id=$account->uid", "$account->name's blog", $items); + $output .= format_rss_channel("$account->name's blog", path_uri() . drupal_url(array("mod" => "blog", "op" => "view", "id" => $account->uid), "module"), "$account->name's blog", $items); $output .= "\n"; header("Content-Type: text/xml"); @@ -121,12 +119,12 @@ function blog_feed_last() { $result = db_query("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 15"); while ($blog = db_fetch_object($result)) { - $items .= format_rss_item($blog->title, path_uri() ."node.php?id=$blog->nid", $blog->teaser); + $items .= format_rss_item($blog->title, path_uri() . drupal_url(array("id" => $blog->nid)), $blog->teaser); } $output .= "\n"; $output .= "\n"; - $output .= format_rss_channel(variable_get("site_name", "drupal") .": user blogs", path_uri() ."module.php?mod=blog", "Recently updated blogs.", $items); + $output .= format_rss_channel(variable_get("site_name", "drupal") .": user blogs", path_uri() . drupal_url(array("mod" => "blog"), "module"), "Recently updated blogs.", $items); $output .= "\n"; header("Content-Type: text/xml"); @@ -159,7 +157,7 @@ function blog_page_user($uid = 0, $date = 0, $all = 0) { if ($date != date("dny", $blog->created)) { $date = date("dny", $blog->created); - $output .= "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") .":"; + $output .= "".lm(format_date($blog->created, custom, "d M Y"), array("mod" => "blog", "id" => $blog->uid, "date" => mktime(23, 59, 59, date("n", $blog->created), date("d", $blog->created), date("Y", $blog->created))), t("Permanent link to this blog entry.")).""; } $links = link_node($blog, 1); @@ -170,15 +168,15 @@ function blog_page_user($uid = 0, $date = 0, $all = 0) { } $output .= ""; - $output .= "uid\" title=\"". t("Read the XML version of this page.") ."\">image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" />\n"; + $output .= lm("image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" />", array("mod" => "blog", "op" => "feed", "id" => $account->uid), t("Read the XML version of this page."))."\n"; if (!$all) { - $output .= "uid&all=1\" title=\"". t("Show all blogs by this user") ."\">". t("show all blogs") .""; + $output .= lm(t("show all blogs"), array("mod" => "blog", "op" => "view", "id" => $account->uid, "all" => 1), t("Show all blogs by this user")); } else { - $output .= "uid\" title=\"". t("Show recent blogs by this user") ."\">". t("show recent blogs") .""; + $output .= lm(t("show recent blogs"), array("mod" => "blog", "op" => "view", "id" => $account->uid), t("Show recent blogs by this user")); } - $theme->box(strtr(t("%u's blog"), array("%u" => $account->name)), $output); + $theme->box(t("%u's blog", array("%u" => $account->name)), $output); } function blog_page_last() { @@ -199,7 +197,7 @@ function blog_page_last() { } $output .= ""; - $output .= "image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" />\n"; + $output .= lm("image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" />", array("mod" => "blog", "op" => "feed"), t("Read the XML version of this page."))."\n"; $theme->box(t("User blogs"), $output, "main"); } @@ -231,10 +229,10 @@ function blog_form(&$node, &$help, &$error) { */ if ($nid && $blog = node_load(array("nid" => $nid))) { - $node->body = "". $blog->body ." [uid&date=$blog->created\">$blog->name]"; + $node->body = "". $blog->body ." [".lm($blog->name, array("mod" => "blog", "id" => $blog->uid, "date" => $blog->created))."]"; } - if ($iid && $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($iid) ."' AND i.fid = f.fid"))) { + if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = '%s' AND i.fid = f.fid", $iid))) { $node->body = "link\">$item->title - ". check_output($item->description) ." [flink\">$item->ftitle]\n"; } } @@ -287,24 +285,24 @@ function blog_link($type, $node = 0, $main) { global $user; if ($type == "page" && user_access("access content")) { - $links[] = "". t("user blogs") .""; + $links[] = lm(t("user blogs"), array("mod" => "blog"), t("Read the latest blog entries.")); } if ($type == "menu.create" && user_access("post content")) { - $links[] = "". t("create blog entry") .""; + $links[] = lm(t("create blog entry"), array("mod" => "node", "op" => "add", "type" => "blog"), t("Add a new personal blog entry.")); } if ($type == "menu.view" && user_access("access content")) { - $links[] = "uid\" title=\"". t("Read your latest blog entries.") ."\">". t("view personal blog") .""; + $links[] = lm(t("view personal blog"), array("mod" => "blog", "op" => "view", "id" => $user->uid), t("Read your latest blog entries.")); } if ($type == "node" && $node->type == "blog") { global $op; if (blog_access("update", $node)) { - $links[] = "nid\" title=\"". t("Edit this blog entry.") ."\">". t("edit this blog") .""; + $links[] = lm(t("edit this blog"), array("mod" => "node", "op" => "edit", "id" => $node->nid), t("Edit this blog entry.")); } else { - $links[] = "uid\" title=\"". strtr(t("Read %u's latest blog entries."), array("%u" => $node->name)) ."\">". strtr(t("%u's blog"), array("%u" => $node->name)) .""; + $links[] = lm(t("%u's blog", array("%u" => $node->name)), array("mod" => "blog", "op" => "view", "id" => $node->uid), t("Read %u's latest blog entries.", array("%u" => $node->name))); } } @@ -317,15 +315,15 @@ function blog_block() { $result = db_query("SELECT u.uid, u.name, n.created, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10"); while ($node = db_fetch_object($result)) { - $output .= "nid\">". check_output($node->title) ."
\n"; + $output .= l(check_output($node->title), array("id" => $node->nid))."
\n"; } - $output .= "
". t("more") ."
"; + $output .= "
".lm(t("more"), array("mod" => "blog"), t("Read the latest blog entries."))."
"; $block[0]["subject"] = t("User blogs"); $block[0]["content"] = $output; $block[0]["info"] = t("User blogs"); - $block[0]["link"] = "module.php?mod=blog"; + $block[0]["link"] = drupal_url(array("mod" => "blog"), "module"); return $block; } -- cgit v1.2.3