Overview

Packages

  • csstidy
  • Text
    • Filter

Classes

  • csstidy
  • csstidy_optimise
  • csstidy_print
  • Overview
  • Package
  • Class
  • Tree

Class csstidy

CSS Parser class

This class represents a CSS parser which reads CSS code and saves it in an array. In opposite to most other CSS parsers, it does not use regular expressions and thus has full CSS2 support and a higher reliability. Additional to that it applies some optimisations and fixes to the CSS code. An online version should be available here: http://cdburnerxp.se/cssparse/css_optimiser.php

Package: csstidy
Author: Florian Schmitz (floele at gmail dot com) 2005-2006
Located at Horde/Text/Filter/Csstidy/class.csstidy.php
Methods summary
public
# csstidy( )

Loads standard template and sets default settings

Loads standard template and sets default settings

public mixed
# get_cfg( string $setting )

Get the value of a setting.

Get the value of a setting.

Parameters

$setting

Returns

mixed
public boolean
# set_cfg( string $setting, mixed $value )

Set the value of a setting.

Set the value of a setting.

Parameters

$setting
$value

Returns

boolean
public
# _add_token( mixed $type, string $data, boolean $do = false )

Adds a token to $this->tokens

Adds a token to $this->tokens

Parameters

$type
$data
$do
add a token even if preserve_css is off
public
# log( string $message, string $type, integer $line = -1 )

Add a message to the message log

Add a message to the message log

Parameters

$message
$type
$line
public string
# _unicode( string & $string, integer & $i )

Parse unicode notations and find a replacement character

Parse unicode notations and find a replacement character

Parameters

$string
$i

Returns

string
public
# load_template( string $content, boolean $from_file = true )

Loads a new template

Loads a new template

Parameters

$content
either filename (if $from_file == true), content of a template file, "high_compression", "highest_compression", "low_compression", or "default"
$from_file
uses $content as filename if true

See

http://csstidy.sourceforge.net/templates.php
public
# parse_from_url( string $url )

Starts parsing from URL

Starts parsing from URL

Parameters

$url
public
# is_token( string & $string, integer $i )

Checks if there is a token at the current position

Checks if there is a token at the current position

Parameters

$string
$i
public boolean
# parse( string $string )

Parses CSS in $string. The code is saved as array in $this->css

Parses CSS in $string. The code is saved as array in $this->css

Parameters

$string
the CSS code

Returns

boolean
public
# explode_selectors( )

Explodes selectors

Explodes selectors

public boolean
# escaped( string & $string, integer $pos )

Checks if a character is escaped (and returns true if it is)

Checks if a character is escaped (and returns true if it is)

Parameters

$string
$pos

Returns

boolean
public
# css_add_property( string $media, string $selector, string $property, string $new_val, string $selector_id = null )

Adds a property with value to the existing CSS code

Adds a property with value to the existing CSS code

Parameters

$media
$selector
$property
$new_val
$selector_id
public
# merge_css_blocks( string $media, string $selector, array $css_add )

Adds CSS to an existing media/selector

Adds CSS to an existing media/selector

Parameters

$media
$selector
$css_add
public boolean
# is_important( string $value )

Checks if $value is !important.

Checks if $value is !important.

Parameters

$value

Returns

boolean
public string
# gvw_important( string $value )

Returns a value without !important

Returns a value without !important

Parameters

$value

Returns

string
public boolean
# property_is_next( string $istring, integer $pos )

Checks if the next word in a string from pos is a CSS property

Checks if the next word in a string from pos is a CSS property

Parameters

$istring
$pos

Returns

boolean
public bool;
# property_is_valid( string $property )

Checks if a property is valid

Checks if a property is valid

Parameters

$property

Returns

bool;
public string
# filterBySelector( array $input )

Filters CSS by a list of simple selectors and returns a string suitable for use in a HTML style attribute.

Filters CSS by a list of simple selectors and returns a string suitable for use in a HTML style attribute.

Parameters

$input
The list of selectors to filter by.

Returns

string
The CSS string.
Properties summary
public array $css

Saves the parsed CSS

Saves the parsed CSS

# array()
public array $tokens

Saves the parsed CSS (raw)

Saves the parsed CSS (raw)

# array()
public object $print

Printer class

Printer class

See

csstidy_print
#
public object $optimise

Optimiser class

Optimiser class

See

csstidy_optimise
#
public string $charset

Saves the CSS charset (@charset)

Saves the CSS charset (@charset)

# ''
public array $import

Saves all @import URLs

Saves all @import URLs

# array()
public string $namespace

Saves the namespace

Saves the namespace

# ''
public array $settings

Stores the settings

Stores the settings

# array()
public string $status

Saves the parser-status.

Saves the parser-status.

Possible values: - is = in selector - ip = in property - iv = in value - instr = in string (started at " or ' or ( ) - ic = in comment (ignore everything) - at = in @-block

# 'is'
public string $at

Saves the current at rule (@media)

Saves the current at rule (@media)

# ''
public string $selector

Saves the current selector

Saves the current selector

# ''
public string $property

Saves the current property

Saves the current property

# ''
public array $sel_separate

Saves the position of , in selectors

Saves the position of , in selectors

# array()
public string $value

Saves the current value

Saves the current value

# ''
public string $sub_value

Saves the current sub-value

Saves the current sub-value

Example for a subvalue: background:url(foo.png) red no-repeat; "url(foo.png)", "red", and "no-repeat" are subvalues, seperated by whitespace

# ''
public array $sub_value_arr

Array which saves all subvalues for a property.

Array which saves all subvalues for a property.

See

csstidy::$sub_value
# array()
public string $str_char

Saves the char which opened the last string

Saves the char which opened the last string

# ''
public string $cur_string
# ''
public string $from

Status from which the parser switched to ic or instr

Status from which the parser switched to ic or instr

# ''
public string $str_in_str

Variable needed to manage string-in-strings, for example url("foo.png")

Variable needed to manage string-in-strings, for example url("foo.png")

# false
public boolean $invalid_at

=true if in invalid at-rule

=true if in invalid at-rule

# false
public boolean $added

=true if something has been added to the current selector

=true if something has been added to the current selector

# false
public array $log

Array which saves the message log

Array which saves the message log

# array()
public integer $line

Saves the line number

Saves the line number

# 1
API documentation generated by ApiGen