Commit a6a47a32 authored by Dries's avatar Dries

- Applied Moshe's "theme head" patch:

  "This patch to theme.inc adds the ability for modules to insert HTML
   into the <HEAD> section of all web pages. The additional modules in
   this directory [ed: blog.module] demonstate possible uses for the
   new _head() hook."
parent 562df8fe
......@@ -20,7 +20,9 @@ function system($field) {
function header($title = "") {
$output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n";
$output .= "<html><head><title>". variable_get(site_name, "drupal") ."</title></head><body bgcolor=\"$this->background\" text=\"$this->foreground\">";
$output .= "<html><head><title>". variable_get(site_name, "drupal") ."</title>";
$output .= theme_head($main);
$output .= "</head><body bgcolor=\"$this->background\" text=\"$this->foreground\">";
$output .= "<table border=\"0\" cellspacing=\"4\" cellpadding=\"4\"><tr><td valign=\"top\" width=\"170\">";
print $output;
......@@ -122,6 +124,11 @@ function theme_list() {
return $list;
}
function theme_head($main = 0) {
$head = module_invoke_all("head", $main);
return "\n". implode($head, "\n"). "\n";
}
function theme_init() {
global $user;
......
......@@ -6,7 +6,6 @@ function blog_system($field){
return $system[$field];
}
function blog_conf_options() {
$output = form_textarea(t("Explanation or submission guidelines"), "blog_help", variable_get("blog_help", ""), 55, 4, t("This text is displayed at the top of the blog submission form. It's useful for helping or instructing your users."));
$words = t("words");
......@@ -45,6 +44,16 @@ function blog_access($op, $node) {
}
function blog_head($main = 0) {
global $id, $mod;
if ($mod && $id) {
$account = user_load(array("uid" => $id));
$output[] = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS - ". $account->name. "'s blog\" href=\"". path_uri(). "module.php?mod=blog&op=view&id=$id\" />";
}
return $output ? $output : array();
}
function blog_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
......@@ -92,7 +101,6 @@ function blog_save($op, $node) {
}
function blog_help() {
?>
<p>Drupal's blog module allows registered users to maintain an online blog, often referred to as an online journal or diary. They can be filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption. It is made up of individual entries that are timestamped and are typically viewed by day as you would a diary. Blogs often contain links to things you've seen, or agree/disagree with. A typical example of a long term blog can be seen at <a href="http://www.scripting.com/">http://www.scripting.com/</a>.</p>
......@@ -117,37 +125,21 @@ 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() . drupal_url(array("id" => $blog->nid)), $blog->teaser);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
// $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">\n";
$output .= "<rss version=\"0.91\">\n";
$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 .= "</rss>\n";
header("Content-Type: text/xml");
print $output;
$channel["title"] = $account->name. "'s blog";
$channel["link"] = path_uri(). drupal_url(array ("mod" => "blog", "op" => "view", "id" => $uid), "module");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
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() . drupal_url(array("id" => $blog->nid)), $blog->teaser);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
$output .= "<rss version=\"0.91\">\n";
$output .= format_rss_channel(variable_get("site_name", "drupal") .": user blogs", path_uri() . drupal_url(array("mod" => "blog"), "module"), "Recently updated blogs.", $items);
$output .= "</rss>\n";
header("Content-Type: text/xml");
print $output;
$channel["title"] = variable_get("site_name", "drupal"). "blogs";
$channel["link"] = path_uri(). drupal_url(array ("mod" => "blog", "op" => "view"), "module");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
......
......@@ -6,7 +6,6 @@ function blog_system($field){
return $system[$field];
}
function blog_conf_options() {
$output = form_textarea(t("Explanation or submission guidelines"), "blog_help", variable_get("blog_help", ""), 55, 4, t("This text is displayed at the top of the blog submission form. It's useful for helping or instructing your users."));
$words = t("words");
......@@ -45,6 +44,16 @@ function blog_access($op, $node) {
}
function blog_head($main = 0) {
global $id, $mod;
if ($mod && $id) {
$account = user_load(array("uid" => $id));
$output[] = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS - ". $account->name. "'s blog\" href=\"". path_uri(). "module.php?mod=blog&op=view&id=$id\" />";
}
return $output ? $output : array();
}
function blog_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
......@@ -92,7 +101,6 @@ function blog_save($op, $node) {
}
function blog_help() {
?>
<p>Drupal's blog module allows registered users to maintain an online blog, often referred to as an online journal or diary. They can be filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption. It is made up of individual entries that are timestamped and are typically viewed by day as you would a diary. Blogs often contain links to things you've seen, or agree/disagree with. A typical example of a long term blog can be seen at <a href="http://www.scripting.com/">http://www.scripting.com/</a>.</p>
......@@ -117,37 +125,21 @@ 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() . drupal_url(array("id" => $blog->nid)), $blog->teaser);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
// $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">\n";
$output .= "<rss version=\"0.91\">\n";
$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 .= "</rss>\n";
header("Content-Type: text/xml");
print $output;
$channel["title"] = $account->name. "'s blog";
$channel["link"] = path_uri(). drupal_url(array ("mod" => "blog", "op" => "view", "id" => $uid), "module");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
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() . drupal_url(array("id" => $blog->nid)), $blog->teaser);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
$output .= "<rss version=\"0.91\">\n";
$output .= format_rss_channel(variable_get("site_name", "drupal") .": user blogs", path_uri() . drupal_url(array("mod" => "blog"), "module"), "Recently updated blogs.", $items);
$output .= "</rss>\n";
header("Content-Type: text/xml");
print $output;
$channel["title"] = variable_get("site_name", "drupal"). "blogs";
$channel["link"] = path_uri(). drupal_url(array ("mod" => "blog", "op" => "view"), "module");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
......
......@@ -30,6 +30,7 @@ function header($title = "") {
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<?php print theme_head($main); ?>
<title><?php echo ($title ? ($title . " - ") : "") . variable_get(site_name, "drupal"); ?></title>
<style type="text/css">
<!--
......
......@@ -32,6 +32,7 @@ function header($title = "") {
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<?php print theme_head($main); ?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
<?php
......
......@@ -50,6 +50,7 @@ function header($title = "") {
?>
<HTML>
<HEAD>
<?php print theme_head($main); ?>
<TITLE><?php echo ($title ? ($title . " - ") : "") . variable_get(site_name, "drupal"); ?></TITLE>
<STYLE type="text/css">
<!--
......
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