From fe2b6f3dfb4a9473905dde49b7741a6c03699c23 Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 30 Jan 2014 00:01:19 +0100 Subject: add image floating to bbcode --- doc/bbcode.html | 6 +++++- include/bbcode.php | 50 ++++++++++++++++++++++++++++++++++++++---------- view/tpl/item_attach.tpl | 2 +- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/doc/bbcode.html b/doc/bbcode.html index a24dd8b5d..d46f9d05a 100644 --- a/doc/bbcode.html +++ b/doc/bbcode.html @@ -1,5 +1,5 @@

BBcode reference

-
+


  • [b]bold[/b] - bold
    @@ -9,6 +9,10 @@
  • [color=red]red[/color] - red
  • [url=https://redmatrix.me]Red Matrix[/url] Red Matrix
  • [img]https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg[/img] Image/photo
    +
  • [img float=left]https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg[/img] Image/photo
    +
    +
  • [img float=right]https://redmatrix.me/images/default_profile_photos/rainbow_man/48.jpg[/img] Image/photo
    +
  • [code]code[/code] code
  • [quote]quote[/quote]
    quote

  • [quote=Author]Author? Me? No, no, no...[/quote]
    Author wrote:
    Author? Me? No, no, no...

    diff --git a/include/bbcode.php b/include/bbcode.php index fec8750e9..57494bd7a 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -439,6 +439,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { if (strpos($Text,'[/center]') !== false) { $Text = preg_replace("(\[center\](.*?)\[\/center\])ism","
    $1
    ",$Text); } + // Check for list text $Text = str_replace("[*]", "
  • ", $Text); @@ -531,23 +532,52 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { "
    " . $t_wrote . "
    $2
    ", $Text); - // [img=widthxheight]image source[/img] - //$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $Text); - if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $Text); - } - if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '', $Text); - } // Images // [img]pathtoimage[/img] - if (strpos($Text,'[/img]') !== false) { + if (strpos($Text,'[/img]') !== false) { $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } - if (strpos($Text,'[/zmg]') !== false) { + if (strpos($Text,'[/zmg]') !== false) { $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } + // [img float={left, right}]pathtoimage[/img] + if (strpos($Text,'[/img]') !== false) { + $Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); + } + if (strpos($Text,'[/img]') !== false) { + $Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); + } + if (strpos($Text,'[/zmg]') !== false) { + $Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + } + if (strpos($Text,'[/zmg]') !== false) { + $Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + } + + // [img=widthxheight]pathtoimage[/img] + if (strpos($Text,'[/img]') !== false) { + $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); + } + if (strpos($Text,'[/zmg]') !== false) { + $Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '' . 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", '' . t('Image/photo') . '', $Text); + } + if (strpos($Text,'[/img]') !== false) { + $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*) float=right\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); + } + if (strpos($Text,'[/zmg]') !== false) { + $Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*) float=left\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + } + if (strpos($Text,'[/zmg]') !== false) { + $Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*) float=right\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + } + + // crypt if (strpos($Text,'[/crypt]') !== false) { $x = random_string(); $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'
    ' . t('Encrypted content') . '
    ', $Text); diff --git a/view/tpl/item_attach.tpl b/view/tpl/item_attach.tpl index 25c127a15..7dc8dfd59 100644 --- a/view/tpl/item_attach.tpl +++ b/view/tpl/item_attach.tpl @@ -1,6 +1,6 @@ +
    {{foreach $attaches as $a}} {{/foreach}} -
    -- cgit v1.2.3