135 lines
5.5 KiB
Markdown
135 lines
5.5 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 ✓
|
||
```
|
||
|
||
Następne: `Admin\` namespace (Fazy 6–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}']`
|
||
|