PEEL Shopping
Open source ecommerce : PEEL Shopping
Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
Minifier Class Reference

Static Public Member Functions

static minify ($js, $options=array())
 Takes a string containing javascript and removes unneeded characters in order to shrink the code without altering it's functionality. More...
 

Protected Member Functions

 minifyDirectToOutput ($js, $options)
 Processes a javascript string and outputs only the required characters, stripping out all unneeded characters. More...
 
 initialize ($js, $options)
 Initializes internal variables, normalizes new lines,. More...
 
 loop ()
 The primary action occurs here. More...
 
 clean ()
 Resets attributes that do not need to be stored between requests so that the next request is ready to go. More...
 
 getChar ()
 Returns the next string for processing based off of the current index. More...
 
 getReal ()
 This function gets the next "real" character. More...
 
 processOneLineComments ($startIndex)
 Removed one line comments, with the exception of some very specific types of conditional comments. More...
 
 processMultiLineComments ($startIndex)
 Skips multiline comments where appropriate, and includes them where needed. More...
 
 getNext ($string)
 Pushes the index ahead to the next instance of the supplied string. More...
 
 saveString ()
 When a javascript string is detected this function crawls for the end of it and saves the whole string. More...
 
 saveRegex ()
 When a regular expression is detected this function crawls for the end of it and saves the whole regex. More...
 
 lock ($js)
 Replace patterns in the given string and store the replacement. More...
 
 unlock ($js)
 Replace "locks" with the original characters. More...
 

Static Protected Member Functions

static isAlphaNumeric ($char)
 Checks to see if a character is alphanumeric. More...
 

Protected Attributes

 $input
 
 $index = 0
 
 $a = ''
 
 $b = ''
 
 $c
 
 $options
 
 $locks = array()
 

Static Protected Attributes

static $defaultOptions = array('flaggedComments' => true)
 

Detailed Description

Definition at line 30 of file JShrink.php.

Member Function Documentation

clean ( )
protected

Resets attributes that do not need to be stored between requests so that the next request is ready to go.

Another reason for this is to make sure the variables are cleared and are not taking up memory.

Definition at line 246 of file JShrink.php.

getChar ( )
protected

Returns the next string for processing based off of the current index.

Returns
string

Definition at line 260 of file JShrink.php.

getNext (   $string)
protected

Pushes the index ahead to the next instance of the supplied string.

If it is found the first character of the string is returned and the index is set to it's position.

Parameters
string$string
Returns
string|false Returns the first character of the string or false.

Definition at line 412 of file JShrink.php.

getReal ( )
protected

This function gets the next "real" character.

It is essentially a wrapper around the getChar function that skips comments. This has significant performance benefits as the skipping is done using native functions (ie, c code) rather than in script php.

Returns
string Next 'real' character to be processed.
Exceptions

Definition at line 299 of file JShrink.php.

initialize (   $js,
  $options 
)
protected

Initializes internal variables, normalizes new lines,.

Parameters
string$jsThe raw javascript to be minified
array$optionsVarious runtime options in an associative array

Definition at line 152 of file JShrink.php.

static isAlphaNumeric (   $char)
staticprotected

Checks to see if a character is alphanumeric.

Parameters
string$charJust one character
Returns
bool

Definition at line 535 of file JShrink.php.

lock (   $js)
protected

Replace patterns in the given string and store the replacement.

Parameters
string$jsThe string to lock
Returns
bool

Definition at line 546 of file JShrink.php.

loop ( )
protected

The primary action occurs here.

This function loops through the input string, outputting anything that's relevant and discarding anything that is not.

Definition at line 173 of file JShrink.php.

static minify (   $js,
  $options = array() 
)
static

Takes a string containing javascript and removes unneeded characters in order to shrink the code without altering it's functionality.

Parameters
string$jsThe raw javascript to be minified
array$optionsVarious runtime options in an associative array
Exceptions

Definition at line 101 of file JShrink.php.

minifyDirectToOutput (   $js,
  $options 
)
protected

Processes a javascript string and outputs only the required characters, stripping out all unneeded characters.

Parameters
string$jsThe raw javascript to be minified
array$optionsVarious runtime options in an associative array

Definition at line 139 of file JShrink.php.

processMultiLineComments (   $startIndex)
protected

Skips multiline comments where appropriate, and includes them where needed.

Conditional comments and "license" style blocks are preserved.

Parameters
int$startIndexThe index point where "getReal" function started
Returns
bool|string False if there's no character
Exceptions

Definition at line 356 of file JShrink.php.

processOneLineComments (   $startIndex)
protected

Removed one line comments, with the exception of some very specific types of conditional comments.

Parameters
int$startIndexThe index point where "getReal" function started
Returns
string

Definition at line 328 of file JShrink.php.

saveRegex ( )
protected

When a regular expression is detected this function crawls for the end of it and saves the whole regex.

Exceptions

Definition at line 508 of file JShrink.php.

saveString ( )
protected

When a javascript string is detected this function crawls for the end of it and saves the whole string.

Exceptions

Definition at line 435 of file JShrink.php.

unlock (   $js)
protected

Replace "locks" with the original characters.

Parameters
string$jsThe string to unlock
Returns
bool

Definition at line 571 of file JShrink.php.

Field Documentation

$a = ''
protected

Definition at line 52 of file JShrink.php.

$b = ''
protected

Definition at line 59 of file JShrink.php.

$c
protected

Definition at line 66 of file JShrink.php.

$defaultOptions = array('flaggedComments' => true)
staticprotected

Definition at line 82 of file JShrink.php.

$index = 0
protected

Definition at line 45 of file JShrink.php.

$input
protected

Definition at line 37 of file JShrink.php.

$locks = array()
protected

Definition at line 90 of file JShrink.php.

$options
protected

Definition at line 73 of file JShrink.php.


The documentation for this class was generated from the following file:

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:43 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.