Files
fusionpbx/resources/classes/modal.php
Alex 295db3b9c8 Show the list of selected domains on toggle/delete confirmation (#7682)
* Show the list of selected domains on toggle/delete confirmation

* Update app_languages.php

* Update modal.php

* Update domains.php
2025-12-29 14:09:53 -07:00

103 lines
3.9 KiB
PHP

<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Copyright (C) 2010-2025
All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
class modal {
/**
* Creates a modal window.
*
* @param array $array Array containing the modal's properties.
* The following keys are supported:
* - id: ID of the modal (optional).
* - type: Type of the modal (optional, one of 'copy', 'toggle',
* 'delete' or 'unassign'). If not specified, a general
* modal will be created. Defaults to 'general'.
* - title: Title of the modal (optional). If not specified,
* a default title will be used based on the type.
* - message: Message of the modal (optional).
* - actions: Actions of the modal (optional).
* - onclose: Function to call when the modal is closed
* (optional).
*
* @return string HTML string representing the modal window.
*/
static function create($array) {
//define as global
global $settings;
//add multi-lingual support
$language = new text;
$text = $language->get();
$modal = "<div id='" . (!empty($array['id']) ? $array['id'] : 'modal') . "' class='modal-window'>\n";
$modal .= " <div>\n";
$modal .= " <span title=\"" . $text['button-close'] . "\" class='modal-close' onclick=\"modal_close(); " . ($array['onclose'] ?? '') . "\">&times</span>\n";
if (!empty($array['type'])) {
//determine type
switch ($array['type']) {
case 'copy':
$array['title'] = $text['modal_title-confirmation'];
$array['message'] = $text['confirm-copy'];
break;
case 'toggle':
$array['title'] = $text['modal_title-confirmation'];
$array['message'] = $text['confirm-toggle'];
break;
case 'toggle_items':
$array['title'] = $text['modal_title-confirmation'];
$array['message'] = $text['confirm-toggle_items'];
break;
case 'delete':
$array['title'] = $text['modal_title-confirmation'];
$array['message'] = $text['confirm-delete'];
break;
case 'delete_items':
$array['title'] = $text['modal_title-confirmation'];
$array['message'] = $text['confirm-delete_items'];
break;
case 'unassign':
$array['title'] = $text['modal_title-confirmation'];
$array['message'] = $text['confirm-unassign'];
default: //general
$array['title'] = !empty($array['title']) ? $array['title'] : $text['modal_title-confirmation'];
}
//prefix cancel button to action
$array['actions'] = button::create(['type' => 'button', 'label' => $text['button-cancel'], 'icon' => $settings->get('theme', 'button_icon_cancel'), 'collapse' => 'never', 'onclick' => 'modal_close(); ' . ($array['onclose'] ?? '')]) . $array['actions'];
}
$modal .= !empty($array['title']) ? " <span class='modal-title'>" . $array['title'] . "</span>\n" : null;
$modal .= !empty($array['message']) ? " <span class='modal-message'>" . $array['message'] . "</span>\n" : null;
$modal .= !empty($array['actions']) ? " <span class='modal-actions'>" . $array['actions'] . "</span>\n" : null;
$modal .= " </div>\n";
$modal .= "</div>";
return $modal;
}
}