本文整理匯總了PHP中Zend_Markup_Token::getAttributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Markup_Token::getAttributes方法的具體用法?PHP Zend_Markup_Token::getAttributes怎麽用?PHP Zend_Markup_Token::getAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Markup_Token
的用法示例。
在下文中一共展示了Zend_Markup_Token::getAttributes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderAttributes
/**
* Render some attributes
*
* @param Zend_Markup_Token $token
* @param array $attributes
* @return string
*/
public static function renderAttributes(Zend_Markup_Token $token, array $attributes = array())
{
$attributes = array_merge(self::$_defaultAttributes, $attributes);
$return = '';
$tokenAttributes = $token->getAttributes();
// correct style attribute
if (isset($tokenAttributes['style'])) {
$tokenAttributes['style'] = trim($tokenAttributes['style']);
if ($tokenAttributes['style'][strlen($tokenAttributes['style']) - 1] != ';') {
$tokenAttributes['style'] .= ';';
}
} else {
$tokenAttributes['style'] = '';
}
// special treathment for 'align' and 'color' attribute
if (isset($tokenAttributes['align'])) {
$tokenAttributes['style'] .= 'text-align: ' . $tokenAttributes['align'] . ';';
unset($tokenAttributes['align']);
}
if (isset($tokenAttributes['color']) && self::checkColor($tokenAttributes['color'])) {
$tokenAttributes['style'] .= 'color: ' . $tokenAttributes['color'] . ';';
unset($tokenAttributes['color']);
}
/*
* loop through all the available attributes, and check if there is
* a value defined by the token
* if there is no value defined by the token, use the default value or
* don't set the attribute
*/
foreach ($attributes as $attribute => $value) {
if (isset($tokenAttributes[$attribute]) && !empty($tokenAttributes[$attribute])) {
$return .= ' ' . $attribute . '="' . htmlentities($tokenAttributes[$attribute], ENT_QUOTES, self::getEncoding()) . '"';
} elseif (!empty($value)) {
$return .= ' ' . $attribute . '="' . htmlentities($value, ENT_QUOTES, self::getEncoding()) . '"';
}
}
return $return;
}