' . $name . '';
}
public static function getHelperButtonsFormat($formats){
$buttons = '';
foreach( $formats as $name => $infos )
{
if ( isset($infos['name']) )
{
$buttons .= HTMLUtils::getHelperButtonFormat($name, $infos['name']) . PHP_EOL;
}
}
return $buttons;
}
public static function displayBridgeCard($bridgeName, $formats, $isActive = true)
{
$bridgeElement = Bridge::create($bridgeName);
if($bridgeElement == false) {
return "";
}
$bridgeElement->loadMetadatas();
$name = ''.$bridgeElement->name.'';
$description = $bridgeElement->description;
$card = <<
{$name}
{$description}
CARD;
// If we don't have any parameter for the bridge, we print a generic form to load it.
if(count($bridgeElement->parameters) == 0) {
$card .= '' . PHP_EOL;
}
foreach($bridgeElement->parameters as $parameterName => $parameter)
{
if(!is_numeric($parameterName)) {
$card .= ''.$parameterName.'
' . PHP_EOL;
}
$card .= '' . PHP_EOL;
}
$card .= ''.$bridgeElement->maintainer.'';
$card .= '';
return $card;
}
}
class HTMLSanitizer {
var $tagsToRemove;
var $keptAttributes;
var $onlyKeepText;
public static $DEFAULT_CLEAR_TAGS = ["script", "iframe"];
public static $KEPT_ATTRIBUTES = ["title", "href", "src"];
const ONLY_TEXT = null;
function __construct($tags_to_remove = HTMLSanitizer::DEFAULT_CLEAR_TAGS, $kept_attributes = HTMLSanitizer::KEPT_ATTRIBUTES, $only_keep_text = HTMLSanitizer::ONLY_TEXT) {
$this->tagsToRemove = $tags_to_remove;
$this->keptAttributes = $kept_attributes;
$this->onlyKeepText = $only_keep_text;
}
function sanitize($textToSanitize) {
$htmlContent = str_get_html($textToSanitize);
foreach($htmlContent->find('*[!j_ai_pas_trouve_comment_tout_demander]') as $element) {
if(in_array($element->tag, $this->onlyKeepText)) {
$element->outertext = $element->plaintext;
} else if(in_array($element->tag, $this->tagsToRemove)) {
$element->outertext = '';
} else {
foreach($element->getAllAttributes() as $attributeName => $attribute) {
if(!in_array($attributeName, $this->keptAttributes)) $element->removeAttribute($attributeName);
}
}
}
return $htmlContent;
}
public static function defaultImageSrcTo($content, $server) {
foreach($content->find('img') as $image) {
if(strpos($image->src, '/')==0) {
$image->src = $server.$image->src;
}
}
}
}
?>