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

Class: HTML_CSS

Source Location: /HTML_CSS-1.5.4/CSS.php

Class Overview

HTML_Common
   |
   --HTML_CSS

Base class for CSS definitions


Author(s):

Version:

  • Release: 1.5.4

Copyright:

  • 2003-2009 Klaus Guenther, Laurent Laville

Methods


Inherited Variables

Inherited Methods


Class Details

[line 84]
Base class for CSS definitions

This class handles the details for creating properly constructed CSS declarations.



[ Top ]


Method Detail

HTML_CSS (Constructor)   [line 277]

HTML_CSS HTML_CSS( [array $attributes = array()], [array $errorPrefs = array()])

Class constructor

Class constructors : Zend Engine 1 uses HTML_CSS, while Zend Engine 2 uses __construct

  • Since: version 0.2.0 (2003-07-31)
  • Access: public

Parameters:

array   $attributes   —  (optional) Pass options to the constructor. Valid options are :
  • xhtml (sets xhtml compliance),
  • tab (sets indent string),
  • filename (name of file to be parsed),
  • cache (determines whether the nocache headers are sent),
  • oneline (whether to output each definition on one line),
  • groupsfirst (determines whether to output groups before elements)
  • allowduplicates (allow to have duplicate rules in selector)
array   $errorPrefs   —  (optional) has to configure error handler

[ Top ]

__construct (Constructor)   [line 306]

HTML_CSS __construct( [array $attributes = array()], [array $errorPrefs = array()])

Class constructor

Class constructors : Zend Engine 1 uses HTML_CSS, while Zend Engine 2 uses __construct

  • Since: version 1.4.0 (2007-12-13)
  • Access: protected

Parameters:

array   $attributes   —  (optional) Pass options to the constructor. Valid options are :
  • xhtml (sets xhtml compliance),
  • tab (sets indent string),
  • filename (name of file to be parsed),
  • cache (determines whether the nocache headers are sent),
  • oneline (whether to output each definition on one line),
  • groupsfirst (determines whether to output groups before elements)
  • allowduplicates (allow to have duplicate rules in selector)
array   $errorPrefs   —  (optional) has to configure error handler

[ Top ]

addGroupSelector   [line 1271]

void|PEAR_Error addGroupSelector( mixed $group, string $selectors)

Add a selector to a CSS definition group.

Add a selector to a CSS definition group

  • Since: version 0.3.0 (2003-11-03)
  • Throws: HTML_CSS_ERROR_NO_GROUP, HTML_CSS_ERROR_INVALID_INPUT
  • Access: public

Parameters:

mixed   $group   —  CSS definition group identifier
string   $selectors   —  Selector(s) to be defined, comma delimited.

[ Top ]

apiVersion   [line 344]

string apiVersion( )

Return the current API version

Since 1.0.0 a string is returned rather than a float (for previous versions).

  • Return: compatible with php.version_compare()
  • Since: version 0.2.0 (2003-07-31)
  • Access: public

[ Top ]

collapseInternalSpaces   [line 614]

string collapseInternalSpaces( string $subject)

Strips excess spaces in string.
  • Since: version 0.3.2 (2004-03-24)
  • Access: protected

Parameters:

string   $subject   —  string to format

[ Top ]

createAtRule   [line 711]

void|PEAR_Error createAtRule( string $atKeyword, [string $arguments = ''], [bool $duplicates = null])

Create a new simple declarative At-Rule

Create a simple at-rule without declaration style blocks. That include @charset, @import and @namespace

  • See: HTML_CSS::unsetAtRule()
  • Throws: HTML_CSS_ERROR_INVALID_INPUT
  • Since: version 1.5.0 (2008-01-15)
  • Access: public

Parameters:

string   $atKeyword   —  at-rule keyword
string   $arguments   —  argument list for @charset, @import or @namespace
bool   $duplicates   —  (optional) Allow or disallow duplicates

[ Top ]

createGroup   [line 1014]

mixed|PEAR_Error createGroup( string $selectors, [mixed $group = null])

Create a new CSS definition group

Create a new CSS definition group. Return an integer identifying the group.

  • See: HTML_CSS::unsetGroup()
  • Throws: HTML_CSS_ERROR_INVALID_INPUT, HTML_CSS_ERROR_INVALID_GROUP
  • Since: version 0.3.0 (2003-11-03)
  • Access: public

Parameters:

string   $selectors   —  Selector(s) to be defined, comma delimited.
mixed   $group   —  (optional) Group identifier. If not passed, will return an automatically assigned integer.

[ Top ]

display   [line 2593]

void display( )

Output CSS Code.

Send the stylesheet content to standard output, handling cacheControl and contentDisposition headers


[ Top ]

getAtRulesList   [line 688]

void getAtRulesList( )

Return list of supported At-Rules

Return the list of At-Rules supported by API 1.5.0 of HTML_CSS

  • Since: version 1.5.0 (2008-01-15)
  • Access: public

[ Top ]

getAtRuleStyle   [line 941]

void|PEAR_Error getAtRuleStyle( string $atKeyword, string $arguments, string $selectors, string $property)

Get style value of an existing At-Rule

Retrieve arguments or style value of an existing At-Rule. See HTML_CSS::getAtRulesList() for a full list of supported At-Rules.


Parameters:

string   $atKeyword   —  at-rule keyword
string   $arguments   —  argument list (optional for @font-face)
string   $selectors   —  selectors of declaration style block (optional for @media, @page, @font-face)
string   $property   —  property of a single declaration style block

[ Top ]

getCache   [line 1731]

boolean getCache( )

Returns the cache option value

[ Top ]

getCharset   [line 1840]

string getCharset( )

Return the charset encoding string

By default, HTML_CSS uses iso-8859-1 encoding.


[ Top ]

getContentDisposition   [line 1797]

mixed getContentDisposition( )

Return the Content-Disposition header

Get value of Content-Disposition header (inline filename) used to display results


[ Top ]

getGroupStyle   [line 1204]

mixed|PEAR_Error getGroupStyle( mixed $group, string $property)

Return CSS definition for a CSS group

Get the CSS definition for group created by setGroupStyle()

  • See: HTML_CSS::setGroupStyle()
  • Throws: HTML_CSS_ERROR_INVALID_INPUT, HTML_CSS_ERROR_NO_GROUP, HTML_CSS_ERROR_NO_ELEMENT
  • Since: version 0.3.0 (2003-11-03)
  • Access: public

Parameters:

mixed   $group   —  CSS definition group identifier
string   $property   —  Property defined

[ Top ]

getOptions   [line 399]

array getOptions( )

Return all options for the class

Return all configuration options at once

  • Since: version 1.5.0 (2008-01-15)
  • Access: public

[ Top ]

getStyle   [line 1464]

mixed|PEAR_Error getStyle( string $element, string $property)

Return the value of a CSS property

Get the value of a property to an identifed simple CSS element

  • See: HTML_CSS::setStyle()
  • Throws: HTML_CSS_ERROR_INVALID_INPUT, HTML_CSS_ERROR_NO_ELEMENT, HTML_CSS_ERROR_NO_ELEMENT_PROPERTY
  • Since: version 0.3.0 (2003-11-03)
  • Access: public

Parameters:

string   $element   —  Element (or class) to be defined
string   $property   —  Property defined

[ Top ]

grepStyle   [line 1546]

array|PEAR_Error grepStyle( string $elmPattern, [string $proPattern = null])

Retrieve styles corresponding to an element filter

Return array entries of styles that match patterns (Perl compatible)


Parameters:

string   $elmPattern   —  Element or class pattern to retrieve
string   $proPattern   —  (optional) Property pattern to retrieve

[ Top ]

isError   [line 2750]

boolean isError( )

Determine whether there is an error

Determine whether last action raised an error or not

  • Return: TRUE if error raised, FALSE otherwise
  • Since: version 1.0.0RC2 (2005-12-15)
  • Access: public

[ Top ]

parseData   [line 2163]

void|PEAR_Error parseData( array $styles, [bool $duplicates = null])

Parse multiple data sources

Parse data sources, file(s) or string(s), that contains CSS information


Parameters:

array   $styles   —  data sources to parse
bool   $duplicates   —  (optional) Allow or disallow duplicates.

[ Top ]

parseFile   [line 2114]

void|PEAR_Error parseFile( string $filename, [bool $duplicates = null])

Parse file content

Parse a file that contains CSS information

  • See: HTML_CSS::parseString()
  • Throws: HTML_CSS_ERROR_INVALID_INPUT, HTML_CSS_ERROR_NO_FILE
  • Since: version 0.3.0 (2003-11-03)
  • Access: public

Parameters:

string   $filename   —  file to parse
bool   $duplicates   —  (optional) Allow or disallow duplicates.

[ Top ]

parseSelectors   [line 506]

mixed|PEAR_Error parseSelectors( string $selectors, [int $outputMode = 0])

Parse a string containing selector(s)

It processes it and returns an array or string containing modified selectors (depends on XHTML compliance setting; defaults to ensure lowercase element names)

  • Since: version 0.3.2 (2004-03-24)
  • Throws: HTML_CSS_ERROR_INVALID_INPUT
  • Access: protected

Parameters:

string   $selectors   —  Selector string
int   $outputMode   —  (optional) 0 = string; 1 = array; 2 = deep array

[ Top ]

parseString   [line 1860]

void|PEAR_Error parseString( string $str, [bool $duplicates = null])

Parse a string

Parse a string that contains CSS information


Parameters:

string   $str   —  text string to parse
bool   $duplicates   —  (optional) Allows or disallows duplicate style definitions

[ Top ]

raiseError   [line 2733]

object PEAR_Error raiseError( )

A basic wrapper around the default PEAR_Error object

This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied.

  • Return: when default error handler is used
  • See: _errorHandler()
  • Since: version 0.3.3 (2004-05-20)
  • Access: public

[ Top ]

removeGroupSelector   [line 1323]

void|PEAR_Error removeGroupSelector( mixed $group, string $selectors)

Remove a selector from a group

Definitively remove a selector from a CSS group

  • Since: version 0.3.0 (2003-11-03)
  • Throws: HTML_CSS_ERROR_NO_GROUP, HTML_CSS_ERROR_INVALID_INPUT
  • Access: public

Parameters:

mixed   $group   —  CSS definition group identifier
string   $selectors   —  Selector(s) to be removed, comma delimited.

[ Top ]

setAtRuleStyle   [line 832]

void|PEAR_Error setAtRuleStyle( string $atKeyword, string $arguments, string $selectors, string $property, string $value, [bool $duplicates = null])

Define a conditional/informative At-Rule

Set arguments and declaration style block for at-rules that follow : "@media, @page, @font-face"


Parameters:

string   $atKeyword   —  at-rule keyword
string   $arguments   —  argument list (optional for @font-face)
string   $selectors   —  selectors of declaration style block (optional for @media, @page, @font-face)
string   $property   —  property of a single declaration style block
string   $value   —  value of a single declaration style block
bool   $duplicates   —  (optional) Allow or disallow duplicates

[ Top ]

setCache   [line 1709]

void|PEAR_Error setCache( [bool $cache = true])

Set cache flag

Define if the document should be cached by the browser. Default to false.

  • Since: version 0.2.0 (2003-07-31)
  • Throws: HTML_CSS_ERROR_INVALID_INPUT
  • Access: public

Parameters:

bool   $cache   —  (optional) flag to true to cache result, false otherwise

[ Top ]

setCharset   [line 1816]

void|PEAR_Error setCharset( [string $type = 'iso-8859-1'])

Set charset value

Define the charset for the file. Default to ISO-8859-1 because of CSS1 compatability issue for older browsers.

  • See: HTML_CSS::getCharset()
  • Throws: HTML_CSS_ERROR_INVALID_INPUT
  • Since: version 0.2.0 (2003-07-31)
  • Access: public

Parameters:

string   $type   —  (optional) Charset encoding; defaults to ISO-8859-1.

[ Top ]

setContentDisposition   [line 1754]

void|PEAR_Error setContentDisposition( [bool $enable = true], [string $filename = ''])

Set Content-Disposition header

Define the Content-Disposition header to supply a recommended filename and force the browser to display the save dialog. Default to basename($_SERVER['PHP_SELF']).'.css'


Parameters:

bool   $enable   —  (optional)
string   $filename   —  (optional)

[ Top ]

setGroupStyle   [line 1118]

void|int|PEAR_Error setGroupStyle( mixed $group, string $property, string $value, [bool $duplicates = null])

Set or add a CSS definition for a CSS group

Define the new value of a property for a CSS group. The group should exist. If not, use HTML_CSS::createGroup first

  • Return: Returns an integer if duplicates are allowed.
  • See: HTML_CSS::getGroupStyle()
  • Throws: HTML_CSS_ERROR_INVALID_INPUT, HTML_CSS_ERROR_NO_GROUP
  • Since: version 0.3.0 (2003-11-03)
  • Access: public

Parameters:

mixed   $group   —  CSS definition group identifier
string   $property   —  Property defined
string   $value   —  Value assigned
bool   $duplicates   —  (optional) Allow or disallow duplicates.

[ Top ]

setLineEnd   [line 432]

void setLineEnd( string $style)

Set lineend value

Set the line end style to Windows, Mac, Unix or a custom string

  • Since: version 1.4.0 (2007-12-13)
  • Access: public

Parameters:

string   $style   —  "win", "mac", "unix" or custom string.

[ Top ]

setOutputGroupsFirst   [line 477]

void|PEAR_Error setOutputGroupsFirst( bool $value)

Set groupsfirst flag

Determine whether groups are output before elements or not

  • Since: version 0.3.3 (2004-05-20)
  • Throws: HTML_CSS_ERROR_INVALID_INPUT
  • Access: public

Parameters:

bool   $value   —  flag to true if groups are output before elements, false otherwise

[ Top ]

setSameStyle   [line 1630]

void|PEAR_Error setSameStyle( string $new, string $old)

Apply same styles on two selectors

Set or change the properties of new selectors to the values of an existing selector

  • Since: version 0.2.0 (2003-07-31)
  • Throws: HTML_CSS_ERROR_INVALID_INPUT, HTML_CSS_ERROR_NO_ELEMENT
  • Access: public

Parameters:

string   $new   —  New selector(s) that should share the same definitions, separated by commas
string   $old   —  Selector that is already defined

[ Top ]

setSingleLineOutput   [line 450]

void|PEAR_Error setSingleLineOutput( bool $value)

Set oneline flag

Determine whether definitions are output on a single line or multi lines

  • Since: version 0.3.3 (2004-05-20)
  • Throws: HTML_CSS_ERROR_INVALID_INPUT
  • Access: public

Parameters:

bool   $value   —  flag to true if single line, false for multi lines

[ Top ]

setStyle   [line 1385]

void|PEAR_Error setStyle( string $element, string $property, string $value, [bool $duplicates = null])

Set or add a CSS definition

Add or change a single value for an element property

  • See: HTML_CSS::getStyle()
  • Throws: HTML_CSS_ERROR_INVALID_INPUT
  • Since: version 0.2.0 (2003-07-31)
  • Access: public

Parameters:

string   $element   —  Element (or class) to be defined
string   $property   —  Property defined
string   $value   —  Value assigned
bool   $duplicates   —  (optional) Allow or disallow duplicates.

[ Top ]

setTab   [line 415]

void setTab( string $string)

Set tab value

Sets the string used to indent HTML

  • Since: version 1.4.0 (2007-12-13)
  • Access: public

Parameters:

string   $string   —  String used to indent ("\11", "\t", ' ', etc.).

[ Top ]

setXhtmlCompliance   [line 665]

void|PEAR_Error setXhtmlCompliance( bool $value)

Set xhtml flag

Active or not the XHTML mode compliant

  • Since: version 0.3.2 (2004-03-24)
  • Throws: HTML_CSS_ERROR_INVALID_INPUT
  • Access: public

Parameters:

bool   $value   —  flag to true if XHTML compliance needed, false otherwise

[ Top ]

sortAtRules   [line 627]

void sortAtRules( )

sort and move simple declarative At-Rules to the top
  • Since: version 1.5.0 (2008-01-15)
  • Access: protected

[ Top ]

toArray   [line 2317]

array toArray( )

Return the CSS contents in an array

Return the full contents of CSS data sources (parsed) in an array

  • Since: version 0.2.0 (2003-07-31)
  • Access: public

[ Top ]

toFile   [line 2415]

void|PEAR_Error toFile( string $filename)

Generate CSS and stores it in a file

Generate current parsed CSS data sources and write result in a user file

  • See: HTML_CSS::toString()
  • Throws: HTML_CSS_ERROR_INVALID_INPUT, HTML_CSS_ERROR_WRITE_FILE
  • Since: version 0.3.0 (2003-11-03)
  • Access: public

Parameters:

string   $filename   —  Name of file that content the stylesheet

[ Top ]

toInline   [line 2347]

string|PEAR_Error toInline( string $element)

Return a string-properties for style attribute of an HTML element

Generate and return the CSS properties of an element or class as a string for inline use.

  • Since: version 0.2.0 (2003-07-31)
  • Throws: HTML_CSS_ERROR_INVALID_INPUT
  • Access: public

Parameters:

string   $element   —  Element or class for which inline CSS should be generated

[ Top ]

toString   [line 2451]

string toString( )

Return current CSS parsed data as a string

Generate current parsed CSS data sources and return result as a string

  • Since: version 0.2.0 (2003-07-31)
  • Access: public

[ Top ]

unsetAtRule   [line 779]

void|PEAR_Error unsetAtRule( string $atKeyword)

Remove an existing At-Rule

Remove an existing and supported at-rule. See HTML_CSS::getAtRulesList() for a full list of supported At-Rules.

  • Since: version 1.5.0 (2008-01-15)
  • Throws: HTML_CSS_ERROR_INVALID_INPUT, HTML_CSS_ERROR_NO_ATRULE
  • Access: public

Parameters:

string   $atKeyword   —  at-rule keyword

[ Top ]

unsetGroup   [line 1063]

void|PEAR_Error unsetGroup( mixed $group)

Remove a CSS definition group

Remove a CSS definition group. Use the same identifier as for group creation.

  • See: HTML_CSS::createGroup()
  • Throws: HTML_CSS_ERROR_INVALID_INPUT, HTML_CSS_ERROR_NO_GROUP
  • Since: version 0.3.0 (2003-11-03)
  • Access: public

Parameters:

mixed   $group   —  CSS definition group identifier

[ Top ]

validate   [line 2222]

boolean|PEAR_Error validate( array $styles, array &$messages)

Validate a CSS data source

Execute the W3C CSS validator service on each data source (filename or string) given by parameter $styles.

  • Since: version 1.5.0 (2008-01-15)
  • Throws: HTML_CSS_ERROR_INVALID_INPUT, HTML_CSS_ERROR_INVALID_DEPS, HTML_CSS_ERROR_INVALID_SOURCE
  • Access: public

Parameters:

array   $styles   —  Data sources to check validity
array   &$messages   —  Error and Warning messages issue from W3C CSS validator service

[ Top ]

__get   [line 380]

mixed __get( string $option)

Get option for the class

Return current value of an individual option. If option does not exist, returns value is NULL.

  • Since: version 1.4.0 (2007-12-13)
  • Access: public

Parameters:

string   $option   —  Name of option to set

[ Top ]

__set   [line 361]

void __set( string $option, string $val)

Set option for the class

Set an individual option value. Option must exist.

  • Since: version 1.4.0 (2007-12-13)
  • Access: public

Parameters:

string   $option   —  Name of option to set
string   $val   —  Value of option to set

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:32:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.