| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage com_vikbooking |
| 5 |
* @author Alessio Gaggii - e4j - Extensionsforjoomla.com |
| 6 |
* @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 12 |
|
| 13 |
$vbo_app = VikBooking::getVboApplication(); |
| 14 |
|
| 15 |
JText::script('VBOCONFIGEDITTMPLFILE'); |
| 16 |
JText::script('VBOSAVETMPLFILE'); |
| 17 |
JText::script('VBANNULLA'); |
| 18 |
JText::script('VBOPREVIEW'); |
| 19 |
|
| 20 |
if (VBOPlatformDetection::isWordPress() && function_exists('wp_enqueue_code_editor')) { |
| 21 |
/** |
| 22 |
* WP >= 4.9.0 |
| 23 |
*/ |
| 24 |
wp_enqueue_code_editor(['type' => 'php']); |
| 25 |
} |
| 26 |
|
| 27 |
$editor = JEditor::getInstance(JFactory::getApplication()->get('editor')); |
| 28 |
$document = JFactory::getDocument(); |
| 29 |
$document->addStyleSheet(VBO_SITE_URI.'resources/jquery.fancybox.css'); |
| 30 |
$document->addStyleSheet(VBO_ADMIN_URI.'resources/js_upload/colorpicker.css'); |
| 31 |
JHtml::fetch('script', VBO_SITE_URI.'resources/jquery.fancybox.js'); |
| 32 |
JHtml::fetch('script', VBO_ADMIN_URI.'resources/js_upload/colorpicker.js'); |
| 33 |
JHtml::fetch('script', VBO_ADMIN_URI.'resources/js_upload/eye.js'); |
| 34 |
JHtml::fetch('script', VBO_ADMIN_URI.'resources/js_upload/utils.js'); |
| 35 |
|
| 36 |
$themesel = '<select name="theme">'; |
| 37 |
$themesel .= '<option value="default">default</option>'; |
| 38 |
$themes = glob(VBO_SITE_PATH.DS.'themes'.DS.'*'); |
| 39 |
$acttheme = VikBooking::getTheme(); |
| 40 |
if ($themes) { |
| 41 |
$strip = VBO_SITE_PATH.DS.'themes'.DS; |
| 42 |
foreach ($themes as $th) { |
| 43 |
if (is_dir($th)) { |
| 44 |
$tname = str_replace($strip, '', $th); |
| 45 |
if ($tname != 'default') { |
| 46 |
$themesel .= '<option value="'.$tname.'"'.($tname == $acttheme ? ' selected="selected"' : '').'>'.$tname.'</option>'; |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
$themesel .= '</select>'; |
| 52 |
$firstwday = VikBooking::getFirstWeekDay(); |
| 53 |
?> |
| 54 |
<div class="vbo-config-maintab-left"> |
| 55 |
<fieldset class="adminform"> |
| 56 |
<div class="vbo-params-wrap"> |
| 57 |
<legend class="adminlegend"><?php echo JText::translate('VBOCPARAMLAYOUT'); ?></legend> |
| 58 |
<div class="vbo-params-container"> |
| 59 |
<div class="vbo-param-container"> |
| 60 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGFIRSTWDAY'); ?></div> |
| 61 |
<div class="vbo-param-setting"><select name="firstwday"><option value="0"<?php echo $firstwday == '0' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBSUNDAY'); ?></option><option value="1"<?php echo $firstwday == '1' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBMONDAY'); ?></option><option value="2"<?php echo $firstwday == '2' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBTUESDAY'); ?></option><option value="3"<?php echo $firstwday == '3' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBWEDNESDAY'); ?></option><option value="4"<?php echo $firstwday == '4' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBTHURSDAY'); ?></option><option value="5"<?php echo $firstwday == '5' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBFRIDAY'); ?></option><option value="6"<?php echo $firstwday == '6' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBSATURDAY'); ?></option></select></div> |
| 62 |
</div> |
| 63 |
<div class="vbo-param-container"> |
| 64 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREETEN'); ?></div> |
| 65 |
<div class="vbo-param-setting"><input type="number" name="numcalendars" value="<?php echo VikBooking::numCalendars(); ?>" min="0" max="24"/></div> |
| 66 |
</div> |
| 67 |
<div class="vbo-param-container"> |
| 68 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGTHUMBSIZE'); ?></div> |
| 69 |
<div class="vbo-param-setting"><input type="number" name="thumbsize" value="<?php echo VikBooking::getThumbSize(true); ?>" min="20" max="1000"/></div> |
| 70 |
</div> |
| 71 |
<div class="vbo-param-container"> |
| 72 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREENINE'); ?></div> |
| 73 |
<div class="vbo-param-setting"><?php echo $vbo_app->printYesNoButtons('showpartlyreserved', JText::translate('VBYES'), JText::translate('VBNO'), (VikBooking::showPartlyReserved() ? 'yes' : 0), 'yes', 0); ?></div> |
| 74 |
</div> |
| 75 |
<div class="vbo-param-container"> |
| 76 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREECHECKINOUTSTAT'); ?></div> |
| 77 |
<div class="vbo-param-setting"><?php echo $vbo_app->printYesNoButtons('showcheckinoutonly', JText::translate('VBYES'), JText::translate('VBNO'), (VikBooking::showStatusCheckinoutOnly() ? 1 : 0), 1, 0); ?></div> |
| 78 |
</div> |
| 79 |
|
| 80 |
<div class="vbo-param-container"> |
| 81 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGEMAILTEMPLATE'); ?></div> |
| 82 |
<div class="vbo-param-setting"> |
| 83 |
<div class="btn-wrapper input-append"> |
| 84 |
<button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'helpers'.DS.'email_tmpl.php'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button> |
| 85 |
<button type="button" class="btn vbo-inspector-btn" title="<?php echo addslashes(JText::translate('VBO_INSPECTOR_START')); ?>" data-inspectfile="email_tmpl.php"><?php VikBookingIcons::e('paint-brush'); ?></button> |
| 86 |
<button type="button" class="btn vbo-edit-tmpl vbo-preview-btn" title="<?php echo addslashes(JText::translate('VBOPREVIEW')); ?>" data-prew-type="email_tmpl.php" data-prew-path="<?php echo urlencode(VBO_SITE_PATH.DS.'helpers'.DS.'email_tmpl.php'); ?>"><?php VikBookingIcons::e('eye'); ?></button> |
| 87 |
</div> |
| 88 |
</div> |
| 89 |
</div> |
| 90 |
<div class="vbo-param-container"> |
| 91 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGINVOICETEMPLATE'); ?></div> |
| 92 |
<div class="vbo-param-setting"> |
| 93 |
<div class="btn-wrapper input-append"> |
| 94 |
<button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'helpers'.DS.'invoices'.DS.'invoice_tmpl.php'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button> |
| 95 |
<button type="button" class="btn vbo-inspector-btn" title="<?php echo addslashes(JText::translate('VBO_INSPECTOR_START')); ?>" data-inspectfile="invoice_tmpl.php"><?php VikBookingIcons::e('paint-brush'); ?></button> |
| 96 |
</div> |
| 97 |
</div> |
| 98 |
</div> |
| 99 |
<div class="vbo-param-container"> |
| 100 |
<div class="vbo-param-label"><?php echo JText::translate('VBOMANUALINVOICE'); ?></div> |
| 101 |
<div class="vbo-param-setting"><button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'helpers'.DS.'invoices'.DS.'custom_invoice_tmpl.php'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button></div> |
| 102 |
</div> |
| 103 |
<div class="vbo-param-container"> |
| 104 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGCHECKINTEMPLATE'); ?></div> |
| 105 |
<div class="vbo-param-setting"> |
| 106 |
<div class="btn-wrapper input-append"> |
| 107 |
<button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'helpers'.DS.'checkins'.DS.'checkin_tmpl.php'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button> |
| 108 |
<button type="button" class="btn vbo-inspector-btn" title="<?php echo addslashes(JText::translate('VBO_INSPECTOR_START')); ?>" data-inspectfile="checkin_tmpl.php"><?php VikBookingIcons::e('paint-brush'); ?></button> |
| 109 |
</div> |
| 110 |
</div> |
| 111 |
</div> |
| 112 |
<div class="vbo-param-container"> |
| 113 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGCUSTCSSTPL'); ?></div> |
| 114 |
<div class="vbo-param-setting"> |
| 115 |
<?php |
| 116 |
if (VBOPlatformDetection::isWordPress()) { |
| 117 |
/** |
| 118 |
* @wponly the path of the file is different in WP, it's inside /resources |
| 119 |
*/ |
| 120 |
?> |
| 121 |
<button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'resources'.DS.'vikbooking_custom.css'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button> |
| 122 |
<?php |
| 123 |
} else { |
| 124 |
?> |
| 125 |
<button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'vikbooking_custom.css'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button> |
| 126 |
<?php |
| 127 |
} |
| 128 |
?> |
| 129 |
</div> |
| 130 |
</div> |
| 131 |
<div class="vbo-param-container"> |
| 132 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGCUSTBACKCSSTPL'); ?></div> |
| 133 |
<div class="vbo-param-setting"><button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_ADMIN_PATH.DS.'resources'.DS.'vikbooking_backendcustom.css'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button></div> |
| 134 |
</div> |
| 135 |
<div class="vbo-param-container"> |
| 136 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREESIX'); ?></div> |
| 137 |
<div class="vbo-param-setting"><?php echo $vbo_app->printYesNoButtons('showfooter', JText::translate('VBYES'), JText::translate('VBNO'), (VikBooking::showFooter() ? 'yes' : 0), 'yes', 0); ?></div> |
| 138 |
</div> |
| 139 |
<div class="vbo-param-container"> |
| 140 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHEME'); ?></div> |
| 141 |
<div class="vbo-param-setting"><?php echo $themesel; ?></div> |
| 142 |
</div> |
| 143 |
<div class="vbo-param-container vbo-param-container-full"> |
| 144 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREESEVEN'); ?></div> |
| 145 |
<div class="vbo-param-setting"> |
| 146 |
<?php |
| 147 |
if (interface_exists('Throwable')) { |
| 148 |
/** |
| 149 |
* With PHP >= 7 supporting throwable exceptions for Fatal Errors |
| 150 |
* we try to avoid issues with third party plugins that make use of |
| 151 |
* the WP native function get_current_screen() or any Joomla plugin. |
| 152 |
*/ |
| 153 |
try { |
| 154 |
echo $editor->display( "intromain", VikBooking::getIntroMain(), '100%', 350, 70, 20 ); |
| 155 |
} catch (Throwable $t) { |
| 156 |
echo $t->getMessage() . ' in ' . $t->getFile() . ':' . $t->getLine() . '<br/>'; |
| 157 |
} |
| 158 |
} else { |
| 159 |
// we cannot catch Fatal Errors in PHP 5.x |
| 160 |
echo $editor->display( "intromain", VikBooking::getIntroMain(), '100%', 350, 70, 20 ); |
| 161 |
} |
| 162 |
?> |
| 163 |
</div> |
| 164 |
</div> |
| 165 |
<div class="vbo-param-container"> |
| 166 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREEEIGHT'); ?></div> |
| 167 |
<div class="vbo-param-setting"><textarea name="closingmain" rows="5" cols="60" style="min-width: 400px;"><?php echo htmlspecialchars(VikBooking::getClosingMain()); ?></textarea></div> |
| 168 |
</div> |
| 169 |
</div> |
| 170 |
</div> |
| 171 |
</fieldset> |
| 172 |
</div> |
| 173 |
|
| 174 |
<div class="vbo-config-maintab-right"> |
| 175 |
|
| 176 |
<?php |
| 177 |
/** |
| 178 |
* Preferred colors for CSS styling |
| 179 |
* |
| 180 |
* @since 1.14 (J) - 1.4.0 (WP) |
| 181 |
*/ |
| 182 |
$preferred_colors = VikBooking::getPreferredColors(); |
| 183 |
?> |
| 184 |
<fieldset class="adminform"> |
| 185 |
<div class="vbo-params-wrap"> |
| 186 |
<legend class="adminlegend"> |
| 187 |
<?php |
| 188 |
echo $vbo_app->createPopover(array('title' => JText::translate('VBO_PREF_COLORS'), 'content' => JText::translate('VBO_PREF_COLORS_HELP'))); |
| 189 |
echo ' ' . JText::translate('VBO_PREF_COLORS'); |
| 190 |
?> |
| 191 |
</legend> |
| 192 |
<div class="vbo-params-container"> |
| 193 |
<div class="vbo-param-container"> |
| 194 |
<div class="vbo-param-label"><?php echo JText::translate('VBO_PREF_COLOR_TEXTS'); ?></div> |
| 195 |
<div class="vbo-param-setting"> |
| 196 |
<span class="vbo-inspector-colorpicker-wrap"> |
| 197 |
<span class="vbo-inspector-colorpicker vbo-prefcolorpicker-trig" data-prefcolortype="textcolor" style="background-color: <?php echo !empty($preferred_colors['textcolor']) ? $preferred_colors['textcolor'] : '#ffffff'; ?>;"><?php VikBookingIcons::e('palette'); ?></span> |
| 198 |
</span> |
| 199 |
<input type="hidden" name="pref_textcolor" id="vbo-pref-textcolor" value="<?php echo $preferred_colors['textcolor']; ?>" /> |
| 200 |
</div> |
| 201 |
</div> |
| 202 |
<div class="vbo-param-container"> |
| 203 |
<div class="vbo-param-label"><?php echo JText::translate('VBO_PREF_COLOR_BKGROUND'); ?></div> |
| 204 |
<div class="vbo-param-setting"> |
| 205 |
<div class="vbo-param-setting-top"> |
| 206 |
<span class="vbo-inspector-colorpicker-wrap"> |
| 207 |
<span class="vbo-inspector-colorpicker vbo-prefcolorpicker-trig" data-prefcolortype="bgcolor" style="background-color: <?php echo !empty($preferred_colors['bgcolor']) ? $preferred_colors['bgcolor'] : '#ffffff'; ?>;"><?php VikBookingIcons::e('palette'); ?></span> |
| 208 |
</span> |
| 209 |
<span class="vbo-colorpicker-label"><?php echo JText::translate('VBO_BKGROUND_COL'); ?></span> |
| 210 |
<input type="hidden" name="pref_bgcolor" id="vbo-pref-bgcolor" value="<?php echo $preferred_colors['bgcolor']; ?>" /> |
| 211 |
</div> |
| 212 |
<div class="vbo-param-setting-bottom"> |
| 213 |
<span class="vbo-inspector-colorpicker-wrap"> |
| 214 |
<span class="vbo-inspector-colorpicker vbo-prefcolorpicker-trig" data-prefcolortype="fontcolor" style="background-color: <?php echo !empty($preferred_colors['fontcolor']) ? $preferred_colors['fontcolor'] : '#ffffff'; ?>;"><?php VikBookingIcons::e('palette'); ?></span> |
| 215 |
</span> |
| 216 |
<span class="vbo-colorpicker-label"><?php echo JText::translate('VBO_FONT_COL'); ?></span> |
| 217 |
<input type="hidden" name="pref_fontcolor" id="vbo-pref-fontcolor" value="<?php echo $preferred_colors['fontcolor']; ?>" /> |
| 218 |
</div> |
| 219 |
</div> |
| 220 |
</div> |
| 221 |
<div class="vbo-param-container"> |
| 222 |
<div class="vbo-param-label"><?php echo JText::translate('VBO_PREF_COLOR_BKGROUNDHOV'); ?></div> |
| 223 |
<div class="vbo-param-setting"> |
| 224 |
<div class="vbo-param-setting-top"> |
| 225 |
<span class="vbo-inspector-colorpicker-wrap"> |
| 226 |
<span class="vbo-inspector-colorpicker vbo-prefcolorpicker-trig" data-prefcolortype="bgcolorhov" style="background-color: <?php echo !empty($preferred_colors['bgcolorhov']) ? $preferred_colors['bgcolorhov'] : '#ffffff'; ?>;"><?php VikBookingIcons::e('palette'); ?></span> |
| 227 |
</span> |
| 228 |
<span class="vbo-colorpicker-label"><?php echo JText::translate('VBO_BKGROUND_COL'); ?></span> |
| 229 |
<input type="hidden" name="pref_bgcolorhov" id="vbo-pref-bgcolorhov" value="<?php echo $preferred_colors['bgcolorhov']; ?>" /> |
| 230 |
</div> |
| 231 |
<div class="vbo-param-setting-bottom"> |
| 232 |
<span class="vbo-inspector-colorpicker-wrap"> |
| 233 |
<span class="vbo-inspector-colorpicker vbo-prefcolorpicker-trig" data-prefcolortype="fontcolorhov" style="background-color: <?php echo !empty($preferred_colors['fontcolorhov']) ? $preferred_colors['fontcolorhov'] : '#ffffff'; ?>;"><?php VikBookingIcons::e('palette'); ?></span> |
| 234 |
</span> |
| 235 |
<span class="vbo-colorpicker-label"><?php echo JText::translate('VBO_FONT_COL'); ?></span> |
| 236 |
<input type="hidden" name="pref_fontcolorhov" id="vbo-pref-fontcolorhov" value="<?php echo $preferred_colors['fontcolorhov']; ?>" /> |
| 237 |
</div> |
| 238 |
</div> |
| 239 |
</div> |
| 240 |
<div id="vbo-pref-color-examples" class="vbo-param-container" style="display: none;"> |
| 241 |
<div class="vbo-param-label"><?php echo JText::translate('VBO_PREF_COLOR_EXAMPLERES'); ?></div> |
| 242 |
<div class="vbo-param-setting"> |
| 243 |
<div class="vbo-pref-color-example"> |
| 244 |
<h4><?php echo JText::translate('VBO_PREF_COLOR_TEXTS'); ?></h4> |
| 245 |
</div> |
| 246 |
<div class="vbo-pref-color-example"> |
| 247 |
<button type="button" class="btn btn-small"><?php echo JText::translate('VBO_PREF_COLOR_BKGROUND'); ?></button> |
| 248 |
</div> |
| 249 |
</div> |
| 250 |
</div> |
| 251 |
</div> |
| 252 |
</div> |
| 253 |
</fieldset> |
| 254 |
|
| 255 |
<script type="text/javascript"> |
| 256 |
|
| 257 |
/** |
| 258 |
* Composes the necessary inline style tag for the styles examples. |
| 259 |
*/ |
| 260 |
function vboPrefColorsApplyExample() { |
| 261 |
// compose inline style tag |
| 262 |
var style = ''; |
| 263 |
style += '<style type="text/css" id="vbo-pref-color-livecss">'; |
| 264 |
style += '.vbo-pref-color-example h4 { color: ' + jQuery('#vbo-pref-textcolor').val() + '; }' + "\n"; |
| 265 |
style += '.vbo-pref-color-example button { background-color: ' + jQuery('#vbo-pref-bgcolor').val() + '; color: ' + jQuery('#vbo-pref-fontcolor').val() + '; }' + "\n"; |
| 266 |
style += '.vbo-pref-color-example button:hover { background-color: ' + jQuery('#vbo-pref-bgcolorhov').val() + '; color: ' + jQuery('#vbo-pref-fontcolorhov').val() + '; }' + "\n"; |
| 267 |
style += '</style>'; |
| 268 |
if (jQuery('#vbo-pref-color-livecss').length) { |
| 269 |
// remove current inline style tag |
| 270 |
jQuery('#vbo-pref-color-livecss').remove(); |
| 271 |
} |
| 272 |
// append styling to example window and show it |
| 273 |
jQuery('#vbo-pref-color-examples').append(style).show(); |
| 274 |
} |
| 275 |
|
| 276 |
jQuery(function() { |
| 277 |
/** |
| 278 |
* Register color-picker for preferred colors. |
| 279 |
*/ |
| 280 |
jQuery('.vbo-prefcolorpicker-trig').ColorPicker({ |
| 281 |
color: '#ffffff', |
| 282 |
onShow: function(colpkr, el) { |
| 283 |
var cur_color = jQuery(el).css('backgroundColor'); |
| 284 |
jQuery(el).ColorPickerSetColor(vboRgb2Hex(cur_color)); |
| 285 |
jQuery(colpkr).show(); |
| 286 |
return false; |
| 287 |
}, |
| 288 |
onChange: function(hsb, hex, rgb, el) { |
| 289 |
var element = jQuery(el); |
| 290 |
var el_type = element.attr('data-prefcolortype'); |
| 291 |
element.css('backgroundColor', '#'+hex); |
| 292 |
if (el_type && jQuery('#vbo-pref-' + el_type).length) { |
| 293 |
jQuery('#vbo-pref-' + el_type).val('#'+hex); |
| 294 |
} |
| 295 |
vboPrefColorsApplyExample(); |
| 296 |
}, |
| 297 |
onSubmit: function(hsb, hex, rgb, el) { |
| 298 |
var element = jQuery(el); |
| 299 |
var el_type = element.attr('data-prefcolortype'); |
| 300 |
element.css('backgroundColor', '#'+hex); |
| 301 |
if (el_type && jQuery('#vbo-pref-' + el_type).length) { |
| 302 |
jQuery('#vbo-pref-' + el_type).val('#'+hex); |
| 303 |
} |
| 304 |
element.ColorPickerHide(); |
| 305 |
vboPrefColorsApplyExample(); |
| 306 |
} |
| 307 |
}); |
| 308 |
}); |
| 309 |
|
| 310 |
</script> |
| 311 |
|
| 312 |
<?php |
| 313 |
$colortags = VikBooking::loadBookingsColorTags(); |
| 314 |
$tagsrules = VikBooking::loadColorTagsRules(); |
| 315 |
$opt_js_rules = ''; |
| 316 |
foreach ($tagsrules as $tagk => $tagv) { |
| 317 |
$opt_js_rules .= '<option value=\"'.$tagk.'\">'.addslashes(JText::translate($tagv)).'</option>'; |
| 318 |
} |
| 319 |
?> |
| 320 |
<fieldset class="adminform"> |
| 321 |
<div class="vbo-params-wrap"> |
| 322 |
<legend class="adminlegend"><?php echo JText::translate('VBOCPARAMBOOKTAGS'); ?></legend> |
| 323 |
<div class="vbo-params-container"> |
| 324 |
<?php |
| 325 |
foreach ($colortags as $ctagk => $ctagv) { |
| 326 |
?> |
| 327 |
<div class="vbo-param-container"> |
| 328 |
<div class="vbo-param-label"><?php echo JText::translate($ctagv['name']); ?></div> |
| 329 |
<div class="vbo-param-setting"> |
| 330 |
<div class="vbo-colortag-square" style="background-color: <?php echo $ctagv['color']; ?>; color: <?php echo VikBooking::getBestColorContrast($ctagv['color']); ?>;"><i class="vboicn-price-tags"></i></div> |
| 331 |
<input type="hidden" name="bctagname[]" class="bctagname" value="<?php echo $ctagv['name']; ?>" /> |
| 332 |
<input type="hidden" name="bctagcolor[]" class="bctagcolor" value="<?php echo $ctagv['color']; ?>" /> |
| 333 |
<select name="bctagrule[]" style="margin: 0; vertical-align: top;"> |
| 334 |
<?php |
| 335 |
foreach ($tagsrules as $tagk => $tagv) { |
| 336 |
?> |
| 337 |
<option value="<?php echo $tagk; ?>"<?php echo !empty($tagk) && $tagk == $ctagv['rule'] ? ' selected="selected"' : ''; ?>><?php echo JText::translate($tagv); ?></option> |
| 338 |
<?php |
| 339 |
} |
| 340 |
?> |
| 341 |
</select> |
| 342 |
<div style="float: right;"><button class="btn btn-danger vbo-colortag-rm" type="button">×</button></div> |
| 343 |
</div> |
| 344 |
</div> |
| 345 |
<?php |
| 346 |
} |
| 347 |
?> |
| 348 |
<div class="vbo-param-container" id="vbo-colortag-lasttr"> |
| 349 |
<div class="vbo-param-label"><button class="btn vbo-colortag-add" type="button"><?php VikBookingIcons::e('plus-circle'); ?> <?php echo JText::translate('VBOCOLORTAGADD'); ?></button></div> |
| 350 |
<div class="vbo-param-setting"> </div> |
| 351 |
</div> |
| 352 |
<div class="vbo-param-container"> |
| 353 |
<div class="vbo-param-label"><a class="btn btn-danger" href="index.php?option=com_vikbooking&task=config&reset_tags=1" onclick="return confirm('<?php echo addslashes(JText::translate('VBDELCONFIRM')); ?>');"><i class="icon-remove"></i> <?php echo JText::translate('VBOCOLORTAGRMALL'); ?></a></div> |
| 354 |
<div class="vbo-param-setting"> </div> |
| 355 |
</div> |
| 356 |
</div> |
| 357 |
</a> |
| 358 |
</fieldset> |
| 359 |
</div> |
| 360 |
|
| 361 |
<script type="text/javascript"> |
| 362 |
var vboHexDigits = new Array ("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"); |
| 363 |
|
| 364 |
function vboRgb2Hex(rgb) { |
| 365 |
var rgb_match = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)$/); |
| 366 |
if (!rgb_match) { |
| 367 |
return rgb; |
| 368 |
} |
| 369 |
return "#" + vboHex(rgb_match[1]) + vboHex(rgb_match[2]) + vboHex(rgb_match[3]); |
| 370 |
} |
| 371 |
|
| 372 |
function vboHex(x) { |
| 373 |
return isNaN(x) ? "00" : vboHexDigits[(x - x % 16) / 16] + vboHexDigits[x % 16]; |
| 374 |
} |
| 375 |
|
| 376 |
jQuery(function() { |
| 377 |
|
| 378 |
jQuery('.vbo-edit-tmpl').click(function() { |
| 379 |
let vbo_tmpl_path = jQuery(this).attr('data-tmpl-path'); |
| 380 |
let vbo_prew_path = jQuery(this).attr('data-prew-path'); |
| 381 |
if (!vbo_tmpl_path && !vbo_prew_path) { |
| 382 |
return; |
| 383 |
} |
| 384 |
let basetask = !vbo_tmpl_path ? 'tmplfileprew' : 'edittmplfile'; |
| 385 |
let basepath = !vbo_tmpl_path ? vbo_prew_path : vbo_tmpl_path; |
| 386 |
let base_ajax = '<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=edittmplfile'); ?>'; |
| 387 |
let ajax_uri = base_ajax.replace('edittmplfile', basetask); |
| 388 |
|
| 389 |
// define the modal cancel button |
| 390 |
let cancel_btn = jQuery('<button></button>') |
| 391 |
.attr('type', 'button') |
| 392 |
.addClass('btn') |
| 393 |
.text(Joomla.JText._('VBANNULLA')) |
| 394 |
.on('click', () => { |
| 395 |
VBOCore.emitEvent('vbo-edit-tmplfile-dismiss'); |
| 396 |
}); |
| 397 |
|
| 398 |
let apply_btn = jQuery('<button></button>') |
| 399 |
.attr('type', 'button') |
| 400 |
.addClass('btn btn-success') |
| 401 |
.text(Joomla.JText._('VBOSAVETMPLFILE')) |
| 402 |
.on('click', () => { |
| 403 |
// start loading |
| 404 |
VBOCore.emitEvent('vbo-edit-tmplfile-loading'); |
| 405 |
|
| 406 |
/** |
| 407 |
* On some CMSs, the real textarea may not update with the new codemirror content |
| 408 |
* and so we force the update of the textarea before submitting the form. |
| 409 |
*/ |
| 410 |
try { |
| 411 |
let is_wp = <?php echo VBOPlatformDetection::isWordPress() ? 'true' : 'false'; ?>; |
| 412 |
if (is_wp) { |
| 413 |
Joomla.editors.instances['vik_editor_cont'].element.codemirror.save(); |
| 414 |
} else { |
| 415 |
Joomla.editors.instances['vik_editor_cont'].save(); |
| 416 |
} |
| 417 |
} catch (err) { |
| 418 |
console.error(err); |
| 419 |
} |
| 420 |
|
| 421 |
// get the content from the editor |
| 422 |
let editor_element = document.querySelector('[name="cont"]'); |
| 423 |
let editor_content = editor_element ? editor_element.value : ''; |
| 424 |
|
| 425 |
if (!editor_content) { |
| 426 |
alert('No source code found'); |
| 427 |
return false; |
| 428 |
} |
| 429 |
|
| 430 |
VBOCore.doAjax( |
| 431 |
"<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=savetmplfile'); ?>", |
| 432 |
{ |
| 433 |
path: basepath, |
| 434 |
ajax: 1, |
| 435 |
cont: editor_content, |
| 436 |
}, |
| 437 |
(response) => { |
| 438 |
// stop loading |
| 439 |
VBOCore.emitEvent('vbo-edit-tmplfile-loading'); |
| 440 |
|
| 441 |
let message = 'Success!'; |
| 442 |
try { |
| 443 |
let data = typeof response === 'string' ? JSON.parse(response) : response; |
| 444 |
message = data.message; |
| 445 |
} catch(e) { |
| 446 |
// do nothing |
| 447 |
} |
| 448 |
|
| 449 |
VBOToast.enqueue(new VBOToastMessage({ |
| 450 |
body: message, |
| 451 |
icon: '<?php echo VikBookingIcons::i('check-circle'); ?>', |
| 452 |
status: VBOToast.SUCCESS_STATUS, |
| 453 |
action: () => { |
| 454 |
VBOToast.dispose(true); |
| 455 |
}, |
| 456 |
})); |
| 457 |
}, |
| 458 |
(error) => { |
| 459 |
// stop loading |
| 460 |
VBOCore.emitEvent('vbo-edit-tmplfile-loading'); |
| 461 |
alert(error.responseText); |
| 462 |
} |
| 463 |
); |
| 464 |
}); |
| 465 |
|
| 466 |
let modal_body = VBOCore.displayModal({ |
| 467 |
extra_class: 'vbo-modal-large' + (!vbo_tmpl_path ? ' vbo-modal-nofooter' : ''), |
| 468 |
lock_scroll: true, |
| 469 |
// prepend to body to let the toast br visible as z-index |
| 470 |
body_prepend: true, |
| 471 |
title: (vbo_tmpl_path ? Joomla.JText._('VBOCONFIGEDITTMPLFILE') : Joomla.JText._('VBOPREVIEW')), |
| 472 |
dismiss_event: 'vbo-edit-tmplfile-dismiss', |
| 473 |
loading_event: 'vbo-edit-tmplfile-loading', |
| 474 |
footer_left: (vbo_tmpl_path ? cancel_btn : null), |
| 475 |
footer_right: (vbo_tmpl_path ? apply_btn : null), |
| 476 |
onDismiss: () => { |
| 477 |
VBOCore.emitEvent('vbo-dismiss-modal-tmplfile'); |
| 478 |
}, |
| 479 |
}); |
| 480 |
|
| 481 |
// start loading |
| 482 |
VBOCore.emitEvent('vbo-edit-tmplfile-loading'); |
| 483 |
|
| 484 |
// make the AJAX request to obtain the modal body |
| 485 |
VBOCore.doAjax( |
| 486 |
ajax_uri, |
| 487 |
{ |
| 488 |
path: basepath, |
| 489 |
ajax: 1, |
| 490 |
tmpl: 'component', |
| 491 |
}, |
| 492 |
(response) => { |
| 493 |
// stop loading |
| 494 |
VBOCore.emitEvent('vbo-edit-tmplfile-loading'); |
| 495 |
|
| 496 |
let html = response; |
| 497 |
|
| 498 |
try { |
| 499 |
html = typeof response === 'string' ? JSON.parse(response) : response; |
| 500 |
html = html[0]; |
| 501 |
} catch(e) { |
| 502 |
// do nothing |
| 503 |
} |
| 504 |
|
| 505 |
modal_body.append(html); |
| 506 |
}, |
| 507 |
(error) => { |
| 508 |
// stop loading |
| 509 |
VBOCore.emitEvent('vbo-edit-tmplfile-loading'); |
| 510 |
// log and display error |
| 511 |
console.error(error); |
| 512 |
alert(error.responseText); |
| 513 |
} |
| 514 |
); |
| 515 |
}); |
| 516 |
|
| 517 |
jQuery(".vbo-colortag-add").click(function() { |
| 518 |
jQuery("#vbo-colortag-lasttr").before( |
| 519 |
"<div class=\"vbo-param-container\">"+ |
| 520 |
"<div class=\"vbo-param-label\"> <input type=\"text\" name=\"bctagname[]\" class=\"bctagname\" value=\"\" placeholder=\"<?php echo addslashes(JText::translate('VBOCOLORTAGADDPLCHLD')); ?>\" size=\"25\" /> </div>"+ |
| 521 |
"<div class=\"vbo-param-setting\">"+ |
| 522 |
"<div class=\"vbo-colortag-square\" style=\"\"><i class=\"vboicn-price-tags\"></i></div>"+ |
| 523 |
"<input type=\"hidden\" name=\"bctagcolor[]\" class=\"bctagcolor\" value=\"#ffffff\" />"+ |
| 524 |
"<select name=\"bctagrule[]\" style=\"margin: 0; vertical-align: top;\"><?php echo $opt_js_rules; ?></select>"+ |
| 525 |
"<div style=\"float: right;\"><button class=\"btn btn-danger vbo-colortag-rm\" type=\"button\">×</button></div>"+ |
| 526 |
"</div>"+ |
| 527 |
"</div>" |
| 528 |
); |
| 529 |
jQuery('.vbo-colortag-square').ColorPicker({ |
| 530 |
color: '#ffffff', |
| 531 |
onShow: function (colpkr, el) { |
| 532 |
var cur_color = jQuery(el).css('backgroundColor'); |
| 533 |
jQuery(el).ColorPickerSetColor(vboRgb2Hex(cur_color)); |
| 534 |
jQuery(colpkr).show(); |
| 535 |
return false; |
| 536 |
}, |
| 537 |
onChange: function (hsb, hex, rgb, el) { |
| 538 |
jQuery(el).css('backgroundColor', '#'+hex); |
| 539 |
jQuery(el).parent().find('.bctagcolor').val('#'+hex); |
| 540 |
}, |
| 541 |
onSubmit: function(hsb, hex, rgb, el) { |
| 542 |
jQuery(el).css('backgroundColor', '#'+hex); |
| 543 |
jQuery(el).parent().find('.bctagcolor').val('#'+hex); |
| 544 |
jQuery(el).ColorPickerHide(); |
| 545 |
}, |
| 546 |
}); |
| 547 |
}); |
| 548 |
|
| 549 |
jQuery(document.body).on('click', '.vbo-colortag-rm', function() { |
| 550 |
jQuery(this).closest('.vbo-param-container').remove(); |
| 551 |
}); |
| 552 |
|
| 553 |
jQuery('.vbo-colortag-square').ColorPicker({ |
| 554 |
color: '#ffffff', |
| 555 |
onShow: function (colpkr, el) { |
| 556 |
var cur_color = jQuery(el).css('backgroundColor'); |
| 557 |
jQuery(el).ColorPickerSetColor(vboRgb2Hex(cur_color)); |
| 558 |
jQuery(colpkr).show(); |
| 559 |
return false; |
| 560 |
}, |
| 561 |
onChange: function (hsb, hex, rgb, el) { |
| 562 |
jQuery(el).css('backgroundColor', '#'+hex); |
| 563 |
jQuery(el).parent().find('.bctagcolor').val('#'+hex); |
| 564 |
}, |
| 565 |
onSubmit: function(hsb, hex, rgb, el) { |
| 566 |
jQuery(el).css('backgroundColor', '#'+hex); |
| 567 |
jQuery(el).parent().find('.bctagcolor').val('#'+hex); |
| 568 |
jQuery(el).ColorPickerHide(); |
| 569 |
}, |
| 570 |
}); |
| 571 |
}); |
| 572 |
</script> |
| 573 |
|