You are here

function views_pdf_plugin_style_table::options_submit in Views PDF 7.3

Same name and namespace in other branches
  1. 6 views_pdf_plugin_style_table.inc \views_pdf_plugin_style_table::options_submit()
  2. 7 views_pdf_plugin_style_table.inc \views_pdf_plugin_style_table::options_submit()
  3. 7.2 plugins/views_pdf_plugin_style_table.inc \views_pdf_plugin_style_table::options_submit()

Options form storage

Overrides views_plugin::options_submit

File

./views_pdf_plugin_style_table.inc, line 272
Table PDF style plugin

Class

views_pdf_plugin_style_table
Style plugin to render each item as a row in a table.

Code

function options_submit(&$form, &$form_state) {
  $default_font_style = $this->display->handler
    ->get_option('default_font_style');
  foreach ($form_state['values']['style_options']['info'] as $id => $field) {
    foreach (array(
      'header_style',
      'body_style',
    ) as $style) {

      // Reset to default, if the elements are equal to the default settings.
      if (count(array_diff($default_font_style, $field[$style]['text']['font_style'])) == 0 && count(array_diff($field[$style]['text']['font_style'], $default_font_style)) == 0) {
        $form_state['values']['style_options']['info'][$id][$style]['text']['font_style'] = NULL;
      }
      if ($field[$style]['text']['font_family'] == 'default') {
        $form_state['values']['style_options']['info'][$id][$style]['text']['font_family'] = NULL;
      }
      if ($field[$style]['text']['align'] == $this->display->handler
        ->get_option('default_text_align')) {
        $form_state['values']['style_options']['info'][$id][$style]['text']['align'] = NULL;
      }
      if ($field[$style]['text']['hyphenate'] == $this->display->handler
        ->get_option('default_text_hyphenate')) {
        $form_state['values']['style_options']['info'][$id][$style]['text']['hyphenate'] = NULL;
      }

      // Strip all empty values.
      $form_state['values']['style_options']['info'][$id][$style] = _array_filter_recursive($form_state['values']['style_options']['info'][$id][$style]);
    }
  }
}