diff options
-rw-r--r-- | database/database.mssql | 3 | ||||
-rw-r--r-- | database/database.mysql | 1 | ||||
-rw-r--r-- | database/database.pgsql | 1 | ||||
-rw-r--r-- | includes/bootstrap.inc | 11 | ||||
-rw-r--r-- | includes/common.inc | 70 | ||||
-rw-r--r-- | includes/theme.inc | 22 | ||||
-rw-r--r-- | modules/aggregator.module | 3 | ||||
-rw-r--r-- | modules/aggregator/aggregator.module | 3 | ||||
-rw-r--r-- | modules/blog.module | 2 | ||||
-rw-r--r-- | modules/blog/blog.module | 2 | ||||
-rw-r--r-- | modules/node.module | 3 | ||||
-rw-r--r-- | modules/node/node.module | 3 | ||||
-rw-r--r-- | modules/taxonomy.module | 2 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 2 | ||||
-rw-r--r-- | themes/chameleon/chameleon.theme | 2 | ||||
-rw-r--r-- | themes/marvin/marvin.theme | 2 | ||||
-rw-r--r-- | themes/xtemplate/xtemplate.theme | 2 | ||||
-rw-r--r-- | update.php | 7 |
18 files changed, 94 insertions, 47 deletions
diff --git a/database/database.mssql b/database/database.mssql index d87740512..77a022002 100644 --- a/database/database.mssql +++ b/database/database.mssql @@ -68,7 +68,8 @@ CREATE TABLE [dbo].[cache] ( [cid] [varchar] (255) NOT NULL , [data] [text] NULL , [expire] [int] NOT NULL , - [created] [int] NOT NULL + [created] [int] NOT NULL , + [headers] [text] NOT NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO diff --git a/database/database.mysql b/database/database.mysql index fd9b300bb..a876a3084 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -108,6 +108,7 @@ CREATE TABLE cache ( data longtext, expire int(11) NOT NULL default '0', created int(11) NOT NULL default '0', + headers text, PRIMARY KEY (cid) ) TYPE=MyISAM; diff --git a/database/database.pgsql b/database/database.pgsql index a125d4ca1..2cc7feaf3 100644 --- a/database/database.pgsql +++ b/database/database.pgsql @@ -106,6 +106,7 @@ CREATE TABLE cache ( data text default '', expire integer NOT NULL default '0', created integer NOT NULL default '0', + headers text default '', PRIMARY KEY (cid) ); diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 9f59b7237..ed274055d 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -60,14 +60,14 @@ function variable_del($name) { } function cache_get($key) { - $cache = db_fetch_object(db_query("SELECT data, created FROM {cache} WHERE cid = '%s'", $key)); + $cache = db_fetch_object(db_query("SELECT data, created, headers FROM {cache} WHERE cid = '%s'", $key)); return $cache->data ? $cache : 0; } -function cache_set($cid, $data, $expire = 0) { - db_query("UPDATE {cache} SET data = '%s', created = %d, expire = %d WHERE cid = '%s'", $data, time(), $expire, $cid); +function cache_set($cid, $data, $expire = 0, $headers = NULL) { + db_query("UPDATE {cache} SET data = '%s', created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, time(), $expire, $headers, $cid); if (!db_affected_rows()) { - db_query("INSERT INTO {cache} (cid, data, created, expire) VALUES('%s', '%s', %d, %d)", $cid, $data, time(), $expire); + db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES('%s', '%s', %d, %d, '%s')", $cid, $data, time(), $expire, $headers); } } @@ -85,7 +85,7 @@ function page_set_cache() { if (!$user->uid && $_SERVER["REQUEST_METHOD"] == "GET") { if ($data = ob_get_contents()) { - cache_set(request_uri(), $data, 1); + cache_set(request_uri(), $data, 1, drupal_get_headers()); } } } @@ -137,6 +137,7 @@ function drupal_page_header() { // Send appropriate response: header("Last-Modified: $date"); header("ETag: $etag"); + header($cache->headers); print $cache->data; /* diff --git a/includes/common.inc b/includes/common.inc index 55f3e6520..26e0d1681 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -88,6 +88,36 @@ function drupal_get_breadcrumb() { /* @} */ /** + * @name HTML head contents + * @ingroup common + * + * Set and get output that should be in the \<head\> tag. + * @{ + */ + +function drupal_set_html_head($data = NULL) { + static $stored_head; + + if (!is_null($data)) { + $stored_head .= "$data\n"; + } + return $stored_head; +} + +function drupal_get_html_head() { + global $base_url; + + $output = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; + $output .= "<base href=\"$base_url/\" />\n"; + $output .= "<style type=\"text/css\">\n"; + $output .= "@import url(misc/drupal.css);\n"; + $output .= "</style>\n"; + + return $output . drupal_set_html_head(); +} +/* @} */ + +/** * @name URL path * @ingroup common * @@ -124,6 +154,28 @@ function drupal_rebuild_path_map() { */ /** + * @name HTTP headers + * @ingroup common + * + * Functions to get and set the HTTP headers of the current page. + * @{ + */ +function drupal_set_header($header = NULL) { + static $stored_headers; + + if (!is_null($header)) { + header($header); + $stored_headers .= "$header\n"; + } + return $stored_headers; +} + +function drupal_get_headers() { + return drupal_set_header(); +} +/* @} */ + +/** * HTTP redirects. Makes sure the redirected url is formatted correctly and * includes the session ID. * @@ -915,8 +967,6 @@ function drupal_get_normal_path($path) { } function url($url = NULL, $query = NULL, $fragment = NULL) { - global $base_url; - static $script; if (empty($script)) { @@ -939,36 +989,36 @@ function url($url = NULL, $query = NULL, $fragment = NULL) { if (variable_get("clean_url", "0") == "0") { if (isset($url)) { if (isset($query)) { - return "$base_url/$script?q=$url&$query$fragment"; + return "$script?q=$url&$query$fragment"; } else { - return "$base_url/$script?q=$url$fragment"; + return "$script?q=$url$fragment"; } } else { if (isset($query)) { - return "$base_url/$script?$query$fragment"; + return "$script?$query$fragment"; } else { - return "$base_url/$fragment"; + return "$fragment"; } } } else { if (isset($url)) { if (isset($query)) { - return "$base_url/$url?$query$fragment"; + return "$url?$query$fragment"; } else { - return "$base_url/$url$fragment"; + return "$url$fragment"; } } else { if (isset($query)) { - return "$base_url/$script?$query$fragment"; + return "$script?$query$fragment"; } else { - return "$base_url/$fragment"; + return "$fragment"; } } } diff --git a/includes/theme.inc b/includes/theme.inc index e5b5ccbed..0bd2416bf 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -137,7 +137,7 @@ function theme_header() { $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; $output .= "<head>"; $output .= " <title>". (drupal_get_title() ? drupal_get_title() : variable_get('site_name', "drupal")) ."</title>"; - $output .= theme_head(); + $output .= drupal_get_html_head(); $output .= " <style type=\"text/css\" media=\"all\">"; $output .= " @import url(misc/drupal.css);"; $output .= " </style>"; @@ -462,26 +462,6 @@ function theme_xml_icon($url) { } /** - * Execute hook _head which is run at the start of the page, and output should - * be in the head tags. - * - * @param $main (optional) - * - * @return a string containing the @a error output. - */ -function theme_head($main = 0) { - global $base_url; - $output .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; - $output .= "<base href=\"$base_url/\" />\n"; - $output .= "<style type=\"text/css\">\n"; - $output .= "@import url(misc/drupal.css);\n"; - $output .= "</style>\n"; - $head = module_invoke_all("head", $main); - $output .= implode($head, "\n"); - return $output; -} - -/** * Execute hook _footer() which is run at the end of the page right before the * \</body> tag. * diff --git a/modules/aggregator.module b/modules/aggregator.module index e7c807961..da9ecb4da 100644 --- a/modules/aggregator.module +++ b/modules/aggregator.module @@ -729,8 +729,7 @@ function aggregator_page_opml() { $output .= "</body>\n"; $output .= "</opml>\n"; - header("Content-Type: text/xml"); - + drupal_set_header("Content-Type: text/xml; charset=utf-8"); print $output; } diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index e7c807961..da9ecb4da 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -729,8 +729,7 @@ function aggregator_page_opml() { $output .= "</body>\n"; $output .= "</opml>\n"; - header("Content-Type: text/xml"); - + drupal_set_header("Content-Type: text/xml; charset=utf-8"); print $output; } diff --git a/modules/blog.module b/modules/blog.module index eb0a52d79..5ee3470ce 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -125,6 +125,7 @@ function blog_page_user($uid) { $output .= theme('pager', NULL, variable_get("default_nodes_main", 10)); $output .= theme('xml_icon', url("blog/feed/$account->uid")); + drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url("blog/feed/$account->uid") .'">'); print theme("page", $output, $title); } @@ -141,6 +142,7 @@ function blog_page_last() { $output .= theme('pager', NULL, variable_get("default_nodes_main", 10)); $output .= theme('xml_icon', url('blog/feed')); + drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - blogs" href="'. url('blog/feed') .'">'); print theme("page", $output); } diff --git a/modules/blog/blog.module b/modules/blog/blog.module index eb0a52d79..5ee3470ce 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -125,6 +125,7 @@ function blog_page_user($uid) { $output .= theme('pager', NULL, variable_get("default_nodes_main", 10)); $output .= theme('xml_icon', url("blog/feed/$account->uid")); + drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url("blog/feed/$account->uid") .'">'); print theme("page", $output, $title); } @@ -141,6 +142,7 @@ function blog_page_last() { $output .= theme('pager', NULL, variable_get("default_nodes_main", 10)); $output .= theme('xml_icon', url('blog/feed')); + drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - blogs" href="'. url('blog/feed') .'">'); print theme("page", $output); } diff --git a/modules/node.module b/modules/node.module index 7f1b2a532..0800cb94f 100644 --- a/modules/node.module +++ b/modules/node.module @@ -964,7 +964,7 @@ function node_feed($nodes = 0, $channel = array()) { $output .= format_rss_channel($channel["title"], $channel["link"], $channel["description"], $items, $channel["language"]); $output .= "</rss>\n"; - header("Content-Type: text/xml"); + drupal_set_header("Content-Type: text/xml; charset=utf-8"); print $output; } @@ -1506,6 +1506,7 @@ function node_page() { $output .= node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1); } $output .= theme('pager', NULL, variable_get("default_nodes_main", 10)); + drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS" href="'. url('node/feed') .'">'); print theme("page", $output, ""); } } diff --git a/modules/node/node.module b/modules/node/node.module index 7f1b2a532..0800cb94f 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -964,7 +964,7 @@ function node_feed($nodes = 0, $channel = array()) { $output .= format_rss_channel($channel["title"], $channel["link"], $channel["description"], $items, $channel["language"]); $output .= "</rss>\n"; - header("Content-Type: text/xml"); + drupal_set_header("Content-Type: text/xml; charset=utf-8"); print $output; } @@ -1506,6 +1506,7 @@ function node_page() { $output .= node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1); } $output .= theme('pager', NULL, variable_get("default_nodes_main", 10)); + drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS" href="'. url('node/feed') .'">'); print theme("page", $output, ""); } } diff --git a/modules/taxonomy.module b/modules/taxonomy.module index cc6f92ec5..40b3e3472 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -751,6 +751,8 @@ function taxonomy_page() { $breadcrumbs[] = l(t('Home'), ''); $breadcrumbs = array_reverse($breadcrumbs); + drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. implode(' : ', $names) .'" href="'. url("taxonomy/feed/or/$taxonomy->str_tids") .'">'); + $output = taxonomy_render_nodes(taxonomy_select_nodes($taxonomy)); print theme("page", $output, implode(', ', $names), $breadcrumbs); break; diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index cc6f92ec5..40b3e3472 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -751,6 +751,8 @@ function taxonomy_page() { $breadcrumbs[] = l(t('Home'), ''); $breadcrumbs = array_reverse($breadcrumbs); + drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. implode(' : ', $names) .'" href="'. url("taxonomy/feed/or/$taxonomy->str_tids") .'">'); + $output = taxonomy_render_nodes(taxonomy_select_nodes($taxonomy)); print theme("page", $output, implode(', ', $names), $breadcrumbs); break; diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme index a162bb33e..0bb52adb0 100644 --- a/themes/chameleon/chameleon.theme +++ b/themes/chameleon/chameleon.theme @@ -38,7 +38,7 @@ function chameleon_header($title = "") { $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n"; $output .= "<head>\n"; $output .= " <title>". ($title ? $title ." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n"; - $output .= theme_head(); + $output .= drupal_get_html_head(); $output .= " <link rel=\"stylesheet\" type=\"text/css\" href=\"themes/chameleon/default.css\" />\n"; $output .= " <link rel=\"stylesheet\" type=\"text/css\" href=\"". variable_get("chameleon_stylesheet", "themes/chameleon/pure.css") ."\" />\n"; $output .= "</head>"; diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme index b2d8d8316..0c090370a 100644 --- a/themes/marvin/marvin.theme +++ b/themes/marvin/marvin.theme @@ -19,7 +19,7 @@ function marvin_header() { $output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; $output .= "<html>\n"; $output .= "<head>\n"; - $output .= theme_head($main); + $output .= drupal_get_html_head(); $output .= "<title>"; if ($title = drupal_get_title()) { diff --git a/themes/xtemplate/xtemplate.theme b/themes/xtemplate/xtemplate.theme index 1c5e6e977..bac833398 100644 --- a/themes/xtemplate/xtemplate.theme +++ b/themes/xtemplate/xtemplate.theme @@ -92,7 +92,7 @@ function xtemplate_header() { $xtemplate->template->assign(array( "head_title" => (drupal_get_title() ? drupal_get_title() ." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")), "site" => variable_get("site_name", "drupal"), - "head" => theme_head(), + "head" => drupal_get_html_head(), "stylesheet" => variable_get("xtemplate_stylesheet", "themes/xtemplate/xtemplate.css"), "onload_attributes" => theme_onload_attribute(), "logo" => variable_get("xtemplate_logo", "<img src=\"themes/xtemplate/images/druplicon.gif\" />"), diff --git a/update.php b/update.php index 0ef7aef62..f4b07e769 100644 --- a/update.php +++ b/update.php @@ -65,7 +65,8 @@ $mysql_updates = array( "2003-12-03" => "update_73", "2003-12-06" => "update_74", "2004-01-06" => "update_75", - "2004-01-11" => "update_76" + "2004-01-11" => "update_76", + "2004-01-13" => "update_77" ); function update_32() { @@ -604,6 +605,10 @@ function update_76() { update_sql("ALTER TABLE {feed} ADD image longtext"); } +function update_77() { + update_sql("ALTER TABLE {cache} ADD headers text"); +} + /* ** System functions */ |