function drupalgap_system_connect_extras in DrupalGap 7
2 calls to drupalgap_system_connect_extras()
- drupalgap_services_request_postprocess_alter in ./
drupalgap.module - Implements hook_services_request_postprocess_alter().
- _drupalgap_resource_system_connect in ./
drupalgap.resource.inc - Performs service calls to various resources and bundles them all up so the mobile device gets results, settings and permissions in one request.
File
- ./
drupalgap.module, line 220 - A module to provide a bridge between Drupal websites and PhoneGap mobile applications.
Code
function drupalgap_system_connect_extras($system_connect_call = true) {
global $user;
$results = array();
if ($system_connect_call) {
// Make a call to the system connect resource.
module_load_include('inc', 'services', 'resources/system_resource');
$results['system_connect'] = _system_resource_connect();
}
// Grab the ip address.
$results['remote_addr'] = $_SERVER['REMOTE_ADDR'];
// Grab the date formats and types.
$results['date_formats'] = system_get_date_formats();
$results['date_types'] = system_get_date_types();
// For each date type, look in the variable table to find its format. Not all
// types will have a format.
foreach ($results['date_types'] as $name => $type) {
$value = variable_get('date_format_' . $name, false);
if ($value) {
$results['date_types'][$name]['format'] = $value;
}
}
// Make calls to various DrupalGap resources.
$results['site_settings'] = _drupalgap_resource_system_site_settings();
$results['user_permissions'] = _drupalgap_resource_user_permissions(array(
'uid' => $user->uid,
));
$results['content_types_list'] = _drupalgap_resource_content_types_list();
$results['content_types_user_permissions'] = _drupalgap_resource_content_types_user_permissions();
$results['entity_info'] = entity_get_info();
$results['field_info_instances']['node'] = field_info_instances('node');
$results['field_info_instances']['comment'] = field_info_instances('comment');
$results['field_info_instances']['taxonomy_vocabulary'] = field_info_instances('taxonomy_vocabulary');
$results['field_info_instances']['taxonomy_term'] = field_info_instances('taxonomy_term');
$results['field_info_instances']['user'] = field_info_instances('user');
$results['field_info_fields'] = field_info_fields();
$results['field_info_extra_fields'] = array();
foreach ($results['content_types_list'] as $content_type) {
$results['field_info_extra_fields'][$content_type->type] = field_info_extra_fields('node', $content_type->type, 'form');
}
$results['taxonomy_vocabularies'] = _drupalgap_taxonomy_get_vocabularies();
// For any image fields with a default image, include the file uri.
$image_fields = field_read_fields(array(
'type' => 'image',
));
foreach ($image_fields as $field_name => $field) {
if (!$results['field_info_fields'][$field_name]['settings']['default_image']) {
continue;
}
$fid = $results['field_info_fields'][$field_name]['settings']['default_image'];
if (!($file = file_load($fid))) {
continue;
}
$results['field_info_fields'][$field_name]['settings']['default_image_uri'] = $file->uri;
}
// Finally return the results.
return $results;
}