PluginProbe ʕ •ᴥ•ʔ
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / trunk
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF vtrunk
2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4
robin-image-optimizer / libs / factory / forms / controls / holders / columns.php
robin-image-optimizer / libs / factory / forms / controls / holders Last commit date
accordion-item.php 5 months ago accordion.php 5 months ago columns.php 5 months ago control-group-item.php 5 months ago control-group.php 5 months ago div.php 5 months ago form-group.php 5 months ago index.php 6 months ago more-link.php 5 months ago tab-item.php 5 months ago tab.php 5 months ago
columns.php
95 lines
1 <?php
2 /**
3 * The file contains the class of Columns Holder.
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_ColumnsHolder' ) ) {
15 /**
16 * Columns Holder
17 *
18 * @since 1.0.0
19 */
20 class Wbcr_FactoryForms600_ColumnsHolder extends Wbcr_FactoryForms600_Holder {
21
22 /**
23 * A holder type.
24 *
25 * @since 1.0.0
26 * @var string
27 */
28 public $type = 'columns';
29
30 public function __construct( $options, $form ) {
31 $columns_items = [];
32
33 // calculates the number of columns
34
35 $this->columns_count = 0;
36
37 foreach ( $options['items'] as $item ) {
38 $i = ( ! isset( $item['column'] )
39 ? 1
40 : intval( $item['column'] ) ) - 1;
41 $columns_items[ $i ][] = $item;
42
43 if ( $i > $this->columns_count ) {
44 $this->columns_count = $i + 1;
45 }
46 }
47 // calculates the number of rows
48
49 $this->rows_count = 0;
50 foreach ( $columns_items as $items ) {
51 $count = count( $items );
52 if ( $count > $this->rows_count ) {
53 $this->rows_count = $count;
54 }
55 }
56
57 // creates elements
58
59 parent::__construct( $options, $form );
60
61 // groups the created by columns
62
63 $element_index = 0;
64 $this->columns = [];
65
66 foreach ( $columns_items as $column_index => $columnItems ) {
67 $count = count( $columnItems );
68 for ( $k = 0; $k < $count; $k++ ) {
69 $this->columns[ $column_index ][] = $this->elements[ $element_index ];
70 ++$element_index;
71 }
72 }
73 }
74
75
76 public function render() {
77 $this->beforeRendering();
78
79 for ( $n = 0; $n < $this->rows_count; $n++ ) {
80
81 $this->form->layout->startRow( $n, $this->rows_count );
82
83 for ( $i = 0; $i < $this->columns_count; $i++ ) {
84 $control = $this->columns[ $i ][ $n ];
85 $this->form->layout->startColumn( $control, $i, $this->columns_count );
86 $this->columns[ $i ][ $n ]->render();
87 $this->form->layout->endColumn( $control, $i, $this->columns_count );
88 }
89
90 $this->form->layout->endRow( $n, $this->rows_count );
91 }
92 }
93 }
94 }
95