PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/docroot/themes/custom/gavias_linoor/gva_content_builder/gva_row.php

https://gitlab.com/kryber/wizionary
PHP | 344 lines | 326 code | 18 blank | 0 comment | 26 complexity | 6c5e83a5b4d798fd79f10c021b413a48 MD5 | raw file
  1. <?php
  2. class element_gva_row{
  3. public function render_form(){
  4. return array(
  5. 'title' => t('Row'),
  6. 'fields' => array(
  7. array(
  8. 'id' => 'row_name',
  9. 'type' => 'text',
  10. 'title' => ('Row Name'),
  11. ),
  12. array(
  13. 'id' => 'info',
  14. 'type' => 'info',
  15. 'title' => 'Setting background for row'
  16. ),
  17. array(
  18. 'id' => 'bg_image',
  19. 'type' => 'upload',
  20. 'title' => ('Background Image'),
  21. 'class' => 'width-1-2'
  22. ),
  23. array(
  24. 'id' => 'bg_color',
  25. 'type' => 'text',
  26. 'title' => ('Background Color'),
  27. 'desc' => ('Use color name (eg. "gray") or hex (eg. "#808080").'),
  28. 'std' => '',
  29. 'class' => 'width-1-2 margin-top-40'
  30. ),
  31. array(
  32. 'id' => 'bg_position',
  33. 'type' => 'select',
  34. 'title' => t('Background Position'),
  35. 'class' => 'width-1-4 clear-both',
  36. 'options' => array(
  37. 'center top' => 'center top',
  38. 'center right' => 'center right',
  39. 'center bottom' => 'center bottom',
  40. 'center center' => 'center center',
  41. 'left top' => 'left top',
  42. 'left center' => 'left center',
  43. 'left bottom' => 'left bottom',
  44. 'right top' => 'right top',
  45. 'right center' => 'right center',
  46. 'right bottom' => 'right bottom',
  47. )
  48. ),
  49. array(
  50. 'id' => 'bg_repeat',
  51. 'type' => 'select',
  52. 'title' => t('Background Position'),
  53. 'class' => 'width-1-4',
  54. 'options' => array(
  55. 'no-repeat' => 'no-repeat',
  56. 'repeat' => 'repeat',
  57. 'repeat-x' => 'repeat-x',
  58. 'repeat-y' => 'repeat-y',
  59. )
  60. ),
  61. array(
  62. 'id' => 'bg_attachment',
  63. 'type' => 'select',
  64. 'title' => t('Background Attachment'),
  65. 'class' => 'width-1-4',
  66. 'options' => array(
  67. 'scroll' => 'Scroll',
  68. 'fixed' => 'Parallax',
  69. 'bg-fixed' => 'Fixed',
  70. ),
  71. 'std' => 'scroll'
  72. ),
  73. array(
  74. 'id' => 'bg_size',
  75. 'type' => 'select',
  76. 'title' => t('Background Size'),
  77. 'class' => 'width-1-4',
  78. 'options' => array(
  79. 'cover' => 'cover',
  80. 'contain' => 'contain',
  81. 'default' => 'default',
  82. 'width-100' => 'Width 100%',
  83. ),
  84. 'std' => 'cover'
  85. ),
  86. array(
  87. 'id' => 'bg_video',
  88. 'type' => 'text',
  89. 'title' => ('Background video (url video)'),
  90. 'desc' => ('Use video youtube.'),
  91. 'std' => '',
  92. ),
  93. array(
  94. 'id' => 'info',
  95. 'type' => 'info',
  96. 'title' => 'Setting padding, margin for row'
  97. ),
  98. array(
  99. 'id' => 'style_space',
  100. 'type' => 'select',
  101. 'title' => 'Style Space',
  102. 'options' => array(
  103. 'default' => 'Default',
  104. 'remove_padding_top' => 'Remove padding top',
  105. 'remove_padding_bottom' => 'Remove padding bottom',
  106. 'remove_padding' => 'Remove padding for row',
  107. 'remove_padding_col' => 'Remove padding for colums of row',
  108. 'remove_margin remove_padding remove_padding_col' => 'Remove padding for [colums & row]',
  109. 'padding-small' => 'Padding Small',
  110. 'padding-large' => 'Padding Large',
  111. 'padding-bottom-large' => 'Padding Bottom Large',
  112. 'padding-top-large' => 'Padding Top Large',
  113. 'padding-bottom-small' => 'Padding Bottom Small'
  114. )
  115. ),
  116. array(
  117. 'id' => 'padding_top',
  118. 'type' => 'text',
  119. 'title' => ('Padding Top'),
  120. 'desc' => ('Padding Top for row (e.g. 30px)'),
  121. 'class' => 'width-1-4',
  122. 'std' => '0',
  123. ),
  124. array(
  125. 'id' => 'padding_right',
  126. 'type' => 'text',
  127. 'title' => ('Padding Right'),
  128. 'desc' => ('Padding Right for row (e.g. 30px)'),
  129. 'class' => 'width-1-4',
  130. 'std' => '0',
  131. ),
  132. array(
  133. 'id' => 'padding_bottom',
  134. 'type' => 'text',
  135. 'title' => ('Padding Bottom'),
  136. 'desc' => ('Padding Bottom for row (e.g. 30px)'),
  137. 'class' => 'width-1-4',
  138. 'std' => '0',
  139. ),
  140. array(
  141. 'id' => 'padding_left',
  142. 'type' => 'text',
  143. 'title' => ('Padding Left'),
  144. 'desc' => ('Padding Left for row (e.g. 30px)'),
  145. 'class' => 'width-1-4',
  146. 'std' => '0',
  147. ),
  148. array(
  149. 'id' => 'info',
  150. 'type' => 'info',
  151. 'title' => 'Setting padding, margin for row'
  152. ),
  153. array(
  154. 'id' => 'margin_top',
  155. 'type' => 'text',
  156. 'title' => ('Margin Top'),
  157. 'desc' => ('Margin top for row (e.g. 30px)'),
  158. 'class' => 'width-1-4',
  159. 'std' => '0',
  160. ),
  161. array(
  162. 'id' => 'margin_right',
  163. 'type' => 'text',
  164. 'title' => ('Margin Right'),
  165. 'desc' => ('Margin Right for row (e.g. 30px)'),
  166. 'class' => 'width-1-4',
  167. 'std' => '0',
  168. ),
  169. array(
  170. 'id' => 'margin_bottom',
  171. 'type' => 'text',
  172. 'title' => ('Margin Bottom'),
  173. 'desc' => ('Margin Bottom for row (e.g. 30px)'),
  174. 'class' => 'width-1-4',
  175. 'std' => '0',
  176. ),
  177. array(
  178. 'id' => 'margin_left',
  179. 'type' => 'text',
  180. 'title' => ('Margin Left'),
  181. 'desc' => ('Margin Left for row (e.g. 30px)'),
  182. 'class' => 'width-1-4',
  183. 'std' => '0',
  184. ),
  185. array(
  186. 'id' => 'info',
  187. 'type' => 'info',
  188. 'title' => 'Setting layout, style for row',
  189. ),
  190. array(
  191. 'id' => 'layout',
  192. 'type' => 'select',
  193. 'title' => 'Layout',
  194. 'options' => array( 'container' => 'Box', 'container-fw' => 'Full Width', 'full-screen' => 'Full Screen' )
  195. ),
  196. array(
  197. 'id' => 'info',
  198. 'type' => 'info',
  199. 'title' => 'Setting style, class, id for row'
  200. ),
  201. array(
  202. 'id' => 'icon',
  203. 'type' => 'text',
  204. 'title' => ('Icon for row'),
  205. 'desc' => t('Use class icon font <a target="_blank" href="http://fontawesome.io/icons/">Icon Awesome</a>'),
  206. ),
  207. array(
  208. 'id' => 'class',
  209. 'type' => 'text',
  210. 'title' => ('Custom CSS classes'),
  211. 'desc' => ('Multiple classes should be separated with SPACE.<br />'),
  212. ),
  213. array(
  214. 'id' => 'row_id',
  215. 'type' => 'text',
  216. 'title' => ('Custom ID'),
  217. 'desc' => ('Use this option to create One Page sites.<br/>For example: Your Custom ID is <strong>offer</strong> and you want to open this section, please use link: <strong>your-url/#offer-2</strong>'),
  218. 'class' => 'small-text',
  219. ),
  220. array(
  221. 'id' => 'bg_row',
  222. 'type' => 'select',
  223. 'title' => ('Style Row Available'),
  224. 'options' => array(
  225. '' => '-- None --',
  226. 'row-gradient-1' => 'Background gradient 1',
  227. 'row-gradient-2' => 'Background gradient 2',
  228. 'row-bg-top' => 'Background top'
  229. )
  230. ),
  231. )
  232. );
  233. }
  234. public function render_content( $settings = array(), $content = '' ) {
  235. global $base_url, $base_path;
  236. extract(gavias_merge_atts(array(
  237. 'row_name' => '',
  238. 'first_level' => false,
  239. 'bg_image' => '',
  240. 'bg_color' => '',
  241. 'bg_position' => '',
  242. 'bg_repeat' => '',
  243. 'bg_attachment' => '',
  244. 'bg_size' => '',
  245. 'bg_video' => '',
  246. 'style_space' => '',
  247. 'padding_top' => '',
  248. 'padding_right' => '',
  249. 'padding_bottom' => '',
  250. 'padding_left' => '',
  251. 'margin_top' => '',
  252. 'margin_right' => '',
  253. 'margin_bottom' => '',
  254. 'margin_left' => '',
  255. 'layout' => 'container',
  256. 'icon' => '',
  257. 'class' => '',
  258. 'row_id' => '',
  259. 'bg_row' => ''
  260. ), $settings));
  261. $array_class = array();
  262. $array_style = array();
  263. if($first_level) $array_class[] = 'row-first-level';
  264. $class ? $array_class[] = $class : false;
  265. $array_class[] = 'gbb-row';
  266. $bg_row ? $array_class[] = $bg_row : false;
  267. if(!empty($padding_top)) $array_style[] = 'padding-top:'. trim($padding_top);
  268. if(!empty($padding_left)) $array_style[] = 'padding-left:'. trim($padding_left);
  269. if(!empty($padding_bottom)) $array_style[] = 'padding-bottom:'. trim($padding_bottom);
  270. if(!empty($padding_right)) $array_style[] = 'padding-right:'. trim($padding_right);
  271. if(!empty($margin_top)) $array_style[] = 'margin-top:'. trim($margin_top);
  272. if(!empty($margin_right)) $array_style[] = 'margin-right:'. trim($margin_right);
  273. if(!empty($margin_bottom)) $array_style[] = 'margin-bottom:'. trim($margin_bottom);
  274. if(!empty($margin_left)) $array_style[] = 'margin-left:'. trim($margin_left);
  275. if($bg_color) $array_style[] = 'background-color:'. $bg_color;
  276. if( $bg_image){
  277. $array_style[] = 'background-image:url(\''. substr($base_path, 0, -1) . $bg_image .'\')';
  278. $array_style[] = 'background-repeat:' . $bg_repeat;
  279. $array_style[] = 'background-position:' . $bg_position;
  280. if($bg_size == 'width-100'){
  281. $array_style[] = 'background-size: 100%';
  282. }
  283. if($bg_attachment=='fixed'){
  284. $array_class[] = 'gva-parallax-background';
  285. }
  286. if($bg_attachment=='bg-fixed'){
  287. $array_class[] = 'gva-fixed-background';
  288. }
  289. }
  290. $row_bg_size = 'bg-size-cover';
  291. if($bg_size){
  292. $row_bg_size = 'bg-size-' . $bg_size;
  293. }
  294. $array_class[] = $row_bg_size;
  295. $data_bg_video = "";
  296. if($bg_video){
  297. $array_class[] = 'youtube-bg';
  298. $data_bg_video ="data-property=\"{videoURL: '{$bg_video}',
  299. containment: 'self', startAt: 0, stopAt: 0, autoPlay: true, loop: true, mute: true, showControls: false,
  300. showYTLogo: false, realfullscreen: true, addRaster: false, optimizeDisplay: true, stopMovieOnBlur: true}\"";
  301. }
  302. $row_class = implode(' ', $array_class);
  303. $row_style = implode('; ', $array_style );
  304. ob_start();
  305. ?>
  306. <div class="gbb-row-wrapper section <?php print trim($row_class) ?>" <?php if($row_id) print 'id="'.$row_id.'"' ?> style="<?php print $row_style ?>" <?php if($data_bg_video) print $data_bg_video; ?> <?php if($row_name) print 'data-onepage-title="'.$row_name.'"'; ?>>
  307. <?php if($icon){ ?><span class="icon-row <?php print $icon ?>"></span><?php } ?>
  308. <div class="bb-inner <?php if($style_space) print $style_space; ?>">
  309. <div class="bb-container <?php print $layout ?>">
  310. <div class="row row-wrapper">
  311. <?php print $content ?>
  312. </div>
  313. </div>
  314. </div>
  315. <?php if( $bg_attachment == 'fixed' ){
  316. $data_parallax = 'data-bottom-top="top: -60%;" data-top-bottom="top: 0%;"';
  317. if($bg_position == 'center top'){
  318. $data_parallax = 'data-bottom-top="top: -40%;" data-top-bottom="top: 20%;"';
  319. }
  320. ?>
  321. <div style="background-repeat: <?php print $bg_repeat; ?>;background-position:<?php print $bg_position ?>;<?php print ($bg_size=='width-100'?'background-size: 100%;':'')?>" class="gva-parallax-inner skrollable skrollable-between <?php print $row_bg_size ?>" <?php print $data_parallax ?>></div>
  322. <?php } ?>
  323. </div>
  324. <?php return ob_get_clean();
  325. }
  326. }