I'm working on a PHP-driven site for a client. It's a fairly standard DB-driven site for letting teachers give quizzes to students. So, the DB has schools, and the schools contain teachers, teachers contain "classes", and the classes have students and assignments, etc. Nothing new, there.
The way the back-end is put together is pretty much that each "role" (ie, student, teacher, administrator) has their own php file. So, for example, the administrator's stuff would be in "admin.php". The particular tasks that an administrator does are invoked with an "action" value passed in the querystring. Something like "admin.php?action=delete_teacher&teacherid=82". Then, in admin.php, there's just this huge switch clause that looks like:
Code: Select all
switch($_GET['action']) {
case "delete_teacher":
blah blah blah...
break;
...Right? So, it's just a static HTML file that throws in some variables from PHP. So, the actual case statement for the "delete_teacher" action in admin.php would look something like:delete_teacher.inc<html><head><title><%php echo $pagetitle %></title></head>
<body><font size="+2" color="#00FF00"><%php echo $maincontent %></font></body>
</html>
Code: Select all
switch($_GET['action']) {
case "delete_teacher":
blah blah blah...
$pagetitle="Deleting teacher number $teacherid";
$maincontent="... blah blah blah... ";
include("templates/delete_teacher.inc");
exit();
break;
...So, what's my big problem?
First off, because the dude decided to name these files ".inc", Dreamweaver doesn't interpret them as HTML. I'd love for my client to be able to manage all of her images, layout, style-sheets (everything except the business logic, I guess) herself, but Dreamweaver just looks at these things like straight text files. It also means that we can't preview what the page is going to look like until we just upload it to the testing server and reload the page in the browser. I guess I could just rename them to .html files but... now that I think about it, I guess I don't know why I don't. I guess I'm just asking here to see if anybody can see of any pitfalls of doing that (or if they have any better ideas to make it easy to design/manage the templates in DW).
It would also be nice if I could employ a less-insane method of page flow, or site navigation, or whatever the preferred term is for it. Right now, I have to put URL's in explicitly, like:
....You've just deleted a teacher. <a href="admin.php?action=main">Click here</a> to return to the main admin screen
So, there are jillions of these things all over the place. If we renamed admin.php or renamed the "main" action to something else, it would break a bunch of stuff and we wouldn't know if we tracked down all of the places where we had to change it. Of course, I could start rewriting the code to use a bunch of global URL/action constants, like
....You've just deleted a teacher. <a href=\"" . getURL("ADMIN_MAIN") . "\">Click here</a> to return to the main admin screen
But, that's not much of an improvement. I'm thinking that the solution is some combination of a smarter IDE (kinda on the order of IDEA for Java) and a more-sensible approach to warehousing names of the php files and their actions, but I want to avoid re-inventing the wheel, here.
What have y'all used to make sense of things when a site starts getting unruly like this?
- Joe