function sweaverThemeSettings::buildStyleConfiguration in Sweaver 7
Same name and namespace in other branches
- 6 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 93 - 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 = Sweaver::get_instance();
$sweaver_style = $sweaver
->get_plugin('sweaver_plugin_styles');
// Rebuild configuration because themesettings isn't looaded in install.
$sweaver
->register_plugins_configuration();
$sweaver_ts = $sweaver
->get_plugin('sweaver_plugin_themesettings');
$form['#current_theme'] = 'bartik';
$form['sweaver_plugin_themesettings']['form'] = $sweaver_ts
->sweaver_get_theme_settings_form('bartik', 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.
'sweaver-css' => '{"#center ":{"font-size":' . $size . '}}',
'css-rendered' => '<style type="text/css">#center { font-size: ' . $size . 'px; } </style>',
'sweaver_plugin_custom_css' => '',
'save_style' => 'Bartik ' . $style_id,
'save_type' => $save_type,
// Theme settings.
'toggle_name' => FALSE,
'style_existing_id' => $save_type ? $style_id : 0,
'var' => 'theme_bartik_settings',
);
}
else {
$edit = array();
}
// Favicon.
if (!is_null($favicon)) {
if (!$upload) {
$edit['default_favicon'] = 0;
$edit['favicon_path'] = $this
->sweaver_public_path() . '/sweaver/favicon_bartik_' . $style_id . '_draft.ico';
}
else {
$source = drupal_get_path('module', 'sweaver') . '/tests/' . $favicon;
$parts = pathinfo($source);
$dest = 'public://sweaver/temp_favicon.' . $parts['extension'];
$return = file_unmanaged_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'] = $this
->sweaver_public_path() . '/sweaver/logo_bartik_' . $style_id . '_draft.' . $logo;
}
else {
$source = drupal_get_path('module', 'sweaver') . '/tests/' . $logo;
$parts = pathinfo($source);
$dest = 'public://sweaver/temp_logo.' . $parts['extension'];
$return = file_unmanaged_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;
}