This commit is contained in:
2026-03-28 11:33:56 +01:00
parent 412e235512
commit aa8e21862d
132 changed files with 24381 additions and 10882 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)
@@ -92,9 +168,8 @@
{
type: 'POST',
cache: false,
url: '/admin/ajax.php',
url: '/admin/pages/cookieMenus/',
data: {
a: 'cookie_menus',
menu_id: menu_id
}
});
@@ -107,10 +182,9 @@
{
type: 'POST',
cache: false,
url: '/admin/ajax.php',
url: '/admin/pages/cookiePages/',
data: {
a: 'cookie_pages',
page_id: page_id
page_id: page_id.replace( 'list_', '' )
}
});
}
@@ -118,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>
<?
@@ -149,7 +241,7 @@ ob_start();
</ul>
<div class="resp-tabs-container layout-tabs">
<div>
<?= \Html::input(
<?= \Shared\Html\Html::input(
array(
'label' => 'Nazwa',
'name' => 'name',
@@ -157,16 +249,16 @@ ob_start();
'value' => $this -> layout['name']
)
);?>
<?= \Html::input_switch(
<?= \Shared\Html\Html::input_switch(
array(
'label' => 'Szablon domyślny',
'label' => 'Szablon domy&#347;lny',
'name' => 'status',
'checked' => $this -> layout['status'] == 1 ? true : false
)
);?>
<?= \Html::input_switch(
<?= \Shared\Html\Html::input_switch(
array(
'label' => 'Szablon domyślny (kategorie)',
'label' => 'Szablon domy&#347;lny (kategorie)',
'name' => 'categories_default',
'checked' => $this -> layout['categories_default'] == 1 ? true : false
)
@@ -179,10 +271,16 @@ 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>
<?= \admin\view\Layouts::subpages_list( \admin\factory\Pages::menu_pages( $menu['id'] ), $this -> layout['pages'] );?>
<?= \Shared\Tpl\Tpl::view( 'layouts/subpages-list', [
'pages' => $menu['pages'],
'layout_pages' => $this -> layout['pages'],
'step' => 1
] );?>
</li>
</ol>
</div>
@@ -197,13 +295,15 @@ 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>
</div>
<?= \Tpl::view( 'shop-product/subcategories-list', [
'categories' => \admin\factory\ShopCategory::subcategories( $category['id'] ),
<?= \Shared\Tpl\Tpl::view( 'layouts/subcategories-list', [
'categories' => $category['subcategories'],
'product_categories' => $this -> layout['categories'],
'dlang' => $this -> dlang
] );?>
@@ -229,25 +329,13 @@ ob_start();
<?
$out = ob_get_clean();
$grid = new \gridEdit;
$grid -> id = 'layout-edit';
$grid -> gdb_opt = $gdb;
$grid -> include_plugins = true;
$grid -> title = 'Edycja szablonu';
$grid -> fields = [
[
'db' => 'id',
'type' => 'hidden',
'value' => $this -> layout['id']
]
];
$grid -> actions = [
'save' => [ 'url' => '/admin/layouts/layout_save/', 'back_url' => '/admin/layouts/view_list/' ],
'cancel' => [ 'url' => '/admin/layouts/view_list/' ]
];
$grid -> external_code = $out;
$grid -> persist_edit = true;
$grid -> id_param = 'id';
$gridId = 'layout-edit';
$gridTitle = 'Edycja szablonu';
$gridSaveUrl = '/admin/layouts/save/';
$gridBackUrl = '/admin/layouts/list/';
$gridHidden = [['name' => 'id', 'value' => $this->layout['id']]];
$gridContent = $out;
$gridPersist = true;
include __DIR__ . '/../components/grid-edit-replacement.php';
?>
echo $grid -> draw();
?>

View File

@@ -1,54 +1 @@
<?php
global $gdb;
$grid = new \grid( 'pp_layouts' );
$grid -> gdb_opt = $gdb;
$grid -> order = [ 'column' => 'name', 'type' => 'ASC' ];
$grid -> search = [
[ 'name' => 'Nazwa', 'db' => 'name', 'type' => 'text' ],
[ 'name' => 'Szablon domyślny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
];
$grid -> columns_view = [
[
'name' => 'Lp.',
'th' => [ 'class' => 'g-lp' ],
'td' => [ 'class' => 'g-center' ],
'autoincrement' => true
],
[
'name' => 'Nazwa',
'db' => 'name',
'php' => 'echo "<a href=\'/admin/layouts/layout_edit/id=[id]\'>[name]</a>";',
'sort' => true
],
[
'name' => 'Szablon domyślny',
'db' => 'status',
'replace' => [ 'array' => [ 0 => 'nie', 1 => '<span class="text-system">tak</span>' ] ],
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
],
[
'name' => 'Szablon domyślny (kategorie)',
'db' => 'categories_default',
'replace' => [ 'array' => [ 0 => 'nie', 1 => '<span class="text-system">tak</span>' ] ],
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
],
[
'name' => 'Akcja',
'action' => [ 'type' => 'edit', 'url' => '/admin/layouts/layout_edit/id=[id]' ],
'th' => [ 'class' => 'g-center' ],
'td' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ]
],
[
'name' => 'Akcja',
'action' => [ 'type' => 'delete', 'url' => '/admin/layouts/layout_delete/id=[id]' ],
'th' => [ 'class' => 'g-center' ],
'td' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ]
]
];
$grid -> buttons = [
[ 'label' => 'Dodaj szablon', 'url' => '/admin/layouts/layout_edit/', 'icon' => 'fa-plus-circle', 'class' => 'btn-success' ]
];
echo $grid -> draw();
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>

View File

@@ -0,0 +1,21 @@
<? if ( is_array( $this -> categories ) ):?>
<ol>
<? foreach ( $this -> categories as $category ):?>
<li id="list_<?= $category['id'];?>" class="list_<?= $category['id'];?>" category="<?= $category['id'];?>">
<div class="context_0 content content_menu">
<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>
</div>
<?= \Shared\Tpl\Tpl::view( 'layouts/subcategories-list', [
'categories' => $category['subcategories'],
'product_categories' => $this -> product_categories,
'dlang' => $this -> dlang
] );?>
</li>
<? endforeach;?>
</ol>
<? endif;?>

View File

@@ -3,14 +3,20 @@
<? 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>
<?
if ( is_array( $page['subpages'] ) )
echo \admin\view\Layouts::subpages_list( $page['subpages'], $this -> layout_pages, $page['id'], $this -> step + 1 );
echo \Shared\Tpl\Tpl::view( 'layouts/subpages-list', [
'pages' => $page['subpages'],
'layout_pages' => $this -> layout_pages,
'step' => $this -> step + 1
] );
?>
</li>
<? endforeach;?>
</ol>
<? endif;?>
<? endif;?>