The first things I started with is was the PHP scripts that query the database. PHP 5 added a wonderful class interface, and I have long wanted a good project I could implement in it. The database for an image gallery is laid out into 3 main categories: pictures, galleries, and gallery groups. Gallery groups contains sets of galleries, and galleries contain sets of pictures. There are more tables than this, but these categories are perfect demarcations for classes.
The first class I implemented is a child of 'mysqli'. I overloaded the 'query' function to throw an exception when the query fails. It also has the names of tables found in the gallery. Table names have a unique name appended to the front so multiple galleries can be assigned to a single database.
The next class I call a database field. It is an abstract class that has two major functions: get attribute and set attribute. These are driven by two internal function: fetch from database, and push to database. It needs a database, the name of the table, and an id for the record each instance will represent. Now when a record is to be read or written, this class handles the database side of life. In this way, the child class only needs to know basics about the table it works with. Each of my gallery implementation could have different table layouts for pictures. In the main gallery on DrQue.net pictures have information about the ISO, lens, f-stop, ext. Other galleries have other settings. This I did not want to matter at this level—the classes should be able to represent themselves without knowing all the details about what they will contain. So the get/set attribute interface allows the class to be mostly ignorant of the table layout—there are just a few key fields required to make the gallery run. Everything else is optional and handled at a lower-level, such as the scripts that will build HTML from the gallery data.
The child classes of the database field are then pictures, galleries, and gallery groups. A gallery group has the ability to retrieve an array of galleries, and a gallery an array of pictures. But neither class cares if the table has an entry for the name of the gallery group/gallery. They only need the ID field for the record their instance represents.
This system allows a lot of flexibility while remaining very simple. The largest class, the picture class, is currently only 200 lines of code, and several of those lines are comments. On the implementation side, things have been very smooth. Although I have a lot of aesthetic work to do yet the gallery view is completely functional requiring no rework to this class system.
The picture today is one I took in the early morning hours. I tried some more High Dynamic Range (HDR) work, this time outside under the stars. There were two problems with this shoot: wind, and the Earth's rotational speed. Both of these caused my images not to align completely, resulting in strange artifacts when I applied the HDR process. As for the wind, I can simply try again on a calm day. But the star field movement because of the Earth's rotation isn't anything I can work around. So interesting pictures, but not the greatest.