Changeset 393


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

Location:
trunk/lib
Files:
3 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?>
  • trunk/lib/FormValidator.inc.php

    r376 r393  
    174174     * Prints the HTML for displaying error messages.
    175175     *
     176     * @param   string  $above    Additional message to print above error messages (e.g. "Oops!").
     177     * @param   string  $below    Additional message to print below error messages (e.g. "Please fix and resubmit").
    176178     * @access  public
    177179     * @author  Quinn Comendant <quinn@strangecode.com>
    178180     * @since   15 Jul 2005 01:39:14
    179181     */
    180     function printErrorMessages()
     182    function printErrorMessages($above='', $below='')
    181183    {
    182184        $app =& App::getInstance();
    183185        if ($this->anyErrors()) {
    184186            ?><div class="sc-msg" id="sc-msg-formvalidator"><?php
     187            if ('' != $above) {
     188                ?><div class="sc-above"><?php echo oTxt($above); ?></div><?php
     189            }
    185190            foreach ($this->getErrorList() as $e) {
    186191                if ('' != $e['message'] && is_string($e['message'])) {
     
    208213                }
    209214            }
     215            if ('' != $below) {
     216                ?><div class="sc-below"><?php echo oTxt($below); ?></div><?php
     217            }
    210218            ?></div><?php
    211219        }
  • trunk/lib/Navigation.inc.php

    r376 r393  
    281281    function currentPage($page_uri, $return=true)
    282282    {
    283         // $page_uri = str_replace('/', '\/', $page_uri);
    284283        if (preg_match('/^' . preg_quote(urldecode($page_uri), '/') . '/i', $_SERVER['PHP_SELF'])) {
    285284            return $return;
Note: See TracChangeset for help on using the changeset viewer.