#!/usr/bin/env python3 """AdminLTE 3 -> 4 hand-written layer: layout skeleton, asset loads, plugin swaps. Runs after bs5_codemod.py. Every edit asserts its anchor was found.""" import os, re, sys ROOT = sys.argv[1] os.chdir(ROOT) applied, missed = [], [] def edit(path, old, new, label, count=1): with open(path, encoding='utf-8', errors='surrogateescape') as f: t = f.read() n = t.count(old) if n != count: missed.append(f'{path}: {label} (found {n}, expected {count})') return with open(path, 'w', encoding='utf-8', errors='surrogateescape') as f: f.write(t.replace(old, new)) applied.append(f'{path}: {label}') def resub(path, pat, new, label, expect=None): with open(path, encoding='utf-8', errors='surrogateescape') as f: t = f.read() t2, n = re.subn(pat, new, t) if n == 0 or (expect is not None and n != expect): missed.append(f'{path}: {label} (matched {n}, expected {expect})') return with open(path, 'w', encoding='utf-8', errors='surrogateescape') as f: f.write(t2) applied.append(f'{path}: {label} x{n}') # =============================================================== 1. main header # AdminLTE 4 dropped the accent-*/dark-mode class pair; colour mode is now the # Bootstrap 5.3 data-bs-theme attribute, set on . edit('includes/header.php', '', '>', 'colour mode -> data-bs-theme on ') edit('includes/header.php', ''' ''', ''' ''', 'stylesheet swap: tempusdominus + select2 theme') # adminlte.min.css must load BEFORE itflow_custom.css now: v4 bundles Bootstrap # 5.3 and ships its own cascade layer ordering, so custom overrides go last. edit('includes/header.php', ''' ''', ''' ''', 'adminlte.css before itflow_custom.css') edit('includes/header.php', '''