roxcoder

site.php

Dec 8th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.84 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * @package SP Page Builder
  5. * @author JoomShaper http://www.joomshaper.com
  6. * @copyright Copyright (c) 2010 - 2016 JoomShaper
  7. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
  8. */
  9. //no direct accees
  10. defined('_JEXEC') or die('resticted aceess');
  11.  
  12.  
  13. class SppagebuilderAddonFeature extends SppagebuilderAddons {
  14.  
  15. public function render() {
  16.  
  17. $class = (isset($this->addon->settings->class) && $this->addon->settings->class) ? $this->addon->settings->class : '';
  18. $title = (isset($this->addon->settings->title) && $this->addon->settings->title) ? $this->addon->settings->title : '';
  19. $heading_selector = (isset($this->addon->settings->heading_selector) && $this->addon->settings->heading_selector) ? $this->addon->settings->heading_selector : 'h3';
  20.  
  21. //Options
  22. $title_url = (isset($this->addon->settings->title_url) && $this->addon->settings->title_url) ? $this->addon->settings->title_url : '';
  23. $url_appear = (isset($this->addon->settings->url_appear) && $this->addon->settings->url_appear) ? $this->addon->settings->url_appear : 'title';
  24. $title_position = (isset($this->addon->settings->title_position) && $this->addon->settings->title_position) ? $this->addon->settings->title_position : 'before';
  25. $feature_type = (isset($this->addon->settings->feature_type) && $this->addon->settings->feature_type) ? $this->addon->settings->feature_type : 'icon';
  26. $feature_image = (isset($this->addon->settings->feature_image) && $this->addon->settings->feature_image) ? $this->addon->settings->feature_image : '';
  27. $icon_name = (isset($this->addon->settings->icon_name) && $this->addon->settings->icon_name) ? $this->addon->settings->icon_name : '';
  28. $hpicon_name = (isset($this->addon->settings->hpicon_name) && $this->addon->settings->hpicon_name) ? $this->addon->settings->hpicon_name : '';
  29. $text = (isset($this->addon->settings->text) && $this->addon->settings->text) ? $this->addon->settings->text : '';
  30. $alignment = (isset($this->addon->settings->alignment) && $this->addon->settings->alignment) ? $this->addon->settings->alignment : '';
  31.  
  32. //Image or icon position
  33. if ($title_position == 'before') {
  34. $icon_image_position = 'after';
  35. } else if ($title_position == 'after') {
  36. $icon_image_position = 'before';
  37. } else {
  38. $icon_image_position = $title_position;
  39. }
  40.  
  41. //Reset Alignment for left and right style
  42. if (($icon_image_position == 'left') || ($icon_image_position == 'right')) {
  43. $alignment = 'sppb-text-' . $icon_image_position;
  44. }
  45.  
  46. //Icon or Image
  47. $media = '';
  48. if ($feature_type == 'icon') {
  49. if ($icon_name || $hpicon_name) {
  50. $media .= '<div class="sppb-icon">';
  51. if (($title_url && $url_appear == 'icon') || ($title_url && $url_appear == 'both' )) {
  52. $media .= '<a href="' . $title_url . '">';
  53. }
  54. $media .= '<span class="sppb-icon-container">';
  55. if ($hpicon_name) {
  56. $media .= '<i class="icon ' . $hpicon_name . '"></i>';
  57. } else {
  58. $media .= '<i class="fa ' . $icon_name . '"></i>';
  59. }
  60. $media .= '</span>';
  61. if (($title_url && $url_appear == 'icon') || ($title_url && $url_appear == 'both' ))
  62. $media .= '</a>';
  63. $media .= '</div>';
  64. }
  65. } else {
  66. if ($feature_image) {
  67. $media .= '<span class="sppb-img-container">';
  68. if (($title_url && $url_appear == 'icon') || ($title_url && $url_appear == 'both' ))
  69. $media .= '<a href="' . $title_url . '">';
  70. $media .= '<img class="sppb-img-responsive" src="' . $feature_image . '" alt="' . $title . '">';
  71. if (($title_url && $url_appear == 'icon') || ($title_url && $url_appear == 'both' ))
  72. $media .= '</a>';
  73. $media .= '</span>';
  74. }
  75. }
  76.  
  77. //Title
  78. $feature_title = '';
  79. if ($title) {
  80. $heading_class = '';
  81. if (($icon_image_position == 'left') || ($icon_image_position == 'right')) {
  82. $heading_class = ' sppb-media-heading';
  83. }
  84.  
  85. if (($title_url && $url_appear == 'title') || ($title_url && $url_appear == 'both' ))
  86. $feature_title .= '<a href="' . $title_url . '">';
  87. $feature_title .= '<' . $heading_selector . ' class="sppb-addon-title sppb-feature-box-title' . $heading_class . '">' . $title . '</' . $heading_selector . '>';
  88. if (($title_url && $url_appear == 'title') || ($title_url && $url_appear == 'both' ))
  89. $feature_title .= '</a>';
  90. }
  91.  
  92. //Feature Text
  93. $feature_text = '<div class="sppb-addon-text">';
  94. $feature_text .= $text;
  95. $feature_text .= '</div>';
  96.  
  97. //Output
  98. $output = '<div class="sppb-addon sppb-addon-feature ' . $alignment . ' ' . $class . '">';
  99. $output .= '<div class="sppb-addon-content">';
  100.  
  101. if ($icon_image_position == 'before') {
  102. $output .= ($media) ? $media : '';
  103. $output .= ($title) ? $feature_title : '';
  104. $output .= $feature_text;
  105. } else if ($icon_image_position == 'after') {
  106. $output .= ($title) ? $feature_title : '';
  107. $output .= ($media) ? $media : '';
  108. $output .= $feature_text;
  109. } else {
  110. if ($media) {
  111. $output .= '<div class="sppb-media">';
  112. $output .= '<div class="pull-' . $icon_image_position . '">';
  113. $output .= $media;
  114. $output .= '</div>';
  115. $output .= '<div class="sppb-media-body">';
  116. $output .= ($title) ? $feature_title : '';
  117. $output .= $feature_text;
  118. $output .= '</div>';
  119. $output .= '</div>';
  120. }
  121. }
  122.  
  123. $output .= '</div>';
  124. $output .= '</div>';
  125.  
  126. return $output;
  127. }
  128.  
  129. public function stylesheets() {
  130. $app = JFactory::getApplication();
  131. $base_path = JURI::base(true) . '/templates/' . $app->getTemplate() . '/css/';
  132. return array($base_path . 'hpicon.css');
  133. }
  134.  
  135. public function css() {
  136. $addon_id = '#sppb-addon-' . $this->addon->id;
  137. $icon_color = (isset($this->addon->settings->icon_color) && $this->addon->settings->icon_color) ? $this->addon->settings->icon_color : '';
  138. $icon_size = (isset($this->addon->settings->icon_size) && $this->addon->settings->icon_size) ? $this->addon->settings->icon_size : '';
  139. $icon_border_color = (isset($this->addon->settings->icon_border_color) && $this->addon->settings->icon_border_color) ? $this->addon->settings->icon_border_color : '';
  140. $icon_border_width = (isset($this->addon->settings->icon_border_width) && $this->addon->settings->icon_border_width) ? $this->addon->settings->icon_border_width : '';
  141. $icon_border_radius = (isset($this->addon->settings->icon_border_radius) && $this->addon->settings->icon_border_radius) ? $this->addon->settings->icon_border_radius : '';
  142. $icon_style = (isset($this->addon->settings->icon_style) && $this->addon->settings->icon_style) ? $this->addon->settings->icon_style : '';
  143. $icon_background = (isset($this->addon->settings->icon_background) && $this->addon->settings->icon_background) ? $this->addon->settings->icon_background : '';
  144. $icon_margin_top = (isset($this->addon->settings->icon_margin_top) && $this->addon->settings->icon_margin_top) ? $this->addon->settings->icon_margin_top : '';
  145. $icon_margin_bottom = (isset($this->addon->settings->icon_margin_bottom) && $this->addon->settings->icon_margin_bottom) ? $this->addon->settings->icon_margin_bottom : '';
  146. $icon_padding = (isset($this->addon->settings->icon_padding) && $this->addon->settings->icon_padding) ? $this->addon->settings->icon_padding : '';
  147. $feature_type = (isset($this->addon->settings->feature_type) && $this->addon->settings->feature_type) ? $this->addon->settings->feature_type : 'icon';
  148. $feature_image = (isset($this->addon->settings->feature_image) && $this->addon->settings->feature_image) ? $this->addon->settings->feature_image : '';
  149. $icon_name = (isset($this->addon->settings->icon_name) && $this->addon->settings->icon_name) ? $this->addon->settings->icon_name : '';
  150. $hpicon_name = (isset($this->addon->settings->hpicon_name) && $this->addon->settings->hpicon_name) ? $this->addon->settings->hpicon_name : '';
  151.  
  152. $css = '';
  153. if ($feature_type == 'icon') {
  154. if ($icon_name || $hpicon_name) {
  155. $style = 'display:inline-block;text-align:center;';
  156. $style .= ($icon_margin_top) ? 'margin-top:' . (int) $icon_margin_top . 'px;' : '';
  157. $style .= ($icon_margin_bottom) ? 'margin-bottom:' . (int) $icon_margin_bottom . 'px;' : '';
  158. $style .= ($icon_padding) ? 'padding:' . (int) $icon_padding . 'px;' : '';
  159. $style .= ($icon_color) ? 'color:' . $icon_color . ';' : '';
  160. $style .= ($icon_background) ? 'background-color:' . $icon_background . ';' : '';
  161. $style .= ($icon_border_color) ? 'border-style:solid;border-color:' . $icon_border_color . ';' : '';
  162. $style .= ($icon_border_width) ? 'border-width:' . (int) $icon_border_width . 'px;' : '';
  163. $style .= ($icon_border_radius) ? 'border-radius:' . (int) $icon_border_radius . 'px;' : '';
  164.  
  165. $font_size = ($icon_size) ? 'font-size:' . (int) $icon_size . 'px;width:' . (int) $icon_size . 'px;height:' . (int) $icon_size . 'px;line-height:' . (int) $icon_size . 'px;' : '';
  166.  
  167. if ($style) {
  168. $css .= $addon_id . ' .sppb-icon .sppb-icon-container {';
  169. $css .= $style;
  170. $css .= '}';
  171. }
  172.  
  173. if ($font_size) {
  174. $css .= $addon_id . ' .sppb-icon .sppb-icon-container > i {';
  175. $css .= $font_size;
  176. $css .= '}';
  177. }
  178. }
  179. } else {
  180. if ($feature_image) {
  181. $img_style = 'display:inline-block;';
  182. $img_style .= ($icon_margin_top) ? 'margin-top:' . (int) $icon_margin_top . 'px;' : '';
  183. $img_style .= ($icon_margin_bottom) ? 'margin-bottom:' . (int) $icon_margin_bottom . 'px;' : '';
  184.  
  185. if ($img_style) {
  186. $css .= $addon_id . ' .sppb-img-container {';
  187. $css .= $img_style;
  188. $css .= '}';
  189. }
  190. }
  191. }
  192.  
  193. return $css;
  194. }
  195.  
  196. }
Advertisement
Add Comment
Please, Sign In to add comment