Changeset 4908
- Timestamp:
- 02/22/07 01:42:21 (1 year ago)
- Files:
-
- trunk/wp-includes/functions.php (modified) (2 diffs)
- trunk/xmlrpc.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-includes/functions.php
r4892 r4908 1095 1095 } 1096 1096 1097 function wp_upload_bits($name, $type, $bits ) {1097 function wp_upload_bits($name, $type, $bits, $overwrite = false) { 1098 1098 if ( empty($name) ) 1099 1099 return array('error' => __("Empty filename")); … … 1116 1116 else 1117 1117 $ext = ".$ext"; 1118 while ( file_exists($upload['path'] . "/$filename") ) {1118 while ( file_exists($upload['path'] . "/$filename") && !$overwrite ) { 1119 1119 if ( '' == "$number$ext" ) 1120 1120 $filename = $filename . ++$number . $ext; trunk/xmlrpc.php
r4905 r4908 80 80 'wp.newCategory' => 'this:wp_newCategory', 81 81 'wp.suggestCategories' => 'this:wp_suggestCategories', 82 'wp.uploadFile' => 'this:mw_newMediaObject', // Alias 82 83 83 84 // Blogger API … … 423 424 SELECT ID page_id, 424 425 post_title page_title, 425 post_parent page_parent_id 426 post_parent page_parent_id, 427 post_date 426 428 FROM {$wpdb->posts} 427 429 WHERE post_type = 'page' 428 430 ORDER BY ID 429 431 "); 432 433 // The date needs to be formated properly. 434 $num_pages = count($page_list); 435 for($i = 0; $i < $num_pages; $i++) { 436 $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date); 437 $page_list[$i]->dateCreated = new IXR_Date($post_date); 438 439 unset($page_list[$i]->post_date); 440 } 430 441 431 442 return($page_list); … … 487 498 // If no parent_id was provided make it empty 488 499 // so that it will be a top level page (no parent). 489 if( empty($category["parent_id"])) {500 if(isset($category["parent_id"])) { 490 501 $category["parent_id"] = ""; 491 502 } … … 938 949 939 950 // Only set a post parent if one was provided. 940 if( !empty($content_struct["wp_page_parent_id"])) {951 if(isset($content_struct["wp_page_parent_id"])) { 941 952 $post_parent = $content_struct["wp_page_parent_id"]; 942 953 } … … 978 989 $post_more = $content_struct['mt_text_more']; 979 990 980 $comment_status = ( empty($content_struct['mt_allow_comments'])) ?991 $comment_status = (!isset($content_struct['mt_allow_comments'])) ? 981 992 get_option('default_comment_status') 982 993 : $content_struct['mt_allow_comments']; 983 994 984 $ping_status = ( empty($content_struct['mt_allow_pings'])) ?995 $ping_status = (!isset($content_struct['mt_allow_pings'])) ? 985 996 get_option('default_ping_status') 986 997 : $content_struct['mt_allow_pings']; … … 1158 1169 $to_ping = implode(' ', $to_ping); 1159 1170 1160 $comment_status = ( empty($content_struct['mt_allow_comments'])) ?1171 $comment_status = (!isset($content_struct['mt_allow_comments'])) ? 1161 1172 get_option('default_comment_status') 1162 1173 : $content_struct['mt_allow_comments']; … … 1374 1385 $bits = $data['bits']; 1375 1386 1387 // Default to new file, not over write. 1388 $overwrite = false; 1389 if(!empty($data["overwrite"]) && ($data["overwrite"] == true)) { 1390 $overwrite = true; 1391 } 1392 1376 1393 logIO('O', '(MW) Received '.strlen($bits).' bytes'); 1377 1394 … … 1389 1406 return new IXR_Error(500, $upload_err); 1390 1407 1391 $upload = wp_upload_bits($name, $type, $bits );1408 $upload = wp_upload_bits($name, $type, $bits, $overwrite); 1392 1409 if ( ! empty($upload['error']) ) { 1393 1410 logIO('O', '(MW) Could not write file '.$name); … … 1405 1422 'guid' => $upload[ 'url' ] 1406 1423 ); 1407 // Save the data 1408 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); 1409 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); 1424 1425 // Only make a database entry if this is a new file. 1426 if(!$overwrite) { 1427 // Save the data 1428 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); 1429 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); 1430 } 1410 1431 1411 1432 return apply_filters( 'wp_handle_upload', array( 'file' => $upload[ 'file' ], 'url' => $upload[ 'url' ], 'type' => $type ) );
