Add view classes for articles, banners, languages, menu, newsletter, containers, shop categories, clients, payment methods, products, and search

- Created Articles.php for rendering article views including full articles, miniature lists, and news sections.
- Added Banners.php for handling banner displays.
- Introduced Languages.php for rendering language options.
- Implemented Menu.php for dynamic menu rendering.
- Developed Newsletter.php for newsletter view rendering.
- Created Scontainers.php for rendering specific containers.
- Added ShopCategory.php for category descriptions and product listings.
- Introduced ShopClient.php for managing client-related views such as address editing and order history.
- Implemented ShopPaymentMethod.php for displaying payment methods in the basket.
- Created ShopProduct.php for generating product URLs.
- Added ShopSearch.php for rendering a simple search form.
- Added .htaccess file to enhance security by restricting access to sensitive files and directories.
This commit is contained in:
2026-02-21 23:00:15 +01:00
parent b51244c1d6
commit 3ecbe628dc
435 changed files with 44107 additions and 31270 deletions

View File

@@ -0,0 +1,19 @@
<?php
$label = trim((string)($this->label ?? 'Kategorie'));
$inputName = trim((string)($this->inputName ?? 'categories[]'));
$categories = is_array($this->categories ?? null) ? $this->categories : [];
$selectedIds = is_array($this->selectedIds ?? null) ? $this->selectedIds : [];
?>
<div class="form-group row js-promotion-row js-promotion-row-categories">
<label class="col-lg-4 control-label"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8'); ?>:</label>
<div class="col-lg-8">
<div class="promotion-categories-box">
<?= \Shared\Tpl\Tpl::view('shop-promotion/promotion-categories-tree', [
'categories' => $categories,
'selectedIds' => $selectedIds,
'inputName' => $inputName,
]); ?>
</div>
</div>
</div>

View File

@@ -0,0 +1,68 @@
<?php
$categories = is_array($this->categories ?? null) ? $this->categories : [];
$inputName = trim((string)($this->inputName ?? 'categories[]'));
$selectedRaw = is_array($this->selectedIds ?? null) ? $this->selectedIds : [];
$selected = [];
foreach ($selectedRaw as $value) {
$id = (int)$value;
if ($id > 0) {
$selected[$id] = true;
}
}
?>
<?php if (!empty($categories)): ?>
<ol class="promotion-categories-tree">
<?php foreach ($categories as $category): ?>
<?php
$categoryId = (int)($category['id'] ?? 0);
if ($categoryId <= 0) {
continue;
}
$title = trim((string)($category['title'] ?? ''));
if ($title === '') {
$title = 'Kategoria #' . $categoryId;
}
$isActive = (int)($category['status'] ?? 0) === 1;
$children = is_array($category['subcategories'] ?? null) ? $category['subcategories'] : [];
$hasChildren = !empty($children);
?>
<li class="promotion-category-item<?= $hasChildren ? ' has-children is-collapsed' : ''; ?>">
<div class="promotion-category-row">
<?php if ($hasChildren): ?>
<button type="button" class="promotion-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
<i class="fa fa-caret-right"></i>
</button>
<?php else: ?>
<span class="promotion-tree-spacer"></span>
<?php endif; ?>
<?php if (!$isActive): ?>
<i class="fa fa-ban text-danger" title="Kategoria nieaktywna"></i>
<?php endif; ?>
<label class="promotion-category-label">
<input
type="checkbox"
class="g-checkbox"
name="<?= htmlspecialchars($inputName, ENT_QUOTES, 'UTF-8'); ?>"
value="<?= $categoryId; ?>"
<?= isset($selected[$categoryId]) ? 'checked="checked"' : ''; ?>
/>
<span><?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?></span>
</label>
</div>
<?php if ($hasChildren): ?>
<?= \Shared\Tpl\Tpl::view('shop-promotion/promotion-categories-tree', [
'categories' => $children,
'selectedIds' => array_keys($selected),
'inputName' => $inputName,
]); ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>

View File

@@ -0,0 +1,115 @@
<style type="text/css">
.promotion-categories-box {
max-height: 420px;
overflow: auto;
border: 1px solid #d6d6d6;
border-radius: 4px;
padding: 8px 10px;
background: #fff;
}
.promotion-categories-tree {
margin: 0;
padding: 0 0 0 16px;
list-style: none;
}
.promotion-category-item {
margin: 2px 0;
}
.promotion-category-item.is-collapsed > ol {
display: none;
}
.promotion-category-row {
display: flex;
align-items: center;
gap: 6px;
min-height: 28px;
}
.promotion-tree-toggle,
.promotion-tree-spacer {
width: 18px;
height: 18px;
display: inline-flex;
align-items: center;
justify-content: center;
border: 0;
background: transparent;
padding: 0;
}
.promotion-tree-toggle {
cursor: pointer;
color: #666;
}
.promotion-category-item:not(.is-collapsed) > .promotion-category-row .promotion-tree-toggle i {
transform: rotate(90deg);
}
.promotion-category-label {
margin: 0;
font-weight: 600;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 6px;
}
.js-promotion-row-hide {
display: none;
}
</style>
<script type="text/javascript">
(function($) {
if (!$) {
return;
}
function updatePromotionConditionRows() {
var conditionType = parseInt($('#condition_type').val(), 10) || 0;
var $discountTypeRow = $('#discount_type').closest('.form-group, .row');
var $amountRow = $('#amount').closest('.form-group, .row');
var $group2Row = $('input[name="condition_categories[]"]').first().closest('.js-promotion-row');
var $minCountRow = $('#min_product_count').closest('.form-group, .row');
var $cheapestPriceRow = $('#price_cheapest_product').closest('.form-group, .row');
if (conditionType === 3) {
$discountTypeRow.addClass('js-promotion-row-hide');
$amountRow.addClass('js-promotion-row-hide');
$group2Row.addClass('js-promotion-row-hide');
$minCountRow.removeClass('js-promotion-row-hide');
$cheapestPriceRow.removeClass('js-promotion-row-hide');
return;
}
$discountTypeRow.removeClass('js-promotion-row-hide');
$amountRow.removeClass('js-promotion-row-hide');
$group2Row.removeClass('js-promotion-row-hide');
$minCountRow.addClass('js-promotion-row-hide');
$cheapestPriceRow.addClass('js-promotion-row-hide');
}
$(document).off('change.shopPromotionCondition', '#condition_type');
$(document).on('change.shopPromotionCondition', '#condition_type', function() {
updatePromotionConditionRows();
});
$(document).off('click.shopPromotionTree', '.promotion-tree-toggle');
$(document).on('click.shopPromotionTree', '.promotion-tree-toggle', function(e) {
e.preventDefault();
var $item = $(this).closest('.promotion-category-item');
$item.toggleClass('is-collapsed');
$(this).attr('aria-expanded', $item.hasClass('is-collapsed') ? 'false' : 'true');
});
$(function() {
updatePromotionConditionRows();
});
})(window.jQuery);
</script>

View File

@@ -1,257 +1,3 @@
<script type="text/javascript" src="/libraries/jquery/sortable/sortable.js"></script>
<?
global $db;
ob_start();
?>
<div id="settings-tabs">
<ul class="resp-tabs-list settings-tabs">
<li><i class="fa fa-wrench"></i>Ustawienia</li>
</ul>
<div class="resp-tabs-container settings-tabs">
<div>
<?=
\Html::input( [
'label' => 'Nazwa',
'name' => 'name',
'id' => 'name',
'value' => $this -> promotion['name']
] );
?>
<?=
\Html::input_switch( [
'label' => 'Aktywna',
'name' => 'status',
'checked' => $this -> promotion['status'] == 1 ? true : false
] );
?>
<?=
\Html::input_switch( [
'label' => 'Łącz z kuponami rabatowymi',
'name' => 'include_coupon',
'checked' => $this -> promotion['include_coupon'] == 1 ? true : false
] );
?>
<?=
\Html::input_switch( [
'label' => 'Uwzględnij produkty przecenione',
'name' => 'include_product_promo',
'checked' => $this -> promotion['include_product_promo'] == 1 ? true : false
] );
?>
<?=
\Html::select( [
'label' => 'Warunki promocji',
'id' => 'condition_type',
'name' => 'condition_type',
'values' => \shop\Promotion::$condition_type,
'value' => $this -> promotion['condition_type'],
] );
?>
<?=
\Html::select( [
'label' => 'Typ rabatu',
'id' => 'discount_type',
'name' => 'discount_type',
'values' => \shop\Promotion::$discount_type,
'value' => $this -> promotion['discount_type'],
] );
?>
<?= \Html::input( [
'label' => 'Min. ilość produktów z danej kategorii',
'class' => 'int-format',
'name' => 'min_product_count',
'id' => 'min_product_count',
'value' => $this -> promotion['min_product_count']
] );?>
<?= \Html::input( [
'label' => 'Cena najtańszego produktu',
'class' => 'number-format',
'name' => 'price_cheapest_product',
'id' => 'price_cheapest_product',
'value' => $this -> promotion['price_cheapest_product']
] );
?>
<?=
\Html::input( [
'label' => 'Wartość',
'class' => 'number-format',
'name' => 'amount',
'id' => 'amount',
'value' => $this -> promotion['amount']
] );
?>
<?=
\Html::input( [
'label' => 'Data do',
'class' => 'date',
'name' => 'date_to',
'id' => 'date_to',
'value' => $this -> promotion['date_to']
] );
?>
<div class="form-group row">
<label class="col-lg-4 control-label">Kategorie grupa I:</label>
<div class="col-lg-8">
<div class="menu_sortable">
<ol class="sortable" id="sortable">
<?
if ( is_array( $this -> categories ) )
{
foreach ( $this -> categories as $category )
{
?>
<li id="list_<?= $category[ 'id' ];?>" class="category_<?= $category[ 'id' ];?>" category="<?= $category[ 'id' ];?>">
<div class="context_0 content content_menu">
<span class="disclose"><span></span></span>
<? if ( !$category[ 'status' ] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
<input type="checkbox" class="g-checkbox" name="categories[]" value="<?= $category[ 'id' ];?>" <? if ( is_array( json_decode( $this -> promotion['categories'] ) ) and in_array( $category[ 'id' ], json_decode( $this -> promotion['categories'] ) ) ):?>checked="checked"<? endif;?> />
<b><?= $category[ 'languages' ][ $this -> dlang ][ 'title' ];?></b>
</div>
<?=
\Tpl::view( 'shop-product/subcategories-list', [
'categories' => \admin\factory\ShopCategory::subcategories( $category[ 'id' ] ),
'product_categories' => json_decode( $this -> promotion['categories'] ),
'dlang' => $this -> dlang
] );
?>
</li>
<?
}
}
?>
</ol>
</div>
</div>
<div class="clear"></div>
</div>
<div class="form-group row">
<label class="col-lg-4 control-label">Kategoria grupa II:</label>
<div class="col-lg-8">
<div class="menu_sortable">
<ol class="sortable" id="sortable2">
<?
if ( is_array( $this -> categories ) )
{
foreach ( $this -> categories as $category )
{
?>
<li id="list_<?= $category[ 'id' ];?>" class="category_<?= $category[ 'id' ];?>" category="<?= $category[ 'id' ];?>">
<div class="context_0 content content_menu">
<span class="disclose"><span></span></span>
<? if ( !$category[ 'status' ] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
<input type="checkbox" class="g-checkbox" name="condition_categories[]" value="<?= $category[ 'id' ];?>" <? if ( is_array( json_decode( $this -> promotion['condition_categories'] ) ) and in_array( $category[ 'id' ], json_decode( $this -> promotion['condition_categories'] ) ) ):?>checked="checked"<? endif;?> />
<b><?= $category[ 'languages' ][ $this -> dlang ][ 'title' ];?></b>
</div>
<?=
\Tpl::view( 'shop-product/subcategories-list', [
'categories' => \admin\factory\ShopCategory::subcategories( $category[ 'id' ] ),
'product_categories' => json_decode( $this -> promotion['condition_categories'] ),
'dlang' => $this -> dlang,
'name' => 'condition_categories[]'
] );
?>
</li>
<?
}
}
?>
</ol>
</div>
</div>
</div>
</div>
</div>
</div>
<?
$out = ob_get_clean();
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
<?= \Shared\Tpl\Tpl::view('shop-promotion/promotion-edit-custom-script'); ?>
$grid = new \gridEdit;
$grid -> id = 'promotion-edit';
$grid -> gdb_opt = $gdb;
$grid -> include_plugins = true;
$grid -> title = $this -> promotion['id'] ? 'Edycja promocji: <u>' . $this -> promotion['name'] . '</u>' : 'Nowa promocja';
$grid -> fields = [
[
'db' => 'id',
'type' => 'hidden',
'value' => $this -> promotion['id']
]
];
$grid -> actions = [
'save' => [ 'url' => '/admin/shop_promotion/save/', 'back_url' => '/admin/shop_promotion/view_list/' ],
'cancel' => [ 'url' => '/admin/shop_promotion/view_list/' ]
];
$grid -> external_code = $out;
$grid -> persist_edit = true;
$grid -> id_param = 'id';
echo $grid -> draw();
?>
<link type="text/css" rel="stylesheet" href="/libraries/selectize/css/selectize.css">
<link type="text/css" rel="stylesheet" href="/libraries/selectize/css/selectize.default.css">
<script type="text/javascript" src="/libraries/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
<script type="text/javascript" src="/libraries/selectize/js/standalone/selectize.js"></script>
<script type="text/javascript">
function condition_type_change()
{
if ( $( '#condition_type' ).val() == 1 || $( '#condition_type' ).val() == 2 )
{
$( '#discount_type' ).closest( '.row' ).show();
$( '#amount' ).closest( '.row' ).show();
$( '#sortable2' ).closest( '.row' ).show();
$( '#min_product_count' ).closest( '.row' ).hide();
$( '#price_cheapest_product' ).closest( '.row' ).hide();
}
if ( $( '#condition_type' ).val() == 3 )
{
$( '#discount_type' ).closest( '.row' ).hide();
$( '#amount' ).closest( '.row' ).hide();
$( '#sortable2' ).closest( '.row' ).hide();
$( '#min_product_count' ).closest( '.row' ).show();
$( '#price_cheapest_product' ).closest( '.row' ).show();
}
}
$(function ()
{
condition_type_change();
$( 'body' ).on( 'change', '#condition_type', function()
{
condition_type_change();
});
disable_menu();
$('#settings-tabs').easyResponsiveTabs({
width: 'auto',
fit: true,
tabidentify: 'settings-tabs',
type: 'vertical'
});
$('ol.sortable').nestedSortable({
forcePlaceholderSize: true,
handle: 'div',
helper: 'clone',
items: 'li',
opacity: .9,
placeholder: 'placeholder',
revert: 250,
tabSize: 45,
tolerance: 'pointer',
toleranceElement: '> div',
maxLevels: 2,
isTree: true,
expandOnHover: 700,
protectRoot: false
});
$('.disclose').on('click', function ()
{
$(this).closest('li').toggleClass('sort-collapsed').toggleClass('sort-expanded');
});
});
</script>

View File

@@ -0,0 +1,2 @@
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>