Changeset 393 for trunk/lib/CSS.inc.php


Ignore:
Timestamp:
Nov 29, 2011 4:02:29 PM (12 years ago)
Author:
anonymous
Message:

Output compression for CSS.inc.php. Above/below print for printErrorMessage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/CSS.inc.php

    r376 r393  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2010 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3636    // CSS object parameters.
    3737    var $_params = array(
    38         'cache_css' => true,
    3938        'character_set' => 'utf-8',
     39        'cache_css' => false,
     40        'strip_whitespace' => false,
     41        'output_compression' => false,
    4042    );
    4143
     
    4951    {
    5052        $app =& App::getInstance();
    51    
     53
    5254        if (isset($params) && is_array($params)) {
    5355            // Merge new parameters with old overriding only those passed.
     
    6870    {
    6971        $app =& App::getInstance();
    70    
     72
    7173        if (isset($this->_params[$param])) {
    7274            return $this->_params[$param];
     
    8890    {
    8991        $app =& App::getInstance();
    90    
     92
    9193        if (!is_array($realms)) {
    9294            $realms = array($realms);
     
    116118    {
    117119        $app =& App::getInstance();
    118    
     120
    119121        $realm = '' == $realm ? 'default' : $realm;
    120122
     
    132134        $latest_mtime = array_pop($files_mtime);
    133135
    134         if ($this->_params['cache_css']) {
     136        if ($this->getParam('output_compression') && extension_loaded('zlib')) {
     137            ob_start('ob_gzhandler');
     138        }
     139
     140        if ($this->getParam('cache_css')) {
    135141            header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $latest_mtime) . ' GMT');
    136142            header('Cache-Control: public, max-age=86400');
     
    140146            header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    141147        }
    142         header('Content-Type: text/css; charset=' . $this->_params['character_set']);
     148        header('Content-Type: text/css; charset=' . $this->getParam('character_set'));
    143149    }
    144150
     
    160166
    161167        foreach ($this->_css_files[$realm] as $file) {
    162             include $file;
     168            if ($this->getParam('strip_whitespace')) {
     169                // Strip whitespace and print file.
     170                echo preg_replace('/[ \t\n\r]+/', ' ', file_get_contents($file, true));
     171            } else {
     172                // Include file as is.
     173                include $file;
     174            }
     175        }
     176
     177        if ($this->getParam('output_compression') && extension_loaded('zlib')) {
     178            ob_end_flush();
    163179        }
    164180    }
    165 
    166181}
    167182?>
Note: See TracChangeset for help on using the changeset viewer.