private function sweaver_plugin_editor::sweaver_property_element in Sweaver 7
Same name and namespace in other branches
- 6 plugins/sweaver_plugin_editor/sweaver_plugin_editor.inc \sweaver_plugin_editor::sweaver_property_element()
Create a form element for a property.
Parameters
$property: The property.
$images: A collection of images to use for the image type.
1 call to sweaver_plugin_editor::sweaver_property_element()
- sweaver_plugin_editor::sweaver_form in plugins/
sweaver_plugin_editor/ sweaver_plugin_editor.inc - Frontend form.
File
- plugins/
sweaver_plugin_editor/ sweaver_plugin_editor.inc, line 529 - Properties editor class.
Class
- sweaver_plugin_editor
- @file Properties editor class.
Code
private function sweaver_property_element($property, $images) {
switch ($property->property_type) {
case 'slider':
return array(
'#type' => 'textfield',
'#title' => $property->description,
'#attributes' => array(
'class' => array(
'slider-value',
),
'title' => $property->description,
'autocomplete' => 'off',
),
'#prefix' => isset($property->css_prefix) ? $property->css_prefix : '',
'#suffix' => isset($property->css_suffix) ? $property->css_suffix : '',
);
break;
case 'button':
$click = isset($property->property_options['click']) ? $property->property_options['click'] : '';
drupal_add_js("(function(\$) {\n \$(document).ready(function() {\n \$('#edit-" . $property->name . "').click(function(event) {\n event.preventDefault();\n " . $click . "\n });\n });\n\n })(jQuery);", "inline");
return array(
'#type' => 'button',
'#value' => $property->description,
);
// New Type of Field implemented to improve the interface
case 'checkbox':
return array(
'#markup' => '<div id="button-checkbox-' . $property->name . '" class="editor_icons form-item-' . $property->name . '" title="' . $property->description . '"></div>',
);
break;
case 'color':
return array(
'#markup' => '<div id="edit-' . $property->name . '-wrapper" class="form-item clearfix">
<label class="color">' . $property->description . ':</label>
<div id="' . $property->name . '" class="colorSelector-wrapper">
<div class="colorSelector"><div style="background-color: #ffffff"></div>
</div></div></div>',
);
break;
case 'image':
$sweaver = Sweaver::get_instance();
if ($sweaver
->is_plugin_activated('sweaver_plugin_images')) {
return array(
'#type' => 'select',
'#title' => $property->description,
'#options' => $images,
'#attributes' => array(
'class' => array(
'background-image',
),
),
);
}
else {
return array(
'#type' => 'managed_file',
'#title' => $property->description,
'#size' => '40',
'#upload_location' => 'public://sweaver/',
'#upload_validators' => array(
'file_validate_is_image' => array(),
'file_validate_extensions' => array(
'png gif jpg jpeg',
),
),
);
}
break;
case 'select':
return array(
'#type' => 'select',
'#title' => $property->description,
'#options' => $property->property_options,
'#prefix' => isset($property->css_prefix) ? $property->css_prefix : '',
'#suffix' => isset($property->css_suffix) ? $property->css_suffix : '',
);
break;
case 'parent':
if (empty($property->property_options)) {
return array(
'#type' => 'markup',
'#prefix' => '<div class="sweaver-group clearfix"><label>' . $property->description . ':</label><div class="sweaver-group-content">',
'#suffix' => '</div></div>',
);
}
else {
return array(
'#theme' => 'table',
) + $property->property_options;
}
break;
// New Type of Field implemented to improve the interface
case 'radio':
$return_markup = '';
foreach ($property->property_options as $key => $value) {
$return_markup .= '<div id="button-radio-' . $property->name . '-' . $key . '" name="' . $property->name . '" class="editor_icons form-item-' . $property->name . '" title="' . $property->description . ' : ' . $value . '"></div>';
}
return array(
'#markup' => $return_markup,
'#prefix' => '<div class="sweaver-group clearfix"><label>' . $property->description . ':</label><div class="sweaver-group-content">',
'#suffix' => '</div></div>',
);
break;
}
}