Skip to content

Commit

Permalink
[K5.2] Add confirmation modal before restore menus #7810 (#7852)
Browse files Browse the repository at this point in the history
  • Loading branch information
xillibit committed Jan 10, 2021
1 parent 55df4f5 commit 9975468
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
Expand Up @@ -1011,7 +1011,10 @@ COM_KUNENA_SYNC_USERS_DELLIFE_DESC = "Delete all lifetime ban users. <em><b>All

COM_KUNENA_A_MENU_TOOLBAR_FIXLEGACY = "Fix Legacy"
COM_KUNENA_A_PURGE_RE_MENU_VALIDATE = "Purge Prefix"
COM_KUNENA_A_TRASH_MENU = "Restore Kunena Menu"
COM_KUNENA_VIEW_TOOLS_RESTOREMENU_CONFIRMATION_TRASH = "Restore Kunena Menu"
COM_KUNENA_VIEW_TOOLS_RESTOREMENU_CONFIRMATION_TRASH_MODAL_TITLE = "Confirmation Restore Kunena Menu"
COM_KUNENA_VIEW_TOOLS_RESTOREMENU_CONFIRMATION_TRASH_TIP = "Are you sure you want to delete and restore the Kunena menu? Confirming will delete the Kunena menu type, all their menu items and the associated menu modules."
COM_KUNENA_TOOLS_BUTTON_RESTOREMENU_CONFIRMATION_PROCESS = "Process"
COM_KUNENA_PRUNE = "Prune"
COM_KUNENA_SYNC = "Sync"
COM_KUNENA_TOOLS_LABEL_CLEANUP_IP = "Clean IP Addresses"
Expand Down
Expand Up @@ -78,6 +78,7 @@
<?php endforeach ?>
</table>
</fieldset>
<?php echo $this->loadTemplateFile('trashmenuconfirmation'); ?>
</form>
</div>
<div class="pull-right small">
Expand Down
@@ -0,0 +1,40 @@
<?php
/**
* Kunena Component
* @package Kunena.Administrator.Tools
* @subpackage Tools
*
* @copyright Copyright (C) 2008 - 2021 Kunena Team. All rights reserved.
* @license https://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;

?>
<div class="modal hide fade" id="trashmenuconfirmationModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" role="presentation" class="close" data-dismiss="modal">x</button>
<h3><?php echo Text::_('COM_KUNENA_VIEW_TOOLS_RESTOREMENU_CONFIRMATION_TRASH_MODAL_TITLE'); ?></h3>
</div>
<div class="modal-body span11">
<p><?php echo Text::_('COM_KUNENA_VIEW_TOOLS_RESTOREMENU_CONFIRMATION_TRASH_TIP'); ?></p>
<div class="control-group">
<div class="controls">

</div>
</div>
</div>
<div class="modal-footer">
<button class="btn" type="button" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</button>
<button class="btn btn-warning" type="submit" onclick="Joomla.submitbutton('trashmenu');">
<?php echo Text::_('COM_KUNENA_TOOLS_BUTTON_RESTOREMENU_CONFIRMATION_PROCESS'); ?>
</button>
</div>
</div>
</div>
</div>
Expand Up @@ -11,6 +11,7 @@
**/
defined('_JEXEC') or die();

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

/**
Expand Down Expand Up @@ -157,13 +158,30 @@ protected function setToolBarMenu()
{
JToolbarHelper::title(Text::_('COM_KUNENA'), 'tools');
JToolbarHelper::spacer();

// Get the toolbar object instance
$bar = \Joomla\CMS\Toolbar\Toolbar::getInstance('toolbar');

if (!empty($this->legacy))
{
JToolbarHelper::custom('fixlegacy', 'edit.png', 'edit_f2.png', 'COM_KUNENA_A_MENU_TOOLBAR_FIXLEGACY', false);
}

if (version_compare(JVERSION, '4.0', '>'))
{
HTMLHelper::_('bootstrap.renderModal', 'trashmenuconfirmationModal');
}
else
{
HTMLHelper::_('bootstrap.modal', 'trashmenuconfirmationModal');
}

$title = Text::_('COM_KUNENA_VIEW_TOOLS_RESTOREMENU_CONFIRMATION_TRASH');
$dhtml = "<button data-toggle=\"modal\" data-target=\"#trashmenuconfirmationModal\" class=\"btn btn-small\">
<i class=\"icon-apply\" title=\"$title\"> </i>
$title</button>";
$bar->appendButton('Custom', $dhtml, 'batch');

JToolbarHelper::custom('trashmenu', 'apply.png', 'apply_f2.png', 'COM_KUNENA_A_TRASH_MENU', false);
JToolbarHelper::spacer();
JToolbarHelper::cancel();
JToolbarHelper::spacer();
Expand Down

0 comments on commit 9975468

Please sign in to comment.