add image floating to bbcode

This commit is contained in:
marijus 2014-01-30 00:01:19 +01:00
parent 286dca84a1
commit fe2b6f3dfb
3 changed files with 46 additions and 12 deletions

View File

@ -1,5 +1,5 @@
<h3>BBcode reference</h3> <h3>BBcode reference</h3>
<div style="font-size: 14px;"> <div style="font-size: 14px; width=92%; max-width=1024px; display:block">
<br /><br /> <br /><br />
<ul class="listdecimal" style="list-style-type: decimal;"> <ul class="listdecimal" style="list-style-type: decimal;">
<li>[b]bold[/b] - <strong>bold</strong><br /> <li>[b]bold[/b] - <strong>bold</strong><br />
@ -9,6 +9,10 @@
<li>[color=red]red[/color] - <span style="color: red;">red</span><br /> <li>[color=red]red[/color] - <span style="color: red;">red</span><br />
<li>[url=https://redmatrix.me]Red Matrix[/url] <a href="https://redmatrix.me">Red Matrix</a><br /> <li>[url=https://redmatrix.me]Red Matrix[/url] <a href="https://redmatrix.me">Red Matrix</a><br />
<li>[img]https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg[/img] <img src="https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg" alt="Image/photo" /><br /> <li>[img]https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg[/img] <img src="https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg" alt="Image/photo" /><br />
<li>[img float=left]https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg[/img] <img src="https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg" style="float:left;" alt="Image/photo" /><br />
<div style="clear:both;"></div>
<li>[img float=right]https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg[/img] <img src="https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg" style="float:right;" alt="Image/photo" /><br />
<div style="clear:both;"></div>
<li>[code]code[/code] <code>code</code><br /> <li>[code]code[/code] <code>code</code><br />
<li>[quote]quote[/quote] <blockquote>quote</blockquote><br /> <li>[quote]quote[/quote] <blockquote>quote</blockquote><br />
<li>[quote=Author]Author? Me? No, no, no...[/quote] <br /><strong class="author">Author wrote:</strong><blockquote>Author? Me? No, no, no...</blockquote><br /> <li>[quote=Author]Author? Me? No, no, no...[/quote] <br /><strong class="author">Author wrote:</strong><blockquote>Author? Me? No, no, no...</blockquote><br />

View File

@ -439,6 +439,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
if (strpos($Text,'[/center]') !== false) { if (strpos($Text,'[/center]') !== false) {
$Text = preg_replace("(\[center\](.*?)\[\/center\])ism","<div style=\"text-align:center;\">$1</div>",$Text); $Text = preg_replace("(\[center\](.*?)\[\/center\])ism","<div style=\"text-align:center;\">$1</div>",$Text);
} }
// Check for list text // Check for list text
$Text = str_replace("[*]", "<li>", $Text); $Text = str_replace("[*]", "<li>", $Text);
@ -531,23 +532,52 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
"<br /><strong class=".'"author"'.">" . $t_wrote . "</strong><blockquote>$2</blockquote>", "<br /><strong class=".'"author"'.">" . $t_wrote . "</strong><blockquote>$2</blockquote>",
$Text); $Text);
// [img=widthxheight]image source[/img]
//$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
if (strpos($Text,'[/img]') !== false) {
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px;" >', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
$Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$3" style="width: $1px;" >', $Text);
}
// Images // Images
// [img]pathtoimage[/img] // [img]pathtoimage[/img]
if (strpos($Text,'[/img]') !== false) { if (strpos($Text,'[/img]') !== false) {
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text); $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
} }
if (strpos($Text,'[/zmg]') !== false) { if (strpos($Text,'[/zmg]') !== false) {
$Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" alt="' . t('Image/photo') . '" />', $Text); $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" alt="' . t('Image/photo') . '" />', $Text);
} }
// [img float={left, right}]pathtoimage[/img]
if (strpos($Text,'[/img]') !== false) {
$Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '<img src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/img]') !== false) {
$Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '<img src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
$Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
$Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text);
}
// [img=widthxheight]pathtoimage[/img]
if (strpos($Text,'[/img]') !== false) {
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px;" alt="' . t('Image/photo') . '" >', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
$Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$3" style="width: $1px;" alt="' . t('Image/photo') . '" >', $Text);
}
// [img=widthxheight float={left, right}]pathtoimage[/img]
if (strpos($Text,'[/img]') !== false) {
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*) float=left\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px; float: left;" alt="' . t('Image/photo') . '" >', $Text);
}
if (strpos($Text,'[/img]') !== false) {
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*) float=right\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px; float: right;" alt="' . t('Image/photo') . '" >', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
$Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*) float=left\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$3" style="width: $1px; float: left;" alt="' . t('Image/photo') . '" >', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
$Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*) float=right\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$3" style="width: $1px; float: right;" alt="' . t('Image/photo') . '" >', $Text);
}
// crypt
if (strpos($Text,'[/crypt]') !== false) { if (strpos($Text,'[/crypt]') !== false) {
$x = random_string(); $x = random_string();
$Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><div id="' . $x . '"><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" onclick="red_decrypt(\'rot13\',\'\',\'$1\',\'#' . $x . '\');" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br /></div>', $Text); $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><div id="' . $x . '"><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" onclick="red_decrypt(\'rot13\',\'\',\'$1\',\'#' . $x . '\');" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br /></div>', $Text);

View File

@ -1,6 +1,6 @@
<div class="clear"></div>
<div class="body-attach"> <div class="body-attach">
{{foreach $attaches as $a}} {{foreach $attaches as $a}}
<a href="{{$a.url}}" title="{{$a.title}}" class="attachlink" ><i class="icon-paper-clip attach-icons attach-clip"></i><i class="{{$a.icon}} attach-icons"></i></a> <a href="{{$a.url}}" title="{{$a.title}}" class="attachlink" ><i class="icon-paper-clip attach-icons attach-clip"></i><i class="{{$a.icon}} attach-icons"></i></a>
{{/foreach}} {{/foreach}}
<div class="clear"></div>
</div> </div>