Commit a448f5a9 authored by Dries's avatar Dries

- Charset simpliciations.  Patch #46 by Al.
parent ff914280
...@@ -203,7 +203,7 @@ function variable_del($name) { ...@@ -203,7 +203,7 @@ function variable_del($name) {
} }
function drupal_specialchars($input) { function drupal_specialchars($input) {
return htmlspecialchars($input, ENT_NOQUOTES, variable_get("site_charset", "iso-8859-1")); return htmlspecialchars($input, ENT_NOQUOTES, "utf-8");
} }
function table_cell($cell, $header = 0) { function table_cell($cell, $header = 0) {
...@@ -1025,7 +1025,7 @@ function drupal_page_footer() { ...@@ -1025,7 +1025,7 @@ function drupal_page_footer() {
set_error_handler("error_handler"); set_error_handler("error_handler");
// spit out the correct charset http header // spit out the correct charset http header
header("Content-Type: text/html; charset=". variable_get("site_charset", "iso-8859-1")); header("Content-Type: text/html; charset=utf-8");
// initialize installed modules: // initialize installed modules:
module_init(); module_init();
......
...@@ -144,7 +144,7 @@ function theme_list($refresh = 0) { ...@@ -144,7 +144,7 @@ function theme_list($refresh = 0) {
function theme_head($main = 0) { function theme_head($main = 0) {
global $base_url; global $base_url;
$output .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=". variable_get("site_charset", "iso-8859-1") ."\" />"; $output .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
$output .= "<base href=\"$base_url/\" />\n"; $output .= "<base href=\"$base_url/\" />\n";
$output .= "<style type=\"text/css\">\n"; $output .= "<style type=\"text/css\">\n";
$output .= "@import url(misc/drupal.css);\n"; $output .= "@import url(misc/drupal.css);\n";
......
...@@ -706,7 +706,7 @@ function import_page_fd() { ...@@ -706,7 +706,7 @@ function import_page_fd() {
$result = db_query("SELECT * FROM feed ORDER BY title"); $result = db_query("SELECT * FROM feed ORDER BY title");
$output .= "<?xml version=\"1.0\" encoding=\"". variable_get("site_charset", "iso-8859-1") ."\"?>\n\n"; $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n";
$output .= "<rssfeeds version=\"0.1\">\n\n"; $output .= "<rssfeeds version=\"0.1\">\n\n";
while ($feed = db_fetch_object($result)) { while ($feed = db_fetch_object($result)) {
......
...@@ -706,7 +706,7 @@ function import_page_fd() { ...@@ -706,7 +706,7 @@ function import_page_fd() {
$result = db_query("SELECT * FROM feed ORDER BY title"); $result = db_query("SELECT * FROM feed ORDER BY title");
$output .= "<?xml version=\"1.0\" encoding=\"". variable_get("site_charset", "iso-8859-1") ."\"?>\n\n"; $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n";
$output .= "<rssfeeds version=\"0.1\">\n\n"; $output .= "<rssfeeds version=\"0.1\">\n\n";
while ($feed = db_fetch_object($result)) { while ($feed = db_fetch_object($result)) {
......
...@@ -706,7 +706,7 @@ function import_page_fd() { ...@@ -706,7 +706,7 @@ function import_page_fd() {
$result = db_query("SELECT * FROM feed ORDER BY title"); $result = db_query("SELECT * FROM feed ORDER BY title");
$output .= "<?xml version=\"1.0\" encoding=\"". variable_get("site_charset", "iso-8859-1") ."\"?>\n\n"; $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n";
$output .= "<rssfeeds version=\"0.1\">\n\n"; $output .= "<rssfeeds version=\"0.1\">\n\n";
while ($feed = db_fetch_object($result)) { while ($feed = db_fetch_object($result)) {
......
...@@ -879,12 +879,11 @@ function node_feed($nodes = 0, $channel = array()) { ...@@ -879,12 +879,11 @@ function node_feed($nodes = 0, $channel = array()) {
while ($node = db_fetch_object($nodes)) { while ($node = db_fetch_object($nodes)) {
$item = node_load(array("nid" => $node->nid)); $item = node_load(array("nid" => $node->nid));
$link = url("node/view/$item->nid"); $link = url("node/view/$item->nid");
$items .= format_rss_item($item->title, $link, $item->teaser); $items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body));
} }
$output .= "<?xml version=\"1.0\" encoding=\"". variable_get("site_charset", "iso-8859-1") ."\"?>\n"; $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\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 .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n";
// NOTE: &eacute; - for example - is the correct ISO-8859-1 translation of (e acute) but apparently XML parsers don't (have to) understand it. To solve this problem, we use a DTD that defines commonly used entity such as &eacute;.
if (!$channel["version"]) $channel["version"] = "0.91"; if (!$channel["version"]) $channel["version"] = "0.91";
if (!$channel["title"]) $channel["title"] = variable_get("site_name", "drupal") ." - ". variable_get("site_slogan", ""); if (!$channel["title"]) $channel["title"] = variable_get("site_name", "drupal") ." - ". variable_get("site_slogan", "");
if (!$channel["link"]) $channel["link"] = $base_url; if (!$channel["link"]) $channel["link"] = $base_url;
......
...@@ -879,12 +879,11 @@ function node_feed($nodes = 0, $channel = array()) { ...@@ -879,12 +879,11 @@ function node_feed($nodes = 0, $channel = array()) {
while ($node = db_fetch_object($nodes)) { while ($node = db_fetch_object($nodes)) {
$item = node_load(array("nid" => $node->nid)); $item = node_load(array("nid" => $node->nid));
$link = url("node/view/$item->nid"); $link = url("node/view/$item->nid");
$items .= format_rss_item($item->title, $link, $item->teaser); $items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body));
} }
$output .= "<?xml version=\"1.0\" encoding=\"". variable_get("site_charset", "iso-8859-1") ."\"?>\n"; $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\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 .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n";
// NOTE: &eacute; - for example - is the correct ISO-8859-1 translation of (e acute) but apparently XML parsers don't (have to) understand it. To solve this problem, we use a DTD that defines commonly used entity such as &eacute;.
if (!$channel["version"]) $channel["version"] = "0.91"; if (!$channel["version"]) $channel["version"] = "0.91";
if (!$channel["title"]) $channel["title"] = variable_get("site_name", "drupal") ." - ". variable_get("site_slogan", ""); if (!$channel["title"]) $channel["title"] = variable_get("site_name", "drupal") ." - ". variable_get("site_slogan", "");
if (!$channel["link"]) $channel["link"] = $base_url; if (!$channel["link"]) $channel["link"] = $base_url;
......
...@@ -129,31 +129,6 @@ function system_view_general() { ...@@ -129,31 +129,6 @@ function system_view_general() {
$output .= form_select(t("Date format (medium)"), "date_format_medium", variable_get("date_format_medium", $datemedium[0]), $datemediumchoices, t("The medium sized date display.")); $output .= form_select(t("Date format (medium)"), "date_format_medium", variable_get("date_format_medium", $datemedium[0]), $datemediumchoices, t("The medium sized date display."));
$output .= form_select(t("Date format (long)"), "date_format_long", variable_get("date_format_long", $datelong[0]), $datelongchoices, t("Longer date format used for detailed display.")); $output .= form_select(t("Date format (long)"), "date_format_long", variable_get("date_format_long", $datelong[0]), $datelongchoices, t("Longer date format used for detailed display."));
$output .= "<hr />\n";
$output .= "<h3>". t("Character encoding settings") ."</h3>\n";
// charset settings
$charsets = array("iso-8859-1" => "iso-8859-1",
"iso-8859-2" => "iso-8859-2",
"iso-8859-3" => "iso-8859-3",
"iso-8859-4" => "iso-8859-4",
"iso-8859-5" => "iso-8859-5",
"iso-8859-6" => "iso-8859-6",
"iso-8859-7" => "iso-8859-7",
"iso-8859-8" => "iso-8859-8",
"iso-8859-8-i" => "iso-8859-8-i",
"iso-8859-9" => "iso-8859-9",
"utf-8" => "utf-8",
"utf-16" => "utf-16",
"utf-16be" => "utf-16be",
"euc-kr" => "euc-kr",
"koi8-r" => "koi8-r",
"ks_c_5601-1987" => "ks_c_5601-1987",
"tis-620" => "tis-620",
"iso-2022-kr" => "iso-2022-kr",
"us-ascii" => "us-ascii");
$output .= form_select(t("Character set"), "site_charset", variable_get("site_charset", "iso-8859-1"), $charsets, t("Select the character set (charset) used across your site. This will affect the content-type tag in web pages and the XML declarations in RSS feeds, among other things. You probably only need to change this if you need support for languages with non-ASCII characters like Korean, Polish, etc."));
return $output; return $output;
} }
......
...@@ -129,31 +129,6 @@ function system_view_general() { ...@@ -129,31 +129,6 @@ function system_view_general() {
$output .= form_select(t("Date format (medium)"), "date_format_medium", variable_get("date_format_medium", $datemedium[0]), $datemediumchoices, t("The medium sized date display.")); $output .= form_select(t("Date format (medium)"), "date_format_medium", variable_get("date_format_medium", $datemedium[0]), $datemediumchoices, t("The medium sized date display."));
$output .= form_select(t("Date format (long)"), "date_format_long", variable_get("date_format_long", $datelong[0]), $datelongchoices, t("Longer date format used for detailed display.")); $output .= form_select(t("Date format (long)"), "date_format_long", variable_get("date_format_long", $datelong[0]), $datelongchoices, t("Longer date format used for detailed display."));
$output .= "<hr />\n";
$output .= "<h3>". t("Character encoding settings") ."</h3>\n";
// charset settings
$charsets = array("iso-8859-1" => "iso-8859-1",
"iso-8859-2" => "iso-8859-2",
"iso-8859-3" => "iso-8859-3",
"iso-8859-4" => "iso-8859-4",
"iso-8859-5" => "iso-8859-5",
"iso-8859-6" => "iso-8859-6",
"iso-8859-7" => "iso-8859-7",
"iso-8859-8" => "iso-8859-8",
"iso-8859-8-i" => "iso-8859-8-i",
"iso-8859-9" => "iso-8859-9",
"utf-8" => "utf-8",
"utf-16" => "utf-16",
"utf-16be" => "utf-16be",
"euc-kr" => "euc-kr",
"koi8-r" => "koi8-r",
"ks_c_5601-1987" => "ks_c_5601-1987",
"tis-620" => "tis-620",
"iso-2022-kr" => "iso-2022-kr",
"us-ascii" => "us-ascii");
$output .= form_select(t("Character set"), "site_charset", variable_get("site_charset", "iso-8859-1"), $charsets, t("Select the character set (charset) used across your site. This will affect the content-type tag in web pages and the XML declarations in RSS feeds, among other things. You probably only need to change this if you need support for languages with non-ASCII characters like Korean, Polish, etc."));
return $output; return $output;
} }
......
...@@ -68,7 +68,8 @@ ...@@ -68,7 +68,8 @@
"2003-05-18" => "update_53", "2003-05-18" => "update_53",
"2003-05-24" => "update_54", "2003-05-24" => "update_54",
"2003-05-31" => "update_55", "2003-05-31" => "update_55",
"2003-06-04" => "update_56" "2003-06-04" => "update_56",
"2003-06-08" => "update_57"
); );
// Update functions // Update functions
...@@ -725,6 +726,10 @@ function update_56() { ...@@ -725,6 +726,10 @@ function update_56() {
update_sql("ALTER TABLE vocabulary CHANGE types nodes TEXT DEFAULT '' NOT NULL"); update_sql("ALTER TABLE vocabulary CHANGE types nodes TEXT DEFAULT '' NOT NULL");
} }
function update_57() {
update_sql("DELETE FROM variable WHERE name = 'site_charset'");
}
function update_upgrade3() { function update_upgrade3() {
update_sql("INSERT INTO system VALUES ('archive.module','archive','module','',1)"); update_sql("INSERT INTO system VALUES ('archive.module','archive','module','',1)");
update_sql("INSERT INTO system VALUES ('block.module','block','module','',1)"); update_sql("INSERT INTO system VALUES ('block.module','block','module','',1)");
......
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