string TxtToHTML( string text, bool make_url = true, int max_string = 0, string quote_tag_enabled = "N", string not_convert_amp = "Y", string code_tag_enabled = "N", string biu_tags_enabled = "N", string quote_table_class = "quotetable", string quote_head_class = "tdquotehead", string quote_body_class = "tdquote", string code_table_class = "codetable", string code_head_class = "tdcodehead", string code_body_class = "tdcodebody", string code_textarea_class = "codetextarea", string link_class = "txttohtmllink" array event = array() );
The function TxtToHTML converts plain text to HTML formatted text.
Parameter | Description |
---|---|
text | Original text to be converted. |
make_url | If true, strings containing web addresses (http://... or mailto:) will be converted to HTML links. Optional; the default value is true. |
max_string | Maximum length of each word. All words whose length exceeds this value is split with spaces. A value of "0" disables splitting. Optional; the default value is "0". |
quote_tag_enabled | If "Y", a special tag <QUOTE>...</QUOTE> will be converted to the HTML table (frames the quote in border). Optional; the default value is "N". |
not_convert_amp | If "Y", ampersand symbols "&" will not be converted to "&". Optional; the default value is "Y". |
code_tag_enabled | If "Y", a special tag <CODE>...</CODE> will be converted to the HTML element "textarea" in table (frames the code in border and displays it in the "textarea" tag). Optional; the default value is "N". |
biu_tags_enabled | If "Y", special tags <b>...</b>, <i>...</i>, <u>...</u> are converted to corresponding HTML tags. |
quote_table_class | CSS class for the "quote" table (<quote>). Optional; the default value is "quotetable". |
quote_head_class | CSS class for the first cell (TD) of the "quote" table (<quote>). Optional; the default value is "tdquotehead". |
quote_body_class | CSS class for the second cell (TD) of the "quote" table (<quote>):
<table class="quote_table_class"> <tr> <td class="quote_head_class"> ... </td> </tr> <tr> <td class="quote_body_class"> ... </td> </tr> </table>Optional; the default value is "tdquote". |
code_table_class | CSS class for the "code" table (<code>). Optional; the default value is "codetable". |
code_head_class | CSS class for the first cell of the "code" table (<code>). Optional; the default value is "tdcodehead". |
code_body_class | CSS class for the second cell of the "code" table (<code>). Optional; the default value is "tdcodebody". |
code_textarea_class | CSS class for the "textarea" tag in the "code" table (<code>):
<table class="code_table_class"> <tr> <td class="code_head_class"> ... </td> </tr> <tr> <td class="code_body_class"> <textarea class="code_textarea_class"> ... </textarea> </td> </tr> </table>Optional; the default value is "codetextarea". |
link_class | CSS for links:
<a class="link_class"> ... </a>Optional; the default value is "txttohtmllink". |
event | This array can be used to pass the event type identifiers to register
when a link is clicked. This parameter is only effective if
|
$text = " text text text text text text text text longwordlongwordlongword <code>code code code</code> <quote>quote quote quote</quote> <b>bold text</b> <i>italic</i> <u>underlined</u> link: http://www.bitrixsoft.com email: support@bitrixsoft.com "; echo TxtToHTML( $text, true, 20, "Y", "N", "Y", "Y", "quotetable", "tdquotehead", "tdquote", "codetable", "tdcodehead", "tdcodebody", "codetextarea" );
text text text text<br> text text text text<br> longwordlongwordlongwordlon gword<br> <table class='codetable'> <tr> <td class='tdcodehead'>Code</td> </tr> <tr> <td class='tdcodebody'> <textarea class='codetextarea' contentEditable=false cols=60 rows=15 wrap=virtual>code code code</textarea></td> </tr> </table><br> <table class='quotetable' width='95%' border='0' cellpadding='3' cellspacing='1'> <tr> <td class='tdquotehead'>Quote</td> </tr> <tr> <td class='tdquote'>quote quote quote</td> </tr> </table><br> <b>bold text</b><br> <i>italic</i><br> <u>underlined</u><br> link: <a class="txttohtmllink" href="http://www.bitrixsoft.com">http://www.bitrixsoft.com</a><br> email: <a class="txttohtmllink" href="mailto:support@bitrixsoft.com">support@bitrixsoft.com</a>
The CSS is to be included prior to function call.
.quotetable, .codetable {width:90%} .quotetable .tdquotehead, .quotetable .tdquote, .codetable .tdcodehead, .codetable .tdcodebody, .codetextarea {padding: 2px; font-family: Arial; font-size:12px; color:#000000} .quotetable .tdquotehead, .codetable .tdcodehead {font-weight:bold} .quotetable .tdquote, .codetable .tdcodebody {border: 1px solid Black} .quotetable .tdquotehead, .quotetable .tdquote, .codetable .tdcodehead, .codetable .tdcodebody, .codetextarea {background-color: #FFFFFF} .codetextarea { border: solid 0px; width: 100%; overflow: auto; scrollbar-shadow-color: #000000; scrollbar-arrow-color: #000000; scrollbar-base-color: #000000} .codetextarea { scrollbar-face-color: #FFFFFF; scrollbar-highlight-color: #FFFFFF; scrollbar-track-color: #FFFFFF; scrollbar-darkshadow-color: #FFFFFF}
Code |
Quote |
quote quote quote |
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |