Solução Gráfica Design SGD
[ class tree: SGD ] [ index: SGD ] [ all elements ]

Class: crushJsCss

Source Location: /class_crushJsCss.php

Class Overview


Merge, compact, scramble and cache Javascript and CSS files


Author(s):

Version:

  • 0.01

Variables

Methods



Class Details

[line 43]
Merge, compact, scramble and cache Javascript and CSS files

This compact class and scrambles JavaScript files through Dean Edwards's algorithm implemented in a class PHP by Nicolas Martin. Also, it compacts and optimize files CSS through the class CSSTidy. Finally, it compacts everything through gzip. And to save bandwidth, it creates files cache.




Tags:



[ Top ]


Class Variables

$cachedir =

[line 77]



Tags:

var:  absolute script path to cache directory. $_SERVER["DOCUMENT_ROOT"] ."/cache" is default value. This directory should have writing permission (chmod -c 775)
access:  public

Type:   string


[ Top ]

$cachefile =

[line 92]



Tags:

var:  name of cache file.
access:  private

Type:   string


[ Top ]

$deflate =

[line 102]



Tags:

var:  compact method
access:  private

Type:   string


[ Top ]

$encoding =  'none'

[line 87]



Tags:

var:  define which compact method browser client suports, gzip, deflare or none.
access:  private

Type:   string


[ Top ]

$gzip =

[line 97]



Tags:

var:  compact method
access:  private

Type:   string


[ Top ]

$js_encoding =  'Normal'

[line 60]



Tags:

var:  Define scramble level . Values: 'None', 'Numeric', 'Normal', 'High ASCII'. 'Normal' is default value.
see:  http://dean.edwards.name/packer/usage/
access:  public

Type:   string


[ Top ]

$js_fastDecode =  true

[line 66]



Tags:

var:  True is default value.
see:  http://dean.edwards.name/packer/usage/
access:  public

Type:   bolean


[ Top ]

$js_specialChars =  false

[line 72]



Tags:

var:  False is default value.
see:  http://dean.edwards.name/packer/usage/
access:  public

Type:   bolean


[ Top ]

$production =  true

[line 48]



Tags:

var:  Define to false for test phase
access:  public

Type:   bolean


[ Top ]

$scripts =

[line 54]



Tags:

var:  key [ "file"] absolute script path. Use $_SERVER["DOCUMENT_ROOT"] if your server permit it.
access:  public

Type:   string


[ Top ]

$tidy_cfg_case_properties =  0

[line 145]



Tags:

var:  case for properties. 0 = no change, 1 = lowercase, 2 = uppercase. 0 is default.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   numeric


[ Top ]

$tidy_cfg_compress_colors =  true

[line 114]



Tags:

var:  If true, compat "#000000" to "#000". True is default value.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   bolean


[ Top ]

$tidy_cfg_compress_font_weight =  true

[line 120]



Tags:

var:  if true, change "bold" to "700". True is default value.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   bolean


[ Top ]

$tidy_cfg_css_level =  'CSS2.1'

[line 175]



Tags:

var:  Possible values are 'CSS1.0', 'CSS2.0', 'CSS2.1'. Default is 'CSS2.1'
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   string


[ Top ]

$tidy_cfg_discard_invalid_properties =  false

[line 169]



Tags:

var:  Discard invalid properties based at $tidy_cfg_discard_invalid_properties value. False is default.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   bolean


[ Top ]

$tidy_cfg_lowercase_s =  false

[line 126]



Tags:

var:  if true, change all selector to lower case. Default is false.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   bolean


[ Top ]

$tidy_cfg_merge_selectors =  2

[line 163]



Tags:

var:  0 = Do not change anything, 1 = Only separate selectors (split at .), 2 = Merge selectors with same properties (fast). 2 is default.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   numeric


[ Top ]

$tidy_cfg_optimise_shorthands =  1

[line 133]



Tags:

var:  0 = Dont't Optimise, 1 = Safe Optimisations, 2 = All Optisiations. Default is 1.
see:  http://www.dustindiaz.com/css-shorthand/
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   numeric


[ Top ]

$tidy_cfg_preserve_css =  false

[line 181]



Tags:

var:  Save comments, hacks, etc. Most optimisations can *not* be applied if this is enabled. Default is false.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   bolean.


[ Top ]

$tidy_cfg_remove_bslash =  false

[line 108]



Tags:

var:  If true, Remove unnecessary backslashes ("\"). False is default value.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   bolean


[ Top ]

$tidy_cfg_remove_last_semicolon =  false

[line 139]



Tags:

var:  if true, Remove last ";" . False is default.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   bolean


[ Top ]

$tidy_cfg_sort_properties =  false

[line 151]



Tags:

var:  sort properties in ascendant order. False is default.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   bolean


[ Top ]

$tidy_cfg_sort_selectors =  false

[line 157]



Tags:

var:  sort selectors in ascendant order. False is default.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   bolean


[ Top ]

$tidy_cfg_timestamp =  false

[line 187]



Tags:

var:  Insert a first line with a comment like this: "CSSTidy 1.3dev: Tue, 05 Aug 2008 14:56:53 +0200" . Default is false.
see:  http://csstidy.sourceforge.net/usage.php
access:  public

Type:   bolean.


[ Top ]

$type =  'javascript'

[line 82]



Tags:

var:  "javascript" or "css". "javascript " is default value.
access:  public

Type:   string


[ Top ]



Class Methods


constructor crushJsCss [line 194]

crushJsCss crushJsCss( )

Construtor function

This function set defaults values and determine client browser capabilities.




Tags:

access:  public


[ Top ]

method cache [line 268]

string cache( )

It verifies cache´s contents

It verifies that cache is valid. If yes, the version of the cache is sent. If the client's browser already has the file, nothing is sent.




Tags:

return:  or binary content
access:  private


[ Top ]

method gzipIt [line 311]

string gzipIt( string $contents)

Compact javascript and css files and save in cache directory

It ensures the client's browser accepts compressed files. If yes, return the file to accept compaction. If not, return the file without compress. Save the file in the cache for later use.




Tags:

return:  string or binary content
access:  private


Parameters:

string   $contents  

[ Top ]

method jscss [line 226]

string jscss( )

Merge, compact and scramble javascript and css files

This function first checks whether the file needs new version or the version stored in cache can be used. If a new file should be created, the function checks the variable $type to determine if a file is javascript or css. The function also check the $production and $scripts["pack"], to determine whether the file should be compressed. All css or javascripts files are merged into a single file and submitted to function gzipIt, which compact and return the content according to the client browser´s capabilities.




Tags:

return:  string or binary content
access:  public


[ Top ]


Documentation generated on Wed, 06 Aug 2008 13:04:43 -0300 by phpDocumentor 1.4.1