本文整理汇总了PHP中Mage_Core_Helper_Abstract::escapeHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Helper_Abstract::escapeHtml方法的具体用法?PHP Mage_Core_Helper_Abstract::escapeHtml怎么用?PHP Mage_Core_Helper_Abstract::escapeHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Helper_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Helper_Abstract::escapeHtml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getNumberFromToHtmlWithValue
/**
* Number 'from-to' field filter HTML with selected value.
*
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @param mixed $value
* @return string
*/
protected function _getNumberFromToHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value)
{
$fromValue = null;
$toValue = null;
$name = $this->getFilterElementName($attribute->getAttributeCode());
if (is_array($value) && count($value) == 2) {
$fromValue = $this->_helper->escapeHtml(reset($value));
$toValue = $this->_helper->escapeHtml(next($value));
}
return '<strong>' . $this->_helper->__('From') . ':</strong> ' . '<input type="text" name="' . $name . '[]" class="input-text"' . ' value="' . $fromValue . '" style="width:100px;"/> ' . '<strong>' . $this->_helper->__('To') . ':</strong> <input type="text" name="' . $name . '[]" class="input-text" style="width:100px;" value="' . $toValue . '" />';
}
示例2: escapeHtmlWithLinks
/**
* Escape string preserving links
*
* @param array|string $data
* @param null|array $allowedTags
* @return string
*/
public function escapeHtmlWithLinks($data, $allowedTags = null)
{
if (!empty($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {
$links = [];
$i = 1;
$data = str_replace('%', '%%', $data);
$regexp = "/<a\\s[^>]*href\\s*?=\\s*?([\"\\']??)([^\" >]*?)\\1[^>]*>(.*)<\\/a>/siU";
while (preg_match($regexp, $data, $matches)) {
//Revert the sprintf escaping
$url = str_replace('%%', '%', $matches[2]);
$text = str_replace('%%', '%', $matches[3]);
//Check for an valid url
if ($url) {
$urlScheme = strtolower(parse_url($url, PHP_URL_SCHEME));
if ($urlScheme !== 'http' && $urlScheme !== 'https') {
$url = null;
}
}
//Use hash tag as fallback
if (!$url) {
$url = '#';
}
//Recreate a minimalistic secure a tag
$links[] = sprintf('<a href="%s">%s</a>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8', false), parent::escapeHtml($text));
$data = str_replace($matches[0], '%' . $i . '$s', $data);
++$i;
}
$data = parent::escapeHtml($data, $allowedTags);
return vsprintf($data, $links);
}
return parent::escapeHtml($data, $allowedTags);
}
示例3: testEscapeHtml
/**
* @dataProvider escapeHtmlDataProvider
*/
public function testEscapeHtml($data, $expected)
{
$actual = $this->_helper->escapeHtml($data);
$this->assertEquals($expected, $actual);
}