Changeset 852:969647a6c35e for inc/core/class.dc.xmlrpc.php
- Timestamp:
- 07/31/12 15:15:32 (13 years ago)
- Branch:
- sexy
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.xmlrpc.php
r851 r852 75 75 'List of most recent posts in the system'); 76 76 77 $this->addCallback('metaWeblog.newMediaObject',array($this,'mw_newMediaObject'),78 array('struct','string','string','string','struct'),79 'Upload a file on the web server');80 81 77 # MovableType methods 82 78 $this->addCallback('mt.getRecentPostTitles',array($this,'mt_getRecentPostTitles'), … … 573 569 574 570 return true; 575 }576 577 private function newMediaObject($blog_id,$user,$pwd,$file)578 {579 if (empty($file['name'])) {580 throw new Exception('No file name');581 }582 583 if (empty($file['bits'])) {584 throw new Exception('No file content');585 }586 587 $file_name = $file['name'];588 $file_bits = $file['bits'];589 590 $this->setUser($user,$pwd);591 $this->setBlog();592 593 $media = new dcMedia($this->core);594 595 $dir_name = path::clean(dirname($file_name));596 $file_name = basename($file_name);597 598 $dir_name = preg_replace('!^/!','',$dir_name);599 if ($dir_name != '')600 {601 $dir = explode('/',$dir_name);602 $cwd = './';603 foreach ($dir as $v)604 {605 $v = files::tidyFileName($v);606 $cwd .= $v.'/';607 $media->makeDir($v);608 $media->chdir($cwd);609 }610 }611 612 $media_id = $media->uploadBits($file_name,$file_bits);613 614 $f = $media->getFile($media_id);615 return array(616 'file' => $file_name,617 'url' => $f->file_url,618 'type' => files::getMimeType($file_name)619 );620 571 } 621 572 … … 940 891 } 941 892 942 public function mw_newMediaObject($blogid,$username,$password,$file)943 {944 return $this->newMediaObject($blogid,$username,$password,$file);945 }946 947 893 /* MovableType methods 948 894 --------------------------------------------------- */ … … 1024 970 { 1025 971 return $this->getTags($username,$password); 1026 }1027 1028 public function wp_uploadFile($blogid,$username,$password,$file)1029 {1030 return $this->newMediaObject($blogid,$username,$password,$file);1031 972 } 1032 973
Note: See TracChangeset
for help on using the changeset viewer.