You are here

public function sweaver_plugin_themeclasses::sweaver_form in Sweaver 7

Same name and namespace in other branches
  1. 6 plugins/sweaver_plugin_themeclasses/sweaver_plugin_themeclasses.inc \sweaver_plugin_themeclasses::sweaver_form()

Frontend form.

Overrides sweaver_plugin::sweaver_form

File

plugins/sweaver_plugin_themeclasses/sweaver_plugin_themeclasses.inc, line 32
Theme classes plugin.

Class

sweaver_plugin_themeclasses

Code

public function sweaver_form() {
  $form = array();
  $class_groups = trim(variable_get('sweaver_themeclasses_groups', SWEAVER_PLUGIN_THEMECLASSES_DEFAULT));
  if (empty($class_groups)) {
    return $form;
  }
  $theme_key = Sweaver::get_instance()
    ->get_theme_key();
  $theme_info = sweaver_get_theme_info($theme_key);
  if (empty($theme_info)) {
    return $form;
  }

  /*$cache = variable_get('sweaver_plugin_themeclasses_' . $theme_key, array());
    if (!empty($cache)) {
    $styles = $cache['styles'];
    }
    else {*/
  $styles = array();
  $groups = explode("\n", $class_groups);
  foreach ($groups as $group) {
    $group = trim($group);
    if (isset($theme_info[$group])) {
      $this
        ->sweaver_get_styles($theme_info[$group], $styles);
    }
  }

  // Cache the stuff.

  //variable_set('sweaver_plugin_themeclasses_'. $theme_key, array('checked' => TRUE, 'styles' => $styles));

  //}
  if (!empty($styles)) {
    $content = t('<h2>Styles</h2>!styles', array(
      '!styles' => implode(' ', $styles),
    ));
  }
  else {
    $content = t('<p>No styles found.</p>');
  }
  $form['sweaver_plugin_themeclasses'] = array(
    '#markup' => $content,
  );
  return $form;
}