You are here

class views_data_export_plugin_style_export_xml in Views data export 6.2

Same name and namespace in other branches
  1. 6.3 plugins/views_data_export_plugin_style_export_xml.inc \views_data_export_plugin_style_export_xml
  2. 6 plugins/views_data_export_plugin_style_export_xml.inc \views_data_export_plugin_style_export_xml
  3. 7 plugins/views_data_export_plugin_style_export_xml.inc \views_data_export_plugin_style_export_xml
  4. 7.3 plugins/views_data_export_plugin_style_export_xml.inc \views_data_export_plugin_style_export_xml

Generalized style plugin for export plugins.

Hierarchy

Expanded class hierarchy of views_data_export_plugin_style_export_xml

1 string reference to 'views_data_export_plugin_style_export_xml'
views_data_export_views_plugins in ./views_data_export.views.inc
Implementation of hook_views_plugins().

File

plugins/views_data_export_plugin_style_export_xml.inc, line 12
Plugin include file for export style plugin.

View source
class views_data_export_plugin_style_export_xml extends views_data_export_plugin_style_export {

  /**
   * Initialize a style plugin.
   */
  function init(&$view, &$display, $options = NULL) {

    // View is not set in option_definition(), so we fill defaults here if
    // options are empty.
    if (empty($options['root_node']) || empty($options['item_node'])) {
      $base_object_name = rtrim($view->base_table, 's');
      if (empty($options['root_node'])) {
        $options['root_node'] = $base_object_name . 's';
      }
      if (empty($options['item_node'])) {
        $options['item_node'] = $base_object_name;
      }
    }
    parent::init($view, $display, $options);
  }

  /**
   * Set options fields and default values.
   *
   * @return
   * An array of options information.
   */
  function option_definition() {
    $options = parent::option_definition();
    $options['transform'] = array(
      'default' => TRUE,
      'translatable' => FALSE,
    );
    $options['transform_type'] = array(
      'default' => 'dash',
      'translatable' => FALSE,
    );
    $options['root_node'] = array(
      'default' => '',
      'translatable' => FALSE,
    );
    $options['item_node'] = array(
      'default' => '',
      'translatable' => FALSE,
    );
    $options['cdata_wrapper'] = array(
      'default' => array(),
      'translatable' => FALSE,
    );
    return $options;
  }

  /**
   * Options form mini callback.
   *
   * @param $form
   * Form array to add additional fields to.
   * @param $form_state
   * State of the form.
   * @return
   * None.
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['transform'] = array(
      '#type' => 'checkbox',
      '#title' => t('Transform spaces'),
      '#default_value' => $this->options['transform'],
      '#description' => t('Transform spaces to valid XML in field labels (spaces create invalid XML markup). Note that invalid XML tag characters will always be converted.'),
    );
    $form['transform_type'] = array(
      '#type' => 'select',
      '#title' => t('Transform type'),
      '#default_value' => $this->options['transform_type'],
      '#options' => array(
        'dash' => t('Dash'),
        'underline' => t('Underline'),
        'camel' => t('camelCase'),
        'pascal' => t('PascalCase'),
      ),
      '#process' => array(
        'views_process_dependency',
      ),
      '#dependency' => array(
        'edit-style-options-transform' => array(
          TRUE,
        ),
      ),
    );
    $form['root_node'] = array(
      '#type' => 'textfield',
      '#title' => t('Root node'),
      '#default_value' => $this->options['root_node'],
      '#description' => t('The XML tag for the root node.'),
    );
    $form['item_node'] = array(
      '#type' => 'textfield',
      '#title' => t('Item node'),
      '#default_value' => $this->options['item_node'],
      '#description' => t('The XML tag for an item node.'),
    );
    $field_labels = $this->display->handler
      ->get_field_labels();
    if (!empty($field_labels)) {
      $options = $field_labels;
      if (empty($this->options['cdata_wrapper'])) {
        $this->options['cdata_wrapper'] = array();
      }
      $form['cdata_wrapper'] = array(
        '#type' => 'checkboxes',
        '#title' => t('Fields value to wrapped using CDATA'),
        '#options' => $options,
        '#default_value' => $this->options['cdata_wrapper'],
        '#description' => t('If checked the fields content will be wrapped using the CDATA tag.'),
      );
    }
  }

  /**
   * Perform any necessary changes to the form values prior to storage.
   * There is no need for this function to actually store the data.
   *
   * @param $form
   * @param $form_state
   */
  function options_submit(&$form, &$form_state) {
    if (isset($form_state['values']['style_options']['cdata_wrapper'])) {

      // Remove any options values set to 0
      $form_state['values']['style_options']['cdata_wrapper'] = array_filter($form_state['values']['style_options']['cdata_wrapper']);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
views_data_export_plugin_style_export::add_http_headers function Add any HTTP headers that this style plugin wants to.
views_data_export_plugin_style_export::attach_to function Attach this view to another display as a feed.
views_data_export_plugin_style_export::build_sort function
views_data_export_plugin_style_export::build_sort_post function
views_data_export_plugin_style_export::render function Render the display in this style.
views_data_export_plugin_style_export::render_body function
views_data_export_plugin_style_export::render_footer function
views_data_export_plugin_style_export::render_header function
views_data_export_plugin_style_export::theme_functions function Provide a full list of possible theme templates used by this style.
views_data_export_plugin_style_export_xml::init function Initialize a style plugin.
views_data_export_plugin_style_export_xml::options_form function Options form mini callback. Overrides views_data_export_plugin_style_export::options_form
views_data_export_plugin_style_export_xml::options_submit function Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data.
views_data_export_plugin_style_export_xml::option_definition function Set options fields and default values. Overrides views_data_export_plugin_style_export::option_definition