00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 class ConverterHtmlTidy implements IConverter {
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 public function encode($value, $params = false) {
00027
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
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 }
00059
00060
00061
00062
00063 public function decode($value, $params = false) {
00064 return $value;
00065 }
00066 }