SSI is a big beast of a file, and it ends up loading a couple of thousand lines of code, of which a lot of users won't even be using. If, for example, you just do authentication with it, you won't use most of the code there.
Then you have the functions themselves. My personal favourite is ssi_boardNews, which is:
Code: [Select]
There are some issues with this. For example if you want to get the information back you can't just use (the rather logical):
Code: [Select]
It just doesn't work like that.
Then you have the facilities I built into http://custom.simplemachines.org/mods/index.php?mod=2280 for multiple boards and much more stuff. Which, you'll notice, doesn't one massive function call, you set all the options you want first.
So, I thought... how about we do something similar, but cleaner and able to be much more configurable?
Here's what I'm proposing.
Instead of ssi_boardNews(1); to get the news from board 1, I'm thinking about:
Code: [Select]
It looks worse, but hear me out. There are a bunch of things that can be achieved with this.
Firstly, we can remove all the SSI functions out of the file and put them somewhere else, so that you only load what you need, and we achieve this with a thing called an autoloader. (Specifically, an SPL one, but don't worry about that.)
So you just request SSI_boardNews() as a class like above, it goes and makes sure the class is available and boom, you can output the board news with it.
But having it set up like that means it's trivial to add different options at will - instead of having a massive function call to set the number of items, the start/length/whatever, you can set all those with separate calls, e.g. to get items 11 to 20 (page 2), the first 500 characters, you would do:
Code: [Select]
And there's no set order, no requirement to list all parameters, just the ones you want to change compared to the default. (I could even put the board number into the SSI_boardNews call itself for keeping it small's sake)
Thoughts?
:edit: Interesting side benefit, it would allow you to be able to load individual SSI components as needed without having to load the entire file.
Then you have the functions themselves. My personal favourite is ssi_boardNews, which is:
ssi_boardNews($board = null, $limit = null, $start = null, $length = null, $output_method = 'echo')There are some issues with this. For example if you want to get the information back you can't just use (the rather logical):
$var = ssi_boardNews($board = 1, $output_method = 'array');It just doesn't work like that.
Then you have the facilities I built into http://custom.simplemachines.org/mods/index.php?mod=2280 for multiple boards and much more stuff. Which, you'll notice, doesn't one massive function call, you set all the options you want first.
So, I thought... how about we do something similar, but cleaner and able to be much more configurable?
Here's what I'm proposing.
Instead of ssi_boardNews(1); to get the news from board 1, I'm thinking about:
$var = new SSI_boardNews();
$var->setBoard(1);
$var->output();It looks worse, but hear me out. There are a bunch of things that can be achieved with this.
Firstly, we can remove all the SSI functions out of the file and put them somewhere else, so that you only load what you need, and we achieve this with a thing called an autoloader. (Specifically, an SPL one, but don't worry about that.)
So you just request SSI_boardNews() as a class like above, it goes and makes sure the class is available and boom, you can output the board news with it.
But having it set up like that means it's trivial to add different options at will - instead of having a massive function call to set the number of items, the start/length/whatever, you can set all those with separate calls, e.g. to get items 11 to 20 (page 2), the first 500 characters, you would do:
$var = new SSI_boardNews();
$var->setBoard(1);
$var->setStart(10); // skipping 10 items, to start at 11, normally you start with the first 1 by skipping 0 items
$var->setLimit(10);
$var->setLength(500);
$var->output();And there's no set order, no requirement to list all parameters, just the ones you want to change compared to the default. (I could even put the board number into the SSI_boardNews call itself for keeping it small's sake)
Thoughts?
:edit: Interesting side benefit, it would allow you to be able to load individual SSI components as needed without having to load the entire file.



