HTML_Common2
[ class tree: HTML_Common2 ] [ index: HTML_Common2 ] [ all elements ]

Class: HTML_Common2

Source Location: /HTML_Common2-2.1.2/HTML/Common2.php

Class Overview


Base class for HTML classes


Author(s):

Version:

  • Release: 2.1.2

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 58]
Base class for HTML classes

Implements methods for working with HTML attributes, parsing and generating attribute strings. Port of HTML_Common class for PHP4 originally written by Adam Daniel with contributions from numerous other developers.



[ Top ]


Class Variables

$attributes = array()

[line 64]

Associative array of attributes
  • Access: protected

Type:   array


[ Top ]

$watchedAttributes = array()

[line 72]

Changes to attributes in this list will be announced via onAttributeChange()

method rather than performed by HTML_Common2 class itself


Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 234]

HTML_Common2 __construct( [array|string $attributes = null])

Class constructor, sets default attributes
  • Access: public

Parameters:

array|string   $attributes   —  Array of attribute 'name' => 'value' pairs or HTML attribute string

[ Top ]

addClass   [line 435]

$this addClass( string|array $class)

Adds the given CSS class(es) to the element
  • Access: public

Parameters:

string|array   $class   —  Class name, multiple class names separated by whitespace, array of class names

[ Top ]

getAttribute   [line 268]

string|null getAttribute( string $name)

Returns the value of an attribute
  • Return: Attribute value, null if attribute does not exist
  • Access: public

Parameters:

string   $name   —  Attribute name

[ Top ]

getAttributes   [line 308]

array|string getAttributes( [bool $asString = false])

Returns the attribute array or string
  • Access: public

Parameters:

bool   $asString   —  Whether to return attributes as string

[ Top ]

getAttributesString   [line 218]

string getAttributesString( array $attributes)

Creates HTML attribute string from array
  • Return: Attribute string
  • Access: protected

Parameters:

array   $attributes   —  Attribute array

[ Top ]

getComment   [line 409]

string getComment( )

Returns the comment associated with the element
  • Access: public

[ Top ]

getIndent   [line 386]

string getIndent( )

Returns the string to indent the element
  • Access: protected

[ Top ]

getIndentLevel   [line 376]

int getIndentLevel( )

Gets the indentation level
  • Access: public

[ Top ]

getOption   [line 132]

mixed getOption( [string $name = null])

Returns global option(s)
  • Return: Option value, null if option does not exist, array of all options if $name is not given
  • Access: public

Parameters:

string   $name   —  Option name

[ Top ]

hasClass   [line 421]

bool hasClass( string $class)

Checks whether the element has given CSS class
  • Access: public

Parameters:

string   $class   —  CSS Class name

[ Top ]

mergeAttributes   [line 325]

$this mergeAttributes( array|string $attributes)

Merges the existing attributes with the new ones
  • Access: public

Parameters:

array|string   $attributes   —  Array of attribute 'name' => 'value' pairs or HTML attribute string

[ Top ]

offsetExists   [line 515]

boolean offsetExists( string $offset)

Whether or not an offset (HTML attribute) exists

Parameters:

string   $offset   —  An offset to check for.

[ Top ]

offsetGet   [line 529]

string|null offsetGet( string $offset)

Returns the value at specified offset (i.e. attribute name)

Parameters:

string   $offset   —  The offset to retrieve.

[ Top ]

offsetSet   [line 544]

void offsetSet( string $offset, string $value)

Assigns a value to the specified offset (i.e. attribute name)

Parameters:

string   $offset   —  The offset to assign the value to
string   $value   —  The value to set

[ Top ]

offsetUnset   [line 563]

void offsetUnset( string $offset)

Unsets an offset (i.e. removes an attribute)

Parameters:

string   $offset   —  The offset to unset

[ Top ]

onAttributeChange   [line 503]

void onAttributeChange( string $name, [string $value = null])

Called if trying to change an attribute with name in $watchedAttributes

This method is called for each attribute whose name is in the $watchedAttributes array and which is being changed by setAttribute(), setAttributes() or mergeAttributes() or removed via removeAttribute(). Note that the operation for the attribute is not carried on after calling this method, it is the responsibility of this method to change or remove (or not) the attribute.

  • Access: protected

Parameters:

string   $name   —  Attribute name
string   $value   —  Attribute value, null if attribute is being removed

[ Top ]

parseAttributes   [line 148]

array parseAttributes( string $attrString)

Parses the HTML attributes given as string
  • Return: An associative array of attributes
  • Access: protected

Parameters:

string   $attrString   —  HTML attribute string

[ Top ]

prepareAttributes   [line 181]

array prepareAttributes( string|array $attributes)

Creates a valid attribute array from either a string or an array
  • Return: An associative array of attributes
  • Access: protected

Parameters:

string|array   $attributes   —  Array of attributes or HTML attribute string

[ Top ]

removeAttribute   [line 345]

$this removeAttribute( string $attribute)

Removes an attribute
  • Access: public

Parameters:

string   $attribute   —  Name of attribute to remove

[ Top ]

removeAttributeArray   [line 206]

void removeAttributeArray( array &$attributes, string $name)

Removes an attribute from an attribute array
  • Access: protected

Parameters:

array   &$attributes   —  Attribute array
string   $name   —  Name of attribute to remove

[ Top ]

removeClass   [line 461]

$this removeClass( string|array $class)

Removes the given CSS class(es) from the element
  • Access: public

Parameters:

string|array   $class   —  Class name, multiple class names separated by whitespace, array of class names

[ Top ]

setAttribute   [line 247]

$this setAttribute( string $name, [string $value = null])

Sets the value of the attribute
  • Access: public

Parameters:

string   $name   —  Attribute name
string   $value   —  Attribute value (will be set to $name if omitted)

[ Top ]

setAttributes   [line 282]

$this setAttributes( string|array $attributes)

Sets the attributes
  • Access: public

Parameters:

string|array   $attributes   —  Array of attribute 'name' => 'value' pairs or HTML attribute string

[ Top ]

setComment   [line 398]

$this setComment( string $comment)

Sets the comment for the element
  • Access: public

Parameters:

string   $comment   —  String to output as HTML comment

[ Top ]

setIndentLevel   [line 362]

$this setIndentLevel( int $level)

Sets the indentation level
  • Access: public

Parameters:

int   $level   —  Indentation level

[ Top ]

setOption   [line 109]

void setOption( string|array $nameOrOptions, [mixed $value = null])

Sets global option(s)
  • Access: public

Parameters:

string|array   $nameOrOptions   —  Option name or array ('option name' => 'option value')
mixed   $value   —  Option value, if first argument is not an array

[ Top ]

__toString   [line 488]

string __toString( )

Returns the HTML representation of the element

This magic method allows using the instances of HTML_Common2 in string contexts

  • Abstract:
  • Access: public

[ Top ]


Documentation generated on Sun, 07 Apr 2019 07:04:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.