You are here

function cmis_browser_tree in CMIS API 6.3

Same name and namespace in other branches
  1. 6.4 cmis_browser/cmis_browser.content_autocomplete.inc \cmis_browser_tree()
  2. 7.2 cmis_browser/cmis_browser.content_autocomplete.inc \cmis_browser_tree()
  3. 7 cmis_browser/cmis_browser.content_autocomplete.inc \cmis_browser_tree()

TreeView callback for cmis_browser

1 string reference to 'cmis_browser_tree'
cmis_browser_menu in cmis_browser/cmis_browser.module
Implementation of hook_menu().

File

cmis_browser/cmis_browser.content_autocomplete.inc, line 49

Code

function cmis_browser_tree() {
  module_load_include('api.inc', 'cmis');
  $root = $_REQUEST['id'];
  try {
    $repository = cmis_get_repository();
    if ($root == '0') {
      $object = cmisapi_getProperties($repository->repositoryId, $repository->info->repositoryInfo['cmis:rootFolderId']);
    }
    else {
      $object = cmisapi_getObjectByPath($repository->repositoryId, drupal_urlencode($root));
    }
    $children = cmisapi_getChildren($repository->repositoryId, $object->id);
  } catch (CMISException $e) {
    cmis_error_handler('cmis_browser', $e);
    return '';
  }
  $result = array();
  foreach ($children->objectList as $child) {
    $result[] = array(
      'data' => $child->properties['cmis:name'],
      'state' => $child->properties['cmis:baseTypeId'] == 'cmis:folder' ? 'closed' : 'none',
      'attributes' => array(
        'id' => $child->properties['cmis:path'],
        'rel' => $child->properties['cmis:baseTypeId'] == 'cmis:folder' ? 'folder' : 'document',
      ),
    );
  }
  drupal_json($result);
}