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

https://gitlab.com/kryber/wizionary · PHP · 206 lines · 197 code · 8 blank · 1 comment · 12 complexity · 6ebdc35b6c6a887c7f35683400db4309 MD5 · raw file

  1. <?php
  2. if(!class_exists('element_gva_call_to_action')):
  3. class element_gva_call_to_action{
  4. public function render_form(){
  5. $fields = array(
  6. 'type' => 'gsc_call_to_action',
  7. 'title' => t('Call to Action'),
  8. 'fields' => array(
  9. array(
  10. 'id' => 'title',
  11. 'type' => 'text',
  12. 'title' => t('Title'),
  13. 'admin' => true
  14. ),
  15. array(
  16. 'id' => 'title_font_size',
  17. 'type' => 'text',
  18. 'title' => t('Title Font Size')
  19. ),
  20. array(
  21. 'id' => 'sub_title',
  22. 'type' => 'text',
  23. 'title' => t('Sub Title'),
  24. ),
  25. array(
  26. 'id' => 'image',
  27. 'type' => 'upload',
  28. 'title' => t('Image Icon'),
  29. 'desc' => t('Use image icon instead of icon class'),
  30. ),
  31. array(
  32. 'id' => 'content',
  33. 'type' => 'textarea',
  34. 'title' => t('Content'),
  35. 'desc' => t('HTML tags allowed.'),
  36. ),
  37. array(
  38. 'id' => 'style',
  39. 'type' => 'select',
  40. 'title' => 'Style Layout',
  41. 'options' => array(
  42. 'style-v1' => t('Style V1'),
  43. 'style-v2' => t('Style V2'),
  44. 'style-v3' => t('Style V3')
  45. )
  46. ),
  47. array(
  48. 'id' => 'box_background',
  49. 'type' => 'text',
  50. 'title' => t('Box Background'),
  51. 'desc' => t('Box Background, e.g: #f5f5f5')
  52. ),
  53. array(
  54. 'id' => 'width',
  55. 'type' => 'text',
  56. 'title' => t('Max width for content'),
  57. 'desc' => 'e.g 660px'
  58. ),
  59. array(
  60. 'id' => 'style_text',
  61. 'type' => 'select',
  62. 'title' => 'Skin Text for box',
  63. 'options' => array(
  64. 'text-light' => 'Text light',
  65. 'text-dark' => 'Text dark',
  66. ),
  67. 'std' => 'text-dark'
  68. ),
  69. array(
  70. 'id' => 'info',
  71. 'type' => 'info',
  72. 'title' => 'Settings Button'
  73. ),
  74. array(
  75. 'id' => 'link',
  76. 'type' => 'text',
  77. 'title' => t('Link'),
  78. ),
  79. array(
  80. 'id' => 'button_title',
  81. 'type' => 'text',
  82. 'title' => t('Button Title'),
  83. 'desc' => t('Leave this field blank if you want Call to Action with Big Icon'),
  84. ),
  85. array(
  86. 'id' => 'style_button',
  87. 'type' => 'select',
  88. 'title' => 'Style button #1',
  89. 'options' => array(
  90. 'btn-theme' => 'Button Theme',
  91. 'btn-black' => 'Button Black',
  92. 'btn-white' => 'Button white'
  93. ),
  94. 'default' => 'btn-theme'
  95. ),
  96. array(
  97. 'id' => 'target',
  98. 'type' => 'select',
  99. 'title' => t('Open in new window'),
  100. 'desc' => t('Adds a target="_blank" attribute to the link'),
  101. 'options' => array( 'off' => 'Off', 'on' => 'On' ),
  102. ),
  103. array(
  104. 'id' => 'el_class',
  105. 'type' => 'text',
  106. 'title' => t('Extra class name'),
  107. 'desc' => t('Style particular content element differently - add a class name and refer to it in custom CSS.'),
  108. ),
  109. array(
  110. 'id' => 'animate',
  111. 'type' => 'select',
  112. 'title' => t('Animation'),
  113. 'desc' => t('Entrance animation for element'),
  114. 'options' => gavias_content_builder_animate(),
  115. 'class' => 'width-1-2'
  116. ),
  117. array(
  118. 'id' => 'animate_delay',
  119. 'type' => 'select',
  120. 'title' => t('Animation Delay'),
  121. 'options' => gavias_content_builder_delay_wow(),
  122. 'desc' => '0 = default',
  123. 'class' => 'width-1-2'
  124. ),
  125. ),
  126. );
  127. return $fields;
  128. }
  129. function render_content( $attr = array(), $content = '' ){
  130. global $base_url;
  131. extract(gavias_merge_atts(array(
  132. 'title' => '',
  133. 'title_font_size' => '',
  134. 'sub_title' => '',
  135. 'image' => '',
  136. 'content' => '',
  137. 'style' => '',
  138. 'width' => '',
  139. 'link' => '',
  140. 'button_title' => '',
  141. 'style_button' => 'btn-theme',
  142. 'target' => '',
  143. 'style_text' => 'text-dark',
  144. 'box_background' => '',
  145. 'el_class' => '',
  146. 'animate' => '',
  147. 'animate_delay' => '',
  148. ), $attr));
  149. if($image) $image = $base_url . $image;
  150. // target
  151. if( $target =='on' ){
  152. $target = 'target="_blank"';
  153. } else {
  154. $target = false;
  155. }
  156. $class = array();
  157. $class[] = $el_class;
  158. $class[] = $style_text;
  159. $class[] = $style;
  160. $css_background = '';
  161. if($box_background){
  162. $class[] = 'has-background';
  163. $css_background = 'style="background:' . $box_background . '"';
  164. }
  165. if($animate) $class[] = 'wow ' . $animate;
  166. ob_start();
  167. ?>
  168. <div class="widget gsc-call-to-action <?php print implode(' ', $class) ?>" <?php print $css_background ?> <?php print gavias_content_builder_print_animate_wow('', $animate_delay) ?>>
  169. <div class="content-inner clearfix" >
  170. <div class="content" <?php if($width){ ?> style="max-width: <?php echo $width ?>" <?php } ?> >
  171. <?php if($image){ ?>
  172. <div class="image-icon">
  173. <img src="<?php print $image ?>" alt="<?php print strip_tags($title) ?>"/>
  174. </div>
  175. <?php } ?>
  176. <?php if($sub_title){ ?>
  177. <div class="sub-title"><span><?php print $sub_title; ?></span></div>
  178. <?php } ?>
  179. <?php if($title){ ?>
  180. <h2 class="title" <?php if($title_font_size){ ?> style="font-size: <?php echo $title_font_size ?>" <?php } ?>>
  181. <span><?php print $title; ?></span>
  182. </h2>
  183. <?php } ?>
  184. <div class="desc"><?php print $content; ?></div>
  185. </div>
  186. <?php if($link){?>
  187. <div class="button-action">
  188. <a href="<?php print $link ?>" class="<?php print $style_button ?>" <?php print $target ?>>
  189. <i class="btn-curve"></i><span><?php print $button_title ?></span></a>
  190. </div>
  191. <?php } ?>
  192. </div>
  193. </div>
  194. <?php return ob_get_clean() ?>
  195. <?php
  196. }
  197. }
  198. endif;