Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Vanilla's new framework

edited November 2005 in Vanilla 1.0 Help
Ehm... don't know if I can start this topic, but I'm sooo curious about the new framework ^^

This is how I see it now:
The current framework exists out of classes like discussions, comments etc. which hold the data object model. Then you have controls, which you use to display the data with the render method. All these controls are a collection of the Context object... This is really nice! But they all consist of seperate files.

How does the new framework gonna look like? Mark, you said you'd take everything apart and convert them to extensions... Does this mean an extension holds the classes, controls and other stuff? And what to expect from the folderstructure? Is it just one "index.php" file which includes and triggers the appropriate classes?

Ehmm... so what I'm saying: If it's not too much asked, can you give us a sneekpeak on the framework? ^^


  • gigingergiginger New
    edited November 2005
    He did post a picture of the new vanilla folder structure somewhere. I'll try and find it...

    edit: Just tried searching for it with various names and phrases but couldn't find it. It's not that old a thread but I can't remember the name. Sorry.

    edit edit: I couldn't give up. Found it.


    Hope that helps.

    It was from this thread :)
  • MarkMark Vanilla Staff
    It's actually not that different than what exists now. I've just created a new base class called Delegation that any other class can extend. This delegation class will allow you to add methods to events that are called by the classes at various places. It's really allowed me to add a whole new dimension to extensions and made things that couldn't be extensions before absolutely do-able. So, when I say that I'm moving things into extensions, it really means that I'm trying to clean out a lot of the extra controls that appear in the controls folder and move them over into the extensions folder - then taking periphery widgets that are associated with those controls and removing them from the core files - and re-attaching them through the extensions using delegation. Now, when I release the code there will probably be months and months of people wanting to add new delegates to classes. I've put a bunch of ones in there that I feel should be there, and also added a few where I needed them for my extensions - but there's no way I could possibly come up with a complete set of events that handle everything a person would want to do. So we will be looking at short time-frames between minor releases after I let this one out. Back to multiple files: The thought has crossed my mind that I am getting closer to being able to put the forum on a single index.php page and have all pages drawn dependant on the querystring - but there are still a number of unknowns with that approach. So, I'm taking baby steps. I think a single file that handles the entire application will definitely be a version 2 change. One other thing I've done that works suprisingly well (it was just a wacky thought I had that turned out to speed things up a great deal) is that I've separated all of the classes in the library into their own files. So, instead of having the RoleManager *and* the Role classes in the same Vanilla.Role.class.php file, now there are two: Vanilla.Role.class.php and Vanilla.RoleManager.class.php (and so-on, down the line for all classes). Then I use the object factory to do on-demand loading of classes. So, when you tell the object factory to instantiate a certain object, it will first check to see if the class definition exists. If it doesn't, it will attempt to include the appropriate class. If it fails to find the class, it will throw a fatal error. The end result is that instead of including every single class that *might* be required on a given page, it only loads them as it needs them. I saw a massive performance gain when I implemented it.
  • Wow!! Thanks for the big reply!! Yeah, I noticed a lot of classes are loaded which you don't need. Nice to you see you've come up with a solution :) I like the idea of using events! It makes life much easier! And ofcourse you can't define all events people want to have. But you should be in control of the "master file" and release once a while a new version with new events. It will be very nice to see people build around your framework. Since you have many neat ideas, maybe think of this one: Let's say, your framework supports all kinds of "extensions". Ofcourse the "index.php" will be the mainpage and the first file to be started. The current Vanilla always starts up with the discussions page. But what if people want to have a different startup page, e.g. a weblog? or a gallery? Maybe implement something like PhpNuke, and load "modules" (by ?module=forum or ?module=weblog). Or is this something you want to avoid?
  • While you're at it... :P Another difficult subject is the multi-lingual thing. Vanilla supports different languages, but when you break everything into extensions, you can't have a single language file anymore I guess... Maybe create a seperated control or object for the language handling, with add methods or something :) Just a thought ^^
  • yeah, languages with extensions are always gonna be tricky. Personally i think it might work to include any new definitions required into an 'extension installer' (we've discussed about making this an automated process and such before) which runs when you install an extension and adds the required definitions to the dictionary. The difficult bit then is how people release language files. I suppose this is why mark does the thinking :) And as for your module?... thing, while it would work, i dont think it is within the scope of vanilla to do that. That is the job of a cms/whatever and the forum vanilla is not (and i believe should not) be designed to do that job. That's not to say i wouldnt *love* mark to release a CMS (based on the vanilla framework or whatever), but i dont think trying to mash it into the 'simple forum' would be right. On a similar theme, however, i believe the next revision will allow you to choose whether you want catagories or discussions to be the starting page (and i presume this will/could be extended to allow people to choose any of the tabs as their start page), in which case you could setup your homepage/blog/whatever as a the starting page. I guess i sorta went back on myself there but i hope you can see the difference between my theories.
  • JanJan
    edited November 2005
    Hi guys and sorry for jumping in! I'm new here and I'm really impressed with Vanilla. Nice work! Anyways, I'm thinking about making a switch, but there's a problem. I'm currently hosting a forum on my website that runs on IPB 1.3. The forum is both in Swedish and in English, and I'd do the switch today if Vanilla would allow user-specific languages. In other words, if an English user register on the site, he/she could go to the Account page and set the language of his/her own choice. I've been reading on this forum before, and as far as I understand, this wouldn't be possible with the current structure of Vanilla. What about future releases? Could user-specific languages be implemented in them?
  • Unless you can talk mark into changing his mind, i dont think he'll be implementing user specific languages into the forum. When i argued it with him way back when, he made the reasonably valid point that there were few forums where two languages would be used as while the forum software could be in two languages, the posts would most likely all be in one language and therefore it wouldnt help you much. Obviously in your case this isnt true, and therefore multilingual support would be a benefit, so unless you can convince mark to include it while he's working on the next rev, it sounds like it's extension time. I'm sure someone would correct me if i was wrong but i think it should be possible to write an extension to overwrite the GetDefinition class and build in a checker to see which language file the user has requested to use, then return the correct data.
  • I can tell by Mark's Vanilla code, that everything is about objects. So he won't put specific language text in his software (other than his code comments). But it would be cool to see him implementing some sort of language control or class where other developers can build their language on... Btw: Vanilla does have a language feature. But indeed the discussions and comments are in the language that they are posted in. If you want two specific languages forums, you can always install Vanilla twice....
  • Yeah, dual install is always a possibility, particularly with the extra config options and stuff which i believe are being implemented into the next ver. I'm not entirely sure what you meant by your first paragraph - there is an existing language class (or whatever you call them) which retrieves definitions for stuff from the language files?
  • NickENickE New
    edited November 2005
    If you didn't mind doing a little Vanilla hacking and storing the user's language preferences in a cookie, then you could add in a little snippet of code in an initiation file which would load the language file depending upon the value of the cookie. Then you could have a few links on the top of the forum which the user can click to set their language of choice. Easiest would be language.php, but you'd have to etiher one, also rewrite the function that over-writes language.php or two, be very careful not to change the global board language via the administration panel.
  • why would you need to overwite the language.php? Wouldnt it be easier just to write something which changes the output of getdefinition depending which language the user selected? On the assumption both language files were in the /languages dir i dont see why it wouldnt work? The board would still need a default language...
  • I was pointing out that if he did what I was suggesting, but instead put it in language.php, he'd have to be careful with the administration because that file gets re-written every time you change the language. As for GetDefinition changes in an extension, there's probably nothing wrong with that, but it'd be less resource-savvy as the extensions are included after the language file, thus you'd have to include two different language files if the current one wasn't correct. My suggestion was to add in a little something in the language.php file which first checked the user's preference cookie, then included the appropriate language file based on that. Alternately, I don't think it'd be all that hard to add an extra element in the Settings array of that user; you could create an extension to manage their language settings then have the actual language selection in the initiation files.
  • ahhh, i gotcha now. I was sorta skipping the fact that the language setting file was php just like any other. Interesting theory...
  • JanJan
    edited November 2005
    You guys seem to have very good ideas even though I haven't got a clue on how to implement them myself. I know some basic HTML/CSS/PHP but actual programming is completly out of my league! :P On my site I have a bunch of forums (categories) and one of them is in English so that non-Swedish speaking members can participate. The default language is Swedish, but a member can choose between that and English. In any case, actual posts are in the language they were originally written in regardless of the forum language. The user specific language is made available mainly so that non-Swedish members can more easily navigate in the forums. Please Mark, I beg of you, couldn't you take the advice of these nice members and make it possible for user specific languages? It would be greatly appreciated.
  • Yeah jan we completely understand where you're at, but as you can appreciate it probably doesnt happen *that* often. If mark chooses not to implement multilingual support in his next revision then i'm sure SirNot or myself will be plenty willing to throw a quick extension together for you.
  • Of course, minisweeper, it's not that common with multi-lingual forums but they do exist. I'm really thankful for your help and if everything goes well I'll have a multi-lingual version of Vanilla up running one day! Please let me know if you guys have figured out a nice solution. Thanks!
  • MarkMark Vanilla Staff
    Writing an extension to do it actually wouldn't be that difficult. You could make a new user preference called "Language", add it to the user prefs on the account page. Then, if someone chooses a different language, have that code alter the language.php file that is included on every page to check for a user-selected language and include that file instead of the default. The only thing it might break is the language selector in the settings tab. So, you'd either have to disable that somehow, or you'd have to also override that control so that it doesn't muck up the little bit of code generation there.
  • NickENickE New
    edited November 2005
    Hmm, I didn't think of replacing the language class in the settings control file. Anyways, I did make an extension out of it, although I'm afraid you'll just have to make a small change in init_external.php and init_internal.php. Instructions are given within the file:
  • MarkMark Vanilla Staff
    Ohh. No, I meant to actually change the contents of language.php to do the if statement - which you could do in your extension without having to manually alter an init files.
  • hold on, isnt that what sirnot was saying we should do to begin with?
This discussion has been closed.