refactor layouts module to domain/di and prepare 0.256 release

This commit is contained in:
2026-02-12 22:54:47 +01:00
parent 5e9b998043
commit 76287923e8
24 changed files with 970 additions and 315 deletions

View File

@@ -182,7 +182,11 @@ ob_start();
<span class="disclose"><span></span></span>
Menu: <b><?= $menu['name'];?></b>
</div>
<?= \admin\view\Layouts::subpages_list( \admin\factory\Pages::menu_pages( $menu['id'] ), $this -> layout['pages'] );?>
<?= \Tpl::view( 'layouts/subpages-list', [
'pages' => $menu['pages'],
'layout_pages' => $this -> layout['pages'],
'step' => 1
] );?>
</li>
</ol>
</div>
@@ -202,8 +206,8 @@ ob_start();
<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'] ),
<?= \Tpl::view( 'layouts/subcategories-list', [
'categories' => $category['subcategories'],
'product_categories' => $this -> layout['categories'],
'dlang' => $this -> dlang
] );?>
@@ -250,4 +254,4 @@ $grid -> persist_edit = true;
$grid -> id_param = 'id';
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();
<?= \Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>

View File

@@ -0,0 +1,20 @@
<? 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">
<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( $this -> product_categories ) and in_array( $category['id'], $this -> product_categories ) ):?>checked="checked"<? endif;?> />
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
</div>
<?= \Tpl::view( 'layouts/subcategories-list', [
'categories' => $category['subcategories'],
'product_categories' => $this -> product_categories,
'dlang' => $this -> dlang
] );?>
</li>
<? endforeach;?>
</ol>
<? endif;?>

View File

@@ -8,9 +8,13 @@
</div>
<?
if ( is_array( $page['subpages'] ) )
echo \admin\view\Layouts::subpages_list( $page['subpages'], $this -> layout_pages, $page['id'], $this -> step + 1 );
echo \Tpl::view( 'layouts/subpages-list', [
'pages' => $page['subpages'],
'layout_pages' => $this -> layout_pages,
'step' => $this -> step + 1
] );
?>
</li>
<? endforeach;?>
</ol>
<? endif;?>
<? endif;?>