mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
Extract SearchController from public/search.php
Move all data-fetching and request logic out of the 285-line search page into src/SearchController.php: - SearchController::create() — static factory; builds RateLimit + Database dependencies, sends HTTP 429 (and exits) if rate limit is exceeded, runs probabilistic cleanup, returns ready instance - SearchController::handle() — sanitises GET params (query/year/orientation/ ap_program/keyword), runs all DB queries (searchTheses, countSearchResults, getAvailableYears, getAllOrientations, getAllAPPrograms, getUsedTags, getPublishedAuthors), builds alphabetical author→id map, assembles OG/meta tags, returns a flat array of view variables - Rate-limit 429 HTML response moved into private sendRateLimitResponse() public/search.php is now a 6-line dispatcher: require SearchController; extract(SearchController::create()->handle()); followed by the unchanged view template (162 lines total, was 285). The view template is byte-for-byte equivalent: same HTML, same variable names, same pagination partial include.
This commit is contained in:
3
TODO.md
3
TODO.md
@@ -11,6 +11,9 @@ Pending tasks have been split into topic files under [`todo/`](todo/README.md):
|
||||
|
||||
## Recently completed (this session)
|
||||
|
||||
- [x] `src/SearchController.php` — extracted all data-fetching logic from `public/search.php` into a dedicated controller class; `SearchController::create()` handles rate-limit enforcement (429 response + exit) and returns a ready instance; `handle()` sanitises GET params, runs all DB queries (`searchTheses`, `countSearchResults`, `getAvailableYears`, `getAllOrientations`, `getAllAPPrograms`, `getUsedTags`, `getPublishedAuthors`), builds the alphabetical author map, assembles OG/meta tags, and returns a flat view-variable array; `public/search.php` reduced from 285 lines to 162 lines (pure dispatcher + view template)
|
||||
|
||||
|
||||
- [x] `admin/system.php` + `assets/js/system.js` + `assets/css/system.css` — extracted the large `$extraJsInline` heredoc (≈130 lines) into a static `public/assets/js/system.js` loaded via `$extraJs`; replaced 4 inline `style=` attributes with named CSS modifier classes (`srv-section-title--compact`, `srv-section-title--sub`, `php-grid--flush`, `log-toolbar label` rule); only the dynamic `--disk-pct`/`--disk-color` CSS custom properties remain inline because they carry PHP runtime values
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user