/**
 *
 * CSS Crush
 * Extensible CSS preprocessor
 * 
 * @version    1.4.1
 * @license    http://www.opensource.org/licenses/mit-license.php (MIT)
 * @copyright  Copyright 2010-2012 Pete Boere
 * 
 * 
 * <?php
 *
 * // Basic usage
 * require_once 'CssCrush.php';
 * $global_css = CssCrush::file( '/css/global.css' );
 *
 * ?>
 *
 * <link rel="stylesheet" href="<?php echo $global_css; ?>" />
 *
 */
require_once 'lib/Util.php';
require_once 'lib/Core.php';
CssCrush::init(dirname(__FILE__));
require_once 'lib/Rule.php';
require_once 'lib/Function.php';
CssCrush_Function::init();
require_once 'lib/Importer.php';
require_once 'lib/Color.php';
require_once 'lib/Hook.php';
示例#2
0
 protected static function compile($stream)
 {
     $regex = self::$regex;
     // Reset properties for current process
     self::$tokenUID = 0;
     self::$storage = new stdClass();
     self::$storage->tokens = (object) array('strings' => array(), 'comments' => array(), 'rules' => array(), 'parens' => array());
     self::$storage->variables = array();
     // Load in aliases and macros
     if (!self::$assetsLoaded) {
         self::loadAssets();
         self::$assetsLoaded = true;
     }
     // Set the custom function regular expression
     $css_functions = CssCrush_Function::getFunctions();
     $regex->function->custom = str_replace('<functions>', implode('|', $css_functions), $regex->function->custom);
     // Extract comments
     $stream = preg_replace_callback($regex->comment, array('self', 'cb_extractComments'), $stream);
     // Extract strings
     $stream = preg_replace_callback($regex->string, array('self', 'cb_extractStrings'), $stream);
     // Parse variables
     $stream = preg_replace_callback($regex->variables, array('self', 'cb_extractVariables'), $stream);
     // Calculate the variable stack
     self::calculateVariables();
     self::log(self::$storage->variables);
     // Place the variables
     $stream = self::placeVariables($stream);
     // Normalize whitespace
     $stream = self::normalize($stream);
     // Adjust the stream so we can extract the rules cleanly
     $map = array('@' => "\n@", '}' => "}\n", '{' => "{\n", ';' => ";\n");
     $stream = "\n" . str_replace(array_keys($map), array_values($map), $stream);
     // Extract rules
     $stream = preg_replace_callback($regex->rule, array('self', 'cb_extractRules'), $stream);
     // Alias at-rules (if there are any)
     $stream = self::aliasAtRules($stream);
     // print it all back
     $stream = self::display($stream);
     // self::log( self::$storage->tokens->rules );
     // self::log( self::$storage->tokens );
     self::log(self::$config->data);
     // Release memory
     self::$storage = null;
     return $stream;
 }