Make WordPress Core

Changeset 4908


Ignore:
Timestamp:
02/22/2007 01:42:21 AM (19 years ago)
Author:
ryan
Message:

xmlrpc updates from Joseph Scott.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r4892 r4908  
    10951095}
    10961096
    1097 function wp_upload_bits($name, $type, $bits) {
     1097function wp_upload_bits($name, $type, $bits, $overwrite = false) {
    10981098        if ( empty($name) )
    10991099                return array('error' => __("Empty filename"));
     
    11161116        else
    11171117                $ext = ".$ext";
    1118         while ( file_exists($upload['path'] . "/$filename") ) {
     1118        while ( file_exists($upload['path'] . "/$filename") && !$overwrite ) {
    11191119                if ( '' == "$number$ext" )
    11201120                        $filename = $filename . ++$number . $ext;
  • trunk/xmlrpc.php

    r4905 r4908  
    8080                        'wp.newCategory'                => 'this:wp_newCategory',
    8181                        'wp.suggestCategories'  => 'this:wp_suggestCategories',
     82                        'wp.uploadFile'                 => 'this:mw_newMediaObject',    // Alias
    8283
    8384                        // Blogger API
     
    423424                        SELECT ID page_id,
    424425                                post_title page_title,
    425                                 post_parent page_parent_id
     426                                post_parent page_parent_id,
     427                                post_date
    426428                        FROM {$wpdb->posts}
    427429                        WHERE post_type = 'page'
    428430                        ORDER BY ID
    429431                ");
     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                }
    430441
    431442                return($page_list);
     
    487498                // If no parent_id was provided make it empty
    488499                // so that it will be a top level page (no parent).
    489                 if(empty($category["parent_id"])) {
     500                if(isset($category["parent_id"])) {
    490501                        $category["parent_id"] = "";
    491502                }
     
    938949
    939950                // 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"])) {
    941952                        $post_parent = $content_struct["wp_page_parent_id"];
    942953                }
     
    978989          $post_more = $content_struct['mt_text_more'];
    979990
    980           $comment_status = (empty($content_struct['mt_allow_comments'])) ?
     991          $comment_status = (!isset($content_struct['mt_allow_comments'])) ?
    981992            get_option('default_comment_status')
    982993            : $content_struct['mt_allow_comments'];
    983994
    984           $ping_status = (empty($content_struct['mt_allow_pings'])) ?
     995          $ping_status = (!isset($content_struct['mt_allow_pings'])) ?
    985996            get_option('default_ping_status')
    986997            : $content_struct['mt_allow_pings'];
     
    11581169                $to_ping = implode(' ', $to_ping);
    11591170         
    1160           $comment_status = (empty($content_struct['mt_allow_comments'])) ?
     1171          $comment_status = (!isset($content_struct['mt_allow_comments'])) ?
    11611172            get_option('default_comment_status')
    11621173            : $content_struct['mt_allow_comments'];
     
    13741385                $bits = $data['bits'];
    13751386
     1387                // Default to new file, not over write.
     1388                $overwrite = false;
     1389                if(!empty($data["overwrite"]) && ($data["overwrite"] == true)) {
     1390                        $overwrite = true;
     1391                }
     1392
    13761393                logIO('O', '(MW) Received '.strlen($bits).' bytes');
    13771394
     
    13891406                        return new IXR_Error(500, $upload_err);
    13901407
    1391                 $upload = wp_upload_bits($name, $type, $bits);
     1408                $upload = wp_upload_bits($name, $type, $bits, $overwrite);
    13921409                if ( ! empty($upload['error']) ) {
    13931410                        logIO('O', '(MW) Could not write file '.$name);
     
    14051422                        'guid' => $upload[ 'url' ]
    14061423                );
    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                }
    14101431
    14111432                return apply_filters( 'wp_handle_upload', array( 'file' => $upload[ 'file' ], 'url' => $upload[ 'url' ], 'type' => $type ) );
Note: See TracChangeset for help on using the changeset viewer.