providers
1 year ago
complex-control.class.php
1 year ago
control-holder.class.php
1 year ago
control.class.php
1 year ago
custom-element.class.php
1 year ago
form-element.class.php
1 year ago
form-layout.class.php
1 year ago
form.class.php
1 year ago
holder.class.php
1 year ago
html-builder.class.php
1 year ago
index.php
3 years ago
form-layout.class.php
123 lines
| 1 | <?php |
| 2 | /** |
| 3 | * The file contains the base class for all form layouts. |
| 4 | * |
| 5 | * @author Alex Kovalev <alex.kovalevv@gmail.com> |
| 6 | * @copyright (c) 2018, Webcraftic Ltd |
| 7 | * |
| 8 | * @package factory-forms |
| 9 | * @since 1.0.0 |
| 10 | */ |
| 11 | |
| 12 | // Exit if accessed directly |
| 13 | if( !defined('ABSPATH') ) { |
| 14 | exit; |
| 15 | } |
| 16 | |
| 17 | if( !class_exists('Wbcr_FactoryForms480_FormLayout') ) { |
| 18 | |
| 19 | /** |
| 20 | * The base class for all form layouts. |
| 21 | */ |
| 22 | abstract class Wbcr_FactoryForms480_FormLayout extends Wbcr_FactoryForms480_Holder { |
| 23 | |
| 24 | /** |
| 25 | * A form layout name. |
| 26 | * |
| 27 | * @since 1.0.0 |
| 28 | * @var string |
| 29 | */ |
| 30 | protected $name = 'default'; |
| 31 | |
| 32 | /** |
| 33 | * A holder type. |
| 34 | * |
| 35 | * @since 1.0.0 |
| 36 | * @var string |
| 37 | */ |
| 38 | protected $type = 'form-layout'; |
| 39 | |
| 40 | /** |
| 41 | * Creates a new instance of a form layout. |
| 42 | * |
| 43 | * @since 1.0.0 |
| 44 | * @param mixed[] $options A holder options. |
| 45 | * @param Wbcr_FactoryForms480_Form $form A parent form. |
| 46 | */ |
| 47 | public function __construct($options, $form) |
| 48 | { |
| 49 | |
| 50 | $options['name'] = $this->name; |
| 51 | $options['items'] = $form->getItems(); |
| 52 | |
| 53 | parent::__construct($options, $form); |
| 54 | |
| 55 | $this->addCssClass('factory-forms-480-' . $this->type); |
| 56 | $this->addCssClass('factory-forms-480-' . $this->name); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Renders a beginning of a form. |
| 61 | * |
| 62 | * @since 1.0.0 |
| 63 | * @return void |
| 64 | */ |
| 65 | public function beforeRendering() |
| 66 | { |
| 67 | echo '<div '; |
| 68 | $this->attrs(); |
| 69 | echo '>'; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Renders the end of a form. |
| 74 | * |
| 75 | * @since 1.0.0 |
| 76 | * @return void |
| 77 | */ |
| 78 | public function afterRendering() |
| 79 | { |
| 80 | echo '</div>'; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Rendering some html before a holder. |
| 85 | * |
| 86 | * @since 1.0.0 |
| 87 | * @return void |
| 88 | */ |
| 89 | public function beforeHolder($element) |
| 90 | { |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Rendering some html after a holder. |
| 95 | * |
| 96 | * @since 1.0.0 |
| 97 | * @return void |
| 98 | */ |
| 99 | public function afterHolder($element) |
| 100 | { |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Rendering some html before a contol. |
| 105 | * |
| 106 | * @since 1.0.0 |
| 107 | * @return void |
| 108 | */ |
| 109 | public function beforeControl($element) |
| 110 | { |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Rendering some html after a contol. |
| 115 | * |
| 116 | * @since 1.0.0 |
| 117 | * @return void |
| 118 | */ |
| 119 | public function afterControl($element) |
| 120 | { |
| 121 | } |
| 122 | } |
| 123 | } |