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