|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Bears Pricing Tables - white Template |
| 4 | + * Version : 2025.5.15 |
| 5 | + * Created by : N6REJ |
| 6 | + |
| 7 | + * URL : www.hallhome.us |
| 8 | + * License GPLv3.0 - http://www.gnu.org/licenses/gpl-3.0.html |
| 9 | + */ |
| 10 | + |
| 11 | +// no direct access |
| 12 | +defined('_JEXEC') or die('Restricted access'); |
| 13 | + |
| 14 | +// Update for Joomla 5: Use namespaced classes |
| 15 | +use Joomla\CMS\Application\CMSApplication; |
| 16 | +use Joomla\CMS\Factory; |
| 17 | +use Joomla\CMS\HTML\HTMLHelper; |
| 18 | +use Joomla\CMS\Uri\Uri; |
| 19 | +use Joomla\Registry\Registry; |
| 20 | + |
| 21 | +// Make sure $app is defined |
| 22 | +$app = Factory::getApplication(); |
| 23 | + |
| 24 | +// Make sure $document is defined |
| 25 | +$document = Factory::getDocument(); |
| 26 | + |
| 27 | +// Make sure $module is defined |
| 28 | +if (!isset($module)) { |
| 29 | + $module = $app->input->get('module'); |
| 30 | +} |
| 31 | + |
| 32 | +// Make sure $params is defined |
| 33 | +if (!isset($params)) { |
| 34 | + if (isset($module->params)) { |
| 35 | + $params = new Registry($module->params); |
| 36 | + } else { |
| 37 | + $params = new Registry(); |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +// Include the helper file |
| 42 | +require_once dirname(__DIR__) . '/helper.php'; |
| 43 | + |
| 44 | +// Make sure we have a valid module ID |
| 45 | +$bears_moduleid = $module->id; |
| 46 | + |
| 47 | +$baseurl = Uri::base(); // Updated from JURI::base() |
| 48 | + |
| 49 | +// Get processed parameters |
| 50 | +$params_array = ModBearsPricingTablesHelper::getParams($params); |
| 51 | + |
| 52 | +// Add moduleId to params_array for use in the template |
| 53 | +$params_array['moduleId'] = $bears_moduleid; |
| 54 | + |
| 55 | +// Get column references |
| 56 | +$column_ref = array_keys(array_filter($params_array['bears_title'])); |
| 57 | + |
| 58 | +// Load module CSS with moduleId to ensure proper specificity |
| 59 | +ModBearsPricingTablesHelper::loadModuleCSS($params, $bears_moduleid); |
| 60 | + |
| 61 | +// IMPORTANT: All CSS is now loaded through the helper, so we remove all inline CSS that was here before |
| 62 | +?> |
| 63 | +<div class = "template-newborn"> |
| 64 | + <div class = "bears_pricing_tables-outer bears_pricing_tables-<?php |
| 65 | + echo $bears_moduleid; ?>"> |
| 66 | + <!-- Add data-columns attribute for CSS targeting --> |
| 67 | + <div class = 'bears_pricing_tables-container' data-columns = "<?php |
| 68 | + echo $params_array['bears_num_columns']; ?>"> |
| 69 | + <?php |
| 70 | + // Loop through the number of columns to display |
| 71 | + for ($i = 0; $i < $params_array['bears_num_columns']; $i++) { |
| 72 | + // Skip if this column index doesn't exist in our reference array |
| 73 | + if (!isset($column_ref[$i])) { |
| 74 | + continue; |
| 75 | + } |
| 76 | + |
| 77 | + // Get the actual column number from our reference array |
| 78 | + $cur_column = $column_ref[$i]; |
| 79 | + |
| 80 | + // Check if this column is marked as featured |
| 81 | + $is_featured = isset($params_array['bears_featured'][$cur_column]) && $params_array['bears_featured'][$cur_column] == 'yes'; |
| 82 | + |
| 83 | + // Add column-specific class for styling |
| 84 | + $columnClass = 'bears-column-' . $cur_column; |
| 85 | + ?> |
| 86 | + <div class = "bears_pricing_tables"> |
| 87 | + <div class = "plan<?php |
| 88 | + echo $is_featured ? ' featured' : ''; ?> <?php |
| 89 | + echo $columnClass; ?>"> |
| 90 | + <header> |
| 91 | + <?php |
| 92 | + if (!empty($params_array['header_icon_class'][$cur_column]) && str_starts_with($params_array['header_icon_position'][$cur_column], 'top-')) { |
| 93 | + // Prepare inline style for header icon if color is set |
| 94 | + $header_icon_color = !empty($params_array['header_icon_color'][$cur_column]) ? |
| 95 | + ' style="color: ' . htmlspecialchars($params_array['header_icon_color'][$cur_column]) . ';"' : ''; |
| 96 | + ?> |
| 97 | + <div class = "plan-icon icon-<?php |
| 98 | + echo htmlspecialchars($params_array['header_icon_position'][$cur_column]); ?> <?php |
| 99 | + echo $columnClass; ?>"> |
| 100 | + <i class = "<?php |
| 101 | + echo htmlspecialchars(ModBearsPricingTablesHelper::formatIconClass($params_array['header_icon_class'][$cur_column])); ?>"<?php |
| 102 | + echo $header_icon_color; ?>></i> |
| 103 | + </div> |
| 104 | + <?php |
| 105 | + } ?> |
| 106 | + |
| 107 | + <h4 class = "plan-title"> |
| 108 | + <?php |
| 109 | + echo htmlspecialchars($params_array['bears_title'][$cur_column] ?? ''); ?> |
| 110 | + </h4> |
| 111 | + |
| 112 | + <?php |
| 113 | + if (!empty($params_array['header_icon_class'][$cur_column]) && str_starts_with($params_array['header_icon_position'][$cur_column], 'bottom-')) { |
| 114 | + // Prepare inline style for header icon if color is set |
| 115 | + $header_icon_color = !empty($params_array['header_icon_color'][$cur_column]) ? |
| 116 | + ' style="color: ' . htmlspecialchars($params_array['header_icon_color'][$cur_column]) . ';"' : ''; |
| 117 | + ?> |
| 118 | + <div class = "plan-icon icon-<?php |
| 119 | + echo htmlspecialchars($params_array['header_icon_position'][$cur_column]); ?> <?php |
| 120 | + echo $columnClass; ?>"> |
| 121 | + <i class = "<?php |
| 122 | + echo htmlspecialchars(ModBearsPricingTablesHelper::formatIconClass($params_array['header_icon_class'][$cur_column])); ?>"<?php |
| 123 | + echo $header_icon_color; ?>></i> |
| 124 | + </div> |
| 125 | + <?php |
| 126 | + } |
| 127 | + ?> |
| 128 | + </header> |
| 129 | + |
| 130 | + <?php |
| 131 | + // Determine if we should use FontAwesome list format based on whether an icon class is specified |
| 132 | + $icon_class = !empty($params_array['features_icon_class'][$cur_column]) ? |
| 133 | + ModBearsPricingTablesHelper::formatIconClass($params_array['features_icon_class'][$cur_column]) : ''; |
| 134 | + $icon_color = !empty($params_array['features_icon_color'][$cur_column]) ? |
| 135 | + $params_array['features_icon_color'][$cur_column] : ''; |
| 136 | + |
| 137 | + // Prepare inline style for icon if color is set |
| 138 | + $icon_style = !empty($icon_color) ? ' style="color: ' . htmlspecialchars($icon_color) . ';"' : ''; |
| 139 | + |
| 140 | + // Always use plan-features class and add fa-ul only if icon class is specified |
| 141 | + $list_class = !empty($icon_class) ? 'plan-features fa-ul centered-features' : 'plan-features'; |
| 142 | + ?> |
| 143 | + <div class = "features"> |
| 144 | + <ul class = "<?php |
| 145 | + echo $list_class; ?>"> |
| 146 | + <?php |
| 147 | + if (!empty($params_array['bears_features'][$cur_column])) { |
| 148 | + $features = $params_array['bears_features'][$cur_column]; |
| 149 | + |
| 150 | + // Handle the features data from the subform |
| 151 | + $features_items = is_string($features) ? json_decode($features) : $features; |
| 152 | + |
| 153 | + // Ensure we have an iterable |
| 154 | + if (!is_array($features_items) && !is_object($features_items)) { |
| 155 | + $features_items = [$features_items]; |
| 156 | + } |
| 157 | + |
| 158 | + // Render each feature |
| 159 | + foreach ($features_items as $item) { |
| 160 | + $feature_text = ''; |
| 161 | + |
| 162 | + // Get the text (always from bears_feature property when using subform) |
| 163 | + if (is_object($item) && isset($item->bears_feature)) { |
| 164 | + $feature_text = $item->bears_feature; |
| 165 | + } elseif (is_string($item)) { |
| 166 | + $feature_text = $item; |
| 167 | + } |
| 168 | + |
| 169 | + // Output the feature text if not empty |
| 170 | + if (!empty($feature_text)) { |
| 171 | + echo '<li>'; |
| 172 | + |
| 173 | + // Create a span to wrap the content for centering |
| 174 | + echo '<span class="features-content">'; |
| 175 | + |
| 176 | + // Add icon with fa-li span if icon class is specified |
| 177 | + if (!empty($icon_class)) { |
| 178 | + echo '<span class="fa-li"><i class="' . htmlspecialchars($icon_class) . '"' . $icon_style . '></i></span>'; |
| 179 | + } |
| 180 | + |
| 181 | + echo htmlspecialchars($feature_text); |
| 182 | + echo '</span>'; |
| 183 | + echo '</li>'; |
| 184 | + } |
| 185 | + } |
| 186 | + } |
| 187 | + ?> |
| 188 | + </ul> |
| 189 | + </div> |
| 190 | + <div class = 'price'> |
| 191 | + <?php |
| 192 | + if (!empty($params_array['header_icon_class'][$cur_column]) && $params_array['header_icon_position'][$cur_column] === 'price-left') { |
| 193 | + // Prepare inline style for header icon if color is set |
| 194 | + $header_icon_color = !empty($params_array['header_icon_color'][$cur_column]) ? |
| 195 | + ' style="color: ' . htmlspecialchars($params_array['header_icon_color'][$cur_column]) . ';"' : ''; |
| 196 | + ?> |
| 197 | + <div class = "plan-icon price-left <?php |
| 198 | + echo $columnClass; ?>"> |
| 199 | + <i class = "<?php |
| 200 | + echo htmlspecialchars(ModBearsPricingTablesHelper::formatIconClass($params_array['header_icon_class'][$cur_column])); ?>"<?php |
| 201 | + echo $header_icon_color; ?>></i> |
| 202 | + </div> |
| 203 | + <?php |
| 204 | + } ?> |
| 205 | + |
| 206 | + <div class = "plan-cost"> |
| 207 | + <h2 class = "plan-price"><?php |
| 208 | + echo htmlspecialchars($params_array['bears_price'][$cur_column] ?? ''); ?></h2> |
| 209 | + <small class = "plan-type"><?php |
| 210 | + echo htmlspecialchars($params_array['bears_subtitle'][$cur_column] ?? ''); ?></small> |
| 211 | + </div> |
| 212 | + |
| 213 | + <?php |
| 214 | + if (!empty($params_array['header_icon_class'][$cur_column]) && $params_array['header_icon_position'][$cur_column] === 'price-right') { |
| 215 | + // Prepare inline style for header icon if color is set |
| 216 | + $header_icon_color = !empty($params_array['header_icon_color'][$cur_column]) ? |
| 217 | + ' style="color: ' . htmlspecialchars($params_array['header_icon_color'][$cur_column]) . ';"' : ''; |
| 218 | + ?> |
| 219 | + <div class = "plan-icon price-right <?php |
| 220 | + echo $columnClass; ?>"> |
| 221 | + <i class = "<?php |
| 222 | + echo htmlspecialchars(ModBearsPricingTablesHelper::formatIconClass($params_array['header_icon_class'][$cur_column])); ?>"<?php |
| 223 | + echo $header_icon_color; ?>></i> |
| 224 | + </div> |
| 225 | + <?php |
| 226 | + } ?> |
| 227 | + </div> |
| 228 | + <div class = "plan-select"> |
| 229 | + <a class = "btn" href = "<?php |
| 230 | + echo htmlspecialchars($params_array['bears_buttonurl'][$cur_column] ?? '#'); ?>"> |
| 231 | + <?php |
| 232 | + echo htmlspecialchars($params_array['bears_buttontext'][$cur_column] ?? ''); ?> |
| 233 | + </a> |
| 234 | + </div> |
| 235 | + </div> |
| 236 | + </div> |
| 237 | + <?php |
| 238 | + } |
| 239 | + ?> |
| 240 | + </div> |
| 241 | + <div class = "clear"></div> |
| 242 | + </div> |
| 243 | +</div> |
0 commit comments