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

Class: csstidy

Source Location: /class.csstidy.php

Class Overview


CSS Parser class


Author(s):

  • Florian Schmitz (floele at gmail dot com) 2005-2006

Version:

  • 1.2

Variables

Methods



Class Details

[line 61]
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




Tags:

version:  1.2
author:  Florian Schmitz (floele at gmail dot com) 2005-2006


[ Top ]


Class Variables

$added =  false

[line 233]

=true if something has been added to the current selector



Tags:

access:  private

Type:   bool


[ Top ]

$at =  ''

[line 150]

Saves the current at rule (@media)



Tags:

access:  private

Type:   string


[ Top ]

$charset =  ''

[line 98]

Saves the CSS charset (@charset)



Tags:

access:  private

Type:   string


[ Top ]

$css = array()

[line 68]

Saves the parsed CSS



Tags:

access:  public

Type:   array


[ Top ]

$from =  ''

[line 212]

Status from which the parser switched to ic or instr



Tags:

access:  private

Type:   string


[ Top ]

$import = array()

[line 105]

Saves all @import URLs



Tags:

access:  private

Type:   array


[ Top ]

$invalid_at =  false

[line 226]

=true if in invalid at-rule



Tags:

access:  private

Type:   bool


[ Top ]

$line =  1

[line 247]

Saves the line number



Tags:

access:  private

Type:   integer


[ Top ]

$log = array()

[line 240]

Array which saves the message log



Tags:

access:  private

Type:   array


[ Top ]

$namespace =  ''

[line 112]

Saves the namespace



Tags:

access:  private

Type:   string


[ Top ]

$optimise =

[line 91]

Optimiser class



Tags:

access:  private
see:  csstidy_optimise

Type:   object


[ Top ]

$print =

[line 83]

Printer class



Tags:

access:  public
see:  csstidy_print

Type:   object


[ Top ]

$property =  ''

[line 164]

Saves the current property



Tags:

access:  private

Type:   string


[ Top ]

$selector =  ''

[line 157]

Saves the current selector



Tags:

access:  private

Type:   string


[ Top ]

$sel_separate = array()

[line 171]

Saves the position of , in selectors



Tags:

access:  private

Type:   array


[ Top ]

$settings = array()

[line 126]

Stores the settings



Tags:

access:  private

Type:   array


[ Top ]

$status =  'is'

[line 142]

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




Tags:

access:  private

Type:   string


[ Top ]

$str_char =  ''

[line 205]

Saves the char which opened the last string



Tags:

access:  private

Type:   string


[ Top ]

$str_in_str =  false

[line 219]

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



Tags:

access:  private

Type:   string


[ Top ]

$sub_value =  ''

[line 190]

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




Tags:

access:  private

Type:   string


[ Top ]

$sub_value_arr = array()

[line 198]

Array which saves all subvalues for a property.



Tags:

access:  private
see:  csstidy::$sub_value

Type:   array


[ Top ]

$tokens = array()

[line 75]

Saves the parsed CSS (raw)



Tags:

access:  private

Type:   array


[ Top ]

$value =  ''

[line 178]

Saves the current value



Tags:

access:  private

Type:   string


[ Top ]

$version =  '1.2'

[line 119]

Contains the version of csstidy



Tags:

access:  private

Type:   string


[ Top ]



Class Methods


constructor csstidy [line 254]

csstidy csstidy( )

Loads standard template and sets default settings



Tags:

version:  1.2
access:  private


[ Top ]

method css_add_property [line 877]

void css_add_property( string $media, string $selector, string $property, string $new_val)

Adds a property with value to the existing CSS code



Tags:

version:  1.2
access:  private


Parameters:

string   $media  
string   $selector  
string   $property  
string   $new_val  

[ Top ]

method escaped [line 863]

bool escaped( string &$string, integer $pos)

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



Tags:

version:  1.02
access:  public


Parameters:

string   $string  
integer   $pos  

[ Top ]

method explode_selectors [line 825]

void explode_selectors( )

Explodes selectors



Tags:

version:  1.0
access:  private


[ Top ]

method get_cfg [line 283]

mixed get_cfg( string $setting)

Get the value of a setting.



Tags:

version:  1.0
access:  public


Parameters:

string   $setting  

[ Top ]

method gvw_important [line 933]

string gvw_important( string $value)

Returns a value without !important



Tags:

version:  1.0
access:  public


Parameters:

string   $value  

[ Top ]

method is_important [line 921]

bool is_important( string &$value)

Checks if $value is !important.



Tags:

version:  1.0
access:  public


Parameters:

string   $value  

[ Top ]

method is_token [line 444]

void is_token( string &$string, integer $i)

Checks if there is a token at the current position



Tags:

version:  1.11
access:  public


Parameters:

string   $string  
integer   $i  

[ Top ]

method load_template [line 404]

void load_template( string $content, [bool $from_file = true])

Loads a new template



Tags:

see:  http://csstidy.sourceforge.net/templates.php
version:  1.1
access:  public


Parameters:

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

[ Top ]

method log [line 332]

void log( string $message, string $type, [integer $line = -1])

Add a message to the message log



Tags:

version:  1.0
access:  private


Parameters:

string   $message  
string   $type  
integer   $line  

[ Top ]

method merge_css_blocks [line 906]

void merge_css_blocks( string $media, string $selector, array $css_add)

Adds CSS to an existing media/selector



Tags:

version:  1.1
access:  private


Parameters:

string   $media  
string   $selector  
array   $css_add  

[ Top ]

method parse [line 458]

bool parse( string $string)

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



Tags:

version:  1.1
access:  public


Parameters:

string   $string   the CSS code

[ Top ]

method parse_from_url [line 432]

void parse_from_url( string $url)

Starts parsing from URL



Tags:

version:  1.0
access:  public


Parameters:

string   $url  

[ Top ]

method property_is_next [line 955]

bool property_is_next( string $istring, integer $pos)

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



Tags:

version:  1.2
access:  private


Parameters:

string   $istring  
integer   $pos  

[ Top ]

method property_is_valid [line 980]

bool; property_is_valid( string $property)

Checks if a property is valid



Tags:

version:  1.0
access:  public


Parameters:

string   $property  

[ Top ]

method set_cfg [line 300]

bool set_cfg( string $setting, mixed $value)

Set the value of a setting.



Tags:

version:  1.0
access:  public


Parameters:

string   $setting  
mixed   $value  

[ Top ]

method _add_token [line 318]

void _add_token( mixed $type, string $data, [bool $do = false])

Adds a token to $this->tokens



Tags:

version:  1.0
access:  private


Parameters:

mixed   $type  
string   $data  
bool   $do   add a token even if preserve_css is off

[ Top ]

method _unicode [line 354]

string _unicode( string &$string, integer &$i)

Parse unicode notations and find a replacement character



Tags:

version:  1.2
access:  private


Parameters:

string   $string  
integer   $i  

[ Top ]


Documentation generated on Mon, 15 May 2006 22:55:14 +0200 by phpDocumentor 1.3.0RC3