Skip to content

Commit

Permalink
Moved templates to php files (according to some internal requirements) (
Browse files Browse the repository at this point in the history
#61)

Co-authored-by: Karol Wojciechowski <[email protected]>
  • Loading branch information
kwojc and Karol Wojciechowski authored Dec 4, 2023
1 parent 018c11f commit d3cc995
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 73 deletions.
2 changes: 2 additions & 0 deletions .dev-tools/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ parameters:
level: 0
paths:
- ../src/
excludePaths:
- ../src/View/Templates/
3 changes: 3 additions & 0 deletions .dev-tools/psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
>
<projectFiles>
<directory name='../src/' />
<ignoreFiles>
<directory name="../src/View/Templates/"/>
</ignoreFiles>
</projectFiles>
</psalm>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.dev-tools/.php-cs-fixer.cache
/vendor/
/composer.lock
.idea/
15 changes: 10 additions & 5 deletions src/Utilities/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ public static function parseTemplate($templateFileName, $data = [])
$buffer = ob_get_contents();
ob_clean();
}
ob_start();
if (!file_exists($templateDirectory.$templateFileName.'.phtml')) {
return '';
}
$lang = new Lang();
$lang->setLang(static::$lang);
include_once $templateDirectory.$templateFileName.'.phtml';

ob_start();
if (file_exists($templateDirectory.$templateFileName.'.phtml')) {
include_once $templateDirectory.$templateFileName.'.phtml';
}

if (file_exists($templateDirectory.$templateFileName.'.php')) {
include_once $templateDirectory.$templateFileName.'.php';
}

$parsedHTML = ob_get_contents();
ob_clean();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<link rel="stylesheet" type="text/css" href="<?php echo $data['static_files_url'] ?>View/Styles/style.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo $data['static_files_url']; ?>View/Styles/style.css"/>
<div class="tpay-insidebg" id="main-payment">
<div class="tpay-header-wrapper">
<div class="tpay-header-logo">
Expand All @@ -8,11 +8,13 @@
</div>
<div id="groups_v" class="tpay-panel-inside-content">
<div id="bank-selection-form" class="tpay-groups-wrapper">
<?php if ($data['small_list'] === true) { ?>
<?php if (true === $data['small_list']) { ?>
<select name="bank_list" id="tpay-bank-list" onchange="changeOption()" class="tpay-select"></select>
<?php } ?>
</div>
<?php if (isset($data['form'])) {echo $data['form'];} ?>
<?php if (isset($data['form'])) {
echo $data['form'];
} ?>
</div>
</div>

Expand All @@ -36,7 +38,7 @@
changeOption = function () {
document.getElementById('tpay-channel-input').value = document.getElementById('tpay-bank-list').value;
};
s.src = 'https://secure.tpay.com/groups-<?php echo $data['merchant_id'].$data['online_only'] ?>.js';
s.src = 'https://secure.tpay.com/groups-<?php echo $data['merchant_id'].$data['online_only']; ?>.js';
s.onload = function () {
var str = '',
i,
Expand All @@ -47,7 +49,7 @@
id,
groupName,
logoSrc;
<?php if ($data['small_list'] === false) { ?>
<?php if (false === $data['small_list']) { ?>
for (i in tr_groups) {
group = tr_groups[i];
id = group[0];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<link rel="stylesheet" type="text/css" href="<?php echo $data['static_files_url'] ?>View/Styles/style.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo $data['static_files_url']; ?>View/Styles/style.css"/>
<div class="tpay-insidebg" id="main-payment">
<div id="groups_v" class="tpay-panel-inside-content">
<div id="bank-selection-form" class="tpay-groups-wrapper"></div>
<input type="hidden" name="tpay-selected-group" id="tpay-selected-group">
<?php if ($data['show_regulations_checkbox'] === true) { ?>
<?php if (true === $data['show_regulations_checkbox']) { ?>
<div class="tpay-amPmCheckbox">
<input id="tpay-accept-tos-checkbox" type="checkbox" name="tpay-tos" value="0">
<label for="tpay-accept-tos-checkbox" class="tpay-info-label">
<?php $lang->l('accept') ?> <a href="<?php echo $data['regulation_url'] ?>"
target="_blank" rel="noreferrer noopener"><?php $lang->l('regulations_url') ?></a>
<?php $lang->l('accept'); ?> <a href="<?php echo $data['regulation_url']; ?>"
target="_blank" rel="noreferrer noopener"><?php $lang->l('regulations_url'); ?></a>
<?php $lang->l('regulations'); ?>
</label>
</div>
Expand All @@ -33,7 +33,7 @@
bank_block.className = bank_block.className + ' tpay-active';
}
};
s.src = 'https://secure.tpay.com/groups-<?php echo $data['merchant_id'].$data['online_only'] ?>.js';
s.src = 'https://secure.tpay.com/groups-<?php echo $data['merchant_id'].$data['online_only']; ?>.js';
s.onload = function () {
var str = '',
i,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<link rel="stylesheet" type="text/css" href="<?php echo $data['static_files_url'] ?>View/Styles/style.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo $data['static_files_url']; ?>View/Styles/style.css"/>
<div class="tpay-insidebg" id="main-payment">
<div class="tpay-header-wrapper">
<div class="tpay-header-logo">
Expand All @@ -9,12 +9,12 @@
<div class="tpay-panel-inside-content">
<div class="tpay-channel-form-wrapper tpay-content-wrapper-class">
<img src="https://secure.tpay.com/_/banks/b64.png"/>
<form action="<?php echo $data['action_url'] ?>" method="post" id="tpay-blik-form">
<form action="<?php echo $data['action_url']; ?>" method="post" id="tpay-blik-form">
<div class="tpay-row">
<div class="tpay-input-blik-code">
<div class="tpay-input-wrapper">
<div class="tpay-input-label"
title="<?php $lang->l('blik_info') ?>"><?php $lang->l('codeInputText') ?></div>
title="<?php $lang->l('blik_info'); ?>"><?php $lang->l('codeInputText'); ?></div>
<input id="blik_code"
name="blik_code"
pattern="\d*"
Expand All @@ -33,15 +33,15 @@ class="tpay-input-value tpay-blik-input"
<div class="tpay-amPmCheckbox">
<input id="tpay-accept-regulations-checkbox" type="checkbox" name="regulations" value="0">
<label for="tpay-accept-regulations-checkbox" class="tpay-info-label">
<?php $lang->l('accept') ?> <a href="<?php echo $data['regulation_url'] ?>"
target="_blank" rel="noopener noreferrer"><?php $lang->l('regulations_url') ?></a>
<?php $lang->l('accept'); ?> <a href="<?php echo $data['regulation_url']; ?>"
target="_blank" rel="noopener noreferrer"><?php $lang->l('regulations_url'); ?></a>
<?php $lang->l('regulations'); ?>
</label>
</div>
</form>
</div>
<div class="tpay-buttons-holder">
<input class="tpay-pay-button" id="tpay-payment-submit" type="submit" value="<?php $lang->l('pay') ?>">
<input class="tpay-pay-button" id="tpay-payment-submit" type="submit" value="<?php $lang->l('pay'); ?>">
</div>
</div>
</div>
Expand All @@ -51,11 +51,11 @@ class="tpay-input-value tpay-blik-input"
blik_code_input = document.getElementById('blik_code');
submit_form_input.onclick = function () {
if (regulation_checkbox.value == 0) {
alert('<?php $lang->l('acceptance_is_required') ?>');
alert('<?php $lang->l('acceptance_is_required'); ?>');
return false;
}
if (blik_code_input.value.length !== 6 || /^\d+$/.test(blik_code_input.value) === false) {
alert('<?php $lang->l('blik_code_error') ?>');
alert('<?php $lang->l('blik_code_error'); ?>');
return false;
}
document.getElementById('tpay-blik-form').submit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
<td><select name="currency" id="t_currency" required>
<?php
foreach ($data['currencies'] as $currencyCode => $currencyName) {
echo "<option value='$currencyCode'>$currencyName</option>";
echo "<option value='{$currencyCode}'>{$currencyName}</option>";
}
?>
?>
</select></td>
</tr>
<tr>
<td><label for="t_language">Client language</label></td>
<td><select name="language" id="t_language" required>
<?php
foreach ($data['languages'] as $language) {
echo "<option value='$language'>$language</option>";
}
?>
foreach ($data['languages'] as $language) {
echo "<option value='{$language}'>{$language}</option>";
}
?>
</select></td>
</tr>
</table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<form id="tpay-payment" class="tpay-form" action="<?php
echo $data['action_url'] ?>" method="POST">
<input type="hidden" name="sale_auth" value="<?php echo $data['sale_auth'] ?>"/>
<input id="tpay-payment-submit" type="submit" value="<?php $lang->l('pay') ?>">
echo $data['action_url']; ?>" method="POST">
<input type="hidden" name="sale_auth" value="<?php echo $data['sale_auth']; ?>"/>
<input id="tpay-payment-submit" type="submit" value="<?php $lang->l('pay'); ?>">
</form>
30 changes: 15 additions & 15 deletions src/View/Templates/gate.phtml → src/View/Templates/gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class="tpay-groups-wrapper">
<div class="tpay-row">
<div class="tpay-input-wrapper">
<div class="tpay-input-credit-card-number">
<div class="tpay-input-label"><?php $lang->l('card_number') ?></div>
<div class="tpay-input-label"><?php $lang->l('card_number'); ?></div>
<input id="card_number"
pattern="\d*"
autocompletetype="cc-number"
Expand All @@ -32,10 +32,10 @@ class="tpay-input-value"

<?php if ($data['showPayerFields']) { ?>
<div class="tpay-input-wrapper">
<div class="tpay-input-label"><?php $lang->l('name_on_card') ?></div>
<div class="tpay-input-label"><?php $lang->l('name_on_card'); ?></div>
<input type="text"
id="c_name"
placeholder="<?php $lang->l('name_surname') ?>"
placeholder="<?php $lang->l('name_surname'); ?>"
autocomplete="off"
name="client_name"
maxlength="64"
Expand All @@ -50,7 +50,7 @@ class="tpay-input-value"
<div class="tpay-col">
<div class="tpay-row">
<div class="tpay-expiration-date-input tpay-input-wrapper">
<div class="tpay-input-label"><?php $lang->l('expiration_date') ?></div>
<div class="tpay-input-label"><?php $lang->l('expiration_date'); ?></div>
<input id="expiry_date"
maxlength="9"
type="tel"
Expand All @@ -63,7 +63,7 @@ class="tpay-input-value"
/>
</div>
<div class="tpay-cvv-input tpay-input-wrapper">
<div class="tpay-input-label tpay-input-cvc" title="<?php $lang->l('signature') ?>">CVC</div>
<div class="tpay-input-label tpay-input-cvc" title="<?php $lang->l('signature'); ?>">CVC</div>
<input id="cvc"
maxlength="4"
type="tel"
Expand Down Expand Up @@ -100,22 +100,22 @@ class="tpay-input-value"
<input type="checkbox" id="card_save" name="card_save"/>
<label for="card_save"
class="tpay-info-label"
title="<?php $lang->l('save_card_info') ?>"><?php $lang->l('save_card') ?>
title="<?php $lang->l('save_card_info'); ?>"><?php $lang->l('save_card'); ?>
</label>
</div>
<?php } ?>
<p id="info_msg_not_supported" style="display: none"><?php $lang->l('not_supported_card') ?></p>
<p id="info_msg_not_valid" style="display: none"><?php $lang->l('not_valid_card') ?></p>
<p id="info_msg_not_supported" style="display: none"><?php $lang->l('not_supported_card'); ?></p>
<p id="info_msg_not_valid" style="display: none"><?php $lang->l('not_valid_card'); ?></p>
</form>

<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL] ?>View/JS/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL] ?>View/JS/jquery.formance.min.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL] ?>View/JS/jsencrypt.min.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL] ?>View/JS/string_routines.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL] ?>View/JS/jquery.payment.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL] ?>View/JS/cardPayment.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL]; ?>View/JS/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL]; ?>View/JS/jquery.formance.min.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL]; ?>View/JS/jsencrypt.min.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL]; ?>View/JS/string_routines.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL]; ?>View/JS/jquery.payment.js"></script>
<script type="text/javascript" src="<?php echo $data[STATIC_FILES_URL]; ?>View/JS/cardPayment.js"></script>
<script type="text/javascript">
$(document).ready(function () {
new CardPayment('<?php echo $data['payment_redirect_path'] ?>', "<?php echo $data['rsa_key'] ?>");
new CardPayment('<?php echo $data['payment_redirect_path']; ?>', "<?php echo $data['rsa_key']; ?>");
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ function redirect() {
document.getElementById('tpay-payment').submit();
}
</script>
<link rel="stylesheet" type="text/css" href="<?php echo $data['static_files_url'] ?>View/Styles/style.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo $data['static_files_url']; ?>View/Styles/style.css"/>
<body <?php if ($data['redirect']) {
echo 'onload="redirect()"';
} ?>>
<form id="tpay-payment" class="tpay-form" action="<?php echo $data['action_url'] ?>" method="POST"
<form id="tpay-payment" class="tpay-form" action="<?php echo $data['action_url']; ?>" method="POST"
accept-charset="UTF-8">
<?php foreach ($data['fields'] as $name => $value) { ?>
<input <?php if ($name === 'group') {
<input <?php if ('group' === $name) {
echo ' id="tpay-channel-input" ';
}
if ($name === 'accept_tos') {
if ('accept_tos' === $name) {
echo ' id="tpay-regulations-input" ';
} ?> type="hidden"
name="<?php echo $name ?>"
value="<?php echo $value ?>">
name="<?php echo $name; ?>"
value="<?php echo $value; ?>">
<?php
}
?>
<?php if ($data['show_regulations_checkbox'] === true) { ?>
?>
<?php if (true === $data['show_regulations_checkbox']) { ?>
<div class="tpay-amPmCheckbox">
<input id="tpay-accept-regulations-checkbox" type="checkbox" name="regulations" value="0">
<label for="tpay-accept-regulations-checkbox" class="tpay-info-label">
<?php $lang->l('accept') ?> <a href="<?php echo $data['regulation_url'] ?>"
target="_blank" rel="noopener noreferrer"><?php $lang->l('regulations_url') ?></a>
<?php $lang->l('accept'); ?> <a href="<?php echo $data['regulation_url']; ?>"
target="_blank" rel="noopener noreferrer"><?php $lang->l('regulations_url'); ?></a>
<?php $lang->l('regulations'); ?>
</label>
</div>
<?php } ?>
<div class="tpay-buttons-holder">
<input class="tpay-pay-button" id="tpay-payment-submit" type="submit" value="<?php $lang->l('pay') ?>">
<input class="tpay-pay-button" id="tpay-payment-submit" type="submit" value="<?php $lang->l('pay'); ?>">
</div>
</form>
</body>
Expand All @@ -41,10 +41,10 @@ function redirect() {
var regulation_checkbox = document.getElementById('tpay-accept-regulations-checkbox'),
submit_form_input = document.getElementById('tpay-payment-submit'),
regulations_form_input = document.getElementById('tpay-regulations-input');
<?php if ($data['show_regulations_checkbox'] === true){ ?>
<?php if (true === $data['show_regulations_checkbox']) { ?>
submit_form_input.onclick = function () {
if (regulations_form_input.value == 0) {
alert('<?php $lang->l('acceptance_is_required') ?>');
alert('<?php $lang->l('acceptance_is_required'); ?>');
return false;
}
return true;
Expand Down
Loading

0 comments on commit d3cc995

Please sign in to comment.