| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking - Libraries |
| 4 |
* @subpackage html.rss |
| 5 |
* @author E4J s.r.l. |
| 6 |
* @copyright Copyright (C) 2018 E4J s.r.l. All Rights Reserved. |
| 7 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// No direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
$config = !empty($displayData['config']) ? $displayData['config'] : null; |
| 15 |
$channels = !empty($displayData['channels']) ? $displayData['channels'] : array(); |
| 16 |
|
| 17 |
?> |
| 18 |
|
| 19 |
<a name="rss"></a> |
| 20 |
|
| 21 |
<div class="vbo-params-container"> |
| 22 |
|
| 23 |
<!-- OPT IN - Checkbox --> |
| 24 |
<div class="vbo-param-container"> |
| 25 |
<div class="vbo-param-label"><?php echo __('Enable RSS Service', 'vikbooking'); ?></div> |
| 26 |
<div class="vbo-param-setting"> |
| 27 |
<?php |
| 28 |
$cur_opt_in_status = (isset($config) && isset($config['optin']) ? (int)$config['optin'] : 0); |
| 29 |
echo VikBooking::getVboApplication()->printYesNoButtons('rss_optin_status', __('Yes', 'vikbooking'), __('No', 'vikbooking'), $cur_opt_in_status, 1, 0, 'rssOptinValueChanged(this.checked);'); |
| 30 |
?> |
| 31 |
</div> |
| 32 |
</div> |
| 33 |
|
| 34 |
<!-- DISPLAY DASHBOARD - Select --> |
| 35 |
<div class="vbo-param-container rss-child-setting" style="<?php echo $config['optin'] ? '' : 'display:none;'; ?>"> |
| 36 |
<div class="vbo-param-label"><?php echo __('Display on Dashboard', 'vikbooking'); ?></div> |
| 37 |
<div class="vbo-param-setting"> |
| 38 |
<?php |
| 39 |
echo VikBooking::getVboApplication()->printYesNoButtons('rss_display_dashboard', __('Yes', 'vikbooking'), __('No', 'vikbooking'), (isset($config) && isset($config['dashboard']) ? (int)$config['dashboard'] : 0), 1, 0); |
| 40 |
?> |
| 41 |
</div> |
| 42 |
</div> |
| 43 |
|
| 44 |
<?php |
| 45 |
// allow channels management for PRO licenses |
| 46 |
if (VikBookingLicense::isPro()) |
| 47 |
{ |
| 48 |
// iterate supported channels |
| 49 |
foreach ($channels as $label => $url) |
| 50 |
{ |
| 51 |
$checked = in_array($url, (array) $config['channels']); |
| 52 |
|
| 53 |
?> |
| 54 |
<div class="vbo-param-container rss-child-setting" style="<?php echo $config['optin'] ? '' : 'display:none;'; ?>"> |
| 55 |
<div class="vbo-param-label"><?php echo ucwords($label); ?></div> |
| 56 |
<div class="vbo-param-setting"> |
| 57 |
<?php |
| 58 |
echo VikBooking::getVboApplication()->printYesNoButtons('rss_channel_' . md5($url), __('Yes', 'vikbooking'), __('No', 'vikbooking'), (int)$checked, 1, 0, 'rssChannelValueChanged(this.checked, \'' . $url . '\');'); |
| 59 |
|
| 60 |
if ($checked) |
| 61 |
{ |
| 62 |
?> |
| 63 |
<input type="hidden" name="rss_channel_url[]" value="<?php echo $url; ?>" /> |
| 64 |
<?php |
| 65 |
} |
| 66 |
?> |
| 67 |
</div> |
| 68 |
</div> |
| 69 |
<?php |
| 70 |
|
| 71 |
} |
| 72 |
} |
| 73 |
?> |
| 74 |
|
| 75 |
</div> |
| 76 |
|
| 77 |
<script> |
| 78 |
|
| 79 |
// toggle RSS settings according to the opt-in choice |
| 80 |
function rssOptinValueChanged(is) { |
| 81 |
if (is) { |
| 82 |
jQuery('.rss-child-setting').show(); |
| 83 |
} else { |
| 84 |
jQuery('.rss-child-setting').hide(); |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
// toggle RSS channel according to the checkbox status |
| 89 |
function rssChannelValueChanged(is, url) { |
| 90 |
// get existing input URL |
| 91 |
var urlInput = jQuery('input[name="rss_channel_url[]"][value="' + url + '"]'); |
| 92 |
|
| 93 |
if (is && urlInput.length == 0) { |
| 94 |
jQuery('#adminForm').append('<input type="hidden" name="rss_channel_url[]" value="' + url + '" />'); |
| 95 |
} else { |
| 96 |
urlInput.remove(); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
</script> |
| 101 |
|