2026-06-15 05:19:13 -05:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* MokoSuiteClient Cache & Temp Cleaner — status bar split button
|
|
|
|
|
*
|
|
|
|
|
* Displays "Clear: Cache | Temp" as a single header item with two
|
|
|
|
|
* clickable halves. Uses native Atum header-item markup.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
|
|
|
|
use Joomla\CMS\Session\Session;
|
|
|
|
|
|
|
|
|
|
$token = Session::getFormToken();
|
2026-06-23 11:47:06 -05:00
|
|
|
$cacheUrl = 'index.php?option=com_mokosuiteclient&task=display.clearCache&format=json';
|
|
|
|
|
$tempUrl = 'index.php?option=com_mokosuiteclient&task=display.clearTemp&format=json';
|
2026-06-20 22:10:56 -05:00
|
|
|
$domain = $domain ?? '';
|
2026-06-15 05:19:13 -05:00
|
|
|
?>
|
|
|
|
|
|
2026-06-23 11:47:42 -05:00
|
|
|
<div class="header-item">
|
2026-06-23 12:29:53 -05:00
|
|
|
<div class="header-item-content d-flex align-items-center gap-0" style="padding:0;">
|
|
|
|
|
<?php if ($domain): ?>
|
|
|
|
|
<a href="#" class="btn btn-sm btn-outline-secondary rounded-0 rounded-start border-end-0 d-flex align-items-center gap-1 px-3 py-2" id="mokosuiteclient-domain" title="Support key — click to copy" style="font-size:0.8rem;">
|
|
|
|
|
<span class="icon-key" aria-hidden="true"></span> <?php echo htmlspecialchars($domain); ?>
|
|
|
|
|
</a>
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
<a href="#" class="btn btn-sm btn-outline-primary <?php echo $domain ? 'rounded-0 border-end-0' : 'rounded-0 rounded-start border-end-0'; ?> d-flex align-items-center gap-1 px-3 py-2" id="mokosuiteclient-clear-cache" title="Clear all Joomla cache" style="font-size:0.8rem;">
|
|
|
|
|
<span class="icon-bolt" aria-hidden="true" id="mokosuiteclient-cache-icon"></span> Cache
|
|
|
|
|
</a>
|
|
|
|
|
<a href="#" class="btn btn-sm btn-outline-danger rounded-0 rounded-end d-flex align-items-center gap-1 px-3 py-2" id="mokosuiteclient-clear-temp" title="Clear temp directory" style="font-size:0.8rem;">
|
|
|
|
|
<span class="icon-trash" aria-hidden="true" id="mokosuiteclient-temp-icon"></span> Temp
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
2026-06-15 05:19:13 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
function setupCleaner(btnId, iconId, url, token) {
|
|
|
|
|
var btn = document.getElementById(btnId);
|
|
|
|
|
var icon = document.getElementById(iconId);
|
|
|
|
|
if (!btn || !icon) return;
|
|
|
|
|
var origClass = icon.className;
|
|
|
|
|
|
|
|
|
|
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(token, '1');
|
|
|
|
|
|
|
|
|
|
fetch(url, {
|
|
|
|
|
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 = origClass;
|
|
|
|
|
icon.style.color = '';
|
|
|
|
|
delete btn.dataset.busy;
|
|
|
|
|
}, 2000);
|
|
|
|
|
})
|
|
|
|
|
.catch(function() {
|
|
|
|
|
icon.className = 'icon-times';
|
|
|
|
|
icon.style.color = '#dc3545';
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
icon.className = origClass;
|
|
|
|
|
icon.style.color = '';
|
|
|
|
|
delete btn.dataset.busy;
|
|
|
|
|
}, 2000);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setupCleaner('mokosuiteclient-clear-cache', 'mokosuiteclient-cache-icon', '<?php echo $cacheUrl; ?>', '<?php echo $token; ?>');
|
|
|
|
|
setupCleaner('mokosuiteclient-clear-temp', 'mokosuiteclient-temp-icon', '<?php echo $tempUrl; ?>', '<?php echo $token; ?>');
|
2026-06-20 22:10:56 -05:00
|
|
|
|
|
|
|
|
// Click-to-copy domain
|
|
|
|
|
var domainEl = document.getElementById('mokosuiteclient-domain');
|
|
|
|
|
if (domainEl) {
|
|
|
|
|
domainEl.addEventListener('click', function() {
|
|
|
|
|
navigator.clipboard.writeText(domainEl.textContent.trim()).then(function() {
|
|
|
|
|
var orig = domainEl.textContent;
|
|
|
|
|
domainEl.textContent = 'Copied!';
|
|
|
|
|
setTimeout(function() { domainEl.textContent = orig; }, 1500);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-06-15 05:19:13 -05:00
|
|
|
});
|
|
|
|
|
</script>
|