1: <?php
2:
3: 4: 5:
6: class Quform_Element_Column extends Quform_Element_Container
7: {
8: 9: 10: 11: 12: 13:
14: public function render(array $context = array())
15: {
16: $context = $this->prepareContext($context);
17:
18: $output = sprintf('<div class="%s">', Quform::escape(Quform::sanitizeClass($this->getContainerClasses())));
19:
20: foreach ($this->elements as $key => $element) {
21: $output .= $element->render($context);
22: }
23:
24: $output .= '</div>';
25:
26: return $output;
27: }
28:
29: 30: 31: 32: 33:
34: protected function getContainerClasses()
35: {
36: $classes = array(
37: 'quform-element',
38: 'quform-element-column',
39: sprintf('quform-element-%s', $this->getIdentifier())
40: );
41:
42: $classes = apply_filters('quform_container_classes', $classes, $this);
43: $classes = apply_filters('quform_container_classes_' . $this->getIdentifier(), $classes, $this);
44:
45: return $classes;
46: }
47:
48: 49: 50: 51: 52: 53:
54: protected function renderCss(array $context = array())
55: {
56: $css = '';
57:
58: if (Quform::isNonEmptyString($this->config('width'))) {
59: $css .= sprintf('.quform-element-row > .quform-element-column.quform-element-%s { width:%s%%;%s }',
60: $this->getIdentifier(),
61: $this->config('width'),
62: Quform::get($context, 'columnSize') == 'float' ? 'max-width: 100%;' : ''
63: );
64: }
65:
66: $css .= parent::renderCss($context);
67:
68: return $css;
69: }
70:
71: 72: 73: 74: 75: 76:
77: public static function getDefaultConfig($key = null)
78: {
79: $config = apply_filters('quform_default_config_column', array(
80:
81: 'width' => '',
82:
83:
84: 'elements' => array()
85: ));
86:
87: $config['type'] = 'column';
88:
89: if (Quform::isNonEmptyString($key)) {
90: return Quform::get($config, $key);
91: }
92:
93: return $config;
94: }
95: }
96: