.

ConverterHtmlTidy Class Reference
[Tidy]

Converts plain HTML to tidyed HTML. More...

Inheritance diagram for ConverterHtmlTidy:
IConverter

List of all members.

Public Member Functions

  decode ($value, $params=false)
  Implemented for compatability, just returns the value passed in.
  encode ($value, $params=false)
  Tidy up $value.

Detailed Description

Converts plain HTML to tidyed HTML.

Use either directly or through ConverterFactory like this:

Author:
Gerd Riesselmann

Definition at line 14 of file htmltidy.converter.php.


Member Function Documentation

ConverterHtmlTidy::decode ( value,
params = false  
)

Implemented for compatability, just returns the value passed in.

Implements IConverter.

Definition at line 63 of file htmltidy.converter.php.

00063                                                         {
00064                 return $value;          
00065         }       
ConverterHtmlTidy::encode ( value,
params = false  
)

Tidy up $value.

Attention:
If $value starts with a <script> tag, the value is returned untouched. This is because tidy will strip it, even if in mode 'show-body-only'
Parameters:
$value  The original html
$params  Associative array containing tidy config parameters
Returns:
string

Implements IConverter.

Definition at line 26 of file htmltidy.converter.php.

00026                                                         {
00027                 //TODO this is a hotfix to keep tidy from striping <script>-Only-Content
00028                 if (String::starts_with(trim(String::to_lower($value)), '<script')) {
00029                         return $value;
00030                 }
00031                 $is_partial_doc = (strpos($value, '<html') === false);
00032                 $predefined_params = array(
00033                         'bare' => true,
00034                         'clean' => !$is_partial_doc,            
00035                         'drop-empty-paras' => true,
00036                         'drop-font-tags' => true,
00037                         'drop-proprietary-attributes' => true,
00038                         'enclose-block-text' => true,
00039                         'enclose-text' => true,
00040                         'indent' => true,
00041                         'join-classes' => false,
00042                         'join-styles' => false,
00043                         'logical-emphasis' => true,
00044                         'output-xhtml' => true,
00045                         'doctype' => 'loose',
00046                         'show-body-only' => $is_partial_doc, 
00047                         'merge-divs' => false,
00048                         //'merge-spans' => false, // Not widely supported on Debian system
00049                         'hide-comments' => true,
00050                         'lower-literals' => true,
00051                         'char-encoding' => String::plain_ascii(GyroLocale::get_charset(), ''),
00052                         'wrap' => 0
00053                 );
00054                 $params = array_merge($predefined_params, Arr::force($params, false));
00055                 $tidy = tidy_parse_string($value, $params, String::plain_ascii(GyroLocale::get_charset(), ''));
00056                 $tidy->cleanRepair();
00057                 return tidy_get_output($tidy);
00058         }

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