You are here

function easychart_admin_presets in Easychart 7.3

Admin presets.

1 string reference to 'easychart_admin_presets'
easychart_menu in ./easychart.module

File

./easychart.admin.inc, line 174
Easychart admin pages.

Code

function easychart_admin_presets($form, $form_state) {
  if (!isset($form_state['storage']['confirm'])) {
    $form = array();
    libraries_load('highcharts');
    libraries_load('easychart');
    drupal_add_library('system', 'ui.sortable');
    drupal_add_js(drupal_get_path('module', 'easychart') . '/js/easychart.admin.js');
    drupal_add_css(drupal_get_path('module', 'easychart') . '/css/easychart.admin.css');
    $form['easychart_presets'] = array(
      '#type' => 'textarea',
      '#title' => t('Presets'),
      '#default_value' => variable_get('easychart_presets', ''),
      '#description' => t('Presets for every Easychart chart. If these preset are also mentioned in the available options, they will be shown, but not editable. <a href="@url" target="_blank">View an example</a>.', array(
        '@url' => 'https://github.com/bestuurszaken/easychart/tree/3.x#instancesetpresets',
      )),
      '#attributes' => array(
        'class' => array(
          'easychart-presets',
        ),
      ),
      '#rows' => 10,
    );

    // Add the reset button.
    $form['actions']['reset'] = array(
      '#type' => 'submit',
      '#value' => t('Reset to defaults'),
      '#submit' => array(
        'easychart_admin_presets_submit',
      ),
      '#limit_validation_errors' => array(),
      '#weight' => 100,
    );
  }
  else {
    return confirm_form($form, t('Are you sure you want to reset the presets to their default values?'), current_path());
  }
  return system_settings_form($form);
}