PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Document / Models / Options / All.php

All.php in Depicter — Popup & Slider Builder trunk, at app/src/Document/Models/Options/All.php

235 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Document\Models\Options;
3
4
5 use Averta\Core\Utility\Arr;
6
7 class All
8 {
9 /**
10 * @var string
11 */
12 public $sectionLayout;
13
14 /**
15 * @var bool|null
16 */
17 public $stretch;
18
19 /**
20 * @var object
21 */
22 public $sectionTransition;
23
24 /**
25 * @var \Depicter\Document\Models\Common\Size\States
26 */
27 public $wrapperSize;
28
29 /**
30 * @var int
31 */
32 public $wrapperSideSpace = 0;
33
34 /**
35 * @var object|null
36 */
37 public $documentTypeOptions;
38
39 /**
40 * @var General
41 */
42 public $general;
43
44 /**
45 * @var Navigation
46 */
47 public $navigation;
48
49 /**
50 * @var object|null
51 */
52 public $navigator;
53
54 /**
55 * @var Animation
56 */
57 public $slidingAnimation;
58
59 /**
60 * @var Loading|null
61 */
62 public $loading;
63
64 /**
65 * @var Advanced
66 */
67 public $advanced;
68
69 /**
70 * @var Callback[]
71 */
72 public $callbacks;
73
74 /**
75 * @var Callback[]
76 */
77 public $controls;
78
79 /**
80 * List of option styles
81 *
82 * @var array
83 */
84 protected $stylesList = [];
85
86
87 /**
88 * Get document size
89 *
90 * @param $sizeProp
91 *
92 * @param bool $includeUnit
93 *
94 * @return string
95 */
96 public function getSize( $sizeProp, $includeUnit = false ) {
97 return implode( ',', $this->wrapperSize->getResponsiveSizes( $sizeProp, $includeUnit ) );
98 }
99
100 /**
101 * Get document size
102 *
103 * @param $sizeProp
104 * @param bool $includeUnit
105 *
106 * @return array
107 */
108 public function getSizes( $sizeProp, $includeUnit = false ) {
109 return $this->wrapperSize->getResponsiveSizes( $sizeProp, $includeUnit );
110 }
111
112 /**
113 * Get document layout
114 *
115 * @return string
116 */
117 public function getLayout(){
118 return isset( $this->sectionLayout ) ? $this->sectionLayout : 'fullwidth';
119 }
120
121 public function getStyles(){
122 $this->stylesList = [];
123
124 // Collect styles for general options
125 if( $this->general ){
126 $this->general->setAllOptions( $this );
127 $this->stylesList = Arr::merge( $this->general->getStylesList(), $this->stylesList );
128 }
129
130 return $this->stylesList;
131 }
132
133 public function getPrimaryContainerStyles() {
134 $this->stylesList = [];
135
136 // Collect styles for general options
137 if( $this->general ){
138 $this->general->setAllOptions( $this );
139 $this->stylesList = array_merge_recursive( $this->general->getPrimaryContainerStyles(), $this->stylesList );
140 }
141
142 return $this->stylesList;
143 }
144
145 /**
146 * Get before init document styles
147 *
148 * @return array
149 */
150 public function getBeforeInitStyles(){
151 $this->general = $this->general ?? new General();
152 $this->general->setAllOptions( $this );
153
154 return $this->general->getBeforeInitStyles();
155 }
156
157 /**
158 * get styles for layers wrapper
159 *
160 * @return array
161 */
162 public function getLayersWrapperStyles(){
163 $styles = [];
164 if( ! empty( $this->wrapperSideSpace ) ){
165 $styles = [ 'default' => [ 'padding-left' => $this->wrapperSideSpace.'px', 'padding-right' => $this->wrapperSideSpace.'px' ] ];
166 }
167
168 return $styles;
169 }
170
171 /**
172 * Get general section styles
173 *
174 * @return array
175 */
176 public function getSectionGeneralStyles(){
177 $this->general = $this->general ?? new General();
178 $this->general->setAllOptions( $this );
179
180 $minHeightStyles = $this->general->getMinHeightStyles();
181 $carouselStyles = $this->general->getCarouselSectionStyles( $this->documentTypeOptions );
182
183 return array_merge_recursive( $minHeightStyles, $carouselStyles );
184 }
185
186 /**
187 * Generate backdrop styles for display extensions
188 *
189 * @return array|array[]
190 */
191 public function getBackdropStyles(){
192 if ( empty( $this->documentTypeOptions ) || empty( $this->documentTypeOptions->displayOptions ) ) {
193 return [];
194 }
195
196 $displayOptions = $this->documentTypeOptions->displayOptions;
197 if ( empty( $displayOptions->backdrop ) ) {
198 return [];
199 }
200
201 $styles = [
202 'default' => []
203 ];
204
205 if ( ! empty( $displayOptions->backdropColor ) ) {
206 $styles['default']['background-color'] = $displayOptions->backdropColor;
207 }
208
209 if ( ! empty( $displayOptions->backdropBlur ) ) {
210 $styles['default']['backdrop-filter'] = 'blur( ' . $displayOptions->backdropBlur . 'px )';
211 }
212
213 return $styles;
214 }
215
216 /**
217 * get callbacks
218 * @param string $sliderName
219 *
220 * @return string
221 */
222 public function getCallbacks( $sliderName = '' ) {
223 $script = '';
224 if ( !empty( $this->callbacks ) ) {
225 foreach ( $this->callbacks as $callback ) {
226 $callback->value = !empty( $sliderName ) ? str_replace( 'depicter.on', $sliderName . '.on', $callback->value ) : $callback->value;
227 $script .= "\n\t$callback->value";
228 }
229 $script .= "\n";
230 }
231
232 return $script;
233 }
234 }
235