| [ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 <?php 2 // $Id: metaweblogapi.php 2 2005-11-02 18:23:29Z skalpa $ 3 // ------------------------------------------------------------------------ // 4 // XOOPS - PHP Content Management System // 5 // Copyright (c) 2000 XOOPS.org // 6 // <http://www.xoops.org/> // 7 // ------------------------------------------------------------------------ // 8 // This program is free software; you can redistribute it and/or modify // 9 // it under the terms of the GNU General Public License as published by // 10 // the Free Software Foundation; either version 2 of the License, or // 11 // (at your option) any later version. // 12 // // 13 // You may not change or alter any portion of this comment or credits // 14 // of supporting developers from this source code or any supporting // 15 // source code which is considered copyrighted (c) material of the // 16 // original comment or credit authors. // 17 // // 18 // This program is distributed in the hope that it will be useful, // 19 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 21 // GNU General Public License for more details. // 22 // // 23 // You should have received a copy of the GNU General Public License // 24 // along with this program; if not, write to the Free Software // 25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 26 // ------------------------------------------------------------------------ // 27 // Author: Kazumi Ono (AKA onokazu) // 28 // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // 29 // Project: The XOOPS Project // 30 // ------------------------------------------------------------------------- // 31 if (!defined('XOOPS_ROOT_PATH')) { 32 die("XOOPS root path not defined"); 33 } 34 require_once XOOPS_ROOT_PATH.'/class/xml/rpc/xmlrpcapi.php'; 35 36 class MetaWeblogApi extends XoopsXmlRpcApi 37 { 38 function MetaWeblogApi(&$params, &$response, &$module) 39 { 40 $this->XoopsXmlRpcApi($params, $response, $module); 41 $this->_setXoopsTagMap('storyid', 'postid'); 42 $this->_setXoopsTagMap('published', 'dateCreated'); 43 $this->_setXoopsTagMap('uid', 'userid'); 44 //$this->_setXoopsTagMap('hometext', 'description'); 45 } 46 47 function newPost() 48 { 49 if (!$this->_checkUser($this->params[1], $this->params[2])) { 50 51 $this->response->add(new XoopsXmlRpcFault(104)); 52 } else { 53 if (!$fields =& $this->_getPostFields(null, $this->params[0])) { 54 $this->response->add(new XoopsXmlRpcFault(106)); 55 } else { 56 $missing = array(); 57 $post = array(); 58 foreach ($fields as $tag => $detail) { 59 $maptag = $this->_getXoopsTagMap($tag); 60 if (!isset($this->params[3][$maptag])) { 61 $data = $this->_getTagCdata($this->params[3]['description'], $maptag, true); 62 if (trim($data) == ''){ 63 if ($detail['required']) { 64 $missing[] = $maptag; 65 } 66 } else { 67 $post[$tag] = $data; 68 } 69 } else { 70 $post[$tag] = $this->params[3][$maptag]; 71 } 72 } 73 if (count($missing) > 0) { 74 $msg = ''; 75 foreach ($missing as $m) { 76 $msg .= '<'.$m.'> ';echo $m; 77 } 78 $this->response->add(new XoopsXmlRpcFault(109, $msg)); 79 } else { 80 $newparams = array(); 81 $newparams[0] = $this->params[0]; 82 $newparams[1] = $this->params[1]; 83 $newparams[2] = $this->params[2]; 84 foreach ($post as $key => $value) { 85 $newparams[3][$key] =& $value; 86 unset($value); 87 } 88 $newparams[3]['xoops_text'] = $this->params[3]['description']; 89 if (isset($this->params[3]['categories']) && is_array($this->params[3]['categories'])) { 90 foreach ($this->params[3]['categories'] as $k => $v) { 91 $newparams[3]['categories'][$k] = $v; 92 } 93 } 94 $newparams[4] = $this->params[4]; 95 $xoopsapi =& $this->_getXoopsApi($newparams); 96 $xoopsapi->_setUser($this->user, $this->isadmin); 97 $xoopsapi->newPost(); 98 } 99 } 100 } 101 } 102 103 function editPost() 104 { 105 if (!$this->_checkUser($this->params[1], $this->params[2])) { 106 $this->response->add(new XoopsXmlRpcFault(104)); 107 } else { 108 if (!$fields =& $this->_getPostFields($this->params[0])) { 109 } else { 110 $missing = array(); 111 $post = array(); 112 foreach ($fields as $tag => $detail) { 113 $maptag = $this->_getXoopsTagMap($tag); 114 if (!isset($this->params[3][$maptag])) { 115 $data = $this->_getTagCdata($this->params[3]['description'], $maptag, true); 116 if (trim($data) == ''){ 117 if ($detail['required']) { 118 $missing[] = $tag; 119 } 120 } else { 121 $post[$tag] = $data; 122 } 123 } else { 124 $post[$tag] =& $this->params[3][$maptag]; 125 } 126 } 127 if (count($missing) > 0) { 128 $msg = ''; 129 foreach ($missing as $m) { 130 $msg .= '<'.$m.'> '; 131 } 132 $this->response->add(new XoopsXmlRpcFault(109, $msg)); 133 } else { 134 $newparams = array(); 135 $newparams[0] = $this->params[0]; 136 $newparams[1] = $this->params[1]; 137 $newparams[2] = $this->params[2]; 138 foreach ($post as $key => $value) { 139 $newparams[3][$key] =& $value; 140 unset($value); 141 } 142 if (isset($this->params[3]['categories']) && is_array($this->params[3]['categories'])) { 143 foreach ($this->params[3]['categories'] as $k => $v) { 144 $newparams[3]['categories'][$k] = $v; 145 } 146 } 147 $newparams[3]['xoops_text'] = $this->params[3]['description']; 148 $newparams[4] = $this->params[4]; 149 $xoopsapi =& $this->_getXoopsApi($newparams); 150 $xoopsapi->_setUser($this->user, $this->isadmin); 151 $xoopsapi->editPost(); 152 } 153 } 154 } 155 } 156 157 function getPost() 158 { 159 if (!$this->_checkUser($this->params[1], $this->params[2])) { 160 $this->response->add(new XoopsXmlRpcFault(104)); 161 } else { 162 $xoopsapi =& $this->_getXoopsApi($this->params); 163 $xoopsapi->_setUser($this->user, $this->isadmin); 164 $ret =& $xoopsapi->getPost(false); 165 if (is_array($ret)) { 166 $struct = new XoopsXmlRpcStruct(); 167 $content = ''; 168 foreach ($ret as $key => $value) { 169 $maptag = $this->_getXoopsTagMap($key); 170 switch($maptag) { 171 case 'userid': 172 $struct->add('userid', new XoopsXmlRpcString($value)); 173 break; 174 case 'dateCreated': 175 $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); 176 break; 177 case 'postid': 178 $struct->add('postid', new XoopsXmlRpcString($value)); 179 $struct->add('link', new XoopsXmlRpcString(XOOPS_URL.'/modules/xoopssections/item.php?item='.$value)); 180 $struct->add('permaLink', new XoopsXmlRpcString(XOOPS_URL.'/modules/xoopssections/item.php?item='.$value)); 181 break; 182 case 'title': 183 $struct->add('title', new XoopsXmlRpcString($value)); 184 break; 185 default : 186 $content .= '<'.$key.'>'.trim($value).'</'.$key.'>'; 187 break; 188 } 189 } 190 $struct->add('description', new XoopsXmlRpcString($content)); 191 $this->response->add($struct); 192 } else { 193 $this->response->add(new XoopsXmlRpcFault(106)); 194 } 195 } 196 } 197 198 function getRecentPosts() 199 { 200 if (!$this->_checkUser($this->params[1], $this->params[2])) { 201 $this->response->add(new XoopsXmlRpcFault(104)); 202 } else { 203 $xoopsapi =& $this->_getXoopsApi($this->params); 204 $xoopsapi->_setUser($this->user, $this->isadmin); 205 $ret =& $xoopsapi->getRecentPosts(false); 206 if (is_array($ret)) { 207 $arr = new XoopsXmlRpcArray(); 208 $count = count($ret); 209 if ($count == 0) { 210 $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); 211 } else { 212 for ($i = 0; $i < $count; $i++) { 213 $struct = new XoopsXmlRpcStruct(); 214 $content = ''; 215 foreach($ret[$i] as $key => $value) { 216 $maptag = $this->_getXoopsTagMap($key); 217 switch($maptag) { 218 case 'userid': 219 $struct->add('userid', new XoopsXmlRpcString($value)); 220 break; 221 case 'dateCreated': 222 $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); 223 break; 224 case 'postid': 225 $struct->add('postid', new XoopsXmlRpcString($value)); 226 $struct->add('link', new XoopsXmlRpcString(XOOPS_URL.'/modules/news/article.php?item_id='.$value)); 227 $struct->add('permaLink', new XoopsXmlRpcString(XOOPS_URL.'/modules/news/article.php?item_id='.$value)); 228 break; 229 case 'title': 230 $struct->add('title', new XoopsXmlRpcString($value)); 231 break; 232 default : 233 $content .= '<'.$key.'>'.trim($value).'</'.$key.'>'; 234 break; 235 } 236 } 237 $struct->add('description', new XoopsXmlRpcString($content)); 238 $arr->add($struct); 239 unset($struct); 240 } 241 $this->response->add($arr); 242 } 243 } else { 244 $this->response->add(new XoopsXmlRpcFault(106)); 245 } 246 } 247 } 248 249 function getCategories() 250 { 251 if (!$this->_checkUser($this->params[1], $this->params[2])) { 252 $this->response->add(new XoopsXmlRpcFault(104)); 253 } else { 254 $xoopsapi =& $this->_getXoopsApi($this->params); 255 $xoopsapi->_setUser($this->user, $this->isadmin); 256 $ret =& $xoopsapi->getCategories(false); 257 if (is_array($ret)) { 258 $arr = new XoopsXmlRpcArray(); 259 foreach ($ret as $id => $detail) { 260 $struct = new XoopsXmlRpcStruct(); 261 $struct->add('description', new XoopsXmlRpcString($detail)); 262 $struct->add('htmlUrl', new XoopsXmlRpcString(XOOPS_URL.'/modules/news/index.php?storytopic='.$id)); 263 $struct->add('rssUrl', new XoopsXmlRpcString('')); 264 $catstruct = new XoopsXmlRpcStruct(); 265 $catstruct->add($detail['title'], $struct); 266 $arr->add($catstruct); 267 unset($struct); 268 unset($catstruct); 269 } 270 $this->response->add($arr); 271 } else { 272 $this->response->add(new XoopsXmlRpcFault(106)); 273 } 274 } 275 } 276 } 277 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Nov 25 11:44:32 2007 | par Balluche grâce à PHPXref 0.7 |
|