#!/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', '''
''', '''
''', 'body classes + wrapper -> app-wrapper') # ============================================================== 2. content area edit('includes/inc_wrapper.php', '''
''', '''
''', 'content-wrapper -> app-main/app-content') edit('guest/includes/inc_wrapper.php', '''
''', '''
''', 'guest content-wrapper -> app-main') # ==================================================================== 3. footer edit('includes/footer.php', '''
''', '''
''', 'closing tags match app-* skeleton') edit('includes/footer.php', ''' ''', ''' ''', 'bootstrap comment') edit('includes/footer.php', '', '', 'tempusdominus -> tempus-dominus 6') # Show-Hide-Passwords is a jQuery/BS4 plugin with no BS5 release. Replaced by a # vanilla toggle in js/app.js that keeps the same data-toggle="password" contract. edit('includes/footer.php', '\n', '', 'drop Show-Hide-Passwords-Bootstrap-4') # ================================================================== 4. top nav edit('includes/top_nav.php', '