Sprinx
Пользователь
Нужно удалить bb_posts_text, ибо не кошерно дергать от туда инфу, а также хранить лишние данные.
Так же, плюсом будет уменьшенное количество запросов.
Написал фуньку преобразования html в ббкод, разработчикам в помощь.
В функцию не вошли теги, так как хрен знает зачем они:
'[tab]' => ' ',
'[del]' => '<span class="post-s">',
'[/del]' => '</span>',
Так же, плюсом будет уменьшенное количество запросов.
Написал фуньку преобразования html в ббкод, разработчикам в помощь.
Код:
function html_to_bbcode ($text)
{
$text = preg_replace('/<span class="post-b">(.*?)<(?=\/)\/span>/', '[b]$1[/b]', $text);
$text = preg_replace('/<span class="post-u">(.*?)<(?=\/)\/span>/', '[u]$1[/u]', $text);
$text = preg_replace('/<span class="post-i">(.*?)<(?=\/)\/span>/', '[i]$1[/i]', $text);
$text = preg_replace('/<span class="post-s">(.*?)<(?=\/)\/span>/', '[s]$1[/s]', $text);
$text = preg_replace('/<u class="q-post">(.*?)<(?=\/)\/u>/', '[qpost=$1]', $text);
$text = preg_replace('/<a href="mailto:.*?">(.*?)<(?=\/)\/span>/', '[email]$1[/email]', $text);
$text = preg_replace('/<a href="(.*?)" class="postLink">(.*?)<(?=\/)\/a>/', '[url=$1]$2[/url]', $text);
$text = preg_replace('/<span style="font-family: (.*?);">(.*?)<(?=\/)\/span>/', '[font=$1]$2[/font]', $text);
$text = preg_replace('/<span class="post-align" style="text-align: (.*?);">(.*?)<(?=\/)\/span>/', '[align=$1]$2[/align]', $text);
$text = preg_replace('/<span style="font-size: (.*?)px; line-height: normal;">(.*?)<(?=\/)\/span>/', '[size=$1]$2[/size]', $text);
$text = preg_replace('/<span style="color: (.*?);">(.*?)<(?=\/)\/span>/', '[color=$1]$2[/color]', $text);
$text = preg_replace('/<pre class="post-pre">(.*?)<(?=\/)\/pre>/', '[pre]$1[/pre]', $text);
$text = preg_replace('/<a class="postLink-name" href="#(.*?)">(.*?)<(?=\/)\/a>/', '[url=$1]$2[/url]', $text);
$text = preg_replace('/<a name="(.*?)"><(?=\/)\/a>/', '[name=$1]', $text);
$text = preg_replace('/<ul type="(.*?)">(.*?)<(?=\/)\/ul>/', '[list=$1]$2[/list]', $text);
$text = preg_replace('/<var class="postImg" title="(.*?)">.*?<(?=\/)\/var>/', '[img]$1[/img]', $text);
$text = preg_replace('/<var class="postImg postImgAligned img-(.*?)" title="(.*?)">.*?<(?=\/)\/var>/', '[img=$1]$2[/img]', $text);
$text = preg_replace('/<div class="q-wrap"><div class="q" head="(.*?)">(.*?)<\/div><(?=\/)\/div>/', '[quote="$1"]$2[/quote]', $text);
$text = preg_replace('/<div class="q-wrap"><div class="q">(.*?)<\/div><(?=\/)\/div>/', '[quote]$1[/quote]', $text);
$text = preg_replace('/<div class="sp-wrap"><div class="sp-body">(.*?)<\/div><(?=\/)\/div>/', '[spoiler]$1[/spoiler]', $text);
$text = preg_replace('/<div class="sp-wrap"><div class="sp-body" title=".*?"><h3 class="sp-title">(.*?)<\/h3>(.*?)<\/div><(?=\/)\/div>/', '[spoiler="$1"]$2[/spoiler]', $text);
$text = preg_replace('/<div class="clear">.*?<(?=\/)\/div>/', '[clear]', $text);
$text = str_replace('<span class="post-br"><br /></span>', '[br]', $text);
$text = str_replace('<span class="post-hr">-</span>', '[hr]', $text);
$text = str_replace('<li>', '[*]', $text);
$text = str_replace("\n\n", '[br]', $text);
$text = str_replace('<br />', "\n", $text);
return trim( strip_tags( html_entity_decode( $text ) ) );
}
В функцию не вошли теги, так как хрен знает зачем они:
'[tab]' => ' ',
'[del]' => '<span class="post-s">',
'[/del]' => '</span>',