function testGetHTMLEscapesContent() { $field = new TextField('comment'); $content = '<strong>some markup in a text area</strong> & some more \'"'; $expected = '<strong>some markup in a text area</strong> & some more \'"'; $field->setValue($content); $html = $field->getHtml(); $this->assertContains($expected, $html); }
public function getHtml() { $html = parent::getHtml(); $id = $this->getId(); $ep = $this->getEmoticonParser(); if ($ep) { $emoticons = $ep->getEmoticons(); $toolbar = '<div id="' . $id . 'EmoticonToolbar" class="bbcodeToolbar">'; $images = array(); foreach ($emoticons as $emoticon => $image) { if (in_array($image, $images)) { continue; } $images[] = $image; $image = new Image($image); $image->setAttribute('alt', $emoticon); $image->setAttribute('title', $emoticon); $emoticon = addslashes($emoticon); $toolbar .= '<a href="#" onclick="return bbcodeAdd(\'' . $id . "', ' " . $emoticon . '\');">'; $toolbar .= $image->getHtml(); $toolbar .= '</a> '; } $toolbar .= '</div>'; $html = $toolbar . $html; } $toolbar = '<div id="' . $id . 'BBCodeToolbar" class="bbcodeToolbar">'; foreach ($this->bbcode as $code => $bbcode) { $open = $bbcode['open']; if (isset($bbcode['close'])) { $close = $bbcode['close']; } else { $close = false; } $image = new Image($bbcode['image']); $image->setAttribute('alt', $code); $image->setAttribute('title', $code); if (!$close) { $toolbar .= '<a href="#" onclick="return bbcodeAdd(\'' . $id . "', '" . $open . '\');">'; } else { $toolbar .= '<a href="#" onclick="return bbcodeAdd(\'' . $id . "', '" . $open . "', '" . $close . '\');">'; } $toolbar .= $image->getHtml(); $toolbar .= '</a> '; } $toolbar .= '</div>'; $html = $toolbar . $html; return $html; }