default.php
3 days ago
default_api.php
3 days ago
default_api_basic.php
3 days ago
default_api_users.php
3 days ago
default_backup.php
3 days ago
default_backup_basic.php
3 days ago
default_customizer.php
3 days ago
default_customizer_addcss.php
3 days ago
default_customizer_form.php
3 days ago
default_customizer_preview.php
3 days ago
default_customizer_toolbar.php
3 days ago
default_webhooks.php
3 days ago
default_webhooks_basic.php
3 days ago
index.html
3 days ago
default_backup_basic.php
188 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 | $config = $this->config; |
| 15 | |
| 16 | $vik = VAPApplication::getInstance(); |
| 17 | |
| 18 | /** |
| 19 | * Trigger event to display custom HTML. |
| 20 | * In case it is needed to include any additional fields, |
| 21 | * it is possible to create a plugin and attach it to an event |
| 22 | * called "onDisplayViewConfigappBackupDetails". The event method |
| 23 | * receives the view instance as argument. |
| 24 | * |
| 25 | * @since 1.7.1 |
| 26 | */ |
| 27 | $forms = $this->onDisplayView('BackupDetails'); |
| 28 | |
| 29 | ?> |
| 30 | |
| 31 | <div class="config-fieldset" id="backup-config-panel"> |
| 32 | |
| 33 | <div class="config-fieldset-body"> |
| 34 | |
| 35 | <!-- TYPE - Select --> |
| 36 | |
| 37 | <?php |
| 38 | $options = []; |
| 39 | |
| 40 | foreach ($this->backupExportTypes as $type => $handler) |
| 41 | { |
| 42 | $options[] = JHtml::fetch('select.option', $type, $handler->getName()); |
| 43 | } |
| 44 | |
| 45 | $backup_export_type = $config->get('backuptype', 'full'); |
| 46 | |
| 47 | echo $vik->openControl(JText::translate('VAPBACKUPCONFIG1')); ?> |
| 48 | <select name="backuptype" class="medium-large"> |
| 49 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $backup_export_type); ?> |
| 50 | </select> |
| 51 | <?php |
| 52 | |
| 53 | // display a description for the export types |
| 54 | foreach ($this->backupExportTypes as $type => $handler) |
| 55 | { |
| 56 | echo $vik->alert($handler->getDescription(), 'info', $dismiss = false, [ |
| 57 | 'style' => $type === $backup_export_type ? '' : 'display: none;', |
| 58 | 'id' => 'backup_export_type_' . $type, |
| 59 | ]); |
| 60 | } |
| 61 | |
| 62 | echo $vik->closeControl(); |
| 63 | ?> |
| 64 | |
| 65 | <!-- FOLDER - Text --> |
| 66 | |
| 67 | <?php |
| 68 | $help = $vik->createPopover(array( |
| 69 | 'title' => JText::translate('VAPBACKUPCONFIG2'), |
| 70 | 'content' => JText::translate('VAPBACKUPCONFIG2_HELP'), |
| 71 | )); |
| 72 | |
| 73 | // get saved path |
| 74 | $path = rtrim($config->get('backupfolder', ''), DIRECTORY_SEPARATOR); |
| 75 | |
| 76 | // get system temporary path |
| 77 | $tmp_path = rtrim(JFactory::getApplication()->get('tmp_path', ''), DIRECTORY_SEPARATOR); |
| 78 | |
| 79 | if (!$path) |
| 80 | { |
| 81 | $path = $tmp_path; |
| 82 | } |
| 83 | |
| 84 | echo $vik->openControl(JText::translate('VAPBACKUPCONFIG2') . $help); ?> |
| 85 | <input type="text" name="backupfolder" value="<?php echo $this->escape($path); ?>" size="64" /> |
| 86 | <?php |
| 87 | // check whether the specified path is equals to the temporary path |
| 88 | if ($path === $tmp_path) |
| 89 | { |
| 90 | // inform the administrator that it is not safe to use the temporary path to store the back-up of the system |
| 91 | $warning = JText::sprintf('VAPBACKUPCONFIG2_WARN', $tmp_path . DIRECTORY_SEPARATOR . VikAppointments::generateSerialCode(8)); |
| 92 | echo $vik->alert($warning, 'warning'); |
| 93 | } |
| 94 | |
| 95 | echo $vik->closeControl(); |
| 96 | ?> |
| 97 | |
| 98 | <!-- Define role to detect the supported hook --> |
| 99 | <!-- {"rule":"customizer","event":"onDisplayViewConfigappBackupDetails","key":"basic","type":"field"} --> |
| 100 | |
| 101 | <?php |
| 102 | /** |
| 103 | * Look for any additional fields to be pushed within |
| 104 | * the Backup > Settings > Details fieldset. |
| 105 | * |
| 106 | * @since 1.7.1 |
| 107 | */ |
| 108 | if (isset($forms['basic'])) |
| 109 | { |
| 110 | echo $forms['basic']; |
| 111 | |
| 112 | // unset details form to avoid displaying it twice |
| 113 | unset($forms['basic']); |
| 114 | } |
| 115 | ?> |
| 116 | |
| 117 | <!-- BACK-UP MANAGEMENT - Button --> |
| 118 | |
| 119 | <?php echo $vik->openControl(''); ?> |
| 120 | <a href="index.php?option=com_vikappointments&view=backups" class="btn" id="backup-btn"> |
| 121 | <?php echo JText::translate('VAPCONFIGSEEBACKUP'); ?> |
| 122 | </a> |
| 123 | <?php echo $vik->closeControl(); ?> |
| 124 | |
| 125 | </div> |
| 126 | |
| 127 | </div> |
| 128 | |
| 129 | <!-- Define role to detect the supported hook --> |
| 130 | <!-- {"rule":"customizer","event":"onDisplayViewConfigappBackupDetails","type":"fieldset"} --> |
| 131 | |
| 132 | <?php |
| 133 | // iterate remaining forms to be displayed as new fieldsets |
| 134 | // within the Backup > Settings tab |
| 135 | foreach ($forms as $formTitle => $formHtml) |
| 136 | { |
| 137 | ?> |
| 138 | <div class="config-fieldset"> |
| 139 | |
| 140 | <div class="config-fieldset-head"> |
| 141 | <h3><?php echo JText::translate($formTitle); ?></h3> |
| 142 | </div> |
| 143 | |
| 144 | <div class="config-fieldset-body"> |
| 145 | <?php echo $formHtml; ?> |
| 146 | </div> |
| 147 | |
| 148 | </div> |
| 149 | <?php |
| 150 | } |
| 151 | |
| 152 | JText::script('VAPFORMCHANGEDCONFIRMTEXT'); |
| 153 | ?> |
| 154 | |
| 155 | <script> |
| 156 | |
| 157 | (function($) { |
| 158 | 'use strict'; |
| 159 | |
| 160 | $(function() { |
| 161 | $('select[name="backuptype"]').on('change', function() { |
| 162 | const type = $(this).val(); |
| 163 | |
| 164 | $('#adminForm *[id^="backup_export_type_"]').hide(); |
| 165 | $('#backup_export_type_' + type).show(); |
| 166 | }); |
| 167 | |
| 168 | $('#backup-btn').on('click', (event) => { |
| 169 | if (!configObserver.isChanged()) { |
| 170 | // nothing has changed, go ahead |
| 171 | return true; |
| 172 | } |
| 173 | |
| 174 | // ask for a confirmation |
| 175 | let r = confirm(Joomla.JText._('VAPFORMCHANGEDCONFIRMTEXT')); |
| 176 | |
| 177 | if (!r) { |
| 178 | // do not leave the page |
| 179 | event.preventDefault(); |
| 180 | event.stopPropagation(); |
| 181 | return false; |
| 182 | } |
| 183 | }); |
| 184 | }); |
| 185 | })(jQuery); |
| 186 | |
| 187 | </script> |
| 188 |