64eade2589
- Remove update-server.yml — MokoGitea generates update feed dynamically - Remove static updates.xml — no longer needed - Fix cache cleaner CSRF: send token as POST FormData - Update CHANGELOG.md with all 02.33.00 changes Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
74 lines
1.9 KiB
PHP
74 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* MokoWaaS Cache Cleaner — status bar module
|
|
*
|
|
* One-click button in the admin status bar that clears all Joomla cache.
|
|
* Uses native Atum header-item markup.
|
|
*/
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\Session\Session;
|
|
use Joomla\CMS\Language\Text;
|
|
|
|
$token = Session::getFormToken();
|
|
$ajaxUrl = 'index.php?option=com_mokowaas&task=clearCache&format=json';
|
|
?>
|
|
|
|
<a href="#" class="header-item-content" title="<?php echo Text::_('MOD_MOKOWAAS_CACHE_CLEAR_ALL'); ?>" id="mokowaas-clear-cache">
|
|
<div class="header-item-icon">
|
|
<span class="icon-bolt" aria-hidden="true" id="mokowaas-cache-icon"></span>
|
|
</div>
|
|
<div class="header-item-text">
|
|
<?php echo Text::_('MOD_MOKOWAAS_CACHE'); ?>
|
|
</div>
|
|
</a>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
var btn = document.getElementById('mokowaas-clear-cache');
|
|
var icon = document.getElementById('mokowaas-cache-icon');
|
|
if (!btn || !icon) return;
|
|
|
|
btn.addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
if (btn.dataset.busy) return;
|
|
btn.dataset.busy = '1';
|
|
icon.className = 'icon-spinner icon-spin';
|
|
|
|
var formData = new FormData();
|
|
formData.append('<?php echo $token; ?>', '1');
|
|
|
|
fetch('<?php echo $ajaxUrl; ?>', {
|
|
method: 'POST',
|
|
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
|
body: formData
|
|
})
|
|
.then(function(r) { return r.json(); })
|
|
.then(function(data) {
|
|
if (data.success) {
|
|
icon.className = 'icon-check';
|
|
icon.style.color = '#198754';
|
|
} else {
|
|
icon.className = 'icon-times';
|
|
icon.style.color = '#dc3545';
|
|
}
|
|
setTimeout(function() {
|
|
icon.className = 'icon-bolt';
|
|
icon.style.color = '';
|
|
delete btn.dataset.busy;
|
|
}, 2000);
|
|
})
|
|
.catch(function() {
|
|
icon.className = 'icon-times';
|
|
icon.style.color = '#dc3545';
|
|
setTimeout(function() {
|
|
icon.className = 'icon-bolt';
|
|
icon.style.color = '';
|
|
delete btn.dataset.busy;
|
|
}, 2000);
|
|
});
|
|
});
|
|
});
|
|
</script>
|