PluginProbe ʕ •ᴥ•ʔ
Disable Admin Notices – Hide Dashboard Notifications / trunk
Disable Admin Notices – Hide Dashboard Notifications vtrunk
1.4.5 trunk 1.0.0 1.0.2 1.0.3 1.0.5 1.0.6 1.1.1 1.1.3 1.1.4 1.2.0 1.2.2 1.2.3 1.2.4 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4
disable-admin-notices / libs / factory / forms / controls / holders / columns.php
disable-admin-notices / libs / factory / forms / controls / holders Last commit date
accordion-item.php 1 year ago accordion.php 1 year ago columns.php 1 year ago control-group-item.php 1 year ago control-group.php 1 year ago div.php 1 year ago form-group.php 1 year ago index.php 3 years ago more-link.php 1 year ago tab-item.php 1 year ago tab.php 1 year ago
columns.php
99 lines
1 <?php
2 /**
3 * The file contains the class of Columns Holder.
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_ColumnsHolder') ) {
18 /**
19 * Columns Holder
20 *
21 * @since 1.0.0
22 */
23 class Wbcr_FactoryForms480_ColumnsHolder extends Wbcr_FactoryForms480_Holder {
24
25 /**
26 * A holder type.
27 *
28 * @since 1.0.0
29 * @var string
30 */
31 public $type = 'columns';
32
33 public function __construct($options, $form)
34 {
35 $columns_items = array();
36
37 // calculates the number of columns
38
39 $this->columns_count = 0;
40
41 foreach($options['items'] as $item) {
42 $i = (!isset($item['column'])
43 ? 1
44 : intval($item['column'])) - 1;
45 $columns_items[$i][] = $item;
46
47 if( $i > $this->columns_count ) {
48 $this->columns_count = $i + 1;
49 }
50 }
51 // calculates the number of rows
52
53 $this->rows_count = 0;
54 foreach($columns_items as $items) {
55 $count = count($items);
56 if( $count > $this->rows_count ) {
57 $this->rows_count = $count;
58 }
59 }
60
61 // creates elements
62
63 parent::__construct($options, $form);
64
65 // groups the created by columns
66
67 $element_index = 0;
68 $this->columns = array();
69
70 foreach($columns_items as $column_index => $columnItems) {
71 $count = count($columnItems);
72 for($k = 0; $k < $count; $k++) {
73 $this->columns[$column_index][] = $this->elements[$element_index];
74 $element_index++;
75 }
76 }
77 }
78
79
80 public function render()
81 {
82 $this->beforeRendering();
83
84 for($n = 0; $n < $this->rows_count; $n++) {
85
86 $this->form->layout->startRow($n, $this->rows_count);
87
88 for($i = 0; $i < $this->columns_count; $i++) {
89 $control = $this->columns[$i][$n];
90 $this->form->layout->startColumn($control, $i, $this->columns_count);
91 $this->columns[$i][$n]->render();
92 $this->form->layout->endColumn($control, $i, $this->columns_count);
93 }
94
95 $this->form->layout->endRow($n, $this->rows_count);
96 }
97 }
98 }
99 }