[ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 <?php 2 // $Id: bloggerapi.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 BloggerApi extends XoopsXmlRpcApi 37 { 38 39 function BloggerApi(&$params, &$response, &$module) 40 { 41 $this->XoopsXmlRpcApi($params, $response, $module); 42 $this->_setXoopsTagMap('storyid', 'postid'); 43 $this->_setXoopsTagMap('published', 'dateCreated'); 44 $this->_setXoopsTagMap('uid', 'userid'); 45 } 46 47 function newPost() 48 { 49 if (!$this->_checkUser($this->params[2], $this->params[3])) { 50 $this->response->add(new XoopsXmlRpcFault(104)); 51 } else { 52 if (!$fields =& $this->_getPostFields(null, $this->params[1])) { 53 $this->response->add(new XoopsXmlRpcFault(106)); 54 } else { 55 $missing = array(); 56 $post = array(); 57 foreach ($fields as $tag => $detail) { 58 $maptag = $this->_getXoopsTagMap($tag); 59 $data = $this->_getTagCdata($this->params[4], $maptag, true); 60 if (trim($data) == ''){ 61 if ($detail['required']) { 62 $missing[] = $maptag; 63 } 64 } else { 65 $post[$tag] = $data; 66 } 67 } 68 if (count($missing) > 0) { 69 $msg = ''; 70 foreach ($missing as $m) { 71 $msg .= '<'.$m.'> '; 72 } 73 $this->response->add(new XoopsXmlRpcFault(109, $msg)); 74 } else { 75 $newparams = array(); 76 // Xoops Api ignores App key 77 $newparams[0] = $this->params[1]; 78 $newparams[1] = $this->params[2]; 79 $newparams[2] = $this->params[3]; 80 foreach ($post as $key => $value) { 81 $newparams[3][$key] =& $value; 82 unset($value); 83 } 84 $newparams[3]['xoops_text'] =& $this->params[4]; 85 $newparams[4] = $this->params[5]; 86 $xoopsapi =& $this->_getXoopsApi($newparams); 87 $xoopsapi->_setUser($this->user, $this->isadmin); 88 $xoopsapi->newPost(); 89 } 90 } 91 } 92 } 93 94 function editPost() 95 { 96 if (!$this->_checkUser($this->params[2], $this->params[3])) { 97 $this->response->add(new XoopsXmlRpcFault(104)); 98 } else { 99 if (!$fields =& $this->_getPostFields($this->params[1])) { 100 } else { 101 $missing = array(); 102 $post = array(); 103 foreach ($fields as $tag => $detail) { 104 $data = $this->_getTagCdata($this->params[4], $tag, true); 105 if (trim($data) == ''){ 106 if ($detail['required']) { 107 $missing[] = $tag; 108 } 109 } else { 110 $post[$tag] = $data; 111 } 112 } 113 if (count($missing) > 0) { 114 $msg = ''; 115 foreach ($missing as $m) { 116 $msg .= '<'.$m.'> '; 117 } 118 $this->response->add(new XoopsXmlRpcFault(109, $msg)); 119 } else { 120 $newparams = array(); 121 // XOOPS API ignores App key (index 0 of params) 122 $newparams[0] = $this->params[1]; 123 $newparams[1] = $this->params[2]; 124 $newparams[2] = $this->params[3]; 125 foreach ($post as $key => $value) { 126 $newparams[3][$key] =& $value; 127 unset($value); 128 } 129 $newparams[3]['xoops_text'] =& $this->params[4]; 130 $newparams[4] = $this->params[5]; 131 $xoopsapi =& $this->_getXoopsApi($newparams); 132 $xoopsapi->_setUser($this->user, $this->isadmin); 133 $xoopsapi->editPost(); 134 } 135 } 136 } 137 } 138 139 function deletePost() 140 { 141 if (!$this->_checkUser($this->params[2], $this->params[3])) { 142 $this->response->add(new XoopsXmlRpcFault(104)); 143 } else { 144 // XOOPS API ignores App key (index 0 of params) 145 array_shift($this->params); 146 $xoopsapi =& $this->_getXoopsApi($this->params); 147 $xoopsapi->_setUser($this->user, $this->isadmin); 148 $xoopsapi->deletePost(); 149 } 150 } 151 152 function getPost() 153 { 154 if (!$this->_checkUser($this->params[2], $this->params[3])) { 155 $this->response->add(new XoopsXmlRpcFault(104)); 156 } else { 157 // XOOPS API ignores App key (index 0 of params) 158 array_shift($this->params); 159 $xoopsapi =& $this->_getXoopsApi($this->params); 160 $xoopsapi->_setUser($this->user, $this->isadmin); 161 $ret =& $xoopsapi->getPost(false); 162 if (is_array($ret)) { 163 $struct = new XoopsXmlRpcStruct(); 164 $content = ''; 165 foreach ($ret as $key => $value) { 166 $maptag = $this->_getXoopsTagMap($key); 167 switch($maptag) { 168 case 'userid': 169 $struct->add('userid', new XoopsXmlRpcString($value)); 170 break; 171 case 'dateCreated': 172 $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); 173 break; 174 case 'postid': 175 $struct->add('postid', new XoopsXmlRpcString($value)); 176 break; 177 default : 178 $content .= '<'.$key.'>'.trim($value).'</'.$key.'>'; 179 break; 180 } 181 } 182 $struct->add('content', new XoopsXmlRpcString($content)); 183 $this->response->add($struct); 184 } else { 185 $this->response->add(new XoopsXmlRpcFault(106)); 186 } 187 } 188 } 189 190 function getRecentPosts() 191 { 192 if (!$this->_checkUser($this->params[2], $this->params[3])) { 193 $this->response->add(new XoopsXmlRpcFault(104)); 194 } else { 195 // XOOPS API ignores App key (index 0 of params) 196 array_shift($this->params); 197 $xoopsapi =& $this->_getXoopsApi($this->params); 198 $xoopsapi->_setUser($this->user, $this->isadmin); 199 $ret =& $xoopsapi->getRecentPosts(false); 200 if (is_array($ret)) { 201 $arr = new XoopsXmlRpcArray(); 202 $count = count($ret); 203 if ($count == 0) { 204 $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); 205 } else { 206 for ($i = 0; $i < $count; $i++) { 207 $struct = new XoopsXmlRpcStruct(); 208 $content = ''; 209 foreach($ret[$i] as $key => $value) { 210 $maptag = $this->_getXoopsTagMap($key); 211 switch($maptag) { 212 case 'userid': 213 $struct->add('userid', new XoopsXmlRpcString($value)); 214 break; 215 case 'dateCreated': 216 $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); 217 break; 218 case 'postid': 219 $struct->add('postid', new XoopsXmlRpcString($value)); 220 break; 221 default : 222 $content .= '<'.$key.'>'.trim($value).'</'.$key.'>'; 223 break; 224 } 225 } 226 $struct->add('content', new XoopsXmlRpcString($content)); 227 $arr->add($struct); 228 unset($struct); 229 } 230 $this->response->add($arr); 231 } 232 } else { 233 $this->response->add(new XoopsXmlRpcFault(106)); 234 } 235 } 236 } 237 238 function getUsersBlogs() 239 { 240 if (!$this->_checkUser($this->params[1], $this->params[2])) { 241 $this->response->add(new XoopsXmlRpcFault(104)); 242 } else { 243 $arr = new XoopsXmlRpcArray(); 244 $struct = new XoopsXmlRpcStruct(); 245 $struct->add('url', new XoopsXmlRpcString(XOOPS_URL.'/modules/'.$this->module->getVar('dirname').'/')); 246 $struct->add('blogid', new XoopsXmlRpcString($this->module->getVar('mid'))); 247 $struct->add('blogName', new XoopsXmlRpcString('XOOPS Blog')); 248 $arr->add($struct); 249 $this->response->add($arr); 250 } 251 } 252 253 function getUserInfo() 254 { 255 if (!$this->_checkUser($this->params[1], $this->params[2])) { 256 $this->response->add(new XoopsXmlRpcFault(104)); 257 } else { 258 $struct = new XoopsXmlRpcStruct(); 259 $struct->add('nickname', new XoopsXmlRpcString($this->user->getVar('uname'))); 260 $struct->add('userid', new XoopsXmlRpcString($this->user->getVar('uid'))); 261 $struct->add('url', new XoopsXmlRpcString($this->user->getVar('url'))); 262 $struct->add('email', new XoopsXmlRpcString($this->user->getVar('email'))); 263 $struct->add('lastname', new XoopsXmlRpcString('')); 264 $struct->add('firstname', new XoopsXmlRpcString($this->user->getVar('name'))); 265 $this->response->add($struct); 266 } 267 } 268 269 function getTemplate() 270 { 271 if (!$this->_checkUser($this->params[2], $this->params[3])) { 272 $this->response->add(new XoopsXmlRpcFault(104)); 273 } else { 274 switch ($this->params[5]) { 275 case 'main': 276 $this->response->add(new XoopsXmlRpcFault(107)); 277 break; 278 case 'archiveIndex': 279 $this->response->add(new XoopsXmlRpcFault(107)); 280 break; 281 default: 282 $this->response->add(new XoopsXmlRpcFault(107)); 283 break; 284 } 285 } 286 } 287 288 function setTemplate() 289 { 290 if (!$this->_checkUser($this->params[2], $this->params[3])) { 291 $this->response->add(new XoopsXmlRpcFault(104)); 292 } else { 293 $this->response->add(new XoopsXmlRpcFault(107)); 294 } 295 } 296 } 297 ?>
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 |
![]() |