2006-08-11, 07:46 PM
A question or perhaps partly a feature request. I don't know the state of how 1.2 handles things too (which is what I'm waiting for), so...
I want the ability to offer users a choice of markup, where you'd have a set of radio inputs in the post form.
Now, what I'm looking for is the MyBB-specific info to accomplish this.
In 1.1.x, I noticed a couple things, and have some questions.
- Would it be possible to move all the post parsing within postify() to a pre-supplied (but internal) plugin? That way it could be overridden by users without hacking.
For example:
(Code modified to use CraKteR's suggestion.)
- The remove_hook function is commented out?
- What would be the procedure (hooks? etc) to add the radios and check their contents before parsing? Or perhaps I need to just add to some templates? (which ones?)
- For this markup "post preference" I'll need to add a new column to the posts table. I think I'll need to alter the table myself, correct?
- I'm pretty sure as far as the PHP side goes, I've otherwise got all the hooks I need?
Hopefully it's clear what I'm talking about.
I want the ability to offer users a choice of markup, where you'd have a set of radio inputs in the post form.
Now, what I'm looking for is the MyBB-specific info to accomplish this.
In 1.1.x, I noticed a couple things, and have some questions.
- Would it be possible to move all the post parsing within postify() to a pre-supplied (but internal) plugin? That way it could be overridden by users without hacking.
For example:
function postify($message, $allowhtml = 'no', $allowmycode = 'yes', $allowsmilies = 'yes', $allowimgcode = 'yes', $archive = 0)
{
global $db, $mybb, $theme, $plugins;
return $plugins->run_hooks('parse_message', $message);
}
$plugins->add_hook('parse_message', 'mybb_markup');
function mybb_markup($message)
{
global $db, $mybb, $theme, $plugins, $allowhtml, $allowmycode, $allowsmilies, $allowimgcode, $archive;
$message = dobadwords($message);
if ($allowhtml != 'yes')
{
// fix & but allow unicode
$message = preg_replace("#&(?!\#[0-9]+;)#si", '&', $message);
$message = str_replace(array('<','>'), array('<','>'), $message);
if ($allowimgcode != 'yes')
{
$message = str_replace('<img', '<img', $message);
}
}
if ($allowsmilies != 'no')
{
if ($archive == 'yes')
{
$message = dosmilies($message, $mybb->settings['bburl']);
}
else
{
$message = dosmilies($message);
}
}
if ($allowmycode != 'no')
{
$message = domycode($message, $allowimgcode);
}
$message = nl2br($message);
return $message;
}
(Code modified to use CraKteR's suggestion.)
- The remove_hook function is commented out?
- What would be the procedure (hooks? etc) to add the radios and check their contents before parsing? Or perhaps I need to just add to some templates? (which ones?)
- For this markup "post preference" I'll need to add a new column to the posts table. I think I'll need to alter the table myself, correct?
- I'm pretty sure as far as the PHP side goes, I've otherwise got all the hooks I need?
Hopefully it's clear what I'm talking about.