本文整理汇总了PHP中HtmlElement::validateAttrs方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlElement::validateAttrs方法的具体用法?PHP HtmlElement::validateAttrs怎么用?PHP HtmlElement::validateAttrs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlElement
的用法示例。
在下文中一共展示了HtmlElement::validateAttrs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decorate
/**
* Decorates HtmlElement element.
* @return void
*/
public function decorate(Texy $texy, HtmlElement $el)
{
$elAttrs =& $el->attrs;
// tag & attibutes
$tmp = $texy->allowedTags;
// speed-up
if (!$this->attrs) {
} elseif ($tmp === $texy::ALL) {
$elAttrs = $this->attrs;
$el->validateAttrs($texy->dtd);
} elseif (is_array($tmp) && isset($tmp[$el->getName()])) {
$tmp = $tmp[$el->getName()];
if ($tmp === $texy::ALL) {
$elAttrs = $this->attrs;
} elseif (is_array($tmp) && count($tmp)) {
$tmp = array_flip($tmp);
foreach ($this->attrs as $key => $value) {
if (isset($tmp[$key])) {
$el->attrs[$key] = $value;
}
}
}
$el->validateAttrs($texy->dtd);
}
// title
if ($this->title !== NULL) {
$elAttrs['title'] = $texy->typographyModule->postLine($this->title);
}
// classes & ID
if ($this->classes || $this->id !== NULL) {
$tmp = $texy->_classes;
// speed-up
if ($tmp === $texy::ALL) {
foreach ($this->classes as $value => $foo) {
$elAttrs['class'][] = $value;
}
$elAttrs['id'] = $this->id;
} elseif (is_array($tmp)) {
foreach ($this->classes as $value => $foo) {
if (isset($tmp[$value])) {
$elAttrs['class'][] = $value;
}
}
if (isset($tmp['#' . $this->id])) {
$elAttrs['id'] = $this->id;
}
}
}
// styles
if ($this->styles) {
$tmp = $texy->_styles;
// speed-up
if ($tmp === $texy::ALL) {
foreach ($this->styles as $prop => $value) {
$elAttrs['style'][$prop] = $value;
}
} elseif (is_array($tmp)) {
foreach ($this->styles as $prop => $value) {
if (isset($tmp[$prop])) {
$elAttrs['style'][$prop] = $value;
}
}
}
}
// horizontal align
if ($this->hAlign) {
if (empty($texy->alignClasses[$this->hAlign])) {
$elAttrs['style']['text-align'] = $this->hAlign;
} else {
$elAttrs['class'][] = $texy->alignClasses[$this->hAlign];
}
}
// vertical align
if ($this->vAlign) {
if (empty($texy->alignClasses[$this->vAlign])) {
$elAttrs['style']['vertical-align'] = $this->vAlign;
} else {
$elAttrs['class'][] = $texy->alignClasses[$this->vAlign];
}
}
return $el;
}