function cmis_browser_autocomplete in CMIS API 7
Same name and namespace in other branches
- 6.4 cmis_browser/cmis_browser.content_autocomplete.inc \cmis_browser_autocomplete()
- 6.2 cmis_browser/cmis_browser.content_autocomplete.inc \cmis_browser_autocomplete()
- 6.3 cmis_browser/cmis_browser.content_autocomplete.inc \cmis_browser_autocomplete()
- 7.2 cmis_browser/cmis_browser.content_autocomplete.inc \cmis_browser_autocomplete()
Cmis folder picker autocomplete callback.
1 string reference to 'cmis_browser_autocomplete'
- cmis_browser_menu in cmis_browser/
cmis_browser.module - Implementation of hook_menu().
File
- cmis_browser/
cmis_browser.content_autocomplete.inc, line 7
Code
function cmis_browser_autocomplete() {
module_load_include('api.inc', 'cmis');
$args = func_get_args();
$path = '/' . implode('/', array_slice($args, 0, sizeof($args) - 1));
$key = end($args);
$matches = array();
try {
$repository = cmis_get_repository();
$folder_object = cmisapi_getObjectByPath($repository->repositoryId, drupal_encode_path($path));
$matches = array();
foreach (array(
'cmis:folder',
'cmis:document',
) as $cmis_base_type) {
try {
$cmis_objects = cmisapi_query($repository->repositoryId, sprintf('SELECT * FROM %s WHERE cmis:name like \'%s\' AND IN_FOLDER(\'%s\')', $cmis_base_type, '%' . $key . '%', $folder_object->id));
} catch (CMISException $e) {
cmis_error_handler('cmis_path_autocomplete', $e);
continue;
}
foreach ($cmis_objects->objectList as $cmis_object) {
$matched_base_object = $cmis_base_type == 'cmis:folder' ? $cmis_object : $folder_object;
$matches[$matched_base_object->properties['cmis:path'] . '/'] = $cmis_object->properties['cmis:name'];
}
}
} catch (CMISException $e) {
cmis_error_handler('cmis_path_autocomplete', $e);
}
//print_r($matches);
drupal_json_output($matches);
}