Changeset 5910 for trunk/wp-app.php
- Timestamp:
- 08/21/2007 06:27:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-app.php
r5843 r5910 1 1 <?php 2 /* 2 /* 3 3 * wp-app.php - Atom Publishing Protocol support for WordPress 4 4 * Original code by: Elias Torres, http://torrez.us/archives/2006/08/31/491/ … … 167 167 } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) { 168 168 $this->in_content = array(); 169 $this->is_xhtml = $attrs['type'] == 'xhtml'; 169 $this->is_xhtml = $attrs['type'] == 'xhtml'; 170 170 array_push($this->in_content, array($tag,$this->depth)); 171 171 } else if($tag == 'link') { … … 183 183 184 184 if(!empty($this->in_content)) { 185 if($this->in_content[0][0] == $tag && 185 if($this->in_content[0][0] == $tag && 186 186 $this->in_content[0][1] == $this->depth) { 187 187 array_shift($this->in_content); … … 246 246 } 247 247 } 248 } 248 } 249 249 return $name; 250 250 } … … 252 252 function xml_escape($string) 253 253 { 254 return str_replace(array('&','"',"'",'<','>'), 255 array('&','"',''','<','>'), 254 return str_replace(array('&','"',"'",'<','>'), 255 array('&','"',''','<','>'), 256 256 $string ); 257 257 } … … 285 285 286 286 $this->selectors = array( 287 '@/service@' => 287 '@/service@' => 288 288 array('GET' => 'get_service'), 289 289 '@/categories@' => 290 290 array('GET' => 'get_categories_xml'), 291 '@/post/(\d+)@' => 292 array('GET' => 'get_post', 293 'PUT' => 'put_post', 291 '@/post/(\d+)@' => 292 array('GET' => 'get_post', 293 'PUT' => 'put_post', 294 294 'DELETE' => 'delete_post'), 295 '@/posts/?([^/]+)?@' => 296 array('GET' => 'get_posts', 295 '@/posts/?([^/]+)?@' => 296 array('GET' => 'get_posts', 297 297 'POST' => 'create_post'), 298 '@/attachments/?(\d+)?@' => 299 array('GET' => 'get_attachment', 298 '@/attachments/?(\d+)?@' => 299 array('GET' => 'get_attachment', 300 300 'POST' => 'create_attachment'), 301 '@/attachment/file/(\d+)@' => 302 array('GET' => 'get_file', 303 'PUT' => 'put_file', 301 '@/attachment/file/(\d+)@' => 302 array('GET' => 'get_file', 303 'PUT' => 'put_file', 304 304 'DELETE' => 'delete_file'), 305 '@/attachment/(\d+)@' => 306 array('GET' => 'get_attachment', 307 'PUT' => 'put_attachment', 305 '@/attachment/(\d+)@' => 306 array('GET' => 'get_attachment', 307 'PUT' => 'put_attachment', 308 308 'DELETE' => 'delete_attachment'), 309 309 ); … … 325 325 } 326 326 327 // lame. 327 // lame. 328 328 if(strlen($path) == 0 || $path == '/') { 329 329 $path = '/service'; … … 355 355 log_app('function','get_service()'); 356 356 $entries_url = $this->get_entries_url(); 357 $categories_url = $this->get_categories_url(); 357 $categories_url = $this->get_categories_url(); 358 358 $media_url = $this->get_attachments_url(); 359 359 $accepted_content_types = join(',',$this->media_content_types); 360 360 $introspection = <<<EOD 361 <service xmlns="http://purl.org/atom/app#" xmlns:atom="http://www.w3.org/2005/Atom"> 362 <workspace title="WordPress Workspace"> 363 <collection href="$entries_url" title="Posts"> 364 <atom:title>WordPress Posts</atom:title> 365 <accept>entry</accept> 366 <categories href="$categories_url" /> 367 </collection> 368 <collection href="$media_url" title="Media"> 369 <atom:title>WordPress Media</atom:title> 370 <accept>$accepted_content_types</accept> 371 </collection> 372 </workspace> 361 <service xmlns="http://purl.org/atom/app#" xmlns:atom="http://www.w3.org/2005/Atom"> 362 <workspace title="WordPress Workspace"> 363 <collection href="$entries_url" title="Posts"> 364 <atom:title>WordPress Posts</atom:title> 365 <accept>entry</accept> 366 <categories href="$categories_url" /> 367 </collection> 368 <collection href="$media_url" title="Media"> 369 <atom:title>WordPress Media</atom:title> 370 <accept>$accepted_content_types</accept> 371 </collection> 372 </workspace> 373 373 </service> 374 374 375 375 EOD; 376 376 377 $this->output($introspection, $this->INTROSPECTION_CONTENT_TYPE); 377 $this->output($introspection, $this->INTROSPECTION_CONTENT_TYPE); 378 378 } 379 379 … … 394 394 </app:categories> 395 395 EOD; 396 $this->output($output, $this->CATEGORIES_CONTENT_TYPE); 396 $this->output($output, $this->CATEGORIES_CONTENT_TYPE); 397 397 } 398 398 … … 895 895 $last_page = (int) ceil($total_count / $count); 896 896 $next_page = (($page + 1) > $last_page) ? NULL : $page + 1; 897 $prev_page = ($page - 1) < 1 ? NULL : $page - 1; 897 $prev_page = ($page - 1) < 1 ? NULL : $page - 1; 898 898 $last_page = ((int)$last_page == 1 || (int)$last_page == 0) ? NULL : (int) $last_page; 899 899 ?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://purl.org/atom/app#" xml:lang="<?php echo get_option('rss_language'); ?>"> … … 913 913 <rights type="text">Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></rights> 914 914 <generator uri="http://wordpress.com/" version="1.0.5-dc">WordPress.com Atom API</generator> 915 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); 915 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); 916 916 $post = $GLOBALS['post']; 917 917 ?> … … 935 935 <link rel="edit-media" href="<?php $this->the_media_url() ?>" /> 936 936 <?php } else { ?> 937 <link href="<?php permalink_single_rss() ?>" />937 <link href="<?php the_permalink_rss() ?>" /> 938 938 <link rel="edit" href="<?php $this->the_entry_url() ?>" /> 939 939 <?php } ?> … … 946 946 </entry> 947 947 <?php 948 endwhile; 948 endwhile; 949 949 endif; 950 950 ?></feed> 951 <?php 951 <?php 952 952 $feed = ob_get_contents(); 953 953 ob_end_clean(); … … 991 991 <content type="<?php echo $GLOBALS['post']->post_mime_type ?>" src="<?php the_guid(); ?>"/> 992 992 <?php } else { ?> 993 <link href="<?php permalink_single_rss() ?>" />993 <link href="<?php the_permalink_rss() ?>" /> 994 994 <link rel="edit" href="<?php $this->the_entry_url() ?>" /> 995 995 <?php } ?> … … 1012 1012 1013 1013 log_app('get_entry returning:',$entry); 1014 return $entry; 1015 } 1016 1017 function ok() { 1014 return $entry; 1015 } 1016 1017 function ok() { 1018 1018 log_app('Status','200: OK'); 1019 1019 header('Content-Type: text/plain'); … … 1022 1022 } 1023 1023 1024 function no_content() { 1024 function no_content() { 1025 1025 log_app('Status','204: No Content'); 1026 1026 header('Content-Type: text/plain'); … … 1110 1110 nocache_headers(); 1111 1111 header('WWW-Authenticate: Basic realm="WordPress Atom Protocol"'); 1112 header('WWW-Authenticate: Form action="' . get_option('siteurl') . '/wp-login.php"', false); 1112 header('WWW-Authenticate: Form action="' . get_option('siteurl') . '/wp-login.php"', false); 1113 1113 header("HTTP/1.1 401 $msg"); 1114 1114 header('Status: ' . $msg); … … 1160 1160 // http://www.besthostratings.com/articles/http-auth-php-cgi.html 1161 1161 if(isset($_SERVER['HTTP_AUTHORIZATION'])) { 1162 list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = 1162 list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = 1163 1163 explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); 1164 1164 } … … 1199 1199 1200 1200 foreach($types as $t) { 1201 list($acceptedType,$acceptedSubtype) = explode('/',$t); 1201 list($acceptedType,$acceptedSubtype) = explode('/',$t); 1202 1202 if($acceptedType == '*' || $acceptedType == $type) { 1203 1203 if($acceptedSubtype == '*' || $acceptedSubtype == $subtype) … … 1234 1234 1235 1235 // Support for Conditional GET 1236 if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) 1236 if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) 1237 1237 $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); 1238 else 1238 else 1239 1239 $client_etag = false; 1240 1240
Note: See TracChangeset
for help on using the changeset viewer.