mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
src/ThesisEditController.php (285 lines) centralises all data-fetching and
mutation logic for the thesis-edit workflow:
load(int $thesisId): array
Fetches the thesis row, current language/format/jury selections, and all
lookup tables (orientations, AP programmes, finality types, languages,
formats, licences, access types) in one call. Returns a flat view-variable
array that the dispatcher extracts directly.
save(int $thesisId, array $post, array $files): void
Runs the full edit inside a transaction: thesis metadata, authors, jury,
languages, formats, tags. Banner upload/removal is handled outside the
transaction (filesystem op). Rolls back and re-throws on any failure.
static autofocusFieldForError(string $msg): ?string
Centralises the WCAG 3.3.1 exception-message → field-name mapping that
was previously duplicated inline in actions/edit.php.
Dispatcher changes:
admin/edit.php 191 → 162 lines (pure view + ThesisEditController::create() + load())
actions/edit.php 153 → 53 lines (CSRF guard + ThesisEditController::save() call)
Follows the same pattern as SearchController and SystemController.
3.7 KiB
3.7 KiB
PHP Components (Reusable Partials)
Form field partials — templates/partials/form/
text-field.php— already implemented; used acrossadd.phpandedit.phpfor all single-line fieldsselect-field.php— already implemented; used for orientation, ap, finality, license, access type, etc.checkbox-list.php— already implemented with<fieldset>/<legend class="sr-only">/<ul>structure for WCAG 1.3.1file-field.php— already implemented; used for cover image, banner, and TFE filesjury-fieldset.php— already implemented; single partial shared byadd.phpandedit.php; includes all WCAG aria-labels and JS for dynamic rows
Shared UI partials — templates/partials/
pagination.php— partial created and used in bothsearch.phpand (now)admin/index.php;admin/index.phpalso gained proper server-side pagination (25/page) with filter-aware$baseParamsstatus-badge.php— partial fully implemented (templates/partials/status-badge.php) with$badgeType/$badgeValueAPI; CSS rules inadmin.css; used inadmin/index.phpfor publish + access badgesadmin-alert.php— already done;flash-messages.phpcallsApp::consumeFlash()which handles all legacy key variants (_flash_error,error,admin_error,edit_error,form_error,success,admin_success,edit_success) and clears them all
Controller Extraction (In Progress)
- Extract
SearchController—src/SearchController.php; rate-limiting, param sanitisation, DB queries, OG meta, and author-map construction moved out ofpublic/search.php; entry point is now a 6-line dispatcher (create()+handle()+extract()); view template unchanged - Extract
SystemController—src/SystemController.php(452 lines); all status checks, disk/PHP info, log reading, nginx config reading, and line classifiers centralised;system.phpreduced 582→282 lines;system-fragment.phpreduced 213→137 lines with all duplicatedfrag_*helpers eliminated - Extract
ThesisEditController—src/ThesisEditController.php(285 lines);load()fetches thesis row, current language/format/jury selections and all lookup tables for the view;save()validates and persists metadata, authors, jury, languages, formats, tags, banner in a transaction; staticautofocusFieldForError()centralises WCAG 3.3.1 field-name mapping;admin/edit.phpreduced 191→162 lines;actions/edit.phpreduced 153→53 lines - Extract remaining controllers one by one
- Consolidate action handlers into controller methods
- Unify flash message keys project-wide to
_flash_error/_flash_success— all callers already useApp::flash(); removed dead legacy-key fallback chains (error,admin_error,edit_error,form_error,success,admin_success,edit_success) fromconsumeFlash() - Move OG tag construction into controller logic
- Extract inline CSS/JS from
system.phpinto separate assets — JS moved topublic/assets/js/system.js(loaded via$extraJs); 4 inlinestyle=attributes replaced with CSS classes; only dynamic CSS custom properties (--disk-pct,--disk-color) remain as inline styles because they carry PHP runtime values
Backend Maintenance
RateLimitcache dir — already instorage/cache/rate_limit;justfiledeploy excludesstorage/cache/*from rsync. APCu/SQLite migration deferred (not blocking).apropos.phpcontacts and credits — moved toconfig/apropos.phpconfig array (contacts[],credits[],erg_url);apropos.phploops over the config withhtmlspecialchars; update names/emails by editing only the config file