Add new controllers for file management and product archiving

- Introduced FilemanagerController to handle file manager access and URL generation.
- Added ProductArchiveController for managing archived products, including listing and unarchiving functionality.
- Implemented Site class with methods for finalizing admin login and handling special actions.
- Created ShopProduct control class for managing product operations, including mass editing, product duplication, and image handling.
- Added necessary methods for product management, including saving, deleting, and changing product statuses.
This commit is contained in:
2026-02-11 00:26:01 +01:00
parent fdf3900b8d
commit f5054047fd
16 changed files with 2005 additions and 123 deletions

View File

@@ -19,7 +19,9 @@ autoload/
│ ├── Banner/
│ │ └── BannerRepository.php # ✅ Zmigrowane (find, delete, save)
│ ├── Settings/
│ │ └── SettingsRepository.php # ✅ Zmigrowane (saveSettings, getSettings) - fasada → factory
│ │ └── SettingsRepository.php # ✅ Zmigrowane (saveSettings, getSettings) - bezposrednio DB
│ ├── Dictionaries/
│ │ └── DictionariesRepository.php # ✅ Zmigrowane (listForAdmin, find, save, delete, allUnits)
│ ├── Cache/
│ │ └── CacheRepository.php # ✅ Zmigrowane (clearCache)
│ ├── Order/
@@ -28,7 +30,11 @@ autoload/
├── admin/ # Warstwa administratora (istniejący katalog!)
│ ├── Controllers/ # Nowe kontrolery - namespace \admin\Controllers\
│ │ ├── ArticlesController.php
│ │ ├── BannerController.php
│ │ ├── DictionariesController.php
│ │ ├── FilemanagerController.php
│ │ ├── ProductArchiveController.php
│ │ └── SettingsController.php
│ ├── controls/ # Stare kontrolery (legacy fallback)
│ ├── factory/ # Stare helpery (legacy)
@@ -134,7 +140,7 @@ grep -r "Product::getQuantity" .
- ✅ RedisConnection - singleton
- ✅ S::clear_product_cache() - nowa metoda
### 🔄 W trakcie
### 🔄 Status modułów
- **Product**
- ✅ get_product_quantity() - **ZMIGROWANE** (2025-02-05) 🎉
- Nowa klasa: `Domain\Product\ProductRepository::getQuantity()`
@@ -158,10 +164,11 @@ grep -r "Product::getQuantity" .
- ✅ archive() / unarchive() - **ZMIGROWANE** (2026-02-06) 🎉
- Nowe metody: `Domain\Product\ProductRepository::archive()`, `unarchive()`
- Nowy kontroler: `admin\Controllers\ProductArchiveController` (DI, instancyjny)
- Szablony: `admin/templates/product_archive/` (rename z `archive/`)
- Szablony: `admin/templates/product-archive/` (rename z `archive/`, dawniej `product_archive/`)
- Testy: ✅ 4 nowe testy repozytorium + 6 testów kontrolera
- FIX: SQL bug w `ajax_products_list_archive()` (puste wyszukiwanie + brak `archive = 1`)
- Aktualizacja: ver. 0.241
- Dalsze porządki: ver. 0.252 (nowy table-list, wydzielony custom script, usunięte legacy pliki)
- Aktualizacja: ver. 0.241 / 0.252
- [ ] is_product_on_promotion() - NASTĘPNA 👉
- **Banner** (DEMO pełnej migracji kontrolera)
@@ -214,25 +221,41 @@ grep -r "Product::getQuantity" .
- FIX: `\S::htacces()` komentuje `AddHandler|SetHandler|ForceType` dla zgodnosci z hostingiem
- UPDATE: `libraries/htaccess.conf` zaktualizowany, aby poprawki nie znikaly po regeneracji
- **Settings** (migracja kontrolera - krok pośredni)
- **Settings** (migracja kontrolera)
- ✅ SettingsRepository - **ZMIGROWANE** (2026-02-05) 🎉
- Nowa klasa: `Domain\Settings\SettingsRepository` (saveSettings, getSettings)
- Krok pośredni: fasada nad `admin\factory\Settings` (docelowo DI z $db)
- Aktualny stan: bezpośredni dostęp do DB (usunięta delegacja do `admin\factory\Settings`) - ver. 0.250
- Nowy kontroler: `admin\Controllers\SettingsController` (DI, instancyjny)
- Testy: ✅ 3 testy (instancja, metody)
- Stary kontroler `admin\controls\Settings` zachowany jako fallback
- Aktualizacja: ver. 0.240
- Aktualizacja: ver. 0.240 / 0.250
- ✅ CacheRepository - **ZMIGROWANE** (2026-02-05) 🎉
- Nowa klasa: `Domain\Cache\CacheRepository` (clearCache)
- Używa `\S::delete_dir()` + `\RedisConnection`
- Testy: ✅ 4 testy (z Redis, bez Redis, niedostępny, struktura)
- Aktualizacja: ver. 0.240
- **Dictionaries** (migracja kontrolera i repozytorium)
- ✅ DictionariesRepository - **ZMIGROWANE** (2026-02-09) 🎉
- Nowa klasa: `Domain\Dictionaries\DictionariesRepository` (listForAdmin, find, save, delete, allUnits)
- Nowy kontroler: `admin\Controllers\DictionariesController` (DI, instancyjny)
- Migracja na nowe komponenty: `components/table-list` + `components/form-edit`
- Legacy cleanup: usunięto klasy z `admin\controls`, `admin\factory`, `front\factory`
- Aktualizacja: ver. 0.251
- **Filemanager** (migracja routingu)
- ✅ FilemanagerController - **ZMIGROWANE** (2026-02-10) 🎉
- Nowy kontroler: `admin\Controllers\FilemanagerController`
- Naprawa błędu: `Invalid Key`
- Legacy cleanup: usunięto `autoload/admin/controls/class.Filemanager.php` i `autoload/admin/view/class.FileManager.php`
- Aktualizacja: ver. 0.252
### 📋 Do zrobienia
- Order
- Category
- ShopAttribute
- ShopProduct (factory)
- Pages (`browse_list` i widoki drzewiaste nadal w legacy `admin\controls` / `admin\view`)
## Testowanie
@@ -247,17 +270,21 @@ composer require --dev phpunit/phpunit
tests/
├── Unit/
│ ├── Domain/
│ │ ├── Product/ProductRepositoryTest.php # 15 testów
│ │ ├── Banner/BannerRepositoryTest.php # 4 testy
│ │ ├── Settings/SettingsRepositoryTest.php # 3 testy
│ │ ── Cache/CacheRepositoryTest.php # 4 testy
│ │ ├── Article/ArticleRepositoryTest.php
│ │ ├── Banner/BannerRepositoryTest.php
│ │ ├── Cache/CacheRepositoryTest.php
│ │ ── Dictionaries/DictionariesRepositoryTest.php
│ │ ├── Product/ProductRepositoryTest.php
│ │ └── Settings/SettingsRepositoryTest.php
│ └── admin/
│ └── Controllers/
│ ├── SettingsControllerTest.php # 7 testów
── ProductArchiveControllerTest.php # 6 testów
│ ├── ArticlesControllerTest.php
── DictionariesControllerTest.php
│ ├── ProductArchiveControllerTest.php
│ └── SettingsControllerTest.php
└── Integration/
```
**Łącznie: 48 testów, 91 asercji**
**Łącznie: 82 testów, 181 asercji**
### Przykład testu
```php
@@ -337,11 +364,14 @@ vendor/bin/phpstan analyse autoload/Domain
- [ ] getFromCache
- [ ] getProductImg
3. **Banner** ✅ (pełna migracja kontrolera, ver. 0.239)
4. **Settings** ✅ (migracja kontrolera - krok pośredni, ver. 0.240)
5. **ProductArchive** ✅ (migracja kontrolera + cleanup szablonów, ver. 0.241)
6. **Order**
5. **Category**
6. **ShopAttribute**
4. **Settings** ✅ (pełna migracja repo/kontrolera + cleanup legacy, ver. 0.250)
5. **Dictionaries** ✅ (repo + kontroler + form/table, ver. 0.251)
6. **ProductArchive** ✅ (migracja kontrolera + cleanup szablonów, ver. 0.252)
7. **Filemanager** ✅ (migracja routingu + fix `Invalid Key`, ver. 0.252)
8. **Order**
9. **Category**
10. **ShopAttribute**
11. **Pages** (`browse_list` i powiązane widoki nadal legacy)
- **Form Edit System** - Nowy uniwersalny system formularzy edycji
- ✅ Klasy ViewModel: `FormFieldType`, `FormField`, `FormTab`, `FormAction`, `FormEditViewModel`
@@ -352,11 +382,11 @@ vendor/bin/phpstan analyse autoload/Domain
- ✅ BannerController - przerobiony na nowy system formularzy
- Wspierane typy pól: text, number, email, password, date, datetime, switch, select, textarea, editor, image, file, hidden, lang_section
- Obsługa zakładek (vertical) i sekcji językowych (horizontal)
- **Do zrobienia**: Przerobić pozostałe kontrolery (Articles, Settings, Product, Category, itd.)
- **Do zrobienia**: Przerobić pozostałe kontrolery/formularze (Product, Category, Pages, itd.)
---
*Rozpoczęto: 2025-02-05*
*Ostatnia aktualizacja: 2026-02-08*
*Ostatnia aktualizacja: 2026-02-10*
## Form Edit System - Dokumentacja użycia