Adding Textile and Markdown Extra options to a PunBB 1.2.17 forum
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
by Stef Dawson (http://stefdawson.com/)
===================
New database fields
===================
ALTER TABLE `pbb_users` ADD `markup_system` VARCHAR( 15 ) NOT NULL DEFAULT 'BBCode';
INSERT INTO `pbb_config` (
`conf_name` ,
`conf_value`
)
VALUES (
'p_message_textile', '0'
), (
'p_message_markdown', '0'
);
INSERT INTO `pbb_config` (
`conf_name` ,
`conf_value`
)
VALUES (
'p_sig_textile', '0'
), (
'p_sig_markdown', '0'
);
(you may optionally alter install.php to include the new fields too)
=======================
lang/English/common.php
=======================
Replace:
'img tag' => '[img] tag',
With:
'Textile' => 'Textile', // nor this
'Markdown' => 'Markdown Extra', // nor this
'img tag' => 'image markup',
========================
lang/English/profile.php
========================
Find:
'Style info' => 'If you like you can use a different visual style for this forum.',
And add afterwards:
'Markup legend' => 'Select your preferred markup system',
'Markup info' => 'If you like you can use one of these systems to add markup to your posts.',
=====================
admin_permissions.php
=====================
Replace:
Image tag
/> Yes /> NoAllow the BBCode [img][/img] tag in posts.
With:
Textile
/> Yes /> NoAllow Textile in posts (optional).
Markdown
/> Yes /> NoAllow Markdown in posts (optional).
Image tag
/> Yes /> NoAllow images in posts.
Replace:
Image tag in signatures
/> Yes /> NoAllow the BBCode [img][/img] tag in user signatures (not recommended).
With:
Textile in signatures
/> Yes /> NoAllow Textile in user signatures.
Markdown in signatures
/> Yes /> NoAllow Markdown in user signatures.
Image tag in signatures
/> Yes /> NoAllow images in user signatures (not recommended).
===========
profile.php
===========
Replace:
// Validate BBCode syntax
if ($pun_config['p_sig_bbcode'] == '1' && strpos($form['signature'], '[') !== false && strpos($form['signature'], ']') !== false)
{
require PUN_ROOT.'include/parser.php';
$form['signature'] = preparse_bbcode($form['signature'], $foo, true);
}
With:
// Validate BBCode syntax
if ($pun_config['p_sig_bbcode'] == '1' || $pun_config['p_sig_textile'] == '1' || $pun_config['p_sig_markdown'] == '1')
{
require PUN_ROOT.'include/parser.php';
}
if ($pun_config['p_sig_bbcode'] == '1' && strpos($form['signature'], '[') !== false && strpos($form['signature'], ']') !== false)
{
$form['signature'] = preparse_bbcode($form['signature'], $foo, true);
}
A few lines later, replace:
$form = extract_elements(array('disp_topics', 'disp_posts', 'show_smilies', 'show_img', 'show_img_sig', 'show_avatars', 'show_sig', 'style'));
With:
$form = extract_elements(array('disp_topics', 'disp_posts', 'show_smilies', 'show_img', 'show_img_sig', 'show_avatars', 'show_sig', 'style', 'markup_system'));
About halfway down, find:
$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.save_pass, u.notify_with_post, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.language, u.style, u.num_posts, u.last_post, u.registered, u.registration_ip, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
And replace with:
$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.save_pass, u.notify_with_post, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.language, u.style, u.markup_system, u.num_posts, u.last_post, u.registered, u.registration_ip, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
Near the bottom, find:
:
Replace with:
:
:
:
A bit further on, find the post display legend:
'."\n";
else if (count($markup) > 1)
{
natsort($markup);
?>