ver. 0.279: Newsletter frontend migration, Languages facade elimination, bug fix newsletter_unsubscribe

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-16 15:11:38 +01:00
parent 59b36f48b1
commit 3b32ea0b9b
54 changed files with 579 additions and 294 deletions

View File

@@ -1,38 +0,0 @@
<?php
namespace front\controls;
class Newsletter
{
public static function signin()
{
$result = [ 'status' => 'bad' ];
if ( \front\factory\Newsletter::newsletter_signin( \S::get( 'email' ) ) )
$result = [ 'status' => 'ok' ];
echo json_encode( $result );
exit;
}
public static function confirm()
{
global $lang;
if ( \front\factory\Newsletter::newsletter_confirm( \S::get( 'hash' ) ) )
\S::alert( $lang['email-zostal-dodany-do-listy-newsletter'] );
header( 'Location: /' );
exit;
}
public static function unsubscribe()
{
global $lang;
if ( \front\factory\Newsletter::newsletter_unsubscribe( \S::get( 'hash' ) ) )
\S::alert( $lang['email-zostal-usuniety-z-listy-newsletter'] );
header( 'Location: /' );
exit;
}
}

View File

@@ -53,14 +53,21 @@ class Site
if ( $category )
return \front\view\ShopCategory::category_view( $category, $lang_id, \S::get( 'bs' ) );
// stare klasy
$class = '\front\controls\\';
$results = explode( '_', \S::get( 'module' ) );
if ( is_array( $results ) ) foreach ( $results as $row )
$class .= ucfirst( $row );
// nowe kontrolery z DI
$module = \S::get( 'module' );
$action = \S::get( 'action' );
$controllerFactories = self::getControllerFactories();
$moduleName = implode( '', array_map( 'ucfirst', explode( '_', $module ) ) );
if ( isset( $controllerFactories[$moduleName] ) and $action )
{
$controller = $controllerFactories[$moduleName]();
if ( method_exists( $controller, $action ) )
return $controller->$action();
}
// stare klasy
$class = '\front\controls\\' . $moduleName;
if ( class_exists( $class ) and method_exists( new $class, $action ) )
return call_user_func_array( array( $class, $action ), array() );
@@ -132,5 +139,17 @@ class Site
if ( file_exists( 'modules/actions.php' ) )
include 'modules/actions.php';
}
public static function getControllerFactories()
{
return [
'Newsletter' => function() {
global $mdb;
return new \front\Controllers\NewsletterController(
new \Domain\Newsletter\NewsletterRepository( $mdb )
);
},
];
}
}
?>