Make WordPress Core

Changeset 1658


Ignore:
Timestamp:
09/14/2004 04:52:13 PM (21 years ago)
Author:
michelvaldrighi
Message:

various fixes, and started MT API support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r1580 r1658  
    1414$post_default_category = 1; // posts submitted via the xmlrpc interface go into that category
    1515
    16 $xmlrpc_logging = 0;
     16$xmlrpc_logging = 1;
    1717
    1818function logIO($io,$msg) {
     
    140140        'isAdmin'  => $is_admin,
    141141        'url'      => get_settings('home') .'/'.get_settings('blogfilename'),
    142         'blogid'   => 1,
     142        'blogid'   => '1',
    143143        'blogName' => get_settings('blogname')
    144144      );
     
    634634
    635635        $resp = array(
    636                 'link' => $link,
    637                 'title' => $postdata['post_title'],
    638                 'description' => $post['main'],
    639                 'dateCreated' => new IXR_Date($post_date),
    640                 'userid' => $postdata['post_author'],
    641                 'postid' => $postdata['ID'],
    642                 'content' => $postdata['post_content'],
    643                 'permaLink' => $link,
    644                 'categories' => $categories,
    645                 'mt_excerpt' => $postdata['post_excerpt'],
    646                 'mt_allow_comments' => $allow_comments,
    647                 'mt_allow_pings' => $allow_pings,
    648                 'mt_text_more' => $post['extended']
     636          'dateCreated' => new IXR_Date($post_date),
     637          'userid' => $entry['post_author'],
     638          'postid' => $entry['ID'],
     639          'description' => $post['main'],
     640          'title' => $entry['post_title'],
     641          'link' => $link,
     642          'permaLink' => $link,
     643//        'content' => $entry['post_content'],
     644//        'categories' => $categories
     645          'mt_excerpt' => $entry['post_excerpt'],
     646          'mt_text_more' => $post['extended'],
     647          'mt_allow_comments' => $allow_comments,
     648          'mt_allow_pings' => $allow_pings
    649649        );
    650650
     
    662662      $user_login  = $args[1];
    663663      $user_pass   = $args[2];
    664       $num_posts  = $args[4];
     664      $num_posts   = $args[3];
    665665
    666666      if (!$this->login_pass_ok($user_login, $user_pass)) {
     
    691691
    692692        $struct[] = array(
    693           'link' => $link,
    694           'title' => $entry['post_title'],
    695           'description' => $post['main'],
    696693          'dateCreated' => new IXR_Date($post_date),
    697694          'userid' => $entry['post_author'],
    698695          'postid' => $entry['ID'],
    699           'content' => $entry['post_content'],
    700           'permalink' => $link,
    701           'categories' => $categories,
     696          'description' => $post['main'],
     697          'title' => $entry['post_title'],
     698          'link' => $link,
     699          'permaLink' => $link,
     700//        'content' => $entry['post_content'],
     701//        'categories' => $categories
    702702          'mt_excerpt' => $entry['post_excerpt'],
     703          'mt_text_more' => $post['extended'],
    703704          'mt_allow_comments' => $allow_comments,
    704           'mt_allow_pings' => $allow_pings,
    705           'mt_text_more' => $post['extended']
     705          'mt_allow_pings' => $allow_pings
    706706        );
    707707
     
    824824    }
    825825
     826
     827
     828    /* MovableType API functions
     829     * specs on http://www.movabletype.org/docs/mtmanual_programmatic.html
     830     */
     831
     832    /* mt.getRecentPostTitles ...returns recent posts' titles */
     833    function mt_getRecentPostTitles($args) {
     834
     835      $blog_ID     = $args[0];
     836      $user_login  = $args[1];
     837      $user_pass   = $args[2];
     838      $num_posts   = $args[3];
     839
     840      if (!$this->login_pass_ok($user_login, $user_pass)) {
     841        return $this->error;
     842      }
     843
     844      $posts_list = wp_get_recent_posts($num_posts);
     845
     846      if (!$posts_list) {
     847        $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
     848        return $this->error;
     849      }
     850
     851      foreach ($posts_list as $entry) {
     852     
     853        $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
     854
     855        $struct[] = array(
     856          'dateCreated' => new IXR_Date($post_date),
     857          'userid' => $entry['post_author'],
     858          'postid' => $entry['ID'],
     859          'title' => $entry['post_title'],
     860        );
     861
     862      }
     863
     864      $recent_posts = array();
     865      for ($j=0; $j<count($struct); $j++) {
     866        array_push($recent_posts, $struct[$j]);
     867      }
     868     
     869      return $recent_posts;
     870    }
     871
     872
     873    /* mt.getCategoryList ...returns the list of categories on a given weblog */
     874    function mt_getCategoryList($args) {
     875
     876      global $wpdb;
     877
     878      $blog_ID     = $args[0];
     879      $user_login  = $args[1];
     880      $user_pass   = $args[2];
     881
     882      if (!$this->login_pass_ok($user_login, $user_pass)) {
     883        return $this->error;
     884      }
     885
     886      $categories_struct = array();
     887
     888      // FIXME: can we avoid using direct SQL there?
     889      if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) {
     890        foreach ($cats as $cat) {
     891          $struct['categoryId'] = $cat['cat_ID'];
     892          $struct['categoryName'] = $cat['cat_name'];
     893
     894          $categories_struct[] = $struct;
     895        }
     896      }
     897
     898      return $categories_struct;
     899    }
     900
    826901}
    827902
Note: See TracChangeset for help on using the changeset viewer.