diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-30 16:49:38 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-30 16:49:38 +0000 |
commit | d85d717aedbc7690e2a450e40dab8fcebd94b38c (patch) | |
tree | a7340a14bb1192e977fca4f26beef29869e17579 /wp-app.php | |
parent | 9817ff2d282c68faaa09232845829b96f207e72b (diff) | |
download | wordpress-mu-d85d717aedbc7690e2a450e40dab8fcebd94b38c.tar.gz wordpress-mu-d85d717aedbc7690e2a450e40dab8fcebd94b38c.tar.xz wordpress-mu-d85d717aedbc7690e2a450e40dab8fcebd94b38c.zip |
Merge with WordPress 2.3.1
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1139 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-app.php')
-rw-r--r-- | wp-app.php | 40 |
1 files changed, 33 insertions, 7 deletions
@@ -12,7 +12,6 @@ define('APP_REQUEST', true); require_once('./wp-config.php'); require_once(ABSPATH . WPINC . '/post-template.php'); require_once(ABSPATH . WPINC . '/atomlib.php'); -require_once(ABSPATH . WPINC . '/feed.php'); $_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] ); @@ -697,7 +696,7 @@ EOD; } function get_feed($page = 1, $post_type = 'post') { - global $post, $wp, $wp_query, $posts, $wpdb, $blog_id; + global $post, $wp, $wp_query, $posts, $wpdb, $blog_id, $post_cache; log_app('function',"get_feed($page, '$post_type')"); ob_start(); @@ -716,6 +715,7 @@ EOD; $wp_query = $GLOBALS['wp_query']; $wpdb = $GLOBALS['wpdb']; $blog_id = (int) $GLOBALS['blog_id']; + $post_cache = $GLOBALS['post_cache']; log_app('function',"query_posts(# " . print_r($wp_query, true) . "#)"); log_app('function',"total_count(# $wp_query->max_num_pages #)"); @@ -739,7 +739,7 @@ EOD; <link rel="last" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($last_page) ?>" /> <link rel="self" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($self_page) ?>" /> <rights type="text">Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></rights> -<?php the_generator( 'atom' ); ?> +<generator uri="http://wordpress.com/" version="1.0.5-dc">WordPress.com Atom API</generator> <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); @@ -756,7 +756,7 @@ EOD; function get_entry($postID, $post_type = 'post') { log_app('function',"get_entry($postID, '$post_type')"); ob_start(); - global $posts, $post, $wp_query, $wp, $wpdb, $blog_id; + global $posts, $post, $wp_query, $wp, $wpdb, $blog_id, $post_cache; switch($post_type) { case 'post': $varname = 'p'; @@ -785,7 +785,7 @@ EOD; <entry xmlns="<?php echo $this->ATOM_NS ?>" xmlns:app="<?php echo $this->ATOMPUB_NS ?>" xml:lang="<?php echo get_option('rss_language'); ?>"> <id><?php the_guid($GLOBALS['post']->ID); ?></id> -<?php list($content_type, $content) = prep_atom_text_construct(get_the_title()); ?> +<?php list($content_type, $content) = $this->prep_content(get_the_title()); ?> <title type="<?php echo $content_type ?>"><?php echo $content ?></title> <updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated> <published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published> @@ -806,7 +806,7 @@ EOD; <?php } else { ?> <link href="<?php the_permalink_rss() ?>" /> <?php if ( strlen( $GLOBALS['post']->post_content ) ) : -list($content_type, $content) = prep_atom_text_construct(get_the_content()); ?> +list($content_type, $content) = $this->prep_content(get_the_content()); ?> <content type="<?php echo $content_type ?>"><?php echo $content ?></content> <?php endif; ?> <?php } ?> @@ -814,11 +814,37 @@ list($content_type, $content) = prep_atom_text_construct(get_the_content()); ?> <?php foreach(get_the_category() as $category) { ?> <category scheme="<?php bloginfo_rss('home') ?>" term="<?php echo $category->name?>" /> <?php } ?> -<?php list($content_type, $content) = prep_atom_text_construct(get_the_excerpt()); ?> +<?php list($content_type, $content) = $this->prep_content(get_the_excerpt()); ?> <summary type="<?php echo $content_type ?>"><?php echo $content ?></summary> </entry> <?php } + function prep_content($data) { + if (strpos($data, '<') === false && strpos($data, '&') === false) { + return array('text', $data); + } + + $parser = xml_parser_create(); + xml_parse($parser, '<div>' . $data . '</div>', true); + $code = xml_get_error_code($parser); + xml_parser_free($parser); + + if (!$code) { + if (strpos($data, '<') === false) { + return array('text', $data); + } else { + $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>"; + return array('xhtml', $data); + } + } + + if (strpos($data, ']]>') == false) { + return array('html', "<![CDATA[$data]]>"); + } else { + return array('html', htmlspecialchars($data)); + } + } + function ok() { log_app('Status','200: OK'); header('Content-Type: text/plain'); |