refactor(shop-coupon): migrate admin module to DI and release 0.266

This commit is contained in:
2026-02-14 00:05:23 +01:00
parent 88e5673569
commit 40e777afe6
40 changed files with 1668 additions and 426 deletions

View File

@@ -7,6 +7,48 @@
<script type="text/javascript" src="/libraries/codemirror/mode/javascript/javascript.js"></script>
<script type="text/javascript" src="/libraries/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script type="text/javascript" src="/libraries/codemirror/addon/mode/multiplex.js"></script>
<style type="text/css">
.layout-tree-toggle {
width: 18px;
height: 18px;
display: inline-flex;
align-items: center;
justify-content: center;
border: 0;
background: transparent;
padding: 0;
margin-right: 4px;
color: #666;
cursor: pointer;
}
.layout-tree-toggle:focus,
.layout-tree-toggle:active,
.layout-tree-toggle:focus-visible {
outline: none;
box-shadow: none;
}
li.sort-expanded > div .layout-tree-toggle i {
transform: rotate(90deg);
}
#fg-layout-edit input[type=checkbox].g-checkbox {
-webkit-appearance: checkbox;
appearance: auto;
position: static;
width: 14px;
height: 14px;
background: initial;
border-radius: 0;
box-shadow: none;
vertical-align: middle;
}
#fg-layout-edit input[type=checkbox].g-checkbox:before {
content: none;
}
</style>
<script type="text/javascript">
$( function()
{
@@ -76,9 +118,43 @@
}
});
function refreshTreeDisclosureState()
{
$( 'ol.sortable li' ).each( function()
{
var $li = $( this );
var hasChildren = $li.children( 'ol' ).children( 'li' ).length > 0;
var $disclose = $li.children( 'div' ).children( '.disclose' );
if ( hasChildren )
{
$li.removeClass( 'sort-leaf' );
if ( !$li.hasClass( 'sort-collapsed' ) && !$li.hasClass( 'sort-expanded' ) )
$li.addClass( 'sort-collapsed' );
$li.addClass( 'sort-branch' );
$disclose.attr( 'aria-expanded', $li.hasClass( 'sort-expanded' ) ? 'true' : 'false' );
$disclose.show();
}
else
{
$li.removeClass( 'sort-branch sort-collapsed sort-expanded' ).addClass( 'sort-leaf' );
$disclose.attr( 'aria-expanded', 'false' );
$disclose.hide();
}
});
}
refreshTreeDisclosureState();
$( '.disclose' ).on( 'click', function()
{
$( this ).closest( 'li' ).toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
var $li = $( this ).closest( 'li' );
if ( !$li.hasClass( 'sort-branch' ) )
return;
$li.toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
$( this ).attr( 'aria-expanded', $li.hasClass( 'sort-expanded' ) ? 'true' : 'false' );
this.blur();
});
$( '.disclose' ).mousedown( function(e)
@@ -116,21 +192,39 @@
});
<?php
$array = unserialize( $_COOKIE[ 'cookie_pages' ] );
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
if ( $val ):
?>$( '.<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
endif;
endforeach; endif;
$cookiePages = [];
$cookieMenus = [];
$array = unserialize( $_COOKIE[ 'cookie_menus' ] );
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
if ( $val ):
?>$( '.menu_<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
endif;
endforeach; endif;
if ( !empty( $_COOKIE['cookie_pages'] ) )
{
$decoded = @unserialize( (string)$_COOKIE['cookie_pages'], [ 'allowed_classes' => false ] );
if ( is_array( $decoded ) )
$cookiePages = $decoded;
}
if ( !empty( $_COOKIE['cookie_menus'] ) )
{
$decoded = @unserialize( (string)$_COOKIE['cookie_menus'], [ 'allowed_classes' => false ] );
if ( is_array( $decoded ) )
$cookieMenus = $decoded;
}
?>
var cookiePages = <?= json_encode( $cookiePages, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );?>;
var cookieMenus = <?= json_encode( $cookieMenus, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );?>;
Object.keys( cookiePages || {} ).forEach( function( key )
{
if ( String( cookiePages[key] ) === '1' && /^\d+$/.test( String( key ) ) )
$( '.list_' + key ).children( 'div' ).children( '.disclose' ).click();
});
Object.keys( cookieMenus || {} ).forEach( function( key )
{
if ( String( cookieMenus[key] ) === '1' && /^\d+$/.test( String( key ) ) )
$( '.menu_' + key ).children( 'div' ).children( '.disclose' ).click();
});
});
</script>
<?
@@ -177,7 +271,9 @@ ob_start();
<ol class="sortable" id="sortable_<?= $menu['id'];?>">
<li id="list_<?= $menu['id'];?>" class="menu_<?= $menu['id'];?>" menu="<?= $menu['id'];?>">
<div class="context_0 content content_menu" <? if ( !$menu['status'] ) echo 'style="color: #cc0000;"';?>>
<span class="disclose"><span></span></span>
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
<i class="fa fa-caret-right"></i>
</button>
Menu: <b><?= $menu['name'];?></b>
</div>
<?= \Tpl::view( 'layouts/subpages-list', [
@@ -199,7 +295,9 @@ ob_start();
<? 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>
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
<i class="fa fa-caret-right"></i>
</button>
<? 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( $this -> layout['categories'] ) and in_array( $category['id'], $this -> layout['categories'] ) ):?>checked="checked"<? endif;?> />
<b><?= $category['languages'][$this -> dlang]['title'];?></b>

View File

@@ -3,7 +3,9 @@
<? foreach ( $this -> categories as $category ):?>
<li id="list_<?= $category['id'];?>" class="list_<?= $category['id'];?>" category="<?= $category['id'];?>">
<div class="context_0 content content_menu">
<span class="disclose"><span></span></span>
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
<i class="fa fa-caret-right"></i>
</button>
<? 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( $this -> product_categories ) and in_array( $category['id'], $this -> product_categories ) ):?>checked="checked"<? endif;?> />
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
@@ -17,4 +19,3 @@
<? endforeach;?>
</ol>
<? endif;?>

View File

@@ -3,7 +3,9 @@
<? foreach ( $this -> pages as $page ):?>
<li id="list_<?= $page['id'];?>" idk="<?= $page['id'];?>" class="list_<?= $page['id'];?>" menu="<?= $page['menu_id'];?>">
<div class="content <?= $this -> step < 2 ? $tmp = 'content_page' : $tmp = 'content_page_last_level';?>" <? if ( !$page['status'] ) echo 'style="color: #cc0000;"';?>>
<span class="disclose"><span></span></span>
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
<i class="fa fa-caret-right"></i>
</button>
<input type="checkbox" class="g-checkbox" name="pages[]" value="<?= $page['id'];?>" <? if ( is_array( $this -> layout_pages ) and in_array( $page['id'], $this -> layout_pages ) ):?>checked="checked"<? endif;?> /><?= $page['title'];?>
</div>
<?