Returns HTML for a generic HTML tag with attributes.

Paramètres

array $variables: An associative array containing:

  • element: An associative array describing the tag:

    • #tag: The tag name to output. Typical tags added to the HTML HEAD:

      • meta: To provide meta information, such as a page refresh.
      • link: To refer to stylesheets and other contextual information.
      • script: To load JavaScript.
    • #attributes: (optional) An array of HTML attributes to apply to the tag.
    • #value: (optional) A string containing tag content, such as inline CSS.
    • #value_prefix: (optional) A string to prepend to #value, e.g. a CDATA wrapper prefix.
    • #value_suffix: (optional) A string to append to #value, e.g. a CDATA wrapper suffix.
1 string reference to 'theme_html_script_tag'
advagg_theme_registry_alter dans ./advagg.module
Implements hook_theme_registry_alter().

Fichier

./advagg.module, line 3997

Code

function theme_html_script_tag(array $variables) {
    $element = $variables['element'];
    $attributes = '';
    $onload = '';
    $onerror = '';
    if (isset($element['#attributes'])) {
        // On Load.
        if (!empty($element['#attributes']['onload'])) {
            $onload = $element['#attributes']['onload'];
            unset($element['#attributes']['onload']);
        }
        // On Error.
        if (!empty($element['#attributes']['onerror'])) {
            $onerror = $element['#attributes']['onerror'];
            unset($element['#attributes']['onerror']);
        }
        $attributes = !empty($element['#attributes']) ? drupal_attributes($element['#attributes']) : '';
        if (!empty($onload)) {
            $attributes .= ' onload="' . advagg_jsspecialchars($onload) . '"';
        }
        if (!empty($onerror)) {
            $attributes .= ' onerror="' . advagg_jsspecialchars($onerror) . '"';
        }
    }
    if (!isset($element['#value'])) {
        return '<' . $element['#tag'] . $attributes . " />\n";
    }
    else {
        $output = '<' . $element['#tag'] . $attributes . '>';
        if (isset($element['#value_prefix'])) {
            $output .= $element['#value_prefix'];
        }
        $output .= $element['#value'];
        if (isset($element['#value_suffix'])) {
            $output .= $element['#value_suffix'];
        }
        $output .= '</' . $element['#tag'] . ">\n";
        return $output;
    }
}