Changeset 1139 for trunk/wp-app.php

Show
Ignore:
Timestamp:
10/30/07 16:49:38 (1 year ago)
Author:
donncha
Message:

Merge with WordPress? 2.3.1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-app.php

    r1125 r1139  
    1313require_once(ABSPATH . WPINC . '/post-template.php'); 
    1414require_once(ABSPATH . WPINC . '/atomlib.php'); 
    15 require_once(ABSPATH . WPINC . '/feed.php'); 
    1615 
    1716$_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] ); 
     
    698697 
    699698        function get_feed($page = 1, $post_type = 'post') { 
    700                 global $post, $wp, $wp_query, $posts, $wpdb, $blog_id
     699                global $post, $wp, $wp_query, $posts, $wpdb, $blog_id, $post_cache
    701700                log_app('function',"get_feed($page, '$post_type')"); 
    702701                ob_start(); 
     
    717716                $wpdb = $GLOBALS['wpdb']; 
    718717                $blog_id = (int) $GLOBALS['blog_id']; 
     718                $post_cache = $GLOBALS['post_cache']; 
    719719                log_app('function',"query_posts(# " . print_r($wp_query, true) . "#)"); 
    720720 
     
    740740<link rel="self" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($self_page) ?>" /> 
    741741<rights type="text">Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></rights> 
    742 <?php the_generator( 'atom' ); ?
     742<generator uri="http://wordpress.com/" version="1.0.5-dc">WordPress.com Atom API</generator
    743743<?php if ( have_posts() ) { 
    744744                        while ( have_posts() ) { 
     
    757757                log_app('function',"get_entry($postID, '$post_type')"); 
    758758                ob_start(); 
    759                 global $posts, $post, $wp_query, $wp, $wpdb, $blog_id
     759                global $posts, $post, $wp_query, $wp, $wpdb, $blog_id, $post_cache
    760760                switch($post_type) { 
    761761                        case 'post': 
     
    786786       xmlns:app="<?php echo $this->ATOMPUB_NS ?>" xml:lang="<?php echo get_option('rss_language'); ?>"> 
    787787        <id><?php the_guid($GLOBALS['post']->ID); ?></id> 
    788 <?php list($content_type, $content) = prep_atom_text_construct(get_the_title()); ?> 
     788<?php list($content_type, $content) = $this->prep_content(get_the_title()); ?> 
    789789        <title type="<?php echo $content_type ?>"><?php echo $content ?></title> 
    790790        <updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated> 
     
    807807        <link href="<?php the_permalink_rss() ?>" /> 
    808808<?php if ( strlen( $GLOBALS['post']->post_content ) ) : 
    809 list($content_type, $content) = prep_atom_text_construct(get_the_content()); ?> 
     809list($content_type, $content) = $this->prep_content(get_the_content()); ?> 
    810810        <content type="<?php echo $content_type ?>"><?php echo $content ?></content> 
    811811<?php endif; ?> 
     
    815815        <category scheme="<?php bloginfo_rss('home') ?>" term="<?php echo $category->name?>" /> 
    816816<?php } ?> 
    817 <?php list($content_type, $content) = prep_atom_text_construct(get_the_excerpt()); ?> 
     817<?php list($content_type, $content) = $this->prep_content(get_the_excerpt()); ?> 
    818818        <summary type="<?php echo $content_type ?>"><?php echo $content ?></summary> 
    819819</entry> 
    820820<?php } 
     821 
     822        function prep_content($data) { 
     823                if (strpos($data, '<') === false && strpos($data, '&') === false) { 
     824                        return array('text', $data); 
     825                } 
     826 
     827                $parser = xml_parser_create(); 
     828                xml_parse($parser, '<div>' . $data . '</div>', true); 
     829                $code = xml_get_error_code($parser); 
     830                xml_parser_free($parser); 
     831 
     832                if (!$code) { 
     833                        if (strpos($data, '<') === false) { 
     834                                return array('text', $data); 
     835                        } else { 
     836                                $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>"; 
     837                                return array('xhtml', $data); 
     838                        } 
     839                } 
     840 
     841                if (strpos($data, ']]>') == false) { 
     842                        return array('html', "<![CDATA[$data]]>"); 
     843                } else { 
     844                        return array('html', htmlspecialchars($data)); 
     845                } 
     846        } 
    821847 
    822848        function ok() {