Building Admin Tools With JavaScript and PHP
So part of my job at the Indianapolis Motor Speedway is writing Admin Tools for our users to administer the sites with. There are a mix of older admin tools which don’t use any JavaScript and newer admin tools where the front end is completely based on JavaScript.
I was recently asked to build an admin tool to allow one of our users to maintain the drop down portions of the site navigation since they can change with each passing event that happens at the track. This presented the following problems:
- Navigation is stored in a XML file
- The navigation XML file is versioned with Subversion
- The admin had to be easy to use.
What I started with was trying to figure out the whole svn integration thing as I had to figure out a way to make sure that the working copy was always current and that when the user saved the navigation it did a commit on the file to that way it would always be the latest version in the repository.
Problem 1: SVN does not allow you to checkout a single file to be a working copy. I found this to be a problem as I didn’t want the whole directory, I just wanted the navigation.xml file. I did some searching on the SVN bug tracker and found a perl script that David Kilzer wrote that allowed me to check out a single file. Problem 1 is solved.
Once I got the file checked out into the working directory on the server i preceded to write a shell script that updated the file via an svn up command that would be ran on my fetch script before I read in the XML file to pass it back to the JavaScript.
Now that I have the XML back in my front end i can display it. Here is what the admin tools looks like when you have selected which site you want to edit.
As you can see from the screen shot everything is layout in an easy to browse tree view. You can move the child nodes around to order then or place them in any parent menu that you like. There is a simple edit and add features. The adding also incorporates a feature from our Site Pages admin that allows you to select from a page in there so you don’t have to copy and paste a link from the pages admin to this admin.
Once the user gets done with any changed they may have they can select the save button and that passes it back off to the PHP backend where it writes out the xml file and then does an svn ci on the file which places it back in the SVN repository and also promotes it to production via a set of PHP and bash scripts to interface with the SVN repository.
All in all using the ExtJS Library and PHP to build the admin tools for the IMS sites has dramiticly cut down on the time it takes to do everything since I have a very good understand of how everything in ExtJS works and when I don’t there is a great documentation resource out there.
read more

