You are here

public function sweaver_plugin_themeswitch::sweaver_form in Sweaver 6

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

Frontend form.

Overrides sweaver_plugin::sweaver_form

File

plugins/sweaver_plugin_themeswitch/sweaver_plugin_themeswitch.inc, line 39
Themeswitch plugin.

Class

sweaver_plugin_themeswitch
@file Themeswitch plugin.

Code

public function sweaver_form() {
  $form = array();
  $content = '';
  $no_image = drupal_get_path('module', 'sweaver') . '/plugins/sweaver_plugin_themeswitch/no_screenshot.png';
  $theme_key = Sweaver::get_instance()
    ->get_theme_key();
  $number_of_themes = 0;
  $themes = sweaver_get_all_themes();
  foreach ($themes as $theme) {
    if (isset($theme->info['screenshot']) && file_exists($theme->info['screenshot'])) {
      $image_file = $theme->info['screenshot'];
    }
    else {
      $image_file = $no_image;
    }
    if ($theme_key != $theme->name) {
      $switch_description = t('Switch to @theme', array(
        '@theme' => $theme->info['name'],
      ));
      $image = sweaver_theme_image($image_file, $switch_description, $switch_description, array(
        'width' => '150',
        'height' => '90',
      ), FALSE);
      $image = l($image, 'sweaver_themeswitch/' . $theme->name, array(
        'alias' => TRUE,
        'html' => TRUE,
        'query' => drupal_get_destination(),
      ));
      $content .= '<div class="selected-image">' . $image;
    }
    else {
      $switch_description = t('This theme is currently selected');
      $image = sweaver_theme_image($image_file, $switch_description, $switch_description, array(
        'width' => '150',
        'height' => '90',
      ), FALSE);
      $content .= '<div class="selected-image selected-image-default">' . $image;
    }
    $number_of_themes++;
    $content .= '<br />' . check_plain($theme->info['name']);
    $content .= '</div>';
  }
  $form['markup'] = array(
    '#type' => 'markup',
    '#value' => '<div id="themeswitch-pane"><div id="themeswitch-content">' . $content . '</div><div class="scroll-bar-wrap"><div class="scroll-bar"></div></div></div>',
  );
  return $form;
}