Sign in to follow this  
  • entries
    43
  • comments
    51
  • views
    31881

The Solution: Part 2

Sign in to follow this  

225 views

I decided to try to force each module to implement a very specifically named class with some very specifically named members. The name of the class is based on the file name that the module is defined in: admin.php's class name is admin_interface, cudb.php's class name is cudb_interface. Each class must have at least these four functions: Install(), Uninstall(), GetContent(), and Administrate().

ExtractFunctions() has become GetModuleInterface() and now returns the name of the module's class. I discovered that PHP allows you to instantiate that class like so


$class_name = GetModuleInterface();

$instance = new $class_name;


I like this solution a lot better because now I dont need that ugly Function field in my database like I had before, I dont have call_user_function() or an ugly array of functions in my code like I did when I returned an array of functions, and generally it seems like the code is simpler.

Before I decided to try this I tried to take jumpjumpjump up on his suggestion to look at MediaWiki's namespaces but I guess I suck at PHP or I dont get MediaWiki's code because I didnt understand what was going on. I looked in a few files but I didnt find one that included Namespace.php nor did I understand the significance of Namespace.php. [oh]
Sign in to follow this  


2 Comments


Recommended Comments

As far as I know, MediaWiki just uses a : to determine what namespace the requested query is part of. For example:
Toys:Dildo
In this example, Dildo would belong to the Toys namespace. I don't know much about MediaWiki, but I do have it installed on my server.

e107 uses arrays with everything. This way, if you want to make a module, you just add what you want to the end of the array you have to deal with. It also uses a database table to determine what modules are installed along with all its settings. Ummmm, do you want a copy of rWeb? It was a horrible website template system I made a while ago and have just recently decided not to maintain it anymore. You want a copy of it? Here's an example page along with the stylesheet changer. I'm going to delete it soon anyway due to its horribleness [smile].

Share this comment


Link to comment
Thanks for the links. I have a copy of rWeb but I dont know how recent it is. It looks like it's from November. If you have a more recent version I'll be happy to see it (part of the reason I started on this project was rWeb [grin]).

I'll go digging in MediaWiki some more as well.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now