Changeset 16016
- Timestamp:
- 10/27/2010 05:20:46 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class.wp-xmlrpc-server.php
r15980 r16016 62 62 'wp.newComment' => 'this:wp_newComment', 63 63 'wp.getCommentStatusList' => 'this:wp_getCommentStatusList', 64 'wp.getMediaItem' => 'this:wp_getMediaItem', 65 'wp.getMediaLibrary' => 'this:wp_getMediaLibrary', 64 66 65 67 // Blogger API … … 1482 1484 } 1483 1485 1486 /** 1487 * Retrieve media item. 1488 * 1489 * @since 3.1.0 1490 * @todo Docment this! 1491 * 1492 * @param array $args Method parameters. 1493 * @return array 1494 */ 1495 function wp_getMediaItem($args) { 1496 $this->escape($args); 1497 1498 $blog_id = (int) $args[0]; 1499 $username = $args[1]; 1500 $password = $args[2]; 1501 $attachment_id = (int) $args[3]; 1502 1503 if ( !$user = $this->login($username, $password) ) 1504 return $this->error; 1505 1506 if ( !current_user_can( 'upload_files' ) ) 1507 return new IXR_Error( 403, __( 'You are not allowed to upload files on this site.' ) ); 1508 1509 do_action('xmlrpc_call', 'wp.getMediaItem'); 1510 1511 if ( ! $attachment = get_post($attachment_id) ) 1512 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 1513 1514 // Format page date. 1515 $attachment_date = mysql2date("Ymd\TH:i:s", $attachment->post_date, false); 1516 $attachment_date_gmt = mysql2date("Ymd\TH:i:s", $attachment->post_date_gmt, false); 1517 1518 $link = wp_get_attachment_url($attachment->ID); 1519 $thumbnail_link = wp_get_attachment_thumb_url($attachment->ID); 1520 1521 $attachment_struct = array( 1522 "date_created_gmt" => new IXR_Date($attachment_date_gmt), 1523 "parent" => $attachment->post_parent, 1524 "link" => $link, 1525 "thumbnail" => $thumbnail_link, 1526 "title" => $attachment->post_title, 1527 "caption" => $attachment->post_excerpt, 1528 "description" => $attachment->post_content, 1529 "metadata" => wp_get_attachment_metadata($attachment->ID), 1530 ); 1531 1532 return $attachment_struct; 1533 } 1534 1535 /** 1536 * Retrieve media library items. 1537 * 1538 * @since 3.1.0 1539 * @todo Document this. 1540 * 1541 * @param array $args Method parameters. 1542 * @return array 1543 */ 1544 function wp_getMediaLibrary($args) { 1545 $raw_args = $args; 1546 $this->escape($args); 1547 1548 $blog_id = (int) $args[0]; 1549 $username = $args[1]; 1550 $password = $args[2]; 1551 $struct = isset( $args[3] ) ? $args[3] : array() ; 1552 1553 if ( !$user = $this->login($username, $password) ) 1554 return $this->error; 1555 1556 if ( !current_user_can( 'upload_files' ) ) 1557 return new IXR_Error( 401, __( 'Sorry, you cannot upload files.' ) ); 1558 1559 do_action('xmlrpc_call', 'wp.getMediaLibrary'); 1560 1561 $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : 0 ; 1562 $mime_type = ( isset($struct['mime_type']) ) ? absint($struct['mime_type']) : '' ; 1563 $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; 1564 $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; 1565 1566 $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); 1567 $num_attachments = count($attachments); 1568 1569 if ( ! $num_attachments ) 1570 return array(); 1571 1572 $attachments_struct = array(); 1573 1574 foreach ($attachments as $attachment ) 1575 $attachments_struct[] = $this->wp_getMediaItem( array( $raw_args[0], $raw_args[1], $raw_args[2], $attachment->ID ) ); 1576 1577 return $attachments_struct; 1578 } 1579 1484 1580 /* Blogger API functions. 1485 1581 * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
Note: See TracChangeset
for help on using the changeset viewer.