You are here

function views_plugin_style_json::option_definition in Views Datasource 7

Same name and namespace in other branches
  1. 6 views_plugin_style_json.inc \views_plugin_style_json::option_definition()

Implements views_plugin_style::option_definition

Overrides views_plugin_style::option_definition

File

views/plugins/views_plugin_style_json.inc, line 14
Implements views_plugin_style for views_json

Class

views_plugin_style_json
Implements views_plugin_style

Code

function option_definition() {
  $options = parent::option_definition();
  $options['root_object'] = array(
    'default' => 'nodes',
    'translatable' => FALSE,
  );
  $options['top_child_object'] = array(
    'default' => 'node',
    'translatable' => FALSE,
  );
  $options['field_output'] = array(
    'default' => 'normal',
    'translatable' => FALSE,
  );
  $options['plaintext_output'] = array(
    'default' => TRUE,
    'translatable' => FALSE,
  );
  $options['remove_newlines'] = array(
    'default' => NULL,
    'translatable' => FALSE,
  );
  $options['format'] = array(
    'default' => 'simple',
    'translatable' => FALSE,
  );
  $options['jsonp_prefix'] = array(
    'default' => NULL,
    'translatable' => FALSE,
  );
  $options['content_type'] = array(
    'default' => 'default',
    'translatable' => FALSE,
  );
  $options['using_views_api_mode'] = array(
    'default' => FALSE,
    'translatable' => FALSE,
  );
  $options['translate_labels'] = array(
    'default' => FALSE,
    'translatable' => FALSE,
  );

  // Encoding options, to be used by json_encode().
  $options['encoding'] = array(
    'contains' => array(
      'object_arrays' => array(
        'default' => NULL,
        'translatable' => FALSE,
        'bitmask' => 'JSON_FORCE_OBJECT',
      ),
      'numeric_strings' => array(
        'default' => NULL,
        'translatable' => FALSE,
        'bitmask' => 'JSON_NUMERIC_CHECK',
      ),
      'bigint_string' => array(
        'default' => NULL,
        'translatable' => FALSE,
        'bitmask' => 'JSON_BIGINT_AS_STRING',
      ),
      'pretty_print' => array(
        'default' => NULL,
        'translatable' => FALSE,
        'bitmask' => 'JSON_PRETTY_PRINT',
      ),
      'unescaped_slashes' => array(
        'default' => NULL,
        'translatable' => FALSE,
        'bitmask' => 'JSON_UNESCAPED_SLASHES',
      ),
      'unescaped_unicode' => array(
        'default' => NULL,
        'translatable' => FALSE,
        'bitmask' => 'JSON_UNESCAPED_UNICODE',
      ),
      'char_encoding' => array(
        'default' => NULL,
        'translatable' => FALSE,
        'bitmasks' => array(
          'JSON_HEX_TAG' => 'JSON_HEX_TAG',
          'JSON_HEX_APOS' => 'JSON_HEX_APOS',
          'JSON_HEX_QUOT' => 'JSON_HEX_QUOT',
          'JSON_HEX_AMP' => 'JSON_HEX_AMP',
        ),
      ),
    ),
  );

  // Provide Views a flatted copy of 'encoding' in a format it knows how to save and retrieve user data to.
  foreach ($options['encoding']['contains'] as $key => $encoding_option) {
    $options[$key] = $encoding_option;
  }
  return $options;
}