PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / layouts / menu / leftboard / custom / version.php
vikappointments / admin / layouts / menu / leftboard / custom Last commit date
index.html 5 days ago license.php 5 days ago line.php 5 days ago split.php 5 days ago version.php 5 days ago
version.php
182 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
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 extract($displayData);
15
16 /**
17 * Layout variables
18 * -----------------
19 * @var boolean $newupdate True if there is a new available update.
20 * @var boolean $vikupdater True if VikUpdater plugin is active.
21 * @var boolean $connect True to auto-search for new updates.
22 * @var string $url The fallback remote URL.
23 * @var string $title The item title.
24 * @var string $label The item label.
25 */
26
27 JText::script('VAPCHECKINGVERSION');
28 JText::script('ERROR');
29
30 ?>
31
32 <div class="version-box custom<?php echo $newupdate ? ' upd-avail' : ''; ?>">
33
34 <?php
35 if ($vikupdater)
36 {
37 $url = 'index.php?option=com_vikappointments&task=updateprogram.checkversion';
38 $url = VAPApplication::getInstance()->ajaxUrl($url);
39
40 // VikUpdater plugin is enabled
41
42 $document = JFactory::getDocument();
43 $document->addScriptDeclaration(
44 <<<JS
45 function callVersionChecker() {
46 setVersionContent(Joomla.JText._('VAPCHECKINGVERSION'));
47
48 UIAjax.do(
49 '{$url}',
50 {},
51 (obj) => {
52 console.log(obj);
53
54 if (obj["status"] == 1) {
55
56 if (obj.response.status == 1) {
57
58 if (obj.response.compare == 1) {
59 jQuery("#vap-versioncheck-link").attr("onclick", "");
60 jQuery("#vap-versioncheck-link").attr("href", "index.php?option=com_vikappointments&view=updateprogram");
61
62 obj.response.shortTitle += '<i class="upd-avail fas fa-exclamation-triangle"></i>';
63
64 jQuery(".version-box.custom").addClass("upd-avail");
65 }
66
67 setVersionContent(obj.response.shortTitle, obj.response.title);
68
69 } else {
70 console.log(obj.response.error);
71 setVersionContent(Joomla.JText._('ERROR'));
72 }
73
74 } else {
75 console.log("plugin disabled");
76 setVersionContent(Joomla.JText._('ERROR'));
77 }
78 },
79 (err) => {
80 console.log(resp);
81 setVersionContent(Joomla.JText._('ERROR'));
82 }
83 );
84 }
85
86 function setVersionContent(cont, title) {
87 jQuery("#vap-version-content").html(cont);
88
89 if (title === undefined) {
90 var title = "";
91 }
92
93 jQuery("#vap-version-content").attr("title", title);
94 }
95 JS
96 );
97
98 if ($connect)
99 {
100 $document->addScriptDeclaration(
101 <<<JS
102 jQuery(function() {
103 callVersionChecker();
104 });
105 JS
106 );
107 }
108 ?>
109 <a
110 href="<?php echo ($newupdate ? 'index.php?option=com_vikappointments&view=updateprogram' : 'javascript:void(0)'); ?>"
111 onclick="<?php echo ($newupdate ? '' : 'callVersionChecker();'); ?>"
112 id="vap-versioncheck-link"
113 >
114 <i class="fas fa-rocket"></i>
115 <span id="vap-version-content" title="<?php echo $title; ?>">
116 <?php
117 echo $label;
118
119 if ($newupdate)
120 {
121 ?><i class="upd-avail fas fa-exclamation-triangle"></i><?php
122 }
123 ?>
124 </span>
125 </a>
126 <?php
127 }
128 else
129 {
130 echo JHtml::fetch(
131 'bootstrap.renderModal',
132 'jmodal-version-check',
133 array(
134 'title' => $label,
135 'closeButton' => true,
136 'keyboard' => true,
137 'bodyHeight' => 80,
138 'url' => $url,
139 'footer' => '<button type="button" class="btn btn-success" id="version-check-install">' . JText::translate('JTOOLBAR_INSTALL') . '</button>',
140 )
141 );
142
143 ?>
144 <a id="vcheck" href="javascript:void(0)">
145 <i class="fas fa-rocket"></i>
146 <span><?php echo $label; ?></span>
147 </a>
148
149 <script>
150 (function($) {
151 'use strict';
152
153 $(function() {
154 $('#vcheck').on('click', () => {
155 let id = 'version-check';
156 let url = null;
157 let jqmodal = true;
158
159 <?php echo VAPApplication::getInstance()->bootOpenModalJS(); ?>
160 });
161
162 $('#version-check-install').on('click', () => {
163
164 const form = $('<form action="index.php?option=com_installer&task=install.install" method="post"></form>');
165
166 form.append('<input type="hidden" name="installtype" value="url" />');
167 form.append('<input type="hidden" name="install_url" value="https://extensionsforjoomla.com/vikapi/?task=products.freedownload&sku=vup" />');
168 form.append('<input type="hidden" name="return" value="<?php echo base64_encode(JUri::getInstance()); ?>" />');
169 form.append('<?php echo JHtml::fetch('form.token'); ?>');
170
171 $('body').append(form);
172
173 form.submit();
174 });
175 });
176 })(jQuery);
177 </script>
178 <?php
179 }
180 ?>
181
182 </div>