General logic for /admin/index.php
This is not really for users but anyone interested in the system. Just explains the general flow logic for what is quite a complicated file. Separates the PHP from the HTML which is all mixed in together in the actual code.
PHP. Load top. Code for 'if preview'.
Start HTML, head, start of body etc.
PHP. Check whether logged in or logged out. If logged out, password form HTML (which is in /admin/functions.php).
If logged in:
If edit, get page ID and menu details.
If not logged in:
Test cookie notice.
Navigation bar HTML.
PHP. If new page, edit or delete a page, do the business.
Ditto with 'extras', stylesheets and menu.
Response HTML (conditional PHP built-in).
PHP. Prepare main form for 'if submitted'.
HTML for boxes above textarea, then textarea (conditional PHP built-in).
Then the buttons for the various actions (conditional PHP built-in).
Then load the list and footer.
PHP. Or login status can't be verified (whether logged in or logged out).
HTML. If login status can't be verified message.
End body etc.