I have plans to rewrite much of the PHP code on PaperDemon to be more exportable. By this I mean I want to make it easier for me to reuse my code in other projects. Sure I could just copy paste but then when I make customized edits to the copied version, then I can't easily update the copied site with the new features from the first site.
So I'm working on restructuring my PHP classes to be more layered. I haven't read any articles on specifics of how to do this so I'm just sort of figuring things out for myself (if you have some links please send them my way!) I did read once though that a great way to do this is to have a class and then other classes that extend it. I also read that data gathering, data manipulation, and presentation should all be separate layers in any application. This makes a whole lot of sense to me so I'm going to try and apply this concept wherever I can.
So to experiment with this process I thought I'd start with something simple that I know would already be needed multiple instances within PD. And that's the commenting system. Art, Comics, and Writing all have almost identical commenting infrastructure. So I started to create one generic class for handling commenting, then have 3 PHP class layers (for art, comics, and writing) that sort of wrap around the main comments class to add custom functionality. So it would go something like this:
// generic class
class Comments{
function get_comments(){
// do database call and stuff
}
}
And then I have a class that extends this that has custom functionality for Art comment stuff:
// art layer for comments
class ArtComments extends Comments{
function get_comments_extended(){
// custom stuff
// call the generic method
$this->get_comments()
// custom stuff
}
}
I thought since i'm at it, I might as well make some improvements to the Comments system instead of just backend stuff. So I'm making it AJAX and adding navigation to comments. There will come a day when there are more than 50 comment threads on an artwork submission and I don't want to hammer the database with having to retrieve all those comments when its not necessary. So instead its just going to load the latest 20 and you can just click nav buttons to see earlier comments via AJAX. Also, it will only draw the parent threads. If the parent comment has replies, a button will appear which you can click and it will load the children comments.
I'm also adding another element to make things more exportable. After I pull the data from the database, I transform it into XML data and then apply an XSL file to it to transform it. This way I have a separate presentation layer. The current live comment system uses phplib templates. I use it because it's nice to keep the html separate from the PHP. However you can't apply any sort of logic to the presentation when using phplib templates, which means I end up making presentation decisions on the PHP end. that means i end up with messy code. i want the presentation completely separate from the data gathering and data manipulation. At a later time, I can even cache this xml data into either the database or xml files and then just pull from that to avoid load on the database. But I probably wont do that since most art submission pages don't get viewed all the time so their content gets generated only every once in a while (except for newer submissions wich have more traffic). Probably the ideal situation would be to have all the data of the artwork submission (not just comments) in a cached xml file and then use xslt to transform it into html.
But I digress... I'm very close to being finished with the Comments class. I have run into some problems with some people's signatures having malformed html and it causes the xsl transformation to fail. I'll need to resolve that. I also need to make a lot of the comment administration/posting ajaxified so that the stuff doesn't come in the form of pop-ups like it currently does. My plans also include revamping the inbox area and the way members manage comments they receive on their artwork.
I also have some ideas in mind for revamping the Members Portal. I would love to make it a customizable page that has the latest and greatest stuff on PD that the user elects to have. Also it would be good to have all of the subscription notices ajaxified as in you just click a little x next to a notice and it deletes it.
The user interface for dealing with art, writing, and comics needs some revamping as well.
Anyway, I have a lot of great ideas. It's just finding the time to do it all. But I'll try to work on it, even if its just an hour here and there.
| Permalink |
Comments (0) |
Post a comment