/** * 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; }