public function sweaver_plugin_editor::sweaver_form in Sweaver 7
Same name and namespace in other branches
- 6 plugins/sweaver_plugin_editor/sweaver_plugin_editor.inc \sweaver_plugin_editor::sweaver_form()
Frontend form.
Overrides sweaver_plugin::sweaver_form
File
- plugins/
sweaver_plugin_editor/ sweaver_plugin_editor.inc, line 184 - Properties editor class.
Class
- sweaver_plugin_editor
- @file Properties editor class.
Code
public function sweaver_form() {
$form = array();
$form['#editor_containers'] = array();
$current_style = Sweaver::get_instance()
->get_current_style();
$form['sweaver-css'] = array(
'#type' => 'hidden',
'#default_value' => isset($current_style->css) ? $current_style->css : '',
);
$form['css-rendered'] = array(
'#type' => 'hidden',
'#default_value' => '',
);
$properties = sweaver_object_load(NULL, 'property');
$sweaver_editor_form_configuration = variable_get('sweaver_editor_form_configuration', array());
// Images.
$images = array(
'' => t('Theme default'),
'none' => t('No image'),
);
$image_handler_plugin = variable_get('sweaver_plugin_handle_images', '');
if (!empty($image_handler_plugin)) {
$image_handler = Sweaver::get_instance()
->get_plugin($image_handler_plugin);
if (is_object($image_handler) && method_exists($image_handler, 'sweaver_images_handler')) {
$image_handler
->sweaver_images_handler($images);
}
}
// Container and properties.
foreach ($sweaver_editor_form_configuration as $container => $settings) {
if (!empty($settings['properties'])) {
// Container title.
$form['#editor_containers'][$container]['title'] = check_plain($settings['title']);
foreach ($settings['properties'] as $weight => $property_key) {
$form['#editor_containers'][$container]['properties'][$property_key] = $property_key;
// Create property element, continue if it doesn't exist.
if (!isset($properties[$property_key])) {
continue;
}
$property = $properties[$property_key];
sweaver_export_check_serialized_keys($property);
$form[$property->name] = $this
->sweaver_property_element($property, $images);
// Any children?
if ($property->property_type == 'parent') {
foreach ($properties as $key => $prop) {
if ($prop->property_parent == $property->name && !$prop->disabled) {
$form[$property->name][$prop->name] = $this
->sweaver_property_element($prop, $images);
}
}
}
}
}
}
return $form;
}