Phase 6 zamknięta po 2 planach. Pełny fundament dla Phase 7-13 (migracja 17 admin controllers do Admin\ namespace). 06-01 (Forms infrastructure): - Admin\ViewModels\Forms\* — 5 ViewModeli (687 L) - Admin\Validation\FormValidator (196 L) - composer.json: php >=7.4, PSR-4 paths cross-platform safe (Admin\ → autoload/admin/, Frontend\ → autoload/front/) 06-02 (Support layer): - Admin\Support\TableListRequestFactory (99 L) — parser list z $_GET - Admin\Support\Forms\FormRequestHandler (159 L) — POST + CSRF + walidacja + persist - Admin\Support\Forms\FormFieldRenderer (494 L) — renderer HTML pól Decyzje: - Brak BaseController — Phase 7+ kontrolery jako POJOs z DI (jak shopPRO) - PSR-4 filename fix: TableListRequestFactory.php (bez shopPRO 'class.' prefix) - PascalCase namespace (Admin\Support) na lowercase folder admin/ ze względu na Windows fs case-insensitivity vs legacy admin/controls/ Pliki: 8 nowych klas, 1635 L kodu PHP 7.4-kompatybilnego, zero regresji. Smoke test: walidacja e-maila zwraca PL komunikat, factory parsuje ?page=&per_page=&sort=&filter=, Domain/Shared nadal ładują się. PHPUnit: 37/37 OK. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
158 lines
6.7 KiB
Markdown
158 lines
6.7 KiB
Markdown
# Struktura projektu cmsPRO
|
||
|
||
## Punkty wejścia
|
||
|
||
| Plik | Opis |
|
||
|------|------|
|
||
| `index.php` | Router frontendu |
|
||
| `admin/index.php` | Router panelu admina |
|
||
| `ajax.php` | AJAX frontend |
|
||
| `admin/ajax.php` | AJAX admin |
|
||
| `api.php` | Publiczne API |
|
||
| `cron.php` | Zadania cykliczne (newsletter) |
|
||
| `download.php` | Chronione pobieranie plików |
|
||
|
||
Każdy punkt wejścia ładuje centralny autoloader (hybrydowy PSR-4 + legacy):
|
||
```php
|
||
require_once __DIR__ . '/autoload/autoloader.php';
|
||
```
|
||
|
||
---
|
||
|
||
## Wzorzec architektoniczny — Static Factory (MVCish)
|
||
|
||
```
|
||
autoload/{admin|front}/
|
||
├── controls/class.{Module}.php ← obsługa requestów
|
||
├── factory/class.{Module}.php ← logika biznesowa + DB
|
||
└── view/class.{Module}.php ← generowanie HTML
|
||
```
|
||
|
||
Przestrzenie nazw: `\admin\controls`, `\admin\factory`, `\admin\view`,
|
||
`\front\controls`, `\front\factory`, `\front\view`
|
||
|
||
---
|
||
|
||
## Refaktoryzacja DDD — stan aktualny
|
||
|
||
Projekt migruje stopniowo do architektury DDD. Stare klasy stają się
|
||
cienkimi wrapperami delegującymi do nowych klas w `Shared\` i `Domain\`.
|
||
|
||
### Faza 0 ✓ — Autoloader PSR-4
|
||
Centralny autoloader w `autoload/autoloader.php` (hybrydowy: PSR-4 + legacy class.*.php).
|
||
Wszystkie 7 punktów wejścia używają jednego pliku. composer.json z PSR-4 mapowaniem:
|
||
Domain\, Shared\, Admin\, Frontend\ → autoload/.
|
||
|
||
### Faza 1 ✓ — Shared utilities (`autoload/Shared/`)
|
||
|
||
```
|
||
autoload/Shared/
|
||
├── Cache/CacheHandler.php ← \Shared\Cache\CacheHandler
|
||
├── Email/Email.php ← \Shared\Email\Email
|
||
├── Helpers/Helpers.php ← \Shared\Helpers\Helpers
|
||
├── Html/Html.php ← \Shared\Html\Html
|
||
├── Image/ImageManipulator.php ← \Shared\Image\ImageManipulator
|
||
├── Security/CsrfToken.php ← \Shared\Security\CsrfToken
|
||
└── Tpl/Tpl.php ← \Shared\Tpl\Tpl
|
||
```
|
||
|
||
Stare klasy (`class.S.php`, `class.Cache.php`, itd.) są teraz cienkimi
|
||
wrapperami — zachowana pełna kompatybilność wsteczna.
|
||
Helpers::send_email() → Email, Helpers::get_token()/is_token_valid() → CsrfToken.
|
||
|
||
### Faza 2 ✓ — Domain Repositories (`autoload/Domain/`) — KOMPLETNE (13/13)
|
||
|
||
```
|
||
autoload/Domain/
|
||
├── Articles/ArticlesRepository.php ← \Domain\Articles\ArticlesRepository ✓
|
||
├── Authors/AuthorsRepository.php ← \Domain\Authors\AuthorsRepository ✓
|
||
├── Banners/BannersRepository.php ← \Domain\Banners\BannersRepository ✓
|
||
├── Cron/CronRepository.php ← \Domain\Cron\CronRepository ✓
|
||
├── Languages/LanguagesRepository.php ← \Domain\Languages\LanguagesRepository ✓
|
||
├── Layouts/LayoutsRepository.php ← \Domain\Layouts\LayoutsRepository ✓
|
||
├── Newsletter/NewsletterRepository.php ← \Domain\Newsletter\NewsletterRepository ✓
|
||
├── Pages/PagesRepository.php ← \Domain\Pages\PagesRepository ✓
|
||
├── Releases/ReleasesRepository.php ← \Domain\Releases\ReleasesRepository ✓
|
||
├── Releases/UpdateRepository.php ← \Domain\Releases\UpdateRepository ✓
|
||
├── Scontainers/ScontainersRepository.php ← \Domain\Scontainers\ScontainersRepository ✓
|
||
├── SeoAdditional/SeoAdditionalRepository.php ← \Domain\SeoAdditional\SeoAdditionalRepository ✓
|
||
├── Settings/SettingsRepository.php ← \Domain\Settings\SettingsRepository ✓
|
||
└── User/UserRepository.php ← \Domain\User\UserRepository ✓
|
||
```
|
||
|
||
### Faza 6 ✓ — Admin\ Base Infrastructure (`autoload/admin/{ViewModels,Validation,Support}/`)
|
||
|
||
Skopiowane z shopPRO i przeniesione pod `Admin\` (PSR-4 PascalCase namespace, lowercase folder ze względu na case-insensitive Windows fs):
|
||
|
||
```
|
||
autoload/admin/ ← namespace Admin\* (nowe) + admin\* (legacy)
|
||
├── ViewModels/Forms/ ← Admin\ViewModels\Forms
|
||
│ ├── FormEditViewModel.php
|
||
│ ├── FormField.php
|
||
│ ├── FormFieldType.php
|
||
│ ├── FormTab.php
|
||
│ └── FormAction.php
|
||
├── Validation/
|
||
│ └── FormValidator.php ← Admin\Validation\FormValidator
|
||
└── Support/
|
||
├── TableListRequestFactory.php ← Admin\Support — parser list (page/per_page/sort/filter)
|
||
└── Forms/
|
||
├── FormRequestHandler.php ← Admin\Support\Forms — POST + CSRF + validate + persist
|
||
└── FormFieldRenderer.php ← Admin\Support\Forms — HTML renderer (deleguje Shared\Html\Html)
|
||
```
|
||
|
||
Decyzja: **brak BaseController** — Phase 7+ kontrolery będą POJOs z DI w konstruktorze (jak shopPRO `BannerController(BannerRepository, LanguagesRepository)`).
|
||
|
||
Następne: `Admin\` controllers (Fazy 7–13), `Frontend\` namespace (Fazy 14–16).
|
||
---
|
||
|
||
## Katalogi
|
||
|
||
| Katalog | Zawartość |
|
||
|---------|-----------|
|
||
| `autoload/` | Klasy PHP (modele, kontrolery, fabryki, widoki, Shared, Domain) |
|
||
| `admin/templates/` | Szablony panelu admina (17 modułów) |
|
||
| `templates/` | Szablony frontendu (systemowe, tylko do odczytu) |
|
||
| `templates_user/` | Szablony frontendu (nadpisywalne przez użytkownika) |
|
||
| `layout/` | SCSS → CSS (style.scss → style.css) |
|
||
| `upload/` | Pliki użytkownika (article_images/, article_files/, filemanager/) |
|
||
| `libraries/` | Zewnętrzne biblioteki (Medoo, CKEditor, Bootstrap, jQuery…) |
|
||
| `plugins/` | Hooki (special-actions.php, -middle.php, -end.php) |
|
||
| `migrations/` | Pliki SQL per wersja (np. `0.304.sql`) |
|
||
| `updates/` | Paczki ZIP aktualizacji |
|
||
| `temp/` | Cache plikowy (gzip, 24h, generowany automatycznie) |
|
||
| `docs/` | Dokumentacja techniczna |
|
||
|
||
---
|
||
|
||
## Kluczowe klasy
|
||
|
||
| Klasa | Opis |
|
||
|-------|------|
|
||
| `\Shared\Helpers\Helpers` (`class.S.php`) | Megautylita: sesja, cookie, email, SEO, detekcja botów |
|
||
| `\Shared\Tpl\Tpl` (`class.Tpl.php`) | Silnik szablonów |
|
||
| `\Shared\Cache\CacheHandler` (`class.Cache.php`) | Cache plikowy |
|
||
| `\Shared\Html\Html` (`class.Html.php`) | Builder komponentów formularzy |
|
||
| `\Shared\Image\ImageManipulator` (`class.Image.php`) | Manipulacja obrazami + WebP |
|
||
| `class.Article.php` | Model artykułu (ArrayAccess, lazy multilang) |
|
||
|
||
---
|
||
|
||
## Baza danych
|
||
|
||
Prefiks tabel: `pp_`. ORM: Medoo (globalny `$mdb`). Konfiguracja: `config.php`.
|
||
|
||
Główne tabele: `pp_users`, `pp_articles`, `pp_articles_langs`, `pp_pages`,
|
||
`pp_pages_langs`, `pp_languages`, `pp_settings`, `pp_newsletter`,
|
||
`pp_newsletter_users`, `pp_tags`, `pp_banners`, `pp_layouts`, `pp_backups`.
|
||
|
||
---
|
||
|
||
## System wielojęzyczny
|
||
|
||
- Sesja: `$_SESSION['current-lang']`
|
||
- Tabela: `pp_languages`
|
||
- Składnia w treści: `[LANG:klucz]`
|
||
- Cache tłumaczeń: `$_SESSION['lang-{lang_id}']`
|
||
|