PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / trunk
VikAppointments Services Booking Calendar vtrunk
trunk 1.2.17 1.2.18 1.2.19
vikappointments / libraries / html / rss / config.php
vikappointments / libraries / html / rss Last commit date
optin 4 years ago config.php 4 years ago feed.php 5 months ago optin.php 5 months ago
config.php
126 lines
1 <?php
2 /**
3 * @package VikAppointments - Libraries
4 * @subpackage html.rss
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 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 $vik = VAPApplication::getInstance();
18
19 ?>
20
21 <a name="rss"></a>
22
23 <div class="config-fieldset">
24
25 <div class="config-fieldset-head">
26 <h3><?php echo __('Settings', 'vikappointments'); ?></h3>
27 </div>
28
29 <div class="config-fieldset-body">
30
31 <!-- OPT IN - Checkbox -->
32
33 <?php
34 $yes = $vik->initRadioElement('', '', $config['optin'], 'onclick="rssOptinValueChanged(1);"');
35 $no = $vik->initRadioElement('', '', !$config['optin'], 'onclick="rssOptinValueChanged(0);"');
36
37 echo $vik->openControl(__('Enable RSS Service', 'vikappointments'));
38 echo $vik->radioYesNo('rss_optin_status', $yes, $no);
39 echo $vik->closeControl();
40 ?>
41
42 <!-- DISPLAY DASHBOARD - Select -->
43
44 <?php
45 $control = array();
46 $control['style'] = $config['optin'] ? '' : 'display:none;';
47
48 $yes = $vik->initRadioElement('', '', $config['dashboard']);
49 $no = $vik->initRadioElement('', '', !$config['dashboard']);
50
51 echo $vik->openControl(__('Display on Dashboard', 'vikappointments'), 'rss-child-setting', $control);
52 echo $vik->radioYesNo('rss_display_dashboard', $yes, $no);
53 echo $vik->closeControl();
54 ?>
55
56 </div>
57
58 </div>
59
60 <?php
61 // allow channels management for PRO licenses
62 if (VikAppointmentsLicense::isPro())
63 {
64 ?>
65 <div class="config-fieldset rss-child-setting" style="<?php echo $config['optin'] ? '' : 'display:none;'; ?>">
66
67 <div class="config-fieldset-head">
68 <h3><?php echo __('Channels', 'vikappointments'); ?></h3>
69 </div>
70
71 <div class="config-fieldset-body">
72 <?php
73 // iterate supported channels
74 foreach ($channels as $label => $url)
75 {
76 $checked = in_array($url, (array) $config['channels']);
77
78 $yes = $vik->initRadioElement('', '', $checked, 'onclick="rssChannelValueChanged(1, \'' . $url . '\');"');
79 $no = $vik->initRadioElement('', '', !$checked, 'onclick="rssChannelValueChanged(0, \'' . $url . '\');"');
80
81 echo $vik->openControl(ucwords($label), 'rss-child-setting', $control);
82
83 echo $vik->radioYesNo('rss_channel_' . md5($url), $yes, $no);
84
85 if ($checked)
86 {
87 ?>
88 <input type="hidden" name="rss_channel_url[]" value="<?php echo $url; ?>" />
89 <?php
90 }
91
92 echo $vik->closeControl();
93 }
94 ?>
95 </div>
96
97 </div>
98 <?php
99 }
100 ?>
101
102 <script>
103
104 // toggle RSS settings according to the opt-in choice
105 function rssOptinValueChanged(is) {
106 if (is) {
107 jQuery('.rss-child-setting').show();
108 } else {
109 jQuery('.rss-child-setting').hide();
110 }
111 }
112
113 // toggle RSS channel according to the checkbox status
114 function rssChannelValueChanged(is, url) {
115 // get existing input URL
116 var urlInput = jQuery('input[name="rss_channel_url[]"][value="' + url + '"]');
117
118 if (is && urlInput.length == 0) {
119 jQuery('#adminForm').append('<input type="hidden" name="rss_channel_url[]" value="' + url + '" />');
120 } else {
121 urlInput.remove();
122 }
123 }
124
125 </script>
126