Changeset 25394


Ignore:
Timestamp:
Nov 8, 2013, 1:16:14 PM (10 years ago)
Author:
mistic100
Message:

Improve display on ws.htm

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_core.inc.php

    r25115 r25394  
    390390    return isset($signature) ? $signature : array();
    391391  }
     392 
     393  /**
     394   * @since 2.6
     395   */
     396  function getMethodOptions($methodName)
     397  {
     398    $options = @$this->_methods[$methodName]['options'];
     399    return isset($options) ? $options : array();
     400  }
    392401
    393402  static function isPost()
     
    629638      'description' => $service->getMethodDescription($methodName),
    630639      'params' => array(),
     640      'options' => $service->getMethodOptions($methodName),
    631641    );
    632642   
     
    644654        $param_data['defaultValue'] = $options['default'];
    645655      }
     656      if (isset($options['maxValue']))
     657      {
     658        $param_data['maxValue'] = $options['maxValue'];
     659      }
    646660      if (isset($options['info']))
    647661      {
  • trunk/tools/ws.htm

    r25077 r25394  
    11<!DOCTYPE html>
    2 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">
     2<html lang="en" dir="ltr">
    33<head>
    4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     4  <meta charset="utf-8">
    55  <title>Piwigo web API (web-services) explorer</title>
    66 
    7   <link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/tiptip/1.3/tipTip.css">
    8  
    9   <style type="text/css">
     7  <link rel="stylesheet" href="http://cdn.jsdelivr.net/tiptip/1.3/tipTip.css">
     8 
     9  <style>
    1010  /* BEGIN CSS RESET
    1111    http://meyerweb.com/eric/tools/css/reset
     
    6161  #the_content {padding:10px;}
    6262
    63   #methodParams {display:inline-block;}
     63  #methodParams {margin-right:230px;}
    6464  #methodParams thead td {background:#DEE3E9;font-weight:bold;padding:2px 5px;}
    6565  #methodParams td {padding:2px;border:1px solid #cdcdcd;vertical-align:middle;}
     
    7474  #methodParams .subtype {vertical-align:super;}
    7575
    76   #testForm {display:inline-block;margin-left:15px;}
     76  #testForm {float:right;}
    7777  #testForm td {padding:2px 0;}
    7878  #testForm tr:last-child td {padding:8px 0 5px 0;}
     
    9494  #iframeWrapper {width:100%;height:300px;padding:3px 3px 20px 3px;background:#F9F9F9;border:1px solid #cdcdcd;overflow:hidden;position:relative;}
    9595  iframe {width:100%;height:100%;background:#fff;}
     96 
     97  div.onlys {background:#faa;color:#fff;border:1px solid #f22;padding:.25em .5em;display:table;border-radius:4px;margin-bottom:0.5em;}
    9698  </style>
    9799 
     
    99101
    100102<body>
     103<a name="top"></a>
    101104
    102105<div id="the_header">
     
    151154        <br>
    152155      </div> <!-- methodDescription -->
     156     
     157      <div id="testForm">
     158        <h3>Test</h3>
     159        <blockquote>
     160          <table>
     161            <tr>
     162              <td>Request format :</td>
     163              <td>
     164                <select id="requestFormat">
     165                  <option value="get" selected>GET</option>
     166                  <option value="post">POST</option>
     167                </select>
     168              </td>
     169            </tr>
     170            <tr>
     171              <td>Response format :</td>
     172              <td>
     173                <select id="responseFormat">
     174                  <option value="rest" selected>REST (xml)</option>
     175                  <option value="json">JSON</option>
     176                  <option value="php">PHP serial</option>
     177                  <option value="xmlrpc">XML RPC</option>
     178                </select>
     179              </td>
     180            </tr>
     181            <tr>
     182              <td colspan="2">
     183                <a href="#" class="button" id="invokeMethod">INVOKE</a>
     184                <a href="#" class="button" id="invokeMethodBlank">INVOKE (new window)</a>
     185              </td>
     186            </tr>
     187          </table>
     188        </blockquote>
     189      </div> <!-- testForm -->
    153190     
    154191      <div id="methodParams">
     
    179216      </div> <!-- methodParams -->
    180217     
    181       <div id="testForm">
    182         <h3>Test</h3>
    183         <blockquote>
    184           <table>
    185             <tr>
    186               <td>Request format :</td>
    187               <td>
    188                 <select id="requestFormat">
    189                   <option value="get" selected="selected">GET</option>
    190                   <option value="post">POST</option>
    191                 </select>
    192               </td>
    193             </tr>
    194             <tr>
    195               <td>Response format :</td>
    196               <td>
    197                 <select id="responseFormat">
    198                   <option value="rest" selected="selected">REST (xml)</option>
    199                   <option value="json">JSON</option>
    200                   <option value="php">PHP serial</option>
    201                   <option value="xmlrpc">XML RPC</option>
    202                 </select>
    203               </td>
    204             </tr>
    205             <tr>
    206               <td colspan="2">
    207                 <a href="#" class="button" id="invokeMethod">INVOKE</a>
    208                 <a href="#" class="button" id="invokeMethodBlank">INVOKE (new window)</a>
    209               </td>
    210             </tr>
    211           </table>
    212         </blockquote>
    213       </div> <!-- testForm -->
    214      
    215218      <br><br>
    216219     
     
    218221      <div id="iframeWrapper">
    219222        <iframe src="" id="invokeFrame" name="invokeFrame"></iframe>
    220         <a href="#bottom" id="increaseIframe"><b>&darr;</b> increase height</a> &#8226; <a href="#bottom" id="decreaseIframe"><b>&uarr;</b> decrease height</a>
    221         <a name="bottom"></a>
     223        <a href="#iframe-bottom" id="increaseIframe"><b>&darr;</b> increase height</a> &#8226;
     224        <a href="#iframe-bottom" id="decreaseIframe"><b>&uarr;</b> decrease height</a>
     225        <a name="iframe-bottom"></a>
    222226      </div>
    223227    </form> <!-- iframeWrapper -->
     
    234238</div> <!-- the_footer -->
    235239
    236 <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    237 <script type="text/javascript" src="https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js"></script>
    238 
    239 <script type="text/javascript"
     240<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
     241<script src="https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js"></script>
     242
     243<script
    240244// global vars
    241245var cachedMethods = new Array;
     
    287291  $("#methodName").hide();
    288292  $("#urlForm").hide();
     293  $("#methodDescription blockquote").empty();
    289294  $("#methodDescription").hide();
    290295  $("#invokeFrame").attr('src','');
     
    353358      for (var i=0; i<methods.length; i++)
    354359      {
    355         ml += '<li><a href="#">'+ methods[i]+'</a></li>';
     360        ml += '<li><a href="#top">'+ methods[i]+'</a></li>';
    356361      }
    357362      $("#methodsList").html(ml).show();
     
    362367      $("#methodsList li a").click(function() {
    363368        selectMethod($(this).html());
    364         return false;
    365369      });
    366370    }
     
    404408  $("#methodName").html(method.name).show();
    405409 
     410  if (method.options.post_only || method.options.admin_only) {
     411    var onlys = '<div class="onlys">';
     412    if (method.options.post_only) {
     413      onlys+= 'POST only. ';
     414    }
     415    if (method.options.admin_only) {
     416      onlys+= 'Admin only. ';
     417    }
     418    onlys+= '</div>';
     419   
     420    method.description = onlys + method.description;
     421  }
     422 
    406423  if (method.description != "") {
    407424    $("#methodDescription blockquote").html(method.description);
    408425    $("#methodDescription").show();
    409426  }
     427 
     428  $("#requestFormat").val(method.options.post_only ? 'post' : 'get');
    410429 
    411430  var methodParams = '';
  • trunk/ws.php

    r25382 r25394  
    138138      'ws_getInfos',
    139139      null,
    140       '<b>Admin only.</b> Returns general informations.',
     140      'Returns general informations.',
    141141      $ws_functions_root . 'pwg.php',
    142142      array('admin_only'=>true)
     
    150150                           'type'=>WS_TYPE_ID),
    151151        ),
    152       '<b>Admin only.</b> Adds elements to the caddie. Returns the number of elements added.',
     152      'Adds elements to the caddie. Returns the number of elements added.',
    153153      $ws_functions_root . 'pwg.php',
    154154      array('admin_only'=>true)
     
    213213                                'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
    214214        ), $f_params),
    215       '<b>Admin only.</b> Returns a list of derivatives to build.',
     215      'Returns a list of derivatives to build.',
    216216      $ws_functions_root . 'pwg.php',
    217217      array('admin_only'=>true)
     
    227227        'key' =>      array(),
    228228        ),
    229       '<b>POST only.</b> Adds a comment to an image.',
     229      'Adds a comment to an image.',
    230230      $ws_functions_root . 'pwg.images.php',
    231231      array('post_only'=>true)
     
    284284                            'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
    285285        ),
    286       '<b>Admin & POST only.</b> Sets the privacy levels for the images.',
     286      'Sets the privacy levels for the images.',
    287287      $ws_functions_root . 'pwg.images.php',
    288288      array('admin_only'=>true, 'post_only'=>true)
     
    297297        'rank'        => array('type'=>WS_TYPE_INT|WS_TYPE_POSITIVE|WS_TYPE_NOTNULL)
    298298        ),
    299       '<b>Admin & POST only.</b> Sets the rank of a photo for a given album.',
     299      'Sets the rank of a photo for a given album.',
    300300      $ws_functions_root . 'pwg.images.php',
    301301      array('admin_only'=>true, 'post_only'=>true)
     
    309309        'anonymous_id' => array('default'=>null),
    310310        ),
    311       '<b>Admin & POST only.</b> Deletes all rates for a user.',
     311      'Deletes all rates for a user.',
    312312      $ws_functions_root . 'pwg.php',
    313313      array('admin_only'=>true, 'post_only'=>true)
     
    326326      'ws_session_login',
    327327      array('username', 'password'),
    328       '<b>POST only.</b> Tries to login the user.',
     328      'Tries to login the user.',
    329329      $ws_functions_root . 'pwg.php',
    330330      array('post_only'=>true)
     
    385385        'position' =>     array()
    386386        ),
    387       '<b>Admin & POST only.</b> Add a chunk of a file.',
     387      'Add a chunk of a file.',
    388388      $ws_functions_root . 'pwg.images.php',
    389389      array('admin_only'=>true, 'post_only'=>true)
     
    399399        'sum' =>      array(),
    400400        ),
    401       '<b>Admin only.</b> Add or update a file for an existing photo.
     401      'Add or update a file for an existing photo.
    402402<br>pwg.images.addChunk must have been called before (maybe several times).',
    403403      $ws_functions_root . 'pwg.images.php',
     
    431431                                      'type'=>WS_TYPE_ID),
    432432        ),
    433       '<b>Admin only.</b> Add an image.
     433      'Add an image.
    434434<br>pwg.images.addChunk must have been called before (maybe several times).
    435435<br>Don\'t use "thumbnail_sum" and "high_sum", these parameters are here for backward compatibility.',
     
    456456                            'type'=>WS_TYPE_ID),
    457457        ),
    458       '<b>Admin & POST only.</b> Add an image.
     458      'Add an image.
    459459<br>Use the <b>$_FILES[image]</b> field for uploading file.
    460460<br>Set the form encoding to "form-data".
     
    471471        'pwg_token' =>  array(),
    472472        ),
    473       '<b>Admin & POST only.</b> Deletes image(s).',
     473      'Deletes image(s).',
    474474      $ws_functions_root . 'pwg.images.php',
    475475      array('admin_only'=>true, 'post_only'=>true)
     
    480480      'ws_categories_getAdminList',
    481481      null,
    482       '<b>Admin only.</b>',
     482      'Get albums list as displayed on admin page.',
    483483      $ws_functions_root . 'pwg.categories.php',
    484484      array('admin_only'=>true)
     
    500500                                'type'=>WS_TYPE_BOOL),
    501501        ),
    502       '<b>Admin only.</b> Adds an album.',
     502      'Adds an album.',
    503503      $ws_functions_root . 'pwg.categories.php',
    504504      array('admin_only'=>true)
     
    513513        'pwg_token' =>            array(),
    514514        ),
    515       '<b>Admin & POST only.</b> Deletes album(s).
     515      'Deletes album(s).
    516516<br><b>photo_deletion_mode</b> can be "no_delete" (may create orphan photos), "delete_orphans"
    517517(default mode, only deletes photos linked to no other album) or "force_delete" (delete all photos, even those linked to other albums)',
     
    528528        'pwg_token' =>    array(),
    529529        ),
    530       '<b>Admin & POST only.</b> Move album(s).
     530      'Move album(s).
    531531<br>Set parent as 0 to move to gallery root. Only virtual categories can be moved.',
    532532      $ws_functions_root . 'pwg.categories.php',
     
    541541        'image_id' =>     array('type'=>WS_TYPE_ID),
    542542        ),
    543       '<b>Admin & POST only.</b> Sets the representative photo for an album. The photo doesn\'t have to belong to the album.',
     543      'Sets the representative photo for an album. The photo doesn\'t have to belong to the album.',
    544544      $ws_functions_root . 'pwg.categories.php',
    545545      array('admin_only'=>true, 'post_only'=>true)
     
    559559      'ws_tags_add',
    560560      array('name'),
    561       '<b>Admin only.</b> Adds a new tag.',
     561      'Adds a new tag.',
    562562      $ws_functions_root . 'pwg.tags.php',
    563563      array('admin_only'=>true)
     
    571571        'filename_list' =>  array('default'=>null),
    572572        ),
    573       '<b>Admin only.</b>  Checks existence of images.
     573      'Checks existence of images.
    574574<br>Give <b>md5sum_list</b> if $conf[uniqueness_mode]==md5sum. Give <b>filename_list</b> if $conf[uniqueness_mode]==filename.',
    575575      $ws_functions_root . 'pwg.images.php',
     
    586586        'high_sum' =>       array('default'=>null),
    587587        ),
    588       '<b>Admin only.</b> Checks if you have updated version of your files for a given photo, the answer can be "missing", "equals" or "differs".
     588      'Checks if you have updated version of your files for a given photo, the answer can be "missing", "equals" or "differs".
    589589<br>Don\'t use "thumbnail_sum" and "high_sum", these parameters are here for backward compatibility.',
    590590      $ws_functions_root . 'pwg.images.php',
     
    596596      'ws_images_checkUpload',
    597597      null,
    598       '<b>Admin only.</b> Checks if Piwigo is ready for upload.',
     598      'Checks if Piwigo is ready for upload.',
    599599      $ws_functions_root . 'pwg.images.php',
    600600      array('admin_only'=>true)
     
    621621        'multiple_value_mode' =>  array('default'=>'append'),
    622622        ),
    623       '<b>Admin & POST only.</b> Changes properties of an image.
     623      'Changes properties of an image.
    624624<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"
    625625(overwrite any existing value) and applies to single values properties like name/author/date_creation/comment.
     
    637637        'comment' =>      array('default'=>null),
    638638        ),
    639       '<b>Admin & POST only.</b> Changes properties of an album.',
     639      'Changes properties of an album.',
    640640      $ws_functions_root . 'pwg.categories.php',
    641641      array('admin_only'=>true, 'post_only'=>true)
     
    646646      'ws_plugins_getList',
    647647      null,
    648       '<b>Admin only.</b> Gets the list of plugins with id, name, version, state and description.',
     648      'Gets the list of plugins with id, name, version, state and description.',
    649649      $ws_functions_root . 'pwg.extensions.php',
    650650      array('admin_only'=>true)
     
    659659        'pwg_token' => array(),
    660660        ),
    661       '<b>Admin only.</b>',
     661      null,
    662662      $ws_functions_root . 'pwg.extensions.php',
    663663      array('admin_only'=>true)
     
    672672        'pwg_token' => array(),
    673673        ),
    674       '<b>Admin only.</b>',
     674      null,
    675675      $ws_functions_root . 'pwg.extensions.php',
    676676      array('admin_only'=>true)
     
    712712      'ws_extensions_checkupdates',
    713713      null,
    714       '<b>Admin only.</b> Checks if piwigo or extensions are up to date.',
     714      'Checks if piwigo or extensions are up to date.',
    715715      $ws_functions_root . 'pwg.extensions.php',
    716716      array('admin_only'=>true)
     
    733733                            'info'=>'id, name, nb_users, is_default'),
    734734        ),
    735       '<b>Admin only.</b> Retrieves a list of all groups. The list can be filtered.',
     735      'Retrieves a list of all groups. The list can be filtered.',
    736736      $ws_functions_root . 'pwg.groups.php',
    737737      array('admin_only'=>true)
     
    746746                              'type'=>WS_TYPE_BOOL),
    747747        ),
    748       '<b>Admin & POST only.</b> Creates a group and returns the new group record.',
     748      'Creates a group and returns the new group record.',
    749749      $ws_functions_root . 'pwg.groups.php',
    750750      array('admin_only'=>true, 'post_only'=>true)
     
    759759        'pwg_token' =>  array(),
    760760        ),
    761       '<b>Admin & POST only.</b> Deletes a or more groups. Users and photos are not deleted.',
     761      'Deletes a or more groups. Users and photos are not deleted.',
    762762      $ws_functions_root . 'pwg.groups.php',
    763763      array('admin_only'=>true, 'post_only'=>true)
     
    773773                              'type'=>WS_TYPE_BOOL),
    774774        ),
    775       '<b>Admin & POST only.</b> Updates a group. Leave a field blank to keep the current value.',
     775      'Updates a group. Leave a field blank to keep the current value.',
    776776      $ws_functions_root . 'pwg.groups.php',
    777777      array('admin_only'=>true, 'post_only'=>true)
     
    786786                            'type'=>WS_TYPE_ID),
    787787        ),
    788       '<b>Admin only.</b> Adds one or more users to a group.',
     788      'Adds one or more users to a group.',
    789789      $ws_functions_root . 'pwg.groups.php',
    790790      array('admin_only'=>true, 'post_only'=>true)
     
    799799                            'type'=>WS_TYPE_ID),
    800800        ),
    801       '<b>Admin & POST only.</b> Removes one or more users from a group.',
     801      'Removes one or more users from a group.',
    802802      $ws_functions_root . 'pwg.groups.php',
    803803      array('admin_only'=>true, 'post_only'=>true)
     
    829829                              'info'=>'all,basics,none,username,email,status,level,groups,language,theme,nb_image_page,recent_period,expand,show_nb_comments,show_nb_hits,enabled_high'),
    830830        ),
    831       '<b>Admin only.</b> Retrieves a list of all the users.
     831      'Retrieves a list of all the users.
    832832<br>"display" controls which data are returned, "basics" stands for "username,email,status,level,groups"',
    833833      $ws_functions_root . 'pwg.users.php',
     
    845845        'send_password_by_mail' => array('default'=>false, 'type'=>WS_TYPE_BOOL),
    846846        ),
    847       '<b>Admin & POST only.</b> Registers a new user.',
     847      'Registers a new user.',
    848848      $ws_functions_root . 'pwg.users.php',
    849849      array('admin_only'=>true, 'post_only'=>true)
     
    858858        'pwg_token' =>  array(),
    859859        ),
    860       '<b>Admin & POST only.</b> Deletes on or more users. Photos owned by this user are not deleted.',
     860      'Deletes on or more users. Photos owned by this user are not deleted.',
    861861      $ws_functions_root . 'pwg.users.php',
    862862      array('admin_only'=>true, 'post_only'=>true)
     
    893893                                    'type'=>WS_TYPE_BOOL),
    894894        ),
    895       '<b>Admin & POST only.</b> Updates a user. Leave a field blank to keep the current value.
     895      'Updates a user. Leave a field blank to keep the current value.
    896896<br>"username", "password" and "email" are ignored if "user_id" is an array.',
    897897      $ws_functions_root . 'pwg.users.php',
     
    910910                              'type'=>WS_TYPE_ID),
    911911        ),
    912       '<b>Admin only.</b> Returns permissions: user ids and group ids having access to each album ; this list can be filtered.
     912      'Returns permissions: user ids and group ids having access to each album ; this list can be filtered.
    913913<br>Provide only one parameter!',
    914914      $ws_functions_root . 'pwg.permissions.php',
     
    929929                              'type'=>WS_TYPE_BOOL),
    930930        ),
    931       '<b>Admin only.</b> Adds permissions to an album.',
     931      'Adds permissions to an album.',
    932932      $ws_functions_root . 'pwg.permissions.php',
    933933      array('admin_only'=>true, 'post_only'=>true)
     
    945945                            'type'=>WS_TYPE_ID),
    946946        ),
    947       '<b>Admin & POST only.</b> Removes permissions from an album.',
     947      'Removes permissions from an album.',
    948948      $ws_functions_root . 'pwg.permissions.php',
    949949      array('admin_only'=>true, 'post_only'=>true)
Note: See TracChangeset for help on using the changeset viewer.