You are here

function ctools_stylizer_edit_style_form_choose in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/stylizer.inc \ctools_stylizer_edit_style_form_choose()

Choose which plugin to use to create a new style.

2 string references to 'ctools_stylizer_edit_style_form_choose'
ctools_stylizer_edit_style in includes/stylizer.inc
Add a new style of the specified type.
stylizer.inc in stylizer/plugins/export_ui/stylizer.inc

File

includes/stylizer.inc, line 884
Create customized CSS and images from palettes created by user input.

Code

function ctools_stylizer_edit_style_form_choose($form, &$form_state) {
  $plugins = ctools_get_style_bases();
  $options = array();
  $categories = array();
  foreach ($plugins as $name => $plugin) {
    if ($form_state['module'] == $plugin['module'] && $form_state['type'] == $plugin['type']) {
      $categories[$plugin['category']] = $plugin['category'];
      $unsorted_options[$plugin['category']][$name] = ctools_stylizer_print_style_icon($plugin, TRUE);
    }
  }
  asort($categories);
  foreach ($categories as $category) {
    $options[$category] = $unsorted_options[$category];
  }
  $form['style_base'] = array(
    '#prefix' => '<div class="ctools-style-icons clearfix">',
    '#suffix' => '</div>',
  );
  ctools_include('cleanstring');
  foreach ($options as $category => $radios) {
    $cat = ctools_cleanstring($category);
    $form['style_base'][$cat] = array(
      '#prefix' => '<div class="ctools-style-category clearfix"><label>' . $category . '</label>',
      '#suffix' => '</div>',
    );
    foreach ($radios as $key => $choice) {

      // Generate the parents as the autogenerator does, so we will have a
      // unique id for each radio button.
      $form['style_base'][$cat][$key] = array(
        '#type' => 'radio',
        '#title' => $choice,
        '#parents' => array(
          'style_base',
        ),
        '#id' => drupal_clean_css_identifier('edit-style-base-' . $key),
        '#return_value' => check_plain($key),
      );
    }
  }
  return $form;
}