[wp-hackers] XSLT: Sample implementation

Matt Read lists at mattread.com
Mon Jan 30 21:42:31 GMT 2006


My attachment got scrubbed, so here it is as .txt

On January 30, 2006 01:14 pm, David House wrote:
> Right. Now we need an implementation.

Here's a diff for wp-atom.php to do just such that. Sends text/xml if the 
user-agent doesn't accept application/atom+xml.

Could be cleaned up a bit maybe put in a function or something but here it 
is... test away.


-- 
Matthew Read
http://www.mattread.com/
-------------- next part --------------
Index: wp-atom.php
===================================================================
--- wp-atom.php	(revision 3497)
+++ wp-atom.php	(working copy)
@@ -5,7 +5,23 @@
 	wp('feed=atom');
 }
 
-header('Content-type: application/atom+xml; charset=' . get_settings('blog_charset'), true);
+$types = explode(',', $_SERVER['HTTP_ACCEPT']);
+
+foreach ($types as $type) {
+	if (preg_match("|(.*);(.*)|si", $type, $matches)) {
+		preg_match("|q=(.*)|si", $matches[2], $q);
+		$type_map[$matches[1]] = floatval($q[1]);
+	}
+	else
+		$type_map[$type] = floatval(1);
+}
+
+arsort($type_map);
+
+if ($type_map['application/atom+xml'])
+	header('Content-type: application/atom+xml; charset=' . get_settings('blog_charset'), true);
+else
+	header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
 $more = 1;
 
 ?>


More information about the wp-hackers mailing list