124 lines
4.4 KiB
Markdown
124 lines
4.4 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 dwa autoloadery (PSR-4 + legacy):
|
|
```php
|
|
spl_autoload_register(function($class) { /* PSR-4: src/ → autoload/ */ });
|
|
spl_autoload_register(function($class) { /* legacy: class.{Name}.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
|
|
Dodany do wszystkich 6 punktów wejścia. Mapowanie: namespace → `autoload/`.
|
|
|
|
### Faza 1 ✓ — Shared utilities (`autoload/Shared/`)
|
|
|
|
```
|
|
autoload/Shared/
|
|
├── Cache/CacheHandler.php ← \Shared\Cache\CacheHandler
|
|
├── Email/ ← \Shared\Email\*
|
|
├── Helpers/Helpers.php ← \Shared\Helpers\Helpers
|
|
├── Html/Html.php ← \Shared\Html\Html
|
|
├── Image/ImageManipulator.php ← \Shared\Image\ImageManipulator
|
|
└── Tpl/Tpl.php ← \Shared\Tpl\Tpl
|
|
```
|
|
|
|
Stare klasy (`class.S.php`, `class.Cache.php`, itd.) są teraz cienkimi
|
|
wrapperami — zachowana pełna kompatybilność wsteczna.
|
|
|
|
### Faza 2 (w toku) - Domain Repositories (`autoload/Domain/`)
|
|
|
|
```
|
|
autoload/Domain/
|
|
|- Languages/LanguagesRepository.php <- \Domain\Languages\LanguagesRepository OK
|
|
|- Settings/SettingsRepository.php <- \Domain\Settings\SettingsRepository OK
|
|
|- User/UserRepository.php <- \Domain\User\UserRepository OK
|
|
|- Pages/PagesRepository.php <- \Domain\Pages\PagesRepository OK
|
|
|- Layouts/LayoutsRepository.php <- \Domain\Layouts\LayoutsRepository OK
|
|
`- Articles/ArticlesRepository.php <- \Domain\Articles\ArticlesRepository OK (w toku)
|
|
```
|
|
|
|
Nastepne: `Domain\Banners`, `Domain\Authors`, `Domain\Newsletter`, ...
|
|
---
|
|
|
|
## 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}']`
|
|
|