ETidyCleanRepair is wrapper of PHP Tidy's tidy_repair_string.
Tidy is a binding for the Tidy HTML clean and repair utility which allows you to not only clean and otherwise manipulate HTML documents, but also traverse the document tree. To use Tidy, you will need libtidy installed, available on the tidy homepage. In PHP 5 (our case :) ) you need only to compile using the --with-tidy option.
ETidyCleanRepair can be used as either a widget or a controller filter. If Tidy is not available, the content is returned unchanged.
Please read the comments on the source code for licencing information and to learn about the available configurations.
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
- PHP Tidy extension
Installation ¶
- Extract the release file under
protected/extensions
Usage ¶
As a component, inside a controller, cleaning user provided data:
<?php
$tidy = Yii::createComponent('application.extensions.tidycleanrepair.ETidyCleanRepair');
// ...
$tidied = $tidy->cleanRepair($form->attributes['myHTML']);
Clean-up of (X)HTML in a view (you could use a model attribute or variable instead of static (X)HTML):
<?php $this->beginWidget('application.extensions.tidycleanrepair.ETidyCleanRepair',
array('config'=>array('output-xhtml'=>true, 'show-body-only'=>true))); ?>
<p>
<h1>Hello world!</b><br>
Goodbye!
</p>
<?php $this->endWidget('application.extensions.tidycleanrepair.ETidyCleanRepair'); ?>
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.