function drupalgap_preprocess_views_views_json_style_simple in DrupalGap 7
Implements hook_preprocess_views_views_json_style_simple().
File
- ./
drupalgap.module, line 283 - A module to provide a bridge between Drupal websites and PhoneGap mobile applications.
Code
function drupalgap_preprocess_views_views_json_style_simple(&$vars) {
// Place various view object properties and pager data onto the results.
global $pager_total, $pager_page_array, $pager_total_items, $pager_limits;
$view = array(
'name' => $vars['view']->name,
'display' => $vars['view']->current_display,
'path' => implode('/', arg()),
'root' => $vars['options']['root_object'],
'child' => $vars['options']['top_child_object'],
'pages' => $pager_total[0],
'page' => $pager_page_array[0],
'count' => intval($pager_total_items[0]),
'limit' => intval($pager_limits[0]),
);
// If there were no pages, adjust the property values accordingly.
if ($view['pages'] == null) {
$view['count'] = sizeof($vars['rows'][$view['root']]);
$view['limit'] = null;
}
// If there are any exposed filters, attach them to the view object.
if (isset($vars['view']->exposed_data)) {
$view['exposed_data'] = $vars['view']->exposed_data;
$view['exposed_raw_input'] = $vars['view']->exposed_raw_input;
$view['filter'] = array();
foreach ($vars['view']->filter as $field => $filter) {
if ($filter->options['exposed']) {
// The site builder didn't select any available options for this
// exposed filter, but that's OK, they probably want all options
// available.
$value_options = isset($filter->value_options) ? $filter->value_options : NULL;
// The entire field is huge in size and complexity, so let's trim it
// down to the bare necessities.
// @TODO - as the Views Exposed Filters feature evolves, revisit this
// from time to time to see if we need to drop anything else. Anything
// to help slim the amount of JSON is a good thing.
$view['filter'][$field] = array(
//'accept_null' => $filter->accept_null,
//'always_multiple' => $filter->always_multiple,
//'always_required' => $filter->always_required,
'definition' => $filter->definition,
//'field' => $filter->field,
//'group_info' => $filter->group_info,
//'localization_keys' => $filter->localization_keys,
//'no_operator' => $filter->no_operator,
//'operator' => $filter->operator,
'options' => $filter->options,
//'position' => $filter->position,
//'real_field' => $filter->real_field,
//'relationship' => $filter->relationship,
'value' => $filter->value,
'value_options' => $value_options,
);
}
}
}
// Attach the view data to the rows result.
$vars['rows']['view'] = $view;
}