.

ConverterHtml Class Reference
[Lib]

Converts plain texyt to HTML (encode) or HTML to plain text (decode). More...

Inheritance diagram for ConverterHtml:
IConverter ConverterHtmlEx

List of all members.

Public Member Functions

  decode ($value, $params=false)
  encode ($value, $params=false)

Protected Member Functions

  process_paragraph ($text, $params)
  Process a single paragraph.

Detailed Description

Converts plain texyt to HTML (encode) or HTML to plain text (decode).

Author:
Gerd Riesselmann

Definition at line 8 of file html.converter.php.


Member Function Documentation

ConverterHtml::decode ( value,
params = false  
)

Implements IConverter.

Reimplemented in ConverterHtmlEx.

Definition at line 39 of file html.converter.php.

00039                                                         {
00040                 //$value = str_replace("\n", ' ', $value);
00041                 //$value = str_replace("\r", ' ', $value);
00042                 $value = str_replace('</p>', "</p>\n", $value);
00043                 $value = preg_replace('@<br.*?>@', "\n", $value);
00044                 $value = String::unescape($value);
00045                 return strip_tags($value);              
00046         }       
ConverterHtml::encode ( value,
params = false  
)

Implements IConverter.

Definition at line 9 of file html.converter.php.

00009                                                         {
00010                 $value = $this->decode($value);
00011                 $value = str_replace("\r", "\n", $value);
00012                 //var_dump(str_replace("\n", '\n', $value));
00013                 $arr_paragraphs = explode("\n", $value);
00014                 $c = count($arr_paragraphs);
00015                 $arr_result = array();
00016                 for($i = 0; $i < $c; $i++) {
00017                         $tmp = trim($arr_paragraphs[$i]);
00018                         if (empty($tmp)) {
00019                                 continue;
00020                         }
00021                         
00022                         $arr_result[] = $this->process_paragraph($tmp, $params);
00023                 }
00024                 $ret = implode("\n", $arr_result);
00025                 $ret = String::preg_replace('| +|', ' ', $ret);
00026                 return $ret;
00027         }
ConverterHtml::process_paragraph ( text,
params  
) [protected]

Process a single paragraph.

Parameters:
string  $text
Returns:
string

Reimplemented in ConverterHtmlEx.

Definition at line 35 of file html.converter.php.

00035                                                              {
00036                 return html::tag('p', String::escape($text));
00037         }

The documentation for this class was generated from the following file: