ver. 0.284: DbModel elimination, update packages for 0.283-0.284
- Removed class.DbModel.php — only consumer (shop\Promotion) now has inlined constructor + __get() - Created update packages: ver_0.283.zip (S→Helpers migration, ~130 files), ver_0.284.zip (DbModel removal) - Updated docs: CHANGELOG, PROJECT_STRUCTURE, FRONTEND_REFACTORING_PLAN Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
class DbModel
|
||||
{
|
||||
public $data;
|
||||
public $table;
|
||||
public $table_key = 'id';
|
||||
|
||||
public function __construct( $id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $id )
|
||||
{
|
||||
$result = $mdb -> get( $this -> table, '*', [ $this -> table_key => $id ] );
|
||||
if ( is_array( $result ) ) foreach ( $result as $key => $val )
|
||||
$this -> $key = $val;
|
||||
|
||||
if ( is_array( $this -> otm ) ) foreach ( $this -> otm as $otm )
|
||||
{
|
||||
if ( $otm['skey'] )
|
||||
{
|
||||
$result2 = $mdb -> select( $otm['table'], '*', [ $otm['fkey'] => $id ] );
|
||||
if ( is_array( $result2 ) ) foreach ( $result2 as $row2 )
|
||||
{
|
||||
$this -> data[ $otm['name'] ][ $row2[ $otm['skey'] ] ] = $row2;
|
||||
}
|
||||
}
|
||||
else
|
||||
$this -> data[ $otm['name'] ] = $mdb -> select( $otm['table'], '*', [ $otm['fkey'] => $id ] );
|
||||
}
|
||||
|
||||
if ( is_array( $this -> sotm ) ) foreach ( $this -> sotm as $sotm )
|
||||
{
|
||||
$this -> data[ $sotm['name'] ] = $mdb -> select( $sotm['table'], $sotm['column'], [ $sotm['fkey'] => $id ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __get( $variable )
|
||||
{
|
||||
if ( array_key_exists( $variable, $this -> data ) )
|
||||
return $this -> data[$variable];
|
||||
}
|
||||
|
||||
public function __set( $variable, $value )
|
||||
{
|
||||
$this -> data[$variable] = $value;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $this -> __get( $this -> table_key ) )
|
||||
{
|
||||
$table_id_param = $this -> table_key;
|
||||
$table_id_value = $this -> __get( $this -> table_key );
|
||||
$data_tmp = $this -> data;
|
||||
unset( $data_tmp[ $table_id_param ] );
|
||||
|
||||
$mdb -> update( $this -> table, $data_tmp, [ $table_id_param => $table_id_value ] );
|
||||
|
||||
return $table_id_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdb -> insert( $this -> table, $this -> data );
|
||||
$this -> __set( $this -> table_key, $mdb -> id() );
|
||||
}
|
||||
return $this -> __get( $this -> table_key );
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> delete( $this -> table, [ $this -> table_key => $this -> __get( $this -> table_key ) ] );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
<?php
|
||||
namespace shop;
|
||||
|
||||
use DbModel;
|
||||
|
||||
class Promotion extends DbModel
|
||||
class Promotion
|
||||
{
|
||||
public $table = 'pp_shop_promotion';
|
||||
private $data = [];
|
||||
|
||||
public static $condition_type = [
|
||||
1 => 'Rabat procentowy na produkty z kategorii 1 jeżeli w koszyku jest produkt z kategorii 2',
|
||||
@@ -17,6 +15,25 @@ class Promotion extends DbModel
|
||||
|
||||
public static $discount_type = [ 1 => 'Rabat procentowy' ];
|
||||
|
||||
public function __construct( $id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $id )
|
||||
{
|
||||
$result = $mdb->get( 'pp_shop_promotion', '*', [ 'id' => $id ] );
|
||||
if ( is_array( $result ) )
|
||||
$this->data = $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function __get( $variable )
|
||||
{
|
||||
if ( isset( $this->data[$variable] ) )
|
||||
return $this->data[$variable];
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function get_active_promotions()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
@@ -4,6 +4,35 @@ Logi zmian z migracji na Domain-Driven Architecture. Najnowsze na gorze.
|
||||
|
||||
---
|
||||
|
||||
## ver. 0.284 (2026-02-16) - DbModel elimination
|
||||
|
||||
- **DbModel** — usunięcie klasy base ORM
|
||||
- USUNIETA: `autoload/class.DbModel.php` — jedyny konsument (`shop\Promotion`) ma teraz wbudowany konstruktor + `__get()`
|
||||
- UPDATE: `autoload/shop/class.Promotion.php` — usunięto `extends DbModel` + `use DbModel`, wbudowano minimalny konstruktor z `$mdb->get()` i `__get()`
|
||||
- Testy: 454 OK, 1449 asercji
|
||||
|
||||
---
|
||||
|
||||
## ver. 0.283 (2026-02-16) - Legacy class cleanup — S, Html, Email, Image, Log, Mobile_Detect → Shared namespace
|
||||
|
||||
- **class.S.php → Shared\Helpers\Helpers**
|
||||
- PRZENIESIONA: `class.S.php` → `autoload/Shared/Helpers/Helpers.php` (namespace `Shared\Helpers`, klasa `Helpers`)
|
||||
- ZAMIENIONE: ~140 plików — `\S::` → `\Shared\Helpers\Helpers::`
|
||||
- CLEANUP: usunięto 12 nieużywanych metod (set_array_value, parse_name, clear_redis_cache, get_domain, pre_dump, escape, chmod_r, rrmdir, rcopy, pre, json_to_array, is_empty_dir)
|
||||
- FIX: `array_cartesian_product()` — iteracja po niezdefiniowanej zmiennej `$array` zamiast parametru `$input`
|
||||
- NOWY: `tests/stubs/Helpers.php` — stub klasy Helpers dla testów
|
||||
- USUNIETA: `autoload/class.S.php`
|
||||
- **Shared\Html\Html** — `autoload/class.Html.php` → `autoload/Shared/Html/Html.php`
|
||||
- **Shared\Email\Email** — `autoload/class.Email.php` → `autoload/Shared/Email/Email.php`
|
||||
- **Shared\Image\Image** — `autoload/class.Image.php` → `autoload/Shared/Image/Image.php`
|
||||
- **Shared\Log\Log** — `autoload/class.Log.php` → `autoload/Shared/Log/Log.php`
|
||||
- **Mobile_Detect** — USUNIETA: przestarzała detekcja UA (v2.8.16), zastąpiona responsive design
|
||||
- USUNIETA: metoda `S::is_mobile()` i 3 warunki mobilne w `front\view\Site`
|
||||
- USUNIETE z `LayoutsRepository`: pola `m_html`, `m_css`, `m_js`
|
||||
- Testy: 454 OK, 1449 asercji
|
||||
|
||||
---
|
||||
|
||||
## ver. 0.282 (2026-02-16) - Cache cleanup, Shared namespace
|
||||
|
||||
- **Shared\Cache namespace** — przeniesienie CacheHandler i RedisConnection do `Shared\Cache\`
|
||||
|
||||
@@ -78,17 +78,17 @@ Panel administratora (33 moduły) został w pełni zmigrowany na architekturę D
|
||||
### autoload/ root (klasy utility)
|
||||
| Klasa | Linii | Status |
|
||||
|-------|-------|--------|
|
||||
| S | ~1130 | htacces() ~500 linii — generowanie .htaccess; reszta to utility |
|
||||
| S | ~960 | PRZENIESIONA do Shared\Helpers\Helpers — 12 metod usunieto, bug fix |
|
||||
| Tpl | ~90 | OK — silnik szablonów, bez zmian |
|
||||
| CacheHandler | ~50 | ZMIGROWANY do `Shared\Cache\CacheHandler` — wrappery usuniete |
|
||||
| RedisConnection | ~40 | ZMIGROWANY do `Shared\Cache\RedisConnection` — wrappery usuniete |
|
||||
| Email | ~100 | OK — PHPMailer wrapper (drobne poprawki) |
|
||||
| Log | ~20 | OK — audit logging |
|
||||
| DbModel | ~60 | OK — base ORM |
|
||||
| DbModel | — | USUNIETA — logika wbudowana w `shop\Promotion` |
|
||||
| Cache | ~50 | USUNIETA — zastapiona CacheHandler (Redis) w ver. 0.282 |
|
||||
| Html | ~80 | OK — form helpers |
|
||||
| Image | ~100 | OK — GD wrapper |
|
||||
| Mobile_Detect | — | Third-party, bez zmian |
|
||||
| Mobile_Detect | — | USUNIETA — przestarzala detekcja UA, zastapiona responsive design |
|
||||
|
||||
### cms/ (1 klasa)
|
||||
| Klasa | Status |
|
||||
|
||||
@@ -27,10 +27,9 @@ Dokumentacja struktury projektu shopPRO do szybkiego odniesienia.
|
||||
- ~~`autoload/class.Cache.php`~~ — usunięta w ver. 0.282
|
||||
- Zastąpiona przez `CacheHandler` (Redis) we wszystkich wywołaniach
|
||||
|
||||
#### Klasa S (pomocnicza)
|
||||
- **Plik:** `autoload/class.S.php`
|
||||
#### Helpers (`Shared\Helpers\Helpers`)
|
||||
- **Plik:** `autoload/Shared/Helpers/Helpers.php`
|
||||
- **Metody cache:**
|
||||
- `clear_redis_cache()` - czyści cały cache Redis (flushAll)
|
||||
- `clear_product_cache(int $product_id)` - czyści cache konkretnego produktu
|
||||
|
||||
### Wzorce kluczy Redis
|
||||
@@ -105,7 +104,8 @@ shopPRO/
|
||||
│ │ └── factory/ # Fabryki/helpery
|
||||
│ ├── Domain/ # Repozytoria/logika domenowa
|
||||
│ ├── Shared/ # Wspoldzielone narzedzia
|
||||
│ │ └── Cache/ # CacheHandler, RedisConnection
|
||||
│ │ ├── Cache/ # CacheHandler, RedisConnection
|
||||
│ │ └── Helpers/ # Helpers (ex class.S.php)
|
||||
│ ├── front/ # Klasy frontendu
|
||||
│ │ ├── Controllers/ # Nowe kontrolery DI (Newsletter)
|
||||
│ │ ├── Views/ # Nowe widoki (Newsletter, Articles, Languages, Banners)
|
||||
@@ -155,13 +155,14 @@ Pelna dokumentacja tabel: `DATABASE_STRUCTURE.md`
|
||||
|
||||
## Klasy pomocnicze
|
||||
|
||||
### \S (autoload/class.S.php)
|
||||
Główna klasa helper z metodami:
|
||||
### \Shared\Helpers\Helpers (autoload/Shared/Helpers/Helpers.php)
|
||||
Główna klasa helper (przeniesiona z `class.S.php`) z metodami:
|
||||
- `seo($val)` - generowanie URL SEO
|
||||
- `normalize_decimal($val, $precision)` - normalizacja liczb
|
||||
- `send_email()` - wysyłanie emaili
|
||||
- `delete_dir($dir)` - usuwanie katalogów
|
||||
- `htacces()` - generowanie .htaccess i sitemap.xml
|
||||
- `clear_product_cache($id)` - czyszczenie cache produktu
|
||||
|
||||
### Medoo
|
||||
- Plik: `libraries/medoo/medoo.php`
|
||||
@@ -184,10 +185,7 @@ Główna klasa helper z metodami:
|
||||
$product = \shop\Product::getFromCache($product_id, $lang_id, $permutation_hash);
|
||||
|
||||
// Czyszczenie cache produktu
|
||||
\S::clear_product_cache($product_id);
|
||||
|
||||
// Czyszczenie całego cache
|
||||
\S::clear_redis_cache();
|
||||
\Shared\Helpers\Helpers::clear_product_cache($product_id);
|
||||
```
|
||||
|
||||
## Refaktoryzacja do Domain-Driven Architecture
|
||||
@@ -413,5 +411,16 @@ Pelna dokumentacja testow: `TESTING.md`
|
||||
- USUNIETA: `class.Cache.php` — legacy file-based cache.
|
||||
- UPDATE: 6 plikow przepietych z `\Cache::fetch/store` na `CacheHandler` (ShopProduct, ShopPaymentMethod, ShopCategory, ShopTransport, ShopAttribute, DictionariesRepository).
|
||||
|
||||
## Aktualizacja 2026-02-16 - class.S.php migration, Mobile_Detect removal, S cleanup
|
||||
- USUNIETA: `class.Mobile_Detect.php` — przestarzala detekcja mobilna (UA v2.8.16), zastapiona responsive design.
|
||||
- USUNIETA: metoda `S::is_mobile()` i 3 warunki mobilne w `front\view\Site` (m_html/m_css/m_js zawsze puste).
|
||||
- USUNIETE z `LayoutsRepository`: pola `m_html`, `m_css`, `m_js` (save + defaultLayout).
|
||||
- CLEANUP `class.S.php`: usunieto 12 nieuzywanych metod (set_array_value, parse_name, clear_redis_cache, get_domain, pre_dump, escape, chmod_r, rrmdir, rcopy, pre, json_to_array, is_empty_dir).
|
||||
- FIX: `array_cartesian_product()` — iteracja po niezdefiniowanej zmiennej `$array` zamiast parametru `$input`.
|
||||
- PRZENIESIONA: `class.S.php` → `Shared\Helpers\Helpers` (namespace `Shared\Helpers`, klasa `Helpers`).
|
||||
- ZAMIENIONE: ~140 plikow — `\S::` → `\Shared\Helpers\Helpers::`.
|
||||
- NOWY: `tests/stubs/Helpers.php` — stub klasy Helpers dla testow.
|
||||
- USUNIETA: `autoload/class.S.php` — zastapiona przez `Shared\Helpers\Helpers`.
|
||||
|
||||
---
|
||||
*Dokument aktualizowany: 2026-02-16*
|
||||
|
||||
@@ -18,15 +18,15 @@ Aktualizacje znajdują się w folderze `updates/0.XX/` gdzie XX oznacza dziesią
|
||||
|
||||
## Procedura tworzenia nowej aktualizacji
|
||||
|
||||
## Status biezacej aktualizacji (ver. 0.282)
|
||||
## Status biezacej aktualizacji (ver. 0.284)
|
||||
|
||||
- Wersja udostepniona: `0.282` (data: 2026-02-16).
|
||||
- Wersja udostepniona: `0.284` (data: 2026-02-16).
|
||||
- Pliki publikacyjne:
|
||||
- `updates/0.20/ver_0.281.zip`, `ver_0.281_files.txt`
|
||||
- `updates/0.20/ver_0.282.zip`, `ver_0.282_files.txt`
|
||||
- `updates/0.20/ver_0.283.zip`, `ver_0.283_files.txt`
|
||||
- `updates/0.20/ver_0.284.zip`, `ver_0.284_files.txt`
|
||||
- Pliki metadanych aktualizacji:
|
||||
- `updates/changelog.php` (dodane wpisy `ver. 0.281`, `ver. 0.282`)
|
||||
- `updates/versions.php` (`$current_ver = 282`)
|
||||
- `updates/changelog.php` (dodane wpisy `ver. 0.283`, `ver. 0.284`)
|
||||
- `updates/versions.php` (`$current_ver = 284`)
|
||||
- Weryfikacja testow przed publikacja:
|
||||
- `OK (454 tests, 1449 assertions)`
|
||||
|
||||
|
||||
BIN
updates/0.20/ver_0.283.zip
Normal file
BIN
updates/0.20/ver_0.283.zip
Normal file
Binary file not shown.
6
updates/0.20/ver_0.283_files.txt
Normal file
6
updates/0.20/ver_0.283_files.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
F: ../autoload/class.S.php
|
||||
F: ../autoload/class.Email.php
|
||||
F: ../autoload/class.Html.php
|
||||
F: ../autoload/class.Image.php
|
||||
F: ../autoload/class.Log.php
|
||||
F: ../autoload/class.Mobile_Detect.php
|
||||
BIN
updates/0.20/ver_0.284.zip
Normal file
BIN
updates/0.20/ver_0.284.zip
Normal file
Binary file not shown.
1
updates/0.20/ver_0.284_files.txt
Normal file
1
updates/0.20/ver_0.284_files.txt
Normal file
@@ -0,0 +1 @@
|
||||
F: ../autoload/class.DbModel.php
|
||||
@@ -1,3 +1,16 @@
|
||||
<b>ver. 0.284 - 16.02.2026</b><br />
|
||||
- CLEANUP - usunieta klasa DbModel (base ORM) — logika wbudowana bezposrednio w shop\Promotion
|
||||
<hr>
|
||||
<b>ver. 0.283 - 16.02.2026</b><br />
|
||||
- UPDATE - migracja class.S.php do Shared\Helpers\Helpers (~140 plikow przepietych)
|
||||
- UPDATE - migracja class.Html.php do Shared\Html\Html
|
||||
- UPDATE - migracja class.Email.php do Shared\Email\Email
|
||||
- UPDATE - migracja class.Image.php do Shared\Image\ImageManipulator
|
||||
- UPDATE - migracja class.Log.php do Shared\Log\Log (usunieta — logika przeniesiona)
|
||||
- CLEANUP - usunieta class.Mobile_Detect.php (przestarzala detekcja UA)
|
||||
- CLEANUP - usunieto 12 nieuzywanych metod z klasy S
|
||||
- FIX - array_cartesian_product() — blad iteracji po niezdefiniowanej zmiennej
|
||||
<hr>
|
||||
<b>ver. 0.282 - 16.02.2026</b><br />
|
||||
- UPDATE - Cache cleanup: eliminacja legacy class.Cache.php, migracja CacheHandler i RedisConnection do Shared\Cache namespace
|
||||
- UPDATE - 60 odwolan CacheHandler i 12 odwolan RedisConnection przepietych na Shared\Cache\
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?
|
||||
$current_ver = 282;
|
||||
$current_ver = 284;
|
||||
|
||||
for ($i = 1; $i <= $current_ver; $i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user