modal.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Copyright (C) 2010 - 2020
  17. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. if (!class_exists('modal')) {
  22. class modal {
  23. static function create($array) {
  24. //add multi-lingual support
  25. $language = new text;
  26. $text = $language->get();
  27. $modal = "<div id='".(!empty($array['id']) ? $array['id'] : 'modal')."' class='modal-window'>\n";
  28. $modal .= " <div>\n";
  29. $modal .= " <span title=\"".$text['button-close']."\" class='modal-close' onclick=\"modal_close(); ".($array['onclose'] ?? '')."\">&times</span>\n";
  30. if (!empty($array['type'])) {
  31. //determine type
  32. switch ($array['type']) {
  33. case 'copy':
  34. $array['title'] = $text['modal_title-confirmation'];
  35. $array['message'] = $text['confirm-copy'];
  36. break;
  37. case 'toggle':
  38. $array['title'] = $text['modal_title-confirmation'];
  39. $array['message'] = $text['confirm-toggle'];
  40. break;
  41. case 'delete':
  42. $array['title'] = $text['modal_title-confirmation'];
  43. $array['message'] = $text['confirm-delete'];
  44. break;
  45. default: //general
  46. $array['title'] = !empty($array['title']) ? $array['title'] : $text['modal_title-confirmation'];
  47. }
  48. //prefix cancel button to action
  49. $array['actions'] = button::create(['type'=>'button','label'=>$text['button-cancel'],'icon'=>$_SESSION['theme']['button_icon_cancel'],'collapse'=>'never','onclick'=>'modal_close(); '.($array['onclose'] ?? '')]).$array['actions'];
  50. }
  51. $modal .= !empty($array['title']) ? " <span class='modal-title'>".$array['title']."</span>\n" : null;
  52. $modal .= !empty($array['message']) ? " <span class='modal-message'>".$array['message']."</span>\n" : null;
  53. $modal .= !empty($array['actions']) ? " <span class='modal-actions'>".$array['actions']."</span>\n" : null;
  54. $modal .= " </div>\n";
  55. $modal .= "</div>";
  56. return $modal;
  57. unset($modal);
  58. }
  59. }
  60. }
  61. ?>