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 / views / managefile / tmpl / default.php
vikappointments / admin / views / managefile / tmpl Last commit date
default.php 4 days ago index.html 4 days ago
default.php
178 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 $vik = VAPApplication::getInstance();
15
16 $code_mirror = $vik->getCodeMirror('content', $this->content);
17
18 $data = array(
19 'name' => basename($this->file),
20 'path' => $this->file,
21 'base64' => base64_encode($this->file),
22 );
23
24 ?>
25
26 <form action="index.php" method="POST" name="adminForm" id="adminForm">
27
28 <?php
29 if ($this->blank)
30 {
31 ?>
32 <div class="btn-toolbar" style="display:none;">
33 <div class="btn-group pull-left">
34 <button type="button" class="btn btn-success" name="tmplSaveButton" onclick="fileSaveButtonPressed(this);">
35 <i class="icon-apply"></i>&nbsp;<?php echo JText::translate('VAPSAVE'); ?>
36 </button>
37
38 <button type="button" class="btn btn-success" name="tmplSaveCopyButton" onclick="fileSaveAsCopyButtonPressed(this);">
39 <i class="icon-save-copy"></i>&nbsp;<?php echo JText::translate('VAPSAVEASCOPY'); ?>
40 </button>
41 </div>
42 </div>
43 <?php
44 }
45 ?>
46
47 <div class="managefile-wrapper" style="padding:0 10px;">
48
49 <h3><?php echo basename($this->file); ?></h3>
50
51 <div class="vap-file-box">
52 <?php echo $code_mirror; ?>
53 </div>
54
55 </div>
56
57 <?php echo JHtml::fetch('form.token'); ?>
58
59 <input type="hidden" name="file" value="<?php echo base64_encode($this->file); ?>" />
60 <input type="hidden" name="task" value="" />
61 <input type="hidden" name="option" value="com_vikappointments" />
62
63 <?php
64 if ($this->blank)
65 {
66 ?><input type="hidden" name="tmpl" value="component" /><?php
67 }
68 ?>
69
70 </form>
71
72 <?php
73 JText::script('VAPNEWFILENAMETITLE');
74 ?>
75
76 <script>
77
78 function fileSaveButtonPressed(button) {
79 if (jQuery(button).prop('disabled')) {
80 // button already submitted
81 return false;
82 }
83
84 // disable button
85 jQuery(button).prop('disabled', true);
86
87 <?php
88 /**
89 * In WordPress the codemirror seems to have rendering problems while
90 * initialized on a hidden panel. For this reason, we need to refresh
91 * its contents when the modal is displayed.
92 * @wponly
93 */
94 if (VersionListener::isWordpress())
95 {
96 ?>
97 Joomla.editors.instances.content.element.codemirror.save();
98 <?php
99 }
100 ?>
101
102 Joomla.submitform('file.save', document.adminForm);
103 }
104
105 function fileSaveAsCopyButtonPressed(button) {
106 if (jQuery(button).prop('disabled')) {
107 // button already submitted
108 return false;
109 }
110
111 // disable button
112 jQuery(button).prop('disabled', true);
113
114 // ask for the new name
115 var name = prompt(Joomla.JText._('VAPNEWFILENAMETITLE'), 'file.php');
116
117 if (!name) {
118 // enable button
119 jQuery(button).prop('disabled', false);
120
121 // invalid name or aborted
122 return false;
123 }
124
125 <?php
126 /**
127 * In WordPress the codemirror seems to have rendering problems while
128 * initialized on a hidden panel. For this reason, we need to refresh
129 * its contents when the modal is displayed.
130 * @wponly
131 */
132 if (VersionListener::isWordpress())
133 {
134 ?>
135 Joomla.editors.instances.content.element.codemirror.save();
136 <?php
137 }
138 ?>
139
140 if (!name.match(/\.php$/i)) {
141 // append ".php" if not specified
142 name += '.php';
143 }
144
145 jQuery('#adminForm').append('<input type="hidden" name="dir" value="<?php echo base64_encode(dirname($this->file)); ?>" />');
146 jQuery('#adminForm').append('<input type="hidden" name="filename" value="' + name + '" />');
147
148 Joomla.submitform('file.savecopy', document.adminForm);
149 }
150
151 <?php
152 if ($this->blank)
153 {
154 ?>
155 // transfer submit buttons instances to parent for being clicked
156 window.parent.modalFileSaveButton = document.adminForm.tmplSaveButton;
157 window.parent.modalFileSaveCopyButton = document.adminForm.tmplSaveCopyButton;
158
159 // transfer saved file path to parent
160 window.parent.modalSavedFile = <?php echo json_encode($data); ?>;
161 <?php
162 }
163 else
164 {
165 ?>
166 Joomla.submitbutton = function(task) {
167 if (task == 'file.savecopy') {
168 fileSaveAsCopyButtonPressed(null);
169 } else {
170 Joomla.submitform(task, document.adminForm);
171 }
172 }
173 <?php
174 }
175 ?>
176
177 </script>
178