MyBB Community Forums

Full Version: How many of you would be interested in a plugin i made?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

time ago i made a plugin (just for fun) which extends MyBB's template engine.

A basic example of how it works is:
function tatote_method_datenow($args, $text)
{
   global $mybb;
    if(empty($args))
        $args = $mybb->settings['dateformat'];
        return date($args);
}

And if i insert in the template the following code:
{datenow}
It outputs 07-17-2008

If i insert this
{datenow Y-m-d}
It outputs 2008-07-17

A more complex example is
function tatote_method_restrict_to($args, $text)
{
    global $mybb;
    if($mybb->usergroup['gid'] == intval($args))
        return $text;
    else
        return "You can't view this";
}

In template i put this:
{restrict_to 1}Bye bye{/restrict_to}

If you are a guest it outputs "Bye bye" else it outputs you can't view this.

Basically it is a little framework (by default it has only 3/4 functions, the concept is i give the core, you extend it by adding new methods) which extends the template engine, you could extend a template engine by writing some PHP functions.

My question is: would you be interested in seeing this for 1.4?

If i receive a good demand for this, i could port it to 1.4 and releasing it with some new features (one of these is to include currenttemplate_functions.php which would contains some functions designed for the template in use Cool)

Regards
I been thinking of doing something to extend mybb functions too. I find there is limitation for blank pages which could be easily corrected. There are things would could be built in to help make plugin authors life easier.
So in a bit of words: would be you insterested in my plugin? Big Grin

If i should release my hope is that other developers will extend it by writing some functions. Wink
By all means, I encourage plugin development Toungue

I made a similar plugin here: http://community.mybboard.net/thread-31860.html
So feel free to base anything off it if you need help Toungue
Ok i read your phptpl code.

First of all thank you for letting me use your plugin as start point but i used a different approach, your is by taking control of Template Class, mine uses the hook "pre_output_page" and parses it.

Your plugin makes use of the fact that MyBB uses eval() for parsing templates, mine reinvents the wheel Big Grin.

ZiNgA BuRgA's phptpl
- makes use of the fact that MyBB uses eval() for parsing templates
- the only security measure it needs is done by MyBB by parsing < > chars in post
- focuses much on Template Conditionals
- gain control of templates object except in ADMIN_CP

Mine
- Extensibility
- Extensive use of PCRE functions
- Makes use of pre_output_page hook
- Needs parsing posts to avoid that users uses it into posts and search result posts, it replaces { } characters, it makes use of parse_message hooks
(2008-07-19, 01:33 AM)flash.tato Wrote: [ -> ]your is by taking control of Template Class
Yeah, it's the only way to ensure you have the correct scope.
I generally try to avoid PCRE if possible (but I ended up using it anyway >_>) - it's really slow... Toungue


Good luck on your plugin!
(2008-07-19, 07:40 AM)ZiNgA BuRgA Wrote: [ -> ]Yeah, it's the only way to ensure you have the correct scope.
I generally try to avoid PCRE if possible (but I ended up using it anyway >_>) - it's really slow... Toungue
PCRE is highly optimized in my opinion, RegEx's knowledge helps much in writing fast RegEx.

(2008-07-19, 07:40 AM)ZiNgA BuRgA Wrote: [ -> ]Good luck on your plugin!
Thanks Cool but my hope will be that some developers will extend it. Wink
(2008-07-19, 12:50 PM)flash.tato Wrote: [ -> ]
(2008-07-19, 07:40 AM)ZiNgA BuRgA Wrote: [ -> ]Yeah, it's the only way to ensure you have the correct scope.
I generally try to avoid PCRE if possible (but I ended up using it anyway >_>) - it's really slow... Toungue
PCRE is highly optimized in my opinion, RegEx's knowledge helps much in writing fast RegEx.
Note that highly optimised != fast.
By nature, regexes are slow (ever tried writing one in C or ASM?).
Yep. i used PCRE in C and i din't find some issues (maybe i used RegEx with strings with little length).
(2008-07-20, 06:46 PM)flash.tato Wrote: [ -> ]Yep. i used PCRE in C and i din't find some issues (maybe i used RegEx with strings with little length).
No, I meant write a PCRE parser in C, not use one.
Pages: 1 2