/** * Renders an html tag with the given attributes and inner html. * * If the innerHtml is detected as being wrapped in an html tag of some sort, it will attempt to format the code so that * it has a structured view in a browser, with the inner html indented and on a new line in between the tags. You * can turn this off by setting __MINIMIZE__, or by passing in true to $blnNoSpace. * * There area a few special cases to consider: * - Void elements will not be formatted to avoid adding unnecessary white space since these are generally * inline elements * - Non-void elements always use internal newlines, even in __MINIMIZE__ mode. This is to prevent different behavior * from appearing in __MINIMIZE__ mode on inline elements, because inline elements with internal space will render with space to separate * from surrounding elements. Usually, this is not an issue, but in the special situations where you really need inline * elements to be right up against its siblings, set $blnNoSpace to true. * * * @param string $strTag The tag name * @param null|mixed $mixAttributes String of attribute values or array of attribute values. * @param null|string $strInnerHtml The html to print between the opening and closing tags. This will NOT be escaped. * @param boolean $blnIsVoidElement True to print as a tag with no closing tag. * @param boolean $blnNoSpace Renders with no white-space. Useful in special inline situations. * @return string The rendered html tag */ public static function RenderTag($strTag, $mixAttributes, $strInnerHtml = null, $blnIsVoidElement = false, $blnNoSpace = false) { assert('!empty($strTag)'); $strToReturn = '<' . $strTag; if ($mixAttributes) { if (is_string($mixAttributes)) { $strToReturn .= ' ' . trim($mixAttributes); } else { // assume array $strToReturn .= QHtml::RenderHtmlAttributes($mixAttributes); } } if ($blnIsVoidElement) { $strToReturn .= ' />'; // conforms to both XHTML and HTML5 for both normal and foreign elements } elseif ($blnNoSpace || substr(trim($strInnerHtml), 0, 1) !== '<') { $strToReturn .= '>' . $strInnerHtml . '</' . $strTag . '>'; } else { // the hardcoded newlines below are important to prevent different drawing behavior in MINIMIZE mode $strToReturn .= '>' . "\n" . _indent(trim($strInnerHtml)) . "\n" . '</' . $strTag . '>' . _nl(); } return $strToReturn; }
/** * Render just attributes that can be included in any html tag to attach the proxy to the tag. * * @param string|null $strActionParameter * @return string */ public function RenderAttributes($strActionParameter = null) { $attributes['data-qpxy'] = $this->ControlId; if ($strActionParameter) { $attributes['data-qap'] = $strActionParameter; } return QHtml::RenderHtmlAttributes($attributes); }
/** * Returns the html for the attributes. Allows the given arrays to override the attributes and styles before * rendering. * @param null|string $attributeOverrides * @param null|string $styleOverrides * @return string */ public function RenderHtmlAttributes($attributeOverrides = null, $styleOverrides = null) { return QHtml::RenderHtmlAttributes($this->GetHtmlAttributes($attributeOverrides, $styleOverrides)); }