You are here

function sweaverThemeSettings::buildStyleConfiguration in Sweaver 6

Same name and namespace in other branches
  1. 7 tests/sweaver.themesettings.test \sweaverThemeSettings::buildStyleConfiguration()

Build form, form_state values and copy files when necessary.

Parameters

$scenario: The id of the scenario.

$size: The size of the pixels.

$style_id: The id of the style.

$upload: Whether we need to upload or not.

$logo: The logo to upload.

$favicon: The favicon to upload.

$debug: Whether to write debug info or not.

4 calls to sweaverThemeSettings::buildStyleConfiguration()
sweaverThemeSettings::testScenarioA in tests/sweaver.themesettings.test
Scenario A.
sweaverThemeSettings::testScenarioB in tests/sweaver.themesettings.test
Scenario B.
sweaverThemeSettings::testScenarioC in tests/sweaver.themesettings.test
Scenario C.
sweaverThemeSettings::testScenarioD in tests/sweaver.themesettings.test
Scenario D.

File

tests/sweaver.themesettings.test, line 88
Advanced tests for sweaver editor + theme settings.

Class

sweaverThemeSettings
@file Advanced tests for sweaver editor + theme settings.

Code

function buildStyleConfiguration($scenario, $size = FALSE, $style_id = '', $upload = TRUE, $logo = NULL, $favicon = NULL, $save_type = 0, $debug = FALSE) {
  $form = array();
  $values = array();
  $this
    ->enableSweaverData();
  $sweaver_style = Sweaver::get_instance()
    ->get_plugin('sweaver_plugin_styles');
  $sweaver_ts = Sweaver::get_instance()
    ->get_plugin('sweaver_plugin_themesettings');
  $form['#current_theme'] = 'garland';
  $form['sweaver_plugin_themesettings']['form'] = $sweaver_ts
    ->sweaver_get_theme_settings_form('garland', array());
  $form['sweaver_plugin_themesettings']['form']['#sweaver_other_themesettings'] = array();
  $form['sweaver_plugin_styles']['form'] = $sweaver_style
    ->sweaver_form();

  // Submit values.
  if ($size) {
    $edit = array(
      // Style editor.
      'css' => '{"#center ":{"font-size":' . $size . '}}',
      'css_rendered' => '<style type="text/css">#center { font-size: ' . $size . 'px; } </style>',
      'sweaver_plugin_custom_css' => '',
      'save_style' => 'Garland ' . $style_id,
      'save_type' => $save_type,
      // Theme settings.
      'toggle_name' => FALSE,
      'style_existing_id' => $save_type ? $style_id : 0,
      'var' => 'theme_garland_settings',
    );
  }
  else {
    $edit = array();
  }

  // Favicon.
  if (!is_null($favicon)) {
    if (!$upload) {
      $edit['default_favicon'] = 0;
      $edit['favicon_path'] = file_directory_path() . '/sweaver/favicon_garland_' . $style_id . '_draft.ico';
    }
    else {
      $source = drupal_get_path('module', 'sweaver') . '/tests/' . $favicon;
      $parts = pathinfo($source);
      $dest = 'sweaver/temp_favicon.' . $parts['extension'];
      $return = file_copy($source, $dest, FILE_EXISTS_REPLACE);
      $this
        ->assertTrue($return, 'Favicon file copied to ' . $dest . ' for style id ' . $style_id . ' in scenario ' . $scenario);
      $form['sweaver_plugin_themesettings']['form']['#favicon_path'] = $dest;
      $form['sweaver_plugin_themesettings']['form']['#favicon_path_extension'] = $parts['extension'];
      $edit['default_favicon'] = 0;
      $edit['favicon_path'] = $dest;
    }
  }

  // Logo.
  if (!is_null($logo)) {
    if (!$upload) {
      $edit['default_logo'] = 0;
      $edit['logo_path'] = file_directory_path() . '/sweaver/logo_garland_' . $style_id . '_draft.' . $logo;
    }
    else {
      $source = drupal_get_path('module', 'sweaver') . '/tests/' . $logo;
      $parts = pathinfo($source);
      $dest = 'sweaver/temp_logo.' . $parts['extension'];
      $return = file_copy($source, $dest, FILE_EXISTS_REPLACE);
      $this
        ->assertTrue($return, 'Favicon file copied to ' . $dest . ' for style id ' . $style_id . ' in scenario ' . $scenario);
      $form['sweaver_plugin_themesettings']['form']['#logo_path'] = $dest;
      $form['sweaver_plugin_themesettings']['form']['#logo_path_extension'] = $parts['extension'];
      $edit['default_logo'] = 0;
      $edit['logo_path'] = $dest;
    }
  }
  if ($debug) {
    $this
      ->sweaver_filesdir_scan();
  }
  $values['form'] = $form;
  $values['edit'] = $edit;
  return $values;
}