[1698] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 5 | // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | |
---|
[2297] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[1698] | 23 | |
---|
| 24 | define ('PHPWG_ROOT_PATH', './'); |
---|
| 25 | |
---|
| 26 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
[2325] | 27 | check_status(ACCESS_FREE); |
---|
[1698] | 28 | include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php'); |
---|
| 29 | |
---|
[1781] | 30 | if ( !$conf['allow_web_services'] ) |
---|
| 31 | { |
---|
| 32 | page_forbidden('Web services are disabled'); |
---|
| 33 | } |
---|
| 34 | |
---|
[1768] | 35 | /** |
---|
| 36 | * event handler that registers standard methods with the web service |
---|
| 37 | */ |
---|
[1698] | 38 | function ws_addDefaultMethods( $arr ) |
---|
| 39 | { |
---|
| 40 | include_once(PHPWG_ROOT_PATH.'include/ws_functions.inc.php'); |
---|
[1849] | 41 | global $conf, $user; |
---|
[1698] | 42 | $service = &$arr[0]; |
---|
| 43 | $service->addMethod('pwg.getVersion', 'ws_getVersion', null, |
---|
| 44 | 'retrieves the PWG version'); |
---|
[10017] | 45 | |
---|
| 46 | $service->addMethod('pwg.getInfos', 'ws_getInfos', null, |
---|
| 47 | 'retrieves general informations'); |
---|
[1698] | 48 | |
---|
[2435] | 49 | $service->addMethod('pwg.caddie.add', 'ws_caddie_add', |
---|
[2429] | 50 | array( |
---|
| 51 | 'image_id'=> array( 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 52 | ), |
---|
| 53 | 'adds the elements to the caddie'); |
---|
| 54 | |
---|
[1698] | 55 | $service->addMethod('pwg.categories.getImages', 'ws_categories_getImages', |
---|
| 56 | array( |
---|
| 57 | 'cat_id'=>array('default'=>0, 'flags'=>WS_PARAM_FORCE_ARRAY), |
---|
| 58 | 'recursive'=>array('default'=>false), |
---|
[1781] | 59 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
[1698] | 60 | 'page' => array('default'=>0), |
---|
| 61 | 'order' => array('default'=>null), |
---|
| 62 | 'f_min_rate' => array( 'default'=> null ), |
---|
| 63 | 'f_max_rate' => array( 'default'=> null ), |
---|
| 64 | 'f_min_hit' => array( 'default'=> null ), |
---|
| 65 | 'f_max_hit' => array( 'default'=> null ), |
---|
| 66 | 'f_min_date_available' => array( 'default'=> null ), |
---|
| 67 | 'f_max_date_available' => array( 'default'=> null ), |
---|
| 68 | 'f_min_date_created' => array( 'default'=> null ), |
---|
| 69 | 'f_max_date_created' => array( 'default'=> null ), |
---|
| 70 | 'f_min_ratio' => array( 'default'=> null ), |
---|
| 71 | 'f_max_ratio' => array( 'default'=> null ), |
---|
[12865] | 72 | 'f_max_level' => array( 'default'=> null ), |
---|
[1698] | 73 | ), |
---|
| 74 | 'Returns elements for the corresponding categories. |
---|
[3185] | 75 | <br><b>cat_id</b> can be empty if <b>recursive</b> is true. Can be sent as an array. |
---|
[11893] | 76 | <br><b>order</b> comma separated fields for sorting (file,id, rating_score,...)' |
---|
[1698] | 77 | ); |
---|
| 78 | |
---|
| 79 | $service->addMethod('pwg.categories.getList', 'ws_categories_getList', |
---|
| 80 | array( |
---|
| 81 | 'cat_id' => array('default'=>0), |
---|
| 82 | 'recursive' => array('default'=>false), |
---|
| 83 | 'public' => array('default'=>false), |
---|
[11155] | 84 | 'tree_output' => array('default'=>false), |
---|
[11962] | 85 | 'fullname' => array('default'=>false), |
---|
[1698] | 86 | ), |
---|
[11155] | 87 | 'retrieves a list of categories (tree_output option only compatible with json/php output format' ); |
---|
[1698] | 88 | |
---|
[12865] | 89 | $service->addMethod('pwg.getMissingDerivatives', 'ws_getMissingDerivatives', |
---|
| 90 | array( |
---|
| 91 | 'types' => array( 'default'=>array(), 'flags'=>WS_PARAM_FORCE_ARRAY), |
---|
| 92 | 'max_urls' => array( 'default' => 200 ), |
---|
| 93 | 'prev_page' => array( 'default'=> null), |
---|
| 94 | 'f_min_rate' => array( 'default'=> null ), |
---|
| 95 | 'f_max_rate' => array( 'default'=> null ), |
---|
| 96 | 'f_min_hit' => array( 'default'=> null ), |
---|
| 97 | 'f_max_hit' => array( 'default'=> null ), |
---|
| 98 | 'f_min_date_available' => array( 'default'=> null ), |
---|
| 99 | 'f_max_date_available' => array( 'default'=> null ), |
---|
| 100 | 'f_min_date_created' => array( 'default'=> null ), |
---|
| 101 | 'f_max_date_created' => array( 'default'=> null ), |
---|
| 102 | 'f_min_ratio' => array( 'default'=> null ), |
---|
| 103 | 'f_max_ratio' => array( 'default'=> null ), |
---|
| 104 | 'f_max_level' => array( 'default'=> null ), |
---|
| 105 | ), |
---|
| 106 | 'retrieves a list of derivatives to build' ); |
---|
| 107 | |
---|
[1849] | 108 | $service->addMethod('pwg.images.addComment', 'ws_images_addComment', |
---|
| 109 | array( |
---|
| 110 | 'image_id' => array(), |
---|
[2029] | 111 | 'author' => array( 'default' => is_a_guest()? 'guest':$user['username']), |
---|
[1849] | 112 | 'content' => array(), |
---|
| 113 | 'key' => array(), |
---|
| 114 | ), |
---|
| 115 | 'add a comment to an image' ); |
---|
| 116 | |
---|
[1698] | 117 | $service->addMethod('pwg.images.getInfo', 'ws_images_getInfo', |
---|
[1849] | 118 | array( |
---|
| 119 | 'image_id' => array(), |
---|
| 120 | 'comments_page' => array('default'=>0 ), |
---|
[2435] | 121 | 'comments_per_page' => array( |
---|
| 122 | 'default' => $conf['nb_comment_page'], |
---|
[1849] | 123 | 'maxValue' => 2*$conf['nb_comment_page'], |
---|
| 124 | ), |
---|
| 125 | ), |
---|
[1698] | 126 | 'retrieves information about the given photo' ); |
---|
| 127 | |
---|
[2435] | 128 | $service->addMethod('pwg.images.rate', 'ws_images_rate', |
---|
| 129 | array( |
---|
| 130 | 'image_id' => array(), |
---|
| 131 | 'rate' => array(), |
---|
| 132 | ), |
---|
| 133 | 'rate the image' ); |
---|
| 134 | |
---|
[1837] | 135 | $service->addMethod('pwg.images.search', 'ws_images_search', |
---|
| 136 | array( |
---|
| 137 | 'query'=>array(), |
---|
| 138 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
| 139 | 'page' => array('default'=>0), |
---|
| 140 | 'order' => array('default'=>null), |
---|
| 141 | 'f_min_rate' => array( 'default'=> null ), |
---|
| 142 | 'f_max_rate' => array( 'default'=> null ), |
---|
| 143 | 'f_min_hit' => array( 'default'=> null ), |
---|
| 144 | 'f_max_hit' => array( 'default'=> null ), |
---|
| 145 | 'f_min_date_available' => array( 'default'=> null ), |
---|
| 146 | 'f_max_date_available' => array( 'default'=> null ), |
---|
| 147 | 'f_min_date_created' => array( 'default'=> null ), |
---|
| 148 | 'f_max_date_created' => array( 'default'=> null ), |
---|
| 149 | 'f_min_ratio' => array( 'default'=> null ), |
---|
| 150 | 'f_max_ratio' => array( 'default'=> null ), |
---|
[12865] | 151 | 'f_max_level' => array( 'default'=> null ), |
---|
[1837] | 152 | ), |
---|
| 153 | 'Returns elements for the corresponding query search.' |
---|
| 154 | ); |
---|
[2516] | 155 | |
---|
[2463] | 156 | $service->addMethod( |
---|
| 157 | 'pwg.images.setPrivacyLevel', |
---|
| 158 | 'ws_images_setPrivacyLevel', |
---|
| 159 | array( |
---|
| 160 | 'image_id' => array('flags'=>WS_PARAM_FORCE_ARRAY), |
---|
| 161 | 'level' => array('maxValue'=>$conf['available_permission_levels']), |
---|
[2413] | 162 | ), |
---|
[4513] | 163 | 'sets the privacy levels for the images (POST method only)' |
---|
[2463] | 164 | ); |
---|
[1837] | 165 | |
---|
[11372] | 166 | $service->addMethod( |
---|
| 167 | 'pwg.images.setRank', |
---|
| 168 | 'ws_images_setRank', |
---|
| 169 | array( |
---|
| 170 | 'image_id' => array(), |
---|
| 171 | 'category_id' => array(), |
---|
| 172 | 'rank' => array(), |
---|
| 173 | ), |
---|
| 174 | 'sets the rank of a photo for a given album (POST method only, for admins)' |
---|
| 175 | ); |
---|
[12624] | 176 | |
---|
| 177 | |
---|
| 178 | $service->addMethod('pwg.rates.delete', 'ws_rates_delete', |
---|
| 179 | array( |
---|
| 180 | 'user_id' => array(), |
---|
| 181 | 'anonymous_id' => array( 'default'=>'' ), |
---|
| 182 | ), |
---|
| 183 | 'deletes all rates for a user (POST method only, admins only)' |
---|
| 184 | ); |
---|
| 185 | |
---|
[1698] | 186 | $service->addMethod('pwg.session.getStatus', 'ws_session_getStatus', null, '' ); |
---|
| 187 | $service->addMethod('pwg.session.login', 'ws_session_login', |
---|
| 188 | array('username', 'password'), |
---|
| 189 | 'POST method only' ); |
---|
| 190 | $service->addMethod('pwg.session.logout', 'ws_session_logout', null, ''); |
---|
| 191 | |
---|
| 192 | $service->addMethod('pwg.tags.getList', 'ws_tags_getList', |
---|
| 193 | array('sort_by_counter' => array('default' =>false) ), |
---|
| 194 | 'retrieves a list of available tags'); |
---|
| 195 | $service->addMethod('pwg.tags.getImages', 'ws_tags_getImages', |
---|
| 196 | array( |
---|
| 197 | 'tag_id'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 198 | 'tag_url_name'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 199 | 'tag_name'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 200 | 'tag_mode_and'=>array('default'=>false), |
---|
[1781] | 201 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
[1698] | 202 | 'page' => array('default'=>0), |
---|
| 203 | 'order' => array('default'=>null), |
---|
| 204 | 'f_min_rate' => array( 'default'=> null ), |
---|
| 205 | 'f_max_rate' => array( 'default'=> null ), |
---|
| 206 | 'f_min_hit' => array( 'default'=> null ), |
---|
| 207 | 'f_max_hit' => array( 'default'=> null ), |
---|
| 208 | 'f_min_date_available' => array( 'default'=> null ), |
---|
| 209 | 'f_max_date_available' => array( 'default'=> null ), |
---|
| 210 | 'f_min_date_created' => array( 'default'=> null ), |
---|
| 211 | 'f_max_date_created' => array( 'default'=> null ), |
---|
| 212 | 'f_min_ratio' => array( 'default'=> null ), |
---|
| 213 | 'f_max_ratio' => array( 'default'=> null ), |
---|
[12865] | 214 | 'f_max_level' => array( 'default'=> null ), |
---|
[1698] | 215 | ), |
---|
| 216 | 'Returns elements for the corresponding tags. Note that tag_id, tag_url_name, tag_name an be arrays. Fill at least one of them. ' |
---|
| 217 | ); |
---|
[2463] | 218 | |
---|
| 219 | $service->addMethod( |
---|
[3193] | 220 | 'pwg.images.addChunk', |
---|
| 221 | 'ws_images_add_chunk', |
---|
| 222 | array( |
---|
| 223 | 'data' => array(), |
---|
| 224 | 'original_sum' => array(), |
---|
| 225 | 'type' => array(), |
---|
| 226 | 'position' => array(), |
---|
| 227 | ), |
---|
| 228 | 'POST method only. For admin only.' |
---|
| 229 | ); |
---|
| 230 | |
---|
| 231 | $service->addMethod( |
---|
[4348] | 232 | 'pwg.images.addFile', |
---|
| 233 | 'ws_images_addFile', |
---|
| 234 | array( |
---|
| 235 | 'image_id' => array(), |
---|
| 236 | 'type' => array(), |
---|
| 237 | 'sum' => array(), |
---|
| 238 | ), |
---|
| 239 | 'Add or update a file for an existing photo. pwg.images.addChunk must have been called before (maybe several times)' |
---|
| 240 | ); |
---|
| 241 | |
---|
| 242 | |
---|
| 243 | $service->addMethod( |
---|
[2463] | 244 | 'pwg.images.add', |
---|
| 245 | 'ws_images_add', |
---|
| 246 | array( |
---|
[2569] | 247 | 'file_sum' => array(), |
---|
[12724] | 248 | 'thumbnail_sum' => array('default' => null), |
---|
[2670] | 249 | 'high_sum' => array('default' => null), |
---|
[3065] | 250 | 'original_sum' => array(), |
---|
[4911] | 251 | 'original_filename' => array('default' => null), |
---|
[2569] | 252 | 'name' => array('default' => null), |
---|
| 253 | 'author' => array('default' => null), |
---|
| 254 | 'date_creation' => array('default' => null), |
---|
| 255 | 'comment' => array('default' => null), |
---|
| 256 | 'categories' => array('default' => null), |
---|
| 257 | 'tag_ids' => array('default' => null), |
---|
| 258 | 'level' => array( |
---|
| 259 | 'default' => 0, |
---|
| 260 | 'maxValue' => $conf['available_permission_levels'] |
---|
| 261 | ), |
---|
[12726] | 262 | 'check_uniqueness' => array('default' => true), |
---|
[2463] | 263 | ), |
---|
[2569] | 264 | 'POST method only. |
---|
[3185] | 265 | <br><b>categories</b> is a string list "category_id[,rank];category_id[,rank]" The rank is optional and is equivalent to "auto" if not given.' |
---|
[2463] | 266 | ); |
---|
[2563] | 267 | |
---|
| 268 | $service->addMethod( |
---|
[8249] | 269 | 'pwg.images.addSimple', |
---|
| 270 | 'ws_images_addSimple', |
---|
| 271 | array( |
---|
| 272 | 'category' => array('default' => null), |
---|
| 273 | 'name' => array('default' => null), |
---|
| 274 | 'author' => array('default' => null), |
---|
| 275 | 'comment' => array('default' => null), |
---|
| 276 | 'level' => array( |
---|
| 277 | 'default' => 0, |
---|
| 278 | 'maxValue' => $conf['available_permission_levels'] |
---|
| 279 | ), |
---|
| 280 | 'tags' => array('default' => null), |
---|
[9191] | 281 | 'image_id' => array('default' => null), |
---|
[8249] | 282 | ), |
---|
[9191] | 283 | 'POST method only.<br>Use the <b>image</b> field for uploading file.<br>Set the form encoding to "form-data"<br><b>category</b> is the numeric identifier of the destination category.<br>You can update an existing photo if you define an existing image_id.' |
---|
[8249] | 284 | ); |
---|
[8266] | 285 | |
---|
[8249] | 286 | $service->addMethod( |
---|
[8266] | 287 | 'pwg.images.delete', |
---|
| 288 | 'ws_images_delete', |
---|
| 289 | array( |
---|
| 290 | 'image_id'=>array('default'=>0), |
---|
[10502] | 291 | 'pwg_token' => array(), |
---|
[8266] | 292 | ), |
---|
| 293 | 'Delete photos. You can give several image_ids, comma separated' |
---|
| 294 | ); |
---|
| 295 | |
---|
| 296 | $service->addMethod( |
---|
[2563] | 297 | 'pwg.categories.getAdminList', |
---|
| 298 | 'ws_categories_getAdminList', |
---|
| 299 | array(), |
---|
| 300 | 'administration method only' |
---|
| 301 | ); |
---|
[2583] | 302 | |
---|
| 303 | $service->addMethod( |
---|
| 304 | 'pwg.categories.add', |
---|
| 305 | 'ws_categories_add', |
---|
| 306 | array( |
---|
| 307 | 'name' => array(), |
---|
| 308 | 'parent' => array('default' => null), |
---|
| 309 | ), |
---|
| 310 | 'administration method only' |
---|
| 311 | ); |
---|
[2584] | 312 | |
---|
| 313 | $service->addMethod( |
---|
[8266] | 314 | 'pwg.categories.delete', |
---|
| 315 | 'ws_categories_delete', |
---|
| 316 | array( |
---|
| 317 | 'category_id'=>array('default'=>0), |
---|
[10502] | 318 | 'pwg_token' => array(), |
---|
[8266] | 319 | 'photo_deletion_mode' => array('default' => 'delete_orphans'), |
---|
| 320 | ), |
---|
| 321 | 'Delete categories. You can give several category_ids, comma separated. |
---|
| 322 | <br><b>photo_deletion_mode</b> can be "no_delete" (may create orphan photos), "delete_orphans" (default mode, only deletes photos linked to no other album) or "force_delete" (delete all photos, even those linked to other albums)' |
---|
| 323 | ); |
---|
| 324 | |
---|
| 325 | $service->addMethod( |
---|
[8272] | 326 | 'pwg.categories.move', |
---|
| 327 | 'ws_categories_move', |
---|
| 328 | array( |
---|
| 329 | 'category_id'=>array('default'=>0), |
---|
| 330 | 'parent'=>array('default'=>0), |
---|
[10502] | 331 | 'pwg_token' => array(), |
---|
[8272] | 332 | ), |
---|
| 333 | 'Move categories. You can give several category_ids, comma separated. Set parent as 0 to move to gallery root. Only virtual categories can be moved.' |
---|
| 334 | ); |
---|
[11746] | 335 | |
---|
[8272] | 336 | $service->addMethod( |
---|
[11746] | 337 | 'pwg.categories.setRepresentative', |
---|
| 338 | 'ws_categories_setRepresentative', |
---|
| 339 | array( |
---|
| 340 | 'category_id'=>array('default'=>0), |
---|
| 341 | 'image_id'=>array('default'=>0), |
---|
| 342 | ), |
---|
| 343 | 'Set the representative photo for an album. The photo doesn\'t have to belong to the album. POST method only. Administration method only.' |
---|
| 344 | ); |
---|
| 345 | |
---|
| 346 | $service->addMethod( |
---|
[2584] | 347 | 'pwg.tags.getAdminList', |
---|
| 348 | 'ws_tags_getAdminList', |
---|
| 349 | array(), |
---|
| 350 | 'administration method only' |
---|
| 351 | ); |
---|
[2634] | 352 | |
---|
| 353 | $service->addMethod( |
---|
| 354 | 'pwg.tags.add', |
---|
| 355 | 'ws_tags_add', |
---|
| 356 | array( |
---|
| 357 | 'name' => array(), |
---|
| 358 | ), |
---|
| 359 | 'administration method only' |
---|
| 360 | ); |
---|
[2683] | 361 | |
---|
| 362 | $service->addMethod( |
---|
| 363 | 'pwg.images.exist', |
---|
| 364 | 'ws_images_exist', |
---|
| 365 | array( |
---|
[4954] | 366 | 'md5sum_list'=> array('default' => null), |
---|
| 367 | 'filename_list' => array('default' => null), |
---|
[2683] | 368 | ), |
---|
| 369 | 'check existence of a photo list' |
---|
| 370 | ); |
---|
[2919] | 371 | |
---|
| 372 | $service->addMethod( |
---|
[4347] | 373 | 'pwg.images.checkFiles', |
---|
| 374 | 'ws_images_checkFiles', |
---|
| 375 | array( |
---|
| 376 | 'image_id' => array(), |
---|
| 377 | 'thumbnail_sum' => array('default' => null), |
---|
| 378 | 'file_sum' => array('default' => null), |
---|
| 379 | 'high_sum' => array('default' => null), |
---|
| 380 | ), |
---|
| 381 | 'check if you have updated version of your files for a given photo, for each requested file type, the answer can be "missing", "equals" or "differs"' |
---|
| 382 | ); |
---|
| 383 | |
---|
| 384 | $service->addMethod( |
---|
[6049] | 385 | 'pwg.images.checkUpload', |
---|
| 386 | 'ws_images_checkUpload', |
---|
| 387 | null, |
---|
| 388 | 'check if Piwigo is ready for upload' |
---|
| 389 | ); |
---|
| 390 | |
---|
| 391 | $service->addMethod( |
---|
[2919] | 392 | 'pwg.images.setInfo', |
---|
| 393 | 'ws_images_setInfo', |
---|
| 394 | array( |
---|
| 395 | 'image_id' => array(), |
---|
[4513] | 396 | |
---|
[12730] | 397 | 'file' => array('default' => null), |
---|
[2919] | 398 | 'name' => array('default' => null), |
---|
| 399 | 'author' => array('default' => null), |
---|
| 400 | 'date_creation' => array('default' => null), |
---|
| 401 | 'comment' => array('default' => null), |
---|
| 402 | 'categories' => array('default' => null), |
---|
| 403 | 'tag_ids' => array('default' => null), |
---|
| 404 | 'level' => array( |
---|
[11366] | 405 | 'default' => null, |
---|
[2919] | 406 | 'maxValue' => $conf['available_permission_levels'] |
---|
| 407 | ), |
---|
[4460] | 408 | 'single_value_mode' => array('default' => 'fill_if_empty'), |
---|
| 409 | 'multiple_value_mode' => array('default' => 'append'), |
---|
[2919] | 410 | ), |
---|
| 411 | 'POST method only. Admin only |
---|
[4460] | 412 | <br><b>categories</b> is a string list "category_id[,rank];category_id[,rank]" The rank is optional and is equivalent to "auto" if not given. |
---|
| 413 | <br><b>single_value_mode</b> can be "fill_if_empty" (only use the input value if the corresponding values is currently empty) or "replace" (overwrite any existing value) and applies to single values properties like name/author/date_creation/comment |
---|
| 414 | <br><b>multiple_value_mode</b> can be "append" (no change on existing values, add the new values) or "replace" and applies to multiple values properties like tag_ids/categories' |
---|
[2919] | 415 | ); |
---|
[4513] | 416 | |
---|
[3454] | 417 | $service->addMethod( |
---|
| 418 | 'pwg.categories.setInfo', |
---|
| 419 | 'ws_categories_setInfo', |
---|
| 420 | array( |
---|
| 421 | 'category_id' => array(), |
---|
[4513] | 422 | |
---|
[3454] | 423 | 'name' => array('default' => null), |
---|
| 424 | 'comment' => array('default' => null), |
---|
| 425 | ), |
---|
| 426 | 'POST method only.' |
---|
| 427 | ); |
---|
[8273] | 428 | |
---|
| 429 | $service->addMethod( |
---|
| 430 | 'pwg.plugins.getList', |
---|
| 431 | 'ws_plugins_getList', |
---|
| 432 | array(), |
---|
| 433 | 'get the list of plugin with id, name, version, state and description |
---|
| 434 | <br>administration status required' |
---|
| 435 | ); |
---|
| 436 | |
---|
| 437 | $service->addMethod( |
---|
| 438 | 'pwg.plugins.performAction', |
---|
| 439 | 'ws_plugins_performAction', |
---|
| 440 | array( |
---|
[10502] | 441 | 'action' => array(), |
---|
| 442 | 'plugin' => array(), |
---|
| 443 | 'pwg_token' => array(), |
---|
[8273] | 444 | ), |
---|
| 445 | 'install/activate/deactivate/uninstall/delete a plugin |
---|
| 446 | <br>administration status required' |
---|
| 447 | ); |
---|
[8309] | 448 | |
---|
| 449 | $service->addMethod( |
---|
| 450 | 'pwg.themes.performAction', |
---|
| 451 | 'ws_themes_performAction', |
---|
| 452 | array( |
---|
[10502] | 453 | 'action' => array(), |
---|
| 454 | 'theme' => array(), |
---|
| 455 | 'pwg_token' => array(), |
---|
[8309] | 456 | ), |
---|
| 457 | 'activate/deactivate/delete/set_default a theme<br>administration status required' |
---|
| 458 | ); |
---|
[10235] | 459 | |
---|
| 460 | $service->addMethod( |
---|
[10686] | 461 | 'pwg.images.resizeThumbnail', |
---|
| 462 | 'ws_images_resizethumbnail', |
---|
[10235] | 463 | array( |
---|
[10563] | 464 | 'image_id' => array('default' => null), |
---|
| 465 | 'image_path' => array('default' => null), |
---|
[10686] | 466 | 'maxwidth' => array('default' => $conf['upload_form_thumb_maxwidth']), |
---|
| 467 | 'maxheight' => array('default' => $conf['upload_form_thumb_maxheight']), |
---|
| 468 | 'quality' => array('default' => $conf['upload_form_thumb_quality']), |
---|
| 469 | 'crop' => array('default' => $conf['upload_form_thumb_crop']), |
---|
| 470 | 'follow_orientation' => array('default' => $conf['upload_form_thumb_follow_orientation']), |
---|
| 471 | 'library' => array('default' => $conf['graphics_library']), |
---|
| 472 | ), |
---|
| 473 | 'Create/Regenerate thumbnails photo with given arguments. |
---|
| 474 | <br>One of arguments "image_id" or "image_path" must be sent.' |
---|
| 475 | ); |
---|
| 476 | |
---|
| 477 | $service->addMethod( |
---|
| 478 | 'pwg.images.resizeWebsize', |
---|
| 479 | 'ws_images_resizewebsize', |
---|
| 480 | array( |
---|
| 481 | 'image_id' => array(), |
---|
| 482 | 'maxwidth' => array('default' => $conf['upload_form_websize_maxwidth']), |
---|
| 483 | 'maxheight' => array('default' => $conf['upload_form_websize_maxheight']), |
---|
| 484 | 'quality' => array('default' => $conf['upload_form_websize_quality']), |
---|
[10641] | 485 | 'automatic_rotation' => array('default' => $conf['upload_form_automatic_rotation']), |
---|
[10684] | 486 | 'library' => array('default' => $conf['graphics_library']), |
---|
[10235] | 487 | ), |
---|
[10686] | 488 | 'Regenerate websize photo with given arguments.' |
---|
| 489 | ); |
---|
[10511] | 490 | |
---|
| 491 | $service->addMethod( |
---|
| 492 | 'pwg.extensions.update', |
---|
| 493 | 'ws_extensions_update', |
---|
| 494 | array( |
---|
| 495 | 'type' => array(), |
---|
| 496 | 'id' => array(), |
---|
| 497 | 'revision'=> array(), |
---|
| 498 | 'pwg_token' => array(), |
---|
| 499 | ), |
---|
| 500 | 'Update an extension. Webmaster only. |
---|
| 501 | <br>Parameter type must be "plugins", "languages" or "themes".' |
---|
| 502 | ); |
---|
| 503 | |
---|
| 504 | $service->addMethod( |
---|
| 505 | 'pwg.extensions.ignoreUpdate', |
---|
| 506 | 'ws_extensions_ignoreupdate', |
---|
| 507 | array( |
---|
| 508 | 'type' => array('default'=>null), |
---|
| 509 | 'id' => array('default'=>null), |
---|
| 510 | 'reset' => array('default'=>null), |
---|
| 511 | 'pwg_token' => array(), |
---|
| 512 | ), |
---|
| 513 | 'Ignore an extension if it need update. |
---|
| 514 | <br>Parameter type must be "plugins", "languages" or "themes". |
---|
| 515 | <br>If reset parameter is true, all ignored extensions will be reinitilized.' |
---|
| 516 | ); |
---|
[10538] | 517 | |
---|
| 518 | $service->addMethod( |
---|
| 519 | 'pwg.extensions.checkUpdates', |
---|
| 520 | 'ws_extensions_checkupdates', |
---|
| 521 | array(), |
---|
| 522 | 'Check if piwigo or extensions are up to date.' |
---|
| 523 | ); |
---|
[1698] | 524 | } |
---|
| 525 | |
---|
[1768] | 526 | add_event_handler('ws_add_methods', 'ws_addDefaultMethods'); |
---|
[1698] | 527 | |
---|
[1768] | 528 | |
---|
| 529 | add_event_handler('ws_invoke_allowed', 'ws_isInvokeAllowed', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); |
---|
| 530 | |
---|
[12695] | 531 | $requestFormat = 'rest'; |
---|
[1698] | 532 | $responseFormat = null; |
---|
| 533 | |
---|
| 534 | if ( isset($_GET['format']) ) |
---|
| 535 | { |
---|
| 536 | $responseFormat = $_GET['format']; |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | if ( !isset($responseFormat) and isset($requestFormat) ) |
---|
| 540 | { |
---|
| 541 | $responseFormat = $requestFormat; |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | $service = new PwgServer(); |
---|
| 545 | |
---|
| 546 | if (!is_null($requestFormat)) |
---|
| 547 | { |
---|
| 548 | $handler = null; |
---|
| 549 | switch ($requestFormat) |
---|
| 550 | { |
---|
| 551 | case 'rest': |
---|
| 552 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_handler.php'); |
---|
| 553 | $handler = new PwgRestRequestHandler(); |
---|
| 554 | break; |
---|
| 555 | } |
---|
| 556 | $service->setHandler($requestFormat, $handler); |
---|
| 557 | } |
---|
| 558 | |
---|
| 559 | if (!is_null($responseFormat)) |
---|
| 560 | { |
---|
| 561 | $encoder = null; |
---|
| 562 | switch ($responseFormat) |
---|
| 563 | { |
---|
| 564 | case 'rest': |
---|
| 565 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_encoder.php'); |
---|
| 566 | $encoder = new PwgRestEncoder(); |
---|
| 567 | break; |
---|
| 568 | case 'php': |
---|
| 569 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/php_encoder.php'); |
---|
| 570 | $encoder = new PwgSerialPhpEncoder(); |
---|
| 571 | break; |
---|
| 572 | case 'json': |
---|
| 573 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/json_encoder.php'); |
---|
| 574 | $encoder = new PwgJsonEncoder(); |
---|
| 575 | break; |
---|
| 576 | case 'xmlrpc': |
---|
| 577 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/xmlrpc_encoder.php'); |
---|
| 578 | $encoder = new PwgXmlRpcEncoder(); |
---|
| 579 | break; |
---|
| 580 | } |
---|
| 581 | $service->setEncoder($responseFormat, $encoder); |
---|
| 582 | } |
---|
| 583 | |
---|
[1750] | 584 | set_make_full_url(); |
---|
[1698] | 585 | $service->run(); |
---|
| 586 | |
---|
| 587 | ?> |
---|