67 lines
2.4 KiB
PHP
67 lines
2.4 KiB
PHP
<?php
|
|
namespace admin\controls;
|
|
class ShopCategory
|
|
{
|
|
public static function category_products()
|
|
{
|
|
return \Tpl::view( 'shop-category/category-products', [
|
|
'category_id' => \S::get( 'id' ),
|
|
'products' => \admin\factory\ShopCategory::category_products( (int)\S::get( 'id' ) )
|
|
] );
|
|
}
|
|
|
|
public static function category_url_browser() {
|
|
echo \Tpl::view( 'shop-category/category-browse-list', [
|
|
'categories' => \admin\factory\ShopCategory::subcategories( null ),
|
|
'level' => 0,
|
|
'dlang' => \front\factory\Languages::default_language()
|
|
] );
|
|
exit;
|
|
}
|
|
|
|
public static function category_delete()
|
|
{
|
|
if ( \admin\factory\ShopCategory::category_delete( \S::get( 'id' ) ) )
|
|
\S::set_message( 'Kategoria została usunięta.' );
|
|
else
|
|
\S::alert( 'Podczas usuwania kategorii wystąpił błąd. Aby usunąć kategorię nie może ona posiadać przypiętych podkategorii.' );
|
|
header( 'Location: /admin/shop_category/view_list/' );
|
|
exit;
|
|
}
|
|
|
|
static public function save()
|
|
{
|
|
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kategorii wystąpił błąd. Proszę spróbować ponownie.' ];
|
|
$values = json_decode( \S::get( 'values' ), true );
|
|
|
|
if ( $id = \admin\factory\ShopCategory::save(
|
|
$values['id'], $values['title'], $values['text'], $values['text_hidden'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['parent_id'], $values['status'],
|
|
$values['noindex'], $values['category_title'], $values['sort_type'], $values['additional_text'], $values['view_subcategories']
|
|
) )
|
|
$response = [ 'status' => 'ok', 'msg' => 'Kategoria została zapisana.', 'id' => $id ];
|
|
|
|
echo json_encode( $response );
|
|
exit;
|
|
}
|
|
|
|
public static function category_edit()
|
|
{
|
|
return \admin\view\ShopCategory::category_edit(
|
|
\admin\factory\ShopCategory::category_details(
|
|
\S::get( 'id' )
|
|
),
|
|
\S::get( 'pid' ),
|
|
( new \Domain\Languages\LanguagesRepository( $GLOBALS['mdb'] ) )->languagesList()
|
|
);
|
|
}
|
|
|
|
public static function view_list()
|
|
{
|
|
return \Tpl::view( 'shop-category/categories-list', [
|
|
'categories' => \admin\factory\ShopCategory::subcategories( null ),
|
|
'level' => 0,
|
|
'dlang' => \front\factory\Languages::default_language()
|
|
] );
|
|
}
|
|
}
|