Menu

#8 Edit task add lot of CRs

open
nobody
5
2014-08-20
2008-10-23
No

When a task as a long description with some CRs, edit this task will triple the CRs.

Exemple:
Description entered first time:
[line1
line2]

When edited, description look like that:
[line1

line2

]

Discussion

  • Vincent Osele

    Vincent Osele - 2008-10-28

    Nexty use :
    - nl2br
    - str_replace('\r\n',
    - mysql_real_escape_string
    - escapeQuery/unescapeQuery

    Each OS have different ASCII chars for linebreak:
    windows = \r\n
    unix = \n
    mac = \r

    And nl2br doesn't work with \r\n in my system !
    nl2br("blabla\r\nblabla") outputs "blabla<br />\r\n" !!

    As nl2br is called 2 times sometime (when new task is created), \r\n are converted in two <br/> !

    I suggest to define a new method in system called string2html (or whatever you want) that do
    return str_replace(array("\r\n", "\n", "\r"), "<br />",$str)

    And replace all nl2br with this function.

    One can use a more complex method to integrated bbcode for example later...

     
  • Vincent Osele

    Vincent Osele - 2008-10-28

    I think there are 3 forms for text, some could be the same but there are différent:
    1) text rendered on html page (with html tags)
    2) text writen by users in a form
    3) text inside database

    Here an example for CR and image
    1) text has <br/> or <p/>, and <img...> for example
    2) text has \r\n or \n depends of system, and [img] in bbcode style
    3) text could persist as \\n and [img] (same as 2 here)
    or as <br/> and <img...> (like 1)

    We must determine wich class or php do the conversions...

     

Log in to post a comment.

MongoDB Logo MongoDB