Ignore:
Timestamp:
Mar 20, 2013, 6:58:57 PM (11 years ago)
Author:
plg
Message:

bug fixed with iOS/Android app on pwg.categories.getList

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/community/main.inc.php

    r19654 r21751  
    246246    'community_ws_categories_getList',
    247247    array(
    248       'cat_id' => array('default'=>0),
    249       'recursive' => array('default'=>false),
    250       'public' => array('default'=>false),
    251       'fullname' => array('default'=>false),
     248      'cat_id' =>       array('default'=>0),
     249      'recursive' =>    array('default'=>false),
     250      'public' =>       array('default'=>false),
     251      'tree_output' =>  array('default'=>false),
     252      'fullname' =>     array('default'=>false),
    252253      ),
    253254    'retrieves a list of categories'
     
    269270  global $user, $conf;
    270271
     272  if ($params['tree_output'])
     273  {
     274    if (!isset($_GET['format']) or !in_array($_GET['format'], array('php', 'json')))
     275    {
     276      // the algorithm used to build a tree from a flat list of categories
     277      // keeps original array keys, which is not compatible with
     278      // PwgNamedArray.
     279      //
     280      // PwgNamedArray is useful to define which data is an attribute and
     281      // which is an element in the XML output. The "hierarchy" output is
     282      // only compatible with json/php output.
     283
     284      return new PwgError(405, "The tree_output option is only compatible with json/php output formats");
     285    }
     286  }
     287 
    271288  $where = array('1=1');
    272289  $join_type = 'LEFT';
     
    364381  }
    365382  usort($cats, 'global_rank_compare');
    366   return array(
    367     'categories' => new PwgNamedArray(
    368       $cats,
    369       'category',
    370       array(
    371         'id',
    372         'url',
    373         'nb_images',
    374         'total_nb_images',
    375         'nb_categories',
    376         'date_last',
    377         'max_date_last',
     383
     384  if ($params['tree_output'])
     385  {
     386    return categories_flatlist_to_tree($cats);
     387  }
     388  else
     389  {
     390    return array(
     391      'categories' => new PwgNamedArray(
     392        $cats,
     393        'category',
     394        array(
     395          'id',
     396          'url',
     397          'nb_images',
     398          'total_nb_images',
     399          'nb_categories',
     400          'date_last',
     401          'max_date_last',
     402          )
    378403        )
    379       )
    380     );
     404      );
     405  }
    381406}
    382407
Note: See TracChangeset for help on using the changeset viewer.