| 1 |
<?php |
| 2 |
|
| 3 |
function acym_modal( |
| 4 |
string $button, |
| 5 |
string $data, |
| 6 |
?string $id = null, |
| 7 |
array $attributesModal = [], |
| 8 |
array $attributesButton = [], |
| 9 |
bool $isButton = true, |
| 10 |
bool $isLarge = true, |
| 11 |
string $classesModal = '' |
| 12 |
): string { |
| 13 |
if (empty($id)) { |
| 14 |
$id = 'acymodal_'.rand(1000, 9000); |
| 15 |
} |
| 16 |
|
| 17 |
$attributesButton['data-open'] = $id; |
| 18 |
$buttonParams = acym_getFormattedAttributes($attributesButton); |
| 19 |
|
| 20 |
$attributesModal['class'] = 'reveal '.$classesModal; |
| 21 |
$attributesModal['id'] = $id; |
| 22 |
$attributesModal['data-reveal'] = ''; |
| 23 |
if ($isLarge) { |
| 24 |
$attributesModal['data-reveal-larger'] = ''; |
| 25 |
} |
| 26 |
$modalParams = acym_getFormattedAttributes($attributesModal); |
| 27 |
|
| 28 |
$modal = $isButton ? '<button type="button" '.$buttonParams.'>'.$button.'</button>' : $button; |
| 29 |
$modal .= '<div '.$modalParams.'>'; |
| 30 |
$modal .= $data; |
| 31 |
$modal .= '<button class="close-button" data-close aria-label="Close reveal" type="button">'; |
| 32 |
$modal .= '<span aria-hidden="true">×</span>'; |
| 33 |
$modal .= '</button></div>'; |
| 34 |
|
| 35 |
return $modal; |
| 36 |
} |
| 37 |
|
| 38 |
function acym_modalInclude( |
| 39 |
string $button, |
| 40 |
string $file, |
| 41 |
string $id, |
| 42 |
array $data, |
| 43 |
string $classModal = '', |
| 44 |
array $containerAttributes = [] |
| 45 |
): string { |
| 46 |
if (empty($id)) { |
| 47 |
$id = 'acymodal_'.rand(1000, 9000); |
| 48 |
} |
| 49 |
|
| 50 |
$dataModal = $data; |
| 51 |
|
| 52 |
$containerAttributes['data-open'] = $id; |
| 53 |
$containerParams = acym_getFormattedAttributes($containerAttributes); |
| 54 |
$modal = '<div '.$containerParams.'>'.$button; |
| 55 |
$modal .= '<div class="reveal '.acym_escape($classModal).'" id="'.acym_escape($id).'" data-reveal>'; |
| 56 |
ob_start(); |
| 57 |
include $file; |
| 58 |
$modal .= ob_get_clean(); |
| 59 |
$modal .= '<button type="button" class="close-button" data-close aria-label="Close reveal">'; |
| 60 |
$modal .= '<span aria-hidden="true">×</span>'; |
| 61 |
$modal .= '</button></div></div>'; |
| 62 |
|
| 63 |
return $modal; |
| 64 |
} |
| 65 |
|
| 66 |
function acym_modalPaginationLists( |
| 67 |
string $inputEventId, |
| 68 |
string $checkedLists = '[]', |
| 69 |
bool $needDisplaySubscribers = false |
| 70 |
): string { |
| 71 |
$searchField = acym_filterSearch('', 'modal_search_lists'); |
| 72 |
|
| 73 |
$data = '<input type="hidden" id="'.acym_escape($inputEventId).'">'; |
| 74 |
|
| 75 |
if ($needDisplaySubscribers) { |
| 76 |
$data .= '<input type="hidden" id="modal__pagination__need__display__sub">'; |
| 77 |
} |
| 78 |
|
| 79 |
$data .= '<div class="cell grid-x" style="display: none;" id="acym__popup__plugin__subscription__lists__modal"> |
| 80 |
<input type="hidden" name="show_selected" value="false" id="modal__pagination__show-information"> |
| 81 |
<input type="hidden" id="modal__pagination__search__lists"> |
| 82 |
<input type="hidden" name="lists_selected" id="acym__modal__lists-selected" value="'.acym_escape($checkedLists).'"> |
| 83 |
<div class="cell grid-x"> |
| 84 |
<h4 class="cell text-center acym__title acym__title__secondary">'.acym_escape(acym_translation('ACYM_CHOOSE_LISTS')).'</h4> |
| 85 |
</div> |
| 86 |
<div class="cell grid-x modal__pagination__search"> |
| 87 |
'.$searchField.' |
| 88 |
</div> |
| 89 |
<div class="cell text-center padding-top-1" id="modal__pagination__search__spinner" style="display: none"> |
| 90 |
<i class="acymicon-circle-o-notch acymicon-spin"></i> |
| 91 |
</div> |
| 92 |
<div class="cell medium-6 modal__pagination__show"> |
| 93 |
<a href="#" class="acym__color__blue modal__pagination__show-selected modal__pagination__show-button selected">'.acym_escape( |
| 94 |
acym_translation('ACYM_SHOW_SELECTED_LISTS') |
| 95 |
).'</a> |
| 96 |
<a href="#" class="acym__color__blue modal__pagination__show-all modal__pagination__show-button">'.acym_escape(acym_translation('ACYM_SHOW_ALL_LISTS')).'</a> |
| 97 |
</div> |
| 98 |
<div class="cell grid-x modal__pagination__listing__lists"> |
| 99 |
<div class="cell modal__pagination__listing__lists__in-form"></div> |
| 100 |
</div> |
| 101 |
</div>'; |
| 102 |
|
| 103 |
return $data; |
| 104 |
} |
| 105 |
|
| 106 |
function acym_frontModal( |
| 107 |
string $iframeSrc, |
| 108 |
string $buttonText, |
| 109 |
bool $isButton, |
| 110 |
?string $identifier = null, |
| 111 |
?string $iframeClass = null |
| 112 |
): string { |
| 113 |
static $loaded = false; |
| 114 |
if (empty($loaded)) { |
| 115 |
$loaded = true; |
| 116 |
acym_addStyle(false, ACYM_CSS.'modal.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'modal.min.css')); |
| 117 |
acym_addScript(false, ACYM_JS.'modal.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'modal.min.js')); |
| 118 |
} |
| 119 |
|
| 120 |
if (empty($identifier)) { |
| 121 |
$identifier = 'identifier_'.rand(1000, 9000); |
| 122 |
} |
| 123 |
|
| 124 |
if (empty($iframeClass)) { |
| 125 |
$iframeClass = 'acym__modal__iframe'; |
| 126 |
} |
| 127 |
|
| 128 |
ob_start(); |
| 129 |
?> |
| 130 |
<a class="<?php echo $isButton ? 'btn ' : ''; ?>acym__modal__handle" data-acym-modal="<?php echo acym_escape($identifier); ?>" href="#"> |
| 131 |
<?php echo acym_escape(acym_translation($buttonText)); ?> |
| 132 |
</a> |
| 133 |
<div class="acym__modal" id="acym__modal__<?php echo acym_escape($identifier); ?>" style="display: none;"> |
| 134 |
<div class="acym__modal__content"> |
| 135 |
<div class="acym__modal__close"><span>×</span></div> |
| 136 |
<iframe class="<?php echo acym_escape($iframeClass); ?>" src="<?php echo acym_escapeUrl($iframeSrc); ?>"></iframe> |
| 137 |
</div> |
| 138 |
</div> |
| 139 |
<?php |
| 140 |
return ob_get_clean(); |
| 141 |
} |
| 142 |
|